irqdomain.h 20 KB

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