blob: 3c9a05c8d20b27a8054bebc5fed19f89ca03500e [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>
Peter Teichmann6d4518d2006-03-20 17:10:09 +000012#include <asm/param.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 .text
14
Nicolas Pitre8adbb372005-11-11 21:51:49 +000015.LC0: .word loops_per_jiffy
Peter Teichmann6d4518d2006-03-20 17:10:09 +000016.LC1: .word (2199023*HZ)>>11
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070024ENTRY(__udelay)
Peter Teichmann6d4518d2006-03-20 17:10:09 +000025 ldr r2, .LC1
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 mul r0, r2, r0
Peter Teichmann6d4518d2006-03-20 17:10:09 +000027ENTRY(__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 * Oh, if only we had a cycle counter...
44 */
45
46@ Delay routine
47ENTRY(__delay)
48 subs r0, r0, #1
49#if 0
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
Russell King7999d8d2006-06-25 11:17:23 +010062 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 subs r0, r0, #1
64#endif
65 bhi __delay
Russell King7999d8d2006-06-25 11:17:23 +010066 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010067ENDPROC(__udelay)
68ENDPROC(__const_udelay)
69ENDPROC(__delay)