]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
mmc: fix the wrong disabling clock
authorJaehoon Chung <jh80.chung@samsung.com>
Wed, 17 Jan 2018 10:36:58 +0000 (19:36 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 22 Jan 2018 05:15:34 +0000 (14:15 +0900)
When power is off, clock is not disabling.
Because it's passed to 1, mmc->clock should be set to f_min value.
Some drivers can't initialize the eMMC/SD card with current status.

This patch is to fix the disabling clock value to 0.

Fixes: 2e7410d76ad1 ("mmc: disable the mmc clock during power off")
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Tested-by: Guillaume GARDET <guillaume.gardet@free.fr>
Tested-by: Anand Moon <linux.amoon@gmail.com>
drivers/mmc/mmc.c

index 53c819187e7d8af392953b8c3d833ec8551a76d0..311f51f237776aba735deef51237196da0359158 100644 (file)
@@ -1501,11 +1501,13 @@ static int mmc_set_ios(struct mmc *mmc)
 
 int mmc_set_clock(struct mmc *mmc, uint clock, bool disable)
 {
-       if (clock > mmc->cfg->f_max)
-               clock = mmc->cfg->f_max;
+       if (!disable && clock != 0) {
+               if (clock > mmc->cfg->f_max)
+                       clock = mmc->cfg->f_max;
 
-       if (clock < mmc->cfg->f_min)
-               clock = mmc->cfg->f_min;
+               if (clock < mmc->cfg->f_min)
+                       clock = mmc->cfg->f_min;
+       }
 
        mmc->clock = clock;
        mmc->clk_disable = disable;
@@ -2449,7 +2451,7 @@ static int mmc_power_on(struct mmc *mmc)
 
 static int mmc_power_off(struct mmc *mmc)
 {
-       mmc_set_clock(mmc, 1, true);
+       mmc_set_clock(mmc, 0, true);
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR)
        if (mmc->vmmc_supply) {
                int ret = regulator_set_enable(mmc->vmmc_supply, false);