23 #include <linux/kernel.h>
25 #include <linux/pci.h>
27 #include <linux/slab.h>
32 #define valid_IRQ(i) (1)
34 #define valid_IRQ(i) (((i) != 0) && ((i) != 2))
40 static int irq_flags(
int triggering,
int polarity,
int shareable)
62 static void decode_irq_flags(
struct pnp_dev *
dev,
int flags,
int *triggering,
84 dev_err(&dev->
dev,
"can't encode invalid IRQ mode %#x\n",
97 static void pnpacpi_parse_allocated_irqresource(
struct pnp_dev *dev,
99 int polarity,
int shareable)
118 if (triggering != t || polarity != p) {
120 gsi, t ?
"edge":
"level", p ?
"low":
"high");
126 flags = irq_flags(triggering, polarity, shareable);
136 static int dma_flags(
struct pnp_dev *dev,
int type,
int bus_master,
159 dev_err(&dev->
dev,
"invalid DMA type %d\n", type);
174 dev_err(&dev->
dev,
"invalid DMA transfer type %d\n", transfer);
180 static void pnpacpi_parse_allocated_ioresource(
struct pnp_dev *dev,
u64 start,
181 u64 len,
int io_decode,
185 u64 end = start + len - 1;
189 if (len == 0 || end >= 0x10003)
206 .data = { 0xf9, 0xad, 0xe9, 0x69, 0x4f, 0x92, 0x5f, 0xab, 0xf6, 0x4a,
207 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad },
210 static int vendor_resource_matches(
struct pnp_dev *dev,
215 int uuid_len =
sizeof(vendor->
uuid);
223 if (uuid_subtype == match->
subtype &&
224 uuid_len ==
sizeof(match->
data) &&
226 if (expected_len && expected_len != actual_len) {
227 dev_err(&dev->
dev,
"wrong vendor descriptor size; "
228 "expected %d, found %d bytes\n",
229 expected_len, actual_len);
239 static void pnpacpi_parse_allocated_vendor(
struct pnp_dev *dev,
242 if (vendor_resource_matches(dev, vendor, &hp_ccsr_uuid, 16)) {
252 static void pnpacpi_parse_allocated_memresource(
struct pnp_dev *dev,
254 int write_protect,
int window)
257 u64 end = start + len - 1;
269 static void pnpacpi_parse_allocated_busresource(
struct pnp_dev *dev,
272 u64 end = start + len - 1;
277 static void pnpacpi_parse_allocated_address_space(
struct pnp_dev *dev,
287 dev_warn(&dev->
dev,
"failed to convert resource type %d\n",
297 pnpacpi_parse_allocated_memresource(dev, p->
minimum, len,
298 p->info.mem.write_protect, window);
300 pnpacpi_parse_allocated_ioresource(dev, p->
minimum, len,
304 pnpacpi_parse_allocated_busresource(dev, p->
minimum, len);
307 static void pnpacpi_parse_allocated_ext_address_space(
struct pnp_dev *dev,
319 pnpacpi_parse_allocated_memresource(dev, p->
minimum, len,
320 p->info.mem.write_protect, window);
322 pnpacpi_parse_allocated_ioresource(dev, p->
minimum, len,
326 pnpacpi_parse_allocated_busresource(dev, p->
minimum, len);
355 pnpacpi_parse_allocated_irqresource(dev,
369 "_CRS descriptor; configuration can't "
388 pnpacpi_parse_allocated_ioresource(dev,
400 pnpacpi_parse_allocated_ioresource(dev,
408 pnpacpi_parse_allocated_vendor(dev, vendor_typed);
416 pnpacpi_parse_allocated_memresource(dev,
423 pnpacpi_parse_allocated_memresource(dev,
430 pnpacpi_parse_allocated_memresource(dev,
438 pnpacpi_parse_allocated_address_space(dev, res);
442 pnpacpi_parse_allocated_ext_address_space(dev, res);
452 pnpacpi_parse_allocated_irqresource(dev,
467 "_CRS descriptor; configuration can't "
478 dev_warn(&dev->
dev,
"unknown resource type %d in _CRS\n",
488 struct acpi_device *acpi_dev = dev->
data;
492 pnp_dbg(&dev->
dev,
"parse allocated resources\n");
497 pnpacpi_allocated_resource, dev);
501 dev_err(&dev->
dev,
"can't evaluate _CRS: %d", status);
507 static __init void pnpacpi_parse_dma_option(
struct pnp_dev *dev,
508 unsigned int option_flags,
521 static __init void pnpacpi_parse_irq_option(
struct pnp_dev *dev,
522 unsigned int option_flags,
538 static __init void pnpacpi_parse_ext_irq_option(
struct pnp_dev *dev,
539 unsigned int option_flags,
553 "(too large for %d entry bitmap)\n",
562 static __init void pnpacpi_parse_port_option(
struct pnp_dev *dev,
563 unsigned int option_flags,
566 unsigned char flags = 0;
574 static __init void pnpacpi_parse_fixed_port_option(
struct pnp_dev *dev,
575 unsigned int option_flags,
582 static __init void pnpacpi_parse_mem24_option(
struct pnp_dev *dev,
583 unsigned int option_flags,
586 unsigned char flags = 0;
594 static __init void pnpacpi_parse_mem32_option(
struct pnp_dev *dev,
595 unsigned int option_flags,
598 unsigned char flags = 0;
606 static __init void pnpacpi_parse_fixed_mem32_option(
struct pnp_dev *dev,
607 unsigned int option_flags,
610 unsigned char flags = 0;
618 static __init void pnpacpi_parse_address_option(
struct pnp_dev *dev,
619 unsigned int option_flags,
624 unsigned char flags = 0;
628 dev_warn(&dev->
dev,
"can't convert resource type %d\n",
645 static __init void pnpacpi_parse_ext_address_option(
struct pnp_dev *dev,
646 unsigned int option_flags,
650 unsigned char flags = 0;
679 pnpacpi_parse_irq_option(dev, option_flags, &res->
data.
irq);
683 pnpacpi_parse_dma_option(dev, option_flags, &res->
data.
dma);
703 parse_data->
option_flags = pnp_new_dependent_set(dev, priority);
711 pnpacpi_parse_port_option(dev, option_flags, &res->
data.
io);
715 pnpacpi_parse_fixed_port_option(dev, option_flags,
724 pnpacpi_parse_mem24_option(dev, option_flags,
729 pnpacpi_parse_mem32_option(dev, option_flags,
734 pnpacpi_parse_fixed_mem32_option(dev, option_flags,
741 pnpacpi_parse_address_option(dev, option_flags, res);
745 pnpacpi_parse_ext_address_option(dev, option_flags, res);
749 pnpacpi_parse_ext_irq_option(dev, option_flags,
757 dev_warn(&dev->
dev,
"unknown resource type %d in _PRS\n",
767 struct acpi_device *acpi_dev = dev->
data;
772 pnp_dbg(&dev->
dev,
"parse resource options\n");
778 pnpacpi_option_resource, &parse_data);
782 dev_err(&dev->
dev,
"can't evaluate _PRS: %d", status);
788 static int pnpacpi_supported_resource(
struct acpi_resource *res)
816 if (pnpacpi_supported_resource(res))
825 if (pnpacpi_supported_resource(res)) {
826 (*resource)->type = res->
type;
829 (*resource)->data.irq.descriptor_length =
830 res->
data.
irq.descriptor_length;
840 struct acpi_device *acpi_dev = dev->
data;
847 pnpacpi_count_resources, &res_cnt);
849 dev_err(&dev->
dev,
"can't evaluate _CRS: %d\n", status);
861 pnpacpi_type_resources, &resource);
864 dev_err(&dev->
dev,
"can't evaluate _CRS: %d\n", status);
873 static void pnpacpi_encode_irq(
struct pnp_dev *dev,
880 if (!pnp_resource_enabled(p)) {
883 p ?
"disabled" :
"missing");
887 decode_irq_flags(dev, p->
flags, &triggering, &polarity, &shareable);
894 pnp_dbg(&dev->
dev,
" encode irq %d %s %s %s (%d-byte descriptor)\n",
902 static void pnpacpi_encode_ext_irq(
struct pnp_dev *dev,
909 if (!pnp_resource_enabled(p)) {
911 pnp_dbg(&dev->
dev,
" encode extended irq (%s)\n",
912 p ?
"disabled" :
"missing");
916 decode_irq_flags(dev, p->
flags, &triggering, &polarity, &shareable);
930 static void pnpacpi_encode_dma(
struct pnp_dev *dev,
936 if (!pnp_resource_enabled(p)) {
939 p ?
"disabled" :
"missing");
974 "type %#x transfer %#x master %d\n",
978 static void pnpacpi_encode_io(
struct pnp_dev *dev,
984 if (pnp_resource_enabled(p)) {
1001 static void pnpacpi_encode_fixed_io(
struct pnp_dev *dev,
1007 if (pnp_resource_enabled(p)) {
1019 static void pnpacpi_encode_mem24(
struct pnp_dev *dev,
1025 if (pnp_resource_enabled(p)) {
1038 pnp_dbg(&dev->
dev,
" encode mem24 %#x-%#x write_protect %#x\n",
1044 static void pnpacpi_encode_mem32(
struct pnp_dev *dev,
1050 if (pnp_resource_enabled(p)) {
1062 pnp_dbg(&dev->
dev,
" encode mem32 %#x-%#x write_protect %#x\n",
1068 static void pnpacpi_encode_fixed_mem32(
struct pnp_dev *dev,
1074 if (pnp_resource_enabled(p)) {
1085 pnp_dbg(&dev->
dev,
" encode fixed_mem32 %#x-%#x write_protect %#x\n",
1097 int port = 0, irq = 0, dma = 0,
mem = 0;
1099 pnp_dbg(&dev->
dev,
"encode %d resources\n", res_cnt);
1100 while (i < res_cnt) {
1101 switch (resource->
type) {
1103 pnpacpi_encode_irq(dev, resource,
1109 pnpacpi_encode_dma(dev, resource,
1114 pnpacpi_encode_io(dev, resource,
1119 pnpacpi_encode_fixed_io(dev, resource,
1124 pnpacpi_encode_mem24(dev, resource,
1129 pnpacpi_encode_mem32(dev, resource,
1134 pnpacpi_encode_fixed_mem32(dev, resource,
1139 pnpacpi_encode_ext_irq(dev, resource,
1153 dev_warn(&dev->
dev,
"can't encode unknown resource "
1154 "type %d\n", resource->
type);