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