blob: 518bf6e93f78a2cb1c74f7b857c6fa96b1018f53 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Deacond0a533b2012-07-06 15:47:17 +010012#include <asm/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 .text
14
Nicolas Pitre8adbb372005-11-11 21:51:49 +000015.LC0: .word loops_per_jiffy
Will Deacond0a533b2012-07-06 15:47:17 +010016.LC1: .word UDELAY_MULT
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18/*
Peter Teichmann6d4518d2006-03-20 17:10:09 +000019 * r0 <= 2000
20 * lpj <= 0x01ffffff (max. 3355 bogomips)
21 * HZ <= 1000
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 */
Peter Teichmann6d4518d2006-03-20 17:10:09 +000023
Will Deacond0a533b2012-07-06 15:47:17 +010024ENTRY(__loop_udelay)
Peter Teichmann6d4518d2006-03-20 17:10:09 +000025 ldr r2, .LC1
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 mul r0, r2, r0
Will Deacond0a533b2012-07-06 15:47:17 +010027ENTRY(__loop_const_udelay) @ 0 <= r0 <= 0x7fffff06
Russell King56949d42011-01-10 23:55:59 +000028 mov r1, #-1
Nicolas Pitre8adbb372005-11-11 21:51:49 +000029 ldr r2, .LC0
Peter Teichmann6d4518d2006-03-20 17:10:09 +000030 ldr r2, [r2] @ max = 0x01ffffff
Russell King56949d42011-01-10 23:55:59 +000031 add r0, r0, r1, lsr #32-14
Peter Teichmann6d4518d2006-03-20 17:10:09 +000032 mov r0, r0, lsr #14 @ max = 0x0001ffff
Russell King56949d42011-01-10 23:55:59 +000033 add r2, r2, r1, lsr #32-10
Peter Teichmann6d4518d2006-03-20 17:10:09 +000034 mov r2, r2, lsr #10 @ max = 0x00007fff
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 mul r0, r2, r0 @ max = 2^32-1
Russell King56949d42011-01-10 23:55:59 +000036 add r0, r0, r1, lsr #32-6
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 movs r0, r0, lsr #6
Russell King6ebbf2c2014-06-30 16:29:12 +010038 reteq lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/*
Peter Teichmann6d4518d2006-03-20 17:10:09 +000041 * loops = r0 * HZ * loops_per_jiffy / 1000000
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 */
Fabio Estevam11d4bb12013-11-30 15:24:42 +010043 .align 3
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45@ Delay routine
Will Deacond0a533b2012-07-06 15:47:17 +010046ENTRY(__loop_delay)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 subs r0, r0, #1
48#if 0
Russell King6ebbf2c2014-06-30 16:29:12 +010049 retls lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 subs r0, r0, #1
Russell King6ebbf2c2014-06-30 16:29:12 +010051 retls lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 subs r0, r0, #1
Russell King6ebbf2c2014-06-30 16:29:12 +010053 retls lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 subs r0, r0, #1
Russell King6ebbf2c2014-06-30 16:29:12 +010055 retls lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 subs r0, r0, #1
Russell King6ebbf2c2014-06-30 16:29:12 +010057 retls lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 subs r0, r0, #1
Russell King6ebbf2c2014-06-30 16:29:12 +010059 retls lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 subs r0, r0, #1
Russell King6ebbf2c2014-06-30 16:29:12 +010061 retls lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 subs r0, r0, #1
63#endif
Will Deacond0a533b2012-07-06 15:47:17 +010064 bhi __loop_delay
Russell King6ebbf2c2014-06-30 16:29:12 +010065 ret lr
Will Deacond0a533b2012-07-06 15:47:17 +010066ENDPROC(__loop_udelay)
67ENDPROC(__loop_const_udelay)
68ENDPROC(__loop_delay)