blob: f92aca011bababa38fdf66f65889ce081c7c5fbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* Originally from linux/arch/arm/lib/delay.S
*
* Copyright (C) 1995, 1996 Russell King
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/delay.h>
/*
* loops = usecs * HZ * loops_per_jiffy / 1000000
*
* Oh, if only we had a cycle counter...
*/
void __delay(unsigned long loops)
{
asm volatile(
"1: subs %0, %0, #1 \n"
" bhi 1b \n"
: /* No output */
: "r" (loops)
);
}
EXPORT_SYMBOL(__delay);
/*
* 0 <= xloops <= 0x7fffff06
* loops_per_jiffy <= 0x01ffffff (max. 3355 bogomips)
*/
void __const_udelay(unsigned long xloops)
{
unsigned long lpj;
unsigned long loops;
xloops >>= 14; /* max = 0x01ffffff */
lpj = loops_per_jiffy >> 10; /* max = 0x0001ffff */
loops = lpj * xloops; /* max = 0x00007fff */
loops >>= 6; /* max = 2^32-1 */
if (likely(loops))
__delay(loops);
}
EXPORT_SYMBOL(__const_udelay);
/*
* usecs <= 2000
* HZ <= 1000
*/
void __udelay(unsigned long usecs)
{
__const_udelay(usecs * ((2199023*HZ)>>11));
}
EXPORT_SYMBOL(__udelay);
|