From ea7ba3abc3b9b9d7190c00a13ec624195df55710 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Fri, 1 Apr 2016 16:04:22 -0700 Subject: mmc: core: Do regular power cycle when lacking eMMC HW reset support The eMMC HW reset may be implemented either via the host ops ->hw_reset() callback or through DT and the eMMC pwrseq. Additionally some eMMC cards don't support HW reset. To allow a reset to be done for the different combinations of mmc hosts and eMMC/MMC cards, let's implement a fallback via trying a regular power cycle. This improves the mmc block layer retry mechanism of failing I/O requests. Change-Id: I5cafd54327cde22ea9599543382f1b294272a42c Signed-off-by: Gwendal Grignou [Ulf: Rewrote changelog] Signed-off-by: Ulf Hansson Git-commit: 4e6c71788d6bb0e5438fc9211fa6e52dcca01474 Git-repo: git://git.linaro.org/people/ulf.hansson/mmc.git [vviswana@codeaurora.org: resolve trivial merge conflicts] Signed-off-by: Vijay Viswanath --- drivers/mmc/core/core.c | 5 +++-- drivers/mmc/core/mmc.c | 26 +++++++++++--------------- 2 files changed, 14 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 41f0935440fd..8bdb965d0be8 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -3969,8 +3969,9 @@ int mmc_hw_reset(struct mmc_host *host) ret = host->bus_ops->reset(host); mmc_bus_put(host); - if (ret != -EOPNOTSUPP) - pr_warn("%s: tried to reset card\n", mmc_hostname(host)); + if (ret) + pr_warn("%s: tried to reset card, got error %d\n", + mmc_hostname(host), ret); return ret; } diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index afdf70000651..600fdb8ad7ba 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -2893,21 +2893,17 @@ static int mmc_reset(struct mmc_host *host) { struct mmc_card *card = host->card; - if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) - return -EOPNOTSUPP; - - if (!mmc_can_reset(card)) - return -EOPNOTSUPP; - - mmc_host_clk_hold(host); - mmc_set_clock(host, host->f_init); - - host->ops->hw_reset(host); - - /* Set initial state and call mmc_set_ios */ - mmc_set_initial_state(host); - mmc_host_clk_release(host); - + if ((host->caps & MMC_CAP_HW_RESET) && host->ops->hw_reset && + mmc_can_reset(card)) { + /* If the card accept RST_n signal, send it. */ + mmc_set_clock(host, host->f_init); + host->ops->hw_reset(host); + /* Set initial state and call mmc_set_ios */ + mmc_set_initial_state(host); + } else { + /* Do a brute force power cycle */ + mmc_power_cycle(host, card->ocr); + } return mmc_init_card(host, card->ocr, card); } -- cgit v1.2.3