summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksii Bidnichenko <oleksii.bidnichenko@toradex.com>2021-09-09 16:51:43 +0300
committerOleksii Bidnichenko <oleksii.bidnichenko@toradex.com>2021-09-10 12:35:03 +0000
commit3b3cd650c6ee40aa7afb2d6f1fa97c799c639ebb (patch)
tree3b95b0daa69e3a584a4d1087c29e9f732575a5ff
parent4a7ccaf261a5991c9019d19f01b6cc6cfabd7b55 (diff)
mmc: merge upstream __mmc_switch fixes
commit 8e2b0af7216d78b60fccb46a107a4a047938aea9 upstream. commit ef5ab0d13a7a44469f6c765c8acc8d54c23213de upstream. Update a __mmc_switch MMC_STATUS_SWITCH_ERROR notification level from debug to error. Related-to: ELB-4082 Signed-off-by: Oleksii Bidnichenko <oleksii.bidnichenko@toradex.com>
-rw-r--r--drivers/mmc/mmc.c9
-rw-r--r--include/mmc.h1
2 files changed, 7 insertions, 3 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 710890a490..6a4d7658e7 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -788,8 +788,10 @@ static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
* capable of polling by using mmc_wait_dat0, then rely on waiting the
* stated timeout to be sufficient.
*/
- if (ret == -ENOSYS && !send_status)
+ if (ret == -ENOSYS && !send_status) {
mdelay(timeout_ms);
+ return 0;
+ }
/* Finally wait until the card is ready or indicates a failure
* to switch. It doesn't hurt to use CMD13 here even if send_status
@@ -800,11 +802,12 @@ static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
ret = mmc_send_status(mmc, &status);
if (!ret && (status & MMC_STATUS_SWITCH_ERROR)) {
- pr_debug("switch failed %d/%d/0x%x !\n", set, index,
+ pr_err("switch failed %d/%d/0x%x !\n", set, index,
value);
return -EIO;
}
- if (!ret && (status & MMC_STATUS_RDY_FOR_DATA))
+ if (!ret && (status & MMC_STATUS_RDY_FOR_DATA) &&
+ (status & MMC_STATUS_CURR_STATE) == MMC_STATE_TRANS)
return 0;
udelay(100);
} while (get_timer(start) < timeout_ms);
diff --git a/include/mmc.h b/include/mmc.h
index d0d0d1b984..9251275e2e 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -177,6 +177,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
#define MMC_STATUS_ERROR (1 << 19)
#define MMC_STATE_PRG (7 << 9)
+#define MMC_STATE_TRANS (4 << 9)
#define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */
#define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */