diff options
author | Richard Weinberger <richard@nod.at> | 2011-07-25 20:12:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-25 23:57:12 -0400 |
commit | 22e9b917ab7ccd98046ad9428fb28967f0744605 (patch) | |
tree | fb21871390d662b0c9cccd05ee3180336afe8e4f /arch/um/sys-x86_64 | |
parent | c0ce5b673457123406f19e616bb8cf20a0c12cb5 (diff) |
um: clean up delay functions
Both sys-i386 and sys-x86_64 support now ndelay(). The delay functions
are based on arch/x86/lib/delay.c.
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/sys-x86_64')
-rw-r--r-- | arch/um/sys-x86_64/delay.c | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/arch/um/sys-x86_64/delay.c b/arch/um/sys-x86_64/delay.c index dee5be66da82..f3fe1a688f7e 100644 --- a/arch/um/sys-x86_64/delay.c +++ b/arch/um/sys-x86_64/delay.c | |||
@@ -1,30 +1,60 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2003 PathScale, Inc. | 2 | * Copyright (C) 2011 Richard Weinberger <richrd@nod.at> |
3 | * Copied from arch/x86_64 | 3 | * Mostly copied from arch/x86/lib/delay.c |
4 | * | 4 | * |
5 | * Licensed under the GPL | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
6 | */ | 8 | */ |
7 | 9 | ||
8 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/kernel.h> | ||
9 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
10 | #include <asm/processor.h> | ||
11 | #include <asm/param.h> | 13 | #include <asm/param.h> |
12 | 14 | ||
13 | void __delay(unsigned long loops) | 15 | void __delay(unsigned long loops) |
14 | { | 16 | { |
15 | unsigned long i; | 17 | asm volatile( |
18 | "test %0,%0\n" | ||
19 | "jz 3f\n" | ||
20 | "jmp 1f\n" | ||
16 | 21 | ||
17 | for(i = 0; i < loops; i++) | 22 | ".align 16\n" |
18 | cpu_relax(); | 23 | "1: jmp 2f\n" |
24 | |||
25 | ".align 16\n" | ||
26 | "2: dec %0\n" | ||
27 | " jnz 2b\n" | ||
28 | "3: dec %0\n" | ||
29 | |||
30 | : /* we don't need output */ | ||
31 | : "a" (loops) | ||
32 | ); | ||
19 | } | 33 | } |
34 | EXPORT_SYMBOL(__delay); | ||
20 | 35 | ||
21 | void __udelay(unsigned long usecs) | 36 | inline void __const_udelay(unsigned long xloops) |
22 | { | 37 | { |
23 | unsigned long i, n; | 38 | int d0; |
24 | 39 | ||
25 | n = (loops_per_jiffy * HZ * usecs) / MILLION; | 40 | xloops *= 4; |
26 | for(i=0;i<n;i++) | 41 | asm("mull %%edx" |
27 | cpu_relax(); | 42 | : "=d" (xloops), "=&a" (d0) |
43 | : "1" (xloops), "0" | ||
44 | (loops_per_jiffy * (HZ/4))); | ||
45 | |||
46 | __delay(++xloops); | ||
28 | } | 47 | } |
48 | EXPORT_SYMBOL(__const_udelay); | ||
29 | 49 | ||
50 | void __udelay(unsigned long usecs) | ||
51 | { | ||
52 | __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */ | ||
53 | } | ||
30 | EXPORT_SYMBOL(__udelay); | 54 | EXPORT_SYMBOL(__udelay); |
55 | |||
56 | void __ndelay(unsigned long nsecs) | ||
57 | { | ||
58 | __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */ | ||
59 | } | ||
60 | EXPORT_SYMBOL(__ndelay); | ||