public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: meson-mx-sdhc: Fix initialization frozen issue
@ 2023-06-19 17:34 Ziyang Huang
  2023-06-19 19:51 ` Martin Blumenstingl
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Ziyang Huang @ 2023-06-19 17:34 UTC (permalink / raw)
  To: ulf.hansson
  Cc: neil.armstrong, khilman, jbrunet, martin.blumenstingl, linux-mmc,
	linux-arm-kernel, linux-amlogic, linux-kernel, Ziyang Huang

Commit 4bc31edebde5 ("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 a common value - 1 just for initialization. Then let
meson_mx_sdhc_execute_tuning() to find the accurate value for data
transfer.

Fixes: e4bf1b0970ef ("mmc: host: meson-mx-sdhc: new driver for the Amlogic Meson SDHC host")
Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
---
 drivers/mmc/host/meson-mx-sdhc-mmc.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/mmc/host/meson-mx-sdhc-mmc.c b/drivers/mmc/host/meson-mx-sdhc-mmc.c
index da85c2f2..a01090a2 100644
--- a/drivers/mmc/host/meson-mx-sdhc-mmc.c
+++ b/drivers/mmc/host/meson-mx-sdhc-mmc.c
@@ -269,7 +269,6 @@ static int meson_mx_sdhc_enable_clks(struct mmc_host *mmc)
 static int meson_mx_sdhc_set_clk(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct meson_mx_sdhc_host *host = mmc_priv(mmc);
-	u32 rx_clk_phase;
 	int ret;
 
 	meson_mx_sdhc_disable_clks(mmc);
@@ -290,31 +289,12 @@ static int meson_mx_sdhc_set_clk(struct mmc_host *mmc, struct mmc_ios *ios)
 		mmc->actual_clock = clk_get_rate(host->sd_clk);
 
 		/*
-		 * according to Amlogic the following latching points are
-		 * selected with empirical values, there is no (known) formula
-		 * to calculate these.
+		 * This value is just for initialization. For data transmission,
+		 * meson_mx_sdhc_execute_tuning() will find a accurate value
 		 */
-		if (mmc->actual_clock > 100000000) {
-			rx_clk_phase = 1;
-		} else if (mmc->actual_clock > 45000000) {
-			if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
-				rx_clk_phase = 15;
-			else
-				rx_clk_phase = 11;
-		} else if (mmc->actual_clock >= 25000000) {
-			rx_clk_phase = 15;
-		} else if (mmc->actual_clock > 5000000) {
-			rx_clk_phase = 23;
-		} else if (mmc->actual_clock > 1000000) {
-			rx_clk_phase = 55;
-		} else {
-			rx_clk_phase = 1061;
-		}
-
 		regmap_update_bits(host->regmap, MESON_SDHC_CLK2,
 				   MESON_SDHC_CLK2_RX_CLK_PHASE,
-				   FIELD_PREP(MESON_SDHC_CLK2_RX_CLK_PHASE,
-					      rx_clk_phase));
+				   FIELD_PREP(MESON_SDHC_CLK2_RX_CLK_PHASE, 1));
 	} else {
 		mmc->actual_clock = 0;
 	}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-04-28 12:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-19 17:34 [PATCH] mmc: meson-mx-sdhc: Fix initialization frozen issue Ziyang Huang
2023-06-19 19:51 ` Martin Blumenstingl
2023-07-03 20:28   ` Martin Blumenstingl
2023-07-20 17:45   ` Ziyang Huang
2023-09-14 14:45 ` Ulf Hansson
2023-09-20 13:52   ` Thorsten Leemhuis
2023-10-10 16:44 ` [PATCH v2] " Ziyang Huang
2023-10-23 11:14   ` Ulf Hansson
2023-10-25 10:16     ` Linux regression tracking (Thorsten Leemhuis)
2023-10-29 13:08   ` Anand Moon
2023-11-03 15:21     ` Ziyang Huang
2023-11-03 11:15   ` Ulf Hansson
2023-11-03 15:22     ` Ziyang Huang
2026-04-15 15:31   ` [PATCH v2] mtd: spinand: fmsh: add support for FM25G{01,02}B Ziyang Huang
2026-04-28 12:49     ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox