Commit 3cb74922 authored by Derek Basehore's avatar Derek Basehore
Browse files

rockchip/rk3399: Fix sram_udelay



This fixes an off by 576x bug the the sram_udelay code. The wrong
value was multipled by the system ticks per mhz value (which is 24),
so we delayed for 1/576th of the requested time.
Signed-off-by: default avatarDerek Basehore <dbasehore@chromium.org>
parent 93883a29
...@@ -85,10 +85,11 @@ static __pmusramfunc uint32_t sram_get_timer_value(void) ...@@ -85,10 +85,11 @@ static __pmusramfunc uint32_t sram_get_timer_value(void)
static __pmusramfunc void sram_udelay(uint32_t usec) static __pmusramfunc void sram_udelay(uint32_t usec)
{ {
uint32_t start, cnt, delta, delta_us; uint32_t start, cnt, delta, total_ticks;
/* counter is decreasing */ /* counter is decreasing */
start = sram_get_timer_value(); start = sram_get_timer_value();
total_ticks = usec * SYS_COUNTER_FREQ_IN_MHZ;
do { do {
cnt = sram_get_timer_value(); cnt = sram_get_timer_value();
if (cnt > start) { if (cnt > start) {
...@@ -96,8 +97,7 @@ static __pmusramfunc void sram_udelay(uint32_t usec) ...@@ -96,8 +97,7 @@ static __pmusramfunc void sram_udelay(uint32_t usec)
delta += start; delta += start;
} else } else
delta = start - cnt; delta = start - cnt;
delta_us = (delta * SYS_COUNTER_FREQ_IN_MHZ); } while (delta <= total_ticks);
} while (delta_us < usec);
} }
static __pmusramfunc void configure_sgrf(void) static __pmusramfunc void configure_sgrf(void)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment