2 * (C) Copyright 2000-2007
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
27 * written or collected and sometimes rewritten by
28 * Magnus Damm <damm@bitsmart.com>
30 * minor modifications by
31 * Wolfgang Denk <wd@denx.de>
37 #include <asm/cache.h>
40 #if !defined(CONFIG_405)
41 DECLARE_GLOBAL_DATA_PTR;
44 #if defined(CONFIG_BOARD_RESET)
45 void board_reset(void);
48 #if defined(CONFIG_405GP) || \
49 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
50 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
54 int pci_async_enabled(void)
56 #if defined(CONFIG_405GP)
57 return (mfdcr(strap) & PSR_PCI_ASYNC_EN);
60 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
61 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
64 mfsdr(sdr_sdstp1, val);
65 return (val & SDR0_SDSTP1_PAME_MASK);
70 #if defined(CONFIG_PCI) && !defined(CONFIG_IOP480) && \
71 !defined(CONFIG_405) && !defined(CONFIG_405EX)
72 int pci_arbiter_enabled(void)
74 #if defined(CONFIG_405GP)
75 return (mfdcr(strap) & PSR_PCI_ARBIT_EN);
78 #if defined(CONFIG_405EP)
79 return (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN);
82 #if defined(CONFIG_440GP)
83 return (mfdcr(cpc0_strp1) & CPC0_STRP1_PAE_MASK);
86 #if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
90 return (val & 0x80000000);
92 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
93 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
97 return (val & 0x80000000);
102 #if defined(CONFIG_405EP) || defined(CONFIG_440GX) || \
103 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
104 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
105 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
106 defined(CONFIG_405EX)
110 int i2c_bootrom_enabled(void)
112 #if defined(CONFIG_405EP)
113 return (mfdcr(cpc0_boot) & CPC0_BOOT_SEP);
117 mfsdr(sdr_sdcs, val);
118 return (val & SDR0_SDCS_SDD);
123 #if defined(CONFIG_440GX)
124 #define SDR0_PINSTP_SHIFT 29
125 static char *bootstrap_str[] = {
135 static char bootstrap_char[] = { 'A', 'B', 'C', 'B', 'D', 'E', 'x', 'F' };
138 #if defined(CONFIG_440SP) || defined(CONFIG_440SPE)
139 #define SDR0_PINSTP_SHIFT 30
140 static char *bootstrap_str[] = {
146 static char bootstrap_char[] = { 'A', 'B', 'C', 'D'};
149 #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
150 #define SDR0_PINSTP_SHIFT 29
151 static char *bootstrap_str[] = {
161 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
164 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
165 #define SDR0_PINSTP_SHIFT 29
166 static char *bootstrap_str[] = {
176 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
179 #if defined(CONFIG_405EZ)
180 #define SDR0_PINSTP_SHIFT 28
181 static char *bootstrap_str[] = {
184 "NAND (512 page, 4 addr cycle)",
188 "NAND (2K page, 5 addr cycle)",
192 "NAND (2K page, 4 addr cycle)",
194 "NAND (512 page, 3 addr cycle)",
199 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', \
200 'I', 'x', 'K', 'L', 'M', 'N', 'O', 'P' };
203 #if defined(CONFIG_405EX)
204 #define SDR0_PINSTP_SHIFT 29
205 static char *bootstrap_str[] = {
215 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
218 #if defined(SDR0_PINSTP_SHIFT)
219 static int bootstrap_option(void)
223 mfsdr(SDR_PINSTP, val);
224 return ((val & 0xf0000000) >> SDR0_PINSTP_SHIFT);
226 #endif /* SDR0_PINSTP_SHIFT */
229 #if defined(CONFIG_440)
230 static int do_chip_reset(unsigned long sys0, unsigned long sys1);
236 #if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */
237 uint pvr = get_pvr();
238 ulong clock = gd->cpu_clk;
241 #if !defined(CONFIG_IOP480)
242 char addstr[64] = "";
247 get_sys_info(&sys_info);
249 puts("AMCC PowerPC 4");
251 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
252 defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
253 defined(CONFIG_405EX)
256 #if defined(CONFIG_440)
274 case PVR_405GP_RE: /* 405GP rev E and 405CR rev C have same PVR */
288 case PVR_405CR_RC: /* 405GP rev E and 405CR rev C have same PVR */
307 strcpy(addstr, "Security support");
312 strcpy(addstr, "No Security support");
317 strcpy(addstr, "Security support");
322 strcpy(addstr, "No Security support");
325 #if defined(CONFIG_440)
328 /* See errata 1.12: CHIP_4 */
329 if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) ||
330 (mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){
331 puts ( "\n\t CPC0_SYSx DCRs corrupted. "
332 "Resetting chip ...\n");
333 udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
334 do_chip_reset ( mfdcr(cpc0_strp0),
364 case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
368 case PVR_440EP_RC: /* 440EP rev C and 440GR rev B have same PVR */
371 #endif /* CONFIG_440EP */
374 case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
378 case PVR_440GR_RB: /* 440EP rev C and 440GR rev B have same PVR */
381 #endif /* CONFIG_440GR */
382 #endif /* CONFIG_440 */
385 case PVR_440EPX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
387 strcpy(addstr, "Security/Kasumi support");
390 case PVR_440EPX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
392 strcpy(addstr, "No Security/Kasumi support");
394 #endif /* CONFIG_440EPX */
397 case PVR_440GRX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
399 strcpy(addstr, "Security/Kasumi support");
402 case PVR_440GRX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
404 strcpy(addstr, "No Security/Kasumi support");
406 #endif /* CONFIG_440GRX */
408 case PVR_440SP_6_RAB:
410 strcpy(addstr, "RAID 6 support");
415 strcpy(addstr, "No RAID 6 support");
420 strcpy(addstr, "RAID 6 support");
425 strcpy(addstr, "No RAID 6 support");
428 case PVR_440SPe_6_RA:
430 strcpy(addstr, "RAID 6 support");
435 strcpy(addstr, "No RAID 6 support");
438 case PVR_440SPe_6_RB:
440 strcpy(addstr, "RAID 6 support");
445 strcpy(addstr, "No RAID 6 support");
449 printf (" UNKNOWN (PVR=%08x)", pvr);
453 printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
454 sys_info.freqPLB / 1000000,
455 get_OPB_freq() / 1000000,
456 sys_info.freqEBC / 1000000);
459 printf(" %s\n", addstr);
461 #if defined(I2C_BOOTROM)
462 printf (" I2C boot EEPROM %sabled\n", i2c_bootrom_enabled() ? "en" : "dis");
463 #endif /* I2C_BOOTROM */
464 #if defined(SDR0_PINSTP_SHIFT)
465 printf (" Bootstrap Option %c - ", bootstrap_char[bootstrap_option()]);
466 printf ("Boot ROM Location %s\n", bootstrap_str[bootstrap_option()]);
467 #endif /* SDR0_PINSTP_SHIFT */
469 #if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
470 printf (" Internal PCI arbiter %sabled", pci_arbiter_enabled() ? "en" : "dis");
473 #if defined(PCI_ASYNC)
474 if (pci_async_enabled()) {
475 printf (", PCI async ext clock used");
477 printf (", PCI sync clock at %lu MHz",
478 sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
482 #if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
486 #if defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX)
487 printf (" 16 kB I-Cache 16 kB D-Cache");
488 #elif defined(CONFIG_440)
489 printf (" 32 kB I-Cache 32 kB D-Cache");
491 printf (" 16 kB I-Cache %d kB D-Cache",
492 ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
494 #endif /* !defined(CONFIG_IOP480) */
496 #if defined(CONFIG_IOP480)
497 printf ("PLX IOP480 (PVR=%08x)", pvr);
498 printf (" at %s MHz:", strmhz(buf, clock));
499 printf (" %u kB I-Cache", 4);
500 printf (" %u kB D-Cache", 2);
503 #endif /* !defined(CONFIG_405) */
510 #if defined (CONFIG_440SPE)
511 int ppc440spe_revB() {
515 if ((pvr == PVR_440SPe_6_RB) || (pvr == PVR_440SPe_RB))
522 /* ------------------------------------------------------------------------- */
524 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
526 #if defined(CONFIG_BOARD_RESET)
529 #if defined(CFG_4xx_RESET_TYPE)
530 mtspr(dbcr0, CFG_4xx_RESET_TYPE << 28);
533 * Initiate system reset in debug control register DBCR
535 mtspr(dbcr0, 0x30000000);
536 #endif /* defined(CFG_4xx_RESET_TYPE) */
537 #endif /* defined(CONFIG_BOARD_RESET) */
542 #if defined(CONFIG_440)
543 static int do_chip_reset (unsigned long sys0, unsigned long sys1)
545 /* Changes to cpc0_sys0 and cpc0_sys1 require chip
548 mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000); /* Set SWE */
549 mtdcr (cpc0_sys0, sys0);
550 mtdcr (cpc0_sys1, sys1);
551 mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000); /* Clr SWE */
552 mtspr (dbcr0, 0x20000000); /* Reset the chip */
560 * Get timebase clock frequency
562 unsigned long get_tbclk (void)
564 #if !defined(CONFIG_IOP480)
567 get_sys_info(&sys_info);
568 return (sys_info.freqProcessor);
576 #if defined(CONFIG_WATCHDOG)
580 int re_enable = disable_interrupts();
581 reset_4xx_watchdog();
582 if (re_enable) enable_interrupts();
586 reset_4xx_watchdog(void)
591 mtspr(tsr, 0x40000000);
593 #endif /* CONFIG_WATCHDOG */