clk: bcm2835: Correct the prediv logic
authorPhil Elwell <phil@raspberrypi.org>
Mon, 15 May 2017 17:35:04 +0000 (10:35 -0700)
committerStephen Boyd <sboyd@codeaurora.org>
Fri, 2 Jun 2017 22:41:49 +0000 (15:41 -0700)
If a clock has the prediv flag set, both the integer and fractional
parts must be scaled when calculating the resulting frequency.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/bcm/clk-bcm2835.c

index 02585387061967ac9408e18ac1bce67e9e9414c0..7a35df6b45bd7e5c3c5fd07e4ce610109c64b1f1 100644 (file)
@@ -616,8 +616,10 @@ static unsigned long bcm2835_pll_get_rate(struct clk_hw *hw,
        using_prediv = cprman_read(cprman, data->ana_reg_base + 4) &
                data->ana->fb_prediv_mask;
 
-       if (using_prediv)
+       if (using_prediv) {
                ndiv *= 2;
+               fdiv *= 2;
+       }
 
        return bcm2835_pll_rate_from_divisors(parent_rate, ndiv, fdiv, pdiv);
 }