summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Wang <ziniu.wang_1@nxp.com>2025-04-09 15:55:49 +0800
committerUlf Hansson <ulf.hansson@linaro.org>2025-05-14 16:59:17 +0200
commit309d7ef65f46f01afd723401f7fc210244a08159 (patch)
tree49c6514bcf8e62f52aa7c3e2dc65c10712c1d51f
parent8cdba34313712e0dbc4c5650c8f2dcf315c13e6f (diff)
mmc: sdhci-esdhc-imx: verify tuning control status after configuration
Enhance manual tuning configuration reliability by adding tuning control status checks per the i.MX Reference Manual recommendations. Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/20250409075550.3413032-6-ziniu.wang_1@nxp.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index f94b5f08b432..bc84400400b3 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -83,6 +83,7 @@
#define ESDHC_TUNE_CTRL_STEP 1
#define ESDHC_TUNE_CTRL_MIN 0
#define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1)
+#define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_MASK GENMASK(30, 16)
#define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_MASK GENMASK(30, 24)
#define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK GENMASK(14, 8)
#define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_OUT_MASK GENMASK(7, 4)
@@ -1213,7 +1214,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
{
int min, max, avg, ret;
int win_length, target_min, target_max, target_win_length;
- u32 clk_tune_ctrl_status;
+ u32 clk_tune_ctrl_status, temp;
min = ESDHC_TUNE_CTRL_MIN;
max = ESDHC_TUNE_CTRL_MIN;
@@ -1269,6 +1270,13 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
ESDHC_AUTO_TUNING_WINDOW);
writel(clk_tune_ctrl_status, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
+ ret = readl_poll_timeout(host->ioaddr + ESDHC_TUNE_CTRL_STATUS, temp,
+ clk_tune_ctrl_status ==
+ FIELD_GET(ESDHC_TUNE_CTRL_STATUS_TAP_SEL_MASK, temp),
+ 1, 10);
+ if (ret == -ETIMEDOUT)
+ dev_warn(mmc_dev(host->mmc),
+ "clock tuning control status not set in 10us\n");
ret = mmc_send_tuning(host->mmc, opcode, NULL);
esdhc_post_tuning(host);