summaryrefslogtreecommitdiffstats
path: root/include/asm-alpha/delay.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1994-11-28 11:59:19 +0000
committer <ralf@linux-mips.org>1994-11-28 11:59:19 +0000
commit1513ff9b7899ab588401c89db0e99903dbf5f886 (patch)
treef69cc81a940a502ea23d664c3ffb2d215a479667 /include/asm-alpha/delay.h
Import of Linus's Linux 1.1.68
Diffstat (limited to 'include/asm-alpha/delay.h')
-rw-r--r--include/asm-alpha/delay.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/asm-alpha/delay.h b/include/asm-alpha/delay.h
new file mode 100644
index 000000000..87e69f657
--- /dev/null
+++ b/include/asm-alpha/delay.h
@@ -0,0 +1,38 @@
+#ifndef __ALPHA_DELAY_H
+#define __ALPHA_DELAY_H
+
+extern unsigned long loops_per_sec;
+
+/*
+ * Copyright (C) 1993 Linus Torvalds
+ *
+ * Delay routines, using a pre-computed "loops_per_second" value.
+ */
+
+extern __inline__ void __delay(unsigned long loops)
+{
+ __asm__ __volatile__(".align 3\n"
+ "1:\tsubq %0,1,%0\n\t"
+ "bge %0,1b": "=r" (loops) : "0" (loops));
+}
+
+/*
+ * division by multiplication: you don't have to worry about
+ * loss of precision.
+ *
+ * Use only for very small delays ( < 1 msec). Should probably use a
+ * lookup table, really, as the multiplications take much too long with
+ * short delays. This is a "reasonable" implementation, though (and the
+ * first constant multiplications gets optimized away if the delay is
+ * a constant)
+ */
+extern __inline__ void udelay(unsigned long usecs)
+{
+ usecs *= 0x000010c6f7a0b5edUL; /* 2**64 / 1000000 */
+ __asm__("umulh %1,%2,%0"
+ :"=r" (usecs)
+ :"r" (usecs),"r" (loops_per_sec));
+ __delay(usecs);
+}
+
+#endif /* defined(__ALPHA_DELAY_H) */