Merge tag 'armsoc-dt2' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[deliverable/linux.git] / arch / x86 / um / delay.c
CommitLineData
22e9b917
RW
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
060e3522
JD
10#include <linux/module.h>
11#include <linux/kernel.h>
12#include <linux/delay.h>
13#include <asm/param.h>
5fd861b6 14
22e9b917 15void __delay(unsigned long loops)
1da177e4 16{
22e9b917
RW
17 asm volatile(
18 "test %0,%0\n"
19 "jz 3f\n"
20 "jmp 1f\n"
21
1da177e4 22 ".align 16\n"
22e9b917
RW
23 "1: jmp 2f\n"
24
1da177e4 25 ".align 16\n"
22e9b917
RW
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 );
1da177e4 33}
22e9b917 34EXPORT_SYMBOL(__delay);
1da177e4 35
22e9b917 36inline void __const_udelay(unsigned long xloops)
5fd861b6 37{
22e9b917 38 int d0;
5fd861b6 39
22e9b917
RW
40 xloops *= 4;
41 asm("mull %%edx"
42 : "=d" (xloops), "=&a" (d0)
43 : "1" (xloops), "0"
44 (loops_per_jiffy * (HZ/4)));
45
46 __delay(++xloops);
5fd861b6 47}
22e9b917 48EXPORT_SYMBOL(__const_udelay);
5fd861b6 49
22e9b917
RW
50void __udelay(unsigned long usecs)
51{
52 __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
53}
060e3522 54EXPORT_SYMBOL(__udelay);
22e9b917
RW
55
56void __ndelay(unsigned long nsecs)
57{
58 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
59}
60EXPORT_SYMBOL(__ndelay);
This page took 1.102011 seconds and 5 git commands to generate.