1
2
3
4
5
6
7
8
9
10
11
12
13
static inline void udelay(unsigned usecs)
{
    unsigned cycles_per_usec = (cpu_frequency == CPUFREQ_MAX) ?
        (CPUFREQ_MAX / 1000000) : (CPUFREQ_NORMAL / 1000000);
    unsigned cycles = usecs * cycles_per_usec / 4;

    asm volatile(
        "1: subs %0, %0, #1 \n"
        "   bne 1b          \n"
        : : "r"(cycles)
    );

}