timex.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2001 - 2013 Tensilica Inc.
  7. */
  8. #ifndef _XTENSA_TIMEX_H
  9. #define _XTENSA_TIMEX_H
  10. #include <asm/processor.h>
  11. #if XCHAL_NUM_TIMERS > 0 && \
  12. XTENSA_INT_LEVEL(XCHAL_TIMER0_INTERRUPT) <= XCHAL_EXCM_LEVEL
  13. # define LINUX_TIMER 0
  14. # define LINUX_TIMER_INT XCHAL_TIMER0_INTERRUPT
  15. #elif XCHAL_NUM_TIMERS > 1 && \
  16. XTENSA_INT_LEVEL(XCHAL_TIMER1_INTERRUPT) <= XCHAL_EXCM_LEVEL
  17. # define LINUX_TIMER 1
  18. # define LINUX_TIMER_INT XCHAL_TIMER1_INTERRUPT
  19. #elif XCHAL_NUM_TIMERS > 2 && \
  20. XTENSA_INT_LEVEL(XCHAL_TIMER2_INTERRUPT) <= XCHAL_EXCM_LEVEL
  21. # define LINUX_TIMER 2
  22. # define LINUX_TIMER_INT XCHAL_TIMER2_INTERRUPT
  23. #else
  24. # error "Bad timer number for Linux configurations!"
  25. #endif
  26. extern unsigned long ccount_freq;
  27. void local_timer_setup(unsigned cpu);
  28. /*
  29. * Register access.
  30. */
  31. static inline unsigned long get_ccount (void)
  32. {
  33. return xtensa_get_sr(ccount);
  34. }
  35. static inline void set_ccount (unsigned long ccount)
  36. {
  37. xtensa_set_sr(ccount, ccount);
  38. }
  39. static inline unsigned long get_linux_timer (void)
  40. {
  41. return xtensa_get_sr(SREG_CCOMPARE + LINUX_TIMER);
  42. }
  43. static inline void set_linux_timer (unsigned long ccompare)
  44. {
  45. xtensa_set_sr(ccompare, SREG_CCOMPARE + LINUX_TIMER);
  46. }
  47. #include <asm-generic/timex.h>
  48. #endif /* _XTENSA_TIMEX_H */