blob: 73039746ae364536127502e2f4a931dd4293056f [file] [log] [blame]
Ralf Baechled865bea2007-10-11 23:46:10 +01001/*
2 * i8253.c 8253/PIT functions
3 *
4 */
5#include <linux/clockchips.h>
Ralf Baechle334955e2011-06-01 19:04:57 +01006#include <linux/i8253.h>
Paul Gortmaker73bc2562011-07-23 16:30:40 -04007#include <linux/export.h>
Ralf Baechle631330f2009-06-19 14:05:26 +01008#include <linux/smp.h>
David Howellsca4d3e672010-10-07 14:08:54 +01009#include <linux/irq.h>
Ralf Baechled865bea2007-10-11 23:46:10 +010010
Ralf Baechledd3db6e2007-11-01 14:38:20 +000011#include <asm/time.h>
Ralf Baechled865bea2007-10-11 23:46:10 +010012
Ralf Baechledd3db6e2007-11-01 14:38:20 +000013static irqreturn_t timer_interrupt(int irq, void *dev_id)
Ralf Baechled865bea2007-10-11 23:46:10 +010014{
Thomas Gleixnerded7c1e2011-07-22 11:17:11 +020015 i8253_clockevent.event_handler(&i8253_clockevent);
Ralf Baechled865bea2007-10-11 23:46:10 +010016
17 return IRQ_HANDLED;
18}
19
20static struct irqaction irq0 = {
21 .handler = timer_interrupt,
Yong Zhang8b5690f2011-11-22 14:38:03 +000022 .flags = IRQF_NOBALANCING | IRQF_TIMER,
Ralf Baechled865bea2007-10-11 23:46:10 +010023 .name = "timer"
24};
25
Ralf Baechled865bea2007-10-11 23:46:10 +010026void __init setup_pit_timer(void)
27{
Thomas Gleixner2d026122011-06-09 13:08:27 +000028 clockevent_i8253_init(true);
Ralf Baechled865bea2007-10-11 23:46:10 +010029 setup_irq(0, &irq0);
30}
31
Ralf Baechled865bea2007-10-11 23:46:10 +010032static int __init init_pit_clocksource(void)
33{
Thomas Bogendoerfer6f2a9a22019-05-13 13:47:25 +020034 if (num_possible_cpus() > 1 || /* PIT does not scale! */
35 !clockevent_state_periodic(&i8253_clockevent))
Ralf Baechled865bea2007-10-11 23:46:10 +010036 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);