diff options
Diffstat (limited to 'drivers/pnp/pnpacpi/rsparser.c')
-rw-r--r-- | drivers/pnp/pnpacpi/rsparser.c | 441 |
1 files changed, 219 insertions, 222 deletions
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 118ac9779b3c..ce5027feb3da 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -40,8 +40,7 @@ static int irq_flags(int triggering, int polarity) | |||
40 | flag = IORESOURCE_IRQ_LOWLEVEL; | 40 | flag = IORESOURCE_IRQ_LOWLEVEL; |
41 | else | 41 | else |
42 | flag = IORESOURCE_IRQ_HIGHLEVEL; | 42 | flag = IORESOURCE_IRQ_HIGHLEVEL; |
43 | } | 43 | } else { |
44 | else { | ||
45 | if (polarity == ACPI_ACTIVE_LOW) | 44 | if (polarity == ACPI_ACTIVE_LOW) |
46 | flag = IORESOURCE_IRQ_LOWEDGE; | 45 | flag = IORESOURCE_IRQ_LOWEDGE; |
47 | else | 46 | else |
@@ -72,9 +71,9 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity) | |||
72 | } | 71 | } |
73 | } | 72 | } |
74 | 73 | ||
75 | static void | 74 | static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, |
76 | pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, | 75 | u32 gsi, int triggering, |
77 | int triggering, int polarity, int shareable) | 76 | int polarity, int shareable) |
78 | { | 77 | { |
79 | int i = 0; | 78 | int i = 0; |
80 | int irq; | 79 | int irq; |
@@ -83,12 +82,12 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, | |||
83 | return; | 82 | return; |
84 | 83 | ||
85 | while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && | 84 | while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && |
86 | i < PNP_MAX_IRQ) | 85 | i < PNP_MAX_IRQ) |
87 | i++; | 86 | i++; |
88 | if (i >= PNP_MAX_IRQ) | 87 | if (i >= PNP_MAX_IRQ) |
89 | return; | 88 | return; |
90 | 89 | ||
91 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag | 90 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag |
92 | res->irq_resource[i].flags |= irq_flags(triggering, polarity); | 91 | res->irq_resource[i].flags |= irq_flags(triggering, polarity); |
93 | irq = acpi_register_gsi(gsi, triggering, polarity); | 92 | irq = acpi_register_gsi(gsi, triggering, polarity); |
94 | if (irq < 0) { | 93 | if (irq < 0) { |
@@ -147,17 +146,19 @@ static int dma_flags(int type, int bus_master, int transfer) | |||
147 | return flags; | 146 | return flags; |
148 | } | 147 | } |
149 | 148 | ||
150 | static void | 149 | static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, |
151 | pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma, | 150 | u32 dma, int type, |
152 | int type, int bus_master, int transfer) | 151 | int bus_master, int transfer) |
153 | { | 152 | { |
154 | int i = 0; | 153 | int i = 0; |
154 | |||
155 | while (i < PNP_MAX_DMA && | 155 | while (i < PNP_MAX_DMA && |
156 | !(res->dma_resource[i].flags & IORESOURCE_UNSET)) | 156 | !(res->dma_resource[i].flags & IORESOURCE_UNSET)) |
157 | i++; | 157 | i++; |
158 | if (i < PNP_MAX_DMA) { | 158 | if (i < PNP_MAX_DMA) { |
159 | res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag | 159 | res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag |
160 | res->dma_resource[i].flags |= dma_flags(type, bus_master, transfer); | 160 | res->dma_resource[i].flags |= |
161 | dma_flags(type, bus_master, transfer); | ||
161 | if (dma == -1) { | 162 | if (dma == -1) { |
162 | res->dma_resource[i].flags |= IORESOURCE_DISABLED; | 163 | res->dma_resource[i].flags |= IORESOURCE_DISABLED; |
163 | return; | 164 | return; |
@@ -167,19 +168,19 @@ pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma, | |||
167 | } | 168 | } |
168 | } | 169 | } |
169 | 170 | ||
170 | static void | 171 | static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, |
171 | pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, | 172 | u64 io, u64 len, int io_decode) |
172 | u64 io, u64 len, int io_decode) | ||
173 | { | 173 | { |
174 | int i = 0; | 174 | int i = 0; |
175 | |||
175 | while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && | 176 | while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && |
176 | i < PNP_MAX_PORT) | 177 | i < PNP_MAX_PORT) |
177 | i++; | 178 | i++; |
178 | if (i < PNP_MAX_PORT) { | 179 | if (i < PNP_MAX_PORT) { |
179 | res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag | 180 | res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag |
180 | if (io_decode == ACPI_DECODE_16) | 181 | if (io_decode == ACPI_DECODE_16) |
181 | res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR; | 182 | res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR; |
182 | if (len <= 0 || (io + len -1) >= 0x10003) { | 183 | if (len <= 0 || (io + len - 1) >= 0x10003) { |
183 | res->port_resource[i].flags |= IORESOURCE_DISABLED; | 184 | res->port_resource[i].flags |= IORESOURCE_DISABLED; |
184 | return; | 185 | return; |
185 | } | 186 | } |
@@ -188,21 +189,22 @@ pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, | |||
188 | } | 189 | } |
189 | } | 190 | } |
190 | 191 | ||
191 | static void | 192 | static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, |
192 | pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, | 193 | u64 mem, u64 len, |
193 | u64 mem, u64 len, int write_protect) | 194 | int write_protect) |
194 | { | 195 | { |
195 | int i = 0; | 196 | int i = 0; |
197 | |||
196 | while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && | 198 | while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && |
197 | (i < PNP_MAX_MEM)) | 199 | (i < PNP_MAX_MEM)) |
198 | i++; | 200 | i++; |
199 | if (i < PNP_MAX_MEM) { | 201 | if (i < PNP_MAX_MEM) { |
200 | res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag | 202 | res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag |
201 | if (len <= 0) { | 203 | if (len <= 0) { |
202 | res->mem_resource[i].flags |= IORESOURCE_DISABLED; | 204 | res->mem_resource[i].flags |= IORESOURCE_DISABLED; |
203 | return; | 205 | return; |
204 | } | 206 | } |
205 | if(write_protect == ACPI_READ_WRITE_MEMORY) | 207 | if (write_protect == ACPI_READ_WRITE_MEMORY) |
206 | res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE; | 208 | res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE; |
207 | 209 | ||
208 | res->mem_resource[i].start = mem; | 210 | res->mem_resource[i].start = mem; |
@@ -210,9 +212,8 @@ pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, | |||
210 | } | 212 | } |
211 | } | 213 | } |
212 | 214 | ||
213 | static void | 215 | static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, |
214 | pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, | 216 | struct acpi_resource *res) |
215 | struct acpi_resource *res) | ||
216 | { | 217 | { |
217 | struct acpi_resource_address64 addr, *p = &addr; | 218 | struct acpi_resource_address64 addr, *p = &addr; |
218 | acpi_status status; | 219 | acpi_status status; |
@@ -220,7 +221,7 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, | |||
220 | status = acpi_resource_to_address64(res, p); | 221 | status = acpi_resource_to_address64(res, p); |
221 | if (!ACPI_SUCCESS(status)) { | 222 | if (!ACPI_SUCCESS(status)) { |
222 | pnp_warn("PnPACPI: failed to convert resource type %d", | 223 | pnp_warn("PnPACPI: failed to convert resource type %d", |
223 | res->type); | 224 | res->type); |
224 | return; | 225 | return; |
225 | } | 226 | } |
226 | 227 | ||
@@ -229,17 +230,20 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, | |||
229 | 230 | ||
230 | if (p->resource_type == ACPI_MEMORY_RANGE) | 231 | if (p->resource_type == ACPI_MEMORY_RANGE) |
231 | pnpacpi_parse_allocated_memresource(res_table, | 232 | pnpacpi_parse_allocated_memresource(res_table, |
232 | p->minimum, p->address_length, p->info.mem.write_protect); | 233 | p->minimum, p->address_length, |
234 | p->info.mem.write_protect); | ||
233 | else if (p->resource_type == ACPI_IO_RANGE) | 235 | else if (p->resource_type == ACPI_IO_RANGE) |
234 | pnpacpi_parse_allocated_ioresource(res_table, | 236 | pnpacpi_parse_allocated_ioresource(res_table, |
235 | p->minimum, p->address_length, | 237 | p->minimum, p->address_length, |
236 | p->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16); | 238 | p->granularity == 0xfff ? ACPI_DECODE_10 : |
239 | ACPI_DECODE_16); | ||
237 | } | 240 | } |
238 | 241 | ||
239 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | 242 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, |
240 | void *data) | 243 | void *data) |
241 | { | 244 | { |
242 | struct pnp_resource_table *res_table = (struct pnp_resource_table *)data; | 245 | struct pnp_resource_table *res_table = |
246 | (struct pnp_resource_table *)data; | ||
243 | int i; | 247 | int i; |
244 | 248 | ||
245 | switch (res->type) { | 249 | switch (res->type) { |
@@ -260,17 +264,17 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
260 | case ACPI_RESOURCE_TYPE_DMA: | 264 | case ACPI_RESOURCE_TYPE_DMA: |
261 | if (res->data.dma.channel_count > 0) | 265 | if (res->data.dma.channel_count > 0) |
262 | pnpacpi_parse_allocated_dmaresource(res_table, | 266 | pnpacpi_parse_allocated_dmaresource(res_table, |
263 | res->data.dma.channels[0], | 267 | res->data.dma.channels[0], |
264 | res->data.dma.type, | 268 | res->data.dma.type, |
265 | res->data.dma.bus_master, | 269 | res->data.dma.bus_master, |
266 | res->data.dma.transfer); | 270 | res->data.dma.transfer); |
267 | break; | 271 | break; |
268 | 272 | ||
269 | case ACPI_RESOURCE_TYPE_IO: | 273 | case ACPI_RESOURCE_TYPE_IO: |
270 | pnpacpi_parse_allocated_ioresource(res_table, | 274 | pnpacpi_parse_allocated_ioresource(res_table, |
271 | res->data.io.minimum, | 275 | res->data.io.minimum, |
272 | res->data.io.address_length, | 276 | res->data.io.address_length, |
273 | res->data.io.io_decode); | 277 | res->data.io.io_decode); |
274 | break; | 278 | break; |
275 | 279 | ||
276 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 280 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
@@ -279,9 +283,9 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
279 | 283 | ||
280 | case ACPI_RESOURCE_TYPE_FIXED_IO: | 284 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
281 | pnpacpi_parse_allocated_ioresource(res_table, | 285 | pnpacpi_parse_allocated_ioresource(res_table, |
282 | res->data.fixed_io.address, | 286 | res->data.fixed_io.address, |
283 | res->data.fixed_io.address_length, | 287 | res->data.fixed_io.address_length, |
284 | ACPI_DECODE_10); | 288 | ACPI_DECODE_10); |
285 | break; | 289 | break; |
286 | 290 | ||
287 | case ACPI_RESOURCE_TYPE_VENDOR: | 291 | case ACPI_RESOURCE_TYPE_VENDOR: |
@@ -292,21 +296,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
292 | 296 | ||
293 | case ACPI_RESOURCE_TYPE_MEMORY24: | 297 | case ACPI_RESOURCE_TYPE_MEMORY24: |
294 | pnpacpi_parse_allocated_memresource(res_table, | 298 | pnpacpi_parse_allocated_memresource(res_table, |
295 | res->data.memory24.minimum, | 299 | res->data.memory24.minimum, |
296 | res->data.memory24.address_length, | 300 | res->data.memory24.address_length, |
297 | res->data.memory24.write_protect); | 301 | res->data.memory24.write_protect); |
298 | break; | 302 | break; |
299 | case ACPI_RESOURCE_TYPE_MEMORY32: | 303 | case ACPI_RESOURCE_TYPE_MEMORY32: |
300 | pnpacpi_parse_allocated_memresource(res_table, | 304 | pnpacpi_parse_allocated_memresource(res_table, |
301 | res->data.memory32.minimum, | 305 | res->data.memory32.minimum, |
302 | res->data.memory32.address_length, | 306 | res->data.memory32.address_length, |
303 | res->data.memory32.write_protect); | 307 | res->data.memory32.write_protect); |
304 | break; | 308 | break; |
305 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 309 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
306 | pnpacpi_parse_allocated_memresource(res_table, | 310 | pnpacpi_parse_allocated_memresource(res_table, |
307 | res->data.fixed_memory32.address, | 311 | res->data.fixed_memory32.address, |
308 | res->data.fixed_memory32.address_length, | 312 | res->data.fixed_memory32.address_length, |
309 | res->data.fixed_memory32.write_protect); | 313 | res->data.fixed_memory32.write_protect); |
310 | break; | 314 | break; |
311 | case ACPI_RESOURCE_TYPE_ADDRESS16: | 315 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
312 | case ACPI_RESOURCE_TYPE_ADDRESS32: | 316 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
@@ -343,18 +347,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
343 | return AE_OK; | 347 | return AE_OK; |
344 | } | 348 | } |
345 | 349 | ||
346 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table *res) | 350 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, |
351 | struct pnp_resource_table * res) | ||
347 | { | 352 | { |
348 | /* Blank the resource table values */ | 353 | /* Blank the resource table values */ |
349 | pnp_init_resource_table(res); | 354 | pnp_init_resource_table(res); |
350 | 355 | ||
351 | return acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, res); | 356 | return acpi_walk_resources(handle, METHOD_NAME__CRS, |
357 | pnpacpi_allocated_resource, res); | ||
352 | } | 358 | } |
353 | 359 | ||
354 | static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_resource_dma *p) | 360 | static void pnpacpi_parse_dma_option(struct pnp_option *option, |
361 | struct acpi_resource_dma *p) | ||
355 | { | 362 | { |
356 | int i; | 363 | int i; |
357 | struct pnp_dma * dma; | 364 | struct pnp_dma *dma; |
358 | 365 | ||
359 | if (p->channel_count == 0) | 366 | if (p->channel_count == 0) |
360 | return; | 367 | return; |
@@ -362,18 +369,16 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso | |||
362 | if (!dma) | 369 | if (!dma) |
363 | return; | 370 | return; |
364 | 371 | ||
365 | for(i = 0; i < p->channel_count; i++) | 372 | for (i = 0; i < p->channel_count; i++) |
366 | dma->map |= 1 << p->channels[i]; | 373 | dma->map |= 1 << p->channels[i]; |
367 | 374 | ||
368 | dma->flags = dma_flags(p->type, p->bus_master, p->transfer); | 375 | dma->flags = dma_flags(p->type, p->bus_master, p->transfer); |
369 | 376 | ||
370 | pnp_register_dma_resource(option, dma); | 377 | pnp_register_dma_resource(option, dma); |
371 | return; | ||
372 | } | 378 | } |
373 | 379 | ||
374 | |||
375 | static void pnpacpi_parse_irq_option(struct pnp_option *option, | 380 | static void pnpacpi_parse_irq_option(struct pnp_option *option, |
376 | struct acpi_resource_irq *p) | 381 | struct acpi_resource_irq *p) |
377 | { | 382 | { |
378 | int i; | 383 | int i; |
379 | struct pnp_irq *irq; | 384 | struct pnp_irq *irq; |
@@ -384,17 +389,16 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option, | |||
384 | if (!irq) | 389 | if (!irq) |
385 | return; | 390 | return; |
386 | 391 | ||
387 | for(i = 0; i < p->interrupt_count; i++) | 392 | for (i = 0; i < p->interrupt_count; i++) |
388 | if (p->interrupts[i]) | 393 | if (p->interrupts[i]) |
389 | __set_bit(p->interrupts[i], irq->map); | 394 | __set_bit(p->interrupts[i], irq->map); |
390 | irq->flags = irq_flags(p->triggering, p->polarity); | 395 | irq->flags = irq_flags(p->triggering, p->polarity); |
391 | 396 | ||
392 | pnp_register_irq_resource(option, irq); | 397 | pnp_register_irq_resource(option, irq); |
393 | return; | ||
394 | } | 398 | } |
395 | 399 | ||
396 | static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, | 400 | static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, |
397 | struct acpi_resource_extended_irq *p) | 401 | struct acpi_resource_extended_irq *p) |
398 | { | 402 | { |
399 | int i; | 403 | int i; |
400 | struct pnp_irq *irq; | 404 | struct pnp_irq *irq; |
@@ -405,18 +409,16 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, | |||
405 | if (!irq) | 409 | if (!irq) |
406 | return; | 410 | return; |
407 | 411 | ||
408 | for(i = 0; i < p->interrupt_count; i++) | 412 | for (i = 0; i < p->interrupt_count; i++) |
409 | if (p->interrupts[i]) | 413 | if (p->interrupts[i]) |
410 | __set_bit(p->interrupts[i], irq->map); | 414 | __set_bit(p->interrupts[i], irq->map); |
411 | irq->flags = irq_flags(p->triggering, p->polarity); | 415 | irq->flags = irq_flags(p->triggering, p->polarity); |
412 | 416 | ||
413 | pnp_register_irq_resource(option, irq); | 417 | pnp_register_irq_resource(option, irq); |
414 | return; | ||
415 | } | 418 | } |
416 | 419 | ||
417 | static void | 420 | static void pnpacpi_parse_port_option(struct pnp_option *option, |
418 | pnpacpi_parse_port_option(struct pnp_option *option, | 421 | struct acpi_resource_io *io) |
419 | struct acpi_resource_io *io) | ||
420 | { | 422 | { |
421 | struct pnp_port *port; | 423 | struct pnp_port *port; |
422 | 424 | ||
@@ -430,14 +432,12 @@ pnpacpi_parse_port_option(struct pnp_option *option, | |||
430 | port->align = io->alignment; | 432 | port->align = io->alignment; |
431 | port->size = io->address_length; | 433 | port->size = io->address_length; |
432 | port->flags = ACPI_DECODE_16 == io->io_decode ? | 434 | port->flags = ACPI_DECODE_16 == io->io_decode ? |
433 | PNP_PORT_FLAG_16BITADDR : 0; | 435 | PNP_PORT_FLAG_16BITADDR : 0; |
434 | pnp_register_port_resource(option, port); | 436 | pnp_register_port_resource(option, port); |
435 | return; | ||
436 | } | 437 | } |
437 | 438 | ||
438 | static void | 439 | static void pnpacpi_parse_fixed_port_option(struct pnp_option *option, |
439 | pnpacpi_parse_fixed_port_option(struct pnp_option *option, | 440 | struct acpi_resource_fixed_io *io) |
440 | struct acpi_resource_fixed_io *io) | ||
441 | { | 441 | { |
442 | struct pnp_port *port; | 442 | struct pnp_port *port; |
443 | 443 | ||
@@ -451,12 +451,10 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option, | |||
451 | port->align = 0; | 451 | port->align = 0; |
452 | port->flags = PNP_PORT_FLAG_FIXED; | 452 | port->flags = PNP_PORT_FLAG_FIXED; |
453 | pnp_register_port_resource(option, port); | 453 | pnp_register_port_resource(option, port); |
454 | return; | ||
455 | } | 454 | } |
456 | 455 | ||
457 | static void | 456 | static void pnpacpi_parse_mem24_option(struct pnp_option *option, |
458 | pnpacpi_parse_mem24_option(struct pnp_option *option, | 457 | struct acpi_resource_memory24 *p) |
459 | struct acpi_resource_memory24 *p) | ||
460 | { | 458 | { |
461 | struct pnp_mem *mem; | 459 | struct pnp_mem *mem; |
462 | 460 | ||
@@ -471,15 +469,13 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, | |||
471 | mem->size = p->address_length; | 469 | mem->size = p->address_length; |
472 | 470 | ||
473 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? | 471 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
474 | IORESOURCE_MEM_WRITEABLE : 0; | 472 | IORESOURCE_MEM_WRITEABLE : 0; |
475 | 473 | ||
476 | pnp_register_mem_resource(option, mem); | 474 | pnp_register_mem_resource(option, mem); |
477 | return; | ||
478 | } | 475 | } |
479 | 476 | ||
480 | static void | 477 | static void pnpacpi_parse_mem32_option(struct pnp_option *option, |
481 | pnpacpi_parse_mem32_option(struct pnp_option *option, | 478 | struct acpi_resource_memory32 *p) |
482 | struct acpi_resource_memory32 *p) | ||
483 | { | 479 | { |
484 | struct pnp_mem *mem; | 480 | struct pnp_mem *mem; |
485 | 481 | ||
@@ -494,15 +490,13 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, | |||
494 | mem->size = p->address_length; | 490 | mem->size = p->address_length; |
495 | 491 | ||
496 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? | 492 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
497 | IORESOURCE_MEM_WRITEABLE : 0; | 493 | IORESOURCE_MEM_WRITEABLE : 0; |
498 | 494 | ||
499 | pnp_register_mem_resource(option, mem); | 495 | pnp_register_mem_resource(option, mem); |
500 | return; | ||
501 | } | 496 | } |
502 | 497 | ||
503 | static void | 498 | static void pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, |
504 | pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, | 499 | struct acpi_resource_fixed_memory32 *p) |
505 | struct acpi_resource_fixed_memory32 *p) | ||
506 | { | 500 | { |
507 | struct pnp_mem *mem; | 501 | struct pnp_mem *mem; |
508 | 502 | ||
@@ -516,14 +510,13 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, | |||
516 | mem->align = 0; | 510 | mem->align = 0; |
517 | 511 | ||
518 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? | 512 | mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? |
519 | IORESOURCE_MEM_WRITEABLE : 0; | 513 | IORESOURCE_MEM_WRITEABLE : 0; |
520 | 514 | ||
521 | pnp_register_mem_resource(option, mem); | 515 | pnp_register_mem_resource(option, mem); |
522 | return; | ||
523 | } | 516 | } |
524 | 517 | ||
525 | static void | 518 | static void pnpacpi_parse_address_option(struct pnp_option *option, |
526 | pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) | 519 | struct acpi_resource *r) |
527 | { | 520 | { |
528 | struct acpi_resource_address64 addr, *p = &addr; | 521 | struct acpi_resource_address64 addr, *p = &addr; |
529 | acpi_status status; | 522 | acpi_status status; |
@@ -532,7 +525,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) | |||
532 | 525 | ||
533 | status = acpi_resource_to_address64(r, p); | 526 | status = acpi_resource_to_address64(r, p); |
534 | if (!ACPI_SUCCESS(status)) { | 527 | if (!ACPI_SUCCESS(status)) { |
535 | pnp_warn("PnPACPI: failed to convert resource type %d", r->type); | 528 | pnp_warn("PnPACPI: failed to convert resource type %d", |
529 | r->type); | ||
536 | return; | 530 | return; |
537 | } | 531 | } |
538 | 532 | ||
@@ -547,7 +541,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) | |||
547 | mem->size = p->address_length; | 541 | mem->size = p->address_length; |
548 | mem->align = 0; | 542 | mem->align = 0; |
549 | mem->flags = (p->info.mem.write_protect == | 543 | mem->flags = (p->info.mem.write_protect == |
550 | ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; | 544 | ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE |
545 | : 0; | ||
551 | pnp_register_mem_resource(option, mem); | 546 | pnp_register_mem_resource(option, mem); |
552 | } else if (p->resource_type == ACPI_IO_RANGE) { | 547 | } else if (p->resource_type == ACPI_IO_RANGE) { |
553 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); | 548 | port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); |
@@ -568,109 +563,108 @@ struct acpipnp_parse_option_s { | |||
568 | }; | 563 | }; |
569 | 564 | ||
570 | static acpi_status pnpacpi_option_resource(struct acpi_resource *res, | 565 | static acpi_status pnpacpi_option_resource(struct acpi_resource *res, |
571 | void *data) | 566 | void *data) |
572 | { | 567 | { |
573 | int priority = 0; | 568 | int priority = 0; |
574 | struct acpipnp_parse_option_s *parse_data = (struct acpipnp_parse_option_s *)data; | 569 | struct acpipnp_parse_option_s *parse_data = |
570 | (struct acpipnp_parse_option_s *)data; | ||
575 | struct pnp_dev *dev = parse_data->dev; | 571 | struct pnp_dev *dev = parse_data->dev; |
576 | struct pnp_option *option = parse_data->option; | 572 | struct pnp_option *option = parse_data->option; |
577 | 573 | ||
578 | switch (res->type) { | 574 | switch (res->type) { |
579 | case ACPI_RESOURCE_TYPE_IRQ: | 575 | case ACPI_RESOURCE_TYPE_IRQ: |
580 | pnpacpi_parse_irq_option(option, &res->data.irq); | 576 | pnpacpi_parse_irq_option(option, &res->data.irq); |
581 | break; | 577 | break; |
582 | 578 | ||
583 | case ACPI_RESOURCE_TYPE_DMA: | 579 | case ACPI_RESOURCE_TYPE_DMA: |
584 | pnpacpi_parse_dma_option(option, &res->data.dma); | 580 | pnpacpi_parse_dma_option(option, &res->data.dma); |
585 | break; | 581 | break; |
586 | 582 | ||
587 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 583 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
588 | switch (res->data.start_dpf.compatibility_priority) { | 584 | switch (res->data.start_dpf.compatibility_priority) { |
589 | case ACPI_GOOD_CONFIGURATION: | 585 | case ACPI_GOOD_CONFIGURATION: |
590 | priority = PNP_RES_PRIORITY_PREFERRED; | 586 | priority = PNP_RES_PRIORITY_PREFERRED; |
591 | break; | ||
592 | |||
593 | case ACPI_ACCEPTABLE_CONFIGURATION: | ||
594 | priority = PNP_RES_PRIORITY_ACCEPTABLE; | ||
595 | break; | ||
596 | |||
597 | case ACPI_SUB_OPTIMAL_CONFIGURATION: | ||
598 | priority = PNP_RES_PRIORITY_FUNCTIONAL; | ||
599 | break; | ||
600 | default: | ||
601 | priority = PNP_RES_PRIORITY_INVALID; | ||
602 | break; | ||
603 | } | ||
604 | /* TBD: Considering performace/robustness bits */ | ||
605 | option = pnp_register_dependent_option(dev, priority); | ||
606 | if (!option) | ||
607 | return AE_ERROR; | ||
608 | parse_data->option = option; | ||
609 | break; | 587 | break; |
610 | 588 | ||
611 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: | 589 | case ACPI_ACCEPTABLE_CONFIGURATION: |
612 | /*only one EndDependentFn is allowed*/ | 590 | priority = PNP_RES_PRIORITY_ACCEPTABLE; |
613 | if (!parse_data->option_independent) { | ||
614 | pnp_warn("PnPACPI: more than one EndDependentFn"); | ||
615 | return AE_ERROR; | ||
616 | } | ||
617 | parse_data->option = parse_data->option_independent; | ||
618 | parse_data->option_independent = NULL; | ||
619 | break; | 591 | break; |
620 | 592 | ||
621 | case ACPI_RESOURCE_TYPE_IO: | 593 | case ACPI_SUB_OPTIMAL_CONFIGURATION: |
622 | pnpacpi_parse_port_option(option, &res->data.io); | 594 | priority = PNP_RES_PRIORITY_FUNCTIONAL; |
623 | break; | 595 | break; |
624 | 596 | default: | |
625 | case ACPI_RESOURCE_TYPE_FIXED_IO: | 597 | priority = PNP_RES_PRIORITY_INVALID; |
626 | pnpacpi_parse_fixed_port_option(option, | ||
627 | &res->data.fixed_io); | ||
628 | break; | 598 | break; |
599 | } | ||
600 | /* TBD: Consider performance/robustness bits */ | ||
601 | option = pnp_register_dependent_option(dev, priority); | ||
602 | if (!option) | ||
603 | return AE_ERROR; | ||
604 | parse_data->option = option; | ||
605 | break; | ||
629 | 606 | ||
630 | case ACPI_RESOURCE_TYPE_VENDOR: | 607 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
631 | case ACPI_RESOURCE_TYPE_END_TAG: | 608 | /*only one EndDependentFn is allowed */ |
632 | break; | 609 | if (!parse_data->option_independent) { |
610 | pnp_warn("PnPACPI: more than one EndDependentFn"); | ||
611 | return AE_ERROR; | ||
612 | } | ||
613 | parse_data->option = parse_data->option_independent; | ||
614 | parse_data->option_independent = NULL; | ||
615 | break; | ||
633 | 616 | ||
634 | case ACPI_RESOURCE_TYPE_MEMORY24: | 617 | case ACPI_RESOURCE_TYPE_IO: |
635 | pnpacpi_parse_mem24_option(option, &res->data.memory24); | 618 | pnpacpi_parse_port_option(option, &res->data.io); |
636 | break; | 619 | break; |
637 | 620 | ||
638 | case ACPI_RESOURCE_TYPE_MEMORY32: | 621 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
639 | pnpacpi_parse_mem32_option(option, &res->data.memory32); | 622 | pnpacpi_parse_fixed_port_option(option, &res->data.fixed_io); |
640 | break; | 623 | break; |
641 | 624 | ||
642 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 625 | case ACPI_RESOURCE_TYPE_VENDOR: |
643 | pnpacpi_parse_fixed_mem32_option(option, | 626 | case ACPI_RESOURCE_TYPE_END_TAG: |
644 | &res->data.fixed_memory32); | 627 | break; |
645 | break; | ||
646 | 628 | ||
647 | case ACPI_RESOURCE_TYPE_ADDRESS16: | 629 | case ACPI_RESOURCE_TYPE_MEMORY24: |
648 | case ACPI_RESOURCE_TYPE_ADDRESS32: | 630 | pnpacpi_parse_mem24_option(option, &res->data.memory24); |
649 | case ACPI_RESOURCE_TYPE_ADDRESS64: | 631 | break; |
650 | pnpacpi_parse_address_option(option, res); | ||
651 | break; | ||
652 | 632 | ||
653 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: | 633 | case ACPI_RESOURCE_TYPE_MEMORY32: |
654 | break; | 634 | pnpacpi_parse_mem32_option(option, &res->data.memory32); |
635 | break; | ||
655 | 636 | ||
656 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | 637 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
657 | pnpacpi_parse_ext_irq_option(option, | 638 | pnpacpi_parse_fixed_mem32_option(option, |
658 | &res->data.extended_irq); | 639 | &res->data.fixed_memory32); |
659 | break; | 640 | break; |
660 | 641 | ||
661 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: | 642 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
662 | break; | 643 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
644 | case ACPI_RESOURCE_TYPE_ADDRESS64: | ||
645 | pnpacpi_parse_address_option(option, res); | ||
646 | break; | ||
663 | 647 | ||
664 | default: | 648 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
665 | pnp_warn("PnPACPI: unknown resource type %d", res->type); | 649 | break; |
666 | return AE_ERROR; | 650 | |
651 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | ||
652 | pnpacpi_parse_ext_irq_option(option, &res->data.extended_irq); | ||
653 | break; | ||
654 | |||
655 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: | ||
656 | break; | ||
657 | |||
658 | default: | ||
659 | pnp_warn("PnPACPI: unknown resource type %d", res->type); | ||
660 | return AE_ERROR; | ||
667 | } | 661 | } |
668 | 662 | ||
669 | return AE_OK; | 663 | return AE_OK; |
670 | } | 664 | } |
671 | 665 | ||
672 | acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, | 666 | acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, |
673 | struct pnp_dev *dev) | 667 | struct pnp_dev * dev) |
674 | { | 668 | { |
675 | acpi_status status; | 669 | acpi_status status; |
676 | struct acpipnp_parse_option_s parse_data; | 670 | struct acpipnp_parse_option_s parse_data; |
@@ -681,7 +675,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, | |||
681 | parse_data.option_independent = parse_data.option; | 675 | parse_data.option_independent = parse_data.option; |
682 | parse_data.dev = dev; | 676 | parse_data.dev = dev; |
683 | status = acpi_walk_resources(handle, METHOD_NAME__PRS, | 677 | status = acpi_walk_resources(handle, METHOD_NAME__PRS, |
684 | pnpacpi_option_resource, &parse_data); | 678 | pnpacpi_option_resource, &parse_data); |
685 | 679 | ||
686 | return status; | 680 | return status; |
687 | } | 681 | } |
@@ -709,7 +703,7 @@ static int pnpacpi_supported_resource(struct acpi_resource *res) | |||
709 | * Set resource | 703 | * Set resource |
710 | */ | 704 | */ |
711 | static acpi_status pnpacpi_count_resources(struct acpi_resource *res, | 705 | static acpi_status pnpacpi_count_resources(struct acpi_resource *res, |
712 | void *data) | 706 | void *data) |
713 | { | 707 | { |
714 | int *res_cnt = (int *)data; | 708 | int *res_cnt = (int *)data; |
715 | 709 | ||
@@ -732,14 +726,14 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data) | |||
732 | } | 726 | } |
733 | 727 | ||
734 | int pnpacpi_build_resource_template(acpi_handle handle, | 728 | int pnpacpi_build_resource_template(acpi_handle handle, |
735 | struct acpi_buffer *buffer) | 729 | struct acpi_buffer *buffer) |
736 | { | 730 | { |
737 | struct acpi_resource *resource; | 731 | struct acpi_resource *resource; |
738 | int res_cnt = 0; | 732 | int res_cnt = 0; |
739 | acpi_status status; | 733 | acpi_status status; |
740 | 734 | ||
741 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 735 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
742 | pnpacpi_count_resources, &res_cnt); | 736 | pnpacpi_count_resources, &res_cnt); |
743 | if (ACPI_FAILURE(status)) { | 737 | if (ACPI_FAILURE(status)) { |
744 | pnp_err("Evaluate _CRS failed"); | 738 | pnp_err("Evaluate _CRS failed"); |
745 | return -EINVAL; | 739 | return -EINVAL; |
@@ -753,7 +747,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, | |||
753 | pnp_dbg("Res cnt %d", res_cnt); | 747 | pnp_dbg("Res cnt %d", res_cnt); |
754 | resource = (struct acpi_resource *)buffer->pointer; | 748 | resource = (struct acpi_resource *)buffer->pointer; |
755 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 749 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
756 | pnpacpi_type_resources, &resource); | 750 | pnpacpi_type_resources, &resource); |
757 | if (ACPI_FAILURE(status)) { | 751 | if (ACPI_FAILURE(status)) { |
758 | kfree(buffer->pointer); | 752 | kfree(buffer->pointer); |
759 | pnp_err("Evaluate _CRS failed"); | 753 | pnp_err("Evaluate _CRS failed"); |
@@ -766,7 +760,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, | |||
766 | } | 760 | } |
767 | 761 | ||
768 | static void pnpacpi_encode_irq(struct acpi_resource *resource, | 762 | static void pnpacpi_encode_irq(struct acpi_resource *resource, |
769 | struct resource *p) | 763 | struct resource *p) |
770 | { | 764 | { |
771 | int triggering, polarity; | 765 | int triggering, polarity; |
772 | 766 | ||
@@ -782,7 +776,7 @@ static void pnpacpi_encode_irq(struct acpi_resource *resource, | |||
782 | } | 776 | } |
783 | 777 | ||
784 | static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, | 778 | static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, |
785 | struct resource *p) | 779 | struct resource *p) |
786 | { | 780 | { |
787 | int triggering, polarity; | 781 | int triggering, polarity; |
788 | 782 | ||
@@ -799,32 +793,32 @@ static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, | |||
799 | } | 793 | } |
800 | 794 | ||
801 | static void pnpacpi_encode_dma(struct acpi_resource *resource, | 795 | static void pnpacpi_encode_dma(struct acpi_resource *resource, |
802 | struct resource *p) | 796 | struct resource *p) |
803 | { | 797 | { |
804 | /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ | 798 | /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ |
805 | switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { | 799 | switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { |
806 | case IORESOURCE_DMA_TYPEA: | 800 | case IORESOURCE_DMA_TYPEA: |
807 | resource->data.dma.type = ACPI_TYPE_A; | 801 | resource->data.dma.type = ACPI_TYPE_A; |
808 | break; | 802 | break; |
809 | case IORESOURCE_DMA_TYPEB: | 803 | case IORESOURCE_DMA_TYPEB: |
810 | resource->data.dma.type = ACPI_TYPE_B; | 804 | resource->data.dma.type = ACPI_TYPE_B; |
811 | break; | 805 | break; |
812 | case IORESOURCE_DMA_TYPEF: | 806 | case IORESOURCE_DMA_TYPEF: |
813 | resource->data.dma.type = ACPI_TYPE_F; | 807 | resource->data.dma.type = ACPI_TYPE_F; |
814 | break; | 808 | break; |
815 | default: | 809 | default: |
816 | resource->data.dma.type = ACPI_COMPATIBILITY; | 810 | resource->data.dma.type = ACPI_COMPATIBILITY; |
817 | } | 811 | } |
818 | 812 | ||
819 | switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { | 813 | switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { |
820 | case IORESOURCE_DMA_8BIT: | 814 | case IORESOURCE_DMA_8BIT: |
821 | resource->data.dma.transfer = ACPI_TRANSFER_8; | 815 | resource->data.dma.transfer = ACPI_TRANSFER_8; |
822 | break; | 816 | break; |
823 | case IORESOURCE_DMA_8AND16BIT: | 817 | case IORESOURCE_DMA_8AND16BIT: |
824 | resource->data.dma.transfer = ACPI_TRANSFER_8_16; | 818 | resource->data.dma.transfer = ACPI_TRANSFER_8_16; |
825 | break; | 819 | break; |
826 | default: | 820 | default: |
827 | resource->data.dma.transfer = ACPI_TRANSFER_16; | 821 | resource->data.dma.transfer = ACPI_TRANSFER_16; |
828 | } | 822 | } |
829 | 823 | ||
830 | resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); | 824 | resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); |
@@ -833,31 +827,31 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource, | |||
833 | } | 827 | } |
834 | 828 | ||
835 | static void pnpacpi_encode_io(struct acpi_resource *resource, | 829 | static void pnpacpi_encode_io(struct acpi_resource *resource, |
836 | struct resource *p) | 830 | struct resource *p) |
837 | { | 831 | { |
838 | /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ | 832 | /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ |
839 | resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? | 833 | resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ? |
840 | ACPI_DECODE_16 : ACPI_DECODE_10; | 834 | ACPI_DECODE_16 : ACPI_DECODE_10; |
841 | resource->data.io.minimum = p->start; | 835 | resource->data.io.minimum = p->start; |
842 | resource->data.io.maximum = p->end; | 836 | resource->data.io.maximum = p->end; |
843 | resource->data.io.alignment = 0; /* Correct? */ | 837 | resource->data.io.alignment = 0; /* Correct? */ |
844 | resource->data.io.address_length = p->end - p->start + 1; | 838 | resource->data.io.address_length = p->end - p->start + 1; |
845 | } | 839 | } |
846 | 840 | ||
847 | static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, | 841 | static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, |
848 | struct resource *p) | 842 | struct resource *p) |
849 | { | 843 | { |
850 | resource->data.fixed_io.address = p->start; | 844 | resource->data.fixed_io.address = p->start; |
851 | resource->data.fixed_io.address_length = p->end - p->start + 1; | 845 | resource->data.fixed_io.address_length = p->end - p->start + 1; |
852 | } | 846 | } |
853 | 847 | ||
854 | static void pnpacpi_encode_mem24(struct acpi_resource *resource, | 848 | static void pnpacpi_encode_mem24(struct acpi_resource *resource, |
855 | struct resource *p) | 849 | struct resource *p) |
856 | { | 850 | { |
857 | /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ | 851 | /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ |
858 | resource->data.memory24.write_protect = | 852 | resource->data.memory24.write_protect = |
859 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? | 853 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
860 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; | 854 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
861 | resource->data.memory24.minimum = p->start; | 855 | resource->data.memory24.minimum = p->start; |
862 | resource->data.memory24.maximum = p->end; | 856 | resource->data.memory24.maximum = p->end; |
863 | resource->data.memory24.alignment = 0; | 857 | resource->data.memory24.alignment = 0; |
@@ -865,11 +859,11 @@ static void pnpacpi_encode_mem24(struct acpi_resource *resource, | |||
865 | } | 859 | } |
866 | 860 | ||
867 | static void pnpacpi_encode_mem32(struct acpi_resource *resource, | 861 | static void pnpacpi_encode_mem32(struct acpi_resource *resource, |
868 | struct resource *p) | 862 | struct resource *p) |
869 | { | 863 | { |
870 | resource->data.memory32.write_protect = | 864 | resource->data.memory32.write_protect = |
871 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? | 865 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
872 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; | 866 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
873 | resource->data.memory32.minimum = p->start; | 867 | resource->data.memory32.minimum = p->start; |
874 | resource->data.memory32.maximum = p->end; | 868 | resource->data.memory32.maximum = p->end; |
875 | resource->data.memory32.alignment = 0; | 869 | resource->data.memory32.alignment = 0; |
@@ -877,74 +871,77 @@ static void pnpacpi_encode_mem32(struct acpi_resource *resource, | |||
877 | } | 871 | } |
878 | 872 | ||
879 | static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, | 873 | static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, |
880 | struct resource *p) | 874 | struct resource *p) |
881 | { | 875 | { |
882 | resource->data.fixed_memory32.write_protect = | 876 | resource->data.fixed_memory32.write_protect = |
883 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? | 877 | (p->flags & IORESOURCE_MEM_WRITEABLE) ? |
884 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; | 878 | ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; |
885 | resource->data.fixed_memory32.address = p->start; | 879 | resource->data.fixed_memory32.address = p->start; |
886 | resource->data.fixed_memory32.address_length = p->end - p->start + 1; | 880 | resource->data.fixed_memory32.address_length = p->end - p->start + 1; |
887 | } | 881 | } |
888 | 882 | ||
889 | int pnpacpi_encode_resources(struct pnp_resource_table *res_table, | 883 | int pnpacpi_encode_resources(struct pnp_resource_table *res_table, |
890 | struct acpi_buffer *buffer) | 884 | struct acpi_buffer *buffer) |
891 | { | 885 | { |
892 | int i = 0; | 886 | int i = 0; |
893 | /* pnpacpi_build_resource_template allocates extra mem */ | 887 | /* pnpacpi_build_resource_template allocates extra mem */ |
894 | int res_cnt = (buffer->length - 1)/sizeof(struct acpi_resource) - 1; | 888 | int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1; |
895 | struct acpi_resource *resource = (struct acpi_resource*)buffer->pointer; | 889 | struct acpi_resource *resource = |
890 | (struct acpi_resource *)buffer->pointer; | ||
896 | int port = 0, irq = 0, dma = 0, mem = 0; | 891 | int port = 0, irq = 0, dma = 0, mem = 0; |
897 | 892 | ||
898 | pnp_dbg("res cnt %d", res_cnt); | 893 | pnp_dbg("res cnt %d", res_cnt); |
899 | while (i < res_cnt) { | 894 | while (i < res_cnt) { |
900 | switch(resource->type) { | 895 | switch (resource->type) { |
901 | case ACPI_RESOURCE_TYPE_IRQ: | 896 | case ACPI_RESOURCE_TYPE_IRQ: |
902 | pnp_dbg("Encode irq"); | 897 | pnp_dbg("Encode irq"); |
903 | pnpacpi_encode_irq(resource, | 898 | pnpacpi_encode_irq(resource, |
904 | &res_table->irq_resource[irq]); | 899 | &res_table->irq_resource[irq]); |
905 | irq++; | 900 | irq++; |
906 | break; | 901 | break; |
907 | 902 | ||
908 | case ACPI_RESOURCE_TYPE_DMA: | 903 | case ACPI_RESOURCE_TYPE_DMA: |
909 | pnp_dbg("Encode dma"); | 904 | pnp_dbg("Encode dma"); |
910 | pnpacpi_encode_dma(resource, | 905 | pnpacpi_encode_dma(resource, |
911 | &res_table->dma_resource[dma]); | 906 | &res_table->dma_resource[dma]); |
912 | dma++; | 907 | dma++; |
913 | break; | 908 | break; |
914 | case ACPI_RESOURCE_TYPE_IO: | 909 | case ACPI_RESOURCE_TYPE_IO: |
915 | pnp_dbg("Encode io"); | 910 | pnp_dbg("Encode io"); |
916 | pnpacpi_encode_io(resource, | 911 | pnpacpi_encode_io(resource, |
917 | &res_table->port_resource[port]); | 912 | &res_table->port_resource[port]); |
918 | port++; | 913 | port++; |
919 | break; | 914 | break; |
920 | case ACPI_RESOURCE_TYPE_FIXED_IO: | 915 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
921 | pnp_dbg("Encode fixed io"); | 916 | pnp_dbg("Encode fixed io"); |
922 | pnpacpi_encode_fixed_io(resource, | 917 | pnpacpi_encode_fixed_io(resource, |
923 | &res_table->port_resource[port]); | 918 | &res_table-> |
919 | port_resource[port]); | ||
924 | port++; | 920 | port++; |
925 | break; | 921 | break; |
926 | case ACPI_RESOURCE_TYPE_MEMORY24: | 922 | case ACPI_RESOURCE_TYPE_MEMORY24: |
927 | pnp_dbg("Encode mem24"); | 923 | pnp_dbg("Encode mem24"); |
928 | pnpacpi_encode_mem24(resource, | 924 | pnpacpi_encode_mem24(resource, |
929 | &res_table->mem_resource[mem]); | 925 | &res_table->mem_resource[mem]); |
930 | mem++; | 926 | mem++; |
931 | break; | 927 | break; |
932 | case ACPI_RESOURCE_TYPE_MEMORY32: | 928 | case ACPI_RESOURCE_TYPE_MEMORY32: |
933 | pnp_dbg("Encode mem32"); | 929 | pnp_dbg("Encode mem32"); |
934 | pnpacpi_encode_mem32(resource, | 930 | pnpacpi_encode_mem32(resource, |
935 | &res_table->mem_resource[mem]); | 931 | &res_table->mem_resource[mem]); |
936 | mem++; | 932 | mem++; |
937 | break; | 933 | break; |
938 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 934 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
939 | pnp_dbg("Encode fixed mem32"); | 935 | pnp_dbg("Encode fixed mem32"); |
940 | pnpacpi_encode_fixed_mem32(resource, | 936 | pnpacpi_encode_fixed_mem32(resource, |
941 | &res_table->mem_resource[mem]); | 937 | &res_table-> |
938 | mem_resource[mem]); | ||
942 | mem++; | 939 | mem++; |
943 | break; | 940 | break; |
944 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | 941 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
945 | pnp_dbg("Encode ext irq"); | 942 | pnp_dbg("Encode ext irq"); |
946 | pnpacpi_encode_ext_irq(resource, | 943 | pnpacpi_encode_ext_irq(resource, |
947 | &res_table->irq_resource[irq]); | 944 | &res_table->irq_resource[irq]); |
948 | irq++; | 945 | irq++; |
949 | break; | 946 | break; |
950 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 947 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
@@ -956,7 +953,7 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table, | |||
956 | case ACPI_RESOURCE_TYPE_ADDRESS64: | 953 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
957 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: | 954 | case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: |
958 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: | 955 | case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: |
959 | default: /* other type */ | 956 | default: /* other type */ |
960 | pnp_warn("unknown resource type %d", resource->type); | 957 | pnp_warn("unknown resource type %d", resource->type); |
961 | return -EINVAL; | 958 | return -EINVAL; |
962 | } | 959 | } |