diff options
author | Andre Przywara <andre.przywara@arm.com> | 2016-09-29 23:08:31 +0100 |
---|---|---|
committer | Andre Przywara <andre.przywara@arm.com> | 2016-10-23 10:59:51 +0100 |
commit | 4409b3959edf7fd41707f773640e74fdef096383 (patch) | |
tree | 5bca503e1470f63850bd09778150b446a46eecb1 | |
parent | 423bc525f51a54c4a79bf5cf69822a7554584d6d (diff) |
sunxi: fix udelay() implementation
Nah, compilers are way too clever these days to fall for those simple
delay loops, in fact the function resulted into a single "ret" to be
generated.
Use an inline assembly loop instead.
-rw-r--r-- | plat/sun50iw1p1/sunxi_cpu_ops.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/plat/sun50iw1p1/sunxi_cpu_ops.c b/plat/sun50iw1p1/sunxi_cpu_ops.c index 1fcff13..9db3a9e 100644 --- a/plat/sun50iw1p1/sunxi_cpu_ops.c +++ b/plat/sun50iw1p1/sunxi_cpu_ops.c @@ -61,18 +61,18 @@ static unsigned int sun50i_prcm_base = SUN50I_PRCM_PBASE; static unsigned int sun50i_r_cpucfg_base = SUN50I_RCPUCFG_PBASE; extern bakery_lock_t plat_console_lock; - void udelay(unsigned int delay) - { - unsigned int i, j; +void udelay(unsigned int delay) +{ if (!delay) return; - for (i=0; i<1000*delay; i++) - { - j+=i; - } - } + __asm__ volatile ( + "1:\tsubs %0, %0, #1\n" + "\tb.ne 1b" + :: "r" (delay * 1000UL) + ); +} #ifdef SUNXI_CPUOPS_REAL_DELAY #define CPU_DELAY_SHORT 10 |