0001
0002
0003
0004
0005
0006 #include <linux/clockchips.h>
0007 #include <linux/init.h>
0008 #include <linux/timex.h>
0009 #include <linux/i8253.h>
0010
0011 #include <asm/apic.h>
0012 #include <asm/hpet.h>
0013 #include <asm/time.h>
0014 #include <asm/smp.h>
0015
0016
0017
0018
0019
0020 struct clock_event_device *global_clock_event;
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 static bool __init use_pit(void)
0032 {
0033 if (!IS_ENABLED(CONFIG_X86_TSC) || !boot_cpu_has(X86_FEATURE_TSC))
0034 return true;
0035
0036
0037 return apic_needs_pit();
0038 }
0039
0040 bool __init pit_timer_init(void)
0041 {
0042 if (!use_pit())
0043 return false;
0044
0045 clockevent_i8253_init(true);
0046 global_clock_event = &i8253_clockevent;
0047 return true;
0048 }
0049
0050 #ifndef CONFIG_X86_64
0051 static int __init init_pit_clocksource(void)
0052 {
0053
0054
0055
0056
0057
0058
0059
0060 if (num_possible_cpus() > 1 || is_hpet_enabled() ||
0061 !clockevent_state_periodic(&i8253_clockevent))
0062 return 0;
0063
0064 return clocksource_i8253_init();
0065 }
0066 arch_initcall(init_pit_clocksource);
0067 #endif