@@ -1141,7 +1141,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
md->reset_done |= type;
err = mmc_hw_reset(host);
/* Ensure we switch back to the correct partition */
- if (err != -EOPNOTSUPP) {
+ if (!err) {
struct mmc_blk_data *main_md =
dev_get_drvdata(&host->card->dev);
int part_err;
@@ -1153,7 +1153,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
* We have failed to get back into the correct
* partition, so we need to abort the whole request.
*/
- return -ENODEV;
+ err = -ENODEV;
}
}
return err;
@@ -2468,8 +2468,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;
}
@@ -1988,19 +1988,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_set_clock(host, host->f_init);
-
- host->ops->hw_reset(host);
-
- /* Set initial state and call mmc_set_ios */
- mmc_set_initial_state(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);
}
When the eMMC device does not support/allow sending RST_n signal, try to do a brute force power cycle instead of returning EOPNOTSUPP. If power cycle is not supported by the hardware, mmc_init_card still send a CMD0, performing a Software Reset. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> --- Changes in v4: - Integrate Ulf's comment: update mmc_blk_reset() drivers/mmc/card/block.c | 4 ++-- drivers/mmc/core/core.c | 5 +++-- drivers/mmc/core/mmc.c | 24 +++++++++++------------- 3 files changed, 16 insertions(+), 17 deletions(-)