mmc: renesas_sdhi: populate hook for longer busy_wait
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Wed, 25 Nov 2020 21:30:01 +0000 (22:30 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Fri, 4 Dec 2020 12:30:35 +0000 (13:30 +0100)
Make use of the EXTOP bit in R-Car Gen3 SoCs to have a twice as large
busy wait duration.

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/20201125213001.15003-4-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.h

index 153767054c0585617a623a5d8417f8f8ff64d68f..38f028e70633b336e421d7526e0969ddec368a30 100644 (file)
@@ -561,6 +561,7 @@ static int renesas_sdhi_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_io
 static void renesas_sdhi_reset(struct tmio_mmc_host *host)
 {
        struct renesas_sdhi *priv = host_to_priv(host);
+       u16 val;
 
        if (priv->scc_ctl) {
                renesas_sdhi_disable_scc(host->mmc);
@@ -573,6 +574,21 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host)
        }
 
        sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, TMIO_MASK_INIT_RCAR2);
+
+       if (sd_ctrl_read16(host, CTL_VERSION) >= SDHI_VER_GEN3_SD) {
+               val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);
+               val |= CARD_OPT_EXTOP;
+               sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, val);
+       }
+}
+
+static unsigned int renesas_sdhi_gen3_get_cycles(struct tmio_mmc_host *host)
+{
+       u16 num, val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);
+
+       num = (val & CARD_OPT_TOP_MASK) >> CARD_OPT_TOP_SHIFT;
+       return 1 << ((val & CARD_OPT_EXTOP ? 14 : 13) + num);
+
 }
 
 #define SH_MOBILE_SDHI_MIN_TAP_ROW 3
@@ -1067,6 +1083,10 @@ int renesas_sdhi_probe(struct platform_device *pdev,
                        quirks->hs400_calib_table + 1);
        }
 
+       /* these have an EXTOP bit */
+       if (ver >= SDHI_VER_GEN3_SD)
+               host->get_timeout_cycles = renesas_sdhi_gen3_get_cycles;
+
        /* Enable tuning iff we have an SCC and a supported mode */
        if (of_data && of_data->scc_offset &&
            (host->mmc->caps & MMC_CAP_UHS_SDR104 ||
index f60559bc413a4755ad8f2af05bfa905cb1772ba0..784fa6ed58437b25d8cd0e26a5c026efbcc712c4 100644 (file)
@@ -82,7 +82,9 @@
 /* Definitions for values the CTL_SD_MEM_CARD_OPT register can take */
 #define CARD_OPT_TOP_MASK      0xf0
 #define CARD_OPT_TOP_SHIFT     4
+#define CARD_OPT_EXTOP         BIT(9) /* first appeared on R-Car Gen3 SDHI */
 #define CARD_OPT_WIDTH8                BIT(13)
+#define CARD_OPT_ALWAYS1       BIT(14)
 #define CARD_OPT_WIDTH         BIT(15)
 
 /* Definitions for values the CTL_SDIO_STATUS register can take */