ACPI: thinkpad-acpi: clean up probing and move init to subdrivers
[wrt350n-kernel.git] / include / asm-i386 / tsc.h
blob84016ff481b9d2e5df72a2e8bb7411088d971d53
1 /*
2 * linux/include/asm-i386/tsc.h
4 * i386 TSC related functions
5 */
6 #ifndef _ASM_i386_TSC_H
7 #define _ASM_i386_TSC_H
9 #include <asm/processor.h>
12 * Standard way to access the cycle counter.
14 typedef unsigned long long cycles_t;
16 extern unsigned int cpu_khz;
17 extern unsigned int tsc_khz;
19 static inline cycles_t get_cycles(void)
21 unsigned long long ret = 0;
23 #ifndef CONFIG_X86_TSC
24 if (!cpu_has_tsc)
25 return 0;
26 #endif
28 #if defined(CONFIG_X86_GENERIC) || defined(CONFIG_X86_TSC)
29 rdtscll(ret);
30 #endif
31 return ret;
34 /* Like get_cycles, but make sure the CPU is synchronized. */
35 static __always_inline cycles_t get_cycles_sync(void)
37 unsigned long long ret;
38 #ifdef X86_FEATURE_SYNC_RDTSC
39 unsigned eax;
42 * Don't do an additional sync on CPUs where we know
43 * RDTSC is already synchronous:
45 alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC,
46 "=a" (eax), "0" (1) : "ebx","ecx","edx","memory");
47 #else
48 sync_core();
49 #endif
50 rdtscll(ret);
52 return ret;
55 extern void tsc_init(void);
56 extern void mark_tsc_unstable(void);
57 extern int unsynchronized_tsc(void);
58 extern void init_tsc_clocksource(void);
61 * Boot-time check whether the TSCs are synchronized across
62 * all CPUs/cores:
64 extern void check_tsc_sync_source(int cpu);
65 extern void check_tsc_sync_target(void);
67 #endif