]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mmc: sdhci-esdhc-imx: verify tuning control status after configuration
authorLuke Wang <ziniu.wang_1@nxp.com>
Wed, 9 Apr 2025 07:55:49 +0000 (15:55 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 14 May 2025 14:59:17 +0000 (16:59 +0200)
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>
drivers/mmc/host/sdhci-esdhc-imx.c

index f94b5f08b432ec28c28c35a3b851e5c61527d543..bc84400400b3c0facaf95ef77d431d895fc72323 100644 (file)
@@ -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);