1 From a729672f117df3602b6d3171d8ab7a84bf53b053 Mon Sep 17 00:00:00 2001
2 From: Daniel Hellstrom <daniel@gaisler.com>
3 Date: Thu, 16 Sep 2010 11:12:41 +0200
4 Subject: [PATCH] SPARC/LEON: added support for Extended IRQ controller, partial patches are already in git tree.
6 Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
8 arch/sparc/include/asm/irq_32.h | 4 ++++
9 arch/sparc/kernel/irq_32.c | 32 ++++++++++++++++++++++++++------
10 arch/sparc/kernel/leon_kernel.c | 8 +++++++-
11 3 files changed, 37 insertions(+), 7 deletions(-)
13 --- a/arch/sparc/include/asm/irq_32.h
14 +++ b/arch/sparc/include/asm/irq_32.h
19 +#ifdef CONFIG_SPARC_LEON
25 #include <linux/interrupt.h>
27 --- a/arch/sparc/kernel/irq_32.c
28 +++ b/arch/sparc/kernel/irq_32.c
29 @@ -110,6 +110,11 @@ EXPORT_SYMBOL(__raw_local_irq_save);
30 EXPORT_SYMBOL(raw_local_irq_enable);
31 EXPORT_SYMBOL(raw_local_irq_restore);
33 +#ifdef CONFIG_SPARC_LEON
34 +extern unsigned int sparc_leon_eirq;
35 +extern int sparc_leon_eirq_get(int eirq, int cpu);
39 * Dave Redman (djhr@tadpole.co.uk)
41 @@ -222,10 +227,11 @@ void free_irq(unsigned int irq, void *de
44 cpu_irq = irq & (NR_IRQS - 1);
45 - if (cpu_irq > 14) { /* 14 irq levels on the sparc */
46 - printk("Trying to free bogus IRQ %d\n", irq);
49 + /* 14 irq levels on the sparc, however some LEON systems have 31 IRQs */
50 + if ((cpu_irq == 15) || (cpu_irq >= NR_IRQS)) {
51 + printk("Trying to free bogus IRQ %d\n", irq);
55 spin_lock_irqsave(&irq_action_lock, flags);
57 @@ -303,7 +309,14 @@ void unexpected_irq(int irq, void *dev_i
59 struct irqaction * action;
63 +#ifdef CONFIG_SPARC_LEON
64 + /* LEON Extended IRQ requires one extra IRQ Number fetch stage */
65 + if ( sparc_leon_eirq == irq ) {
66 + irq = sparc_leon_eirq_get(irq, smp_processor_id());
70 cpu_irq = irq & (NR_IRQS - 1);
71 action = sparc_irq[cpu_irq].action;
73 @@ -330,6 +343,13 @@ void handler_irq(int irq, struct pt_regs
74 extern void smp4m_irq_rotate(int cpu);
77 +#ifdef CONFIG_SPARC_LEON
78 + /* LEON Extended IRQ requires one extra IRQ Number fetch stage */
79 + if ( sparc_leon_eirq == irq ) {
80 + irq = sparc_leon_eirq_get(irq, cpu);
84 old_regs = set_irq_regs(regs);
87 @@ -526,7 +546,7 @@ int request_irq(unsigned int irq,
88 return sun4d_request_irq(irq, handler, irqflags, devname, dev_id);
90 cpu_irq = irq & (NR_IRQS - 1);
96 --- a/arch/sparc/kernel/leon_kernel.c
97 +++ b/arch/sparc/kernel/leon_kernel.c
98 @@ -104,7 +104,7 @@ static void leon_disable_irq(unsigned in
100 void __init leon_init_timers(irq_handler_t counter_fn)
104 struct device_node *rootnp, *np;
107 @@ -153,6 +153,12 @@ void __init leon_init_timers(irq_handler
108 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0);
111 + LEON3_BYPASS_STORE_PA(&(leon3_irqctrl_regs->mask[0]), 0);
112 + eirq = (LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->mpstatus) >> 16) & 0xf;
114 + /* Extended IRQ controller available */
115 + sparc_leon_eirq_register(eirq);
118 printk(KERN_ERR "No Timer/irqctrl found\n");