2002-08-27 09:48:53 +00:00
|
|
|
/*
|
2007-10-05 15:10:59 +00:00
|
|
|
* (C) Copyright 2000-2007
|
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
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <watchdog.h>
|
2010-09-09 17:18:00 +00:00
|
|
|
#include <asm/ppc4xx-emac.h>
|
2002-08-27 09:48:53 +00:00
|
|
|
#include <asm/processor.h>
|
2010-09-16 12:30:37 +00:00
|
|
|
#include <asm/ppc4xx-gpio.h>
|
2010-09-09 17:18:00 +00:00
|
|
|
#include <asm/ppc4xx.h>
|
2002-08-27 09:48:53 +00:00
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PLL_RECONFIG
|
|
|
|
#define CONFIG_SYS_PLL_RECONFIG 0
|
2008-02-20 16:54:20 +00:00
|
|
|
#endif
|
|
|
|
|
2010-05-19 09:13:24 +00:00
|
|
|
#if defined(CONFIG_440EPX) || \
|
|
|
|
defined(CONFIG_460EX) || defined(CONFIG_460GT)
|
|
|
|
static void reset_with_rli(void)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set reload inhibit so configuration will persist across
|
|
|
|
* processor resets
|
|
|
|
*/
|
|
|
|
mfcpr(CPR0_ICFG, reg);
|
|
|
|
reg |= CPR0_ICFG_RLI_MASK;
|
|
|
|
mtcpr(CPR0_ICFG, reg);
|
|
|
|
|
|
|
|
/* Reset processor if configuration changed */
|
|
|
|
__asm__ __volatile__ ("sync; isync");
|
|
|
|
mtspr(SPRN_DBCR0, 0x20000000);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-02-20 16:54:20 +00:00
|
|
|
void reconfigure_pll(u32 new_cpu_freq)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_440EPX)
|
|
|
|
int reset_needed = 0;
|
|
|
|
u32 reg, temp;
|
|
|
|
u32 prbdv0, target_prbdv0, /* CLK_PRIMBD */
|
|
|
|
fwdva, target_fwdva, fwdvb, target_fwdvb, /* CLK_PLLD */
|
|
|
|
fbdv, target_fbdv, lfbdv, target_lfbdv,
|
|
|
|
perdv0, target_perdv0, /* CLK_PERD */
|
|
|
|
spcid0, target_spcid0; /* CLK_SPCID */
|
|
|
|
|
|
|
|
/* Reconfigure clocks if necessary.
|
|
|
|
* See PPC440EPx User's Manual, sections 8.2 and 14 */
|
|
|
|
if (new_cpu_freq == 667) {
|
|
|
|
target_prbdv0 = 2;
|
|
|
|
target_fwdva = 2;
|
|
|
|
target_fwdvb = 4;
|
|
|
|
target_fbdv = 20;
|
|
|
|
target_lfbdv = 1;
|
|
|
|
target_perdv0 = 4;
|
|
|
|
target_spcid0 = 4;
|
|
|
|
|
2009-10-04 18:04:20 +00:00
|
|
|
mfcpr(CPR0_PRIMBD0, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
temp = (reg & PRBDV_MASK) >> 24;
|
|
|
|
prbdv0 = temp ? temp : 8;
|
|
|
|
if (prbdv0 != target_prbdv0) {
|
|
|
|
reg &= ~PRBDV_MASK;
|
|
|
|
reg |= ((target_prbdv0 == 8 ? 0 : target_prbdv0) << 24);
|
2009-10-04 18:04:20 +00:00
|
|
|
mtcpr(CPR0_PRIMBD0, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
reset_needed = 1;
|
|
|
|
}
|
|
|
|
|
2009-09-09 14:25:29 +00:00
|
|
|
mfcpr(CPR0_PLLD, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
|
|
|
|
temp = (reg & PLLD_FWDVA_MASK) >> 16;
|
|
|
|
fwdva = temp ? temp : 16;
|
|
|
|
|
|
|
|
temp = (reg & PLLD_FWDVB_MASK) >> 8;
|
|
|
|
fwdvb = temp ? temp : 8;
|
|
|
|
|
|
|
|
temp = (reg & PLLD_FBDV_MASK) >> 24;
|
|
|
|
fbdv = temp ? temp : 32;
|
|
|
|
|
|
|
|
temp = (reg & PLLD_LFBDV_MASK);
|
|
|
|
lfbdv = temp ? temp : 64;
|
|
|
|
|
|
|
|
if (fwdva != target_fwdva || fbdv != target_fbdv || lfbdv != target_lfbdv) {
|
|
|
|
reg &= ~(PLLD_FWDVA_MASK | PLLD_FWDVB_MASK |
|
|
|
|
PLLD_FBDV_MASK | PLLD_LFBDV_MASK);
|
|
|
|
reg |= ((target_fwdva == 16 ? 0 : target_fwdva) << 16) |
|
|
|
|
((target_fwdvb == 8 ? 0 : target_fwdvb) << 8) |
|
|
|
|
((target_fbdv == 32 ? 0 : target_fbdv) << 24) |
|
|
|
|
(target_lfbdv == 64 ? 0 : target_lfbdv);
|
2009-09-09 14:25:29 +00:00
|
|
|
mtcpr(CPR0_PLLD, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
reset_needed = 1;
|
|
|
|
}
|
|
|
|
|
2009-09-09 14:25:29 +00:00
|
|
|
mfcpr(CPR0_PERD, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
perdv0 = (reg & CPR0_PERD_PERDV0_MASK) >> 24;
|
|
|
|
if (perdv0 != target_perdv0) {
|
|
|
|
reg &= ~CPR0_PERD_PERDV0_MASK;
|
|
|
|
reg |= (target_perdv0 << 24);
|
2009-09-09 14:25:29 +00:00
|
|
|
mtcpr(CPR0_PERD, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
reset_needed = 1;
|
|
|
|
}
|
|
|
|
|
2009-09-09 14:25:29 +00:00
|
|
|
mfcpr(CPR0_SPCID, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
temp = (reg & CPR0_SPCID_SPCIDV0_MASK) >> 24;
|
|
|
|
spcid0 = temp ? temp : 4;
|
|
|
|
if (spcid0 != target_spcid0) {
|
|
|
|
reg &= ~CPR0_SPCID_SPCIDV0_MASK;
|
|
|
|
reg |= ((target_spcid0 == 4 ? 0 : target_spcid0) << 24);
|
2009-09-09 14:25:29 +00:00
|
|
|
mtcpr(CPR0_SPCID, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
reset_needed = 1;
|
|
|
|
}
|
2010-03-24 11:22:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get current value of FWDVA.*/
|
|
|
|
mfcpr(CPR0_PLLD, reg);
|
|
|
|
temp = (reg & PLLD_FWDVA_MASK) >> 16;
|
2008-02-20 16:54:20 +00:00
|
|
|
|
2010-03-24 11:22:02 +00:00
|
|
|
/*
|
|
|
|
* Check to see if FWDVA has been set to value of 1. if it has we must
|
|
|
|
* modify it.
|
|
|
|
*/
|
|
|
|
if (temp == 1) {
|
|
|
|
/*
|
|
|
|
* Load register that contains current boot strapping option.
|
|
|
|
*/
|
|
|
|
mfcpr(CPR0_ICFG, reg);
|
2010-08-26 15:14:51 +00:00
|
|
|
/*
|
|
|
|
* Strapping option bits (ICS) are already in correct position,
|
|
|
|
* only masking needed.
|
|
|
|
*/
|
|
|
|
reg &= CPR0_ICFG_ICS_MASK;
|
2010-03-24 11:22:02 +00:00
|
|
|
|
|
|
|
if ((reg == BOOT_STRAP_OPTION_A) || (reg == BOOT_STRAP_OPTION_B) ||
|
|
|
|
(reg == BOOT_STRAP_OPTION_D) || (reg == BOOT_STRAP_OPTION_E)) {
|
2010-08-26 15:14:51 +00:00
|
|
|
mfcpr(CPR0_PLLD, reg);
|
|
|
|
|
|
|
|
/* Get current value of fbdv. */
|
|
|
|
temp = (reg & PLLD_FBDV_MASK) >> 24;
|
|
|
|
fbdv = temp ? temp : 32;
|
|
|
|
|
|
|
|
/* Get current value of lfbdv. */
|
|
|
|
temp = (reg & PLLD_LFBDV_MASK);
|
|
|
|
lfbdv = temp ? temp : 64;
|
|
|
|
|
2010-03-24 11:22:02 +00:00
|
|
|
/*
|
|
|
|
* Get current value of FWDVA. Assign current FWDVA to
|
|
|
|
* new FWDVB.
|
|
|
|
*/
|
|
|
|
mfcpr(CPR0_PLLD, reg);
|
|
|
|
target_fwdvb = (reg & PLLD_FWDVA_MASK) >> 16;
|
|
|
|
fwdvb = target_fwdvb ? target_fwdvb : 8;
|
2010-08-26 15:14:51 +00:00
|
|
|
|
2010-03-24 11:22:02 +00:00
|
|
|
/*
|
|
|
|
* Get current value of FWDVB. Assign current FWDVB to
|
|
|
|
* new FWDVA.
|
|
|
|
*/
|
|
|
|
target_fwdva = (reg & PLLD_FWDVB_MASK) >> 8;
|
|
|
|
fwdva = target_fwdva ? target_fwdva : 16;
|
2010-08-26 15:14:51 +00:00
|
|
|
|
2010-03-24 11:22:02 +00:00
|
|
|
/*
|
|
|
|
* Update CPR0_PLLD with switched FWDVA and FWDVB.
|
|
|
|
*/
|
|
|
|
reg &= ~(PLLD_FWDVA_MASK | PLLD_FWDVB_MASK |
|
|
|
|
PLLD_FBDV_MASK | PLLD_LFBDV_MASK);
|
|
|
|
reg |= ((fwdva == 16 ? 0 : fwdva) << 16) |
|
|
|
|
((fwdvb == 8 ? 0 : fwdvb) << 8) |
|
|
|
|
((fbdv == 32 ? 0 : fbdv) << 24) |
|
|
|
|
(lfbdv == 64 ? 0 : lfbdv);
|
|
|
|
mtcpr(CPR0_PLLD, reg);
|
2010-08-26 15:14:51 +00:00
|
|
|
|
2010-03-24 11:22:02 +00:00
|
|
|
/* Acknowledge that a reset is required. */
|
|
|
|
reset_needed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-19 09:13:24 +00:00
|
|
|
/* Now reset the CPU if needed */
|
|
|
|
if (reset_needed)
|
|
|
|
reset_with_rli();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See "9.2.1.1 Booting with Option E" in the 460EX/GT
|
|
|
|
* users manual
|
|
|
|
*/
|
|
|
|
mfcpr(CPR0_PLLC, reg);
|
|
|
|
if ((reg & (CPR0_PLLC_RST | CPR0_PLLC_ENG)) == CPR0_PLLC_RST) {
|
2010-03-24 11:22:02 +00:00
|
|
|
/*
|
2010-05-19 09:13:24 +00:00
|
|
|
* Set engage bit
|
2010-03-24 11:22:02 +00:00
|
|
|
*/
|
2010-05-19 09:13:24 +00:00
|
|
|
reg = (reg & ~CPR0_PLLC_RST) | CPR0_PLLC_ENG;
|
|
|
|
mtcpr(CPR0_PLLC, reg);
|
2008-02-20 16:54:20 +00:00
|
|
|
|
2010-05-19 09:13:24 +00:00
|
|
|
/* Now reset the CPU */
|
|
|
|
reset_with_rli();
|
2008-02-20 16:54:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-05-05 14:08:35 +00:00
|
|
|
#ifdef CONFIG_SYS_4xx_CHIP_21_ERRATA
|
|
|
|
void
|
|
|
|
chip_21_errata(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* See rev 1.09 of the 405EX/405EXr errata. CHIP_21 says that
|
|
|
|
* sometimes reading the PVR and/or SDR0_ECID results in incorrect
|
|
|
|
* values. Since the rev-D chip uses the SDR0_ECID bits to control
|
|
|
|
* internal features, that means the second PCIe or ethernet of an EX
|
|
|
|
* variant could fail to work. Also, security features of both EX and
|
|
|
|
* EXr might be incorrectly disabled.
|
|
|
|
*
|
|
|
|
* The suggested workaround is as follows (covering rev-C and rev-D):
|
|
|
|
*
|
|
|
|
* 1.Read the PVR and SDR0_ECID3.
|
|
|
|
*
|
|
|
|
* 2.If the PVR matches an expected Revision C PVR value AND if
|
|
|
|
* SDR0_ECID3[12:15] is different from PVR[28:31], then processor is
|
|
|
|
* Revision C: continue executing the initialization code (no reset
|
|
|
|
* required). else go to step 3.
|
|
|
|
*
|
|
|
|
* 3.If the PVR matches an expected Revision D PVR value AND if
|
|
|
|
* SDR0_ECID3[10:11] matches its expected value, then continue
|
|
|
|
* executing initialization code, no reset required. else write
|
|
|
|
* DBCR0[RST] = 0b11 to generate a SysReset.
|
|
|
|
*/
|
|
|
|
|
|
|
|
u32 pvr;
|
|
|
|
u32 pvr_28_31;
|
|
|
|
u32 ecid3;
|
|
|
|
u32 ecid3_10_11;
|
|
|
|
u32 ecid3_12_15;
|
|
|
|
|
|
|
|
/* Step 1: */
|
|
|
|
pvr = get_pvr();
|
|
|
|
mfsdr(SDR0_ECID3, ecid3);
|
|
|
|
|
|
|
|
/* Step 2: */
|
|
|
|
pvr_28_31 = pvr & 0xf;
|
|
|
|
ecid3_10_11 = (ecid3 >> 20) & 0x3;
|
|
|
|
ecid3_12_15 = (ecid3 >> 16) & 0xf;
|
|
|
|
if ((pvr == CONFIG_405EX_CHIP21_PVR_REV_C) &&
|
|
|
|
(pvr_28_31 != ecid3_12_15)) {
|
|
|
|
/* No reset required. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Step 3: */
|
|
|
|
if ((pvr == CONFIG_405EX_CHIP21_PVR_REV_D) &&
|
|
|
|
(ecid3_10_11 == CONFIG_405EX_CHIP21_ECID3_REV_D)) {
|
|
|
|
/* No reset required. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset required. */
|
|
|
|
__asm__ __volatile__ ("sync; isync");
|
|
|
|
mtspr(SPRN_DBCR0, 0x30000000);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-08-27 09:48:53 +00:00
|
|
|
/*
|
|
|
|
* Breath some life into the CPU...
|
|
|
|
*
|
2008-02-20 16:54:20 +00:00
|
|
|
* Reconfigure PLL if necessary,
|
|
|
|
* set up the memory map,
|
2002-08-27 09:48:53 +00:00
|
|
|
* initialize a bunch of registers
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cpu_init_f (void)
|
|
|
|
{
|
2008-08-21 09:05:03 +00:00
|
|
|
#if defined(CONFIG_WATCHDOG) || defined(CONFIG_440GX) || defined(CONFIG_460EX)
|
2008-06-28 12:56:17 +00:00
|
|
|
u32 val;
|
2007-01-15 12:41:04 +00:00
|
|
|
#endif
|
2008-06-26 15:36:39 +00:00
|
|
|
|
2011-05-05 14:08:35 +00:00
|
|
|
#ifdef CONFIG_SYS_4xx_CHIP_21_ERRATA
|
|
|
|
chip_21_errata();
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
reconfigure_pll(CONFIG_SYS_PLL_RECONFIG);
|
2007-01-15 12:41:04 +00:00
|
|
|
|
2010-09-28 21:15:14 +00:00
|
|
|
#if (defined(CONFIG_405EP) || defined (CONFIG_405EX)) && \
|
2014-09-28 16:37:59 +00:00
|
|
|
!defined(CONFIG_SYS_4xx_GPIO_TABLE)
|
2003-05-23 11:18:02 +00:00
|
|
|
/*
|
|
|
|
* GPIO0 setup (select GPIO or alternate function)
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_GPIO0_OR)
|
|
|
|
out32(GPIO0_OR, CONFIG_SYS_GPIO0_OR); /* set initial state of output pins */
|
2006-10-12 17:43:29 +00:00
|
|
|
#endif
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_GPIO0_ODR)
|
|
|
|
out32(GPIO0_ODR, CONFIG_SYS_GPIO0_ODR); /* open-drain select */
|
2006-10-12 17:43:29 +00:00
|
|
|
#endif
|
2008-10-16 13:01:15 +00:00
|
|
|
out32(GPIO0_OSRH, CONFIG_SYS_GPIO0_OSRH); /* output select */
|
|
|
|
out32(GPIO0_OSRL, CONFIG_SYS_GPIO0_OSRL);
|
|
|
|
out32(GPIO0_ISR1H, CONFIG_SYS_GPIO0_ISR1H); /* input select */
|
|
|
|
out32(GPIO0_ISR1L, CONFIG_SYS_GPIO0_ISR1L);
|
|
|
|
out32(GPIO0_TSRH, CONFIG_SYS_GPIO0_TSRH); /* three-state select */
|
|
|
|
out32(GPIO0_TSRL, CONFIG_SYS_GPIO0_TSRL);
|
|
|
|
#if defined(CONFIG_SYS_GPIO0_ISR2H)
|
|
|
|
out32(GPIO0_ISR2H, CONFIG_SYS_GPIO0_ISR2H);
|
|
|
|
out32(GPIO0_ISR2L, CONFIG_SYS_GPIO0_ISR2L);
|
2007-10-05 15:10:59 +00:00
|
|
|
#endif
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined (CONFIG_SYS_GPIO0_TCR)
|
|
|
|
out32(GPIO0_TCR, CONFIG_SYS_GPIO0_TCR); /* enable output driver for outputs */
|
2007-10-05 15:10:59 +00:00
|
|
|
#endif
|
2008-10-16 13:01:15 +00:00
|
|
|
#endif /* CONFIG_405EP ... && !CONFIG_SYS_4xx_GPIO_TABLE */
|
2003-05-23 11:18:02 +00:00
|
|
|
|
2007-12-28 14:53:46 +00:00
|
|
|
#if defined (CONFIG_405EP)
|
2003-05-23 11:18:02 +00:00
|
|
|
/*
|
|
|
|
* Set EMAC noise filter bits
|
|
|
|
*/
|
2010-09-12 04:21:37 +00:00
|
|
|
mtdcr(CPC0_EPCTL, CPC0_EPCTL_E0NFE | CPC0_EPCTL_E1NFE);
|
2003-05-23 11:18:02 +00:00
|
|
|
#endif /* CONFIG_405EP */
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_4xx_GPIO_TABLE)
|
2007-03-24 14:57:09 +00:00
|
|
|
gpio_set_chip_configuration();
|
2008-10-16 13:01:15 +00:00
|
|
|
#endif /* CONFIG_SYS_4xx_GPIO_TABLE */
|
2006-06-02 14:18:04 +00:00
|
|
|
|
2002-08-27 09:48:53 +00:00
|
|
|
/*
|
|
|
|
* External Bus Controller (EBC) Setup
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_EBC_PB0AP) && defined(CONFIG_SYS_EBC_PB0CR))
|
2013-08-07 10:10:38 +00:00
|
|
|
#if (defined(CONFIG_405GP) || \
|
2007-03-21 12:38:59 +00:00
|
|
|
defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
|
2007-10-05 15:10:59 +00:00
|
|
|
defined(CONFIG_405EX) || defined(CONFIG_405))
|
2002-08-27 09:48:53 +00:00
|
|
|
/*
|
|
|
|
* Move the next instructions into icache, since these modify the flash
|
|
|
|
* we are running from!
|
|
|
|
*/
|
|
|
|
asm volatile(" bl 0f" ::: "lr");
|
|
|
|
asm volatile("0: mflr 3" ::: "r3");
|
2007-06-22 21:59:00 +00:00
|
|
|
asm volatile(" addi 4, 0, 14" ::: "r4");
|
2002-08-27 09:48:53 +00:00
|
|
|
asm volatile(" mtctr 4" ::: "ctr");
|
|
|
|
asm volatile("1: icbt 0, 3");
|
|
|
|
asm volatile(" addi 3, 3, 32" ::: "r3");
|
|
|
|
asm volatile(" bdnz 1b" ::: "ctr", "cr0");
|
|
|
|
asm volatile(" addis 3, 0, 0x0" ::: "r3");
|
|
|
|
asm volatile(" ori 3, 3, 0xA000" ::: "r3");
|
|
|
|
asm volatile(" mtctr 3" ::: "ctr");
|
|
|
|
asm volatile("2: bdnz 2b" ::: "ctr", "cr0");
|
2006-06-02 14:18:04 +00:00
|
|
|
#endif
|
2002-08-27 09:48:53 +00:00
|
|
|
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc(PB0AP, CONFIG_SYS_EBC_PB0AP);
|
|
|
|
mtebc(PB0CR, CONFIG_SYS_EBC_PB0CR);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_EBC_PB1AP) && defined(CONFIG_SYS_EBC_PB1CR) && !(CONFIG_SYS_INIT_DCACHE_CS == 1))
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc(PB1AP, CONFIG_SYS_EBC_PB1AP);
|
|
|
|
mtebc(PB1CR, CONFIG_SYS_EBC_PB1CR);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_EBC_PB2AP) && defined(CONFIG_SYS_EBC_PB2CR) && !(CONFIG_SYS_INIT_DCACHE_CS == 2))
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc(PB2AP, CONFIG_SYS_EBC_PB2AP);
|
|
|
|
mtebc(PB2CR, CONFIG_SYS_EBC_PB2CR);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_EBC_PB3AP) && defined(CONFIG_SYS_EBC_PB3CR) && !(CONFIG_SYS_INIT_DCACHE_CS == 3))
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc(PB3AP, CONFIG_SYS_EBC_PB3AP);
|
|
|
|
mtebc(PB3CR, CONFIG_SYS_EBC_PB3CR);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_EBC_PB4AP) && defined(CONFIG_SYS_EBC_PB4CR) && !(CONFIG_SYS_INIT_DCACHE_CS == 4))
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc(PB4AP, CONFIG_SYS_EBC_PB4AP);
|
|
|
|
mtebc(PB4CR, CONFIG_SYS_EBC_PB4CR);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_EBC_PB5AP) && defined(CONFIG_SYS_EBC_PB5CR) && !(CONFIG_SYS_INIT_DCACHE_CS == 5))
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc(PB5AP, CONFIG_SYS_EBC_PB5AP);
|
|
|
|
mtebc(PB5CR, CONFIG_SYS_EBC_PB5CR);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_EBC_PB6AP) && defined(CONFIG_SYS_EBC_PB6CR) && !(CONFIG_SYS_INIT_DCACHE_CS == 6))
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc(PB6AP, CONFIG_SYS_EBC_PB6AP);
|
|
|
|
mtebc(PB6CR, CONFIG_SYS_EBC_PB6CR);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if (defined(CONFIG_SYS_EBC_PB7AP) && defined(CONFIG_SYS_EBC_PB7CR) && !(CONFIG_SYS_INIT_DCACHE_CS == 7))
|
2009-09-09 14:25:29 +00:00
|
|
|
mtebc(PB7AP, CONFIG_SYS_EBC_PB7AP);
|
|
|
|
mtebc(PB7CR, CONFIG_SYS_EBC_PB7CR);
|
2002-08-27 09:48:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined (CONFIG_SYS_EBC_CFG)
|
|
|
|
mtebc(EBC0_CFG, CONFIG_SYS_EBC_CFG);
|
2007-01-11 14:44:44 +00:00
|
|
|
#endif
|
2002-08-27 09:48:53 +00:00
|
|
|
|
2007-01-15 12:41:04 +00:00
|
|
|
#if defined(CONFIG_WATCHDOG)
|
2010-10-04 09:09:40 +00:00
|
|
|
val = mfspr(SPRN_TCR);
|
2005-08-08 10:42:22 +00:00
|
|
|
#if defined(CONFIG_440EP) || defined(CONFIG_440GR)
|
2005-08-01 14:41:48 +00:00
|
|
|
val |= 0xb8000000; /* generate system reset after 1.34 seconds */
|
2007-03-28 15:06:19 +00:00
|
|
|
#elif defined(CONFIG_440EPX)
|
|
|
|
val |= 0xb0000000; /* generate system reset after 1.34 seconds */
|
2005-08-01 14:41:48 +00:00
|
|
|
#else
|
2002-08-27 09:48:53 +00:00
|
|
|
val |= 0xf0000000; /* generate system reset after 2.684 seconds */
|
2006-11-27 13:12:17 +00:00
|
|
|
#endif
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_4xx_RESET_TYPE)
|
2006-11-27 13:12:17 +00:00
|
|
|
val &= ~0x30000000; /* clear WRC bits */
|
2008-10-16 13:01:15 +00:00
|
|
|
val |= CONFIG_SYS_4xx_RESET_TYPE << 28; /* set board specific WRC type */
|
2005-08-01 14:41:48 +00:00
|
|
|
#endif
|
2010-10-04 09:09:40 +00:00
|
|
|
mtspr(SPRN_TCR, val);
|
2002-08-27 09:48:53 +00:00
|
|
|
|
2010-10-04 09:09:40 +00:00
|
|
|
val = mfspr(SPRN_TSR);
|
2002-08-27 09:48:53 +00:00
|
|
|
val |= 0x80000000; /* enable watchdog timer */
|
2010-10-04 09:09:40 +00:00
|
|
|
mtspr(SPRN_TSR, val);
|
2002-08-27 09:48:53 +00:00
|
|
|
|
|
|
|
reset_4xx_watchdog();
|
|
|
|
#endif /* CONFIG_WATCHDOG */
|
2008-06-28 12:56:17 +00:00
|
|
|
|
2008-06-26 15:36:39 +00:00
|
|
|
#if defined(CONFIG_440GX)
|
|
|
|
/* Take the GX out of compatibility mode
|
|
|
|
* Travis Sawyer, 9 Mar 2004
|
|
|
|
* NOTE: 440gx user manual inconsistency here
|
|
|
|
* Compatibility mode and Ethernet Clock select are not
|
|
|
|
* correct in the manual
|
|
|
|
*/
|
2009-09-09 14:25:29 +00:00
|
|
|
mfsdr(SDR0_MFR, val);
|
2008-06-26 15:36:39 +00:00
|
|
|
val &= ~0x10000000;
|
2009-09-09 14:25:29 +00:00
|
|
|
mtsdr(SDR0_MFR,val);
|
2008-06-26 15:36:39 +00:00
|
|
|
#endif /* CONFIG_440GX */
|
|
|
|
|
2008-06-28 12:56:17 +00:00
|
|
|
#if defined(CONFIG_460EX)
|
|
|
|
/*
|
|
|
|
* Set SDR0_AHB_CFG[A2P_INCR4] (bit 24) and
|
|
|
|
* clear SDR0_AHB_CFG[A2P_PROT2] (bit 25) for a new 460EX errata
|
|
|
|
* regarding concurrent use of AHB USB OTG, USB 2.0 host and SATA
|
|
|
|
*/
|
|
|
|
mfsdr(SDR0_AHB_CFG, val);
|
|
|
|
val |= 0x80;
|
|
|
|
val &= ~0x40;
|
|
|
|
mtsdr(SDR0_AHB_CFG, val);
|
|
|
|
mfsdr(SDR0_USB2HOST_CFG, val);
|
|
|
|
val &= ~0xf00;
|
|
|
|
val |= 0x400;
|
|
|
|
mtsdr(SDR0_USB2HOST_CFG, val);
|
|
|
|
#endif /* CONFIG_460EX */
|
2008-08-20 16:38:51 +00:00
|
|
|
|
2008-08-21 09:05:03 +00:00
|
|
|
#if defined(CONFIG_405EX) || \
|
|
|
|
defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
|
2008-08-20 16:38:51 +00:00
|
|
|
defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
|
2014-09-28 16:37:59 +00:00
|
|
|
defined(CONFIG_460SX)
|
2008-08-20 16:38:51 +00:00
|
|
|
/*
|
|
|
|
* Set PLB4 arbiter (Segment 0 and 1) to 4 deep pipeline read
|
|
|
|
*/
|
2010-09-11 07:31:43 +00:00
|
|
|
mtdcr(PLB4A0_ACR, (mfdcr(PLB4A0_ACR) & ~PLB4Ax_ACR_RDP_MASK) |
|
|
|
|
PLB4Ax_ACR_RDP_4DEEP);
|
|
|
|
mtdcr(PLB4A1_ACR, (mfdcr(PLB4A1_ACR) & ~PLB4Ax_ACR_RDP_MASK) |
|
|
|
|
PLB4Ax_ACR_RDP_4DEEP);
|
2008-08-20 16:38:51 +00:00
|
|
|
#endif /* CONFIG_440SP/SPE || CONFIG_460EX/GT || CONFIG_405EX */
|
2002-08-27 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initialize higher level parts of CPU like time base and timers
|
|
|
|
*/
|
|
|
|
int cpu_init_r (void)
|
|
|
|
{
|
2003-05-23 11:18:02 +00:00
|
|
|
#if defined(CONFIG_405GP)
|
2003-03-20 15:21:50 +00:00
|
|
|
uint pvr = get_pvr();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set edge conditioning circuitry on PPC405GPr
|
|
|
|
* for compatibility to existing PPC405GP designs.
|
|
|
|
*/
|
2003-04-04 16:00:33 +00:00
|
|
|
if ((pvr & 0xfffffff0) == (PVR_405GPR_RB & 0xfffffff0)) {
|
2009-09-09 14:25:29 +00:00
|
|
|
mtdcr(CPC0_ECR, 0x60606000);
|
2003-03-20 15:21:50 +00:00
|
|
|
}
|
2003-05-23 11:18:02 +00:00
|
|
|
#endif /* defined(CONFIG_405GP) */
|
2008-03-11 14:05:50 +00:00
|
|
|
|
2009-02-23 15:42:51 +00:00
|
|
|
return 0;
|
2002-08-27 09:48:53 +00:00
|
|
|
}
|
2009-10-19 12:06:23 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_PCI) && \
|
|
|
|
(defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
|
|
|
|
defined(CONFIG_440GR) || defined(CONFIG_440GRX))
|
|
|
|
/*
|
|
|
|
* 440EP(x)/GR(x) PCI async/sync clocking restriction:
|
|
|
|
*
|
|
|
|
* In asynchronous PCI mode, the synchronous PCI clock must meet
|
|
|
|
* certain requirements. The following equation describes the
|
|
|
|
* relationship that must be maintained between the asynchronous PCI
|
|
|
|
* clock and synchronous PCI clock. Select an appropriate PCI:PLB
|
|
|
|
* ratio to maintain the relationship:
|
|
|
|
*
|
|
|
|
* AsyncPCIClk - 1MHz <= SyncPCIclock <= (2 * AsyncPCIClk) - 1MHz
|
|
|
|
*/
|
|
|
|
static int ppc4xx_pci_sync_clock_ok(u32 sync, u32 async)
|
|
|
|
{
|
|
|
|
if (((async - 1000000) > sync) || (sync > ((2 * async) - 1000000)))
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ppc4xx_pci_sync_clock_config(u32 async)
|
|
|
|
{
|
|
|
|
sys_info_t sys_info;
|
|
|
|
u32 sync;
|
|
|
|
int div;
|
|
|
|
u32 reg;
|
|
|
|
u32 spcid_val[] = {
|
|
|
|
CPR0_SPCID_SPCIDV0_DIV1, CPR0_SPCID_SPCIDV0_DIV2,
|
|
|
|
CPR0_SPCID_SPCIDV0_DIV3, CPR0_SPCID_SPCIDV0_DIV4 };
|
|
|
|
|
|
|
|
get_sys_info(&sys_info);
|
|
|
|
sync = sys_info.freqPCI;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First check if the equation above is met
|
|
|
|
*/
|
|
|
|
if (!ppc4xx_pci_sync_clock_ok(sync, async)) {
|
|
|
|
/*
|
|
|
|
* Reconfigure PCI sync clock to meet the equation.
|
|
|
|
* Start with highest possible PCI sync frequency
|
|
|
|
* (divider 1).
|
|
|
|
*/
|
|
|
|
for (div = 1; div <= 4; div++) {
|
|
|
|
sync = sys_info.freqPLB / div;
|
|
|
|
if (ppc4xx_pci_sync_clock_ok(sync, async))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (div <= 4) {
|
|
|
|
mtcpr(CPR0_SPCID, spcid_val[div]);
|
|
|
|
|
|
|
|
mfcpr(CPR0_ICFG, reg);
|
|
|
|
reg |= CPR0_ICFG_RLI_MASK;
|
|
|
|
mtcpr(CPR0_ICFG, reg);
|
|
|
|
|
|
|
|
/* do chip reset */
|
|
|
|
mtspr(SPRN_DBCR0, 0x20000000);
|
|
|
|
} else {
|
|
|
|
/* Impossible to configure the PCI sync clock */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|