aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2012-02-14 16:06:55 -0500
committerGrant Likely <grant.likely@secretlab.ca>2012-02-16 08:11:23 -0500
commit1bc04f2cf8c2a1feadbd994f50c40bb145bf2989 (patch)
tree26508a452ca52542ac437f55bb632b48fa607048 /include/linux
parenta8db8cf0d894df5f1dcfd4bce9894e0dbcc01c96 (diff)
irq_domain: Add support for base irq and hwirq in legacy mappings
Add support for a legacy mapping where irq = (hwirq - first_hwirq + first_irq) so that a controller driver can allocate a fixed range of irq_descs and use a simple calculation to translate back and forth between linux and hw irq numbers. This is needed to use an irq_domain with many of the ARM interrupt controller drivers that manage their own irq_desc allocations. Ultimately the goal is to migrate those drivers to use the linear revmap, but doing it this way allows each driver to be converted separately which makes the migration path easier. This patch generalizes the IRQ_DOMAIN_MAP_LEGACY method to use (first_irq-first_hwirq) as the offset between hwirq and linux irq number, and adds checks to make sure that the hwirq number does not exceed range assigned to the controller. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Milton Miller <miltonm@bga.com> Tested-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/irqdomain.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index f95553fa6872..7fef39ed5523 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -39,6 +39,9 @@ struct device_node;
39struct irq_domain; 39struct irq_domain;
40struct of_device_id; 40struct of_device_id;
41 41
42/* Number of irqs reserved for a legacy isa controller */
43#define NUM_ISA_INTERRUPTS 16
44
42/* This type is the placeholder for a hardware interrupt number. It has to 45/* This type is the placeholder for a hardware interrupt number. It has to
43 * be big enough to enclose whatever representation is used by a given 46 * be big enough to enclose whatever representation is used by a given
44 * platform. 47 * platform.
@@ -98,6 +101,11 @@ struct irq_domain {
98 union { 101 union {
99 struct { 102 struct {
100 unsigned int size; 103 unsigned int size;
104 unsigned int first_irq;
105 irq_hw_number_t first_hwirq;
106 } legacy;
107 struct {
108 unsigned int size;
101 unsigned int *revmap; 109 unsigned int *revmap;
102 } linear; 110 } linear;
103 struct radix_tree_root tree; 111 struct radix_tree_root tree;
@@ -117,6 +125,9 @@ struct irq_domain {
117#ifdef CONFIG_IRQ_DOMAIN 125#ifdef CONFIG_IRQ_DOMAIN
118#ifdef CONFIG_PPC 126#ifdef CONFIG_PPC
119struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, 127struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
128 unsigned int size,
129 unsigned int first_irq,
130 irq_hw_number_t first_hwirq,
120 struct irq_domain_ops *ops, 131 struct irq_domain_ops *ops,
121 void *host_data); 132 void *host_data);
122struct irq_domain *irq_domain_add_linear(struct device_node *of_node, 133struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
@@ -130,11 +141,18 @@ struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
130 struct irq_domain_ops *ops, 141 struct irq_domain_ops *ops,
131 void *host_data); 142 void *host_data);
132 143
133
134extern struct irq_domain *irq_find_host(struct device_node *node); 144extern struct irq_domain *irq_find_host(struct device_node *node);
135extern void irq_set_default_host(struct irq_domain *host); 145extern void irq_set_default_host(struct irq_domain *host);
136extern void irq_set_virq_count(unsigned int count); 146extern void irq_set_virq_count(unsigned int count);
137 147
148static inline struct irq_domain *irq_domain_add_legacy_isa(
149 struct device_node *of_node,
150 struct irq_domain_ops *ops,
151 void *host_data)
152{
153 return irq_domain_add_legacy(of_node, NUM_ISA_INTERRUPTS, 0, 0, ops,
154 host_data);
155}
138 156
139extern unsigned int irq_create_mapping(struct irq_domain *host, 157extern unsigned int irq_create_mapping(struct irq_domain *host,
140 irq_hw_number_t hwirq); 158 irq_hw_number_t hwirq);