rtc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* rtc.h
  2. *
  3. * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd
  4. * http://www.samsung.com
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #ifndef __LINUX_MFD_SEC_RTC_H
  18. #define __LINUX_MFD_SEC_RTC_H
  19. enum s5m_rtc_reg {
  20. S5M_RTC_SEC,
  21. S5M_RTC_MIN,
  22. S5M_RTC_HOUR,
  23. S5M_RTC_WEEKDAY,
  24. S5M_RTC_DATE,
  25. S5M_RTC_MONTH,
  26. S5M_RTC_YEAR1,
  27. S5M_RTC_YEAR2,
  28. S5M_ALARM0_SEC,
  29. S5M_ALARM0_MIN,
  30. S5M_ALARM0_HOUR,
  31. S5M_ALARM0_WEEKDAY,
  32. S5M_ALARM0_DATE,
  33. S5M_ALARM0_MONTH,
  34. S5M_ALARM0_YEAR1,
  35. S5M_ALARM0_YEAR2,
  36. S5M_ALARM1_SEC,
  37. S5M_ALARM1_MIN,
  38. S5M_ALARM1_HOUR,
  39. S5M_ALARM1_WEEKDAY,
  40. S5M_ALARM1_DATE,
  41. S5M_ALARM1_MONTH,
  42. S5M_ALARM1_YEAR1,
  43. S5M_ALARM1_YEAR2,
  44. S5M_ALARM0_CONF,
  45. S5M_ALARM1_CONF,
  46. S5M_RTC_STATUS,
  47. S5M_WTSR_SMPL_CNTL,
  48. S5M_RTC_UDR_CON,
  49. S5M_RTC_REG_MAX,
  50. };
  51. enum s2mps_rtc_reg {
  52. S2MPS_RTC_CTRL,
  53. S2MPS_WTSR_SMPL_CNTL,
  54. S2MPS_RTC_UDR_CON,
  55. S2MPS_RSVD,
  56. S2MPS_RTC_SEC,
  57. S2MPS_RTC_MIN,
  58. S2MPS_RTC_HOUR,
  59. S2MPS_RTC_WEEKDAY,
  60. S2MPS_RTC_DATE,
  61. S2MPS_RTC_MONTH,
  62. S2MPS_RTC_YEAR,
  63. S2MPS_ALARM0_SEC,
  64. S2MPS_ALARM0_MIN,
  65. S2MPS_ALARM0_HOUR,
  66. S2MPS_ALARM0_WEEKDAY,
  67. S2MPS_ALARM0_DATE,
  68. S2MPS_ALARM0_MONTH,
  69. S2MPS_ALARM0_YEAR,
  70. S2MPS_ALARM1_SEC,
  71. S2MPS_ALARM1_MIN,
  72. S2MPS_ALARM1_HOUR,
  73. S2MPS_ALARM1_WEEKDAY,
  74. S2MPS_ALARM1_DATE,
  75. S2MPS_ALARM1_MONTH,
  76. S2MPS_ALARM1_YEAR,
  77. S2MPS_OFFSRC,
  78. S2MPS_RTC_REG_MAX,
  79. };
  80. #define RTC_I2C_ADDR (0x0C >> 1)
  81. #define HOUR_12 (1 << 7)
  82. #define HOUR_AMPM (1 << 6)
  83. #define HOUR_PM (1 << 5)
  84. #define S5M_ALARM0_STATUS (1 << 1)
  85. #define S5M_ALARM1_STATUS (1 << 2)
  86. #define S5M_UPDATE_AD (1 << 0)
  87. #define S2MPS_ALARM0_STATUS (1 << 2)
  88. #define S2MPS_ALARM1_STATUS (1 << 1)
  89. /* RTC Control Register */
  90. #define BCD_EN_SHIFT 0
  91. #define BCD_EN_MASK (1 << BCD_EN_SHIFT)
  92. #define MODEL24_SHIFT 1
  93. #define MODEL24_MASK (1 << MODEL24_SHIFT)
  94. /* RTC Update Register1 */
  95. #define S5M_RTC_UDR_SHIFT 0
  96. #define S5M_RTC_UDR_MASK (1 << S5M_RTC_UDR_SHIFT)
  97. #define S2MPS_RTC_WUDR_SHIFT 4
  98. #define S2MPS_RTC_WUDR_MASK (1 << S2MPS_RTC_WUDR_SHIFT)
  99. #define S2MPS13_RTC_AUDR_SHIFT 1
  100. #define S2MPS13_RTC_AUDR_MASK (1 << S2MPS13_RTC_AUDR_SHIFT)
  101. #define S2MPS_RTC_RUDR_SHIFT 0
  102. #define S2MPS_RTC_RUDR_MASK (1 << S2MPS_RTC_RUDR_SHIFT)
  103. #define RTC_TCON_SHIFT 1
  104. #define RTC_TCON_MASK (1 << RTC_TCON_SHIFT)
  105. #define S5M_RTC_TIME_EN_SHIFT 3
  106. #define S5M_RTC_TIME_EN_MASK (1 << S5M_RTC_TIME_EN_SHIFT)
  107. /*
  108. * UDR_T field in S5M_RTC_UDR_CON register determines the time needed
  109. * for updating alarm and time registers. Default is 7.32 ms.
  110. */
  111. #define S5M_RTC_UDR_T_SHIFT 6
  112. #define S5M_RTC_UDR_T_MASK (0x3 << S5M_RTC_UDR_T_SHIFT)
  113. #define S5M_RTC_UDR_T_7320_US (0x0 << S5M_RTC_UDR_T_SHIFT)
  114. #define S5M_RTC_UDR_T_1830_US (0x1 << S5M_RTC_UDR_T_SHIFT)
  115. #define S5M_RTC_UDR_T_3660_US (0x2 << S5M_RTC_UDR_T_SHIFT)
  116. #define S5M_RTC_UDR_T_450_US (0x3 << S5M_RTC_UDR_T_SHIFT)
  117. /* RTC Hour register */
  118. #define HOUR_PM_SHIFT 6
  119. #define HOUR_PM_MASK (1 << HOUR_PM_SHIFT)
  120. /* RTC Alarm Enable */
  121. #define ALARM_ENABLE_SHIFT 7
  122. #define ALARM_ENABLE_MASK (1 << ALARM_ENABLE_SHIFT)
  123. #define SMPL_ENABLE_SHIFT 7
  124. #define SMPL_ENABLE_MASK (1 << SMPL_ENABLE_SHIFT)
  125. #define WTSR_ENABLE_SHIFT 6
  126. #define WTSR_ENABLE_MASK (1 << WTSR_ENABLE_SHIFT)
  127. enum {
  128. RTC_SEC = 0,
  129. RTC_MIN,
  130. RTC_HOUR,
  131. RTC_WEEKDAY,
  132. RTC_DATE,
  133. RTC_MONTH,
  134. RTC_YEAR1,
  135. RTC_YEAR2,
  136. };
  137. #endif /* __LINUX_MFD_SEC_RTC_H */