blob: 36b668d8e121ee7450c8beffb5e9661923102038 [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 King7999d8d2006-06-25 11:17:23 +010038 moveq pc, 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 */
43
44@ Delay routine
Will Deacond0a533b2012-07-06 15:47:17 +010045ENTRY(__loop_delay)
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 subs r0, r0, #1
47#if 0
Russell King7999d8d2006-06-25 11:17:23 +010048 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 subs r0, r0, #1
Russell King7999d8d2006-06-25 11:17:23 +010050 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 subs r0, r0, #1
Russell King7999d8d2006-06-25 11:17:23 +010052 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 subs r0, r0, #1
Russell King7999d8d2006-06-25 11:17:23 +010054 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 subs r0, r0, #1
Russell King7999d8d2006-06-25 11:17:23 +010056 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 subs r0, r0, #1
Russell King7999d8d2006-06-25 11:17:23 +010058 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 subs r0, r0, #1
Russell King7999d8d2006-06-25 11:17:23 +010060 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 subs r0, r0, #1
62#endif
Will Deacond0a533b2012-07-06 15:47:17 +010063 bhi __loop_delay
Russell King7999d8d2006-06-25 11:17:23 +010064 mov pc, lr
Will Deacond0a533b2012-07-06 15:47:17 +010065ENDPROC(__loop_udelay)
66ENDPROC(__loop_const_udelay)
67ENDPROC(__loop_delay)