Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / arch / blackfin / include / asm / delay.h
blob171d8deb04a5e0f431531e9ecaf7f57dbb2a58c5
1 /*
2 * delay.h - delay functions
4 * Copyright (c) 2004-2007 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
7 */
9 #ifndef __ASM_DELAY_H__
10 #define __ASM_DELAY_H__
12 #include <mach/anomaly.h>
14 static inline void __delay(unsigned long loops)
16 __asm__ __volatile__ (
17 "LSETUP(1f, 1f) LC0 = %0;"
18 "1: NOP;"
20 : "a" (loops)
21 : "LT0", "LB0", "LC0"
25 #include <linux/param.h> /* needed for HZ */
28 * close approximation borrowed from m68knommu to avoid 64-bit math
31 #define HZSCALE (268435456 / (1000000/HZ))
33 static inline unsigned long __to_delay(unsigned long scale)
35 extern unsigned long loops_per_jiffy;
36 return (((scale * HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6;
39 static inline void udelay(unsigned long usecs)
41 __delay(__to_delay(usecs));
44 static inline void ndelay(unsigned long nsecs)
46 __delay(__to_delay(1) * nsecs / 1000);
49 #define ndelay ndelay
51 #endif