aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/at91
diff options
context:
space:
mode:
authorBoris BREZILLON <boris.brezillon@free-electrons.com>2014-09-02 03:50:16 -0400
committerMike Turquette <mturquette@linaro.org>2014-09-02 18:37:17 -0400
commit87e2ed338f1b56798807ccf12eb6112d25062202 (patch)
tree3547acba47040ac108b4ecb02a3c414aa1ed1ada /drivers/clk/at91
parent3ef9dd2bab7d6a013f75f9fb226d0191e9981288 (diff)
clk: at91: fix recalc_rate implementation of PLL driver
Use the cached values to calculate PLL rate instead of the register values. This is required to prevent erroneous PLL rate return when the PLL rate has been configured but the PLL is not prepared yet. Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com> Reported-by: Gaël PORTAY <gael.portay@gmail.com> Tested-by: Gaël PORTAY <gael.portay@gmail.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/at91')
-rw-r--r--drivers/clk/at91/clk-pll.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c
index a1adcf186023..6ec79dbc0840 100644
--- a/drivers/clk/at91/clk-pll.c
+++ b/drivers/clk/at91/clk-pll.c
@@ -151,16 +151,11 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
151 unsigned long parent_rate) 151 unsigned long parent_rate)
152{ 152{
153 struct clk_pll *pll = to_clk_pll(hw); 153 struct clk_pll *pll = to_clk_pll(hw);
154 const struct clk_pll_layout *layout = pll->layout; 154
155 struct at91_pmc *pmc = pll->pmc; 155 if (!pll->div || !pll->mul)
156 int offset = PLL_REG(pll->id);
157 u32 tmp = pmc_read(pmc, offset) & layout->pllr_mask;
158 u8 div = PLL_DIV(tmp);
159 u16 mul = PLL_MUL(tmp, layout);
160 if (!div || !mul)
161 return 0; 156 return 0;
162 157
163 return (parent_rate * (mul + 1)) / div; 158 return (parent_rate / pll->div) * (pll->mul + 1);
164} 159}
165 160
166static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate, 161static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate,