blob: 8d6a8762ab889fdc1d2ef165c9733a92393e7c9a [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
Nicolas Pitre8adbb372005-11-11 21:51:49 +000028 ldr r2, .LC0
Peter Teichmann6d4518d2006-03-20 17:10:09 +000029 ldr r2, [r2] @ max = 0x01ffffff
30 mov r0, r0, lsr #14 @ max = 0x0001ffff
31 mov r2, r2, lsr #10 @ max = 0x00007fff
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 mul r0, r2, r0 @ max = 2^32-1
33 movs r0, r0, lsr #6
Russell King7999d8d2006-06-25 11:17:23 +010034 moveq pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36/*
Peter Teichmann6d4518d2006-03-20 17:10:09 +000037 * loops = r0 * HZ * loops_per_jiffy / 1000000
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 *
39 * Oh, if only we had a cycle counter...
40 */
41
42@ Delay routine
43ENTRY(__delay)
44 subs r0, r0, #1
45#if 0
Russell King7999d8d2006-06-25 11:17:23 +010046 movls pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 subs r0, r0, #1
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
60#endif
61 bhi __delay
Russell King7999d8d2006-06-25 11:17:23 +010062 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010063ENDPROC(__udelay)
64ENDPROC(__const_udelay)
65ENDPROC(__delay)