All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2 1/3] Kirkwood: dram_init is moved to dram.c
@ 2010-10-07 14:58 Prafulla Wadaskar
  2010-10-07 14:58 ` [U-Boot] [PATCH V2 2/3] kirkwood: added common config file mv-common.h Prafulla Wadaskar
  2010-10-12  5:02 ` [U-Boot] [PATCH V2 1/3] Kirkwood: dram_init is moved to dram.c Prafulla Wadaskar
  0 siblings, 2 replies; 9+ messages in thread
From: Prafulla Wadaskar @ 2010-10-07 14:58 UTC (permalink / raw)
  To: u-boot

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>
---
Changelog
v2:
dram_init only performed for consecutive memory
removed CONFIG_SYS_WITHOUT_RELOC dependency
dram_init_banksize added to avoid re-configuration of dram bank 0

 arch/arm/cpu/arm926ejs/kirkwood/dram.c          |   38 +++++++++++++++++++++++
 board/Marvell/guruplug/guruplug.c               |   11 ------
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |   11 ------
 board/Marvell/openrd_base/openrd_base.c         |   11 ------
 board/Marvell/rd6281a/rd6281a.c                 |   11 ------
 board/Marvell/sheevaplug/sheevaplug.c           |   11 ------
 include/configs/keymile-common.h                |    1 +
 7 files changed, 39 insertions(+), 55 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/kirkwood/dram.c b/arch/arm/cpu/arm926ejs/kirkwood/dram.c
index 8f2a18a..cb29f97 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/dram.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/dram.c
@@ -23,8 +23,11 @@
  */
 
 #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 */
+
diff --git a/board/Marvell/guruplug/guruplug.c b/board/Marvell/guruplug/guruplug.c
index c028a53..4df4e9b 100644
--- a/board/Marvell/guruplug/guruplug.c
+++ b/board/Marvell/guruplug/guruplug.c
@@ -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)
 {
diff --git a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
index c959bf8..93d1400 100644
--- a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
+++ b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
@@ -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)
 {
diff --git a/board/Marvell/openrd_base/openrd_base.c b/board/Marvell/openrd_base/openrd_base.c
index c00a08a..d006b2d 100644
--- a/board/Marvell/openrd_base/openrd_base.c
+++ b/board/Marvell/openrd_base/openrd_base.c
@@ -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)
diff --git a/board/Marvell/rd6281a/rd6281a.c b/board/Marvell/rd6281a/rd6281a.c
index 8713a3c..0d76146 100644
--- a/board/Marvell/rd6281a/rd6281a.c
+++ b/board/Marvell/rd6281a/rd6281a.c
@@ -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;
diff --git a/board/Marvell/sheevaplug/sheevaplug.c b/board/Marvell/sheevaplug/sheevaplug.c
index 547126a..173a7b8 100644
--- a/board/Marvell/sheevaplug/sheevaplug.c
+++ b/board/Marvell/sheevaplug/sheevaplug.c
@@ -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)
diff --git a/include/configs/keymile-common.h b/include/configs/keymile-common.h
index 6c14ca0..62d21f6 100644
--- a/include/configs/keymile-common.h
+++ b/include/configs/keymile-common.h
@@ -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
-- 
1.5.3.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-10-12  5:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-07 14:58 [U-Boot] [PATCH V2 1/3] Kirkwood: dram_init is moved to dram.c Prafulla Wadaskar
2010-10-07 14:58 ` [U-Boot] [PATCH V2 2/3] kirkwood: added common config file mv-common.h Prafulla Wadaskar
2010-10-07 14:58   ` [U-Boot] [PATCH V2 3/3] Kirkwood: Changes specific to ARM relocation support Prafulla Wadaskar
2010-10-08  7:54     ` Albert ARIBAUD
2010-10-08  8:32       ` Wolfgang Denk
2010-10-08  8:53         ` Albert ARIBAUD
2010-10-12  5:03     ` Prafulla Wadaskar
2010-10-12  5:02   ` [U-Boot] [PATCH V2 2/3] kirkwood: added common config file mv-common.h Prafulla Wadaskar
2010-10-12  5:02 ` [U-Boot] [PATCH V2 1/3] Kirkwood: dram_init is moved to dram.c Prafulla Wadaskar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.