mmc: core: Hold re-tuning during switch commands
Hold re-tuning during switch commands to prevent it from conflicting with the busy state or the CMD13 verification. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
90a81489b0
commit
c6dbab9cb5
1 changed files with 20 additions and 10 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include <linux/mmc/mmc.h>
|
#include <linux/mmc/mmc.h>
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
#include "host.h"
|
||||||
#include "mmc_ops.h"
|
#include "mmc_ops.h"
|
||||||
|
|
||||||
#define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
|
#define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
|
||||||
|
@ -474,6 +475,8 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
u32 status = 0;
|
u32 status = 0;
|
||||||
bool use_r1b_resp = use_busy_signal;
|
bool use_r1b_resp = use_busy_signal;
|
||||||
|
|
||||||
|
mmc_retune_hold(host);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the cmd timeout and the max_busy_timeout of the host are both
|
* If the cmd timeout and the max_busy_timeout of the host are both
|
||||||
* specified, let's validate them. A failure means we need to prevent
|
* specified, let's validate them. A failure means we need to prevent
|
||||||
|
@ -506,11 +509,11 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
|
|
||||||
err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
|
err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
goto out;
|
||||||
|
|
||||||
/* No need to check card status in case of unblocking command */
|
/* No need to check card status in case of unblocking command */
|
||||||
if (!use_busy_signal)
|
if (!use_busy_signal)
|
||||||
return 0;
|
goto out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CRC errors shall only be ignored in cases were CMD13 is used to poll
|
* CRC errors shall only be ignored in cases were CMD13 is used to poll
|
||||||
|
@ -529,7 +532,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
if (send_status) {
|
if (send_status) {
|
||||||
err = __mmc_send_status(card, &status, ignore_crc);
|
err = __mmc_send_status(card, &status, ignore_crc);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
goto out;
|
||||||
}
|
}
|
||||||
if ((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp)
|
if ((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp)
|
||||||
break;
|
break;
|
||||||
|
@ -543,29 +546,36 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
*/
|
*/
|
||||||
if (!send_status) {
|
if (!send_status) {
|
||||||
mmc_delay(timeout_ms);
|
mmc_delay(timeout_ms);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Timeout if the device never leaves the program state. */
|
/* Timeout if the device never leaves the program state. */
|
||||||
if (time_after(jiffies, timeout)) {
|
if (time_after(jiffies, timeout)) {
|
||||||
pr_err("%s: Card stuck in programming state! %s\n",
|
pr_err("%s: Card stuck in programming state! %s\n",
|
||||||
mmc_hostname(host), __func__);
|
mmc_hostname(host), __func__);
|
||||||
return -ETIMEDOUT;
|
err = -ETIMEDOUT;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
|
} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
|
||||||
|
|
||||||
if (mmc_host_is_spi(host)) {
|
if (mmc_host_is_spi(host)) {
|
||||||
if (status & R1_SPI_ILLEGAL_COMMAND)
|
if (status & R1_SPI_ILLEGAL_COMMAND) {
|
||||||
return -EBADMSG;
|
err = -EBADMSG;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (status & 0xFDFFA000)
|
if (status & 0xFDFFA000)
|
||||||
pr_warn("%s: unexpected status %#x after switch\n",
|
pr_warn("%s: unexpected status %#x after switch\n",
|
||||||
mmc_hostname(host), status);
|
mmc_hostname(host), status);
|
||||||
if (status & R1_SWITCH_ERROR)
|
if (status & R1_SWITCH_ERROR) {
|
||||||
return -EBADMSG;
|
err = -EBADMSG;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
|
mmc_retune_release(host);
|
||||||
|
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__mmc_switch);
|
EXPORT_SYMBOL_GPL(__mmc_switch);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue