diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/s390/lib/delay.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/s390/lib/delay.c')
-rw-r--r-- | arch/s390/lib/delay.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/arch/s390/lib/delay.c b/arch/s390/lib/delay.c new file mode 100644 index 000000000000..e96c35bddac7 --- /dev/null +++ b/arch/s390/lib/delay.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * arch/s390/kernel/delay.c | ||
3 | * Precise Delay Loops for S390 | ||
4 | * | ||
5 | * S390 version | ||
6 | * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation | ||
7 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), | ||
8 | * | ||
9 | * Derived from "arch/i386/lib/delay.c" | ||
10 | * Copyright (C) 1993 Linus Torvalds | ||
11 | * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz> | ||
12 | */ | ||
13 | |||
14 | #include <linux/config.h> | ||
15 | #include <linux/sched.h> | ||
16 | #include <linux/delay.h> | ||
17 | |||
18 | #ifdef CONFIG_SMP | ||
19 | #include <asm/smp.h> | ||
20 | #endif | ||
21 | |||
22 | void __delay(unsigned long loops) | ||
23 | { | ||
24 | /* | ||
25 | * To end the bloody studid and useless discussion about the | ||
26 | * BogoMips number I took the liberty to define the __delay | ||
27 | * function in a way that that resulting BogoMips number will | ||
28 | * yield the megahertz number of the cpu. The important function | ||
29 | * is udelay and that is done using the tod clock. -- martin. | ||
30 | */ | ||
31 | __asm__ __volatile__( | ||
32 | "0: brct %0,0b" | ||
33 | : /* no outputs */ : "r" (loops/2) ); | ||
34 | } | ||
35 | |||
36 | /* | ||
37 | * Waits for 'usecs' microseconds using the tod clock, giving up the time slice | ||
38 | * of the virtual PU inbetween to avoid congestion. | ||
39 | */ | ||
40 | void __udelay(unsigned long usecs) | ||
41 | { | ||
42 | uint64_t start_cc, end_cc; | ||
43 | |||
44 | if (usecs == 0) | ||
45 | return; | ||
46 | asm volatile ("STCK %0" : "=m" (start_cc)); | ||
47 | do { | ||
48 | cpu_relax(); | ||
49 | asm volatile ("STCK %0" : "=m" (end_cc)); | ||
50 | } while (((end_cc - start_cc)/4096) < usecs); | ||
51 | } | ||