From 7716fb9b8fe4b3b77e00d376711d35636aff4822 Mon Sep 17 00:00:00 2001 From: Ram Prakash Gupta Date: Thu, 26 Apr 2018 16:24:46 +0530 Subject: [PATCH] mmc: core: power cycle card when sd card switch voltage operation fails As per the sd card spec, mmc need to power cycle sd card in case sd card voltage switch operation fails. Currently we are directly going for low speed mode without power cycle, which is in violation of sd card spec. Now we will retry for 10 times in case timeout happens while switching voltage and at last, in case, it did not succeed in switching sd card voltage, mmc would go for low speed mode. Change-Id: Icece08732b8d52104e0890dce81ad16844265edd Signed-off-by: Ram Prakash Gupta --- drivers/mmc/core/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 2af0e819d0cb..547d18c9feef 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -3011,8 +3011,16 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr) */ mmc_host_clk_hold(host); err = mmc_wait_for_cmd(host, &cmd, 0); - if (err) - goto err_command; + if (err) { + if (err == -ETIMEDOUT) { + pr_debug("%s: voltage switching failed with err %d\n", + mmc_hostname(host), err); + err = -EAGAIN; + goto power_cycle; + } else { + goto err_command; + } + } if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR)) { err = -EIO;