diff options
Diffstat (limited to 'arch/sparc/kernel/of_device_64.c')
-rw-r--r-- | arch/sparc/kernel/of_device_64.c | 61 |
1 files changed, 23 insertions, 38 deletions
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c index 1dae8079f728..63cd4e5d47c2 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c | |||
@@ -310,10 +310,10 @@ static int __init use_1to1_mapping(struct device_node *pp) | |||
310 | 310 | ||
311 | static int of_resource_verbose; | 311 | static int of_resource_verbose; |
312 | 312 | ||
313 | static void __init build_device_resources(struct of_device *op, | 313 | static void __init build_device_resources(struct platform_device *op, |
314 | struct device *parent) | 314 | struct device *parent) |
315 | { | 315 | { |
316 | struct of_device *p_op; | 316 | struct platform_device *p_op; |
317 | struct of_bus *bus; | 317 | struct of_bus *bus; |
318 | int na, ns; | 318 | int na, ns; |
319 | int index, num_reg; | 319 | int index, num_reg; |
@@ -322,7 +322,7 @@ static void __init build_device_resources(struct of_device *op, | |||
322 | if (!parent) | 322 | if (!parent) |
323 | return; | 323 | return; |
324 | 324 | ||
325 | p_op = to_of_device(parent); | 325 | p_op = to_platform_device(parent); |
326 | bus = of_match_bus(p_op->dev.of_node); | 326 | bus = of_match_bus(p_op->dev.of_node); |
327 | bus->count_cells(op->dev.of_node, &na, &ns); | 327 | bus->count_cells(op->dev.of_node, &na, &ns); |
328 | 328 | ||
@@ -344,6 +344,8 @@ static void __init build_device_resources(struct of_device *op, | |||
344 | num_reg = PROMREG_MAX; | 344 | num_reg = PROMREG_MAX; |
345 | } | 345 | } |
346 | 346 | ||
347 | op->resource = op->archdata.resource; | ||
348 | op->num_resources = num_reg; | ||
347 | for (index = 0; index < num_reg; index++) { | 349 | for (index = 0; index < num_reg; index++) { |
348 | struct resource *r = &op->resource[index]; | 350 | struct resource *r = &op->resource[index]; |
349 | u32 addr[OF_MAX_ADDR_CELLS]; | 351 | u32 addr[OF_MAX_ADDR_CELLS]; |
@@ -526,7 +528,7 @@ static unsigned int __init pci_irq_swizzle(struct device_node *dp, | |||
526 | 528 | ||
527 | static int of_irq_verbose; | 529 | static int of_irq_verbose; |
528 | 530 | ||
529 | static unsigned int __init build_one_device_irq(struct of_device *op, | 531 | static unsigned int __init build_one_device_irq(struct platform_device *op, |
530 | struct device *parent, | 532 | struct device *parent, |
531 | unsigned int irq) | 533 | unsigned int irq) |
532 | { | 534 | { |
@@ -628,10 +630,10 @@ out: | |||
628 | return irq; | 630 | return irq; |
629 | } | 631 | } |
630 | 632 | ||
631 | static struct of_device * __init scan_one_device(struct device_node *dp, | 633 | static struct platform_device * __init scan_one_device(struct device_node *dp, |
632 | struct device *parent) | 634 | struct device *parent) |
633 | { | 635 | { |
634 | struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); | 636 | struct platform_device *op = kzalloc(sizeof(*op), GFP_KERNEL); |
635 | const unsigned int *irq; | 637 | const unsigned int *irq; |
636 | struct dev_archdata *sd; | 638 | struct dev_archdata *sd; |
637 | int len, i; | 639 | int len, i; |
@@ -644,34 +646,28 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
644 | 646 | ||
645 | op->dev.of_node = dp; | 647 | op->dev.of_node = dp; |
646 | 648 | ||
647 | op->clock_freq = of_getintprop_default(dp, "clock-frequency", | ||
648 | (25*1000*1000)); | ||
649 | op->portid = of_getintprop_default(dp, "upa-portid", -1); | ||
650 | if (op->portid == -1) | ||
651 | op->portid = of_getintprop_default(dp, "portid", -1); | ||
652 | |||
653 | irq = of_get_property(dp, "interrupts", &len); | 649 | irq = of_get_property(dp, "interrupts", &len); |
654 | if (irq) { | 650 | if (irq) { |
655 | op->num_irqs = len / 4; | 651 | op->archdata.num_irqs = len / 4; |
656 | 652 | ||
657 | /* Prevent overrunning the op->irqs[] array. */ | 653 | /* Prevent overrunning the op->irqs[] array. */ |
658 | if (op->num_irqs > PROMINTR_MAX) { | 654 | if (op->archdata.num_irqs > PROMINTR_MAX) { |
659 | printk(KERN_WARNING "%s: Too many irqs (%d), " | 655 | printk(KERN_WARNING "%s: Too many irqs (%d), " |
660 | "limiting to %d.\n", | 656 | "limiting to %d.\n", |
661 | dp->full_name, op->num_irqs, PROMINTR_MAX); | 657 | dp->full_name, op->archdata.num_irqs, PROMINTR_MAX); |
662 | op->num_irqs = PROMINTR_MAX; | 658 | op->archdata.num_irqs = PROMINTR_MAX; |
663 | } | 659 | } |
664 | memcpy(op->irqs, irq, op->num_irqs * 4); | 660 | memcpy(op->archdata.irqs, irq, op->archdata.num_irqs * 4); |
665 | } else { | 661 | } else { |
666 | op->num_irqs = 0; | 662 | op->archdata.num_irqs = 0; |
667 | } | 663 | } |
668 | 664 | ||
669 | build_device_resources(op, parent); | 665 | build_device_resources(op, parent); |
670 | for (i = 0; i < op->num_irqs; i++) | 666 | for (i = 0; i < op->archdata.num_irqs; i++) |
671 | op->irqs[i] = build_one_device_irq(op, parent, op->irqs[i]); | 667 | op->archdata.irqs[i] = build_one_device_irq(op, parent, op->archdata.irqs[i]); |
672 | 668 | ||
673 | op->dev.parent = parent; | 669 | op->dev.parent = parent; |
674 | op->dev.bus = &of_platform_bus_type; | 670 | op->dev.bus = &platform_bus_type; |
675 | if (!parent) | 671 | if (!parent) |
676 | dev_set_name(&op->dev, "root"); | 672 | dev_set_name(&op->dev, "root"); |
677 | else | 673 | else |
@@ -690,7 +686,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
690 | static void __init scan_tree(struct device_node *dp, struct device *parent) | 686 | static void __init scan_tree(struct device_node *dp, struct device *parent) |
691 | { | 687 | { |
692 | while (dp) { | 688 | while (dp) { |
693 | struct of_device *op = scan_one_device(dp, parent); | 689 | struct platform_device *op = scan_one_device(dp, parent); |
694 | 690 | ||
695 | if (op) | 691 | if (op) |
696 | scan_tree(dp->child, &op->dev); | 692 | scan_tree(dp->child, &op->dev); |
@@ -699,30 +695,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent) | |||
699 | } | 695 | } |
700 | } | 696 | } |
701 | 697 | ||
702 | static void __init scan_of_devices(void) | 698 | static int __init scan_of_devices(void) |
703 | { | 699 | { |
704 | struct device_node *root = of_find_node_by_path("/"); | 700 | struct device_node *root = of_find_node_by_path("/"); |
705 | struct of_device *parent; | 701 | struct platform_device *parent; |
706 | 702 | ||
707 | parent = scan_one_device(root, NULL); | 703 | parent = scan_one_device(root, NULL); |
708 | if (!parent) | 704 | if (!parent) |
709 | return; | 705 | return 0; |
710 | 706 | ||
711 | scan_tree(root->child, &parent->dev); | 707 | scan_tree(root->child, &parent->dev); |
708 | return 0; | ||
712 | } | 709 | } |
713 | 710 | postcore_initcall(scan_of_devices); | |
714 | static int __init of_bus_driver_init(void) | ||
715 | { | ||
716 | int err; | ||
717 | |||
718 | err = of_bus_type_init(&of_platform_bus_type, "of"); | ||
719 | if (!err) | ||
720 | scan_of_devices(); | ||
721 | |||
722 | return err; | ||
723 | } | ||
724 | |||
725 | postcore_initcall(of_bus_driver_init); | ||
726 | 711 | ||
727 | static int __init of_debug(char *str) | 712 | static int __init of_debug(char *str) |
728 | { | 713 | { |