31
29
* which isn't an evil thing.
33
31
* We know that all SMP capable CPUs have cycle counters.
35
* Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
36
* HAVE_GET_CYCLES makes sure that this case is handled properly :
38
* Ralf Baechle <ralf@linux-mips.org> :
39
* This avoids us executing an mfc0 c0_count instruction on processors which
40
* don't have but also on certain R4000 and R4400 versions where reading from
41
* the count register just in the very moment when its value equals c0_compare
42
* will result in the timer interrupt getting lost.
45
#ifdef CONFIG_HAVE_GET_CYCLES
46
# ifdef CONFIG_CPU_CAVIUM_OCTEON
47
typedef unsigned long cycles_t;
49
static inline cycles_t get_cycles(void)
51
return read_c0_cvmcount();
54
static inline void get_cycles_barrier(void)
58
static inline cycles_t get_cycles_rate(void)
60
return mips_hpt_frequency;
63
extern int test_tsc_synchronization(void);
64
extern int _tsc_is_sync;
65
static inline int tsc_is_sync(void)
69
# else /* #ifdef CONFIG_CPU_CAVIUM_OCTEON */
70
# error "64-bit get_cycles() supported only on Cavium Octeon MIPS architectures"
71
# endif /* #else #ifdef CONFIG_CPU_CAVIUM_OCTEON */
72
#elif defined(CONFIG_HAVE_GET_CYCLES_32)
73
typedef unsigned int cycles_t;
75
static inline cycles_t get_cycles(void)
77
return read_c0_count();
80
static inline void get_cycles_barrier(void)
84
static inline cycles_t get_cycles_rate(void)
86
return mips_hpt_frequency;
89
extern int test_tsc_synchronization(void);
90
extern int _tsc_is_sync;
91
static inline int tsc_is_sync(void)
96
typedef unsigned int cycles_t;
98
static inline cycles_t get_cycles(void)
102
static inline int test_tsc_synchronization(void)
106
static inline int tsc_is_sync(void)
112
#define DELAY_INTERRUPT 100
114
* Only updates 32 LSB.
116
static inline void write_tsc(u32 val1, u32 val2)
118
write_c0_count(val1);
119
/* Arrange for an interrupt in a short while */
120
write_c0_compare(read_c0_count() + DELAY_INTERRUPT);
124
* Currently unused, should update internal tsc-related timekeeping sources.
126
static inline void mark_tsc_unstable(char *reason)
131
* Currently simply use the tsc_is_sync value.
133
static inline int unsynchronized_tsc(void)
135
return !tsc_is_sync();
34
typedef unsigned int cycles_t;
36
static inline cycles_t get_cycles(void)
138
41
#endif /* __KERNEL__ */