Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * i8253.c 8253/PIT functions |
| 3 | * |
| 4 | */ |
| 5 | #include <linux/clockchips.h> |
Ralf Baechle | 334955e | 2011-06-01 19:04:57 +0100 | [diff] [blame] | 6 | #include <linux/i8253.h> |
Paul Gortmaker | 73bc256 | 2011-07-23 16:30:40 -0400 | [diff] [blame] | 7 | #include <linux/export.h> |
Ralf Baechle | 631330f | 2009-06-19 14:05:26 +0100 | [diff] [blame] | 8 | #include <linux/smp.h> |
David Howells | ca4d3e67 | 2010-10-07 14:08:54 +0100 | [diff] [blame] | 9 | #include <linux/irq.h> |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 10 | |
Ralf Baechle | dd3db6e | 2007-11-01 14:38:20 +0000 | [diff] [blame] | 11 | #include <asm/time.h> |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 12 | |
Ralf Baechle | dd3db6e | 2007-11-01 14:38:20 +0000 | [diff] [blame] | 13 | static irqreturn_t timer_interrupt(int irq, void *dev_id) |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 14 | { |
Thomas Gleixner | ded7c1e | 2011-07-22 11:17:11 +0200 | [diff] [blame] | 15 | i8253_clockevent.event_handler(&i8253_clockevent); |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 16 | |
| 17 | return IRQ_HANDLED; |
| 18 | } |
| 19 | |
| 20 | static struct irqaction irq0 = { |
| 21 | .handler = timer_interrupt, |
Yong Zhang | 8b5690f | 2011-11-22 14:38:03 +0000 | [diff] [blame] | 22 | .flags = IRQF_NOBALANCING | IRQF_TIMER, |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 23 | .name = "timer" |
| 24 | }; |
| 25 | |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 26 | void __init setup_pit_timer(void) |
| 27 | { |
Thomas Gleixner | 2d02612 | 2011-06-09 13:08:27 +0000 | [diff] [blame] | 28 | clockevent_i8253_init(true); |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 29 | setup_irq(0, &irq0); |
| 30 | } |
| 31 | |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 32 | static int __init init_pit_clocksource(void) |
| 33 | { |
| 34 | if (num_possible_cpus() > 1) /* PIT does not scale! */ |
| 35 | return 0; |
| 36 | |
Russell King | 798778b | 2011-05-08 19:03:03 +0100 | [diff] [blame] | 37 | return clocksource_i8253_init(); |
Ralf Baechle | d865bea | 2007-10-11 23:46:10 +0100 | [diff] [blame] | 38 | } |
| 39 | arch_initcall(init_pit_clocksource); |