Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / nios2 / lib / delay.c
blobf1e39c7f743947fbd34bad72a518d8ed5f5bd5ef
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright Altera Corporation (C) 2014. All rights reserved.
3 */
5 #include <linux/module.h>
6 #include <asm/delay.h>
7 #include <asm/param.h>
8 #include <asm/processor.h>
9 #include <asm/timex.h>
11 void __delay(unsigned long cycles)
13 cycles_t start = get_cycles();
15 while ((get_cycles() - start) < cycles)
16 cpu_relax();
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);