jdl@freescale.com | dd56fdf | 2005-09-07 15:59:48 -0500 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_TIMEX_H |
| 2 | #define _ASM_POWERPC_TIMEX_H |
| 3 | |
| 4 | #ifdef __KERNEL__ |
| 5 | |
| 6 | /* |
| 7 | * PowerPC architecture timex specifications |
| 8 | */ |
| 9 | |
jdl@freescale.com | dd56fdf | 2005-09-07 15:59:48 -0500 | [diff] [blame] | 10 | #include <asm/cputable.h> |
| 11 | |
Benjamin Herrenschmidt | cbd27b8 | 2005-10-12 11:39:33 +1000 | [diff] [blame] | 12 | #define CLOCK_TICK_RATE 1024000 /* Underlying HZ */ |
jdl@freescale.com | dd56fdf | 2005-09-07 15:59:48 -0500 | [diff] [blame] | 13 | |
| 14 | typedef unsigned long cycles_t; |
| 15 | |
| 16 | static inline cycles_t get_cycles(void) |
| 17 | { |
| 18 | cycles_t ret; |
| 19 | |
| 20 | #ifdef __powerpc64__ |
| 21 | |
| 22 | __asm__ __volatile__("mftb %0" : "=r" (ret) : ); |
| 23 | |
| 24 | #else |
| 25 | /* |
| 26 | * For the "cycle" counter we use the timebase lower half. |
| 27 | * Currently only used on SMP. |
| 28 | */ |
| 29 | |
| 30 | ret = 0; |
| 31 | |
| 32 | __asm__ __volatile__( |
Benjamin Herrenschmidt | 0909c8c | 2006-10-20 11:47:18 +1000 | [diff] [blame^] | 33 | "97: mftb %0\n" |
jdl@freescale.com | dd56fdf | 2005-09-07 15:59:48 -0500 | [diff] [blame] | 34 | "99:\n" |
| 35 | ".section __ftr_fixup,\"a\"\n" |
Benjamin Herrenschmidt | 0909c8c | 2006-10-20 11:47:18 +1000 | [diff] [blame^] | 36 | ".align 2\n" |
| 37 | "98:\n" |
jdl@freescale.com | dd56fdf | 2005-09-07 15:59:48 -0500 | [diff] [blame] | 38 | " .long %1\n" |
| 39 | " .long 0\n" |
Benjamin Herrenschmidt | 0909c8c | 2006-10-20 11:47:18 +1000 | [diff] [blame^] | 40 | " .long 97b-98b\n" |
| 41 | " .long 99b-98b\n" |
jdl@freescale.com | dd56fdf | 2005-09-07 15:59:48 -0500 | [diff] [blame] | 42 | ".previous" |
| 43 | : "=r" (ret) : "i" (CPU_FTR_601)); |
| 44 | #endif |
| 45 | |
| 46 | return ret; |
| 47 | } |
| 48 | |
| 49 | #endif /* __KERNEL__ */ |
| 50 | #endif /* _ASM_POWERPC_TIMEX_H */ |