OSDN Git Service

mmc: core: power cycle card when sd card switch voltage operation fails
authorRam Prakash Gupta <rampraka@codeaurora.org>
Thu, 26 Apr 2018 10:54:46 +0000 (16:24 +0530)
committerRam Prakash Gupta <rampraka@codeaurora.org>
Wed, 2 May 2018 09:44:25 +0000 (15:14 +0530)
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 <rampraka@codeaurora.org>
drivers/mmc/core/core.c

index 2af0e81..547d18c 100644 (file)
@@ -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;