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