summaryrefslogtreecommitdiff
path: root/cpu
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2010-03-22 23:27:24 +0100
committerWolfgang Denk <wd@denx.de>2010-03-22 23:27:24 +0100
commit859500a2be94bfa77a845b9c8a4c499587035fd5 (patch)
tree986cd224308690760453635e60038091a3a928a4 /cpu
parentb46b353b901a45ebe860f8bf874ca99f018cd410 (diff)
parent152dda3d94e97ede7af3f9560a59a659384d4585 (diff)
downloadu-boot-imx-859500a2be94bfa77a845b9c8a4c499587035fd5.zip
u-boot-imx-859500a2be94bfa77a845b9c8a4c499587035fd5.tar.gz
u-boot-imx-859500a2be94bfa77a845b9c8a4c499587035fd5.tar.bz2
Merge remote branch 'origin/master' into next
Diffstat (limited to 'cpu')
-rw-r--r--cpu/arm920t/ep93xx/timer.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/cpu/arm920t/ep93xx/timer.c b/cpu/arm920t/ep93xx/timer.c
index b1a01a0..31304b7 100644
--- a/cpu/arm920t/ep93xx/timer.c
+++ b/cpu/arm920t/ep93xx/timer.c
@@ -36,7 +36,7 @@
#define TIMER_CLKSEL (1 << 3)
#define TIMER_ENABLE (1 << 7)
-#define TIMER_FREQ 508469
+#define TIMER_FREQ 508469 /* ticks / second */
#define TIMER_MAX_VAL 0xFFFFFFFF
static struct ep93xx_timer
@@ -53,18 +53,10 @@ static inline unsigned long clk_to_systicks(unsigned long long clk_ticks)
return (unsigned long)sys_ticks;
}
-static inline unsigned long usecs_to_ticks(unsigned long usecs)
+static inline unsigned long long usecs_to_ticks(unsigned long usecs)
{
- unsigned long ticks;
-
- if (usecs >= 1000) {
- ticks = usecs / 1000;
- ticks *= TIMER_FREQ;
- ticks /= 1000;
- } else {
- ticks = usecs * TIMER_FREQ;
- ticks /= (1000 * 1000);
- }
+ unsigned long long ticks = (unsigned long long)usecs * TIMER_FREQ;
+ do_div(ticks, 1000 * 1000);
return ticks;
}
@@ -77,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)
{
@@ -91,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)
@@ -117,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();
+
+ const unsigned long long target = timer.ticks + usecs_to_ticks(usec);
- while (get_ticks() < target)
- /* noop */;
+ while (timer.ticks < target)
+ get_ticks();
}
int timer_init(void)