blob: 9183b06c0e2f2a77499db21f05205d0bb6907dfe [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
34 RETINSTR(moveq,pc,lr)
35
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
46 RETINSTR(movls,pc,lr)
47 subs r0, r0, #1
48 RETINSTR(movls,pc,lr)
49 subs r0, r0, #1
50 RETINSTR(movls,pc,lr)
51 subs r0, r0, #1
52 RETINSTR(movls,pc,lr)
53 subs r0, r0, #1
54 RETINSTR(movls,pc,lr)
55 subs r0, r0, #1
56 RETINSTR(movls,pc,lr)
57 subs r0, r0, #1
58 RETINSTR(movls,pc,lr)
59 subs r0, r0, #1
60#endif
61 bhi __delay
62 RETINSTR(mov,pc,lr)