summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>2008-12-09 11:32:46 +0900
committerNobuhiro Iwamatsu <iwamatsu@nigauri.org>2008-12-10 23:11:36 +0900
commitd8bbc51c7ba9b737a20984333d19fe28a3526431 (patch)
tree6987fa8b4d58600f76537492823bff54ba58ed96
parenta319f1496210117b73198e3d889ffffaf6825d00 (diff)
downloadblackbird-obmc-uboot-d8bbc51c7ba9b737a20984333d19fe28a3526431.tar.gz
blackbird-obmc-uboot-d8bbc51c7ba9b737a20984333d19fe28a3526431.zip
sh: Update sh2/sh2a timer
Renesas SH2/SH2A timer broken. This patch fix timer function. Signed-off-by: Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
-rw-r--r--lib_sh/time_sh2.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib_sh/time_sh2.c b/lib_sh/time_sh2.c
index fcbb921c8c..4f893c87bd 100644
--- a/lib_sh/time_sh2.c
+++ b/lib_sh/time_sh2.c
@@ -65,8 +65,8 @@ unsigned long long get_ticks(void)
return cmt0_timer;
}
-static vu_long cmcnt;
-ulong get_timer(ulong base)
+static vu_long cmcnt = 0;
+static unsigned long get_usec (void)
{
ulong data = readw(CMCNT_0);
@@ -81,7 +81,13 @@ ulong get_timer(ulong base)
cmt0_timer += cmcnt;
cmcnt = data;
- return cmt0_timer - base;
+ return cmt0_timer;
+}
+
+/* return msec */
+ulong get_timer(ulong base)
+{
+ return (get_usec()/1000) - base;
}
void set_timer(ulong t)
@@ -99,9 +105,9 @@ void reset_timer(void)
void udelay(unsigned long usec)
{
- unsigned int start = get_timer(0);
+ unsigned long end = get_usec() + usec;
- while (get_timer((ulong) start) < (usec * (CONFIG_SYS_HZ / 1000000)))
+ while (get_usec() < end)
continue;
}
OpenPOWER on IntegriCloud