Unverified Commit a8d9550b authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by GitHub
Browse files

Merge pull request #1345 from dbasehore/udelay

rockchip/rk3399: Fix sram_udelay
parents 7f6d8f49 3cb74922
...@@ -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