Thomas Gleixner | 3e0a4e8 | 2019-05-23 11:14:55 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * pnpacpi -- PnP ACPI driver |
| 4 | * |
| 5 | * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr> |
| 6 | * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com> |
Bjorn Helgaas | 40ab4f4 | 2008-06-27 16:57:19 -0600 | [diff] [blame] | 7 | * Copyright (C) 2008 Hewlett-Packard Development Company, L.P. |
| 8 | * Bjorn Helgaas <bjorn.helgaas@hp.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | #include <linux/kernel.h> |
| 11 | #include <linux/acpi.h> |
| 12 | #include <linux/pci.h> |
Bjorn Helgaas | 02d83b5 | 2008-04-28 16:34:28 -0600 | [diff] [blame] | 13 | #include <linux/pnp.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 14 | #include <linux/slab.h> |
Bjorn Helgaas | 02d83b5 | 2008-04-28 16:34:28 -0600 | [diff] [blame] | 15 | #include "../base.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include "pnpacpi.h" |
| 17 | |
Fabian Frederick | bbee06d | 2015-05-02 17:14:49 +0200 | [diff] [blame] | 18 | static void decode_irq_flags(struct pnp_dev *dev, int flags, u8 *triggering, |
| 19 | u8 *polarity, u8 *shareable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | { |
Bjorn Helgaas | e9fe9e1 | 2008-06-09 16:52:04 -0700 | [diff] [blame] | 21 | switch (flags & (IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL | |
| 22 | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | case IORESOURCE_IRQ_LOWLEVEL: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 24 | *triggering = ACPI_LEVEL_SENSITIVE; |
| 25 | *polarity = ACPI_ACTIVE_LOW; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | break; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 27 | case IORESOURCE_IRQ_HIGHLEVEL: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 28 | *triggering = ACPI_LEVEL_SENSITIVE; |
| 29 | *polarity = ACPI_ACTIVE_HIGH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | break; |
| 31 | case IORESOURCE_IRQ_LOWEDGE: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 32 | *triggering = ACPI_EDGE_SENSITIVE; |
| 33 | *polarity = ACPI_ACTIVE_LOW; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | break; |
| 35 | case IORESOURCE_IRQ_HIGHEDGE: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 36 | *triggering = ACPI_EDGE_SENSITIVE; |
| 37 | *polarity = ACPI_ACTIVE_HIGH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | break; |
Bjorn Helgaas | e9fe9e1 | 2008-06-09 16:52:04 -0700 | [diff] [blame] | 39 | default: |
| 40 | dev_err(&dev->dev, "can't encode invalid IRQ mode %#x\n", |
| 41 | flags); |
| 42 | *triggering = ACPI_EDGE_SENSITIVE; |
| 43 | *polarity = ACPI_ACTIVE_HIGH; |
| 44 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 46 | |
| 47 | if (flags & IORESOURCE_IRQ_SHAREABLE) |
| 48 | *shareable = ACPI_SHARED; |
| 49 | else |
| 50 | *shareable = ACPI_EXCLUSIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 53 | static int dma_flags(struct pnp_dev *dev, int type, int bus_master, |
| 54 | int transfer) |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 55 | { |
| 56 | int flags = 0; |
| 57 | |
| 58 | if (bus_master) |
| 59 | flags |= IORESOURCE_DMA_MASTER; |
| 60 | switch (type) { |
| 61 | case ACPI_COMPATIBILITY: |
| 62 | flags |= IORESOURCE_DMA_COMPATIBLE; |
| 63 | break; |
| 64 | case ACPI_TYPE_A: |
| 65 | flags |= IORESOURCE_DMA_TYPEA; |
| 66 | break; |
| 67 | case ACPI_TYPE_B: |
| 68 | flags |= IORESOURCE_DMA_TYPEB; |
| 69 | break; |
| 70 | case ACPI_TYPE_F: |
| 71 | flags |= IORESOURCE_DMA_TYPEF; |
| 72 | break; |
| 73 | default: |
| 74 | /* Set a default value ? */ |
| 75 | flags |= IORESOURCE_DMA_COMPATIBLE; |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 76 | dev_err(&dev->dev, "invalid DMA type %d\n", type); |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 77 | } |
| 78 | switch (transfer) { |
| 79 | case ACPI_TRANSFER_8: |
| 80 | flags |= IORESOURCE_DMA_8BIT; |
| 81 | break; |
| 82 | case ACPI_TRANSFER_8_16: |
| 83 | flags |= IORESOURCE_DMA_8AND16BIT; |
| 84 | break; |
| 85 | case ACPI_TRANSFER_16: |
| 86 | flags |= IORESOURCE_DMA_16BIT; |
| 87 | break; |
| 88 | default: |
| 89 | /* Set a default value ? */ |
| 90 | flags |= IORESOURCE_DMA_8AND16BIT; |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 91 | dev_err(&dev->dev, "invalid DMA transfer type %d\n", transfer); |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | return flags; |
| 95 | } |
| 96 | |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 97 | /* |
| 98 | * Allocated Resources |
| 99 | */ |
| 100 | |
| 101 | static void pnpacpi_add_irqresource(struct pnp_dev *dev, struct resource *r) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | { |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 103 | if (!(r->flags & IORESOURCE_DISABLED)) |
| 104 | pcibios_penalize_isa_irq(r->start, 1); |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 105 | |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 106 | pnp_add_resource(dev, r); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Bjorn Helgaas | 40ab4f4 | 2008-06-27 16:57:19 -0600 | [diff] [blame] | 109 | /* |
| 110 | * Device CSRs that do not appear in PCI config space should be described |
| 111 | * via ACPI. This would normally be done with Address Space Descriptors |
| 112 | * marked as "consumer-only," but old versions of Windows and Linux ignore |
| 113 | * the producer/consumer flag, so HP invented a vendor-defined resource to |
| 114 | * describe the location and size of CSR space. |
| 115 | */ |
| 116 | static struct acpi_vendor_uuid hp_ccsr_uuid = { |
| 117 | .subtype = 2, |
| 118 | .data = { 0xf9, 0xad, 0xe9, 0x69, 0x4f, 0x92, 0x5f, 0xab, 0xf6, 0x4a, |
| 119 | 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad }, |
| 120 | }; |
| 121 | |
| 122 | static int vendor_resource_matches(struct pnp_dev *dev, |
| 123 | struct acpi_resource_vendor_typed *vendor, |
| 124 | struct acpi_vendor_uuid *match, |
| 125 | int expected_len) |
| 126 | { |
| 127 | int uuid_len = sizeof(vendor->uuid); |
| 128 | u8 uuid_subtype = vendor->uuid_subtype; |
| 129 | u8 *uuid = vendor->uuid; |
| 130 | int actual_len; |
| 131 | |
| 132 | /* byte_length includes uuid_subtype and uuid */ |
| 133 | actual_len = vendor->byte_length - uuid_len - 1; |
| 134 | |
| 135 | if (uuid_subtype == match->subtype && |
| 136 | uuid_len == sizeof(match->data) && |
| 137 | memcmp(uuid, match->data, uuid_len) == 0) { |
| 138 | if (expected_len && expected_len != actual_len) { |
Andy Shevchenko | 1d7f2cd | 2017-05-23 20:03:26 +0300 | [diff] [blame] | 139 | dev_err(&dev->dev, |
| 140 | "wrong vendor descriptor size; expected %d, found %d bytes\n", |
Bjorn Helgaas | 40ab4f4 | 2008-06-27 16:57:19 -0600 | [diff] [blame] | 141 | expected_len, actual_len); |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | return 1; |
| 146 | } |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | static void pnpacpi_parse_allocated_vendor(struct pnp_dev *dev, |
| 152 | struct acpi_resource_vendor_typed *vendor) |
| 153 | { |
| 154 | if (vendor_resource_matches(dev, vendor, &hp_ccsr_uuid, 16)) { |
| 155 | u64 start, length; |
| 156 | |
| 157 | memcpy(&start, vendor->byte_data, sizeof(start)); |
| 158 | memcpy(&length, vendor->byte_data + 8, sizeof(length)); |
| 159 | |
| 160 | pnp_add_mem_resource(dev, start, start + length - 1, 0); |
| 161 | } |
| 162 | } |
| 163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 165 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | { |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 167 | struct pnp_dev *dev = data; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 168 | struct acpi_resource_dma *dma; |
Bjorn Helgaas | 40ab4f4 | 2008-06-27 16:57:19 -0600 | [diff] [blame] | 169 | struct acpi_resource_vendor_typed *vendor_typed; |
Jagadish Krishnamoorthy | 2a56e91 | 2017-05-23 20:03:25 +0300 | [diff] [blame] | 170 | struct acpi_resource_gpio *gpio; |
Jiang Liu | a49170b | 2015-02-02 10:42:58 +0800 | [diff] [blame] | 171 | struct resource_win win = {{0}, 0}; |
| 172 | struct resource *r = &win.res; |
Bjorn Helgaas | dc16f5f | 2008-04-28 16:34:35 -0600 | [diff] [blame] | 173 | int i, flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
Jiang Liu | a49170b | 2015-02-02 10:42:58 +0800 | [diff] [blame] | 175 | if (acpi_dev_resource_address_space(res, &win) |
| 176 | || acpi_dev_resource_ext_address_space(res, &win)) { |
| 177 | pnp_add_resource(dev, &win.res); |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 178 | return AE_OK; |
| 179 | } |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 180 | |
Jiang Liu | a49170b | 2015-02-02 10:42:58 +0800 | [diff] [blame] | 181 | r->flags = 0; |
| 182 | if (acpi_dev_resource_interrupt(res, 0, r)) { |
| 183 | pnpacpi_add_irqresource(dev, r); |
| 184 | for (i = 1; acpi_dev_resource_interrupt(res, i, r); i++) |
| 185 | pnpacpi_add_irqresource(dev, r); |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 186 | |
| 187 | if (i > 1) { |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 188 | /* |
| 189 | * The IRQ encoder puts a single interrupt in each |
| 190 | * descriptor, so if a _CRS descriptor has more than |
| 191 | * one interrupt, we won't be able to re-encode it. |
| 192 | */ |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 193 | if (pnp_can_write(dev)) { |
Andy Shevchenko | 1d7f2cd | 2017-05-23 20:03:26 +0300 | [diff] [blame] | 194 | dev_warn(&dev->dev, |
| 195 | "multiple interrupts in _CRS descriptor; configuration can't be changed\n"); |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 196 | dev->capabilities &= ~PNP_WRITE; |
| 197 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 199 | return AE_OK; |
Jagadish Krishnamoorthy | 2a56e91 | 2017-05-23 20:03:25 +0300 | [diff] [blame] | 200 | } else if (acpi_gpio_get_irq_resource(res, &gpio)) { |
| 201 | /* |
| 202 | * If the resource is GpioInt() type then extract the IRQ |
| 203 | * from GPIO resource and fill it into IRQ resource type. |
| 204 | */ |
| 205 | i = acpi_dev_gpio_irq_get(dev->data, 0); |
| 206 | if (i >= 0) { |
| 207 | flags = acpi_dev_irq_flags(gpio->triggering, |
| 208 | gpio->polarity, |
Erik Schmauss | c163f90c | 2019-02-15 13:36:19 -0800 | [diff] [blame] | 209 | gpio->shareable); |
Jagadish Krishnamoorthy | 2a56e91 | 2017-05-23 20:03:25 +0300 | [diff] [blame] | 210 | } else { |
| 211 | flags = IORESOURCE_DISABLED; |
| 212 | } |
| 213 | pnp_add_irq_resource(dev, i, flags); |
| 214 | return AE_OK; |
Jiang Liu | a49170b | 2015-02-02 10:42:58 +0800 | [diff] [blame] | 215 | } else if (r->flags & IORESOURCE_DISABLED) { |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 216 | pnp_add_irq_resource(dev, 0, IORESOURCE_DISABLED); |
| 217 | return AE_OK; |
| 218 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 220 | switch (res->type) { |
Zhang Rui | 8993531 | 2014-03-11 22:40:27 +0800 | [diff] [blame] | 221 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 222 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 223 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Jiang Liu | a49170b | 2015-02-02 10:42:58 +0800 | [diff] [blame] | 224 | if (acpi_dev_resource_memory(res, r)) |
| 225 | pnp_add_resource(dev, r); |
Zhang Rui | 8993531 | 2014-03-11 22:40:27 +0800 | [diff] [blame] | 226 | break; |
| 227 | case ACPI_RESOURCE_TYPE_IO: |
| 228 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Jiang Liu | a49170b | 2015-02-02 10:42:58 +0800 | [diff] [blame] | 229 | if (acpi_dev_resource_io(res, r)) |
| 230 | pnp_add_resource(dev, r); |
Zhang Rui | 8993531 | 2014-03-11 22:40:27 +0800 | [diff] [blame] | 231 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 232 | case ACPI_RESOURCE_TYPE_DMA: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 233 | dma = &res->data.dma; |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 234 | if (dma->channel_count > 0 && dma->channels[0] != (u8) -1) |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 235 | flags = dma_flags(dev, dma->type, dma->bus_master, |
Bjorn Helgaas | dc16f5f | 2008-04-28 16:34:35 -0600 | [diff] [blame] | 236 | dma->transfer); |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 237 | else |
| 238 | flags = IORESOURCE_DISABLED; |
| 239 | pnp_add_dma_resource(dev, dma->channels[0], flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 241 | |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 242 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 243 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 244 | break; |
| 245 | |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 246 | case ACPI_RESOURCE_TYPE_VENDOR: |
Bjorn Helgaas | 40ab4f4 | 2008-06-27 16:57:19 -0600 | [diff] [blame] | 247 | vendor_typed = &res->data.vendor_typed; |
| 248 | pnpacpi_parse_allocated_vendor(dev, vendor_typed); |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 249 | break; |
| 250 | |
| 251 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 252 | break; |
| 253 | |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 254 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
| 255 | break; |
| 256 | |
Harb Abdulhamid | 86e7541 | 2016-03-01 13:31:45 -0600 | [diff] [blame] | 257 | case ACPI_RESOURCE_TYPE_SERIAL_BUS: |
| 258 | /* serial bus connections (I2C/SPI/UART) are not pnp */ |
| 259 | break; |
| 260 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | default: |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 262 | dev_warn(&dev->dev, "unknown resource type %d in _CRS\n", |
| 263 | res->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | return AE_ERROR; |
| 265 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 266 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | return AE_OK; |
| 268 | } |
| 269 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 270 | int pnpacpi_parse_allocated_resource(struct pnp_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 272 | struct acpi_device *acpi_dev = dev->data; |
| 273 | acpi_handle handle = acpi_dev->handle; |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 274 | acpi_status status; |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 275 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 276 | pnp_dbg(&dev->dev, "parse allocated resources\n"); |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 277 | |
Bjorn Helgaas | f449000 | 2008-04-28 16:34:09 -0600 | [diff] [blame] | 278 | pnp_init_resources(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 280 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
| 281 | pnpacpi_allocated_resource, dev); |
| 282 | |
| 283 | if (ACPI_FAILURE(status)) { |
| 284 | if (status != AE_NOT_FOUND) |
| 285 | dev_err(&dev->dev, "can't evaluate _CRS: %d", status); |
| 286 | return -EPERM; |
| 287 | } |
| 288 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 291 | static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 292 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 293 | struct acpi_resource_dma *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | { |
| 295 | int i; |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 296 | unsigned char map = 0, flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 298 | for (i = 0; i < p->channel_count; i++) |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 299 | map |= 1 << p->channels[i]; |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 300 | |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 301 | flags = dma_flags(dev, p->type, p->bus_master, p->transfer); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 302 | pnp_register_dma_resource(dev, option_flags, map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 305 | static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 306 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 307 | struct acpi_resource_irq *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | { |
| 309 | int i; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 310 | pnp_irq_mask_t map; |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 311 | unsigned char flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 313 | bitmap_zero(map.bits, PNP_IRQ_NR); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 314 | for (i = 0; i < p->interrupt_count; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | if (p->interrupts[i]) |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 316 | __set_bit(p->interrupts[i], map.bits); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | |
Erik Schmauss | c163f90c | 2019-02-15 13:36:19 -0800 | [diff] [blame] | 318 | flags = acpi_dev_irq_flags(p->triggering, p->polarity, p->shareable); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 319 | pnp_register_irq_resource(dev, option_flags, &map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 322 | static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 323 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 324 | struct acpi_resource_extended_irq *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { |
| 326 | int i; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 327 | pnp_irq_mask_t map; |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 328 | unsigned char flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 330 | bitmap_zero(map.bits, PNP_IRQ_NR); |
Bjorn Helgaas | fe2cf59 | 2008-06-27 16:57:12 -0600 | [diff] [blame] | 331 | for (i = 0; i < p->interrupt_count; i++) { |
| 332 | if (p->interrupts[i]) { |
| 333 | if (p->interrupts[i] < PNP_IRQ_NR) |
| 334 | __set_bit(p->interrupts[i], map.bits); |
| 335 | else |
Andy Shevchenko | 1d7f2cd | 2017-05-23 20:03:26 +0300 | [diff] [blame] | 336 | dev_err(&dev->dev, |
| 337 | "ignoring IRQ %d option (too large for %d entry bitmap)\n", |
Bjorn Helgaas | fe2cf59 | 2008-06-27 16:57:12 -0600 | [diff] [blame] | 338 | p->interrupts[i], PNP_IRQ_NR); |
| 339 | } |
| 340 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
Erik Schmauss | c163f90c | 2019-02-15 13:36:19 -0800 | [diff] [blame] | 342 | flags = acpi_dev_irq_flags(p->triggering, p->polarity, p->shareable); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 343 | pnp_register_irq_resource(dev, option_flags, &map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | } |
| 345 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 346 | static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 347 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 348 | struct acpi_resource_io *io) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 350 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 352 | if (io->io_decode == ACPI_DECODE_16) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 353 | flags = IORESOURCE_IO_16BIT_ADDR; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 354 | pnp_register_port_resource(dev, option_flags, io->minimum, io->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 355 | io->alignment, io->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | } |
| 357 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 358 | static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 359 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 360 | struct acpi_resource_fixed_io *io) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | { |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 362 | pnp_register_port_resource(dev, option_flags, io->address, io->address, |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 363 | 0, io->address_length, IORESOURCE_IO_FIXED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | } |
| 365 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 366 | static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 367 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 368 | struct acpi_resource_memory24 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 370 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 372 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 373 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 374 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 375 | p->alignment, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 378 | static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 379 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 380 | struct acpi_resource_memory32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 382 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 384 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 385 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 386 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 387 | p->alignment, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | } |
| 389 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 390 | static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 391 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 392 | struct acpi_resource_fixed_memory32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 394 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 396 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 397 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 398 | pnp_register_mem_resource(dev, option_flags, p->address, p->address, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 399 | 0, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | } |
| 401 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 402 | static __init void pnpacpi_parse_address_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 403 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 404 | struct acpi_resource *r) |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 405 | { |
| 406 | struct acpi_resource_address64 addr, *p = &addr; |
| 407 | acpi_status status; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 408 | unsigned char flags = 0; |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 409 | |
| 410 | status = acpi_resource_to_address64(r, p); |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 411 | if (ACPI_FAILURE(status)) { |
| 412 | dev_warn(&dev->dev, "can't convert resource type %d\n", |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 413 | r->type); |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 414 | return; |
| 415 | } |
| 416 | |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 417 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 418 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 419 | flags = IORESOURCE_MEM_WRITEABLE; |
Lv Zheng | a45de93 | 2015-01-26 16:58:56 +0800 | [diff] [blame] | 420 | pnp_register_mem_resource(dev, option_flags, p->address.minimum, |
| 421 | p->address.minimum, 0, p->address.address_length, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 422 | flags); |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 423 | } else if (p->resource_type == ACPI_IO_RANGE) |
Lv Zheng | a45de93 | 2015-01-26 16:58:56 +0800 | [diff] [blame] | 424 | pnp_register_port_resource(dev, option_flags, p->address.minimum, |
| 425 | p->address.minimum, 0, p->address.address_length, |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 426 | IORESOURCE_IO_FIXED); |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 427 | } |
| 428 | |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 429 | static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, |
| 430 | unsigned int option_flags, |
| 431 | struct acpi_resource *r) |
| 432 | { |
| 433 | struct acpi_resource_extended_address64 *p = &r->data.ext_address64; |
| 434 | unsigned char flags = 0; |
| 435 | |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 436 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
| 437 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 438 | flags = IORESOURCE_MEM_WRITEABLE; |
Lv Zheng | a45de93 | 2015-01-26 16:58:56 +0800 | [diff] [blame] | 439 | pnp_register_mem_resource(dev, option_flags, p->address.minimum, |
| 440 | p->address.minimum, 0, p->address.address_length, |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 441 | flags); |
| 442 | } else if (p->resource_type == ACPI_IO_RANGE) |
Lv Zheng | a45de93 | 2015-01-26 16:58:56 +0800 | [diff] [blame] | 443 | pnp_register_port_resource(dev, option_flags, p->address.minimum, |
| 444 | p->address.minimum, 0, p->address.address_length, |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 445 | IORESOURCE_IO_FIXED); |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 446 | } |
| 447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | struct acpipnp_parse_option_s { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | struct pnp_dev *dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 450 | unsigned int option_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | }; |
| 452 | |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 453 | static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, |
| 454 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | { |
Bjorn Helgaas | e2a1a6f | 2008-06-27 16:57:15 -0600 | [diff] [blame] | 456 | int priority; |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 457 | struct acpipnp_parse_option_s *parse_data = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | struct pnp_dev *dev = parse_data->dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 459 | unsigned int option_flags = parse_data->option_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 461 | switch (res->type) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 462 | case ACPI_RESOURCE_TYPE_IRQ: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 463 | pnpacpi_parse_irq_option(dev, option_flags, &res->data.irq); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 464 | break; |
| 465 | |
| 466 | case ACPI_RESOURCE_TYPE_DMA: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 467 | pnpacpi_parse_dma_option(dev, option_flags, &res->data.dma); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 468 | break; |
| 469 | |
| 470 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 471 | switch (res->data.start_dpf.compatibility_priority) { |
| 472 | case ACPI_GOOD_CONFIGURATION: |
| 473 | priority = PNP_RES_PRIORITY_PREFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 475 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 476 | case ACPI_ACCEPTABLE_CONFIGURATION: |
| 477 | priority = PNP_RES_PRIORITY_ACCEPTABLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 479 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 480 | case ACPI_SUB_OPTIMAL_CONFIGURATION: |
| 481 | priority = PNP_RES_PRIORITY_FUNCTIONAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | default: |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 484 | priority = PNP_RES_PRIORITY_INVALID; |
| 485 | break; |
| 486 | } |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 487 | parse_data->option_flags = pnp_new_dependent_set(dev, priority); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 488 | break; |
| 489 | |
| 490 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 491 | parse_data->option_flags = 0; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 492 | break; |
| 493 | |
| 494 | case ACPI_RESOURCE_TYPE_IO: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 495 | pnpacpi_parse_port_option(dev, option_flags, &res->data.io); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 496 | break; |
| 497 | |
| 498 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 499 | pnpacpi_parse_fixed_port_option(dev, option_flags, |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 500 | &res->data.fixed_io); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 501 | break; |
| 502 | |
| 503 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 504 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 505 | break; |
| 506 | |
| 507 | case ACPI_RESOURCE_TYPE_MEMORY24: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 508 | pnpacpi_parse_mem24_option(dev, option_flags, |
| 509 | &res->data.memory24); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 510 | break; |
| 511 | |
| 512 | case ACPI_RESOURCE_TYPE_MEMORY32: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 513 | pnpacpi_parse_mem32_option(dev, option_flags, |
| 514 | &res->data.memory32); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 515 | break; |
| 516 | |
| 517 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 518 | pnpacpi_parse_fixed_mem32_option(dev, option_flags, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 519 | &res->data.fixed_memory32); |
| 520 | break; |
| 521 | |
| 522 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 523 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 524 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 525 | pnpacpi_parse_address_option(dev, option_flags, res); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 526 | break; |
| 527 | |
| 528 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 529 | pnpacpi_parse_ext_address_option(dev, option_flags, res); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 530 | break; |
| 531 | |
| 532 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 533 | pnpacpi_parse_ext_irq_option(dev, option_flags, |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 534 | &res->data.extended_irq); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 535 | break; |
| 536 | |
| 537 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
| 538 | break; |
| 539 | |
| 540 | default: |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 541 | dev_warn(&dev->dev, "unknown resource type %d in _PRS\n", |
| 542 | res->type); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 543 | return AE_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 545 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | return AE_OK; |
| 547 | } |
| 548 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 549 | int __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 551 | struct acpi_device *acpi_dev = dev->data; |
| 552 | acpi_handle handle = acpi_dev->handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | acpi_status status; |
| 554 | struct acpipnp_parse_option_s parse_data; |
| 555 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 556 | pnp_dbg(&dev->dev, "parse resource options\n"); |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 557 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | parse_data.dev = dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 559 | parse_data.option_flags = 0; |
| 560 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 561 | status = acpi_walk_resources(handle, METHOD_NAME__PRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 562 | pnpacpi_option_resource, &parse_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 564 | if (ACPI_FAILURE(status)) { |
| 565 | if (status != AE_NOT_FOUND) |
| 566 | dev_err(&dev->dev, "can't evaluate _PRS: %d", status); |
| 567 | return -EPERM; |
| 568 | } |
| 569 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | } |
| 571 | |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 572 | static int pnpacpi_supported_resource(struct acpi_resource *res) |
| 573 | { |
| 574 | switch (res->type) { |
| 575 | case ACPI_RESOURCE_TYPE_IRQ: |
| 576 | case ACPI_RESOURCE_TYPE_DMA: |
| 577 | case ACPI_RESOURCE_TYPE_IO: |
| 578 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
| 579 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 580 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 581 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
| 582 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 583 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 584 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 585 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 586 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
| 587 | return 1; |
| 588 | } |
| 589 | return 0; |
| 590 | } |
| 591 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | /* |
| 593 | * Set resource |
| 594 | */ |
| 595 | static acpi_status pnpacpi_count_resources(struct acpi_resource *res, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 596 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | { |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 598 | int *res_cnt = data; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 599 | |
| 600 | if (pnpacpi_supported_resource(res)) |
| 601 | (*res_cnt)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | return AE_OK; |
| 603 | } |
| 604 | |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 605 | static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | { |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 607 | struct acpi_resource **resource = data; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 608 | |
| 609 | if (pnpacpi_supported_resource(res)) { |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 610 | (*resource)->type = res->type; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 611 | (*resource)->length = sizeof(struct acpi_resource); |
Bjorn Helgaas | 36d872a | 2008-06-09 16:52:06 -0700 | [diff] [blame] | 612 | if (res->type == ACPI_RESOURCE_TYPE_IRQ) |
| 613 | (*resource)->data.irq.descriptor_length = |
| 614 | res->data.irq.descriptor_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | (*resource)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | return AE_OK; |
| 619 | } |
| 620 | |
Bjorn Helgaas | cdef625 | 2008-04-28 16:34:03 -0600 | [diff] [blame] | 621 | int pnpacpi_build_resource_template(struct pnp_dev *dev, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 622 | struct acpi_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 624 | struct acpi_device *acpi_dev = dev->data; |
| 625 | acpi_handle handle = acpi_dev->handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | struct acpi_resource *resource; |
| 627 | int res_cnt = 0; |
| 628 | acpi_status status; |
| 629 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 630 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 631 | pnpacpi_count_resources, &res_cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | if (ACPI_FAILURE(status)) { |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 633 | dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | return -EINVAL; |
| 635 | } |
| 636 | if (!res_cnt) |
| 637 | return -EINVAL; |
| 638 | buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; |
Robert P. J. Day | cd86128 | 2006-12-13 00:34:52 -0800 | [diff] [blame] | 639 | buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | if (!buffer->pointer) |
| 641 | return -ENOMEM; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 642 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | resource = (struct acpi_resource *)buffer->pointer; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 644 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 645 | pnpacpi_type_resources, &resource); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | if (ACPI_FAILURE(status)) { |
| 647 | kfree(buffer->pointer); |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 648 | dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | return -EINVAL; |
| 650 | } |
| 651 | /* resource will pointer the end resource now */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 652 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; |
Yinghai Lu | f084dbb | 2013-03-23 19:16:37 +0000 | [diff] [blame] | 653 | resource->length = sizeof(struct acpi_resource); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
| 655 | return 0; |
| 656 | } |
| 657 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 658 | static void pnpacpi_encode_irq(struct pnp_dev *dev, |
| 659 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 660 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 662 | struct acpi_resource_irq *irq = &resource->data.irq; |
Fabian Frederick | bbee06d | 2015-05-02 17:14:49 +0200 | [diff] [blame] | 663 | u8 triggering, polarity, shareable; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 664 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 665 | if (!pnp_resource_enabled(p)) { |
| 666 | irq->interrupt_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 667 | pnp_dbg(&dev->dev, " encode irq (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 668 | p ? "disabled" : "missing"); |
| 669 | return; |
| 670 | } |
| 671 | |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 672 | decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable); |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 673 | irq->triggering = triggering; |
| 674 | irq->polarity = polarity; |
Erik Schmauss | c163f90c | 2019-02-15 13:36:19 -0800 | [diff] [blame] | 675 | irq->shareable = shareable; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 676 | irq->interrupt_count = 1; |
| 677 | irq->interrupts[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 678 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 679 | pnp_dbg(&dev->dev, " encode irq %d %s %s %s (%d-byte descriptor)\n", |
Bjorn Helgaas | 36d872a | 2008-06-09 16:52:06 -0700 | [diff] [blame] | 680 | (int) p->start, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 681 | triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge", |
| 682 | polarity == ACPI_ACTIVE_LOW ? "low" : "high", |
Erik Schmauss | c163f90c | 2019-02-15 13:36:19 -0800 | [diff] [blame] | 683 | irq->shareable == ACPI_SHARED ? "shared" : "exclusive", |
Bjorn Helgaas | 36d872a | 2008-06-09 16:52:06 -0700 | [diff] [blame] | 684 | irq->descriptor_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | } |
| 686 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 687 | static void pnpacpi_encode_ext_irq(struct pnp_dev *dev, |
| 688 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 689 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 691 | struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq; |
Fabian Frederick | bbee06d | 2015-05-02 17:14:49 +0200 | [diff] [blame] | 692 | u8 triggering, polarity, shareable; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 693 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 694 | if (!pnp_resource_enabled(p)) { |
| 695 | extended_irq->interrupt_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 696 | pnp_dbg(&dev->dev, " encode extended irq (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 697 | p ? "disabled" : "missing"); |
| 698 | return; |
| 699 | } |
| 700 | |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 701 | decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable); |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 702 | extended_irq->producer_consumer = ACPI_CONSUMER; |
| 703 | extended_irq->triggering = triggering; |
| 704 | extended_irq->polarity = polarity; |
Erik Schmauss | c163f90c | 2019-02-15 13:36:19 -0800 | [diff] [blame] | 705 | extended_irq->shareable = shareable; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 706 | extended_irq->interrupt_count = 1; |
| 707 | extended_irq->interrupts[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 708 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 709 | pnp_dbg(&dev->dev, " encode irq %d %s %s %s\n", (int) p->start, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 710 | triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge", |
| 711 | polarity == ACPI_ACTIVE_LOW ? "low" : "high", |
Erik Schmauss | c163f90c | 2019-02-15 13:36:19 -0800 | [diff] [blame] | 712 | extended_irq->shareable == ACPI_SHARED ? "shared" : "exclusive"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | } |
| 714 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 715 | static void pnpacpi_encode_dma(struct pnp_dev *dev, |
| 716 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 717 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 719 | struct acpi_resource_dma *dma = &resource->data.dma; |
| 720 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 721 | if (!pnp_resource_enabled(p)) { |
| 722 | dma->channel_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 723 | pnp_dbg(&dev->dev, " encode dma (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 724 | p ? "disabled" : "missing"); |
| 725 | return; |
| 726 | } |
| 727 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 729 | switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 730 | case IORESOURCE_DMA_TYPEA: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 731 | dma->type = ACPI_TYPE_A; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 732 | break; |
| 733 | case IORESOURCE_DMA_TYPEB: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 734 | dma->type = ACPI_TYPE_B; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 735 | break; |
| 736 | case IORESOURCE_DMA_TYPEF: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 737 | dma->type = ACPI_TYPE_F; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 738 | break; |
| 739 | default: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 740 | dma->type = ACPI_COMPATIBILITY; |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 744 | case IORESOURCE_DMA_8BIT: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 745 | dma->transfer = ACPI_TRANSFER_8; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 746 | break; |
| 747 | case IORESOURCE_DMA_8AND16BIT: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 748 | dma->transfer = ACPI_TRANSFER_8_16; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 749 | break; |
| 750 | default: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 751 | dma->transfer = ACPI_TRANSFER_16; |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 752 | } |
| 753 | |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 754 | dma->bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); |
| 755 | dma->channel_count = 1; |
| 756 | dma->channels[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 757 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 758 | pnp_dbg(&dev->dev, " encode dma %d " |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 759 | "type %#x transfer %#x master %d\n", |
| 760 | (int) p->start, dma->type, dma->transfer, dma->bus_master); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | } |
| 762 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 763 | static void pnpacpi_encode_io(struct pnp_dev *dev, |
| 764 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 765 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 767 | struct acpi_resource_io *io = &resource->data.io; |
| 768 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 769 | if (pnp_resource_enabled(p)) { |
| 770 | /* Note: pnp_assign_port copies pnp_port->flags into p->flags */ |
Bjorn Helgaas | 08c9f26 | 2008-06-27 16:57:03 -0600 | [diff] [blame] | 771 | io->io_decode = (p->flags & IORESOURCE_IO_16BIT_ADDR) ? |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 772 | ACPI_DECODE_16 : ACPI_DECODE_10; |
| 773 | io->minimum = p->start; |
| 774 | io->maximum = p->end; |
| 775 | io->alignment = 0; /* Correct? */ |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 776 | io->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 777 | } else { |
| 778 | io->minimum = 0; |
| 779 | io->address_length = 0; |
| 780 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 781 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 782 | pnp_dbg(&dev->dev, " encode io %#x-%#x decode %#x\n", io->minimum, |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 783 | io->minimum + io->address_length - 1, io->io_decode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | } |
| 785 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 786 | static void pnpacpi_encode_fixed_io(struct pnp_dev *dev, |
| 787 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 788 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 790 | struct acpi_resource_fixed_io *fixed_io = &resource->data.fixed_io; |
| 791 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 792 | if (pnp_resource_enabled(p)) { |
| 793 | fixed_io->address = p->start; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 794 | fixed_io->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 795 | } else { |
| 796 | fixed_io->address = 0; |
| 797 | fixed_io->address_length = 0; |
| 798 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 799 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 800 | pnp_dbg(&dev->dev, " encode fixed_io %#x-%#x\n", fixed_io->address, |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 801 | fixed_io->address + fixed_io->address_length - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | } |
| 803 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 804 | static void pnpacpi_encode_mem24(struct pnp_dev *dev, |
| 805 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 806 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 808 | struct acpi_resource_memory24 *memory24 = &resource->data.memory24; |
| 809 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 810 | if (pnp_resource_enabled(p)) { |
| 811 | /* Note: pnp_assign_mem copies pnp_mem->flags into p->flags */ |
| 812 | memory24->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 813 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 814 | memory24->minimum = p->start; |
| 815 | memory24->maximum = p->end; |
| 816 | memory24->alignment = 0; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 817 | memory24->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 818 | } else { |
| 819 | memory24->minimum = 0; |
| 820 | memory24->address_length = 0; |
| 821 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 822 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 823 | pnp_dbg(&dev->dev, " encode mem24 %#x-%#x write_protect %#x\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 824 | memory24->minimum, |
| 825 | memory24->minimum + memory24->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 826 | memory24->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | } |
| 828 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 829 | static void pnpacpi_encode_mem32(struct pnp_dev *dev, |
| 830 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 831 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 833 | struct acpi_resource_memory32 *memory32 = &resource->data.memory32; |
| 834 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 835 | if (pnp_resource_enabled(p)) { |
| 836 | memory32->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 837 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 838 | memory32->minimum = p->start; |
| 839 | memory32->maximum = p->end; |
| 840 | memory32->alignment = 0; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 841 | memory32->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 842 | } else { |
| 843 | memory32->minimum = 0; |
| 844 | memory32->alignment = 0; |
| 845 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 846 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 847 | pnp_dbg(&dev->dev, " encode mem32 %#x-%#x write_protect %#x\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 848 | memory32->minimum, |
| 849 | memory32->minimum + memory32->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 850 | memory32->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | } |
| 852 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 853 | static void pnpacpi_encode_fixed_mem32(struct pnp_dev *dev, |
| 854 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 855 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 857 | struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32; |
| 858 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 859 | if (pnp_resource_enabled(p)) { |
| 860 | fixed_memory32->write_protect = |
| 861 | p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 862 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 863 | fixed_memory32->address = p->start; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 864 | fixed_memory32->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 865 | } else { |
| 866 | fixed_memory32->address = 0; |
| 867 | fixed_memory32->address_length = 0; |
| 868 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 869 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 870 | pnp_dbg(&dev->dev, " encode fixed_mem32 %#x-%#x write_protect %#x\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 871 | fixed_memory32->address, |
| 872 | fixed_memory32->address + fixed_memory32->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 873 | fixed_memory32->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | } |
| 875 | |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 876 | int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | { |
| 878 | int i = 0; |
| 879 | /* pnpacpi_build_resource_template allocates extra mem */ |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 880 | int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1; |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 881 | struct acpi_resource *resource = buffer->pointer; |
Fabian Frederick | fac69a2 | 2015-05-02 17:14:50 +0200 | [diff] [blame] | 882 | unsigned int port = 0, irq = 0, dma = 0, mem = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 884 | pnp_dbg(&dev->dev, "encode %d resources\n", res_cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | while (i < res_cnt) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 886 | switch (resource->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 887 | case ACPI_RESOURCE_TYPE_IRQ: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 888 | pnpacpi_encode_irq(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 889 | pnp_get_resource(dev, IORESOURCE_IRQ, irq)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | irq++; |
| 891 | break; |
| 892 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 893 | case ACPI_RESOURCE_TYPE_DMA: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 894 | pnpacpi_encode_dma(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 895 | pnp_get_resource(dev, IORESOURCE_DMA, dma)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 896 | dma++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 898 | case ACPI_RESOURCE_TYPE_IO: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 899 | pnpacpi_encode_io(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 900 | pnp_get_resource(dev, IORESOURCE_IO, port)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 901 | port++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 903 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 904 | pnpacpi_encode_fixed_io(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 905 | pnp_get_resource(dev, IORESOURCE_IO, port)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 906 | port++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 908 | case ACPI_RESOURCE_TYPE_MEMORY24: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 909 | pnpacpi_encode_mem24(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 910 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 911 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 913 | case ACPI_RESOURCE_TYPE_MEMORY32: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 914 | pnpacpi_encode_mem32(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 915 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 916 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 918 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 919 | pnpacpi_encode_fixed_mem32(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 920 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 921 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 923 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 924 | pnpacpi_encode_ext_irq(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 925 | pnp_get_resource(dev, IORESOURCE_IRQ, irq)); |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 926 | irq++; |
| 927 | break; |
| 928 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 929 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 930 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 931 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 932 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 933 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 934 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
| 935 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
| 936 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 937 | default: /* other type */ |
Andy Shevchenko | 1d7f2cd | 2017-05-23 20:03:26 +0300 | [diff] [blame] | 938 | dev_warn(&dev->dev, |
| 939 | "can't encode unknown resource type %d\n", |
| 940 | resource->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | return -EINVAL; |
| 942 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 943 | resource++; |
| 944 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | } |
| 946 | return 0; |
| 947 | } |