diff options
-rw-r--r-- | Documentation/devicetree/bindings/arm/omap/intc.txt | 27 | ||||
-rw-r--r-- | arch/arm/mach-omap2/common.h | 12 | ||||
-rw-r--r-- | arch/arm/mach-omap2/irq.c | 60 |
3 files changed, 89 insertions, 10 deletions
diff --git a/Documentation/devicetree/bindings/arm/omap/intc.txt b/Documentation/devicetree/bindings/arm/omap/intc.txt new file mode 100644 index 000000000000..f2583e6ec060 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/omap/intc.txt | |||
@@ -0,0 +1,27 @@ | |||
1 | * OMAP Interrupt Controller | ||
2 | |||
3 | OMAP2/3 are using a TI interrupt controller that can support several | ||
4 | configurable number of interrupts. | ||
5 | |||
6 | Main node required properties: | ||
7 | |||
8 | - compatible : should be: | ||
9 | "ti,omap2-intc" | ||
10 | - interrupt-controller : Identifies the node as an interrupt controller | ||
11 | - #interrupt-cells : Specifies the number of cells needed to encode an | ||
12 | interrupt source. The type shall be a <u32> and the value shall be 1. | ||
13 | |||
14 | The cell contains the interrupt number in the range [0-128]. | ||
15 | - ti,intc-size: Number of interrupts handled by the interrupt controller. | ||
16 | - reg: physical base address and size of the intc registers map. | ||
17 | |||
18 | Example: | ||
19 | |||
20 | intc: interrupt-controller@1 { | ||
21 | compatible = "ti,omap2-intc"; | ||
22 | interrupt-controller; | ||
23 | #interrupt-cells = <1>; | ||
24 | ti,intc-size = <96>; | ||
25 | reg = <0x48200000 0x1000>; | ||
26 | }; | ||
27 | |||
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index febffde2ff10..dd8c9906b1ab 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h | |||
@@ -174,6 +174,18 @@ void omap3_intc_handle_irq(struct pt_regs *regs); | |||
174 | extern void __iomem *omap4_get_l2cache_base(void); | 174 | extern void __iomem *omap4_get_l2cache_base(void); |
175 | #endif | 175 | #endif |
176 | 176 | ||
177 | struct device_node; | ||
178 | #ifdef CONFIG_OF | ||
179 | int __init omap_intc_of_init(struct device_node *node, | ||
180 | struct device_node *parent); | ||
181 | #else | ||
182 | int __init omap_intc_of_init(struct device_node *node, | ||
183 | struct device_node *parent) | ||
184 | { | ||
185 | return 0; | ||
186 | } | ||
187 | #endif | ||
188 | |||
177 | #ifdef CONFIG_SMP | 189 | #ifdef CONFIG_SMP |
178 | extern void __iomem *omap4_get_scu_base(void); | 190 | extern void __iomem *omap4_get_scu_base(void); |
179 | #else | 191 | #else |
diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c index 1fef061f7927..26eaf37ce4d9 100644 --- a/arch/arm/mach-omap2/irq.c +++ b/arch/arm/mach-omap2/irq.c | |||
@@ -11,12 +11,16 @@ | |||
11 | * for more details. | 11 | * for more details. |
12 | */ | 12 | */ |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | 15 | #include <linux/init.h> |
15 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
16 | #include <linux/io.h> | 17 | #include <linux/io.h> |
17 | #include <mach/hardware.h> | 18 | #include <mach/hardware.h> |
18 | #include <asm/exception.h> | 19 | #include <asm/exception.h> |
19 | #include <asm/mach/irq.h> | 20 | #include <asm/mach/irq.h> |
21 | #include <linux/irqdomain.h> | ||
22 | #include <linux/of.h> | ||
23 | #include <linux/of_address.h> | ||
20 | 24 | ||
21 | 25 | ||
22 | /* selected INTC register offsets */ | 26 | /* selected INTC register offsets */ |
@@ -57,6 +61,8 @@ static struct omap_irq_bank { | |||
57 | }, | 61 | }, |
58 | }; | 62 | }; |
59 | 63 | ||
64 | static struct irq_domain *domain; | ||
65 | |||
60 | /* Structure to save interrupt controller context */ | 66 | /* Structure to save interrupt controller context */ |
61 | struct omap3_intc_regs { | 67 | struct omap3_intc_regs { |
62 | u32 sysconfig; | 68 | u32 sysconfig; |
@@ -147,17 +153,27 @@ omap_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num) | |||
147 | IRQ_NOREQUEST | IRQ_NOPROBE, 0); | 153 | IRQ_NOREQUEST | IRQ_NOPROBE, 0); |
148 | } | 154 | } |
149 | 155 | ||
150 | static void __init omap_init_irq(u32 base, int nr_irqs) | 156 | static void __init omap_init_irq(u32 base, int nr_irqs, |
157 | struct device_node *node) | ||
151 | { | 158 | { |
152 | void __iomem *omap_irq_base; | 159 | void __iomem *omap_irq_base; |
153 | unsigned long nr_of_irqs = 0; | 160 | unsigned long nr_of_irqs = 0; |
154 | unsigned int nr_banks = 0; | 161 | unsigned int nr_banks = 0; |
155 | int i, j; | 162 | int i, j, irq_base; |
156 | 163 | ||
157 | omap_irq_base = ioremap(base, SZ_4K); | 164 | omap_irq_base = ioremap(base, SZ_4K); |
158 | if (WARN_ON(!omap_irq_base)) | 165 | if (WARN_ON(!omap_irq_base)) |
159 | return; | 166 | return; |
160 | 167 | ||
168 | irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); | ||
169 | if (irq_base < 0) { | ||
170 | pr_warn("Couldn't allocate IRQ numbers\n"); | ||
171 | irq_base = 0; | ||
172 | } | ||
173 | |||
174 | domain = irq_domain_add_legacy(node, nr_irqs, irq_base, 0, | ||
175 | &irq_domain_simple_ops, NULL); | ||
176 | |||
161 | for (i = 0; i < ARRAY_SIZE(irq_banks); i++) { | 177 | for (i = 0; i < ARRAY_SIZE(irq_banks); i++) { |
162 | struct omap_irq_bank *bank = irq_banks + i; | 178 | struct omap_irq_bank *bank = irq_banks + i; |
163 | 179 | ||
@@ -166,36 +182,36 @@ static void __init omap_init_irq(u32 base, int nr_irqs) | |||
166 | /* Static mapping, never released */ | 182 | /* Static mapping, never released */ |
167 | bank->base_reg = ioremap(base, SZ_4K); | 183 | bank->base_reg = ioremap(base, SZ_4K); |
168 | if (!bank->base_reg) { | 184 | if (!bank->base_reg) { |
169 | printk(KERN_ERR "Could not ioremap irq bank%i\n", i); | 185 | pr_err("Could not ioremap irq bank%i\n", i); |
170 | continue; | 186 | continue; |
171 | } | 187 | } |
172 | 188 | ||
173 | omap_irq_bank_init_one(bank); | 189 | omap_irq_bank_init_one(bank); |
174 | 190 | ||
175 | for (j = 0; j < bank->nr_irqs; j += 32) | 191 | for (j = 0; j < bank->nr_irqs; j += 32) |
176 | omap_alloc_gc(bank->base_reg + j, j, 32); | 192 | omap_alloc_gc(bank->base_reg + j, j + irq_base, 32); |
177 | 193 | ||
178 | nr_of_irqs += bank->nr_irqs; | 194 | nr_of_irqs += bank->nr_irqs; |
179 | nr_banks++; | 195 | nr_banks++; |
180 | } | 196 | } |
181 | 197 | ||
182 | printk(KERN_INFO "Total of %ld interrupts on %d active controller%s\n", | 198 | pr_info("Total of %ld interrupts on %d active controller%s\n", |
183 | nr_of_irqs, nr_banks, nr_banks > 1 ? "s" : ""); | 199 | nr_of_irqs, nr_banks, nr_banks > 1 ? "s" : ""); |
184 | } | 200 | } |
185 | 201 | ||
186 | void __init omap2_init_irq(void) | 202 | void __init omap2_init_irq(void) |
187 | { | 203 | { |
188 | omap_init_irq(OMAP24XX_IC_BASE, 96); | 204 | omap_init_irq(OMAP24XX_IC_BASE, 96, NULL); |
189 | } | 205 | } |
190 | 206 | ||
191 | void __init omap3_init_irq(void) | 207 | void __init omap3_init_irq(void) |
192 | { | 208 | { |
193 | omap_init_irq(OMAP34XX_IC_BASE, 96); | 209 | omap_init_irq(OMAP34XX_IC_BASE, 96, NULL); |
194 | } | 210 | } |
195 | 211 | ||
196 | void __init ti81xx_init_irq(void) | 212 | void __init ti81xx_init_irq(void) |
197 | { | 213 | { |
198 | omap_init_irq(OMAP34XX_IC_BASE, 128); | 214 | omap_init_irq(OMAP34XX_IC_BASE, 128, NULL); |
199 | } | 215 | } |
200 | 216 | ||
201 | static inline void omap_intc_handle_irq(void __iomem *base_addr, struct pt_regs *regs) | 217 | static inline void omap_intc_handle_irq(void __iomem *base_addr, struct pt_regs *regs) |
@@ -225,8 +241,10 @@ out: | |||
225 | irqnr = readl_relaxed(base_addr + INTCPS_SIR_IRQ_OFFSET); | 241 | irqnr = readl_relaxed(base_addr + INTCPS_SIR_IRQ_OFFSET); |
226 | irqnr &= ACTIVEIRQ_MASK; | 242 | irqnr &= ACTIVEIRQ_MASK; |
227 | 243 | ||
228 | if (irqnr) | 244 | if (irqnr) { |
245 | irqnr = irq_find_mapping(domain, irqnr); | ||
229 | handle_IRQ(irqnr, regs); | 246 | handle_IRQ(irqnr, regs); |
247 | } | ||
230 | } while (irqnr); | 248 | } while (irqnr); |
231 | } | 249 | } |
232 | 250 | ||
@@ -236,6 +254,28 @@ asmlinkage void __exception_irq_entry omap2_intc_handle_irq(struct pt_regs *regs | |||
236 | omap_intc_handle_irq(base_addr, regs); | 254 | omap_intc_handle_irq(base_addr, regs); |
237 | } | 255 | } |
238 | 256 | ||
257 | int __init omap_intc_of_init(struct device_node *node, | ||
258 | struct device_node *parent) | ||
259 | { | ||
260 | struct resource res; | ||
261 | u32 nr_irqs = 96; | ||
262 | |||
263 | if (WARN_ON(!node)) | ||
264 | return -ENODEV; | ||
265 | |||
266 | if (of_address_to_resource(node, 0, &res)) { | ||
267 | WARN(1, "unable to get intc registers\n"); | ||
268 | return -EINVAL; | ||
269 | } | ||
270 | |||
271 | if (of_property_read_u32(node, "ti,intc-size", &nr_irqs)) | ||
272 | pr_warn("unable to get intc-size, default to %d\n", nr_irqs); | ||
273 | |||
274 | omap_init_irq(res.start, nr_irqs, of_node_get(node)); | ||
275 | |||
276 | return 0; | ||
277 | } | ||
278 | |||
239 | #ifdef CONFIG_ARCH_OMAP3 | 279 | #ifdef CONFIG_ARCH_OMAP3 |
240 | static struct omap3_intc_regs intc_context[ARRAY_SIZE(irq_banks)]; | 280 | static struct omap3_intc_regs intc_context[ARRAY_SIZE(irq_banks)]; |
241 | 281 | ||