Linux Audio

Check our new training course

In-person Linux kernel drivers training

Jun 16-20, 2025
Register
Loading...
v4.17
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * 8253/PIT functions
 4 *
 5 */
 6#include <linux/clockchips.h>
 7#include <linux/init.h>
 8#include <linux/timex.h>
 9#include <linux/i8253.h>
10
11#include <asm/hpet.h>
12#include <asm/time.h>
13#include <asm/smp.h>
14
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
21void __init setup_pit_timer(void)
22{
23	clockevent_i8253_init(true);
24	global_clock_event = &i8253_clockevent;
25}
26
27#ifndef CONFIG_X86_64
28static int __init init_pit_clocksource(void)
29{
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() ||
38	    !clockevent_state_periodic(&i8253_clockevent))
39		return 0;
40
41	return clocksource_i8253_init();
42}
43arch_initcall(init_pit_clocksource);
44#endif /* !CONFIG_X86_64 */
v3.5.6
 
 1/*
 2 * 8253/PIT functions
 3 *
 4 */
 5#include <linux/clockchips.h>
 6#include <linux/module.h>
 7#include <linux/timex.h>
 8#include <linux/i8253.h>
 9
10#include <asm/hpet.h>
11#include <asm/time.h>
12#include <asm/smp.h>
13
14/*
15 * HPET replaces the PIT, when enabled. So we need to know, which of
16 * the two timers is used
17 */
18struct clock_event_device *global_clock_event;
19
20void __init setup_pit_timer(void)
21{
22	clockevent_i8253_init(true);
23	global_clock_event = &i8253_clockevent;
24}
25
26#ifndef CONFIG_X86_64
27static int __init init_pit_clocksource(void)
28{
29	 /*
30	  * Several reasons not to register PIT as a clocksource:
31	  *
32	  * - On SMP PIT does not scale due to i8253_lock
33	  * - when HPET is enabled
34	  * - when local APIC timer is active (PIT is switched off)
35	  */
36	if (num_possible_cpus() > 1 || is_hpet_enabled() ||
37	    i8253_clockevent.mode != CLOCK_EVT_MODE_PERIODIC)
38		return 0;
39
40	return clocksource_i8253_init();
41}
42arch_initcall(init_pit_clocksource);
43#endif /* !CONFIG_X86_64 */