All of lore.kernel.org
 help / color / mirror / Atom feed
From: "NG, TZE YEE" <tze.yee.ng@altera.com>
To: Adrian Hunter <adrian.hunter@intel.com>,
	Tanmay Kathpalia <tanmay.kathpalia@altera.com>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	devicetree@vger.kernel.org, Ulf Hansson <ulfh@kernel.org>
Subject: Re: [PATCH v4 3/3] mmc: sdhci-cadence6: tune SD6HC DDR50/DDR52 read path
Date: Thu, 3 Dec 2026 16:51:04 +0800	[thread overview]
Message-ID: <ea6798f2-27d2-433e-ac60-da5e11ba5c36@altera.com> (raw)
In-Reply-To: <cdf7f33f-9383-47d6-8482-cb415572a889@intel.com>

Hi Adrian,


On 2/12/2026 3:50 pm, Adrian Hunter wrote:
> On 19/11/2026 11:45, tze.yee.ng@altera.com wrote:
>> From: Tze Yee Ng <tze.yee.ng@altera.com>
>>
>> DDR50 and DDR52 have no CMD19 tuning, so the SD6HC extended-read path
>> relies on static PHY settings. Two things are needed to make it work.
>>
>> First, PHONY_DQS_TIMING (phy_ctrl_reg[9:4]) was left at 0 in every mode.
>> In extended-read mode the RE# (rebar) pulse is held high for half an
>> SDCLK period, so its width in clk_phy (sdmclk) cycles is the SDCLK/sdmclk
>> divider / 2, and the field must hold that width minus 1 (0 otherwise).
>> Leaving it at 0 in extended-read DDR duplicates one DDR edge and corrupts
>> reads. Derive the width from the clock divider so it tracks the
>> integration rather than a hard-coded value: e.g. 1 at divide-by-4,
>> confirmed on DDR50 hardware where 1 captures both beats and 0 corrupts
>> reads. The field only takes effect when the fabricated phony DQS is
>> selected, so the computed value is written in every extended-read mode
>> and clamped to the 6-bit field. This timing model follows the Cadence
>> SD6HC PHY documentation.
>>
>> Second, the remaining read-path knobs need board/SoC characterisation, so
>> read them from device tree at PHY probe and apply them in the
>> extended-read DDR modes (DDR50 and DDR52):
>>
>>    - cdns,ddr-read-dqs-delay: read-DQS delay as a count of DLL delay
>>      elements (each cdns,delay-element-ps wide), written to the 8-bit PHY
>>      field (0-255);
>>    - cdns,ddr-no-lpbk-dqs: fall back from the recommended loopback DQS to
>>      the fabricated phony DQS.
>>
>> Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
> 
> One cosmetic note below.  Nevertheless:
> 
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> 
>> ---
>> Changes in v4:
>> - Merged v3 2/4 (PHONY_DQS_TIMING) and v3 4/4 (read DDR tuning from
>>    device tree)
>> - Derive the PHONY_DQS_TIMING rebar pulse width from the
>>    SDCLK/sdmclk divider (t_sdclk / (2 * t_sdmclk) - 1, clamped to the 6-bit
>>    field) instead of the hard-coded 2 clk_phy cycles, and apply it in every
>>    extended-read mode instead of only DDR50/DDR52.
>> - Dropped the cdns,ddr-phony-dqs-timing override.
>> - Stored ddr_read_dqs_delay as u8.
>> - Dropped Adrian's Acked-by from v3 2/4 since the patch was merged and
>>    substantially reworked
>>
>> Changes in v3:
>> - Read cdns,ddr-read-dqs-delay directly as the delay-element count and
>>    write it to the 8-bit PHY field; dropped the ps->element conversion
>>    (divide by cdns,delay-element-ps) and the FIELD_MAX() clamp.
>>    (Krzysztof Kozlowski)
>> - Hoisted the repeated DDR-mode test to a local bool. (Adrian Hunter)
>> - Removed the probe-time dev_warn() that validated the firmware value.
>>    (Adrian Hunter)
>> - Unwrapped the of_property_read_u32() call to 100 columns.
>>    (Adrian Hunter)
>>
>> Changes in v2:
>> - Updated patch title to "mmc: sdhci-cadence6:" since it touches only the
>>    v6 PHY.
>> - Renamed the properties to cdns,ddr-*.
>> - Read cdns,ddr-read-dqs-delay-ps in ps and convert it to delay elements
>>    (dividing by cdns,delay-element-ps), clamping that quotient to the 8-bit
>>    PHY field. (Krzysztof Kozlowski)
>> - Read cdns,ddr-no-lpbk-dqs via of_property_read_bool().
>>    (Krzysztof Kozlowski)
>> - Dropped the v1 per-property range checks and redundant FIELD_MAX() write
>>    masks. (Adrian Hunter)
>> - Apply the overrides in both DDR50 and DDR52.
>> ---
>>   drivers/mmc/host/sdhci-cadence-phy-v6.c | 52 ++++++++++++++++++++++++++++++++-
>>   1 file changed, 51 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-cadence-phy-v6.c b/drivers/mmc/host/sdhci-cadence-phy-v6.c
>> index 22d56bb46d75..f3a878e86f9b 100644
>> --- a/drivers/mmc/host/sdhci-cadence-phy-v6.c
>> +++ b/drivers/mmc/host/sdhci-cadence-phy-v6.c
>> @@ -126,6 +126,10 @@ struct sdhci_cdns6_phy {
>>   	/* Active delay element (ps); doubled when one SDMCLK requires > 256 steps */
>>   	u32 delay_element;
>>   
>> +	/* DDR read-path overrides (SoC-specific) */
>> +	u8 ddr_read_dqs_delay;
>> +	bool ddr_no_lpbk_dqs;
>> +
>>   	/* PHY_DLL_SLAVE_CTRL register fields */
>>   	u8 cp_read_dqs_cmd_delay;	/* bits [31:24] */
>>   	u8 cp_clk_wrdqs_delay;		/* bits [23:16] */
>> @@ -142,6 +146,10 @@ struct sdhci_cdns6_phy {
>>   	/* PHY_DQS_TIMING register fields */
>>   	bool cp_use_phony_dqs;		/* bit [20] */
>>   	bool cp_use_phony_dqs_cmd;	/* bit [19] */
>> +	bool cp_use_lpbk_dqs;		/* bit [21] */
>> +
>> +	/* PHY_CTRL register fields */
>> +	u8 cp_phony_dqs_timing;		/* bits [9:4] */
>>   
>>   	/* HRS07 register - IO delay Information */
>>   	u8 sdhc_rw_compensate;		/* bits [20:16] */
>> @@ -505,6 +513,7 @@ static void sdhci_cdns6_phy_calc_dat_in(struct sdhci_cdns6_phy *phy)
>>   {
>>   	u32 hcsdclkadj = 0;
>>   	bool strobe_dat = (phy->mode == MMC_TIMING_MMC_HS400);
>> +	bool ddr = (phy->mode == MMC_TIMING_UHS_DDR50 || phy->mode == MMC_TIMING_MMC_DDR52);
>>   
>>   	if (strobe_dat) {
>>   		phy->cp_use_phony_dqs = false;
>> @@ -517,6 +526,33 @@ static void sdhci_cdns6_phy_calc_dat_in(struct sdhci_cdns6_phy *phy)
>>   	if (phy->mode == MMC_TIMING_MMC_HS200)
>>   		phy->cp_read_dqs_delay = phy->hs200_tune_val;
>>   
>> +	if (ddr && phy->ddr_read_dqs_delay)
>> +		phy->cp_read_dqs_delay = phy->ddr_read_dqs_delay;
>> +
>> +	phy->cp_use_lpbk_dqs = true;
>> +
>> +	/*
>> +	 * In extended-read mode the RE# (rebar) pulse is held high for half an
>> +	 * SDCLK period, so its width in clk_phy (sdmclk) cycles equals half the
>> +	 * SDCLK/sdmclk divider. PHONY_DQS_TIMING holds that width minus one.
>> +	 */
>> +	if (phy->sdhc_extended_rd_mode) {
>> +		u32 rebar_cycles = phy->t_sdclk / (2 * phy->t_sdmclk);
>> +
>> +		phy->cp_phony_dqs_timing = rebar_cycles ?
>> +			min_t(u32, rebar_cycles - 1,
>> +			      FIELD_MAX(SDHCI_CDNS6_PHY_CTRL_PHONY_DQS_TIMING)) : 0;
>> +	} else {
>> +		phy->cp_phony_dqs_timing = 0;
>> +	}
>> +
>> +	/*
>> +	 * Loopback DQS is the recommended read-capture path; allow boards that
>> +	 * need the fabricated phony DQS instead to opt out in the DDR modes.
>> +	 */
>> +	if (ddr && phy->ddr_no_lpbk_dqs)
>> +		phy->cp_use_lpbk_dqs = false;
>> +
>>   	if (strobe_dat) {
>>   		/* dqs loopback input via IO cell */
>>   		hcsdclkadj += phy->iocell_input_delay;
>> @@ -680,10 +716,11 @@ int sdhci_cdns6_phy_init(struct sdhci_cdns_priv *priv)
>>   	sdhci_cdns6_dll_reset(priv, true);
>>   
>>   	reg = sdhci_cdns6_read_phy_reg(priv, SDHCI_CDNS6_PHY_DQS_TIMING_REG);
>> +	reg &= ~SDHCI_CDNS6_PHY_DQS_TIMING_USE_LPBK_DQS;
>>   	reg &= ~SDHCI_CDNS6_PHY_DQS_TIMING_USE_PHONY_DQS;
>>   	reg &= ~SDHCI_CDNS6_PHY_DQS_TIMING_USE_PHONY_DQS_CMD;
>>   	reg |= SDHCI_CDNS6_PHY_DQS_TIMING_USE_EXT_LPBK_DQS;
>> -	reg |= SDHCI_CDNS6_PHY_DQS_TIMING_USE_LPBK_DQS;
>> +	reg |= FIELD_PREP(SDHCI_CDNS6_PHY_DQS_TIMING_USE_LPBK_DQS, phy->cp_use_lpbk_dqs);
>>   	reg |= FIELD_PREP(SDHCI_CDNS6_PHY_DQS_TIMING_USE_PHONY_DQS, phy->cp_use_phony_dqs);
>>   	reg |= FIELD_PREP(SDHCI_CDNS6_PHY_DQS_TIMING_USE_PHONY_DQS_CMD, phy->cp_use_phony_dqs_cmd);
>>   	sdhci_cdns6_write_phy_reg(priv, SDHCI_CDNS6_PHY_DQS_TIMING_REG, reg);
>> @@ -715,6 +752,8 @@ int sdhci_cdns6_phy_init(struct sdhci_cdns_priv *priv)
>>   
>>   	reg = sdhci_cdns6_read_phy_reg(priv, SDHCI_CDNS6_PHY_CTRL_REG);
>>   	reg &= ~SDHCI_CDNS6_PHY_CTRL_PHONY_DQS_TIMING;
>> +	reg |= FIELD_PREP(SDHCI_CDNS6_PHY_CTRL_PHONY_DQS_TIMING,
>> +			  phy->cp_phony_dqs_timing);
> 
> Unecessary line wrap
> 

Thanks for the Ack. I will fix it in v5, together with the Patch 1/3 
comment. I'll carry your Acked-by since both are cosmetic.

Thanks,
Tze Yee

>>   	sdhci_cdns6_write_phy_reg(priv, SDHCI_CDNS6_PHY_CTRL_REG, reg);
>>   
>>   	/*
>> @@ -863,6 +902,7 @@ int sdhci_cdns6_phy_probe(struct platform_device *pdev, struct sdhci_cdns_priv *
>>   	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
>>   	struct sdhci_cdns6_phy *phy;
>>   	unsigned long val;
>> +	u32 read_dqs_delay;
>>   	int ret;
>>   
>>   	phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
>> @@ -901,6 +941,16 @@ int sdhci_cdns6_phy_probe(struct platform_device *pdev, struct sdhci_cdns_priv *
>>   
>>   	phy->delay_element_org = phy->delay_element;
>>   
>> +	/*
>> +	 * Optional read-path tuning for the extended-read DDR modes (SD DDR50,
>> +	 * eMMC DDR52).
>> +	 */
>> +	phy->ddr_read_dqs_delay = 0;
>> +	if (!of_property_read_u32(dev->of_node, "cdns,ddr-read-dqs-delay", &read_dqs_delay))
>> +		phy->ddr_read_dqs_delay = read_dqs_delay;
>> +
>> +	phy->ddr_no_lpbk_dqs = of_property_read_bool(dev->of_node, "cdns,ddr-no-lpbk-dqs");
>> +
>>   	priv->phy = phy;
>>   
>>   	return 0;
>>
> 


  reply	other threads:[~2026-12-03  8:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  9:45 [PATCH v4 0/3] mmc: sdhci-cadence: SD6HC DDR50/DDR52 read-path tuning and fixes tze.yee.ng
2026-11-19  9:45 ` [PATCH v4 1/3] mmc: sdhci-cadence: abort failed tuning command on SD6HC tze.yee.ng
2026-11-19  9:53   ` sashiko-bot
2026-12-02  7:50   ` Adrian Hunter
2026-12-03  8:38     ` NG, TZE YEE
2026-11-19  9:45 ` [PATCH v4 2/3] dt-bindings: mmc: cdns,sd6hc: add SD6HC DDR50 read-path tuning tze.yee.ng
2026-11-22 16:03   ` Krzysztof Kozlowski
2026-11-22 19:05   ` Kathpalia, Tanmay
2026-11-25  7:26     ` NG, TZE YEE
2026-12-02  8:22       ` Kathpalia, Tanmay
2026-11-19  9:45 ` [PATCH v4 3/3] mmc: sdhci-cadence6: tune SD6HC DDR50/DDR52 read path tze.yee.ng
2026-11-22 19:06   ` Kathpalia, Tanmay
2026-11-25  7:48     ` NG, TZE YEE
2026-12-02  8:12       ` Kathpalia, Tanmay
2026-12-03  8:44         ` NG, TZE YEE
2026-12-02  7:50   ` Adrian Hunter
2026-12-03  8:51     ` NG, TZE YEE [this message]
2026-11-22 16:03 ` [PATCH v4 0/3] mmc: sdhci-cadence: SD6HC DDR50/DDR52 read-path tuning and fixes Krzysztof Kozlowski
2026-11-25  6:38   ` NG, TZE YEE

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=ea6798f2-27d2-433e-ac60-da5e11ba5c36@altera.com \
    --to=tze.yee.ng@altera.com \
    --cc=adrian.hunter@intel.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=tanmay.kathpalia@altera.com \
    --cc=ulfh@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.