rtc.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. * rtc.h -- RTC driver for Wolfson WM8350 PMIC
  3. *
  4. * Copyright 2007 Wolfson Microelectronics PLC
  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. #ifndef __LINUX_MFD_WM8350_RTC_H
  12. #define __LINUX_MFD_WM8350_RTC_H
  13. #include <linux/platform_device.h>
  14. /*
  15. * Register values.
  16. */
  17. #define WM8350_RTC_SECONDS_MINUTES 0x10
  18. #define WM8350_RTC_HOURS_DAY 0x11
  19. #define WM8350_RTC_DATE_MONTH 0x12
  20. #define WM8350_RTC_YEAR 0x13
  21. #define WM8350_ALARM_SECONDS_MINUTES 0x14
  22. #define WM8350_ALARM_HOURS_DAY 0x15
  23. #define WM8350_ALARM_DATE_MONTH 0x16
  24. #define WM8350_RTC_TIME_CONTROL 0x17
  25. /*
  26. * R16 (0x10) - RTC Seconds/Minutes
  27. */
  28. #define WM8350_RTC_MINS_MASK 0x7F00
  29. #define WM8350_RTC_MINS_SHIFT 8
  30. #define WM8350_RTC_SECS_MASK 0x007F
  31. #define WM8350_RTC_SECS_SHIFT 0
  32. /*
  33. * R17 (0x11) - RTC Hours/Day
  34. */
  35. #define WM8350_RTC_DAY_MASK 0x0700
  36. #define WM8350_RTC_DAY_SHIFT 8
  37. #define WM8350_RTC_HPM_MASK 0x0020
  38. #define WM8350_RTC_HPM_SHIFT 5
  39. #define WM8350_RTC_HRS_MASK 0x001F
  40. #define WM8350_RTC_HRS_SHIFT 0
  41. /* Bit values for R21 (0x15) */
  42. #define WM8350_RTC_DAY_SUN 1
  43. #define WM8350_RTC_DAY_MON 2
  44. #define WM8350_RTC_DAY_TUE 3
  45. #define WM8350_RTC_DAY_WED 4
  46. #define WM8350_RTC_DAY_THU 5
  47. #define WM8350_RTC_DAY_FRI 6
  48. #define WM8350_RTC_DAY_SAT 7
  49. #define WM8350_RTC_HPM_AM 0
  50. #define WM8350_RTC_HPM_PM 1
  51. /*
  52. * R18 (0x12) - RTC Date/Month
  53. */
  54. #define WM8350_RTC_MTH_MASK 0x1F00
  55. #define WM8350_RTC_MTH_SHIFT 8
  56. #define WM8350_RTC_DATE_MASK 0x003F
  57. #define WM8350_RTC_DATE_SHIFT 0
  58. /* Bit values for R22 (0x16) */
  59. #define WM8350_RTC_MTH_JAN 1
  60. #define WM8350_RTC_MTH_FEB 2
  61. #define WM8350_RTC_MTH_MAR 3
  62. #define WM8350_RTC_MTH_APR 4
  63. #define WM8350_RTC_MTH_MAY 5
  64. #define WM8350_RTC_MTH_JUN 6
  65. #define WM8350_RTC_MTH_JUL 7
  66. #define WM8350_RTC_MTH_AUG 8
  67. #define WM8350_RTC_MTH_SEP 9
  68. #define WM8350_RTC_MTH_OCT 10
  69. #define WM8350_RTC_MTH_NOV 11
  70. #define WM8350_RTC_MTH_DEC 12
  71. #define WM8350_RTC_MTH_JAN_BCD 0x01
  72. #define WM8350_RTC_MTH_FEB_BCD 0x02
  73. #define WM8350_RTC_MTH_MAR_BCD 0x03
  74. #define WM8350_RTC_MTH_APR_BCD 0x04
  75. #define WM8350_RTC_MTH_MAY_BCD 0x05
  76. #define WM8350_RTC_MTH_JUN_BCD 0x06
  77. #define WM8350_RTC_MTH_JUL_BCD 0x07
  78. #define WM8350_RTC_MTH_AUG_BCD 0x08
  79. #define WM8350_RTC_MTH_SEP_BCD 0x09
  80. #define WM8350_RTC_MTH_OCT_BCD 0x10
  81. #define WM8350_RTC_MTH_NOV_BCD 0x11
  82. #define WM8350_RTC_MTH_DEC_BCD 0x12
  83. /*
  84. * R19 (0x13) - RTC Year
  85. */
  86. #define WM8350_RTC_YHUNDREDS_MASK 0x3F00
  87. #define WM8350_RTC_YHUNDREDS_SHIFT 8
  88. #define WM8350_RTC_YUNITS_MASK 0x00FF
  89. #define WM8350_RTC_YUNITS_SHIFT 0
  90. /*
  91. * R20 (0x14) - Alarm Seconds/Minutes
  92. */
  93. #define WM8350_RTC_ALMMINS_MASK 0x7F00
  94. #define WM8350_RTC_ALMMINS_SHIFT 8
  95. #define WM8350_RTC_ALMSECS_MASK 0x007F
  96. #define WM8350_RTC_ALMSECS_SHIFT 0
  97. /* Bit values for R20 (0x14) */
  98. #define WM8350_RTC_ALMMINS_DONT_CARE -1
  99. #define WM8350_RTC_ALMSECS_DONT_CARE -1
  100. /*
  101. * R21 (0x15) - Alarm Hours/Day
  102. */
  103. #define WM8350_RTC_ALMDAY_MASK 0x0F00
  104. #define WM8350_RTC_ALMDAY_SHIFT 8
  105. #define WM8350_RTC_ALMHPM_MASK 0x0020
  106. #define WM8350_RTC_ALMHPM_SHIFT 5
  107. #define WM8350_RTC_ALMHRS_MASK 0x001F
  108. #define WM8350_RTC_ALMHRS_SHIFT 0
  109. /* Bit values for R21 (0x15) */
  110. #define WM8350_RTC_ALMDAY_DONT_CARE -1
  111. #define WM8350_RTC_ALMDAY_SUN 1
  112. #define WM8350_RTC_ALMDAY_MON 2
  113. #define WM8350_RTC_ALMDAY_TUE 3
  114. #define WM8350_RTC_ALMDAY_WED 4
  115. #define WM8350_RTC_ALMDAY_THU 5
  116. #define WM8350_RTC_ALMDAY_FRI 6
  117. #define WM8350_RTC_ALMDAY_SAT 7
  118. #define WM8350_RTC_ALMHPM_AM 0
  119. #define WM8350_RTC_ALMHPM_PM 1
  120. #define WM8350_RTC_ALMHRS_DONT_CARE -1
  121. /*
  122. * R22 (0x16) - Alarm Date/Month
  123. */
  124. #define WM8350_RTC_ALMMTH_MASK 0x1F00
  125. #define WM8350_RTC_ALMMTH_SHIFT 8
  126. #define WM8350_RTC_ALMDATE_MASK 0x003F
  127. #define WM8350_RTC_ALMDATE_SHIFT 0
  128. /* Bit values for R22 (0x16) */
  129. #define WM8350_RTC_ALMDATE_DONT_CARE -1
  130. #define WM8350_RTC_ALMMTH_DONT_CARE -1
  131. #define WM8350_RTC_ALMMTH_JAN 1
  132. #define WM8350_RTC_ALMMTH_FEB 2
  133. #define WM8350_RTC_ALMMTH_MAR 3
  134. #define WM8350_RTC_ALMMTH_APR 4
  135. #define WM8350_RTC_ALMMTH_MAY 5
  136. #define WM8350_RTC_ALMMTH_JUN 6
  137. #define WM8350_RTC_ALMMTH_JUL 7
  138. #define WM8350_RTC_ALMMTH_AUG 8
  139. #define WM8350_RTC_ALMMTH_SEP 9
  140. #define WM8350_RTC_ALMMTH_OCT 10
  141. #define WM8350_RTC_ALMMTH_NOV 11
  142. #define WM8350_RTC_ALMMTH_DEC 12
  143. #define WM8350_RTC_ALMMTH_JAN_BCD 0x01
  144. #define WM8350_RTC_ALMMTH_FEB_BCD 0x02
  145. #define WM8350_RTC_ALMMTH_MAR_BCD 0x03
  146. #define WM8350_RTC_ALMMTH_APR_BCD 0x04
  147. #define WM8350_RTC_ALMMTH_MAY_BCD 0x05
  148. #define WM8350_RTC_ALMMTH_JUN_BCD 0x06
  149. #define WM8350_RTC_ALMMTH_JUL_BCD 0x07
  150. #define WM8350_RTC_ALMMTH_AUG_BCD 0x08
  151. #define WM8350_RTC_ALMMTH_SEP_BCD 0x09
  152. #define WM8350_RTC_ALMMTH_OCT_BCD 0x10
  153. #define WM8350_RTC_ALMMTH_NOV_BCD 0x11
  154. #define WM8350_RTC_ALMMTH_DEC_BCD 0x12
  155. /*
  156. * R23 (0x17) - RTC Time Control
  157. */
  158. #define WM8350_RTC_BCD 0x8000
  159. #define WM8350_RTC_BCD_MASK 0x8000
  160. #define WM8350_RTC_BCD_SHIFT 15
  161. #define WM8350_RTC_12HR 0x4000
  162. #define WM8350_RTC_12HR_MASK 0x4000
  163. #define WM8350_RTC_12HR_SHIFT 14
  164. #define WM8350_RTC_DST 0x2000
  165. #define WM8350_RTC_DST_MASK 0x2000
  166. #define WM8350_RTC_DST_SHIFT 13
  167. #define WM8350_RTC_SET 0x0800
  168. #define WM8350_RTC_SET_MASK 0x0800
  169. #define WM8350_RTC_SET_SHIFT 11
  170. #define WM8350_RTC_STS 0x0400
  171. #define WM8350_RTC_STS_MASK 0x0400
  172. #define WM8350_RTC_STS_SHIFT 10
  173. #define WM8350_RTC_ALMSET 0x0200
  174. #define WM8350_RTC_ALMSET_MASK 0x0200
  175. #define WM8350_RTC_ALMSET_SHIFT 9
  176. #define WM8350_RTC_ALMSTS 0x0100
  177. #define WM8350_RTC_ALMSTS_MASK 0x0100
  178. #define WM8350_RTC_ALMSTS_SHIFT 8
  179. #define WM8350_RTC_PINT 0x0070
  180. #define WM8350_RTC_PINT_MASK 0x0070
  181. #define WM8350_RTC_PINT_SHIFT 4
  182. #define WM8350_RTC_DSW 0x000F
  183. #define WM8350_RTC_DSW_MASK 0x000F
  184. #define WM8350_RTC_DSW_SHIFT 0
  185. /* Bit values for R23 (0x17) */
  186. #define WM8350_RTC_BCD_BINARY 0
  187. #define WM8350_RTC_BCD_BCD 1
  188. #define WM8350_RTC_12HR_24HR 0
  189. #define WM8350_RTC_12HR_12HR 1
  190. #define WM8350_RTC_DST_DISABLED 0
  191. #define WM8350_RTC_DST_ENABLED 1
  192. #define WM8350_RTC_SET_RUN 0
  193. #define WM8350_RTC_SET_SET 1
  194. #define WM8350_RTC_STS_RUNNING 0
  195. #define WM8350_RTC_STS_STOPPED 1
  196. #define WM8350_RTC_ALMSET_RUN 0
  197. #define WM8350_RTC_ALMSET_SET 1
  198. #define WM8350_RTC_ALMSTS_RUNNING 0
  199. #define WM8350_RTC_ALMSTS_STOPPED 1
  200. #define WM8350_RTC_PINT_DISABLED 0
  201. #define WM8350_RTC_PINT_SECS 1
  202. #define WM8350_RTC_PINT_MINS 2
  203. #define WM8350_RTC_PINT_HRS 3
  204. #define WM8350_RTC_PINT_DAYS 4
  205. #define WM8350_RTC_PINT_MTHS 5
  206. #define WM8350_RTC_DSW_DISABLED 0
  207. #define WM8350_RTC_DSW_1HZ 1
  208. #define WM8350_RTC_DSW_2HZ 2
  209. #define WM8350_RTC_DSW_4HZ 3
  210. #define WM8350_RTC_DSW_8HZ 4
  211. #define WM8350_RTC_DSW_16HZ 5
  212. #define WM8350_RTC_DSW_32HZ 6
  213. #define WM8350_RTC_DSW_64HZ 7
  214. #define WM8350_RTC_DSW_128HZ 8
  215. #define WM8350_RTC_DSW_256HZ 9
  216. #define WM8350_RTC_DSW_512HZ 10
  217. #define WM8350_RTC_DSW_1024HZ 11
  218. /*
  219. * R218 (0xDA) - RTC Tick Control
  220. */
  221. #define WM8350_RTC_TICKSTS 0x4000
  222. #define WM8350_RTC_CLKSRC 0x2000
  223. #define WM8350_RTC_TRIM_MASK 0x03FF
  224. /*
  225. * RTC Interrupts.
  226. */
  227. #define WM8350_IRQ_RTC_PER 7
  228. #define WM8350_IRQ_RTC_SEC 8
  229. #define WM8350_IRQ_RTC_ALM 9
  230. struct wm8350_rtc {
  231. struct platform_device *pdev;
  232. struct rtc_device *rtc;
  233. int alarm_enabled; /* used over suspend/resume */
  234. int update_enabled;
  235. };
  236. #endif