i8253.c 1002 B

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