clk: sunxi: Support factor clocks with N factor starting not from 0
authorChen-Yu Tsai <wens@csie.org>
Thu, 26 Jun 2014 15:55:41 +0000 (23:55 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Mar 2015 12:22:34 +0000 (13:22 +0100)
commit 9a5e6c7eb5ccbb5f0d3a1dffce135f0a727f40e1 upstream.

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 factor clk driver's config data
structures to specify the base value of N.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/clk/sunxi/clk-factors.c
drivers/clk/sunxi/clk-factors.h

index 88523f91d9b703cc57b1272421fed39430b6f7a6..7555793097f256b1ff5319c2a1d3a38a418dc666 100644 (file)
@@ -70,7 +70,7 @@ 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);
+       rate = (parent_rate * (n + config->n_start) * (k + 1) >> p) / (m + 1);
 
        return rate;
 }
index f49851cc43804d57cce6f8d7035965059500853d..441fdc3f57173f628639c336fb1cc8f6a38d3080 100644 (file)
@@ -15,6 +15,7 @@ struct clk_factors_config {
        u8 mwidth;
        u8 pshift;
        u8 pwidth;
+       u8 n_start;
 };
 
 struct clk *clk_register_factors(struct device *dev, const char *name,