SPARC/LEON: added support for IRQAMP IRQ Controller
authorDaniel Hellstrom <daniel@gaisler.com>
Tue, 4 Jan 2011 01:41:30 +0000 (01:41 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 4 Jan 2011 19:16:36 +0000 (11:16 -0800)
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>
arch/sparc/include/asm/leon.h
arch/sparc/include/asm/leon_amba.h
arch/sparc/kernel/leon_kernel.c

index 3ea5964c43b423c6180090cb44afa61b7d945ca2..8580d1764f90e2a22da538c37191ac038c3e6ab2 100644 (file)
@@ -224,6 +224,18 @@ static inline void sparc_leon3_disable_cache(void)
                          "sta %%l2, [%%g0] 2\n\t" : : : "l1", "l2");
 };
 
+static inline unsigned long sparc_leon3_asr17(void)
+{
+       u32 asr17;
+       __asm__ __volatile__ ("rd %%asr17, %0\n\t" : "=r"(asr17));
+       return asr17;
+};
+
+static inline int sparc_leon3_cpuid(void)
+{
+       return sparc_leon3_asr17() >> 28;
+}
+
 #endif /*!__ASSEMBLY__*/
 
 #ifdef CONFIG_SMP
index 618e8882179588e3ac0cc7cd542a8444b01f0049..263c719e96f5e6e87662cb2e8b75dd9c1447c911 100644 (file)
@@ -100,9 +100,8 @@ struct leon3_irqctrl_regs_map {
        u32 mpbroadcast;
        u32 notused02;
        u32 notused03;
-       u32 notused10;
-       u32 notused11;
-       u32 notused12;
+       u32 ampctrl;
+       u32 icsel[2];
        u32 notused13;
        u32 notused20;
        u32 notused21;
@@ -112,6 +111,7 @@ struct leon3_irqctrl_regs_map {
        u32 force[16];
        /* Extended IRQ registers */
        u32 intid[16];  /* 0xc0 */
+       u32 unused[(0x1000-0x100)/4];
 };
 
 struct leon3_apbuart_regs_map {
index 80ba8f517318a184f6472ba25b52dd08eb65b6ad..91a978f4d83beadb507b6c4313a658fc5ca3deee 100644 (file)
@@ -108,6 +108,7 @@ void __init leon_init_timers(irq_handler_t counter_fn)
        struct device_node *rootnp, *np;
        struct property *pp;
        int len;
+       int cpu, icsel;
 
        leondebug_irq_disable = 0;
        leon_debug_irqout = 0;
@@ -160,6 +161,19 @@ void __init leon_init_timers(irq_handler_t counter_fn)
                LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0);
 # endif
 
+               /*
+                * The IRQ controller may (if implemented) consist of multiple
+                * IRQ controllers, each mapped on a 4Kb boundary.
+                * Each CPU may be routed to different IRQCTRLs, however
+                * we assume that all CPUs (in SMP system) is routed to the
+                * same IRQ Controller, and for non-SMP only one IRQCTRL is
+                * accessed anyway.
+                * In AMP systems, Linux must run on CPU0 for the time being.
+                */
+               cpu = sparc_leon3_cpuid();
+               icsel = LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->icsel[cpu/8]);
+               icsel = (icsel >> ((7 - (cpu&0x7)) * 4)) & 0xf;
+               leon3_irqctrl_regs += icsel;
        } else {
                goto bad;
        }