blob: 1214cabb22479be282ea6482ecec1657d8d59c1a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Grant Likelye3873442010-06-18 11:09:59 -06002#ifndef __OF_IRQ_H
3#define __OF_IRQ_H
4
Grant Likelye3873442010-06-18 11:09:59 -06005#include <linux/types.h>
Grant Likely7dc2e112010-06-08 07:48:06 -06006#include <linux/errno.h>
Grant Likely530719b2010-10-21 11:34:55 -06007#include <linux/irq.h>
Grant Likelyd593f252012-02-24 08:24:17 -07008#include <linux/irqdomain.h>
Grant Likely7dc2e112010-06-08 07:48:06 -06009#include <linux/ioport.h>
Grant Likelye3873442010-06-18 11:09:59 -060010#include <linux/of.h>
11
Rob Herringdf3ed932017-05-11 10:15:10 -050012typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
Rob Herringc71a54b2011-09-20 15:13:50 -050013
Grant Likely7dc2e112010-06-08 07:48:06 -060014/*
15 * Workarounds only applied to 32bit powermac machines
16 */
17#define OF_IMAP_OLDWORLD_MAC 0x00000001
18#define OF_IMAP_NO_PHANDLE 0x00000002
19
20#if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC)
21extern unsigned int of_irq_workarounds;
22extern struct device_node *of_irq_dflt_pic;
Grant Likely0c02c802013-09-19 11:22:36 -050023extern int of_irq_parse_oldworld(struct device_node *device, int index,
Grant Likely530210c2013-09-15 16:39:11 +010024 struct of_phandle_args *out_irq);
Grant Likely7dc2e112010-06-08 07:48:06 -060025#else /* CONFIG_PPC32 && CONFIG_PPC_PMAC */
26#define of_irq_workarounds (0)
27#define of_irq_dflt_pic (NULL)
Grant Likely0c02c802013-09-19 11:22:36 -050028static inline int of_irq_parse_oldworld(struct device_node *device, int index,
Grant Likely530210c2013-09-15 16:39:11 +010029 struct of_phandle_args *out_irq)
Grant Likely7dc2e112010-06-08 07:48:06 -060030{
31 return -EINVAL;
32}
33#endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */
34
Grant Likely23616132013-09-15 22:32:39 +010035extern int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq);
Grant Likely0c02c802013-09-19 11:22:36 -050036extern int of_irq_parse_one(struct device_node *device, int index,
Grant Likely530210c2013-09-15 16:39:11 +010037 struct of_phandle_args *out_irq);
Grant Likelye6d30ab2013-09-15 16:55:53 +010038extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data);
Grant Likely7dc2e112010-06-08 07:48:06 -060039extern int of_irq_to_resource(struct device_node *dev, int index,
40 struct resource *r);
Grant Likelye3873442010-06-18 11:09:59 -060041
Rob Herringc71a54b2011-09-20 15:13:50 -050042extern void of_irq_init(const struct of_device_id *matches);
Grant Likely08a543a2011-07-26 03:19:06 -060043
Rob Herringa8d3f362013-11-07 12:13:27 -060044#ifdef CONFIG_OF_IRQ
45extern int of_irq_count(struct device_node *dev);
Rob Herring9ec36ca2014-04-23 17:57:41 -050046extern int of_irq_get(struct device_node *dev, int index);
Grygorii Strashkoad696742014-05-20 13:42:02 +030047extern int of_irq_get_byname(struct device_node *dev, const char *name);
Geert Uytterhoevend616a702015-04-05 16:59:25 +020048extern int of_irq_to_resource_table(struct device_node *dev,
49 struct resource *res, int nr_irqs);
Carlo Caione4c3141e2015-12-01 17:24:17 +010050extern struct device_node *of_irq_find_parent(struct device_node *child);
Marc Zyngier48ae34f2015-09-18 14:07:40 +010051extern struct irq_domain *of_msi_get_domain(struct device *dev,
52 struct device_node *np,
53 enum irq_domain_bus_token token);
Marc Zyngier82b9b422015-10-02 14:38:55 +010054extern struct irq_domain *of_msi_map_get_device_domain(struct device *dev,
55 u32 rid);
Jonas Gorskif9f9f112015-10-12 14:43:22 +020056extern void of_msi_configure(struct device *dev, struct device_node *np);
Rob Herringeaddb572015-12-09 09:11:10 -060057u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in);
Rob Herringa8d3f362013-11-07 12:13:27 -060058#else
59static inline int of_irq_count(struct device_node *dev)
60{
61 return 0;
62}
Rob Herring9ec36ca2014-04-23 17:57:41 -050063static inline int of_irq_get(struct device_node *dev, int index)
64{
65 return 0;
66}
Grygorii Strashkoad696742014-05-20 13:42:02 +030067static inline int of_irq_get_byname(struct device_node *dev, const char *name)
68{
69 return 0;
70}
Geert Uytterhoevend616a702015-04-05 16:59:25 +020071static inline int of_irq_to_resource_table(struct device_node *dev,
72 struct resource *res, int nr_irqs)
73{
74 return 0;
75}
Carlo Caione4c3141e2015-12-01 17:24:17 +010076static inline void *of_irq_find_parent(struct device_node *child)
77{
78 return NULL;
79}
80
Marc Zyngier48ae34f2015-09-18 14:07:40 +010081static inline struct irq_domain *of_msi_get_domain(struct device *dev,
82 struct device_node *np,
83 enum irq_domain_bus_token token)
84{
85 return NULL;
86}
Marc Zyngier82b9b422015-10-02 14:38:55 +010087static inline struct irq_domain *of_msi_map_get_device_domain(struct device *dev,
88 u32 rid)
89{
90 return NULL;
91}
Jonas Gorskif9f9f112015-10-12 14:43:22 +020092static inline void of_msi_configure(struct device *dev, struct device_node *np)
93{
94}
Rob Herringeaddb572015-12-09 09:11:10 -060095static inline u32 of_msi_map_rid(struct device *dev,
96 struct device_node *msi_np, u32 rid_in)
97{
98 return rid_in;
99}
Rob Herringa8d3f362013-11-07 12:13:27 -0600100#endif
101
Jonas Gorski62ebf932015-10-12 14:43:24 +0200102#if defined(CONFIG_OF_IRQ) || defined(CONFIG_SPARC)
Rob Herringb0b8c962013-09-04 10:52:57 -0500103/*
104 * irq_of_parse_and_map() is used by all OF enabled platforms; but SPARC
105 * implements it differently. However, the prototype is the same for all,
106 * so declare it here regardless of the CONFIG_OF_IRQ setting.
107 */
108extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
Thomas Abraham766644d2012-03-25 20:32:49 +0530109
Jonas Gorski62ebf932015-10-12 14:43:24 +0200110#else /* !CONFIG_OF && !CONFIG_SPARC */
Thomas Abraham766644d2012-03-25 20:32:49 +0530111static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
112 int index)
113{
114 return 0;
115}
116#endif /* !CONFIG_OF */
117
Grant Likelye3873442010-06-18 11:09:59 -0600118#endif /* __OF_IRQ_H */