rtc.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2014-2019 MediaTek Inc.
  4. *
  5. * Author: Tianping.Fang <[email protected]>
  6. * Sean Wang <[email protected]>
  7. */
  8. #ifndef _LINUX_MFD_MT6397_RTC_H_
  9. #define _LINUX_MFD_MT6397_RTC_H_
  10. #include <linux/jiffies.h>
  11. #include <linux/mutex.h>
  12. #include <linux/regmap.h>
  13. #include <linux/rtc.h>
  14. #define RTC_BBPU 0x0000
  15. #define RTC_BBPU_CBUSY BIT(6)
  16. #define RTC_BBPU_KEY (0x43 << 8)
  17. #define RTC_WRTGR_MT6358 0x003a
  18. #define RTC_WRTGR_MT6397 0x003c
  19. #define RTC_WRTGR_MT6323 RTC_WRTGR_MT6397
  20. #define RTC_IRQ_STA 0x0002
  21. #define RTC_IRQ_STA_AL BIT(0)
  22. #define RTC_IRQ_STA_LP BIT(3)
  23. #define RTC_IRQ_EN 0x0004
  24. #define RTC_IRQ_EN_AL BIT(0)
  25. #define RTC_IRQ_EN_ONESHOT BIT(2)
  26. #define RTC_IRQ_EN_LP BIT(3)
  27. #define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL)
  28. #define RTC_AL_MASK 0x0008
  29. #define RTC_AL_MASK_DOW BIT(4)
  30. #define RTC_TC_SEC 0x000a
  31. #define RTC_TC_MTH_MASK 0x000f
  32. /* Min, Hour, Dom... register offset to RTC_TC_SEC */
  33. #define RTC_OFFSET_SEC 0
  34. #define RTC_OFFSET_MIN 1
  35. #define RTC_OFFSET_HOUR 2
  36. #define RTC_OFFSET_DOM 3
  37. #define RTC_OFFSET_DOW 4
  38. #define RTC_OFFSET_MTH 5
  39. #define RTC_OFFSET_YEAR 6
  40. #define RTC_OFFSET_COUNT 7
  41. #define RTC_AL_SEC 0x0018
  42. #define RTC_AL_SEC_MASK 0x003f
  43. #define RTC_AL_MIN_MASK 0x003f
  44. #define RTC_AL_HOU_MASK 0x001f
  45. #define RTC_AL_DOM_MASK 0x001f
  46. #define RTC_AL_DOW_MASK 0x0007
  47. #define RTC_AL_MTH_MASK 0x000f
  48. #define RTC_AL_YEA_MASK 0x007f
  49. #define RTC_PDN2 0x002e
  50. #define RTC_PDN2_PWRON_ALARM BIT(4)
  51. #define RTC_MIN_YEAR 1968
  52. #define RTC_BASE_YEAR 1900
  53. #define RTC_NUM_YEARS 128
  54. #define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR)
  55. #define MTK_RTC_POLL_DELAY_US 10
  56. #define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ))
  57. struct mtk_rtc_data {
  58. u32 wrtgr;
  59. };
  60. struct mt6397_rtc {
  61. struct rtc_device *rtc_dev;
  62. /* Protect register access from multiple tasks */
  63. struct mutex lock;
  64. struct regmap *regmap;
  65. int irq;
  66. u32 addr_base;
  67. const struct mtk_rtc_data *data;
  68. };
  69. #endif /* _LINUX_MFD_MT6397_RTC_H_ */