summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/system-as3525.c
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-06-18 19:14:08 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-06-18 19:14:08 +0000
commit7a9033179f34ba5175b5dc13c674d21235f2f98a (patch)
tree0c76fc01b163dae4b4fa9fbf9a828b539a10ea00 /firmware/target/arm/as3525/system-as3525.c
parent955bb4004fcfbc762db7c9364665a40fa2018e7e (diff)
as3525*: make udelay() be a simple busy loop
it achieves all the requirements, work fine on c200v2, and is much simpler git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26933 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/system-as3525.c')
-rw-r--r--firmware/target/arm/as3525/system-as3525.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
index 940f183c63..aa98aff852 100644
--- a/firmware/target/arm/as3525/system-as3525.c
+++ b/firmware/target/arm/as3525/system-as3525.c
@@ -326,6 +326,26 @@ int system_memory_guard(int newmode)
return 0;
}
+void udelay(unsigned short usecs)
+{
+ unsigned cycles_per_usec;
+ unsigned delay;
+
+ if (cpu_frequency == CPUFREQ_MAX) {
+ cycles_per_usec = (CPUFREQ_MAX + 999999) / 1000000;
+ } else {
+ cycles_per_usec = (CPUFREQ_NORMAL + 999999) / 1000000;
+ }
+
+ delay = (usecs * cycles_per_usec + 3) / 4;
+
+ asm volatile(
+ "1: subs %0, %0, #1 \n" /* 1 cycle */
+ " bne 1b \n" /* 3 cycles */
+ : : "r"(delay)
+ );
+}
+
#ifndef BOOTLOADER
#ifdef HAVE_ADJUSTABLE_CPU_FREQ