aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-i386/delay.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/sys-i386/delay.c')
-rw-r--r--arch/um/sys-i386/delay.c59
1 files changed, 45 insertions, 14 deletions
diff --git a/arch/um/sys-i386/delay.c b/arch/um/sys-i386/delay.c
index d623e074f41d..f3fe1a688f7e 100644
--- a/arch/um/sys-i386/delay.c
+++ b/arch/um/sys-i386/delay.c
@@ -1,29 +1,60 @@
1/*
2 * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
3 * Mostly copied from arch/x86/lib/delay.c
4 *
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.
8 */
9
1#include <linux/module.h> 10#include <linux/module.h>
2#include <linux/kernel.h> 11#include <linux/kernel.h>
3#include <linux/delay.h> 12#include <linux/delay.h>
4#include <asm/param.h> 13#include <asm/param.h>
5 14
6void __delay(unsigned long time) 15void __delay(unsigned long loops)
7{ 16{
8 /* Stolen from the i386 __loop_delay */ 17 asm volatile(
9 int d0; 18 "test %0,%0\n"
10 __asm__ __volatile__( 19 "jz 3f\n"
11 "\tjmp 1f\n" 20 "jmp 1f\n"
21
12 ".align 16\n" 22 ".align 16\n"
13 "1:\tjmp 2f\n" 23 "1: jmp 2f\n"
24
14 ".align 16\n" 25 ".align 16\n"
15 "2:\tdecl %0\n\tjns 2b" 26 "2: dec %0\n"
16 :"=&a" (d0) 27 " jnz 2b\n"
17 :"0" (time)); 28 "3: dec %0\n"
29
30 : /* we don't need output */
31 : "a" (loops)
32 );
18} 33}
34EXPORT_SYMBOL(__delay);
19 35
20void __udelay(unsigned long usecs) 36inline void __const_udelay(unsigned long xloops)
21{ 37{
22 int i, n; 38 int d0;
23 39
24 n = (loops_per_jiffy * HZ * usecs) / MILLION; 40 xloops *= 4;
25 for(i=0;i<n;i++) 41 asm("mull %%edx"
26 cpu_relax(); 42 : "=d" (xloops), "=&a" (d0)
43 : "1" (xloops), "0"
44 (loops_per_jiffy * (HZ/4)));
45
46 __delay(++xloops);
27} 47}
48EXPORT_SYMBOL(__const_udelay);
28 49
50void __udelay(unsigned long usecs)
51{
52 __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
53}
29EXPORT_SYMBOL(__udelay); 54EXPORT_SYMBOL(__udelay);
55
56void __ndelay(unsigned long nsecs)
57{
58 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
59}
60EXPORT_SYMBOL(__ndelay);