• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * irq_domain - IRQ translation domains
4  *
5  * Translation infrastructure between hw and linux irq numbers.  This is
6  * helpful for interrupt controllers to implement mapping between hardware
7  * irq numbers and the Linux irq number space.
8  *
9  * irq_domains also have hooks for translating device tree or other
10  * firmware interrupt representations into a hardware irq number that
11  * can be mapped back to a Linux irq number without any extra platform
12  * support code.
13  *
14  * Interrupt controller "domain" data structure. This could be defined as a
15  * irq domain controller. That is, it handles the mapping between hardware
16  * and virtual interrupt numbers for a given interrupt domain. The domain
17  * structure is generally created by the PIC code for a given PIC instance
18  * (though a domain can cover more than one PIC if they have a flat number
19  * model). It's the domain callbacks that are responsible for setting the
20  * irq_chip on a given irq_desc after it's been mapped.
21  *
22  * The host code and data structures use a fwnode_handle pointer to
23  * identify the domain. In some cases, and in order to preserve source
24  * code compatibility, this fwnode pointer is "upgraded" to a DT
25  * device_node. For those firmware infrastructures that do not provide
26  * a unique identifier for an interrupt controller, the irq_domain
27  * code offers a fwnode allocator.
28  */
29 
30 #ifndef _LINUX_IRQDOMAIN_H
31 #define _LINUX_IRQDOMAIN_H
32 
33 #include <linux/types.h>
34 #include <linux/irqdomain_defs.h>
35 #include <linux/irqhandler.h>
36 #include <linux/of.h>
37 #include <linux/mutex.h>
38 #include <linux/radix-tree.h>
39 #include <linux/android_kabi.h>
40 
41 struct device_node;
42 struct fwnode_handle;
43 struct irq_domain;
44 struct irq_chip;
45 struct irq_data;
46 struct irq_desc;
47 struct cpumask;
48 struct seq_file;
49 struct irq_affinity_desc;
50 struct msi_parent_ops;
51 
52 #define IRQ_DOMAIN_IRQ_SPEC_PARAMS 16
53 
54 /**
55  * struct irq_fwspec - generic IRQ specifier structure
56  *
57  * @fwnode:		Pointer to a firmware-specific descriptor
58  * @param_count:	Number of device-specific parameters
59  * @param:		Device-specific parameters
60  *
61  * This structure, directly modeled after of_phandle_args, is used to
62  * pass a device-specific description of an interrupt.
63  */
64 struct irq_fwspec {
65 	struct fwnode_handle *fwnode;
66 	int param_count;
67 	u32 param[IRQ_DOMAIN_IRQ_SPEC_PARAMS];
68 };
69 
70 /* Conversion function from of_phandle_args fields to fwspec  */
71 void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args,
72 			       unsigned int count, struct irq_fwspec *fwspec);
73 
74 /**
75  * struct irq_domain_ops - Methods for irq_domain objects
76  * @match: Match an interrupt controller device node to a host, returns
77  *         1 on a match
78  * @map: Create or update a mapping between a virtual irq number and a hw
79  *       irq number. This is called only once for a given mapping.
80  * @unmap: Dispose of such a mapping
81  * @xlate: Given a device tree node and interrupt specifier, decode
82  *         the hardware irq number and linux irq type value.
83  *
84  * Functions below are provided by the driver and called whenever a new mapping
85  * is created or an old mapping is disposed. The driver can then proceed to
86  * whatever internal data structures management is required. It also needs
87  * to setup the irq_desc when returning from map().
88  */
89 struct irq_domain_ops {
90 	int (*match)(struct irq_domain *d, struct device_node *node,
91 		     enum irq_domain_bus_token bus_token);
92 	int (*select)(struct irq_domain *d, struct irq_fwspec *fwspec,
93 		      enum irq_domain_bus_token bus_token);
94 	int (*map)(struct irq_domain *d, unsigned int virq, irq_hw_number_t hw);
95 	void (*unmap)(struct irq_domain *d, unsigned int virq);
96 	int (*xlate)(struct irq_domain *d, struct device_node *node,
97 		     const u32 *intspec, unsigned int intsize,
98 		     unsigned long *out_hwirq, unsigned int *out_type);
99 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
100 	/* extended V2 interfaces to support hierarchy irq_domains */
101 	int (*alloc)(struct irq_domain *d, unsigned int virq,
102 		     unsigned int nr_irqs, void *arg);
103 	void (*free)(struct irq_domain *d, unsigned int virq,
104 		     unsigned int nr_irqs);
105 	int (*activate)(struct irq_domain *d, struct irq_data *irqd, bool reserve);
106 	void (*deactivate)(struct irq_domain *d, struct irq_data *irq_data);
107 	int (*translate)(struct irq_domain *d, struct irq_fwspec *fwspec,
108 			 unsigned long *out_hwirq, unsigned int *out_type);
109 #endif
110 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
111 	void (*debug_show)(struct seq_file *m, struct irq_domain *d,
112 			   struct irq_data *irqd, int ind);
113 #endif
114 };
115 
116 extern const struct irq_domain_ops irq_generic_chip_ops;
117 
118 struct irq_domain_chip_generic;
119 
120 /**
121  * struct irq_domain - Hardware interrupt number translation object
122  * @link:	Element in global irq_domain list.
123  * @name:	Name of interrupt domain
124  * @ops:	Pointer to irq_domain methods
125  * @host_data:	Private data pointer for use by owner.  Not touched by irq_domain
126  *		core code.
127  * @flags:	Per irq_domain flags
128  * @mapcount:	The number of mapped interrupts
129  * @mutex:	Domain lock, hierarchical domains use root domain's lock
130  * @root:	Pointer to root domain, or containing structure if non-hierarchical
131  *
132  * Optional elements:
133  * @fwnode:	Pointer to firmware node associated with the irq_domain. Pretty easy
134  *		to swap it for the of_node via the irq_domain_get_of_node accessor
135  * @gc:		Pointer to a list of generic chips. There is a helper function for
136  *		setting up one or more generic chips for interrupt controllers
137  *		drivers using the generic chip library which uses this pointer.
138  * @dev:	Pointer to the device which instantiated the irqdomain
139  *		With per device irq domains this is not necessarily the same
140  *		as @pm_dev.
141  * @pm_dev:	Pointer to a device that can be utilized for power management
142  *		purposes related to the irq domain.
143  * @parent:	Pointer to parent irq_domain to support hierarchy irq_domains
144  * @msi_parent_ops: Pointer to MSI parent domain methods for per device domain init
145  *
146  * Revmap data, used internally by the irq domain code:
147  * @revmap_size:	Size of the linear map table @revmap[]
148  * @revmap_tree:	Radix map tree for hwirqs that don't fit in the linear map
149  * @revmap:		Linear table of irq_data pointers
150  */
151 struct irq_domain {
152 	struct list_head		link;
153 	const char			*name;
154 	const struct irq_domain_ops	*ops;
155 	void				*host_data;
156 	unsigned int			flags;
157 	unsigned int			mapcount;
158 	struct mutex			mutex;
159 	struct irq_domain		*root;
160 
161 	/* Optional data */
162 	struct fwnode_handle		*fwnode;
163 	enum irq_domain_bus_token	bus_token;
164 	struct irq_domain_chip_generic	*gc;
165 	struct device			*dev;
166 	struct device			*pm_dev;
167 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
168 	struct irq_domain		*parent;
169 #endif
170 #ifdef CONFIG_GENERIC_MSI_IRQ
171 	const struct msi_parent_ops	*msi_parent_ops;
172 #endif
173 
174 	ANDROID_KABI_RESERVE(1);
175 	ANDROID_KABI_RESERVE(2);
176 	ANDROID_KABI_RESERVE(3);
177 	ANDROID_KABI_RESERVE(4);
178 
179 	/* reverse map data. The linear map gets appended to the irq_domain */
180 	irq_hw_number_t			hwirq_max;
181 	unsigned int			revmap_size;
182 	struct radix_tree_root		revmap_tree;
183 	struct irq_data __rcu		*revmap[];
184 };
185 
186 /* Irq domain flags */
187 enum {
188 	/* Irq domain is hierarchical */
189 	IRQ_DOMAIN_FLAG_HIERARCHY	= (1 << 0),
190 
191 	/* Irq domain name was allocated in __irq_domain_add() */
192 	IRQ_DOMAIN_NAME_ALLOCATED	= (1 << 1),
193 
194 	/* Irq domain is an IPI domain with virq per cpu */
195 	IRQ_DOMAIN_FLAG_IPI_PER_CPU	= (1 << 2),
196 
197 	/* Irq domain is an IPI domain with single virq */
198 	IRQ_DOMAIN_FLAG_IPI_SINGLE	= (1 << 3),
199 
200 	/* Irq domain implements MSIs */
201 	IRQ_DOMAIN_FLAG_MSI		= (1 << 4),
202 
203 	/*
204 	 * Irq domain implements isolated MSI, see msi_device_has_isolated_msi()
205 	 */
206 	IRQ_DOMAIN_FLAG_ISOLATED_MSI	= (1 << 5),
207 
208 	/* Irq domain doesn't translate anything */
209 	IRQ_DOMAIN_FLAG_NO_MAP		= (1 << 6),
210 
211 	/* Irq domain is a MSI parent domain */
212 	IRQ_DOMAIN_FLAG_MSI_PARENT	= (1 << 8),
213 
214 	/* Irq domain is a MSI device domain */
215 	IRQ_DOMAIN_FLAG_MSI_DEVICE	= (1 << 9),
216 
217 	/*
218 	 * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved
219 	 * for implementation specific purposes and ignored by the
220 	 * core code.
221 	 */
222 	IRQ_DOMAIN_FLAG_NONCORE		= (1 << 16),
223 };
224 
irq_domain_get_of_node(struct irq_domain * d)225 static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
226 {
227 	return to_of_node(d->fwnode);
228 }
229 
irq_domain_set_pm_device(struct irq_domain * d,struct device * dev)230 static inline void irq_domain_set_pm_device(struct irq_domain *d,
231 					    struct device *dev)
232 {
233 	if (d)
234 		d->pm_dev = dev;
235 }
236 
237 #ifdef CONFIG_IRQ_DOMAIN
238 struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id,
239 						const char *name, phys_addr_t *pa);
240 
241 enum {
242 	IRQCHIP_FWNODE_REAL,
243 	IRQCHIP_FWNODE_NAMED,
244 	IRQCHIP_FWNODE_NAMED_ID,
245 };
246 
247 static inline
irq_domain_alloc_named_fwnode(const char * name)248 struct fwnode_handle *irq_domain_alloc_named_fwnode(const char *name)
249 {
250 	return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED, 0, name, NULL);
251 }
252 
253 static inline
irq_domain_alloc_named_id_fwnode(const char * name,int id)254 struct fwnode_handle *irq_domain_alloc_named_id_fwnode(const char *name, int id)
255 {
256 	return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED_ID, id, name,
257 					 NULL);
258 }
259 
irq_domain_alloc_fwnode(phys_addr_t * pa)260 static inline struct fwnode_handle *irq_domain_alloc_fwnode(phys_addr_t *pa)
261 {
262 	return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_REAL, 0, NULL, pa);
263 }
264 
265 void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
266 struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size,
267 				    irq_hw_number_t hwirq_max, int direct_max,
268 				    const struct irq_domain_ops *ops,
269 				    void *host_data);
270 struct irq_domain *irq_domain_create_simple(struct fwnode_handle *fwnode,
271 					    unsigned int size,
272 					    unsigned int first_irq,
273 					    const struct irq_domain_ops *ops,
274 					    void *host_data);
275 struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
276 					 unsigned int size,
277 					 unsigned int first_irq,
278 					 irq_hw_number_t first_hwirq,
279 					 const struct irq_domain_ops *ops,
280 					 void *host_data);
281 struct irq_domain *irq_domain_create_legacy(struct fwnode_handle *fwnode,
282 					    unsigned int size,
283 					    unsigned int first_irq,
284 					    irq_hw_number_t first_hwirq,
285 					    const struct irq_domain_ops *ops,
286 					    void *host_data);
287 extern struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec,
288 						   enum irq_domain_bus_token bus_token);
289 extern void irq_set_default_host(struct irq_domain *host);
290 extern struct irq_domain *irq_get_default_host(void);
291 extern int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
292 				  irq_hw_number_t hwirq, int node,
293 				  const struct irq_affinity_desc *affinity);
294 
of_node_to_fwnode(struct device_node * node)295 static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
296 {
297 	return node ? &node->fwnode : NULL;
298 }
299 
300 extern const struct fwnode_operations irqchip_fwnode_ops;
301 
is_fwnode_irqchip(struct fwnode_handle * fwnode)302 static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
303 {
304 	return fwnode && fwnode->ops == &irqchip_fwnode_ops;
305 }
306 
307 extern void irq_domain_update_bus_token(struct irq_domain *domain,
308 					enum irq_domain_bus_token bus_token);
309 
310 static inline
irq_find_matching_fwnode(struct fwnode_handle * fwnode,enum irq_domain_bus_token bus_token)311 struct irq_domain *irq_find_matching_fwnode(struct fwnode_handle *fwnode,
312 					    enum irq_domain_bus_token bus_token)
313 {
314 	struct irq_fwspec fwspec = {
315 		.fwnode = fwnode,
316 	};
317 
318 	return irq_find_matching_fwspec(&fwspec, bus_token);
319 }
320 
irq_find_matching_host(struct device_node * node,enum irq_domain_bus_token bus_token)321 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
322 							enum irq_domain_bus_token bus_token)
323 {
324 	return irq_find_matching_fwnode(of_node_to_fwnode(node), bus_token);
325 }
326 
irq_find_host(struct device_node * node)327 static inline struct irq_domain *irq_find_host(struct device_node *node)
328 {
329 	struct irq_domain *d;
330 
331 	d = irq_find_matching_host(node, DOMAIN_BUS_WIRED);
332 	if (!d)
333 		d = irq_find_matching_host(node, DOMAIN_BUS_ANY);
334 
335 	return d;
336 }
337 
irq_domain_add_simple(struct device_node * of_node,unsigned int size,unsigned int first_irq,const struct irq_domain_ops * ops,void * host_data)338 static inline struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
339 						       unsigned int size,
340 						       unsigned int first_irq,
341 						       const struct irq_domain_ops *ops,
342 						       void *host_data)
343 {
344 	return irq_domain_create_simple(of_node_to_fwnode(of_node), size, first_irq, ops, host_data);
345 }
346 
347 /**
348  * irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
349  * @of_node: pointer to interrupt controller's device tree node.
350  * @size: Number of interrupts in the domain.
351  * @ops: map/unmap domain callbacks
352  * @host_data: Controller private data pointer
353  */
irq_domain_add_linear(struct device_node * of_node,unsigned int size,const struct irq_domain_ops * ops,void * host_data)354 static inline struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
355 					 unsigned int size,
356 					 const struct irq_domain_ops *ops,
357 					 void *host_data)
358 {
359 	return __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data);
360 }
361 
362 #ifdef CONFIG_IRQ_DOMAIN_NOMAP
irq_domain_add_nomap(struct device_node * of_node,unsigned int max_irq,const struct irq_domain_ops * ops,void * host_data)363 static inline struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
364 					 unsigned int max_irq,
365 					 const struct irq_domain_ops *ops,
366 					 void *host_data)
367 {
368 	return __irq_domain_add(of_node_to_fwnode(of_node), 0, max_irq, max_irq, ops, host_data);
369 }
370 
371 extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
372 #endif
373 
irq_domain_add_tree(struct device_node * of_node,const struct irq_domain_ops * ops,void * host_data)374 static inline struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
375 					 const struct irq_domain_ops *ops,
376 					 void *host_data)
377 {
378 	return __irq_domain_add(of_node_to_fwnode(of_node), 0, ~0, 0, ops, host_data);
379 }
380 
irq_domain_create_linear(struct fwnode_handle * fwnode,unsigned int size,const struct irq_domain_ops * ops,void * host_data)381 static inline struct irq_domain *irq_domain_create_linear(struct fwnode_handle *fwnode,
382 					 unsigned int size,
383 					 const struct irq_domain_ops *ops,
384 					 void *host_data)
385 {
386 	return __irq_domain_add(fwnode, size, size, 0, ops, host_data);
387 }
388 
irq_domain_create_tree(struct fwnode_handle * fwnode,const struct irq_domain_ops * ops,void * host_data)389 static inline struct irq_domain *irq_domain_create_tree(struct fwnode_handle *fwnode,
390 					 const struct irq_domain_ops *ops,
391 					 void *host_data)
392 {
393 	return __irq_domain_add(fwnode, 0, ~0, 0, ops, host_data);
394 }
395 
396 extern void irq_domain_remove(struct irq_domain *host);
397 
398 extern int irq_domain_associate(struct irq_domain *domain, unsigned int irq,
399 					irq_hw_number_t hwirq);
400 extern void irq_domain_associate_many(struct irq_domain *domain,
401 				      unsigned int irq_base,
402 				      irq_hw_number_t hwirq_base, int count);
403 
404 extern unsigned int irq_create_mapping_affinity(struct irq_domain *host,
405 				      irq_hw_number_t hwirq,
406 				      const struct irq_affinity_desc *affinity);
407 extern unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec);
408 extern void irq_dispose_mapping(unsigned int virq);
409 
irq_create_mapping(struct irq_domain * host,irq_hw_number_t hwirq)410 static inline unsigned int irq_create_mapping(struct irq_domain *host,
411 					      irq_hw_number_t hwirq)
412 {
413 	return irq_create_mapping_affinity(host, hwirq, NULL);
414 }
415 
416 extern struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain,
417 					      irq_hw_number_t hwirq,
418 					      unsigned int *irq);
419 
irq_resolve_mapping(struct irq_domain * domain,irq_hw_number_t hwirq)420 static inline struct irq_desc *irq_resolve_mapping(struct irq_domain *domain,
421 						   irq_hw_number_t hwirq)
422 {
423 	return __irq_resolve_mapping(domain, hwirq, NULL);
424 }
425 
426 /**
427  * irq_find_mapping() - Find a linux irq from a hw irq number.
428  * @domain: domain owning this hardware interrupt
429  * @hwirq: hardware irq number in that domain space
430  */
irq_find_mapping(struct irq_domain * domain,irq_hw_number_t hwirq)431 static inline unsigned int irq_find_mapping(struct irq_domain *domain,
432 					    irq_hw_number_t hwirq)
433 {
434 	unsigned int irq;
435 
436 	if (__irq_resolve_mapping(domain, hwirq, &irq))
437 		return irq;
438 
439 	return 0;
440 }
441 
irq_linear_revmap(struct irq_domain * domain,irq_hw_number_t hwirq)442 static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
443 					     irq_hw_number_t hwirq)
444 {
445 	return irq_find_mapping(domain, hwirq);
446 }
447 
448 extern const struct irq_domain_ops irq_domain_simple_ops;
449 
450 /* stock xlate functions */
451 int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
452 			const u32 *intspec, unsigned int intsize,
453 			irq_hw_number_t *out_hwirq, unsigned int *out_type);
454 int irq_domain_xlate_twocell(struct irq_domain *d, struct device_node *ctrlr,
455 			const u32 *intspec, unsigned int intsize,
456 			irq_hw_number_t *out_hwirq, unsigned int *out_type);
457 int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
458 			const u32 *intspec, unsigned int intsize,
459 			irq_hw_number_t *out_hwirq, unsigned int *out_type);
460 
461 int irq_domain_translate_twocell(struct irq_domain *d,
462 				 struct irq_fwspec *fwspec,
463 				 unsigned long *out_hwirq,
464 				 unsigned int *out_type);
465 
466 int irq_domain_translate_onecell(struct irq_domain *d,
467 				 struct irq_fwspec *fwspec,
468 				 unsigned long *out_hwirq,
469 				 unsigned int *out_type);
470 
471 /* IPI functions */
472 int irq_reserve_ipi(struct irq_domain *domain, const struct cpumask *dest);
473 int irq_destroy_ipi(unsigned int irq, const struct cpumask *dest);
474 
475 /* V2 interfaces to support hierarchy IRQ domains. */
476 extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
477 						unsigned int virq);
478 extern void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
479 				irq_hw_number_t hwirq,
480 				const struct irq_chip *chip,
481 				void *chip_data, irq_flow_handler_t handler,
482 				void *handler_data, const char *handler_name);
483 extern void irq_domain_reset_irq_data(struct irq_data *irq_data);
484 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
485 extern struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
486 			unsigned int flags, unsigned int size,
487 			struct fwnode_handle *fwnode,
488 			const struct irq_domain_ops *ops, void *host_data);
489 
irq_domain_add_hierarchy(struct irq_domain * parent,unsigned int flags,unsigned int size,struct device_node * node,const struct irq_domain_ops * ops,void * host_data)490 static inline struct irq_domain *irq_domain_add_hierarchy(struct irq_domain *parent,
491 					    unsigned int flags,
492 					    unsigned int size,
493 					    struct device_node *node,
494 					    const struct irq_domain_ops *ops,
495 					    void *host_data)
496 {
497 	return irq_domain_create_hierarchy(parent, flags, size,
498 					   of_node_to_fwnode(node),
499 					   ops, host_data);
500 }
501 
502 extern int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
503 				   unsigned int nr_irqs, int node, void *arg,
504 				   bool realloc,
505 				   const struct irq_affinity_desc *affinity);
506 extern void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs);
507 extern int irq_domain_activate_irq(struct irq_data *irq_data, bool early);
508 extern void irq_domain_deactivate_irq(struct irq_data *irq_data);
509 
irq_domain_alloc_irqs(struct irq_domain * domain,unsigned int nr_irqs,int node,void * arg)510 static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
511 			unsigned int nr_irqs, int node, void *arg)
512 {
513 	return __irq_domain_alloc_irqs(domain, -1, nr_irqs, node, arg, false,
514 				       NULL);
515 }
516 
517 extern int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
518 					   unsigned int irq_base,
519 					   unsigned int nr_irqs, void *arg);
520 extern int irq_domain_set_hwirq_and_chip(struct irq_domain *domain,
521 					 unsigned int virq,
522 					 irq_hw_number_t hwirq,
523 					 const struct irq_chip *chip,
524 					 void *chip_data);
525 extern void irq_domain_free_irqs_common(struct irq_domain *domain,
526 					unsigned int virq,
527 					unsigned int nr_irqs);
528 extern void irq_domain_free_irqs_top(struct irq_domain *domain,
529 				     unsigned int virq, unsigned int nr_irqs);
530 
531 extern int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg);
532 extern int irq_domain_pop_irq(struct irq_domain *domain, int virq);
533 
534 extern int irq_domain_alloc_irqs_parent(struct irq_domain *domain,
535 					unsigned int irq_base,
536 					unsigned int nr_irqs, void *arg);
537 
538 extern void irq_domain_free_irqs_parent(struct irq_domain *domain,
539 					unsigned int irq_base,
540 					unsigned int nr_irqs);
541 
542 extern int irq_domain_disconnect_hierarchy(struct irq_domain *domain,
543 					   unsigned int virq);
544 
irq_domain_is_hierarchy(struct irq_domain * domain)545 static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
546 {
547 	return domain->flags & IRQ_DOMAIN_FLAG_HIERARCHY;
548 }
549 
irq_domain_is_ipi(struct irq_domain * domain)550 static inline bool irq_domain_is_ipi(struct irq_domain *domain)
551 {
552 	return domain->flags &
553 		(IRQ_DOMAIN_FLAG_IPI_PER_CPU | IRQ_DOMAIN_FLAG_IPI_SINGLE);
554 }
555 
irq_domain_is_ipi_per_cpu(struct irq_domain * domain)556 static inline bool irq_domain_is_ipi_per_cpu(struct irq_domain *domain)
557 {
558 	return domain->flags & IRQ_DOMAIN_FLAG_IPI_PER_CPU;
559 }
560 
irq_domain_is_ipi_single(struct irq_domain * domain)561 static inline bool irq_domain_is_ipi_single(struct irq_domain *domain)
562 {
563 	return domain->flags & IRQ_DOMAIN_FLAG_IPI_SINGLE;
564 }
565 
irq_domain_is_msi(struct irq_domain * domain)566 static inline bool irq_domain_is_msi(struct irq_domain *domain)
567 {
568 	return domain->flags & IRQ_DOMAIN_FLAG_MSI;
569 }
570 
irq_domain_is_msi_parent(struct irq_domain * domain)571 static inline bool irq_domain_is_msi_parent(struct irq_domain *domain)
572 {
573 	return domain->flags & IRQ_DOMAIN_FLAG_MSI_PARENT;
574 }
575 
irq_domain_is_msi_device(struct irq_domain * domain)576 static inline bool irq_domain_is_msi_device(struct irq_domain *domain)
577 {
578 	return domain->flags & IRQ_DOMAIN_FLAG_MSI_DEVICE;
579 }
580 
581 #else	/* CONFIG_IRQ_DOMAIN_HIERARCHY */
irq_domain_alloc_irqs(struct irq_domain * domain,unsigned int nr_irqs,int node,void * arg)582 static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
583 			unsigned int nr_irqs, int node, void *arg)
584 {
585 	return -1;
586 }
587 
irq_domain_free_irqs(unsigned int virq,unsigned int nr_irqs)588 static inline void irq_domain_free_irqs(unsigned int virq,
589 					unsigned int nr_irqs) { }
590 
irq_domain_is_hierarchy(struct irq_domain * domain)591 static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
592 {
593 	return false;
594 }
595 
irq_domain_is_ipi(struct irq_domain * domain)596 static inline bool irq_domain_is_ipi(struct irq_domain *domain)
597 {
598 	return false;
599 }
600 
irq_domain_is_ipi_per_cpu(struct irq_domain * domain)601 static inline bool irq_domain_is_ipi_per_cpu(struct irq_domain *domain)
602 {
603 	return false;
604 }
605 
irq_domain_is_ipi_single(struct irq_domain * domain)606 static inline bool irq_domain_is_ipi_single(struct irq_domain *domain)
607 {
608 	return false;
609 }
610 
irq_domain_is_msi(struct irq_domain * domain)611 static inline bool irq_domain_is_msi(struct irq_domain *domain)
612 {
613 	return false;
614 }
615 
irq_domain_is_msi_parent(struct irq_domain * domain)616 static inline bool irq_domain_is_msi_parent(struct irq_domain *domain)
617 {
618 	return false;
619 }
620 
irq_domain_is_msi_device(struct irq_domain * domain)621 static inline bool irq_domain_is_msi_device(struct irq_domain *domain)
622 {
623 	return false;
624 }
625 
626 #endif	/* CONFIG_IRQ_DOMAIN_HIERARCHY */
627 
628 #else /* CONFIG_IRQ_DOMAIN */
irq_dispose_mapping(unsigned int virq)629 static inline void irq_dispose_mapping(unsigned int virq) { }
irq_find_matching_fwnode(struct fwnode_handle * fwnode,enum irq_domain_bus_token bus_token)630 static inline struct irq_domain *irq_find_matching_fwnode(
631 	struct fwnode_handle *fwnode, enum irq_domain_bus_token bus_token)
632 {
633 	return NULL;
634 }
635 #endif /* !CONFIG_IRQ_DOMAIN */
636 
637 #endif /* _LINUX_IRQDOMAIN_H */
638