mm-only debug patch...
[mmotm.git] / arch / sh / lib / delay.c
blobfaa8f86c0db490718d5dbb2c6948f11d3fff28d1
1 /*
2 * Precise Delay Loops for SuperH
4 * Copyright (C) 1999 Niibe Yutaka & Kaz Kojima
5 */
7 #include <linux/sched.h>
8 #include <linux/delay.h>
10 void __delay(unsigned long loops)
12 __asm__ __volatile__(
13 "tst %0, %0\n\t"
14 "1:\t"
15 "bf/s 1b\n\t"
16 " dt %0"
17 : "=r" (loops)
18 : "0" (loops)
19 : "t");
22 inline void __const_udelay(unsigned long xloops)
24 xloops *= 4;
25 __asm__("dmulu.l %0, %2\n\t"
26 "sts mach, %0"
27 : "=r" (xloops)
28 : "0" (xloops),
29 "r" (cpu_data[raw_smp_processor_id()].loops_per_jiffy * (HZ/4))
30 : "macl", "mach");
31 __delay(++xloops);
34 void __udelay(unsigned long usecs)
36 __const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */
39 void __ndelay(unsigned long nsecs)
41 __const_udelay(nsecs * 0x00000005);