Revert "mmc: sdhci-cadence: trigger tuning for SD HS mode on SD6HC (v6) PHY"
PATCH v2 1/1 Revert "mmc: sdhci-cadence: trigger tuning for SD HS mode on SD6HC (v6) PHY"
This reverts commit b42c67188c14 ("mmc: sdhci-cadence: trigger tuning for SD HS mode on SD6HC (v6) PHY").
The reverted patch introduced several issues:
1. Non-standard tuning trigger: The SD Physical Layer Specification only mandates execute_tuning for SDR50 and SDR104 UHS-I modes. Triggering tuning for SD High Speed mode is outside the spec and is handled via a non-standard set_ios_post callback rather than through the established SDHCI framework tuning path.
2. Non-standard device tree property: The patch introduced a new "cdns,sd-hs-tuning" DT property to opt into SD HS tuning. This is not aligned with existing DT bindings and bypasses the standard MMC capability negotiation mechanism.
3. Incorrect tunable mode allowlist: The sdhci_cdns6_mode_is_tuned() function includes SD_HS, UHS_SDR50, and MMC_HS_400_ES as tunable modes. According to the Cadence SD6HC IP User Guide (section 7.5.2, Figure 18), tuning is only required for UHS-I SDR104 (SD) and HS200 (eMMC). SD High Speed, UHS-I SDR50, and DDR50 only require a PHY settings update from the pre-calculation script, not the tuning procedure. HS400 transitions through HS200 and reuses its tuned DLL value with a partial settings update. HS400ES only requires a plain settings update from the calculation script with no dependency on HS200 tuning.
4. Tuned state management outside the framework: The patch manually tracks tuned DLL state (tuned_mode, tuned_dll_slave_ctrl) and restores it across PHY reconfigurations. This duplicates responsibility that belongs in the core MMC tuning framework and adds unnecessary complexity to the driver.
Reverting to realign the driver with the IP documentation and the SD Physical Layer Specification.
--- drivers/mmc/sdhci-cadence.c | 108 +---------------------------------- drivers/mmc/sdhci-cadence.h | 5 -- drivers/mmc/sdhci-cadence6.c | 45 +-------------- 3 files changed, 2 insertions(+), 156 deletions(-)
drivers/mmc/sdhci-cadence.c +1 -107
@@ -39,9 +39,6 @@ static const struct sdhci_cdns_phy_cfg sdhci_cdns_phy_cfgs[] = { { "cdns,phy-dll-delay-strobe", SDHCI_CDNS_PHY_DLY_STROBE, }, }; -static int __maybe_unused sdhci_cdns_execute_tuning (struct udevice *dev, -unsigned int opcode); -static int sdhci_cdns_write_phy_reg (struct sdhci_cdns_plat *plat,u8 addr,u8 data) {
@@ -158,93 +155,8 @@ static void sdhci_cdns_set_control_reg(struct sdhci_host *host)sdhci_cdns6_phy_adj (mmc->dev, plat, mmc->selected_mode); } -static __maybe_unused bool sdhci_cdns_sd_needs_tuning (struct mmc *mmc) -{ -struct sdhci_cdns_plat *plat =dev_get_plat (mmc->dev); - -if (!IS_SD (mmc)) -return false; - -if (!dev_read_bool (mmc->dev,"cdns,sd-hs-tuning" )) -return false; - -/* Already tuned for this mode */ -if (plat->tuned_mode == mmc->selected_mode) -return false; - -switch (mmc->selected_mode) { -case SD_HS : -return mmc->bus_width ==4 ; -/* Add future modes here, e.g.: -* case UHS_SDR50: -* return true; -*/ -default : -return false; - } -} - -static int sdhci_cdns_set_ios_post (struct sdhci_host *host) -{ -struct mmc *mmc = host->mmc; -struct sdhci_cdns_plat *plat =dev_get_plat (mmc->dev); -int ret__maybe_unused ; -/* -* The SD6HC soft PHY requires runtime DLL delay calibration -* for SD High Speed mode. The default PHY_DLL_SLAVE_CTRL_REG -* values (READ_DQS_CMD_DELAY and READ_DQS_DELAY = 0) do not -* provide sufficient timing margin due to PVT and board trace -* variations. -* -* Tuning is performed once per entry into SD_HS mode -* (tracked by plat->tuned_mode state). The calibrated PHY delay -* values remain valid while the card stays in SD_HS mode, and -* leaving that tuned mode clears the state so re-entering SD_HS -* triggers tuning again. -* -* This must be done in set_ios_post (not set_control_reg) -* because the SDHCI controller must already be operating at -* the target bus width, clock, and speed mode before CMD19 -* tuning commands can succeed. -*/ - -if (IS_ENABLED (CONFIG_MMC_SUPPORTS_TUNING )) { -if (SDHCI_GET_VERSION (host) >=SDHCI_SPEC_420 && -sdhci_cdns_sd_needs_tuning (mmc)) { - ret =sdhci_cdns_execute_tuning (mmc->dev, -MMC_CMD_SEND_TUNING_BLOCK ); -if (ret) { -dev_err (mmc->dev, -"SD_HS tuning failed (ret=%d), using default PHY\n" , - ret); -/* Restore default PHY settings and avoid retrying in this mode */ -sdhci_cdns6_phy_adj (mmc->dev, plat, - mmc->selected_mode); - plat->tuned_mode = mmc->selected_mode; - plat->tuned_dll_slave_ctrl =sdhci_cdns6_phy_get_dll_slave (plat); -return 0 ; - } -/* -* Tuning succeeded. The tuned_mode is already set by -* execute_tuning(), so the tuned value will be preserved -* across subsequent PHY reconfigurations. -*/ -dev_dbg (mmc->dev,"SD_HS tuning successful\n" ); - } - -/* Reset when mode changes away from a tuned mode */ -if (mmc->selected_mode != plat->tuned_mode) { - plat->tuned_mode =MMC_MODES_END ; - plat->tuned_dll_slave_ctrl =0 ; - } - } - -return 0 ; -} -static const struct sdhci_ops sdhci_cdns_ops = { .set_control_reg = sdhci_cdns_set_control_reg, - .set_ios_post = sdhci_cdns_set_ios_post, }; static int sdhci_cdns_set_tune_val(struct sdhci_cdns_plat *plat,
@@ -292,7 +204,6 @@ static int __maybe_unused sdhci_cdns_execute_tuning(struct udevice *dev,int cur_streak =0 ;int max_streak =0 ;int end_of_streak =0 ; -int ret;int i;/*
@@ -318,24 +229,7 @@ static int __maybe_unused sdhci_cdns_execute_tuning(struct udevice *dev,return -EIO ; } - ret =sdhci_cdns_set_tune_val (plat, end_of_streak - max_streak /2 ); -if (ret) -return ret; - -/* -* Mark this mode as tuned. This is critical for both driver tuning -* (SD_HS via set_ios_post) and framework tuning (UHS_SDR104, MMC_HS_200, -* MMC_HS_400) so that subsequent PHY reconfigurations restore the -* calibrated DLL value instead of overwriting with DT defaults. -* -* For HS400, tuning is performed while the controller is in HS200 mode -* (mmc->selected_mode == MMC_HS_200 and mmc->hs400_tuning == true). -* Record the tuned mode as MMC_HS_400 so the calibrated DLL value is -* preserved across the HS200→HS400 transition. -*/ - plat->tuned_mode = mmc->hs400_tuning ?MMC_HS_400 : mmc->selected_mode; - -return 0 ; +return sdhci_cdns_set_tune_val (plat, end_of_streak - max_streak /2 ); }static struct dm_mmc_ops sdhci_cdns_mmc_ops;
drivers/mmc/sdhci-cadence.h +0 -5
@@ -7,8 +7,6 @@#ifndef SDHCI_CADENCE_H_ #define SDHCI_CADENCE_H_ -#include <mmc.h> -/* HRS - Host Register Set (specific to Cadence) */ /* PHY access port */ #define SDHCI_CDNS_HRS04 0x10
@@ -62,13 +60,10 @@ struct sdhci_cdns_plat {struct mmc_config cfg;struct mmc mmc; void __iomem *hrs_addr; -enum bus_mode tuned_mode; - u32 tuned_dll_slave_ctrl; };int sdhci_cdns6_phy_adj (struct udevice *dev,struct sdhci_cdns_plat *plat,u32 mode);int sdhci_cdns6_phy_init (struct udevice *dev,struct sdhci_cdns_plat *plat);int sdhci_cdns6_set_tune_val (struct sdhci_cdns_plat *plat,unsigned int val); -u32 sdhci_cdns6_phy_get_dll_slave (struct sdhci_cdns_plat *plat);#endif
drivers/mmc/sdhci-cadence6.c +1 -44
66 lines not on this page · raw message
Signature · 1 line
2.43.7
Quoted 27 lines · Tanmay Kathpalia
This reverts commit
b42c67188c14("mmc: sdhci-cadence: trigger tuning for SD HS mode on SD6HC (v6) PHY").The reverted patch introduced several issues:
1. Non-standard tuning trigger: The SD Physical Layer Specification only mandates
execute_tuningfor SDR50 and SDR104 UHS-I modes. Triggering tuning for SD High Speed mode is outside the spec and is handled via a non-standardset_ios_postcallback rather than through the established SDHCI framework tuning path.2. Non-standard device tree property: The patch introduced a new "cdns,sd-hs-tuning" DT property to opt into SD HS tuning. This is not aligned with existing DT bindings and bypasses the standard MMC capability negotiation mechanism.
3. Incorrect tunable mode allowlist: The
sdhci_cdns6_mode_is_tuned()function includesSD_HS,UHS_SDR50, andMMC_HS_400_ESas tunable modes. According to the Cadence SD6HC IP User Guide (section 7.5.2, Figure 18), tuning is only required for UHS-I SDR104 (SD) and HS200 (eMMC). SD High Speed, UHS-I SDR50, and DDR50 only require a PHY settings update from the pre-calculation script, not the tuning procedure. HS400 transitions through HS200 and reuses its tuned DLL value with a partial settings update. HS400ES only requires a plain settings update from the calculation script with no dependency on HS200 tuning.
Quoted 8 lines
4. Tuned state management outside the framework: The patch manually tracks tuned DLL state (
tuned_mode,tuned_dll_slave_ctrl) and restores it across PHY reconfigurations. This duplicates responsibility that belongs in the core MMC tuning framework and adds unnecessary complexity to the driver.Reverting to realign the driver with the IP documentation and the SD Physical Layer Specification.
Thank you for the update.
Peng Fan
AppliedQuoted 33 lines · Tanmay Kathpalia
This reverts commit
b42c67188c14("mmc: sdhci-cadence: trigger tuning for SD HS mode on SD6HC (v6) PHY").The reverted patch introduced several issues:
1. Non-standard tuning trigger: The SD Physical Layer Specification only mandates
execute_tuningfor SDR50 and SDR104 UHS-I modes. Triggering tuning for SD High Speed mode is outside the spec and is handled via a non-standardset_ios_postcallback rather than through the established SDHCI framework tuning path.2. Non-standard device tree property: The patch introduced a new "cdns,sd-hs-tuning" DT property to opt into SD HS tuning. This is not aligned with existing DT bindings and bypasses the standard MMC capability negotiation mechanism.
3. Incorrect tunable mode allowlist: The
sdhci_cdns6_mode_is_tuned()function includesSD_HS,UHS_SDR50, andMMC_HS_400_ESas tunable modes. According to the Cadence SD6HC IP User Guide (section 7.5.2, Figure 18), tuning is only required for UHS-I SDR104 (SD) and HS200 (eMMC). SD High Speed, UHS-I SDR50, and DDR50 only require a PHY settings update from the pre-calculation script, not the tuning procedure. HS400 transitions through HS200 and reuses its tuned DLL value with a partial settings update. HS400ES only requires a plain settings update from the calculation script with no dependency on HS200 tuning.4. Tuned state management outside the framework: The patch manually tracks tuned DLL state (
tuned_mode,tuned_dll_slave_ctrl) and restores it across PHY reconfigurations. This duplicates responsibility that belongs in the core MMC tuning framework and adds unnecessary complexity to the driver.
Quoted 4 lines
Reverting to realign the driver with the IP documentation and the SD Physical Layer Specification.
Signed-off-by Tanmay Kathpalia <[email protected]>
Applied.
Thanks
Peng