diff options
author | Chen-Yu Tsai <wens@csie.org> | 2017-02-13 22:35:22 -0500 |
---|---|---|
committer | Maxime Ripard <maxime.ripard@free-electrons.com> | 2017-03-06 01:36:04 -0500 |
commit | ac8616e4c81dded650dfade49a7da283565d37ce (patch) | |
tree | 84ff6cfb9d1b96767417e6b09502c7fab5394b41 | |
parent | c1ae3cfa0e89fa1a7ecc4c99031f5e9ae99d9201 (diff) |
clk: sunxi-ng: mp: Adjust parent rate for pre-dividers
The MP style clocks support an mux with pre-dividers. While the driver
correctly accounted for them in the .determine_rate callback, it did
not in the .recalc_rate and .set_rate callbacks.
This means when calculating the factors in the .set_rate callback, they
would be off by a factor of the active pre-divider. Same goes for
reading back the clock rate after it is set.
Cc: stable@vger.kernel.org
Fixes: 2ab836db5097 ("clk: sunxi-ng: Add M-P factor clock support")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
-rw-r--r-- | drivers/clk/sunxi-ng/ccu_mp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c index 22c2ca7a2a22..b583f186a804 100644 --- a/drivers/clk/sunxi-ng/ccu_mp.c +++ b/drivers/clk/sunxi-ng/ccu_mp.c | |||
@@ -85,6 +85,10 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw, | |||
85 | unsigned int m, p; | 85 | unsigned int m, p; |
86 | u32 reg; | 86 | u32 reg; |
87 | 87 | ||
88 | /* Adjust parent_rate according to pre-dividers */ | ||
89 | ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux, | ||
90 | -1, &parent_rate); | ||
91 | |||
88 | reg = readl(cmp->common.base + cmp->common.reg); | 92 | reg = readl(cmp->common.base + cmp->common.reg); |
89 | 93 | ||
90 | m = reg >> cmp->m.shift; | 94 | m = reg >> cmp->m.shift; |
@@ -117,6 +121,10 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long rate, | |||
117 | unsigned int m, p; | 121 | unsigned int m, p; |
118 | u32 reg; | 122 | u32 reg; |
119 | 123 | ||
124 | /* Adjust parent_rate according to pre-dividers */ | ||
125 | ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux, | ||
126 | -1, &parent_rate); | ||
127 | |||
120 | max_m = cmp->m.max ?: 1 << cmp->m.width; | 128 | max_m = cmp->m.max ?: 1 << cmp->m.width; |
121 | max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); | 129 | max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); |
122 | 130 | ||