0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/delay.h>
0012 #include <linux/export.h>
0013 #include <linux/param.h>
0014 #include <linux/smp.h>
0015 #include <linux/stringify.h>
0016
0017 #include <asm/asm.h>
0018 #include <asm/compiler.h>
0019
0020 #ifndef CONFIG_CPU_DADDI_WORKAROUNDS
0021 #define GCC_DADDI_IMM_ASM() "I"
0022 #else
0023 #define GCC_DADDI_IMM_ASM() "r"
0024 #endif
0025
0026 #ifndef CONFIG_HAVE_PLAT_DELAY
0027
0028 void __delay(unsigned long loops)
0029 {
0030 __asm__ __volatile__ (
0031 " .set noreorder \n"
0032 " .align 3 \n"
0033 "1: bnez %0, 1b \n"
0034 " " __stringify(LONG_SUBU) " %0, %1 \n"
0035 " .set reorder \n"
0036 : "=r" (loops)
0037 : GCC_DADDI_IMM_ASM() (1), "0" (loops));
0038 }
0039 EXPORT_SYMBOL(__delay);
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 void __udelay(unsigned long us)
0053 {
0054 unsigned int lpj = raw_current_cpu_data.udelay_val;
0055
0056 __delay((us * 0x000010c7ull * HZ * lpj) >> 32);
0057 }
0058 EXPORT_SYMBOL(__udelay);
0059
0060 void __ndelay(unsigned long ns)
0061 {
0062 unsigned int lpj = raw_current_cpu_data.udelay_val;
0063
0064 __delay((ns * 0x00000005ull * HZ * lpj) >> 32);
0065 }
0066 EXPORT_SYMBOL(__ndelay);
0067
0068 #endif