public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jon Hunter <jon-hunter@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4] omap2420-h4: Fix get_timer() and CONFIG_SYS_HZ
Date: Wed, 3 Apr 2013 14:35:36 -0500	[thread overview]
Message-ID: <1365017737-5926-5-git-send-email-jon-hunter@ti.com> (raw)
In-Reply-To: <1365017737-5926-1-git-send-email-jon-hunter@ti.com>

The function get_timer() should return time in ms and CONFIG_SYS_HZ
should be set to 1000 by default. Fix both of these items.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
 arch/arm/cpu/arm1136/omap24xx/timer.c |    8 ++++++--
 include/configs/omap2420h4.h          |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c
index 53015cb..3b6666b 100644
--- a/arch/arm/cpu/arm1136/omap24xx/timer.c
+++ b/arch/arm/cpu/arm1136/omap24xx/timer.c
@@ -31,13 +31,16 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
 #include <asm/arch/bits.h>
 #include <asm/arch/omap2420.h>
 
+#define TIMER_CLOCK	(CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV))
 #define TIMER_LOAD_VAL 0
 
 /* macro to read the 32 bit timer */
-#define READ_TIMER (*((volatile ulong *)(CONFIG_SYS_TIMERBASE+TCRR)))
+#define READ_TIMER	readl(CONFIG_SYS_TIMERBASE+TCRR) \
+			/ (TIMER_CLOCK / CONFIG_SYS_HZ)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -99,7 +102,8 @@ ulong get_timer_masked (void)
 		gd->arch.tbl += (now - gd->arch.lastinc);
 	} else {
 		/* we have rollover of incrementer */
-		gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now;
+		gd->arch.tbl += ((0xFFFFFFFF / (TIMER_CLOCK / CONFIG_SYS_HZ))
+				 - gd->arch.lastinc) + now;
 	}
 	gd->arch.lastinc = now;
 	return gd->arch.tbl;
diff --git a/include/configs/omap2420h4.h b/include/configs/omap2420h4.h
index e144ae9d..04e8d3a 100644
--- a/include/configs/omap2420h4.h
+++ b/include/configs/omap2420h4.h
@@ -190,7 +190,7 @@
 
 #define CONFIG_SYS_TIMERBASE		OMAP2420_GPT2
 #define CONFIG_SYS_PTV			V_PTV	/* 2^(PTV+1) */
-#define CONFIG_SYS_HZ			((CONFIG_SYS_CLK_FREQ)/(2 << CONFIG_SYS_PTV))
+#define CONFIG_SYS_HZ			1000
 
 /*-----------------------------------------------------------------------
  * Physical Memory Map
-- 
1.7.10.4

  parent reply	other threads:[~2013-04-03 19:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03 19:35 [U-Boot] [PATCH 0/4] omap2420-h4: Fix u-boot support for board Jon Hunter
2013-04-03 19:35 ` [U-Boot] [PATCH 1/4] omap2420-h4: Fix DRAM initialisation Jon Hunter
2013-04-03 19:35 ` [U-Boot] [PATCH 2/4] omap2420-h4: Fix booting from NOR flash Jon Hunter
2013-04-03 19:35 ` [U-Boot] [PATCH 3/4] omap2420-h4: Add device tree support Jon Hunter
2013-04-03 19:35 ` Jon Hunter [this message]
2013-04-03 19:35 ` [U-Boot] [PATCH 4/4] omap2420h4: Fix get_timer() and CONFIG_SYS_HZ Jon Hunter
2013-04-03 19:36   ` Jon Hunter
2013-04-10 20:08 ` [U-Boot] [PATCH 0/4] omap2420-h4: Fix u-boot support for board Tom Rini

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=1365017737-5926-5-git-send-email-jon-hunter@ti.com \
    --to=jon-hunter@ti.com \
    --cc=u-boot@lists.denx.de \
    /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