Skip to content

Commit e2305e3

Browse files
daniel-hellstromdavem330
authored andcommitted
SPARC/LEON: added support for IRQAMP IRQ Controller
Needed for LEON AMP systems where different CPUs are routed to different IRQ controllers. This patch selects the IRQ Controller which has been routed to the boot CPU, it is up to the boot loader to configure the IRQ controller. Signed-off-by: Daniel Hellstrom <daniel@gaisler.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 53aea7c commit e2305e3

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

‎arch/sparc/include/asm/leon.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ static inline void sparc_leon3_disable_cache(void)
224224
"sta %%l2, [%%g0] 2\n\t" : : : "l1", "l2");
225225
};
226226

227+
static inline unsigned long sparc_leon3_asr17(void)
228+
{
229+
u32 asr17;
230+
__asm__ __volatile__ ("rd %%asr17, %0\n\t" : "=r"(asr17));
231+
return asr17;
232+
};
233+
234+
static inline int sparc_leon3_cpuid(void)
235+
{
236+
return sparc_leon3_asr17() >> 28;
237+
}
238+
227239
#endif /*!__ASSEMBLY__*/
228240

229241
#ifdef CONFIG_SMP

‎arch/sparc/include/asm/leon_amba.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ struct leon3_irqctrl_regs_map {
100100
u32 mpbroadcast;
101101
u32 notused02;
102102
u32 notused03;
103-
u32 notused10;
104-
u32 notused11;
105-
u32 notused12;
103+
u32 ampctrl;
104+
u32 icsel[2];
106105
u32 notused13;
107106
u32 notused20;
108107
u32 notused21;
@@ -112,6 +111,7 @@ struct leon3_irqctrl_regs_map {
112111
u32 force[16];
113112
/* Extended IRQ registers */
114113
u32 intid[16]; /* 0xc0 */
114+
u32 unused[(0x1000-0x100)/4];
115115
};
116116

117117
struct leon3_apbuart_regs_map {

‎arch/sparc/kernel/leon_kernel.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ void __init leon_init_timers(irq_handler_t counter_fn)
108108
struct device_node *rootnp, *np;
109109
struct property *pp;
110110
int len;
111+
int cpu, icsel;
111112

112113
leondebug_irq_disable = 0;
113114
leon_debug_irqout = 0;
@@ -160,6 +161,19 @@ void __init leon_init_timers(irq_handler_t counter_fn)
160161
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0);
161162
# endif
162163

164+
/*
165+
* The IRQ controller may (if implemented) consist of multiple
166+
* IRQ controllers, each mapped on a 4Kb boundary.
167+
* Each CPU may be routed to different IRQCTRLs, however
168+
* we assume that all CPUs (in SMP system) is routed to the
169+
* same IRQ Controller, and for non-SMP only one IRQCTRL is
170+
* accessed anyway.
171+
* In AMP systems, Linux must run on CPU0 for the time being.
172+
*/
173+
cpu = sparc_leon3_cpuid();
174+
icsel = LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->icsel[cpu/8]);
175+
icsel = (icsel >> ((7 - (cpu&0x7)) * 4)) & 0xf;
176+
leon3_irqctrl_regs += icsel;
163177
} else {
164178
goto bad;
165179
}

0 commit comments

Comments
 (0)