On Tue, Jun 17, 2014 at 9:52 AM, Chen-Yu Tsai [off-list ref] wrote:
quoted hunk ↗ jump to hunk
The PLLs on newer Allwinner SoC's, such as the A31 and A23, have a
N multiplier factor that starts from 1, not 0.
This patch adds an option to the clock driver's config data structures
to define the difference.
Signed-off-by: Chen-Yu Tsai <redacted>
Acked-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
drivers/clk/sunxi/clk-factors.c | 5 ++++-
drivers/clk/sunxi/clk-factors.h | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 3806d97..399cf4d 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -62,7 +62,10 @@ static unsigned long clk_factors_recalc_rate(struct clk_hw *hw,
p = FACTOR_GET(config->pshift, config->pwidth, reg);
/* Calculate the rate */
- rate = (parent_rate * n * (k + 1) >> p) / (m + 1);
+ if (config->n_from_one)
+ rate = (parent_rate * (n + 1) * (k + 1) >> p) / (m + 1);
+ else
+ rate = (parent_rate * n * (k + 1) >> p) / (m + 1);
This can be simplified and support any base with:
rate = (parent_rate * (n + config->n_base) * (k + 1) >> p) / (m + 1);