blob: aab65d405c59950557ef8b2b2b6405f2c67e8e49 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
Stefan Roesedbbd1252007-10-05 17:10:59 +02002 * (C) Copyright 2000-2007
wdenkc6097192002-11-03 00:24:07 +00003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00006 */
7
8/*
wdenkc6097192002-11-03 00:24:07 +00009 * CPU specific code
10 *
11 * written or collected and sometimes rewritten by
12 * Magnus Damm <damm@bitsmart.com>
13 *
14 * minor modifications by
15 * Wolfgang Denk <wd@denx.de>
16 */
17
18#include <common.h>
19#include <watchdog.h>
20#include <command.h>
21#include <asm/cache.h>
Stefan Roeseb36df562010-09-09 19:18:00 +020022#include <asm/ppc4xx.h>
Ben Warren25a85902008-10-27 23:53:17 -070023#include <netdev.h>
wdenkc6097192002-11-03 00:24:07 +000024
Wolfgang Denkd87080b2006-03-31 18:32:53 +020025DECLARE_GLOBAL_DATA_PTR;
Wolfgang Denkd87080b2006-03-31 18:32:53 +020026
Stefan Roesef3443862006-10-07 11:30:52 +020027void board_reset(void);
Stefan Roesef3443862006-10-07 11:30:52 +020028
Adam Grahamc9c11d72008-10-08 10:13:19 -070029/*
30 * To provide an interface to detect CPU number for boards that support
31 * more then one CPU, we implement the "weak" default functions here.
32 *
33 * Returns CPU number
34 */
35int __get_cpu_num(void)
36{
37 return NA_OR_UNKNOWN_CPU;
38}
39int get_cpu_num(void) __attribute__((weak, alias("__get_cpu_num")));
40
Stefan Roese20b3c4b2009-07-06 11:44:33 +020041#if defined(CONFIG_PCI)
Stefan Roese887e2ec2006-09-07 11:51:23 +020042#if defined(CONFIG_405GP) || \
43 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
44 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010045
46#define PCI_ASYNC
47
Stefan Roesec7f69c32007-11-09 12:18:54 +010048static int pci_async_enabled(void)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010049{
50#if defined(CONFIG_405GP)
Stefan Roesed1c3b272009-09-09 16:25:29 +020051 return (mfdcr(CPC0_PSR) & PSR_PCI_ASYNC_EN);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010052#endif
53
Stefan Roese887e2ec2006-09-07 11:51:23 +020054#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
Stefan Roese2801b2d2008-03-11 15:05:50 +010055 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
56 defined(CONFIG_460EX) || defined(CONFIG_460GT)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010057 unsigned long val;
58
Stefan Roesed1c3b272009-09-09 16:25:29 +020059 mfsdr(SDR0_SDSTP1, val);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010060 return (val & SDR0_SDSTP1_PAME_MASK);
61#endif
62}
63#endif
Stefan Roese20b3c4b2009-07-06 11:44:33 +020064#endif /* CONFIG_PCI */
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010065
Stefan Roese99bcad12012-09-19 14:33:52 +020066#if defined(CONFIG_PCI) && \
Stefan Roesedbbd1252007-10-05 17:10:59 +020067 !defined(CONFIG_405) && !defined(CONFIG_405EX)
Stefan Roesea760b022009-11-12 16:41:09 +010068int pci_arbiter_enabled(void)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010069{
70#if defined(CONFIG_405GP)
Stefan Roesed1c3b272009-09-09 16:25:29 +020071 return (mfdcr(CPC0_PSR) & PSR_PCI_ARBIT_EN);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010072#endif
73
74#if defined(CONFIG_405EP)
Stefan Roesed1c3b272009-09-09 16:25:29 +020075 return (mfdcr(CPC0_PCI) & CPC0_PCI_ARBIT_EN);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010076#endif
77
78#if defined(CONFIG_440GP)
Stefan Roesed1c3b272009-09-09 16:25:29 +020079 return (mfdcr(CPC0_STRP1) & CPC0_STRP1_PAE_MASK);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010080#endif
81
Stefan Roese7372ca62007-02-02 12:44:22 +010082#if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010083 unsigned long val;
84
Stefan Roese5e7abce2010-09-11 09:31:43 +020085 mfsdr(SDR0_XCR0, val);
86 return (val & SDR0_XCR0_PAE_MASK);
Stefan Roese7372ca62007-02-02 12:44:22 +010087#endif
88#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
Stefan Roese2801b2d2008-03-11 15:05:50 +010089 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
90 defined(CONFIG_460EX) || defined(CONFIG_460GT)
Stefan Roese7372ca62007-02-02 12:44:22 +010091 unsigned long val;
92
Stefan Roesed1c3b272009-09-09 16:25:29 +020093 mfsdr(SDR0_PCI0, val);
Stefan Roese5e7abce2010-09-11 09:31:43 +020094 return (val & SDR0_PCI0_PAE_MASK);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +010095#endif
96}
97#endif
98
Stefan Roesec7f69c32007-11-09 12:18:54 +010099#if defined(CONFIG_405EP)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100100#define I2C_BOOTROM
101
Stefan Roesec7f69c32007-11-09 12:18:54 +0100102static int i2c_bootrom_enabled(void)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100103{
104#if defined(CONFIG_405EP)
Stefan Roesed1c3b272009-09-09 16:25:29 +0200105 return (mfdcr(CPC0_BOOT) & CPC0_BOOT_SEP);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200106#else
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100107 unsigned long val;
108
Stefan Roesed1c3b272009-09-09 16:25:29 +0200109 mfsdr(SDR0_SDCS0, val);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100110 return (val & SDR0_SDCS_SDD);
111#endif
112}
Stefan Roese90e6f412007-04-18 12:05:59 +0200113#endif
Stefan Roese887e2ec2006-09-07 11:51:23 +0200114
115#if defined(CONFIG_440GX)
116#define SDR0_PINSTP_SHIFT 29
117static char *bootstrap_str[] = {
118 "EBC (16 bits)",
119 "EBC (8 bits)",
120 "EBC (32 bits)",
121 "EBC (8 bits)",
122 "PCI",
123 "I2C (Addr 0x54)",
124 "Reserved",
125 "I2C (Addr 0x50)",
126};
BenoƮt Monine3cbe1f2007-06-04 08:36:05 +0200127static char bootstrap_char[] = { 'A', 'B', 'C', 'B', 'D', 'E', 'x', 'F' };
Stefan Roese887e2ec2006-09-07 11:51:23 +0200128#endif
129
130#if defined(CONFIG_440SP) || defined(CONFIG_440SPE)
131#define SDR0_PINSTP_SHIFT 30
132static char *bootstrap_str[] = {
133 "EBC (8 bits)",
134 "PCI",
135 "I2C (Addr 0x54)",
136 "I2C (Addr 0x50)",
137};
BenoƮt Monine3cbe1f2007-06-04 08:36:05 +0200138static char bootstrap_char[] = { 'A', 'B', 'C', 'D'};
Stefan Roese887e2ec2006-09-07 11:51:23 +0200139#endif
140
141#if defined(CONFIG_440EP) || defined(CONFIG_440GR)
142#define SDR0_PINSTP_SHIFT 29
143static char *bootstrap_str[] = {
144 "EBC (8 bits)",
145 "PCI",
146 "NAND (8 bits)",
147 "EBC (16 bits)",
148 "EBC (16 bits)",
149 "I2C (Addr 0x54)",
150 "PCI",
151 "I2C (Addr 0x52)",
152};
BenoƮt Monine3cbe1f2007-06-04 08:36:05 +0200153static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
Stefan Roese887e2ec2006-09-07 11:51:23 +0200154#endif
155
156#if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
157#define SDR0_PINSTP_SHIFT 29
158static char *bootstrap_str[] = {
159 "EBC (8 bits)",
160 "EBC (16 bits)",
161 "EBC (16 bits)",
162 "NAND (8 bits)",
163 "PCI",
164 "I2C (Addr 0x54)",
165 "PCI",
166 "I2C (Addr 0x52)",
167};
BenoƮt Monine3cbe1f2007-06-04 08:36:05 +0200168static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
Stefan Roese887e2ec2006-09-07 11:51:23 +0200169#endif
170
Stefan Roese2801b2d2008-03-11 15:05:50 +0100171#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
172#define SDR0_PINSTP_SHIFT 29
173static char *bootstrap_str[] = {
174 "EBC (8 bits)",
175 "EBC (16 bits)",
176 "PCI",
177 "PCI",
178 "EBC (16 bits)",
179 "NAND (8 bits)",
180 "I2C (Addr 0x54)", /* A8 */
181 "I2C (Addr 0x52)", /* A4 */
182};
Felix Radenskyd98964a2010-01-19 17:37:13 +0200183static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
Stefan Roese2801b2d2008-03-11 15:05:50 +0100184#endif
185
Feng Kan7d307932008-07-08 22:47:31 -0700186#if defined(CONFIG_460SX)
187#define SDR0_PINSTP_SHIFT 29
188static char *bootstrap_str[] = {
189 "EBC (8 bits)",
190 "EBC (16 bits)",
191 "EBC (32 bits)",
192 "NAND (8 bits)",
193 "I2C (Addr 0x54)", /* A8 */
194 "I2C (Addr 0x52)", /* A4 */
195};
196static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G' };
197#endif
198
Stefan Roese90e6f412007-04-18 12:05:59 +0200199#if defined(CONFIG_405EZ)
200#define SDR0_PINSTP_SHIFT 28
201static char *bootstrap_str[] = {
202 "EBC (8 bits)",
203 "SPI (fast)",
204 "NAND (512 page, 4 addr cycle)",
205 "I2C (Addr 0x50)",
206 "EBC (32 bits)",
207 "I2C (Addr 0x50)",
208 "NAND (2K page, 5 addr cycle)",
209 "I2C (Addr 0x50)",
210 "EBC (16 bits)",
211 "Reserved",
212 "NAND (2K page, 4 addr cycle)",
213 "I2C (Addr 0x50)",
214 "NAND (512 page, 3 addr cycle)",
215 "I2C (Addr 0x50)",
216 "SPI (slow)",
217 "I2C (Addr 0x50)",
218};
BenoƮt Monine3cbe1f2007-06-04 08:36:05 +0200219static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', \
220 'I', 'x', 'K', 'L', 'M', 'N', 'O', 'P' };
Stefan Roese90e6f412007-04-18 12:05:59 +0200221#endif
222
Stefan Roesedbbd1252007-10-05 17:10:59 +0200223#if defined(CONFIG_405EX)
224#define SDR0_PINSTP_SHIFT 29
225static char *bootstrap_str[] = {
226 "EBC (8 bits)",
227 "EBC (16 bits)",
228 "EBC (16 bits)",
229 "NAND (8 bits)",
230 "NAND (8 bits)",
231 "I2C (Addr 0x54)",
232 "EBC (8 bits)",
233 "I2C (Addr 0x52)",
234};
235static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
236#endif
237
Stefan Roese887e2ec2006-09-07 11:51:23 +0200238#if defined(SDR0_PINSTP_SHIFT)
239static int bootstrap_option(void)
240{
241 unsigned long val;
242
Stefan Roesed1c3b272009-09-09 16:25:29 +0200243 mfsdr(SDR0_PINSTP, val);
Stefan Roese90e6f412007-04-18 12:05:59 +0200244 return ((val & 0xf0000000) >> SDR0_PINSTP_SHIFT);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200245}
246#endif /* SDR0_PINSTP_SHIFT */
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100247
Stefan Roese3d9569b2005-11-27 19:36:26 +0100248
Stefan Roese5e7abce2010-09-11 09:31:43 +0200249#if defined(CONFIG_440GP)
Stefan Roesec7f69c32007-11-09 12:18:54 +0100250static int do_chip_reset (unsigned long sys0, unsigned long sys1)
251{
Stefan Roesed1c3b272009-09-09 16:25:29 +0200252 /* Changes to CPC0_SYS0 and CPC0_SYS1 require chip
Stefan Roesec7f69c32007-11-09 12:18:54 +0100253 * reset.
254 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200255 mtdcr (CPC0_CR0, mfdcr (CPC0_CR0) | 0x80000000); /* Set SWE */
256 mtdcr (CPC0_SYS0, sys0);
257 mtdcr (CPC0_SYS1, sys1);
258 mtdcr (CPC0_CR0, mfdcr (CPC0_CR0) & ~0x80000000); /* Clr SWE */
Matthias Fuchs58ea1422009-07-22 17:27:56 +0200259 mtspr (SPRN_DBCR0, 0x20000000); /* Reset the chip */
Stefan Roesec7f69c32007-11-09 12:18:54 +0100260
261 return 1;
262}
Stefan Roese5e7abce2010-09-11 09:31:43 +0200263#endif /* CONFIG_440GP */
Stefan Roese3d9569b2005-11-27 19:36:26 +0100264
wdenkc6097192002-11-03 00:24:07 +0000265
266int checkcpu (void)
267{
Stefan Roese3d9569b2005-11-27 19:36:26 +0100268#if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */
Stefan Roese3d9569b2005-11-27 19:36:26 +0100269 uint pvr = get_pvr();
wdenkc6097192002-11-03 00:24:07 +0000270 ulong clock = gd->cpu_clk;
271 char buf[32];
Stefan Roese89bcc482009-07-29 08:45:27 +0200272#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
273 u32 reg;
274#endif
wdenkc6097192002-11-03 00:24:07 +0000275
Wolfgang Denkba999c52006-10-20 17:54:33 +0200276 char addstr[64] = "";
Stefan Roese3d9569b2005-11-27 19:36:26 +0100277 sys_info_t sys_info;
Adam Grahamc9c11d72008-10-08 10:13:19 -0700278 int cpu_num;
wdenkc6097192002-11-03 00:24:07 +0000279
Adam Grahamc9c11d72008-10-08 10:13:19 -0700280 cpu_num = get_cpu_num();
281 if (cpu_num >= 0)
282 printf("CPU%d: ", cpu_num);
283 else
284 puts("CPU: ");
wdenkc6097192002-11-03 00:24:07 +0000285
286 get_sys_info(&sys_info);
287
Ricardo Ribalda Delgadod865fd02008-07-17 11:44:12 +0200288#if defined(CONFIG_XILINX_440)
Stefan Roesee02d4492010-09-03 13:27:02 +0200289 puts("IBM PowerPC ");
Ricardo Ribalda Delgadod865fd02008-07-17 11:44:12 +0200290#else
Stefan Roesee02d4492010-09-03 13:27:02 +0200291 puts("AMCC PowerPC ");
Stefan Roese2801b2d2008-03-11 15:05:50 +0100292#endif
Stefan Roese3d9569b2005-11-27 19:36:26 +0100293
wdenkc6097192002-11-03 00:24:07 +0000294 switch (pvr) {
Stefan Roesee02d4492010-09-03 13:27:02 +0200295
296#if !defined(CONFIG_440)
wdenkc6097192002-11-03 00:24:07 +0000297 case PVR_405GP_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200298 puts("405GP Rev. B");
wdenkc6097192002-11-03 00:24:07 +0000299 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100300
wdenkc6097192002-11-03 00:24:07 +0000301 case PVR_405GP_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200302 puts("405GP Rev. C");
wdenkc6097192002-11-03 00:24:07 +0000303 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100304
wdenkc6097192002-11-03 00:24:07 +0000305 case PVR_405GP_RD:
Stefan Roesee02d4492010-09-03 13:27:02 +0200306 puts("405GP Rev. D");
wdenkc6097192002-11-03 00:24:07 +0000307 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100308
Matthias Fuchs3fb85882013-08-07 12:10:38 +0200309 case PVR_405GP_RE:
Stefan Roesee02d4492010-09-03 13:27:02 +0200310 puts("405GP Rev. E");
wdenkc6097192002-11-03 00:24:07 +0000311 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100312
313 case PVR_405GPR_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200314 puts("405GPr Rev. B");
Stefan Roese3d9569b2005-11-27 19:36:26 +0100315 break;
316
stroeseb867d702003-05-23 11:18:02 +0000317 case PVR_405EP_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200318 puts("405EP Rev. B");
wdenkc6097192002-11-03 00:24:07 +0000319 break;
wdenkc6097192002-11-03 00:24:07 +0000320
Stefan Roesee01bd212007-03-21 13:38:59 +0100321 case PVR_405EZ_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200322 puts("405EZ Rev. A");
Stefan Roesee01bd212007-03-21 13:38:59 +0100323 break;
324
Stefan Roesedbbd1252007-10-05 17:10:59 +0200325 case PVR_405EX1_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200326 puts("405EX Rev. A");
Stefan Roesedbbd1252007-10-05 17:10:59 +0200327 strcpy(addstr, "Security support");
328 break;
329
Stefan Roesedbbd1252007-10-05 17:10:59 +0200330 case PVR_405EXR2_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200331 puts("405EXr Rev. A");
Stefan Roesedbbd1252007-10-05 17:10:59 +0200332 strcpy(addstr, "No Security support");
333 break;
334
Stefan Roese70fab192008-05-13 20:22:01 +0200335 case PVR_405EX1_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200336 puts("405EX Rev. C");
Stefan Roese70fab192008-05-13 20:22:01 +0200337 strcpy(addstr, "Security support");
338 break;
339
340 case PVR_405EX2_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200341 puts("405EX Rev. C");
Stefan Roese70fab192008-05-13 20:22:01 +0200342 strcpy(addstr, "No Security support");
343 break;
344
345 case PVR_405EXR1_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200346 puts("405EXr Rev. C");
Stefan Roese70fab192008-05-13 20:22:01 +0200347 strcpy(addstr, "Security support");
348 break;
349
350 case PVR_405EXR2_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200351 puts("405EXr Rev. C");
Stefan Roese70fab192008-05-13 20:22:01 +0200352 strcpy(addstr, "No Security support");
353 break;
354
Stefan Roese56f14812009-10-06 07:21:08 +0200355 case PVR_405EX1_RD:
Stefan Roesee02d4492010-09-03 13:27:02 +0200356 puts("405EX Rev. D");
Stefan Roese56f14812009-10-06 07:21:08 +0200357 strcpy(addstr, "Security support");
358 break;
359
360 case PVR_405EX2_RD:
Stefan Roesee02d4492010-09-03 13:27:02 +0200361 puts("405EX Rev. D");
Stefan Roese56f14812009-10-06 07:21:08 +0200362 strcpy(addstr, "No Security support");
363 break;
364
365 case PVR_405EXR1_RD:
Stefan Roesee02d4492010-09-03 13:27:02 +0200366 puts("405EXr Rev. D");
Stefan Roese56f14812009-10-06 07:21:08 +0200367 strcpy(addstr, "Security support");
368 break;
369
370 case PVR_405EXR2_RD:
Stefan Roesee02d4492010-09-03 13:27:02 +0200371 puts("405EXr Rev. D");
Stefan Roese56f14812009-10-06 07:21:08 +0200372 strcpy(addstr, "No Security support");
373 break;
374
Stefan Roesee02d4492010-09-03 13:27:02 +0200375#else /* CONFIG_440 */
376
Stefan Roese5e7abce2010-09-11 09:31:43 +0200377#if defined(CONFIG_440GP)
wdenk8bde7f72003-06-27 21:31:46 +0000378 case PVR_440GP_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200379 puts("440GP Rev. B");
wdenk4d816772003-09-03 14:03:26 +0000380 /* See errata 1.12: CHIP_4 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200381 if ((mfdcr(CPC0_SYS0) != mfdcr(CPC0_STRP0)) ||
382 (mfdcr(CPC0_SYS1) != mfdcr(CPC0_STRP1)) ){
wdenk4d816772003-09-03 14:03:26 +0000383 puts ( "\n\t CPC0_SYSx DCRs corrupted. "
384 "Resetting chip ...\n");
385 udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200386 do_chip_reset ( mfdcr(CPC0_STRP0),
387 mfdcr(CPC0_STRP1) );
wdenk4d816772003-09-03 14:03:26 +0000388 }
wdenkc6097192002-11-03 00:24:07 +0000389 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100390
wdenk8bde7f72003-06-27 21:31:46 +0000391 case PVR_440GP_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200392 puts("440GP Rev. C");
wdenkba56f622004-02-06 23:19:44 +0000393 break;
Stefan Roese5e7abce2010-09-11 09:31:43 +0200394#endif /* CONFIG_440GP */
Stefan Roese3d9569b2005-11-27 19:36:26 +0100395
wdenkba56f622004-02-06 23:19:44 +0000396 case PVR_440GX_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200397 puts("440GX Rev. A");
wdenkba56f622004-02-06 23:19:44 +0000398 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100399
wdenkba56f622004-02-06 23:19:44 +0000400 case PVR_440GX_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200401 puts("440GX Rev. B");
wdenkc6097192002-11-03 00:24:07 +0000402 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100403
stroese0a7c5392005-04-07 05:33:41 +0000404 case PVR_440GX_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200405 puts("440GX Rev. C");
stroese0a7c5392005-04-07 05:33:41 +0000406 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100407
Stefan Roese57275b62005-11-01 10:08:03 +0100408 case PVR_440GX_RF:
Stefan Roesee02d4492010-09-03 13:27:02 +0200409 puts("440GX Rev. F");
Stefan Roese57275b62005-11-01 10:08:03 +0100410 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100411
Stefan Roesec157d8e2005-08-01 16:41:48 +0200412 case PVR_440EP_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200413 puts("440EP Rev. A");
Stefan Roesec157d8e2005-08-01 16:41:48 +0200414 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100415
Stefan Roese9a8d82f2005-10-04 15:00:30 +0200416#ifdef CONFIG_440EP
417 case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
Stefan Roesee02d4492010-09-03 13:27:02 +0200418 puts("440EP Rev. B");
Stefan Roesec157d8e2005-08-01 16:41:48 +0200419 break;
Stefan Roese512f8d52006-05-10 14:10:41 +0200420
421 case PVR_440EP_RC: /* 440EP rev C and 440GR rev B have same PVR */
Stefan Roesee02d4492010-09-03 13:27:02 +0200422 puts("440EP Rev. C");
Stefan Roese512f8d52006-05-10 14:10:41 +0200423 break;
Stefan Roese9a8d82f2005-10-04 15:00:30 +0200424#endif /* CONFIG_440EP */
Stefan Roese3d9569b2005-11-27 19:36:26 +0100425
Stefan Roese9a8d82f2005-10-04 15:00:30 +0200426#ifdef CONFIG_440GR
427 case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
Stefan Roesee02d4492010-09-03 13:27:02 +0200428 puts("440GR Rev. A");
Stefan Roese9a8d82f2005-10-04 15:00:30 +0200429 break;
Stefan Roese512f8d52006-05-10 14:10:41 +0200430
Stefan Roese5770a1e2006-05-18 19:21:53 +0200431 case PVR_440GR_RB: /* 440EP rev C and 440GR rev B have same PVR */
Stefan Roesee02d4492010-09-03 13:27:02 +0200432 puts("440GR Rev. B");
Stefan Roese512f8d52006-05-10 14:10:41 +0200433 break;
Stefan Roese9a8d82f2005-10-04 15:00:30 +0200434#endif /* CONFIG_440GR */
Stefan Roese3d9569b2005-11-27 19:36:26 +0100435
Stefan Roese2902fad2007-01-31 16:56:10 +0100436#ifdef CONFIG_440EPX
437 case PVR_440EPX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
Stefan Roesee02d4492010-09-03 13:27:02 +0200438 puts("440EPx Rev. A");
Stefan Roeseedf0b542006-10-18 15:59:35 +0200439 strcpy(addstr, "Security/Kasumi support");
Stefan Roese887e2ec2006-09-07 11:51:23 +0200440 break;
441
Stefan Roese2902fad2007-01-31 16:56:10 +0100442 case PVR_440EPX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
Stefan Roesee02d4492010-09-03 13:27:02 +0200443 puts("440EPx Rev. A");
Stefan Roeseedf0b542006-10-18 15:59:35 +0200444 strcpy(addstr, "No Security/Kasumi support");
Stefan Roese887e2ec2006-09-07 11:51:23 +0200445 break;
Stefan Roese2902fad2007-01-31 16:56:10 +0100446#endif /* CONFIG_440EPX */
Stefan Roese887e2ec2006-09-07 11:51:23 +0200447
Stefan Roese2902fad2007-01-31 16:56:10 +0100448#ifdef CONFIG_440GRX
449 case PVR_440GRX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
Stefan Roesee02d4492010-09-03 13:27:02 +0200450 puts("440GRx Rev. A");
Stefan Roeseedf0b542006-10-18 15:59:35 +0200451 strcpy(addstr, "Security/Kasumi support");
Stefan Roese887e2ec2006-09-07 11:51:23 +0200452 break;
453
Stefan Roese2902fad2007-01-31 16:56:10 +0100454 case PVR_440GRX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
Stefan Roesee02d4492010-09-03 13:27:02 +0200455 puts("440GRx Rev. A");
Stefan Roeseedf0b542006-10-18 15:59:35 +0200456 strcpy(addstr, "No Security/Kasumi support");
Stefan Roese887e2ec2006-09-07 11:51:23 +0200457 break;
Stefan Roese2902fad2007-01-31 16:56:10 +0100458#endif /* CONFIG_440GRX */
Stefan Roese887e2ec2006-09-07 11:51:23 +0200459
Stefan Roese95981772007-01-13 08:01:03 +0100460 case PVR_440SP_6_RAB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200461 puts("440SP Rev. A/B");
Stefan Roese95981772007-01-13 08:01:03 +0100462 strcpy(addstr, "RAID 6 support");
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100463 break;
464
Stefan Roese95981772007-01-13 08:01:03 +0100465 case PVR_440SP_RAB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200466 puts("440SP Rev. A/B");
Stefan Roese95981772007-01-13 08:01:03 +0100467 strcpy(addstr, "No RAID 6 support");
468 break;
469
470 case PVR_440SP_6_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200471 puts("440SP Rev. C");
Stefan Roese95981772007-01-13 08:01:03 +0100472 strcpy(addstr, "RAID 6 support");
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100473 break;
474
Stefan Roesee732fae2006-11-28 16:09:24 +0100475 case PVR_440SP_RC:
Stefan Roesee02d4492010-09-03 13:27:02 +0200476 puts("440SP Rev. C");
Stefan Roese95981772007-01-13 08:01:03 +0100477 strcpy(addstr, "No RAID 6 support");
478 break;
479
480 case PVR_440SPe_6_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200481 puts("440SPe Rev. A");
Stefan Roese95981772007-01-13 08:01:03 +0100482 strcpy(addstr, "RAID 6 support");
Stefan Roesee732fae2006-11-28 16:09:24 +0100483 break;
484
Marian Balakowicz6c5879f2006-06-30 16:30:46 +0200485 case PVR_440SPe_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200486 puts("440SPe Rev. A");
Stefan Roese95981772007-01-13 08:01:03 +0100487 strcpy(addstr, "No RAID 6 support");
488 break;
489
490 case PVR_440SPe_6_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200491 puts("440SPe Rev. B");
Stefan Roese95981772007-01-13 08:01:03 +0100492 strcpy(addstr, "RAID 6 support");
Marian Balakowicz6c5879f2006-06-30 16:30:46 +0200493 break;
Marian Balakowiczfe84b482006-07-03 23:42:36 +0200494
Marian Balakowicz6c5879f2006-06-30 16:30:46 +0200495 case PVR_440SPe_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200496 puts("440SPe Rev. B");
Stefan Roese95981772007-01-13 08:01:03 +0100497 strcpy(addstr, "No RAID 6 support");
Marian Balakowicz6c5879f2006-06-30 16:30:46 +0200498 break;
Marian Balakowiczfe84b482006-07-03 23:42:36 +0200499
Stefan Roese89bcc482009-07-29 08:45:27 +0200500#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
Stefan Roese2801b2d2008-03-11 15:05:50 +0100501 case PVR_460EX_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200502 puts("460EX Rev. A");
Stefan Roese2801b2d2008-03-11 15:05:50 +0100503 strcpy(addstr, "No Security/Kasumi support");
504 break;
505
506 case PVR_460EX_SE_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200507 puts("460EX Rev. A");
Stefan Roese2801b2d2008-03-11 15:05:50 +0100508 strcpy(addstr, "Security/Kasumi support");
509 break;
510
Stefan Roese89bcc482009-07-29 08:45:27 +0200511 case PVR_460EX_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200512 puts("460EX Rev. B");
Stefan Roese89bcc482009-07-29 08:45:27 +0200513 mfsdr(SDR0_ECID3, reg);
514 if (reg & 0x00100000)
515 strcpy(addstr, "No Security/Kasumi support");
516 else
517 strcpy(addstr, "Security/Kasumi support");
518 break;
519
Stefan Roese2801b2d2008-03-11 15:05:50 +0100520 case PVR_460GT_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200521 puts("460GT Rev. A");
Stefan Roese2801b2d2008-03-11 15:05:50 +0100522 strcpy(addstr, "No Security/Kasumi support");
523 break;
524
525 case PVR_460GT_SE_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200526 puts("460GT Rev. A");
Stefan Roese2801b2d2008-03-11 15:05:50 +0100527 strcpy(addstr, "Security/Kasumi support");
528 break;
529
Stefan Roese89bcc482009-07-29 08:45:27 +0200530 case PVR_460GT_RB:
Stefan Roesee02d4492010-09-03 13:27:02 +0200531 puts("460GT Rev. B");
Stefan Roese89bcc482009-07-29 08:45:27 +0200532 mfsdr(SDR0_ECID3, reg);
533 if (reg & 0x00100000)
534 strcpy(addstr, "No Security/Kasumi support");
535 else
536 strcpy(addstr, "Security/Kasumi support");
537 break;
538#endif
539
Feng Kan7d307932008-07-08 22:47:31 -0700540 case PVR_460SX_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200541 puts("460SX Rev. A");
Feng Kan7d307932008-07-08 22:47:31 -0700542 strcpy(addstr, "Security support");
543 break;
544
545 case PVR_460SX_RA_V1:
Stefan Roesee02d4492010-09-03 13:27:02 +0200546 puts("460SX Rev. A");
Feng Kan7d307932008-07-08 22:47:31 -0700547 strcpy(addstr, "No Security support");
548 break;
549
550 case PVR_460GX_RA:
Stefan Roesee02d4492010-09-03 13:27:02 +0200551 puts("460GX Rev. A");
Feng Kan7d307932008-07-08 22:47:31 -0700552 strcpy(addstr, "Security support");
553 break;
554
555 case PVR_460GX_RA_V1:
Stefan Roesee02d4492010-09-03 13:27:02 +0200556 puts("460GX Rev. A");
Feng Kan7d307932008-07-08 22:47:31 -0700557 strcpy(addstr, "No Security support");
558 break;
559
Tirumala Marri1b8fec12010-09-28 14:15:14 -0700560 case PVR_APM821XX_RA:
561 puts("APM821XX Rev. A");
562 strcpy(addstr, "Security support");
563 break;
564
Ricardo Ribalda Delgadod865fd02008-07-17 11:44:12 +0200565 case PVR_VIRTEX5:
Stefan Roesee02d4492010-09-03 13:27:02 +0200566 puts("440x5 VIRTEX5");
Ricardo Ribalda Delgadod865fd02008-07-17 11:44:12 +0200567 break;
Stefan Roesee02d4492010-09-03 13:27:02 +0200568#endif /* CONFIG_440 */
Ricardo Ribalda Delgadod865fd02008-07-17 11:44:12 +0200569
wdenk8bde7f72003-06-27 21:31:46 +0000570 default:
Stefan Roese17f50f222005-08-04 17:09:16 +0200571 printf (" UNKNOWN (PVR=%08x)", pvr);
wdenkc6097192002-11-03 00:24:07 +0000572 break;
573 }
Stefan Roese3d9569b2005-11-27 19:36:26 +0100574
Stefan Roese08c6a262009-10-19 14:44:11 +0200575 printf (" at %s MHz (PLB=%lu OPB=%lu EBC=%lu",
576 strmhz(buf, clock),
Stefan Roesee01bd212007-03-21 13:38:59 +0100577 sys_info.freqPLB / 1000000,
578 get_OPB_freq() / 1000000,
Stefan Roesedbbd1252007-10-05 17:10:59 +0200579 sys_info.freqEBC / 1000000);
Stefan Roese08c6a262009-10-19 14:44:11 +0200580#if defined(CONFIG_PCI) && \
581 (defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
582 defined(CONFIG_440GR) || defined(CONFIG_440GRX))
583 printf(" PCI=%lu MHz", sys_info.freqPCI / 1000000);
584#endif
585 printf(")\n");
Stefan Roese3d9569b2005-11-27 19:36:26 +0100586
Stefan Roeseedf0b542006-10-18 15:59:35 +0200587 if (addstr[0] != 0)
588 printf(" %s\n", addstr);
589
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100590#if defined(I2C_BOOTROM)
591 printf (" I2C boot EEPROM %sabled\n", i2c_bootrom_enabled() ? "en" : "dis");
Stefan Roese90e6f412007-04-18 12:05:59 +0200592#endif /* I2C_BOOTROM */
Stefan Roese887e2ec2006-09-07 11:51:23 +0200593#if defined(SDR0_PINSTP_SHIFT)
BenoƮt Monine3cbe1f2007-06-04 08:36:05 +0200594 printf (" Bootstrap Option %c - ", bootstrap_char[bootstrap_option()]);
Stefan Roesecf940982009-04-15 10:50:48 +0200595 printf ("Boot ROM Location %s", bootstrap_str[bootstrap_option()]);
Stefan Roesecf940982009-04-15 10:50:48 +0200596 putc('\n');
Wolfgang Denkba999c52006-10-20 17:54:33 +0200597#endif /* SDR0_PINSTP_SHIFT */
Stefan Roese3d9569b2005-11-27 19:36:26 +0100598
Stefan Roesedbbd1252007-10-05 17:10:59 +0200599#if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100600 printf (" Internal PCI arbiter %sabled", pci_arbiter_enabled() ? "en" : "dis");
Stefan Roese3d9569b2005-11-27 19:36:26 +0100601#endif
602
Stefan Roese1bbae2b2009-05-27 10:34:32 +0200603#if defined(CONFIG_PCI) && defined(PCI_ASYNC)
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100604 if (pci_async_enabled()) {
Stefan Roese3d9569b2005-11-27 19:36:26 +0100605 printf (", PCI async ext clock used");
606 } else {
607 printf (", PCI sync clock at %lu MHz",
608 sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
609 }
610#endif
611
Stefan Roesedbbd1252007-10-05 17:10:59 +0200612#if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
Stefan Roese3d9569b2005-11-27 19:36:26 +0100613 putc('\n');
614#endif
615
Stefan Roesedbbd1252007-10-05 17:10:59 +0200616#if defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX)
Shruti Kanetkar6b44d9e2013-08-15 11:25:38 -0500617 printf(" 16 KiB I-Cache 16 KiB D-Cache");
Stefan Roese3d9569b2005-11-27 19:36:26 +0100618#elif defined(CONFIG_440)
Shruti Kanetkar6b44d9e2013-08-15 11:25:38 -0500619 printf(" 32 KiB I-Cache 32 KiB D-Cache");
Stefan Roese3d9569b2005-11-27 19:36:26 +0100620#else
Shruti Kanetkar6b44d9e2013-08-15 11:25:38 -0500621 printf(" 16 KiB I-Cache %d KiB D-Cache",
622 ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
Stefan Roese3d9569b2005-11-27 19:36:26 +0100623#endif
Stefan Roese3d9569b2005-11-27 19:36:26 +0100624
625#endif /* !defined(CONFIG_405) */
626
627 putc ('\n');
wdenkc6097192002-11-03 00:24:07 +0000628
629 return 0;
630}
631
Rafal Jaworowski692519b2006-08-10 12:43:17 +0200632int ppc440spe_revB() {
633 unsigned int pvr;
634
635 pvr = get_pvr();
Stefan Roese5a5c5692007-01-15 09:46:29 +0100636 if ((pvr == PVR_440SPe_6_RB) || (pvr == PVR_440SPe_RB))
Rafal Jaworowski692519b2006-08-10 12:43:17 +0200637 return 1;
638 else
639 return 0;
640}
wdenkc6097192002-11-03 00:24:07 +0000641
642/* ------------------------------------------------------------------------- */
643
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200644int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenkc6097192002-11-03 00:24:07 +0000645{
Stefan Roese1f94d162006-11-27 14:48:41 +0100646#if defined(CONFIG_BOARD_RESET)
647 board_reset();
Stefan Roese1729b922006-11-27 14:52:04 +0100648#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200649#if defined(CONFIG_SYS_4xx_RESET_TYPE)
Matthias Fuchs58ea1422009-07-22 17:27:56 +0200650 mtspr(SPRN_DBCR0, CONFIG_SYS_4xx_RESET_TYPE << 28);
Stefan Roesec157d8e2005-08-01 16:41:48 +0200651#else
wdenk8bde7f72003-06-27 21:31:46 +0000652 /*
653 * Initiate system reset in debug control register DBCR
654 */
Matthias Fuchs58ea1422009-07-22 17:27:56 +0200655 mtspr(SPRN_DBCR0, 0x30000000);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200656#endif /* defined(CONFIG_SYS_4xx_RESET_TYPE) */
Stefan Roesef3443862006-10-07 11:30:52 +0200657#endif /* defined(CONFIG_BOARD_RESET) */
Stefan Roesec157d8e2005-08-01 16:41:48 +0200658
wdenkc6097192002-11-03 00:24:07 +0000659 return 1;
660}
661
wdenkc6097192002-11-03 00:24:07 +0000662
663/*
664 * Get timebase clock frequency
665 */
666unsigned long get_tbclk (void)
667{
wdenkc6097192002-11-03 00:24:07 +0000668 sys_info_t sys_info;
669
670 get_sys_info(&sys_info);
671 return (sys_info.freqProcessor);
wdenkc6097192002-11-03 00:24:07 +0000672}
673
674
675#if defined(CONFIG_WATCHDOG)
Stefan Roesec7f69c32007-11-09 12:18:54 +0100676void watchdog_reset(void)
wdenkc6097192002-11-03 00:24:07 +0000677{
678 int re_enable = disable_interrupts();
679 reset_4xx_watchdog();
680 if (re_enable) enable_interrupts();
681}
682
Stefan Roesec7f69c32007-11-09 12:18:54 +0100683void reset_4xx_watchdog(void)
wdenkc6097192002-11-03 00:24:07 +0000684{
685 /*
686 * Clear TSR(WIS) bit
687 */
Matthias Fuchs58ea1422009-07-22 17:27:56 +0200688 mtspr(SPRN_TSR, 0x40000000);
wdenkc6097192002-11-03 00:24:07 +0000689}
690#endif /* CONFIG_WATCHDOG */
Ben Warren25a85902008-10-27 23:53:17 -0700691
692/*
693 * Initializes on-chip ethernet controllers.
694 * to override, implement board_eth_init()
695 */
696int cpu_eth_init(bd_t *bis)
697{
698#if defined(CONFIG_PPC4xx_EMAC)
699 ppc_4xx_eth_initialize(bis);
700#endif
701 return 0;
702}