/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1994 by Waldorf Electronics * Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle * Copyright (C) 1999, 2000 Silicon Graphics, Inc. * Copyright (C) 2007 Maciej W. Rozycki */ #ifndef _ASM_DELAY_H #define _ASM_DELAY_H #include #include #include #include static inline void __delay(unsigned int loops) { __asm__ __volatile__ ( " .set noreorder \n" " .align 3 \n" "1: bnez %0, 1b \n" " subu %0, 1 \n" " .set reorder \n" : "=r" (loops) : "0" (loops)); } static inline void __udelay(unsigned long us, unsigned long lpj) { __delay((us * 0x000010c7ull * HZ * lpj) >> 32); } static inline void __ndelay(unsigned long ns, unsigned long lpj) { __delay((ns * 0x00000005ull * HZ * lpj) >> 32); } #define __udelay_val cpu_data[raw_smp_processor_id()].udelay_val #define udelay(usecs) __udelay((usecs), __udelay_val) /* make sure "usecs *= ..." in udelay do not overflow. */ #if HZ >= 1000 #define MAX_UDELAY_MS 1 #elif HZ <= 200 #define MAX_UDELAY_MS 5 #else #define MAX_UDELAY_MS (1000 / HZ) #endif #endif /* _ASM_DELAY_H */