2006-06-26 07:25:09 +00:00
|
|
|
/*
|
2007-10-13 01:10:53 +00:00
|
|
|
* 8253/PIT functions
|
2006-06-26 07:25:09 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-02-16 09:28:04 +00:00
|
|
|
#include <linux/clockchips.h>
|
2006-06-26 07:25:09 +00:00
|
|
|
#include <linux/module.h>
|
2009-06-16 22:31:12 +00:00
|
|
|
#include <linux/timex.h>
|
2011-06-01 18:04:57 +00:00
|
|
|
#include <linux/i8253.h>
|
2006-06-26 07:25:09 +00:00
|
|
|
|
2008-01-30 12:30:02 +00:00
|
|
|
#include <asm/hpet.h>
|
2011-06-01 18:05:06 +00:00
|
|
|
#include <asm/time.h>
|
2009-03-21 11:26:10 +00:00
|
|
|
#include <asm/smp.h>
|
2006-06-26 07:25:09 +00:00
|
|
|
|
2007-02-16 09:28:04 +00:00
|
|
|
/*
|
|
|
|
* HPET replaces the PIT, when enabled. So we need to know, which of
|
|
|
|
* the two timers is used
|
|
|
|
*/
|
|
|
|
struct clock_event_device *global_clock_event;
|
|
|
|
|
|
|
|
void __init setup_pit_timer(void)
|
|
|
|
{
|
2011-06-09 13:08:26 +00:00
|
|
|
clockevent_i8253_init(true);
|
|
|
|
global_clock_event = &i8253_clockevent;
|
2006-06-26 07:25:09 +00:00
|
|
|
}
|
2006-06-26 07:25:12 +00:00
|
|
|
|
2007-10-12 21:04:06 +00:00
|
|
|
#ifndef CONFIG_X86_64
|
2006-06-26 07:25:12 +00:00
|
|
|
static int __init init_pit_clocksource(void)
|
|
|
|
{
|
2008-01-30 12:30:02 +00:00
|
|
|
/*
|
|
|
|
* Several reasons not to register PIT as a clocksource:
|
|
|
|
*
|
|
|
|
* - On SMP PIT does not scale due to i8253_lock
|
|
|
|
* - when HPET is enabled
|
|
|
|
* - when local APIC timer is active (PIT is switched off)
|
|
|
|
*/
|
|
|
|
if (num_possible_cpus() > 1 || is_hpet_enabled() ||
|
2011-06-09 13:08:26 +00:00
|
|
|
i8253_clockevent.mode != CLOCK_EVT_MODE_PERIODIC)
|
2006-06-26 07:25:12 +00:00
|
|
|
return 0;
|
|
|
|
|
2011-05-08 17:55:19 +00:00
|
|
|
return clocksource_i8253_init();
|
2006-06-26 07:25:12 +00:00
|
|
|
}
|
2007-03-05 08:30:50 +00:00
|
|
|
arch_initcall(init_pit_clocksource);
|
2009-03-21 11:26:10 +00:00
|
|
|
#endif /* !CONFIG_X86_64 */
|