1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _METAG_DELAY_H 3 #define _METAG_DELAY_H 4 5 /* 6 * Copyright (C) 1993 Linus Torvalds 7 * 8 * Delay routines calling functions in arch/metag/lib/delay.c 9 */ 10 11 /* Undefined functions to get compile-time errors */ 12 extern void __bad_udelay(void); 13 extern void __bad_ndelay(void); 14 15 extern void __udelay(unsigned long usecs); 16 extern void __ndelay(unsigned long nsecs); 17 extern void __const_udelay(unsigned long xloops); 18 extern void __delay(unsigned long loops); 19 20 /* 0x10c7 is 2**32 / 1000000 (rounded up) */ 21 #define udelay(n) (__builtin_constant_p(n) ? \ 22 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \ 23 __udelay(n)) 24 25 /* 0x5 is 2**32 / 1000000000 (rounded up) */ 26 #define ndelay(n) (__builtin_constant_p(n) ? \ 27 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ 28 __ndelay(n)) 29 30 #endif /* _METAG_DELAY_H */ 31