summaryrefslogtreecommitdiffstats
path: root/include/asm-sparc/delay.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1995-11-14 08:00:00 +0000
committer <ralf@linux-mips.org>1995-11-14 08:00:00 +0000
commite7c2a72e2680827d6a733931273a93461c0d8d1b (patch)
treec9abeda78ef7504062bb2e816bcf3e3c9d680112 /include/asm-sparc/delay.h
parentec6044459060a8c9ce7f64405c465d141898548c (diff)
Import of Linux/MIPS 1.3.0
Diffstat (limited to 'include/asm-sparc/delay.h')
-rw-r--r--include/asm-sparc/delay.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/asm-sparc/delay.h b/include/asm-sparc/delay.h
new file mode 100644
index 000000000..d6c4b360e
--- /dev/null
+++ b/include/asm-sparc/delay.h
@@ -0,0 +1,40 @@
+#ifndef __SPARC_DELAY_H
+#define __SPARC_DELAY_H
+
+extern unsigned long loops_per_sec;
+
+/*
+ * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu).
+ *
+ * Delay quick inlined code using 'loops_per_second' which is
+ * calculated in calibrate_delay() in main.c (ie. BogoMIPS :-)
+ */
+
+extern __inline__ void __delay(unsigned int loops)
+{
+ __asm__ __volatile__("\n1:\tcmp %0, 0\n\t"
+ "bne,a 1b\n\t"
+ "sub %0, 1, %0\n": "=&r" (loops) : "0" (loops));
+}
+
+/* udelay(usecs) is used for very short delays up to 1 millisecond. */
+
+extern __inline__ void udelay(unsigned int usecs)
+{
+ usecs *= 0x000010c6; /* Sparc is 32-bit just like ix86 */
+
+ __asm__("sethi %hi(_loops_per_sec), %o1\n\t"
+ "ld [%o1 + %lo(_loops_per_sec)], %o1\n\t"
+ "call ___delay\n\t"
+ "umul %o1, %o0, %o0\n\t");
+}
+
+/* calibrate_delay() wants this... */
+
+extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
+{
+ return ((a*b)/c);
+}
+
+#endif /* defined(__SPARC_DELAY_H) */
+