xref: /openbmc/linux/arch/x86/include/asm/timer.h (revision b2441318)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21965aae3SH. Peter Anvin #ifndef _ASM_X86_TIMER_H
31965aae3SH. Peter Anvin #define _ASM_X86_TIMER_H
4bb898558SAl Viro #include <linux/pm.h>
5bb898558SAl Viro #include <linux/percpu.h>
68e6dafd6SIngo Molnar #include <linux/interrupt.h>
75dd12c21SPeter Zijlstra #include <linux/math64.h>
8bb898558SAl Viro 
9bb898558SAl Viro #define TICK_SIZE (tick_nsec / 1000)
10bb898558SAl Viro 
11bb898558SAl Viro unsigned long long native_sched_clock(void);
1225c1a411SStephen Rothwell extern void recalibrate_cpu_khz(void);
13bb898558SAl Viro 
14bb898558SAl Viro extern int no_timer_check;
15bb898558SAl Viro 
16698eff63SPeter Zijlstra extern bool using_native_sched_clock(void);
17698eff63SPeter Zijlstra 
1820d1c86aSPeter Zijlstra /*
1920d1c86aSPeter Zijlstra  * We use the full linear equation: f(x) = a + b*x, in order to allow
2020d1c86aSPeter Zijlstra  * a continuous function in the face of dynamic freq changes.
2120d1c86aSPeter Zijlstra  *
2220d1c86aSPeter Zijlstra  * Continuity means that when our frequency changes our slope (b); we want to
2320d1c86aSPeter Zijlstra  * ensure that: f(t) == f'(t), which gives: a + b*t == a' + b'*t.
2420d1c86aSPeter Zijlstra  *
2520d1c86aSPeter Zijlstra  * Without an offset (a) the above would not be possible.
2620d1c86aSPeter Zijlstra  *
2720d1c86aSPeter Zijlstra  * See the comment near cycles_2_ns() for details on how we compute (b).
2820d1c86aSPeter Zijlstra  */
2920d1c86aSPeter Zijlstra struct cyc2ns_data {
3020d1c86aSPeter Zijlstra 	u32 cyc2ns_mul;
3120d1c86aSPeter Zijlstra 	u32 cyc2ns_shift;
3220d1c86aSPeter Zijlstra 	u64 cyc2ns_offset;
3359eaef78SPeter Zijlstra }; /* 16 bytes */
3420d1c86aSPeter Zijlstra 
3559eaef78SPeter Zijlstra extern void cyc2ns_read_begin(struct cyc2ns_data *);
3659eaef78SPeter Zijlstra extern void cyc2ns_read_end(void);
37bb898558SAl Viro 
381965aae3SH. Peter Anvin #endif /* _ASM_X86_TIMER_H */
39