blob: f3ddd2133e6f4edffb5a7fc7958350d9d1c2f680 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Precise Delay Loops for SuperH
3 *
4 * Copyright (C) 1999 Niibe Yutaka & Kaz Kojima
5 */
6
7#include <linux/sched.h>
8#include <linux/delay.h>
9
10void __delay(unsigned long loops)
11{
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");
20}
21
22inline void __const_udelay(unsigned long xloops)
23{
24 __asm__("dmulu.l %0, %2\n\t"
25 "sts mach, %0"
26 : "=r" (xloops)
kogiidenac71861e2007-05-08 20:45:46 +090027 : "0" (xloops),
28 "r" (HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 : "macl", "mach");
kogiidenac71861e2007-05-08 20:45:46 +090030 __delay(xloops);
Linus Torvalds1da177e2005-04-16 15:20:36 -070031}
32
33void __udelay(unsigned long usecs)
34{
35 __const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */
36}
37
38void __ndelay(unsigned long nsecs)
39{
40 __const_udelay(nsecs * 0x00000005);
41}
42