Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | #ifndef _BLACKFIN_DELAY_H |
| 2 | #define _BLACKFIN_DELAY_H |
| 3 | |
| 4 | static inline void __delay(unsigned long loops) |
| 5 | { |
| 6 | |
| 7 | /* FIXME: Currently the assembler doesn't recognize Loop Register Clobbers, |
| 8 | uncomment this as soon those are implemented */ |
| 9 | /* |
| 10 | __asm__ __volatile__ ( "\t LSETUP (1f,1f) LC0= %0\n\t" |
| 11 | "1:\t NOP;\n\t" |
| 12 | : :"a" (loops) |
| 13 | : "LT0","LB0","LC0"); |
| 14 | |
| 15 | */ |
| 16 | |
| 17 | __asm__ __volatile__("[--SP] = LC0;\n\t" |
| 18 | "[--SP] = LT0;\n\t" |
| 19 | "[--SP] = LB0;\n\t" |
| 20 | "LSETUP (1f,1f) LC0 = %0;\n\t" |
| 21 | "1:\t NOP;\n\t" |
| 22 | "LB0 = [SP++];\n\t" |
| 23 | "LT0 = [SP++];\n\t" |
| 24 | "LC0 = [SP++];\n" |
| 25 | : |
| 26 | :"a" (loops)); |
| 27 | } |
| 28 | |
| 29 | #include <linux/param.h> /* needed for HZ */ |
| 30 | |
| 31 | /* |
| 32 | * Use only for very small delays ( < 1 msec). Should probably use a |
| 33 | * lookup table, really, as the multiplications take much too long with |
| 34 | * short delays. This is a "reasonable" implementation, though (and the |
| 35 | * first constant multiplications gets optimized away if the delay is |
| 36 | * a constant) |
| 37 | */ |
| 38 | static inline void udelay(unsigned long usecs) |
| 39 | { |
| 40 | extern unsigned long loops_per_jiffy; |
| 41 | __delay(usecs * loops_per_jiffy / (1000000 / HZ)); |
| 42 | } |
| 43 | |
| 44 | #endif /* defined(_BLACKFIN_DELAY_H) */ |