1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
5 #include <linux/export.h>
6 #include <linux/init.h>
7 #include <linux/kernel.h>
8 #include <linux/reboot.h>
9 #include <linux/string.h>
11 #include <asm/bootinfo.h>
13 #include <asm/mipsregs.h>
15 #include <asm/sibyte/sb1250.h>
16 #include <asm/sibyte/sb1250_regs.h>
17 #include <asm/sibyte/sb1250_scd.h>
19 unsigned int sb1_pass
;
20 unsigned int soc_pass
;
21 unsigned int soc_type
;
22 EXPORT_SYMBOL(soc_type
);
23 unsigned int periph_rev
;
24 EXPORT_SYMBOL_GPL(periph_rev
);
25 unsigned int zbbus_mhz
;
26 EXPORT_SYMBOL(zbbus_mhz
);
29 static char *pass_str
;
30 static unsigned int war_pass
; /* XXXKW don't overload PASS defines? */
32 static int __init
setup_bcm1250(void)
37 case K_SYS_REVISION_BCM1250_PASS1
:
41 case K_SYS_REVISION_BCM1250_A10
:
44 /* XXXKW different war_pass? */
45 war_pass
= K_SYS_REVISION_BCM1250_PASS2
;
47 case K_SYS_REVISION_BCM1250_PASS2_2
:
51 case K_SYS_REVISION_BCM1250_B2
:
54 war_pass
= K_SYS_REVISION_BCM1250_PASS2_2
;
56 case K_SYS_REVISION_BCM1250_PASS3
:
60 case K_SYS_REVISION_BCM1250_C1
:
65 if (soc_pass
< K_SYS_REVISION_BCM1250_PASS2_2
) {
68 war_pass
= K_SYS_REVISION_BCM1250_PASS2
;
70 printk("Unknown BCM1250 rev %x\n", soc_pass
);
79 int sb1250_m3_workaround_needed(void)
82 case K_SYS_SOC_TYPE_BCM1250
:
83 case K_SYS_SOC_TYPE_BCM1250_ALT
:
84 case K_SYS_SOC_TYPE_BCM1250_ALT2
:
85 case K_SYS_SOC_TYPE_BCM1125
:
86 case K_SYS_SOC_TYPE_BCM1125H
:
87 return soc_pass
< K_SYS_REVISION_BCM1250_C0
;
94 static int __init
setup_bcm112x(void)
100 /* Early build didn't have revid set */
103 war_pass
= K_SYS_REVISION_BCM112x_A1
;
105 case K_SYS_REVISION_BCM112x_A1
:
109 case K_SYS_REVISION_BCM112x_A2
:
113 case K_SYS_REVISION_BCM112x_A3
:
117 case K_SYS_REVISION_BCM112x_A4
:
121 case K_SYS_REVISION_BCM112x_B0
:
126 printk("Unknown %s rev %x\n", soc_str
, soc_pass
);
133 /* Setup code likely to be common to all SiByte platforms */
135 static int __init
sys_rev_decode(void)
141 case K_SYS_SOC_TYPE_BCM1250
:
142 case K_SYS_SOC_TYPE_BCM1250_ALT
:
143 case K_SYS_SOC_TYPE_BCM1250_ALT2
:
145 ret
= setup_bcm1250();
147 case K_SYS_SOC_TYPE_BCM1120
:
149 ret
= setup_bcm112x();
151 case K_SYS_SOC_TYPE_BCM1125
:
153 ret
= setup_bcm112x();
155 case K_SYS_SOC_TYPE_BCM1125H
:
156 soc_str
= "BCM1125H";
157 ret
= setup_bcm112x();
160 printk("Unknown SOC type %x\n", soc_type
);
168 void __init
sb1250_setup(void)
174 sb1_pass
= read_c0_prid() & PRID_REV_MASK
;
175 sys_rev
= __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION
));
176 soc_type
= SYS_SOC_TYPE(sys_rev
);
177 soc_pass
= G_SYS_REVISION(sys_rev
);
179 if (sys_rev_decode()) {
180 printk("Restart after failure to identify SiByte chip\n");
181 machine_restart(NULL
);
184 plldiv
= G_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG
)));
185 zbbus_mhz
= ((plldiv
>> 1) * 50) + ((plldiv
& 1) * 25);
187 printk("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n",
188 soc_str
, pass_str
, zbbus_mhz
* 2, sb1_pass
);
189 printk("Board type: %s\n", get_system_type());
192 case K_SYS_REVISION_BCM1250_PASS1
:
193 printk("@@@@ This is a BCM1250 A0-A2 (Pass 1) board, "
194 "and the kernel doesn't have the proper "
195 "workarounds compiled in. @@@@\n");
198 case K_SYS_REVISION_BCM1250_PASS2
:
199 /* Pass 2 - easiest as default for now - so many numbers */
200 #if !defined(CONFIG_SB1_PASS_2_WORKAROUNDS) || \
201 !defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS)
202 printk("@@@@ This is a BCM1250 A3-A10 board, and the "
203 "kernel doesn't have the proper workarounds "
204 "compiled in. @@@@\n");
207 #ifdef CONFIG_CPU_HAS_PREFETCH
208 printk("@@@@ Prefetches may be enabled in this kernel, "
209 "but are buggy on this board. @@@@\n");
213 case K_SYS_REVISION_BCM1250_PASS2_2
:
214 #ifndef CONFIG_SB1_PASS_2_WORKAROUNDS
215 printk("@@@@ This is a BCM1250 B1/B2. board, and the "
216 "kernel doesn't have the proper workarounds "
217 "compiled in. @@@@\n");
220 #if defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) || \
221 !defined(CONFIG_CPU_HAS_PREFETCH)
222 printk("@@@@ This is a BCM1250 B1/B2, but the kernel is "
223 "conservatively configured for an 'A' stepping. "
231 printk("Invalid configuration for this chip.\n");
232 machine_restart(NULL
);