mmc: core: when downgrading HS400, callback into drivers earlier
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Tue, 1 Sep 2020 15:02:47 +0000 (17:02 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 7 Sep 2020 07:16:31 +0000 (09:16 +0200)
The driver specific downgrade function makes more sense if we run it
before we set the timing to something lower, not after. Otherwise some
non-HS400 communication has already happened.

No need to convert users. There is only one currently which needs this
change in a following patch.

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/20200901150250.26236-2-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/mmc.c

index b3fa193de846d957b9ae3d5ac99e244496825e12..ba2852b684b167809e751f4ae01c37bce4cd6075 100644 (file)
@@ -1168,13 +1168,13 @@ static int mmc_select_hs400(struct mmc_card *card)
                return err;
        }
 
-       /* Set host controller to HS timing */
-       mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
-
        /* Prepare host to downgrade to HS timing */
        if (host->ops->hs400_downgrade)
                host->ops->hs400_downgrade(host);
 
+       /* Set host controller to HS timing */
+       mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
+
        /* Reduce frequency to HS frequency */
        max_dtr = card->ext_csd.hs_max_dtr;
        mmc_set_clock(host, max_dtr);
@@ -1253,6 +1253,9 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
        if (err)
                goto out_err;
 
+       if (host->ops->hs400_downgrade)
+               host->ops->hs400_downgrade(host);
+
        mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
 
        err = mmc_switch_status(card, true);
@@ -1268,9 +1271,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 
        mmc_set_timing(host, MMC_TIMING_MMC_HS);
 
-       if (host->ops->hs400_downgrade)
-               host->ops->hs400_downgrade(host);
-
        err = mmc_switch_status(card, true);
        if (err)
                goto out_err;