Merge branches 'fixes' and 'ioremap' into for-linus
[linux-2.6-block.git] / arch / unicore32 / lib / delay.S
CommitLineData
96cf5185
G
1/*
2 * linux/arch/unicore32/lib/delay.S
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/linkage.h>
13#include <asm/assembler.h>
14#include <asm/param.h>
15 .text
16
17.LC0: .word loops_per_jiffy
18.LC1: .word (2199023*HZ)>>11
19
20/*
21 * r0 <= 2000
22 * lpj <= 0x01ffffff (max. 3355 bogomips)
23 * HZ <= 1000
24 */
25
26ENTRY(__udelay)
27 ldw r2, .LC1
28 mul r0, r2, r0
29ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06
30 ldw r2, .LC0
31 ldw r2, [r2] @ max = 0x01ffffff
32 mov r0, r0 >> #14 @ max = 0x0001ffff
33 mov r2, r2 >> #10 @ max = 0x00007fff
34 mul r0, r2, r0 @ max = 2^32-1
35 mov.a r0, r0 >> #6
36 cmoveq pc, lr
37
38/*
39 * loops = r0 * HZ * loops_per_jiffy / 1000000
40 *
41 * Oh, if only we had a cycle counter...
42 */
43
44@ Delay routine
45ENTRY(__delay)
46 sub.a r0, r0, #2
47 bua __delay
48 mov pc, lr
49ENDPROC(__udelay)
50ENDPROC(__const_udelay)
51ENDPROC(__delay)