@@ -1351,6 +1351,7 @@ void mmc_power_off(struct mmc_host *host)
* Reset ocr mask to be the highest possible voltage supported for
* this mmc host. This value will be used at next power up.
*/
+ host->ocr_bak = host->ocr;
host->ocr = 1 << (fls(host->ocr_avail) - 1);
if (!mmc_host_is_spi(host)) {
@@ -2491,7 +2492,6 @@ int mmc_resume_host(struct mmc_host *host)
if (host->bus_ops && !host->bus_dead) {
if (!mmc_card_keep_power(host)) {
mmc_power_up(host);
- mmc_select_voltage(host, host->ocr);
/*
* Tell runtime PM core we just powered up the card,
* since it still believes the card is powered off.
@@ -882,7 +882,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
err = -ENOENT;
goto err;
}
-
+ /* restore ocr for the same card */
+ if (host->ocr_bak && (host->ocr_bak != host->ocr))
+ host->ocr = mmc_select_voltage(host, host->ocr_bak);
card = oldcard;
} else {
/*
@@ -908,7 +908,9 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
if (oldcard) {
if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0)
return -ENOENT;
-
+ /* restore ocr for the same card */
+ if (host->ocr_bak && (host->ocr_bak != host->ocr))
+ host->ocr = mmc_select_voltage(host, host->ocr_bak);
card = oldcard;
} else {
/*
@@ -594,6 +594,11 @@ static int mmc_sdio_init_card(struct mmc_host
*host, u32 ocr,
err = mmc_send_io_op_cond(host, host->ocr, &ocr);
if (err)
goto err;
+ if (oldcard) {
+ /* restore ocr for the same card */
+ if (host->ocr_bak && (host->ocr_bak != host->ocr))
+ host->ocr = mmc_select_voltage(host,
host->ocr_bak);
+ }
}
/*
@@ -285,6 +285,7 @@ struct mmc_host {
struct mmc_ios ios; /* current io bus settings */
u32 ocr; /* the current OCR setting */
+ u32 ocr_bak; /* save current OCR setting */
/* group bitfields together to minimize padding */
unsigned int use_spi_crc:1;