From c897adb1c65fae7080a9eec9c31340c27b054ee9 Mon Sep 17 00:00:00 2001 From: Paul Alvin Date: Tue, 25 Feb 2025 10:07:12 +0000 Subject: [PATCH] sd: mmc: Remove unwanted request to card for reading OCR content As part of the MMC card initialization sequence, CMD1 command send multiple times to the card, first time to identify the card type and second time to check the requested voltage window is supported or not. There is a chance that after issuing the CMD1 for first time, card will move to the ready state before issuing the CMD1 for second time. In this case, card will not respond to the CMD1 send for the second time as card is already moved to ready state and this leads to failures. Hence remove the separate card identification logic and call mmc_send_op_cond only once to check both supported voltage window and card type identification. Signed-off-by: Paul Alvin --- subsys/sd/mmc.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/subsys/sd/mmc.c b/subsys/sd/mmc.c index 8ea0b5746d7..02216d3700a 100644 --- a/subsys/sd/mmc.c +++ b/subsys/sd/mmc.c @@ -111,16 +111,6 @@ int mmc_card_init(struct sd_card *card) return -EINVAL; } - /* Probe to see if card is an MMC card */ - ret = mmc_send_op_cond(card, ocr_arg); - if (ret) { - return ret; - } - /* Card is MMC card if no error - * (Only MMC protocol supports CMD1) - */ - card->type = CARD_MMC; - /* Set OCR Arguments */ if (card->host_props.host_caps.vol_180_support) { ocr_arg |= MMC_OCR_VDD170_195FLAG; @@ -137,7 +127,7 @@ int mmc_card_init(struct sd_card *card) /* CMD1 */ ret = mmc_send_op_cond(card, ocr_arg); if (ret) { - LOG_ERR("Failed to query card OCR"); + LOG_DBG("Failed to query card OCR"); return ret; } @@ -221,9 +211,11 @@ static int mmc_send_op_cond(struct sd_card *card, int ocr) /* OCR failed */ return ret; } - if (ocr == 0) { - /* Just probing */ - return 0; + if (retries == 0) { + /* Card is MMC card if no error + * (Only MMC protocol supports CMD1) + */ + card->type = CARD_MMC; } sd_delay(10); }