Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/delay.S |
| 3 | * |
| 4 | * Copyright (C) 1995, 1996 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> |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 12 | #include <asm/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | .text |
| 14 | |
Nicolas Pitre | 8adbb37 | 2005-11-11 21:51:49 +0000 | [diff] [blame] | 15 | .LC0: .word loops_per_jiffy |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 16 | .LC1: .word UDELAY_MULT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | /* |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 19 | * r0 <= 2000 |
| 20 | * lpj <= 0x01ffffff (max. 3355 bogomips) |
| 21 | * HZ <= 1000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | */ |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 23 | |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 24 | ENTRY(__loop_udelay) |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 25 | ldr r2, .LC1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | mul r0, r2, r0 |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 27 | ENTRY(__loop_const_udelay) @ 0 <= r0 <= 0x7fffff06 |
Russell King | 56949d4 | 2011-01-10 23:55:59 +0000 | [diff] [blame] | 28 | mov r1, #-1 |
Nicolas Pitre | 8adbb37 | 2005-11-11 21:51:49 +0000 | [diff] [blame] | 29 | ldr r2, .LC0 |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 30 | ldr r2, [r2] @ max = 0x01ffffff |
Russell King | 56949d4 | 2011-01-10 23:55:59 +0000 | [diff] [blame] | 31 | add r0, r0, r1, lsr #32-14 |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 32 | mov r0, r0, lsr #14 @ max = 0x0001ffff |
Russell King | 56949d4 | 2011-01-10 23:55:59 +0000 | [diff] [blame] | 33 | add r2, r2, r1, lsr #32-10 |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 34 | mov r2, r2, lsr #10 @ max = 0x00007fff |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | mul r0, r2, r0 @ max = 2^32-1 |
Russell King | 56949d4 | 2011-01-10 23:55:59 +0000 | [diff] [blame] | 36 | add r0, r0, r1, lsr #32-6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | movs r0, r0, lsr #6 |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 38 | moveq pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | /* |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 41 | * loops = r0 * HZ * loops_per_jiffy / 1000000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | */ |
| 43 | |
| 44 | @ Delay routine |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 45 | ENTRY(__loop_delay) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | subs r0, r0, #1 |
| 47 | #if 0 |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 48 | movls pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | subs r0, r0, #1 |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 50 | movls pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | subs r0, r0, #1 |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 52 | movls pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | subs r0, r0, #1 |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 54 | movls pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | subs r0, r0, #1 |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 56 | movls pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | subs r0, r0, #1 |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 58 | movls pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | subs r0, r0, #1 |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 60 | movls pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | subs r0, r0, #1 |
| 62 | #endif |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 63 | bhi __loop_delay |
Russell King | 7999d8d | 2006-06-25 11:17:23 +0100 | [diff] [blame] | 64 | mov pc, lr |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 65 | ENDPROC(__loop_udelay) |
| 66 | ENDPROC(__loop_const_udelay) |
| 67 | ENDPROC(__loop_delay) |