as3722.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. /*
  2. * as3722 definitions
  3. *
  4. * Copyright (C) 2013 ams
  5. * Copyright (c) 2013, NVIDIA Corporation. All rights reserved.
  6. *
  7. * Author: Florian Lobmaier <florian.lobmaier@ams.com>
  8. * Author: Laxman Dewangan <ldewangan@nvidia.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. *
  24. */
  25. #ifndef __LINUX_MFD_AS3722_H__
  26. #define __LINUX_MFD_AS3722_H__
  27. #include <linux/regmap.h>
  28. /* AS3722 registers */
  29. #define AS3722_SD0_VOLTAGE_REG 0x00
  30. #define AS3722_SD1_VOLTAGE_REG 0x01
  31. #define AS3722_SD2_VOLTAGE_REG 0x02
  32. #define AS3722_SD3_VOLTAGE_REG 0x03
  33. #define AS3722_SD4_VOLTAGE_REG 0x04
  34. #define AS3722_SD5_VOLTAGE_REG 0x05
  35. #define AS3722_SD6_VOLTAGE_REG 0x06
  36. #define AS3722_GPIO0_CONTROL_REG 0x08
  37. #define AS3722_GPIO1_CONTROL_REG 0x09
  38. #define AS3722_GPIO2_CONTROL_REG 0x0A
  39. #define AS3722_GPIO3_CONTROL_REG 0x0B
  40. #define AS3722_GPIO4_CONTROL_REG 0x0C
  41. #define AS3722_GPIO5_CONTROL_REG 0x0D
  42. #define AS3722_GPIO6_CONTROL_REG 0x0E
  43. #define AS3722_GPIO7_CONTROL_REG 0x0F
  44. #define AS3722_LDO0_VOLTAGE_REG 0x10
  45. #define AS3722_LDO1_VOLTAGE_REG 0x11
  46. #define AS3722_LDO2_VOLTAGE_REG 0x12
  47. #define AS3722_LDO3_VOLTAGE_REG 0x13
  48. #define AS3722_LDO4_VOLTAGE_REG 0x14
  49. #define AS3722_LDO5_VOLTAGE_REG 0x15
  50. #define AS3722_LDO6_VOLTAGE_REG 0x16
  51. #define AS3722_LDO7_VOLTAGE_REG 0x17
  52. #define AS3722_LDO9_VOLTAGE_REG 0x19
  53. #define AS3722_LDO10_VOLTAGE_REG 0x1A
  54. #define AS3722_LDO11_VOLTAGE_REG 0x1B
  55. #define AS3722_GPIO_DEB1_REG 0x1E
  56. #define AS3722_GPIO_DEB2_REG 0x1F
  57. #define AS3722_GPIO_SIGNAL_OUT_REG 0x20
  58. #define AS3722_GPIO_SIGNAL_IN_REG 0x21
  59. #define AS3722_REG_SEQU_MOD1_REG 0x22
  60. #define AS3722_REG_SEQU_MOD2_REG 0x23
  61. #define AS3722_REG_SEQU_MOD3_REG 0x24
  62. #define AS3722_SD_PHSW_CTRL_REG 0x27
  63. #define AS3722_SD_PHSW_STATUS 0x28
  64. #define AS3722_SD0_CONTROL_REG 0x29
  65. #define AS3722_SD1_CONTROL_REG 0x2A
  66. #define AS3722_SDmph_CONTROL_REG 0x2B
  67. #define AS3722_SD23_CONTROL_REG 0x2C
  68. #define AS3722_SD4_CONTROL_REG 0x2D
  69. #define AS3722_SD5_CONTROL_REG 0x2E
  70. #define AS3722_SD6_CONTROL_REG 0x2F
  71. #define AS3722_SD_DVM_REG 0x30
  72. #define AS3722_RESET_REASON_REG 0x31
  73. #define AS3722_BATTERY_VOLTAGE_MONITOR_REG 0x32
  74. #define AS3722_STARTUP_CONTROL_REG 0x33
  75. #define AS3722_RESET_TIMER_REG 0x34
  76. #define AS3722_REFERENCE_CONTROL_REG 0x35
  77. #define AS3722_RESET_CONTROL_REG 0x36
  78. #define AS3722_OVER_TEMP_CONTROL_REG 0x37
  79. #define AS3722_WATCHDOG_CONTROL_REG 0x38
  80. #define AS3722_REG_STANDBY_MOD1_REG 0x39
  81. #define AS3722_REG_STANDBY_MOD2_REG 0x3A
  82. #define AS3722_REG_STANDBY_MOD3_REG 0x3B
  83. #define AS3722_ENABLE_CTRL1_REG 0x3C
  84. #define AS3722_ENABLE_CTRL2_REG 0x3D
  85. #define AS3722_ENABLE_CTRL3_REG 0x3E
  86. #define AS3722_ENABLE_CTRL4_REG 0x3F
  87. #define AS3722_ENABLE_CTRL5_REG 0x40
  88. #define AS3722_PWM_CONTROL_L_REG 0x41
  89. #define AS3722_PWM_CONTROL_H_REG 0x42
  90. #define AS3722_WATCHDOG_TIMER_REG 0x46
  91. #define AS3722_WATCHDOG_SOFTWARE_SIGNAL_REG 0x48
  92. #define AS3722_IOVOLTAGE_REG 0x49
  93. #define AS3722_BATTERY_VOLTAGE_MONITOR2_REG 0x4A
  94. #define AS3722_SD_CONTROL_REG 0x4D
  95. #define AS3722_LDOCONTROL0_REG 0x4E
  96. #define AS3722_LDOCONTROL1_REG 0x4F
  97. #define AS3722_SD0_PROTECT_REG 0x50
  98. #define AS3722_SD6_PROTECT_REG 0x51
  99. #define AS3722_PWM_VCONTROL1_REG 0x52
  100. #define AS3722_PWM_VCONTROL2_REG 0x53
  101. #define AS3722_PWM_VCONTROL3_REG 0x54
  102. #define AS3722_PWM_VCONTROL4_REG 0x55
  103. #define AS3722_BB_CHARGER_REG 0x57
  104. #define AS3722_CTRL_SEQU1_REG 0x58
  105. #define AS3722_CTRL_SEQU2_REG 0x59
  106. #define AS3722_OVCURRENT_REG 0x5A
  107. #define AS3722_OVCURRENT_DEB_REG 0x5B
  108. #define AS3722_SDLV_DEB_REG 0x5C
  109. #define AS3722_OC_PG_CTRL_REG 0x5D
  110. #define AS3722_OC_PG_CTRL2_REG 0x5E
  111. #define AS3722_CTRL_STATUS 0x5F
  112. #define AS3722_RTC_CONTROL_REG 0x60
  113. #define AS3722_RTC_SECOND_REG 0x61
  114. #define AS3722_RTC_MINUTE_REG 0x62
  115. #define AS3722_RTC_HOUR_REG 0x63
  116. #define AS3722_RTC_DAY_REG 0x64
  117. #define AS3722_RTC_MONTH_REG 0x65
  118. #define AS3722_RTC_YEAR_REG 0x66
  119. #define AS3722_RTC_ALARM_SECOND_REG 0x67
  120. #define AS3722_RTC_ALARM_MINUTE_REG 0x68
  121. #define AS3722_RTC_ALARM_HOUR_REG 0x69
  122. #define AS3722_RTC_ALARM_DAY_REG 0x6A
  123. #define AS3722_RTC_ALARM_MONTH_REG 0x6B
  124. #define AS3722_RTC_ALARM_YEAR_REG 0x6C
  125. #define AS3722_SRAM_REG 0x6D
  126. #define AS3722_RTC_ACCESS_REG 0x6F
  127. #define AS3722_RTC_STATUS_REG 0x73
  128. #define AS3722_INTERRUPT_MASK1_REG 0x74
  129. #define AS3722_INTERRUPT_MASK2_REG 0x75
  130. #define AS3722_INTERRUPT_MASK3_REG 0x76
  131. #define AS3722_INTERRUPT_MASK4_REG 0x77
  132. #define AS3722_INTERRUPT_STATUS1_REG 0x78
  133. #define AS3722_INTERRUPT_STATUS2_REG 0x79
  134. #define AS3722_INTERRUPT_STATUS3_REG 0x7A
  135. #define AS3722_INTERRUPT_STATUS4_REG 0x7B
  136. #define AS3722_TEMP_STATUS_REG 0x7D
  137. #define AS3722_ADC0_CONTROL_REG 0x80
  138. #define AS3722_ADC1_CONTROL_REG 0x81
  139. #define AS3722_ADC0_MSB_RESULT_REG 0x82
  140. #define AS3722_ADC0_LSB_RESULT_REG 0x83
  141. #define AS3722_ADC1_MSB_RESULT_REG 0x84
  142. #define AS3722_ADC1_LSB_RESULT_REG 0x85
  143. #define AS3722_ADC1_THRESHOLD_HI_MSB_REG 0x86
  144. #define AS3722_ADC1_THRESHOLD_HI_LSB_REG 0x87
  145. #define AS3722_ADC1_THRESHOLD_LO_MSB_REG 0x88
  146. #define AS3722_ADC1_THRESHOLD_LO_LSB_REG 0x89
  147. #define AS3722_ADC_CONFIGURATION_REG 0x8A
  148. #define AS3722_ASIC_ID1_REG 0x90
  149. #define AS3722_ASIC_ID2_REG 0x91
  150. #define AS3722_LOCK_REG 0x9E
  151. #define AS3722_FUSE7_REG 0xA7
  152. #define AS3722_MAX_REGISTER 0xF4
  153. #define AS3722_SD0_EXT_ENABLE_MASK 0x03
  154. #define AS3722_SD1_EXT_ENABLE_MASK 0x0C
  155. #define AS3722_SD2_EXT_ENABLE_MASK 0x30
  156. #define AS3722_SD3_EXT_ENABLE_MASK 0xC0
  157. #define AS3722_SD4_EXT_ENABLE_MASK 0x03
  158. #define AS3722_SD5_EXT_ENABLE_MASK 0x0C
  159. #define AS3722_SD6_EXT_ENABLE_MASK 0x30
  160. #define AS3722_LDO0_EXT_ENABLE_MASK 0x03
  161. #define AS3722_LDO1_EXT_ENABLE_MASK 0x0C
  162. #define AS3722_LDO2_EXT_ENABLE_MASK 0x30
  163. #define AS3722_LDO3_EXT_ENABLE_MASK 0xC0
  164. #define AS3722_LDO4_EXT_ENABLE_MASK 0x03
  165. #define AS3722_LDO5_EXT_ENABLE_MASK 0x0C
  166. #define AS3722_LDO6_EXT_ENABLE_MASK 0x30
  167. #define AS3722_LDO7_EXT_ENABLE_MASK 0xC0
  168. #define AS3722_LDO9_EXT_ENABLE_MASK 0x0C
  169. #define AS3722_LDO10_EXT_ENABLE_MASK 0x30
  170. #define AS3722_LDO11_EXT_ENABLE_MASK 0xC0
  171. #define AS3722_OVCURRENT_SD0_ALARM_MASK 0x07
  172. #define AS3722_OVCURRENT_SD0_ALARM_SHIFT 0x01
  173. #define AS3722_OVCURRENT_SD0_TRIP_MASK 0x18
  174. #define AS3722_OVCURRENT_SD0_TRIP_SHIFT 0x03
  175. #define AS3722_OVCURRENT_SD1_TRIP_MASK 0x60
  176. #define AS3722_OVCURRENT_SD1_TRIP_SHIFT 0x05
  177. #define AS3722_OVCURRENT_SD6_ALARM_MASK 0x07
  178. #define AS3722_OVCURRENT_SD6_ALARM_SHIFT 0x01
  179. #define AS3722_OVCURRENT_SD6_TRIP_MASK 0x18
  180. #define AS3722_OVCURRENT_SD6_TRIP_SHIFT 0x03
  181. /* AS3722 register bits and bit masks */
  182. #define AS3722_LDO_ILIMIT_MASK BIT(7)
  183. #define AS3722_LDO_ILIMIT_BIT BIT(7)
  184. #define AS3722_LDO0_VSEL_MASK 0x1F
  185. #define AS3722_LDO0_VSEL_MIN 0x01
  186. #define AS3722_LDO0_VSEL_MAX 0x12
  187. #define AS3722_LDO0_NUM_VOLT 0x12
  188. #define AS3722_LDO3_VSEL_MASK 0x3F
  189. #define AS3722_LDO3_VSEL_MIN 0x01
  190. #define AS3722_LDO3_VSEL_MAX 0x2D
  191. #define AS3722_LDO3_NUM_VOLT 0x2D
  192. #define AS3722_LDO_VSEL_MASK 0x7F
  193. #define AS3722_LDO_VSEL_MIN 0x01
  194. #define AS3722_LDO_VSEL_MAX 0x7F
  195. #define AS3722_LDO_VSEL_DNU_MIN 0x25
  196. #define AS3722_LDO_VSEL_DNU_MAX 0x3F
  197. #define AS3722_LDO_NUM_VOLT 0x80
  198. #define AS3722_LDO0_CTRL BIT(0)
  199. #define AS3722_LDO1_CTRL BIT(1)
  200. #define AS3722_LDO2_CTRL BIT(2)
  201. #define AS3722_LDO3_CTRL BIT(3)
  202. #define AS3722_LDO4_CTRL BIT(4)
  203. #define AS3722_LDO5_CTRL BIT(5)
  204. #define AS3722_LDO6_CTRL BIT(6)
  205. #define AS3722_LDO7_CTRL BIT(7)
  206. #define AS3722_LDO9_CTRL BIT(1)
  207. #define AS3722_LDO10_CTRL BIT(2)
  208. #define AS3722_LDO11_CTRL BIT(3)
  209. #define AS3722_LDO3_MODE_MASK (3 << 6)
  210. #define AS3722_LDO3_MODE_VAL(n) (((n) & 0x3) << 6)
  211. #define AS3722_LDO3_MODE_PMOS AS3722_LDO3_MODE_VAL(0)
  212. #define AS3722_LDO3_MODE_PMOS_TRACKING AS3722_LDO3_MODE_VAL(1)
  213. #define AS3722_LDO3_MODE_NMOS AS3722_LDO3_MODE_VAL(2)
  214. #define AS3722_LDO3_MODE_SWITCH AS3722_LDO3_MODE_VAL(3)
  215. #define AS3722_SD_VSEL_MASK 0x7F
  216. #define AS3722_SD0_VSEL_MIN 0x01
  217. #define AS3722_SD0_VSEL_MAX 0x5A
  218. #define AS3722_SD0_VSEL_LOW_VOL_MAX 0x6E
  219. #define AS3722_SD2_VSEL_MIN 0x01
  220. #define AS3722_SD2_VSEL_MAX 0x7F
  221. #define AS3722_SDn_CTRL(n) BIT(n)
  222. #define AS3722_SD0_MODE_FAST BIT(4)
  223. #define AS3722_SD1_MODE_FAST BIT(4)
  224. #define AS3722_SD2_MODE_FAST BIT(2)
  225. #define AS3722_SD3_MODE_FAST BIT(6)
  226. #define AS3722_SD4_MODE_FAST BIT(2)
  227. #define AS3722_SD5_MODE_FAST BIT(2)
  228. #define AS3722_SD6_MODE_FAST BIT(4)
  229. #define AS3722_POWER_OFF BIT(1)
  230. #define AS3722_INTERRUPT_MASK1_LID BIT(0)
  231. #define AS3722_INTERRUPT_MASK1_ACOK BIT(1)
  232. #define AS3722_INTERRUPT_MASK1_ENABLE1 BIT(2)
  233. #define AS3722_INTERRUPT_MASK1_OCURR_ALARM_SD0 BIT(3)
  234. #define AS3722_INTERRUPT_MASK1_ONKEY_LONG BIT(4)
  235. #define AS3722_INTERRUPT_MASK1_ONKEY BIT(5)
  236. #define AS3722_INTERRUPT_MASK1_OVTMP BIT(6)
  237. #define AS3722_INTERRUPT_MASK1_LOWBAT BIT(7)
  238. #define AS3722_INTERRUPT_MASK2_SD0_LV BIT(0)
  239. #define AS3722_INTERRUPT_MASK2_SD1_LV BIT(1)
  240. #define AS3722_INTERRUPT_MASK2_SD2345_LV BIT(2)
  241. #define AS3722_INTERRUPT_MASK2_PWM1_OV_PROT BIT(3)
  242. #define AS3722_INTERRUPT_MASK2_PWM2_OV_PROT BIT(4)
  243. #define AS3722_INTERRUPT_MASK2_ENABLE2 BIT(5)
  244. #define AS3722_INTERRUPT_MASK2_SD6_LV BIT(6)
  245. #define AS3722_INTERRUPT_MASK2_RTC_REP BIT(7)
  246. #define AS3722_INTERRUPT_MASK3_RTC_ALARM BIT(0)
  247. #define AS3722_INTERRUPT_MASK3_GPIO1 BIT(1)
  248. #define AS3722_INTERRUPT_MASK3_GPIO2 BIT(2)
  249. #define AS3722_INTERRUPT_MASK3_GPIO3 BIT(3)
  250. #define AS3722_INTERRUPT_MASK3_GPIO4 BIT(4)
  251. #define AS3722_INTERRUPT_MASK3_GPIO5 BIT(5)
  252. #define AS3722_INTERRUPT_MASK3_WATCHDOG BIT(6)
  253. #define AS3722_INTERRUPT_MASK3_ENABLE3 BIT(7)
  254. #define AS3722_INTERRUPT_MASK4_TEMP_SD0_SHUTDOWN BIT(0)
  255. #define AS3722_INTERRUPT_MASK4_TEMP_SD1_SHUTDOWN BIT(1)
  256. #define AS3722_INTERRUPT_MASK4_TEMP_SD6_SHUTDOWN BIT(2)
  257. #define AS3722_INTERRUPT_MASK4_TEMP_SD0_ALARM BIT(3)
  258. #define AS3722_INTERRUPT_MASK4_TEMP_SD1_ALARM BIT(4)
  259. #define AS3722_INTERRUPT_MASK4_TEMP_SD6_ALARM BIT(5)
  260. #define AS3722_INTERRUPT_MASK4_OCCUR_ALARM_SD6 BIT(6)
  261. #define AS3722_INTERRUPT_MASK4_ADC BIT(7)
  262. #define AS3722_ADC1_INTERVAL_TIME BIT(0)
  263. #define AS3722_ADC1_INT_MODE_ON BIT(1)
  264. #define AS3722_ADC_BUF_ON BIT(2)
  265. #define AS3722_ADC1_LOW_VOLTAGE_RANGE BIT(5)
  266. #define AS3722_ADC1_INTEVAL_SCAN BIT(6)
  267. #define AS3722_ADC1_INT_MASK BIT(7)
  268. #define AS3722_ADC_MSB_VAL_MASK 0x7F
  269. #define AS3722_ADC_LSB_VAL_MASK 0x07
  270. #define AS3722_ADC0_CONV_START BIT(7)
  271. #define AS3722_ADC0_CONV_NOTREADY BIT(7)
  272. #define AS3722_ADC0_SOURCE_SELECT_MASK 0x1F
  273. #define AS3722_ADC1_CONV_START BIT(7)
  274. #define AS3722_ADC1_CONV_NOTREADY BIT(7)
  275. #define AS3722_ADC1_SOURCE_SELECT_MASK 0x1F
  276. /* GPIO modes */
  277. #define AS3722_GPIO_MODE_MASK 0x07
  278. #define AS3722_GPIO_MODE_INPUT 0x00
  279. #define AS3722_GPIO_MODE_OUTPUT_VDDH 0x01
  280. #define AS3722_GPIO_MODE_IO_OPEN_DRAIN 0x02
  281. #define AS3722_GPIO_MODE_ADC_IN 0x03
  282. #define AS3722_GPIO_MODE_INPUT_PULL_UP 0x04
  283. #define AS3722_GPIO_MODE_INPUT_PULL_DOWN 0x05
  284. #define AS3722_GPIO_MODE_IO_OPEN_DRAIN_PULL_UP 0x06
  285. #define AS3722_GPIO_MODE_OUTPUT_VDDL 0x07
  286. #define AS3722_GPIO_MODE_VAL(n) ((n) & AS3722_GPIO_MODE_MASK)
  287. #define AS3722_GPIO_INV BIT(7)
  288. #define AS3722_GPIO_IOSF_MASK 0x78
  289. #define AS3722_GPIO_IOSF_VAL(n) (((n) & 0xF) << 3)
  290. #define AS3722_GPIO_IOSF_NORMAL AS3722_GPIO_IOSF_VAL(0)
  291. #define AS3722_GPIO_IOSF_INTERRUPT_OUT AS3722_GPIO_IOSF_VAL(1)
  292. #define AS3722_GPIO_IOSF_VSUP_LOW_OUT AS3722_GPIO_IOSF_VAL(2)
  293. #define AS3722_GPIO_IOSF_GPIO_INTERRUPT_IN AS3722_GPIO_IOSF_VAL(3)
  294. #define AS3722_GPIO_IOSF_ISINK_PWM_IN AS3722_GPIO_IOSF_VAL(4)
  295. #define AS3722_GPIO_IOSF_VOLTAGE_STBY AS3722_GPIO_IOSF_VAL(5)
  296. #define AS3722_GPIO_IOSF_SD0_OUT AS3722_GPIO_IOSF_VAL(6)
  297. #define AS3722_GPIO_IOSF_PWR_GOOD_OUT AS3722_GPIO_IOSF_VAL(7)
  298. #define AS3722_GPIO_IOSF_Q32K_OUT AS3722_GPIO_IOSF_VAL(8)
  299. #define AS3722_GPIO_IOSF_WATCHDOG_IN AS3722_GPIO_IOSF_VAL(9)
  300. #define AS3722_GPIO_IOSF_SOFT_RESET_IN AS3722_GPIO_IOSF_VAL(11)
  301. #define AS3722_GPIO_IOSF_PWM_OUT AS3722_GPIO_IOSF_VAL(12)
  302. #define AS3722_GPIO_IOSF_VSUP_LOW_DEB_OUT AS3722_GPIO_IOSF_VAL(13)
  303. #define AS3722_GPIO_IOSF_SD6_LOW_VOLT_LOW AS3722_GPIO_IOSF_VAL(14)
  304. #define AS3722_GPIOn_SIGNAL(n) BIT(n)
  305. #define AS3722_GPIOn_CONTROL_REG(n) (AS3722_GPIO0_CONTROL_REG + n)
  306. #define AS3722_I2C_PULL_UP BIT(4)
  307. #define AS3722_INT_PULL_UP BIT(5)
  308. #define AS3722_RTC_REP_WAKEUP_EN BIT(0)
  309. #define AS3722_RTC_ALARM_WAKEUP_EN BIT(1)
  310. #define AS3722_RTC_ON BIT(2)
  311. #define AS3722_RTC_IRQMODE BIT(3)
  312. #define AS3722_RTC_CLK32K_OUT_EN BIT(5)
  313. #define AS3722_WATCHDOG_TIMER_MAX 0x7F
  314. #define AS3722_WATCHDOG_ON BIT(0)
  315. #define AS3722_WATCHDOG_SW_SIG BIT(0)
  316. #define AS3722_EXT_CONTROL_ENABLE1 0x1
  317. #define AS3722_EXT_CONTROL_ENABLE2 0x2
  318. #define AS3722_EXT_CONTROL_ENABLE3 0x3
  319. #define AS3722_FUSE7_SD0_LOW_VOLTAGE BIT(4)
  320. /* Interrupt IDs */
  321. enum as3722_irq {
  322. AS3722_IRQ_LID,
  323. AS3722_IRQ_ACOK,
  324. AS3722_IRQ_ENABLE1,
  325. AS3722_IRQ_OCCUR_ALARM_SD0,
  326. AS3722_IRQ_ONKEY_LONG_PRESS,
  327. AS3722_IRQ_ONKEY,
  328. AS3722_IRQ_OVTMP,
  329. AS3722_IRQ_LOWBAT,
  330. AS3722_IRQ_SD0_LV,
  331. AS3722_IRQ_SD1_LV,
  332. AS3722_IRQ_SD2_LV,
  333. AS3722_IRQ_PWM1_OV_PROT,
  334. AS3722_IRQ_PWM2_OV_PROT,
  335. AS3722_IRQ_ENABLE2,
  336. AS3722_IRQ_SD6_LV,
  337. AS3722_IRQ_RTC_REP,
  338. AS3722_IRQ_RTC_ALARM,
  339. AS3722_IRQ_GPIO1,
  340. AS3722_IRQ_GPIO2,
  341. AS3722_IRQ_GPIO3,
  342. AS3722_IRQ_GPIO4,
  343. AS3722_IRQ_GPIO5,
  344. AS3722_IRQ_WATCHDOG,
  345. AS3722_IRQ_ENABLE3,
  346. AS3722_IRQ_TEMP_SD0_SHUTDOWN,
  347. AS3722_IRQ_TEMP_SD1_SHUTDOWN,
  348. AS3722_IRQ_TEMP_SD2_SHUTDOWN,
  349. AS3722_IRQ_TEMP_SD0_ALARM,
  350. AS3722_IRQ_TEMP_SD1_ALARM,
  351. AS3722_IRQ_TEMP_SD6_ALARM,
  352. AS3722_IRQ_OCCUR_ALARM_SD6,
  353. AS3722_IRQ_ADC,
  354. AS3722_IRQ_MAX,
  355. };
  356. struct as3722 {
  357. struct device *dev;
  358. struct regmap *regmap;
  359. int chip_irq;
  360. unsigned long irq_flags;
  361. bool en_intern_int_pullup;
  362. bool en_intern_i2c_pullup;
  363. struct regmap_irq_chip_data *irq_data;
  364. };
  365. static inline int as3722_read(struct as3722 *as3722, u32 reg, u32 *dest)
  366. {
  367. return regmap_read(as3722->regmap, reg, dest);
  368. }
  369. static inline int as3722_write(struct as3722 *as3722, u32 reg, u32 value)
  370. {
  371. return regmap_write(as3722->regmap, reg, value);
  372. }
  373. static inline int as3722_block_read(struct as3722 *as3722, u32 reg,
  374. int count, u8 *buf)
  375. {
  376. return regmap_bulk_read(as3722->regmap, reg, buf, count);
  377. }
  378. static inline int as3722_block_write(struct as3722 *as3722, u32 reg,
  379. int count, u8 *data)
  380. {
  381. return regmap_bulk_write(as3722->regmap, reg, data, count);
  382. }
  383. static inline int as3722_update_bits(struct as3722 *as3722, u32 reg,
  384. u32 mask, u8 val)
  385. {
  386. return regmap_update_bits(as3722->regmap, reg, mask, val);
  387. }
  388. static inline int as3722_irq_get_virq(struct as3722 *as3722, int irq)
  389. {
  390. return regmap_irq_get_virq(as3722->irq_data, irq);
  391. }
  392. #endif /* __LINUX_MFD_AS3722_H__ */