aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/of_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc64/kernel/of_device.c')
-rw-r--r--arch/sparc64/kernel/of_device.c71
1 files changed, 46 insertions, 25 deletions
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index f845f150f565..0f616ae3246c 100644
--- a/arch/sparc64/kernel/of_device.c
+++ b/arch/sparc64/kernel/of_device.c
@@ -55,15 +55,38 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
55} 55}
56EXPORT_SYMBOL(of_find_device_by_node); 56EXPORT_SYMBOL(of_find_device_by_node);
57 57
58#ifdef CONFIG_PCI 58unsigned int irq_of_parse_and_map(struct device_node *node, int index)
59struct bus_type ebus_bus_type; 59{
60EXPORT_SYMBOL(ebus_bus_type); 60 struct of_device *op = of_find_device_by_node(node);
61#endif 61
62 if (!op || index >= op->num_irqs)
63 return 0;
64
65 return op->irqs[index];
66}
67EXPORT_SYMBOL(irq_of_parse_and_map);
68
69/* Take the archdata values for IOMMU, STC, and HOSTDATA found in
70 * BUS and propagate to all child of_device objects.
71 */
72void of_propagate_archdata(struct of_device *bus)
73{
74 struct dev_archdata *bus_sd = &bus->dev.archdata;
75 struct device_node *bus_dp = bus->node;
76 struct device_node *dp;
62 77
63#ifdef CONFIG_SBUS 78 for (dp = bus_dp->child; dp; dp = dp->sibling) {
64struct bus_type sbus_bus_type; 79 struct of_device *op = of_find_device_by_node(dp);
65EXPORT_SYMBOL(sbus_bus_type); 80
66#endif 81 op->dev.archdata.iommu = bus_sd->iommu;
82 op->dev.archdata.stc = bus_sd->stc;
83 op->dev.archdata.host_controller = bus_sd->host_controller;
84 op->dev.archdata.numa_node = bus_sd->numa_node;
85
86 if (dp->child)
87 of_propagate_archdata(op);
88 }
89}
67 90
68struct bus_type of_platform_bus_type; 91struct bus_type of_platform_bus_type;
69EXPORT_SYMBOL(of_platform_bus_type); 92EXPORT_SYMBOL(of_platform_bus_type);
@@ -169,7 +192,7 @@ static unsigned long of_bus_default_get_flags(const u32 *addr, unsigned long fla
169 192
170static int of_bus_pci_match(struct device_node *np) 193static int of_bus_pci_match(struct device_node *np)
171{ 194{
172 if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) { 195 if (!strcmp(np->name, "pci")) {
173 const char *model = of_get_property(np, "model", NULL); 196 const char *model = of_get_property(np, "model", NULL);
174 197
175 if (model && !strcmp(model, "SUNW,simba")) 198 if (model && !strcmp(model, "SUNW,simba"))
@@ -200,7 +223,7 @@ static int of_bus_simba_match(struct device_node *np)
200 /* Treat PCI busses lacking ranges property just like 223 /* Treat PCI busses lacking ranges property just like
201 * simba. 224 * simba.
202 */ 225 */
203 if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) { 226 if (!strcmp(np->name, "pci")) {
204 if (!of_find_property(np, "ranges", NULL)) 227 if (!of_find_property(np, "ranges", NULL))
205 return 1; 228 return 1;
206 } 229 }
@@ -378,8 +401,7 @@ static int __init build_one_resource(struct device_node *parent,
378 int na, int ns, int pna) 401 int na, int ns, int pna)
379{ 402{
380 const u32 *ranges; 403 const u32 *ranges;
381 unsigned int rlen; 404 int rone, rlen;
382 int rone;
383 405
384 ranges = of_get_property(parent, "ranges", &rlen); 406 ranges = of_get_property(parent, "ranges", &rlen);
385 if (ranges == NULL || rlen == 0) { 407 if (ranges == NULL || rlen == 0) {
@@ -421,15 +443,24 @@ static int __init use_1to1_mapping(struct device_node *pp)
421 443
422 /* If the parent is the dma node of an ISA bus, pass 444 /* If the parent is the dma node of an ISA bus, pass
423 * the translation up to the root. 445 * the translation up to the root.
446 *
447 * Some SBUS devices use intermediate nodes to express
448 * hierarchy within the device itself. These aren't
449 * real bus nodes, and don't have a 'ranges' property.
450 * But, we should still pass the translation work up
451 * to the SBUS itself.
424 */ 452 */
425 if (!strcmp(pp->name, "dma")) 453 if (!strcmp(pp->name, "dma") ||
454 !strcmp(pp->name, "espdma") ||
455 !strcmp(pp->name, "ledma") ||
456 !strcmp(pp->name, "lebuffer"))
426 return 0; 457 return 0;
427 458
428 /* Similarly for all PCI bridges, if we get this far 459 /* Similarly for all PCI bridges, if we get this far
429 * it lacks a ranges property, and this will include 460 * it lacks a ranges property, and this will include
430 * cases like Simba. 461 * cases like Simba.
431 */ 462 */
432 if (!strcmp(pp->type, "pci") || !strcmp(pp->type, "pciex")) 463 if (!strcmp(pp->name, "pci"))
433 return 0; 464 return 0;
434 465
435 return 1; 466 return 1;
@@ -714,8 +745,7 @@ static unsigned int __init build_one_device_irq(struct of_device *op,
714 break; 745 break;
715 } 746 }
716 } else { 747 } else {
717 if (!strcmp(pp->type, "pci") || 748 if (!strcmp(pp->name, "pci")) {
718 !strcmp(pp->type, "pciex")) {
719 unsigned int this_orig_irq = irq; 749 unsigned int this_orig_irq = irq;
720 750
721 irq = pci_irq_swizzle(dp, pp, irq); 751 irq = pci_irq_swizzle(dp, pp, irq);
@@ -845,15 +875,6 @@ static int __init of_bus_driver_init(void)
845 int err; 875 int err;
846 876
847 err = of_bus_type_init(&of_platform_bus_type, "of"); 877 err = of_bus_type_init(&of_platform_bus_type, "of");
848#ifdef CONFIG_PCI
849 if (!err)
850 err = of_bus_type_init(&ebus_bus_type, "ebus");
851#endif
852#ifdef CONFIG_SBUS
853 if (!err)
854 err = of_bus_type_init(&sbus_bus_type, "sbus");
855#endif
856
857 if (!err) 878 if (!err)
858 scan_of_devices(); 879 scan_of_devices();
859 880