blob: bbbf8057565b236e69561439f8326106204ff82b [file] [log] [blame]
Maxime Bizone7300d02009-08-18 13:23:37 +01001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7 */
8
9#include <linux/init.h>
10#include <linux/bootmem.h>
Kevin Cernekeea068dde2013-06-18 08:34:31 +000011#include <linux/smp.h>
Maxime Bizone7300d02009-08-18 13:23:37 +010012#include <asm/bootinfo.h>
Kevin Cernekeea068dde2013-06-18 08:34:31 +000013#include <asm/bmips.h>
14#include <asm/smp-ops.h>
15#include <asm/mipsregs.h>
Maxime Bizone7300d02009-08-18 13:23:37 +010016#include <bcm63xx_board.h>
17#include <bcm63xx_cpu.h>
18#include <bcm63xx_io.h>
19#include <bcm63xx_regs.h>
Maxime Bizone7300d02009-08-18 13:23:37 +010020
21void __init prom_init(void)
22{
23 u32 reg, mask;
24
25 bcm63xx_cpu_init();
26
27 /* stop any running watchdog */
28 bcm_wdt_writel(WDT_STOP_1, WDT_CTL_REG);
29 bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG);
30
31 /* disable all hardware blocks clock for now */
Florian Fainelli7b933422013-06-18 16:55:40 +000032 if (BCMCPU_IS_3368())
33 mask = CKCTL_3368_ALL_SAFE_EN;
34 else if (BCMCPU_IS_6328())
Jonas Gorskie5766ae2012-07-24 16:33:12 +020035 mask = CKCTL_6328_ALL_SAFE_EN;
36 else if (BCMCPU_IS_6338())
Maxime Bizone7300d02009-08-18 13:23:37 +010037 mask = CKCTL_6338_ALL_SAFE_EN;
38 else if (BCMCPU_IS_6345())
39 mask = CKCTL_6345_ALL_SAFE_EN;
40 else if (BCMCPU_IS_6348())
41 mask = CKCTL_6348_ALL_SAFE_EN;
Maxime Bizon04712f32011-11-04 19:09:35 +010042 else if (BCMCPU_IS_6358())
Maxime Bizone7300d02009-08-18 13:23:37 +010043 mask = CKCTL_6358_ALL_SAFE_EN;
Jonas Gorski2c8aaf72013-03-21 14:03:17 +000044 else if (BCMCPU_IS_6362())
45 mask = CKCTL_6362_ALL_SAFE_EN;
Maxime Bizon04712f32011-11-04 19:09:35 +010046 else if (BCMCPU_IS_6368())
47 mask = CKCTL_6368_ALL_SAFE_EN;
48 else
49 mask = 0;
Maxime Bizone7300d02009-08-18 13:23:37 +010050
51 reg = bcm_perf_readl(PERF_CKCTL_REG);
52 reg &= ~mask;
53 bcm_perf_writel(reg, PERF_CKCTL_REG);
54
Maxime Bizone7300d02009-08-18 13:23:37 +010055 /* do low level board init */
56 board_prom_init();
Kevin Cernekeea068dde2013-06-18 08:34:31 +000057
Jonas Gorski10102692013-12-18 14:12:07 +010058 /* set up SMP */
59 if (!register_bmips_smp_ops()) {
Kevin Cernekeea068dde2013-06-18 08:34:31 +000060 /*
Jonas Gorski0e983d72013-12-18 14:11:59 +010061 * BCM6328 might not have its second CPU enabled, while BCM3368
62 * and BCM6358 need special handling for their shared TLB, so
63 * disable SMP for now.
Kevin Cernekeea068dde2013-06-18 08:34:31 +000064 */
65 if (BCMCPU_IS_6328()) {
Jonas Gorski7ac836c2013-06-18 08:34:32 +000066 reg = bcm_readl(BCM_6328_OTP_BASE +
67 OTP_USER_BITS_6328_REG(3));
68
69 if (reg & OTP_6328_REG3_TP1_DISABLED)
70 bmips_smp_enabled = 0;
Jonas Gorski0e983d72013-12-18 14:11:59 +010071 } else if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) {
Kevin Cernekeea068dde2013-06-18 08:34:31 +000072 bmips_smp_enabled = 0;
73 }
74
75 if (!bmips_smp_enabled)
76 return;
77
78 /*
79 * The bootloader has set up the CPU1 reset vector at
80 * 0xa000_0200.
81 * This conflicts with the special interrupt vector (IV).
82 * The bootloader has also set up CPU1 to respond to the wrong
83 * IPI interrupt.
84 * Here we will start up CPU1 in the background and ask it to
85 * reconfigure itself then go back to sleep.
86 */
Jonas Gorski4b1ee302019-10-22 21:11:00 +020087 memcpy((void *)0xa0000200, bmips_smp_movevec, 0x20);
Kevin Cernekeea068dde2013-06-18 08:34:31 +000088 __sync();
89 set_c0_cause(C_SW0);
90 cpumask_set_cpu(1, &bmips_booted_mask);
91
92 /*
93 * FIXME: we really should have some sort of hazard barrier here
94 */
95 }
Maxime Bizone7300d02009-08-18 13:23:37 +010096}
97
98void __init prom_free_prom_memory(void)
99{
100}