i8253.c 968 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * 8253/PIT functions
  3. *
  4. */
  5. #include <linux/clockchips.h>
  6. #include <linux/module.h>
  7. #include <linux/timex.h>
  8. #include <linux/i8253.h>
  9. #include <asm/hpet.h>
  10. #include <asm/time.h>
  11. #include <asm/smp.h>
  12. /*
  13. * HPET replaces the PIT, when enabled. So we need to know, which of
  14. * the two timers is used
  15. */
  16. struct clock_event_device *global_clock_event;
  17. void __init setup_pit_timer(void)
  18. {
  19. clockevent_i8253_init(true);
  20. global_clock_event = &i8253_clockevent;
  21. }
  22. #ifndef CONFIG_X86_64
  23. static int __init init_pit_clocksource(void)
  24. {
  25. /*
  26. * Several reasons not to register PIT as a clocksource:
  27. *
  28. * - On SMP PIT does not scale due to i8253_lock
  29. * - when HPET is enabled
  30. * - when local APIC timer is active (PIT is switched off)
  31. */
  32. if (num_possible_cpus() > 1 || is_hpet_enabled() ||
  33. !clockevent_state_periodic(&i8253_clockevent))
  34. return 0;
  35. return clocksource_i8253_init();
  36. }
  37. arch_initcall(init_pit_clocksource);
  38. #endif /* !CONFIG_X86_64 */