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