aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2011-04-19 19:41:22 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-21 18:31:29 -0400
commit4c6773c3954cb1192f70a63e2dc61adc55bb0948 (patch)
tree959f841e0ac17fc3e4796f9ee7582ea1a02627c3 /arch/sparc
parentd61a38b2ced149c00898833ccd3ea0433db8ae7d (diff)
sparc32,leon: add support for extended interrupt controller
The extended IRQ controller gives the LEON 16 more IRQs. The patch installs a custom handler for the exetended controller IRQ, where a register is read and the "real" IRQ causing IRQ is determined. Signed-off-by: Daniel Hellstrom <daniel@gaisler.com> Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/include/asm/leon.h7
-rw-r--r--arch/sparc/kernel/leon_kernel.c95
2 files changed, 74 insertions, 28 deletions
diff --git a/arch/sparc/include/asm/leon.h b/arch/sparc/include/asm/leon.h
index c04f96fb753c..12712541e9ee 100644
--- a/arch/sparc/include/asm/leon.h
+++ b/arch/sparc/include/asm/leon.h
@@ -183,7 +183,6 @@ static inline void leon_srmmu_enabletlb(void)
183/* macro access for leon_readnobuffer_reg() */ 183/* macro access for leon_readnobuffer_reg() */
184#define LEON_BYPASSCACHE_LOAD_VA(x) leon_readnobuffer_reg((unsigned long)(x)) 184#define LEON_BYPASSCACHE_LOAD_VA(x) leon_readnobuffer_reg((unsigned long)(x))
185 185
186extern void sparc_leon_eirq_register(int eirq);
187extern void leon_init(void); 186extern void leon_init(void);
188extern void leon_switch_mm(void); 187extern void leon_switch_mm(void);
189extern void leon_init_IRQ(void); 188extern void leon_init_IRQ(void);
@@ -339,9 +338,9 @@ struct leon2_cacheregs {
339#include <linux/interrupt.h> 338#include <linux/interrupt.h>
340 339
341struct device_node; 340struct device_node;
342extern int sparc_leon_eirq_get(int eirq, int cpu); 341extern unsigned int leon_build_device_irq(unsigned int real_irq,
343extern irqreturn_t sparc_leon_eirq_isr(int dummy, void *dev_id); 342 irq_flow_handler_t flow_handler,
344extern void sparc_leon_eirq_register(int eirq); 343 const char *name, int do_ack);
345extern void leon_clear_clock_irq(void); 344extern void leon_clear_clock_irq(void);
346extern void leon_load_profile_irq(int cpu, unsigned int limit); 345extern void leon_load_profile_irq(int cpu, unsigned int limit);
347extern void leon_init_timers(irq_handler_t counter_fn); 346extern void leon_init_timers(irq_handler_t counter_fn);
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index 390e46962760..210f4a0a8457 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -19,6 +19,7 @@
19#include <asm/leon_amba.h> 19#include <asm/leon_amba.h>
20#include <asm/traps.h> 20#include <asm/traps.h>
21#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
22#include <asm/smp.h>
22 23
23#include "prom.h" 24#include "prom.h"
24#include "irq.h" 25#include "irq.h"
@@ -36,37 +37,51 @@ static DEFINE_SPINLOCK(leon_irq_lock);
36unsigned long leon3_gptimer_irq; /* interrupt controller irq number */ 37unsigned long leon3_gptimer_irq; /* interrupt controller irq number */
37unsigned long leon3_gptimer_idx; /* Timer Index (0..6) within Timer Core */ 38unsigned long leon3_gptimer_idx; /* Timer Index (0..6) within Timer Core */
38unsigned int sparc_leon_eirq; 39unsigned int sparc_leon_eirq;
39#define LEON_IMASK ((&leon3_irqctrl_regs->mask[0])) 40#define LEON_IMASK (&leon3_irqctrl_regs->mask[0])
41#define LEON_IACK (&leon3_irqctrl_regs->iclear)
42#define LEON_DO_ACK_HW 1
40 43
41/* Return the IRQ of the pending IRQ on the extended IRQ controller */ 44/* Return the last ACKed IRQ by the Extended IRQ controller. It has already
42int sparc_leon_eirq_get(int eirq, int cpu) 45 * been (automatically) ACKed when the CPU takes the trap.
46 */
47static inline unsigned int leon_eirq_get(int cpu)
43{ 48{
44 return LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->intid[cpu]) & 0x1f; 49 return LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->intid[cpu]) & 0x1f;
45} 50}
46 51
47irqreturn_t sparc_leon_eirq_isr(int dummy, void *dev_id) 52/* Handle one or multiple IRQs from the extended interrupt controller */
53static void leon_handle_ext_irq(unsigned int irq, struct irq_desc *desc)
48{ 54{
49 printk(KERN_ERR "sparc_leon_eirq_isr: ERROR EXTENDED IRQ\n"); 55 unsigned int eirq;
50 return IRQ_HANDLED; 56 int cpu = hard_smp_processor_id();
57
58 eirq = leon_eirq_get(cpu);
59 if ((eirq & 0x10) && irq_map[eirq]->irq) /* bit4 tells if IRQ happened */
60 generic_handle_irq(irq_map[eirq]->irq);
51} 61}
52 62
53/* The extended IRQ controller has been found, this function registers it */ 63/* The extended IRQ controller has been found, this function registers it */
54void sparc_leon_eirq_register(int eirq) 64void leon_eirq_setup(unsigned int eirq)
55{ 65{
56 int irq; 66 unsigned long mask, oldmask;
67 unsigned int veirq;
57 68
58 /* Register a "BAD" handler for this interrupt, it should never happen */ 69 if (eirq < 1 || eirq > 0xf) {
59 irq = request_irq(eirq, sparc_leon_eirq_isr, 70 printk(KERN_ERR "LEON EXT IRQ NUMBER BAD: %d\n", eirq);
60 (IRQF_DISABLED | SA_STATIC_ALLOC), "extirq", NULL); 71 return;
61
62 if (irq) {
63 printk(KERN_ERR
64 "sparc_leon_eirq_register: unable to attach IRQ%d\n",
65 eirq);
66 } else {
67 sparc_leon_eirq = eirq;
68 } 72 }
69 73
74 veirq = leon_build_device_irq(eirq, leon_handle_ext_irq, "extirq", 0);
75
76 /*
77 * Unmask the Extended IRQ, the IRQs routed through the Ext-IRQ
78 * controller have a mask-bit of their own, so this is safe.
79 */
80 irq_link(veirq);
81 mask = 1 << eirq;
82 oldmask = LEON3_BYPASS_LOAD_PA(LEON_IMASK);
83 LEON3_BYPASS_STORE_PA(LEON_IMASK, (oldmask | mask));
84 sparc_leon_eirq = eirq;
70} 85}
71 86
72static inline unsigned long get_irqmask(unsigned int irq) 87static inline unsigned long get_irqmask(unsigned int irq)
@@ -119,16 +134,33 @@ static void leon_shutdown_irq(struct irq_data *data)
119 irq_unlink(data->irq); 134 irq_unlink(data->irq);
120} 135}
121 136
137/* Used by external level sensitive IRQ handlers on the LEON: ACK IRQ ctrl */
138static void leon_eoi_irq(struct irq_data *data)
139{
140 unsigned long mask = (unsigned long)data->chip_data;
141
142 if (mask & LEON_DO_ACK_HW)
143 LEON3_BYPASS_STORE_PA(LEON_IACK, mask & ~LEON_DO_ACK_HW);
144}
145
122static struct irq_chip leon_irq = { 146static struct irq_chip leon_irq = {
123 .name = "leon", 147 .name = "leon",
124 .irq_startup = leon_startup_irq, 148 .irq_startup = leon_startup_irq,
125 .irq_shutdown = leon_shutdown_irq, 149 .irq_shutdown = leon_shutdown_irq,
126 .irq_mask = leon_mask_irq, 150 .irq_mask = leon_mask_irq,
127 .irq_unmask = leon_unmask_irq, 151 .irq_unmask = leon_unmask_irq,
152 .irq_eoi = leon_eoi_irq,
128}; 153};
129 154
130static unsigned int leon_build_device_irq(struct platform_device *op, 155/*
131 unsigned int real_irq) 156 * Build a LEON IRQ for the edge triggered LEON IRQ controller:
157 * Edge (normal) IRQ - handle_simple_irq, ack=DONT-CARE, never ack
158 * Level IRQ (PCI|Level-GPIO) - handle_fasteoi_irq, ack=1, ack after ISR
159 * Per-CPU Edge - handle_percpu_irq, ack=0
160 */
161unsigned int leon_build_device_irq(unsigned int real_irq,
162 irq_flow_handler_t flow_handler,
163 const char *name, int do_ack)
132{ 164{
133 unsigned int irq; 165 unsigned int irq;
134 unsigned long mask; 166 unsigned long mask;
@@ -142,17 +174,26 @@ static unsigned int leon_build_device_irq(struct platform_device *op,
142 if (irq == 0) 174 if (irq == 0)
143 goto out; 175 goto out;
144 176
177 if (do_ack)
178 mask |= LEON_DO_ACK_HW;
179
145 irq_set_chip_and_handler_name(irq, &leon_irq, 180 irq_set_chip_and_handler_name(irq, &leon_irq,
146 handle_simple_irq, "edge"); 181 flow_handler, name);
147 irq_set_chip_data(irq, (void *)mask); 182 irq_set_chip_data(irq, (void *)mask);
148 183
149out: 184out:
150 return irq; 185 return irq;
151} 186}
152 187
188static unsigned int _leon_build_device_irq(struct platform_device *op,
189 unsigned int real_irq)
190{
191 return leon_build_device_irq(real_irq, handle_simple_irq, "edge", 0);
192}
193
153void __init leon_init_timers(irq_handler_t counter_fn) 194void __init leon_init_timers(irq_handler_t counter_fn)
154{ 195{
155 int irq; 196 int irq, eirq;
156 struct device_node *rootnp, *np, *nnp; 197 struct device_node *rootnp, *np, *nnp;
157 struct property *pp; 198 struct property *pp;
158 int len; 199 int len;
@@ -262,11 +303,17 @@ void __init leon_init_timers(irq_handler_t counter_fn)
262 icsel = LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->icsel[cpu/8]); 303 icsel = LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->icsel[cpu/8]);
263 icsel = (icsel >> ((7 - (cpu&0x7)) * 4)) & 0xf; 304 icsel = (icsel >> ((7 - (cpu&0x7)) * 4)) & 0xf;
264 leon3_irqctrl_regs += icsel; 305 leon3_irqctrl_regs += icsel;
306
307 /* Probe extended IRQ controller */
308 eirq = (LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->mpstatus)
309 >> 16) & 0xf;
310 if (eirq != 0)
311 leon_eirq_setup(eirq);
265 } else { 312 } else {
266 goto bad; 313 goto bad;
267 } 314 }
268 315
269 irq = leon_build_device_irq(NULL, leon3_gptimer_irq + leon3_gptimer_idx); 316 irq = _leon_build_device_irq(NULL, leon3_gptimer_irq+leon3_gptimer_idx);
270 err = request_irq(irq, counter_fn, IRQF_TIMER, "timer", NULL); 317 err = request_irq(irq, counter_fn, IRQF_TIMER, "timer", NULL);
271 318
272 if (err) { 319 if (err) {
@@ -394,7 +441,7 @@ void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu)
394void __init leon_init_IRQ(void) 441void __init leon_init_IRQ(void)
395{ 442{
396 sparc_irq_config.init_timers = leon_init_timers; 443 sparc_irq_config.init_timers = leon_init_timers;
397 sparc_irq_config.build_device_irq = leon_build_device_irq; 444 sparc_irq_config.build_device_irq = _leon_build_device_irq;
398 445
399 BTFIXUPSET_CALL(clear_clock_irq, leon_clear_clock_irq, 446 BTFIXUPSET_CALL(clear_clock_irq, leon_clear_clock_irq,
400 BTFIXUPCALL_NORM); 447 BTFIXUPCALL_NORM);