2002-08-27 09:48:53 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2002
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <watchdog.h>
|
|
|
|
|
|
|
|
#include <mpc8xx.h>
|
|
|
|
#include <commproc.h>
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_RTCSC) || defined(CONFIG_SYS_RMDS)
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_I2C_UCODE_PATCH) || defined(CONFIG_SYS_SPI_UCODE_PATCH) || \
|
|
|
|
defined(CONFIG_SYS_SMC_UCODE_PATCH)
|
2002-08-27 09:48:53 +00:00
|
|
|
void cpm_load_patch (volatile immap_t * immr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Breath some life into the CPU...
|
|
|
|
*
|
|
|
|
* Set up the memory map,
|
|
|
|
* initialize a bunch of registers,
|
|
|
|
* initialize the UPM's
|
|
|
|
*/
|
|
|
|
void cpu_init_f (volatile immap_t * immr)
|
|
|
|
{
|
|
|
|
#ifndef CONFIG_MBX
|
|
|
|
volatile memctl8xx_t *memctl = &immr->im_memctl;
|
2008-10-16 13:01:15 +00:00
|
|
|
# ifdef CONFIG_SYS_PLPRCR
|
2004-01-04 16:28:35 +00:00
|
|
|
ulong mfmask;
|
2004-01-24 20:25:54 +00:00
|
|
|
# endif
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
2003-03-12 10:41:04 +00:00
|
|
|
ulong reg;
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
/* SYPCR - contains watchdog control (11-9) */
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_sypcr = CONFIG_SYS_SYPCR;
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_WATCHDOG)
|
|
|
|
reset_8xx_watchdog (immr);
|
|
|
|
#endif /* CONFIG_WATCHDOG */
|
|
|
|
|
|
|
|
/* SIUMCR - contains debug pin configuration (11-6) */
|
2003-03-26 06:55:25 +00:00
|
|
|
#ifndef CONFIG_SVM_SC8xx
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_siumcr |= CONFIG_SYS_SIUMCR;
|
2003-03-26 06:55:25 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_siumcr = CONFIG_SYS_SIUMCR;
|
2003-03-26 06:55:25 +00:00
|
|
|
#endif
|
2002-08-27 09:48:53 +00:00
|
|
|
/* initialize timebase status and control register (11-26) */
|
|
|
|
/* unlock TBSCRK */
|
|
|
|
|
|
|
|
immr->im_sitk.sitk_tbscrk = KAPWR_KEY;
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_sit.sit_tbscr = CONFIG_SYS_TBSCR;
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
/* initialize the PIT (11-31) */
|
|
|
|
|
|
|
|
immr->im_sitk.sitk_piscrk = KAPWR_KEY;
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_sit.sit_piscr = CONFIG_SYS_PISCR;
|
2002-08-27 09:48:53 +00:00
|
|
|
|
2003-03-06 21:55:29 +00:00
|
|
|
/* System integration timers. Don't change EBDF! (15-27) */
|
|
|
|
|
|
|
|
immr->im_clkrstk.cark_sccrk = KAPWR_KEY;
|
|
|
|
reg = immr->im_clkrst.car_sccr;
|
|
|
|
reg &= SCCR_MASK;
|
2008-10-16 13:01:15 +00:00
|
|
|
reg |= CONFIG_SYS_SCCR;
|
2003-03-06 21:55:29 +00:00
|
|
|
immr->im_clkrst.car_sccr = reg;
|
|
|
|
|
2002-08-27 09:48:53 +00:00
|
|
|
/* PLL (CPU clock) settings (15-30) */
|
|
|
|
|
|
|
|
immr->im_clkrstk.cark_plprcrk = KAPWR_KEY;
|
|
|
|
|
|
|
|
#ifndef CONFIG_MBX /* MBX board does things different */
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
/* If CONFIG_SYS_PLPRCR (set in the various *_config.h files) tries to
|
|
|
|
* set the MF field, then just copy CONFIG_SYS_PLPRCR over car_plprcr,
|
|
|
|
* otherwise OR in CONFIG_SYS_PLPRCR so we do not change the current MF
|
2002-08-27 09:48:53 +00:00
|
|
|
* field value.
|
2004-01-04 16:28:35 +00:00
|
|
|
*
|
|
|
|
* For newer (starting MPC866) chips PLPRCR layout is different.
|
2002-08-27 09:48:53 +00:00
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_PLPRCR
|
2004-01-04 16:28:35 +00:00
|
|
|
if (get_immr(0xFFFF) >= MPC8xx_NEW_CLK)
|
|
|
|
mfmask = PLPRCR_MFACT_MSK;
|
|
|
|
else
|
|
|
|
mfmask = PLPRCR_MF_MSK;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
if ((CONFIG_SYS_PLPRCR & mfmask) != 0)
|
|
|
|
reg = CONFIG_SYS_PLPRCR; /* reset control bits */
|
2004-01-04 16:28:35 +00:00
|
|
|
else {
|
|
|
|
reg = immr->im_clkrst.car_plprcr;
|
|
|
|
reg &= mfmask; /* isolate MF-related fields */
|
2008-10-16 13:01:15 +00:00
|
|
|
reg |= CONFIG_SYS_PLPRCR; /* reset control bits */
|
2004-01-04 16:28:35 +00:00
|
|
|
}
|
2002-08-27 09:48:53 +00:00
|
|
|
immr->im_clkrst.car_plprcr = reg;
|
2004-01-24 20:25:54 +00:00
|
|
|
#endif
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Memory Controller:
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* perform BR0 reset that MPC850 Rev. A can't guarantee */
|
|
|
|
reg = memctl->memc_br0;
|
|
|
|
reg &= BR_PS_MSK; /* Clear everything except Port Size bits */
|
|
|
|
reg |= BR_V; /* then add just the "Bank Valid" bit */
|
|
|
|
memctl->memc_br0 = reg;
|
|
|
|
|
|
|
|
/* Map banks 0 (and maybe 1) to the FLASH banks 0 (and 1) at
|
|
|
|
* preliminary addresses - these have to be modified later
|
|
|
|
* when FLASH size has been determined
|
|
|
|
*
|
|
|
|
* Depending on the size of the memory region defined by
|
2008-10-16 13:01:15 +00:00
|
|
|
* CONFIG_SYS_OR0_REMAP some boards (wide address mask) allow to map the
|
|
|
|
* CONFIG_SYS_MONITOR_BASE, while others (narrower address mask) can't
|
|
|
|
* map CONFIG_SYS_MONITOR_BASE.
|
2002-08-27 09:48:53 +00:00
|
|
|
*
|
2008-10-16 13:01:15 +00:00
|
|
|
* For example, for CONFIG_IVMS8, the CONFIG_SYS_MONITOR_BASE is
|
|
|
|
* 0xff000000, but CONFIG_SYS_OR0_REMAP's address mask is 0xfff80000.
|
2002-08-27 09:48:53 +00:00
|
|
|
*
|
|
|
|
* If BR0 wasn't loaded with address base 0xff000000, then BR0's
|
|
|
|
* base address remains as 0x00000000. However, the address mask
|
2008-10-16 13:01:15 +00:00
|
|
|
* have been narrowed to 512Kb, so CONFIG_SYS_MONITOR_BASE wasn't mapped
|
2002-08-27 09:48:53 +00:00
|
|
|
* into the Bank0.
|
|
|
|
*
|
|
|
|
* This is why CONFIG_IVMS8 and similar boards must load BR0 with
|
2008-10-16 13:01:15 +00:00
|
|
|
* CONFIG_SYS_BR0_PRELIM in advance.
|
2002-08-27 09:48:53 +00:00
|
|
|
*
|
|
|
|
* [Thanks to Michael Liao for this explanation.
|
|
|
|
* I owe him a free beer. - wd]
|
|
|
|
*/
|
|
|
|
|
2004-07-09 22:51:01 +00:00
|
|
|
#if defined(CONFIG_GTH) || \
|
2002-08-27 09:48:53 +00:00
|
|
|
defined(CONFIG_HERMES) || \
|
|
|
|
defined(CONFIG_ICU862) || \
|
|
|
|
defined(CONFIG_IP860) || \
|
|
|
|
defined(CONFIG_IVML24) || \
|
|
|
|
defined(CONFIG_IVMS8) || \
|
|
|
|
defined(CONFIG_LWMON) || \
|
|
|
|
defined(CONFIG_MHPC) || \
|
|
|
|
defined(CONFIG_PCU_E) || \
|
|
|
|
defined(CONFIG_R360MPI) || \
|
2004-04-08 22:31:29 +00:00
|
|
|
defined(CONFIG_RMU) || \
|
2002-08-27 09:48:53 +00:00
|
|
|
defined(CONFIG_RPXCLASSIC) || \
|
|
|
|
defined(CONFIG_RPXLITE) || \
|
2006-07-12 06:48:24 +00:00
|
|
|
defined(CONFIG_SPC1920) || \
|
2003-12-07 21:39:28 +00:00
|
|
|
defined(CONFIG_SPD823TS)
|
2002-08-27 09:48:53 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
memctl->memc_br0 = CONFIG_SYS_BR0_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR0_REMAP)
|
|
|
|
memctl->memc_or0 = CONFIG_SYS_OR0_REMAP;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR1_REMAP)
|
|
|
|
memctl->memc_or1 = CONFIG_SYS_OR1_REMAP;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR5_REMAP)
|
|
|
|
memctl->memc_or5 = CONFIG_SYS_OR5_REMAP;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* now restrict to preliminary range */
|
2008-10-16 13:01:15 +00:00
|
|
|
memctl->memc_br0 = CONFIG_SYS_BR0_PRELIM;
|
|
|
|
memctl->memc_or0 = CONFIG_SYS_OR0_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM))
|
|
|
|
memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM;
|
|
|
|
memctl->memc_br1 = CONFIG_SYS_BR1_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_IP860) /* disable CS0 now that Flash is mapped on CS1 */
|
|
|
|
memctl->memc_br0 = 0;
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
|
|
|
|
memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM;
|
|
|
|
memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM)
|
|
|
|
memctl->memc_or3 = CONFIG_SYS_OR3_PRELIM;
|
|
|
|
memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM)
|
|
|
|
memctl->memc_or4 = CONFIG_SYS_OR4_PRELIM;
|
|
|
|
memctl->memc_br4 = CONFIG_SYS_BR4_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM)
|
|
|
|
memctl->memc_or5 = CONFIG_SYS_OR5_PRELIM;
|
|
|
|
memctl->memc_br5 = CONFIG_SYS_BR5_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM)
|
|
|
|
memctl->memc_or6 = CONFIG_SYS_OR6_PRELIM;
|
|
|
|
memctl->memc_br6 = CONFIG_SYS_BR6_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM)
|
|
|
|
memctl->memc_or7 = CONFIG_SYS_OR7_PRELIM;
|
|
|
|
memctl->memc_br7 = CONFIG_SYS_BR7_PRELIM;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* ! CONFIG_MBX */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset CPM
|
|
|
|
*/
|
|
|
|
immr->im_cpm.cp_cpcr = CPM_CR_RST | CPM_CR_FLG;
|
|
|
|
do { /* Spin until command processed */
|
|
|
|
__asm__ ("eieio");
|
|
|
|
} while (immr->im_cpm.cp_cpcr & CPM_CR_FLG);
|
|
|
|
|
|
|
|
#ifdef CONFIG_MBX
|
|
|
|
/*
|
|
|
|
* on the MBX, things are a little bit different:
|
|
|
|
* - we need to read the VPD to get board information
|
|
|
|
* - the plprcr is set up dynamically
|
|
|
|
* - the memory controller is set up dynamically
|
|
|
|
*/
|
|
|
|
mbx_init ();
|
|
|
|
#endif /* CONFIG_MBX */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RPXCLASSIC
|
|
|
|
rpxclassic_init ();
|
|
|
|
#endif
|
|
|
|
|
2008-09-10 20:47:59 +00:00
|
|
|
#if defined(CONFIG_RPXLITE) && defined(CONFIG_ENV_IS_IN_NVRAM)
|
2004-06-09 21:04:48 +00:00
|
|
|
rpxlite_init ();
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_RCCR /* must be done before cpm_load_patch() */
|
2002-08-27 09:48:53 +00:00
|
|
|
/* write config value */
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_cpm.cp_rccr = CONFIG_SYS_RCCR;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_I2C_UCODE_PATCH) || defined(CONFIG_SYS_SPI_UCODE_PATCH) || \
|
|
|
|
defined(CONFIG_SYS_SMC_UCODE_PATCH)
|
2002-08-27 09:48:53 +00:00
|
|
|
cpm_load_patch (immr); /* load mpc8xx microcode patch */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initialize higher level parts of CPU like timers
|
|
|
|
*/
|
|
|
|
int cpu_init_r (void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_RTCSC) || defined(CONFIG_SYS_RMDS)
|
2002-08-27 09:48:53 +00:00
|
|
|
bd_t *bd = gd->bd;
|
|
|
|
volatile immap_t *immr = (volatile immap_t *) (bd->bi_immr_base);
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_RTCSC
|
2002-08-27 09:48:53 +00:00
|
|
|
/* Unlock RTSC register */
|
|
|
|
immr->im_sitk.sitk_rtcsck = KAPWR_KEY;
|
|
|
|
/* write config value */
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_sit.sit_rtcsc = CONFIG_SYS_RTCSC;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_RMDS
|
2002-08-27 09:48:53 +00:00
|
|
|
/* write config value */
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_cpm.cp_rmds = CONFIG_SYS_RMDS;
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|