1
2
3
4
5
6
7
8
9
10
11#include <linux/module.h>
12#include <linux/sched.h>
13#include <linux/delay.h>
14#include <asm/div64.h>
15
16
17
18
19void __delay(unsigned long loops)
20{
21 int d0;
22
23 asm volatile(
24 " bra 1f \n"
25 " .align 4 \n"
26 "1: bra 2f \n"
27 " .align 4 \n"
28 "2: add -1,%0 \n"
29 " bne 2b \n"
30 : "=&d" (d0)
31 : "0" (loops)
32 : "cc");
33}
34EXPORT_SYMBOL(__delay);
35
36
37
38
39void __udelay(unsigned long usecs)
40{
41 unsigned long start, stop, cnt;
42
43
44 stop = __muldiv64u(usecs, MN10300_TSCCLK, 1000000);
45 start = TMTSCBC;
46
47 do {
48 cnt = start - TMTSCBC;
49 } while (cnt < stop);
50}
51EXPORT_SYMBOL(__udelay);
52