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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | default: |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 256 | dev_warn(&dev->dev, "unknown resource type %d in _CRS\n", |
| 257 | res->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | return AE_ERROR; |
| 259 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 260 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | return AE_OK; |
| 262 | } |
| 263 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 264 | int pnpacpi_parse_allocated_resource(struct pnp_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 266 | struct acpi_device *acpi_dev = dev->data; |
| 267 | acpi_handle handle = acpi_dev->handle; |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 268 | acpi_status status; |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 269 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 270 | pnp_dbg(&dev->dev, "parse allocated resources\n"); |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 271 | |
Bjorn Helgaas | f449000 | 2008-04-28 16:34:09 -0600 | [diff] [blame] | 272 | pnp_init_resources(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 274 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
| 275 | pnpacpi_allocated_resource, dev); |
| 276 | |
| 277 | if (ACPI_FAILURE(status)) { |
| 278 | if (status != AE_NOT_FOUND) |
| 279 | dev_err(&dev->dev, "can't evaluate _CRS: %d", status); |
| 280 | return -EPERM; |
| 281 | } |
| 282 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 285 | static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 286 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 287 | struct acpi_resource_dma *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | { |
| 289 | int i; |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 290 | unsigned char map = 0, flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 292 | for (i = 0; i < p->channel_count; i++) |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 293 | map |= 1 << p->channels[i]; |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 294 | |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 295 | flags = dma_flags(dev, p->type, p->bus_master, p->transfer); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 296 | pnp_register_dma_resource(dev, option_flags, map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 299 | static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 300 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 301 | struct acpi_resource_irq *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | { |
| 303 | int i; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 304 | pnp_irq_mask_t map; |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 305 | unsigned char flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 307 | bitmap_zero(map.bits, PNP_IRQ_NR); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 308 | for (i = 0; i < p->interrupt_count; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | if (p->interrupts[i]) |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 310 | __set_bit(p->interrupts[i], map.bits); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 312 | flags = acpi_dev_irq_flags(p->triggering, p->polarity, p->sharable); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 313 | pnp_register_irq_resource(dev, option_flags, &map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 316 | static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 317 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 318 | struct acpi_resource_extended_irq *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | { |
| 320 | int i; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 321 | pnp_irq_mask_t map; |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 322 | unsigned char flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 324 | bitmap_zero(map.bits, PNP_IRQ_NR); |
Bjorn Helgaas | fe2cf59 | 2008-06-27 16:57:12 -0600 | [diff] [blame] | 325 | for (i = 0; i < p->interrupt_count; i++) { |
| 326 | if (p->interrupts[i]) { |
| 327 | if (p->interrupts[i] < PNP_IRQ_NR) |
| 328 | __set_bit(p->interrupts[i], map.bits); |
| 329 | else |
| 330 | dev_err(&dev->dev, "ignoring IRQ %d option " |
| 331 | "(too large for %d entry bitmap)\n", |
| 332 | p->interrupts[i], PNP_IRQ_NR); |
| 333 | } |
| 334 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Rafael J. Wysocki | 046d9ce | 2012-11-15 00:30:01 +0100 | [diff] [blame] | 336 | flags = acpi_dev_irq_flags(p->triggering, p->polarity, p->sharable); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 337 | pnp_register_irq_resource(dev, option_flags, &map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 340 | static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 341 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 342 | struct acpi_resource_io *io) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 344 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 346 | if (io->io_decode == ACPI_DECODE_16) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 347 | flags = IORESOURCE_IO_16BIT_ADDR; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 348 | pnp_register_port_resource(dev, option_flags, io->minimum, io->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 349 | io->alignment, io->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 352 | static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 353 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 354 | struct acpi_resource_fixed_io *io) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | { |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 356 | pnp_register_port_resource(dev, option_flags, io->address, io->address, |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 357 | 0, io->address_length, IORESOURCE_IO_FIXED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 360 | static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 361 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 362 | struct acpi_resource_memory24 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 364 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 366 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 367 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 368 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 369 | p->alignment, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | } |
| 371 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 372 | static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 373 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 374 | struct acpi_resource_memory32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 376 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 378 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 379 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 380 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 381 | p->alignment, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | } |
| 383 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 384 | static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 385 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 386 | struct acpi_resource_fixed_memory32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 388 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 390 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 391 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 392 | pnp_register_mem_resource(dev, option_flags, p->address, p->address, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 393 | 0, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | } |
| 395 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 396 | static __init void pnpacpi_parse_address_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 397 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 398 | struct acpi_resource *r) |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 399 | { |
| 400 | struct acpi_resource_address64 addr, *p = &addr; |
| 401 | acpi_status status; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 402 | unsigned char flags = 0; |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 403 | |
| 404 | status = acpi_resource_to_address64(r, p); |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 405 | if (ACPI_FAILURE(status)) { |
| 406 | dev_warn(&dev->dev, "can't convert resource type %d\n", |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 407 | r->type); |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 408 | return; |
| 409 | } |
| 410 | |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 411 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 412 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 413 | flags = IORESOURCE_MEM_WRITEABLE; |
Lv Zheng | a45de93 | 2015-01-26 16:58:56 +0800 | [diff] [blame] | 414 | pnp_register_mem_resource(dev, option_flags, p->address.minimum, |
| 415 | p->address.minimum, 0, p->address.address_length, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 416 | flags); |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 417 | } else if (p->resource_type == ACPI_IO_RANGE) |
Lv Zheng | a45de93 | 2015-01-26 16:58:56 +0800 | [diff] [blame] | 418 | pnp_register_port_resource(dev, option_flags, p->address.minimum, |
| 419 | p->address.minimum, 0, p->address.address_length, |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 420 | IORESOURCE_IO_FIXED); |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 421 | } |
| 422 | |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 423 | static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, |
| 424 | unsigned int option_flags, |
| 425 | struct acpi_resource *r) |
| 426 | { |
| 427 | struct acpi_resource_extended_address64 *p = &r->data.ext_address64; |
| 428 | unsigned char flags = 0; |
| 429 | |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 430 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
| 431 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 432 | flags = IORESOURCE_MEM_WRITEABLE; |
Lv Zheng | a45de93 | 2015-01-26 16:58:56 +0800 | [diff] [blame] | 433 | pnp_register_mem_resource(dev, option_flags, p->address.minimum, |
| 434 | p->address.minimum, 0, p->address.address_length, |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 435 | flags); |
| 436 | } else if (p->resource_type == ACPI_IO_RANGE) |
Lv Zheng | a45de93 | 2015-01-26 16:58:56 +0800 | [diff] [blame] | 437 | pnp_register_port_resource(dev, option_flags, p->address.minimum, |
| 438 | p->address.minimum, 0, p->address.address_length, |
Witold Szczeponik | 18fd470 | 2011-10-27 20:56:47 +0200 | [diff] [blame] | 439 | IORESOURCE_IO_FIXED); |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 440 | } |
| 441 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | struct acpipnp_parse_option_s { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | struct pnp_dev *dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 444 | unsigned int option_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | }; |
| 446 | |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 447 | static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, |
| 448 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | { |
Bjorn Helgaas | e2a1a6f | 2008-06-27 16:57:15 -0600 | [diff] [blame] | 450 | int priority; |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 451 | struct acpipnp_parse_option_s *parse_data = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | struct pnp_dev *dev = parse_data->dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 453 | unsigned int option_flags = parse_data->option_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 455 | switch (res->type) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 456 | case ACPI_RESOURCE_TYPE_IRQ: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 457 | pnpacpi_parse_irq_option(dev, option_flags, &res->data.irq); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 458 | break; |
| 459 | |
| 460 | case ACPI_RESOURCE_TYPE_DMA: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 461 | pnpacpi_parse_dma_option(dev, option_flags, &res->data.dma); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 462 | break; |
| 463 | |
| 464 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 465 | switch (res->data.start_dpf.compatibility_priority) { |
| 466 | case ACPI_GOOD_CONFIGURATION: |
| 467 | priority = PNP_RES_PRIORITY_PREFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 469 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 470 | case ACPI_ACCEPTABLE_CONFIGURATION: |
| 471 | priority = PNP_RES_PRIORITY_ACCEPTABLE; |
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_SUB_OPTIMAL_CONFIGURATION: |
| 475 | priority = PNP_RES_PRIORITY_FUNCTIONAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | default: |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 478 | priority = PNP_RES_PRIORITY_INVALID; |
| 479 | break; |
| 480 | } |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 481 | parse_data->option_flags = pnp_new_dependent_set(dev, priority); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 482 | break; |
| 483 | |
| 484 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 485 | parse_data->option_flags = 0; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 486 | break; |
| 487 | |
| 488 | case ACPI_RESOURCE_TYPE_IO: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 489 | pnpacpi_parse_port_option(dev, option_flags, &res->data.io); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 490 | break; |
| 491 | |
| 492 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 493 | pnpacpi_parse_fixed_port_option(dev, option_flags, |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 494 | &res->data.fixed_io); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 495 | break; |
| 496 | |
| 497 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 498 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 499 | break; |
| 500 | |
| 501 | case ACPI_RESOURCE_TYPE_MEMORY24: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 502 | pnpacpi_parse_mem24_option(dev, option_flags, |
| 503 | &res->data.memory24); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 504 | break; |
| 505 | |
| 506 | case ACPI_RESOURCE_TYPE_MEMORY32: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 507 | pnpacpi_parse_mem32_option(dev, option_flags, |
| 508 | &res->data.memory32); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 509 | break; |
| 510 | |
| 511 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 512 | pnpacpi_parse_fixed_mem32_option(dev, option_flags, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 513 | &res->data.fixed_memory32); |
| 514 | break; |
| 515 | |
| 516 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 517 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 518 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 519 | pnpacpi_parse_address_option(dev, option_flags, res); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 520 | break; |
| 521 | |
| 522 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 523 | pnpacpi_parse_ext_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_IRQ: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 527 | pnpacpi_parse_ext_irq_option(dev, option_flags, |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 528 | &res->data.extended_irq); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 529 | break; |
| 530 | |
| 531 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
| 532 | break; |
| 533 | |
| 534 | default: |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 535 | dev_warn(&dev->dev, "unknown resource type %d in _PRS\n", |
| 536 | res->type); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 537 | return AE_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 539 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | return AE_OK; |
| 541 | } |
| 542 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 543 | int __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 545 | struct acpi_device *acpi_dev = dev->data; |
| 546 | acpi_handle handle = acpi_dev->handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | acpi_status status; |
| 548 | struct acpipnp_parse_option_s parse_data; |
| 549 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 550 | pnp_dbg(&dev->dev, "parse resource options\n"); |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 551 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | parse_data.dev = dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 553 | parse_data.option_flags = 0; |
| 554 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 555 | status = acpi_walk_resources(handle, METHOD_NAME__PRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 556 | pnpacpi_option_resource, &parse_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 558 | if (ACPI_FAILURE(status)) { |
| 559 | if (status != AE_NOT_FOUND) |
| 560 | dev_err(&dev->dev, "can't evaluate _PRS: %d", status); |
| 561 | return -EPERM; |
| 562 | } |
| 563 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | } |
| 565 | |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 566 | static int pnpacpi_supported_resource(struct acpi_resource *res) |
| 567 | { |
| 568 | switch (res->type) { |
| 569 | case ACPI_RESOURCE_TYPE_IRQ: |
| 570 | case ACPI_RESOURCE_TYPE_DMA: |
| 571 | case ACPI_RESOURCE_TYPE_IO: |
| 572 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
| 573 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 574 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 575 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
| 576 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 577 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 578 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 579 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 580 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
| 581 | return 1; |
| 582 | } |
| 583 | return 0; |
| 584 | } |
| 585 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | /* |
| 587 | * Set resource |
| 588 | */ |
| 589 | static acpi_status pnpacpi_count_resources(struct acpi_resource *res, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 590 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | { |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 592 | int *res_cnt = data; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 593 | |
| 594 | if (pnpacpi_supported_resource(res)) |
| 595 | (*res_cnt)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | return AE_OK; |
| 597 | } |
| 598 | |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 599 | static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | { |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 601 | struct acpi_resource **resource = data; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 602 | |
| 603 | if (pnpacpi_supported_resource(res)) { |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 604 | (*resource)->type = res->type; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 605 | (*resource)->length = sizeof(struct acpi_resource); |
Bjorn Helgaas | 36d872a | 2008-06-09 16:52:06 -0700 | [diff] [blame] | 606 | if (res->type == ACPI_RESOURCE_TYPE_IRQ) |
| 607 | (*resource)->data.irq.descriptor_length = |
| 608 | res->data.irq.descriptor_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | (*resource)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | return AE_OK; |
| 613 | } |
| 614 | |
Bjorn Helgaas | cdef625 | 2008-04-28 16:34:03 -0600 | [diff] [blame] | 615 | int pnpacpi_build_resource_template(struct pnp_dev *dev, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 616 | struct acpi_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 618 | struct acpi_device *acpi_dev = dev->data; |
| 619 | acpi_handle handle = acpi_dev->handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | struct acpi_resource *resource; |
| 621 | int res_cnt = 0; |
| 622 | acpi_status status; |
| 623 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 624 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 625 | pnpacpi_count_resources, &res_cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | if (ACPI_FAILURE(status)) { |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 627 | dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | return -EINVAL; |
| 629 | } |
| 630 | if (!res_cnt) |
| 631 | return -EINVAL; |
| 632 | buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; |
Robert P. J. Day | cd86128 | 2006-12-13 00:34:52 -0800 | [diff] [blame] | 633 | buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | if (!buffer->pointer) |
| 635 | return -ENOMEM; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 636 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | resource = (struct acpi_resource *)buffer->pointer; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 638 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 639 | pnpacpi_type_resources, &resource); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | if (ACPI_FAILURE(status)) { |
| 641 | kfree(buffer->pointer); |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 642 | dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | return -EINVAL; |
| 644 | } |
| 645 | /* resource will pointer the end resource now */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 646 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; |
Yinghai Lu | f084dbb | 2013-03-23 19:16:37 +0000 | [diff] [blame] | 647 | resource->length = sizeof(struct acpi_resource); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | |
| 649 | return 0; |
| 650 | } |
| 651 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 652 | static void pnpacpi_encode_irq(struct pnp_dev *dev, |
| 653 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 654 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 656 | struct acpi_resource_irq *irq = &resource->data.irq; |
Fabian Frederick | bbee06d | 2015-05-02 17:14:49 +0200 | [diff] [blame] | 657 | u8 triggering, polarity, shareable; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 658 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 659 | if (!pnp_resource_enabled(p)) { |
| 660 | irq->interrupt_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 661 | pnp_dbg(&dev->dev, " encode irq (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 662 | p ? "disabled" : "missing"); |
| 663 | return; |
| 664 | } |
| 665 | |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 666 | decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable); |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 667 | irq->triggering = triggering; |
| 668 | irq->polarity = polarity; |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 669 | irq->sharable = shareable; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 670 | irq->interrupt_count = 1; |
| 671 | irq->interrupts[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 672 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 673 | 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] | 674 | (int) p->start, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 675 | triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge", |
| 676 | polarity == ACPI_ACTIVE_LOW ? "low" : "high", |
Bjorn Helgaas | 36d872a | 2008-06-09 16:52:06 -0700 | [diff] [blame] | 677 | irq->sharable == ACPI_SHARED ? "shared" : "exclusive", |
| 678 | irq->descriptor_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | } |
| 680 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 681 | static void pnpacpi_encode_ext_irq(struct pnp_dev *dev, |
| 682 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 683 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 685 | struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq; |
Fabian Frederick | bbee06d | 2015-05-02 17:14:49 +0200 | [diff] [blame] | 686 | u8 triggering, polarity, shareable; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 687 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 688 | if (!pnp_resource_enabled(p)) { |
| 689 | extended_irq->interrupt_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 690 | pnp_dbg(&dev->dev, " encode extended irq (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 691 | p ? "disabled" : "missing"); |
| 692 | return; |
| 693 | } |
| 694 | |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 695 | decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable); |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 696 | extended_irq->producer_consumer = ACPI_CONSUMER; |
| 697 | extended_irq->triggering = triggering; |
| 698 | extended_irq->polarity = polarity; |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 699 | extended_irq->sharable = shareable; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 700 | extended_irq->interrupt_count = 1; |
| 701 | extended_irq->interrupts[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 702 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 703 | 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] | 704 | triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge", |
| 705 | polarity == ACPI_ACTIVE_LOW ? "low" : "high", |
| 706 | extended_irq->sharable == ACPI_SHARED ? "shared" : "exclusive"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 709 | static void pnpacpi_encode_dma(struct pnp_dev *dev, |
| 710 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 711 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 713 | struct acpi_resource_dma *dma = &resource->data.dma; |
| 714 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 715 | if (!pnp_resource_enabled(p)) { |
| 716 | dma->channel_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 717 | pnp_dbg(&dev->dev, " encode dma (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 718 | p ? "disabled" : "missing"); |
| 719 | return; |
| 720 | } |
| 721 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 723 | switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 724 | case IORESOURCE_DMA_TYPEA: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 725 | dma->type = ACPI_TYPE_A; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 726 | break; |
| 727 | case IORESOURCE_DMA_TYPEB: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 728 | dma->type = ACPI_TYPE_B; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 729 | break; |
| 730 | case IORESOURCE_DMA_TYPEF: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 731 | dma->type = ACPI_TYPE_F; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 732 | break; |
| 733 | default: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 734 | dma->type = ACPI_COMPATIBILITY; |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 738 | case IORESOURCE_DMA_8BIT: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 739 | dma->transfer = ACPI_TRANSFER_8; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 740 | break; |
| 741 | case IORESOURCE_DMA_8AND16BIT: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 742 | dma->transfer = ACPI_TRANSFER_8_16; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 743 | break; |
| 744 | default: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 745 | dma->transfer = ACPI_TRANSFER_16; |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 746 | } |
| 747 | |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 748 | dma->bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); |
| 749 | dma->channel_count = 1; |
| 750 | dma->channels[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 751 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 752 | pnp_dbg(&dev->dev, " encode dma %d " |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 753 | "type %#x transfer %#x master %d\n", |
| 754 | (int) p->start, dma->type, dma->transfer, dma->bus_master); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | } |
| 756 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 757 | static void pnpacpi_encode_io(struct pnp_dev *dev, |
| 758 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 759 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 761 | struct acpi_resource_io *io = &resource->data.io; |
| 762 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 763 | if (pnp_resource_enabled(p)) { |
| 764 | /* Note: pnp_assign_port copies pnp_port->flags into p->flags */ |
Bjorn Helgaas | 08c9f26 | 2008-06-27 16:57:03 -0600 | [diff] [blame] | 765 | io->io_decode = (p->flags & IORESOURCE_IO_16BIT_ADDR) ? |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 766 | ACPI_DECODE_16 : ACPI_DECODE_10; |
| 767 | io->minimum = p->start; |
| 768 | io->maximum = p->end; |
| 769 | io->alignment = 0; /* Correct? */ |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 770 | io->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 771 | } else { |
| 772 | io->minimum = 0; |
| 773 | io->address_length = 0; |
| 774 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 775 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 776 | 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] | 777 | io->minimum + io->address_length - 1, io->io_decode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | } |
| 779 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 780 | static void pnpacpi_encode_fixed_io(struct pnp_dev *dev, |
| 781 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 782 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 784 | struct acpi_resource_fixed_io *fixed_io = &resource->data.fixed_io; |
| 785 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 786 | if (pnp_resource_enabled(p)) { |
| 787 | fixed_io->address = p->start; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 788 | fixed_io->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 789 | } else { |
| 790 | fixed_io->address = 0; |
| 791 | fixed_io->address_length = 0; |
| 792 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 793 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 794 | 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] | 795 | fixed_io->address + fixed_io->address_length - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | } |
| 797 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 798 | static void pnpacpi_encode_mem24(struct pnp_dev *dev, |
| 799 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 800 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 802 | struct acpi_resource_memory24 *memory24 = &resource->data.memory24; |
| 803 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 804 | if (pnp_resource_enabled(p)) { |
| 805 | /* Note: pnp_assign_mem copies pnp_mem->flags into p->flags */ |
| 806 | memory24->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 807 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 808 | memory24->minimum = p->start; |
| 809 | memory24->maximum = p->end; |
| 810 | memory24->alignment = 0; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 811 | memory24->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 812 | } else { |
| 813 | memory24->minimum = 0; |
| 814 | memory24->address_length = 0; |
| 815 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 816 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 817 | pnp_dbg(&dev->dev, " encode mem24 %#x-%#x write_protect %#x\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 818 | memory24->minimum, |
| 819 | memory24->minimum + memory24->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 820 | memory24->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | } |
| 822 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 823 | static void pnpacpi_encode_mem32(struct pnp_dev *dev, |
| 824 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 825 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 827 | struct acpi_resource_memory32 *memory32 = &resource->data.memory32; |
| 828 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 829 | if (pnp_resource_enabled(p)) { |
| 830 | memory32->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 831 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 832 | memory32->minimum = p->start; |
| 833 | memory32->maximum = p->end; |
| 834 | memory32->alignment = 0; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 835 | memory32->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 836 | } else { |
| 837 | memory32->minimum = 0; |
| 838 | memory32->alignment = 0; |
| 839 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 840 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 841 | pnp_dbg(&dev->dev, " encode mem32 %#x-%#x write_protect %#x\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 842 | memory32->minimum, |
| 843 | memory32->minimum + memory32->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 844 | memory32->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | } |
| 846 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 847 | static void pnpacpi_encode_fixed_mem32(struct pnp_dev *dev, |
| 848 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 849 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 851 | struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32; |
| 852 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 853 | if (pnp_resource_enabled(p)) { |
| 854 | fixed_memory32->write_protect = |
| 855 | p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 856 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 857 | fixed_memory32->address = p->start; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 858 | fixed_memory32->address_length = resource_size(p); |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 859 | } else { |
| 860 | fixed_memory32->address = 0; |
| 861 | fixed_memory32->address_length = 0; |
| 862 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 863 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 864 | 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] | 865 | fixed_memory32->address, |
| 866 | fixed_memory32->address + fixed_memory32->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 867 | fixed_memory32->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | } |
| 869 | |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 870 | int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | { |
| 872 | int i = 0; |
| 873 | /* pnpacpi_build_resource_template allocates extra mem */ |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 874 | int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1; |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 875 | struct acpi_resource *resource = buffer->pointer; |
Fabian Frederick | fac69a2 | 2015-05-02 17:14:50 +0200 | [diff] [blame] | 876 | unsigned int port = 0, irq = 0, dma = 0, mem = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 878 | pnp_dbg(&dev->dev, "encode %d resources\n", res_cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | while (i < res_cnt) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 880 | switch (resource->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 881 | case ACPI_RESOURCE_TYPE_IRQ: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 882 | pnpacpi_encode_irq(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 883 | pnp_get_resource(dev, IORESOURCE_IRQ, irq)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | irq++; |
| 885 | break; |
| 886 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 887 | case ACPI_RESOURCE_TYPE_DMA: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 888 | pnpacpi_encode_dma(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 889 | pnp_get_resource(dev, IORESOURCE_DMA, dma)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 890 | dma++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 892 | case ACPI_RESOURCE_TYPE_IO: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 893 | pnpacpi_encode_io(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 894 | pnp_get_resource(dev, IORESOURCE_IO, port)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 895 | port++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 897 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 898 | pnpacpi_encode_fixed_io(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 899 | pnp_get_resource(dev, IORESOURCE_IO, port)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 900 | port++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 902 | case ACPI_RESOURCE_TYPE_MEMORY24: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 903 | pnpacpi_encode_mem24(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 904 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 905 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 907 | case ACPI_RESOURCE_TYPE_MEMORY32: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 908 | pnpacpi_encode_mem32(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 909 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 910 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 912 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 913 | pnpacpi_encode_fixed_mem32(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 914 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 915 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 917 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 918 | pnpacpi_encode_ext_irq(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 919 | pnp_get_resource(dev, IORESOURCE_IRQ, irq)); |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 920 | irq++; |
| 921 | break; |
| 922 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 923 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 924 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 925 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 926 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 927 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 928 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
| 929 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
| 930 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 931 | default: /* other type */ |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 932 | dev_warn(&dev->dev, "can't encode unknown resource " |
| 933 | "type %d\n", resource->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | return -EINVAL; |
| 935 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 936 | resource++; |
| 937 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | } |
| 939 | return 0; |
| 940 | } |