]> git.sur5r.net Git - u-boot/blobdiff - arch/arm/mach-sunxi/dram_sun8i_h3.c
Move dram_init_banksize() to a common header
[u-boot] / arch / arm / mach-sunxi / dram_sun8i_h3.c
index fe9cf9a181b392782a7a932c62b900e19c9865e6..9f7cc7fd4ccdcec499519ed0d89dd0f8687bc7cc 100644 (file)
@@ -414,6 +414,11 @@ static void mctl_sys_init(uint16_t socid, struct dram_para *para)
        udelay(500);
 }
 
+/* These are more guessed based on some Allwinner code. */
+#define DX_GCR_ODT_DYNAMIC     (0x0 << 4)
+#define DX_GCR_ODT_ALWAYS_ON   (0x1 << 4)
+#define DX_GCR_ODT_OFF         (0x2 << 4)
+
 static int mctl_channel_init(uint16_t socid, struct dram_para *para)
 {
        struct sunxi_mctl_com_reg * const mctl_com =
@@ -443,7 +448,8 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
                clrsetbits_le32(&mctl_ctl->dx[i].gcr, (0x3 << 4) |
                                (0x1 << 1) | (0x3 << 2) | (0x3 << 12) |
                                (0x3 << 14),
-                               IS_ENABLED(CONFIG_DRAM_ODT_EN) ? 0x0 : 0x2);
+                               IS_ENABLED(CONFIG_DRAM_ODT_EN) ?
+                                       DX_GCR_ODT_DYNAMIC : DX_GCR_ODT_OFF);
 
        /* AC PDR should always ON */
        setbits_le32(&mctl_ctl->aciocr, 0x1 << 1);
@@ -658,6 +664,6 @@ unsigned long sunxi_dram_init(void)
        mctl_auto_detect_dram_size(&para);
        mctl_set_cr(&para);
 
-       return (1 << (para.row_bits + 3)) * para.page_size *
+       return (1UL << (para.row_bits + 3)) * para.page_size *
                                                (para.dual_rank ? 2 : 1);
 }