timer.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2016 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _ASM_ARCH_TIMER_H
  7. #define _ASM_ARCH_TIMER_H
  8. /* Each timer has 4 control bits in ctrl1 register.
  9. * Timer1 uses bits 0:3, Timer2 uses bits 4:7 and so on,
  10. * such that timer X uses bits (4 * X - 4):(4 * X - 1)
  11. * If the timer does not support PWM, bit 4 is reserved.
  12. */
  13. #define AST_TMC_EN (1 << 0)
  14. #define AST_TMC_1MHZ (1 << 1)
  15. #define AST_TMC_OVFINTR (1 << 2)
  16. #define AST_TMC_PWM (1 << 3)
  17. /* Timers are counted from 1 in the datasheet. */
  18. #define AST_TMC_CTRL1_SHIFT(n) (4 * ((n) - 1))
  19. #define AST_TMC_RATE (1000*1000)
  20. #ifndef __ASSEMBLY__
  21. /*
  22. * All timers share control registers, which makes it harder to make them
  23. * separate devices. Since only one timer is needed at the moment, making
  24. * it this just one device.
  25. */
  26. struct ast_timer_counter {
  27. u32 status;
  28. u32 reload_val;
  29. u32 match1;
  30. u32 match2;
  31. };
  32. struct ast_timer {
  33. struct ast_timer_counter timers1[3];
  34. u32 ctrl1;
  35. u32 ctrl2;
  36. #ifdef CONFIG_ASPEED_AST2500
  37. u32 ctrl3;
  38. u32 ctrl1_clr;
  39. #else
  40. u32 reserved[2];
  41. #endif
  42. struct ast_timer_counter timers2[5];
  43. };
  44. #endif /* __ASSEMBLY__ */
  45. #endif /* _ASM_ARCH_TIMER_H */