mmc: tmio: don't reset whole IP core when tuning fails
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 20 Aug 2020 13:25:37 +0000 (15:25 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 7 Sep 2020 07:11:31 +0000 (09:11 +0200)
SDHI needs to reset the SCC only, not the whole IP core. So, if tuning
fails, don't handle specifics in the generic TMIO core, but in the
specific drivers. For SDHI, we need to move around the reset routine a
bit. It is not modified.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20200820132538.24758-6-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/renesas_sdhi_core.c
drivers/mmc/host/tmio_mmc_core.c

index 9b2d4e8039d905087e93eaeaf29bf1699f86dcf4..50a92d49efd9143f807c0fb5051eee4d632ad966 100644 (file)
@@ -432,6 +432,25 @@ static int renesas_sdhi_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_io
        return 0;
 }
 
+static void renesas_sdhi_reset(struct tmio_mmc_host *host)
+{
+       struct renesas_sdhi *priv = host_to_priv(host);
+
+       renesas_sdhi_reset_scc(host, priv);
+       renesas_sdhi_reset_hs400_mode(host, priv);
+
+       sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
+                       sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
+
+       sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
+                      ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
+                      sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
+
+       if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
+               sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK,
+                                            TMIO_MASK_INIT_RCAR2);
+}
+
 #define SH_MOBILE_SDHI_MIN_TAP_ROW 3
 
 static int renesas_sdhi_select_tuning(struct tmio_mmc_host *host)
@@ -503,7 +522,7 @@ static int renesas_sdhi_select_tuning(struct tmio_mmc_host *host)
 static int renesas_sdhi_execute_tuning(struct tmio_mmc_host *host, u32 opcode)
 {
        struct renesas_sdhi *priv = host_to_priv(host);
-       int i;
+       int i, ret;
 
        priv->tap_num = renesas_sdhi_init_tuning(host);
        if (!priv->tap_num)
@@ -531,7 +550,10 @@ static int renesas_sdhi_execute_tuning(struct tmio_mmc_host *host, u32 opcode)
                        set_bit(i, priv->smpcmp);
        }
 
-       return renesas_sdhi_select_tuning(host);
+       ret = renesas_sdhi_select_tuning(host);
+       if (ret < 0)
+               renesas_sdhi_reset(host);
+       return ret;
 }
 
 static bool renesas_sdhi_manual_correction(struct tmio_mmc_host *host, bool use_4tap)
@@ -631,25 +653,6 @@ static bool renesas_sdhi_check_scc_error(struct tmio_mmc_host *host)
        return renesas_sdhi_manual_correction(host, use_4tap);
 }
 
-static void renesas_sdhi_reset(struct tmio_mmc_host *host)
-{
-       struct renesas_sdhi *priv = host_to_priv(host);
-
-       renesas_sdhi_reset_scc(host, priv);
-       renesas_sdhi_reset_hs400_mode(host, priv);
-
-       sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
-                       sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
-
-       sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
-                      ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
-                      sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
-
-       if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
-               sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK,
-                                            TMIO_MASK_INIT_RCAR2);
-}
-
 static int renesas_sdhi_wait_idle(struct tmio_mmc_host *host, u32 bit)
 {
        int timeout = 1000;
index f68c10b8ed611d280725fc536d4df9e5cb8666bb..e7bad761c714edef2b374a0af7872fb2c695cfde 100644 (file)
@@ -722,10 +722,8 @@ static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
 
        ret = host->execute_tuning(host, opcode);
 
-       if (ret < 0) {
+       if (ret < 0)
                dev_warn(&host->pdev->dev, "Tuning procedure failed\n");
-               tmio_mmc_reset(host);
-       }
 
        return ret;
 }