]> git.sur5r.net Git - u-boot/commitdiff
Kirkwood: dram_init is moved to dram.c
authorPrafulla Wadaskar <prafulla@marvell.com>
Thu, 30 Sep 2010 14:03:19 +0000 (19:33 +0530)
committerPrafulla Wadaskar <prafulla@marvell.com>
Tue, 12 Oct 2010 09:09:15 +0000 (14:39 +0530)
For all Kirkwood boards so far dram_init function is duplicated
dram_init function is moved to dram.c and relevant code from all
board specific files removed

If any board needs specific dram init handling than standard one,
then, a macro CONFIG_SYS_BOARD_DRAM_INIT should be defined in
board config header file and the dram_init function can be put
in board specific source file
For ex. keymile boards

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
arch/arm/cpu/arm926ejs/kirkwood/dram.c
board/Marvell/guruplug/guruplug.c
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
board/Marvell/openrd_base/openrd_base.c
board/Marvell/rd6281a/rd6281a.c
board/Marvell/sheevaplug/sheevaplug.c
include/configs/keymile-common.h

index 8f2a18af6b3742ad90251b84103e65429e622484..7439c87f681070cb3ab24c615afcf8642bbb6ca7 100644 (file)
  */
 
 #include <config.h>
+#include <common.h>
 #include <asm/arch/kirkwood.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define KW_REG_CPUCS_WIN_BAR(x)                (KW_REGISTER(0x1500) + (x * 0x08))
 #define KW_REG_CPUCS_WIN_SZ(x)         (KW_REGISTER(0x1504) + (x * 0x08))
 /*
@@ -56,3 +59,38 @@ u32 kw_sdram_bs(enum memory_bank bank)
        result += 0x01000000;
        return result;
 }
+
+#ifndef CONFIG_SYS_BOARD_DRAM_INIT
+int dram_init(void)
+{
+       int i;
+
+       gd->ram_size = 0;
+       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
+               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+               /*
+                * It is assumed that all memory banks are consecutive
+                * and without gaps.
+                * If the gap is found, ram_size will be reported for
+                * consecutive memory only
+                */
+               if (gd->bd->bi_dram[i].start != gd->ram_size)
+                       break;
+
+               gd->ram_size += gd->bd->bi_dram[i].size;
+
+       }
+       return 0;
+}
+
+/*
+ * If this function is not defined here,
+ * board.c alters dram bank zero configuration defined above.
+ */
+void dram_init_banksize(void)
+{
+       dram_init();
+}
+#endif /* CONFIG_SYS_BOARD_DRAM_INIT */
+
index c028a53bcbf939f036e33573be278131ac7a48c1..4df4e9b260482f49caab002473a2ea24713c3219 100644 (file)
@@ -108,17 +108,6 @@ int board_init(void)
        return 0;
 }
 
-int dram_init(void)
-{
-       int i;
-
-       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
-               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
-       }
-       return 0;
-}
-
 #ifdef CONFIG_RESET_PHY_R
 void mv_phy_88e1121_init(char *name)
 {
index c959bf879e91c27b7acb88c5572392a5a70a9b2b..93d1400be49d469fbdb04248617cf0523fa44ef9 100644 (file)
@@ -110,17 +110,6 @@ int board_init(void)
        return 0;
 }
 
-int dram_init(void)
-{
-       int i;
-
-       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
-               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
-       }
-       return 0;
-}
-
 #ifdef CONFIG_MV88E61XX_SWITCH
 void reset_phy(void)
 {
index c00a08aeab319d1f933b9800a915c5f1d9654ad5..d006b2ddf7d3abece1524b7e94b99ed6555fed12 100644 (file)
@@ -113,17 +113,6 @@ int board_init(void)
        return 0;
 }
 
-int dram_init(void)
-{
-       int i;
-
-       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
-               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
-       }
-       return 0;
-}
-
 #ifdef CONFIG_RESET_PHY_R
 /* Configure and enable MV88E1116 PHY */
 void reset_phy(void)
index 8713a3cf9b26aba0f50f74a2d092901de548eb18..0d76146b658069e44e54ec98a64057ac9421bf6c 100644 (file)
@@ -109,17 +109,6 @@ int board_init(void)
        return 0;
 }
 
-int dram_init(void)
-{
-       int i;
-
-       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
-               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
-       }
-       return 0;
-}
-
 void mv_phy_88e1116_init(char *name)
 {
        u16 reg;
index 547126af8f049bd66693c2ee383d4bb2d04f1ae2..173a7b809df33f9b2072e5d9e43597f30548db9a 100644 (file)
@@ -108,17 +108,6 @@ int board_init(void)
        return 0;
 }
 
-int dram_init(void)
-{
-       int i;
-
-       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
-               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
-       }
-       return 0;
-}
-
 #ifdef CONFIG_RESET_PHY_R
 /* Configure and enable MV88E1116 PHY */
 void reset_phy(void)
index 6c14ca00c53dc00020a615e5c9918227d55b3740..62d21f628666d522da8d103cda644f277cfbd6ed 100644 (file)
@@ -85,6 +85,7 @@
 
 #define CONFIG_LOADS_ECHO      1       /* echo on for serial download */
 #define CONFIG_SYS_LOADS_BAUD_CHANGE   1       /* allow baudrate change */
+#define CONFIG_SYS_BOARD_DRAM_INIT     /* Used board specific dram_init */
 
 /*
  * How to get access to the slot ID.  Put this here to make it easy