diff options
Diffstat (limited to 'arch/sparc64/kernel/of_device.c')
-rw-r--r-- | arch/sparc64/kernel/of_device.c | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c index fb9bf1e4d036..9ac9a307999a 100644 --- a/arch/sparc64/kernel/of_device.c +++ b/arch/sparc64/kernel/of_device.c | |||
@@ -245,7 +245,7 @@ struct of_bus { | |||
245 | int *addrc, int *sizec); | 245 | int *addrc, int *sizec); |
246 | int (*map)(u32 *addr, const u32 *range, | 246 | int (*map)(u32 *addr, const u32 *range, |
247 | int na, int ns, int pna); | 247 | int na, int ns, int pna); |
248 | unsigned int (*get_flags)(u32 *addr); | 248 | unsigned int (*get_flags)(const u32 *addr); |
249 | }; | 249 | }; |
250 | 250 | ||
251 | /* | 251 | /* |
@@ -305,7 +305,7 @@ static int of_bus_default_map(u32 *addr, const u32 *range, | |||
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | static unsigned int of_bus_default_get_flags(u32 *addr) | 308 | static unsigned int of_bus_default_get_flags(const u32 *addr) |
309 | { | 309 | { |
310 | return IORESOURCE_MEM; | 310 | return IORESOURCE_MEM; |
311 | } | 311 | } |
@@ -317,6 +317,11 @@ static unsigned int of_bus_default_get_flags(u32 *addr) | |||
317 | static int of_bus_pci_match(struct device_node *np) | 317 | static int of_bus_pci_match(struct device_node *np) |
318 | { | 318 | { |
319 | if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) { | 319 | if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) { |
320 | const char *model = of_get_property(np, "model", NULL); | ||
321 | |||
322 | if (model && !strcmp(model, "SUNW,simba")) | ||
323 | return 0; | ||
324 | |||
320 | /* Do not do PCI specific frobbing if the | 325 | /* Do not do PCI specific frobbing if the |
321 | * PCI bridge lacks a ranges property. We | 326 | * PCI bridge lacks a ranges property. We |
322 | * want to pass it through up to the next | 327 | * want to pass it through up to the next |
@@ -332,6 +337,21 @@ static int of_bus_pci_match(struct device_node *np) | |||
332 | return 0; | 337 | return 0; |
333 | } | 338 | } |
334 | 339 | ||
340 | static int of_bus_simba_match(struct device_node *np) | ||
341 | { | ||
342 | const char *model = of_get_property(np, "model", NULL); | ||
343 | |||
344 | if (model && !strcmp(model, "SUNW,simba")) | ||
345 | return 1; | ||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | static int of_bus_simba_map(u32 *addr, const u32 *range, | ||
350 | int na, int ns, int pna) | ||
351 | { | ||
352 | return 0; | ||
353 | } | ||
354 | |||
335 | static void of_bus_pci_count_cells(struct device_node *np, | 355 | static void of_bus_pci_count_cells(struct device_node *np, |
336 | int *addrc, int *sizec) | 356 | int *addrc, int *sizec) |
337 | { | 357 | { |
@@ -369,7 +389,7 @@ static int of_bus_pci_map(u32 *addr, const u32 *range, | |||
369 | return 0; | 389 | return 0; |
370 | } | 390 | } |
371 | 391 | ||
372 | static unsigned int of_bus_pci_get_flags(u32 *addr) | 392 | static unsigned int of_bus_pci_get_flags(const u32 *addr) |
373 | { | 393 | { |
374 | unsigned int flags = 0; | 394 | unsigned int flags = 0; |
375 | u32 w = addr[0]; | 395 | u32 w = addr[0]; |
@@ -436,6 +456,15 @@ static struct of_bus of_busses[] = { | |||
436 | .map = of_bus_pci_map, | 456 | .map = of_bus_pci_map, |
437 | .get_flags = of_bus_pci_get_flags, | 457 | .get_flags = of_bus_pci_get_flags, |
438 | }, | 458 | }, |
459 | /* SIMBA */ | ||
460 | { | ||
461 | .name = "simba", | ||
462 | .addr_prop_name = "assigned-addresses", | ||
463 | .match = of_bus_simba_match, | ||
464 | .count_cells = of_bus_pci_count_cells, | ||
465 | .map = of_bus_simba_map, | ||
466 | .get_flags = of_bus_pci_get_flags, | ||
467 | }, | ||
439 | /* SBUS */ | 468 | /* SBUS */ |
440 | { | 469 | { |
441 | .name = "sbus", | 470 | .name = "sbus", |
@@ -482,7 +511,7 @@ static int __init build_one_resource(struct device_node *parent, | |||
482 | u32 *addr, | 511 | u32 *addr, |
483 | int na, int ns, int pna) | 512 | int na, int ns, int pna) |
484 | { | 513 | { |
485 | u32 *ranges; | 514 | const u32 *ranges; |
486 | unsigned int rlen; | 515 | unsigned int rlen; |
487 | int rone; | 516 | int rone; |
488 | 517 | ||
@@ -513,7 +542,7 @@ static int __init build_one_resource(struct device_node *parent, | |||
513 | 542 | ||
514 | static int __init use_1to1_mapping(struct device_node *pp) | 543 | static int __init use_1to1_mapping(struct device_node *pp) |
515 | { | 544 | { |
516 | char *model; | 545 | const char *model; |
517 | 546 | ||
518 | /* If this is on the PMU bus, don't try to translate it even | 547 | /* If this is on the PMU bus, don't try to translate it even |
519 | * if a ranges property exists. | 548 | * if a ranges property exists. |
@@ -548,7 +577,7 @@ static void __init build_device_resources(struct of_device *op, | |||
548 | struct of_bus *bus; | 577 | struct of_bus *bus; |
549 | int na, ns; | 578 | int na, ns; |
550 | int index, num_reg; | 579 | int index, num_reg; |
551 | void *preg; | 580 | const void *preg; |
552 | 581 | ||
553 | if (!parent) | 582 | if (!parent) |
554 | return; | 583 | return; |
@@ -578,7 +607,7 @@ static void __init build_device_resources(struct of_device *op, | |||
578 | for (index = 0; index < num_reg; index++) { | 607 | for (index = 0; index < num_reg; index++) { |
579 | struct resource *r = &op->resource[index]; | 608 | struct resource *r = &op->resource[index]; |
580 | u32 addr[OF_MAX_ADDR_CELLS]; | 609 | u32 addr[OF_MAX_ADDR_CELLS]; |
581 | u32 *reg = (preg + (index * ((na + ns) * 4))); | 610 | const u32 *reg = (preg + (index * ((na + ns) * 4))); |
582 | struct device_node *dp = op->node; | 611 | struct device_node *dp = op->node; |
583 | struct device_node *pp = p_op->node; | 612 | struct device_node *pp = p_op->node; |
584 | struct of_bus *pbus, *dbus; | 613 | struct of_bus *pbus, *dbus; |
@@ -643,14 +672,14 @@ static void __init build_device_resources(struct of_device *op, | |||
643 | 672 | ||
644 | static struct device_node * __init | 673 | static struct device_node * __init |
645 | apply_interrupt_map(struct device_node *dp, struct device_node *pp, | 674 | apply_interrupt_map(struct device_node *dp, struct device_node *pp, |
646 | u32 *imap, int imlen, u32 *imask, | 675 | const u32 *imap, int imlen, const u32 *imask, |
647 | unsigned int *irq_p) | 676 | unsigned int *irq_p) |
648 | { | 677 | { |
649 | struct device_node *cp; | 678 | struct device_node *cp; |
650 | unsigned int irq = *irq_p; | 679 | unsigned int irq = *irq_p; |
651 | struct of_bus *bus; | 680 | struct of_bus *bus; |
652 | phandle handle; | 681 | phandle handle; |
653 | u32 *reg; | 682 | const u32 *reg; |
654 | int na, num_reg, i; | 683 | int na, num_reg, i; |
655 | 684 | ||
656 | bus = of_match_bus(pp); | 685 | bus = of_match_bus(pp); |
@@ -705,7 +734,7 @@ static unsigned int __init pci_irq_swizzle(struct device_node *dp, | |||
705 | struct device_node *pp, | 734 | struct device_node *pp, |
706 | unsigned int irq) | 735 | unsigned int irq) |
707 | { | 736 | { |
708 | struct linux_prom_pci_registers *regs; | 737 | const struct linux_prom_pci_registers *regs; |
709 | unsigned int bus, devfn, slot, ret; | 738 | unsigned int bus, devfn, slot, ret; |
710 | 739 | ||
711 | if (irq < 1 || irq > 4) | 740 | if (irq < 1 || irq > 4) |
@@ -730,12 +759,6 @@ static unsigned int __init pci_irq_swizzle(struct device_node *dp, | |||
730 | * D: 2-bit slot number, derived from PCI device number as | 759 | * D: 2-bit slot number, derived from PCI device number as |
731 | * (dev - 1) for bus A, or (dev - 2) for bus B | 760 | * (dev - 1) for bus A, or (dev - 2) for bus B |
732 | * L: 2-bit line number | 761 | * L: 2-bit line number |
733 | * | ||
734 | * Actually, more "portable" way to calculate the funky | ||
735 | * slot number is to subtract pbm->pci_first_slot from the | ||
736 | * device number, and that's exactly what the pre-OF | ||
737 | * sparc64 code did, but we're building this stuff generically | ||
738 | * using the OBP tree, not in the PCI controller layer. | ||
739 | */ | 762 | */ |
740 | if (bus & 0x80) { | 763 | if (bus & 0x80) { |
741 | /* PBM-A */ | 764 | /* PBM-A */ |
@@ -794,7 +817,7 @@ static unsigned int __init build_one_device_irq(struct of_device *op, | |||
794 | pp = dp->parent; | 817 | pp = dp->parent; |
795 | ip = NULL; | 818 | ip = NULL; |
796 | while (pp) { | 819 | while (pp) { |
797 | void *imap, *imsk; | 820 | const void *imap, *imsk; |
798 | int imlen; | 821 | int imlen; |
799 | 822 | ||
800 | imap = of_get_property(pp, "interrupt-map", &imlen); | 823 | imap = of_get_property(pp, "interrupt-map", &imlen); |
@@ -859,7 +882,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
859 | struct device *parent) | 882 | struct device *parent) |
860 | { | 883 | { |
861 | struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); | 884 | struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); |
862 | unsigned int *irq; | 885 | const unsigned int *irq; |
863 | int len, i; | 886 | int len, i; |
864 | 887 | ||
865 | if (!op) | 888 | if (!op) |