Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: AR7: Fix loops per jiffies on TNETD7200 devices

TNETD7200 run their CPU clock faster than the default CPU clock we assume.
In order to have the correct loops per jiffies settings, initialize clocks right
before setting mips_hpt_frequency. As a side effect, we can no longer use
msleep in clocks.c which requires other parts of the kernel to be initialized,
so replace these with mdelay.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
To: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/1749/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Florian Fainelli and committed by
Ralf Baechle
0bc67917 ff42d620

+7 -6
+3 -6
arch/mips/ar7/clock.c
··· 239 239 calculate(base_clock, frequency, &prediv, &postdiv, &mul); 240 240 241 241 writel(((prediv - 1) << PREDIV_SHIFT) | (postdiv - 1), &clock->ctrl); 242 - msleep(1); 242 + mdelay(1); 243 243 writel(4, &clock->pll); 244 244 while (readl(&clock->pll) & PLL_STATUS) 245 245 ; 246 246 writel(((mul - 1) << MUL_SHIFT) | (0xff << 3) | 0x0e, &clock->pll); 247 - msleep(75); 247 + mdelay(75); 248 248 } 249 249 250 250 static void __init tnetd7300_init_clocks(void) ··· 456 456 } 457 457 EXPORT_SYMBOL(clk_put); 458 458 459 - int __init ar7_init_clocks(void) 459 + void __init ar7_init_clocks(void) 460 460 { 461 461 switch (ar7_chip_id()) { 462 462 case AR7_CHIP_7100: ··· 472 472 } 473 473 /* adjust vbus clock rate */ 474 474 vbus_clk.rate = bus_clk.rate / 2; 475 - 476 - return 0; 477 475 } 478 - arch_initcall(ar7_init_clocks);
+3
arch/mips/ar7/time.c
··· 30 30 { 31 31 struct clk *cpu_clk; 32 32 33 + /* Initialize ar7 clocks so the CPU clock frequency is correct */ 34 + ar7_init_clocks(); 35 + 33 36 cpu_clk = clk_get(NULL, "cpu"); 34 37 if (IS_ERR(cpu_clk)) { 35 38 printk(KERN_ERR "unable to get cpu clock\n");
+1
arch/mips/include/asm/mach-ar7/ar7.h
··· 201 201 } 202 202 203 203 int __init ar7_gpio_init(void); 204 + void __init ar7_init_clocks(void); 204 205 205 206 #endif /* __AR7_H__ */