1 #ifndef __ALPHA_DELAY_H
2 #define __ALPHA_DELAY_H
7 * Copyright (C) 1993 Linus Torvalds
9 * Delay routines, using a pre-computed "loops_per_second" value.
12 extern __inline__
void
13 __delay(unsigned long loops
)
15 register unsigned long r0
__asm__("$0") = loops
;
17 __asm__
__volatile__("lda $28,___delay; jsr $28,($28),0"
18 : "=r"(r0
) : "r"(r0
) : "$28");
20 __asm__
__volatile__("bsr $28,___delay" : "=r"(r0
) : "r"(r0
) : "$28");
25 * division by multiplication: you don't have to worry about
28 * Use only for very small delays ( < 1 msec). Should probably use a
29 * lookup table, really, as the multiplications take much too long with
30 * short delays. This is a "reasonable" implementation, though (and the
31 * first constant multiplications gets optimized away if the delay is
34 * Optimize small constants further by exposing the second multiplication
35 * to the compiler. In addition, mulq is 2 cycles faster than umulh.
38 extern __inline__
void
39 __udelay(unsigned long usecs
, unsigned long lps
)
41 /* compute (usecs * 2**64 / 10**6) * loops_per_sec / 2**64 */
43 usecs
*= 0x000010c6f7a0b5edUL
; /* 2**64 / 1000000 */
44 __asm__("umulh %1,%2,%0" :"=r" (usecs
) :"r" (usecs
),"r" (lps
));
48 extern __inline__
void
49 __small_const_udelay(unsigned long usecs
, unsigned long lps
)
51 /* compute (usecs * 2**32 / 10**6) * loops_per_sec / 2**32 */
53 usecs
*= 0x10c6; /* 2^32 / 10^6 */
60 #define udelay(usecs) \
61 (__builtin_constant_p(usecs) && usecs < 0x100000000UL \
62 ? __small_const_udelay(usecs, \
63 cpu_data[smp_processor_id()].loops_per_sec) \
65 cpu_data[smp_processor_id()].loops_per_sec))
67 #define udelay(usecs) \
68 (__builtin_constant_p(usecs) && usecs < 0x100000000UL \
69 ? __small_const_udelay(usecs, loops_per_sec) \
70 : __udelay(usecs, loops_per_sec))
74 #endif /* defined(__ALPHA_DELAY_H) */