blob: 92da3155ce074ac16840c715fde220946a13b4fd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
3 *
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.
8 *
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.
13 *
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.
17 */
Ralf Baechle5ac71fd2006-01-29 20:56:43 +000018#include <linux/init.h>
Ralf Baechlebb9b8132007-03-09 15:59:56 +000019#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/kernel.h>
21#include <linux/reboot.h>
22#include <linux/string.h>
23
24#include <asm/bootinfo.h>
25#include <asm/mipsregs.h>
26#include <asm/io.h>
27#include <asm/sibyte/sb1250.h>
28#include <asm/sibyte/sb1250_regs.h>
29#include <asm/sibyte/sb1250_scd.h>
30
31unsigned int sb1_pass;
32unsigned int soc_pass;
33unsigned int soc_type;
Maciej W. Rozyckib45d5272007-07-17 04:03:50 -070034EXPORT_SYMBOL(soc_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035unsigned int periph_rev;
36unsigned int zbbus_mhz;
Ralf Baechlebb9b8132007-03-09 15:59:56 +000037EXPORT_SYMBOL(zbbus_mhz);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39static char *soc_str;
40static char *pass_str;
41static unsigned int war_pass; /* XXXKW don't overload PASS defines? */
42
Ralf Baechle5ac71fd2006-01-29 20:56:43 +000043static int __init setup_bcm1250(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
45 int ret = 0;
46
47 switch (soc_pass) {
48 case K_SYS_REVISION_BCM1250_PASS1:
49 periph_rev = 1;
50 pass_str = "Pass 1";
51 break;
52 case K_SYS_REVISION_BCM1250_A10:
53 periph_rev = 2;
54 pass_str = "A8/A10";
55 /* XXXKW different war_pass? */
56 war_pass = K_SYS_REVISION_BCM1250_PASS2;
57 break;
58 case K_SYS_REVISION_BCM1250_PASS2_2:
59 periph_rev = 2;
60 pass_str = "B1";
61 break;
62 case K_SYS_REVISION_BCM1250_B2:
63 periph_rev = 2;
64 pass_str = "B2";
65 war_pass = K_SYS_REVISION_BCM1250_PASS2_2;
66 break;
67 case K_SYS_REVISION_BCM1250_PASS3:
68 periph_rev = 3;
69 pass_str = "C0";
70 break;
71 case K_SYS_REVISION_BCM1250_C1:
72 periph_rev = 3;
73 pass_str = "C1";
74 break;
75 default:
76 if (soc_pass < K_SYS_REVISION_BCM1250_PASS2_2) {
77 periph_rev = 2;
78 pass_str = "A0-A6";
79 war_pass = K_SYS_REVISION_BCM1250_PASS2;
80 } else {
Ralf Baechle36a88532007-03-01 11:56:43 +000081 printk("Unknown BCM1250 rev %x\n", soc_pass);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 ret = 1;
83 }
84 break;
85 }
Ralf Baechle7c4b4772007-10-11 23:46:05 +010086
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 return ret;
88}
89
Ralf Baechle8d9df292010-03-23 00:02:43 +010090int sb1250_m3_workaround_needed(void)
91{
92 switch (soc_type) {
93 case K_SYS_SOC_TYPE_BCM1250:
94 case K_SYS_SOC_TYPE_BCM1250_ALT:
95 case K_SYS_SOC_TYPE_BCM1250_ALT2:
96 case K_SYS_SOC_TYPE_BCM1125:
97 case K_SYS_SOC_TYPE_BCM1125H:
98 return soc_pass < K_SYS_REVISION_BCM1250_C0;
99
100 default:
101 return 0;
102 }
103}
104
Ralf Baechle5ac71fd2006-01-29 20:56:43 +0000105static int __init setup_bcm112x(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106{
107 int ret = 0;
108
109 switch (soc_pass) {
110 case 0:
111 /* Early build didn't have revid set */
112 periph_rev = 3;
113 pass_str = "A1";
114 war_pass = K_SYS_REVISION_BCM112x_A1;
115 break;
116 case K_SYS_REVISION_BCM112x_A1:
117 periph_rev = 3;
118 pass_str = "A1";
119 break;
120 case K_SYS_REVISION_BCM112x_A2:
121 periph_rev = 3;
122 pass_str = "A2";
123 break;
Mark Mason9a994352007-04-13 10:32:25 -0700124 case K_SYS_REVISION_BCM112x_A3:
125 periph_rev = 3;
126 pass_str = "A3";
127 break;
128 case K_SYS_REVISION_BCM112x_A4:
129 periph_rev = 3;
130 pass_str = "A4";
131 break;
132 case K_SYS_REVISION_BCM112x_B0:
133 periph_rev = 3;
134 pass_str = "B0";
135 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 default:
Ralf Baechle36a88532007-03-01 11:56:43 +0000137 printk("Unknown %s rev %x\n", soc_str, soc_pass);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 ret = 1;
139 }
Ralf Baechle7c4b4772007-10-11 23:46:05 +0100140
141 return ret;
142}
143
144/* Setup code likely to be common to all SiByte platforms */
145
146static int __init sys_rev_decode(void)
147{
148 int ret = 0;
149
150 war_pass = soc_pass;
151 switch (soc_type) {
152 case K_SYS_SOC_TYPE_BCM1250:
153 case K_SYS_SOC_TYPE_BCM1250_ALT:
154 case K_SYS_SOC_TYPE_BCM1250_ALT2:
155 soc_str = "BCM1250";
156 ret = setup_bcm1250();
157 break;
158 case K_SYS_SOC_TYPE_BCM1120:
159 soc_str = "BCM1120";
160 ret = setup_bcm112x();
161 break;
162 case K_SYS_SOC_TYPE_BCM1125:
163 soc_str = "BCM1125";
164 ret = setup_bcm112x();
165 break;
166 case K_SYS_SOC_TYPE_BCM1125H:
167 soc_str = "BCM1125H";
168 ret = setup_bcm112x();
169 break;
170 default:
171 printk("Unknown SOC type %x\n", soc_type);
172 ret = 1;
173 break;
174 }
175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 return ret;
177}
178
Ralf Baechle5ac71fd2006-01-29 20:56:43 +0000179void __init sb1250_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180{
181 uint64_t sys_rev;
182 int plldiv;
183 int bad_config = 0;
184
185 sb1_pass = read_c0_prid() & 0xff;
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +0000186 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 soc_type = SYS_SOC_TYPE(sys_rev);
188 soc_pass = G_SYS_REVISION(sys_rev);
189
190 if (sys_rev_decode()) {
Ralf Baechle36a88532007-03-01 11:56:43 +0000191 printk("Restart after failure to identify SiByte chip\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 machine_restart(NULL);
193 }
194
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +0000195 plldiv = G_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
197
Ralf Baechle36a88532007-03-01 11:56:43 +0000198 printk("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
Ralf Baechle36a88532007-03-01 11:56:43 +0000200 printk("Board type: %s\n", get_system_type());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Ralf Baechleb6f78802006-01-29 21:01:42 +0000202 switch (war_pass) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 case K_SYS_REVISION_BCM1250_PASS1:
204#ifndef CONFIG_SB1_PASS_1_WORKAROUNDS
Ralf Baechle36a88532007-03-01 11:56:43 +0000205 printk("@@@@ This is a BCM1250 A0-A2 (Pass 1) board, "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000206 "and the kernel doesn't have the proper "
207 "workarounds compiled in. @@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 bad_config = 1;
209#endif
210 break;
211 case K_SYS_REVISION_BCM1250_PASS2:
212 /* Pass 2 - easiest as default for now - so many numbers */
Ralf Baechleb6f78802006-01-29 21:01:42 +0000213#if !defined(CONFIG_SB1_PASS_2_WORKAROUNDS) || \
214 !defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS)
Ralf Baechle36a88532007-03-01 11:56:43 +0000215 printk("@@@@ This is a BCM1250 A3-A10 board, and the "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000216 "kernel doesn't have the proper workarounds "
217 "compiled in. @@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 bad_config = 1;
219#endif
220#ifdef CONFIG_CPU_HAS_PREFETCH
Ralf Baechle36a88532007-03-01 11:56:43 +0000221 printk("@@@@ Prefetches may be enabled in this kernel, "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000222 "but are buggy on this board. @@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 bad_config = 1;
224#endif
225 break;
226 case K_SYS_REVISION_BCM1250_PASS2_2:
227#ifndef CONFIG_SB1_PASS_2_WORKAROUNDS
Ralf Baechle36a88532007-03-01 11:56:43 +0000228 printk("@@@@ This is a BCM1250 B1/B2. board, and the "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000229 "kernel doesn't have the proper workarounds "
230 "compiled in. @@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 bad_config = 1;
232#endif
Ralf Baechleb6f78802006-01-29 21:01:42 +0000233#if defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) || \
234 !defined(CONFIG_CPU_HAS_PREFETCH)
Ralf Baechle36a88532007-03-01 11:56:43 +0000235 printk("@@@@ This is a BCM1250 B1/B2, but the kernel is "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000236 "conservatively configured for an 'A' stepping. "
237 "@@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238#endif
239 break;
240 default:
241 break;
242 }
243 if (bad_config) {
Ralf Baechle36a88532007-03-01 11:56:43 +0000244 printk("Invalid configuration for this chip.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 machine_restart(NULL);
246 }
247}