]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: Fix OMAP2 DPLL clock rate calculation for large multipliers
authorImre Deak <imre.deak@nokia.com>
Mon, 2 Jan 2006 15:53:35 +0000 (17:53 +0200)
committerJuha Yrjola <juha.yrjola@nokia.com>
Mon, 2 Jan 2006 15:53:35 +0000 (17:53 +0200)
If the multiplier is large enough the result may not fit in 32 bits.
Use a 64-bit scratch variable and 64-bit division instead.

arch/arm/mach-omap2/clock.c

index 6f897f307d67fce2d3badfc781f802ec630b54be..440db5153014e02add31550fbe81c7ad74602d56 100644 (file)
@@ -54,11 +54,13 @@ static void omap2_sys_clk_recalc(struct clk * clk)
 
 static u32 omap2_get_dpll_rate(struct clk * tclk)
 {
-       int dpll_clk, dpll_mult, dpll_div, amult;
+       long long dpll_clk;
+       int dpll_mult, dpll_div, amult;
 
        dpll_mult = (CM_CLKSEL1_PLL >> 12) & 0x03ff;    /* 10 bits */
        dpll_div = (CM_CLKSEL1_PLL >> 8) & 0x0f;        /* 4 bits */
-       dpll_clk = (tclk->parent->rate * dpll_mult) / (dpll_div + 1);
+       dpll_clk = (long long)tclk->parent->rate * dpll_mult;
+       do_div(dpll_clk, dpll_div + 1);
        amult = CM_CLKSEL2_PLL & 0x3;
        dpll_clk *= amult;