Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * irq_domain - IRQ translation domains
0004  *
0005  * Translation infrastructure between hw and linux irq numbers.  This is
0006  * helpful for interrupt controllers to implement mapping between hardware
0007  * irq numbers and the Linux irq number space.
0008  *
0009  * irq_domains also have hooks for translating device tree or other
0010  * firmware interrupt representations into a hardware irq number that
0011  * can be mapped back to a Linux irq number without any extra platform
0012  * support code.
0013  *
0014  * Interrupt controller "domain" data structure. This could be defined as a
0015  * irq domain controller. That is, it handles the mapping between hardware
0016  * and virtual interrupt numbers for a given interrupt domain. The domain
0017  * structure is generally created by the PIC code for a given PIC instance
0018  * (though a domain can cover more than one PIC if they have a flat number
0019  * model). It's the domain callbacks that are responsible for setting the
0020  * irq_chip on a given irq_desc after it's been mapped.
0021  *
0022  * The host code and data structures use a fwnode_handle pointer to
0023  * identify the domain. In some cases, and in order to preserve source
0024  * code compatibility, this fwnode pointer is "upgraded" to a DT
0025  * device_node. For those firmware infrastructures that do not provide
0026  * a unique identifier for an interrupt controller, the irq_domain
0027  * code offers a fwnode allocator.
0028  */
0029 
0030 #ifndef _LINUX_IRQDOMAIN_H
0031 #define _LINUX_IRQDOMAIN_H
0032 
0033 #include <linux/types.h>
0034 #include <linux/irqhandler.h>
0035 #include <linux/of.h>
0036 #include <linux/mutex.h>
0037 #include <linux/radix-tree.h>
0038 
0039 struct device_node;
0040 struct fwnode_handle;
0041 struct irq_domain;
0042 struct irq_chip;
0043 struct irq_data;
0044 struct irq_desc;
0045 struct cpumask;
0046 struct seq_file;
0047 struct irq_affinity_desc;
0048 
0049 #define IRQ_DOMAIN_IRQ_SPEC_PARAMS 16
0050 
0051 /**
0052  * struct irq_fwspec - generic IRQ specifier structure
0053  *
0054  * @fwnode:     Pointer to a firmware-specific descriptor
0055  * @param_count:    Number of device-specific parameters
0056  * @param:      Device-specific parameters
0057  *
0058  * This structure, directly modeled after of_phandle_args, is used to
0059  * pass a device-specific description of an interrupt.
0060  */
0061 struct irq_fwspec {
0062     struct fwnode_handle *fwnode;
0063     int param_count;
0064     u32 param[IRQ_DOMAIN_IRQ_SPEC_PARAMS];
0065 };
0066 
0067 /* Conversion function from of_phandle_args fields to fwspec  */
0068 void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args,
0069                    unsigned int count, struct irq_fwspec *fwspec);
0070 
0071 /*
0072  * Should several domains have the same device node, but serve
0073  * different purposes (for example one domain is for PCI/MSI, and the
0074  * other for wired IRQs), they can be distinguished using a
0075  * bus-specific token. Most domains are expected to only carry
0076  * DOMAIN_BUS_ANY.
0077  */
0078 enum irq_domain_bus_token {
0079     DOMAIN_BUS_ANY      = 0,
0080     DOMAIN_BUS_WIRED,
0081     DOMAIN_BUS_GENERIC_MSI,
0082     DOMAIN_BUS_PCI_MSI,
0083     DOMAIN_BUS_PLATFORM_MSI,
0084     DOMAIN_BUS_NEXUS,
0085     DOMAIN_BUS_IPI,
0086     DOMAIN_BUS_FSL_MC_MSI,
0087     DOMAIN_BUS_TI_SCI_INTA_MSI,
0088     DOMAIN_BUS_WAKEUP,
0089     DOMAIN_BUS_VMD_MSI,
0090 };
0091 
0092 /**
0093  * struct irq_domain_ops - Methods for irq_domain objects
0094  * @match: Match an interrupt controller device node to a host, returns
0095  *         1 on a match
0096  * @map: Create or update a mapping between a virtual irq number and a hw
0097  *       irq number. This is called only once for a given mapping.
0098  * @unmap: Dispose of such a mapping
0099  * @xlate: Given a device tree node and interrupt specifier, decode
0100  *         the hardware irq number and linux irq type value.
0101  *
0102  * Functions below are provided by the driver and called whenever a new mapping
0103  * is created or an old mapping is disposed. The driver can then proceed to
0104  * whatever internal data structures management is required. It also needs
0105  * to setup the irq_desc when returning from map().
0106  */
0107 struct irq_domain_ops {
0108     int (*match)(struct irq_domain *d, struct device_node *node,
0109              enum irq_domain_bus_token bus_token);
0110     int (*select)(struct irq_domain *d, struct irq_fwspec *fwspec,
0111               enum irq_domain_bus_token bus_token);
0112     int (*map)(struct irq_domain *d, unsigned int virq, irq_hw_number_t hw);
0113     void (*unmap)(struct irq_domain *d, unsigned int virq);
0114     int (*xlate)(struct irq_domain *d, struct device_node *node,
0115              const u32 *intspec, unsigned int intsize,
0116              unsigned long *out_hwirq, unsigned int *out_type);
0117 #ifdef  CONFIG_IRQ_DOMAIN_HIERARCHY
0118     /* extended V2 interfaces to support hierarchy irq_domains */
0119     int (*alloc)(struct irq_domain *d, unsigned int virq,
0120              unsigned int nr_irqs, void *arg);
0121     void (*free)(struct irq_domain *d, unsigned int virq,
0122              unsigned int nr_irqs);
0123     int (*activate)(struct irq_domain *d, struct irq_data *irqd, bool reserve);
0124     void (*deactivate)(struct irq_domain *d, struct irq_data *irq_data);
0125     int (*translate)(struct irq_domain *d, struct irq_fwspec *fwspec,
0126              unsigned long *out_hwirq, unsigned int *out_type);
0127 #endif
0128 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
0129     void (*debug_show)(struct seq_file *m, struct irq_domain *d,
0130                struct irq_data *irqd, int ind);
0131 #endif
0132 };
0133 
0134 extern const struct irq_domain_ops irq_generic_chip_ops;
0135 
0136 struct irq_domain_chip_generic;
0137 
0138 /**
0139  * struct irq_domain - Hardware interrupt number translation object
0140  * @link: Element in global irq_domain list.
0141  * @name: Name of interrupt domain
0142  * @ops: pointer to irq_domain methods
0143  * @host_data: private data pointer for use by owner.  Not touched by irq_domain
0144  *             core code.
0145  * @flags: host per irq_domain flags
0146  * @mapcount: The number of mapped interrupts
0147  *
0148  * Optional elements
0149  * @fwnode: Pointer to firmware node associated with the irq_domain. Pretty easy
0150  *          to swap it for the of_node via the irq_domain_get_of_node accessor
0151  * @gc: Pointer to a list of generic chips. There is a helper function for
0152  *      setting up one or more generic chips for interrupt controllers
0153  *      drivers using the generic chip library which uses this pointer.
0154  * @dev: Pointer to a device that the domain represent, and that will be
0155  *       used for power management purposes.
0156  * @parent: Pointer to parent irq_domain to support hierarchy irq_domains
0157  *
0158  * Revmap data, used internally by irq_domain
0159  * @revmap_size: Size of the linear map table @revmap[]
0160  * @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map
0161  * @revmap_mutex: Lock for the revmap
0162  * @revmap: Linear table of irq_data pointers
0163  */
0164 struct irq_domain {
0165     struct list_head link;
0166     const char *name;
0167     const struct irq_domain_ops *ops;
0168     void *host_data;
0169     unsigned int flags;
0170     unsigned int mapcount;
0171 
0172     /* Optional data */
0173     struct fwnode_handle *fwnode;
0174     enum irq_domain_bus_token bus_token;
0175     struct irq_domain_chip_generic *gc;
0176     struct device *dev;
0177 #ifdef  CONFIG_IRQ_DOMAIN_HIERARCHY
0178     struct irq_domain *parent;
0179 #endif
0180 
0181     /* reverse map data. The linear map gets appended to the irq_domain */
0182     irq_hw_number_t hwirq_max;
0183     unsigned int revmap_size;
0184     struct radix_tree_root revmap_tree;
0185     struct mutex revmap_mutex;
0186     struct irq_data __rcu *revmap[];
0187 };
0188 
0189 /* Irq domain flags */
0190 enum {
0191     /* Irq domain is hierarchical */
0192     IRQ_DOMAIN_FLAG_HIERARCHY   = (1 << 0),
0193 
0194     /* Irq domain name was allocated in __irq_domain_add() */
0195     IRQ_DOMAIN_NAME_ALLOCATED   = (1 << 1),
0196 
0197     /* Irq domain is an IPI domain with virq per cpu */
0198     IRQ_DOMAIN_FLAG_IPI_PER_CPU = (1 << 2),
0199 
0200     /* Irq domain is an IPI domain with single virq */
0201     IRQ_DOMAIN_FLAG_IPI_SINGLE  = (1 << 3),
0202 
0203     /* Irq domain implements MSIs */
0204     IRQ_DOMAIN_FLAG_MSI     = (1 << 4),
0205 
0206     /* Irq domain implements MSI remapping */
0207     IRQ_DOMAIN_FLAG_MSI_REMAP   = (1 << 5),
0208 
0209     /*
0210      * Quirk to handle MSI implementations which do not provide
0211      * masking. Currently known to affect x86, but partially
0212      * handled in core code.
0213      */
0214     IRQ_DOMAIN_MSI_NOMASK_QUIRK = (1 << 6),
0215 
0216     /* Irq domain doesn't translate anything */
0217     IRQ_DOMAIN_FLAG_NO_MAP      = (1 << 7),
0218 
0219     /*
0220      * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved
0221      * for implementation specific purposes and ignored by the
0222      * core code.
0223      */
0224     IRQ_DOMAIN_FLAG_NONCORE     = (1 << 16),
0225 };
0226 
0227 static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
0228 {
0229     return to_of_node(d->fwnode);
0230 }
0231 
0232 static inline void irq_domain_set_pm_device(struct irq_domain *d,
0233                         struct device *dev)
0234 {
0235     if (d)
0236         d->dev = dev;
0237 }
0238 
0239 #ifdef CONFIG_IRQ_DOMAIN
0240 struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id,
0241                         const char *name, phys_addr_t *pa);
0242 
0243 enum {
0244     IRQCHIP_FWNODE_REAL,
0245     IRQCHIP_FWNODE_NAMED,
0246     IRQCHIP_FWNODE_NAMED_ID,
0247 };
0248 
0249 static inline
0250 struct fwnode_handle *irq_domain_alloc_named_fwnode(const char *name)
0251 {
0252     return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED, 0, name, NULL);
0253 }
0254 
0255 static inline
0256 struct fwnode_handle *irq_domain_alloc_named_id_fwnode(const char *name, int id)
0257 {
0258     return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED_ID, id, name,
0259                      NULL);
0260 }
0261 
0262 static inline struct fwnode_handle *irq_domain_alloc_fwnode(phys_addr_t *pa)
0263 {
0264     return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_REAL, 0, NULL, pa);
0265 }
0266 
0267 void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
0268 struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size,
0269                     irq_hw_number_t hwirq_max, int direct_max,
0270                     const struct irq_domain_ops *ops,
0271                     void *host_data);
0272 struct irq_domain *irq_domain_create_simple(struct fwnode_handle *fwnode,
0273                         unsigned int size,
0274                         unsigned int first_irq,
0275                         const struct irq_domain_ops *ops,
0276                         void *host_data);
0277 struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
0278                      unsigned int size,
0279                      unsigned int first_irq,
0280                      irq_hw_number_t first_hwirq,
0281                      const struct irq_domain_ops *ops,
0282                      void *host_data);
0283 struct irq_domain *irq_domain_create_legacy(struct fwnode_handle *fwnode,
0284                         unsigned int size,
0285                         unsigned int first_irq,
0286                         irq_hw_number_t first_hwirq,
0287                         const struct irq_domain_ops *ops,
0288                         void *host_data);
0289 extern struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec,
0290                            enum irq_domain_bus_token bus_token);
0291 extern bool irq_domain_check_msi_remap(void);
0292 extern void irq_set_default_host(struct irq_domain *host);
0293 extern struct irq_domain *irq_get_default_host(void);
0294 extern int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
0295                   irq_hw_number_t hwirq, int node,
0296                   const struct irq_affinity_desc *affinity);
0297 
0298 static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
0299 {
0300     return node ? &node->fwnode : NULL;
0301 }
0302 
0303 extern const struct fwnode_operations irqchip_fwnode_ops;
0304 
0305 static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
0306 {
0307     return fwnode && fwnode->ops == &irqchip_fwnode_ops;
0308 }
0309 
0310 extern void irq_domain_update_bus_token(struct irq_domain *domain,
0311                     enum irq_domain_bus_token bus_token);
0312 
0313 static inline
0314 struct irq_domain *irq_find_matching_fwnode(struct fwnode_handle *fwnode,
0315                         enum irq_domain_bus_token bus_token)
0316 {
0317     struct irq_fwspec fwspec = {
0318         .fwnode = fwnode,
0319     };
0320 
0321     return irq_find_matching_fwspec(&fwspec, bus_token);
0322 }
0323 
0324 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
0325                             enum irq_domain_bus_token bus_token)
0326 {
0327     return irq_find_matching_fwnode(of_node_to_fwnode(node), bus_token);
0328 }
0329 
0330 static inline struct irq_domain *irq_find_host(struct device_node *node)
0331 {
0332     struct irq_domain *d;
0333 
0334     d = irq_find_matching_host(node, DOMAIN_BUS_WIRED);
0335     if (!d)
0336         d = irq_find_matching_host(node, DOMAIN_BUS_ANY);
0337 
0338     return d;
0339 }
0340 
0341 static inline struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
0342                                unsigned int size,
0343                                unsigned int first_irq,
0344                                const struct irq_domain_ops *ops,
0345                                void *host_data)
0346 {
0347     return irq_domain_create_simple(of_node_to_fwnode(of_node), size, first_irq, ops, host_data);
0348 }
0349 
0350 /**
0351  * irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
0352  * @of_node: pointer to interrupt controller's device tree node.
0353  * @size: Number of interrupts in the domain.
0354  * @ops: map/unmap domain callbacks
0355  * @host_data: Controller private data pointer
0356  */
0357 static inline struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
0358                      unsigned int size,
0359                      const struct irq_domain_ops *ops,
0360                      void *host_data)
0361 {
0362     return __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data);
0363 }
0364 
0365 #ifdef CONFIG_IRQ_DOMAIN_NOMAP
0366 static inline struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
0367                      unsigned int max_irq,
0368                      const struct irq_domain_ops *ops,
0369                      void *host_data)
0370 {
0371     return __irq_domain_add(of_node_to_fwnode(of_node), 0, max_irq, max_irq, ops, host_data);
0372 }
0373 
0374 extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
0375 #endif
0376 
0377 static inline struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
0378                      const struct irq_domain_ops *ops,
0379                      void *host_data)
0380 {
0381     return __irq_domain_add(of_node_to_fwnode(of_node), 0, ~0, 0, ops, host_data);
0382 }
0383 
0384 static inline struct irq_domain *irq_domain_create_linear(struct fwnode_handle *fwnode,
0385                      unsigned int size,
0386                      const struct irq_domain_ops *ops,
0387                      void *host_data)
0388 {
0389     return __irq_domain_add(fwnode, size, size, 0, ops, host_data);
0390 }
0391 
0392 static inline struct irq_domain *irq_domain_create_tree(struct fwnode_handle *fwnode,
0393                      const struct irq_domain_ops *ops,
0394                      void *host_data)
0395 {
0396     return __irq_domain_add(fwnode, 0, ~0, 0, ops, host_data);
0397 }
0398 
0399 extern void irq_domain_remove(struct irq_domain *host);
0400 
0401 extern int irq_domain_associate(struct irq_domain *domain, unsigned int irq,
0402                     irq_hw_number_t hwirq);
0403 extern void irq_domain_associate_many(struct irq_domain *domain,
0404                       unsigned int irq_base,
0405                       irq_hw_number_t hwirq_base, int count);
0406 
0407 extern unsigned int irq_create_mapping_affinity(struct irq_domain *host,
0408                       irq_hw_number_t hwirq,
0409                       const struct irq_affinity_desc *affinity);
0410 extern unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec);
0411 extern void irq_dispose_mapping(unsigned int virq);
0412 
0413 static inline unsigned int irq_create_mapping(struct irq_domain *host,
0414                           irq_hw_number_t hwirq)
0415 {
0416     return irq_create_mapping_affinity(host, hwirq, NULL);
0417 }
0418 
0419 extern struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain,
0420                           irq_hw_number_t hwirq,
0421                           unsigned int *irq);
0422 
0423 static inline struct irq_desc *irq_resolve_mapping(struct irq_domain *domain,
0424                            irq_hw_number_t hwirq)
0425 {
0426     return __irq_resolve_mapping(domain, hwirq, NULL);
0427 }
0428 
0429 /**
0430  * irq_find_mapping() - Find a linux irq from a hw irq number.
0431  * @domain: domain owning this hardware interrupt
0432  * @hwirq: hardware irq number in that domain space
0433  */
0434 static inline unsigned int irq_find_mapping(struct irq_domain *domain,
0435                         irq_hw_number_t hwirq)
0436 {
0437     unsigned int irq;
0438 
0439     if (__irq_resolve_mapping(domain, hwirq, &irq))
0440         return irq;
0441 
0442     return 0;
0443 }
0444 
0445 static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
0446                          irq_hw_number_t hwirq)
0447 {
0448     return irq_find_mapping(domain, hwirq);
0449 }
0450 
0451 extern const struct irq_domain_ops irq_domain_simple_ops;
0452 
0453 /* stock xlate functions */
0454 int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
0455             const u32 *intspec, unsigned int intsize,
0456             irq_hw_number_t *out_hwirq, unsigned int *out_type);
0457 int irq_domain_xlate_twocell(struct irq_domain *d, struct device_node *ctrlr,
0458             const u32 *intspec, unsigned int intsize,
0459             irq_hw_number_t *out_hwirq, unsigned int *out_type);
0460 int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
0461             const u32 *intspec, unsigned int intsize,
0462             irq_hw_number_t *out_hwirq, unsigned int *out_type);
0463 
0464 int irq_domain_translate_twocell(struct irq_domain *d,
0465                  struct irq_fwspec *fwspec,
0466                  unsigned long *out_hwirq,
0467                  unsigned int *out_type);
0468 
0469 int irq_domain_translate_onecell(struct irq_domain *d,
0470                  struct irq_fwspec *fwspec,
0471                  unsigned long *out_hwirq,
0472                  unsigned int *out_type);
0473 
0474 /* IPI functions */
0475 int irq_reserve_ipi(struct irq_domain *domain, const struct cpumask *dest);
0476 int irq_destroy_ipi(unsigned int irq, const struct cpumask *dest);
0477 
0478 /* V2 interfaces to support hierarchy IRQ domains. */
0479 extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
0480                         unsigned int virq);
0481 extern void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
0482                 irq_hw_number_t hwirq,
0483                 const struct irq_chip *chip,
0484                 void *chip_data, irq_flow_handler_t handler,
0485                 void *handler_data, const char *handler_name);
0486 extern void irq_domain_reset_irq_data(struct irq_data *irq_data);
0487 #ifdef  CONFIG_IRQ_DOMAIN_HIERARCHY
0488 extern struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
0489             unsigned int flags, unsigned int size,
0490             struct fwnode_handle *fwnode,
0491             const struct irq_domain_ops *ops, void *host_data);
0492 
0493 static inline struct irq_domain *irq_domain_add_hierarchy(struct irq_domain *parent,
0494                         unsigned int flags,
0495                         unsigned int size,
0496                         struct device_node *node,
0497                         const struct irq_domain_ops *ops,
0498                         void *host_data)
0499 {
0500     return irq_domain_create_hierarchy(parent, flags, size,
0501                        of_node_to_fwnode(node),
0502                        ops, host_data);
0503 }
0504 
0505 extern int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
0506                    unsigned int nr_irqs, int node, void *arg,
0507                    bool realloc,
0508                    const struct irq_affinity_desc *affinity);
0509 extern void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs);
0510 extern int irq_domain_activate_irq(struct irq_data *irq_data, bool early);
0511 extern void irq_domain_deactivate_irq(struct irq_data *irq_data);
0512 
0513 static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
0514             unsigned int nr_irqs, int node, void *arg)
0515 {
0516     return __irq_domain_alloc_irqs(domain, -1, nr_irqs, node, arg, false,
0517                        NULL);
0518 }
0519 
0520 extern int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
0521                        unsigned int irq_base,
0522                        unsigned int nr_irqs, void *arg);
0523 extern int irq_domain_set_hwirq_and_chip(struct irq_domain *domain,
0524                      unsigned int virq,
0525                      irq_hw_number_t hwirq,
0526                      const struct irq_chip *chip,
0527                      void *chip_data);
0528 extern void irq_domain_free_irqs_common(struct irq_domain *domain,
0529                     unsigned int virq,
0530                     unsigned int nr_irqs);
0531 extern void irq_domain_free_irqs_top(struct irq_domain *domain,
0532                      unsigned int virq, unsigned int nr_irqs);
0533 
0534 extern int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg);
0535 extern int irq_domain_pop_irq(struct irq_domain *domain, int virq);
0536 
0537 extern int irq_domain_alloc_irqs_parent(struct irq_domain *domain,
0538                     unsigned int irq_base,
0539                     unsigned int nr_irqs, void *arg);
0540 
0541 extern void irq_domain_free_irqs_parent(struct irq_domain *domain,
0542                     unsigned int irq_base,
0543                     unsigned int nr_irqs);
0544 
0545 extern int irq_domain_disconnect_hierarchy(struct irq_domain *domain,
0546                        unsigned int virq);
0547 
0548 static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
0549 {
0550     return domain->flags & IRQ_DOMAIN_FLAG_HIERARCHY;
0551 }
0552 
0553 static inline bool irq_domain_is_ipi(struct irq_domain *domain)
0554 {
0555     return domain->flags &
0556         (IRQ_DOMAIN_FLAG_IPI_PER_CPU | IRQ_DOMAIN_FLAG_IPI_SINGLE);
0557 }
0558 
0559 static inline bool irq_domain_is_ipi_per_cpu(struct irq_domain *domain)
0560 {
0561     return domain->flags & IRQ_DOMAIN_FLAG_IPI_PER_CPU;
0562 }
0563 
0564 static inline bool irq_domain_is_ipi_single(struct irq_domain *domain)
0565 {
0566     return domain->flags & IRQ_DOMAIN_FLAG_IPI_SINGLE;
0567 }
0568 
0569 static inline bool irq_domain_is_msi(struct irq_domain *domain)
0570 {
0571     return domain->flags & IRQ_DOMAIN_FLAG_MSI;
0572 }
0573 
0574 static inline bool irq_domain_is_msi_remap(struct irq_domain *domain)
0575 {
0576     return domain->flags & IRQ_DOMAIN_FLAG_MSI_REMAP;
0577 }
0578 
0579 extern bool irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain);
0580 
0581 #else   /* CONFIG_IRQ_DOMAIN_HIERARCHY */
0582 static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
0583             unsigned int nr_irqs, int node, void *arg)
0584 {
0585     return -1;
0586 }
0587 
0588 static inline void irq_domain_free_irqs(unsigned int virq,
0589                     unsigned int nr_irqs) { }
0590 
0591 static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
0592 {
0593     return false;
0594 }
0595 
0596 static inline bool irq_domain_is_ipi(struct irq_domain *domain)
0597 {
0598     return false;
0599 }
0600 
0601 static inline bool irq_domain_is_ipi_per_cpu(struct irq_domain *domain)
0602 {
0603     return false;
0604 }
0605 
0606 static inline bool irq_domain_is_ipi_single(struct irq_domain *domain)
0607 {
0608     return false;
0609 }
0610 
0611 static inline bool irq_domain_is_msi(struct irq_domain *domain)
0612 {
0613     return false;
0614 }
0615 
0616 static inline bool irq_domain_is_msi_remap(struct irq_domain *domain)
0617 {
0618     return false;
0619 }
0620 
0621 static inline bool
0622 irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain)
0623 {
0624     return false;
0625 }
0626 #endif  /* CONFIG_IRQ_DOMAIN_HIERARCHY */
0627 
0628 #else /* CONFIG_IRQ_DOMAIN */
0629 static inline void irq_dispose_mapping(unsigned int virq) { }
0630 static inline struct irq_domain *irq_find_matching_fwnode(
0631     struct fwnode_handle *fwnode, enum irq_domain_bus_token bus_token)
0632 {
0633     return NULL;
0634 }
0635 static inline bool irq_domain_check_msi_remap(void)
0636 {
0637     return false;
0638 }
0639 #endif /* !CONFIG_IRQ_DOMAIN */
0640 
0641 #endif /* _LINUX_IRQDOMAIN_H */