• 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/irqhandler.h>
35 #include <linux/of.h>
36 #include <linux/mutex.h>
37 #include <linux/radix-tree.h>
38 #include <linux/android_kabi.h>
39 
40 struct device_node;
41 struct irq_domain;
42 struct of_device_id;
43 struct irq_chip;
44 struct irq_data;
45 struct cpumask;
46 struct seq_file;
47 struct irq_affinity_desc;
48 
49 /* Number of irqs reserved for a legacy isa controller */
50 #define NUM_ISA_INTERRUPTS	16
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 /*
71  * Should several domains have the same device node, but serve
72  * different purposes (for example one domain is for PCI/MSI, and the
73  * other for wired IRQs), they can be distinguished using a
74  * bus-specific token. Most domains are expected to only carry
75  * DOMAIN_BUS_ANY.
76  */
77 enum irq_domain_bus_token {
78 	DOMAIN_BUS_ANY		= 0,
79 	DOMAIN_BUS_WIRED,
80 	DOMAIN_BUS_GENERIC_MSI,
81 	DOMAIN_BUS_PCI_MSI,
82 	DOMAIN_BUS_PLATFORM_MSI,
83 	DOMAIN_BUS_NEXUS,
84 	DOMAIN_BUS_IPI,
85 	DOMAIN_BUS_FSL_MC_MSI,
86 	DOMAIN_BUS_TI_SCI_INTA_MSI,
87 	DOMAIN_BUS_WAKEUP,
88 };
89 
90 /**
91  * struct irq_domain_ops - Methods for irq_domain objects
92  * @match: Match an interrupt controller device node to a host, returns
93  *         1 on a match
94  * @map: Create or update a mapping between a virtual irq number and a hw
95  *       irq number. This is called only once for a given mapping.
96  * @unmap: Dispose of such a mapping
97  * @xlate: Given a device tree node and interrupt specifier, decode
98  *         the hardware irq number and linux irq type value.
99  *
100  * Functions below are provided by the driver and called whenever a new mapping
101  * is created or an old mapping is disposed. The driver can then proceed to
102  * whatever internal data structures management is required. It also needs
103  * to setup the irq_desc when returning from map().
104  */
105 struct irq_domain_ops {
106 	int (*match)(struct irq_domain *d, struct device_node *node,
107 		     enum irq_domain_bus_token bus_token);
108 	int (*select)(struct irq_domain *d, struct irq_fwspec *fwspec,
109 		      enum irq_domain_bus_token bus_token);
110 	int (*map)(struct irq_domain *d, unsigned int virq, irq_hw_number_t hw);
111 	void (*unmap)(struct irq_domain *d, unsigned int virq);
112 	int (*xlate)(struct irq_domain *d, struct device_node *node,
113 		     const u32 *intspec, unsigned int intsize,
114 		     unsigned long *out_hwirq, unsigned int *out_type);
115 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
116 	/* extended V2 interfaces to support hierarchy irq_domains */
117 	int (*alloc)(struct irq_domain *d, unsigned int virq,
118 		     unsigned int nr_irqs, void *arg);
119 	void (*free)(struct irq_domain *d, unsigned int virq,
120 		     unsigned int nr_irqs);
121 	int (*activate)(struct irq_domain *d, struct irq_data *irqd, bool reserve);
122 	void (*deactivate)(struct irq_domain *d, struct irq_data *irq_data);
123 	int (*translate)(struct irq_domain *d, struct irq_fwspec *fwspec,
124 			 unsigned long *out_hwirq, unsigned int *out_type);
125 #endif
126 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
127 	void (*debug_show)(struct seq_file *m, struct irq_domain *d,
128 			   struct irq_data *irqd, int ind);
129 #endif
130 };
131 
132 extern struct irq_domain_ops irq_generic_chip_ops;
133 
134 struct irq_domain_chip_generic;
135 
136 /**
137  * struct irq_domain - Hardware interrupt number translation object
138  * @link: Element in global irq_domain list.
139  * @name: Name of interrupt domain
140  * @ops: pointer to irq_domain methods
141  * @host_data: private data pointer for use by owner.  Not touched by irq_domain
142  *             core code.
143  * @flags: host per irq_domain flags
144  * @mapcount: The number of mapped interrupts
145  *
146  * Optional elements
147  * @fwnode: Pointer to firmware node associated with the irq_domain. Pretty easy
148  *          to swap it for the of_node via the irq_domain_get_of_node accessor
149  * @gc: Pointer to a list of generic chips. There is a helper function for
150  *      setting up one or more generic chips for interrupt controllers
151  *      drivers using the generic chip library which uses this pointer.
152  * @parent: Pointer to parent irq_domain to support hierarchy irq_domains
153  * @debugfs_file: dentry for the domain debugfs file
154  *
155  * Revmap data, used internally by irq_domain
156  * @revmap_direct_max_irq: The largest hwirq that can be set for controllers that
157  *                         support direct mapping
158  * @revmap_size: Size of the linear map table @linear_revmap[]
159  * @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map
160  * @linear_revmap: Linear table of hwirq->virq reverse mappings
161  */
162 struct irq_domain {
163 	struct list_head link;
164 	const char *name;
165 	const struct irq_domain_ops *ops;
166 	void *host_data;
167 	unsigned int flags;
168 	unsigned int mapcount;
169 
170 	/* Optional data */
171 	struct fwnode_handle *fwnode;
172 	enum irq_domain_bus_token bus_token;
173 	struct irq_domain_chip_generic *gc;
174 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
175 	struct irq_domain *parent;
176 #endif
177 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
178 	struct dentry		*debugfs_file;
179 #endif
180 
181 	ANDROID_KABI_RESERVE(1);
182 	ANDROID_KABI_RESERVE(2);
183 	ANDROID_KABI_RESERVE(3);
184 	ANDROID_KABI_RESERVE(4);
185 
186 	/* reverse map data. The linear map gets appended to the irq_domain */
187 	irq_hw_number_t hwirq_max;
188 	unsigned int revmap_direct_max_irq;
189 	unsigned int revmap_size;
190 	struct radix_tree_root revmap_tree;
191 	struct mutex revmap_tree_mutex;
192 	unsigned int linear_revmap[];
193 };
194 
195 /* Irq domain flags */
196 enum {
197 	/* Irq domain is hierarchical */
198 	IRQ_DOMAIN_FLAG_HIERARCHY	= (1 << 0),
199 
200 	/* Irq domain name was allocated in __irq_domain_add() */
201 	IRQ_DOMAIN_NAME_ALLOCATED	= (1 << 1),
202 
203 	/* Irq domain is an IPI domain with virq per cpu */
204 	IRQ_DOMAIN_FLAG_IPI_PER_CPU	= (1 << 2),
205 
206 	/* Irq domain is an IPI domain with single virq */
207 	IRQ_DOMAIN_FLAG_IPI_SINGLE	= (1 << 3),
208 
209 	/* Irq domain implements MSIs */
210 	IRQ_DOMAIN_FLAG_MSI		= (1 << 4),
211 
212 	/* Irq domain implements MSI remapping */
213 	IRQ_DOMAIN_FLAG_MSI_REMAP	= (1 << 5),
214 
215 	/*
216 	 * Quirk to handle MSI implementations which do not provide
217 	 * masking. Currently known to affect x86, but partially
218 	 * handled in core code.
219 	 */
220 	IRQ_DOMAIN_MSI_NOMASK_QUIRK	= (1 << 6),
221 
222 	/*
223 	 * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved
224 	 * for implementation specific purposes and ignored by the
225 	 * core code.
226 	 */
227 	IRQ_DOMAIN_FLAG_NONCORE		= (1 << 16),
228 };
229 
irq_domain_get_of_node(struct irq_domain * d)230 static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
231 {
232 	return to_of_node(d->fwnode);
233 }
234 
235 #ifdef CONFIG_IRQ_DOMAIN
236 struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id,
237 						const char *name, phys_addr_t *pa);
238 
239 enum {
240 	IRQCHIP_FWNODE_REAL,
241 	IRQCHIP_FWNODE_NAMED,
242 	IRQCHIP_FWNODE_NAMED_ID,
243 };
244 
245 static inline
irq_domain_alloc_named_fwnode(const char * name)246 struct fwnode_handle *irq_domain_alloc_named_fwnode(const char *name)
247 {
248 	return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED, 0, name, NULL);
249 }
250 
251 static inline
irq_domain_alloc_named_id_fwnode(const char * name,int id)252 struct fwnode_handle *irq_domain_alloc_named_id_fwnode(const char *name, int id)
253 {
254 	return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED_ID, id, name,
255 					 NULL);
256 }
257 
irq_domain_alloc_fwnode(phys_addr_t * pa)258 static inline struct fwnode_handle *irq_domain_alloc_fwnode(phys_addr_t *pa)
259 {
260 	return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_REAL, 0, NULL, pa);
261 }
262 
263 void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
264 #ifdef __GENKSYMS__	/* Android KABI hack to preserve CRC checker */
265 struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
266 #else
267 struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size,
268 #endif
269 				    irq_hw_number_t hwirq_max, int direct_max,
270 				    const struct irq_domain_ops *ops,
271 				    void *host_data);
272 struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
273 					 unsigned int size,
274 					 unsigned int first_irq,
275 					 const struct irq_domain_ops *ops,
276 					 void *host_data);
277 struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
278 					 unsigned int size,
279 					 unsigned int first_irq,
280 					 irq_hw_number_t first_hwirq,
281 					 const struct irq_domain_ops *ops,
282 					 void *host_data);
283 extern struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec,
284 						   enum irq_domain_bus_token bus_token);
285 extern bool irq_domain_check_msi_remap(void);
286 extern void irq_set_default_host(struct irq_domain *host);
287 extern struct irq_domain *irq_get_default_host(void);
288 extern int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
289 				  irq_hw_number_t hwirq, int node,
290 				  const struct irq_affinity_desc *affinity);
291 
of_node_to_fwnode(struct device_node * node)292 static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
293 {
294 	return node ? &node->fwnode : NULL;
295 }
296 
297 extern const struct fwnode_operations irqchip_fwnode_ops;
298 
is_fwnode_irqchip(struct fwnode_handle * fwnode)299 static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
300 {
301 	return fwnode && fwnode->ops == &irqchip_fwnode_ops;
302 }
303 
304 extern void irq_domain_update_bus_token(struct irq_domain *domain,
305 					enum irq_domain_bus_token bus_token);
306 
307 static inline
irq_find_matching_fwnode(struct fwnode_handle * fwnode,enum irq_domain_bus_token bus_token)308 struct irq_domain *irq_find_matching_fwnode(struct fwnode_handle *fwnode,
309 					    enum irq_domain_bus_token bus_token)
310 {
311 	struct irq_fwspec fwspec = {
312 		.fwnode = fwnode,
313 	};
314 
315 	return irq_find_matching_fwspec(&fwspec, bus_token);
316 }
317 
irq_find_matching_host(struct device_node * node,enum irq_domain_bus_token bus_token)318 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
319 							enum irq_domain_bus_token bus_token)
320 {
321 	return irq_find_matching_fwnode(of_node_to_fwnode(node), bus_token);
322 }
323 
irq_find_host(struct device_node * node)324 static inline struct irq_domain *irq_find_host(struct device_node *node)
325 {
326 	struct irq_domain *d;
327 
328 	d = irq_find_matching_host(node, DOMAIN_BUS_WIRED);
329 	if (!d)
330 		d = irq_find_matching_host(node, DOMAIN_BUS_ANY);
331 
332 	return d;
333 }
334 
335 /**
336  * irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
337  * @of_node: pointer to interrupt controller's device tree node.
338  * @size: Number of interrupts in the domain.
339  * @ops: map/unmap domain callbacks
340  * @host_data: Controller private data pointer
341  */
irq_domain_add_linear(struct device_node * of_node,unsigned int size,const struct irq_domain_ops * ops,void * host_data)342 static inline struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
343 					 unsigned int size,
344 					 const struct irq_domain_ops *ops,
345 					 void *host_data)
346 {
347 	return __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data);
348 }
irq_domain_add_nomap(struct device_node * of_node,unsigned int max_irq,const struct irq_domain_ops * ops,void * host_data)349 static inline struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
350 					 unsigned int max_irq,
351 					 const struct irq_domain_ops *ops,
352 					 void *host_data)
353 {
354 	return __irq_domain_add(of_node_to_fwnode(of_node), 0, max_irq, max_irq, ops, host_data);
355 }
irq_domain_add_legacy_isa(struct device_node * of_node,const struct irq_domain_ops * ops,void * host_data)356 static inline struct irq_domain *irq_domain_add_legacy_isa(
357 				struct device_node *of_node,
358 				const struct irq_domain_ops *ops,
359 				void *host_data)
360 {
361 	return irq_domain_add_legacy(of_node, NUM_ISA_INTERRUPTS, 0, 0, ops,
362 				     host_data);
363 }
irq_domain_add_tree(struct device_node * of_node,const struct irq_domain_ops * ops,void * host_data)364 static inline struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
365 					 const struct irq_domain_ops *ops,
366 					 void *host_data)
367 {
368 	return __irq_domain_add(of_node_to_fwnode(of_node), 0, ~0, 0, ops, host_data);
369 }
370 
irq_domain_create_linear(struct fwnode_handle * fwnode,unsigned int size,const struct irq_domain_ops * ops,void * host_data)371 static inline struct irq_domain *irq_domain_create_linear(struct fwnode_handle *fwnode,
372 					 unsigned int size,
373 					 const struct irq_domain_ops *ops,
374 					 void *host_data)
375 {
376 	return __irq_domain_add(fwnode, size, size, 0, ops, host_data);
377 }
378 
irq_domain_create_tree(struct fwnode_handle * fwnode,const struct irq_domain_ops * ops,void * host_data)379 static inline struct irq_domain *irq_domain_create_tree(struct fwnode_handle *fwnode,
380 					 const struct irq_domain_ops *ops,
381 					 void *host_data)
382 {
383 	return __irq_domain_add(fwnode, 0, ~0, 0, ops, host_data);
384 }
385 
386 extern void irq_domain_remove(struct irq_domain *host);
387 
388 extern int irq_domain_associate(struct irq_domain *domain, unsigned int irq,
389 					irq_hw_number_t hwirq);
390 extern void irq_domain_associate_many(struct irq_domain *domain,
391 				      unsigned int irq_base,
392 				      irq_hw_number_t hwirq_base, int count);
393 extern void irq_domain_disassociate(struct irq_domain *domain,
394 				    unsigned int irq);
395 
396 extern unsigned int irq_create_mapping_affinity(struct irq_domain *host,
397 				      irq_hw_number_t hwirq,
398 				      const struct irq_affinity_desc *affinity);
399 unsigned int irq_create_mapping(struct irq_domain *host, irq_hw_number_t hwirq);
400 extern unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec);
401 extern void irq_dispose_mapping(unsigned int virq);
402 
403 /**
404  * irq_linear_revmap() - Find a linux irq from a hw irq number.
405  * @domain: domain owning this hardware interrupt
406  * @hwirq: hardware irq number in that domain space
407  *
408  * This is a fast path alternative to irq_find_mapping() that can be
409  * called directly by irq controller code to save a handful of
410  * instructions. It is always safe to call, but won't find irqs mapped
411  * using the radix tree.
412  */
irq_linear_revmap(struct irq_domain * domain,irq_hw_number_t hwirq)413 static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
414 					     irq_hw_number_t hwirq)
415 {
416 	return hwirq < domain->revmap_size ? domain->linear_revmap[hwirq] : 0;
417 }
418 extern unsigned int irq_find_mapping(struct irq_domain *host,
419 				     irq_hw_number_t hwirq);
420 extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
421 extern int irq_create_strict_mappings(struct irq_domain *domain,
422 				      unsigned int irq_base,
423 				      irq_hw_number_t hwirq_base, int count);
424 
irq_create_identity_mapping(struct irq_domain * host,irq_hw_number_t hwirq)425 static inline int irq_create_identity_mapping(struct irq_domain *host,
426 					      irq_hw_number_t hwirq)
427 {
428 	return irq_create_strict_mappings(host, hwirq, hwirq, 1);
429 }
430 
431 extern const struct irq_domain_ops irq_domain_simple_ops;
432 
433 /* stock xlate functions */
434 int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
435 			const u32 *intspec, unsigned int intsize,
436 			irq_hw_number_t *out_hwirq, unsigned int *out_type);
437 int irq_domain_xlate_twocell(struct irq_domain *d, struct device_node *ctrlr,
438 			const u32 *intspec, unsigned int intsize,
439 			irq_hw_number_t *out_hwirq, unsigned int *out_type);
440 int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
441 			const u32 *intspec, unsigned int intsize,
442 			irq_hw_number_t *out_hwirq, unsigned int *out_type);
443 
444 int irq_domain_translate_twocell(struct irq_domain *d,
445 				 struct irq_fwspec *fwspec,
446 				 unsigned long *out_hwirq,
447 				 unsigned int *out_type);
448 
449 /* IPI functions */
450 int irq_reserve_ipi(struct irq_domain *domain, const struct cpumask *dest);
451 int irq_destroy_ipi(unsigned int irq, const struct cpumask *dest);
452 
453 /* V2 interfaces to support hierarchy IRQ domains. */
454 extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
455 						unsigned int virq);
456 extern void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
457 				irq_hw_number_t hwirq, struct irq_chip *chip,
458 				void *chip_data, irq_flow_handler_t handler,
459 				void *handler_data, const char *handler_name);
460 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
461 extern struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
462 			unsigned int flags, unsigned int size,
463 			struct fwnode_handle *fwnode,
464 			const struct irq_domain_ops *ops, void *host_data);
465 
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)466 static inline struct irq_domain *irq_domain_add_hierarchy(struct irq_domain *parent,
467 					    unsigned int flags,
468 					    unsigned int size,
469 					    struct device_node *node,
470 					    const struct irq_domain_ops *ops,
471 					    void *host_data)
472 {
473 	return irq_domain_create_hierarchy(parent, flags, size,
474 					   of_node_to_fwnode(node),
475 					   ops, host_data);
476 }
477 
478 extern int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
479 				   unsigned int nr_irqs, int node, void *arg,
480 				   bool realloc,
481 				   const struct irq_affinity_desc *affinity);
482 extern void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs);
483 extern int irq_domain_activate_irq(struct irq_data *irq_data, bool early);
484 extern void irq_domain_deactivate_irq(struct irq_data *irq_data);
485 
irq_domain_alloc_irqs(struct irq_domain * domain,unsigned int nr_irqs,int node,void * arg)486 static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
487 			unsigned int nr_irqs, int node, void *arg)
488 {
489 	return __irq_domain_alloc_irqs(domain, -1, nr_irqs, node, arg, false,
490 				       NULL);
491 }
492 
493 extern int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
494 					   unsigned int irq_base,
495 					   unsigned int nr_irqs, void *arg);
496 extern int irq_domain_set_hwirq_and_chip(struct irq_domain *domain,
497 					 unsigned int virq,
498 					 irq_hw_number_t hwirq,
499 					 struct irq_chip *chip,
500 					 void *chip_data);
501 extern void irq_domain_reset_irq_data(struct irq_data *irq_data);
502 extern void irq_domain_free_irqs_common(struct irq_domain *domain,
503 					unsigned int virq,
504 					unsigned int nr_irqs);
505 extern void irq_domain_free_irqs_top(struct irq_domain *domain,
506 				     unsigned int virq, unsigned int nr_irqs);
507 
508 extern int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg);
509 extern int irq_domain_pop_irq(struct irq_domain *domain, int virq);
510 
511 extern int irq_domain_alloc_irqs_parent(struct irq_domain *domain,
512 					unsigned int irq_base,
513 					unsigned int nr_irqs, void *arg);
514 
515 extern void irq_domain_free_irqs_parent(struct irq_domain *domain,
516 					unsigned int irq_base,
517 					unsigned int nr_irqs);
518 
irq_domain_is_hierarchy(struct irq_domain * domain)519 static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
520 {
521 	return domain->flags & IRQ_DOMAIN_FLAG_HIERARCHY;
522 }
523 
irq_domain_is_ipi(struct irq_domain * domain)524 static inline bool irq_domain_is_ipi(struct irq_domain *domain)
525 {
526 	return domain->flags &
527 		(IRQ_DOMAIN_FLAG_IPI_PER_CPU | IRQ_DOMAIN_FLAG_IPI_SINGLE);
528 }
529 
irq_domain_is_ipi_per_cpu(struct irq_domain * domain)530 static inline bool irq_domain_is_ipi_per_cpu(struct irq_domain *domain)
531 {
532 	return domain->flags & IRQ_DOMAIN_FLAG_IPI_PER_CPU;
533 }
534 
irq_domain_is_ipi_single(struct irq_domain * domain)535 static inline bool irq_domain_is_ipi_single(struct irq_domain *domain)
536 {
537 	return domain->flags & IRQ_DOMAIN_FLAG_IPI_SINGLE;
538 }
539 
irq_domain_is_msi(struct irq_domain * domain)540 static inline bool irq_domain_is_msi(struct irq_domain *domain)
541 {
542 	return domain->flags & IRQ_DOMAIN_FLAG_MSI;
543 }
544 
irq_domain_is_msi_remap(struct irq_domain * domain)545 static inline bool irq_domain_is_msi_remap(struct irq_domain *domain)
546 {
547 	return domain->flags & IRQ_DOMAIN_FLAG_MSI_REMAP;
548 }
549 
550 extern bool irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain);
551 
552 #else	/* CONFIG_IRQ_DOMAIN_HIERARCHY */
irq_domain_alloc_irqs(struct irq_domain * domain,unsigned int nr_irqs,int node,void * arg)553 static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
554 			unsigned int nr_irqs, int node, void *arg)
555 {
556 	return -1;
557 }
558 
irq_domain_free_irqs(unsigned int virq,unsigned int nr_irqs)559 static inline void irq_domain_free_irqs(unsigned int virq,
560 					unsigned int nr_irqs) { }
561 
irq_domain_is_hierarchy(struct irq_domain * domain)562 static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
563 {
564 	return false;
565 }
566 
irq_domain_is_ipi(struct irq_domain * domain)567 static inline bool irq_domain_is_ipi(struct irq_domain *domain)
568 {
569 	return false;
570 }
571 
irq_domain_is_ipi_per_cpu(struct irq_domain * domain)572 static inline bool irq_domain_is_ipi_per_cpu(struct irq_domain *domain)
573 {
574 	return false;
575 }
576 
irq_domain_is_ipi_single(struct irq_domain * domain)577 static inline bool irq_domain_is_ipi_single(struct irq_domain *domain)
578 {
579 	return false;
580 }
581 
irq_domain_is_msi(struct irq_domain * domain)582 static inline bool irq_domain_is_msi(struct irq_domain *domain)
583 {
584 	return false;
585 }
586 
irq_domain_is_msi_remap(struct irq_domain * domain)587 static inline bool irq_domain_is_msi_remap(struct irq_domain *domain)
588 {
589 	return false;
590 }
591 
592 static inline bool
irq_domain_hierarchical_is_msi_remap(struct irq_domain * domain)593 irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain)
594 {
595 	return false;
596 }
597 #endif	/* CONFIG_IRQ_DOMAIN_HIERARCHY */
598 
599 #else /* CONFIG_IRQ_DOMAIN */
irq_dispose_mapping(unsigned int virq)600 static inline void irq_dispose_mapping(unsigned int virq) { }
irq_find_matching_fwnode(struct fwnode_handle * fwnode,enum irq_domain_bus_token bus_token)601 static inline struct irq_domain *irq_find_matching_fwnode(
602 	struct fwnode_handle *fwnode, enum irq_domain_bus_token bus_token)
603 {
604 	return NULL;
605 }
irq_domain_check_msi_remap(void)606 static inline bool irq_domain_check_msi_remap(void)
607 {
608 	return false;
609 }
610 #endif /* !CONFIG_IRQ_DOMAIN */
611 
612 #endif /* _LINUX_IRQDOMAIN_H */
613