2003-07-16 21:53:01 +00:00
|
|
|
/*
|
2010-01-20 13:28:48 +00:00
|
|
|
* (C) Copyright 2000-2010
|
2003-07-16 21:53:01 +00:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2003-07-16 21:53:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CPU specific code for the MPC5xxx CPUs
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <watchdog.h>
|
|
|
|
#include <command.h>
|
2009-03-17 09:06:40 +00:00
|
|
|
#include <net.h>
|
2003-07-16 21:53:01 +00:00
|
|
|
#include <mpc5xxx.h>
|
2008-08-31 17:39:12 +00:00
|
|
|
#include <netdev.h>
|
2007-09-06 15:46:23 +00:00
|
|
|
#include <asm/io.h>
|
2003-07-16 21:53:01 +00:00
|
|
|
#include <asm/processor.h>
|
|
|
|
|
2007-09-06 15:46:23 +00:00
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
|
|
|
#include <libfdt.h>
|
2007-11-04 00:46:28 +00:00
|
|
|
#include <fdt_support.h>
|
2006-11-28 16:55:49 +00:00
|
|
|
#endif
|
|
|
|
|
2009-09-23 05:56:08 +00:00
|
|
|
#if defined(CONFIG_OF_IDE_FIXUP)
|
|
|
|
#include <ide.h>
|
|
|
|
#endif
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2003-07-16 21:53:01 +00:00
|
|
|
int checkcpu (void)
|
|
|
|
{
|
|
|
|
ulong clock = gd->cpu_clk;
|
|
|
|
char buf[32];
|
2006-03-29 11:17:09 +00:00
|
|
|
uint svr, pvr;
|
2003-07-16 21:53:01 +00:00
|
|
|
|
|
|
|
puts ("CPU: ");
|
|
|
|
|
2006-03-29 11:17:09 +00:00
|
|
|
svr = get_svr();
|
|
|
|
pvr = get_pvr();
|
2007-04-29 12:01:54 +00:00
|
|
|
|
|
|
|
switch (pvr) {
|
|
|
|
case PVR_5200:
|
|
|
|
printf("MPC5200");
|
|
|
|
break;
|
|
|
|
case PVR_5200B:
|
|
|
|
printf("MPC5200B");
|
2004-06-09 17:45:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-04-29 12:01:54 +00:00
|
|
|
printf("Unknown MPC5xxx");
|
2004-06-09 17:45:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-16 08:51:58 +00:00
|
|
|
printf (" v%d.%d, Core v%d.%d", SVR_MJREV (svr), SVR_MNREV (svr),
|
2006-03-29 11:17:09 +00:00
|
|
|
PVR_MAJ(pvr), PVR_MIN(pvr));
|
2003-07-16 21:53:01 +00:00
|
|
|
printf (" at %s MHz\n", strmhz (buf, clock));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int
|
2010-06-28 20:00:46 +00:00
|
|
|
do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
2003-07-16 21:53:01 +00:00
|
|
|
{
|
2003-08-28 09:41:22 +00:00
|
|
|
ulong msr;
|
2003-07-16 21:53:01 +00:00
|
|
|
/* Interrupts and MMU off */
|
|
|
|
__asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
|
|
|
|
|
|
|
|
msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
|
|
|
|
__asm__ __volatile__ ("mtmsr %0"::"r" (msr));
|
|
|
|
|
2003-08-28 09:41:22 +00:00
|
|
|
/* Charge the watchdog timer */
|
2003-10-14 19:43:55 +00:00
|
|
|
*(vu_long *)(MPC5XXX_GPT0_COUNTER) = 0x0001000f;
|
2003-08-28 09:41:22 +00:00
|
|
|
*(vu_long *)(MPC5XXX_GPT0_ENABLE) = 0x9004; /* wden|ce|timer_ms */
|
2003-10-14 19:43:55 +00:00
|
|
|
while(1);
|
2003-08-28 09:41:22 +00:00
|
|
|
|
2003-07-16 21:53:01 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get timebase clock frequency (like cpu_clk in Hz)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
unsigned long get_tbclk (void)
|
|
|
|
{
|
|
|
|
ulong tbclk;
|
|
|
|
|
|
|
|
tbclk = (gd->bus_clk + 3L) / 4L;
|
|
|
|
|
|
|
|
return (tbclk);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
2006-11-28 16:55:49 +00:00
|
|
|
|
2008-02-21 16:20:18 +00:00
|
|
|
#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
|
2007-09-06 15:46:23 +00:00
|
|
|
void ft_cpu_setup(void *blob, bd_t *bd)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
int div = in_8((void*)CONFIG_SYS_MBAR + 0x204) & 0x0020 ? 8 : 4;
|
2007-09-06 15:46:23 +00:00
|
|
|
char * cpu_path = "/cpus/" OF_CPU;
|
2008-03-13 12:50:52 +00:00
|
|
|
#ifdef CONFIG_MPC5xxx_FEC
|
2009-03-17 09:06:40 +00:00
|
|
|
uchar enetaddr[6];
|
2007-09-06 15:46:23 +00:00
|
|
|
char * eth_path = "/" OF_SOC "/ethernet@3000";
|
2008-03-13 12:50:52 +00:00
|
|
|
#endif
|
2007-09-06 15:46:23 +00:00
|
|
|
|
2007-11-04 00:46:28 +00:00
|
|
|
do_fixup_by_path_u32(blob, cpu_path, "timebase-frequency", OF_TBCLK, 1);
|
|
|
|
do_fixup_by_path_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
|
|
|
|
do_fixup_by_path_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
|
|
|
|
do_fixup_by_path_u32(blob, "/" OF_SOC, "bus-frequency", bd->bi_ipbfreq, 1);
|
|
|
|
do_fixup_by_path_u32(blob, "/" OF_SOC, "system-frequency",
|
|
|
|
bd->bi_busfreq*div, 1);
|
2008-03-13 12:50:52 +00:00
|
|
|
#ifdef CONFIG_MPC5xxx_FEC
|
2009-02-12 00:18:41 +00:00
|
|
|
eth_getenv_enetaddr("ethaddr", enetaddr);
|
|
|
|
do_fixup_by_path(blob, eth_path, "mac-address", enetaddr, 6, 0);
|
|
|
|
do_fixup_by_path(blob, eth_path, "local-mac-address", enetaddr, 6, 0);
|
2008-03-13 12:50:52 +00:00
|
|
|
#endif
|
2009-09-23 05:56:08 +00:00
|
|
|
#if defined(CONFIG_OF_IDE_FIXUP)
|
|
|
|
if (!ide_device_present(0)) {
|
|
|
|
/* NO CF card detected -> delete ata node in DTS */
|
|
|
|
int nodeoffset = 0;
|
|
|
|
char nodename[] = "/soc5200@f0000000/ata@3a00";
|
|
|
|
|
|
|
|
nodeoffset = fdt_path_offset(blob, nodename);
|
|
|
|
if (nodeoffset >= 0) {
|
|
|
|
fdt_del_node(blob, nodeoffset);
|
|
|
|
} else {
|
|
|
|
printf("%s: cannot find %s node err:%s\n",
|
|
|
|
__func__, nodename, fdt_strerror(nodeoffset));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2009-12-03 10:20:06 +00:00
|
|
|
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
2006-11-28 16:55:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-08-15 22:30:48 +00:00
|
|
|
|
2008-08-31 17:39:12 +00:00
|
|
|
#ifdef CONFIG_MPC5xxx_FEC
|
|
|
|
/* Default initializations for FEC controllers. To override,
|
|
|
|
* create a board-specific function called:
|
|
|
|
* int board_eth_init(bd_t *bis)
|
|
|
|
*/
|
|
|
|
|
|
|
|
int cpu_eth_init(bd_t *bis)
|
|
|
|
{
|
|
|
|
return mpc5xxx_fec_initialize(bis);
|
|
|
|
}
|
|
|
|
#endif
|
2010-01-20 13:28:48 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_WATCHDOG)
|
|
|
|
void watchdog_reset(void)
|
|
|
|
{
|
|
|
|
int re_enable = disable_interrupts();
|
|
|
|
reset_5xxx_watchdog();
|
|
|
|
if (re_enable) enable_interrupts();
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset_5xxx_watchdog(void)
|
|
|
|
{
|
|
|
|
volatile struct mpc5xxx_gpt *gpt0 =
|
|
|
|
(struct mpc5xxx_gpt *) MPC5XXX_GPT;
|
|
|
|
|
|
|
|
/* Trigger TIMER_0 by writing A5 to OCPW */
|
|
|
|
clrsetbits_be32(&gpt0->emsr, 0xff000000, 0xa5000000);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_WATCHDOG */
|