Skip to content

Commit 95992eb

Browse files
Andy-ld Lugregkh
authored andcommitted
mmc: mtk-sd: Fix register settings for hs400(es) mode
commit 3e68abf upstream. For hs400(es) mode, the 'hs400-ds-delay' is typically configured in the dts. However, some projects may only define 'mediatek,hs400-ds-dly3', which can lead to initialization failures in hs400es mode. CMD13 reported response crc error in the mmc_switch_status() just after switching to hs400es mode. [ 1.914038][ T82] mmc0: mmc_select_hs400es failed, error -84 [ 1.914954][ T82] mmc0: error -84 whilst initialising MMC card Currently, the hs400_ds_dly3 value is set within the tuning function. This means that the PAD_DS_DLY3 field is not configured before tuning process, which is the reason for the above-mentioned CMD13 response crc error. Move the PAD_DS_DLY3 field configuration into msdc_prepare_hs400_tuning(), and add a value check of hs400_ds_delay to prevent overwriting by zero when the 'hs400-ds-delay' is not set in the dts. In addition, since hs400(es) only tune the PAD_DS_DLY1, the PAD_DS_DLY2_SEL bit should be cleared to bypass it. Fixes: c4ac38c ("mmc: mtk-sd: Add HS400 online tuning support") Signed-off-by: Andy-ld Lu <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7caed8d commit 95992eb

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

drivers/mmc/host/mtk-sd.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@
263263
#define MSDC_PAD_TUNE_CMD2_SEL BIT(21) /* RW */
264264

265265
#define PAD_DS_TUNE_DLY_SEL BIT(0) /* RW */
266+
#define PAD_DS_TUNE_DLY2_SEL BIT(1) /* RW */
266267
#define PAD_DS_TUNE_DLY1 GENMASK(6, 2) /* RW */
267268
#define PAD_DS_TUNE_DLY2 GENMASK(11, 7) /* RW */
268269
#define PAD_DS_TUNE_DLY3 GENMASK(16, 12) /* RW */
@@ -308,6 +309,7 @@
308309

309310
/* EMMC50_PAD_DS_TUNE mask */
310311
#define PAD_DS_DLY_SEL BIT(16) /* RW */
312+
#define PAD_DS_DLY2_SEL BIT(15) /* RW */
311313
#define PAD_DS_DLY1 GENMASK(14, 10) /* RW */
312314
#define PAD_DS_DLY3 GENMASK(4, 0) /* RW */
313315

@@ -2361,13 +2363,23 @@ static int msdc_execute_tuning(struct mmc_host *mmc, u32 opcode)
23612363
static int msdc_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios)
23622364
{
23632365
struct msdc_host *host = mmc_priv(mmc);
2366+
23642367
host->hs400_mode = true;
23652368

2366-
if (host->top_base)
2367-
writel(host->hs400_ds_delay,
2368-
host->top_base + EMMC50_PAD_DS_TUNE);
2369-
else
2370-
writel(host->hs400_ds_delay, host->base + PAD_DS_TUNE);
2369+
if (host->top_base) {
2370+
if (host->hs400_ds_dly3)
2371+
sdr_set_field(host->top_base + EMMC50_PAD_DS_TUNE,
2372+
PAD_DS_DLY3, host->hs400_ds_dly3);
2373+
if (host->hs400_ds_delay)
2374+
writel(host->hs400_ds_delay,
2375+
host->top_base + EMMC50_PAD_DS_TUNE);
2376+
} else {
2377+
if (host->hs400_ds_dly3)
2378+
sdr_set_field(host->base + PAD_DS_TUNE,
2379+
PAD_DS_TUNE_DLY3, host->hs400_ds_dly3);
2380+
if (host->hs400_ds_delay)
2381+
writel(host->hs400_ds_delay, host->base + PAD_DS_TUNE);
2382+
}
23712383
/* hs400 mode must set it to 0 */
23722384
sdr_clr_bits(host->base + MSDC_PATCH_BIT2, MSDC_PATCH_BIT2_CFGCRCSTS);
23732385
/* to improve read performance, set outstanding to 2 */
@@ -2387,14 +2399,11 @@ static int msdc_execute_hs400_tuning(struct mmc_host *mmc, struct mmc_card *card
23872399
if (host->top_base) {
23882400
sdr_set_bits(host->top_base + EMMC50_PAD_DS_TUNE,
23892401
PAD_DS_DLY_SEL);
2390-
if (host->hs400_ds_dly3)
2391-
sdr_set_field(host->top_base + EMMC50_PAD_DS_TUNE,
2392-
PAD_DS_DLY3, host->hs400_ds_dly3);
2402+
sdr_clr_bits(host->top_base + EMMC50_PAD_DS_TUNE,
2403+
PAD_DS_DLY2_SEL);
23932404
} else {
23942405
sdr_set_bits(host->base + PAD_DS_TUNE, PAD_DS_TUNE_DLY_SEL);
2395-
if (host->hs400_ds_dly3)
2396-
sdr_set_field(host->base + PAD_DS_TUNE,
2397-
PAD_DS_TUNE_DLY3, host->hs400_ds_dly3);
2406+
sdr_clr_bits(host->base + PAD_DS_TUNE, PAD_DS_TUNE_DLY2_SEL);
23982407
}
23992408

24002409
host->hs400_tuning = true;

0 commit comments

Comments
 (0)