Skip to content
Snippets Groups Projects
Commit d8bbc51c authored by Nobuhiro Iwamatsu's avatar Nobuhiro Iwamatsu Committed by Nobuhiro Iwamatsu
Browse files

sh: Update sh2/sh2a timer


Renesas SH2/SH2A timer broken.
This patch fix timer function.

Signed-off-by: default avatarNobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
Signed-off-by: default avatarNobuhiro Iwamatsu <iwamatsu@nigauri.org>
parent a319f149
No related branches found
No related tags found
No related merge requests found
...@@ -65,8 +65,8 @@ unsigned long long get_ticks(void) ...@@ -65,8 +65,8 @@ unsigned long long get_ticks(void)
return cmt0_timer; return cmt0_timer;
} }
static vu_long cmcnt; static vu_long cmcnt = 0;
ulong get_timer(ulong base) static unsigned long get_usec (void)
{ {
ulong data = readw(CMCNT_0); ulong data = readw(CMCNT_0);
...@@ -81,7 +81,13 @@ ulong get_timer(ulong base) ...@@ -81,7 +81,13 @@ ulong get_timer(ulong base)
cmt0_timer += cmcnt; cmt0_timer += cmcnt;
cmcnt = data; 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) void set_timer(ulong t)
...@@ -99,9 +105,9 @@ void reset_timer(void) ...@@ -99,9 +105,9 @@ void reset_timer(void)
void udelay(unsigned long usec) 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; continue;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment