timer.h 1.2 KB

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