Linux 4.13.16
[linux/fpc-iii.git] / arch / h8300 / lib / delay.c
blob463f6b3afb523c573b0082428a92582191ac19a1
1 /*
2 * delay loops
4 * Copyright (C) 2015 Yoshinori Sato
5 */
7 #include <linux/module.h>
8 #include <linux/delay.h>
9 #include <asm/param.h>
10 #include <asm/processor.h>
11 #include <asm/timex.h>
13 void __delay(unsigned long cycles)
15 __asm__ volatile ("1: dec.l #1,%0\n\t"
16 "bne 1b":"=r"(cycles):"0"(cycles));
18 EXPORT_SYMBOL(__delay);
20 void __const_udelay(unsigned long xloops)
22 u64 loops;
24 loops = (u64)xloops * loops_per_jiffy * HZ;
26 __delay(loops >> 32);
28 EXPORT_SYMBOL(__const_udelay);
30 void __udelay(unsigned long usecs)
32 __const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */
34 EXPORT_SYMBOL(__udelay);
36 void __ndelay(unsigned long nsecs)
38 __const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */
40 EXPORT_SYMBOL(__ndelay);