irqdomain.h 21 KB

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