clk: axg: fine-tune pll set_rate op [1/1]
authorQiufang Dai <qiufang.dai@amlogic.com>
Fri, 14 Jul 2017 12:19:33 +0000 (20:19 +0800)
committerQiufang Dai <qiufang.dai@amlogic.com>
Wed, 19 Jul 2017 09:17:05 +0000 (17:17 +0800)
PD#146411: if set_rate target rate equal to old rate, just skip.

Change-Id: I945fdf6f72c5fccc6e0e701fe8f50fba8458d99f
Signed-off-by: Qiufang Dai <qiufang.dai@amlogic.com>
drivers/amlogic/clk/axg/axg_clk-pll.c

index e02b448..5e58d3d 100644 (file)
@@ -188,6 +188,18 @@ static int meson_axg_pll_set_rate(struct clk_hw *hw, unsigned long rate,
        if (pll->lock)
                spin_lock_irqsave(pll->lock, flags);
 
+       if (readl(pll->base + p->reg_off) & MESON_PLL_ENABLE) {
+               old_rate = meson_axg_pll_recalc_rate(hw,
+                       clk_get_rate(clk_get_parent(hw->clk)));
+               old_rate = meson_axg_pll_round_rate(hw, old_rate, NULL);
+
+               if (old_rate == rate) {
+                       if (pll->lock)
+                               spin_unlock_irqrestore(pll->lock, flags);
+                       return ret;
+               }
+       }
+
        if (!strcmp(clk_hw_get_name(hw), "gp0_pll")
                || !strcmp(clk_hw_get_name(hw), "hifi_pll")
                || !strcmp(clk_hw_get_name(hw), "pcie_pll")) {
@@ -266,9 +278,9 @@ static int meson_axg_pll_set_rate(struct clk_hw *hw, unsigned long rate,
                spin_unlock_irqrestore(pll->lock, flags);
 
        if (ret) {
-               pr_warn("%s: pll did not lock, trying to restore old rate %lu\n",
-                       __func__, old_rate);
-               meson_axg_pll_set_rate(hw, old_rate, parent_rate);
+               pr_warn("%s: pll did not lock, trying to lock rate %lu again\n",
+                       __func__, rate);
+               meson_axg_pll_set_rate(hw, rate, parent_rate);
        }
 
        return ret;