u-boot/cpu/ppc4xx/cpu.c

280 lines
6.1 KiB
C
Raw Normal View History

2002-11-03 00:24:07 +00:00
/*
* (C) Copyright 2000
* 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
*/
/*
* m8xx.c
*
* 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>
#if defined(CONFIG_440)
static int do_chip_reset( unsigned long sys0, unsigned long sys1 );
#endif
/* ------------------------------------------------------------------------- */
int checkcpu (void)
{
2003-05-23 11:18:02 +00:00
#if defined(CONFIG_405GP) || \
defined(CONFIG_405CR) || \
defined(CONFIG_IOP480) || \
defined(CONFIG_440) || \
defined(CONFIG_405EP)
2002-11-03 00:24:07 +00:00
uint pvr = get_pvr();
#endif
2003-05-23 11:18:02 +00:00
#if defined(CONFIG_405GP) || \
defined(CONFIG_405CR) || \
defined(CONFIG_IOP480) || \
defined(CONFIG_405EP)
2002-11-03 00:24:07 +00:00
DECLARE_GLOBAL_DATA_PTR;
ulong clock = gd->cpu_clk;
char buf[32];
#endif
2003-05-23 11:18:02 +00:00
#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
2002-11-03 00:24:07 +00:00
PPC405_SYS_INFO sys_info;
puts ("CPU: ");
get_sys_info(&sys_info);
#if CONFIG_405GP
puts("IBM PowerPC 405GP");
2003-04-04 16:00:33 +00:00
if (pvr == PVR_405GPR_RB) {
2002-11-03 00:24:07 +00:00
putc('r');
}
puts(" Rev. ");
#endif
#if CONFIG_405CR
puts("IBM PowerPC 405CR Rev. ");
2003-05-23 11:18:02 +00:00
#endif
#if CONFIG_405EP
puts("IBM PowerPC 405EP Rev. ");
2002-11-03 00:24:07 +00:00
#endif
switch (pvr) {
case PVR_405GP_RB:
2003-04-04 16:00:33 +00:00
case PVR_405GPR_RB:
2002-11-03 00:24:07 +00:00
putc('B');
break;
case PVR_405GP_RC:
#if CONFIG_405CR
case PVR_405CR_RC:
#endif
putc('C');
break;
case PVR_405GP_RD:
putc('D');
break;
#if CONFIG_405GP
case PVR_405GP_RE:
putc('E');
break;
#endif
case PVR_405CR_RA:
putc('A');
break;
case PVR_405CR_RB:
2003-05-23 11:18:02 +00:00
case PVR_405EP_RB:
2002-11-03 00:24:07 +00:00
putc('B');
break;
default:
printf("? (PVR=%08x)", pvr);
break;
}
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,
sys_info.freqPLB / sys_info.pllExtBusDiv / 1000000);
2003-05-23 11:18:02 +00:00
#if defined(CONFIG_405GP)
2002-11-03 00:24:07 +00:00
if (mfdcr(strap) & PSR_PCI_ASYNC_EN)
printf(" PCI async ext clock used, ");
else
printf(" PCI sync clock at %lu MHz, ",
sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
if (mfdcr(strap) & PSR_PCI_ARBIT_EN)
printf("internal PCI arbiter enabled\n");
else
printf("external PCI arbiter enabled\n");
2003-05-23 11:18:02 +00:00
#elif defined(CONFIG_405EP)
if (mfdcr(cpc0_boot) & CPC0_BOOT_SEP)
printf(" IIC Boot EEPROM enabled\n");
else
printf(" IIC Boot EEPROM disabled\n");
printf(" PCI async ext clock used, ");
if (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN)
printf("internal PCI arbiter enabled\n");
else
printf("external PCI arbiter enabled\n");
2002-11-03 00:24:07 +00:00
#endif
2003-05-23 11:18:02 +00:00
#if defined(CONFIG_405EP)
printf(" 16 kB I-Cache 16 kB D-Cache");
#else
2003-04-04 16:00:33 +00:00
if ((pvr | 0x00000001) == PVR_405GPR_RB) {
2002-11-03 00:24:07 +00:00
printf(" 16 kB I-Cache 16 kB D-Cache");
} else {
printf(" 16 kB I-Cache 8 kB D-Cache");
}
2003-05-23 11:18:02 +00:00
#endif
2002-11-03 00:24:07 +00:00
#endif /* defined(CONFIG_405GP) || defined(CONFIG_405CR) */
#ifdef 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
#if defined(CONFIG_440)
puts("IBM PowerPC 440 Rev. ");
switch(pvr)
{
case PVR_440GP_RB:
2002-11-03 00:24:07 +00:00
putc('B');
/* 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;
case PVR_440GP_RC:
2002-11-03 00:24:07 +00:00
putc('C');
break;
default:
2002-11-03 00:24:07 +00:00
printf("UNKNOWN (PVR=%08x)", pvr);
break;
}
#endif
printf("\n");
return 0;
}
/* ------------------------------------------------------------------------- */
int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2002-11-03 00:24:07 +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
return 1;
}
#if defined(CONFIG_440)
static
int do_chip_reset( unsigned long sys0, unsigned long sys1 )
{
/* 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;
}
#endif
/*
* Get timebase clock frequency
*/
unsigned long get_tbclk (void)
{
#if defined(CONFIG_440)
sys_info_t sys_info;
get_sys_info(&sys_info);
return (sys_info.freqProcessor);
2003-05-23 11:18:02 +00:00
#elif defined(CONFIG_405GP) || \
defined(CONFIG_405CR) || \
defined(CONFIG_405) || \
defined(CONFIG_405EP)
2002-11-03 00:24:07 +00:00
PPC405_SYS_INFO sys_info;
get_sys_info(&sys_info);
return (sys_info.freqProcessor);
#elif defined(CONFIG_IOP480)
return (66000000);
#else
# error get_tbclk() not implemented
#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 */