File: i8253.c

package info (click to toggle)
linux 5.10.28-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,142,388 kB
  • sloc: ansic: 19,494,753; asm: 263,677; sh: 73,927; makefile: 44,698; perl: 34,644; python: 32,383; cpp: 6,070; yacc: 4,755; lex: 2,742; awk: 1,214; ruby: 25; sed: 5
file content (38 lines) | stat: -rw-r--r-- 839 bytes parent folder | download | duplicates (20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: GPL-2.0
/*
 * i8253.c  8253/PIT functions
 *
 */
#include <linux/clockchips.h>
#include <linux/i8253.h>
#include <linux/export.h>
#include <linux/smp.h>
#include <linux/irq.h>

#include <asm/time.h>

static irqreturn_t timer_interrupt(int irq, void *dev_id)
{
	i8253_clockevent.event_handler(&i8253_clockevent);

	return IRQ_HANDLED;
}

void __init setup_pit_timer(void)
{
	unsigned long flags = IRQF_NOBALANCING | IRQF_TIMER;

	clockevent_i8253_init(true);
	if (request_irq(0, timer_interrupt, flags, "timer", NULL))
		pr_err("Failed to request irq 0 (timer)\n");
}

static int __init init_pit_clocksource(void)
{
	if (num_possible_cpus() > 1 || /* PIT does not scale! */
	    !clockevent_state_periodic(&i8253_clockevent))
		return 0;

	return clocksource_i8253_init();
}
arch_initcall(init_pit_clocksource);