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
|
2013-03-15 10:07:07 +00:00
|
|
|
static struct dmm_lisa_map_regs *hw_lisa_map_regs =
|
|
|
|
(struct dmm_lisa_map_regs *)DMM_BASE;
|
2013-03-15 10:07:03 +00:00
|
|
|
static struct vtp_reg *vtpreg[2] = {
|
|
|
|
(struct vtp_reg *)VTP0_CTRL_ADDR,
|
|
|
|
(struct vtp_reg *)VTP1_CTRL_ADDR};
|
|
|
|
#ifdef CONFIG_AM33XX
|
2012-07-30 21:13:16 +00:00
|
|
|
static struct ddr_ctrl *ddrctrl = (struct ddr_ctrl *)DDR_CTRL_ADDR;
|
2013-03-15 10:07:03 +00:00
|
|
|
#endif
|
2012-07-30 21:13:16 +00:00
|
|
|
|
2013-03-15 10:07:07 +00:00
|
|
|
void config_dmm(const struct dmm_lisa_map_regs *regs)
|
|
|
|
{
|
|
|
|
enable_dmm_clocks();
|
|
|
|
|
|
|
|
writel(0, &hw_lisa_map_regs->dmm_lisa_map_3);
|
|
|
|
writel(0, &hw_lisa_map_regs->dmm_lisa_map_2);
|
|
|
|
writel(0, &hw_lisa_map_regs->dmm_lisa_map_1);
|
|
|
|
writel(0, &hw_lisa_map_regs->dmm_lisa_map_0);
|
|
|
|
|
|
|
|
writel(regs->dmm_lisa_map_3, &hw_lisa_map_regs->dmm_lisa_map_3);
|
|
|
|
writel(regs->dmm_lisa_map_2, &hw_lisa_map_regs->dmm_lisa_map_2);
|
|
|
|
writel(regs->dmm_lisa_map_1, &hw_lisa_map_regs->dmm_lisa_map_1);
|
|
|
|
writel(regs->dmm_lisa_map_0, &hw_lisa_map_regs->dmm_lisa_map_0);
|
|
|
|
}
|
|
|
|
|
2013-03-15 10:07:03 +00:00
|
|
|
static void config_vtp(int nr)
|
2011-10-14 02:58:24 +00:00
|
|
|
{
|
2013-03-15 10:07:03 +00:00
|
|
|
writel(readl(&vtpreg[nr]->vtp0ctrlreg) | VTP_CTRL_ENABLE,
|
|
|
|
&vtpreg[nr]->vtp0ctrlreg);
|
|
|
|
writel(readl(&vtpreg[nr]->vtp0ctrlreg) & (~VTP_CTRL_START_EN),
|
|
|
|
&vtpreg[nr]->vtp0ctrlreg);
|
|
|
|
writel(readl(&vtpreg[nr]->vtp0ctrlreg) | VTP_CTRL_START_EN,
|
|
|
|
&vtpreg[nr]->vtp0ctrlreg);
|
2011-10-14 02:58:24 +00:00
|
|
|
|
|
|
|
/* Poll for READY */
|
2013-03-15 10:07:03 +00:00
|
|
|
while ((readl(&vtpreg[nr]->vtp0ctrlreg) & VTP_CTRL_READY) !=
|
2011-10-14 02:58:24 +00:00
|
|
|
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,
|
2013-03-15 10:07:03 +00:00
|
|
|
const struct emif_regs *regs, int nr)
|
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);
|
2013-03-15 10:07:03 +00:00
|
|
|
config_vtp(nr);
|
|
|
|
config_cmd_ctrl(ctrl, nr);
|
2011-10-14 02:58:24 +00:00
|
|
|
|
2013-03-15 10:07:03 +00:00
|
|
|
config_ddr_data(data, nr);
|
|
|
|
#ifdef CONFIG_AM33XX
|
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);
|
2013-03-15 10:07:03 +00:00
|
|
|
#endif
|
2011-10-14 02:58:24 +00:00
|
|
|
|
2012-07-30 21:13:56 +00:00
|
|
|
/* Program EMIF instance */
|
2013-03-15 10:07:03 +00:00
|
|
|
config_ddr_phy(regs, nr);
|
|
|
|
set_sdram_timings(regs, nr);
|
|
|
|
config_sdram(regs, nr);
|
2011-10-14 02:58:24 +00:00
|
|
|
}
|
|
|
|
#endif
|