mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] at91: fix timer rate
Date: Fri, 23 Nov 2012 16:55:01 +0100	[thread overview]
Message-ID: <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20121123155224.GV8327@game.jcrosoft.org>

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-11-23 15:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-23 15:52 [PATCH 0/4] at91: some fixes Jean-Christophe PLAGNIOL-VILLARD
2012-11-23 15:55 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-11-23 15:55   ` [PATCH 2/4] atmel_nand: fix pmecc timeout Jean-Christophe PLAGNIOL-VILLARD
2012-11-23 15:55   ` [PATCH 3/4] at91: clock: check overclock for sam9260/9261/9263/9rl Jean-Christophe PLAGNIOL-VILLARD
2012-11-23 15:55   ` [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write buffer functions" Jean-Christophe PLAGNIOL-VILLARD
2012-11-24  3:42     ` 张忠山
2012-11-24  8:45       ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-25  8:11         ` 张忠山
2012-11-25 19:32           ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-26  2:17             ` 张忠山
2012-11-26  7:31 ` [PATCH 0/4] at91: some fixes Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox