blob: 8d95fe4f48713296930c2af8a937ead1472012ed [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>
Ralf Baechled865bea2007-10-11 23:46:10 +01007#include <linux/module.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 Gleixner2d026122011-06-09 13:08:27 +000015 i8253_clockevent.event_handler(&pit_clockevent);
Ralf Baechled865bea2007-10-11 23:46:10 +010016
17 return IRQ_HANDLED;
18}
19
20static struct irqaction irq0 = {
21 .handler = timer_interrupt,
Wu Zhangjinf45e5182009-10-08 21:17:54 +080022 .flags = IRQF_DISABLED | 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{
34 if (num_possible_cpus() > 1) /* PIT does not scale! */
35 return 0;
36
Russell King798778b2011-05-08 19:03:03 +010037 return clocksource_i8253_init();
Ralf Baechled865bea2007-10-11 23:46:10 +010038}
39arch_initcall(init_pit_clocksource);