[U-Boot] [PATCH 21/31] mpc83xx, kmeter1: autodetect size of DDR II Ram.

Heiko Schocher hs at denx.de
Wed Jan 28 10:40:20 CET 2009


Signed-off-by: Heiko Schocher <hs at denx.de>
---
 board/keymile/kmeter1/kmeter1.c |   31 +++++++++++++++++++++----------
 include/configs/kmeter1.h       |    4 ++--
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/board/keymile/kmeter1/kmeter1.c b/board/keymile/kmeter1/kmeter1.c
index 27f0998..6b79794 100644
--- a/board/keymile/kmeter1/kmeter1.c
+++ b/board/keymile/kmeter1/kmeter1.c
@@ -30,6 +30,8 @@

 #include "../common/common.h"

+extern void disable_addr_trans (void);
+extern void enable_addr_trans (void);
 const qe_iop_conf_t qe_iop_conf_tab[] = {
 	/* port pin dir open_drain assign */

@@ -110,16 +112,7 @@ int fixed_sdram(void)
 	u32 ddr_size;
 	u32 ddr_size_log2;

-	msize = CONFIG_SYS_DDR_SIZE;
-	for (ddr_size = msize << 20, ddr_size_log2 = 0;
-	     (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
-		if (ddr_size & 1)
-			return -1;
-	}
-
-	im->sysconf.ddrlaw[0].ar =
-	    LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
-
+	im->sysconf.ddrlaw[0].ar = LAWAR_EN | 0x1e;
 	im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
 	im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
 	im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
@@ -135,6 +128,24 @@ int fixed_sdram(void)
 	udelay (200);
 	im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;

+	msize = CONFIG_SYS_DDR_SIZE;
+	msize *= 1024;
+	msize *= 1024;
+	disable_addr_trans ();
+	msize = get_ram_size (CONFIG_SYS_DDR_BASE, msize);
+	enable_addr_trans ();
+	msize /= (1024 * 1024);
+	if (CONFIG_SYS_DDR_SIZE != msize) {
+		for (ddr_size = msize << 20, ddr_size_log2 = 0;
+		     (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
+			if (ddr_size & 1)
+				return -1;
+		}
+		im->sysconf.ddrlaw[0].ar =
+		    LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
+		im->ddr.csbnds[0].csbnds = (((msize / 16) - 1) & 0xff);
+	}
+
 	return msize;
 }

diff --git a/include/configs/kmeter1.h b/include/configs/kmeter1.h
index f6b4035..d66ba8b 100644
--- a/include/configs/kmeter1.h
+++ b/include/configs/kmeter1.h
@@ -94,8 +94,8 @@
  * Manually set up DDR parameters
  */
 #define CONFIG_DDR_II
-#define CONFIG_SYS_DDR_SIZE		256 /* MB */
-#define CONFIG_SYS_DDR_CS0_BNDS		0x0000000f
+#define CONFIG_SYS_DDR_SIZE		2048 /* MB */
+#define CONFIG_SYS_DDR_CS0_BNDS		0x0000007f
 #define CONFIG_SYS_DDR_CS0_CONFIG	(CSCONFIG_EN | CSCONFIG_AP | \
 					 CSCONFIG_ROW_BIT_13 | \
 					 CSCONFIG_COL_BIT_10 | CSCONFIG_ODT_WR_ACS)
-- 
1.6.0.6

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


More information about the U-Boot mailing list