]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
clk: rockchip: rk3588: Avoid re-setting the pll rate of dclk_vop's parent
authorElaine Zhang <zhangqing@rock-chips.com>
Thu, 12 Oct 2023 10:18:12 +0000 (18:18 +0800)
committerKever Yang <kever.yang@rock-chips.com>
Mon, 23 Oct 2023 10:21:55 +0000 (18:21 +0800)
Optimize setting process.

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/clk/rockchip/clk_rk3588.c

index 7ba037ad72ba3ed7580393e8a5d1c68950012e77..a995dd5591d3924728ffd0755c25a296a96529da 100644 (file)
@@ -1130,13 +1130,23 @@ static ulong rk3588_dclk_vop_set_clk(struct rk3588_clk_priv *priv,
        }
 
        if (sel == DCLK_VOP_SRC_SEL_V0PLL) {
-               div = DIV_ROUND_UP(RK3588_VOP_PLL_LIMIT_FREQ, rate);
-               rk_clrsetreg(&cru->clksel_con[conid],
-                            mask,
-                            DCLK_VOP_SRC_SEL_V0PLL << sel_shift |
-                            ((div - 1) << div_shift));
-               rockchip_pll_set_rate(&rk3588_pll_clks[V0PLL],
-                                     priv->cru, V0PLL, div * rate);
+               pll_rate = rockchip_pll_get_rate(&rk3588_pll_clks[V0PLL],
+                                                priv->cru, V0PLL);
+               if (pll_rate >= RK3588_VOP_PLL_LIMIT_FREQ && pll_rate % rate == 0) {
+                       div = DIV_ROUND_UP(pll_rate, rate);
+                       rk_clrsetreg(&cru->clksel_con[conid],
+                                    mask,
+                                    DCLK_VOP_SRC_SEL_V0PLL << sel_shift |
+                                    ((div - 1) << div_shift));
+               } else {
+                       div = DIV_ROUND_UP(RK3588_VOP_PLL_LIMIT_FREQ, rate);
+                       rk_clrsetreg(&cru->clksel_con[conid],
+                                    mask,
+                                    DCLK_VOP_SRC_SEL_V0PLL << sel_shift |
+                                    ((div - 1) << div_shift));
+                       rockchip_pll_set_rate(&rk3588_pll_clks[V0PLL],
+                                             priv->cru, V0PLL, div * rate);
+               }
        } else {
                for (i = 0; i <= DCLK_VOP_SRC_SEL_AUPLL; i++) {
                        switch (i) {