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>
38 #include <asm/ppc4xx.h>
41 DECLARE_GLOBAL_DATA_PTR;
43 void board_reset(void);
46 * To provide an interface to detect CPU number for boards that support
47 * more then one CPU, we implement the "weak" default functions here.
51 int __get_cpu_num(void)
53 return NA_OR_UNKNOWN_CPU;
55 int get_cpu_num(void) __attribute__((weak, alias("__get_cpu_num")));
57 #if defined(CONFIG_PCI)
58 #if defined(CONFIG_405GP) || \
59 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
60 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
64 static int pci_async_enabled(void)
66 #if defined(CONFIG_405GP)
67 return (mfdcr(CPC0_PSR) & PSR_PCI_ASYNC_EN);
70 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
71 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
72 defined(CONFIG_460EX) || defined(CONFIG_460GT)
75 mfsdr(SDR0_SDSTP1, val);
76 return (val & SDR0_SDSTP1_PAME_MASK);
80 #endif /* CONFIG_PCI */
82 #if defined(CONFIG_PCI) && \
83 !defined(CONFIG_405) && !defined(CONFIG_405EX)
84 int pci_arbiter_enabled(void)
86 #if defined(CONFIG_405GP)
87 return (mfdcr(CPC0_PSR) & PSR_PCI_ARBIT_EN);
90 #if defined(CONFIG_405EP)
91 return (mfdcr(CPC0_PCI) & CPC0_PCI_ARBIT_EN);
94 #if defined(CONFIG_440GP)
95 return (mfdcr(CPC0_STRP1) & CPC0_STRP1_PAE_MASK);
98 #if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
101 mfsdr(SDR0_XCR0, val);
102 return (val & SDR0_XCR0_PAE_MASK);
104 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
105 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
106 defined(CONFIG_460EX) || defined(CONFIG_460GT)
109 mfsdr(SDR0_PCI0, val);
110 return (val & SDR0_PCI0_PAE_MASK);
115 #if defined(CONFIG_405EP)
118 static int i2c_bootrom_enabled(void)
120 #if defined(CONFIG_405EP)
121 return (mfdcr(CPC0_BOOT) & CPC0_BOOT_SEP);
125 mfsdr(SDR0_SDCS0, val);
126 return (val & SDR0_SDCS_SDD);
131 #if defined(CONFIG_440GX)
132 #define SDR0_PINSTP_SHIFT 29
133 static char *bootstrap_str[] = {
143 static char bootstrap_char[] = { 'A', 'B', 'C', 'B', 'D', 'E', 'x', 'F' };
146 #if defined(CONFIG_440SP) || defined(CONFIG_440SPE)
147 #define SDR0_PINSTP_SHIFT 30
148 static char *bootstrap_str[] = {
154 static char bootstrap_char[] = { 'A', 'B', 'C', 'D'};
157 #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
158 #define SDR0_PINSTP_SHIFT 29
159 static char *bootstrap_str[] = {
169 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
172 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
173 #define SDR0_PINSTP_SHIFT 29
174 static char *bootstrap_str[] = {
184 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
187 #if defined(CONFIG_460EX) || defined(CONFIG_460GT)
188 #define SDR0_PINSTP_SHIFT 29
189 static char *bootstrap_str[] = {
196 "I2C (Addr 0x54)", /* A8 */
197 "I2C (Addr 0x52)", /* A4 */
199 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
202 #if defined(CONFIG_460SX)
203 #define SDR0_PINSTP_SHIFT 29
204 static char *bootstrap_str[] = {
209 "I2C (Addr 0x54)", /* A8 */
210 "I2C (Addr 0x52)", /* A4 */
212 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G' };
215 #if defined(CONFIG_405EZ)
216 #define SDR0_PINSTP_SHIFT 28
217 static char *bootstrap_str[] = {
220 "NAND (512 page, 4 addr cycle)",
224 "NAND (2K page, 5 addr cycle)",
228 "NAND (2K page, 4 addr cycle)",
230 "NAND (512 page, 3 addr cycle)",
235 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', \
236 'I', 'x', 'K', 'L', 'M', 'N', 'O', 'P' };
239 #if defined(CONFIG_405EX)
240 #define SDR0_PINSTP_SHIFT 29
241 static char *bootstrap_str[] = {
251 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
253 #if defined(CONFIG_APM821XX)
254 #define SDR0_PINSTP_SHIFT 29
255 static char *bootstrap_str[] = {
261 "NOR (8 bits) w/PLL Bypassed",
265 static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
268 #if defined(SDR0_PINSTP_SHIFT)
269 static int bootstrap_option(void)
273 mfsdr(SDR0_PINSTP, val);
274 return ((val & 0xf0000000) >> SDR0_PINSTP_SHIFT);
276 #endif /* SDR0_PINSTP_SHIFT */
279 #if defined(CONFIG_440GP)
280 static int do_chip_reset (unsigned long sys0, unsigned long sys1)
282 /* Changes to CPC0_SYS0 and CPC0_SYS1 require chip
285 mtdcr (CPC0_CR0, mfdcr (CPC0_CR0) | 0x80000000); /* Set SWE */
286 mtdcr (CPC0_SYS0, sys0);
287 mtdcr (CPC0_SYS1, sys1);
288 mtdcr (CPC0_CR0, mfdcr (CPC0_CR0) & ~0x80000000); /* Clr SWE */
289 mtspr (SPRN_DBCR0, 0x20000000); /* Reset the chip */
293 #endif /* CONFIG_440GP */
298 #if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */
299 uint pvr = get_pvr();
300 ulong clock = gd->cpu_clk;
302 #if defined(CONFIG_460EX) || defined(CONFIG_460GT)
306 char addstr[64] = "";
310 cpu_num = get_cpu_num();
312 printf("CPU%d: ", cpu_num);
316 get_sys_info(&sys_info);
318 #if defined(CONFIG_XILINX_440)
319 puts("IBM PowerPC ");
321 puts("AMCC PowerPC ");
326 #if !defined(CONFIG_440)
328 puts("405GP Rev. B");
332 puts("405GP Rev. C");
336 puts("405GP Rev. D");
340 case PVR_405GP_RE: /* 405GP rev E and 405CR rev C have same PVR */
341 puts("405GP Rev. E");
346 puts("405CR Rev. A");
350 puts("405CR Rev. B");
354 case PVR_405CR_RC: /* 405GP rev E and 405CR rev C have same PVR */
355 puts("405CR Rev. C");
360 puts("405GPr Rev. B");
364 puts("405EP Rev. B");
368 puts("405EZ Rev. A");
372 puts("405EX Rev. A");
373 strcpy(addstr, "Security support");
377 puts("405EXr Rev. A");
378 strcpy(addstr, "No Security support");
382 puts("405EX Rev. C");
383 strcpy(addstr, "Security support");
387 puts("405EX Rev. C");
388 strcpy(addstr, "No Security support");
392 puts("405EXr Rev. C");
393 strcpy(addstr, "Security support");
397 puts("405EXr Rev. C");
398 strcpy(addstr, "No Security support");
402 puts("405EX Rev. D");
403 strcpy(addstr, "Security support");
407 puts("405EX Rev. D");
408 strcpy(addstr, "No Security support");
412 puts("405EXr Rev. D");
413 strcpy(addstr, "Security support");
417 puts("405EXr Rev. D");
418 strcpy(addstr, "No Security support");
421 #else /* CONFIG_440 */
423 #if defined(CONFIG_440GP)
425 puts("440GP Rev. B");
426 /* See errata 1.12: CHIP_4 */
427 if ((mfdcr(CPC0_SYS0) != mfdcr(CPC0_STRP0)) ||
428 (mfdcr(CPC0_SYS1) != mfdcr(CPC0_STRP1)) ){
429 puts ( "\n\t CPC0_SYSx DCRs corrupted. "
430 "Resetting chip ...\n");
431 udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
432 do_chip_reset ( mfdcr(CPC0_STRP0),
438 puts("440GP Rev. C");
440 #endif /* CONFIG_440GP */
443 puts("440GX Rev. A");
447 puts("440GX Rev. B");
451 puts("440GX Rev. C");
455 puts("440GX Rev. F");
459 puts("440EP Rev. A");
463 case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
464 puts("440EP Rev. B");
467 case PVR_440EP_RC: /* 440EP rev C and 440GR rev B have same PVR */
468 puts("440EP Rev. C");
470 #endif /* CONFIG_440EP */
473 case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
474 puts("440GR Rev. A");
477 case PVR_440GR_RB: /* 440EP rev C and 440GR rev B have same PVR */
478 puts("440GR Rev. B");
480 #endif /* CONFIG_440GR */
483 case PVR_440EPX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
484 puts("440EPx Rev. A");
485 strcpy(addstr, "Security/Kasumi support");
488 case PVR_440EPX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
489 puts("440EPx Rev. A");
490 strcpy(addstr, "No Security/Kasumi support");
492 #endif /* CONFIG_440EPX */
495 case PVR_440GRX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
496 puts("440GRx Rev. A");
497 strcpy(addstr, "Security/Kasumi support");
500 case PVR_440GRX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
501 puts("440GRx Rev. A");
502 strcpy(addstr, "No Security/Kasumi support");
504 #endif /* CONFIG_440GRX */
506 case PVR_440SP_6_RAB:
507 puts("440SP Rev. A/B");
508 strcpy(addstr, "RAID 6 support");
512 puts("440SP Rev. A/B");
513 strcpy(addstr, "No RAID 6 support");
517 puts("440SP Rev. C");
518 strcpy(addstr, "RAID 6 support");
522 puts("440SP Rev. C");
523 strcpy(addstr, "No RAID 6 support");
526 case PVR_440SPe_6_RA:
527 puts("440SPe Rev. A");
528 strcpy(addstr, "RAID 6 support");
532 puts("440SPe Rev. A");
533 strcpy(addstr, "No RAID 6 support");
536 case PVR_440SPe_6_RB:
537 puts("440SPe Rev. B");
538 strcpy(addstr, "RAID 6 support");
542 puts("440SPe Rev. B");
543 strcpy(addstr, "No RAID 6 support");
546 #if defined(CONFIG_460EX) || defined(CONFIG_460GT)
548 puts("460EX Rev. A");
549 strcpy(addstr, "No Security/Kasumi support");
552 case PVR_460EX_SE_RA:
553 puts("460EX Rev. A");
554 strcpy(addstr, "Security/Kasumi support");
558 puts("460EX Rev. B");
559 mfsdr(SDR0_ECID3, reg);
560 if (reg & 0x00100000)
561 strcpy(addstr, "No Security/Kasumi support");
563 strcpy(addstr, "Security/Kasumi support");
567 puts("460GT Rev. A");
568 strcpy(addstr, "No Security/Kasumi support");
571 case PVR_460GT_SE_RA:
572 puts("460GT Rev. A");
573 strcpy(addstr, "Security/Kasumi support");
577 puts("460GT Rev. B");
578 mfsdr(SDR0_ECID3, reg);
579 if (reg & 0x00100000)
580 strcpy(addstr, "No Security/Kasumi support");
582 strcpy(addstr, "Security/Kasumi support");
587 puts("460SX Rev. A");
588 strcpy(addstr, "Security support");
591 case PVR_460SX_RA_V1:
592 puts("460SX Rev. A");
593 strcpy(addstr, "No Security support");
597 puts("460GX Rev. A");
598 strcpy(addstr, "Security support");
601 case PVR_460GX_RA_V1:
602 puts("460GX Rev. A");
603 strcpy(addstr, "No Security support");
606 case PVR_APM821XX_RA:
607 puts("APM821XX Rev. A");
608 strcpy(addstr, "Security support");
612 puts("440x5 VIRTEX5");
614 #endif /* CONFIG_440 */
617 printf (" UNKNOWN (PVR=%08x)", pvr);
621 printf (" at %s MHz (PLB=%lu OPB=%lu EBC=%lu",
623 sys_info.freqPLB / 1000000,
624 get_OPB_freq() / 1000000,
625 sys_info.freqEBC / 1000000);
626 #if defined(CONFIG_PCI) && \
627 (defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
628 defined(CONFIG_440GR) || defined(CONFIG_440GRX))
629 printf(" PCI=%lu MHz", sys_info.freqPCI / 1000000);
634 printf(" %s\n", addstr);
636 #if defined(I2C_BOOTROM)
637 printf (" I2C boot EEPROM %sabled\n", i2c_bootrom_enabled() ? "en" : "dis");
638 #endif /* I2C_BOOTROM */
639 #if defined(SDR0_PINSTP_SHIFT)
640 printf (" Bootstrap Option %c - ", bootstrap_char[bootstrap_option()]);
641 printf ("Boot ROM Location %s", bootstrap_str[bootstrap_option()]);
642 #ifdef CONFIG_NAND_U_BOOT
643 puts(", booting from NAND");
644 #endif /* CONFIG_NAND_U_BOOT */
646 #endif /* SDR0_PINSTP_SHIFT */
648 #if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
649 printf (" Internal PCI arbiter %sabled", pci_arbiter_enabled() ? "en" : "dis");
652 #if defined(CONFIG_PCI) && defined(PCI_ASYNC)
653 if (pci_async_enabled()) {
654 printf (", PCI async ext clock used");
656 printf (", PCI sync clock at %lu MHz",
657 sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
661 #if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
665 #if defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX)
666 printf (" 16 kB I-Cache 16 kB D-Cache");
667 #elif defined(CONFIG_440)
668 printf (" 32 kB I-Cache 32 kB D-Cache");
670 printf (" 16 kB I-Cache %d kB D-Cache",
671 ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
674 #endif /* !defined(CONFIG_405) */
681 int ppc440spe_revB() {
685 if ((pvr == PVR_440SPe_6_RB) || (pvr == PVR_440SPe_RB))
691 /* ------------------------------------------------------------------------- */
693 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
695 #if defined(CONFIG_BOARD_RESET)
698 #if defined(CONFIG_SYS_4xx_RESET_TYPE)
699 mtspr(SPRN_DBCR0, CONFIG_SYS_4xx_RESET_TYPE << 28);
702 * Initiate system reset in debug control register DBCR
704 mtspr(SPRN_DBCR0, 0x30000000);
705 #endif /* defined(CONFIG_SYS_4xx_RESET_TYPE) */
706 #endif /* defined(CONFIG_BOARD_RESET) */
713 * Get timebase clock frequency
715 unsigned long get_tbclk (void)
719 get_sys_info(&sys_info);
720 return (sys_info.freqProcessor);
724 #if defined(CONFIG_WATCHDOG)
725 void watchdog_reset(void)
727 int re_enable = disable_interrupts();
728 reset_4xx_watchdog();
729 if (re_enable) enable_interrupts();
732 void reset_4xx_watchdog(void)
737 mtspr(SPRN_TSR, 0x40000000);
739 #endif /* CONFIG_WATCHDOG */
742 * Initializes on-chip ethernet controllers.
743 * to override, implement board_eth_init()
745 int cpu_eth_init(bd_t *bis)
747 #if defined(CONFIG_PPC4xx_EMAC)
748 ppc_4xx_eth_initialize(bis);