Enable power cycle and re-initialization of SD cards via the hw_reset
bus_ops. Power cycling a buggy SD card sometimes helps it get back on
track.

Signed-off-by: Johan Rudholm <joha...@axis.com>
---
 drivers/mmc/core/sd.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index d90a6de..a7fa124 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1180,6 +1180,18 @@ static int mmc_sd_runtime_resume(struct mmc_host *host)
        return 0;
 }
 
+static int mmc_sd_hw_reset(struct mmc_host *host, int test)
+{
+       struct mmc_card *card = host->card;
+
+       if (test == MMC_HW_RESET_TEST || test == MMC_HW_RESET_TEST_CARD)
+               return 0;
+
+       mmc_power_cycle(host, card->ocr);
+
+       return 0;
+}
+
 static int mmc_sd_power_restore(struct mmc_host *host)
 {
        int ret;
@@ -1201,6 +1213,7 @@ static const struct mmc_bus_ops mmc_sd_ops = {
        .power_restore = mmc_sd_power_restore,
        .alive = mmc_sd_alive,
        .shutdown = mmc_sd_suspend,
+       .hw_reset = mmc_sd_hw_reset,
 };
 
 /*
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to