blob: 5cebafdbae6a0550f68daee093bfcf6189dbfef5 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
Stefan Roese153b3e22007-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 Denkd79de1d2013-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 Roese247e9d72010-09-09 19:18:00 +020022#include <asm/ppc4xx.h>
Ben Warren9e37c582008-10-27 23:53:17 -070023#include <netdev.h>
wdenkc6097192002-11-03 00:24:07 +000024
Wolfgang Denk6405a152006-03-31 18:32:53 +020025DECLARE_GLOBAL_DATA_PTR;
Wolfgang Denk6405a152006-03-31 18:32:53 +020026
Stefan Roese03687752006-10-07 11:30:52 +020027void board_reset(void);
Stefan Roese03687752006-10-07 11:30:52 +020028
Adam Grahamc31ff682008-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 Roese9f500fa2009-07-06 11:44:33 +020041#if defined(CONFIG_PCI)
Stefan Roese42fbddd2006-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 Roese99644742005-11-29 18:18:21 +010045
46#define PCI_ASYNC
47
Stefan Roese6964fd62007-11-09 12:18:54 +010048static int pci_async_enabled(void)
Stefan Roese99644742005-11-29 18:18:21 +010049{
50#if defined(CONFIG_405GP)
Stefan Roese918010a2009-09-09 16:25:29 +020051 return (mfdcr(CPC0_PSR) & PSR_PCI_ASYNC_EN);
Stefan Roese42f2a822005-11-27 19:36:26 +010052#endif
53
Stefan Roese42fbddd2006-09-07 11:51:23 +020054#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
Stefan Roesecc019d12008-03-11 15:05:50 +010055 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
56 defined(CONFIG_460EX) || defined(CONFIG_460GT)
Stefan Roese99644742005-11-29 18:18:21 +010057 unsigned long val;
58
Stefan Roese918010a2009-09-09 16:25:29 +020059 mfsdr(SDR0_SDSTP1, val);
Stefan Roese99644742005-11-29 18:18:21 +010060 return (val & SDR0_SDSTP1_PAME_MASK);
61#endif
62}
63#endif
Stefan Roese9f500fa2009-07-06 11:44:33 +020064#endif /* CONFIG_PCI */
Stefan Roese99644742005-11-29 18:18:21 +010065
Stefan Roese32ca04a2012-09-19 14:33:52 +020066#if defined(CONFIG_PCI) && \
Stefan Roese153b3e22007-10-05 17:10:59 +020067 !defined(CONFIG_405) && !defined(CONFIG_405EX)
Stefan Roese5d8033e2009-11-12 16:41:09 +010068int pci_arbiter_enabled(void)
Stefan Roese99644742005-11-29 18:18:21 +010069{
70#if defined(CONFIG_405GP)
Stefan Roese918010a2009-09-09 16:25:29 +020071 return (mfdcr(CPC0_PSR) & PSR_PCI_ARBIT_EN);
Stefan Roese99644742005-11-29 18:18:21 +010072#endif
Stefan Roese42f2a822005-11-27 19:36:26 +010073
Stefan Roese99644742005-11-29 18:18:21 +010074#if defined(CONFIG_405EP)
Stefan Roese918010a2009-09-09 16:25:29 +020075 return (mfdcr(CPC0_PCI) & CPC0_PCI_ARBIT_EN);
Stefan Roese42f2a822005-11-27 19:36:26 +010076#endif
77
78#if defined(CONFIG_440GP)
Stefan Roese918010a2009-09-09 16:25:29 +020079 return (mfdcr(CPC0_STRP1) & CPC0_STRP1_PAE_MASK);
Stefan Roese99644742005-11-29 18:18:21 +010080#endif
Stefan Roese42f2a822005-11-27 19:36:26 +010081
Stefan Roese84382432007-02-02 12:44:22 +010082#if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
Stefan Roese99644742005-11-29 18:18:21 +010083 unsigned long val;
84
Stefan Roese95ca5fa2010-09-11 09:31:43 +020085 mfsdr(SDR0_XCR0, val);
86 return (val & SDR0_XCR0_PAE_MASK);
Stefan Roese84382432007-02-02 12:44:22 +010087#endif
88#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
Stefan Roesecc019d12008-03-11 15:05:50 +010089 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
90 defined(CONFIG_460EX) || defined(CONFIG_460GT)
Stefan Roese84382432007-02-02 12:44:22 +010091 unsigned long val;
92
Stefan Roese918010a2009-09-09 16:25:29 +020093 mfsdr(SDR0_PCI0, val);
Stefan Roese95ca5fa2010-09-11 09:31:43 +020094 return (val & SDR0_PCI0_PAE_MASK);
Stefan Roese42f2a822005-11-27 19:36:26 +010095#endif
Stefan Roese99644742005-11-29 18:18:21 +010096}
97#endif
98
Stefan Roese6964fd62007-11-09 12:18:54 +010099#if defined(CONFIG_405EP)
Stefan Roese99644742005-11-29 18:18:21 +0100100#define I2C_BOOTROM
Stefan Roese42f2a822005-11-27 19:36:26 +0100101
Stefan Roese6964fd62007-11-09 12:18:54 +0100102static int i2c_bootrom_enabled(void)
Stefan Roese99644742005-11-29 18:18:21 +0100103{
104#if defined(CONFIG_405EP)
Stefan Roese918010a2009-09-09 16:25:29 +0200105 return (mfdcr(CPC0_BOOT) & CPC0_BOOT_SEP);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200106#else
Stefan Roese99644742005-11-29 18:18:21 +0100107 unsigned long val;
108
Stefan Roese918010a2009-09-09 16:25:29 +0200109 mfsdr(SDR0_SDCS0, val);
Stefan Roese99644742005-11-29 18:18:21 +0100110 return (val & SDR0_SDCS_SDD);
111#endif
Stefan Roese42fbddd2006-09-07 11:51:23 +0200112}
Stefan Roese3a75ac12007-04-18 12:05:59 +0200113#endif
Stefan Roese42fbddd2006-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 Monin1a70cf22007-06-04 08:36:05 +0200127static char bootstrap_char[] = { 'A', 'B', 'C', 'B', 'D', 'E', 'x', 'F' };
Stefan Roese42fbddd2006-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 Monin1a70cf22007-06-04 08:36:05 +0200138static char bootstrap_char[] = { 'A', 'B', 'C', 'D'};
Stefan Roese42fbddd2006-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 Monin1a70cf22007-06-04 08:36:05 +0200153static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
Stefan Roese42fbddd2006-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 Monin1a70cf22007-06-04 08:36:05 +0200168static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
Stefan Roese42fbddd2006-09-07 11:51:23 +0200169#endif
170
Stefan Roesecc019d12008-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 Radenskye6be1452010-01-19 17:37:13 +0200183static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
Stefan Roesecc019d12008-03-11 15:05:50 +0100184#endif
185
Feng Kan224bc962008-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 Roese3a75ac12007-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 Monin1a70cf22007-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 Roese3a75ac12007-04-18 12:05:59 +0200221#endif
222
Stefan Roese153b3e22007-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
Tirumala Marri95ac4282010-09-28 14:15:14 -0700237#if defined(CONFIG_APM821XX)
238#define SDR0_PINSTP_SHIFT 29
239static char *bootstrap_str[] = {
240 "RESERVED",
241 "RESERVED",
242 "RESERVED",
243 "NAND (8 bits)",
244 "NOR (8 bits)",
245 "NOR (8 bits) w/PLL Bypassed",
246 "I2C (Addr 0x54)",
247 "I2C (Addr 0x52)",
248};
249static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
250#endif
Stefan Roese153b3e22007-10-05 17:10:59 +0200251
Stefan Roese42fbddd2006-09-07 11:51:23 +0200252#if defined(SDR0_PINSTP_SHIFT)
253static int bootstrap_option(void)
254{
255 unsigned long val;
256
Stefan Roese918010a2009-09-09 16:25:29 +0200257 mfsdr(SDR0_PINSTP, val);
Stefan Roese3a75ac12007-04-18 12:05:59 +0200258 return ((val & 0xf0000000) >> SDR0_PINSTP_SHIFT);
Stefan Roese99644742005-11-29 18:18:21 +0100259}
Stefan Roese42fbddd2006-09-07 11:51:23 +0200260#endif /* SDR0_PINSTP_SHIFT */
Stefan Roese42f2a822005-11-27 19:36:26 +0100261
262
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200263#if defined(CONFIG_440GP)
Stefan Roese6964fd62007-11-09 12:18:54 +0100264static int do_chip_reset (unsigned long sys0, unsigned long sys1)
265{
Stefan Roese918010a2009-09-09 16:25:29 +0200266 /* Changes to CPC0_SYS0 and CPC0_SYS1 require chip
Stefan Roese6964fd62007-11-09 12:18:54 +0100267 * reset.
268 */
Stefan Roese918010a2009-09-09 16:25:29 +0200269 mtdcr (CPC0_CR0, mfdcr (CPC0_CR0) | 0x80000000); /* Set SWE */
270 mtdcr (CPC0_SYS0, sys0);
271 mtdcr (CPC0_SYS1, sys1);
272 mtdcr (CPC0_CR0, mfdcr (CPC0_CR0) & ~0x80000000); /* Clr SWE */
Matthias Fuchs730b2d22009-07-22 17:27:56 +0200273 mtspr (SPRN_DBCR0, 0x20000000); /* Reset the chip */
Stefan Roese6964fd62007-11-09 12:18:54 +0100274
275 return 1;
276}
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200277#endif /* CONFIG_440GP */
wdenkc6097192002-11-03 00:24:07 +0000278
wdenkc6097192002-11-03 00:24:07 +0000279
280int checkcpu (void)
281{
Stefan Roese42f2a822005-11-27 19:36:26 +0100282#if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */
Stefan Roese42f2a822005-11-27 19:36:26 +0100283 uint pvr = get_pvr();
wdenkc6097192002-11-03 00:24:07 +0000284 ulong clock = gd->cpu_clk;
285 char buf[32];
Stefan Roese048f5a62009-07-29 08:45:27 +0200286#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
287 u32 reg;
288#endif
wdenkc6097192002-11-03 00:24:07 +0000289
Wolfgang Denk65505432006-10-20 17:54:33 +0200290 char addstr[64] = "";
Stefan Roese42f2a822005-11-27 19:36:26 +0100291 sys_info_t sys_info;
Adam Grahamc31ff682008-10-08 10:13:19 -0700292 int cpu_num;
wdenkc6097192002-11-03 00:24:07 +0000293
Adam Grahamc31ff682008-10-08 10:13:19 -0700294 cpu_num = get_cpu_num();
295 if (cpu_num >= 0)
296 printf("CPU%d: ", cpu_num);
297 else
298 puts("CPU: ");
wdenkc6097192002-11-03 00:24:07 +0000299
300 get_sys_info(&sys_info);
301
Ricardo Ribalda Delgado95c50202008-07-17 11:44:12 +0200302#if defined(CONFIG_XILINX_440)
Stefan Roese43e1b452010-09-03 13:27:02 +0200303 puts("IBM PowerPC ");
Ricardo Ribalda Delgado95c50202008-07-17 11:44:12 +0200304#else
Stefan Roese43e1b452010-09-03 13:27:02 +0200305 puts("AMCC PowerPC ");
Ricardo Ribalda Delgado95c50202008-07-17 11:44:12 +0200306#endif
Stefan Roese42f2a822005-11-27 19:36:26 +0100307
wdenkc6097192002-11-03 00:24:07 +0000308 switch (pvr) {
Stefan Roese43e1b452010-09-03 13:27:02 +0200309
310#if !defined(CONFIG_440)
wdenkc6097192002-11-03 00:24:07 +0000311 case PVR_405GP_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200312 puts("405GP Rev. B");
wdenkc6097192002-11-03 00:24:07 +0000313 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100314
wdenkc6097192002-11-03 00:24:07 +0000315 case PVR_405GP_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200316 puts("405GP Rev. C");
wdenkc6097192002-11-03 00:24:07 +0000317 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100318
wdenkc6097192002-11-03 00:24:07 +0000319 case PVR_405GP_RD:
Stefan Roese43e1b452010-09-03 13:27:02 +0200320 puts("405GP Rev. D");
wdenkc6097192002-11-03 00:24:07 +0000321 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100322
Matthias Fuchse54a67f2013-08-07 12:10:38 +0200323 case PVR_405GP_RE:
Stefan Roese43e1b452010-09-03 13:27:02 +0200324 puts("405GP Rev. E");
wdenkc6097192002-11-03 00:24:07 +0000325 break;
wdenkc6097192002-11-03 00:24:07 +0000326
Stefan Roese42f2a822005-11-27 19:36:26 +0100327 case PVR_405GPR_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200328 puts("405GPr Rev. B");
Stefan Roese42f2a822005-11-27 19:36:26 +0100329 break;
wdenkc6097192002-11-03 00:24:07 +0000330
Stefan Roese42f2a822005-11-27 19:36:26 +0100331 case PVR_405EP_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200332 puts("405EP Rev. B");
Stefan Roese42f2a822005-11-27 19:36:26 +0100333 break;
wdenkc6097192002-11-03 00:24:07 +0000334
Stefan Roese17ffbc82007-03-21 13:38:59 +0100335 case PVR_405EZ_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200336 puts("405EZ Rev. A");
Stefan Roese17ffbc82007-03-21 13:38:59 +0100337 break;
338
Stefan Roese153b3e22007-10-05 17:10:59 +0200339 case PVR_405EX1_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200340 puts("405EX Rev. A");
Stefan Roese153b3e22007-10-05 17:10:59 +0200341 strcpy(addstr, "Security support");
342 break;
343
Stefan Roese153b3e22007-10-05 17:10:59 +0200344 case PVR_405EXR2_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200345 puts("405EXr Rev. A");
Stefan Roese153b3e22007-10-05 17:10:59 +0200346 strcpy(addstr, "No Security support");
347 break;
348
Stefan Roesefbf24302008-05-13 20:22:01 +0200349 case PVR_405EX1_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200350 puts("405EX Rev. C");
Stefan Roesefbf24302008-05-13 20:22:01 +0200351 strcpy(addstr, "Security support");
352 break;
353
354 case PVR_405EX2_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200355 puts("405EX Rev. C");
Stefan Roesefbf24302008-05-13 20:22:01 +0200356 strcpy(addstr, "No Security support");
357 break;
358
359 case PVR_405EXR1_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200360 puts("405EXr Rev. C");
Stefan Roesefbf24302008-05-13 20:22:01 +0200361 strcpy(addstr, "Security support");
362 break;
363
364 case PVR_405EXR2_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200365 puts("405EXr Rev. C");
Stefan Roesefbf24302008-05-13 20:22:01 +0200366 strcpy(addstr, "No Security support");
367 break;
368
Stefan Roesef1a80e42009-10-06 07:21:08 +0200369 case PVR_405EX1_RD:
Stefan Roese43e1b452010-09-03 13:27:02 +0200370 puts("405EX Rev. D");
Stefan Roesef1a80e42009-10-06 07:21:08 +0200371 strcpy(addstr, "Security support");
372 break;
373
374 case PVR_405EX2_RD:
Stefan Roese43e1b452010-09-03 13:27:02 +0200375 puts("405EX Rev. D");
Stefan Roesef1a80e42009-10-06 07:21:08 +0200376 strcpy(addstr, "No Security support");
377 break;
378
379 case PVR_405EXR1_RD:
Stefan Roese43e1b452010-09-03 13:27:02 +0200380 puts("405EXr Rev. D");
Stefan Roesef1a80e42009-10-06 07:21:08 +0200381 strcpy(addstr, "Security support");
382 break;
383
384 case PVR_405EXR2_RD:
Stefan Roese43e1b452010-09-03 13:27:02 +0200385 puts("405EXr Rev. D");
Stefan Roesef1a80e42009-10-06 07:21:08 +0200386 strcpy(addstr, "No Security support");
387 break;
388
Stefan Roese43e1b452010-09-03 13:27:02 +0200389#else /* CONFIG_440 */
390
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200391#if defined(CONFIG_440GP)
wdenk57b2d802003-06-27 21:31:46 +0000392 case PVR_440GP_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200393 puts("440GP Rev. B");
wdenka4685fe2003-09-03 14:03:26 +0000394 /* See errata 1.12: CHIP_4 */
Stefan Roese918010a2009-09-09 16:25:29 +0200395 if ((mfdcr(CPC0_SYS0) != mfdcr(CPC0_STRP0)) ||
396 (mfdcr(CPC0_SYS1) != mfdcr(CPC0_STRP1)) ){
wdenka4685fe2003-09-03 14:03:26 +0000397 puts ( "\n\t CPC0_SYSx DCRs corrupted. "
398 "Resetting chip ...\n");
399 udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
Stefan Roese918010a2009-09-09 16:25:29 +0200400 do_chip_reset ( mfdcr(CPC0_STRP0),
401 mfdcr(CPC0_STRP1) );
wdenka4685fe2003-09-03 14:03:26 +0000402 }
wdenkc6097192002-11-03 00:24:07 +0000403 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100404
wdenk57b2d802003-06-27 21:31:46 +0000405 case PVR_440GP_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200406 puts("440GP Rev. C");
wdenk544e9732004-02-06 23:19:44 +0000407 break;
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200408#endif /* CONFIG_440GP */
Stefan Roese42f2a822005-11-27 19:36:26 +0100409
wdenk544e9732004-02-06 23:19:44 +0000410 case PVR_440GX_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200411 puts("440GX Rev. A");
wdenk544e9732004-02-06 23:19:44 +0000412 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100413
wdenk544e9732004-02-06 23:19:44 +0000414 case PVR_440GX_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200415 puts("440GX Rev. B");
wdenkc6097192002-11-03 00:24:07 +0000416 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100417
stroesec0125272005-04-07 05:33:41 +0000418 case PVR_440GX_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200419 puts("440GX Rev. C");
stroesec0125272005-04-07 05:33:41 +0000420 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100421
Stefan Roese08fb4042005-11-01 10:08:03 +0100422 case PVR_440GX_RF:
Stefan Roese43e1b452010-09-03 13:27:02 +0200423 puts("440GX Rev. F");
Stefan Roese08fb4042005-11-01 10:08:03 +0100424 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100425
Stefan Roese326c9712005-08-01 16:41:48 +0200426 case PVR_440EP_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200427 puts("440EP Rev. A");
Stefan Roese326c9712005-08-01 16:41:48 +0200428 break;
Stefan Roese42f2a822005-11-27 19:36:26 +0100429
Stefan Roese95258d52005-10-04 15:00:30 +0200430#ifdef CONFIG_440EP
431 case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
Stefan Roese43e1b452010-09-03 13:27:02 +0200432 puts("440EP Rev. B");
Stefan Roese326c9712005-08-01 16:41:48 +0200433 break;
Stefan Roese31ce7de2006-05-10 14:10:41 +0200434
435 case PVR_440EP_RC: /* 440EP rev C and 440GR rev B have same PVR */
Stefan Roese43e1b452010-09-03 13:27:02 +0200436 puts("440EP Rev. C");
Stefan Roese31ce7de2006-05-10 14:10:41 +0200437 break;
Stefan Roese95258d52005-10-04 15:00:30 +0200438#endif /* CONFIG_440EP */
Stefan Roese42f2a822005-11-27 19:36:26 +0100439
Stefan Roese95258d52005-10-04 15:00:30 +0200440#ifdef CONFIG_440GR
441 case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
Stefan Roese43e1b452010-09-03 13:27:02 +0200442 puts("440GR Rev. A");
Stefan Roese95258d52005-10-04 15:00:30 +0200443 break;
Stefan Roese31ce7de2006-05-10 14:10:41 +0200444
Stefan Roese96467d62006-05-18 19:21:53 +0200445 case PVR_440GR_RB: /* 440EP rev C and 440GR rev B have same PVR */
Stefan Roese43e1b452010-09-03 13:27:02 +0200446 puts("440GR Rev. B");
Stefan Roese31ce7de2006-05-10 14:10:41 +0200447 break;
Stefan Roese95258d52005-10-04 15:00:30 +0200448#endif /* CONFIG_440GR */
Stefan Roese42f2a822005-11-27 19:36:26 +0100449
Stefan Roese188fab62007-01-31 16:56:10 +0100450#ifdef CONFIG_440EPX
451 case PVR_440EPX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
Stefan Roese43e1b452010-09-03 13:27:02 +0200452 puts("440EPx Rev. A");
Stefan Roese11dd8812006-10-18 15:59:35 +0200453 strcpy(addstr, "Security/Kasumi support");
Stefan Roese42fbddd2006-09-07 11:51:23 +0200454 break;
455
Stefan Roese188fab62007-01-31 16:56:10 +0100456 case PVR_440EPX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
Stefan Roese43e1b452010-09-03 13:27:02 +0200457 puts("440EPx Rev. A");
Stefan Roese11dd8812006-10-18 15:59:35 +0200458 strcpy(addstr, "No Security/Kasumi support");
Stefan Roese42fbddd2006-09-07 11:51:23 +0200459 break;
Stefan Roese188fab62007-01-31 16:56:10 +0100460#endif /* CONFIG_440EPX */
Stefan Roese42fbddd2006-09-07 11:51:23 +0200461
Stefan Roese188fab62007-01-31 16:56:10 +0100462#ifdef CONFIG_440GRX
463 case PVR_440GRX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
Stefan Roese43e1b452010-09-03 13:27:02 +0200464 puts("440GRx Rev. A");
Stefan Roese11dd8812006-10-18 15:59:35 +0200465 strcpy(addstr, "Security/Kasumi support");
Stefan Roese42fbddd2006-09-07 11:51:23 +0200466 break;
467
Stefan Roese188fab62007-01-31 16:56:10 +0100468 case PVR_440GRX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
Stefan Roese43e1b452010-09-03 13:27:02 +0200469 puts("440GRx Rev. A");
Stefan Roese11dd8812006-10-18 15:59:35 +0200470 strcpy(addstr, "No Security/Kasumi support");
Stefan Roese42fbddd2006-09-07 11:51:23 +0200471 break;
Stefan Roese188fab62007-01-31 16:56:10 +0100472#endif /* CONFIG_440GRX */
Stefan Roese42fbddd2006-09-07 11:51:23 +0200473
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100474 case PVR_440SP_6_RAB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200475 puts("440SP Rev. A/B");
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100476 strcpy(addstr, "RAID 6 support");
Stefan Roese99644742005-11-29 18:18:21 +0100477 break;
478
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100479 case PVR_440SP_RAB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200480 puts("440SP Rev. A/B");
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100481 strcpy(addstr, "No RAID 6 support");
Stefan Roese99644742005-11-29 18:18:21 +0100482 break;
483
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100484 case PVR_440SP_6_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200485 puts("440SP Rev. C");
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100486 strcpy(addstr, "RAID 6 support");
487 break;
488
Stefan Roesec6d59302006-11-28 16:09:24 +0100489 case PVR_440SP_RC:
Stefan Roese43e1b452010-09-03 13:27:02 +0200490 puts("440SP Rev. C");
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100491 strcpy(addstr, "No RAID 6 support");
Stefan Roesec6d59302006-11-28 16:09:24 +0100492 break;
493
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100494 case PVR_440SPe_6_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200495 puts("440SPe Rev. A");
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100496 strcpy(addstr, "RAID 6 support");
497 break;
498
Marian Balakowicz49d0eee2006-06-30 16:30:46 +0200499 case PVR_440SPe_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200500 puts("440SPe Rev. A");
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100501 strcpy(addstr, "No RAID 6 support");
502 break;
503
504 case PVR_440SPe_6_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200505 puts("440SPe Rev. B");
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100506 strcpy(addstr, "RAID 6 support");
Marian Balakowicz49d0eee2006-06-30 16:30:46 +0200507 break;
Marian Balakowicz11b8c432006-07-03 23:42:36 +0200508
Marian Balakowicz49d0eee2006-06-30 16:30:46 +0200509 case PVR_440SPe_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200510 puts("440SPe Rev. B");
Stefan Roesef4b01bf2007-01-13 08:01:03 +0100511 strcpy(addstr, "No RAID 6 support");
Marian Balakowicz49d0eee2006-06-30 16:30:46 +0200512 break;
Marian Balakowicz11b8c432006-07-03 23:42:36 +0200513
Stefan Roese048f5a62009-07-29 08:45:27 +0200514#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
Stefan Roesecc019d12008-03-11 15:05:50 +0100515 case PVR_460EX_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200516 puts("460EX Rev. A");
Stefan Roesecc019d12008-03-11 15:05:50 +0100517 strcpy(addstr, "No Security/Kasumi support");
518 break;
519
520 case PVR_460EX_SE_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200521 puts("460EX Rev. A");
Stefan Roesecc019d12008-03-11 15:05:50 +0100522 strcpy(addstr, "Security/Kasumi support");
523 break;
524
Stefan Roese048f5a62009-07-29 08:45:27 +0200525 case PVR_460EX_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200526 puts("460EX Rev. B");
Stefan Roese048f5a62009-07-29 08:45:27 +0200527 mfsdr(SDR0_ECID3, reg);
528 if (reg & 0x00100000)
529 strcpy(addstr, "No Security/Kasumi support");
530 else
531 strcpy(addstr, "Security/Kasumi support");
532 break;
533
Stefan Roesecc019d12008-03-11 15:05:50 +0100534 case PVR_460GT_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200535 puts("460GT Rev. A");
Stefan Roesecc019d12008-03-11 15:05:50 +0100536 strcpy(addstr, "No Security/Kasumi support");
537 break;
538
539 case PVR_460GT_SE_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200540 puts("460GT Rev. A");
Stefan Roesecc019d12008-03-11 15:05:50 +0100541 strcpy(addstr, "Security/Kasumi support");
542 break;
Stefan Roese048f5a62009-07-29 08:45:27 +0200543
544 case PVR_460GT_RB:
Stefan Roese43e1b452010-09-03 13:27:02 +0200545 puts("460GT Rev. B");
Stefan Roese048f5a62009-07-29 08:45:27 +0200546 mfsdr(SDR0_ECID3, reg);
547 if (reg & 0x00100000)
548 strcpy(addstr, "No Security/Kasumi support");
549 else
550 strcpy(addstr, "Security/Kasumi support");
551 break;
552#endif
Stefan Roesecc019d12008-03-11 15:05:50 +0100553
Feng Kan224bc962008-07-08 22:47:31 -0700554 case PVR_460SX_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200555 puts("460SX Rev. A");
Feng Kan224bc962008-07-08 22:47:31 -0700556 strcpy(addstr, "Security support");
557 break;
558
559 case PVR_460SX_RA_V1:
Stefan Roese43e1b452010-09-03 13:27:02 +0200560 puts("460SX Rev. A");
Feng Kan224bc962008-07-08 22:47:31 -0700561 strcpy(addstr, "No Security support");
562 break;
563
564 case PVR_460GX_RA:
Stefan Roese43e1b452010-09-03 13:27:02 +0200565 puts("460GX Rev. A");
Feng Kan224bc962008-07-08 22:47:31 -0700566 strcpy(addstr, "Security support");
567 break;
568
569 case PVR_460GX_RA_V1:
Stefan Roese43e1b452010-09-03 13:27:02 +0200570 puts("460GX Rev. A");
Feng Kan224bc962008-07-08 22:47:31 -0700571 strcpy(addstr, "No Security support");
572 break;
573
Tirumala Marri95ac4282010-09-28 14:15:14 -0700574 case PVR_APM821XX_RA:
575 puts("APM821XX Rev. A");
576 strcpy(addstr, "Security support");
577 break;
578
Ricardo Ribalda Delgado95c50202008-07-17 11:44:12 +0200579 case PVR_VIRTEX5:
Stefan Roese43e1b452010-09-03 13:27:02 +0200580 puts("440x5 VIRTEX5");
Ricardo Ribalda Delgado95c50202008-07-17 11:44:12 +0200581 break;
Stefan Roese43e1b452010-09-03 13:27:02 +0200582#endif /* CONFIG_440 */
Ricardo Ribalda Delgado95c50202008-07-17 11:44:12 +0200583
wdenk57b2d802003-06-27 21:31:46 +0000584 default:
Stefan Roese363330b2005-08-04 17:09:16 +0200585 printf (" UNKNOWN (PVR=%08x)", pvr);
wdenkc6097192002-11-03 00:24:07 +0000586 break;
587 }
Stefan Roese42f2a822005-11-27 19:36:26 +0100588
Stefan Roesee620ff12009-10-19 14:44:11 +0200589 printf (" at %s MHz (PLB=%lu OPB=%lu EBC=%lu",
590 strmhz(buf, clock),
Stefan Roese17ffbc82007-03-21 13:38:59 +0100591 sys_info.freqPLB / 1000000,
592 get_OPB_freq() / 1000000,
Stefan Roese153b3e22007-10-05 17:10:59 +0200593 sys_info.freqEBC / 1000000);
Stefan Roesee620ff12009-10-19 14:44:11 +0200594#if defined(CONFIG_PCI) && \
595 (defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
596 defined(CONFIG_440GR) || defined(CONFIG_440GRX))
597 printf(" PCI=%lu MHz", sys_info.freqPCI / 1000000);
598#endif
599 printf(")\n");
Stefan Roese42f2a822005-11-27 19:36:26 +0100600
Stefan Roese11dd8812006-10-18 15:59:35 +0200601 if (addstr[0] != 0)
602 printf(" %s\n", addstr);
603
Stefan Roese99644742005-11-29 18:18:21 +0100604#if defined(I2C_BOOTROM)
605 printf (" I2C boot EEPROM %sabled\n", i2c_bootrom_enabled() ? "en" : "dis");
Stefan Roese3a75ac12007-04-18 12:05:59 +0200606#endif /* I2C_BOOTROM */
Stefan Roese42fbddd2006-09-07 11:51:23 +0200607#if defined(SDR0_PINSTP_SHIFT)
BenoƮt Monin1a70cf22007-06-04 08:36:05 +0200608 printf (" Bootstrap Option %c - ", bootstrap_char[bootstrap_option()]);
Stefan Roese8ebdb922009-04-15 10:50:48 +0200609 printf ("Boot ROM Location %s", bootstrap_str[bootstrap_option()]);
610#ifdef CONFIG_NAND_U_BOOT
611 puts(", booting from NAND");
612#endif /* CONFIG_NAND_U_BOOT */
613 putc('\n');
Wolfgang Denk65505432006-10-20 17:54:33 +0200614#endif /* SDR0_PINSTP_SHIFT */
Stefan Roese42f2a822005-11-27 19:36:26 +0100615
Stefan Roese153b3e22007-10-05 17:10:59 +0200616#if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
Stefan Roese99644742005-11-29 18:18:21 +0100617 printf (" Internal PCI arbiter %sabled", pci_arbiter_enabled() ? "en" : "dis");
Stefan Roese42f2a822005-11-27 19:36:26 +0100618#endif
619
Stefan Roesef5150122009-05-27 10:34:32 +0200620#if defined(CONFIG_PCI) && defined(PCI_ASYNC)
Stefan Roese99644742005-11-29 18:18:21 +0100621 if (pci_async_enabled()) {
Stefan Roese42f2a822005-11-27 19:36:26 +0100622 printf (", PCI async ext clock used");
623 } else {
624 printf (", PCI sync clock at %lu MHz",
625 sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
626 }
wdenkc6097192002-11-03 00:24:07 +0000627#endif
Stefan Roese42f2a822005-11-27 19:36:26 +0100628
Stefan Roese153b3e22007-10-05 17:10:59 +0200629#if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
Stefan Roese42f2a822005-11-27 19:36:26 +0100630 putc('\n');
631#endif
632
Stefan Roese153b3e22007-10-05 17:10:59 +0200633#if defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX)
Stefan Roese42f2a822005-11-27 19:36:26 +0100634 printf (" 16 kB I-Cache 16 kB D-Cache");
635#elif defined(CONFIG_440)
636 printf (" 32 kB I-Cache 32 kB D-Cache");
637#else
638 printf (" 16 kB I-Cache %d kB D-Cache",
639 ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
640#endif
Stefan Roese42f2a822005-11-27 19:36:26 +0100641
642#endif /* !defined(CONFIG_405) */
643
644 putc ('\n');
wdenkc6097192002-11-03 00:24:07 +0000645
646 return 0;
647}
648
Rafal Jaworowskia2e7ef02006-08-10 12:43:17 +0200649int ppc440spe_revB() {
650 unsigned int pvr;
651
652 pvr = get_pvr();
Stefan Roese1456a772007-01-15 09:46:29 +0100653 if ((pvr == PVR_440SPe_6_RB) || (pvr == PVR_440SPe_RB))
Rafal Jaworowskia2e7ef02006-08-10 12:43:17 +0200654 return 1;
655 else
656 return 0;
657}
wdenkc6097192002-11-03 00:24:07 +0000658
659/* ------------------------------------------------------------------------- */
660
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200661int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenkc6097192002-11-03 00:24:07 +0000662{
Stefan Roeseecf05b22006-11-27 14:48:41 +0100663#if defined(CONFIG_BOARD_RESET)
664 board_reset();
Stefan Roesea5232952006-11-27 14:52:04 +0100665#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200666#if defined(CONFIG_SYS_4xx_RESET_TYPE)
Matthias Fuchs730b2d22009-07-22 17:27:56 +0200667 mtspr(SPRN_DBCR0, CONFIG_SYS_4xx_RESET_TYPE << 28);
Stefan Roese326c9712005-08-01 16:41:48 +0200668#else
wdenk57b2d802003-06-27 21:31:46 +0000669 /*
670 * Initiate system reset in debug control register DBCR
671 */
Matthias Fuchs730b2d22009-07-22 17:27:56 +0200672 mtspr(SPRN_DBCR0, 0x30000000);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200673#endif /* defined(CONFIG_SYS_4xx_RESET_TYPE) */
Stefan Roese03687752006-10-07 11:30:52 +0200674#endif /* defined(CONFIG_BOARD_RESET) */
Stefan Roese326c9712005-08-01 16:41:48 +0200675
wdenkc6097192002-11-03 00:24:07 +0000676 return 1;
677}
wdenkc6097192002-11-03 00:24:07 +0000678
679
680/*
681 * Get timebase clock frequency
682 */
683unsigned long get_tbclk (void)
684{
wdenkc6097192002-11-03 00:24:07 +0000685 sys_info_t sys_info;
686
687 get_sys_info(&sys_info);
688 return (sys_info.freqProcessor);
wdenkc6097192002-11-03 00:24:07 +0000689}
690
691
692#if defined(CONFIG_WATCHDOG)
Stefan Roese6964fd62007-11-09 12:18:54 +0100693void watchdog_reset(void)
wdenkc6097192002-11-03 00:24:07 +0000694{
695 int re_enable = disable_interrupts();
696 reset_4xx_watchdog();
697 if (re_enable) enable_interrupts();
698}
699
Stefan Roese6964fd62007-11-09 12:18:54 +0100700void reset_4xx_watchdog(void)
wdenkc6097192002-11-03 00:24:07 +0000701{
702 /*
703 * Clear TSR(WIS) bit
704 */
Matthias Fuchs730b2d22009-07-22 17:27:56 +0200705 mtspr(SPRN_TSR, 0x40000000);
wdenkc6097192002-11-03 00:24:07 +0000706}
707#endif /* CONFIG_WATCHDOG */
Ben Warren9e37c582008-10-27 23:53:17 -0700708
709/*
710 * Initializes on-chip ethernet controllers.
711 * to override, implement board_eth_init()
712 */
713int cpu_eth_init(bd_t *bis)
714{
715#if defined(CONFIG_PPC4xx_EMAC)
716 ppc_4xx_eth_initialize(bis);
717#endif
718 return 0;
719}