2 * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #include <linux/config.h>
19 #include <linux/kernel.h>
20 #include <linux/reboot.h>
21 #include <linux/string.h>
23 #include <asm/bootinfo.h>
24 #include <asm/mipsregs.h>
26 #include <asm/sibyte/sb1250.h>
27 #include <asm/sibyte/sb1250_regs.h>
28 #include <asm/sibyte/sb1250_scd.h>
30 unsigned int sb1_pass;
31 unsigned int soc_pass;
32 unsigned int soc_type;
33 unsigned int periph_rev;
34 unsigned int zbbus_mhz;
37 static char *pass_str;
38 static unsigned int war_pass; /* XXXKW don't overload PASS defines? */
40 static inline int setup_bcm1250(void);
41 static inline int setup_bcm112x(void);
43 /* Setup code likely to be common to all SiByte platforms */
45 static inline int sys_rev_decode(void)
51 case K_SYS_SOC_TYPE_BCM1250:
52 case K_SYS_SOC_TYPE_BCM1250_ALT:
53 case K_SYS_SOC_TYPE_BCM1250_ALT2:
55 ret = setup_bcm1250();
57 case K_SYS_SOC_TYPE_BCM1120:
59 ret = setup_bcm112x();
61 case K_SYS_SOC_TYPE_BCM1125:
63 ret = setup_bcm112x();
65 case K_SYS_SOC_TYPE_BCM1125H:
67 ret = setup_bcm112x();
70 prom_printf("Unknown SOC type %x\n", soc_type);
77 static inline int setup_bcm1250(void)
82 case K_SYS_REVISION_BCM1250_PASS1:
86 case K_SYS_REVISION_BCM1250_A10:
89 /* XXXKW different war_pass? */
90 war_pass = K_SYS_REVISION_BCM1250_PASS2;
92 case K_SYS_REVISION_BCM1250_PASS2_2:
96 case K_SYS_REVISION_BCM1250_B2:
99 war_pass = K_SYS_REVISION_BCM1250_PASS2_2;
101 case K_SYS_REVISION_BCM1250_PASS3:
105 case K_SYS_REVISION_BCM1250_C1:
110 if (soc_pass < K_SYS_REVISION_BCM1250_PASS2_2) {
113 war_pass = K_SYS_REVISION_BCM1250_PASS2;
115 prom_printf("Unknown BCM1250 rev %x\n", soc_pass);
123 static inline int setup_bcm112x(void)
129 /* Early build didn't have revid set */
132 war_pass = K_SYS_REVISION_BCM112x_A1;
134 case K_SYS_REVISION_BCM112x_A1:
138 case K_SYS_REVISION_BCM112x_A2:
143 prom_printf("Unknown %s rev %x\n", soc_str, soc_pass);
149 void sb1250_setup(void)
155 sb1_pass = read_c0_prid() & 0xff;
156 sys_rev = bus_readq(IOADDR(A_SCD_SYSTEM_REVISION));
157 soc_type = SYS_SOC_TYPE(sys_rev);
158 soc_pass = G_SYS_REVISION(sys_rev);
160 if (sys_rev_decode()) {
161 prom_printf("Restart after failure to identify SiByte chip\n");
162 machine_restart(NULL);
165 plldiv = G_SYS_PLL_DIV(bus_readq(IOADDR(A_SCD_SYSTEM_CFG)));
166 zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
168 prom_printf("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n",
169 soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
170 prom_printf("Board type: %s\n", get_system_type());
173 case K_SYS_REVISION_BCM1250_PASS1:
174 #ifndef CONFIG_SB1_PASS_1_WORKAROUNDS
175 prom_printf("@@@@ This is a BCM1250 A0-A2 (Pass 1) board, and the kernel doesn't have the proper workarounds compiled in. @@@@\n");
179 case K_SYS_REVISION_BCM1250_PASS2:
180 /* Pass 2 - easiest as default for now - so many numbers */
181 #if !defined(CONFIG_SB1_PASS_2_WORKAROUNDS) || !defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS)
182 prom_printf("@@@@ This is a BCM1250 A3-A10 board, and the kernel doesn't have the proper workarounds compiled in. @@@@\n");
185 #ifdef CONFIG_CPU_HAS_PREFETCH
186 prom_printf("@@@@ Prefetches may be enabled in this kernel, but are buggy on this board. @@@@\n");
190 case K_SYS_REVISION_BCM1250_PASS2_2:
191 #ifndef CONFIG_SB1_PASS_2_WORKAROUNDS
192 prom_printf("@@@@ This is a BCM1250 B1/B2. board, and the kernel doesn't have the proper workarounds compiled in. @@@@\n");
195 #if defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) || !defined(CONFIG_CPU_HAS_PREFETCH)
196 prom_printf("@@@@ This is a BCM1250 B1/B2, but the kernel is conservatively configured for an 'A' stepping. @@@@\n");
203 prom_printf("Invalid configuration for this chip.\n");
204 machine_restart(NULL);