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> |
Nicolas Pitre | 215e362 | 2015-02-25 22:50:39 +0100 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | .text |
| 15 | |
Nicolas Pitre | 8adbb37 | 2005-11-11 21:51:49 +0000 | [diff] [blame] | 16 | .LC0: .word loops_per_jiffy |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 17 | .LC1: .word UDELAY_MULT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
| 19 | /* |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 20 | * r0 <= 2000 |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 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 |
Nicolas Pitre | 8adbb37 | 2005-11-11 21:51:49 +0000 | [diff] [blame] | 28 | ldr r2, .LC0 |
Nicolas Pitre | 215e362 | 2015-02-25 22:50:39 +0100 | [diff] [blame] | 29 | ldr r2, [r2] |
| 30 | umull r1, r0, r2, r0 |
| 31 | adds r1, r1, #0xffffffff |
| 32 | adcs r0, r0, r0 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 33 | reteq lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /* |
Peter Teichmann | 6d4518d | 2006-03-20 17:10:09 +0000 | [diff] [blame] | 36 | * loops = r0 * HZ * loops_per_jiffy / 1000000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | */ |
Fabio Estevam | 11d4bb1 | 2013-11-30 15:24:42 +0100 | [diff] [blame] | 38 | .align 3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | @ Delay routine |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 41 | ENTRY(__loop_delay) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | subs r0, r0, #1 |
| 43 | #if 0 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 44 | retls lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | subs r0, r0, #1 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 46 | retls lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | subs r0, r0, #1 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 48 | retls lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | subs r0, r0, #1 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 50 | retls lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | subs r0, r0, #1 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 52 | retls lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | subs r0, r0, #1 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 54 | retls lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | subs r0, r0, #1 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 56 | retls lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | subs r0, r0, #1 |
| 58 | #endif |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 59 | bhi __loop_delay |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 60 | ret lr |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 61 | ENDPROC(__loop_udelay) |
| 62 | ENDPROC(__loop_const_udelay) |
| 63 | ENDPROC(__loop_delay) |