2 * pnpacpi -- PnP ACPI driver
4 * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
5 * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/kernel.h>
22 #include <linux/acpi.h>
23 #include <linux/pci.h>
27 #define valid_IRQ(i) (1)
29 #define valid_IRQ(i) (((i) != 0) && ((i) != 2))
35 static int irq_flags(int edge_level, int active_high_low)
38 if (edge_level == ACPI_LEVEL_SENSITIVE) {
39 if(active_high_low == ACPI_ACTIVE_LOW)
40 flag = IORESOURCE_IRQ_LOWLEVEL;
42 flag = IORESOURCE_IRQ_HIGHLEVEL;
45 if(active_high_low == ACPI_ACTIVE_LOW)
46 flag = IORESOURCE_IRQ_LOWEDGE;
48 flag = IORESOURCE_IRQ_HIGHEDGE;
53 static void decode_irq_flags(int flag, int *edge_level, int *active_high_low)
56 case IORESOURCE_IRQ_LOWLEVEL:
57 *edge_level = ACPI_LEVEL_SENSITIVE;
58 *active_high_low = ACPI_ACTIVE_LOW;
60 case IORESOURCE_IRQ_HIGHLEVEL:
61 *edge_level = ACPI_LEVEL_SENSITIVE;
62 *active_high_low = ACPI_ACTIVE_HIGH;
64 case IORESOURCE_IRQ_LOWEDGE:
65 *edge_level = ACPI_EDGE_SENSITIVE;
66 *active_high_low = ACPI_ACTIVE_LOW;
68 case IORESOURCE_IRQ_HIGHEDGE:
69 *edge_level = ACPI_EDGE_SENSITIVE;
70 *active_high_low = ACPI_ACTIVE_HIGH;
76 pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
77 int edge_level, int active_high_low)
85 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
92 irq = acpi_register_gsi(gsi, edge_level, active_high_low);
94 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
98 res->irq_resource[i].start = irq;
99 res->irq_resource[i].end = irq;
100 pcibios_penalize_isa_irq(irq, 1);
104 pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, u32 dma)
107 while (i < PNP_MAX_DMA &&
108 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
110 if (i < PNP_MAX_DMA) {
111 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
113 res->dma_resource[i].flags |= IORESOURCE_DISABLED;
116 res->dma_resource[i].start = dma;
117 res->dma_resource[i].end = dma;
122 pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res,
126 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) &&
129 if (i < PNP_MAX_PORT) {
130 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
131 if (len <= 0 || (io + len -1) >= 0x10003) {
132 res->port_resource[i].flags |= IORESOURCE_DISABLED;
135 res->port_resource[i].start = io;
136 res->port_resource[i].end = io + len - 1;
141 pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res,
145 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) &&
148 if (i < PNP_MAX_MEM) {
149 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
151 res->mem_resource[i].flags |= IORESOURCE_DISABLED;
154 res->mem_resource[i].start = mem;
155 res->mem_resource[i].end = mem + len - 1;
160 static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
163 struct pnp_resource_table * res_table = (struct pnp_resource_table *)data;
167 case ACPI_RSTYPE_IRQ:
169 * Per spec, only one interrupt per descriptor is allowed in
170 * _CRS, but some firmware violates this, so parse them all.
172 for (i = 0; i < res->data.irq.number_of_interrupts; i++) {
173 pnpacpi_parse_allocated_irqresource(res_table,
174 res->data.irq.interrupts[i],
175 res->data.irq.edge_level,
176 res->data.irq.active_high_low);
180 case ACPI_RSTYPE_EXT_IRQ:
181 for (i = 0; i < res->data.extended_irq.number_of_interrupts; i++) {
182 pnpacpi_parse_allocated_irqresource(res_table,
183 res->data.extended_irq.interrupts[i],
184 res->data.extended_irq.edge_level,
185 res->data.extended_irq.active_high_low);
188 case ACPI_RSTYPE_DMA:
189 if (res->data.dma.number_of_channels > 0)
190 pnpacpi_parse_allocated_dmaresource(res_table,
191 res->data.dma.channels[0]);
194 pnpacpi_parse_allocated_ioresource(res_table,
195 res->data.io.min_base_address,
196 res->data.io.range_length);
198 case ACPI_RSTYPE_FIXED_IO:
199 pnpacpi_parse_allocated_ioresource(res_table,
200 res->data.fixed_io.base_address,
201 res->data.fixed_io.range_length);
203 case ACPI_RSTYPE_MEM24:
204 pnpacpi_parse_allocated_memresource(res_table,
205 res->data.memory24.min_base_address,
206 res->data.memory24.range_length);
208 case ACPI_RSTYPE_MEM32:
209 pnpacpi_parse_allocated_memresource(res_table,
210 res->data.memory32.min_base_address,
211 res->data.memory32.range_length);
213 case ACPI_RSTYPE_FIXED_MEM32:
214 pnpacpi_parse_allocated_memresource(res_table,
215 res->data.fixed_memory32.range_base_address,
216 res->data.fixed_memory32.range_length);
218 case ACPI_RSTYPE_ADDRESS16:
219 pnpacpi_parse_allocated_memresource(res_table,
220 res->data.address16.min_address_range,
221 res->data.address16.address_length);
223 case ACPI_RSTYPE_ADDRESS32:
224 pnpacpi_parse_allocated_memresource(res_table,
225 res->data.address32.min_address_range,
226 res->data.address32.address_length);
228 case ACPI_RSTYPE_ADDRESS64:
229 pnpacpi_parse_allocated_memresource(res_table,
230 res->data.address64.min_address_range,
231 res->data.address64.address_length);
233 case ACPI_RSTYPE_VENDOR:
236 pnp_warn("PnPACPI: unknown resource type %d", res->id);
243 acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table * res)
245 /* Blank the resource table values */
246 pnp_init_resource_table(res);
248 return acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, res);
251 static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_resource_dma *p)
254 struct pnp_dma * dma;
256 if (p->number_of_channels == 0)
258 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
262 for(i = 0; i < p->number_of_channels; i++)
263 dma->map |= 1 << p->channels[i];
266 dma->flags |= IORESOURCE_DMA_MASTER;
268 case ACPI_COMPATIBILITY:
269 dma->flags |= IORESOURCE_DMA_COMPATIBLE;
272 dma->flags |= IORESOURCE_DMA_TYPEA;
275 dma->flags |= IORESOURCE_DMA_TYPEB;
278 dma->flags |= IORESOURCE_DMA_TYPEF;
281 /* Set a default value ? */
282 dma->flags |= IORESOURCE_DMA_COMPATIBLE;
283 pnp_err("Invalid DMA type");
285 switch (p->transfer) {
286 case ACPI_TRANSFER_8:
287 dma->flags |= IORESOURCE_DMA_8BIT;
289 case ACPI_TRANSFER_8_16:
290 dma->flags |= IORESOURCE_DMA_8AND16BIT;
292 case ACPI_TRANSFER_16:
293 dma->flags |= IORESOURCE_DMA_16BIT;
296 /* Set a default value ? */
297 dma->flags |= IORESOURCE_DMA_8AND16BIT;
298 pnp_err("Invalid DMA transfer type");
301 pnp_register_dma_resource(option,dma);
306 static void pnpacpi_parse_irq_option(struct pnp_option *option,
307 struct acpi_resource_irq *p)
310 struct pnp_irq * irq;
312 if (p->number_of_interrupts == 0)
314 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
318 for(i = 0; i < p->number_of_interrupts; i++)
319 if (p->interrupts[i])
320 __set_bit(p->interrupts[i], irq->map);
321 irq->flags = irq_flags(p->edge_level, p->active_high_low);
323 pnp_register_irq_resource(option, irq);
327 static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
328 struct acpi_resource_ext_irq *p)
331 struct pnp_irq * irq;
333 if (p->number_of_interrupts == 0)
335 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
339 for(i = 0; i < p->number_of_interrupts; i++)
340 if (p->interrupts[i])
341 __set_bit(p->interrupts[i], irq->map);
342 irq->flags = irq_flags(p->edge_level, p->active_high_low);
344 pnp_register_irq_resource(option, irq);
349 pnpacpi_parse_port_option(struct pnp_option *option,
350 struct acpi_resource_io *io)
352 struct pnp_port * port;
354 if (io->range_length == 0)
356 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
359 port->min = io->min_base_address;
360 port->max = io->max_base_address;
361 port->align = io->alignment;
362 port->size = io->range_length;
363 port->flags = ACPI_DECODE_16 == io->io_decode ?
364 PNP_PORT_FLAG_16BITADDR : 0;
365 pnp_register_port_resource(option,port);
370 pnpacpi_parse_fixed_port_option(struct pnp_option *option,
371 struct acpi_resource_fixed_io *io)
373 struct pnp_port * port;
375 if (io->range_length == 0)
377 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
380 port->min = port->max = io->base_address;
381 port->size = io->range_length;
383 port->flags = PNP_PORT_FLAG_FIXED;
384 pnp_register_port_resource(option,port);
389 pnpacpi_parse_mem24_option(struct pnp_option *option,
390 struct acpi_resource_mem24 *p)
392 struct pnp_mem * mem;
394 if (p->range_length == 0)
396 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
399 mem->min = p->min_base_address;
400 mem->max = p->max_base_address;
401 mem->align = p->alignment;
402 mem->size = p->range_length;
404 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
405 IORESOURCE_MEM_WRITEABLE : 0;
407 pnp_register_mem_resource(option,mem);
412 pnpacpi_parse_mem32_option(struct pnp_option *option,
413 struct acpi_resource_mem32 *p)
415 struct pnp_mem * mem;
417 if (p->range_length == 0)
419 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
422 mem->min = p->min_base_address;
423 mem->max = p->max_base_address;
424 mem->align = p->alignment;
425 mem->size = p->range_length;
427 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
428 IORESOURCE_MEM_WRITEABLE : 0;
430 pnp_register_mem_resource(option,mem);
435 pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
436 struct acpi_resource_fixed_mem32 *p)
438 struct pnp_mem * mem;
440 if (p->range_length == 0)
442 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
445 mem->min = mem->max = p->range_base_address;
446 mem->size = p->range_length;
449 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
450 IORESOURCE_MEM_WRITEABLE : 0;
452 pnp_register_mem_resource(option,mem);
456 struct acpipnp_parse_option_s {
457 struct pnp_option *option;
458 struct pnp_option *option_independent;
462 static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
466 struct acpipnp_parse_option_s *parse_data = (struct acpipnp_parse_option_s *)data;
467 struct pnp_dev *dev = parse_data->dev;
468 struct pnp_option *option = parse_data->option;
471 case ACPI_RSTYPE_IRQ:
472 pnpacpi_parse_irq_option(option, &res->data.irq);
474 case ACPI_RSTYPE_EXT_IRQ:
475 pnpacpi_parse_ext_irq_option(option,
476 &res->data.extended_irq);
478 case ACPI_RSTYPE_DMA:
479 pnpacpi_parse_dma_option(option, &res->data.dma);
482 pnpacpi_parse_port_option(option, &res->data.io);
484 case ACPI_RSTYPE_FIXED_IO:
485 pnpacpi_parse_fixed_port_option(option,
486 &res->data.fixed_io);
488 case ACPI_RSTYPE_MEM24:
489 pnpacpi_parse_mem24_option(option, &res->data.memory24);
491 case ACPI_RSTYPE_MEM32:
492 pnpacpi_parse_mem32_option(option, &res->data.memory32);
494 case ACPI_RSTYPE_FIXED_MEM32:
495 pnpacpi_parse_fixed_mem32_option(option,
496 &res->data.fixed_memory32);
498 case ACPI_RSTYPE_START_DPF:
499 switch (res->data.start_dpf.compatibility_priority) {
500 case ACPI_GOOD_CONFIGURATION:
501 priority = PNP_RES_PRIORITY_PREFERRED;
504 case ACPI_ACCEPTABLE_CONFIGURATION:
505 priority = PNP_RES_PRIORITY_ACCEPTABLE;
508 case ACPI_SUB_OPTIMAL_CONFIGURATION:
509 priority = PNP_RES_PRIORITY_FUNCTIONAL;
512 priority = PNP_RES_PRIORITY_INVALID;
515 /* TBD: Considering performace/robustness bits */
516 option = pnp_register_dependent_option(dev, priority);
519 parse_data->option = option;
521 case ACPI_RSTYPE_END_DPF:
522 /*only one EndDependentFn is allowed*/
523 if (!parse_data->option_independent) {
524 pnp_warn("PnPACPI: more than one EndDependentFn");
527 parse_data->option = parse_data->option_independent;
528 parse_data->option_independent = NULL;
531 pnp_warn("PnPACPI: unknown resource type %d", res->id);
538 acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
542 struct acpipnp_parse_option_s parse_data;
544 parse_data.option = pnp_register_independent_option(dev);
545 if (!parse_data.option)
547 parse_data.option_independent = parse_data.option;
548 parse_data.dev = dev;
549 status = acpi_walk_resources(handle, METHOD_NAME__PRS,
550 pnpacpi_option_resource, &parse_data);
558 static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
561 int *res_cnt = (int *)data;
563 case ACPI_RSTYPE_IRQ:
564 case ACPI_RSTYPE_EXT_IRQ:
565 case ACPI_RSTYPE_DMA:
567 case ACPI_RSTYPE_FIXED_IO:
568 case ACPI_RSTYPE_MEM24:
569 case ACPI_RSTYPE_MEM32:
570 case ACPI_RSTYPE_FIXED_MEM32:
572 case ACPI_RSTYPE_ADDRESS16:
573 case ACPI_RSTYPE_ADDRESS32:
574 case ACPI_RSTYPE_ADDRESS64:
583 static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
586 struct acpi_resource **resource = (struct acpi_resource **)data;
588 case ACPI_RSTYPE_IRQ:
589 case ACPI_RSTYPE_EXT_IRQ:
590 case ACPI_RSTYPE_DMA:
592 case ACPI_RSTYPE_FIXED_IO:
593 case ACPI_RSTYPE_MEM24:
594 case ACPI_RSTYPE_MEM32:
595 case ACPI_RSTYPE_FIXED_MEM32:
597 case ACPI_RSTYPE_ADDRESS16:
598 case ACPI_RSTYPE_ADDRESS32:
599 case ACPI_RSTYPE_ADDRESS64:
601 (*resource)->id = res->id;
610 int pnpacpi_build_resource_template(acpi_handle handle,
611 struct acpi_buffer *buffer)
613 struct acpi_resource *resource;
617 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
618 pnpacpi_count_resources, &res_cnt);
619 if (ACPI_FAILURE(status)) {
620 pnp_err("Evaluate _CRS failed");
625 buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1;
626 buffer->pointer = kcalloc(1, buffer->length - 1, GFP_KERNEL);
627 if (!buffer->pointer)
629 pnp_dbg("Res cnt %d", res_cnt);
630 resource = (struct acpi_resource *)buffer->pointer;
631 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
632 pnpacpi_type_resources, &resource);
633 if (ACPI_FAILURE(status)) {
634 kfree(buffer->pointer);
635 pnp_err("Evaluate _CRS failed");
638 /* resource will pointer the end resource now */
639 resource->id = ACPI_RSTYPE_END_TAG;
644 static void pnpacpi_encode_irq(struct acpi_resource *resource,
647 int edge_level, active_high_low;
649 decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level,
651 resource->id = ACPI_RSTYPE_IRQ;
652 resource->length = sizeof(struct acpi_resource);
653 resource->data.irq.edge_level = edge_level;
654 resource->data.irq.active_high_low = active_high_low;
655 if (edge_level == ACPI_EDGE_SENSITIVE)
656 resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
658 resource->data.irq.shared_exclusive = ACPI_SHARED;
659 resource->data.irq.number_of_interrupts = 1;
660 resource->data.irq.interrupts[0] = p->start;
663 static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
666 int edge_level, active_high_low;
668 decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level,
670 resource->id = ACPI_RSTYPE_EXT_IRQ;
671 resource->length = sizeof(struct acpi_resource);
672 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER;
673 resource->data.extended_irq.edge_level = edge_level;
674 resource->data.extended_irq.active_high_low = active_high_low;
675 if (edge_level == ACPI_EDGE_SENSITIVE)
676 resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
678 resource->data.irq.shared_exclusive = ACPI_SHARED;
679 resource->data.extended_irq.number_of_interrupts = 1;
680 resource->data.extended_irq.interrupts[0] = p->start;
683 static void pnpacpi_encode_dma(struct acpi_resource *resource,
686 resource->id = ACPI_RSTYPE_DMA;
687 resource->length = sizeof(struct acpi_resource);
688 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
689 if (p->flags & IORESOURCE_DMA_COMPATIBLE)
690 resource->data.dma.type = ACPI_COMPATIBILITY;
691 else if (p->flags & IORESOURCE_DMA_TYPEA)
692 resource->data.dma.type = ACPI_TYPE_A;
693 else if (p->flags & IORESOURCE_DMA_TYPEB)
694 resource->data.dma.type = ACPI_TYPE_B;
695 else if (p->flags & IORESOURCE_DMA_TYPEF)
696 resource->data.dma.type = ACPI_TYPE_F;
697 if (p->flags & IORESOURCE_DMA_8BIT)
698 resource->data.dma.transfer = ACPI_TRANSFER_8;
699 else if (p->flags & IORESOURCE_DMA_8AND16BIT)
700 resource->data.dma.transfer = ACPI_TRANSFER_8_16;
701 else if (p->flags & IORESOURCE_DMA_16BIT)
702 resource->data.dma.transfer = ACPI_TRANSFER_16;
703 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER;
704 resource->data.dma.number_of_channels = 1;
705 resource->data.dma.channels[0] = p->start;
708 static void pnpacpi_encode_io(struct acpi_resource *resource,
711 resource->id = ACPI_RSTYPE_IO;
712 resource->length = sizeof(struct acpi_resource);
713 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
714 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)?
715 ACPI_DECODE_16 : ACPI_DECODE_10;
716 resource->data.io.min_base_address = p->start;
717 resource->data.io.max_base_address = p->end;
718 resource->data.io.alignment = 0; /* Correct? */
719 resource->data.io.range_length = p->end - p->start + 1;
722 static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
725 resource->id = ACPI_RSTYPE_FIXED_IO;
726 resource->length = sizeof(struct acpi_resource);
727 resource->data.fixed_io.base_address = p->start;
728 resource->data.fixed_io.range_length = p->end - p->start + 1;
731 static void pnpacpi_encode_mem24(struct acpi_resource *resource,
734 resource->id = ACPI_RSTYPE_MEM24;
735 resource->length = sizeof(struct acpi_resource);
736 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
737 resource->data.memory24.read_write_attribute =
738 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
739 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
740 resource->data.memory24.min_base_address = p->start;
741 resource->data.memory24.max_base_address = p->end;
742 resource->data.memory24.alignment = 0;
743 resource->data.memory24.range_length = p->end - p->start + 1;
746 static void pnpacpi_encode_mem32(struct acpi_resource *resource,
749 resource->id = ACPI_RSTYPE_MEM32;
750 resource->length = sizeof(struct acpi_resource);
751 resource->data.memory32.read_write_attribute =
752 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
753 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
754 resource->data.memory32.min_base_address = p->start;
755 resource->data.memory32.max_base_address = p->end;
756 resource->data.memory32.alignment = 0;
757 resource->data.memory32.range_length = p->end - p->start + 1;
760 static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
763 resource->id = ACPI_RSTYPE_FIXED_MEM32;
764 resource->length = sizeof(struct acpi_resource);
765 resource->data.fixed_memory32.read_write_attribute =
766 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
767 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
768 resource->data.fixed_memory32.range_base_address = p->start;
769 resource->data.fixed_memory32.range_length = p->end - p->start + 1;
772 int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
773 struct acpi_buffer *buffer)
776 /* pnpacpi_build_resource_template allocates extra mem */
777 int res_cnt = (buffer->length - 1)/sizeof(struct acpi_resource) - 1;
778 struct acpi_resource *resource = (struct acpi_resource*)buffer->pointer;
779 int port = 0, irq = 0, dma = 0, mem = 0;
781 pnp_dbg("res cnt %d", res_cnt);
782 while (i < res_cnt) {
783 switch(resource->id) {
784 case ACPI_RSTYPE_IRQ:
785 pnp_dbg("Encode irq");
786 pnpacpi_encode_irq(resource,
787 &res_table->irq_resource[irq]);
791 case ACPI_RSTYPE_EXT_IRQ:
792 pnp_dbg("Encode ext irq");
793 pnpacpi_encode_ext_irq(resource,
794 &res_table->irq_resource[irq]);
797 case ACPI_RSTYPE_DMA:
798 pnp_dbg("Encode dma");
799 pnpacpi_encode_dma(resource,
800 &res_table->dma_resource[dma]);
804 pnp_dbg("Encode io");
805 pnpacpi_encode_io(resource,
806 &res_table->port_resource[port]);
809 case ACPI_RSTYPE_FIXED_IO:
810 pnp_dbg("Encode fixed io");
811 pnpacpi_encode_fixed_io(resource,
812 &res_table->port_resource[port]);
815 case ACPI_RSTYPE_MEM24:
816 pnp_dbg("Encode mem24");
817 pnpacpi_encode_mem24(resource,
818 &res_table->mem_resource[mem]);
821 case ACPI_RSTYPE_MEM32:
822 pnp_dbg("Encode mem32");
823 pnpacpi_encode_mem32(resource,
824 &res_table->mem_resource[mem]);
827 case ACPI_RSTYPE_FIXED_MEM32:
828 pnp_dbg("Encode fixed mem32");
829 pnpacpi_encode_fixed_mem32(resource,
830 &res_table->mem_resource[mem]);
833 default: /* other type */
834 pnp_warn("unknown resource type %d", resource->id);