Skip to contentSkip to conversation

Add Elpida Memory Configuration to mpc5121ads Boards

PATCH New Martha M Stan 2 participants 2 messages Sep 11, 2009 – Sep 15, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add Elpida Memory Configuration to mpc5121ads Boards

---
 board/freescale/mpc5121ads/mpc5121ads.c |   97 ++++++++++++++++++++++++++++++-
 include/configs/mpc5121ads.h            |   39 ++++++++++++-
 2 files changed, 132 insertions(+), 4 deletions(-)
board/freescale/mpc5121ads/mpc5121ads.c +95 -2
index 8defb00..9892d50 100644
@@ -31,6 +31,7 @@
 #ifdef CONFIG_MISC_INIT_R
 #include <i2c.h>
 #endif
+#include <net.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
@@ -133,11 +134,103 @@ int board_early_init_f(void)
 	return 0;
 }
 
+int is_micron(void){
+
+	ushort brd_rev = *(vu_short *)(CONFIG_SYS_CPLD_BASE + 0x00);
+	uchar macaddr[6];
+	u32 brddate, macchk, ismicron;
+
+	/*
+	 * MAC address has serial number with date of manufacture
+	 * Boards made before Nov-08 #1180 use Micron memory;
+	 * 001e59 is the STx vendor #
+	 * Default is Elpida since it works for both but is slightly slower
+	 */
+	ismicron = 0;
+	if (brd_rev >= 0x0400 && eth_getenv_enetaddr("ethaddr", macaddr)) {
+		brddate = (macaddr[3] << 16) + (macaddr[4] << 8) + macaddr[5];
+		macchk = (macaddr[0] << 16) + (macaddr[1] << 8) + macaddr[2];
+		debug("brddate = %d\n\t", brddate);
+
+		if (macchk == 0x001e59 && brddate <= 8111180)
+			ismicron = 1;
+	} else if (brd_rev < 0x400) {
+		ismicron = 1;
+	}
+	debug("Using %s Memory settings\n\t",
+		ismicron ? "Micron" : "Elpida");
+	return(ismicron);
+}
+
 phys_size_t initdram(int board_type)
 {
-	u32 msize = 0;
+	/* Elpida MDDRC and initialization settings are an alternative
+	 * to the Default Micron ones for all but the earliest Rev 4 boards
+	 */
+	u32 elpida_mddrc_config[4] = {
+		CONFIG_SYS_MDDRC_SYS_CFG_ELPIDA,
+		CONFIG_SYS_MDDRC_TIME_CFG0,
+		CONFIG_SYS_MDDRC_TIME_CFG1_ELPIDA,
+		CONFIG_SYS_MDDRC_TIME_CFG2_ELPIDA
+	};
+
+	u32 elpida_init_sequence[] = {
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_PCHG_ALL,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_EM2,
+		CONFIG_SYS_MICRON_EM3,
+		CONFIG_SYS_MICRON_EN_DLL,
+		CONFIG_SYS_ELPIDA_RES_DLL,
+		CONFIG_SYS_MICRON_PCHG_ALL,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_ELPIDA_INIT_DEV_OP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_OCD_DEFAULT,
+		CONFIG_SYS_ELPIDA_OCD_EXIT,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP
+	};
 
-	msize = fixed_sdram(NULL, NULL, 0);
+	u32 msize = 0;
+	if (is_micron())
+		msize = fixed_sdram(NULL, NULL, 0);
+	else
+		msize = fixed_sdram(elpida_mddrc_config,
+				elpida_init_sequence,
+				sizeof(elpida_init_sequence)/sizeof(u32));
 
 	return msize;
 }
include/configs/mpc5121ads.h +37 -2
index d96e7f5..fda63dd 100644
@@ -141,14 +141,49 @@
 #endif
 #define CONFIG_SYS_MDDRC_TIME_CFG0	0x06183D2E
 
+#define CONFIG_SYS_MDDRC_SYS_CFG_ELPIDA	 	0xFA802B00
+#define CONFIG_SYS_MDDRC_TIME_CFG1_ELPIDA	0x690e1189
+#define CONFIG_SYS_MDDRC_TIME_CFG2_ELPIDA	0x35310864
+
+/* MICRON Configuration and Commands
+ * These also work for Elpida unless explicitly overwritten
+ */
 #define CONFIG_SYS_MICRON_NOP		0x01380000
 #define CONFIG_SYS_MICRON_PCHG_ALL	0x01100400
 #define CONFIG_SYS_MICRON_EM2		0x01020000
 #define CONFIG_SYS_MICRON_EM3		0x01030000
 #define CONFIG_SYS_MICRON_EN_DLL	0x01010000
 #define CONFIG_SYS_MICRON_RFSH		0x01080000
-#define CONFIG_SYS_MICRON_INIT_DEV_OP	0x01000432
-#define CONFIG_SYS_MICRON_OCD_DEFAULT	0x01010780
+
+#define DDR_CMD_EMR_OCD(pr, ohm) ( \
+	(1 << 24)	   | /* MDDRC Command Request	*/ \
+	(1 << 16)	   | /* MODE Reg BA[2:0] 	*/ \
+	(0 << 12)	   | /* Outputs 0=Enabled	*/ \
+	(0 << 11)	   | /* RDQS 			*/ \
+	(1 << 10)	   | /* DQS# 			*/ \
+	(pr <<  7)	   | /* OCD prog 7=deflt,0=exit	*/ \
+		    /* ODT Rtt[1:0] 0=0,1=75,2=150,3=50 */ \
+	((ohm & 0x1) <<  6)| /* Rtt1			*/ \
+	(0 <<  3)	   | /* additive posted CAS#	*/ \
+	((ohm & 0x2) <<  2)| /* Rtt0			*/ \
+	(0 <<  0)	   | /* Output Drive Strength	*/ \
+	(0 <<  0))	     /* DLL Enable 0=Normal	*/
+
+#define CONFIG_SYS_MICRON_OCD_DEFAULT	DDR_CMD_EMR_OCD(7, 0)
+#define CONFIG_SYS_ELPIDA_OCD_EXIT	DDR_CMD_EMR_OCD(0, 0)
+
+#define DDR_CMD_MODE_REG(cas, wr) ( \
+	(1 << 24)    | /* MDDRC Command Request			*/ \
+	(0 << 16)    | /* MODE Reg BA[2:0] 			*/ \
+	((wr-1) << 9)| /* Write Recovery 			*/ \
+	(cas << 4)   | /* CAS 					*/ \
+	(0 << 3)     | /* Burst Type:0=Sequential,1=Interleaved	*/ \
+	(2 << 0))      /* 4 or 8 Burst Length:0x2=4 0x3=8	*/
+
+#define CONFIG_SYS_MICRON_INIT_DEV_OP	DDR_CMD_MODE_REG(3, 3)
+#define CONFIG_SYS_ELPIDA_INIT_DEV_OP	DDR_CMD_MODE_REG(4, 4)
+#define CONFIG_SYS_ELPIDA_RES_DLL	(DDR_CMD_MODE_REG(4, 4) | (1 << 8))
+
 
 /* DDR Priority Manager Configuration */
 #define CONFIG_SYS_MDDRCGRP_PM_CFG1	0x00077777
Signature · 1 line
1.5.2.4
#1 lore raw

PATCH 1/1 Add Elpida Memory Configuration to mpc5121ads Boards

Dear Martha M Stan,

Quoted 5 lines · In message <[email protected]> you wrote:
---
 board/freescale/mpc5121ads/mpc5121ads.c |   97 ++++++++++++++++++++++++++++++-
 include/configs/mpc5121ads.h            |   39 ++++++++++++-
 2 files changed, 132 insertions(+), 4 deletions(-)

...

Quoted 39 lines
board/freescale/mpc5121ads/mpc5121ads.c +39 -0
+	u32 elpida_init_sequence[] = {
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_PCHG_ALL,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_EM2,
+		CONFIG_SYS_MICRON_EM3,
+		CONFIG_SYS_MICRON_EN_DLL,
+		CONFIG_SYS_ELPIDA_RES_DLL,
+		CONFIG_SYS_MICRON_PCHG_ALL,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_MICRON_RFSH,
+		CONFIG_SYS_ELPIDA_INIT_DEV_OP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_OCD_DEFAULT,
+		CONFIG_SYS_ELPIDA_OCD_EXIT,
+		CONFIG_SYS_MICRON_NOP,

board/freescale/mpc5121ads/mpc5121ads.c int board_early_init_f(void) · line 225

Quoted 10 lines
board/freescale/mpc5121ads/mpc5121ads.c +10 -0
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP,
+		CONFIG_SYS_MICRON_NOP
+	};

This seems wrong to me. Elpida settings should use CONFIG_SYS_ELPIDA_* variables only, should't it?

board/freescale/mpc5121ads/mpc5121ads.c int board_early_init_f(void) · line 233

Quoted 8 lines
board/freescale/mpc5121ads/mpc5121ads.c +7 -1
-	msize = fixed_sdram(NULL, NULL, 0);
+	u32 msize = 0;
+	if (is_micron())
+		msize = fixed_sdram(NULL, NULL, 0);
+	else
+		msize = fixed_sdram(elpida_mddrc_config,
+				elpida_init_sequence,
+				sizeof(elpida_init_sequence)/sizeof(u32));

Braces needed for multiline statement.

Quoted 5 lines
include/configs/mpc5121ads.h +0 -0
index d96e7f5..fda63dd 100644

include/configs/mpc5121ads.h line 150

Quoted 10 lines
include/configs/mpc5121ads.h +7 -0
@@ -141,14 +141,49 @@
 #endif
 #define CONFIG_SYS_MDDRC_TIME_CFG0	0x06183D2E
 
+#define CONFIG_SYS_MDDRC_SYS_CFG_ELPIDA	 	0xFA802B00
+#define CONFIG_SYS_MDDRC_TIME_CFG1_ELPIDA	0x690e1189
+#define CONFIG_SYS_MDDRC_TIME_CFG2_ELPIDA	0x35310864
+
+/* MICRON Configuration and Commands
+ * These also work for Elpida unless explicitly overwritten
+ */

Incorrect multiline comment style.

For clearness, I'd prefer to see separate settings.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
There is a time in the tides of men, Which, taken at its flood, leads
on to success. On the other hand, don't count on it.   - T. K. Lawson