Skip to contentSkip to conversation

mmc: mediatek: fixed clk contrl flow

PATCH In review Mason Zhang 2 participants 2 messages Aug 16, 2021 – Aug 24, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: mediatek: fixed clk contrl flow

this patch fixed clk contrl flow in set clk rate, no need close clk src, gate cg is enough, so no need call clk prepare/unprepare.

---
 drivers/mmc/host/mtk-sd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/mtk-sd.c +4 -4
index 4dfc246c5f95..d9835b272c1f 100644
@@ -895,9 +895,9 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz)
 	 * So if want to only gate src_clk, need gate its parent(mux).
 	 */
 	if (host->src_clk_cg)
-		clk_disable_unprepare(host->src_clk_cg);
+		clk_disable(host->src_clk_cg);
 	else
-		clk_disable_unprepare(clk_get_parent(host->src_clk));
+		clk_disable(clk_get_parent(host->src_clk));
 	if (host->dev_comp->clk_div_bits == 8)
 		sdr_set_field(host->base + MSDC_CFG,
 			      MSDC_CFG_CKMOD | MSDC_CFG_CKDIV,
@@ -907,9 +907,9 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz)
 			      MSDC_CFG_CKMOD_EXTRA | MSDC_CFG_CKDIV_EXTRA,
 			      (mode << 12) | div);
 	if (host->src_clk_cg)
-		clk_prepare_enable(host->src_clk_cg);
+		clk_enable(host->src_clk_cg);
 	else
-		clk_prepare_enable(clk_get_parent(host->src_clk));
+		clk_enable(clk_get_parent(host->src_clk));
 
 	while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB))
 		cpu_relax();
Signature · 1 line
2.18.0
#1 lore raw
Quoted 3 lines · Mason Zhang

this patch fixed clk contrl flow in set clk rate, no need close clk src, gate cg is enough, so no need call clk prepare/unprepare.

No, this isn't the way we should deploy clock support in drivers.

If the driver doesn't need to gate/ungate clocks from atomic context, the proper thing is to use the slow path APIs, clk_prepare_enable() and clk_disable_unprepare().

Kind regards
Uffe

Quoted 37 lines
---
 drivers/mmc/host/mtk-sd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/mtk-sd.c +4 -5
index 4dfc246c5f95..d9835b272c1f 100644
@@ -895,9 +895,9 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz)
         * So if want to only gate src_clk, need gate its parent(mux).
         */
        if (host->src_clk_cg)
-               clk_disable_unprepare(host->src_clk_cg);
+               clk_disable(host->src_clk_cg);
        else
-               clk_disable_unprepare(clk_get_parent(host->src_clk));
+               clk_disable(clk_get_parent(host->src_clk));
        if (host->dev_comp->clk_div_bits == 8)
                sdr_set_field(host->base + MSDC_CFG,
                              MSDC_CFG_CKMOD | MSDC_CFG_CKDIV,
@@ -907,9 +907,9 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz)
                              MSDC_CFG_CKMOD_EXTRA | MSDC_CFG_CKDIV_EXTRA,
                              (mode << 12) | div);
        if (host->src_clk_cg)
-               clk_prepare_enable(host->src_clk_cg);
+               clk_enable(host->src_clk_cg);
        else
-               clk_prepare_enable(clk_get_parent(host->src_clk));
+               clk_enable(clk_get_parent(host->src_clk));
 
        while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB))
                cpu_relax();
--

2.18.0