import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / arm / lib / delay.S
1 /*
2  *  linux/arch/arm/lib/delay.S
3  *
4  *  Copyright (C) 1995-2003 Russell King
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #include <linux/linkage.h>
11 #include <asm/assembler.h>
12 #include <asm/delay.h>
13
14                 .text
15
16 /*
17  * See linux/include/asm-arm/delay.h for a description of the maths.
18  */
19
20 #if NDELAY_FACTOR > 255
21 #error NDELAY_FACTOR out of range
22 #endif
23 #if UDELAY_FACTOR > 65535
24 #error UDELAY_FACTOR out of range
25 #endif
26
27 LC0:            .word   SYMBOL_NAME(loops_per_jiffy)
28
29 ENTRY(__const_delay)
30                 ldr     r3, LC0
31                 mov     r1, r0, lsr #11
32                 ldr     r2, [r3, #0]
33                 b       2f
34
35 ENTRY(__ndelay)
36                 mov     r2, #NDELAY_FACTOR
37                 b       1f
38
39 ENTRY(__udelay)
40                 mov     r2,     #UDELAY_FACTOR & 0xff00
41                 orr     r2, r2, #UDELAY_FACTOR & 0x00ff
42 1:              ldr     r3, LC0
43                 mul     r1, r0, r2
44                 ldr     r2, [r3, #0]
45                 mov     r1, r1, lsr #11
46 2:              mov     r2, r2, lsr #12
47                 mul     r0, r1, r2
48                 movs    r0, r0, lsr #5
49                 RETINSTR(moveq,pc,lr)
50
51 /*
52  * loops = (r0 * 0x10c6 * HZ * loops_per_jiffy) / 2^32
53  *
54  * Oh, if only we had a cycle counter...
55  */
56
57 ENTRY(__delay)
58                 subs    r0, r0, #1
59                 bcs     SYMBOL_NAME(__delay)
60                 RETINSTR(mov,pc,lr)