base-files: diag does not need to insmod any drivers, procd already did it for us
[openwrt.git] / target / linux / brcm63xx / patches-3.9 / 310-BCM63XX-Add-SMP-support-to-prom.c.patch
1 From 10ea7fd6b854c3ecf745d053beba10c7e00c33c9 Mon Sep 17 00:00:00 2001
2 From: Kevin Cernekee <cernekee@gmail.com>
3 Date: Sat, 9 Jul 2011 12:15:06 -0700
4 Subject: [PATCH 01/13] MIPS: BCM63XX: Add SMP support to prom.c
5
6 This involves two changes to the BSP code:
7
8 1) register_smp_ops() for BMIPS SMP
9
10 2) The CPU1 boot vector on some of the BCM63xx platforms conflicts with
11 the special interrupt vector (IV).  Move it to 0x8000_0380 at boot time,
12 to resolve the conflict.
13
14 Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
15 [jogo@openwrt: move smp ops registration below #ifdef guard, don't enable
16  smp for 6328/6358]
17 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
18 ---
19  arch/mips/bcm63xx/prom.c |   33 +++++++++++++++++++++++++++++++++
20  1 file changed, 33 insertions(+)
21
22 --- a/arch/mips/bcm63xx/prom.c
23 +++ b/arch/mips/bcm63xx/prom.c
24 @@ -8,7 +8,11 @@
25  
26  #include <linux/init.h>
27  #include <linux/bootmem.h>
28 +#include <linux/smp.h>
29  #include <asm/bootinfo.h>
30 +#include <asm/bmips.h>
31 +#include <asm/smp-ops.h>
32 +#include <asm/mipsregs.h>
33  #include <bcm63xx_board.h>
34  #include <bcm63xx_cpu.h>
35  #include <bcm63xx_io.h>
36 @@ -52,6 +56,35 @@ void __init prom_init(void)
37  
38         /* do low level board init */
39         board_prom_init();
40 +
41 +#if defined(CONFIG_CPU_BMIPS4350) && defined(CONFIG_SMP)
42 +       /* set up SMP */
43 +       register_smp_ops(&bmips_smp_ops);
44 +
45 +       /*
46 +        * BCM6328 does not have its second CPU enabled, while BCM6358
47 +        * needs special handling for its shared TLB, so disable SMP for now.
48 +        */
49 +       if (BCMCPU_IS_6328() || BCMCPU_IS_6358()) {
50 +               bmips_smp_enabled = 0;
51 +               return;
52 +       }
53 +
54 +       /*
55 +        * The bootloader has set up the CPU1 reset vector at 0xa000_0200.
56 +        * This conflicts with the special interrupt vector (IV).
57 +        * The bootloader has also set up CPU1 to respond to the wrong
58 +        * IPI interrupt.
59 +        * Here we will start up CPU1 in the background and ask it to
60 +        * reconfigure itself then go back to sleep.
61 +        */
62 +       memcpy((void *)0xa0000200, &bmips_smp_movevec, 0x20);
63 +       __sync();
64 +       set_c0_cause(C_SW0);
65 +       cpumask_set_cpu(1, &bmips_booted_mask);
66 +
67 +       /* FIXME: we really should have some sort of hazard barrier here */
68 +#endif
69  }
70  
71  void __init prom_free_prom_memory(void)