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