From: Matthias Kaehlcke <matthias@kaehlcke.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4] ep93xx timer: Fix resolution of get_ticks()
Date: Tue, 9 Mar 2010 22:13:33 +0100 [thread overview]
Message-ID: <20100309211333.GD12559@darwin> (raw)
In-Reply-To: <a41656a7b95f18a5ef51428b285767d0a70cbbc7.1268169068.git.matthias@kaehlcke.net>
ep93xx timer: Make get_ticks() return a value in CONFIG_SYS_HZ resolution,
as announced by get_tbclk()
Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
---
cpu/arm920t/ep93xx/timer.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/cpu/arm920t/ep93xx/timer.c b/cpu/arm920t/ep93xx/timer.c
index bc4ec8f..31304b7 100644
--- a/cpu/arm920t/ep93xx/timer.c
+++ b/cpu/arm920t/ep93xx/timer.c
@@ -69,7 +69,7 @@ static inline unsigned long read_timer(void)
}
/*
- * timer without interrupts
+ * Get the number of ticks (in CONFIG_SYS_HZ resolution)
*/
unsigned long long get_ticks(void)
{
@@ -83,12 +83,12 @@ unsigned long long get_ticks(void)
timer.last_update = now;
- return timer.ticks;
+ return clk_to_systicks(timer.ticks);
}
unsigned long get_timer_masked(void)
{
- return clk_to_systicks(get_ticks());
+ return get_ticks();
}
unsigned long get_timer(unsigned long base)
@@ -109,10 +109,13 @@ void reset_timer(void)
void __udelay(unsigned long usec)
{
- const unsigned long target = get_ticks() + usecs_to_ticks(usec);
+ /* read the timer and update timer.ticks */
+ get_ticks();
- while (get_ticks() < target)
- /* noop */;
+ const unsigned long long target = timer.ticks + usecs_to_ticks(usec);
+
+ while (timer.ticks < target)
+ get_ticks();
}
int timer_init(void)
--
1.6.5
next parent reply other threads:[~2010-03-09 21:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a41656a7b95f18a5ef51428b285767d0a70cbbc7.1268169068.git.matthias@kaehlcke.net>
2010-03-09 21:13 ` Matthias Kaehlcke [this message]
2010-03-09 21:13 ` [U-Boot] [PATCH 3/4] ep93xx timer: Rename struct timer_reg pointers Matthias Kaehlcke
2010-03-09 21:13 ` [U-Boot] [PATCH 4/4] ep93xx timer: refactoring Matthias Kaehlcke
2010-03-13 20:32 ` Tom
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=20100309211333.GD12559@darwin \
--to=matthias@kaehlcke.net \
--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