From: Andre Schwarz <andre.schwarz@matrix-vision.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] mpc83xx: add config options to spd_sdram
Date: Tue, 05 Apr 2011 11:49:49 +0200 [thread overview]
Message-ID: <4D9AE5BD.704@matrix-vision.de> (raw)
Kim,
I have made some mods to spd_sdram.c for various reason:
1.
use SPD setup also for soldered RAM.
This allows DDR mounting options without U-Boot change because SPD data
is written during in-circuit/boundary-scan testing.
2.
read SPD data also from extended adressing EEPROMS used for e.g. HRCW
storage.
Due to HRCW being being located at offset 0 we need an SPD data offset.
3.
for optimized signal integrity and power consumption we need more
influence on
the on-die termination. Although the assumed default values are working they
are far from ideal.
4.
CPO values depend on internal bond wire length which has significantly
high variance on MPC837x, i.e. this value also should be board specific.
I have taken care not to increase code size and not to break existing
boards.
Any comments from your side ?
Is this something you might ACK ?
Regards,
Andr?
diff --git a/arch/powerpc/cpu/mpc83xx/spd_sdram.c
b/arch/powerpc/cpu/mpc83xx/spd_sdram.c
index 44aaa9a..7d10c8c 100644
--- a/arch/powerpc/cpu/mpc83xx/spd_sdram.c
+++ b/arch/powerpc/cpu/mpc83xx/spd_sdram.c
@@ -68,6 +68,12 @@ void board_add_ram_info(int use_default)
#ifndef CONFIG_SYS_READ_SPD
#define CONFIG_SYS_READ_SPD i2c_read
#endif
+#ifndef SPD_EEPROM_OFFSET
+#define SPD_EEPROM_OFFSET 0
+#endif
+#ifndef SPD_EEPROM_ADDR_LEN
+#define SPD_EEPROM_ADDR_LEN 1
+#endif
/*
* Convert picoseconds into clock cycles (rounding up if needed).
@@ -160,7 +166,8 @@ long int spd_sdram()
isync();
/* Read SPD parameters with I2C */
- CONFIG_SYS_READ_SPD(SPD_EEPROM_ADDRESS, 0, 1, (uchar *) & spd,
sizeof (spd));
+ CONFIG_SYS_READ_SPD(SPD_EEPROM_ADDRESS, SPD_EEPROM_OFFSET,
+ SPD_EEPROM_ADDR_LEN, (uchar *) & spd, sizeof (spd));
#ifdef SPD_DEBUG
spd_debug(&spd);
#endif
@@ -562,6 +569,9 @@ long int spd_sdram()
* Empirically, 0x3 == 6/8 clock delay is suggested for DDR I 266.
*/
wr_data_delay = 2;
+#ifdef CONFIG_SYS_DDR_WRITE_DATA_DELAY
+ wr_data_delay = CONFIG_SYS_DDR_WRITE_DATA_DELAY;
+#endif
/*
* Write Latency
@@ -601,6 +611,9 @@ long int spd_sdram()
*/
cpo = 0;
if (spd.mem_type == SPD_MEMTYPE_DDR2) {
+#ifdef CONFIG_SYS_DDR_CPO
+ cpo = CONFIG_SYS_DDR_CPO;
+#else
if (effective_data_rate == 266) {
cpo = 0x4; /* READ_LAT + 1/2 */
} else if (effective_data_rate == 333) {
@@ -611,6 +624,7 @@ long int spd_sdram()
/* Automatic calibration */
cpo = 0x1f;
}
+#endif
}
ddr->timing_cfg_2 = (0
@@ -673,12 +687,23 @@ long int spd_sdram()
* Bit 2 == 0x04 == 75 Ohm, with 2 DIMM modules.
* Bit 6 == 0x40 == 150 Ohm, with 1 DIMM module.
*/
+#if defined(CONFIG_SYS_DDR_MODE_ODT_OFF)
+ mode_odt_enable = 0x00; /* disabled */
+#elif defined(CONFIG_SYS_DDR_MODE_ODT_50)
+ mode_odt_enable = 0x44; /* 50 Ohm */
+#elif defined(CONFIG_SYS_DDR_MODE_ODT_75)
+ mode_odt_enable = 0x04; /* 75 Ohm */
+#else
mode_odt_enable = 0x40; /* 150 Ohm */
+#endif
}
ddr->sdram_mode =
(0
| (1 << (16 + 10)) /* DQS Differential disable */
+#ifdef CONFIG_SYS_DDR_MODE_WEAK
+ | (1 << (16 + 1)) /* weak driver (~60%) */
+#endif
| (add_lat << (16 + 3)) /* Additive Latency in
EMRS1 */
| (mode_odt_enable << 16) /* ODT Enable in EMRS1 */
| ((twr_clk - 1) << 9) /* Write Recovery Autopre */
@@ -740,6 +765,9 @@ long int spd_sdram()
odt_cfg = 0x2; /* ODT to IOs during reads */
}
#endif
+#ifdef CONFIG_ALWAYS_ASSERT_ODT_TO_CPU
+ odt_cfg = 0x3; /* ODT always on */
+#endif
if (spd.mem_type == SPD_MEMTYPE_DDR2) {
ddr->sdram_cfg2 = (0
| (0 << 26) /* True DQS */
@@ -779,10 +807,12 @@ long int spd_sdram()
sdram_type = SDRAM_CFG_SDRAM_TYPE_DDR2;
sdram_cfg = (0
- | SDRAM_CFG_MEM_EN /* DDR enable */
| SDRAM_CFG_SREN /* Self refresh */
| sdram_type /* SDRAM type */
);
+#ifdef CONFIG_DDR_HALF_STRENGTH
+ sdram_cfg |= SDRAM_CFG_HSE;
+#endif
/* sdram_cfg[3] = RD_EN - registered DIMM enable */
if (spd.mod_attr & 0x02)
@@ -822,6 +852,7 @@ long int spd_sdram()
*/
sdram_cfg |= SDRAM_CFG_2T_EN;
#endif
+ sdram_cfg |= SDRAM_CFG_MEM_EN;
/* Enable controller, and GO! */
ddr->sdram_cfg = sdram_cfg;
asm("sync;isync");
MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner
next reply other threads:[~2011-04-05 9:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-05 9:49 Andre Schwarz [this message]
2011-04-05 21:52 ` [U-Boot] [RFC] mpc83xx: add config options to spd_sdram Kim Phillips
2011-04-05 22:03 ` York Sun
2011-04-06 8:42 ` Andre Schwarz
2011-04-06 16:30 ` York Sun
2011-04-06 8:18 ` Andre Schwarz
2011-04-06 16:37 ` York Sun
2011-04-06 18:42 ` Schwarz, Andre
2011-04-07 20:42 ` Schwarz, Andre
2011-04-07 20:56 ` York Sun
2011-04-08 7:41 ` Andre Schwarz
2011-04-08 15:31 ` York Sun
2011-04-08 16:29 ` Andre Schwarz
2011-04-08 16:36 ` York Sun
2011-04-08 16:43 ` Andre Schwarz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D9AE5BD.704@matrix-vision.de \
--to=andre.schwarz@matrix-vision.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox