2008-01-16 06:38:05 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Freescale Semiconductor, Inc.
|
|
|
|
* Kevin Lam <kevin.lam@freescale.com>
|
|
|
|
* Joe D'Abbraccio <joe.d'abbraccio@freescale.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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2009-06-09 20:25:30 +00:00
|
|
|
#include <hwconfig.h>
|
2008-01-16 06:38:05 +00:00
|
|
|
#include <i2c.h>
|
|
|
|
#include <asm/io.h>
|
2010-04-20 15:02:24 +00:00
|
|
|
#include <asm/fsl_mpc83xx_serdes.h>
|
2008-04-02 11:41:21 +00:00
|
|
|
#include <fdt_support.h>
|
2008-01-16 06:38:05 +00:00
|
|
|
#include <spd_sdram.h>
|
2008-02-08 19:15:55 +00:00
|
|
|
#include <vsc7385.h>
|
2009-06-09 20:25:30 +00:00
|
|
|
#include <fsl_esdhc.h>
|
2008-02-08 19:15:55 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_DRAM_TEST)
|
2008-01-16 06:38:05 +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;
|
2008-01-16 06:38:05 +00:00
|
|
|
uint *p;
|
|
|
|
|
|
|
|
printf("Testing DRAM from 0x%08x to 0x%08x\n",
|
2008-10-16 13:01:15 +00:00
|
|
|
CONFIG_SYS_MEMTEST_START,
|
|
|
|
CONFIG_SYS_MEMTEST_END);
|
2008-01-16 06:38:05 +00:00
|
|
|
|
|
|
|
printf("DRAM test phase 1:\n");
|
|
|
|
for (p = pstart; p < pend; p++)
|
|
|
|
*p = 0xaaaaaaaa;
|
|
|
|
|
|
|
|
for (p = pstart; p < pend; p++) {
|
|
|
|
if (*p != 0xaaaaaaaa) {
|
|
|
|
printf("DRAM test fails at: %08x\n", (uint) p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("DRAM test phase 2:\n");
|
|
|
|
for (p = pstart; p < pend; p++)
|
|
|
|
*p = 0x55555555;
|
|
|
|
|
|
|
|
for (p = pstart; p < pend; p++) {
|
|
|
|
if (*p != 0x55555555) {
|
|
|
|
printf("DRAM test fails at: %08x\n", (uint) p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("DRAM test passed.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-30 22:15:50 +00:00
|
|
|
#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
|
2008-01-16 06:38:05 +00:00
|
|
|
void ddr_enable_ecc(unsigned int dram_size);
|
|
|
|
#endif
|
|
|
|
int fixed_sdram(void);
|
|
|
|
|
2008-06-09 21:03:40 +00:00
|
|
|
phys_size_t initdram(int board_type)
|
2008-01-16 06:38:05 +00:00
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
|
2008-01-16 06:38:05 +00:00
|
|
|
u32 msize = 0;
|
|
|
|
|
|
|
|
if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#if defined(CONFIG_SPD_EEPROM)
|
|
|
|
msize = spd_sdram();
|
|
|
|
#else
|
|
|
|
msize = fixed_sdram();
|
|
|
|
#endif
|
|
|
|
|
2009-06-30 22:15:50 +00:00
|
|
|
#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
|
2008-01-16 06:38:05 +00:00
|
|
|
/* Initialize DDR ECC byte */
|
|
|
|
ddr_enable_ecc(msize * 1024 * 1024);
|
|
|
|
#endif
|
|
|
|
/* return total bus DDR size(bytes) */
|
|
|
|
return (msize * 1024 * 1024);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_SPD_EEPROM)
|
|
|
|
/*************************************************************************
|
|
|
|
* fixed sdram init -- doesn't use serial presence detect.
|
|
|
|
************************************************************************/
|
|
|
|
int fixed_sdram(void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
|
|
|
|
u32 msize = CONFIG_SYS_DDR_SIZE * 1024 * 1024;
|
2008-01-16 06:38:05 +00:00
|
|
|
u32 msize_log2 = __ilog2(msize);
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
|
2008-01-16 06:38:05 +00:00
|
|
|
im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR_VALUE;
|
2008-01-16 06:38:05 +00:00
|
|
|
udelay(50000);
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_SDRAM_CLK_CNTL;
|
2008-01-16 06:38:05 +00:00
|
|
|
udelay(1000);
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
|
|
|
|
im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
|
2008-01-16 06:38:05 +00:00
|
|
|
udelay(1000);
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
|
|
|
|
im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
|
|
|
|
im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
|
|
|
|
im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
|
|
|
|
im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
|
|
|
|
im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
|
|
|
|
im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
|
|
|
|
im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
|
|
|
|
im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
|
2008-01-16 06:38:05 +00:00
|
|
|
sync();
|
|
|
|
udelay(1000);
|
|
|
|
|
|
|
|
im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
|
|
|
|
udelay(2000);
|
2008-10-16 13:01:15 +00:00
|
|
|
return CONFIG_SYS_DDR_SIZE;
|
2008-01-16 06:38:05 +00:00
|
|
|
}
|
2008-10-16 13:01:15 +00:00
|
|
|
#endif /*!CONFIG_SYS_SPD_EEPROM */
|
2008-01-16 06:38:05 +00:00
|
|
|
|
|
|
|
int checkboard(void)
|
|
|
|
{
|
|
|
|
puts("Board: Freescale MPC837xERDB\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-24 14:40:43 +00:00
|
|
|
int board_early_init_f(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_FSL_SERDES
|
2008-10-16 13:01:15 +00:00
|
|
|
immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
|
2008-03-24 14:40:43 +00:00
|
|
|
u32 spridr = in_be32(&immr->sysconf.spridr);
|
|
|
|
|
|
|
|
/* we check only part num, and don't look for CPU revisions */
|
2008-03-28 15:19:07 +00:00
|
|
|
switch (PARTID_NO_E(spridr)) {
|
|
|
|
case SPR_8377:
|
2008-03-24 14:40:43 +00:00
|
|
|
fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
|
|
|
|
FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
|
2008-03-28 15:19:07 +00:00
|
|
|
fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_PEX,
|
2008-03-24 14:40:43 +00:00
|
|
|
FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
|
|
|
|
break;
|
2008-03-28 15:19:07 +00:00
|
|
|
case SPR_8378:
|
2008-10-02 14:31:53 +00:00
|
|
|
fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_PEX,
|
2008-03-24 14:40:43 +00:00
|
|
|
FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
|
|
|
|
break;
|
2008-03-28 15:19:07 +00:00
|
|
|
case SPR_8379:
|
2008-03-24 14:40:43 +00:00
|
|
|
fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
|
|
|
|
FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
|
2008-03-28 15:19:07 +00:00
|
|
|
fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_SATA,
|
2008-03-24 14:40:43 +00:00
|
|
|
FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("serdes not configured: unknown CPU part number: "
|
|
|
|
"%04x\n", spridr >> 16);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_FSL_SERDES */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-09 20:25:30 +00:00
|
|
|
#ifdef CONFIG_FSL_ESDHC
|
|
|
|
int board_mmc_init(bd_t *bd)
|
|
|
|
{
|
|
|
|
struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR;
|
|
|
|
|
|
|
|
if (!hwconfig("esdhc"))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
clrsetbits_be32(&im->sysconf.sicrl, SICRL_USB_B, SICRL_USB_B_SD);
|
|
|
|
clrsetbits_be32(&im->sysconf.sicrh, SICRH_SPI, SICRH_SPI_SD);
|
|
|
|
|
|
|
|
return fsl_esdhc_mmc_init(bd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-02-08 19:15:55 +00:00
|
|
|
/*
|
|
|
|
* Miscellaneous late-boot configurations
|
|
|
|
*
|
|
|
|
* If a VSC7385 microcode image is present, then upload it.
|
|
|
|
*/
|
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
#ifdef CONFIG_VSC7385_IMAGE
|
|
|
|
if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
|
|
|
|
CONFIG_VSC7385_IMAGE_SIZE)) {
|
|
|
|
puts("Failure uploading VSC7385 microcode.\n");
|
|
|
|
rc = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2008-01-16 06:38:05 +00:00
|
|
|
#if defined(CONFIG_OF_BOARD_SETUP)
|
|
|
|
|
|
|
|
void ft_board_setup(void *blob, bd_t *bd)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
ft_pci_setup(blob, bd);
|
|
|
|
#endif
|
|
|
|
ft_cpu_setup(blob, bd);
|
2008-03-14 20:20:18 +00:00
|
|
|
fdt_fixup_dr_usb(blob, bd);
|
2009-06-09 20:25:30 +00:00
|
|
|
fdt_fixup_esdhc(blob, bd);
|
2008-01-16 06:38:05 +00:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_OF_BOARD_SETUP */
|