diff options
-rw-r--r-- | arch/arm/lib/delay.S | 20 | ||||
-rw-r--r-- | include/asm-arm/delay.h | 12 |
2 files changed, 19 insertions, 13 deletions
diff --git a/arch/arm/lib/delay.S b/arch/arm/lib/delay.S index b3fb475b4120..9183b06c0e2f 100644 --- a/arch/arm/lib/delay.S +++ b/arch/arm/lib/delay.S | |||
@@ -9,28 +9,32 @@ | |||
9 | */ | 9 | */ |
10 | #include <linux/linkage.h> | 10 | #include <linux/linkage.h> |
11 | #include <asm/assembler.h> | 11 | #include <asm/assembler.h> |
12 | #include <asm/param.h> | ||
12 | .text | 13 | .text |
13 | 14 | ||
14 | .LC0: .word loops_per_jiffy | 15 | .LC0: .word loops_per_jiffy |
16 | .LC1: .word (2199023*HZ)>>11 | ||
15 | 17 | ||
16 | /* | 18 | /* |
17 | * 0 <= r0 <= 2000 | 19 | * r0 <= 2000 |
20 | * lpj <= 0x01ffffff (max. 3355 bogomips) | ||
21 | * HZ <= 1000 | ||
18 | */ | 22 | */ |
23 | |||
19 | ENTRY(__udelay) | 24 | ENTRY(__udelay) |
20 | mov r2, #0x6800 | 25 | ldr r2, .LC1 |
21 | orr r2, r2, #0x00db | ||
22 | mul r0, r2, r0 | 26 | mul r0, r2, r0 |
23 | ENTRY(__const_udelay) @ 0 <= r0 <= 0x01ffffff | 27 | ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06 |
24 | ldr r2, .LC0 | 28 | ldr r2, .LC0 |
25 | ldr r2, [r2] @ max = 0x0fffffff | 29 | ldr r2, [r2] @ max = 0x01ffffff |
26 | mov r0, r0, lsr #11 @ max = 0x00003fff | 30 | mov r0, r0, lsr #14 @ max = 0x0001ffff |
27 | mov r2, r2, lsr #11 @ max = 0x0003ffff | 31 | mov r2, r2, lsr #10 @ max = 0x00007fff |
28 | mul r0, r2, r0 @ max = 2^32-1 | 32 | mul r0, r2, r0 @ max = 2^32-1 |
29 | movs r0, r0, lsr #6 | 33 | movs r0, r0, lsr #6 |
30 | RETINSTR(moveq,pc,lr) | 34 | RETINSTR(moveq,pc,lr) |
31 | 35 | ||
32 | /* | 36 | /* |
33 | * loops = (r0 * 0x10c6 * 100 * loops_per_jiffy) / 2^32 | 37 | * loops = r0 * HZ * loops_per_jiffy / 1000000 |
34 | * | 38 | * |
35 | * Oh, if only we had a cycle counter... | 39 | * Oh, if only we had a cycle counter... |
36 | */ | 40 | */ |
diff --git a/include/asm-arm/delay.h b/include/asm-arm/delay.h index 1704360e9699..b2deda181549 100644 --- a/include/asm-arm/delay.h +++ b/include/asm-arm/delay.h | |||
@@ -6,6 +6,8 @@ | |||
6 | #ifndef __ASM_ARM_DELAY_H | 6 | #ifndef __ASM_ARM_DELAY_H |
7 | #define __ASM_ARM_DELAY_H | 7 | #define __ASM_ARM_DELAY_H |
8 | 8 | ||
9 | #include <asm/param.h> /* HZ */ | ||
10 | |||
9 | extern void __delay(int loops); | 11 | extern void __delay(int loops); |
10 | 12 | ||
11 | /* | 13 | /* |
@@ -13,7 +15,7 @@ extern void __delay(int loops); | |||
13 | * it, it means that you're calling udelay() with an out of range value. | 15 | * it, it means that you're calling udelay() with an out of range value. |
14 | * | 16 | * |
15 | * With currently imposed limits, this means that we support a max delay | 17 | * With currently imposed limits, this means that we support a max delay |
16 | * of 2000us and 671 bogomips | 18 | * of 2000us. Further limits: HZ<=1000 and bogomips<=3355 |
17 | */ | 19 | */ |
18 | extern void __bad_udelay(void); | 20 | extern void __bad_udelay(void); |
19 | 21 | ||
@@ -32,10 +34,10 @@ extern void __const_udelay(unsigned long); | |||
32 | 34 | ||
33 | #define MAX_UDELAY_MS 2 | 35 | #define MAX_UDELAY_MS 2 |
34 | 36 | ||
35 | #define udelay(n) \ | 37 | #define udelay(n) \ |
36 | (__builtin_constant_p(n) ? \ | 38 | (__builtin_constant_p(n) ? \ |
37 | ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \ | 39 | ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \ |
38 | __const_udelay((n) * 0x68dbul)) : \ | 40 | __const_udelay((n) * ((2199023U*HZ)>>11))) : \ |
39 | __udelay(n)) | 41 | __udelay(n)) |
40 | 42 | ||
41 | #endif /* defined(_ARM_DELAY_H) */ | 43 | #endif /* defined(_ARM_DELAY_H) */ |