mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
rk27xx: make udelay() more accurate
Change-Id: Ic448c4e5ec52af6aaeebccee4feea49954394677
This commit is contained in:
parent
6be8097651
commit
3c802a95ed
1 changed files with 2 additions and 8 deletions
|
|
@ -177,19 +177,13 @@ int system_memory_guard(int newmode)
|
||||||
/* usecs may be at most 2^32/200 (~21 seconds) for 200MHz max cpu freq */
|
/* usecs may be at most 2^32/200 (~21 seconds) for 200MHz max cpu freq */
|
||||||
void udelay(unsigned usecs)
|
void udelay(unsigned usecs)
|
||||||
{
|
{
|
||||||
unsigned cycles_per_usec;
|
|
||||||
unsigned delay;
|
unsigned delay;
|
||||||
|
|
||||||
if (cpu_frequency == CPUFREQ_MAX) {
|
delay = (usecs * (cpu_frequency/1000000)) / 5;
|
||||||
cycles_per_usec = (CPUFREQ_MAX + 999999) / 1000000;
|
|
||||||
} else {
|
|
||||||
cycles_per_usec = (CPUFREQ_NORMAL + 999999) / 1000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
delay = (usecs * cycles_per_usec + 3) / 4;
|
|
||||||
|
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"1: subs %0, %0, #1 \n" /* 1 cycle */
|
"1: subs %0, %0, #1 \n" /* 1 cycle */
|
||||||
|
" nop \n" /* 1 cycle */
|
||||||
" bne 1b \n" /* 3 cycles */
|
" bne 1b \n" /* 3 cycles */
|
||||||
: : "r"(delay)
|
: : "r"(delay)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue