diff options
| author | Shiji Yang | 2025-05-24 08:31:07 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2025-06-16 17:31:51 +0000 |
| commit | e69c867cdf62623613c9026b577b290edae780a1 (patch) | |
| tree | 2e767d9ce655d6fb4732a2730136713b965fb951 | |
| parent | ca866328d555692e91e870bdeb368a830b39ceba (diff) | |
| download | openwrt-e69c867cdf62623613c9026b577b290edae780a1.tar.gz | |
ramips: mtk-mmc: fix data timeout value
The MT7628 programing guide shows that the correct DTOC unit is
1048576 clocks instead of 65536 clocks. This value is also used
by linux upstream mtk-sd driver. Correct the DTOC register and
also round up its value.
Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Link: https://github.com/openwrt/openwrt/pull/18896
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | target/linux/ramips/files/drivers/mmc/host/mtk-mmc/sd.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/target/linux/ramips/files/drivers/mmc/host/mtk-mmc/sd.c b/target/linux/ramips/files/drivers/mmc/host/mtk-mmc/sd.c index fc89fa5f8b..5a52dd6310 100644 --- a/target/linux/ramips/files/drivers/mmc/host/mtk-mmc/sd.c +++ b/target/linux/ramips/files/drivers/mmc/host/mtk-mmc/sd.c @@ -84,7 +84,7 @@ #endif /* end of --- */ #define DEFAULT_DEBOUNCE (8) /* 8 cycles */ -#define DEFAULT_DTOC (40) /* data timeout counter. 65536x40 sclk. */ +#define DEFAULT_DTOC (40) /* data timeout counter. 1048576x40 sclk. */ #define CMD_TIMEOUT (HZ / 10) /* 100ms */ #define DAT_TIMEOUT (HZ / 2 * 5) /* 500ms x5 */ @@ -414,13 +414,13 @@ static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks) clk_ns = 1000000000UL / host->sclk; timeout = ns / clk_ns + clks; - timeout = timeout >> 16; /* in 65536 sclk cycle unit */ + timeout = DIV_ROUND_UP(timeout, BIT(20)); /* in 1048576 sclk cycle unit */ timeout = timeout > 1 ? timeout - 1 : 0; timeout = timeout > 255 ? 255 : timeout; sdr_set_field(SDC_CFG, SDC_CFG_DTOC, timeout); - N_MSG(OPS, "Set read data timeout: %dns %dclks -> %d x 65536 cycles", + N_MSG(OPS, "Set read data timeout: %dns %dclks -> %d x 1048576 cycles", ns, clks, timeout + 1); } @@ -2276,7 +2276,7 @@ static int msdc_drv_probe(struct platform_device *pdev) host->power_mode = MMC_POWER_OFF; // host->card_inserted = hw->flags & MSDC_REMOVABLE ? 0 : 1; host->timeout_ns = 0; - host->timeout_clks = DEFAULT_DTOC * 65536; + host->timeout_clks = DEFAULT_DTOC * 1048576; host->mrq = NULL; //init_MUTEX(&host->sem); /* we don't need to support multiple threads access */ |