2 * Copyright (C) 1993, 2000 Linus Torvalds
4 * Delay routines, using a pre-computed "loops_per_jiffy" value.
6 #include <linux/config.h>
7 #include <linux/sched.h>
10 #include <linux/delay.h>
13 * Use only for very small delays (< 1 msec).
15 * The active part of our cycle counter is only 32-bits wide, and
16 * we're treating the difference between two marks as signed. On
17 * a 1GHz box, that's about 2 seconds.
20 void __delay(int loops)
23 __asm__ __volatile__("gettr " __t0 ", %1\n\t"
24 "_pta 4, " __t0 "\n\t"
26 "bne %0, r63, " __t0 "\n\t"
27 "ptabs %1, " __t0 "\n\t":"=r"(loops),
32 void __udelay(unsigned long long usecs, unsigned long lpj)
34 usecs *= (((unsigned long long) HZ << 32) / 1000000) * lpj;
35 __delay((long long) usecs >> 32);
38 void __ndelay(unsigned long long nsecs, unsigned long lpj)
40 nsecs *= (((unsigned long long) HZ << 32) / 1000000000) * lpj;
41 __delay((long long) nsecs >> 32);
44 void udelay(unsigned long usecs)
46 __udelay(usecs, loops_per_jiffy);
49 void ndelay(unsigned long nsecs)
51 __ndelay(nsecs, loops_per_jiffy);