Fix DRAM type detection on Dragino 2
authorPiotr Dymacz <pepe2k@gmail.com>
Tue, 13 Jun 2017 18:25:20 +0000 (20:25 +0200)
committerPiotr Dymacz <pepe2k@gmail.com>
Tue, 13 Jun 2017 18:25:20 +0000 (20:25 +0200)
Dragino 2 needs custom DRAM type detection as it doesn't follow general
convention. MEM_TYPE value in BOOT_STRAP register isn't set correctly
on this board because only GPIO28 is used for DRAM type detection.

This fixes DRAM type detection on new Dragino 2 version which is based
on Dragino HE module, with DDR2 memory.

u-boot/cpu/mips/ar7240/qca_dram.c

index 86fc3f151bb382e8045339a057de23bc97920f89..dd4f702b7e04148174bd068d0bb5cc467f3ee287 100644 (file)
@@ -82,6 +82,23 @@ u32 qca_dram_type(void)
                      & QCA_RST_BOOTSTRAP_MEM_TYPE_MASK)
                     >> QCA_RST_BOOTSTRAP_MEM_TYPE_SHIFT);
 
+/*
+ * There are two major different versions of Dragino 2. Initial one uses DDR1
+ * and a custom PCB. The new one is based on Dragino HE module which has DDR2.
+ *
+ * Both versions have a "bug" in DRAM type detection. They don't use both GPIOs
+ * (12 and 28) for setting DRAM type during bootstrap - only GPIO28 is used.
+ *
+ * Therefore, use a custom DRAM type detection here (ignore LSB bit)
+ */
+#if defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2)
+       dram_type = dram_type >> 1;
+
+       if (dram_type)
+               dram_type = RAM_MEMORY_TYPE_DDR2;
+       else
+               dram_type = RAM_MEMORY_TYPE_DDR1;
+#else
        switch (dram_type) {
        case QCA_RST_BOOTSTRAP_MEM_TYPE_SDR_VAL:
                dram_type = RAM_MEMORY_TYPE_SDR;
@@ -96,6 +113,7 @@ u32 qca_dram_type(void)
                dram_type = RAM_MEMORY_TYPE_UNKNOWN;
                break;
        }
+#endif
 
        return dram_type;
 #endif