stm32-lptimer.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * STM32 Low-Power Timer parent driver.
  4. * Copyright (C) STMicroelectronics 2017
  5. * Author: Fabrice Gasnier <[email protected]>
  6. * Inspired by Benjamin Gaignard's stm32-timers driver
  7. */
  8. #ifndef _LINUX_STM32_LPTIMER_H_
  9. #define _LINUX_STM32_LPTIMER_H_
  10. #include <linux/clk.h>
  11. #include <linux/regmap.h>
  12. #define STM32_LPTIM_ISR 0x00 /* Interrupt and Status Reg */
  13. #define STM32_LPTIM_ICR 0x04 /* Interrupt Clear Reg */
  14. #define STM32_LPTIM_IER 0x08 /* Interrupt Enable Reg */
  15. #define STM32_LPTIM_CFGR 0x0C /* Configuration Reg */
  16. #define STM32_LPTIM_CR 0x10 /* Control Reg */
  17. #define STM32_LPTIM_CMP 0x14 /* Compare Reg */
  18. #define STM32_LPTIM_ARR 0x18 /* Autoreload Reg */
  19. #define STM32_LPTIM_CNT 0x1C /* Counter Reg */
  20. /* STM32_LPTIM_ISR - bit fields */
  21. #define STM32_LPTIM_CMPOK_ARROK GENMASK(4, 3)
  22. #define STM32_LPTIM_ARROK BIT(4)
  23. #define STM32_LPTIM_CMPOK BIT(3)
  24. /* STM32_LPTIM_ICR - bit fields */
  25. #define STM32_LPTIM_ARRMCF BIT(1)
  26. #define STM32_LPTIM_CMPOKCF_ARROKCF GENMASK(4, 3)
  27. /* STM32_LPTIM_IER - bit flieds */
  28. #define STM32_LPTIM_ARRMIE BIT(1)
  29. /* STM32_LPTIM_CR - bit fields */
  30. #define STM32_LPTIM_CNTSTRT BIT(2)
  31. #define STM32_LPTIM_SNGSTRT BIT(1)
  32. #define STM32_LPTIM_ENABLE BIT(0)
  33. /* STM32_LPTIM_CFGR - bit fields */
  34. #define STM32_LPTIM_ENC BIT(24)
  35. #define STM32_LPTIM_COUNTMODE BIT(23)
  36. #define STM32_LPTIM_WAVPOL BIT(21)
  37. #define STM32_LPTIM_PRESC GENMASK(11, 9)
  38. #define STM32_LPTIM_CKPOL GENMASK(2, 1)
  39. /* STM32_LPTIM_CKPOL */
  40. #define STM32_LPTIM_CKPOL_RISING_EDGE 0
  41. #define STM32_LPTIM_CKPOL_FALLING_EDGE 1
  42. #define STM32_LPTIM_CKPOL_BOTH_EDGES 2
  43. /* STM32_LPTIM_ARR */
  44. #define STM32_LPTIM_MAX_ARR 0xFFFF
  45. /**
  46. * struct stm32_lptimer - STM32 Low-Power Timer data assigned by parent device
  47. * @clk: clock reference for this instance
  48. * @regmap: register map reference for this instance
  49. * @has_encoder: indicates this Low-Power Timer supports encoder mode
  50. */
  51. struct stm32_lptimer {
  52. struct clk *clk;
  53. struct regmap *regmap;
  54. bool has_encoder;
  55. };
  56. #endif