Skip to contentSkip to conversation

mmc: dw_mmc-rockchip: Fix wrong internal phase calculate

PATCH In review Shawn Lin 3 participants 3 messages Nov 4, 2025 – Nov 11, 2025

Subsystems (3)
lore
Share & tools
lore

Shawn Lin

author maintainer
#0 lore raw

PATCH 1/1 mmc: dw_mmc-rockchip: Fix wrong internal phase calculate

ciu clock is 2 times of io clock, but the sample clk used is derived from io clock provided to the card. So we should use io clock to calculate the phase.

Fixes 59903441f5e4 ("mmc: dw_mmc-rockchip: Add internal phase support")

---

 drivers/mmc/host/dw_mmc-rockchip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc-rockchip.c +2 -2
index 82dd906..6813549 100644
@@ -42,7 +42,7 @@ struct dw_mci_rockchip_priv_data {
  */
 static int rockchip_mmc_get_internal_phase(struct dw_mci *host, bool sample)
 {
-	unsigned long rate = clk_get_rate(host->ciu_clk);
+	unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
 	u32 raw_value;
 	u16 degrees;
 	u32 delay_num = 0;
@@ -85,7 +85,7 @@ static int rockchip_mmc_get_phase(struct dw_mci *host, bool sample)
 
 static int rockchip_mmc_set_internal_phase(struct dw_mci *host, bool sample, int degrees)
 {
-	unsigned long rate = clk_get_rate(host->ciu_clk);
+	unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
 	u8 nineties, remainder;
 	u8 delay_num;
 	u32 raw_value;
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw

Am Dienstag, 4. November 2025, 04:51:23 Mitteleuropäische Normalzeit schrieb Shawn Lin:

Quoted 6 lines

ciu clock is 2 times of io clock, but the sample clk used is derived from io clock provided to the card. So we should use io clock to calculate the phase.

Fixes 59903441f5e4 ("mmc: dw_mmc-rockchip: Add internal phase support")
Quoted 28 lines

---

 drivers/mmc/host/dw_mmc-rockchip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc-rockchip.c +2 -2
index 82dd906..6813549 100644
@@ -42,7 +42,7 @@ struct dw_mci_rockchip_priv_data {
  */
 static int rockchip_mmc_get_internal_phase(struct dw_mci *host, bool sample)
 {
-	unsigned long rate = clk_get_rate(host->ciu_clk);
+	unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
 	u32 raw_value;
 	u16 degrees;
 	u32 delay_num = 0;
@@ -85,7 +85,7 @@ static int rockchip_mmc_get_phase(struct dw_mci *host, bool sample)
 
 static int rockchip_mmc_set_internal_phase(struct dw_mci *host, bool sample, int degrees)
 {
-	unsigned long rate = clk_get_rate(host->ciu_clk);
+	unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
 	u8 nineties, remainder;
 	u8 delay_num;
 	u32 raw_value;
#2 lore raw
In reply to Shawn Lin
Quoted 7 lines · Shawn Lin

ciu clock is 2 times of io clock, but the sample clk used is derived from io clock provided to the card. So we should use io clock to calculate the phase.

Fixes 59903441f5e4 ("mmc: dw_mmc-rockchip: Add internal phase support")

Applied for fixes and by adding a stable-tag, thanks!

Kind regards
Uffe

Quoted 30 lines

---

 drivers/mmc/host/dw_mmc-rockchip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc-rockchip.c +2 -3
index 82dd906..6813549 100644
@@ -42,7 +42,7 @@ struct dw_mci_rockchip_priv_data {
  */
 static int rockchip_mmc_get_internal_phase(struct dw_mci *host, bool sample)
 {
-       unsigned long rate = clk_get_rate(host->ciu_clk);
+       unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
        u32 raw_value;
        u16 degrees;
        u32 delay_num = 0;
@@ -85,7 +85,7 @@ static int rockchip_mmc_get_phase(struct dw_mci *host, bool sample)
 
 static int rockchip_mmc_set_internal_phase(struct dw_mci *host, bool sample, int degrees)
 {
-       unsigned long rate = clk_get_rate(host->ciu_clk);
+       unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
        u8 nineties, remainder;
        u8 delay_num;
        u32 raw_value;
--

2.7.4