]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/arm/cpu/armv7/am33xx/emif4.c
am33xx: Update DT files, add am335x_gp_evm_config target
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / am33xx / emif4.c
index 55dc3212ab66d1a68b8799a8cd0f90b21bbaee3e..27fa3fb4628bbfa08ff38a29386d09144e799668 100644 (file)
@@ -21,6 +21,10 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+       sdram_init();
+#endif
+
        /* dram_init must store complete ramsize in gd->ram_size */
        gd->ram_size = get_ram_size(
                        (void *)CONFIG_SYS_SDRAM_BASE,
@@ -35,17 +39,24 @@ void dram_init_banksize(void)
 }
 
 
-#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT)
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
 #ifdef CONFIG_TI81XX
 static struct dmm_lisa_map_regs *hw_lisa_map_regs =
                                (struct dmm_lisa_map_regs *)DMM_BASE;
 #endif
+#ifndef CONFIG_TI816X
 static struct vtp_reg *vtpreg[2] = {
                                (struct vtp_reg *)VTP0_CTRL_ADDR,
                                (struct vtp_reg *)VTP1_CTRL_ADDR};
+#endif
 #ifdef CONFIG_AM33XX
 static struct ddr_ctrl *ddrctrl = (struct ddr_ctrl *)DDR_CTRL_ADDR;
 #endif
+#ifdef CONFIG_AM43XX
+static struct ddr_ctrl *ddrctrl = (struct ddr_ctrl *)DDR_CTRL_ADDR;
+static struct cm_device_inst *cm_device =
+                               (struct cm_device_inst *)CM_DEVICE_INST;
+#endif
 
 #ifdef CONFIG_TI81XX
 void config_dmm(const struct dmm_lisa_map_regs *regs)
@@ -64,6 +75,7 @@ void config_dmm(const struct dmm_lisa_map_regs *regs)
 }
 #endif
 
+#ifndef CONFIG_TI816X
 static void config_vtp(int nr)
 {
        writel(readl(&vtpreg[nr]->vtp0ctrlreg) | VTP_CTRL_ENABLE,
@@ -78,27 +90,51 @@ static void config_vtp(int nr)
                        VTP_CTRL_READY)
                ;
 }
+#endif
+
+void __weak ddr_pll_config(unsigned int ddrpll_m)
+{
+}
 
-void config_ddr(unsigned int pll, unsigned int ioctrl,
+void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs,
                const struct ddr_data *data, const struct cmd_control *ctrl,
                const struct emif_regs *regs, int nr)
 {
-       enable_emif_clocks();
        ddr_pll_config(pll);
+#ifndef CONFIG_TI816X
        config_vtp(nr);
+#endif
        config_cmd_ctrl(ctrl, nr);
 
        config_ddr_data(data, nr);
 #ifdef CONFIG_AM33XX
-       config_io_ctrl(ioctrl);
+       config_io_ctrl(ioregs);
 
        /* Set CKE to be controlled by EMIF/DDR PHY */
        writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);
+
+#endif
+#ifdef CONFIG_AM43XX
+       writel(readl(&cm_device->cm_dll_ctrl) & ~0x1, &cm_device->cm_dll_ctrl);
+       while ((readl(&cm_device->cm_dll_ctrl) & CM_DLL_READYST) == 0)
+               ;
+
+       config_io_ctrl(ioregs);
+
+       /* Set CKE to be controlled by EMIF/DDR PHY */
+       writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);
+
+       if (emif_sdram_type(regs->sdram_config) == EMIF_SDRAM_TYPE_DDR3)
+               /* Allow EMIF to control DDR_RESET */
+               writel(0x00000000, &ddrctrl->ddrioctrl);
 #endif
 
        /* Program EMIF instance */
        config_ddr_phy(regs, nr);
        set_sdram_timings(regs, nr);
-       config_sdram(regs, nr);
+       if (get_emif_rev(EMIF1_BASE) == EMIF_4D5)
+               config_sdram_emif4d5(regs, nr);
+       else
+               config_sdram(regs, nr);
 }
 #endif