Skip to content

Commit d6a08e8

Browse files
mmc: Add quirk to disable DDR50 tuning
Adds the MMC_QUIRK_NO_UHS_DDR50_TUNING quirk and updates mmc_execute_tuning() to return 0 if that quirk is set. This fixes an issue on certain Swissbit SD cards that do not support DDR50 tuning where tuning requests caused I/O errors to be thrown. Signed-off-by: Erick Shepherd <[email protected]>
1 parent 6769f94 commit d6a08e8

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

drivers/mmc/core/card.h

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct mmc_fixup {
8686
#define CID_MANFID_MICRON 0x13
8787
#define CID_MANFID_SAMSUNG 0x15
8888
#define CID_MANFID_APACER 0x27
89+
#define CID_MANFID_SWISSBIT 0x5D
8990
#define CID_MANFID_KINGSTON 0x70
9091
#define CID_MANFID_HYNIX 0x90
9192
#define CID_MANFID_KINGSTON_SD 0x9F
@@ -291,4 +292,9 @@ static inline int mmc_card_broken_sd_poweroff_notify(const struct mmc_card *c)
291292
return c->quirks & MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY;
292293
}
293294

295+
static inline int mmc_card_no_uhs_ddr50_tuning(const struct mmc_card *c)
296+
{
297+
return c->quirks & MMC_QUIRK_NO_UHS_DDR50_TUNING;
298+
}
299+
294300
#endif

drivers/mmc/core/quirks.h

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ static const struct mmc_fixup __maybe_unused mmc_sd_fixups[] = {
3434
MMC_QUIRK_BROKEN_SD_CACHE | MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY,
3535
EXT_CSD_REV_ANY),
3636

37+
/*
38+
* Swissbit series S46-u cards throw I/O errors during tuning requests
39+
* after the initial tuning request expectedly times out. This has
40+
* only been observed on cards manufactured on 01/2019 that are using
41+
* Bay Trail host controllers.
42+
*/
43+
_FIXUP_EXT("0016G", CID_MANFID_SWISSBIT, 0x5342, 2019, 1,
44+
0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
45+
MMC_QUIRK_NO_UHS_DDR50_TUNING, EXT_CSD_REV_ANY),
46+
3747
END_FIXUP
3848
};
3949

drivers/mmc/core/sd.c

+24-8
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,29 @@ static int sd_set_current_limit(struct mmc_card *card, u8 *status)
618618
return 0;
619619
}
620620

621+
/*
622+
* Determine if the card should tune or not.
623+
*/
624+
static bool mmc_sd_use_tuning(struct mmc_card *card)
625+
{
626+
/*
627+
* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
628+
* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
629+
*/
630+
if (mmc_host_is_spi(card->host))
631+
return false;
632+
633+
switch (card->host->ios.timing) {
634+
case MMC_TIMING_UHS_SDR50:
635+
case MMC_TIMING_UHS_SDR104:
636+
return true;
637+
case MMC_TIMING_UHS_DDR50:
638+
return !mmc_card_no_uhs_ddr50_tuning(card);
639+
}
640+
641+
return false;
642+
}
643+
621644
/*
622645
* UHS-I specific initialization procedure
623646
*/
@@ -661,14 +684,7 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
661684
if (err)
662685
goto out;
663686

664-
/*
665-
* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
666-
* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
667-
*/
668-
if (!mmc_host_is_spi(card->host) &&
669-
(card->host->ios.timing == MMC_TIMING_UHS_SDR50 ||
670-
card->host->ios.timing == MMC_TIMING_UHS_DDR50 ||
671-
card->host->ios.timing == MMC_TIMING_UHS_SDR104)) {
687+
if (mmc_sd_use_tuning(card)) {
672688
err = mmc_execute_tuning(card);
673689

674690
/*

include/linux/mmc/card.h

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ struct mmc_card {
297297
#define MMC_QUIRK_BROKEN_SD_CACHE (1<<15) /* Disable broken SD cache support */
298298
#define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16) /* Don't flush cache until the write has occurred */
299299
#define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17) /* Disable broken SD poweroff notify support */
300+
#define MMC_QUIRK_NO_UHS_DDR50_TUNING (1<<18) /* Disable DDR50 tuning */
300301

301302
bool written_flag; /* Indicates eMMC has been written since power on */
302303
bool reenable_cmdq; /* Re-enable Command Queue */

0 commit comments

Comments
 (0)