forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/arch/x86/kernel/i8253.c
....@@ -8,6 +8,7 @@
88 #include <linux/timex.h>
99 #include <linux/i8253.h>
1010
11
+#include <asm/apic.h>
1112 #include <asm/hpet.h>
1213 #include <asm/time.h>
1314 #include <asm/smp.h>
....@@ -18,10 +19,32 @@
1819 */
1920 struct clock_event_device *global_clock_event;
2021
21
-void __init setup_pit_timer(void)
22
+/*
23
+ * Modern chipsets can disable the PIT clock which makes it unusable. It
24
+ * would be possible to enable the clock but the registers are chipset
25
+ * specific and not discoverable. Avoid the whack a mole game.
26
+ *
27
+ * These platforms have discoverable TSC/CPU frequencies but this also
28
+ * requires to know the local APIC timer frequency as it normally is
29
+ * calibrated against the PIT interrupt.
30
+ */
31
+static bool __init use_pit(void)
2232 {
33
+ if (!IS_ENABLED(CONFIG_X86_TSC) || !boot_cpu_has(X86_FEATURE_TSC))
34
+ return true;
35
+
36
+ /* This also returns true when APIC is disabled */
37
+ return apic_needs_pit();
38
+}
39
+
40
+bool __init pit_timer_init(void)
41
+{
42
+ if (!use_pit())
43
+ return false;
44
+
2345 clockevent_i8253_init(true);
2446 global_clock_event = &i8253_clockevent;
47
+ return true;
2548 }
2649
2750 #ifndef CONFIG_X86_64