blob: 2d5c6d8b41f23be8caf9b5e70b49b4f5e40e2377 [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
43static inline int setup_bcm1250(void);
44static inline int setup_bcm112x(void);
45
46/* Setup code likely to be common to all SiByte platforms */
47
Ralf Baechle5ac71fd2006-01-29 20:56:43 +000048static int __init sys_rev_decode(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049{
50 int ret = 0;
51
52 war_pass = soc_pass;
53 switch (soc_type) {
54 case K_SYS_SOC_TYPE_BCM1250:
55 case K_SYS_SOC_TYPE_BCM1250_ALT:
56 case K_SYS_SOC_TYPE_BCM1250_ALT2:
57 soc_str = "BCM1250";
58 ret = setup_bcm1250();
59 break;
60 case K_SYS_SOC_TYPE_BCM1120:
61 soc_str = "BCM1120";
62 ret = setup_bcm112x();
63 break;
64 case K_SYS_SOC_TYPE_BCM1125:
65 soc_str = "BCM1125";
66 ret = setup_bcm112x();
67 break;
68 case K_SYS_SOC_TYPE_BCM1125H:
69 soc_str = "BCM1125H";
70 ret = setup_bcm112x();
71 break;
72 default:
Ralf Baechle36a88532007-03-01 11:56:43 +000073 printk("Unknown SOC type %x\n", soc_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 ret = 1;
75 break;
76 }
77 return ret;
78}
79
Ralf Baechle5ac71fd2006-01-29 20:56:43 +000080static int __init setup_bcm1250(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081{
82 int ret = 0;
83
84 switch (soc_pass) {
85 case K_SYS_REVISION_BCM1250_PASS1:
86 periph_rev = 1;
87 pass_str = "Pass 1";
88 break;
89 case K_SYS_REVISION_BCM1250_A10:
90 periph_rev = 2;
91 pass_str = "A8/A10";
92 /* XXXKW different war_pass? */
93 war_pass = K_SYS_REVISION_BCM1250_PASS2;
94 break;
95 case K_SYS_REVISION_BCM1250_PASS2_2:
96 periph_rev = 2;
97 pass_str = "B1";
98 break;
99 case K_SYS_REVISION_BCM1250_B2:
100 periph_rev = 2;
101 pass_str = "B2";
102 war_pass = K_SYS_REVISION_BCM1250_PASS2_2;
103 break;
104 case K_SYS_REVISION_BCM1250_PASS3:
105 periph_rev = 3;
106 pass_str = "C0";
107 break;
108 case K_SYS_REVISION_BCM1250_C1:
109 periph_rev = 3;
110 pass_str = "C1";
111 break;
112 default:
113 if (soc_pass < K_SYS_REVISION_BCM1250_PASS2_2) {
114 periph_rev = 2;
115 pass_str = "A0-A6";
116 war_pass = K_SYS_REVISION_BCM1250_PASS2;
117 } else {
Ralf Baechle36a88532007-03-01 11:56:43 +0000118 printk("Unknown BCM1250 rev %x\n", soc_pass);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 ret = 1;
120 }
121 break;
122 }
123 return ret;
124}
125
Ralf Baechle5ac71fd2006-01-29 20:56:43 +0000126static int __init setup_bcm112x(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127{
128 int ret = 0;
129
130 switch (soc_pass) {
131 case 0:
132 /* Early build didn't have revid set */
133 periph_rev = 3;
134 pass_str = "A1";
135 war_pass = K_SYS_REVISION_BCM112x_A1;
136 break;
137 case K_SYS_REVISION_BCM112x_A1:
138 periph_rev = 3;
139 pass_str = "A1";
140 break;
141 case K_SYS_REVISION_BCM112x_A2:
142 periph_rev = 3;
143 pass_str = "A2";
144 break;
Mark Mason9a994352007-04-13 10:32:25 -0700145 case K_SYS_REVISION_BCM112x_A3:
146 periph_rev = 3;
147 pass_str = "A3";
148 break;
149 case K_SYS_REVISION_BCM112x_A4:
150 periph_rev = 3;
151 pass_str = "A4";
152 break;
153 case K_SYS_REVISION_BCM112x_B0:
154 periph_rev = 3;
155 pass_str = "B0";
156 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 default:
Ralf Baechle36a88532007-03-01 11:56:43 +0000158 printk("Unknown %s rev %x\n", soc_str, soc_pass);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 ret = 1;
160 }
161 return ret;
162}
163
Ralf Baechle5ac71fd2006-01-29 20:56:43 +0000164void __init sb1250_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165{
166 uint64_t sys_rev;
167 int plldiv;
168 int bad_config = 0;
169
170 sb1_pass = read_c0_prid() & 0xff;
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +0000171 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 soc_type = SYS_SOC_TYPE(sys_rev);
173 soc_pass = G_SYS_REVISION(sys_rev);
174
175 if (sys_rev_decode()) {
Ralf Baechle36a88532007-03-01 11:56:43 +0000176 printk("Restart after failure to identify SiByte chip\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 machine_restart(NULL);
178 }
179
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +0000180 plldiv = G_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
182
Ralf Baechle36a88532007-03-01 11:56:43 +0000183 printk("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
Ralf Baechle36a88532007-03-01 11:56:43 +0000185 printk("Board type: %s\n", get_system_type());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
Ralf Baechleb6f78802006-01-29 21:01:42 +0000187 switch (war_pass) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 case K_SYS_REVISION_BCM1250_PASS1:
189#ifndef CONFIG_SB1_PASS_1_WORKAROUNDS
Ralf Baechle36a88532007-03-01 11:56:43 +0000190 printk("@@@@ This is a BCM1250 A0-A2 (Pass 1) board, "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000191 "and the kernel doesn't have the proper "
192 "workarounds compiled in. @@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 bad_config = 1;
194#endif
195 break;
196 case K_SYS_REVISION_BCM1250_PASS2:
197 /* Pass 2 - easiest as default for now - so many numbers */
Ralf Baechleb6f78802006-01-29 21:01:42 +0000198#if !defined(CONFIG_SB1_PASS_2_WORKAROUNDS) || \
199 !defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS)
Ralf Baechle36a88532007-03-01 11:56:43 +0000200 printk("@@@@ This is a BCM1250 A3-A10 board, and the "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000201 "kernel doesn't have the proper workarounds "
202 "compiled in. @@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 bad_config = 1;
204#endif
205#ifdef CONFIG_CPU_HAS_PREFETCH
Ralf Baechle36a88532007-03-01 11:56:43 +0000206 printk("@@@@ Prefetches may be enabled in this kernel, "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000207 "but are buggy on this board. @@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 bad_config = 1;
209#endif
210 break;
211 case K_SYS_REVISION_BCM1250_PASS2_2:
212#ifndef CONFIG_SB1_PASS_2_WORKAROUNDS
Ralf Baechle36a88532007-03-01 11:56:43 +0000213 printk("@@@@ This is a BCM1250 B1/B2. board, and the "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000214 "kernel doesn't have the proper workarounds "
215 "compiled in. @@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 bad_config = 1;
217#endif
Ralf Baechleb6f78802006-01-29 21:01:42 +0000218#if defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) || \
219 !defined(CONFIG_CPU_HAS_PREFETCH)
Ralf Baechle36a88532007-03-01 11:56:43 +0000220 printk("@@@@ This is a BCM1250 B1/B2, but the kernel is "
Ralf Baechleb6f78802006-01-29 21:01:42 +0000221 "conservatively configured for an 'A' stepping. "
222 "@@@@\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223#endif
224 break;
225 default:
226 break;
227 }
228 if (bad_config) {
Ralf Baechle36a88532007-03-01 11:56:43 +0000229 printk("Invalid configuration for this chip.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 machine_restart(NULL);
231 }
232}