diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-06-08 09:48:06 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-07-05 18:14:25 -0400 |
commit | 7dc2e1134a22dc242175d5321c0c9e97d16eb87b (patch) | |
tree | 213406e4688340c788b40a8eb272255e8c44c8fe | |
parent | b83da291b4c73eaddc20e2edb614123a6d681b3b (diff) |
of/irq: merge irq mapping code
Merge common irq mapping code between PowerPC and Microblaze.
This patch merges of_irq_find_parent(), of_irq_map_raw() and
of_irq_map_one(). The functions are dependent on one another, so all
three are merged in a single patch. Other than cosmetic difference
(ie. DBG() vs. pr_debug()), the implementations are identical.
of_irq_to_resource() is also merged, but in this case the
implementations are different. This patch drops the microblaze version
and uses the powerpc implementation unchanged. The microblaze version
essentially open-coded irq_of_parse_and_map() which it does not need
to do. Therefore the powerpc version is safe to adopt.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
CC: Michal Simek <monstr@monstr.eu>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Stephen Rothwell <sfr@canb.auug.org.au>
-rw-r--r-- | arch/microblaze/include/asm/prom.h | 31 | ||||
-rw-r--r-- | arch/microblaze/kernel/prom_parse.c | 290 | ||||
-rw-r--r-- | arch/powerpc/include/asm/prom.h | 47 | ||||
-rw-r--r-- | arch/powerpc/kernel/prom_parse.c | 266 | ||||
-rw-r--r-- | drivers/of/irq.c | 301 | ||||
-rw-r--r-- | include/linux/of_irq.h | 29 |
6 files changed, 330 insertions, 634 deletions
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index 4f34bc5baa83..5fbdfe76fe76 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h | |||
@@ -89,34 +89,6 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); | |||
89 | /* Get the MAC address */ | 89 | /* Get the MAC address */ |
90 | extern const void *of_get_mac_address(struct device_node *np); | 90 | extern const void *of_get_mac_address(struct device_node *np); |
91 | 91 | ||
92 | /* | ||
93 | * OF interrupt mapping | ||
94 | */ | ||
95 | |||
96 | #define OF_IMAP_OLDWORLD_MAC 0x00000001 | ||
97 | #define OF_IMAP_NO_PHANDLE 0x00000002 | ||
98 | |||
99 | /** | ||
100 | * of_irq_map_raw - Low level interrupt tree parsing | ||
101 | * @parent: the device interrupt parent | ||
102 | * @intspec: interrupt specifier ("interrupts" property of the device) | ||
103 | * @ointsize: size of the passed in interrupt specifier | ||
104 | * @addr: address specifier (start of "reg" property of the device) | ||
105 | * @out_irq: structure of_irq filled by this function | ||
106 | * | ||
107 | * Returns 0 on success and a negative number on error | ||
108 | * | ||
109 | * This function is a low-level interrupt tree walking function. It | ||
110 | * can be used to do a partial walk with synthetized reg and interrupts | ||
111 | * properties, for example when resolving PCI interrupts when no device | ||
112 | * node exist for the parent. | ||
113 | * | ||
114 | */ | ||
115 | |||
116 | extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec, | ||
117 | u32 ointsize, const u32 *addr, | ||
118 | struct of_irq *out_irq); | ||
119 | |||
120 | /** | 92 | /** |
121 | * of_irq_map_pci - Resolve the interrupt for a PCI device | 93 | * of_irq_map_pci - Resolve the interrupt for a PCI device |
122 | * @pdev: the device whose interrupt is to be resolved | 94 | * @pdev: the device whose interrupt is to be resolved |
@@ -131,9 +103,6 @@ extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec, | |||
131 | struct pci_dev; | 103 | struct pci_dev; |
132 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); | 104 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); |
133 | 105 | ||
134 | extern int of_irq_to_resource(struct device_node *dev, int index, | ||
135 | struct resource *r); | ||
136 | |||
137 | /** | 106 | /** |
138 | * of_iomap - Maps the memory mapped IO for a given device_node | 107 | * of_iomap - Maps the memory mapped IO for a given device_node |
139 | * @device: the device whose io range will be mapped | 108 | * @device: the device whose io range will be mapped |
diff --git a/arch/microblaze/kernel/prom_parse.c b/arch/microblaze/kernel/prom_parse.c index cba05812ab46..e28968fa34c1 100644 --- a/arch/microblaze/kernel/prom_parse.c +++ b/arch/microblaze/kernel/prom_parse.c | |||
@@ -644,267 +644,6 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, | |||
644 | *size = of_read_number(dma_window, cells); | 644 | *size = of_read_number(dma_window, cells); |
645 | } | 645 | } |
646 | 646 | ||
647 | /* | ||
648 | * Interrupt remapper | ||
649 | */ | ||
650 | |||
651 | static unsigned int of_irq_workarounds; | ||
652 | static struct device_node *of_irq_dflt_pic; | ||
653 | |||
654 | static struct device_node *of_irq_find_parent(struct device_node *child) | ||
655 | { | ||
656 | struct device_node *p; | ||
657 | const phandle *parp; | ||
658 | |||
659 | if (!of_node_get(child)) | ||
660 | return NULL; | ||
661 | |||
662 | do { | ||
663 | parp = of_get_property(child, "interrupt-parent", NULL); | ||
664 | if (parp == NULL) | ||
665 | p = of_get_parent(child); | ||
666 | else { | ||
667 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
668 | p = of_node_get(of_irq_dflt_pic); | ||
669 | else | ||
670 | p = of_find_node_by_phandle(*parp); | ||
671 | } | ||
672 | of_node_put(child); | ||
673 | child = p; | ||
674 | } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL); | ||
675 | |||
676 | return p; | ||
677 | } | ||
678 | |||
679 | int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize, | ||
680 | const u32 *addr, struct of_irq *out_irq) | ||
681 | { | ||
682 | struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; | ||
683 | const u32 *tmp, *imap, *imask; | ||
684 | u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; | ||
685 | int imaplen, match, i; | ||
686 | |||
687 | pr_debug("of_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...]," | ||
688 | "ointsize=%d\n", | ||
689 | parent->full_name, intspec[0], intspec[1], ointsize); | ||
690 | |||
691 | ipar = of_node_get(parent); | ||
692 | |||
693 | /* First get the #interrupt-cells property of the current cursor | ||
694 | * that tells us how to interpret the passed-in intspec. If there | ||
695 | * is none, we are nice and just walk up the tree | ||
696 | */ | ||
697 | do { | ||
698 | tmp = of_get_property(ipar, "#interrupt-cells", NULL); | ||
699 | if (tmp != NULL) { | ||
700 | intsize = *tmp; | ||
701 | break; | ||
702 | } | ||
703 | tnode = ipar; | ||
704 | ipar = of_irq_find_parent(ipar); | ||
705 | of_node_put(tnode); | ||
706 | } while (ipar); | ||
707 | if (ipar == NULL) { | ||
708 | pr_debug(" -> no parent found !\n"); | ||
709 | goto fail; | ||
710 | } | ||
711 | |||
712 | pr_debug("of_irq_map_raw: ipar=%s, size=%d\n", | ||
713 | ipar->full_name, intsize); | ||
714 | |||
715 | if (ointsize != intsize) | ||
716 | return -EINVAL; | ||
717 | |||
718 | /* Look for this #address-cells. We have to implement the old linux | ||
719 | * trick of looking for the parent here as some device-trees rely on it | ||
720 | */ | ||
721 | old = of_node_get(ipar); | ||
722 | do { | ||
723 | tmp = of_get_property(old, "#address-cells", NULL); | ||
724 | tnode = of_get_parent(old); | ||
725 | of_node_put(old); | ||
726 | old = tnode; | ||
727 | } while (old && tmp == NULL); | ||
728 | of_node_put(old); | ||
729 | old = NULL; | ||
730 | addrsize = (tmp == NULL) ? 2 : *tmp; | ||
731 | |||
732 | pr_debug(" -> addrsize=%d\n", addrsize); | ||
733 | |||
734 | /* Now start the actual "proper" walk of the interrupt tree */ | ||
735 | while (ipar != NULL) { | ||
736 | /* Now check if cursor is an interrupt-controller and if it is | ||
737 | * then we are done | ||
738 | */ | ||
739 | if (of_get_property(ipar, "interrupt-controller", NULL) != | ||
740 | NULL) { | ||
741 | pr_debug(" -> got it !\n"); | ||
742 | memcpy(out_irq->specifier, intspec, | ||
743 | intsize * sizeof(u32)); | ||
744 | out_irq->size = intsize; | ||
745 | out_irq->controller = ipar; | ||
746 | of_node_put(old); | ||
747 | return 0; | ||
748 | } | ||
749 | |||
750 | /* Now look for an interrupt-map */ | ||
751 | imap = of_get_property(ipar, "interrupt-map", &imaplen); | ||
752 | /* No interrupt map, check for an interrupt parent */ | ||
753 | if (imap == NULL) { | ||
754 | pr_debug(" -> no map, getting parent\n"); | ||
755 | newpar = of_irq_find_parent(ipar); | ||
756 | goto skiplevel; | ||
757 | } | ||
758 | imaplen /= sizeof(u32); | ||
759 | |||
760 | /* Look for a mask */ | ||
761 | imask = of_get_property(ipar, "interrupt-map-mask", NULL); | ||
762 | |||
763 | /* If we were passed no "reg" property and we attempt to parse | ||
764 | * an interrupt-map, then #address-cells must be 0. | ||
765 | * Fail if it's not. | ||
766 | */ | ||
767 | if (addr == NULL && addrsize != 0) { | ||
768 | pr_debug(" -> no reg passed in when needed !\n"); | ||
769 | goto fail; | ||
770 | } | ||
771 | |||
772 | /* Parse interrupt-map */ | ||
773 | match = 0; | ||
774 | while (imaplen > (addrsize + intsize + 1) && !match) { | ||
775 | /* Compare specifiers */ | ||
776 | match = 1; | ||
777 | for (i = 0; i < addrsize && match; ++i) { | ||
778 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
779 | match = ((addr[i] ^ imap[i]) & mask) == 0; | ||
780 | } | ||
781 | for (; i < (addrsize + intsize) && match; ++i) { | ||
782 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
783 | match = | ||
784 | ((intspec[i-addrsize] ^ imap[i]) | ||
785 | & mask) == 0; | ||
786 | } | ||
787 | imap += addrsize + intsize; | ||
788 | imaplen -= addrsize + intsize; | ||
789 | |||
790 | pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen); | ||
791 | |||
792 | /* Get the interrupt parent */ | ||
793 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
794 | newpar = of_node_get(of_irq_dflt_pic); | ||
795 | else | ||
796 | newpar = | ||
797 | of_find_node_by_phandle((phandle)*imap); | ||
798 | imap++; | ||
799 | --imaplen; | ||
800 | |||
801 | /* Check if not found */ | ||
802 | if (newpar == NULL) { | ||
803 | pr_debug(" -> imap parent not found !\n"); | ||
804 | goto fail; | ||
805 | } | ||
806 | |||
807 | /* Get #interrupt-cells and #address-cells of new | ||
808 | * parent | ||
809 | */ | ||
810 | tmp = of_get_property(newpar, "#interrupt-cells", NULL); | ||
811 | if (tmp == NULL) { | ||
812 | pr_debug(" -> parent lacks " | ||
813 | "#interrupt-cells!\n"); | ||
814 | goto fail; | ||
815 | } | ||
816 | newintsize = *tmp; | ||
817 | tmp = of_get_property(newpar, "#address-cells", NULL); | ||
818 | newaddrsize = (tmp == NULL) ? 0 : *tmp; | ||
819 | |||
820 | pr_debug(" -> newintsize=%d, newaddrsize=%d\n", | ||
821 | newintsize, newaddrsize); | ||
822 | |||
823 | /* Check for malformed properties */ | ||
824 | if (imaplen < (newaddrsize + newintsize)) | ||
825 | goto fail; | ||
826 | |||
827 | imap += newaddrsize + newintsize; | ||
828 | imaplen -= newaddrsize + newintsize; | ||
829 | |||
830 | pr_debug(" -> imaplen=%d\n", imaplen); | ||
831 | } | ||
832 | if (!match) | ||
833 | goto fail; | ||
834 | |||
835 | of_node_put(old); | ||
836 | old = of_node_get(newpar); | ||
837 | addrsize = newaddrsize; | ||
838 | intsize = newintsize; | ||
839 | intspec = imap - intsize; | ||
840 | addr = intspec - addrsize; | ||
841 | |||
842 | skiplevel: | ||
843 | /* Iterate again with new parent */ | ||
844 | pr_debug(" -> new parent: %s\n", | ||
845 | newpar ? newpar->full_name : "<>"); | ||
846 | of_node_put(ipar); | ||
847 | ipar = newpar; | ||
848 | newpar = NULL; | ||
849 | } | ||
850 | fail: | ||
851 | of_node_put(ipar); | ||
852 | of_node_put(old); | ||
853 | of_node_put(newpar); | ||
854 | |||
855 | return -EINVAL; | ||
856 | } | ||
857 | EXPORT_SYMBOL_GPL(of_irq_map_raw); | ||
858 | |||
859 | int of_irq_map_one(struct device_node *device, | ||
860 | int index, struct of_irq *out_irq) | ||
861 | { | ||
862 | struct device_node *p; | ||
863 | const u32 *intspec, *tmp, *addr; | ||
864 | u32 intsize, intlen; | ||
865 | int res; | ||
866 | |||
867 | pr_debug("of_irq_map_one: dev=%s, index=%d\n", | ||
868 | device->full_name, index); | ||
869 | |||
870 | /* Get the interrupts property */ | ||
871 | intspec = of_get_property(device, "interrupts", (int *) &intlen); | ||
872 | if (intspec == NULL) | ||
873 | return -EINVAL; | ||
874 | intlen /= sizeof(u32); | ||
875 | |||
876 | pr_debug(" intspec=%d intlen=%d\n", *intspec, intlen); | ||
877 | |||
878 | /* Get the reg property (if any) */ | ||
879 | addr = of_get_property(device, "reg", NULL); | ||
880 | |||
881 | /* Look for the interrupt parent. */ | ||
882 | p = of_irq_find_parent(device); | ||
883 | if (p == NULL) | ||
884 | return -EINVAL; | ||
885 | |||
886 | /* Get size of interrupt specifier */ | ||
887 | tmp = of_get_property(p, "#interrupt-cells", NULL); | ||
888 | if (tmp == NULL) { | ||
889 | of_node_put(p); | ||
890 | return -EINVAL; | ||
891 | } | ||
892 | intsize = *tmp; | ||
893 | |||
894 | pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); | ||
895 | |||
896 | /* Check index */ | ||
897 | if ((index + 1) * intsize > intlen) | ||
898 | return -EINVAL; | ||
899 | |||
900 | /* Get new specifier and map it */ | ||
901 | res = of_irq_map_raw(p, intspec + index * intsize, intsize, | ||
902 | addr, out_irq); | ||
903 | of_node_put(p); | ||
904 | return res; | ||
905 | } | ||
906 | EXPORT_SYMBOL_GPL(of_irq_map_one); | ||
907 | |||
908 | /** | 647 | /** |
909 | * Search the device tree for the best MAC address to use. 'mac-address' is | 648 | * Search the device tree for the best MAC address to use. 'mac-address' is |
910 | * checked first, because that is supposed to contain to "most recent" MAC | 649 | * checked first, because that is supposed to contain to "most recent" MAC |
@@ -943,35 +682,6 @@ const void *of_get_mac_address(struct device_node *np) | |||
943 | } | 682 | } |
944 | EXPORT_SYMBOL(of_get_mac_address); | 683 | EXPORT_SYMBOL(of_get_mac_address); |
945 | 684 | ||
946 | int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) | ||
947 | { | ||
948 | struct of_irq out_irq; | ||
949 | int irq; | ||
950 | int res; | ||
951 | |||
952 | res = of_irq_map_one(dev, index, &out_irq); | ||
953 | |||
954 | /* Get irq for the device */ | ||
955 | if (res) { | ||
956 | pr_debug("IRQ not found... code = %d", res); | ||
957 | return NO_IRQ; | ||
958 | } | ||
959 | /* Assuming single interrupt controller... */ | ||
960 | irq = out_irq.specifier[0]; | ||
961 | |||
962 | pr_debug("IRQ found = %d", irq); | ||
963 | |||
964 | /* Only dereference the resource if both the | ||
965 | * resource and the irq are valid. */ | ||
966 | if (r && irq != NO_IRQ) { | ||
967 | r->start = r->end = irq; | ||
968 | r->flags = IORESOURCE_IRQ; | ||
969 | } | ||
970 | |||
971 | return irq; | ||
972 | } | ||
973 | EXPORT_SYMBOL_GPL(of_irq_to_resource); | ||
974 | |||
975 | void __iomem *of_iomap(struct device_node *np, int index) | 685 | void __iomem *of_iomap(struct device_node *np, int index) |
976 | { | 686 | { |
977 | struct resource res; | 687 | struct resource res; |
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 4486765db6e7..10d5ee556702 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h | |||
@@ -105,50 +105,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np); | |||
105 | /* Get the MAC address */ | 105 | /* Get the MAC address */ |
106 | extern const void *of_get_mac_address(struct device_node *np); | 106 | extern const void *of_get_mac_address(struct device_node *np); |
107 | 107 | ||
108 | /* | ||
109 | * OF interrupt mapping | ||
110 | */ | ||
111 | |||
112 | #define OF_IMAP_OLDWORLD_MAC 0x00000001 | ||
113 | #define OF_IMAP_NO_PHANDLE 0x00000002 | ||
114 | |||
115 | #if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC) | ||
116 | /* Workarounds only needed for 32bit powermac machines */ | ||
117 | extern unsigned int of_irq_workarounds; | ||
118 | extern struct device_node *of_irq_dflt_pic; | ||
119 | extern int of_irq_map_oldworld(struct device_node *device, int index, | ||
120 | struct of_irq *out_irq); | ||
121 | #else | ||
122 | #define of_irq_workarounds (0) | ||
123 | #define of_irq_dflt_pic (NULL) | ||
124 | static inline int of_irq_map_oldworld(struct device_node *device, int index, | ||
125 | struct of_irq *out_irq) | ||
126 | { | ||
127 | return -EINVAL; | ||
128 | } | ||
129 | #endif | ||
130 | |||
131 | /** | ||
132 | * of_irq_map_raw - Low level interrupt tree parsing | ||
133 | * @parent: the device interrupt parent | ||
134 | * @intspec: interrupt specifier ("interrupts" property of the device) | ||
135 | * @ointsize: size of the passed in interrupt specifier | ||
136 | * @addr: address specifier (start of "reg" property of the device) | ||
137 | * @out_irq: structure of_irq filled by this function | ||
138 | * | ||
139 | * Returns 0 on success and a negative number on error | ||
140 | * | ||
141 | * This function is a low-level interrupt tree walking function. It | ||
142 | * can be used to do a partial walk with synthetized reg and interrupts | ||
143 | * properties, for example when resolving PCI interrupts when no device | ||
144 | * node exist for the parent. | ||
145 | * | ||
146 | */ | ||
147 | |||
148 | extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec, | ||
149 | u32 ointsize, const u32 *addr, | ||
150 | struct of_irq *out_irq); | ||
151 | |||
152 | /** | 108 | /** |
153 | * of_irq_map_pci - Resolve the interrupt for a PCI device | 109 | * of_irq_map_pci - Resolve the interrupt for a PCI device |
154 | * @pdev: the device whose interrupt is to be resolved | 110 | * @pdev: the device whose interrupt is to be resolved |
@@ -163,9 +119,6 @@ extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec, | |||
163 | struct pci_dev; | 119 | struct pci_dev; |
164 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); | 120 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); |
165 | 121 | ||
166 | extern int of_irq_to_resource(struct device_node *dev, int index, | ||
167 | struct resource *r); | ||
168 | |||
169 | /** | 122 | /** |
170 | * of_iomap - Maps the memory mapped IO for a given device_node | 123 | * of_iomap - Maps the memory mapped IO for a given device_node |
171 | * @device: the device whose io range will be mapped | 124 | * @device: the device whose io range will be mapped |
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c index dfa6de6572bb..d61a5c5fe690 100644 --- a/arch/powerpc/kernel/prom_parse.c +++ b/arch/powerpc/kernel/prom_parse.c | |||
@@ -678,257 +678,6 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, | |||
678 | *size = of_read_number(dma_window, cells); | 678 | *size = of_read_number(dma_window, cells); |
679 | } | 679 | } |
680 | 680 | ||
681 | /* | ||
682 | * Interrupt remapper | ||
683 | */ | ||
684 | |||
685 | static struct device_node *of_irq_find_parent(struct device_node *child) | ||
686 | { | ||
687 | struct device_node *p; | ||
688 | const phandle *parp; | ||
689 | |||
690 | if (!of_node_get(child)) | ||
691 | return NULL; | ||
692 | |||
693 | do { | ||
694 | parp = of_get_property(child, "interrupt-parent", NULL); | ||
695 | if (parp == NULL) | ||
696 | p = of_get_parent(child); | ||
697 | else { | ||
698 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
699 | p = of_node_get(of_irq_dflt_pic); | ||
700 | else | ||
701 | p = of_find_node_by_phandle(*parp); | ||
702 | } | ||
703 | of_node_put(child); | ||
704 | child = p; | ||
705 | } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL); | ||
706 | |||
707 | return p; | ||
708 | } | ||
709 | |||
710 | int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize, | ||
711 | const u32 *addr, struct of_irq *out_irq) | ||
712 | { | ||
713 | struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; | ||
714 | const u32 *tmp, *imap, *imask; | ||
715 | u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; | ||
716 | int imaplen, match, i; | ||
717 | |||
718 | DBG("of_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n", | ||
719 | parent->full_name, intspec[0], intspec[1], ointsize); | ||
720 | |||
721 | ipar = of_node_get(parent); | ||
722 | |||
723 | /* First get the #interrupt-cells property of the current cursor | ||
724 | * that tells us how to interpret the passed-in intspec. If there | ||
725 | * is none, we are nice and just walk up the tree | ||
726 | */ | ||
727 | do { | ||
728 | tmp = of_get_property(ipar, "#interrupt-cells", NULL); | ||
729 | if (tmp != NULL) { | ||
730 | intsize = *tmp; | ||
731 | break; | ||
732 | } | ||
733 | tnode = ipar; | ||
734 | ipar = of_irq_find_parent(ipar); | ||
735 | of_node_put(tnode); | ||
736 | } while (ipar); | ||
737 | if (ipar == NULL) { | ||
738 | DBG(" -> no parent found !\n"); | ||
739 | goto fail; | ||
740 | } | ||
741 | |||
742 | DBG("of_irq_map_raw: ipar=%s, size=%d\n", ipar->full_name, intsize); | ||
743 | |||
744 | if (ointsize != intsize) | ||
745 | return -EINVAL; | ||
746 | |||
747 | /* Look for this #address-cells. We have to implement the old linux | ||
748 | * trick of looking for the parent here as some device-trees rely on it | ||
749 | */ | ||
750 | old = of_node_get(ipar); | ||
751 | do { | ||
752 | tmp = of_get_property(old, "#address-cells", NULL); | ||
753 | tnode = of_get_parent(old); | ||
754 | of_node_put(old); | ||
755 | old = tnode; | ||
756 | } while(old && tmp == NULL); | ||
757 | of_node_put(old); | ||
758 | old = NULL; | ||
759 | addrsize = (tmp == NULL) ? 2 : *tmp; | ||
760 | |||
761 | DBG(" -> addrsize=%d\n", addrsize); | ||
762 | |||
763 | /* Now start the actual "proper" walk of the interrupt tree */ | ||
764 | while (ipar != NULL) { | ||
765 | /* Now check if cursor is an interrupt-controller and if it is | ||
766 | * then we are done | ||
767 | */ | ||
768 | if (of_get_property(ipar, "interrupt-controller", NULL) != | ||
769 | NULL) { | ||
770 | DBG(" -> got it !\n"); | ||
771 | memcpy(out_irq->specifier, intspec, | ||
772 | intsize * sizeof(u32)); | ||
773 | out_irq->size = intsize; | ||
774 | out_irq->controller = ipar; | ||
775 | of_node_put(old); | ||
776 | return 0; | ||
777 | } | ||
778 | |||
779 | /* Now look for an interrupt-map */ | ||
780 | imap = of_get_property(ipar, "interrupt-map", &imaplen); | ||
781 | /* No interrupt map, check for an interrupt parent */ | ||
782 | if (imap == NULL) { | ||
783 | DBG(" -> no map, getting parent\n"); | ||
784 | newpar = of_irq_find_parent(ipar); | ||
785 | goto skiplevel; | ||
786 | } | ||
787 | imaplen /= sizeof(u32); | ||
788 | |||
789 | /* Look for a mask */ | ||
790 | imask = of_get_property(ipar, "interrupt-map-mask", NULL); | ||
791 | |||
792 | /* If we were passed no "reg" property and we attempt to parse | ||
793 | * an interrupt-map, then #address-cells must be 0. | ||
794 | * Fail if it's not. | ||
795 | */ | ||
796 | if (addr == NULL && addrsize != 0) { | ||
797 | DBG(" -> no reg passed in when needed !\n"); | ||
798 | goto fail; | ||
799 | } | ||
800 | |||
801 | /* Parse interrupt-map */ | ||
802 | match = 0; | ||
803 | while (imaplen > (addrsize + intsize + 1) && !match) { | ||
804 | /* Compare specifiers */ | ||
805 | match = 1; | ||
806 | for (i = 0; i < addrsize && match; ++i) { | ||
807 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
808 | match = ((addr[i] ^ imap[i]) & mask) == 0; | ||
809 | } | ||
810 | for (; i < (addrsize + intsize) && match; ++i) { | ||
811 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
812 | match = | ||
813 | ((intspec[i-addrsize] ^ imap[i]) & mask) == 0; | ||
814 | } | ||
815 | imap += addrsize + intsize; | ||
816 | imaplen -= addrsize + intsize; | ||
817 | |||
818 | DBG(" -> match=%d (imaplen=%d)\n", match, imaplen); | ||
819 | |||
820 | /* Get the interrupt parent */ | ||
821 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
822 | newpar = of_node_get(of_irq_dflt_pic); | ||
823 | else | ||
824 | newpar = of_find_node_by_phandle((phandle)*imap); | ||
825 | imap++; | ||
826 | --imaplen; | ||
827 | |||
828 | /* Check if not found */ | ||
829 | if (newpar == NULL) { | ||
830 | DBG(" -> imap parent not found !\n"); | ||
831 | goto fail; | ||
832 | } | ||
833 | |||
834 | /* Get #interrupt-cells and #address-cells of new | ||
835 | * parent | ||
836 | */ | ||
837 | tmp = of_get_property(newpar, "#interrupt-cells", NULL); | ||
838 | if (tmp == NULL) { | ||
839 | DBG(" -> parent lacks #interrupt-cells !\n"); | ||
840 | goto fail; | ||
841 | } | ||
842 | newintsize = *tmp; | ||
843 | tmp = of_get_property(newpar, "#address-cells", NULL); | ||
844 | newaddrsize = (tmp == NULL) ? 0 : *tmp; | ||
845 | |||
846 | DBG(" -> newintsize=%d, newaddrsize=%d\n", | ||
847 | newintsize, newaddrsize); | ||
848 | |||
849 | /* Check for malformed properties */ | ||
850 | if (imaplen < (newaddrsize + newintsize)) | ||
851 | goto fail; | ||
852 | |||
853 | imap += newaddrsize + newintsize; | ||
854 | imaplen -= newaddrsize + newintsize; | ||
855 | |||
856 | DBG(" -> imaplen=%d\n", imaplen); | ||
857 | } | ||
858 | if (!match) | ||
859 | goto fail; | ||
860 | |||
861 | of_node_put(old); | ||
862 | old = of_node_get(newpar); | ||
863 | addrsize = newaddrsize; | ||
864 | intsize = newintsize; | ||
865 | intspec = imap - intsize; | ||
866 | addr = intspec - addrsize; | ||
867 | |||
868 | skiplevel: | ||
869 | /* Iterate again with new parent */ | ||
870 | DBG(" -> new parent: %s\n", newpar ? newpar->full_name : "<>"); | ||
871 | of_node_put(ipar); | ||
872 | ipar = newpar; | ||
873 | newpar = NULL; | ||
874 | } | ||
875 | fail: | ||
876 | of_node_put(ipar); | ||
877 | of_node_put(old); | ||
878 | of_node_put(newpar); | ||
879 | |||
880 | return -EINVAL; | ||
881 | } | ||
882 | EXPORT_SYMBOL_GPL(of_irq_map_raw); | ||
883 | |||
884 | int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq) | ||
885 | { | ||
886 | struct device_node *p; | ||
887 | const u32 *intspec, *tmp, *addr; | ||
888 | u32 intsize, intlen; | ||
889 | int res = -EINVAL; | ||
890 | |||
891 | DBG("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index); | ||
892 | |||
893 | /* OldWorld mac stuff is "special", handle out of line */ | ||
894 | if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC) | ||
895 | return of_irq_map_oldworld(device, index, out_irq); | ||
896 | |||
897 | /* Get the interrupts property */ | ||
898 | intspec = of_get_property(device, "interrupts", &intlen); | ||
899 | if (intspec == NULL) | ||
900 | return -EINVAL; | ||
901 | intlen /= sizeof(u32); | ||
902 | |||
903 | /* Get the reg property (if any) */ | ||
904 | addr = of_get_property(device, "reg", NULL); | ||
905 | |||
906 | /* Look for the interrupt parent. */ | ||
907 | p = of_irq_find_parent(device); | ||
908 | if (p == NULL) | ||
909 | return -EINVAL; | ||
910 | |||
911 | /* Get size of interrupt specifier */ | ||
912 | tmp = of_get_property(p, "#interrupt-cells", NULL); | ||
913 | if (tmp == NULL) | ||
914 | goto out; | ||
915 | intsize = *tmp; | ||
916 | |||
917 | DBG(" intsize=%d intlen=%d\n", intsize, intlen); | ||
918 | |||
919 | /* Check index */ | ||
920 | if ((index + 1) * intsize > intlen) | ||
921 | goto out; | ||
922 | |||
923 | /* Get new specifier and map it */ | ||
924 | res = of_irq_map_raw(p, intspec + index * intsize, intsize, | ||
925 | addr, out_irq); | ||
926 | out: | ||
927 | of_node_put(p); | ||
928 | return res; | ||
929 | } | ||
930 | EXPORT_SYMBOL_GPL(of_irq_map_one); | ||
931 | |||
932 | /** | 681 | /** |
933 | * Search the device tree for the best MAC address to use. 'mac-address' is | 682 | * Search the device tree for the best MAC address to use. 'mac-address' is |
934 | * checked first, because that is supposed to contain to "most recent" MAC | 683 | * checked first, because that is supposed to contain to "most recent" MAC |
@@ -967,21 +716,6 @@ const void *of_get_mac_address(struct device_node *np) | |||
967 | } | 716 | } |
968 | EXPORT_SYMBOL(of_get_mac_address); | 717 | EXPORT_SYMBOL(of_get_mac_address); |
969 | 718 | ||
970 | int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) | ||
971 | { | ||
972 | int irq = irq_of_parse_and_map(dev, index); | ||
973 | |||
974 | /* Only dereference the resource if both the | ||
975 | * resource and the irq are valid. */ | ||
976 | if (r && irq != NO_IRQ) { | ||
977 | r->start = r->end = irq; | ||
978 | r->flags = IORESOURCE_IRQ; | ||
979 | } | ||
980 | |||
981 | return irq; | ||
982 | } | ||
983 | EXPORT_SYMBOL_GPL(of_irq_to_resource); | ||
984 | |||
985 | void __iomem *of_iomap(struct device_node *np, int index) | 719 | void __iomem *of_iomap(struct device_node *np, int index) |
986 | { | 720 | { |
987 | struct resource res; | 721 | struct resource res; |
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 9b3397c27096..598454fbdd1e 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c | |||
@@ -43,3 +43,304 @@ unsigned int irq_of_parse_and_map(struct device_node *dev, int index) | |||
43 | oirq.size); | 43 | oirq.size); |
44 | } | 44 | } |
45 | EXPORT_SYMBOL_GPL(irq_of_parse_and_map); | 45 | EXPORT_SYMBOL_GPL(irq_of_parse_and_map); |
46 | |||
47 | /** | ||
48 | * of_irq_find_parent - Given a device node, find its interrupt parent node | ||
49 | * @child: pointer to device node | ||
50 | * | ||
51 | * Returns a pointer to the interrupt parent node, or NULL if the interrupt | ||
52 | * parent could not be determined. | ||
53 | */ | ||
54 | static struct device_node *of_irq_find_parent(struct device_node *child) | ||
55 | { | ||
56 | struct device_node *p; | ||
57 | const phandle *parp; | ||
58 | |||
59 | if (!of_node_get(child)) | ||
60 | return NULL; | ||
61 | |||
62 | do { | ||
63 | parp = of_get_property(child, "interrupt-parent", NULL); | ||
64 | if (parp == NULL) | ||
65 | p = of_get_parent(child); | ||
66 | else { | ||
67 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
68 | p = of_node_get(of_irq_dflt_pic); | ||
69 | else | ||
70 | p = of_find_node_by_phandle(*parp); | ||
71 | } | ||
72 | of_node_put(child); | ||
73 | child = p; | ||
74 | } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL); | ||
75 | |||
76 | return p; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * of_irq_map_raw - Low level interrupt tree parsing | ||
81 | * @parent: the device interrupt parent | ||
82 | * @intspec: interrupt specifier ("interrupts" property of the device) | ||
83 | * @ointsize: size of the passed in interrupt specifier | ||
84 | * @addr: address specifier (start of "reg" property of the device) | ||
85 | * @out_irq: structure of_irq filled by this function | ||
86 | * | ||
87 | * Returns 0 on success and a negative number on error | ||
88 | * | ||
89 | * This function is a low-level interrupt tree walking function. It | ||
90 | * can be used to do a partial walk with synthetized reg and interrupts | ||
91 | * properties, for example when resolving PCI interrupts when no device | ||
92 | * node exist for the parent. | ||
93 | */ | ||
94 | int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize, | ||
95 | const u32 *addr, struct of_irq *out_irq) | ||
96 | { | ||
97 | struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; | ||
98 | const u32 *tmp, *imap, *imask; | ||
99 | u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; | ||
100 | int imaplen, match, i; | ||
101 | |||
102 | pr_debug("of_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n", | ||
103 | parent->full_name, intspec[0], intspec[1], ointsize); | ||
104 | |||
105 | ipar = of_node_get(parent); | ||
106 | |||
107 | /* First get the #interrupt-cells property of the current cursor | ||
108 | * that tells us how to interpret the passed-in intspec. If there | ||
109 | * is none, we are nice and just walk up the tree | ||
110 | */ | ||
111 | do { | ||
112 | tmp = of_get_property(ipar, "#interrupt-cells", NULL); | ||
113 | if (tmp != NULL) { | ||
114 | intsize = *tmp; | ||
115 | break; | ||
116 | } | ||
117 | tnode = ipar; | ||
118 | ipar = of_irq_find_parent(ipar); | ||
119 | of_node_put(tnode); | ||
120 | } while (ipar); | ||
121 | if (ipar == NULL) { | ||
122 | pr_debug(" -> no parent found !\n"); | ||
123 | goto fail; | ||
124 | } | ||
125 | |||
126 | pr_debug("of_irq_map_raw: ipar=%s, size=%d\n", ipar->full_name, intsize); | ||
127 | |||
128 | if (ointsize != intsize) | ||
129 | return -EINVAL; | ||
130 | |||
131 | /* Look for this #address-cells. We have to implement the old linux | ||
132 | * trick of looking for the parent here as some device-trees rely on it | ||
133 | */ | ||
134 | old = of_node_get(ipar); | ||
135 | do { | ||
136 | tmp = of_get_property(old, "#address-cells", NULL); | ||
137 | tnode = of_get_parent(old); | ||
138 | of_node_put(old); | ||
139 | old = tnode; | ||
140 | } while (old && tmp == NULL); | ||
141 | of_node_put(old); | ||
142 | old = NULL; | ||
143 | addrsize = (tmp == NULL) ? 2 : *tmp; | ||
144 | |||
145 | pr_debug(" -> addrsize=%d\n", addrsize); | ||
146 | |||
147 | /* Now start the actual "proper" walk of the interrupt tree */ | ||
148 | while (ipar != NULL) { | ||
149 | /* Now check if cursor is an interrupt-controller and if it is | ||
150 | * then we are done | ||
151 | */ | ||
152 | if (of_get_property(ipar, "interrupt-controller", NULL) != | ||
153 | NULL) { | ||
154 | pr_debug(" -> got it !\n"); | ||
155 | memcpy(out_irq->specifier, intspec, | ||
156 | intsize * sizeof(u32)); | ||
157 | out_irq->size = intsize; | ||
158 | out_irq->controller = ipar; | ||
159 | of_node_put(old); | ||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | /* Now look for an interrupt-map */ | ||
164 | imap = of_get_property(ipar, "interrupt-map", &imaplen); | ||
165 | /* No interrupt map, check for an interrupt parent */ | ||
166 | if (imap == NULL) { | ||
167 | pr_debug(" -> no map, getting parent\n"); | ||
168 | newpar = of_irq_find_parent(ipar); | ||
169 | goto skiplevel; | ||
170 | } | ||
171 | imaplen /= sizeof(u32); | ||
172 | |||
173 | /* Look for a mask */ | ||
174 | imask = of_get_property(ipar, "interrupt-map-mask", NULL); | ||
175 | |||
176 | /* If we were passed no "reg" property and we attempt to parse | ||
177 | * an interrupt-map, then #address-cells must be 0. | ||
178 | * Fail if it's not. | ||
179 | */ | ||
180 | if (addr == NULL && addrsize != 0) { | ||
181 | pr_debug(" -> no reg passed in when needed !\n"); | ||
182 | goto fail; | ||
183 | } | ||
184 | |||
185 | /* Parse interrupt-map */ | ||
186 | match = 0; | ||
187 | while (imaplen > (addrsize + intsize + 1) && !match) { | ||
188 | /* Compare specifiers */ | ||
189 | match = 1; | ||
190 | for (i = 0; i < addrsize && match; ++i) { | ||
191 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
192 | match = ((addr[i] ^ imap[i]) & mask) == 0; | ||
193 | } | ||
194 | for (; i < (addrsize + intsize) && match; ++i) { | ||
195 | u32 mask = imask ? imask[i] : 0xffffffffu; | ||
196 | match = | ||
197 | ((intspec[i-addrsize] ^ imap[i]) & mask) == 0; | ||
198 | } | ||
199 | imap += addrsize + intsize; | ||
200 | imaplen -= addrsize + intsize; | ||
201 | |||
202 | pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen); | ||
203 | |||
204 | /* Get the interrupt parent */ | ||
205 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | ||
206 | newpar = of_node_get(of_irq_dflt_pic); | ||
207 | else | ||
208 | newpar = of_find_node_by_phandle((phandle)*imap); | ||
209 | imap++; | ||
210 | --imaplen; | ||
211 | |||
212 | /* Check if not found */ | ||
213 | if (newpar == NULL) { | ||
214 | pr_debug(" -> imap parent not found !\n"); | ||
215 | goto fail; | ||
216 | } | ||
217 | |||
218 | /* Get #interrupt-cells and #address-cells of new | ||
219 | * parent | ||
220 | */ | ||
221 | tmp = of_get_property(newpar, "#interrupt-cells", NULL); | ||
222 | if (tmp == NULL) { | ||
223 | pr_debug(" -> parent lacks #interrupt-cells!\n"); | ||
224 | goto fail; | ||
225 | } | ||
226 | newintsize = *tmp; | ||
227 | tmp = of_get_property(newpar, "#address-cells", NULL); | ||
228 | newaddrsize = (tmp == NULL) ? 0 : *tmp; | ||
229 | |||
230 | pr_debug(" -> newintsize=%d, newaddrsize=%d\n", | ||
231 | newintsize, newaddrsize); | ||
232 | |||
233 | /* Check for malformed properties */ | ||
234 | if (imaplen < (newaddrsize + newintsize)) | ||
235 | goto fail; | ||
236 | |||
237 | imap += newaddrsize + newintsize; | ||
238 | imaplen -= newaddrsize + newintsize; | ||
239 | |||
240 | pr_debug(" -> imaplen=%d\n", imaplen); | ||
241 | } | ||
242 | if (!match) | ||
243 | goto fail; | ||
244 | |||
245 | of_node_put(old); | ||
246 | old = of_node_get(newpar); | ||
247 | addrsize = newaddrsize; | ||
248 | intsize = newintsize; | ||
249 | intspec = imap - intsize; | ||
250 | addr = intspec - addrsize; | ||
251 | |||
252 | skiplevel: | ||
253 | /* Iterate again with new parent */ | ||
254 | pr_debug(" -> new parent: %s\n", newpar ? newpar->full_name : "<>"); | ||
255 | of_node_put(ipar); | ||
256 | ipar = newpar; | ||
257 | newpar = NULL; | ||
258 | } | ||
259 | fail: | ||
260 | of_node_put(ipar); | ||
261 | of_node_put(old); | ||
262 | of_node_put(newpar); | ||
263 | |||
264 | return -EINVAL; | ||
265 | } | ||
266 | EXPORT_SYMBOL_GPL(of_irq_map_raw); | ||
267 | |||
268 | /** | ||
269 | * of_irq_map_one - Resolve an interrupt for a device | ||
270 | * @device: the device whose interrupt is to be resolved | ||
271 | * @index: index of the interrupt to resolve | ||
272 | * @out_irq: structure of_irq filled by this function | ||
273 | * | ||
274 | * This function resolves an interrupt, walking the tree, for a given | ||
275 | * device-tree node. It's the high level pendant to of_irq_map_raw(). | ||
276 | */ | ||
277 | int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq) | ||
278 | { | ||
279 | struct device_node *p; | ||
280 | const u32 *intspec, *tmp, *addr; | ||
281 | u32 intsize, intlen; | ||
282 | int res = -EINVAL; | ||
283 | |||
284 | pr_debug("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index); | ||
285 | |||
286 | /* OldWorld mac stuff is "special", handle out of line */ | ||
287 | if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC) | ||
288 | return of_irq_map_oldworld(device, index, out_irq); | ||
289 | |||
290 | /* Get the interrupts property */ | ||
291 | intspec = of_get_property(device, "interrupts", &intlen); | ||
292 | if (intspec == NULL) | ||
293 | return -EINVAL; | ||
294 | intlen /= sizeof(u32); | ||
295 | |||
296 | pr_debug(" intspec=%d intlen=%d\n", *intspec, intlen); | ||
297 | |||
298 | /* Get the reg property (if any) */ | ||
299 | addr = of_get_property(device, "reg", NULL); | ||
300 | |||
301 | /* Look for the interrupt parent. */ | ||
302 | p = of_irq_find_parent(device); | ||
303 | if (p == NULL) | ||
304 | return -EINVAL; | ||
305 | |||
306 | /* Get size of interrupt specifier */ | ||
307 | tmp = of_get_property(p, "#interrupt-cells", NULL); | ||
308 | if (tmp == NULL) | ||
309 | goto out; | ||
310 | intsize = *tmp; | ||
311 | |||
312 | pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); | ||
313 | |||
314 | /* Check index */ | ||
315 | if ((index + 1) * intsize > intlen) | ||
316 | goto out; | ||
317 | |||
318 | /* Get new specifier and map it */ | ||
319 | res = of_irq_map_raw(p, intspec + index * intsize, intsize, | ||
320 | addr, out_irq); | ||
321 | out: | ||
322 | of_node_put(p); | ||
323 | return res; | ||
324 | } | ||
325 | EXPORT_SYMBOL_GPL(of_irq_map_one); | ||
326 | |||
327 | /** | ||
328 | * of_irq_to_resource - Decode a node's IRQ and return it as a resource | ||
329 | * @dev: pointer to device tree node | ||
330 | * @index: zero-based index of the irq | ||
331 | * @r: pointer to resource structure to return result into. | ||
332 | */ | ||
333 | int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) | ||
334 | { | ||
335 | int irq = irq_of_parse_and_map(dev, index); | ||
336 | |||
337 | /* Only dereference the resource if both the | ||
338 | * resource and the irq are valid. */ | ||
339 | if (r && irq != NO_IRQ) { | ||
340 | r->start = r->end = irq; | ||
341 | r->flags = IORESOURCE_IRQ; | ||
342 | } | ||
343 | |||
344 | return irq; | ||
345 | } | ||
346 | EXPORT_SYMBOL_GPL(of_irq_to_resource); | ||
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index 0e37c05b7dd8..5929781c104d 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h | |||
@@ -4,6 +4,8 @@ | |||
4 | #if defined(CONFIG_OF) | 4 | #if defined(CONFIG_OF) |
5 | struct of_irq; | 5 | struct of_irq; |
6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
7 | #include <linux/errno.h> | ||
8 | #include <linux/ioport.h> | ||
7 | #include <linux/of.h> | 9 | #include <linux/of.h> |
8 | 10 | ||
9 | /* | 11 | /* |
@@ -30,11 +32,38 @@ struct of_irq { | |||
30 | u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */ | 32 | u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */ |
31 | }; | 33 | }; |
32 | 34 | ||
35 | /* | ||
36 | * Workarounds only applied to 32bit powermac machines | ||
37 | */ | ||
38 | #define OF_IMAP_OLDWORLD_MAC 0x00000001 | ||
39 | #define OF_IMAP_NO_PHANDLE 0x00000002 | ||
40 | |||
41 | #if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC) | ||
42 | extern unsigned int of_irq_workarounds; | ||
43 | extern struct device_node *of_irq_dflt_pic; | ||
44 | extern int of_irq_map_oldworld(struct device_node *device, int index, | ||
45 | struct of_irq *out_irq); | ||
46 | #else /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ | ||
47 | #define of_irq_workarounds (0) | ||
48 | #define of_irq_dflt_pic (NULL) | ||
49 | static inline int of_irq_map_oldworld(struct device_node *device, int index, | ||
50 | struct of_irq *out_irq) | ||
51 | { | ||
52 | return -EINVAL; | ||
53 | } | ||
54 | #endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ | ||
55 | |||
56 | |||
57 | extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec, | ||
58 | u32 ointsize, const u32 *addr, | ||
59 | struct of_irq *out_irq); | ||
33 | extern int of_irq_map_one(struct device_node *device, int index, | 60 | extern int of_irq_map_one(struct device_node *device, int index, |
34 | struct of_irq *out_irq); | 61 | struct of_irq *out_irq); |
35 | extern unsigned int irq_create_of_mapping(struct device_node *controller, | 62 | extern unsigned int irq_create_of_mapping(struct device_node *controller, |
36 | const u32 *intspec, | 63 | const u32 *intspec, |
37 | unsigned int intsize); | 64 | unsigned int intsize); |
65 | extern int of_irq_to_resource(struct device_node *dev, int index, | ||
66 | struct resource *r); | ||
38 | 67 | ||
39 | #endif /* CONFIG_OF_IRQ */ | 68 | #endif /* CONFIG_OF_IRQ */ |
40 | #endif /* CONFIG_OF */ | 69 | #endif /* CONFIG_OF */ |