* [PATCH v4 1/3] mmc: sdhci-cadence: abort failed tuning command on SD6HC
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 ` tze.yee.ng
2026-11-19 9:53 ` sashiko-bot
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-19 9:45 ` [PATCH v4 3/3] mmc: sdhci-cadence6: tune SD6HC DDR50/DDR52 read path tze.yee.ng
2 siblings, 1 reply; 5+ messages in thread
From: tze.yee.ng @ 2026-11-19 9:45 UTC (permalink / raw)
To: Adrian Hunter, Tanmay Kathpalia, linux-mmc, linux-kernel,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
Ulf Hansson
From: Tze Yee Ng <tze.yee.ng@altera.com>
SD6HC uses a software tuning loop that calls mmc_send_tuning() for every
tap but never aborts a command that fails. When a CMD21 fails with a
command error the eMMC can remain in the Data state and reject the next
command, so the CMD6 that mmc_select_hs400() issues right after tuning
times out.
Request the command error from mmc_send_tuning() and, on a command
error, abort the tuning command with mmc_send_abort_tuning(). This
matches the generic sdhci tuning path. SD is unaffected because
mmc_send_abort_tuning() only acts on the CMD21 tuning command and is a
no-op for the SD CMD19 one.
sdhci_cdns_execute_tuning() is shared with SD4HC, so limit the abort to
SD6HC (SDHCI_SPEC_420 and later); only SD6HC has been tested and SD4HC
can opt in once validated.
Suggested-by: Tanmay Kathpalia <tanmay.kathpalia@altera.com>
Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
Reviewed-by: Tanmay Kathpalia <tanmay.kathpalia@altera.com>
---
Changes in v4:
- Limited the abort to SD6HC (host->version >= SDHCI_SPEC_420)
because sdhci_cdns_execute_tuning() is shared with SD4HC, which has
not been tested; reworded the commit message accordingly.
- Added Tanmay's Reviewed-by.
Changes in v3:
- New patch replacing the v2 1/4 PHY settle: abort the failed tuning
command (mmc_send_abort_tuning(), a no-op for SD) instead of masking
the post-tuning command timeout with a settle delay. (Tanmay Kathpalia)
---
drivers/mmc/host/sdhci-cadence-core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-cadence-core.c b/drivers/mmc/host/sdhci-cadence-core.c
index 745455743b01..5e5a74ca25ce 100644
--- a/drivers/mmc/host/sdhci-cadence-core.c
+++ b/drivers/mmc/host/sdhci-cadence-core.c
@@ -330,9 +330,19 @@ static int sdhci_cdns_execute_tuning(struct sdhci_host *host, u32 opcode)
}
for (i = 0; i < SDHCI_CDNS_MAX_TUNING_LOOP; i++) {
+ int cmd_error = 0;
+
if (sdhci_cdns_set_tune_val(host, i) ||
- mmc_send_tuning(host->mmc, opcode, NULL)) { /* bad */
+ mmc_send_tuning(host->mmc, opcode, &cmd_error)) { /* bad */
cur_streak = 0;
+ /*
+ * Abort a failed tuning command so an eMMC does not
+ * stay in the Data state and reject the next command.
+ * Restrict to SD6HC; the shared path also serves the
+ * untested SD4HC. A no-op for SD in any case.
+ */
+ if (cmd_error && host->version >= SDHCI_SPEC_420)
+ mmc_send_abort_tuning(host->mmc, opcode);
} else { /* good */
cur_streak++;
if (cur_streak > max_streak) {
--
2.43.7
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v4 2/3] dt-bindings: mmc: cdns,sd6hc: add SD6HC DDR50 read-path tuning
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:45 ` tze.yee.ng
2026-11-19 9:45 ` [PATCH v4 3/3] mmc: sdhci-cadence6: tune SD6HC DDR50/DDR52 read path tze.yee.ng
2 siblings, 0 replies; 5+ messages in thread
From: tze.yee.ng @ 2026-11-19 9:45 UTC (permalink / raw)
To: Adrian Hunter, Tanmay Kathpalia, linux-mmc, linux-kernel,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
Ulf Hansson
From: Tze Yee Ng <tze.yee.ng@altera.com>
DDR50 has no CMD19 tuning, so the SD6HC read path must be centred by
static, board/SoC-characterised PHY settings. Add two optional SD6HC
properties for the extended-read DDR modes (SD DDR50 and eMMC DDR52):
- cdns,ddr-read-dqs-delay: read-DQS delay as a count of DLL delay
elements (0-255), each cdns,delay-element-ps wide, that centres the
read eye (default 0).
- cdns,ddr-no-lpbk-dqs: disable the loopback DQS read strobe and
use the fabricated phony DQS instead. Loopback DQS is the recommended
default; set this only on boards that need the phony DQS read path.
Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
---
Changes in v4:
- Dropped the cdns,ddr-phony-dqs-timing property; the phony DQS
timing is always derived by the driver. (Tanmay Kathpalia)
- Dropped Krzysztof's Reviewed-by since property set changed.
- The two remaining properties are unchanged.
Changes in v3:
- Re-expressed cdns,ddr-read-dqs-delay-ps as cdns,ddr-read-dqs-delay: a
count of DLL delay elements (0-255, each cdns,delay-element-ps wide)
that maps 1:1 to the 8-bit PHY field, instead of a picosecond value.
(Krzysztof Kozlowski)
- Added $ref uint32 and maximum: 255; dropped the redundant minimum: 0.
- Used plain description: text for the three new properties.
Changes in v2:
- Retitled to "dt-bindings: mmc: cdns,sd6hc:". (Tanmay Kathpalia)
- Renamed cdns,ddr50-* -> cdns,ddr-*. (Tanmay Kathpalia)
- cdns,ddr-read-dqs-delay-ps is now in picoseconds. (Krzysztof Kozlowski)
- Replaced the read-DQS source selector with a cdns,ddr-no-lpbk-dqs
boolean. (Krzysztof Kozlowski)
- Reworded the phony-dqs-timing text. (Krzysztof Kozlowski,
Tanmay Kathpalia)
- Dropped the SD4HC note. (Tanmay Kathpalia)
- Scope the new properties to the extended-read DDR modes (DDR50 and
DDR52). (Tanmay Kathpalia)
---
Documentation/devicetree/bindings/mmc/cdns,sd6hc.yaml | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/Documentation/devicetree/bindings/mmc/cdns,sd6hc.yaml b/Documentation/devicetree/bindings/mmc/cdns,sd6hc.yaml
index d5ea2717904b..9f48a737241a 100644
--- a/Documentation/devicetree/bindings/mmc/cdns,sd6hc.yaml
+++ b/Documentation/devicetree/bindings/mmc/cdns,sd6hc.yaml
@@ -74,6 +74,25 @@ properties:
maximum: 1000
default: 24
+ cdns,ddr-read-dqs-delay:
+ description:
+ Read-DQS delay (DLL_SLAVE[7:0]) that centres the read eye in the
+ extended-read DDR modes (SD DDR50, eMMC DDR52), which have no CMD19
+ tuning. Expressed as a count of DLL delay elements, each element
+ cdns,delay-element-ps wide, written directly to the 8-bit hardware
+ field.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ maximum: 255
+ default: 0
+
+ cdns,ddr-no-lpbk-dqs:
+ description:
+ Disable the loopback DQS read strobe and use the fabricated (phony)
+ DQS instead in the extended-read DDR modes (SD DDR50, eMMC DDR52).
+ Loopback DQS is the recommended default; set this only on boards that
+ require the phony DQS read path.
+ type: boolean
+
required:
- compatible
- reg
--
2.43.7
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v4 3/3] mmc: sdhci-cadence6: tune SD6HC DDR50/DDR52 read path
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:45 ` [PATCH v4 2/3] dt-bindings: mmc: cdns,sd6hc: add SD6HC DDR50 read-path tuning tze.yee.ng
@ 2026-11-19 9:45 ` tze.yee.ng
2 siblings, 0 replies; 5+ messages in thread
From: tze.yee.ng @ 2026-11-19 9:45 UTC (permalink / raw)
To: Adrian Hunter, Tanmay Kathpalia, linux-mmc, linux-kernel,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
Ulf Hansson
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>
---
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);
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;
--
2.43.7
^ permalink raw reply related [flat|nested] 5+ messages in thread