2002-11-03 00:24:07 +00:00
|
|
|
/*
|
2003-09-03 14:03:26 +00:00
|
|
|
* (C) Copyright 2000-2003
|
2002-11-03 00:24:07 +00:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CPU specific code
|
|
|
|
*
|
|
|
|
* written or collected and sometimes rewritten by
|
|
|
|
* Magnus Damm <damm@bitsmart.com>
|
|
|
|
*
|
|
|
|
* minor modifications by
|
|
|
|
* Wolfgang Denk <wd@denx.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <watchdog.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <asm/cache.h>
|
|
|
|
#include <ppc4xx.h>
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
#if !defined(CONFIG_405)
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
#endif
|
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#if defined(CONFIG_440)
|
|
|
|
#define FREQ_EBC (sys_info.freqEPB)
|
|
|
|
#else
|
|
|
|
#define FREQ_EBC (sys_info.freqPLB / sys_info.pllExtBusDiv)
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#if defined(CONFIG_405GP) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
|
|
|
|
|
|
|
|
#define PCI_ASYNC
|
|
|
|
|
|
|
|
int pci_async_enabled(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_405GP)
|
|
|
|
return (mfdcr(strap) & PSR_PCI_ASYNC_EN);
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_440EP) || defined(CONFIG_440GR)
|
2005-11-29 17:18:21 +00:00
|
|
|
unsigned long val;
|
|
|
|
|
2005-12-12 15:06:05 +00:00
|
|
|
mfsdr(sdr_sdstp1, val);
|
2005-11-29 17:18:21 +00:00
|
|
|
return (val & SDR0_SDSTP1_PAME_MASK);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-11-29 18:13:38 +00:00
|
|
|
#if defined(CONFIG_PCI) && !defined(CONFIG_IOP480) && !defined(CONFIG_405)
|
2005-11-29 17:18:21 +00:00
|
|
|
int pci_arbiter_enabled(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_405GP)
|
|
|
|
return (mfdcr(strap) & PSR_PCI_ARBIT_EN);
|
|
|
|
#endif
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#if defined(CONFIG_405EP)
|
|
|
|
return (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN);
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_440GP)
|
2005-11-29 17:18:21 +00:00
|
|
|
return (mfdcr(cpc0_strp1) & CPC0_STRP1_PAE_MASK);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_440GX) || defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_440SP)
|
|
|
|
unsigned long val;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
mfsdr(sdr_sdstp1, val);
|
|
|
|
return (val & SDR0_SDSTP1_PAE_MASK);
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif
|
2005-11-29 17:18:21 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_405EP)|| defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
|
|
|
|
defined(CONFIG_440GX) || defined(CONFIG_440SP)
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#define I2C_BOOTROM
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
int i2c_bootrom_enabled(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_405EP)
|
|
|
|
return (mfdcr(cpc0_boot) & CPC0_BOOT_SEP);
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#if defined(CONFIG_440GX) || defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_440SP)
|
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
mfsdr(sdr_sdcs, val);
|
|
|
|
return (val & SDR0_SDCS_SDD);
|
|
|
|
#endif
|
|
|
|
}
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
#if defined(CONFIG_440)
|
2005-11-27 18:36:26 +00:00
|
|
|
static int do_chip_reset(unsigned long sys0, unsigned long sys1);
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int checkcpu (void)
|
|
|
|
{
|
2005-11-27 18:36:26 +00:00
|
|
|
#if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */
|
|
|
|
uint pvr = get_pvr();
|
2002-11-03 00:24:07 +00:00
|
|
|
ulong clock = gd->cpu_clk;
|
|
|
|
char buf[32];
|
|
|
|
|
2005-11-27 18:36:26 +00:00
|
|
|
#if !defined(CONFIG_IOP480)
|
|
|
|
sys_info_t sys_info;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
puts ("CPU: ");
|
|
|
|
|
|
|
|
get_sys_info(&sys_info);
|
|
|
|
|
2005-11-27 18:36:26 +00:00
|
|
|
puts("AMCC PowerPC 4");
|
|
|
|
|
|
|
|
#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
|
|
|
|
puts("05");
|
2003-05-23 11:18:02 +00:00
|
|
|
#endif
|
2005-11-27 18:36:26 +00:00
|
|
|
#if defined(CONFIG_440)
|
|
|
|
puts("40");
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
switch (pvr) {
|
|
|
|
case PVR_405GP_RB:
|
2005-11-27 18:36:26 +00:00
|
|
|
puts("GP Rev. B");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
case PVR_405GP_RC:
|
2005-11-27 18:36:26 +00:00
|
|
|
puts("GP Rev. C");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
case PVR_405GP_RD:
|
2005-11-27 18:36:26 +00:00
|
|
|
puts("GP Rev. D");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2004-03-14 22:25:36 +00:00
|
|
|
#ifdef CONFIG_405GP
|
2005-11-27 18:36:26 +00:00
|
|
|
case PVR_405GP_RE: /* 405GP rev E and 405CR rev C have same PVR */
|
|
|
|
puts("GP Rev. E");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
case PVR_405CR_RA:
|
2005-11-27 18:36:26 +00:00
|
|
|
puts("CR Rev. A");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
case PVR_405CR_RB:
|
2005-11-27 18:36:26 +00:00
|
|
|
puts("CR Rev. B");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
|
2005-11-27 18:36:26 +00:00
|
|
|
#ifdef CONFIG_405CR
|
|
|
|
case PVR_405CR_RC: /* 405GP rev E and 405CR rev C have same PVR */
|
|
|
|
puts("CR Rev. C");
|
|
|
|
break;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-27 18:36:26 +00:00
|
|
|
case PVR_405GPR_RB:
|
|
|
|
puts("GPr Rev. B");
|
|
|
|
break;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2005-11-27 18:36:26 +00:00
|
|
|
case PVR_405EP_RB:
|
|
|
|
puts("EP Rev. B");
|
|
|
|
break;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_440)
|
2003-06-27 21:31:46 +00:00
|
|
|
case PVR_440GP_RB:
|
2005-08-01 14:41:48 +00:00
|
|
|
puts("GP Rev. B");
|
2003-09-03 14:03:26 +00:00
|
|
|
/* See errata 1.12: CHIP_4 */
|
|
|
|
if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) ||
|
|
|
|
(mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){
|
|
|
|
puts ( "\n\t CPC0_SYSx DCRs corrupted. "
|
|
|
|
"Resetting chip ...\n");
|
|
|
|
udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
|
|
|
|
do_chip_reset ( mfdcr(cpc0_strp0),
|
|
|
|
mfdcr(cpc0_strp1) );
|
|
|
|
}
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
case PVR_440GP_RC:
|
2005-08-01 14:41:48 +00:00
|
|
|
puts("GP Rev. C");
|
2004-02-06 23:19:44 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2004-02-06 23:19:44 +00:00
|
|
|
case PVR_440GX_RA:
|
2005-08-01 14:41:48 +00:00
|
|
|
puts("GX Rev. A");
|
2004-02-06 23:19:44 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2004-02-06 23:19:44 +00:00
|
|
|
case PVR_440GX_RB:
|
2005-08-01 14:41:48 +00:00
|
|
|
puts("GX Rev. B");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-04-07 05:33:41 +00:00
|
|
|
case PVR_440GX_RC:
|
2005-08-01 14:41:48 +00:00
|
|
|
puts("GX Rev. C");
|
2005-04-07 05:33:41 +00:00
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-11-01 09:08:03 +00:00
|
|
|
case PVR_440GX_RF:
|
|
|
|
puts("GX Rev. F");
|
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-08-01 14:41:48 +00:00
|
|
|
case PVR_440EP_RA:
|
|
|
|
puts("EP Rev. A");
|
|
|
|
break;
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-10-04 13:00:30 +00:00
|
|
|
#ifdef CONFIG_440EP
|
|
|
|
case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
|
2005-08-01 14:41:48 +00:00
|
|
|
puts("EP Rev. B");
|
|
|
|
break;
|
2005-10-04 13:00:30 +00:00
|
|
|
#endif /* CONFIG_440EP */
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-10-04 13:00:30 +00:00
|
|
|
#ifdef CONFIG_440GR
|
|
|
|
case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
|
|
|
|
puts("GR Rev. A");
|
|
|
|
break;
|
|
|
|
#endif /* CONFIG_440GR */
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif /* CONFIG_440 */
|
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
case PVR_440SP_RA:
|
|
|
|
puts("SP Rev. A");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PVR_440SP_RB:
|
|
|
|
puts("SP Rev. B");
|
|
|
|
break;
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
default:
|
2005-08-04 15:09:16 +00:00
|
|
|
printf (" UNKNOWN (PVR=%08x)", pvr);
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-11-27 18:36:26 +00:00
|
|
|
|
|
|
|
printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
|
|
|
|
sys_info.freqPLB / 1000000,
|
|
|
|
sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
|
|
|
|
FREQ_EBC / 1000000);
|
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#if defined(I2C_BOOTROM)
|
|
|
|
printf (" I2C boot EEPROM %sabled\n", i2c_bootrom_enabled() ? "en" : "dis");
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#if defined(CONFIG_PCI)
|
|
|
|
printf (" Internal PCI arbiter %sabled", pci_arbiter_enabled() ? "en" : "dis");
|
2005-11-27 18:36:26 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#if defined(PCI_ASYNC)
|
|
|
|
if (pci_async_enabled()) {
|
2005-11-27 18:36:26 +00:00
|
|
|
printf (", PCI async ext clock used");
|
|
|
|
} else {
|
|
|
|
printf (", PCI sync clock at %lu MHz",
|
|
|
|
sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
|
|
|
|
}
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
2005-11-27 18:36:26 +00:00
|
|
|
|
2005-11-29 17:18:21 +00:00
|
|
|
#if defined(CONFIG_PCI)
|
2005-11-27 18:36:26 +00:00
|
|
|
putc('\n');
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_405EP)
|
|
|
|
printf (" 16 kB I-Cache 16 kB D-Cache");
|
|
|
|
#elif defined(CONFIG_440)
|
|
|
|
printf (" 32 kB I-Cache 32 kB D-Cache");
|
|
|
|
#else
|
|
|
|
printf (" 16 kB I-Cache %d kB D-Cache",
|
|
|
|
((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
|
|
|
|
#endif
|
|
|
|
#endif /* !defined(CONFIG_IOP480) */
|
|
|
|
|
|
|
|
#if defined(CONFIG_IOP480)
|
|
|
|
printf ("PLX IOP480 (PVR=%08x)", pvr);
|
|
|
|
printf (" at %s MHz:", strmhz(buf, clock));
|
|
|
|
printf (" %u kB I-Cache", 4);
|
|
|
|
printf (" %u kB D-Cache", 2);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* !defined(CONFIG_405) */
|
|
|
|
|
|
|
|
putc ('\n');
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
2005-08-01 14:41:48 +00:00
|
|
|
#if defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)
|
|
|
|
/*give reset to BCSR*/
|
|
|
|
*(unsigned char*)(CFG_BCSR_BASE | 0x06) = 0x09;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
|
|
|
* Initiate system reset in debug control register DBCR
|
|
|
|
*/
|
2002-11-03 00:24:07 +00:00
|
|
|
__asm__ __volatile__("lis 3, 0x3000" ::: "r3");
|
|
|
|
#if defined(CONFIG_440)
|
|
|
|
__asm__ __volatile__("mtspr 0x134, 3");
|
|
|
|
#else
|
|
|
|
__asm__ __volatile__("mtspr 0x3f2, 3");
|
|
|
|
#endif
|
2005-08-01 14:41:48 +00:00
|
|
|
|
|
|
|
#endif/* defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)*/
|
2002-11-03 00:24:07 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CONFIG_440)
|
2005-11-27 18:36:26 +00:00
|
|
|
static int do_chip_reset (unsigned long sys0, unsigned long sys1)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
2003-09-03 14:03:26 +00:00
|
|
|
/* Changes to cpc0_sys0 and cpc0_sys1 require chip
|
|
|
|
* reset.
|
|
|
|
*/
|
|
|
|
mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000); /* Set SWE */
|
|
|
|
mtdcr (cpc0_sys0, sys0);
|
|
|
|
mtdcr (cpc0_sys1, sys1);
|
|
|
|
mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000); /* Clr SWE */
|
|
|
|
mtspr (dbcr0, 0x20000000); /* Reset the chip */
|
|
|
|
|
|
|
|
return 1;
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get timebase clock frequency
|
|
|
|
*/
|
|
|
|
unsigned long get_tbclk (void)
|
|
|
|
{
|
2005-11-27 18:36:26 +00:00
|
|
|
#if !defined(CONFIG_IOP480)
|
2002-11-03 00:24:07 +00:00
|
|
|
sys_info_t sys_info;
|
|
|
|
|
|
|
|
get_sys_info(&sys_info);
|
|
|
|
return (sys_info.freqProcessor);
|
|
|
|
#else
|
2005-11-27 18:36:26 +00:00
|
|
|
return (66000000);
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(CONFIG_WATCHDOG)
|
|
|
|
void
|
|
|
|
watchdog_reset(void)
|
|
|
|
{
|
|
|
|
int re_enable = disable_interrupts();
|
|
|
|
reset_4xx_watchdog();
|
|
|
|
if (re_enable) enable_interrupts();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
reset_4xx_watchdog(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Clear TSR(WIS) bit
|
|
|
|
*/
|
|
|
|
mtspr(tsr, 0x40000000);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_WATCHDOG */
|