aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpacpi/rsparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/pnpacpi/rsparser.c')
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c160
1 files changed, 61 insertions, 99 deletions
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 2f0d66886404..ce5027feb3da 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -71,9 +71,9 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity)
71 } 71 }
72} 72}
73 73
74static void 74static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
75pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, 75 u32 gsi, int triggering,
76 int triggering, int polarity, int shareable) 76 int polarity, int shareable)
77{ 77{
78 int i = 0; 78 int i = 0;
79 int irq; 79 int irq;
@@ -146,11 +146,12 @@ static int dma_flags(int type, int bus_master, int transfer)
146 return flags; 146 return flags;
147} 147}
148 148
149static void 149static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res,
150pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma, 150 u32 dma, int type,
151 int type, int bus_master, int transfer) 151 int bus_master, int transfer)
152{ 152{
153 int i = 0; 153 int i = 0;
154
154 while (i < PNP_MAX_DMA && 155 while (i < PNP_MAX_DMA &&
155 !(res->dma_resource[i].flags & IORESOURCE_UNSET)) 156 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
156 i++; 157 i++;
@@ -167,11 +168,11 @@ pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma,
167 } 168 }
168} 169}
169 170
170static void 171static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
171pnpacpi_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++;
@@ -188,11 +189,12 @@ pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
188 } 189 }
189} 190}
190 191
191static void 192static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
192pnpacpi_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++;
@@ -210,9 +212,8 @@ pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
210 } 212 }
211} 213}
212 214
213static void 215static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
214pnpacpi_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;
@@ -229,16 +230,13 @@ 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, 233 p->minimum, p->address_length,
233 p->address_length, 234 p->info.mem.write_protect);
234 p->info.mem.write_protect);
235 else if (p->resource_type == ACPI_IO_RANGE) 235 else if (p->resource_type == ACPI_IO_RANGE)
236 pnpacpi_parse_allocated_ioresource(res_table, 236 pnpacpi_parse_allocated_ioresource(res_table,
237 p->minimum, 237 p->minimum, p->address_length,
238 p->address_length, 238 p->granularity == 0xfff ? ACPI_DECODE_10 :
239 p->granularity == 239 ACPI_DECODE_16);
240 0xfff ? ACPI_DECODE_10 :
241 ACPI_DECODE_16);
242} 240}
243 241
244static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 242static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
@@ -256,34 +254,27 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
256 */ 254 */
257 for (i = 0; i < res->data.irq.interrupt_count; i++) { 255 for (i = 0; i < res->data.irq.interrupt_count; i++) {
258 pnpacpi_parse_allocated_irqresource(res_table, 256 pnpacpi_parse_allocated_irqresource(res_table,
259 res->data.irq. 257 res->data.irq.interrupts[i],
260 interrupts[i], 258 res->data.irq.triggering,
261 res->data.irq. 259 res->data.irq.polarity,
262 triggering, 260 res->data.irq.sharable);
263 res->data.irq.
264 polarity,
265 res->data.irq.
266 sharable);
267 } 261 }
268 break; 262 break;
269 263
270 case ACPI_RESOURCE_TYPE_DMA: 264 case ACPI_RESOURCE_TYPE_DMA:
271 if (res->data.dma.channel_count > 0) 265 if (res->data.dma.channel_count > 0)
272 pnpacpi_parse_allocated_dmaresource(res_table, 266 pnpacpi_parse_allocated_dmaresource(res_table,
273 res->data.dma. 267 res->data.dma.channels[0],
274 channels[0], 268 res->data.dma.type,
275 res->data.dma.type, 269 res->data.dma.bus_master,
276 res->data.dma. 270 res->data.dma.transfer);
277 bus_master,
278 res->data.dma.
279 transfer);
280 break; 271 break;
281 272
282 case ACPI_RESOURCE_TYPE_IO: 273 case ACPI_RESOURCE_TYPE_IO:
283 pnpacpi_parse_allocated_ioresource(res_table, 274 pnpacpi_parse_allocated_ioresource(res_table,
284 res->data.io.minimum, 275 res->data.io.minimum,
285 res->data.io.address_length, 276 res->data.io.address_length,
286 res->data.io.io_decode); 277 res->data.io.io_decode);
287 break; 278 break;
288 279
289 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 280 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -292,10 +283,9 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
292 283
293 case ACPI_RESOURCE_TYPE_FIXED_IO: 284 case ACPI_RESOURCE_TYPE_FIXED_IO:
294 pnpacpi_parse_allocated_ioresource(res_table, 285 pnpacpi_parse_allocated_ioresource(res_table,
295 res->data.fixed_io.address, 286 res->data.fixed_io.address,
296 res->data.fixed_io. 287 res->data.fixed_io.address_length,
297 address_length, 288 ACPI_DECODE_10);
298 ACPI_DECODE_10);
299 break; 289 break;
300 290
301 case ACPI_RESOURCE_TYPE_VENDOR: 291 case ACPI_RESOURCE_TYPE_VENDOR:
@@ -306,28 +296,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
306 296
307 case ACPI_RESOURCE_TYPE_MEMORY24: 297 case ACPI_RESOURCE_TYPE_MEMORY24:
308 pnpacpi_parse_allocated_memresource(res_table, 298 pnpacpi_parse_allocated_memresource(res_table,
309 res->data.memory24.minimum, 299 res->data.memory24.minimum,
310 res->data.memory24. 300 res->data.memory24.address_length,
311 address_length, 301 res->data.memory24.write_protect);
312 res->data.memory24.
313 write_protect);
314 break; 302 break;
315 case ACPI_RESOURCE_TYPE_MEMORY32: 303 case ACPI_RESOURCE_TYPE_MEMORY32:
316 pnpacpi_parse_allocated_memresource(res_table, 304 pnpacpi_parse_allocated_memresource(res_table,
317 res->data.memory32.minimum, 305 res->data.memory32.minimum,
318 res->data.memory32. 306 res->data.memory32.address_length,
319 address_length, 307 res->data.memory32.write_protect);
320 res->data.memory32.
321 write_protect);
322 break; 308 break;
323 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 309 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
324 pnpacpi_parse_allocated_memresource(res_table, 310 pnpacpi_parse_allocated_memresource(res_table,
325 res->data.fixed_memory32. 311 res->data.fixed_memory32.address,
326 address, 312 res->data.fixed_memory32.address_length,
327 res->data.fixed_memory32. 313 res->data.fixed_memory32.write_protect);
328 address_length,
329 res->data.fixed_memory32.
330 write_protect);
331 break; 314 break;
332 case ACPI_RESOURCE_TYPE_ADDRESS16: 315 case ACPI_RESOURCE_TYPE_ADDRESS16:
333 case ACPI_RESOURCE_TYPE_ADDRESS32: 316 case ACPI_RESOURCE_TYPE_ADDRESS32:
@@ -346,18 +329,10 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
346 329
347 for (i = 0; i < res->data.extended_irq.interrupt_count; i++) { 330 for (i = 0; i < res->data.extended_irq.interrupt_count; i++) {
348 pnpacpi_parse_allocated_irqresource(res_table, 331 pnpacpi_parse_allocated_irqresource(res_table,
349 res->data. 332 res->data.extended_irq.interrupts[i],
350 extended_irq. 333 res->data.extended_irq.triggering,
351 interrupts[i], 334 res->data.extended_irq.polarity,
352 res->data. 335 res->data.extended_irq.sharable);
353 extended_irq.
354 triggering,
355 res->data.
356 extended_irq.
357 polarity,
358 res->data.
359 extended_irq.
360 sharable);
361 } 336 }
362 break; 337 break;
363 338
@@ -400,7 +375,6 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option,
400 dma->flags = dma_flags(p->type, p->bus_master, p->transfer); 375 dma->flags = dma_flags(p->type, p->bus_master, p->transfer);
401 376
402 pnp_register_dma_resource(option, dma); 377 pnp_register_dma_resource(option, dma);
403 return;
404} 378}
405 379
406static void pnpacpi_parse_irq_option(struct pnp_option *option, 380static void pnpacpi_parse_irq_option(struct pnp_option *option,
@@ -421,7 +395,6 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
421 irq->flags = irq_flags(p->triggering, p->polarity); 395 irq->flags = irq_flags(p->triggering, p->polarity);
422 396
423 pnp_register_irq_resource(option, irq); 397 pnp_register_irq_resource(option, irq);
424 return;
425} 398}
426 399
427static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, 400static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
@@ -442,12 +415,10 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
442 irq->flags = irq_flags(p->triggering, p->polarity); 415 irq->flags = irq_flags(p->triggering, p->polarity);
443 416
444 pnp_register_irq_resource(option, irq); 417 pnp_register_irq_resource(option, irq);
445 return;
446} 418}
447 419
448static void 420static void pnpacpi_parse_port_option(struct pnp_option *option,
449pnpacpi_parse_port_option(struct pnp_option *option, 421 struct acpi_resource_io *io)
450 struct acpi_resource_io *io)
451{ 422{
452 struct pnp_port *port; 423 struct pnp_port *port;
453 424
@@ -463,12 +434,10 @@ pnpacpi_parse_port_option(struct pnp_option *option,
463 port->flags = ACPI_DECODE_16 == io->io_decode ? 434 port->flags = ACPI_DECODE_16 == io->io_decode ?
464 PNP_PORT_FLAG_16BITADDR : 0; 435 PNP_PORT_FLAG_16BITADDR : 0;
465 pnp_register_port_resource(option, port); 436 pnp_register_port_resource(option, port);
466 return;
467} 437}
468 438
469static void 439static void pnpacpi_parse_fixed_port_option(struct pnp_option *option,
470pnpacpi_parse_fixed_port_option(struct pnp_option *option, 440 struct acpi_resource_fixed_io *io)
471 struct acpi_resource_fixed_io *io)
472{ 441{
473 struct pnp_port *port; 442 struct pnp_port *port;
474 443
@@ -482,12 +451,10 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
482 port->align = 0; 451 port->align = 0;
483 port->flags = PNP_PORT_FLAG_FIXED; 452 port->flags = PNP_PORT_FLAG_FIXED;
484 pnp_register_port_resource(option, port); 453 pnp_register_port_resource(option, port);
485 return;
486} 454}
487 455
488static void 456static void pnpacpi_parse_mem24_option(struct pnp_option *option,
489pnpacpi_parse_mem24_option(struct pnp_option *option, 457 struct acpi_resource_memory24 *p)
490 struct acpi_resource_memory24 *p)
491{ 458{
492 struct pnp_mem *mem; 459 struct pnp_mem *mem;
493 460
@@ -505,12 +472,10 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
505 IORESOURCE_MEM_WRITEABLE : 0; 472 IORESOURCE_MEM_WRITEABLE : 0;
506 473
507 pnp_register_mem_resource(option, mem); 474 pnp_register_mem_resource(option, mem);
508 return;
509} 475}
510 476
511static void 477static void pnpacpi_parse_mem32_option(struct pnp_option *option,
512pnpacpi_parse_mem32_option(struct pnp_option *option, 478 struct acpi_resource_memory32 *p)
513 struct acpi_resource_memory32 *p)
514{ 479{
515 struct pnp_mem *mem; 480 struct pnp_mem *mem;
516 481
@@ -528,12 +493,10 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
528 IORESOURCE_MEM_WRITEABLE : 0; 493 IORESOURCE_MEM_WRITEABLE : 0;
529 494
530 pnp_register_mem_resource(option, mem); 495 pnp_register_mem_resource(option, mem);
531 return;
532} 496}
533 497
534static void 498static void pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
535pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, 499 struct acpi_resource_fixed_memory32 *p)
536 struct acpi_resource_fixed_memory32 *p)
537{ 500{
538 struct pnp_mem *mem; 501 struct pnp_mem *mem;
539 502
@@ -550,11 +513,10 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
550 IORESOURCE_MEM_WRITEABLE : 0; 513 IORESOURCE_MEM_WRITEABLE : 0;
551 514
552 pnp_register_mem_resource(option, mem); 515 pnp_register_mem_resource(option, mem);
553 return;
554} 516}
555 517
556static void 518static void pnpacpi_parse_address_option(struct pnp_option *option,
557pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) 519 struct acpi_resource *r)
558{ 520{
559 struct acpi_resource_address64 addr, *p = &addr; 521 struct acpi_resource_address64 addr, *p = &addr;
560 acpi_status status; 522 acpi_status status;
@@ -635,7 +597,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
635 priority = PNP_RES_PRIORITY_INVALID; 597 priority = PNP_RES_PRIORITY_INVALID;
636 break; 598 break;
637 } 599 }
638 /* TBD: Considering performace/robustness bits */ 600 /* TBD: Consider performance/robustness bits */
639 option = pnp_register_dependent_option(dev, priority); 601 option = pnp_register_dependent_option(dev, priority);
640 if (!option) 602 if (!option)
641 return AE_ERROR; 603 return AE_ERROR;