These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / arch / h8300 / lib / delay.c
1 /*
2  * delay loops
3  *
4  * Copyright (C) 2015 Yoshinori Sato
5  */
6
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>
12
13 void __delay(unsigned long cycles)
14 {
15         __asm__ volatile ("1: dec.l #1,%0\n\t"
16                           "bne 1b":"=r"(cycles):"0"(cycles));
17 }
18 EXPORT_SYMBOL(__delay);
19
20 void __const_udelay(unsigned long xloops)
21 {
22         u64 loops;
23
24         loops = (u64)xloops * loops_per_jiffy * HZ;
25
26         __delay(loops >> 32);
27 }
28 EXPORT_SYMBOL(__const_udelay);
29
30 void __udelay(unsigned long usecs)
31 {
32         __const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */
33 }
34 EXPORT_SYMBOL(__udelay);
35
36 void __ndelay(unsigned long nsecs)
37 {
38         __const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */
39 }
40 EXPORT_SYMBOL(__ndelay);