Skip to content

Commit 65fc7f9

Browse files
juhosgralfbaechle
authored andcommitted
MIPS: ath79: use correct fractional dividers for {CPU,DDR}_PLL on AR934x
The current dividers in the code are wrong and this leads to broken CPU frequency calculation on boards where the fractional part is used. For example, if the SoC is running from a 40MHz reference clock, refdiv=1, nint=14, outdiv=0 and nfrac=31 the real frequency is 579.375MHz but the current code calculates 569.687MHz instead. Because the system time is indirectly related to the CPU frequency the broken computation causes drift in the system time. The correct divider is 2^6 for the CPU PLL and 2^10 for the DDR PLL. Use the correct values to fix the issue. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Cc: stable@vger.kernel.org Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/4305/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent d21a771 commit 65fc7f9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/mips/ath79/clock.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static void __init ar934x_clocks_init(void)
189189
AR934X_PLL_CPU_CONFIG_NFRAC_MASK;
190190

191191
cpu_pll = nint * ath79_ref_clk.rate / ref_div;
192-
cpu_pll += frac * ath79_ref_clk.rate / (ref_div * (2 << 6));
192+
cpu_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 6));
193193
cpu_pll /= (1 << out_div);
194194

195195
pll = ath79_pll_rr(AR934X_PLL_DDR_CONFIG_REG);
@@ -203,7 +203,7 @@ static void __init ar934x_clocks_init(void)
203203
AR934X_PLL_DDR_CONFIG_NFRAC_MASK;
204204

205205
ddr_pll = nint * ath79_ref_clk.rate / ref_div;
206-
ddr_pll += frac * ath79_ref_clk.rate / (ref_div * (2 << 10));
206+
ddr_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 10));
207207
ddr_pll /= (1 << out_div);
208208

209209
clk_ctrl = ath79_pll_rr(AR934X_PLL_CPU_DDR_CLK_CTRL_REG);

0 commit comments

Comments
 (0)