Skip to content

Commit 8c124d9

Browse files
hzyitcstorulf
authored andcommitted
mmc: meson-mx-sdhc: Fix initialization frozen issue
Commit 4bc31ed ("mmc: core: Set HS clock speed before sending HS CMD13") set HS clock (52MHz) before switching to HS mode. For this freq, FCLK_DIV5 will be selected and div value is 10 (reg value is 9). Then we set rx_clk_phase to 11 or 15 which is out of range and make hardware frozen. After we send command request, no irq will be interrupted and the mmc driver will keep to wait for request finished, even durning rebooting. So let's set it to Phase 90 which should work in most cases. Then let meson_mx_sdhc_execute_tuning() to find the accurate value for data transfer. If this doesn't work, maybe need to define a factor in dts. Fixes: e4bf1b0 ("mmc: host: meson-mx-sdhc: new driver for the Amlogic Meson SDHC host") Signed-off-by: Ziyang Huang <[email protected]> Tested-by: Anand Moon <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/TYZPR01MB5556A3E71554A2EC08597EA4C9CDA@TYZPR01MB5556.apcprd01.prod.exchangelabs.com Signed-off-by: Ulf Hansson <[email protected]>
1 parent 33cc938 commit 8c124d9

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

drivers/mmc/host/meson-mx-sdhc-mmc.c

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static int meson_mx_sdhc_enable_clks(struct mmc_host *mmc)
269269
static int meson_mx_sdhc_set_clk(struct mmc_host *mmc, struct mmc_ios *ios)
270270
{
271271
struct meson_mx_sdhc_host *host = mmc_priv(mmc);
272-
u32 rx_clk_phase;
272+
u32 val, rx_clk_phase;
273273
int ret;
274274

275275
meson_mx_sdhc_disable_clks(mmc);
@@ -290,27 +290,11 @@ static int meson_mx_sdhc_set_clk(struct mmc_host *mmc, struct mmc_ios *ios)
290290
mmc->actual_clock = clk_get_rate(host->sd_clk);
291291

292292
/*
293-
* according to Amlogic the following latching points are
294-
* selected with empirical values, there is no (known) formula
295-
* to calculate these.
293+
* Phase 90 should work in most cases. For data transmission,
294+
* meson_mx_sdhc_execute_tuning() will find a accurate value
296295
*/
297-
if (mmc->actual_clock > 100000000) {
298-
rx_clk_phase = 1;
299-
} else if (mmc->actual_clock > 45000000) {
300-
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
301-
rx_clk_phase = 15;
302-
else
303-
rx_clk_phase = 11;
304-
} else if (mmc->actual_clock >= 25000000) {
305-
rx_clk_phase = 15;
306-
} else if (mmc->actual_clock > 5000000) {
307-
rx_clk_phase = 23;
308-
} else if (mmc->actual_clock > 1000000) {
309-
rx_clk_phase = 55;
310-
} else {
311-
rx_clk_phase = 1061;
312-
}
313-
296+
regmap_read(host->regmap, MESON_SDHC_CLKC, &val);
297+
rx_clk_phase = FIELD_GET(MESON_SDHC_CLKC_CLK_DIV, val) / 4;
314298
regmap_update_bits(host->regmap, MESON_SDHC_CLK2,
315299
MESON_SDHC_CLK2_RX_CLK_PHASE,
316300
FIELD_PREP(MESON_SDHC_CLK2_RX_CLK_PHASE,

0 commit comments

Comments
 (0)