Skip to contentSkip to conversation

83xx: Fix some bugs in spd sdram code

PATCH New Dave Liu 3 participants 9 messages Feb 25, 2009 – Mar 10, 2009

lore
Share & tools
lore

Dave Liu

author
#0 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

1. RD_TO_PRE missed to add the AL, and need min 2 clocks for tRTP according to DDR2 JEDEC spec.
2. WRTORD - tWTR need min 2 clocks according to DDR2 JEDEC spec.
3. add the support of DDR2-533,667,800 DIMMs
4. cpo
5. make the AL to min to gain better performance.

The Micron MT9HTF6472CHY-667D1 DIMMs test passed on MPC837xEMDS platform at 266MHz/333MHz/400MHz data rate.

---
 cpu/mpc83xx/spd_sdram.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)
cpu/mpc83xx/spd_sdram.c +23 -3
index 42a4e67..ff15cda 100644
@@ -319,7 +319,20 @@ long int spd_sdram()
 	ddrc_clk = gd->mem_clk / 1000000;
 	effective_data_rate = 0;
 
-	if (max_data_rate >= 390 && max_data_rate < 460) { /* it is DDR 400 */
+	if (max_data_rate >= 460) { /* it is DDR2-800, 667, 533 */
+		if (spd.cas_lat & 0x08)
+			caslat = 3;
+		else
+			caslat = 4;
+		if (ddrc_clk <= 460 && ddrc_clk > 350)
+			effective_data_rate = 400;
+		else if (ddrc_clk <=350 && ddrc_clk > 280)
+			effective_data_rate = 333;
+		else if (ddrc_clk <= 280 && ddrc_clk > 230)
+			effective_data_rate = 266;
+		else
+			effective_data_rate = 200;
+	} else if (max_data_rate >= 390 && max_data_rate < 460) { /* it is DDR 400 */
 		if (ddrc_clk <= 460 && ddrc_clk > 350) {
 			/* DDR controller clk at 350~460 */
 			effective_data_rate = 400; /* 5ns */
@@ -466,6 +479,8 @@ long int spd_sdram()
 	} else {
 		twr_clk = picos_to_clk(spd.twr * 250);
 		twtr_clk = picos_to_clk(spd.twtr * 250);
+		if (twtr_clk < 2)
+			twtr_clk = 2;
 	}
 
 	/*
@@ -529,7 +544,7 @@ long int spd_sdram()
 	if (spd.mem_type == SPD_MEMTYPE_DDR2
 	    && (odt_wr_cfg || odt_rd_cfg)
 	    && (caslat < 4)) {
-		add_lat = trcd_clk - 1;
+		add_lat = 4 - caslat;
 		if ((add_lat + caslat) < 4) {
 			add_lat = 0;
 		}
@@ -566,6 +581,9 @@ long int spd_sdram()
 
 		/* Convert SPD value from quarter nanos to picos. */
 		trtp_clk = picos_to_clk(spd.trtp * 250);
+		if (trtp_clk < 2)
+			trtp_clk = 2;
+		trtp_clk += add_lat;
 
 		cke_min_clk = 3;	/* By the book. */
 		four_act = picos_to_clk(37500);	/* By the book. 1k pages? */
@@ -579,7 +597,9 @@ long int spd_sdram()
 	if (spd.mem_type == SPD_MEMTYPE_DDR2) {
 		if (effective_data_rate == 266) {
 			cpo = 0x4;		/* READ_LAT + 1/2 */
-		} else if (effective_data_rate == 333 || effective_data_rate == 400) {
+		} else if (effective_data_rate == 333) {
+			cpo = 0x6;		/* READ_LAT + 1 */
+		} else if (effective_data_rate == 400) {
 			cpo = 0x7;		/* READ_LAT + 5/4 */
 		} else {
 			/* Automatic calibration */
Signature · 1 line
1.5.4
#1 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

Quoted 8 lines

1. RD_TO_PRE missed to add the AL, and need min 2 clocks for tRTP according to DDR2 JEDEC spec.
2. WRTORD - tWTR need min 2 clocks according to DDR2 JEDEC spec.
3. add the support of DDR2-533,667,800 DIMMs
4. cpo
5. make the AL to min to gain better performance.

Quoted 5 lines

The Micron MT9HTF6472CHY-667D1 DIMMs test passed on MPC837xEMDS platform at 266MHz/333MHz/400MHz data rate.

1, 2 and 5

Don't understand cpo and haven't looked at 3 so
I can't say anything useful.

Jocke

#2 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

Quoted 10 lines
Quoted 10 lines

1. RD_TO_PRE missed to add the AL, and need min 2 clocks for tRTP according to DDR2 JEDEC spec.
2. WRTORD - tWTR need min 2 clocks according to DDR2 JEDEC spec.
3. add the support of DDR2-533,667,800 DIMMs
4. cpo
5. make the AL to min to gain better performance.

The Micron MT9HTF6472CHY-667D1 DIMMs test passed on MPC837xEMDS platform at 266MHz/333MHz/400MHz data rate.

Quoted 8 lines
Quoted 2 lines

1, 2 and 5

Don't understand cpo and haven't looked at 3 so
I can't say anything useful.

Did you test the patch on your board?
Have a try... Give me the result.

The code actually is ugly. The max operation freq of the whole 83xx DDR controller is lagging the mainstream DDR2 DIMMs. We have to put the high speed DIMMs to low speed controller. It sounds like ugly. So we often happen the boundary issue.

Basically, the mainstream PC industry DDR2 DIMMs is DDR2-667 DDR2-800, and it is shifting to DDR3 technology. However, the max data rate for 83xx family is 400MHz.

Thanks, Dave

#3 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

1. RD_TO_PRE missed to add the AL, and need min 2 clocks for tRTP according to DDR2 JEDEC spec.
2. WRTORD - tWTR need min 2 clocks according to DDR2 JEDEC spec.
3. add the support of DDR2-533,667,800 DIMMs
4. cpo
5. make the AL to min to gain better performance.

The Micron MT9HTF6472CHY-667D1 DIMMs test passed on MPC837xEMDS platform at 266MHz/333MHz/400MHz data rate.

Quoted 8 lines
Quoted 5 lines

1, 2 and 5

Don't understand cpo and haven't looked at 3 so
I can't say anything useful.

Did you test the patch on your board?
Have a try... Give me the result.

I wish I could, but I am still on an older version of u-boot and have not ported it to main stream yet. Tried but it was non trivial so it have to wait for the moment.

Quoted 9 lines

The code actually is ugly. The max operation freq of the whole 83xx DDR controller is lagging the mainstream DDR2 DIMMs. We have to put the high speed DIMMs to low speed controller. It sounds like ugly. So we often happen the boundary issue.

Basically, the mainstream PC industry DDR2 DIMMs is DDR2-667 DDR2-800, and it is shifting to DDR3 technology. However, the max data rate for 83xx family is 400MHz.

hmm, are there 832x that can do 400 MHz?
We are using 266 ATM.

#4 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

Quoted 5 lines
Quoted 5 lines

The code actually is ugly. The max operation freq of the whole 83xx DDR controller is lagging the mainstream DDR2 DIMMs.
We have to put the high speed DIMMs to low speed controller. It sounds like ugly. So we often happen the boundary issue.

Quoted 7 lines
Quoted 1 line

Basically, the mainstream PC industry DDR2 DIMMs is

DDR2-667 DDR2-800,

Quoted 2 lines

and it is shifting to DDR3 technology. However, the max data rate for 83xx family is 400MHz.

hmm, are there 832x that can do 400 MHz?
We are using 266 ATM.

No. 832x can support max 266MHz data rate from H/W spec.

#5 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

In reply to Joakim Tjernlund
Quoted 6 lines · On Wed, 25 Feb 2009 10:30:26 +0100 Joakim Tjernlund…
Quoted 6 lines
Quoted 5 lines

1, 2 and 5

Don't understand cpo and haven't looked at 3 so
I can't say anything useful.

Quoted 6 lines
Quoted 2 lines

Did you test the patch on your board?
Have a try... Give me the result.

I wish I could, but I am still on an older version of u-boot and have not ported it to main stream yet. Tried but it was non trivial so it have to wait for the moment.

tested working here. applied hunks 1-5.

Kim

#6 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

Quoted 13 lines
Quoted 9 lines · On Wed, 25 Feb 2009 10:30:26 +0100 Joakim Tjernlund…
Quoted 8 lines
Quoted 5 lines

1, 2 and 5

Don't understand cpo and haven't looked at 3 so
I can't say anything useful.

Did you test the patch on your board?
Have a try... Give me the result.

Quoted 7 lines
Quoted 3 lines

I wish I could, but I am still on an older version of u-boot and have not ported it to main stream yet. Tried but it was non trivial so it have to wait for the moment.

tested working here. applied hunks 1-5.

Kim

FYI, the "odt_rd_cfg" and "odt_wr_cfg" are still
wrong for 832x. They should be

odt_rd_cfg << 22
and
odt_wr_cfg << 18

for 832x

Jocke

#7 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

Quoted 4 lines · On Mon, 9 Mar 2009 18:03:34 +0100 Joakim Tjernlund…
Quoted 3 lines

tested working here. applied hunks 1-5.

Kim

Quoted 8 lines

FYI, the "odt_rd_cfg" and "odt_wr_cfg" are still
wrong for 832x. They should be

odt_rd_cfg << 22
and
odt_wr_cfg << 18

for 832x

yes you are right - I'll get this if one of you don't beat me to it.

Kim

#8 lore raw

PATCH 1/1 83xx: Fix some bugs in spd sdram code

Quoted 1 line

yes you are right - I'll get this if one of you don't beat me to it.

It is fine for me.

Thanks, Dave