Skip to content

Commit

Permalink
MIPS: BMIPS: change compile time checks to runtime checks
Browse files Browse the repository at this point in the history
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: Jonas Gorski <jogo@openwrt.org>
Signed-off-by: John Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/6241/
  • Loading branch information
Jonas Gorski authored and Ralf Baechle committed Jan 22, 2014
1 parent 68248d0 commit 6465460
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 137 deletions.
2 changes: 1 addition & 1 deletion arch/mips/bcm63xx/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void __init prom_init(void)

if (IS_ENABLED(CONFIG_CPU_BMIPS4350) && IS_ENABLED(CONFIG_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
Expand Down
3 changes: 2 additions & 1 deletion arch/mips/include/asm/bmips.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
#include <linux/cpumask.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_end;
extern char bmips_smp_movevec;
Expand Down
55 changes: 43 additions & 12 deletions arch/mips/kernel/bmips_vec.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <asm/asm.h>
#include <asm/asmmacro.h>
#include <asm/cacheops.h>
#include <asm/cpu.h>
#include <asm/regdef.h>
#include <asm/mipsregs.h>
#include <asm/stackframe.h>
Expand Down Expand Up @@ -91,12 +92,18 @@ NESTED(bmips_reset_nmi_vec, PT_SIZE, sp)
beqz k0, bmips_smp_entry

#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 */
li k1, (3 << 25)
mfc0 k0, $22
and k0, k1
bnez k0, bmips_smp_entry
#endif
1:
#endif /* CONFIG_CPU_BMIPS5000 */
#endif /* CONFIG_SMP */

/* nope, it's just a regular NMI */
Expand Down Expand Up @@ -139,7 +146,12 @@ bmips_smp_entry:
xori k0, 0x04
mtc0 k0, CP0_CONFIG

mfc0 k0, CP0_PRID
andi k0, 0xff00
#if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
li k1, PRID_IMP_BMIPS43XX
bne k0, k1, 2f

/* initialize CPU1's local I-cache */
li k0, 0x80000000
li k1, 0x80010000
Expand All @@ -150,14 +162,21 @@ bmips_smp_entry:
1: cache Index_Store_Tag_I, 0(k0)
addiu k0, 16
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 */
li k1, PRID_IMP_BMIPS5000
bne k0, k1, 3f

la k0, ebase
lw k0, 0(k0)
mtc0 k0, $15, 1
BARRIER
#endif

#endif /* CONFIG_CPU_BMIPS5000 */
3:
/* jump back to kseg0 in case we need to remap the kseg1 area */
la k0, 1f
jr k0
Expand Down Expand Up @@ -221,8 +240,18 @@ END(bmips_smp_int_vec)
LEAF(bmips_enable_xks01)

#if defined(CONFIG_XKS01)

mfc0 t0, CP0_PRID
andi t2, t0, 0xff00
#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
li t1, 0x1ff0
li t2, (1 << 12) | (1 << 9)
Expand All @@ -231,7 +260,13 @@ LEAF(bmips_enable_xks01)
or t0, t2
mtc0 t0, $22, 3
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
li t1, 0x01ff
li t2, (1 << 8) | (1 << 5)
Expand All @@ -240,12 +275,8 @@ LEAF(bmips_enable_xks01)
or t0, t2
mtc0 t0, $22, 5
BARRIER
#else

#error Missing XKS01 setup

#endif

#endif /* CONFIG_CPU_BMIPS5000 */
2:
#endif /* defined(CONFIG_XKS01) */

jr ra
Expand Down
Loading

0 comments on commit 6465460

Please sign in to comment.