2 * Precise Delay Loops for x86-64
4 * Copyright (C) 1993 Linus Torvalds
5 * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
7 * The __delay function must _NOT_ be inlined as its execution time
8 * depends wildly on alignment on many x86 processors.
12 #include <lwk/cpuinfo.h>
13 #include <lwk/delay.h>
15 #include <arch/processor.h>
18 void __delay(unsigned long cycles)
28 while((now-bclock) < cycles);
31 inline void __const_udelay(unsigned long xsecs)
34 (xsecs * cpu_info[this_cpu].arch.tsc_khz * 1000) /* cycles * 2**32 */
35 >> 32 /* div by 2**32 */
39 void __udelay(unsigned long usecs)
41 __const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */
44 void __ndelay(unsigned long nsecs)
46 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */