ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-ppc / timex.h
1 /*
2  * include/asm-ppc/timex.h
3  *
4  * ppc architecture timex specifications
5  */
6 #ifdef __KERNEL__
7 #ifndef _ASMppc_TIMEX_H
8 #define _ASMppc_TIMEX_H
9
10 #include <linux/config.h>
11 #include <asm/cputable.h>
12
13 #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
14 #define CLOCK_TICK_FACTOR       20      /* Factor of both 1000000 and CLOCK_TICK_RATE */
15 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
16         (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
17                 << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
18
19 typedef unsigned long cycles_t;
20
21 /*
22  * For the "cycle" counter we use the timebase lower half.
23  * Currently only used on SMP.
24  */
25
26 extern cycles_t cacheflush_time;
27
28 static inline cycles_t get_cycles(void)
29 {
30         cycles_t ret = 0;
31
32         __asm__ __volatile__(
33                 "98:    mftb %0\n"
34                 "99:\n"
35                 ".section __ftr_fixup,\"a\"\n"
36                 "       .long %1\n"
37                 "       .long 0\n"
38                 "       .long 98b\n"
39                 "       .long 99b\n"
40                 ".previous"
41                 : "=r" (ret) : "i" (CPU_FTR_601));
42         return ret;
43 }
44
45 #endif
46 #endif /* __KERNEL__ */