@@ -553,6 +553,12 @@ static void mmc_sdio_resend_if_cond(struct mmc_host *host,
mmc_remove_card(card);
}
+static bool mmc_sdio_valid_rocr(u32 rocr)
+{
+ return (rocr & MMC_CARD_BUSY) && R4_OCR(rocr) &&
+ R4_FUNCTION_NUMBER(rocr);
+}
+
/*
* Handle the detection and initialisation of a card.
*
@@ -605,6 +611,12 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
goto err;
}
+ if (!mmc_sdio_valid_rocr(rocr)) {
+ mmc_sdio_resend_if_cond(host, card);
+ retries--;
+ goto try_again;
+ }
+
if ((rocr & R4_MEMORY_PRESENT) &&
mmc_sd_get_cid(host, ocr & rocr, card->raw_cid, NULL) == 0) {
card->type = MMC_TYPE_SD_COMBO;
@@ -646,7 +658,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
*/
if (rocr & ocr & R4_18V_PRESENT) {
err = mmc_set_uhs_voltage(host, ocr_card);
- if (err == -EAGAIN) {
+ if (err == -EAGAIN || err == -EILSEQ) {
mmc_sdio_resend_if_cond(host, card);
retries--;
goto try_again;
@@ -36,6 +36,8 @@
#define R4_18V_PRESENT (1<<24)
#define R4_MEMORY_PRESENT (1 << 27)
+#define R4_OCR(x) ((x) & 0xFFFFFF)
+#define R4_FUNCTION_NUMBER(x) (((x) & 0x70000000) >> 28)
/*
SDIO status in R5