public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [Patch v3] driver/ddr/fsl: Fix MRC_CYC calculation for DDR3
@ 2014-12-02 19:18 York Sun
  2014-12-16 17:17 ` York Sun
  0 siblings, 1 reply; 2+ messages in thread
From: York Sun @ 2014-12-02 19:18 UTC (permalink / raw)
  To: u-boot

For DDR controller version 4.7 or newer, MRC_CYC (mode register set
cycle time) is max(tMRD, tMOD). tMRD is 4nCK, or 8nCK (RDIMM). tMOD
is max(12nCK, 15ns) according to JEDEC spec.

DDR4 is not affected by this change.

Signed-off-by: York Sun <yorksun@freescale.com>
---
Change log
 v3: Add cast for using max()
 v2: Apply the change only to DDR controller newer than v4.7
     Older DDRC needs to take into account of RDIMM for tMRD

 drivers/ddr/fsl/ctrl_regs.c |   21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/ddr/fsl/ctrl_regs.c b/drivers/ddr/fsl/ctrl_regs.c
index fe8aa98..03d7ff1 100644
--- a/drivers/ddr/fsl/ctrl_regs.c
+++ b/drivers/ddr/fsl/ctrl_regs.c
@@ -324,6 +324,7 @@ static void set_timing_cfg_0(fsl_ddr_cfg_regs_t *ddr,
 #elif defined(CONFIG_SYS_FSL_DDR3)
 	unsigned int data_rate = get_ddr_freq(0);
 	int txp;
+	unsigned int ip_rev;
 	int odt_overlap;
 	/*
 	 * (tXARD and tXARDS). Empirical?
@@ -336,7 +337,25 @@ static void set_timing_cfg_0(fsl_ddr_cfg_regs_t *ddr,
 	 */
 	txp = max((int)mclk_ps * 3, (mclk_ps > 1540 ? 7500 : 6000));
 
-	tmrd_mclk = 4;
+	ip_rev = fsl_ddr_get_version();
+	if (ip_rev >= 0x40700) {
+		/*
+		 * MRS_CYC = max(tMRD, tMOD)
+		 * tMRD = 4nCK (8nCK for RDIMM)
+		 * tMOD = max(12nCK, 15ns)
+		 */
+		tmrd_mclk = max((unsigned int)12, picos_to_mclk(15000));
+	} else {
+		/*
+		 * MRS_CYC = tMRD
+		 * tMRD = 4nCK (8nCK for RDIMM)
+		 */
+		if (popts->registered_dimm_en)
+			tmrd_mclk = 8;
+		else
+			tmrd_mclk = 4;
+	}
+
 	/* set the turnaround time */
 
 	/*
-- 
1.7.9.5

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

* [U-Boot] [Patch v3] driver/ddr/fsl: Fix MRC_CYC calculation for DDR3
  2014-12-02 19:18 [U-Boot] [Patch v3] driver/ddr/fsl: Fix MRC_CYC calculation for DDR3 York Sun
@ 2014-12-16 17:17 ` York Sun
  0 siblings, 0 replies; 2+ messages in thread
From: York Sun @ 2014-12-16 17:17 UTC (permalink / raw)
  To: u-boot

On 12/02/2014 11:18 AM, York Sun wrote:
> For DDR controller version 4.7 or newer, MRC_CYC (mode register set
> cycle time) is max(tMRD, tMOD). tMRD is 4nCK, or 8nCK (RDIMM). tMOD
> is max(12nCK, 15ns) according to JEDEC spec.
> 
> DDR4 is not affected by this change.
> 
> Signed-off-by: York Sun <yorksun@freescale.com>
> ---
> Change log
>  v3: Add cast for using max()
>  v2: Apply the change only to DDR controller newer than v4.7
>      Older DDRC needs to take into account of RDIMM for tMRD

Applied to u-boot-mpc85xx master, awaiting upstream.

York

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

end of thread, other threads:[~2014-12-16 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-02 19:18 [U-Boot] [Patch v3] driver/ddr/fsl: Fix MRC_CYC calculation for DDR3 York Sun
2014-12-16 17:17 ` York Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox