[PATCH 1/4] at91: fix timer rate

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Fri Nov 23 10:55:01 EST 2012


today the timer rate is hardcoded to 6MHz which is wrong the PIT rate is MCK / 16

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam926x_time.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index 7411ad8..7425e0a 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -34,6 +34,7 @@
 #include <mach/at91_rstc.h>
 #include <mach/io.h>
 #include <io.h>
+#include <linux/clk.h>
 
 uint64_t at91sam9_clocksource_read(void)
 {
@@ -48,16 +49,20 @@ static struct clocksource cs = {
 
 static int clocksource_init (void)
 {
+	u32 pit_rate;
+
 	/*
 	 * Enable PITC Clock
 	 * The clock is already enabled for system controller in boot
 	 */
 	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
 
+	pit_rate = clk_get_rate(clk_get(NULL, "mck")) / 16;
+
 	/* Enable PITC */
 	at91_sys_write(AT91_PIT_MR, 0xfffff | AT91_PIT_PITEN);
 
-	cs.mult = clocksource_hz2mult(1000000 * 6, cs.shift);
+	cs.mult = clocksource_hz2mult(pit_rate, cs.shift);
 
 	init_clock(&cs);
 
-- 
1.7.10.4




More information about the barebox mailing list