aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh64/lib/udelay.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh64/lib/udelay.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/sh64/lib/udelay.c')
-rw-r--r--arch/sh64/lib/udelay.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/arch/sh64/lib/udelay.c b/arch/sh64/lib/udelay.c
new file mode 100644
index 000000000000..dad2f254efee
--- /dev/null
+++ b/arch/sh64/lib/udelay.c
@@ -0,0 +1,60 @@
1/*
2 * arch/sh64/lib/udelay.c
3 *
4 * Delay routines, using a pre-computed "loops_per_jiffy" value.
5 *
6 * Copyright (C) 2000, 2001 Paolo Alberelli
7 * Copyright (C) 2003, 2004 Paul Mundt
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/config.h>
14#include <linux/sched.h>
15#include <asm/param.h>
16
17extern unsigned long loops_per_jiffy;
18
19/*
20 * Use only for very small delays (< 1 msec).
21 *
22 * The active part of our cycle counter is only 32-bits wide, and
23 * we're treating the difference between two marks as signed. On
24 * a 1GHz box, that's about 2 seconds.
25 */
26
27void __delay(int loops)
28{
29 long long dummy;
30 __asm__ __volatile__("gettr tr0, %1\n\t"
31 "pta $+4, tr0\n\t"
32 "addi %0, -1, %0\n\t"
33 "bne %0, r63, tr0\n\t"
34 "ptabs %1, tr0\n\t":"=r"(loops),
35 "=r"(dummy)
36 :"0"(loops));
37}
38
39void __udelay(unsigned long long usecs, unsigned long lpj)
40{
41 usecs *= (((unsigned long long) HZ << 32) / 1000000) * lpj;
42 __delay((long long) usecs >> 32);
43}
44
45void __ndelay(unsigned long long nsecs, unsigned long lpj)
46{
47 nsecs *= (((unsigned long long) HZ << 32) / 1000000000) * lpj;
48 __delay((long long) nsecs >> 32);
49}
50
51void udelay(unsigned long usecs)
52{
53 __udelay(usecs, loops_per_jiffy);
54}
55
56void ndelay(unsigned long nsecs)
57{
58 __ndelay(nsecs, loops_per_jiffy);
59}
60