1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Port on Texas Instruments TMS320C6x architecture
5 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
6 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
8 #ifndef _ASM_C6X_DELAY_H
9 #define _ASM_C6X_DELAY_H
11 #include <linux/kernel.h>
13 extern unsigned int ticks_per_ns_scaled
;
15 static inline void __delay(unsigned long loops
)
19 /* 6 cycles per loop */
20 asm volatile (" mv .s1 %0,%1\n"
23 " cmplt .l1 1,%0,%1\n"
25 : "+a"(loops
), "=A"(tmp
));
28 static inline void _c6x_tickdelay(unsigned int x
)
32 asm volatile (" mvc .s2 TSCL,%0\n"
33 " add .s2x %0,%1,%2\n"
38 " cmpgt .l2 0,%0,B0\n"
40 : "=b"(cnt
), "+a"(x
), "=b"(endcnt
) : : "B0");
43 /* use scaled math to avoid slow division */
44 #define C6X_NDELAY_SCALE 10
46 static inline void _ndelay(unsigned int n
)
48 _c6x_tickdelay((ticks_per_ns_scaled
* n
) >> C6X_NDELAY_SCALE
);
51 static inline void _udelay(unsigned int n
)
61 #define udelay(x) _udelay((unsigned int)(x))
62 #define ndelay(x) _ndelay((unsigned int)(x))
64 #endif /* _ASM_C6X_DELAY_H */