Commit 6465460c authored by Jonas Gorski's avatar Jonas Gorski Committed by Ralf Baechle

MIPS: BMIPS: change compile time checks to runtime checks

Allow building for all bmips cpus at the same time by changing ifdefs
to checks for the cpu type, or adding appropriate checks to the
assembly.

Since BMIPS43XX and BMIPS5000 require different IPI implementations,
split the SMP ops into one for each, so the runtime overhead is only
at registration time for them.
Signed-off-by: default avatarJonas Gorski <jogo@openwrt.org>
Signed-off-by: default avatarJohn Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/6241/
parent 68248d0c
...@@ -61,7 +61,7 @@ void __init prom_init(void) ...@@ -61,7 +61,7 @@ void __init prom_init(void)
if (IS_ENABLED(CONFIG_CPU_BMIPS4350) && IS_ENABLED(CONFIG_SMP)) { if (IS_ENABLED(CONFIG_CPU_BMIPS4350) && IS_ENABLED(CONFIG_SMP)) {
/* set up SMP */ /* set up SMP */
register_smp_ops(&bmips_smp_ops); register_smp_ops(&bmips43xx_smp_ops);
/* /*
* BCM6328 might not have its second CPU enabled, while BCM3368 * BCM6328 might not have its second CPU enabled, while BCM3368
......
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <asm/r4kcache.h> #include <asm/r4kcache.h>
extern struct plat_smp_ops bmips_smp_ops; extern struct plat_smp_ops bmips43xx_smp_ops;
extern struct plat_smp_ops bmips5000_smp_ops;
extern char bmips_reset_nmi_vec; extern char bmips_reset_nmi_vec;
extern char bmips_reset_nmi_vec_end; extern char bmips_reset_nmi_vec_end;
extern char bmips_smp_movevec; extern char bmips_smp_movevec;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/asmmacro.h> #include <asm/asmmacro.h>
#include <asm/cacheops.h> #include <asm/cacheops.h>
#include <asm/cpu.h>
#include <asm/regdef.h> #include <asm/regdef.h>
#include <asm/mipsregs.h> #include <asm/mipsregs.h>
#include <asm/stackframe.h> #include <asm/stackframe.h>
...@@ -91,12 +92,18 @@ NESTED(bmips_reset_nmi_vec, PT_SIZE, sp) ...@@ -91,12 +92,18 @@ NESTED(bmips_reset_nmi_vec, PT_SIZE, sp)
beqz k0, bmips_smp_entry beqz k0, bmips_smp_entry
#if defined(CONFIG_CPU_BMIPS5000) #if defined(CONFIG_CPU_BMIPS5000)
mfc0 k0, CP0_PRID
li k1, PRID_IMP_BMIPS5000
andi k0, 0xff00
bne k0, k1, 1f
/* if we're not on core 0, this must be the SMP boot signal */ /* if we're not on core 0, this must be the SMP boot signal */
li k1, (3 << 25) li k1, (3 << 25)
mfc0 k0, $22 mfc0 k0, $22
and k0, k1 and k0, k1
bnez k0, bmips_smp_entry bnez k0, bmips_smp_entry
#endif 1:
#endif /* CONFIG_CPU_BMIPS5000 */
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
/* nope, it's just a regular NMI */ /* nope, it's just a regular NMI */
...@@ -139,7 +146,12 @@ bmips_smp_entry: ...@@ -139,7 +146,12 @@ bmips_smp_entry:
xori k0, 0x04 xori k0, 0x04
mtc0 k0, CP0_CONFIG mtc0 k0, CP0_CONFIG
mfc0 k0, CP0_PRID
andi k0, 0xff00
#if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380) #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
li k1, PRID_IMP_BMIPS43XX
bne k0, k1, 2f
/* initialize CPU1's local I-cache */ /* initialize CPU1's local I-cache */
li k0, 0x80000000 li k0, 0x80000000
li k1, 0x80010000 li k1, 0x80010000
...@@ -150,14 +162,21 @@ bmips_smp_entry: ...@@ -150,14 +162,21 @@ bmips_smp_entry:
1: cache Index_Store_Tag_I, 0(k0) 1: cache Index_Store_Tag_I, 0(k0)
addiu k0, 16 addiu k0, 16
bne k0, k1, 1b bne k0, k1, 1b
#elif defined(CONFIG_CPU_BMIPS5000)
b 3f
2:
#endif /* CONFIG_CPU_BMIPS4350 || CONFIG_CPU_BMIPS4380 */
#if defined(CONFIG_CPU_BMIPS5000)
/* set exception vector base */ /* set exception vector base */
li k1, PRID_IMP_BMIPS5000
bne k0, k1, 3f
la k0, ebase la k0, ebase
lw k0, 0(k0) lw k0, 0(k0)
mtc0 k0, $15, 1 mtc0 k0, $15, 1
BARRIER BARRIER
#endif #endif /* CONFIG_CPU_BMIPS5000 */
3:
/* jump back to kseg0 in case we need to remap the kseg1 area */ /* jump back to kseg0 in case we need to remap the kseg1 area */
la k0, 1f la k0, 1f
jr k0 jr k0
...@@ -221,8 +240,18 @@ END(bmips_smp_int_vec) ...@@ -221,8 +240,18 @@ END(bmips_smp_int_vec)
LEAF(bmips_enable_xks01) LEAF(bmips_enable_xks01)
#if defined(CONFIG_XKS01) #if defined(CONFIG_XKS01)
mfc0 t0, CP0_PRID
andi t2, t0, 0xff00
#if defined(CONFIG_CPU_BMIPS4380) #if defined(CONFIG_CPU_BMIPS4380)
li t1, PRID_IMP_BMIPS43XX
bne t2, t1, 1f
andi t0, 0xff
addiu t1, t0, -PRID_REV_BMIPS4380_HI
bgtz t1, 2f
addiu t0, -PRID_REV_BMIPS4380_LO
bltz t0, 2f
mfc0 t0, $22, 3 mfc0 t0, $22, 3
li t1, 0x1ff0 li t1, 0x1ff0
li t2, (1 << 12) | (1 << 9) li t2, (1 << 12) | (1 << 9)
...@@ -231,7 +260,13 @@ LEAF(bmips_enable_xks01) ...@@ -231,7 +260,13 @@ LEAF(bmips_enable_xks01)
or t0, t2 or t0, t2
mtc0 t0, $22, 3 mtc0 t0, $22, 3
BARRIER BARRIER
#elif defined(CONFIG_CPU_BMIPS5000) b 2f
1:
#endif /* CONFIG_CPU_BMIPS4380 */
#if defined(CONFIG_CPU_BMIPS5000)
li t1, PRID_IMP_BMIPS5000
bne t2, t1, 2f
mfc0 t0, $22, 5 mfc0 t0, $22, 5
li t1, 0x01ff li t1, 0x01ff
li t2, (1 << 8) | (1 << 5) li t2, (1 << 8) | (1 << 5)
...@@ -240,12 +275,8 @@ LEAF(bmips_enable_xks01) ...@@ -240,12 +275,8 @@ LEAF(bmips_enable_xks01)
or t0, t2 or t0, t2
mtc0 t0, $22, 5 mtc0 t0, $22, 5
BARRIER BARRIER
#else #endif /* CONFIG_CPU_BMIPS5000 */
2:
#error Missing XKS01 setup
#endif
#endif /* defined(CONFIG_XKS01) */ #endif /* defined(CONFIG_XKS01) */
jr ra jr ra
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment