x86/unwinder: Handle stack overflows more gracefully
[linux/fpc-iii.git] / arch / mips / sibyte / sb1250 / setup.c
blobaa7713adfa58fa79d5f2dcb00f420d2e02b43fc8
1 /*
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/export.h>
19 #include <linux/init.h>
20 #include <linux/kernel.h>
21 #include <linux/reboot.h>
22 #include <linux/string.h>
24 #include <asm/bootinfo.h>
25 #include <asm/cpu.h>
26 #include <asm/mipsregs.h>
27 #include <asm/io.h>
28 #include <asm/sibyte/sb1250.h>
29 #include <asm/sibyte/sb1250_regs.h>
30 #include <asm/sibyte/sb1250_scd.h>
32 unsigned int sb1_pass;
33 unsigned int soc_pass;
34 unsigned int soc_type;
35 EXPORT_SYMBOL(soc_type);
36 unsigned int periph_rev;
37 EXPORT_SYMBOL_GPL(periph_rev);
38 unsigned int zbbus_mhz;
39 EXPORT_SYMBOL(zbbus_mhz);
41 static char *soc_str;
42 static char *pass_str;
43 static unsigned int war_pass; /* XXXKW don't overload PASS defines? */
45 static int __init setup_bcm1250(void)
47 int ret = 0;
49 switch (soc_pass) {
50 case K_SYS_REVISION_BCM1250_PASS1:
51 periph_rev = 1;
52 pass_str = "Pass 1";
53 break;
54 case K_SYS_REVISION_BCM1250_A10:
55 periph_rev = 2;
56 pass_str = "A8/A10";
57 /* XXXKW different war_pass? */
58 war_pass = K_SYS_REVISION_BCM1250_PASS2;
59 break;
60 case K_SYS_REVISION_BCM1250_PASS2_2:
61 periph_rev = 2;
62 pass_str = "B1";
63 break;
64 case K_SYS_REVISION_BCM1250_B2:
65 periph_rev = 2;
66 pass_str = "B2";
67 war_pass = K_SYS_REVISION_BCM1250_PASS2_2;
68 break;
69 case K_SYS_REVISION_BCM1250_PASS3:
70 periph_rev = 3;
71 pass_str = "C0";
72 break;
73 case K_SYS_REVISION_BCM1250_C1:
74 periph_rev = 3;
75 pass_str = "C1";
76 break;
77 default:
78 if (soc_pass < K_SYS_REVISION_BCM1250_PASS2_2) {
79 periph_rev = 2;
80 pass_str = "A0-A6";
81 war_pass = K_SYS_REVISION_BCM1250_PASS2;
82 } else {
83 printk("Unknown BCM1250 rev %x\n", soc_pass);
84 ret = 1;
86 break;
89 return ret;
92 int sb1250_m3_workaround_needed(void)
94 switch (soc_type) {
95 case K_SYS_SOC_TYPE_BCM1250:
96 case K_SYS_SOC_TYPE_BCM1250_ALT:
97 case K_SYS_SOC_TYPE_BCM1250_ALT2:
98 case K_SYS_SOC_TYPE_BCM1125:
99 case K_SYS_SOC_TYPE_BCM1125H:
100 return soc_pass < K_SYS_REVISION_BCM1250_C0;
102 default:
103 return 0;
107 static int __init setup_bcm112x(void)
109 int ret = 0;
111 switch (soc_pass) {
112 case 0:
113 /* Early build didn't have revid set */
114 periph_rev = 3;
115 pass_str = "A1";
116 war_pass = K_SYS_REVISION_BCM112x_A1;
117 break;
118 case K_SYS_REVISION_BCM112x_A1:
119 periph_rev = 3;
120 pass_str = "A1";
121 break;
122 case K_SYS_REVISION_BCM112x_A2:
123 periph_rev = 3;
124 pass_str = "A2";
125 break;
126 case K_SYS_REVISION_BCM112x_A3:
127 periph_rev = 3;
128 pass_str = "A3";
129 break;
130 case K_SYS_REVISION_BCM112x_A4:
131 periph_rev = 3;
132 pass_str = "A4";
133 break;
134 case K_SYS_REVISION_BCM112x_B0:
135 periph_rev = 3;
136 pass_str = "B0";
137 break;
138 default:
139 printk("Unknown %s rev %x\n", soc_str, soc_pass);
140 ret = 1;
143 return ret;
146 /* Setup code likely to be common to all SiByte platforms */
148 static int __init sys_rev_decode(void)
150 int ret = 0;
152 war_pass = soc_pass;
153 switch (soc_type) {
154 case K_SYS_SOC_TYPE_BCM1250:
155 case K_SYS_SOC_TYPE_BCM1250_ALT:
156 case K_SYS_SOC_TYPE_BCM1250_ALT2:
157 soc_str = "BCM1250";
158 ret = setup_bcm1250();
159 break;
160 case K_SYS_SOC_TYPE_BCM1120:
161 soc_str = "BCM1120";
162 ret = setup_bcm112x();
163 break;
164 case K_SYS_SOC_TYPE_BCM1125:
165 soc_str = "BCM1125";
166 ret = setup_bcm112x();
167 break;
168 case K_SYS_SOC_TYPE_BCM1125H:
169 soc_str = "BCM1125H";
170 ret = setup_bcm112x();
171 break;
172 default:
173 printk("Unknown SOC type %x\n", soc_type);
174 ret = 1;
175 break;
178 return ret;
181 void __init sb1250_setup(void)
183 uint64_t sys_rev;
184 int plldiv;
185 int bad_config = 0;
187 sb1_pass = read_c0_prid() & PRID_REV_MASK;
188 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
189 soc_type = SYS_SOC_TYPE(sys_rev);
190 soc_pass = G_SYS_REVISION(sys_rev);
192 if (sys_rev_decode()) {
193 printk("Restart after failure to identify SiByte chip\n");
194 machine_restart(NULL);
197 plldiv = G_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
198 zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
200 printk("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n",
201 soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
202 printk("Board type: %s\n", get_system_type());
204 switch (war_pass) {
205 case K_SYS_REVISION_BCM1250_PASS1:
206 printk("@@@@ This is a BCM1250 A0-A2 (Pass 1) board, "
207 "and the kernel doesn't have the proper "
208 "workarounds compiled in. @@@@\n");
209 bad_config = 1;
210 break;
211 case K_SYS_REVISION_BCM1250_PASS2:
212 /* Pass 2 - easiest as default for now - so many numbers */
213 #if !defined(CONFIG_SB1_PASS_2_WORKAROUNDS) || \
214 !defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS)
215 printk("@@@@ This is a BCM1250 A3-A10 board, and the "
216 "kernel doesn't have the proper workarounds "
217 "compiled in. @@@@\n");
218 bad_config = 1;
219 #endif
220 #ifdef CONFIG_CPU_HAS_PREFETCH
221 printk("@@@@ Prefetches may be enabled in this kernel, "
222 "but are buggy on this board. @@@@\n");
223 bad_config = 1;
224 #endif
225 break;
226 case K_SYS_REVISION_BCM1250_PASS2_2:
227 #ifndef CONFIG_SB1_PASS_2_WORKAROUNDS
228 printk("@@@@ This is a BCM1250 B1/B2. board, and the "
229 "kernel doesn't have the proper workarounds "
230 "compiled in. @@@@\n");
231 bad_config = 1;
232 #endif
233 #if defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) || \
234 !defined(CONFIG_CPU_HAS_PREFETCH)
235 printk("@@@@ This is a BCM1250 B1/B2, but the kernel is "
236 "conservatively configured for an 'A' stepping. "
237 "@@@@\n");
238 #endif
239 break;
240 default:
241 break;
243 if (bad_config) {
244 printk("Invalid configuration for this chip.\n");
245 machine_restart(NULL);