time.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2001, 2002, MontaVista Software Inc.
  4. * Author: Jun Sun, [email protected] or [email protected]
  5. * Copyright (c) 2003 Maciej W. Rozycki
  6. *
  7. * include/asm-mips/time.h
  8. * header file for the new style time.c file and time services.
  9. */
  10. #ifndef _ASM_TIME_H
  11. #define _ASM_TIME_H
  12. #include <linux/rtc.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/clockchips.h>
  15. #include <linux/clocksource.h>
  16. extern spinlock_t rtc_lock;
  17. /*
  18. * board specific routines required by time_init().
  19. */
  20. extern void plat_time_init(void);
  21. /*
  22. * mips_hpt_frequency - must be set if you intend to use an R4k-compatible
  23. * counter as a timer interrupt source.
  24. */
  25. extern unsigned int mips_hpt_frequency;
  26. /*
  27. * The performance counter IRQ on MIPS is a close relative to the timer IRQ
  28. * so it lives here.
  29. */
  30. extern int (*perf_irq)(void);
  31. extern int __weak get_c0_perfcount_int(void);
  32. /*
  33. * Initialize the calling CPU's compare interrupt as clockevent device
  34. */
  35. extern unsigned int get_c0_compare_int(void);
  36. extern int r4k_clockevent_init(void);
  37. static inline int mips_clockevent_init(void)
  38. {
  39. #ifdef CONFIG_CEVT_R4K
  40. return r4k_clockevent_init();
  41. #else
  42. return -ENXIO;
  43. #endif
  44. }
  45. /*
  46. * Initialize the count register as a clocksource
  47. */
  48. extern int init_r4k_clocksource(void);
  49. static inline int init_mips_clocksource(void)
  50. {
  51. #ifdef CONFIG_CSRC_R4K
  52. return init_r4k_clocksource();
  53. #else
  54. return 0;
  55. #endif
  56. }
  57. static inline void clockevent_set_clock(struct clock_event_device *cd,
  58. unsigned int clock)
  59. {
  60. clockevents_calc_mult_shift(cd, clock, 4);
  61. }
  62. #endif /* _ASM_TIME_H */