aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2011-07-26 05:19:06 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-07-28 03:32:04 -0400
commit08a543ad33fc188650801bd36eed4ffe272643e1 (patch)
treecf2b41b922e77190425f999c2268f1558dd52d18 /include/linux
parent5fd1a2ed0ec6fb5449c71a988cc15edb8671b3d0 (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')
-rw-r--r--include/linux/irq.h6
-rw-r--r--include/linux/irqdomain.h81
-rw-r--r--include/linux/of_irq.h4
3 files changed, 91 insertions, 0 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 5f695041090c..87a06f345bd2 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -108,14 +108,18 @@ enum {
108}; 108};
109 109
110struct msi_desc; 110struct msi_desc;
111struct irq_domain;
111 112
112/** 113/**
113 * struct irq_data - per irq and irq chip data passed down to chip functions 114 * struct irq_data - per irq and irq chip data passed down to chip functions
114 * @irq: interrupt number 115 * @irq: interrupt number
116 * @hwirq: hardware interrupt number, local to the interrupt domain
115 * @node: node index useful for balancing 117 * @node: node index useful for balancing
116 * @state_use_accessors: status information for irq chip functions. 118 * @state_use_accessors: status information for irq chip functions.
117 * Use accessor functions to deal with it 119 * Use accessor functions to deal with it
118 * @chip: low level interrupt hardware access 120 * @chip: low level interrupt hardware access
121 * @domain: Interrupt translation domain; responsible for mapping
122 * between hwirq number and linux irq number.
119 * @handler_data: per-IRQ data for the irq_chip methods 123 * @handler_data: per-IRQ data for the irq_chip methods
120 * @chip_data: platform-specific per-chip private data for the chip 124 * @chip_data: platform-specific per-chip private data for the chip
121 * methods, to allow shared chip implementations 125 * methods, to allow shared chip implementations
@@ -128,9 +132,11 @@ struct msi_desc;
128 */ 132 */
129struct irq_data { 133struct irq_data {
130 unsigned int irq; 134 unsigned int irq;
135 unsigned long hwirq;
131 unsigned int node; 136 unsigned int node;
132 unsigned int state_use_accessors; 137 unsigned int state_use_accessors;
133 struct irq_chip *chip; 138 struct irq_chip *chip;
139 struct irq_domain *domain;
134 void *handler_data; 140 void *handler_data;
135 void *chip_data; 141 void *chip_data;
136 struct msi_desc *msi_desc; 142 struct msi_desc *msi_desc;
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
21struct device_node;
22struct 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 */
32struct 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 */
55struct 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 */
71static 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
77extern void irq_domain_add(struct irq_domain *domain);
78extern void irq_domain_del(struct irq_domain *domain);
79#endif /* CONFIG_IRQ_DOMAIN */
80
81#endif /* _LINUX_IRQDOMAIN_H */
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index e6955f5d1f08..cd2e61ce4e83 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -63,6 +63,9 @@ extern int of_irq_map_one(struct device_node *device, int index,
63extern unsigned int irq_create_of_mapping(struct device_node *controller, 63extern unsigned int irq_create_of_mapping(struct device_node *controller,
64 const u32 *intspec, 64 const u32 *intspec,
65 unsigned int intsize); 65 unsigned int intsize);
66#ifdef CONFIG_IRQ_DOMAIN
67extern void irq_dispose_mapping(unsigned int irq);
68#endif
66extern int of_irq_to_resource(struct device_node *dev, int index, 69extern int of_irq_to_resource(struct device_node *dev, int index,
67 struct resource *r); 70 struct resource *r);
68extern int of_irq_count(struct device_node *dev); 71extern int of_irq_count(struct device_node *dev);
@@ -70,6 +73,7 @@ extern int of_irq_to_resource_table(struct device_node *dev,
70 struct resource *res, int nr_irqs); 73 struct resource *res, int nr_irqs);
71extern struct device_node *of_irq_find_parent(struct device_node *child); 74extern struct device_node *of_irq_find_parent(struct device_node *child);
72 75
76
73#endif /* CONFIG_OF_IRQ */ 77#endif /* CONFIG_OF_IRQ */
74#endif /* CONFIG_OF */ 78#endif /* CONFIG_OF */
75#endif /* __OF_IRQ_H */ 79#endif /* __OF_IRQ_H */