Commit | Line | Data |
---|---|---|
08a543ad GL |
1 | /* |
2 | * irq_domain - IRQ translation domains | |
3 | * | |
4 | * Translation infrastructure between hw and linux irq numbers. This is | |
5 | * helpful for interrupt controllers to implement mapping between hardware | |
6 | * irq numbers and the Linux irq number space. | |
7 | * | |
8 | * irq_domains also have a hook for translating device tree interrupt | |
9 | * representation into a hardware irq number that can be mapped back to a | |
10 | * Linux irq number without any extra platform support code. | |
11 | * | |
12 | * irq_domain is expected to be embedded in an interrupt controller's private | |
13 | * data structure. | |
14 | */ | |
15 | #ifndef _LINUX_IRQDOMAIN_H | |
16 | #define _LINUX_IRQDOMAIN_H | |
17 | ||
18 | #include <linux/irq.h> | |
19 | ||
20 | #ifdef CONFIG_IRQ_DOMAIN | |
21 | struct device_node; | |
22 | struct irq_domain; | |
23 | ||
24 | /** | |
25 | * struct irq_domain_ops - Methods for irq_domain objects | |
26 | * @to_irq: (optional) given a local hardware irq number, return the linux | |
27 | * irq number. If to_irq is not implemented, then the irq_domain | |
28 | * will use this translation: irq = (domain->irq_base + hwirq) | |
29 | * @dt_translate: Given a device tree node and interrupt specifier, decode | |
30 | * the hardware irq number and linux irq type value. | |
31 | */ | |
32 | struct irq_domain_ops { | |
33 | unsigned int (*to_irq)(struct irq_domain *d, unsigned long hwirq); | |
34 | ||
35 | #ifdef CONFIG_OF | |
36 | int (*dt_translate)(struct irq_domain *d, struct device_node *node, | |
37 | const u32 *intspec, unsigned int intsize, | |
38 | unsigned long *out_hwirq, unsigned int *out_type); | |
39 | #endif /* CONFIG_OF */ | |
40 | }; | |
41 | ||
42 | /** | |
43 | * struct irq_domain - Hardware interrupt number translation object | |
44 | * @list: Element in global irq_domain list. | |
45 | * @irq_base: Start of irq_desc range assigned to the irq_domain. The creator | |
46 | * of the irq_domain is responsible for allocating the array of | |
47 | * irq_desc structures. | |
48 | * @nr_irq: Number of irqs managed by the irq domain | |
49 | * @ops: pointer to irq_domain methods | |
50 | * @priv: private data pointer for use by owner. Not touched by irq_domain | |
51 | * core code. | |
52 | * @of_node: (optional) Pointer to device tree nodes associated with the | |
53 | * irq_domain. Used when decoding device tree interrupt specifiers. | |
54 | */ | |
55 | struct irq_domain { | |
56 | struct list_head list; | |
57 | unsigned int irq_base; | |
58 | unsigned int nr_irq; | |
59 | const struct irq_domain_ops *ops; | |
60 | void *priv; | |
61 | struct device_node *of_node; | |
62 | }; | |
63 | ||
64 | /** | |
65 | * irq_domain_to_irq() - Translate from a hardware irq to a linux irq number | |
66 | * | |
67 | * Returns the linux irq number associated with a hardware irq. By default, | |
68 | * the mapping is irq == domain->irq_base + hwirq, but this mapping can | |
69 | * be overridden if the irq_domain implements a .to_irq() hook. | |
70 | */ | |
71 | static inline unsigned int irq_domain_to_irq(struct irq_domain *d, | |
72 | unsigned long hwirq) | |
73 | { | |
74 | return d->ops->to_irq ? d->ops->to_irq(d, hwirq) : d->irq_base + hwirq; | |
75 | } | |
76 | ||
77 | extern void irq_domain_add(struct irq_domain *domain); | |
78 | extern void irq_domain_del(struct irq_domain *domain); | |
79 | #endif /* CONFIG_IRQ_DOMAIN */ | |
80 | ||
81 | #endif /* _LINUX_IRQDOMAIN_H */ |