Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
[linux-2.6] / arch / blackfin / include / asm / delay.h
1 /*
2  * delay.h - delay functions
3  *
4  * Copyright (c) 2004-2007 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2 or later.
7  */
8
9 #ifndef __ASM_DELAY_H__
10 #define __ASM_DELAY_H__
11
12 #include <mach/anomaly.h>
13
14 static inline void __delay(unsigned long loops)
15 {
16 __asm__ __volatile__ (
17                         "LSETUP(1f, 1f) LC0 = %0;"
18                         "1: NOP;"
19                         :
20                         : "a" (loops)
21                         : "LT0", "LB0", "LC0"
22                 );
23 }
24
25 #include <linux/param.h>        /* needed for HZ */
26
27 /*
28  * close approximation borrowed from m68knommu to avoid 64-bit math
29  */
30
31 #define HZSCALE         (268435456 / (1000000/HZ))
32
33 static inline void udelay(unsigned long usecs)
34 {
35         extern unsigned long loops_per_jiffy;
36         __delay((((usecs * HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6);
37 }
38
39 #endif