^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_X86_TIMER_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_X86_TIMER_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/math64.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define TICK_SIZE (tick_nsec / 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) unsigned long long native_sched_clock(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) extern void recalibrate_cpu_khz(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) extern int no_timer_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) extern bool using_native_sched_clock(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * We use the full linear equation: f(x) = a + b*x, in order to allow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * a continuous function in the face of dynamic freq changes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Continuity means that when our frequency changes our slope (b); we want to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * ensure that: f(t) == f'(t), which gives: a + b*t == a' + b'*t.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * Without an offset (a) the above would not be possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * See the comment near cycles_2_ns() for details on how we compute (b).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct cyc2ns_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u32 cyc2ns_mul;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u32 cyc2ns_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u64 cyc2ns_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }; /* 16 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) extern void cyc2ns_read_begin(struct cyc2ns_data *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) extern void cyc2ns_read_end(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #endif /* _ASM_X86_TIMER_H */