brcm63xx: update bmips patches with upstream submission
[openwrt.git] / target / linux / brcm63xx / patches-3.10 / 058-MIPS-BMIPS-fix-slave-CPU-booting-when-physical-CPU-i.patch
1 From ff5fadaff39180dc0b652753b5614a564711be29 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <florian@openwrt.org>
3 Date: Wed, 24 Jul 2013 17:12:11 +0100
4 Subject: [PATCH] MIPS: BMIPS: fix slave CPU booting when physical CPU is not 0
5
6 The current BMIPS SMP code assumes that the slave CPU is physical and
7 logical CPU 1, but on some systems such as BCM3368, the slave CPU is
8 physical CPU0. Fix the code to read the physical CPU (thread ID) we are
9 running this code on, and adjust the relocation vector address based on
10 it. This allows bringing up the second CPU on BCM3368 for instance.
11
12 Signed-off-by: Florian Fainelli <florian@openwrt.org>
13 Cc: linux-mips@linux-mips.org
14 Cc: cernekee@gmail.com
15 Cc: jogo@openwrt.org
16 Cc: blogic@openwrt.org
17 Patchwork: https://patchwork.linux-mips.org/patch/5621/
18 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
19 ---
20  arch/mips/kernel/bmips_vec.S |  6 +++++-
21  arch/mips/kernel/smp-bmips.c | 10 ++++++++--
22  2 files changed, 13 insertions(+), 3 deletions(-)
23
24 --- a/arch/mips/kernel/bmips_vec.S
25 +++ b/arch/mips/kernel/bmips_vec.S
26 @@ -56,7 +56,11 @@ LEAF(bmips_smp_movevec)
27         /* set up CPU1 CBR; move BASE to 0xa000_0000 */
28         li      k0, 0xff400000
29         mtc0    k0, $22, 6
30 -       li      k1, CKSEG1 | BMIPS_RELO_VECTOR_CONTROL_1
31 +       /* set up relocation vector address based on thread ID */
32 +       mfc0    k1, $22, 3
33 +       srl     k1, 16
34 +       andi    k1, 0x8000
35 +       or      k1, CKSEG1 | BMIPS_RELO_VECTOR_CONTROL_0
36         or      k0, k1
37         li      k1, 0xa0080000
38         sw      k1, 0(k0)
39 --- a/arch/mips/kernel/smp-bmips.c
40 +++ b/arch/mips/kernel/smp-bmips.c
41 @@ -196,9 +196,15 @@ static void bmips_init_secondary(void)
42  #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
43         void __iomem *cbr = BMIPS_GET_CBR();
44         unsigned long old_vec;
45 +       unsigned long relo_vector;
46 +       int boot_cpu;
47  
48 -       old_vec = __raw_readl(cbr + BMIPS_RELO_VECTOR_CONTROL_1);
49 -       __raw_writel(old_vec & ~0x20000000, cbr + BMIPS_RELO_VECTOR_CONTROL_1);
50 +       boot_cpu = !!(read_c0_brcm_cmt_local() & (1 << 31));
51 +       relo_vector = boot_cpu ? BMIPS_RELO_VECTOR_CONTROL_0 :
52 +                         BMIPS_RELO_VECTOR_CONTROL_1;
53 +
54 +       old_vec = __raw_readl(cbr + relo_vector);
55 +       __raw_writel(old_vec & ~0x20000000, cbr + relo_vector);
56  
57         clear_c0_cause(smp_processor_id() ? C_SW1 : C_SW0);
58  #elif defined(CONFIG_CPU_BMIPS5000)