public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Dylan Hung <dylan_hung@aspeedtech.com>
To: <ryan_chen@aspeedtech.com>, <chiawei_wang@aspeedtech.com>,
	<joel@jms.id.au>, <dylan_hung@aspeedtech.com>,
	<u-boot@lists.denx.de>
Cc: <BMC-SW@aspeedtech.com>
Subject: [PATCH 3/3] ram: ast2600: Align the RL and WL setting
Date: Fri, 11 Nov 2022 15:30:08 +0800	[thread overview]
Message-ID: <20221111073008.16364-4-dylan_hung@aspeedtech.com> (raw)
In-Reply-To: <20221111073008.16364-1-dylan_hung@aspeedtech.com>

Use macro to represent the RL and WL setting to ensure the PHY and
controller setting are aligned.

Signed-off-by: Dylan Hung <dylan_hung@aspeedtech.com>
---
 arch/arm/include/asm/arch-aspeed/sdram_ast2600.h | 4 ++++
 drivers/ram/aspeed/sdram_ast2600.c               | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/arch/arm/include/asm/arch-aspeed/sdram_ast2600.h b/arch/arm/include/asm/arch-aspeed/sdram_ast2600.h
index d2408c0020f8..b0a91ae40d44 100644
--- a/arch/arm/include/asm/arch-aspeed/sdram_ast2600.h
+++ b/arch/arm/include/asm/arch-aspeed/sdram_ast2600.h
@@ -104,6 +104,10 @@
 #define SDRAM_FORCE_PRECHARGE_EN	BIT(4)
 #define SDRAM_REFRESH_EN		BIT(0)
 
+/* MCR14 */
+#define SDRAM_WL_SETTING		GENMASK(23, 20)
+#define SDRAM_CL_SETTING		GENMASK(19, 16)
+
 #define SDRAM_TEST_LEN_SHIFT		4
 #define SDRAM_TEST_LEN_MASK		0xfffff
 #define SDRAM_TEST_START_ADDR_SHIFT	24
diff --git a/drivers/ram/aspeed/sdram_ast2600.c b/drivers/ram/aspeed/sdram_ast2600.c
index bda02d062900..5d426088be3e 100644
--- a/drivers/ram/aspeed/sdram_ast2600.c
+++ b/drivers/ram/aspeed/sdram_ast2600.c
@@ -15,6 +15,7 @@
 #include <asm/global_data.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
+#include <linux/bitfield.h>
 #include <dt-bindings/clock/ast2600-clock.h>
 
 #define DDR_PHY_TBL_CHG_ADDR            0xaeeddeea
@@ -935,6 +936,7 @@ static void ast2600_sdrammc_lock(struct dram_info *info)
 static void ast2600_sdrammc_common_init(struct ast2600_sdrammc_regs *regs)
 {
 	int i;
+	u32 reg;
 
 	writel(MCR34_MREQI_DIS | MCR34_RESETN_DIS, &regs->power_ctrl);
 	writel(SDRAM_VIDEO_UNLOCK_KEY, &regs->gm_protection_key);
@@ -969,6 +971,13 @@ static void ast2600_sdrammc_common_init(struct ast2600_sdrammc_regs *regs)
 	for (i = 0; i < ARRAY_SIZE(ddr4_ac_timing); ++i)
 		writel(ddr4_ac_timing[i], &regs->ac_timing[i]);
 
+	/* update CL and WL */
+	reg = readl(&regs->ac_timing[1]);
+	reg &= ~(SDRAM_WL_SETTING | SDRAM_CL_SETTING);
+	reg |= FIELD_PREP(SDRAM_WL_SETTING, CONFIG_WL - 5) |
+	       FIELD_PREP(SDRAM_CL_SETTING, CONFIG_RL - 5);
+	writel(reg, &regs->ac_timing[1]);
+
 	writel(DDR4_MR01_MODE, &regs->mr01_mode_setting);
 	writel(DDR4_MR23_MODE, &regs->mr23_mode_setting);
 	writel(DDR4_MR45_MODE, &regs->mr45_mode_setting);
-- 
2.25.1


  parent reply	other threads:[~2022-11-11  7:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11  7:30 [PATCH 0/3] Improve AST26x0 DDR4 timing and signal quality Dylan Hung
2022-11-11  7:30 ` [PATCH 1/3] ram: ast2600: Fix incorrect statement of the register polling Dylan Hung
2022-11-24  1:22   ` Ryan Chen
2022-11-24 21:33   ` Tom Rini
2022-11-11  7:30 ` [PATCH 2/3] ram: ast2600: Improve ddr4 timing and signal quality Dylan Hung
2022-11-24  1:22   ` Ryan Chen
2022-11-24 21:33   ` Tom Rini
2022-11-11  7:30 ` Dylan Hung [this message]
2022-11-24  1:23   ` [PATCH 3/3] ram: ast2600: Align the RL and WL setting Ryan Chen
2022-11-24 21:33   ` Tom Rini

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=20221111073008.16364-4-dylan_hung@aspeedtech.com \
    --to=dylan_hung@aspeedtech.com \
    --cc=BMC-SW@aspeedtech.com \
    --cc=chiawei_wang@aspeedtech.com \
    --cc=joel@jms.id.au \
    --cc=ryan_chen@aspeedtech.com \
    --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