Skip to content

Commit 0d98a51

Browse files
maass-hamburgkartben
authored andcommitted
sd: speed up mmc init
speed up mmc init, when sdmmc is also used. as sdmmc has to fail for that and can take some long time. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
1 parent 95b48cd commit 0d98a51

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

drivers/disk/mmc_subsys.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ static int disk_mmc_init(const struct device *dev)
114114

115115
data->status = SD_UNINIT;
116116
data->card.bus_width = config->bus_width;
117+
data->card.type = CARD_MMC;
117118

118119
return disk_access_register(data->disk_info);
119120
}

subsys/sd/sd.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,16 @@ static int sd_command_init(struct sd_card *card)
202202
if (ret) {
203203
return ret;
204204
}
205-
205+
#ifdef CONFIG_MMC_STACK
206+
/*
207+
* If card type is already known, skip to relevant init.
208+
* SDMMC init takes pretty long, until it fails and we can
209+
* try MMC init.
210+
*/
211+
if (card->type == CARD_MMC) {
212+
goto mmc_init;
213+
}
214+
#endif /* CONFIG_MMC_STACK */
206215
#ifdef CONFIG_SDIO_STACK
207216
/* Attempt to initialize SDIO card */
208217
if (!sdio_card_init(card)) {
@@ -216,6 +225,7 @@ static int sd_command_init(struct sd_card *card)
216225
}
217226
#endif /* CONFIG_SDMMC_STACK */
218227
#ifdef CONFIG_MMC_STACK
228+
mmc_init:
219229
ret = sd_idle(card);
220230
if (ret) {
221231
LOG_ERR("Card error on CMD0");

0 commit comments

Comments
 (0)