2002-08-27 09:48:53 +00:00
|
|
|
/*
|
2006-03-31 16:32:53 +00:00
|
|
|
* (C) Copyright 2000-2006
|
2002-08-27 09:48:53 +00:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2002-08-27 09:48:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2003-07-14 22:13:32 +00:00
|
|
|
* CPU specific code for the MPC825x / MPC826x / MPC827x / MPC828x
|
2002-08-27 09:48:53 +00:00
|
|
|
*
|
|
|
|
* written or collected and sometimes rewritten by
|
|
|
|
* Magnus Damm <damm@bitsmart.com>
|
|
|
|
*
|
2003-04-27 22:52:51 +00:00
|
|
|
* modified by
|
2002-08-27 09:48:53 +00:00
|
|
|
* Wolfgang Denk <wd@denx.de>
|
|
|
|
*
|
|
|
|
* modified for 8260 by
|
|
|
|
* Murray Jensen <Murray.Jensen@cmst.csiro.au>
|
|
|
|
*
|
|
|
|
* added 8260 masks by
|
|
|
|
* Marius Groeger <mag@sysgo.de>
|
2003-07-14 22:13:32 +00:00
|
|
|
*
|
2004-04-15 18:22:41 +00:00
|
|
|
* added HiP7 (824x/827x/8280) processors support by
|
2003-07-14 22:13:32 +00:00
|
|
|
* Yuli Barcohen <yuli@arabellasw.com>
|
2002-08-27 09:48:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <watchdog.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <mpc8260.h>
|
2008-10-23 06:20:29 +00:00
|
|
|
#include <netdev.h>
|
2002-08-27 09:48:53 +00:00
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/cpm_8260.h>
|
|
|
|
|
2007-10-17 09:13:51 +00:00
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
|
|
|
#include <libfdt.h>
|
2007-11-04 00:46:28 +00:00
|
|
|
#include <fdt_support.h>
|
2007-10-17 09:13:51 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2006-12-21 16:17:02 +00:00
|
|
|
#if defined(CONFIG_GET_CPU_STR_F)
|
|
|
|
extern int get_cpu_str_f (char *buf);
|
|
|
|
#endif
|
|
|
|
|
2002-08-27 09:48:53 +00:00
|
|
|
int checkcpu (void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
|
2002-08-27 09:48:53 +00:00
|
|
|
ulong clock = gd->cpu_clk;
|
|
|
|
uint pvr = get_pvr ();
|
|
|
|
uint immr, rev, m, k;
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
puts ("CPU: ");
|
|
|
|
|
2003-07-14 22:13:32 +00:00
|
|
|
switch (pvr) {
|
|
|
|
case PVR_8260:
|
|
|
|
case PVR_8260_HIP3:
|
|
|
|
k = 3;
|
|
|
|
break;
|
|
|
|
case PVR_8260_HIP4:
|
|
|
|
k = 4;
|
|
|
|
break;
|
2003-12-06 23:55:10 +00:00
|
|
|
case PVR_8260_HIP7R1:
|
2004-10-10 23:27:33 +00:00
|
|
|
case PVR_8260_HIP7RA:
|
2003-07-14 22:13:32 +00:00
|
|
|
case PVR_8260_HIP7:
|
|
|
|
k = 7;
|
|
|
|
break;
|
|
|
|
default:
|
2002-08-27 09:48:53 +00:00
|
|
|
return -1; /* whoops! not an MPC8260 */
|
2003-07-14 22:13:32 +00:00
|
|
|
}
|
2002-08-27 09:48:53 +00:00
|
|
|
rev = pvr & 0xff;
|
|
|
|
|
|
|
|
immr = immap->im_memctl.memc_immr;
|
2008-10-16 13:01:15 +00:00
|
|
|
if ((immr & IMMR_ISB_MSK) != CONFIG_SYS_IMMR)
|
2002-08-27 09:48:53 +00:00
|
|
|
return -1; /* whoops! someone moved the IMMR */
|
|
|
|
|
2006-12-21 16:17:02 +00:00
|
|
|
#if defined(CONFIG_GET_CPU_STR_F)
|
|
|
|
get_cpu_str_f (buf);
|
|
|
|
printf ("%s (HiP%d Rev %02x, Mask ", buf, k, rev);
|
|
|
|
#else
|
2003-07-14 22:13:32 +00:00
|
|
|
printf (CPU_ID_STR " (HiP%d Rev %02x, Mask ", k, rev);
|
2006-12-21 16:17:02 +00:00
|
|
|
#endif
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the bottom 16 bits of the immr are the Part Number and Mask Number
|
|
|
|
* (4-34); the 16 bits at PROFF_REVNUM (0x8af0) in dual port ram is the
|
|
|
|
* RISC Microcode Revision Number (13-10).
|
|
|
|
* For the 8260, Motorola doesn't include the Microcode Revision
|
|
|
|
* in the mask.
|
|
|
|
*/
|
|
|
|
m = immr & (IMMR_PARTNUM_MSK | IMMR_MASKNUM_MSK);
|
2013-05-18 01:01:54 +00:00
|
|
|
k = immap->im_dprambase16[PROFF_REVNUM / sizeof(u16)];
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
switch (m) {
|
|
|
|
case 0x0000:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("0.2 2J24M");
|
2002-08-27 09:48:53 +00:00
|
|
|
break;
|
|
|
|
case 0x0010:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("A.0 K22A");
|
2002-08-27 09:48:53 +00:00
|
|
|
break;
|
|
|
|
case 0x0011:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("A.1 1K22A-XC");
|
2002-08-27 09:48:53 +00:00
|
|
|
break;
|
|
|
|
case 0x0001:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("B.1 1K23A");
|
2002-08-27 09:48:53 +00:00
|
|
|
break;
|
|
|
|
case 0x0021:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("B.2 2K23A-XC");
|
2002-08-27 09:48:53 +00:00
|
|
|
break;
|
|
|
|
case 0x0023:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("B.3 3K23A");
|
2002-08-27 09:48:53 +00:00
|
|
|
break;
|
|
|
|
case 0x0024:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("C.2 6K23A");
|
2002-08-27 09:48:53 +00:00
|
|
|
break;
|
|
|
|
case 0x0060:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("A.0(A) 2K25A");
|
2002-08-27 09:48:53 +00:00
|
|
|
break;
|
2003-04-27 22:52:51 +00:00
|
|
|
case 0x0062:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("B.1 4K25A");
|
2003-04-27 22:52:51 +00:00
|
|
|
break;
|
2003-10-08 22:45:44 +00:00
|
|
|
case 0x0064:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("C.0 5K25A");
|
2003-10-08 22:45:44 +00:00
|
|
|
break;
|
2003-07-14 22:13:32 +00:00
|
|
|
case 0x0A00:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("0.0 0K49M");
|
2003-07-14 22:13:32 +00:00
|
|
|
break;
|
|
|
|
case 0x0A01:
|
2004-03-23 22:14:11 +00:00
|
|
|
puts ("0.1 1K49M");
|
2003-07-14 22:13:32 +00:00
|
|
|
break;
|
2004-10-10 23:27:33 +00:00
|
|
|
case 0x0A10:
|
|
|
|
puts ("1.0 1K49M");
|
|
|
|
break;
|
2004-04-15 18:22:41 +00:00
|
|
|
case 0x0C00:
|
2004-10-10 23:27:33 +00:00
|
|
|
puts ("0.0 0K50M");
|
|
|
|
break;
|
|
|
|
case 0x0C10:
|
2005-08-06 00:03:03 +00:00
|
|
|
puts ("1.0 1K50M");
|
2004-10-10 23:27:33 +00:00
|
|
|
break;
|
2004-04-15 18:22:41 +00:00
|
|
|
case 0x0D00:
|
2004-10-10 23:27:33 +00:00
|
|
|
puts ("0.0 0K50M");
|
|
|
|
break;
|
|
|
|
case 0x0D10:
|
2005-08-06 00:03:03 +00:00
|
|
|
puts ("1.0 1K50M");
|
2004-04-15 18:22:41 +00:00
|
|
|
break;
|
2002-08-27 09:48:53 +00:00
|
|
|
default:
|
|
|
|
printf ("unknown [immr=0x%04x,k=0x%04x]", m, k);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf (") at %s MHz\n", strmhz (buf, clock));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* configures a UPM by writing into the UPM RAM array */
|
|
|
|
/* uses bank 11 and a dummy physical address (=BRx_BA_MSK) */
|
|
|
|
/* NOTE: the physical address chosen must not overlap into any other area */
|
|
|
|
/* mapped by the memory controller because bank 11 has the lowest priority */
|
|
|
|
|
|
|
|
void upmconfig (uint upm, uint * table, uint size)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
|
2002-08-27 09:48:53 +00:00
|
|
|
volatile memctl8260_t *memctl = &immap->im_memctl;
|
|
|
|
volatile uchar *dummy = (uchar *) BRx_BA_MSK; /* set all BA bits */
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
/* first set up bank 11 to reference the correct UPM at a dummy address */
|
|
|
|
|
|
|
|
memctl->memc_or11 = ORxU_AM_MSK; /* set all AM bits */
|
|
|
|
|
|
|
|
switch (upm) {
|
|
|
|
|
|
|
|
case UPMA:
|
|
|
|
memctl->memc_br11 =
|
|
|
|
((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMA |
|
|
|
|
BRx_V;
|
|
|
|
memctl->memc_mamr = MxMR_OP_WARR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UPMB:
|
|
|
|
memctl->memc_br11 =
|
|
|
|
((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMB |
|
|
|
|
BRx_V;
|
|
|
|
memctl->memc_mbmr = MxMR_OP_WARR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UPMC:
|
|
|
|
memctl->memc_br11 =
|
|
|
|
((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMC |
|
|
|
|
BRx_V;
|
|
|
|
memctl->memc_mcmr = MxMR_OP_WARR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic ("upmconfig passed invalid UPM number (%u)\n", upm);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* at this point, the dummy address is set up to access the selected UPM,
|
|
|
|
* the MAD pointer is zero, and the MxMR OP is set for writing to RAM
|
|
|
|
*
|
|
|
|
* now we simply load the mdr with each word and poke the dummy address.
|
|
|
|
* the MAD is incremented on each access.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
memctl->memc_mdr = table[i];
|
|
|
|
*dummy = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now kill bank 11 */
|
|
|
|
memctl->memc_br11 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2005-05-30 23:55:42 +00:00
|
|
|
#if !defined(CONFIG_HAVE_OWN_RESET)
|
2002-08-27 09:48:53 +00:00
|
|
|
int
|
2010-06-28 20:00:46 +00:00
|
|
|
do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
2002-08-27 09:48:53 +00:00
|
|
|
{
|
|
|
|
ulong msr, addr;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
immap->im_clkrst.car_rmr = RMR_CSRE; /* Checkstop Reset enable */
|
|
|
|
|
|
|
|
/* 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));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Trying to execute the next instruction at a non-existing address
|
|
|
|
* should cause a machine check, resulting in reset
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_RESET_ADDRESS
|
|
|
|
addr = CONFIG_SYS_RESET_ADDRESS;
|
2002-08-27 09:48:53 +00:00
|
|
|
#else
|
|
|
|
/*
|
2008-10-16 13:01:15 +00:00
|
|
|
* note: when CONFIG_SYS_MONITOR_BASE points to a RAM address, CONFIG_SYS_MONITOR_BASE
|
2002-08-27 09:48:53 +00:00
|
|
|
* - sizeof (ulong) is usually a valid address. Better pick an address
|
2008-10-16 13:01:15 +00:00
|
|
|
* known to be invalid on your system and assign it to CONFIG_SYS_RESET_ADDRESS.
|
2002-08-27 09:48:53 +00:00
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
((void (*)(void)) addr) ();
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
2005-05-30 23:55:42 +00:00
|
|
|
#endif /* CONFIG_HAVE_OWN_RESET */
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get timebase clock frequency (like cpu_clk in Hz)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
unsigned long get_tbclk (void)
|
|
|
|
{
|
|
|
|
ulong tbclk;
|
|
|
|
|
|
|
|
tbclk = (gd->bus_clk + 3L) / 4L;
|
|
|
|
|
|
|
|
return (tbclk);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#if defined(CONFIG_WATCHDOG)
|
|
|
|
void watchdog_reset (void)
|
|
|
|
{
|
|
|
|
int re_enable = disable_interrupts ();
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
reset_8260_watchdog ((immap_t *) CONFIG_SYS_IMMR);
|
2002-08-27 09:48:53 +00:00
|
|
|
if (re_enable)
|
|
|
|
enable_interrupts ();
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_WATCHDOG */
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
2016-05-19 19:23:12 +00:00
|
|
|
#ifdef CONFIG_OF_BOARD_SETUP
|
2007-10-17 09:13:51 +00:00
|
|
|
void ft_cpu_setup (void *blob, bd_t *bd)
|
|
|
|
{
|
2008-06-18 09:03:57 +00:00
|
|
|
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
|
|
|
|
defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
2008-08-19 20:41:18 +00:00
|
|
|
fdt_fixup_ethernet(blob);
|
2008-06-18 09:03:57 +00:00
|
|
|
#endif
|
|
|
|
|
2009-04-02 21:10:36 +00:00
|
|
|
do_fixup_by_compat_u32(blob, "fsl,cpm2-brg",
|
|
|
|
"clock-frequency", bd->bi_brgfreq, 1);
|
|
|
|
|
2009-05-12 13:17:35 +00:00
|
|
|
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
|
|
|
"bus-frequency", bd->bi_busfreq, 1);
|
|
|
|
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
|
|
|
"timebase-frequency", OF_TBCLK, 1);
|
|
|
|
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
|
|
|
"clock-frequency", bd->bi_intfreq, 1);
|
2009-10-01 21:55:17 +00:00
|
|
|
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
2007-10-17 09:13:51 +00:00
|
|
|
}
|
2016-05-19 19:23:12 +00:00
|
|
|
#endif /* CONFIG_OF_BOARD_SETUP */
|
2008-10-23 06:20:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initializes on-chip ethernet controllers.
|
|
|
|
* to override, implement board_eth_init()
|
|
|
|
*/
|
|
|
|
int cpu_eth_init(bd_t *bis)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_ETHER_ON_FCC)
|
|
|
|
fec_initialize(bis);
|
2008-11-20 11:28:38 +00:00
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_ETHER_ON_SCC)
|
2009-02-07 00:27:55 +00:00
|
|
|
mpc82xx_scc_enet_initialize(bis);
|
2008-10-23 06:20:29 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|