diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2011-07-26 05:19:06 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-07-28 03:32:04 -0400 |
commit | 08a543ad33fc188650801bd36eed4ffe272643e1 (patch) | |
tree | cf2b41b922e77190425f999c2268f1558dd52d18 /include/linux/irqdomain.h | |
parent | 5fd1a2ed0ec6fb5449c71a988cc15edb8671b3d0 (diff) |
irq: add irq_domain translation infrastructure
This patch adds irq_domain infrastructure for translating from
hardware irq numbers to linux irqs. This is particularly important
for architectures adding device tree support because the current
implementation (excluding PowerPC and SPARC) cannot handle
translation for more than a single interrupt controller. irq_domain
supports device tree translation for any number of interrupt
controllers.
This patch converts x86, Microblaze, ARM and MIPS to use irq_domain
for device tree irq translation. x86 is untested beyond compiling it,
irq_domain is enabled for MIPS and Microblaze, but the old behaviour is
preserved until the core code is modified to actually register an
irq_domain yet. On ARM it works and is required for much of the new
ARM device tree board support.
PowerPC has /not/ been converted to use this new infrastructure. It
is still missing some features before it can replace the virq
infrastructure already in powerpc (see documentation on
irq_domain_map/unmap for details). Followup patches will add the
missing pieces and migrate PowerPC to use irq_domain.
SPARC has its own method of managing interrupts from the device tree
and is unaffected by this change.
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'include/linux/irqdomain.h')
-rw-r--r-- | include/linux/irqdomain.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h new file mode 100644 index 000000000000..8f2c10a784a4 --- /dev/null +++ b/include/linux/irqdomain.h | |||
@@ -0,0 +1,81 @@ | |||
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 */ | ||