From 743c3378305aa98cdef197832065dea4cb76c137 Mon Sep 17 00:00:00 2001 From: Qiufang Dai Date: Fri, 14 Jul 2017 20:19:33 +0800 Subject: [PATCH] clk: axg: fine-tune pll set_rate op [1/1] PD#146411: if set_rate target rate equal to old rate, just skip. Change-Id: I945fdf6f72c5fccc6e0e701fe8f50fba8458d99f Signed-off-by: Qiufang Dai --- drivers/amlogic/clk/axg/axg_clk-pll.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/amlogic/clk/axg/axg_clk-pll.c b/drivers/amlogic/clk/axg/axg_clk-pll.c index e02b448af083..5e58d3d1a35f 100644 --- a/drivers/amlogic/clk/axg/axg_clk-pll.c +++ b/drivers/amlogic/clk/axg/axg_clk-pll.c @@ -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;