Skip to content

Commit ddec63e

Browse files
erickshepherdNIgregkh
authored andcommitted
mmc: Add quirk to disable DDR50 tuning
[ Upstream commit 9510b38 ] 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 <erick.shepherd@ni.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/20250331221337.1414534-1-erick.shepherd@ni.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0cd0ef0 commit ddec63e

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

drivers/mmc/core/card.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct mmc_fixup {
8989
#define CID_MANFID_MICRON 0x13
9090
#define CID_MANFID_SAMSUNG 0x15
9191
#define CID_MANFID_APACER 0x27
92+
#define CID_MANFID_SWISSBIT 0x5D
9293
#define CID_MANFID_KINGSTON 0x70
9394
#define CID_MANFID_HYNIX 0x90
9495
#define CID_MANFID_KINGSTON_SD 0x9F
@@ -294,4 +295,9 @@ static inline int mmc_card_broken_sd_poweroff_notify(const struct mmc_card *c)
294295
return c->quirks & MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY;
295296
}
296297

298+
static inline int mmc_card_no_uhs_ddr50_tuning(const struct mmc_card *c)
299+
{
300+
return c->quirks & MMC_QUIRK_NO_UHS_DDR50_TUNING;
301+
}
302+
297303
#endif

drivers/mmc/core/quirks.h

Lines changed: 10 additions & 0 deletions
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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,29 @@ static int sd_set_current_limit(struct mmc_card *card, u8 *status)
613613
return 0;
614614
}
615615

616+
/*
617+
* Determine if the card should tune or not.
618+
*/
619+
static bool mmc_sd_use_tuning(struct mmc_card *card)
620+
{
621+
/*
622+
* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
623+
* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
624+
*/
625+
if (mmc_host_is_spi(card->host))
626+
return false;
627+
628+
switch (card->host->ios.timing) {
629+
case MMC_TIMING_UHS_SDR50:
630+
case MMC_TIMING_UHS_SDR104:
631+
return true;
632+
case MMC_TIMING_UHS_DDR50:
633+
return !mmc_card_no_uhs_ddr50_tuning(card);
634+
}
635+
636+
return false;
637+
}
638+
616639
/*
617640
* UHS-I specific initialization procedure
618641
*/
@@ -656,14 +679,7 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
656679
if (err)
657680
goto out;
658681

659-
/*
660-
* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
661-
* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
662-
*/
663-
if (!mmc_host_is_spi(card->host) &&
664-
(card->host->ios.timing == MMC_TIMING_UHS_SDR50 ||
665-
card->host->ios.timing == MMC_TIMING_UHS_DDR50 ||
666-
card->host->ios.timing == MMC_TIMING_UHS_SDR104)) {
682+
if (mmc_sd_use_tuning(card)) {
667683
err = mmc_execute_tuning(card);
668684

669685
/*

include/linux/mmc/card.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ struct mmc_card {
295295
#define MMC_QUIRK_BROKEN_SD_CACHE (1<<15) /* Disable broken SD cache support */
296296
#define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16) /* Don't flush cache until the write has occurred */
297297
#define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17) /* Disable broken SD poweroff notify support */
298+
#define MMC_QUIRK_NO_UHS_DDR50_TUNING (1<<18) /* Disable DDR50 tuning */
298299

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

0 commit comments

Comments
 (0)