diff options
author | Tony Lindgren <tony@atomide.com> | 2015-03-22 18:35:24 -0400 |
---|---|---|
committer | Tero Kristo <t-kristo@ti.com> | 2015-03-24 14:26:05 -0400 |
commit | 33ca29c99e8680b4c921c6eafb9fc1603c5b9779 (patch) | |
tree | 7bcae4571d8ff8a3f6859b5dcda71ff6907e5afc | |
parent | 712f7d64f079872d2895743f4b718bc0fdff725c (diff) |
clk: ti: Fix FAPLL recalc_rate for rounding errors
We need to round the calculated value to have it match the requested rate.
While at it, let's fix a typo and use a define for SYNTH_MAX_DIV_M as we
will need it in later patches for set_rate.
And let's remove two unused includes.
Cc: Brian Hutchinson <b.hutchman@gmail.com>
Cc: Matthijs van Duin <matthijsvanduin@gmail.com>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Tero Kristo <t-kristo@ti.com>
-rw-r--r-- | drivers/clk/ti/fapll.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c index 6ef89639a9f6..97138c106a67 100644 --- a/drivers/clk/ti/fapll.c +++ b/drivers/clk/ti/fapll.c | |||
@@ -11,12 +11,10 @@ | |||
11 | 11 | ||
12 | #include <linux/clk-provider.h> | 12 | #include <linux/clk-provider.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/slab.h> | ||
15 | #include <linux/err.h> | 14 | #include <linux/err.h> |
16 | #include <linux/of.h> | 15 | #include <linux/of.h> |
17 | #include <linux/of_address.h> | 16 | #include <linux/of_address.h> |
18 | #include <linux/clk/ti.h> | 17 | #include <linux/clk/ti.h> |
19 | #include <asm/div64.h> | ||
20 | 18 | ||
21 | /* FAPLL Control Register PLL_CTRL */ | 19 | /* FAPLL Control Register PLL_CTRL */ |
22 | #define FAPLL_MAIN_LOCK BIT(7) | 20 | #define FAPLL_MAIN_LOCK BIT(7) |
@@ -49,6 +47,8 @@ | |||
49 | /* Synthesizer frequency register */ | 47 | /* Synthesizer frequency register */ |
50 | #define SYNTH_LDFREQ BIT(31) | 48 | #define SYNTH_LDFREQ BIT(31) |
51 | 49 | ||
50 | #define SYNTH_MAX_DIV_M 0xff | ||
51 | |||
52 | struct fapll_data { | 52 | struct fapll_data { |
53 | struct clk_hw hw; | 53 | struct clk_hw hw; |
54 | void __iomem *base; | 54 | void __iomem *base; |
@@ -218,11 +218,10 @@ static unsigned long ti_fapll_synth_recalc_rate(struct clk_hw *hw, | |||
218 | rate *= 8; | 218 | rate *= 8; |
219 | } | 219 | } |
220 | 220 | ||
221 | /* Synth ost-divider M */ | 221 | /* Synth post-divider M */ |
222 | synth_div_m = readl_relaxed(synth->div) & 0xff; | 222 | synth_div_m = readl_relaxed(synth->div) & SYNTH_MAX_DIV_M; |
223 | do_div(rate, synth_div_m); | ||
224 | 223 | ||
225 | return rate; | 224 | return DIV_ROUND_UP_ULL(rate, synth_div_m); |
226 | } | 225 | } |
227 | 226 | ||
228 | static struct clk_ops ti_fapll_synt_ops = { | 227 | static struct clk_ops ti_fapll_synt_ops = { |