0001
0002 #ifndef __OF_IRQ_H
0003 #define __OF_IRQ_H
0004
0005 #include <linux/types.h>
0006 #include <linux/errno.h>
0007 #include <linux/irq.h>
0008 #include <linux/irqdomain.h>
0009 #include <linux/ioport.h>
0010 #include <linux/of.h>
0011
0012 typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
0013
0014
0015
0016
0017 #define OF_IMAP_OLDWORLD_MAC 0x00000001
0018 #define OF_IMAP_NO_PHANDLE 0x00000002
0019
0020 #if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC)
0021 extern unsigned int of_irq_workarounds;
0022 extern struct device_node *of_irq_dflt_pic;
0023 int of_irq_parse_oldworld(const struct device_node *device, int index,
0024 struct of_phandle_args *out_irq);
0025 #else
0026 #define of_irq_workarounds (0)
0027 #define of_irq_dflt_pic (NULL)
0028 static inline int of_irq_parse_oldworld(const struct device_node *device, int index,
0029 struct of_phandle_args *out_irq)
0030 {
0031 return -EINVAL;
0032 }
0033 #endif
0034
0035 extern int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq);
0036 extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data);
0037 extern int of_irq_to_resource(struct device_node *dev, int index,
0038 struct resource *r);
0039
0040 extern void of_irq_init(const struct of_device_id *matches);
0041
0042 #ifdef CONFIG_OF_IRQ
0043 extern int of_irq_parse_one(struct device_node *device, int index,
0044 struct of_phandle_args *out_irq);
0045 extern int of_irq_count(struct device_node *dev);
0046 extern int of_irq_get(struct device_node *dev, int index);
0047 extern int of_irq_get_byname(struct device_node *dev, const char *name);
0048 extern int of_irq_to_resource_table(struct device_node *dev,
0049 struct resource *res, int nr_irqs);
0050 extern struct device_node *of_irq_find_parent(struct device_node *child);
0051 extern struct irq_domain *of_msi_get_domain(struct device *dev,
0052 struct device_node *np,
0053 enum irq_domain_bus_token token);
0054 extern struct irq_domain *of_msi_map_get_device_domain(struct device *dev,
0055 u32 id,
0056 u32 bus_token);
0057 extern void of_msi_configure(struct device *dev, struct device_node *np);
0058 u32 of_msi_map_id(struct device *dev, struct device_node *msi_np, u32 id_in);
0059 #else
0060 static inline int of_irq_parse_one(struct device_node *device, int index,
0061 struct of_phandle_args *out_irq)
0062 {
0063 return -EINVAL;
0064 }
0065 static inline int of_irq_count(struct device_node *dev)
0066 {
0067 return 0;
0068 }
0069 static inline int of_irq_get(struct device_node *dev, int index)
0070 {
0071 return 0;
0072 }
0073 static inline int of_irq_get_byname(struct device_node *dev, const char *name)
0074 {
0075 return 0;
0076 }
0077 static inline int of_irq_to_resource_table(struct device_node *dev,
0078 struct resource *res, int nr_irqs)
0079 {
0080 return 0;
0081 }
0082 static inline void *of_irq_find_parent(struct device_node *child)
0083 {
0084 return NULL;
0085 }
0086
0087 static inline struct irq_domain *of_msi_get_domain(struct device *dev,
0088 struct device_node *np,
0089 enum irq_domain_bus_token token)
0090 {
0091 return NULL;
0092 }
0093 static inline struct irq_domain *of_msi_map_get_device_domain(struct device *dev,
0094 u32 id, u32 bus_token)
0095 {
0096 return NULL;
0097 }
0098 static inline void of_msi_configure(struct device *dev, struct device_node *np)
0099 {
0100 }
0101 static inline u32 of_msi_map_id(struct device *dev,
0102 struct device_node *msi_np, u32 id_in)
0103 {
0104 return id_in;
0105 }
0106 #endif
0107
0108 #if defined(CONFIG_OF_IRQ) || defined(CONFIG_SPARC)
0109
0110
0111
0112
0113
0114 extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
0115
0116 #else
0117 static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
0118 int index)
0119 {
0120 return 0;
0121 }
0122 #endif
0123
0124 #endif