blob: 6c619530f455de32122cd301fdceaa342388ec31 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
wdenk4d816772003-09-03 14:03:26 +00002 * (C) Copyright 2000-2003
wdenkc6097192002-11-03 00:24:07 +00003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
wdenkc6097192002-11-03 00:24:07 +000025 * CPU specific code
26 *
27 * written or collected and sometimes rewritten by
28 * Magnus Damm <damm@bitsmart.com>
29 *
30 * minor modifications by
31 * Wolfgang Denk <wd@denx.de>
32 */
33
34#include <common.h>
35#include <watchdog.h>
36#include <command.h>
37#include <asm/cache.h>
38#include <ppc4xx.h>
39
40
Stefan Roese3d9569b2005-11-27 19:36:26 +010041#if defined(CONFIG_405GP)
42#define PCI_ARBITER_ENABLED (mfdcr(strap) & PSR_PCI_ARBIT_EN)
43#define PCI_ASYNC_ENABLED (mfdcr(strap) & PSR_PCI_ASYNC_EN)
wdenkc6097192002-11-03 00:24:07 +000044#endif
45
Stefan Roese3d9569b2005-11-27 19:36:26 +010046#if defined(CONFIG_405EP)
47#define PCI_ARBITER_ENABLED (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN)
48#define I2C_BOOTROM_ENABLED (mfdcr(cpc0_boot) & CPC0_BOOT_SEP)
49#endif
50
51#if defined(CONFIG_440EP) || defined(CONFIG_440GR)
52#define SDR0_SDSTP1_PAE (0x80000000 >> 21)
53#define SDR0_SDSTP1_PAME (0x80000000 >> 27)
54
55#define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAE)
56#define PCI_ASYNC_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAME)
57#endif
58
59#if defined(CONFIG_440GP)
60#define CPC0_STRP1_PAE (0x80000000 >> 11)
61
62#define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & CPC0_STRP1_PAE)
63#endif
64
65#if defined(CONFIG_440GX)
66#define SDR0_SDSTP1_PAE (0x80000000 >> 13)
67
68#define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAE)
69#endif
70
71#if defined(CONFIG_440)
72#define FREQ_EBC (sys_info.freqEPB)
73#else
74#define FREQ_EBC (sys_info.freqPLB / sys_info.pllExtBusDiv)
75#endif
76
77
78#if defined(CONFIG_440)
79static int do_chip_reset(unsigned long sys0, unsigned long sys1);
80#endif
81
wdenkc6097192002-11-03 00:24:07 +000082
83int checkcpu (void)
84{
Stefan Roese3d9569b2005-11-27 19:36:26 +010085#if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */
wdenkc6097192002-11-03 00:24:07 +000086 DECLARE_GLOBAL_DATA_PTR;
Stefan Roese3d9569b2005-11-27 19:36:26 +010087 uint pvr = get_pvr();
wdenkc6097192002-11-03 00:24:07 +000088 ulong clock = gd->cpu_clk;
89 char buf[32];
wdenkc6097192002-11-03 00:24:07 +000090
Stefan Roese3d9569b2005-11-27 19:36:26 +010091#if !defined(CONFIG_IOP480)
92 sys_info_t sys_info;
wdenkc6097192002-11-03 00:24:07 +000093
94 puts ("CPU: ");
95
96 get_sys_info(&sys_info);
97
Stefan Roese3d9569b2005-11-27 19:36:26 +010098 puts("AMCC PowerPC 4");
99
100#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
101 puts("05");
wdenkc6097192002-11-03 00:24:07 +0000102#endif
Stefan Roese3d9569b2005-11-27 19:36:26 +0100103#if defined(CONFIG_440)
104 puts("40");
wdenkc6097192002-11-03 00:24:07 +0000105#endif
Stefan Roese3d9569b2005-11-27 19:36:26 +0100106
wdenkc6097192002-11-03 00:24:07 +0000107 switch (pvr) {
108 case PVR_405GP_RB:
Stefan Roese3d9569b2005-11-27 19:36:26 +0100109 puts("GP Rev. B");
wdenkc6097192002-11-03 00:24:07 +0000110 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100111
wdenkc6097192002-11-03 00:24:07 +0000112 case PVR_405GP_RC:
Stefan Roese3d9569b2005-11-27 19:36:26 +0100113 puts("GP Rev. C");
wdenkc6097192002-11-03 00:24:07 +0000114 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100115
wdenkc6097192002-11-03 00:24:07 +0000116 case PVR_405GP_RD:
Stefan Roese3d9569b2005-11-27 19:36:26 +0100117 puts("GP Rev. D");
wdenkc6097192002-11-03 00:24:07 +0000118 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100119
wdenk42dfe7a2004-03-14 22:25:36 +0000120#ifdef CONFIG_405GP
Stefan Roese3d9569b2005-11-27 19:36:26 +0100121 case PVR_405GP_RE: /* 405GP rev E and 405CR rev C have same PVR */
122 puts("GP Rev. E");
wdenkc6097192002-11-03 00:24:07 +0000123 break;
124#endif
Stefan Roese3d9569b2005-11-27 19:36:26 +0100125
wdenkc6097192002-11-03 00:24:07 +0000126 case PVR_405CR_RA:
Stefan Roese3d9569b2005-11-27 19:36:26 +0100127 puts("CR Rev. A");
wdenkc6097192002-11-03 00:24:07 +0000128 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100129
wdenkc6097192002-11-03 00:24:07 +0000130 case PVR_405CR_RB:
Stefan Roese3d9569b2005-11-27 19:36:26 +0100131 puts("CR Rev. B");
132 break;
133
134#ifdef CONFIG_405CR
135 case PVR_405CR_RC: /* 405GP rev E and 405CR rev C have same PVR */
136 puts("CR Rev. C");
137 break;
138#endif
139
140 case PVR_405GPR_RB:
141 puts("GPr Rev. B");
142 break;
143
stroeseb867d702003-05-23 11:18:02 +0000144 case PVR_405EP_RB:
Stefan Roese3d9569b2005-11-27 19:36:26 +0100145 puts("EP Rev. B");
wdenkc6097192002-11-03 00:24:07 +0000146 break;
wdenkc6097192002-11-03 00:24:07 +0000147
148#if defined(CONFIG_440)
wdenk8bde7f72003-06-27 21:31:46 +0000149 case PVR_440GP_RB:
Stefan Roesec157d8e2005-08-01 16:41:48 +0200150 puts("GP Rev. B");
wdenk4d816772003-09-03 14:03:26 +0000151 /* See errata 1.12: CHIP_4 */
152 if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) ||
153 (mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){
154 puts ( "\n\t CPC0_SYSx DCRs corrupted. "
155 "Resetting chip ...\n");
156 udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
157 do_chip_reset ( mfdcr(cpc0_strp0),
158 mfdcr(cpc0_strp1) );
159 }
wdenkc6097192002-11-03 00:24:07 +0000160 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100161
wdenk8bde7f72003-06-27 21:31:46 +0000162 case PVR_440GP_RC:
Stefan Roesec157d8e2005-08-01 16:41:48 +0200163 puts("GP Rev. C");
wdenkba56f622004-02-06 23:19:44 +0000164 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100165
wdenkba56f622004-02-06 23:19:44 +0000166 case PVR_440GX_RA:
Stefan Roesec157d8e2005-08-01 16:41:48 +0200167 puts("GX Rev. A");
wdenkba56f622004-02-06 23:19:44 +0000168 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100169
wdenkba56f622004-02-06 23:19:44 +0000170 case PVR_440GX_RB:
Stefan Roesec157d8e2005-08-01 16:41:48 +0200171 puts("GX Rev. B");
wdenkc6097192002-11-03 00:24:07 +0000172 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100173
stroese0a7c5392005-04-07 05:33:41 +0000174 case PVR_440GX_RC:
Stefan Roesec157d8e2005-08-01 16:41:48 +0200175 puts("GX Rev. C");
stroese0a7c5392005-04-07 05:33:41 +0000176 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100177
Stefan Roese57275b62005-11-01 10:08:03 +0100178 case PVR_440GX_RF:
179 puts("GX Rev. F");
180 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100181
Stefan Roesec157d8e2005-08-01 16:41:48 +0200182 case PVR_440EP_RA:
183 puts("EP Rev. A");
184 break;
Stefan Roese3d9569b2005-11-27 19:36:26 +0100185
Stefan Roese9a8d82f2005-10-04 15:00:30 +0200186#ifdef CONFIG_440EP
187 case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
Stefan Roesec157d8e2005-08-01 16:41:48 +0200188 puts("EP Rev. B");
189 break;
Stefan Roese9a8d82f2005-10-04 15:00:30 +0200190#endif /* CONFIG_440EP */
Stefan Roese3d9569b2005-11-27 19:36:26 +0100191
Stefan Roese9a8d82f2005-10-04 15:00:30 +0200192#ifdef CONFIG_440GR
193 case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
194 puts("GR Rev. A");
195 break;
196#endif /* CONFIG_440GR */
Stefan Roese3d9569b2005-11-27 19:36:26 +0100197#endif /* CONFIG_440 */
198
wdenk8bde7f72003-06-27 21:31:46 +0000199 default:
Stefan Roese17f50f222005-08-04 17:09:16 +0200200 printf (" UNKNOWN (PVR=%08x)", pvr);
wdenkc6097192002-11-03 00:24:07 +0000201 break;
202 }
Stefan Roese3d9569b2005-11-27 19:36:26 +0100203
204 printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
205 sys_info.freqPLB / 1000000,
206 sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
207 FREQ_EBC / 1000000);
208
209#if defined(I2C_BOOTROM_ENABLED)
210 printf (" IIC Boot EEPROM %sabled\n", I2C_BOOTROM_ENABLED ? "en" : "dis");
wdenkc6097192002-11-03 00:24:07 +0000211#endif
Stefan Roese3d9569b2005-11-27 19:36:26 +0100212
213#if defined(PCI_ARBITER_ENABLED)
214 printf (" %sternal PCI arbiter enabled",
215 (PCI_ARBITER_ENABLED) ? "In" : "Ex");
216#endif
217
218#if defined(PCI_ASYNC_ENABLED)
219 if (PCI_ASYNC_ENABLED) {
220 printf (", PCI async ext clock used");
221 } else {
222 printf (", PCI sync clock at %lu MHz",
223 sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
224 }
225#endif
226
227#if defined(PCI_ARBITER_ENABLED) || defined(PCI_ASYNC_ENABLED)
228 putc('\n');
229#endif
230
231#if defined(CONFIG_405EP)
232 printf (" 16 kB I-Cache 16 kB D-Cache");
233#elif defined(CONFIG_440)
234 printf (" 32 kB I-Cache 32 kB D-Cache");
235#else
236 printf (" 16 kB I-Cache %d kB D-Cache",
237 ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
238#endif
239#endif /* !defined(CONFIG_IOP480) */
240
241#if defined(CONFIG_IOP480)
242 printf ("PLX IOP480 (PVR=%08x)", pvr);
243 printf (" at %s MHz:", strmhz(buf, clock));
244 printf (" %u kB I-Cache", 4);
245 printf (" %u kB D-Cache", 2);
246#endif
247
248#endif /* !defined(CONFIG_405) */
249
250 putc ('\n');
wdenkc6097192002-11-03 00:24:07 +0000251
252 return 0;
253}
254
255
256/* ------------------------------------------------------------------------- */
257
wdenk8bde7f72003-06-27 21:31:46 +0000258int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
wdenkc6097192002-11-03 00:24:07 +0000259{
Stefan Roesec157d8e2005-08-01 16:41:48 +0200260#if defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)
261 /*give reset to BCSR*/
262 *(unsigned char*)(CFG_BCSR_BASE | 0x06) = 0x09;
263
264#else
265
wdenk8bde7f72003-06-27 21:31:46 +0000266 /*
267 * Initiate system reset in debug control register DBCR
268 */
wdenkc6097192002-11-03 00:24:07 +0000269 __asm__ __volatile__("lis 3, 0x3000" ::: "r3");
270#if defined(CONFIG_440)
271 __asm__ __volatile__("mtspr 0x134, 3");
272#else
273 __asm__ __volatile__("mtspr 0x3f2, 3");
274#endif
Stefan Roesec157d8e2005-08-01 16:41:48 +0200275
276#endif/* defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)*/
wdenkc6097192002-11-03 00:24:07 +0000277 return 1;
278}
279
280#if defined(CONFIG_440)
Stefan Roese3d9569b2005-11-27 19:36:26 +0100281static int do_chip_reset (unsigned long sys0, unsigned long sys1)
wdenkc6097192002-11-03 00:24:07 +0000282{
wdenk4d816772003-09-03 14:03:26 +0000283 /* Changes to cpc0_sys0 and cpc0_sys1 require chip
284 * reset.
285 */
286 mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000); /* Set SWE */
287 mtdcr (cpc0_sys0, sys0);
288 mtdcr (cpc0_sys1, sys1);
289 mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000); /* Clr SWE */
290 mtspr (dbcr0, 0x20000000); /* Reset the chip */
wdenkc6097192002-11-03 00:24:07 +0000291
wdenk4d816772003-09-03 14:03:26 +0000292 return 1;
wdenkc6097192002-11-03 00:24:07 +0000293}
294#endif
295
296
297/*
298 * Get timebase clock frequency
299 */
300unsigned long get_tbclk (void)
301{
Stefan Roese3d9569b2005-11-27 19:36:26 +0100302#if !defined(CONFIG_IOP480)
wdenkc6097192002-11-03 00:24:07 +0000303 sys_info_t sys_info;
304
305 get_sys_info(&sys_info);
306 return (sys_info.freqProcessor);
wdenkc6097192002-11-03 00:24:07 +0000307#else
Stefan Roese3d9569b2005-11-27 19:36:26 +0100308 return (66000000);
wdenkc6097192002-11-03 00:24:07 +0000309#endif
310
311}
312
313
314#if defined(CONFIG_WATCHDOG)
315void
316watchdog_reset(void)
317{
318 int re_enable = disable_interrupts();
319 reset_4xx_watchdog();
320 if (re_enable) enable_interrupts();
321}
322
323void
324reset_4xx_watchdog(void)
325{
326 /*
327 * Clear TSR(WIS) bit
328 */
329 mtspr(tsr, 0x40000000);
330}
331#endif /* CONFIG_WATCHDOG */