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 | |
| 31 | #ifdef CONFIG_IA64 |
| 32 | #define valid_IRQ(i) (1) |
| 33 | #else |
| 34 | #define valid_IRQ(i) (((i) != 0) && ((i) != 2)) |
| 35 | #endif |
| 36 | |
| 37 | /* |
| 38 | * Allocated Resources |
| 39 | */ |
Bjorn Helgaas | cd7ec92 | 2008-04-28 16:34:02 -0600 | [diff] [blame] | 40 | static int irq_flags(int triggering, int polarity, int shareable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | { |
Bjorn Helgaas | cd7ec92 | 2008-04-28 16:34:02 -0600 | [diff] [blame] | 42 | int flags; |
| 43 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 44 | if (triggering == ACPI_LEVEL_SENSITIVE) { |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 45 | if (polarity == ACPI_ACTIVE_LOW) |
Bjorn Helgaas | cd7ec92 | 2008-04-28 16:34:02 -0600 | [diff] [blame] | 46 | flags = IORESOURCE_IRQ_LOWLEVEL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | else |
Bjorn Helgaas | cd7ec92 | 2008-04-28 16:34:02 -0600 | [diff] [blame] | 48 | flags = IORESOURCE_IRQ_HIGHLEVEL; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 49 | } else { |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 50 | if (polarity == ACPI_ACTIVE_LOW) |
Bjorn Helgaas | cd7ec92 | 2008-04-28 16:34:02 -0600 | [diff] [blame] | 51 | flags = IORESOURCE_IRQ_LOWEDGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | else |
Bjorn Helgaas | cd7ec92 | 2008-04-28 16:34:02 -0600 | [diff] [blame] | 53 | flags = IORESOURCE_IRQ_HIGHEDGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } |
Bjorn Helgaas | cd7ec92 | 2008-04-28 16:34:02 -0600 | [diff] [blame] | 55 | |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 56 | if (shareable == ACPI_SHARED) |
Bjorn Helgaas | cd7ec92 | 2008-04-28 16:34:02 -0600 | [diff] [blame] | 57 | flags |= IORESOURCE_IRQ_SHAREABLE; |
| 58 | |
| 59 | return flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Bjorn Helgaas | e9fe9e1 | 2008-06-09 16:52:04 -0700 | [diff] [blame] | 62 | static void decode_irq_flags(struct pnp_dev *dev, int flags, int *triggering, |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 63 | int *polarity, int *shareable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | { |
Bjorn Helgaas | e9fe9e1 | 2008-06-09 16:52:04 -0700 | [diff] [blame] | 65 | switch (flags & (IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL | |
| 66 | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | case IORESOURCE_IRQ_LOWLEVEL: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 68 | *triggering = ACPI_LEVEL_SENSITIVE; |
| 69 | *polarity = ACPI_ACTIVE_LOW; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | break; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 71 | case IORESOURCE_IRQ_HIGHLEVEL: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 72 | *triggering = ACPI_LEVEL_SENSITIVE; |
| 73 | *polarity = ACPI_ACTIVE_HIGH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | break; |
| 75 | case IORESOURCE_IRQ_LOWEDGE: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 76 | *triggering = ACPI_EDGE_SENSITIVE; |
| 77 | *polarity = ACPI_ACTIVE_LOW; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | break; |
| 79 | case IORESOURCE_IRQ_HIGHEDGE: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 80 | *triggering = ACPI_EDGE_SENSITIVE; |
| 81 | *polarity = ACPI_ACTIVE_HIGH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | break; |
Bjorn Helgaas | e9fe9e1 | 2008-06-09 16:52:04 -0700 | [diff] [blame] | 83 | default: |
| 84 | dev_err(&dev->dev, "can't encode invalid IRQ mode %#x\n", |
| 85 | flags); |
| 86 | *triggering = ACPI_EDGE_SENSITIVE; |
| 87 | *polarity = ACPI_ACTIVE_HIGH; |
| 88 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | } |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 90 | |
| 91 | if (flags & IORESOURCE_IRQ_SHAREABLE) |
| 92 | *shareable = ACPI_SHARED; |
| 93 | else |
| 94 | *shareable = ACPI_EXCLUSIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 97 | static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev, |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 98 | u32 gsi, int triggering, |
| 99 | int polarity, int shareable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | { |
Bjorn Helgaas | dbddd03 | 2008-04-28 16:34:34 -0600 | [diff] [blame] | 101 | int irq, flags; |
Shaohua Li | 61fd47e | 2007-11-17 01:05:28 -0500 | [diff] [blame] | 102 | int p, t; |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 103 | |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 104 | if (!valid_IRQ(gsi)) { |
| 105 | pnp_add_irq_resource(dev, gsi, IORESOURCE_DISABLED); |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 106 | return; |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 107 | } |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 108 | |
Shaohua Li | 61fd47e | 2007-11-17 01:05:28 -0500 | [diff] [blame] | 109 | /* |
| 110 | * in IO-APIC mode, use overrided attribute. Two reasons: |
| 111 | * 1. BIOS bug in DSDT |
| 112 | * 2. BIOS uses IO-APIC mode Interrupt Source Override |
| 113 | */ |
| 114 | if (!acpi_get_override_irq(gsi, &t, &p)) { |
| 115 | t = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; |
| 116 | p = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; |
| 117 | |
| 118 | if (triggering != t || polarity != p) { |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 119 | dev_warn(&dev->dev, "IRQ %d override to %s, %s\n", |
Shaohua Li | 61fd47e | 2007-11-17 01:05:28 -0500 | [diff] [blame] | 120 | gsi, t ? "edge":"level", p ? "low":"high"); |
| 121 | triggering = t; |
| 122 | polarity = p; |
| 123 | } |
| 124 | } |
| 125 | |
Bjorn Helgaas | dbddd03 | 2008-04-28 16:34:34 -0600 | [diff] [blame] | 126 | flags = irq_flags(triggering, polarity, shareable); |
Yinghai Lu | a2f809b | 2009-04-27 18:01:20 -0700 | [diff] [blame] | 127 | irq = acpi_register_gsi(&dev->dev, gsi, triggering, polarity); |
Bjorn Helgaas | dbddd03 | 2008-04-28 16:34:34 -0600 | [diff] [blame] | 128 | if (irq >= 0) |
| 129 | pcibios_penalize_isa_irq(irq, 1); |
| 130 | else |
| 131 | flags |= IORESOURCE_DISABLED; |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 132 | |
Bjorn Helgaas | dbddd03 | 2008-04-28 16:34:34 -0600 | [diff] [blame] | 133 | pnp_add_irq_resource(dev, irq, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 136 | static int dma_flags(struct pnp_dev *dev, int type, int bus_master, |
| 137 | int transfer) |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 138 | { |
| 139 | int flags = 0; |
| 140 | |
| 141 | if (bus_master) |
| 142 | flags |= IORESOURCE_DMA_MASTER; |
| 143 | switch (type) { |
| 144 | case ACPI_COMPATIBILITY: |
| 145 | flags |= IORESOURCE_DMA_COMPATIBLE; |
| 146 | break; |
| 147 | case ACPI_TYPE_A: |
| 148 | flags |= IORESOURCE_DMA_TYPEA; |
| 149 | break; |
| 150 | case ACPI_TYPE_B: |
| 151 | flags |= IORESOURCE_DMA_TYPEB; |
| 152 | break; |
| 153 | case ACPI_TYPE_F: |
| 154 | flags |= IORESOURCE_DMA_TYPEF; |
| 155 | break; |
| 156 | default: |
| 157 | /* Set a default value ? */ |
| 158 | flags |= IORESOURCE_DMA_COMPATIBLE; |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 159 | dev_err(&dev->dev, "invalid DMA type %d\n", type); |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 160 | } |
| 161 | switch (transfer) { |
| 162 | case ACPI_TRANSFER_8: |
| 163 | flags |= IORESOURCE_DMA_8BIT; |
| 164 | break; |
| 165 | case ACPI_TRANSFER_8_16: |
| 166 | flags |= IORESOURCE_DMA_8AND16BIT; |
| 167 | break; |
| 168 | case ACPI_TRANSFER_16: |
| 169 | flags |= IORESOURCE_DMA_16BIT; |
| 170 | break; |
| 171 | default: |
| 172 | /* Set a default value ? */ |
| 173 | flags |= IORESOURCE_DMA_8AND16BIT; |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 174 | dev_err(&dev->dev, "invalid DMA transfer type %d\n", transfer); |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | return flags; |
| 178 | } |
| 179 | |
Bjorn Helgaas | cc8c2e3 | 2008-04-28 16:34:36 -0600 | [diff] [blame] | 180 | static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 start, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 181 | u64 len, int io_decode, |
| 182 | int window) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | { |
Bjorn Helgaas | cc8c2e3 | 2008-04-28 16:34:36 -0600 | [diff] [blame] | 184 | int flags = 0; |
| 185 | u64 end = start + len - 1; |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 186 | |
Bjorn Helgaas | cc8c2e3 | 2008-04-28 16:34:36 -0600 | [diff] [blame] | 187 | if (io_decode == ACPI_DECODE_16) |
Bjorn Helgaas | 08c9f26 | 2008-06-27 16:57:03 -0600 | [diff] [blame] | 188 | flags |= IORESOURCE_IO_16BIT_ADDR; |
Bjorn Helgaas | cc8c2e3 | 2008-04-28 16:34:36 -0600 | [diff] [blame] | 189 | if (len == 0 || end >= 0x10003) |
| 190 | flags |= IORESOURCE_DISABLED; |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 191 | if (window) |
| 192 | flags |= IORESOURCE_WINDOW; |
Bjorn Helgaas | cc8c2e3 | 2008-04-28 16:34:36 -0600 | [diff] [blame] | 193 | |
| 194 | pnp_add_io_resource(dev, start, end, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Bjorn Helgaas | 40ab4f4 | 2008-06-27 16:57:19 -0600 | [diff] [blame] | 197 | /* |
| 198 | * Device CSRs that do not appear in PCI config space should be described |
| 199 | * via ACPI. This would normally be done with Address Space Descriptors |
| 200 | * marked as "consumer-only," but old versions of Windows and Linux ignore |
| 201 | * the producer/consumer flag, so HP invented a vendor-defined resource to |
| 202 | * describe the location and size of CSR space. |
| 203 | */ |
| 204 | static struct acpi_vendor_uuid hp_ccsr_uuid = { |
| 205 | .subtype = 2, |
| 206 | .data = { 0xf9, 0xad, 0xe9, 0x69, 0x4f, 0x92, 0x5f, 0xab, 0xf6, 0x4a, |
| 207 | 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad }, |
| 208 | }; |
| 209 | |
| 210 | static int vendor_resource_matches(struct pnp_dev *dev, |
| 211 | struct acpi_resource_vendor_typed *vendor, |
| 212 | struct acpi_vendor_uuid *match, |
| 213 | int expected_len) |
| 214 | { |
| 215 | int uuid_len = sizeof(vendor->uuid); |
| 216 | u8 uuid_subtype = vendor->uuid_subtype; |
| 217 | u8 *uuid = vendor->uuid; |
| 218 | int actual_len; |
| 219 | |
| 220 | /* byte_length includes uuid_subtype and uuid */ |
| 221 | actual_len = vendor->byte_length - uuid_len - 1; |
| 222 | |
| 223 | if (uuid_subtype == match->subtype && |
| 224 | uuid_len == sizeof(match->data) && |
| 225 | memcmp(uuid, match->data, uuid_len) == 0) { |
| 226 | if (expected_len && expected_len != actual_len) { |
| 227 | dev_err(&dev->dev, "wrong vendor descriptor size; " |
| 228 | "expected %d, found %d bytes\n", |
| 229 | expected_len, actual_len); |
| 230 | return 0; |
| 231 | } |
| 232 | |
| 233 | return 1; |
| 234 | } |
| 235 | |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | static void pnpacpi_parse_allocated_vendor(struct pnp_dev *dev, |
| 240 | struct acpi_resource_vendor_typed *vendor) |
| 241 | { |
| 242 | if (vendor_resource_matches(dev, vendor, &hp_ccsr_uuid, 16)) { |
| 243 | u64 start, length; |
| 244 | |
| 245 | memcpy(&start, vendor->byte_data, sizeof(start)); |
| 246 | memcpy(&length, vendor->byte_data + 8, sizeof(length)); |
| 247 | |
| 248 | pnp_add_mem_resource(dev, start, start + length - 1, 0); |
| 249 | } |
| 250 | } |
| 251 | |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 252 | static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, |
Bjorn Helgaas | d6180f3 | 2008-04-28 16:34:37 -0600 | [diff] [blame] | 253 | u64 start, u64 len, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 254 | int write_protect, int window) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | { |
Bjorn Helgaas | d6180f3 | 2008-04-28 16:34:37 -0600 | [diff] [blame] | 256 | int flags = 0; |
| 257 | u64 end = start + len - 1; |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 258 | |
Bjorn Helgaas | d6180f3 | 2008-04-28 16:34:37 -0600 | [diff] [blame] | 259 | if (len == 0) |
| 260 | flags |= IORESOURCE_DISABLED; |
| 261 | if (write_protect == ACPI_READ_WRITE_MEMORY) |
| 262 | flags |= IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 263 | if (window) |
| 264 | flags |= IORESOURCE_WINDOW; |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 265 | |
Bjorn Helgaas | d6180f3 | 2008-04-28 16:34:37 -0600 | [diff] [blame] | 266 | pnp_add_mem_resource(dev, start, end, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Bjorn Helgaas | 7e0e9c0 | 2010-03-05 10:47:57 -0700 | [diff] [blame] | 269 | static void pnpacpi_parse_allocated_busresource(struct pnp_dev *dev, |
| 270 | u64 start, u64 len) |
| 271 | { |
| 272 | u64 end = start + len - 1; |
| 273 | |
| 274 | pnp_add_bus_resource(dev, start, end); |
| 275 | } |
| 276 | |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 277 | static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev, |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 278 | struct acpi_resource *res) |
Bjorn Helgaas | 1acfb7f | 2006-03-28 17:03:00 -0500 | [diff] [blame] | 279 | { |
| 280 | struct acpi_resource_address64 addr, *p = &addr; |
| 281 | acpi_status status; |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 282 | int window; |
Bjorn Helgaas | 3162b6f | 2010-03-25 10:32:49 -0600 | [diff] [blame] | 283 | u64 len; |
Bjorn Helgaas | 1acfb7f | 2006-03-28 17:03:00 -0500 | [diff] [blame] | 284 | |
| 285 | status = acpi_resource_to_address64(res, p); |
| 286 | if (!ACPI_SUCCESS(status)) { |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 287 | dev_warn(&dev->dev, "failed to convert resource type %d\n", |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 288 | res->type); |
Bjorn Helgaas | 1acfb7f | 2006-03-28 17:03:00 -0500 | [diff] [blame] | 289 | return; |
| 290 | } |
| 291 | |
Bjorn Helgaas | f238b41 | 2010-04-27 14:45:38 -0600 | [diff] [blame] | 292 | /* Windows apparently computes length rather than using _LEN */ |
| 293 | len = p->maximum - p->minimum + 1; |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 294 | window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0; |
matthieu castet | 2b8de5f | 2006-08-05 12:15:12 -0700 | [diff] [blame] | 295 | |
Bjorn Helgaas | 1acfb7f | 2006-03-28 17:03:00 -0500 | [diff] [blame] | 296 | if (p->resource_type == ACPI_MEMORY_RANGE) |
Bjorn Helgaas | 3162b6f | 2010-03-25 10:32:49 -0600 | [diff] [blame] | 297 | pnpacpi_parse_allocated_memresource(dev, p->minimum, len, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 298 | p->info.mem.write_protect, window); |
Bjorn Helgaas | 1acfb7f | 2006-03-28 17:03:00 -0500 | [diff] [blame] | 299 | else if (p->resource_type == ACPI_IO_RANGE) |
Bjorn Helgaas | 3162b6f | 2010-03-25 10:32:49 -0600 | [diff] [blame] | 300 | pnpacpi_parse_allocated_ioresource(dev, p->minimum, len, |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 301 | p->granularity == 0xfff ? ACPI_DECODE_10 : |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 302 | ACPI_DECODE_16, window); |
Bjorn Helgaas | 7e0e9c0 | 2010-03-05 10:47:57 -0700 | [diff] [blame] | 303 | else if (p->resource_type == ACPI_BUS_NUMBER_RANGE) |
Bjorn Helgaas | 3162b6f | 2010-03-25 10:32:49 -0600 | [diff] [blame] | 304 | pnpacpi_parse_allocated_busresource(dev, p->minimum, len); |
Bjorn Helgaas | 1acfb7f | 2006-03-28 17:03:00 -0500 | [diff] [blame] | 305 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 307 | static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev, |
| 308 | struct acpi_resource *res) |
| 309 | { |
| 310 | struct acpi_resource_extended_address64 *p = &res->data.ext_address64; |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 311 | int window; |
Bjorn Helgaas | 3162b6f | 2010-03-25 10:32:49 -0600 | [diff] [blame] | 312 | u64 len; |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 313 | |
Bjorn Helgaas | f238b41 | 2010-04-27 14:45:38 -0600 | [diff] [blame] | 314 | /* Windows apparently computes length rather than using _LEN */ |
| 315 | len = p->maximum - p->minimum + 1; |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 316 | window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0; |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 317 | |
| 318 | if (p->resource_type == ACPI_MEMORY_RANGE) |
Bjorn Helgaas | 3162b6f | 2010-03-25 10:32:49 -0600 | [diff] [blame] | 319 | pnpacpi_parse_allocated_memresource(dev, p->minimum, len, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 320 | p->info.mem.write_protect, window); |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 321 | else if (p->resource_type == ACPI_IO_RANGE) |
Bjorn Helgaas | 3162b6f | 2010-03-25 10:32:49 -0600 | [diff] [blame] | 322 | pnpacpi_parse_allocated_ioresource(dev, p->minimum, len, |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 323 | p->granularity == 0xfff ? ACPI_DECODE_10 : |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 324 | ACPI_DECODE_16, window); |
Bjorn Helgaas | 7e0e9c0 | 2010-03-05 10:47:57 -0700 | [diff] [blame] | 325 | else if (p->resource_type == ACPI_BUS_NUMBER_RANGE) |
Bjorn Helgaas | 3162b6f | 2010-03-25 10:32:49 -0600 | [diff] [blame] | 326 | pnpacpi_parse_allocated_busresource(dev, p->minimum, len); |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 327 | } |
| 328 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 330 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | { |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 332 | struct pnp_dev *dev = data; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 333 | struct acpi_resource_irq *irq; |
| 334 | struct acpi_resource_dma *dma; |
| 335 | struct acpi_resource_io *io; |
| 336 | struct acpi_resource_fixed_io *fixed_io; |
Bjorn Helgaas | 40ab4f4 | 2008-06-27 16:57:19 -0600 | [diff] [blame] | 337 | struct acpi_resource_vendor_typed *vendor_typed; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 338 | struct acpi_resource_memory24 *memory24; |
| 339 | struct acpi_resource_memory32 *memory32; |
| 340 | struct acpi_resource_fixed_memory32 *fixed_memory32; |
| 341 | struct acpi_resource_extended_irq *extended_irq; |
Bjorn Helgaas | dc16f5f | 2008-04-28 16:34:35 -0600 | [diff] [blame] | 342 | int i, flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 344 | switch (res->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 345 | case ACPI_RESOURCE_TYPE_IRQ: |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 346 | /* |
| 347 | * Per spec, only one interrupt per descriptor is allowed in |
| 348 | * _CRS, but some firmware violates this, so parse them all. |
| 349 | */ |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 350 | irq = &res->data.irq; |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 351 | if (irq->interrupt_count == 0) |
| 352 | pnp_add_irq_resource(dev, 0, IORESOURCE_DISABLED); |
| 353 | else { |
| 354 | for (i = 0; i < irq->interrupt_count; i++) { |
| 355 | pnpacpi_parse_allocated_irqresource(dev, |
| 356 | irq->interrupts[i], |
| 357 | irq->triggering, |
| 358 | irq->polarity, |
| 359 | irq->sharable); |
| 360 | } |
| 361 | |
| 362 | /* |
| 363 | * The IRQ encoder puts a single interrupt in each |
| 364 | * descriptor, so if a _CRS descriptor has more than |
| 365 | * one interrupt, we won't be able to re-encode it. |
| 366 | */ |
| 367 | if (pnp_can_write(dev) && irq->interrupt_count > 1) { |
| 368 | dev_warn(&dev->dev, "multiple interrupts in " |
| 369 | "_CRS descriptor; configuration can't " |
| 370 | "be changed\n"); |
| 371 | dev->capabilities &= ~PNP_WRITE; |
| 372 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | } |
| 374 | break; |
| 375 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 376 | case ACPI_RESOURCE_TYPE_DMA: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 377 | dma = &res->data.dma; |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 378 | if (dma->channel_count > 0 && dma->channels[0] != (u8) -1) |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 379 | flags = dma_flags(dev, dma->type, dma->bus_master, |
Bjorn Helgaas | dc16f5f | 2008-04-28 16:34:35 -0600 | [diff] [blame] | 380 | dma->transfer); |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 381 | else |
| 382 | flags = IORESOURCE_DISABLED; |
| 383 | pnp_add_dma_resource(dev, dma->channels[0], flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 385 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 386 | case ACPI_RESOURCE_TYPE_IO: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 387 | io = &res->data.io; |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 388 | pnpacpi_parse_allocated_ioresource(dev, |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 389 | io->minimum, |
| 390 | io->address_length, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 391 | io->io_decode, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 393 | |
| 394 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 395 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 396 | break; |
| 397 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 398 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 399 | fixed_io = &res->data.fixed_io; |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 400 | pnpacpi_parse_allocated_ioresource(dev, |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 401 | fixed_io->address, |
| 402 | fixed_io->address_length, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 403 | ACPI_DECODE_10, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 405 | |
| 406 | case ACPI_RESOURCE_TYPE_VENDOR: |
Bjorn Helgaas | 40ab4f4 | 2008-06-27 16:57:19 -0600 | [diff] [blame] | 407 | vendor_typed = &res->data.vendor_typed; |
| 408 | pnpacpi_parse_allocated_vendor(dev, vendor_typed); |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 409 | break; |
| 410 | |
| 411 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 412 | break; |
| 413 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 414 | case ACPI_RESOURCE_TYPE_MEMORY24: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 415 | memory24 = &res->data.memory24; |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 416 | pnpacpi_parse_allocated_memresource(dev, |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 417 | memory24->minimum, |
| 418 | memory24->address_length, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 419 | memory24->write_protect, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 421 | case ACPI_RESOURCE_TYPE_MEMORY32: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 422 | memory32 = &res->data.memory32; |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 423 | pnpacpi_parse_allocated_memresource(dev, |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 424 | memory32->minimum, |
| 425 | memory32->address_length, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 426 | memory32->write_protect, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 428 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 429 | fixed_memory32 = &res->data.fixed_memory32; |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 430 | pnpacpi_parse_allocated_memresource(dev, |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 431 | fixed_memory32->address, |
| 432 | fixed_memory32->address_length, |
Bjorn Helgaas | fa35b492 | 2010-03-05 10:47:52 -0700 | [diff] [blame] | 433 | fixed_memory32->write_protect, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 435 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 436 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 437 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 438 | pnpacpi_parse_allocated_address_space(dev, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 440 | |
| 441 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 442 | pnpacpi_parse_allocated_ext_address_space(dev, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 444 | |
| 445 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 446 | extended_irq = &res->data.extended_irq; |
matthieu castet | 2b8de5f | 2006-08-05 12:15:12 -0700 | [diff] [blame] | 447 | |
Bjorn Helgaas | 5acf914 | 2008-06-27 16:56:58 -0600 | [diff] [blame] | 448 | if (extended_irq->interrupt_count == 0) |
| 449 | pnp_add_irq_resource(dev, 0, IORESOURCE_DISABLED); |
| 450 | else { |
| 451 | for (i = 0; i < extended_irq->interrupt_count; i++) { |
| 452 | pnpacpi_parse_allocated_irqresource(dev, |
| 453 | extended_irq->interrupts[i], |
| 454 | extended_irq->triggering, |
| 455 | extended_irq->polarity, |
| 456 | extended_irq->sharable); |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | * The IRQ encoder puts a single interrupt in each |
| 461 | * descriptor, so if a _CRS descriptor has more than |
| 462 | * one interrupt, we won't be able to re-encode it. |
| 463 | */ |
| 464 | if (pnp_can_write(dev) && |
| 465 | extended_irq->interrupt_count > 1) { |
| 466 | dev_warn(&dev->dev, "multiple interrupts in " |
| 467 | "_CRS descriptor; configuration can't " |
| 468 | "be changed\n"); |
| 469 | dev->capabilities &= ~PNP_WRITE; |
| 470 | } |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 471 | } |
| 472 | break; |
| 473 | |
| 474 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
| 475 | break; |
| 476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | default: |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 478 | dev_warn(&dev->dev, "unknown resource type %d in _CRS\n", |
| 479 | res->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | return AE_ERROR; |
| 481 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 482 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | return AE_OK; |
| 484 | } |
| 485 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 486 | int pnpacpi_parse_allocated_resource(struct pnp_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 488 | struct acpi_device *acpi_dev = dev->data; |
| 489 | acpi_handle handle = acpi_dev->handle; |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 490 | acpi_status status; |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 491 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 492 | pnp_dbg(&dev->dev, "parse allocated resources\n"); |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 493 | |
Bjorn Helgaas | f449000 | 2008-04-28 16:34:09 -0600 | [diff] [blame] | 494 | pnp_init_resources(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 496 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
| 497 | pnpacpi_allocated_resource, dev); |
| 498 | |
| 499 | if (ACPI_FAILURE(status)) { |
| 500 | if (status != AE_NOT_FOUND) |
| 501 | dev_err(&dev->dev, "can't evaluate _CRS: %d", status); |
| 502 | return -EPERM; |
| 503 | } |
| 504 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | } |
| 506 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 507 | static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 508 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 509 | struct acpi_resource_dma *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | { |
| 511 | int i; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 512 | unsigned char map = 0, flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 514 | if (p->channel_count == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 517 | for (i = 0; i < p->channel_count; i++) |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 518 | map |= 1 << p->channels[i]; |
Michael Karcher | 362ea08 | 2007-03-08 23:29:29 -0500 | [diff] [blame] | 519 | |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 520 | flags = dma_flags(dev, p->type, p->bus_master, p->transfer); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 521 | pnp_register_dma_resource(dev, option_flags, map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | } |
| 523 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 524 | static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 525 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 526 | struct acpi_resource_irq *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | { |
| 528 | int i; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 529 | pnp_irq_mask_t map; |
| 530 | unsigned char flags; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 531 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 532 | if (p->interrupt_count == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 535 | bitmap_zero(map.bits, PNP_IRQ_NR); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 536 | for (i = 0; i < p->interrupt_count; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | if (p->interrupts[i]) |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 538 | __set_bit(p->interrupts[i], map.bits); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 540 | flags = irq_flags(p->triggering, p->polarity, p->sharable); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 541 | pnp_register_irq_resource(dev, option_flags, &map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | } |
| 543 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 544 | static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 545 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 546 | struct acpi_resource_extended_irq *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | { |
| 548 | int i; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 549 | pnp_irq_mask_t map; |
| 550 | unsigned char flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 552 | if (p->interrupt_count == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 555 | bitmap_zero(map.bits, PNP_IRQ_NR); |
Bjorn Helgaas | fe2cf59 | 2008-06-27 16:57:12 -0600 | [diff] [blame] | 556 | for (i = 0; i < p->interrupt_count; i++) { |
| 557 | if (p->interrupts[i]) { |
| 558 | if (p->interrupts[i] < PNP_IRQ_NR) |
| 559 | __set_bit(p->interrupts[i], map.bits); |
| 560 | else |
| 561 | dev_err(&dev->dev, "ignoring IRQ %d option " |
| 562 | "(too large for %d entry bitmap)\n", |
| 563 | p->interrupts[i], PNP_IRQ_NR); |
| 564 | } |
| 565 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 567 | flags = irq_flags(p->triggering, p->polarity, p->sharable); |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 568 | pnp_register_irq_resource(dev, option_flags, &map, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 571 | static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 572 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 573 | struct acpi_resource_io *io) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 575 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 577 | if (io->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | return; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 579 | |
| 580 | if (io->io_decode == ACPI_DECODE_16) |
| 581 | flags = IORESOURCE_IO_16BIT_ADDR; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 582 | pnp_register_port_resource(dev, option_flags, io->minimum, io->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 583 | io->alignment, io->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | } |
| 585 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 586 | static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 587 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 588 | struct acpi_resource_fixed_io *io) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 590 | if (io->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | return; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 592 | |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 593 | pnp_register_port_resource(dev, option_flags, io->address, io->address, |
| 594 | 0, io->address_length, IORESOURCE_IO_FIXED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 597 | static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 598 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 599 | struct acpi_resource_memory24 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 601 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 603 | if (p->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 606 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
| 607 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 608 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 609 | p->alignment, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | } |
| 611 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 612 | static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 613 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 614 | struct acpi_resource_memory32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 616 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 618 | if (p->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 621 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
| 622 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 623 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 624 | p->alignment, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | } |
| 626 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 627 | static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 628 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 629 | struct acpi_resource_fixed_memory32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 631 | unsigned char flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 633 | if (p->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 636 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
| 637 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 638 | pnp_register_mem_resource(dev, option_flags, p->address, p->address, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 639 | 0, p->address_length, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 642 | static __init void pnpacpi_parse_address_option(struct pnp_dev *dev, |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 643 | unsigned int option_flags, |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 644 | struct acpi_resource *r) |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 645 | { |
| 646 | struct acpi_resource_address64 addr, *p = &addr; |
| 647 | acpi_status status; |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 648 | unsigned char flags = 0; |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 649 | |
| 650 | status = acpi_resource_to_address64(r, p); |
Bjorn Helgaas | 958a1fd | 2008-08-19 16:53:21 -0600 | [diff] [blame] | 651 | if (ACPI_FAILURE(status)) { |
| 652 | dev_warn(&dev->dev, "can't convert resource type %d\n", |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 653 | r->type); |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 654 | return; |
| 655 | } |
| 656 | |
| 657 | if (p->address_length == 0) |
| 658 | return; |
| 659 | |
| 660 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 661 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) |
| 662 | flags = IORESOURCE_MEM_WRITEABLE; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 663 | pnp_register_mem_resource(dev, option_flags, p->minimum, |
| 664 | p->minimum, 0, p->address_length, |
| 665 | flags); |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 666 | } else if (p->resource_type == ACPI_IO_RANGE) |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 667 | pnp_register_port_resource(dev, option_flags, p->minimum, |
| 668 | p->minimum, 0, p->address_length, |
Bjorn Helgaas | c227536 | 2008-06-27 16:57:11 -0600 | [diff] [blame] | 669 | IORESOURCE_IO_FIXED); |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 670 | } |
| 671 | |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 672 | static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, |
| 673 | unsigned int option_flags, |
| 674 | struct acpi_resource *r) |
| 675 | { |
| 676 | struct acpi_resource_extended_address64 *p = &r->data.ext_address64; |
| 677 | unsigned char flags = 0; |
| 678 | |
| 679 | if (p->address_length == 0) |
| 680 | return; |
| 681 | |
| 682 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
| 683 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) |
| 684 | flags = IORESOURCE_MEM_WRITEABLE; |
| 685 | pnp_register_mem_resource(dev, option_flags, p->minimum, |
| 686 | p->minimum, 0, p->address_length, |
| 687 | flags); |
| 688 | } else if (p->resource_type == ACPI_IO_RANGE) |
| 689 | pnp_register_port_resource(dev, option_flags, p->minimum, |
| 690 | p->minimum, 0, p->address_length, |
| 691 | IORESOURCE_IO_FIXED); |
| 692 | } |
| 693 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | struct acpipnp_parse_option_s { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | struct pnp_dev *dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 696 | unsigned int option_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | }; |
| 698 | |
Thomas Renninger | 2bb9a6b | 2008-02-06 01:40:03 -0800 | [diff] [blame] | 699 | static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, |
| 700 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | { |
Bjorn Helgaas | e2a1a6f | 2008-06-27 16:57:15 -0600 | [diff] [blame] | 702 | int priority; |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 703 | struct acpipnp_parse_option_s *parse_data = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | struct pnp_dev *dev = parse_data->dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 705 | unsigned int option_flags = parse_data->option_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 707 | switch (res->type) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 708 | case ACPI_RESOURCE_TYPE_IRQ: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 709 | pnpacpi_parse_irq_option(dev, option_flags, &res->data.irq); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 710 | break; |
| 711 | |
| 712 | case ACPI_RESOURCE_TYPE_DMA: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 713 | pnpacpi_parse_dma_option(dev, option_flags, &res->data.dma); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 714 | break; |
| 715 | |
| 716 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 717 | switch (res->data.start_dpf.compatibility_priority) { |
| 718 | case ACPI_GOOD_CONFIGURATION: |
| 719 | priority = PNP_RES_PRIORITY_PREFERRED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 721 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 722 | case ACPI_ACCEPTABLE_CONFIGURATION: |
| 723 | priority = PNP_RES_PRIORITY_ACCEPTABLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 725 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 726 | case ACPI_SUB_OPTIMAL_CONFIGURATION: |
| 727 | priority = PNP_RES_PRIORITY_FUNCTIONAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | default: |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 730 | priority = PNP_RES_PRIORITY_INVALID; |
| 731 | break; |
| 732 | } |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 733 | parse_data->option_flags = pnp_new_dependent_set(dev, priority); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 734 | break; |
| 735 | |
| 736 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 737 | parse_data->option_flags = 0; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 738 | break; |
| 739 | |
| 740 | case ACPI_RESOURCE_TYPE_IO: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 741 | pnpacpi_parse_port_option(dev, option_flags, &res->data.io); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 742 | break; |
| 743 | |
| 744 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 745 | pnpacpi_parse_fixed_port_option(dev, option_flags, |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 746 | &res->data.fixed_io); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 747 | break; |
| 748 | |
| 749 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 750 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 751 | break; |
| 752 | |
| 753 | case ACPI_RESOURCE_TYPE_MEMORY24: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 754 | pnpacpi_parse_mem24_option(dev, option_flags, |
| 755 | &res->data.memory24); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 756 | break; |
| 757 | |
| 758 | case ACPI_RESOURCE_TYPE_MEMORY32: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 759 | pnpacpi_parse_mem32_option(dev, option_flags, |
| 760 | &res->data.memory32); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 761 | break; |
| 762 | |
| 763 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 764 | pnpacpi_parse_fixed_mem32_option(dev, option_flags, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 765 | &res->data.fixed_memory32); |
| 766 | break; |
| 767 | |
| 768 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 769 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 770 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 771 | pnpacpi_parse_address_option(dev, option_flags, res); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 772 | break; |
| 773 | |
| 774 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 775 | pnpacpi_parse_ext_address_option(dev, option_flags, res); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 776 | break; |
| 777 | |
| 778 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 779 | pnpacpi_parse_ext_irq_option(dev, option_flags, |
Bjorn Helgaas | c1caf06 | 2008-04-28 16:34:04 -0600 | [diff] [blame] | 780 | &res->data.extended_irq); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 781 | break; |
| 782 | |
| 783 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
| 784 | break; |
| 785 | |
| 786 | default: |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 787 | dev_warn(&dev->dev, "unknown resource type %d in _PRS\n", |
| 788 | res->type); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 789 | return AE_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 791 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | return AE_OK; |
| 793 | } |
| 794 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 795 | int __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 797 | struct acpi_device *acpi_dev = dev->data; |
| 798 | acpi_handle handle = acpi_dev->handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | acpi_status status; |
| 800 | struct acpipnp_parse_option_s parse_data; |
| 801 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 802 | pnp_dbg(&dev->dev, "parse resource options\n"); |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 803 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | parse_data.dev = dev; |
Bjorn Helgaas | 1f32ca3 | 2008-06-27 16:57:17 -0600 | [diff] [blame] | 805 | parse_data.option_flags = 0; |
| 806 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 807 | status = acpi_walk_resources(handle, METHOD_NAME__PRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 808 | pnpacpi_option_resource, &parse_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 810 | if (ACPI_FAILURE(status)) { |
| 811 | if (status != AE_NOT_FOUND) |
| 812 | dev_err(&dev->dev, "can't evaluate _PRS: %d", status); |
| 813 | return -EPERM; |
| 814 | } |
| 815 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | } |
| 817 | |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 818 | static int pnpacpi_supported_resource(struct acpi_resource *res) |
| 819 | { |
| 820 | switch (res->type) { |
| 821 | case ACPI_RESOURCE_TYPE_IRQ: |
| 822 | case ACPI_RESOURCE_TYPE_DMA: |
| 823 | case ACPI_RESOURCE_TYPE_IO: |
| 824 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
| 825 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 826 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 827 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
| 828 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 829 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 830 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Bjorn Helgaas | 8cb24c8 | 2009-05-21 15:49:59 -0600 | [diff] [blame] | 831 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 832 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
| 833 | return 1; |
| 834 | } |
| 835 | return 0; |
| 836 | } |
| 837 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | /* |
| 839 | * Set resource |
| 840 | */ |
| 841 | static acpi_status pnpacpi_count_resources(struct acpi_resource *res, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 842 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | { |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 844 | int *res_cnt = data; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 845 | |
| 846 | if (pnpacpi_supported_resource(res)) |
| 847 | (*res_cnt)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | return AE_OK; |
| 849 | } |
| 850 | |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 851 | static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | { |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 853 | struct acpi_resource **resource = data; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 854 | |
| 855 | if (pnpacpi_supported_resource(res)) { |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 856 | (*resource)->type = res->type; |
Bjorn Helgaas | b5f2490b | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 857 | (*resource)->length = sizeof(struct acpi_resource); |
Bjorn Helgaas | 36d872a | 2008-06-09 16:52:06 -0700 | [diff] [blame] | 858 | if (res->type == ACPI_RESOURCE_TYPE_IRQ) |
| 859 | (*resource)->data.irq.descriptor_length = |
| 860 | res->data.irq.descriptor_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | (*resource)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | return AE_OK; |
| 865 | } |
| 866 | |
Bjorn Helgaas | cdef625 | 2008-04-28 16:34:03 -0600 | [diff] [blame] | 867 | int pnpacpi_build_resource_template(struct pnp_dev *dev, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 868 | struct acpi_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | { |
Bjorn Helgaas | c4da694 | 2009-11-17 17:05:14 -0700 | [diff] [blame] | 870 | struct acpi_device *acpi_dev = dev->data; |
| 871 | acpi_handle handle = acpi_dev->handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | struct acpi_resource *resource; |
| 873 | int res_cnt = 0; |
| 874 | acpi_status status; |
| 875 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 876 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 877 | pnpacpi_count_resources, &res_cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | if (ACPI_FAILURE(status)) { |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 879 | dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | return -EINVAL; |
| 881 | } |
| 882 | if (!res_cnt) |
| 883 | return -EINVAL; |
| 884 | buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; |
Robert P. J. Day | cd86128 | 2006-12-13 00:34:52 -0800 | [diff] [blame] | 885 | buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | if (!buffer->pointer) |
| 887 | return -ENOMEM; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 888 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | resource = (struct acpi_resource *)buffer->pointer; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 890 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 891 | pnpacpi_type_resources, &resource); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | if (ACPI_FAILURE(status)) { |
| 893 | kfree(buffer->pointer); |
Bjorn Helgaas | d152cf5 | 2008-04-28 16:34:39 -0600 | [diff] [blame] | 894 | dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | return -EINVAL; |
| 896 | } |
| 897 | /* resource will pointer the end resource now */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 898 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | |
| 900 | return 0; |
| 901 | } |
| 902 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 903 | static void pnpacpi_encode_irq(struct pnp_dev *dev, |
| 904 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 905 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 907 | struct acpi_resource_irq *irq = &resource->data.irq; |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 908 | int triggering, polarity, shareable; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 909 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 910 | if (!pnp_resource_enabled(p)) { |
| 911 | irq->interrupt_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 912 | pnp_dbg(&dev->dev, " encode irq (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 913 | p ? "disabled" : "missing"); |
| 914 | return; |
| 915 | } |
| 916 | |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 917 | decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable); |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 918 | irq->triggering = triggering; |
| 919 | irq->polarity = polarity; |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 920 | irq->sharable = shareable; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 921 | irq->interrupt_count = 1; |
| 922 | irq->interrupts[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 923 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 924 | 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] | 925 | (int) p->start, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 926 | triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge", |
| 927 | polarity == ACPI_ACTIVE_LOW ? "low" : "high", |
Bjorn Helgaas | 36d872a | 2008-06-09 16:52:06 -0700 | [diff] [blame] | 928 | irq->sharable == ACPI_SHARED ? "shared" : "exclusive", |
| 929 | irq->descriptor_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | } |
| 931 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 932 | static void pnpacpi_encode_ext_irq(struct pnp_dev *dev, |
| 933 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 934 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 936 | struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq; |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 937 | int triggering, polarity, shareable; |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 938 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 939 | if (!pnp_resource_enabled(p)) { |
| 940 | extended_irq->interrupt_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 941 | pnp_dbg(&dev->dev, " encode extended irq (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 942 | p ? "disabled" : "missing"); |
| 943 | return; |
| 944 | } |
| 945 | |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 946 | decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable); |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 947 | extended_irq->producer_consumer = ACPI_CONSUMER; |
| 948 | extended_irq->triggering = triggering; |
| 949 | extended_irq->polarity = polarity; |
Bjorn Helgaas | a993273 | 2008-06-09 16:52:05 -0700 | [diff] [blame] | 950 | extended_irq->sharable = shareable; |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 951 | extended_irq->interrupt_count = 1; |
| 952 | extended_irq->interrupts[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 953 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 954 | 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] | 955 | triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge", |
| 956 | polarity == ACPI_ACTIVE_LOW ? "low" : "high", |
| 957 | extended_irq->sharable == ACPI_SHARED ? "shared" : "exclusive"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | } |
| 959 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 960 | static void pnpacpi_encode_dma(struct pnp_dev *dev, |
| 961 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 962 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 964 | struct acpi_resource_dma *dma = &resource->data.dma; |
| 965 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 966 | if (!pnp_resource_enabled(p)) { |
| 967 | dma->channel_count = 0; |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 968 | pnp_dbg(&dev->dev, " encode dma (%s)\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 969 | p ? "disabled" : "missing"); |
| 970 | return; |
| 971 | } |
| 972 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 974 | switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 975 | case IORESOURCE_DMA_TYPEA: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 976 | dma->type = ACPI_TYPE_A; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 977 | break; |
| 978 | case IORESOURCE_DMA_TYPEB: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 979 | dma->type = ACPI_TYPE_B; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 980 | break; |
| 981 | case IORESOURCE_DMA_TYPEF: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 982 | dma->type = ACPI_TYPE_F; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 983 | break; |
| 984 | default: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 985 | dma->type = ACPI_COMPATIBILITY; |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 986 | } |
| 987 | |
| 988 | switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 989 | case IORESOURCE_DMA_8BIT: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 990 | dma->transfer = ACPI_TRANSFER_8; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 991 | break; |
| 992 | case IORESOURCE_DMA_8AND16BIT: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 993 | dma->transfer = ACPI_TRANSFER_8_16; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 994 | break; |
| 995 | default: |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 996 | dma->transfer = ACPI_TRANSFER_16; |
Vojtech Pavlik | ccc4c7b | 2006-04-07 20:00:27 +0200 | [diff] [blame] | 997 | } |
| 998 | |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 999 | dma->bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); |
| 1000 | dma->channel_count = 1; |
| 1001 | dma->channels[0] = p->start; |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1002 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 1003 | pnp_dbg(&dev->dev, " encode dma %d " |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1004 | "type %#x transfer %#x master %d\n", |
| 1005 | (int) p->start, dma->type, dma->transfer, dma->bus_master); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | } |
| 1007 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1008 | static void pnpacpi_encode_io(struct pnp_dev *dev, |
| 1009 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 1010 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 1012 | struct acpi_resource_io *io = &resource->data.io; |
| 1013 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 1014 | if (pnp_resource_enabled(p)) { |
| 1015 | /* Note: pnp_assign_port copies pnp_port->flags into p->flags */ |
Bjorn Helgaas | 08c9f26 | 2008-06-27 16:57:03 -0600 | [diff] [blame] | 1016 | io->io_decode = (p->flags & IORESOURCE_IO_16BIT_ADDR) ? |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 1017 | ACPI_DECODE_16 : ACPI_DECODE_10; |
| 1018 | io->minimum = p->start; |
| 1019 | io->maximum = p->end; |
| 1020 | io->alignment = 0; /* Correct? */ |
| 1021 | io->address_length = p->end - p->start + 1; |
| 1022 | } else { |
| 1023 | io->minimum = 0; |
| 1024 | io->address_length = 0; |
| 1025 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1026 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 1027 | 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] | 1028 | io->minimum + io->address_length - 1, io->io_decode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | } |
| 1030 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1031 | static void pnpacpi_encode_fixed_io(struct pnp_dev *dev, |
| 1032 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 1033 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 1035 | struct acpi_resource_fixed_io *fixed_io = &resource->data.fixed_io; |
| 1036 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 1037 | if (pnp_resource_enabled(p)) { |
| 1038 | fixed_io->address = p->start; |
| 1039 | fixed_io->address_length = p->end - p->start + 1; |
| 1040 | } else { |
| 1041 | fixed_io->address = 0; |
| 1042 | fixed_io->address_length = 0; |
| 1043 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1044 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 1045 | 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] | 1046 | fixed_io->address + fixed_io->address_length - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | } |
| 1048 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1049 | static void pnpacpi_encode_mem24(struct pnp_dev *dev, |
| 1050 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 1051 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 1053 | struct acpi_resource_memory24 *memory24 = &resource->data.memory24; |
| 1054 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 1055 | if (pnp_resource_enabled(p)) { |
| 1056 | /* Note: pnp_assign_mem copies pnp_mem->flags into p->flags */ |
| 1057 | memory24->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 1058 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 1059 | memory24->minimum = p->start; |
| 1060 | memory24->maximum = p->end; |
| 1061 | memory24->alignment = 0; |
| 1062 | memory24->address_length = p->end - p->start + 1; |
| 1063 | } else { |
| 1064 | memory24->minimum = 0; |
| 1065 | memory24->address_length = 0; |
| 1066 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1067 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 1068 | pnp_dbg(&dev->dev, " encode mem24 %#x-%#x write_protect %#x\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 1069 | memory24->minimum, |
| 1070 | memory24->minimum + memory24->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1071 | memory24->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1074 | static void pnpacpi_encode_mem32(struct pnp_dev *dev, |
| 1075 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 1076 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 1078 | struct acpi_resource_memory32 *memory32 = &resource->data.memory32; |
| 1079 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 1080 | if (pnp_resource_enabled(p)) { |
| 1081 | memory32->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 1082 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 1083 | memory32->minimum = p->start; |
| 1084 | memory32->maximum = p->end; |
| 1085 | memory32->alignment = 0; |
| 1086 | memory32->address_length = p->end - p->start + 1; |
| 1087 | } else { |
| 1088 | memory32->minimum = 0; |
| 1089 | memory32->alignment = 0; |
| 1090 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1091 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 1092 | pnp_dbg(&dev->dev, " encode mem32 %#x-%#x write_protect %#x\n", |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 1093 | memory32->minimum, |
| 1094 | memory32->minimum + memory32->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1095 | memory32->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | } |
| 1097 | |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1098 | static void pnpacpi_encode_fixed_mem32(struct pnp_dev *dev, |
| 1099 | struct acpi_resource *resource, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 1100 | struct resource *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | { |
Bjorn Helgaas | 9570a20 | 2008-04-28 16:34:00 -0600 | [diff] [blame] | 1102 | struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32; |
| 1103 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 1104 | if (pnp_resource_enabled(p)) { |
| 1105 | fixed_memory32->write_protect = |
| 1106 | p->flags & IORESOURCE_MEM_WRITEABLE ? |
| 1107 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
| 1108 | fixed_memory32->address = p->start; |
| 1109 | fixed_memory32->address_length = p->end - p->start + 1; |
| 1110 | } else { |
| 1111 | fixed_memory32->address = 0; |
| 1112 | fixed_memory32->address_length = 0; |
| 1113 | } |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1114 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 1115 | 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] | 1116 | fixed_memory32->address, |
| 1117 | fixed_memory32->address + fixed_memory32->address_length - 1, |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1118 | fixed_memory32->write_protect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | } |
| 1120 | |
Bjorn Helgaas | 4ab55d8 | 2008-04-28 16:34:06 -0600 | [diff] [blame] | 1121 | int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | { |
| 1123 | int i = 0; |
| 1124 | /* pnpacpi_build_resource_template allocates extra mem */ |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 1125 | int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1; |
Bjorn Helgaas | 4721a4cc | 2007-08-15 10:32:10 -0600 | [diff] [blame] | 1126 | struct acpi_resource *resource = buffer->pointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | int port = 0, irq = 0, dma = 0, mem = 0; |
| 1128 | |
Bjorn Helgaas | 2f53432 | 2008-08-19 16:53:47 -0600 | [diff] [blame] | 1129 | pnp_dbg(&dev->dev, "encode %d resources\n", res_cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | while (i < res_cnt) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 1131 | switch (resource->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 1132 | case ACPI_RESOURCE_TYPE_IRQ: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1133 | pnpacpi_encode_irq(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 1134 | pnp_get_resource(dev, IORESOURCE_IRQ, irq)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | irq++; |
| 1136 | break; |
| 1137 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 1138 | case ACPI_RESOURCE_TYPE_DMA: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1139 | pnpacpi_encode_dma(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 1140 | pnp_get_resource(dev, IORESOURCE_DMA, dma)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 1141 | dma++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 1143 | case ACPI_RESOURCE_TYPE_IO: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1144 | pnpacpi_encode_io(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 1145 | pnp_get_resource(dev, IORESOURCE_IO, port)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 1146 | port++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 1148 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1149 | pnpacpi_encode_fixed_io(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 1150 | pnp_get_resource(dev, IORESOURCE_IO, port)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 1151 | port++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 1153 | case ACPI_RESOURCE_TYPE_MEMORY24: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1154 | pnpacpi_encode_mem24(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 1155 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 1156 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 1158 | case ACPI_RESOURCE_TYPE_MEMORY32: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1159 | pnpacpi_encode_mem32(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 1160 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 1161 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 1163 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1164 | pnpacpi_encode_fixed_mem32(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 1165 | pnp_get_resource(dev, IORESOURCE_MEM, mem)); |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 1166 | mem++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 1168 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Bjorn Helgaas | 72dcc88 | 2008-04-28 16:34:07 -0600 | [diff] [blame] | 1169 | pnpacpi_encode_ext_irq(dev, resource, |
Bjorn Helgaas | 7e2cf31 | 2008-04-28 16:34:24 -0600 | [diff] [blame] | 1170 | pnp_get_resource(dev, IORESOURCE_IRQ, irq)); |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame] | 1171 | irq++; |
| 1172 | break; |
| 1173 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 1174 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 1175 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 1176 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 1177 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 1178 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 1179 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
| 1180 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
| 1181 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 1182 | default: /* other type */ |
Bjorn Helgaas | af11cb2 | 2008-04-28 16:34:12 -0600 | [diff] [blame] | 1183 | dev_warn(&dev->dev, "can't encode unknown resource " |
| 1184 | "type %d\n", resource->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | return -EINVAL; |
| 1186 | } |
Bjorn Helgaas | 1c6e7d0 | 2006-03-28 17:04:00 -0500 | [diff] [blame] | 1187 | resource++; |
| 1188 | i++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | } |
| 1190 | return 0; |
| 1191 | } |