aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpacpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/pnpacpi')
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c176
1 files changed, 103 insertions, 73 deletions
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 4ce754ab14fd..37708fdefe09 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -280,6 +280,14 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
280 void *data) 280 void *data)
281{ 281{
282 struct pnp_resource_table *res_table = data; 282 struct pnp_resource_table *res_table = data;
283 struct acpi_resource_irq *irq;
284 struct acpi_resource_dma *dma;
285 struct acpi_resource_io *io;
286 struct acpi_resource_fixed_io *fixed_io;
287 struct acpi_resource_memory24 *memory24;
288 struct acpi_resource_memory32 *memory32;
289 struct acpi_resource_fixed_memory32 *fixed_memory32;
290 struct acpi_resource_extended_irq *extended_irq;
283 int i; 291 int i;
284 292
285 switch (res->type) { 293 switch (res->type) {
@@ -288,29 +296,32 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
288 * Per spec, only one interrupt per descriptor is allowed in 296 * Per spec, only one interrupt per descriptor is allowed in
289 * _CRS, but some firmware violates this, so parse them all. 297 * _CRS, but some firmware violates this, so parse them all.
290 */ 298 */
291 for (i = 0; i < res->data.irq.interrupt_count; i++) { 299 irq = &res->data.irq;
300 for (i = 0; i < irq->interrupt_count; i++) {
292 pnpacpi_parse_allocated_irqresource(res_table, 301 pnpacpi_parse_allocated_irqresource(res_table,
293 res->data.irq.interrupts[i], 302 irq->interrupts[i],
294 res->data.irq.triggering, 303 irq->triggering,
295 res->data.irq.polarity, 304 irq->polarity,
296 res->data.irq.sharable); 305 irq->sharable);
297 } 306 }
298 break; 307 break;
299 308
300 case ACPI_RESOURCE_TYPE_DMA: 309 case ACPI_RESOURCE_TYPE_DMA:
301 if (res->data.dma.channel_count > 0) 310 dma = &res->data.dma;
311 if (dma->channel_count > 0)
302 pnpacpi_parse_allocated_dmaresource(res_table, 312 pnpacpi_parse_allocated_dmaresource(res_table,
303 res->data.dma.channels[0], 313 dma->channels[0],
304 res->data.dma.type, 314 dma->type,
305 res->data.dma.bus_master, 315 dma->bus_master,
306 res->data.dma.transfer); 316 dma->transfer);
307 break; 317 break;
308 318
309 case ACPI_RESOURCE_TYPE_IO: 319 case ACPI_RESOURCE_TYPE_IO:
320 io = &res->data.io;
310 pnpacpi_parse_allocated_ioresource(res_table, 321 pnpacpi_parse_allocated_ioresource(res_table,
311 res->data.io.minimum, 322 io->minimum,
312 res->data.io.address_length, 323 io->address_length,
313 res->data.io.io_decode); 324 io->io_decode);
314 break; 325 break;
315 326
316 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 327 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -318,9 +329,10 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
318 break; 329 break;
319 330
320 case ACPI_RESOURCE_TYPE_FIXED_IO: 331 case ACPI_RESOURCE_TYPE_FIXED_IO:
332 fixed_io = &res->data.fixed_io;
321 pnpacpi_parse_allocated_ioresource(res_table, 333 pnpacpi_parse_allocated_ioresource(res_table,
322 res->data.fixed_io.address, 334 fixed_io->address,
323 res->data.fixed_io.address_length, 335 fixed_io->address_length,
324 ACPI_DECODE_10); 336 ACPI_DECODE_10);
325 break; 337 break;
326 338
@@ -331,22 +343,25 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
331 break; 343 break;
332 344
333 case ACPI_RESOURCE_TYPE_MEMORY24: 345 case ACPI_RESOURCE_TYPE_MEMORY24:
346 memory24 = &res->data.memory24;
334 pnpacpi_parse_allocated_memresource(res_table, 347 pnpacpi_parse_allocated_memresource(res_table,
335 res->data.memory24.minimum, 348 memory24->minimum,
336 res->data.memory24.address_length, 349 memory24->address_length,
337 res->data.memory24.write_protect); 350 memory24->write_protect);
338 break; 351 break;
339 case ACPI_RESOURCE_TYPE_MEMORY32: 352 case ACPI_RESOURCE_TYPE_MEMORY32:
353 memory32 = &res->data.memory32;
340 pnpacpi_parse_allocated_memresource(res_table, 354 pnpacpi_parse_allocated_memresource(res_table,
341 res->data.memory32.minimum, 355 memory32->minimum,
342 res->data.memory32.address_length, 356 memory32->address_length,
343 res->data.memory32.write_protect); 357 memory32->write_protect);
344 break; 358 break;
345 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 359 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
360 fixed_memory32 = &res->data.fixed_memory32;
346 pnpacpi_parse_allocated_memresource(res_table, 361 pnpacpi_parse_allocated_memresource(res_table,
347 res->data.fixed_memory32.address, 362 fixed_memory32->address,
348 res->data.fixed_memory32.address_length, 363 fixed_memory32->address_length,
349 res->data.fixed_memory32.write_protect); 364 fixed_memory32->write_protect);
350 break; 365 break;
351 case ACPI_RESOURCE_TYPE_ADDRESS16: 366 case ACPI_RESOURCE_TYPE_ADDRESS16:
352 case ACPI_RESOURCE_TYPE_ADDRESS32: 367 case ACPI_RESOURCE_TYPE_ADDRESS32:
@@ -360,15 +375,16 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
360 break; 375 break;
361 376
362 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 377 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
363 if (res->data.extended_irq.producer_consumer == ACPI_PRODUCER) 378 extended_irq = &res->data.extended_irq;
379 if (extended_irq->producer_consumer == ACPI_PRODUCER)
364 return AE_OK; 380 return AE_OK;
365 381
366 for (i = 0; i < res->data.extended_irq.interrupt_count; i++) { 382 for (i = 0; i < extended_irq->interrupt_count; i++) {
367 pnpacpi_parse_allocated_irqresource(res_table, 383 pnpacpi_parse_allocated_irqresource(res_table,
368 res->data.extended_irq.interrupts[i], 384 extended_irq->interrupts[i],
369 res->data.extended_irq.triggering, 385 extended_irq->triggering,
370 res->data.extended_irq.polarity, 386 extended_irq->polarity,
371 res->data.extended_irq.sharable); 387 extended_irq->sharable);
372 } 388 }
373 break; 389 break;
374 390
@@ -797,122 +813,136 @@ int pnpacpi_build_resource_template(acpi_handle handle,
797static void pnpacpi_encode_irq(struct acpi_resource *resource, 813static void pnpacpi_encode_irq(struct acpi_resource *resource,
798 struct resource *p) 814 struct resource *p)
799{ 815{
816 struct acpi_resource_irq *irq = &resource->data.irq;
800 int triggering, polarity; 817 int triggering, polarity;
801 818
802 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity); 819 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity);
803 resource->data.irq.triggering = triggering; 820 irq->triggering = triggering;
804 resource->data.irq.polarity = polarity; 821 irq->polarity = polarity;
805 if (triggering == ACPI_EDGE_SENSITIVE) 822 if (triggering == ACPI_EDGE_SENSITIVE)
806 resource->data.irq.sharable = ACPI_EXCLUSIVE; 823 irq->sharable = ACPI_EXCLUSIVE;
807 else 824 else
808 resource->data.irq.sharable = ACPI_SHARED; 825 irq->sharable = ACPI_SHARED;
809 resource->data.irq.interrupt_count = 1; 826 irq->interrupt_count = 1;
810 resource->data.irq.interrupts[0] = p->start; 827 irq->interrupts[0] = p->start;
811} 828}
812 829
813static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, 830static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
814 struct resource *p) 831 struct resource *p)
815{ 832{
833 struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq;
816 int triggering, polarity; 834 int triggering, polarity;
817 835
818 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity); 836 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity);
819 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; 837 extended_irq->producer_consumer = ACPI_CONSUMER;
820 resource->data.extended_irq.triggering = triggering; 838 extended_irq->triggering = triggering;
821 resource->data.extended_irq.polarity = polarity; 839 extended_irq->polarity = polarity;
822 if (triggering == ACPI_EDGE_SENSITIVE) 840 if (triggering == ACPI_EDGE_SENSITIVE)
823 resource->data.extended_irq.sharable = ACPI_EXCLUSIVE; 841 extended_irq->sharable = ACPI_EXCLUSIVE;
824 else 842 else
825 resource->data.extended_irq.sharable = ACPI_SHARED; 843 extended_irq->sharable = ACPI_SHARED;
826 resource->data.extended_irq.interrupt_count = 1; 844 extended_irq->interrupt_count = 1;
827 resource->data.extended_irq.interrupts[0] = p->start; 845 extended_irq->interrupts[0] = p->start;
828} 846}
829 847
830static void pnpacpi_encode_dma(struct acpi_resource *resource, 848static void pnpacpi_encode_dma(struct acpi_resource *resource,
831 struct resource *p) 849 struct resource *p)
832{ 850{
851 struct acpi_resource_dma *dma = &resource->data.dma;
852
833 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 853 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
834 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { 854 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) {
835 case IORESOURCE_DMA_TYPEA: 855 case IORESOURCE_DMA_TYPEA:
836 resource->data.dma.type = ACPI_TYPE_A; 856 dma->type = ACPI_TYPE_A;
837 break; 857 break;
838 case IORESOURCE_DMA_TYPEB: 858 case IORESOURCE_DMA_TYPEB:
839 resource->data.dma.type = ACPI_TYPE_B; 859 dma->type = ACPI_TYPE_B;
840 break; 860 break;
841 case IORESOURCE_DMA_TYPEF: 861 case IORESOURCE_DMA_TYPEF:
842 resource->data.dma.type = ACPI_TYPE_F; 862 dma->type = ACPI_TYPE_F;
843 break; 863 break;
844 default: 864 default:
845 resource->data.dma.type = ACPI_COMPATIBILITY; 865 dma->type = ACPI_COMPATIBILITY;
846 } 866 }
847 867
848 switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { 868 switch (p->flags & IORESOURCE_DMA_TYPE_MASK) {
849 case IORESOURCE_DMA_8BIT: 869 case IORESOURCE_DMA_8BIT:
850 resource->data.dma.transfer = ACPI_TRANSFER_8; 870 dma->transfer = ACPI_TRANSFER_8;
851 break; 871 break;
852 case IORESOURCE_DMA_8AND16BIT: 872 case IORESOURCE_DMA_8AND16BIT:
853 resource->data.dma.transfer = ACPI_TRANSFER_8_16; 873 dma->transfer = ACPI_TRANSFER_8_16;
854 break; 874 break;
855 default: 875 default:
856 resource->data.dma.transfer = ACPI_TRANSFER_16; 876 dma->transfer = ACPI_TRANSFER_16;
857 } 877 }
858 878
859 resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); 879 dma->bus_master = !!(p->flags & IORESOURCE_DMA_MASTER);
860 resource->data.dma.channel_count = 1; 880 dma->channel_count = 1;
861 resource->data.dma.channels[0] = p->start; 881 dma->channels[0] = p->start;
862} 882}
863 883
864static void pnpacpi_encode_io(struct acpi_resource *resource, 884static void pnpacpi_encode_io(struct acpi_resource *resource,
865 struct resource *p) 885 struct resource *p)
866{ 886{
887 struct acpi_resource_io *io = &resource->data.io;
888
867 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ 889 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
868 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ? 890 io->io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ?
869 ACPI_DECODE_16 : ACPI_DECODE_10; 891 ACPI_DECODE_16 : ACPI_DECODE_10;
870 resource->data.io.minimum = p->start; 892 io->minimum = p->start;
871 resource->data.io.maximum = p->end; 893 io->maximum = p->end;
872 resource->data.io.alignment = 0; /* Correct? */ 894 io->alignment = 0; /* Correct? */
873 resource->data.io.address_length = p->end - p->start + 1; 895 io->address_length = p->end - p->start + 1;
874} 896}
875 897
876static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, 898static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
877 struct resource *p) 899 struct resource *p)
878{ 900{
879 resource->data.fixed_io.address = p->start; 901 struct acpi_resource_fixed_io *fixed_io = &resource->data.fixed_io;
880 resource->data.fixed_io.address_length = p->end - p->start + 1; 902
903 fixed_io->address = p->start;
904 fixed_io->address_length = p->end - p->start + 1;
881} 905}
882 906
883static void pnpacpi_encode_mem24(struct acpi_resource *resource, 907static void pnpacpi_encode_mem24(struct acpi_resource *resource,
884 struct resource *p) 908 struct resource *p)
885{ 909{
910 struct acpi_resource_memory24 *memory24 = &resource->data.memory24;
911
886 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ 912 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
887 resource->data.memory24.write_protect = 913 memory24->write_protect =
888 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 914 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
889 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 915 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
890 resource->data.memory24.minimum = p->start; 916 memory24->minimum = p->start;
891 resource->data.memory24.maximum = p->end; 917 memory24->maximum = p->end;
892 resource->data.memory24.alignment = 0; 918 memory24->alignment = 0;
893 resource->data.memory24.address_length = p->end - p->start + 1; 919 memory24->address_length = p->end - p->start + 1;
894} 920}
895 921
896static void pnpacpi_encode_mem32(struct acpi_resource *resource, 922static void pnpacpi_encode_mem32(struct acpi_resource *resource,
897 struct resource *p) 923 struct resource *p)
898{ 924{
899 resource->data.memory32.write_protect = 925 struct acpi_resource_memory32 *memory32 = &resource->data.memory32;
926
927 memory32->write_protect =
900 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 928 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
901 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 929 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
902 resource->data.memory32.minimum = p->start; 930 memory32->minimum = p->start;
903 resource->data.memory32.maximum = p->end; 931 memory32->maximum = p->end;
904 resource->data.memory32.alignment = 0; 932 memory32->alignment = 0;
905 resource->data.memory32.address_length = p->end - p->start + 1; 933 memory32->address_length = p->end - p->start + 1;
906} 934}
907 935
908static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, 936static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
909 struct resource *p) 937 struct resource *p)
910{ 938{
911 resource->data.fixed_memory32.write_protect = 939 struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32;
940
941 fixed_memory32->write_protect =
912 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 942 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
913 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 943 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
914 resource->data.fixed_memory32.address = p->start; 944 fixed_memory32->address = p->start;
915 resource->data.fixed_memory32.address_length = p->end - p->start + 1; 945 fixed_memory32->address_length = p->end - p->start + 1;
916} 946}
917 947
918int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 948int pnpacpi_encode_resources(struct pnp_resource_table *res_table,