Skip to content

Commit 8cdba34

Browse files
Haibo Chenstorulf
authored andcommitted
mmc: sdhci-esdhc-imx: widen auto-tuning window for manual tuning
Expand the auto-tuning window width from 0 to 3 for manual tuning to account for sampling point shifts caused by temperature change. This change is based on hardware recommendation, providing enough margin for the auto-tuning logic to locate valid sampling points. When config the manual tuning final sample delay, need deduct the auto tuning window width according to the IP logic. Signed-off-by: Haibo Chen <[email protected]> Signed-off-by: Luke Wang <[email protected]> Acked-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent be953af commit 8cdba34

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@
8585
#define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1)
8686
#define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_MASK GENMASK(30, 24)
8787
#define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK GENMASK(14, 8)
88-
88+
#define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_OUT_MASK GENMASK(7, 4)
89+
#define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_POST_MASK GENMASK(3, 0)
8990
/* strobe dll register */
9091
#define ESDHC_STROBE_DLL_CTRL 0x70
9192
#define ESDHC_STROBE_DLL_CTRL_ENABLE (1 << 0)
@@ -243,6 +244,7 @@ struct esdhc_platform_data {
243244
unsigned int tuning_start_tap; /* The start delay cell point in tuning procedure */
244245
unsigned int strobe_dll_delay_target; /* The delay cell for strobe pad (read clock) */
245246
unsigned int saved_tuning_delay_cell; /* save the value of tuning delay cell */
247+
unsigned int saved_auto_tuning_window; /* save the auto tuning window width */
246248
};
247249

248250
struct esdhc_soc_data {
@@ -1211,6 +1213,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
12111213
{
12121214
int min, max, avg, ret;
12131215
int win_length, target_min, target_max, target_win_length;
1216+
u32 clk_tune_ctrl_status;
12141217

12151218
min = ESDHC_TUNE_CTRL_MIN;
12161219
max = ESDHC_TUNE_CTRL_MIN;
@@ -1250,6 +1253,23 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
12501253
/* use average delay to get the best timing */
12511254
avg = (target_min + target_max) / 2;
12521255
esdhc_prepare_tuning(host, avg);
1256+
1257+
/*
1258+
* adjust the delay according to tuning window, make preparation
1259+
* for the auto-tuning logic. According to hardware suggest, need
1260+
* to config the auto tuning window width to 3, to make the auto
1261+
* tuning logic have enough space to handle the sample point shift
1262+
* caused by temperature change.
1263+
*/
1264+
clk_tune_ctrl_status = FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK,
1265+
avg - ESDHC_AUTO_TUNING_WINDOW) |
1266+
FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_OUT_MASK,
1267+
ESDHC_AUTO_TUNING_WINDOW) |
1268+
FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_POST_MASK,
1269+
ESDHC_AUTO_TUNING_WINDOW);
1270+
1271+
writel(clk_tune_ctrl_status, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
1272+
12531273
ret = mmc_send_tuning(host->mmc, opcode, NULL);
12541274
esdhc_post_tuning(host);
12551275

@@ -1652,7 +1672,11 @@ static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
16521672
writel(reg, host->ioaddr + ESDHC_MIX_CTRL);
16531673

16541674
writel(FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK,
1655-
imx_data->boarddata.saved_tuning_delay_cell),
1675+
imx_data->boarddata.saved_tuning_delay_cell) |
1676+
FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_OUT_MASK,
1677+
ESDHC_AUTO_TUNING_WINDOW) |
1678+
FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_POST_MASK,
1679+
ESDHC_AUTO_TUNING_WINDOW),
16561680
host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
16571681
}
16581682
}

0 commit comments

Comments
 (0)