MIPS: MSP71xx: Set up MSP VPE1 timer.
authorAnoop P A <anoop.pa@gmail.com>
Tue, 25 Jan 2011 18:08:16 +0000 (23:38 +0530)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 25 Mar 2011 17:45:13 +0000 (18:45 +0100)
VPE1 timer will be required for VSMP / SMTC.

[Ralf: Fixed a bunch of issues raised by checkpatch.]

Signed-off-by: Anoop P A <anoop.pa@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/2049/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/pmc-sierra/msp71xx/msp_time.c

index 01df84ce31e209cd3d05e0e316b68ea78d74798e..8b42f307a7a7c10f0ea886cf1a28744cf895329a 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/ptrace.h>
 
+#include <asm/cevt-r4k.h>
 #include <asm/mipsregs.h>
 #include <asm/time.h>
 
 #include <msp_int.h>
 #include <msp_regs.h>
 
+#define get_current_vpe()   \
+       ((read_c0_tcbind() >> TCBIND_CURVPE_SHIFT) & TCBIND_CURVPE)
+
+static struct irqaction timer_vpe1;
+static int tim_installed;
+
 void __init plat_time_init(void)
 {
        char    *endp, *s;
@@ -83,5 +90,12 @@ void __init plat_time_init(void)
 
 unsigned int __cpuinit get_c0_compare_int(void)
 {
-       return MSP_INT_VPE0_TIMER;
+       /* MIPS_MT modes may want timer for second VPE */
+       if ((get_current_vpe()) && !tim_installed) {
+               memcpy(&timer_vpe1, &c0_compare_irqaction, sizeof(timer_vpe1));
+               setup_irq(MSP_INT_VPE1_TIMER, &timer_vpe1);
+               tim_installed++;
+       }
+
+       return get_current_vpe() ? MSP_INT_VPE1_TIMER : MSP_INT_VPE0_TIMER;
 }