2005-07-29 15:20:29 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002,2003, Motorola Inc.
|
|
|
|
* Xianghua Xiao, (X.Xiao@motorola.com)
|
|
|
|
*
|
|
|
|
* (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
|
|
|
|
*
|
|
|
|
* 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>
|
2008-08-31 17:45:44 +00:00
|
|
|
#include <netdev.h>
|
2005-07-29 15:20:29 +00:00
|
|
|
#include <asm/processor.h>
|
2008-08-27 04:52:32 +00:00
|
|
|
#include <asm/mmu.h>
|
2005-07-29 15:20:29 +00:00
|
|
|
#include <asm/immap_85xx.h>
|
2008-08-27 04:52:32 +00:00
|
|
|
#include <asm/fsl_ddr_sdram.h>
|
2008-03-04 16:03:03 +00:00
|
|
|
#include <spd_sdram.h>
|
2005-07-29 15:20:29 +00:00
|
|
|
|
|
|
|
long int fixed_sdram (void);
|
|
|
|
|
|
|
|
int board_pre_init (void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_PCI)
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_pcix_t *pci = (void *)(CONFIG_SYS_MPC85xx_PCIX_ADDR);
|
2005-07-29 15:20:29 +00:00
|
|
|
|
|
|
|
pci->peer &= 0xffffffdf; /* disable master abort */
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int checkboard (void)
|
|
|
|
{
|
|
|
|
sys_info_t sysinfo;
|
|
|
|
|
|
|
|
get_sys_info (&sysinfo);
|
|
|
|
|
|
|
|
printf ("Board: Freescale MPC8540EVAL Board\n");
|
2009-01-28 14:31:10 +00:00
|
|
|
printf ("\tCPU: %lu MHz\n", sysinfo.freqProcessor[0] / 1000000);
|
2005-07-29 15:20:29 +00:00
|
|
|
printf ("\tCCB: %lu MHz\n", sysinfo.freqSystemBus / 1000000);
|
|
|
|
printf ("\tDDR: %lu MHz\n", sysinfo.freqSystemBus / 2000000);
|
2008-10-16 13:01:15 +00:00
|
|
|
if((CONFIG_SYS_LBC_LCRR & 0x0f) == 2 || (CONFIG_SYS_LBC_LCRR & 0x0f) == 4 \
|
|
|
|
|| (CONFIG_SYS_LBC_LCRR & 0x0f) == 8) {
|
2005-08-01 18:20:47 +00:00
|
|
|
printf ("\tLBC: %lu MHz\n",
|
2008-10-16 13:01:15 +00:00
|
|
|
sysinfo.freqSystemBus / 1000000/(CONFIG_SYS_LBC_LCRR & 0x0f));
|
2005-07-29 15:20:29 +00:00
|
|
|
} else {
|
|
|
|
printf("\tLBC: unknown\n");
|
|
|
|
}
|
|
|
|
printf("L1 D-cache 32KB, L1 I-cache 32KB enabled.\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2008-06-09 21:03:40 +00:00
|
|
|
phys_size_t initdram (int board_type)
|
2005-07-29 15:20:29 +00:00
|
|
|
{
|
|
|
|
long dram_size = 0;
|
2008-03-04 16:03:03 +00:00
|
|
|
|
2005-07-29 15:20:29 +00:00
|
|
|
#if !defined(CONFIG_RAM_AS_FLASH)
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
|
2005-07-29 15:20:29 +00:00
|
|
|
sys_info_t sysinfo;
|
|
|
|
uint temp_lbcdll = 0;
|
|
|
|
#endif
|
|
|
|
#if !defined(CONFIG_RAM_AS_FLASH) || defined(CONFIG_DDR_DLL)
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
2005-07-29 15:20:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_DDR_DLL)
|
|
|
|
uint temp_ddrdll = 0;
|
|
|
|
|
|
|
|
/* Work around to stabilize DDR DLL */
|
|
|
|
temp_ddrdll = gur->ddrdllcr;
|
|
|
|
gur->ddrdllcr = ((temp_ddrdll & 0xff) << 16) | 0x80000000;
|
|
|
|
asm("sync;isync;msync");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_SPD_EEPROM)
|
2008-08-27 04:52:32 +00:00
|
|
|
dram_size = fsl_ddr_sdram();
|
|
|
|
dram_size = setup_ddr_tlbs(dram_size / 0x100000);
|
|
|
|
dram_size *= 0x100000;
|
2005-07-29 15:20:29 +00:00
|
|
|
#else
|
|
|
|
dram_size = fixed_sdram ();
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_RAMBOOT)
|
2005-07-29 15:20:29 +00:00
|
|
|
return dram_size;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(CONFIG_RAM_AS_FLASH) /* LocalBus is not emulating flash */
|
|
|
|
get_sys_info(&sysinfo);
|
2008-10-19 00:35:50 +00:00
|
|
|
/* if localbus freq is less than 66MHz,we use bypass mode,otherwise use DLL */
|
2008-12-03 23:16:34 +00:00
|
|
|
if(sysinfo.freqSystemBus/(CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV) < 66000000) {
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lcrr = (CONFIG_SYS_LBC_LCRR & 0x0fffffff)| 0x80000000;
|
2005-07-29 15:20:29 +00:00
|
|
|
} else {
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lcrr = CONFIG_SYS_LBC_LCRR & 0x7fffffff;
|
2005-07-29 15:20:29 +00:00
|
|
|
udelay(200);
|
|
|
|
temp_lbcdll = gur->lbcdllcr;
|
|
|
|
gur->lbcdllcr = ((temp_lbcdll & 0xff) << 16 ) | 0x80000000;
|
|
|
|
asm("sync;isync;msync");
|
|
|
|
}
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->or2 = CONFIG_SYS_OR2_PRELIM; /* 64MB SDRAM */
|
|
|
|
lbc->br2 = CONFIG_SYS_BR2_PRELIM;
|
|
|
|
lbc->lbcr = CONFIG_SYS_LBC_LBCR;
|
|
|
|
lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_1;
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync");
|
|
|
|
* (ulong *)0 = 0x000000ff;
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_2;
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync");
|
|
|
|
* (ulong *)0 = 0x000000ff;
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_3;
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync");
|
|
|
|
* (ulong *)0 = 0x000000ff;
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_4;
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync");
|
|
|
|
* (ulong *)0 = 0x000000ff;
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5;
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync");
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lsrt = CONFIG_SYS_LBC_LSRT;
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync");
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_DDR_ECC)
|
|
|
|
{
|
|
|
|
/* Initialize all of memory for ECC, then
|
|
|
|
* enable errors */
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
|
2009-06-30 22:15:47 +00:00
|
|
|
|
2009-06-30 22:15:48 +00:00
|
|
|
dma_meminit(CONFIG_MEM_INIT_VALUE, dram_size);
|
2005-07-29 15:20:29 +00:00
|
|
|
|
|
|
|
/* Enable errors for ECC */
|
|
|
|
ddr->err_disable = 0x00000000;
|
|
|
|
asm("sync;isync;msync");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return dram_size;
|
|
|
|
}
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_DRAM_TEST)
|
2005-07-29 15:20:29 +00:00
|
|
|
int testdram (void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
|
|
|
|
uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
|
2005-07-29 15:20:29 +00:00
|
|
|
uint *p;
|
|
|
|
|
|
|
|
printf("SDRAM test phase 1:\n");
|
|
|
|
for (p = pstart; p < pend; p++)
|
|
|
|
*p = 0xaaaaaaaa;
|
|
|
|
|
|
|
|
for (p = pstart; p < pend; p++) {
|
|
|
|
if (*p != 0xaaaaaaaa) {
|
|
|
|
printf ("SDRAM test fails at: %08x\n", (uint) p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("SDRAM test phase 2:\n");
|
|
|
|
for (p = pstart; p < pend; p++)
|
|
|
|
*p = 0x55555555;
|
|
|
|
|
|
|
|
for (p = pstart; p < pend; p++) {
|
|
|
|
if (*p != 0x55555555) {
|
|
|
|
printf ("SDRAM test fails at: %08x\n", (uint) p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("SDRAM test passed.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(CONFIG_SPD_EEPROM)
|
|
|
|
/*************************************************************************
|
|
|
|
* fixed sdram init -- doesn't use serial presence detect.
|
|
|
|
************************************************************************/
|
|
|
|
long int fixed_sdram (void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_RAMBOOT
|
|
|
|
volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
|
2005-07-29 15:20:29 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
|
|
|
|
ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
|
|
|
|
ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
|
|
|
|
ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
|
|
|
|
ddr->sdram_mode = CONFIG_SYS_DDR_MODE;
|
|
|
|
ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
|
2005-08-01 18:20:47 +00:00
|
|
|
#if defined (CONFIG_DDR_ECC)
|
2005-07-29 15:20:29 +00:00
|
|
|
ddr->err_disable = 0x0000000D;
|
|
|
|
ddr->err_sbe = 0x00ff0000;
|
2005-08-01 18:20:47 +00:00
|
|
|
#endif
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync;isync;msync");
|
|
|
|
udelay(500);
|
2005-08-01 18:20:47 +00:00
|
|
|
#if defined (CONFIG_DDR_ECC)
|
2005-07-29 15:20:29 +00:00
|
|
|
/* Enable ECC checking */
|
2008-10-16 13:01:15 +00:00
|
|
|
ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
|
2005-08-01 18:20:47 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
|
2005-08-01 18:20:47 +00:00
|
|
|
#endif
|
2005-07-29 15:20:29 +00:00
|
|
|
asm("sync; isync; msync");
|
|
|
|
udelay(500);
|
2005-08-01 18:20:47 +00:00
|
|
|
#endif
|
2008-10-16 13:01:15 +00:00
|
|
|
return (CONFIG_SYS_SDRAM_SIZE * 1024 * 1024);
|
2005-07-29 15:20:29 +00:00
|
|
|
}
|
|
|
|
#endif /* !defined(CONFIG_SPD_EEPROM) */
|
2008-08-31 17:45:44 +00:00
|
|
|
|
|
|
|
int board_eth_init(bd_t *bis)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This board either has PCI NICs or uses the CPU's TSECs
|
|
|
|
* pci_eth_init() will return 0 if no NICs found, so in that case
|
|
|
|
* returning -1 will force cpu_eth_init() to be called.
|
|
|
|
*/
|
|
|
|
int num = pci_eth_init(bis);
|
|
|
|
return (num <= 0 ? -1 : num);
|
|
|
|
}
|