blob: 5f209f111e59e3ad9c6e31bee8352623cacc3e68 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Ralf Baechled865bea2007-10-11 23:46:10 +01002/*
3 * i8253.c 8253/PIT functions
4 *
5 */
6#include <linux/clockchips.h>
Ralf Baechle334955e2011-06-01 19:04:57 +01007#include <linux/i8253.h>
Paul Gortmaker73bc2562011-07-23 16:30:40 -04008#include <linux/export.h>
Ralf Baechle631330f2009-06-19 14:05:26 +01009#include <linux/smp.h>
David Howellsca4d3e672010-10-07 14:08:54 +010010#include <linux/irq.h>
Ralf Baechled865bea2007-10-11 23:46:10 +010011
Ralf Baechledd3db6e2007-11-01 14:38:20 +000012#include <asm/time.h>
Ralf Baechled865bea2007-10-11 23:46:10 +010013
Ralf Baechledd3db6e2007-11-01 14:38:20 +000014static irqreturn_t timer_interrupt(int irq, void *dev_id)
Ralf Baechled865bea2007-10-11 23:46:10 +010015{
Thomas Gleixnerded7c1e2011-07-22 11:17:11 +020016 i8253_clockevent.event_handler(&i8253_clockevent);
Ralf Baechled865bea2007-10-11 23:46:10 +010017
18 return IRQ_HANDLED;
19}
20
21static struct irqaction irq0 = {
22 .handler = timer_interrupt,
Yong Zhang8b5690f2011-11-22 14:38:03 +000023 .flags = IRQF_NOBALANCING | IRQF_TIMER,
Ralf Baechled865bea2007-10-11 23:46:10 +010024 .name = "timer"
25};
26
Ralf Baechled865bea2007-10-11 23:46:10 +010027void __init setup_pit_timer(void)
28{
Thomas Gleixner2d026122011-06-09 13:08:27 +000029 clockevent_i8253_init(true);
Ralf Baechled865bea2007-10-11 23:46:10 +010030 setup_irq(0, &irq0);
31}
32
Ralf Baechled865bea2007-10-11 23:46:10 +010033static int __init init_pit_clocksource(void)
34{
35 if (num_possible_cpus() > 1) /* PIT does not scale! */
36 return 0;
37
Russell King798778b2011-05-08 19:03:03 +010038 return clocksource_i8253_init();
Ralf Baechled865bea2007-10-11 23:46:10 +010039}
40arch_initcall(init_pit_clocksource);