2 * (C) Copyright 2000-2006
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_440)
49 #define FREQ_EBC (sys_info.freqEPB)
50 #elif defined(CONFIG_405EZ)
51 #define FREQ_EBC ((CONFIG_SYS_CLK_FREQ * sys_info.pllFbkDiv) / \
52 sys_info.pllExtBusDiv)
54 #define FREQ_EBC (sys_info.freqPLB / sys_info.pllExtBusDiv)
57 #if defined(CONFIG_405GP) || \
58 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
59 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
63 int pci_async_enabled(void)
65 #if defined(CONFIG_405GP)
66 return (mfdcr(strap) & PSR_PCI_ASYNC_EN);
69 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
70 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
73 mfsdr(sdr_sdstp1, val);
74 return (val & SDR0_SDSTP1_PAME_MASK);
79 #if defined(CONFIG_PCI) && !defined(CONFIG_IOP480) && !defined(CONFIG_405)
80 int pci_arbiter_enabled(void)
82 #if defined(CONFIG_405GP)
83 return (mfdcr(strap) & PSR_PCI_ARBIT_EN);
86 #if defined(CONFIG_405EP)
87 return (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN);
90 #if defined(CONFIG_440GP)
91 return (mfdcr(cpc0_strp1) & CPC0_STRP1_PAE_MASK);
94 #if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
98 return (val & 0x80000000);
100 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
101 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
104 mfsdr(sdr_pci0, val);
105 return (val & 0x80000000);
110 #if defined(CONFIG_405EP) || defined(CONFIG_440GX) || \
111 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
112 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
113 defined(CONFIG_440SP) || defined(CONFIG_440SPE)
117 int i2c_bootrom_enabled(void)
119 #if defined(CONFIG_405EP)
120 return (mfdcr(cpc0_boot) & CPC0_BOOT_SEP);
124 mfsdr(sdr_sdcs, val);
125 return (val & SDR0_SDCS_SDD);
129 #if defined(CONFIG_440GX)
130 #define SDR0_PINSTP_SHIFT 29
131 static char *bootstrap_str[] = {
143 #if defined(CONFIG_440SP) || defined(CONFIG_440SPE)
144 #define SDR0_PINSTP_SHIFT 30
145 static char *bootstrap_str[] = {
153 #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
154 #define SDR0_PINSTP_SHIFT 29
155 static char *bootstrap_str[] = {
167 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
168 #define SDR0_PINSTP_SHIFT 29
169 static char *bootstrap_str[] = {
181 #if defined(SDR0_PINSTP_SHIFT)
182 static int bootstrap_option(void)
186 mfsdr(sdr_pinstp, val);
187 return ((val & 0xe0000000) >> SDR0_PINSTP_SHIFT);
189 #endif /* SDR0_PINSTP_SHIFT */
193 #if defined(CONFIG_440)
194 static int do_chip_reset(unsigned long sys0, unsigned long sys1);
200 #if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */
201 uint pvr = get_pvr();
202 ulong clock = gd->cpu_clk;
205 #if !defined(CONFIG_IOP480)
206 char addstr[64] = "";
211 get_sys_info(&sys_info);
213 puts("AMCC PowerPC 4");
215 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
216 defined(CONFIG_405EP) || defined(CONFIG_405EZ)
219 #if defined(CONFIG_440)
237 case PVR_405GP_RE: /* 405GP rev E and 405CR rev C have same PVR */
251 case PVR_405CR_RC: /* 405GP rev E and 405CR rev C have same PVR */
268 #if defined(CONFIG_440)
271 /* See errata 1.12: CHIP_4 */
272 if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) ||
273 (mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){
274 puts ( "\n\t CPC0_SYSx DCRs corrupted. "
275 "Resetting chip ...\n");
276 udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
277 do_chip_reset ( mfdcr(cpc0_strp0),
307 case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
311 case PVR_440EP_RC: /* 440EP rev C and 440GR rev B have same PVR */
314 #endif /* CONFIG_440EP */
317 case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
321 case PVR_440GR_RB: /* 440EP rev C and 440GR rev B have same PVR */
324 #endif /* CONFIG_440GR */
325 #endif /* CONFIG_440 */
328 case PVR_440EPX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
330 strcpy(addstr, "Security/Kasumi support");
333 case PVR_440EPX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
335 strcpy(addstr, "No Security/Kasumi support");
337 #endif /* CONFIG_440EPX */
340 case PVR_440GRX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
342 strcpy(addstr, "Security/Kasumi support");
345 case PVR_440GRX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
347 strcpy(addstr, "No Security/Kasumi support");
349 #endif /* CONFIG_440GRX */
351 case PVR_440SP_6_RAB:
353 strcpy(addstr, "RAID 6 support");
358 strcpy(addstr, "No RAID 6 support");
363 strcpy(addstr, "RAID 6 support");
368 strcpy(addstr, "No RAID 6 support");
371 case PVR_440SPe_6_RA:
373 strcpy(addstr, "RAID 6 support");
378 strcpy(addstr, "No RAID 6 support");
381 case PVR_440SPe_6_RB:
383 strcpy(addstr, "RAID 6 support");
388 strcpy(addstr, "No RAID 6 support");
392 printf (" UNKNOWN (PVR=%08x)", pvr);
396 printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
397 sys_info.freqPLB / 1000000,
398 get_OPB_freq() / 1000000,
402 printf(" %s\n", addstr);
404 #if defined(I2C_BOOTROM)
405 printf (" I2C boot EEPROM %sabled\n", i2c_bootrom_enabled() ? "en" : "dis");
406 #if defined(SDR0_PINSTP_SHIFT)
407 printf (" Bootstrap Option %c - ", (char)bootstrap_option() + 'A');
408 printf ("Boot ROM Location %s\n", bootstrap_str[bootstrap_option()]);
409 #endif /* SDR0_PINSTP_SHIFT */
410 #endif /* I2C_BOOTROM */
412 #if defined(CONFIG_PCI)
413 printf (" Internal PCI arbiter %sabled", pci_arbiter_enabled() ? "en" : "dis");
416 #if defined(PCI_ASYNC)
417 if (pci_async_enabled()) {
418 printf (", PCI async ext clock used");
420 printf (", PCI sync clock at %lu MHz",
421 sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
425 #if defined(CONFIG_PCI)
429 #if defined(CONFIG_405EP) || defined(CONFIG_405EZ)
430 printf (" 16 kB I-Cache 16 kB D-Cache");
431 #elif defined(CONFIG_440)
432 printf (" 32 kB I-Cache 32 kB D-Cache");
434 printf (" 16 kB I-Cache %d kB D-Cache",
435 ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
437 #endif /* !defined(CONFIG_IOP480) */
439 #if defined(CONFIG_IOP480)
440 printf ("PLX IOP480 (PVR=%08x)", pvr);
441 printf (" at %s MHz:", strmhz(buf, clock));
442 printf (" %u kB I-Cache", 4);
443 printf (" %u kB D-Cache", 2);
446 #endif /* !defined(CONFIG_405) */
453 #if defined (CONFIG_440SPE)
454 int ppc440spe_revB() {
458 if ((pvr == PVR_440SPe_6_RB) || (pvr == PVR_440SPe_RB))
465 /* ------------------------------------------------------------------------- */
467 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
469 #if defined(CONFIG_BOARD_RESET)
472 #if defined(CFG_4xx_RESET_TYPE)
473 mtspr(dbcr0, CFG_4xx_RESET_TYPE << 28);
476 * Initiate system reset in debug control register DBCR
478 mtspr(dbcr0, 0x30000000);
479 #endif /* defined(CFG_4xx_RESET_TYPE) */
480 #endif /* defined(CONFIG_BOARD_RESET) */
485 #if defined(CONFIG_440)
486 static int do_chip_reset (unsigned long sys0, unsigned long sys1)
488 /* Changes to cpc0_sys0 and cpc0_sys1 require chip
491 mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000); /* Set SWE */
492 mtdcr (cpc0_sys0, sys0);
493 mtdcr (cpc0_sys1, sys1);
494 mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000); /* Clr SWE */
495 mtspr (dbcr0, 0x20000000); /* Reset the chip */
503 * Get timebase clock frequency
505 unsigned long get_tbclk (void)
507 #if !defined(CONFIG_IOP480)
510 get_sys_info(&sys_info);
511 return (sys_info.freqProcessor);
519 #if defined(CONFIG_WATCHDOG)
523 int re_enable = disable_interrupts();
524 reset_4xx_watchdog();
525 if (re_enable) enable_interrupts();
529 reset_4xx_watchdog(void)
534 mtspr(tsr, 0x40000000);
536 #endif /* CONFIG_WATCHDOG */