blob: f2b96de3c7c16dc45a36a6d4a8acd02d3b453b6a [file] [log] [blame]
john stultz8d016ef2006-06-26 00:25:09 -07001/*
Dave Jones835c34a2007-10-12 21:10:53 -04002 * 8253/PIT functions
john stultz8d016ef2006-06-26 00:25:09 -07003 *
4 */
Thomas Gleixnere9e2cdb2007-02-16 01:28:04 -08005#include <linux/clockchips.h>
Thomas Gleixner18de5bc2007-07-21 04:37:34 -07006#include <linux/module.h>
Arnd Bergmann08604bd2009-06-16 15:31:12 -07007#include <linux/timex.h>
Ralf Baechle334955e2011-06-01 19:04:57 +01008#include <linux/i8253.h>
john stultz8d016ef2006-06-26 00:25:09 -07009
Thomas Gleixner4713e22c2008-01-30 13:30:02 +010010#include <asm/hpet.h>
Ralf Baechle16f871b2011-06-01 19:05:06 +010011#include <asm/time.h>
Jaswinder Singh Rajputc8344bc2009-03-21 16:56:10 +053012#include <asm/smp.h>
john stultz8d016ef2006-06-26 00:25:09 -070013
Thomas Gleixnere9e2cdb2007-02-16 01:28:04 -080014/*
15 * HPET replaces the PIT, when enabled. So we need to know, which of
16 * the two timers is used
17 */
18struct clock_event_device *global_clock_event;
19
Thomas Gleixnere9e2cdb2007-02-16 01:28:04 -080020void __init setup_pit_timer(void)
21{
Thomas Gleixner0a779c52011-06-09 13:08:26 +000022 clockevent_i8253_init(true);
23 global_clock_event = &i8253_clockevent;
Thomas Gleixnere9e2cdb2007-02-16 01:28:04 -080024}
25
Thomas Gleixnerf5e0e932007-10-12 23:04:06 +020026#ifndef CONFIG_X86_64
john stultz5d0cf412006-06-26 00:25:12 -070027static int __init init_pit_clocksource(void)
28{
Thomas Gleixner316da3b2008-01-30 13:30:02 +010029 /*
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 Gleixner0a779c52011-06-09 13:08:26 +000037 i8253_clockevent.mode != CLOCK_EVT_MODE_PERIODIC)
john stultz5d0cf412006-06-26 00:25:12 -070038 return 0;
39
Russell King82491452011-05-08 18:55:19 +010040 return clocksource_i8253_init();
john stultz5d0cf412006-06-26 00:25:12 -070041}
john stultz6bb74df2007-03-05 00:30:50 -080042arch_initcall(init_pit_clocksource);
Jaswinder Singh Rajputc8344bc2009-03-21 16:56:10 +053043#endif /* !CONFIG_X86_64 */