2002-11-03 00:24:07 +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 <mpc8260.h>
|
|
|
|
#include <asm/cpm_8260.h>
|
|
|
|
#include <ioports.h>
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2006-12-21 16:17:02 +00:00
|
|
|
#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
|
|
|
|
extern unsigned long board_get_cpu_clk_f (void);
|
|
|
|
#endif
|
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
static void config_8260_ioports (volatile immap_t * immr)
|
|
|
|
{
|
|
|
|
int portnum;
|
|
|
|
|
|
|
|
for (portnum = 0; portnum < 4; portnum++) {
|
|
|
|
uint pmsk = 0,
|
|
|
|
ppar = 0,
|
|
|
|
psor = 0,
|
|
|
|
pdir = 0,
|
|
|
|
podr = 0,
|
|
|
|
pdat = 0;
|
|
|
|
iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0];
|
|
|
|
iop_conf_t *eiopc = iopc + 32;
|
|
|
|
uint msk = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE:
|
|
|
|
* index 0 refers to pin 31,
|
|
|
|
* index 31 refers to pin 0
|
|
|
|
*/
|
|
|
|
while (iopc < eiopc) {
|
|
|
|
if (iopc->conf) {
|
|
|
|
pmsk |= msk;
|
|
|
|
if (iopc->ppar)
|
|
|
|
ppar |= msk;
|
|
|
|
if (iopc->psor)
|
|
|
|
psor |= msk;
|
|
|
|
if (iopc->pdir)
|
|
|
|
pdir |= msk;
|
|
|
|
if (iopc->podr)
|
|
|
|
podr |= msk;
|
|
|
|
if (iopc->pdat)
|
|
|
|
pdat |= msk;
|
|
|
|
}
|
|
|
|
|
|
|
|
msk <<= 1;
|
|
|
|
iopc++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pmsk != 0) {
|
|
|
|
volatile ioport_t *iop = ioport_addr (immr, portnum);
|
|
|
|
uint tpmsk = ~pmsk;
|
|
|
|
|
|
|
|
/*
|
2003-06-27 21:31:46 +00:00
|
|
|
* the (somewhat confused) paragraph at the
|
|
|
|
* bottom of page 35-5 warns that there might
|
|
|
|
* be "unknown behaviour" when programming
|
|
|
|
* PSORx and PDIRx, if PPARx = 1, so I
|
|
|
|
* decided this meant I had to disable the
|
|
|
|
* dedicated function first, and enable it
|
|
|
|
* last.
|
2002-11-03 00:24:07 +00:00
|
|
|
*/
|
|
|
|
iop->ppar &= tpmsk;
|
|
|
|
iop->psor = (iop->psor & tpmsk) | psor;
|
2003-06-19 23:40:20 +00:00
|
|
|
iop->podr = (iop->podr & tpmsk) | podr;
|
2002-11-03 00:24:07 +00:00
|
|
|
iop->pdat = (iop->pdat & tpmsk) | pdat;
|
|
|
|
iop->pdir = (iop->pdir & tpmsk) | pdir;
|
|
|
|
iop->ppar |= ppar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-21 16:17:02 +00:00
|
|
|
#define SET_VAL_MASK(a, b, mask) ((a & mask) | (b & ~mask))
|
2002-11-03 00:24:07 +00:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
2004-03-14 16:51:43 +00:00
|
|
|
#if !defined(CONFIG_COGENT) /* done in start.S for the cogent */
|
|
|
|
uint sccr;
|
2006-12-21 16:17:02 +00:00
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
|
|
|
|
unsigned long cpu_clk;
|
2004-03-14 16:51:43 +00:00
|
|
|
#endif
|
2002-11-03 00:24:07 +00:00
|
|
|
volatile memctl8260_t *memctl = &immr->im_memctl;
|
|
|
|
extern void m8260_cpm_reset (void);
|
|
|
|
|
|
|
|
/* Pointer is writable since we allocated a register for it */
|
2008-10-16 13:01:15 +00:00
|
|
|
gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
/* Clear initial global data */
|
|
|
|
memset ((void *) gd, 0, sizeof (gd_t));
|
|
|
|
|
|
|
|
/* RSR - Reset Status Register - clear all status (5-4) */
|
|
|
|
gd->reset_status = immr->im_clkrst.car_rsr;
|
|
|
|
immr->im_clkrst.car_rsr = RSR_ALLBITS;
|
|
|
|
|
|
|
|
/* RMR - Reset Mode Register - contains checkstop reset enable (5-5) */
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_clkrst.car_rmr = CONFIG_SYS_RMR;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
/* BCR - Bus Configuration Register (4-25) */
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BCR_60x) && (CONFIG_SYS_BCR_SINGLE)
|
2006-12-21 16:17:02 +00:00
|
|
|
if (immr->im_siu_conf.sc_bcr & BCR_EBM) {
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_bcr = SET_VAL_MASK(immr->im_siu_conf.sc_bcr, CONFIG_SYS_BCR_60x, 0x80000010);
|
2006-12-21 16:17:02 +00:00
|
|
|
} else {
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_bcr = SET_VAL_MASK(immr->im_siu_conf.sc_bcr, CONFIG_SYS_BCR_SINGLE, 0x80000010);
|
2006-12-21 16:17:02 +00:00
|
|
|
}
|
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_bcr = CONFIG_SYS_BCR;
|
2006-12-21 16:17:02 +00:00
|
|
|
#endif
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
/* SIUMCR - contains debug pin configuration (4-31) */
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_SIUMCR_LOW) && (CONFIG_SYS_SIUMCR_HIGH)
|
2006-12-21 16:17:02 +00:00
|
|
|
cpu_clk = board_get_cpu_clk_f ();
|
|
|
|
if (cpu_clk >= 100000000) {
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_siumcr = SET_VAL_MASK(immr->im_siu_conf.sc_siumcr, CONFIG_SYS_SIUMCR_HIGH, 0x9f3cc000);
|
2006-12-21 16:17:02 +00:00
|
|
|
} else {
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_siumcr = SET_VAL_MASK(immr->im_siu_conf.sc_siumcr, CONFIG_SYS_SIUMCR_LOW, 0x9f3cc000);
|
2006-12-21 16:17:02 +00:00
|
|
|
}
|
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_siu_conf.sc_siumcr = CONFIG_SYS_SIUMCR;
|
2006-12-21 16:17:02 +00:00
|
|
|
#endif
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
config_8260_ioports (immr);
|
|
|
|
|
|
|
|
/* initialize time counter status and control register (4-40) */
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_sit.sit_tmcntsc = CONFIG_SYS_TMCNTSC;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
/* initialize the PIT (4-42) */
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_sit.sit_piscr = CONFIG_SYS_PISCR;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
#if !defined(CONFIG_COGENT) /* done in start.S for the cogent */
|
|
|
|
/* System clock control register (9-8) */
|
2004-03-14 16:51:43 +00:00
|
|
|
sccr = immr->im_clkrst.car_sccr &
|
|
|
|
(SCCR_PCI_MODE | SCCR_PCI_MODCK | SCCR_PCIDF_MSK);
|
|
|
|
immr->im_clkrst.car_sccr = sccr |
|
2008-10-16 13:01:15 +00:00
|
|
|
(CONFIG_SYS_SCCR & ~(SCCR_PCI_MODE | SCCR_PCI_MODCK | SCCR_PCIDF_MSK) );
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif /* !CONFIG_COGENT */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Memory Controller:
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
|
|
|
|
* addresses - these have to be modified later when FLASH size
|
|
|
|
* has been determined
|
|
|
|
*/
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR0_REMAP)
|
|
|
|
memctl->memc_or0 = CONFIG_SYS_OR0_REMAP;
|
2002-11-03 00:24:07 +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-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* now restrict to preliminary range */
|
2011-08-04 16:45:45 +00:00
|
|
|
/* the PS came from the HRCW, don't change it */
|
2008-10-16 13:01:15 +00:00
|
|
|
memctl->memc_br0 = SET_VAL_MASK(memctl->memc_br0 , CONFIG_SYS_BR0_PRELIM, BRx_PS_MSK);
|
|
|
|
memctl->memc_or0 = CONFIG_SYS_OR0_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR1_PRELIM) && defined(CONFIG_SYS_OR1_PRELIM)
|
|
|
|
memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM;
|
|
|
|
memctl->memc_br1 = CONFIG_SYS_BR1_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR2_PRELIM) && defined(CONFIG_SYS_OR2_PRELIM)
|
|
|
|
memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM;
|
|
|
|
memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR3_PRELIM) && defined(CONFIG_SYS_OR3_PRELIM)
|
|
|
|
memctl->memc_or3 = CONFIG_SYS_OR3_PRELIM;
|
|
|
|
memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR4_PRELIM) && defined(CONFIG_SYS_OR4_PRELIM)
|
|
|
|
memctl->memc_or4 = CONFIG_SYS_OR4_PRELIM;
|
|
|
|
memctl->memc_br4 = CONFIG_SYS_BR4_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR5_PRELIM) && defined(CONFIG_SYS_OR5_PRELIM)
|
|
|
|
memctl->memc_or5 = CONFIG_SYS_OR5_PRELIM;
|
|
|
|
memctl->memc_br5 = CONFIG_SYS_BR5_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR6_PRELIM) && defined(CONFIG_SYS_OR6_PRELIM)
|
|
|
|
memctl->memc_or6 = CONFIG_SYS_OR6_PRELIM;
|
|
|
|
memctl->memc_br6 = CONFIG_SYS_BR6_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR7_PRELIM) && defined(CONFIG_SYS_OR7_PRELIM)
|
|
|
|
memctl->memc_or7 = CONFIG_SYS_OR7_PRELIM;
|
|
|
|
memctl->memc_br7 = CONFIG_SYS_BR7_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR8_PRELIM) && defined(CONFIG_SYS_OR8_PRELIM)
|
|
|
|
memctl->memc_or8 = CONFIG_SYS_OR8_PRELIM;
|
|
|
|
memctl->memc_br8 = CONFIG_SYS_BR8_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR9_PRELIM) && defined(CONFIG_SYS_OR9_PRELIM)
|
|
|
|
memctl->memc_or9 = CONFIG_SYS_OR9_PRELIM;
|
|
|
|
memctl->memc_br9 = CONFIG_SYS_BR9_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR10_PRELIM) && defined(CONFIG_SYS_OR10_PRELIM)
|
|
|
|
memctl->memc_or10 = CONFIG_SYS_OR10_PRELIM;
|
|
|
|
memctl->memc_br10 = CONFIG_SYS_BR10_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_BR11_PRELIM) && defined(CONFIG_SYS_OR11_PRELIM)
|
|
|
|
memctl->memc_or11 = CONFIG_SYS_OR11_PRELIM;
|
|
|
|
memctl->memc_br11 = CONFIG_SYS_BR11_PRELIM;
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
m8260_cpm_reset ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initialize higher level parts of CPU like time base and timers
|
|
|
|
*/
|
|
|
|
int cpu_init_r (void)
|
|
|
|
{
|
|
|
|
volatile immap_t *immr = (immap_t *) gd->bd->bi_immr_base;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
immr->im_cpm.cp_rccr = CONFIG_SYS_RCCR;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* print out the reason for the reset
|
|
|
|
*/
|
|
|
|
int prt_8260_rsr (void)
|
|
|
|
{
|
|
|
|
static struct {
|
|
|
|
ulong mask;
|
|
|
|
char *desc;
|
|
|
|
} bits[] = {
|
|
|
|
{
|
|
|
|
RSR_JTRS, "JTAG"}, {
|
|
|
|
RSR_CSRS, "Check Stop"}, {
|
|
|
|
RSR_SWRS, "Software Watchdog"}, {
|
|
|
|
RSR_BMRS, "Bus Monitor"}, {
|
|
|
|
RSR_ESRS, "External Soft"}, {
|
|
|
|
RSR_EHRS, "External Hard"}
|
|
|
|
};
|
|
|
|
static int n = sizeof bits / sizeof bits[0];
|
|
|
|
ulong rsr = gd->reset_status;
|
|
|
|
int i;
|
|
|
|
char *sep;
|
|
|
|
|
2003-04-27 22:52:51 +00:00
|
|
|
puts (CPU_ID_STR " Reset Status:");
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
sep = " ";
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
if (rsr & bits[i].mask) {
|
|
|
|
printf ("%s%s", sep, bits[i].desc);
|
|
|
|
sep = ", ";
|
|
|
|
}
|
|
|
|
|
|
|
|
puts ("\n\n");
|
|
|
|
return (0);
|
|
|
|
}
|