summaryrefslogtreecommitdiffstats
path: root/cpu
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2008-02-15 00:45:39 +0100
committerWolfgang Denk <wd@denx.de>2008-02-15 00:45:39 +0100
commit94a78da26ce17af61fbb2b620de51ba79bc80597 (patch)
tree0802da0103d0763e4552ae126767292eb95a0a23 /cpu
parentae91a8055c933f4528d88cf92314dabdc8b6acf2 (diff)
parentea686f52e45b3df2938866d3f5a98bb2556dfe2b (diff)
downloadblackbird-obmc-uboot-94a78da26ce17af61fbb2b620de51ba79bc80597.tar.gz
blackbird-obmc-uboot-94a78da26ce17af61fbb2b620de51ba79bc80597.zip
Merge branch 'master' of git://www.denx.de/git/u-boot-arm
Diffstat (limited to 'cpu')
-rw-r--r--cpu/arm926ejs/davinci/timer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/cpu/arm926ejs/davinci/timer.c b/cpu/arm926ejs/davinci/timer.c
index c6b1dda51f..4a1a54dcf1 100644
--- a/cpu/arm926ejs/davinci/timer.c
+++ b/cpu/arm926ejs/davinci/timer.c
@@ -61,6 +61,11 @@ davinci_timer *timer = (davinci_timer *)CFG_TIMERBASE;
#define TIMER_LOAD_VAL (CFG_HZ_CLOCK / CFG_HZ)
#define READ_TIMER timer->tim34
+/* Timer runs with CFG_HZ_CLOCK, currently 27MHz. To avoid wrap
+ around of timestamp already after min ~159s, divide it, e.g. by 16.
+ timestamp will then wrap around all min ~42min */
+#define DIV(x) ((x) >> 4)
+
static ulong timestamp;
static ulong lastinc;
@@ -101,20 +106,20 @@ void udelay(unsigned long usec)
void reset_timer_masked(void)
{
- lastinc = READ_TIMER;
+ lastinc = DIV(READ_TIMER);
timestamp = 0;
}
ulong get_timer_raw(void)
{
- ulong now = READ_TIMER;
+ ulong now = DIV(READ_TIMER);
if (now >= lastinc) {
/* normal mode */
timestamp += now - lastinc;
} else {
/* overflow ... */
- timestamp += now + TIMER_LOAD_VAL - lastinc;
+ timestamp += now + DIV(TIMER_LOAD_VAL) - lastinc;
}
lastinc = now;
return timestamp;
@@ -122,7 +127,7 @@ ulong get_timer_raw(void)
ulong get_timer_masked(void)
{
- return(get_timer_raw() / TIMER_LOAD_VAL);
+ return(get_timer_raw() / DIV(TIMER_LOAD_VAL));
}
void udelay_masked(unsigned long usec)
OpenPOWER on IntegriCloud