diff options
author | Arnd Bergmann <arnd@arndb.de> | 2006-10-04 11:26:20 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-10-04 19:21:01 -0400 |
commit | 7650f2f2c367242a2092908794b4486876baf6c7 (patch) | |
tree | 82b60df9ed602d19bcaa70e728b2b8213e9d3172 /arch/powerpc/platforms | |
parent | e1dbff2bafa83f839ef15f51904b0cce9fc89387 (diff) |
[POWERPC] spufs: support new OF device tree format
The properties we used traditionally in the device tree are somewhat
nonstandard. This adds support for a more conventional format using
'interrupts' and 'reg' properties.
The interrupts are specified in three cells (class 0, 1 and 2) and
registered at the interrupt-parent.
The reg property contains either three or four register areas in the
order 'local-store', 'problem', 'priv2', and 'priv1', so the priv1 one
can be left out in case of hypervisor driven systems that access these
through hcalls.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/cell/spu_base.c | 99 |
1 files changed, 94 insertions, 5 deletions
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c index d4e4f0f683df..ac5f12662dbb 100644 --- a/arch/powerpc/platforms/cell/spu_base.c +++ b/arch/powerpc/platforms/cell/spu_base.c | |||
@@ -25,11 +25,13 @@ | |||
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/list.h> | 26 | #include <linux/list.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/pci.h> | ||
28 | #include <linux/poll.h> | 29 | #include <linux/poll.h> |
29 | #include <linux/ptrace.h> | 30 | #include <linux/ptrace.h> |
30 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
31 | #include <linux/wait.h> | 32 | #include <linux/wait.h> |
32 | 33 | ||
34 | #include <asm/firmware.h> | ||
33 | #include <asm/io.h> | 35 | #include <asm/io.h> |
34 | #include <asm/prom.h> | 36 | #include <asm/prom.h> |
35 | #include <linux/mutex.h> | 37 | #include <linux/mutex.h> |
@@ -576,7 +578,7 @@ static void spu_unmap(struct spu *spu) | |||
576 | } | 578 | } |
577 | 579 | ||
578 | /* This function shall be abstracted for HV platforms */ | 580 | /* This function shall be abstracted for HV platforms */ |
579 | static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) | 581 | static int __init spu_map_interrupts_old(struct spu *spu, struct device_node *np) |
580 | { | 582 | { |
581 | unsigned int isrc; | 583 | unsigned int isrc; |
582 | const u32 *tmp; | 584 | const u32 *tmp; |
@@ -600,7 +602,7 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) | |||
600 | return spu->irqs[2] == NO_IRQ ? -EINVAL : 0; | 602 | return spu->irqs[2] == NO_IRQ ? -EINVAL : 0; |
601 | } | 603 | } |
602 | 604 | ||
603 | static int __init spu_map_device(struct spu *spu, struct device_node *node) | 605 | static int __init spu_map_device_old(struct spu *spu, struct device_node *node) |
604 | { | 606 | { |
605 | const char *prop; | 607 | const char *prop; |
606 | int ret; | 608 | int ret; |
@@ -645,6 +647,88 @@ out: | |||
645 | return ret; | 647 | return ret; |
646 | } | 648 | } |
647 | 649 | ||
650 | static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) | ||
651 | { | ||
652 | struct of_irq oirq; | ||
653 | int ret; | ||
654 | int i; | ||
655 | |||
656 | for (i=0; i < 3; i++) { | ||
657 | ret = of_irq_map_one(np, i, &oirq); | ||
658 | if (ret) | ||
659 | goto err; | ||
660 | |||
661 | ret = -EINVAL; | ||
662 | spu->irqs[i] = irq_create_of_mapping(oirq.controller, | ||
663 | oirq.specifier, oirq.size); | ||
664 | if (spu->irqs[i] == NO_IRQ) | ||
665 | goto err; | ||
666 | } | ||
667 | return 0; | ||
668 | |||
669 | err: | ||
670 | pr_debug("failed to map irq %x for spu %s\n", *oirq.specifier, spu->name); | ||
671 | for (; i >= 0; i--) { | ||
672 | if (spu->irqs[i] != NO_IRQ) | ||
673 | irq_dispose_mapping(spu->irqs[i]); | ||
674 | } | ||
675 | return ret; | ||
676 | } | ||
677 | |||
678 | static int spu_map_resource(struct device_node *node, int nr, | ||
679 | void __iomem** virt, unsigned long *phys) | ||
680 | { | ||
681 | struct resource resource = { }; | ||
682 | int ret; | ||
683 | |||
684 | ret = of_address_to_resource(node, 0, &resource); | ||
685 | if (ret) | ||
686 | goto out; | ||
687 | |||
688 | if (phys) | ||
689 | *phys = resource.start; | ||
690 | *virt = ioremap(resource.start, resource.end - resource.start); | ||
691 | if (!*virt) | ||
692 | ret = -EINVAL; | ||
693 | |||
694 | out: | ||
695 | return ret; | ||
696 | } | ||
697 | |||
698 | static int __init spu_map_device(struct spu *spu, struct device_node *node) | ||
699 | { | ||
700 | int ret = -ENODEV; | ||
701 | spu->name = get_property(node, "name", NULL); | ||
702 | if (!spu->name) | ||
703 | goto out; | ||
704 | |||
705 | ret = spu_map_resource(node, 0, (void __iomem**)&spu->local_store, | ||
706 | &spu->local_store_phys); | ||
707 | if (ret) | ||
708 | goto out; | ||
709 | ret = spu_map_resource(node, 1, (void __iomem**)&spu->problem, | ||
710 | &spu->problem_phys); | ||
711 | if (ret) | ||
712 | goto out_unmap; | ||
713 | ret = spu_map_resource(node, 2, (void __iomem**)&spu->priv2, | ||
714 | NULL); | ||
715 | if (ret) | ||
716 | goto out_unmap; | ||
717 | |||
718 | if (!firmware_has_feature(FW_FEATURE_LPAR)) | ||
719 | ret = spu_map_resource(node, 3, (void __iomem**)&spu->priv1, | ||
720 | NULL); | ||
721 | if (ret) | ||
722 | goto out_unmap; | ||
723 | return 0; | ||
724 | |||
725 | out_unmap: | ||
726 | spu_unmap(spu); | ||
727 | out: | ||
728 | pr_debug("failed to map spe %s: %d\n", spu->name, ret); | ||
729 | return ret; | ||
730 | } | ||
731 | |||
648 | struct sysdev_class spu_sysdev_class = { | 732 | struct sysdev_class spu_sysdev_class = { |
649 | set_kset_name("spu") | 733 | set_kset_name("spu") |
650 | }; | 734 | }; |
@@ -698,6 +782,9 @@ static int __init create_spu(struct device_node *spe) | |||
698 | goto out; | 782 | goto out; |
699 | 783 | ||
700 | ret = spu_map_device(spu, spe); | 784 | ret = spu_map_device(spu, spe); |
785 | /* try old method */ | ||
786 | if (ret) | ||
787 | ret = spu_map_device_old(spu, spe); | ||
701 | if (ret) | 788 | if (ret) |
702 | goto out_free; | 789 | goto out_free; |
703 | 790 | ||
@@ -707,6 +794,8 @@ static int __init create_spu(struct device_node *spe) | |||
707 | spu->nid = 0; | 794 | spu->nid = 0; |
708 | ret = spu_map_interrupts(spu, spe); | 795 | ret = spu_map_interrupts(spu, spe); |
709 | if (ret) | 796 | if (ret) |
797 | ret = spu_map_interrupts_old(spu, spe); | ||
798 | if (ret) | ||
710 | goto out_unmap; | 799 | goto out_unmap; |
711 | spin_lock_init(&spu->register_lock); | 800 | spin_lock_init(&spu->register_lock); |
712 | spu_mfc_sdr_set(spu, mfspr(SPRN_SDR1)); | 801 | spu_mfc_sdr_set(spu, mfspr(SPRN_SDR1)); |
@@ -716,7 +805,7 @@ static int __init create_spu(struct device_node *spe) | |||
716 | spu->number = number++; | 805 | spu->number = number++; |
717 | ret = spu_request_irqs(spu); | 806 | ret = spu_request_irqs(spu); |
718 | if (ret) | 807 | if (ret) |
719 | goto out_unmap; | 808 | goto out_unlock; |
720 | 809 | ||
721 | ret = spu_create_sysdev(spu); | 810 | ret = spu_create_sysdev(spu); |
722 | if (ret) | 811 | if (ret) |
@@ -732,9 +821,9 @@ static int __init create_spu(struct device_node *spe) | |||
732 | 821 | ||
733 | out_free_irqs: | 822 | out_free_irqs: |
734 | spu_free_irqs(spu); | 823 | spu_free_irqs(spu); |
735 | 824 | out_unlock: | |
736 | out_unmap: | ||
737 | mutex_unlock(&spu_mutex); | 825 | mutex_unlock(&spu_mutex); |
826 | out_unmap: | ||
738 | spu_unmap(spu); | 827 | spu_unmap(spu); |
739 | out_free: | 828 | out_free: |
740 | kfree(spu); | 829 | kfree(spu); |