License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / arch / x86 / kernel / i8253.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
8d016ef1 2/*
835c34a1 3 * 8253/PIT functions
8d016ef1 4 *
5 */
e9e2cdb4 6#include <linux/clockchips.h>
186f4360 7#include <linux/init.h>
08604bd9 8#include <linux/timex.h>
334955ef 9#include <linux/i8253.h>
8d016ef1 10
4713e22c 11#include <asm/hpet.h>
16f871bc 12#include <asm/time.h>
c8344bc2 13#include <asm/smp.h>
8d016ef1 14
e9e2cdb4
TG
15/*
16 * HPET replaces the PIT, when enabled. So we need to know, which of
17 * the two timers is used
18 */
19struct clock_event_device *global_clock_event;
20
e9e2cdb4
TG
21void __init setup_pit_timer(void)
22{
0a779c57
TG
23 clockevent_i8253_init(true);
24 global_clock_event = &i8253_clockevent;
8d016ef1 25}
5d0cf410 26
f5e0e93f 27#ifndef CONFIG_X86_64
5d0cf410 28static int __init init_pit_clocksource(void)
29{
316da3b3
TG
30 /*
31 * Several reasons not to register PIT as a clocksource:
32 *
33 * - On SMP PIT does not scale due to i8253_lock
34 * - when HPET is enabled
35 * - when local APIC timer is active (PIT is switched off)
36 */
37 if (num_possible_cpus() > 1 || is_hpet_enabled() ||
8eda41b0 38 !clockevent_state_periodic(&i8253_clockevent))
5d0cf410 39 return 0;
40
82491451 41 return clocksource_i8253_init();
5d0cf410 42}
6bb74df4 43arch_initcall(init_pit_clocksource);
c8344bc2 44#endif /* !CONFIG_X86_64 */