GNU Linux-libre 4.14.294-gnu1
[releases.git] / arch / score / include / asm / delay.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_SCORE_DELAY_H
3 #define _ASM_SCORE_DELAY_H
4
5 #include <asm-generic/param.h>
6
7 static inline void __delay(unsigned long loops)
8 {
9         /* 3 cycles per loop. */
10         __asm__ __volatile__ (
11                 "1:\tsubi\t%0, 3\n\t"
12                 "cmpz.c\t%0\n\t"
13                 "ble\t1b\n\t"
14                 : "=r" (loops)
15                 : "0" (loops));
16 }
17
18 static inline void __udelay(unsigned long usecs)
19 {
20         unsigned long loops_per_usec;
21
22         loops_per_usec = (loops_per_jiffy * HZ) / 1000000;
23
24         __delay(usecs * loops_per_usec);
25 }
26
27 #define udelay(usecs) __udelay(usecs)
28
29 #endif /* _ASM_SCORE_DELAY_H */