2011-10-14 02:58:24 +00:00
|
|
|
/*
|
|
|
|
* emif4.c
|
|
|
|
*
|
|
|
|
* AM33XX emif4 configuration file
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/arch/cpu.h>
|
|
|
|
#include <asm/arch/ddr_defs.h>
|
|
|
|
#include <asm/arch/hardware.h>
|
|
|
|
#include <asm/arch/clock.h>
|
2012-07-03 16:20:06 +00:00
|
|
|
#include <asm/arch/sys_proto.h>
|
2011-10-14 02:58:24 +00:00
|
|
|
#include <asm/io.h>
|
2012-07-03 15:51:34 +00:00
|
|
|
#include <asm/emif.h>
|
2011-10-14 02:58:24 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
int dram_init(void)
|
|
|
|
{
|
|
|
|
/* dram_init must store complete ramsize in gd->ram_size */
|
|
|
|
gd->ram_size = get_ram_size(
|
|
|
|
(void *)CONFIG_SYS_SDRAM_BASE,
|
|
|
|
CONFIG_MAX_RAM_BANK_SIZE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dram_init_banksize(void)
|
|
|
|
{
|
|
|
|
gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
|
|
|
|
gd->bd->bi_dram[0].size = gd->ram_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-09 20:38:59 +00:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
2012-07-30 21:13:16 +00:00
|
|
|
static struct vtp_reg *vtpreg = (struct vtp_reg *)VTP0_CTRL_ADDR;
|
|
|
|
static struct ddr_ctrl *ddrctrl = (struct ddr_ctrl *)DDR_CTRL_ADDR;
|
|
|
|
|
2011-10-14 02:58:24 +00:00
|
|
|
static void config_vtp(void)
|
|
|
|
{
|
|
|
|
writel(readl(&vtpreg->vtp0ctrlreg) | VTP_CTRL_ENABLE,
|
|
|
|
&vtpreg->vtp0ctrlreg);
|
|
|
|
writel(readl(&vtpreg->vtp0ctrlreg) & (~VTP_CTRL_START_EN),
|
|
|
|
&vtpreg->vtp0ctrlreg);
|
|
|
|
writel(readl(&vtpreg->vtp0ctrlreg) | VTP_CTRL_START_EN,
|
|
|
|
&vtpreg->vtp0ctrlreg);
|
|
|
|
|
|
|
|
/* Poll for READY */
|
|
|
|
while ((readl(&vtpreg->vtp0ctrlreg) & VTP_CTRL_READY) !=
|
|
|
|
VTP_CTRL_READY)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2012-10-18 01:21:12 +00:00
|
|
|
void config_ddr(unsigned int pll, unsigned int ioctrl,
|
|
|
|
const struct ddr_data *data, const struct cmd_control *ctrl,
|
|
|
|
const struct emif_regs *regs)
|
2011-10-14 02:58:24 +00:00
|
|
|
{
|
2012-07-30 21:13:56 +00:00
|
|
|
enable_emif_clocks();
|
2012-10-18 01:21:12 +00:00
|
|
|
ddr_pll_config(pll);
|
2012-07-30 21:13:56 +00:00
|
|
|
config_vtp();
|
2012-10-18 01:21:12 +00:00
|
|
|
config_cmd_ctrl(ctrl);
|
2011-10-14 02:58:24 +00:00
|
|
|
|
2012-10-18 01:21:12 +00:00
|
|
|
config_ddr_data(0, data);
|
|
|
|
config_ddr_data(1, data);
|
2011-10-14 02:58:24 +00:00
|
|
|
|
2012-10-18 01:21:12 +00:00
|
|
|
config_io_ctrl(ioctrl);
|
2011-10-14 02:58:24 +00:00
|
|
|
|
2012-07-30 21:13:56 +00:00
|
|
|
/* Set CKE to be controlled by EMIF/DDR PHY */
|
|
|
|
writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);
|
2011-10-14 02:58:24 +00:00
|
|
|
|
2012-07-30 21:13:56 +00:00
|
|
|
/* Program EMIF instance */
|
2012-10-18 01:21:12 +00:00
|
|
|
config_ddr_phy(regs);
|
|
|
|
set_sdram_timings(regs);
|
|
|
|
config_sdram(regs);
|
2011-10-14 02:58:24 +00:00
|
|
|
}
|
|
|
|
#endif
|