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> |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/acpi.h> |
| 23 | #include <linux/pci.h> |
| 24 | #include "pnpacpi.h" |
| 25 | |
| 26 | #ifdef CONFIG_IA64 |
| 27 | #define valid_IRQ(i) (1) |
| 28 | #else |
| 29 | #define valid_IRQ(i) (((i) != 0) && ((i) != 2)) |
| 30 | #endif |
| 31 | |
| 32 | /* |
| 33 | * Allocated Resources |
| 34 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 35 | static int irq_flags(int triggering, int polarity) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { |
| 37 | int flag; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 38 | if (triggering == ACPI_LEVEL_SENSITIVE) { |
| 39 | if(polarity == ACPI_ACTIVE_LOW) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | flag = IORESOURCE_IRQ_LOWLEVEL; |
| 41 | else |
| 42 | flag = IORESOURCE_IRQ_HIGHLEVEL; |
| 43 | } |
| 44 | else { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 45 | if(polarity == ACPI_ACTIVE_LOW) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | flag = IORESOURCE_IRQ_LOWEDGE; |
| 47 | else |
| 48 | flag = IORESOURCE_IRQ_HIGHEDGE; |
| 49 | } |
| 50 | return flag; |
| 51 | } |
| 52 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 53 | static void decode_irq_flags(int flag, int *triggering, int *polarity) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | { |
| 55 | switch (flag) { |
| 56 | case IORESOURCE_IRQ_LOWLEVEL: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 57 | *triggering = ACPI_LEVEL_SENSITIVE; |
| 58 | *polarity = ACPI_ACTIVE_LOW; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | break; |
| 60 | case IORESOURCE_IRQ_HIGHLEVEL: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 61 | *triggering = ACPI_LEVEL_SENSITIVE; |
| 62 | *polarity = ACPI_ACTIVE_HIGH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | break; |
| 64 | case IORESOURCE_IRQ_LOWEDGE: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 65 | *triggering = ACPI_EDGE_SENSITIVE; |
| 66 | *polarity = ACPI_ACTIVE_LOW; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | break; |
| 68 | case IORESOURCE_IRQ_HIGHEDGE: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 69 | *triggering = ACPI_EDGE_SENSITIVE; |
| 70 | *polarity = ACPI_ACTIVE_HIGH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | break; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | static void |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 76 | pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 77 | int triggering, int polarity) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | { |
| 79 | int i = 0; |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 80 | int irq; |
| 81 | |
| 82 | if (!valid_IRQ(gsi)) |
| 83 | return; |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && |
| 86 | i < PNP_MAX_IRQ) |
| 87 | i++; |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 88 | if (i >= PNP_MAX_IRQ) |
| 89 | return; |
| 90 | |
| 91 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 92 | irq = acpi_register_gsi(gsi, triggering, polarity); |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 93 | if (irq < 0) { |
| 94 | res->irq_resource[i].flags |= IORESOURCE_DISABLED; |
| 95 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | } |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 97 | |
| 98 | res->irq_resource[i].start = irq; |
| 99 | res->irq_resource[i].end = irq; |
| 100 | pcibios_penalize_isa_irq(irq, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static void |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 104 | pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, u32 dma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | { |
| 106 | int i = 0; |
Adrian Bunk | 0dec63b | 2005-05-01 08:59:30 -0700 | [diff] [blame] | 107 | while (i < PNP_MAX_DMA && |
| 108 | !(res->dma_resource[i].flags & IORESOURCE_UNSET)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | i++; |
| 110 | if (i < PNP_MAX_DMA) { |
| 111 | res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag |
| 112 | if (dma == -1) { |
| 113 | res->dma_resource[i].flags |= IORESOURCE_DISABLED; |
| 114 | return; |
| 115 | } |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 116 | res->dma_resource[i].start = dma; |
| 117 | res->dma_resource[i].end = dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
| 121 | static void |
| 122 | pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res, |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 123 | u32 io, u32 len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | { |
| 125 | int i = 0; |
| 126 | while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && |
| 127 | i < PNP_MAX_PORT) |
| 128 | i++; |
| 129 | if (i < PNP_MAX_PORT) { |
| 130 | res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag |
| 131 | if (len <= 0 || (io + len -1) >= 0x10003) { |
| 132 | res->port_resource[i].flags |= IORESOURCE_DISABLED; |
| 133 | return; |
| 134 | } |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 135 | res->port_resource[i].start = io; |
| 136 | res->port_resource[i].end = io + len - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | |
| 140 | static void |
| 141 | pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res, |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 142 | u64 mem, u64 len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | { |
| 144 | int i = 0; |
| 145 | while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && |
| 146 | (i < PNP_MAX_MEM)) |
| 147 | i++; |
| 148 | if (i < PNP_MAX_MEM) { |
| 149 | res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag |
| 150 | if (len <= 0) { |
| 151 | res->mem_resource[i].flags |= IORESOURCE_DISABLED; |
| 152 | return; |
| 153 | } |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 154 | res->mem_resource[i].start = mem; |
| 155 | res->mem_resource[i].end = mem + len - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | } |
| 157 | } |
| 158 | |
| 159 | |
| 160 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, |
| 161 | void *data) |
| 162 | { |
| 163 | struct pnp_resource_table * res_table = (struct pnp_resource_table *)data; |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 164 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 166 | switch (res->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 167 | case ACPI_RESOURCE_TYPE_IRQ: |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 168 | /* |
| 169 | * Per spec, only one interrupt per descriptor is allowed in |
| 170 | * _CRS, but some firmware violates this, so parse them all. |
| 171 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 172 | for (i = 0; i < res->data.irq.interrupt_count; i++) { |
Bjorn Helgaas | dbed12d | 2005-09-03 00:37:56 -0400 | [diff] [blame] | 173 | pnpacpi_parse_allocated_irqresource(res_table, |
| 174 | res->data.irq.interrupts[i], |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 175 | res->data.irq.triggering, |
| 176 | res->data.irq.polarity); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | } |
| 178 | break; |
| 179 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 180 | case ACPI_RESOURCE_TYPE_DMA: |
| 181 | if (res->data.dma.channel_count > 0) |
| 182 | pnpacpi_parse_allocated_dmaresource(res_table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | res->data.dma.channels[0]); |
| 184 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 185 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 186 | case ACPI_RESOURCE_TYPE_IO: |
| 187 | pnpacpi_parse_allocated_ioresource(res_table, |
| 188 | res->data.io.minimum, |
| 189 | res->data.io.address_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 191 | |
| 192 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 193 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 194 | break; |
| 195 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 196 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
| 197 | pnpacpi_parse_allocated_ioresource(res_table, |
| 198 | res->data.fixed_io.address, |
| 199 | res->data.fixed_io.address_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 201 | |
| 202 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 203 | break; |
| 204 | |
| 205 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 206 | break; |
| 207 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 208 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 209 | pnpacpi_parse_allocated_memresource(res_table, |
| 210 | res->data.memory24.minimum, |
| 211 | res->data.memory24.address_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 213 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 214 | pnpacpi_parse_allocated_memresource(res_table, |
| 215 | res->data.memory32.minimum, |
| 216 | res->data.memory32.address_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 218 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
| 219 | pnpacpi_parse_allocated_memresource(res_table, |
| 220 | res->data.fixed_memory32.address, |
| 221 | res->data.fixed_memory32.address_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 223 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 224 | pnpacpi_parse_allocated_memresource(res_table, |
| 225 | res->data.address16.minimum, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | res->data.address16.address_length); |
| 227 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 228 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 229 | pnpacpi_parse_allocated_memresource(res_table, |
| 230 | res->data.address32.minimum, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | res->data.address32.address_length); |
| 232 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 233 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
| 234 | pnpacpi_parse_allocated_memresource(res_table, |
| 235 | res->data.address64.minimum, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | res->data.address64.address_length); |
| 237 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 238 | |
| 239 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 241 | |
| 242 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
| 243 | for (i = 0; i < res->data.extended_irq.interrupt_count; i++) { |
| 244 | pnpacpi_parse_allocated_irqresource(res_table, |
| 245 | res->data.extended_irq.interrupts[i], |
| 246 | res->data.extended_irq.triggering, |
| 247 | res->data.extended_irq.polarity); |
| 248 | } |
| 249 | break; |
| 250 | |
| 251 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
| 252 | break; |
| 253 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | default: |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 255 | pnp_warn("PnPACPI: unknown resource type %d", res->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | return AE_ERROR; |
| 257 | } |
| 258 | |
| 259 | return AE_OK; |
| 260 | } |
| 261 | |
| 262 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table * res) |
| 263 | { |
| 264 | /* Blank the resource table values */ |
| 265 | pnp_init_resource_table(res); |
| 266 | |
| 267 | return acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, res); |
| 268 | } |
| 269 | |
| 270 | static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_resource_dma *p) |
| 271 | { |
| 272 | int i; |
| 273 | struct pnp_dma * dma; |
| 274 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 275 | if (p->channel_count == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | return; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 277 | dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | if (!dma) |
| 279 | return; |
| 280 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 281 | for(i = 0; i < p->channel_count; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | dma->map |= 1 << p->channels[i]; |
| 283 | dma->flags = 0; |
| 284 | if (p->bus_master) |
| 285 | dma->flags |= IORESOURCE_DMA_MASTER; |
| 286 | switch (p->type) { |
| 287 | case ACPI_COMPATIBILITY: |
| 288 | dma->flags |= IORESOURCE_DMA_COMPATIBLE; |
| 289 | break; |
| 290 | case ACPI_TYPE_A: |
| 291 | dma->flags |= IORESOURCE_DMA_TYPEA; |
| 292 | break; |
| 293 | case ACPI_TYPE_B: |
| 294 | dma->flags |= IORESOURCE_DMA_TYPEB; |
| 295 | break; |
| 296 | case ACPI_TYPE_F: |
| 297 | dma->flags |= IORESOURCE_DMA_TYPEF; |
| 298 | break; |
| 299 | default: |
| 300 | /* Set a default value ? */ |
| 301 | dma->flags |= IORESOURCE_DMA_COMPATIBLE; |
| 302 | pnp_err("Invalid DMA type"); |
| 303 | } |
| 304 | switch (p->transfer) { |
| 305 | case ACPI_TRANSFER_8: |
| 306 | dma->flags |= IORESOURCE_DMA_8BIT; |
| 307 | break; |
| 308 | case ACPI_TRANSFER_8_16: |
| 309 | dma->flags |= IORESOURCE_DMA_8AND16BIT; |
| 310 | break; |
| 311 | case ACPI_TRANSFER_16: |
| 312 | dma->flags |= IORESOURCE_DMA_16BIT; |
| 313 | break; |
| 314 | default: |
| 315 | /* Set a default value ? */ |
| 316 | dma->flags |= IORESOURCE_DMA_8AND16BIT; |
| 317 | pnp_err("Invalid DMA transfer type"); |
| 318 | } |
| 319 | |
| 320 | pnp_register_dma_resource(option,dma); |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | |
| 325 | static void pnpacpi_parse_irq_option(struct pnp_option *option, |
| 326 | struct acpi_resource_irq *p) |
| 327 | { |
| 328 | int i; |
| 329 | struct pnp_irq * irq; |
| 330 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 331 | if (p->interrupt_count == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | return; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 333 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | if (!irq) |
| 335 | return; |
| 336 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 337 | for(i = 0; i < p->interrupt_count; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | if (p->interrupts[i]) |
| 339 | __set_bit(p->interrupts[i], irq->map); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 340 | irq->flags = irq_flags(p->triggering, p->polarity); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
| 342 | pnp_register_irq_resource(option, irq); |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 347 | struct acpi_resource_extended_irq *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | { |
| 349 | int i; |
| 350 | struct pnp_irq * irq; |
| 351 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 352 | if (p->interrupt_count == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | return; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 354 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | if (!irq) |
| 356 | return; |
| 357 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 358 | for(i = 0; i < p->interrupt_count; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | if (p->interrupts[i]) |
| 360 | __set_bit(p->interrupts[i], irq->map); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 361 | irq->flags = irq_flags(p->triggering, p->polarity); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
| 363 | pnp_register_irq_resource(option, irq); |
| 364 | return; |
| 365 | } |
| 366 | |
| 367 | static void |
| 368 | pnpacpi_parse_port_option(struct pnp_option *option, |
| 369 | struct acpi_resource_io *io) |
| 370 | { |
| 371 | struct pnp_port * port; |
| 372 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 373 | if (io->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | return; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 375 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | if (!port) |
| 377 | return; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 378 | port->min = io->minimum; |
| 379 | port->max = io->maximum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | port->align = io->alignment; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 381 | port->size = io->address_length; |
| 382 | port->flags = ACPI_DECODE_16 == io->io_decode ? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | PNP_PORT_FLAG_16BITADDR : 0; |
| 384 | pnp_register_port_resource(option,port); |
| 385 | return; |
| 386 | } |
| 387 | |
| 388 | static void |
| 389 | pnpacpi_parse_fixed_port_option(struct pnp_option *option, |
| 390 | struct acpi_resource_fixed_io *io) |
| 391 | { |
| 392 | struct pnp_port * port; |
| 393 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 394 | if (io->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | return; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 396 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | if (!port) |
| 398 | return; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 399 | port->min = port->max = io->address; |
| 400 | port->size = io->address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | port->align = 0; |
| 402 | port->flags = PNP_PORT_FLAG_FIXED; |
| 403 | pnp_register_port_resource(option,port); |
| 404 | return; |
| 405 | } |
| 406 | |
| 407 | static void |
| 408 | pnpacpi_parse_mem24_option(struct pnp_option *option, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 409 | struct acpi_resource_memory24 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | { |
| 411 | struct pnp_mem * mem; |
| 412 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 413 | if (p->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | return; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 415 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | if (!mem) |
| 417 | return; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 418 | mem->min = p->minimum; |
| 419 | mem->max = p->maximum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | mem->align = p->alignment; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 421 | mem->size = p->address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 423 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | IORESOURCE_MEM_WRITEABLE : 0; |
| 425 | |
| 426 | pnp_register_mem_resource(option,mem); |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | static void |
| 431 | pnpacpi_parse_mem32_option(struct pnp_option *option, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 432 | struct acpi_resource_memory32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | { |
| 434 | struct pnp_mem * mem; |
| 435 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 436 | if (p->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | return; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 438 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | if (!mem) |
| 440 | return; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 441 | mem->min = p->minimum; |
| 442 | mem->max = p->maximum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | mem->align = p->alignment; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 444 | mem->size = p->address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 446 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | IORESOURCE_MEM_WRITEABLE : 0; |
| 448 | |
| 449 | pnp_register_mem_resource(option,mem); |
| 450 | return; |
| 451 | } |
| 452 | |
| 453 | static void |
| 454 | pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 455 | struct acpi_resource_fixed_memory32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | { |
| 457 | struct pnp_mem * mem; |
| 458 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 459 | if (p->address_length == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | return; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 461 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | if (!mem) |
| 463 | return; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 464 | mem->min = mem->max = p->address; |
| 465 | mem->size = p->address_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | mem->align = 0; |
| 467 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 468 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | IORESOURCE_MEM_WRITEABLE : 0; |
| 470 | |
| 471 | pnp_register_mem_resource(option,mem); |
| 472 | return; |
| 473 | } |
| 474 | |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 475 | static void |
| 476 | pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) |
| 477 | { |
| 478 | struct acpi_resource_address64 addr, *p = &addr; |
| 479 | acpi_status status; |
| 480 | struct pnp_mem * mem; |
| 481 | struct pnp_port * port; |
| 482 | |
| 483 | status = acpi_resource_to_address64(r, p); |
| 484 | if (!ACPI_SUCCESS(status)) { |
Len Brown | ed03f43 | 2006-01-07 03:50:18 -0500 | [diff] [blame] | 485 | pnp_warn("PnPACPI: failed to convert resource type %d", r->type); |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 486 | return; |
| 487 | } |
| 488 | |
| 489 | if (p->address_length == 0) |
| 490 | return; |
| 491 | |
| 492 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
| 493 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
| 494 | if (!mem) |
| 495 | return; |
Len Brown | ed03f43 | 2006-01-07 03:50:18 -0500 | [diff] [blame] | 496 | mem->min = mem->max = p->minimum; |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 497 | mem->size = p->address_length; |
| 498 | mem->align = 0; |
Len Brown | ed03f43 | 2006-01-07 03:50:18 -0500 | [diff] [blame] | 499 | mem->flags = (p->info.mem.write_protect == |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 500 | ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; |
| 501 | pnp_register_mem_resource(option,mem); |
| 502 | } else if (p->resource_type == ACPI_IO_RANGE) { |
| 503 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
| 504 | if (!port) |
| 505 | return; |
Len Brown | ed03f43 | 2006-01-07 03:50:18 -0500 | [diff] [blame] | 506 | port->min = port->max = p->minimum; |
Bjorn Helgaas | 6f957ea | 2005-09-20 15:26:00 -0400 | [diff] [blame] | 507 | port->size = p->address_length; |
| 508 | port->align = 0; |
| 509 | port->flags = PNP_PORT_FLAG_FIXED; |
| 510 | pnp_register_port_resource(option,port); |
| 511 | } |
| 512 | } |
| 513 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | struct acpipnp_parse_option_s { |
| 515 | struct pnp_option *option; |
Matthieu Castet | b008b8d | 2005-03-25 12:03:15 -0500 | [diff] [blame] | 516 | struct pnp_option *option_independent; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | struct pnp_dev *dev; |
| 518 | }; |
| 519 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 520 | static acpi_status pnpacpi_option_resource(struct acpi_resource *res, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | void *data) |
| 522 | { |
| 523 | int priority = 0; |
| 524 | struct acpipnp_parse_option_s *parse_data = (struct acpipnp_parse_option_s *)data; |
| 525 | struct pnp_dev *dev = parse_data->dev; |
| 526 | struct pnp_option *option = parse_data->option; |
| 527 | |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 528 | switch (res->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 529 | case ACPI_RESOURCE_TYPE_IRQ: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | pnpacpi_parse_irq_option(option, &res->data.irq); |
| 531 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 532 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 533 | case ACPI_RESOURCE_TYPE_DMA: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | pnpacpi_parse_dma_option(option, &res->data.dma); |
| 535 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 536 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 537 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | switch (res->data.start_dpf.compatibility_priority) { |
| 539 | case ACPI_GOOD_CONFIGURATION: |
| 540 | priority = PNP_RES_PRIORITY_PREFERRED; |
| 541 | break; |
| 542 | |
| 543 | case ACPI_ACCEPTABLE_CONFIGURATION: |
| 544 | priority = PNP_RES_PRIORITY_ACCEPTABLE; |
| 545 | break; |
| 546 | |
| 547 | case ACPI_SUB_OPTIMAL_CONFIGURATION: |
| 548 | priority = PNP_RES_PRIORITY_FUNCTIONAL; |
| 549 | break; |
| 550 | default: |
| 551 | priority = PNP_RES_PRIORITY_INVALID; |
| 552 | break; |
| 553 | } |
| 554 | /* TBD: Considering performace/robustness bits */ |
| 555 | option = pnp_register_dependent_option(dev, priority); |
| 556 | if (!option) |
| 557 | return AE_ERROR; |
| 558 | parse_data->option = option; |
| 559 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 560 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 561 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
Matthieu Castet | b008b8d | 2005-03-25 12:03:15 -0500 | [diff] [blame] | 562 | /*only one EndDependentFn is allowed*/ |
| 563 | if (!parse_data->option_independent) { |
| 564 | pnp_warn("PnPACPI: more than one EndDependentFn"); |
| 565 | return AE_ERROR; |
| 566 | } |
| 567 | parse_data->option = parse_data->option_independent; |
| 568 | parse_data->option_independent = NULL; |
| 569 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 570 | |
| 571 | case ACPI_RESOURCE_TYPE_IO: |
| 572 | pnpacpi_parse_port_option(option, &res->data.io); |
| 573 | break; |
| 574 | |
| 575 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
| 576 | pnpacpi_parse_fixed_port_option(option, |
| 577 | &res->data.fixed_io); |
| 578 | break; |
| 579 | |
| 580 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 581 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 582 | break; |
| 583 | |
| 584 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 585 | pnpacpi_parse_mem24_option(option, &res->data.memory24); |
| 586 | break; |
| 587 | |
| 588 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 589 | pnpacpi_parse_mem32_option(option, &res->data.memory32); |
| 590 | break; |
| 591 | |
| 592 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
| 593 | pnpacpi_parse_fixed_mem32_option(option, |
| 594 | &res->data.fixed_memory32); |
| 595 | break; |
| 596 | |
| 597 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 598 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 599 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
| 600 | pnpacpi_parse_address_option(option, res); |
| 601 | break; |
| 602 | |
| 603 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
| 604 | break; |
| 605 | |
| 606 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
| 607 | pnpacpi_parse_ext_irq_option(option, |
| 608 | &res->data.extended_irq); |
| 609 | break; |
| 610 | |
| 611 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
| 612 | break; |
| 613 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | default: |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 615 | pnp_warn("PnPACPI: unknown resource type %d", res->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | return AE_ERROR; |
| 617 | } |
| 618 | |
| 619 | return AE_OK; |
| 620 | } |
| 621 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 622 | acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | struct pnp_dev *dev) |
| 624 | { |
| 625 | acpi_status status; |
| 626 | struct acpipnp_parse_option_s parse_data; |
| 627 | |
| 628 | parse_data.option = pnp_register_independent_option(dev); |
| 629 | if (!parse_data.option) |
| 630 | return AE_ERROR; |
Matthieu Castet | b008b8d | 2005-03-25 12:03:15 -0500 | [diff] [blame] | 631 | parse_data.option_independent = parse_data.option; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | parse_data.dev = dev; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 633 | status = acpi_walk_resources(handle, METHOD_NAME__PRS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | pnpacpi_option_resource, &parse_data); |
| 635 | |
| 636 | return status; |
| 637 | } |
| 638 | |
| 639 | /* |
| 640 | * Set resource |
| 641 | */ |
| 642 | static acpi_status pnpacpi_count_resources(struct acpi_resource *res, |
| 643 | void *data) |
| 644 | { |
| 645 | int *res_cnt = (int *)data; |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 646 | switch (res->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 647 | case ACPI_RESOURCE_TYPE_IRQ: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 648 | case ACPI_RESOURCE_TYPE_DMA: |
| 649 | case ACPI_RESOURCE_TYPE_IO: |
| 650 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
| 651 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 652 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 653 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 654 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 655 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 656 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 657 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | (*res_cnt) ++; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 659 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 660 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 661 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 662 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 663 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | default: |
| 665 | return AE_OK; |
| 666 | } |
| 667 | return AE_OK; |
| 668 | } |
| 669 | |
| 670 | static acpi_status pnpacpi_type_resources(struct acpi_resource *res, |
| 671 | void *data) |
| 672 | { |
| 673 | struct acpi_resource **resource = (struct acpi_resource **)data; |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 674 | switch (res->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 675 | case ACPI_RESOURCE_TYPE_IRQ: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 676 | case ACPI_RESOURCE_TYPE_DMA: |
| 677 | case ACPI_RESOURCE_TYPE_IO: |
| 678 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
| 679 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 680 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 681 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 682 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 683 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 684 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 685 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 686 | (*resource)->type = res->type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | (*resource)++; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 688 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 689 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 690 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 691 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 692 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | default: |
| 694 | return AE_OK; |
| 695 | } |
| 696 | |
| 697 | return AE_OK; |
| 698 | } |
| 699 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 700 | int pnpacpi_build_resource_template(acpi_handle handle, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | struct acpi_buffer *buffer) |
| 702 | { |
| 703 | struct acpi_resource *resource; |
| 704 | int res_cnt = 0; |
| 705 | acpi_status status; |
| 706 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 707 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | pnpacpi_count_resources, &res_cnt); |
| 709 | if (ACPI_FAILURE(status)) { |
| 710 | pnp_err("Evaluate _CRS failed"); |
| 711 | return -EINVAL; |
| 712 | } |
| 713 | if (!res_cnt) |
| 714 | return -EINVAL; |
| 715 | buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; |
Bjorn Helgaas | a2822e7 | 2005-09-06 15:16:51 -0700 | [diff] [blame] | 716 | buffer->pointer = kcalloc(1, buffer->length - 1, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | if (!buffer->pointer) |
| 718 | return -ENOMEM; |
| 719 | pnp_dbg("Res cnt %d", res_cnt); |
| 720 | resource = (struct acpi_resource *)buffer->pointer; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 721 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | pnpacpi_type_resources, &resource); |
| 723 | if (ACPI_FAILURE(status)) { |
| 724 | kfree(buffer->pointer); |
| 725 | pnp_err("Evaluate _CRS failed"); |
| 726 | return -EINVAL; |
| 727 | } |
| 728 | /* resource will pointer the end resource now */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 729 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | |
| 731 | return 0; |
| 732 | } |
| 733 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 734 | static void pnpacpi_encode_irq(struct acpi_resource *resource, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | struct resource *p) |
| 736 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 737 | int triggering, polarity; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 739 | decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, |
| 740 | &polarity); |
| 741 | resource->type = ACPI_RESOURCE_TYPE_IRQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | resource->length = sizeof(struct acpi_resource); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 743 | resource->data.irq.triggering = triggering; |
| 744 | resource->data.irq.polarity = polarity; |
| 745 | if (triggering == ACPI_EDGE_SENSITIVE) |
| 746 | resource->data.irq.sharable = ACPI_EXCLUSIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | else |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 748 | resource->data.irq.sharable = ACPI_SHARED; |
| 749 | resource->data.irq.interrupt_count = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | resource->data.irq.interrupts[0] = p->start; |
| 751 | } |
| 752 | |
| 753 | static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, |
| 754 | struct resource *p) |
| 755 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 756 | int triggering, polarity; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 758 | decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, |
| 759 | &polarity); |
| 760 | resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | resource->length = sizeof(struct acpi_resource); |
| 762 | resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 763 | resource->data.extended_irq.triggering = triggering; |
| 764 | resource->data.extended_irq.polarity = polarity; |
| 765 | if (triggering == ACPI_EDGE_SENSITIVE) |
| 766 | resource->data.irq.sharable = ACPI_EXCLUSIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | else |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 768 | resource->data.irq.sharable = ACPI_SHARED; |
| 769 | resource->data.extended_irq.interrupt_count = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | resource->data.extended_irq.interrupts[0] = p->start; |
| 771 | } |
| 772 | |
| 773 | static void pnpacpi_encode_dma(struct acpi_resource *resource, |
| 774 | struct resource *p) |
| 775 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 776 | resource->type = ACPI_RESOURCE_TYPE_DMA; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | resource->length = sizeof(struct acpi_resource); |
| 778 | /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ |
| 779 | if (p->flags & IORESOURCE_DMA_COMPATIBLE) |
| 780 | resource->data.dma.type = ACPI_COMPATIBILITY; |
| 781 | else if (p->flags & IORESOURCE_DMA_TYPEA) |
| 782 | resource->data.dma.type = ACPI_TYPE_A; |
| 783 | else if (p->flags & IORESOURCE_DMA_TYPEB) |
| 784 | resource->data.dma.type = ACPI_TYPE_B; |
| 785 | else if (p->flags & IORESOURCE_DMA_TYPEF) |
| 786 | resource->data.dma.type = ACPI_TYPE_F; |
| 787 | if (p->flags & IORESOURCE_DMA_8BIT) |
| 788 | resource->data.dma.transfer = ACPI_TRANSFER_8; |
| 789 | else if (p->flags & IORESOURCE_DMA_8AND16BIT) |
| 790 | resource->data.dma.transfer = ACPI_TRANSFER_8_16; |
| 791 | else if (p->flags & IORESOURCE_DMA_16BIT) |
| 792 | resource->data.dma.transfer = ACPI_TRANSFER_16; |
| 793 | resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 794 | resource->data.dma.channel_count = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 795 | resource->data.dma.channels[0] = p->start; |
| 796 | } |
| 797 | |
| 798 | static void pnpacpi_encode_io(struct acpi_resource *resource, |
| 799 | struct resource *p) |
| 800 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 801 | resource->type = ACPI_RESOURCE_TYPE_IO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | resource->length = sizeof(struct acpi_resource); |
| 803 | /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ |
| 804 | resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 805 | ACPI_DECODE_16 : ACPI_DECODE_10; |
| 806 | resource->data.io.minimum = p->start; |
| 807 | resource->data.io.maximum = p->end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | resource->data.io.alignment = 0; /* Correct? */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 809 | resource->data.io.address_length = p->end - p->start + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, |
| 813 | struct resource *p) |
| 814 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 815 | resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | resource->length = sizeof(struct acpi_resource); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 817 | resource->data.fixed_io.address = p->start; |
| 818 | resource->data.fixed_io.address_length = p->end - p->start + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | static void pnpacpi_encode_mem24(struct acpi_resource *resource, |
| 822 | struct resource *p) |
| 823 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 824 | resource->type = ACPI_RESOURCE_TYPE_MEMORY24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | resource->length = sizeof(struct acpi_resource); |
| 826 | /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 827 | resource->data.memory24.write_protect = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
| 829 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 830 | resource->data.memory24.minimum = p->start; |
| 831 | resource->data.memory24.maximum = p->end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | resource->data.memory24.alignment = 0; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 833 | resource->data.memory24.address_length = p->end - p->start + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | static void pnpacpi_encode_mem32(struct acpi_resource *resource, |
| 837 | struct resource *p) |
| 838 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 839 | resource->type = ACPI_RESOURCE_TYPE_MEMORY32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | resource->length = sizeof(struct acpi_resource); |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 841 | resource->data.memory32.write_protect = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
| 843 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 844 | resource->data.memory32.minimum = p->start; |
| 845 | resource->data.memory32.maximum = p->end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | resource->data.memory32.alignment = 0; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 847 | resource->data.memory32.address_length = p->end - p->start + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | } |
| 849 | |
| 850 | static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, |
| 851 | struct resource *p) |
| 852 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 853 | resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | resource->length = sizeof(struct acpi_resource); |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 855 | resource->data.fixed_memory32.write_protect = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
| 857 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 858 | resource->data.fixed_memory32.address = p->start; |
| 859 | resource->data.fixed_memory32.address_length = p->end - p->start + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | } |
| 861 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 862 | int pnpacpi_encode_resources(struct pnp_resource_table *res_table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | struct acpi_buffer *buffer) |
| 864 | { |
| 865 | int i = 0; |
| 866 | /* pnpacpi_build_resource_template allocates extra mem */ |
| 867 | int res_cnt = (buffer->length - 1)/sizeof(struct acpi_resource) - 1; |
| 868 | struct acpi_resource *resource = (struct acpi_resource*)buffer->pointer; |
| 869 | int port = 0, irq = 0, dma = 0, mem = 0; |
| 870 | |
| 871 | pnp_dbg("res cnt %d", res_cnt); |
| 872 | while (i < res_cnt) { |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 873 | switch(resource->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 874 | case ACPI_RESOURCE_TYPE_IRQ: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | pnp_dbg("Encode irq"); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 876 | pnpacpi_encode_irq(resource, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | &res_table->irq_resource[irq]); |
| 878 | irq++; |
| 879 | break; |
| 880 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 881 | case ACPI_RESOURCE_TYPE_DMA: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | pnp_dbg("Encode dma"); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 883 | pnpacpi_encode_dma(resource, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | &res_table->dma_resource[dma]); |
| 885 | dma ++; |
| 886 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 887 | case ACPI_RESOURCE_TYPE_IO: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | pnp_dbg("Encode io"); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 889 | pnpacpi_encode_io(resource, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | &res_table->port_resource[port]); |
| 891 | port ++; |
| 892 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 893 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | pnp_dbg("Encode fixed io"); |
| 895 | pnpacpi_encode_fixed_io(resource, |
| 896 | &res_table->port_resource[port]); |
| 897 | port ++; |
| 898 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 899 | case ACPI_RESOURCE_TYPE_MEMORY24: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | pnp_dbg("Encode mem24"); |
| 901 | pnpacpi_encode_mem24(resource, |
| 902 | &res_table->mem_resource[mem]); |
| 903 | mem ++; |
| 904 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 905 | case ACPI_RESOURCE_TYPE_MEMORY32: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | pnp_dbg("Encode mem32"); |
| 907 | pnpacpi_encode_mem32(resource, |
| 908 | &res_table->mem_resource[mem]); |
| 909 | mem ++; |
| 910 | break; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 911 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | pnp_dbg("Encode fixed mem32"); |
| 913 | pnpacpi_encode_fixed_mem32(resource, |
| 914 | &res_table->mem_resource[mem]); |
| 915 | mem ++; |
| 916 | break; |
Len Brown | 0af5853 | 2006-01-20 01:11:37 -0500 | [diff] [blame^] | 917 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
| 918 | pnp_dbg("Encode ext irq"); |
| 919 | pnpacpi_encode_ext_irq(resource, |
| 920 | &res_table->irq_resource[irq]); |
| 921 | irq++; |
| 922 | break; |
| 923 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
| 924 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
| 925 | case ACPI_RESOURCE_TYPE_VENDOR: |
| 926 | case ACPI_RESOURCE_TYPE_END_TAG: |
| 927 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
| 928 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
| 929 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
| 930 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
| 931 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | default: /* other type */ |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 933 | pnp_warn("unknown resource type %d", resource->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | return -EINVAL; |
| 935 | } |
| 936 | resource ++; |
| 937 | i ++; |
| 938 | } |
| 939 | return 0; |
| 940 | } |