john stultz | 8d016ef | 2006-06-26 00:25:09 -0700 | [diff] [blame] | 1 | /* |
Dave Jones | 835c34a | 2007-10-12 21:10:53 -0400 | [diff] [blame] | 2 | * 8253/PIT functions |
john stultz | 8d016ef | 2006-06-26 00:25:09 -0700 | [diff] [blame] | 3 | * |
| 4 | */ |
Thomas Gleixner | e9e2cdb | 2007-02-16 01:28:04 -0800 | [diff] [blame] | 5 | #include <linux/clockchips.h> |
Thomas Gleixner | 18de5bc | 2007-07-21 04:37:34 -0700 | [diff] [blame] | 6 | #include <linux/module.h> |
Arnd Bergmann | 08604bd | 2009-06-16 15:31:12 -0700 | [diff] [blame] | 7 | #include <linux/timex.h> |
Ralf Baechle | 334955e | 2011-06-01 19:04:57 +0100 | [diff] [blame] | 8 | #include <linux/i8253.h> |
john stultz | 8d016ef | 2006-06-26 00:25:09 -0700 | [diff] [blame] | 9 | |
Thomas Gleixner | 4713e22c | 2008-01-30 13:30:02 +0100 | [diff] [blame] | 10 | #include <asm/hpet.h> |
Ralf Baechle | 16f871b | 2011-06-01 19:05:06 +0100 | [diff] [blame] | 11 | #include <asm/time.h> |
Jaswinder Singh Rajput | c8344bc | 2009-03-21 16:56:10 +0530 | [diff] [blame] | 12 | #include <asm/smp.h> |
john stultz | 8d016ef | 2006-06-26 00:25:09 -0700 | [diff] [blame] | 13 | |
Thomas Gleixner | e9e2cdb | 2007-02-16 01:28:04 -0800 | [diff] [blame] | 14 | /* |
| 15 | * HPET replaces the PIT, when enabled. So we need to know, which of |
| 16 | * the two timers is used |
| 17 | */ |
| 18 | struct clock_event_device *global_clock_event; |
| 19 | |
Thomas Gleixner | e9e2cdb | 2007-02-16 01:28:04 -0800 | [diff] [blame] | 20 | void __init setup_pit_timer(void) |
| 21 | { |
Thomas Gleixner | 0a779c5 | 2011-06-09 13:08:26 +0000 | [diff] [blame^] | 22 | clockevent_i8253_init(true); |
| 23 | global_clock_event = &i8253_clockevent; |
Thomas Gleixner | e9e2cdb | 2007-02-16 01:28:04 -0800 | [diff] [blame] | 24 | } |
| 25 | |
Thomas Gleixner | f5e0e93 | 2007-10-12 23:04:06 +0200 | [diff] [blame] | 26 | #ifndef CONFIG_X86_64 |
john stultz | 5d0cf41 | 2006-06-26 00:25:12 -0700 | [diff] [blame] | 27 | static int __init init_pit_clocksource(void) |
| 28 | { |
Thomas Gleixner | 316da3b | 2008-01-30 13:30:02 +0100 | [diff] [blame] | 29 | /* |
| 30 | * Several reasons not to register PIT as a clocksource: |
| 31 | * |
| 32 | * - On SMP PIT does not scale due to i8253_lock |
| 33 | * - when HPET is enabled |
| 34 | * - when local APIC timer is active (PIT is switched off) |
| 35 | */ |
| 36 | if (num_possible_cpus() > 1 || is_hpet_enabled() || |
Thomas Gleixner | 0a779c5 | 2011-06-09 13:08:26 +0000 | [diff] [blame^] | 37 | i8253_clockevent.mode != CLOCK_EVT_MODE_PERIODIC) |
john stultz | 5d0cf41 | 2006-06-26 00:25:12 -0700 | [diff] [blame] | 38 | return 0; |
| 39 | |
Russell King | 8249145 | 2011-05-08 18:55:19 +0100 | [diff] [blame] | 40 | return clocksource_i8253_init(); |
john stultz | 5d0cf41 | 2006-06-26 00:25:12 -0700 | [diff] [blame] | 41 | } |
john stultz | 6bb74df | 2007-03-05 00:30:50 -0800 | [diff] [blame] | 42 | arch_initcall(init_pit_clocksource); |
Jaswinder Singh Rajput | c8344bc | 2009-03-21 16:56:10 +0530 | [diff] [blame] | 43 | #endif /* !CONFIG_X86_64 */ |