tps80031.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*
  2. * tps80031.h -- TI TPS80031 and TI TPS80032 PMIC driver.
  3. *
  4. * Copyright (c) 2012, NVIDIA Corporation.
  5. *
  6. * Author: Laxman Dewangan <ldewangan@nvidia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation version 2.
  11. *
  12. * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
  13. * whether express or implied; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  20. * 02111-1307, USA
  21. */
  22. #ifndef __LINUX_MFD_TPS80031_H
  23. #define __LINUX_MFD_TPS80031_H
  24. #include <linux/device.h>
  25. #include <linux/regmap.h>
  26. /* Pull-ups/Pull-downs */
  27. #define TPS80031_CFG_INPUT_PUPD1 0xF0
  28. #define TPS80031_CFG_INPUT_PUPD2 0xF1
  29. #define TPS80031_CFG_INPUT_PUPD3 0xF2
  30. #define TPS80031_CFG_INPUT_PUPD4 0xF3
  31. #define TPS80031_CFG_LDO_PD1 0xF4
  32. #define TPS80031_CFG_LDO_PD2 0xF5
  33. #define TPS80031_CFG_SMPS_PD 0xF6
  34. /* Real Time Clock */
  35. #define TPS80031_SECONDS_REG 0x00
  36. #define TPS80031_MINUTES_REG 0x01
  37. #define TPS80031_HOURS_REG 0x02
  38. #define TPS80031_DAYS_REG 0x03
  39. #define TPS80031_MONTHS_REG 0x04
  40. #define TPS80031_YEARS_REG 0x05
  41. #define TPS80031_WEEKS_REG 0x06
  42. #define TPS80031_ALARM_SECONDS_REG 0x08
  43. #define TPS80031_ALARM_MINUTES_REG 0x09
  44. #define TPS80031_ALARM_HOURS_REG 0x0A
  45. #define TPS80031_ALARM_DAYS_REG 0x0B
  46. #define TPS80031_ALARM_MONTHS_REG 0x0C
  47. #define TPS80031_ALARM_YEARS_REG 0x0D
  48. #define TPS80031_RTC_CTRL_REG 0x10
  49. #define TPS80031_RTC_STATUS_REG 0x11
  50. #define TPS80031_RTC_INTERRUPTS_REG 0x12
  51. #define TPS80031_RTC_COMP_LSB_REG 0x13
  52. #define TPS80031_RTC_COMP_MSB_REG 0x14
  53. #define TPS80031_RTC_RESET_STATUS_REG 0x16
  54. /*PMC Master Module */
  55. #define TPS80031_PHOENIX_START_CONDITION 0x1F
  56. #define TPS80031_PHOENIX_MSK_TRANSITION 0x20
  57. #define TPS80031_STS_HW_CONDITIONS 0x21
  58. #define TPS80031_PHOENIX_LAST_TURNOFF_STS 0x22
  59. #define TPS80031_VSYSMIN_LO_THRESHOLD 0x23
  60. #define TPS80031_VSYSMIN_HI_THRESHOLD 0x24
  61. #define TPS80031_PHOENIX_DEV_ON 0x25
  62. #define TPS80031_STS_PWR_GRP_STATE 0x27
  63. #define TPS80031_PH_CFG_VSYSLOW 0x28
  64. #define TPS80031_PH_STS_BOOT 0x29
  65. #define TPS80031_PHOENIX_SENS_TRANSITION 0x2A
  66. #define TPS80031_PHOENIX_SEQ_CFG 0x2B
  67. #define TPS80031_PRIMARY_WATCHDOG_CFG 0X2C
  68. #define TPS80031_KEY_PRESS_DUR_CFG 0X2D
  69. #define TPS80031_SMPS_LDO_SHORT_STS 0x2E
  70. /* PMC Slave Module - Broadcast */
  71. #define TPS80031_BROADCAST_ADDR_ALL 0x31
  72. #define TPS80031_BROADCAST_ADDR_REF 0x32
  73. #define TPS80031_BROADCAST_ADDR_PROV 0x33
  74. #define TPS80031_BROADCAST_ADDR_CLK_RST 0x34
  75. /* PMC Slave Module SMPS Regulators */
  76. #define TPS80031_SMPS4_CFG_TRANS 0x41
  77. #define TPS80031_SMPS4_CFG_STATE 0x42
  78. #define TPS80031_SMPS4_CFG_VOLTAGE 0x44
  79. #define TPS80031_VIO_CFG_TRANS 0x47
  80. #define TPS80031_VIO_CFG_STATE 0x48
  81. #define TPS80031_VIO_CFG_FORCE 0x49
  82. #define TPS80031_VIO_CFG_VOLTAGE 0x4A
  83. #define TPS80031_VIO_CFG_STEP 0x48
  84. #define TPS80031_SMPS1_CFG_TRANS 0x53
  85. #define TPS80031_SMPS1_CFG_STATE 0x54
  86. #define TPS80031_SMPS1_CFG_FORCE 0x55
  87. #define TPS80031_SMPS1_CFG_VOLTAGE 0x56
  88. #define TPS80031_SMPS1_CFG_STEP 0x57
  89. #define TPS80031_SMPS2_CFG_TRANS 0x59
  90. #define TPS80031_SMPS2_CFG_STATE 0x5A
  91. #define TPS80031_SMPS2_CFG_FORCE 0x5B
  92. #define TPS80031_SMPS2_CFG_VOLTAGE 0x5C
  93. #define TPS80031_SMPS2_CFG_STEP 0x5D
  94. #define TPS80031_SMPS3_CFG_TRANS 0x65
  95. #define TPS80031_SMPS3_CFG_STATE 0x66
  96. #define TPS80031_SMPS3_CFG_VOLTAGE 0x68
  97. /* PMC Slave Module LDO Regulators */
  98. #define TPS80031_VANA_CFG_TRANS 0x81
  99. #define TPS80031_VANA_CFG_STATE 0x82
  100. #define TPS80031_VANA_CFG_VOLTAGE 0x83
  101. #define TPS80031_LDO2_CFG_TRANS 0x85
  102. #define TPS80031_LDO2_CFG_STATE 0x86
  103. #define TPS80031_LDO2_CFG_VOLTAGE 0x87
  104. #define TPS80031_LDO4_CFG_TRANS 0x89
  105. #define TPS80031_LDO4_CFG_STATE 0x8A
  106. #define TPS80031_LDO4_CFG_VOLTAGE 0x8B
  107. #define TPS80031_LDO3_CFG_TRANS 0x8D
  108. #define TPS80031_LDO3_CFG_STATE 0x8E
  109. #define TPS80031_LDO3_CFG_VOLTAGE 0x8F
  110. #define TPS80031_LDO6_CFG_TRANS 0x91
  111. #define TPS80031_LDO6_CFG_STATE 0x92
  112. #define TPS80031_LDO6_CFG_VOLTAGE 0x93
  113. #define TPS80031_LDOLN_CFG_TRANS 0x95
  114. #define TPS80031_LDOLN_CFG_STATE 0x96
  115. #define TPS80031_LDOLN_CFG_VOLTAGE 0x97
  116. #define TPS80031_LDO5_CFG_TRANS 0x99
  117. #define TPS80031_LDO5_CFG_STATE 0x9A
  118. #define TPS80031_LDO5_CFG_VOLTAGE 0x9B
  119. #define TPS80031_LDO1_CFG_TRANS 0x9D
  120. #define TPS80031_LDO1_CFG_STATE 0x9E
  121. #define TPS80031_LDO1_CFG_VOLTAGE 0x9F
  122. #define TPS80031_LDOUSB_CFG_TRANS 0xA1
  123. #define TPS80031_LDOUSB_CFG_STATE 0xA2
  124. #define TPS80031_LDOUSB_CFG_VOLTAGE 0xA3
  125. #define TPS80031_LDO7_CFG_TRANS 0xA5
  126. #define TPS80031_LDO7_CFG_STATE 0xA6
  127. #define TPS80031_LDO7_CFG_VOLTAGE 0xA7
  128. /* PMC Slave Module External Control */
  129. #define TPS80031_REGEN1_CFG_TRANS 0xAE
  130. #define TPS80031_REGEN1_CFG_STATE 0xAF
  131. #define TPS80031_REGEN2_CFG_TRANS 0xB1
  132. #define TPS80031_REGEN2_CFG_STATE 0xB2
  133. #define TPS80031_SYSEN_CFG_TRANS 0xB4
  134. #define TPS80031_SYSEN_CFG_STATE 0xB5
  135. /* PMC Slave Module Internal Control */
  136. #define TPS80031_NRESPWRON_CFG_TRANS 0xB7
  137. #define TPS80031_NRESPWRON_CFG_STATE 0xB8
  138. #define TPS80031_CLK32KAO_CFG_TRANS 0xBA
  139. #define TPS80031_CLK32KAO_CFG_STATE 0xBB
  140. #define TPS80031_CLK32KG_CFG_TRANS 0xBD
  141. #define TPS80031_CLK32KG_CFG_STATE 0xBE
  142. #define TPS80031_CLK32KAUDIO_CFG_TRANS 0xC0
  143. #define TPS80031_CLK32KAUDIO_CFG_STATE 0xC1
  144. #define TPS80031_VRTC_CFG_TRANS 0xC3
  145. #define TPS80031_VRTC_CFG_STATE 0xC4
  146. #define TPS80031_BIAS_CFG_TRANS 0xC6
  147. #define TPS80031_BIAS_CFG_STATE 0xC7
  148. #define TPS80031_VSYSMIN_HI_CFG_TRANS 0xC9
  149. #define TPS80031_VSYSMIN_HI_CFG_STATE 0xCA
  150. #define TPS80031_RC6MHZ_CFG_TRANS 0xCC
  151. #define TPS80031_RC6MHZ_CFG_STATE 0xCD
  152. #define TPS80031_TMP_CFG_TRANS 0xCF
  153. #define TPS80031_TMP_CFG_STATE 0xD0
  154. /* PMC Slave Module resources assignment */
  155. #define TPS80031_PREQ1_RES_ASS_A 0xD7
  156. #define TPS80031_PREQ1_RES_ASS_B 0xD8
  157. #define TPS80031_PREQ1_RES_ASS_C 0xD9
  158. #define TPS80031_PREQ2_RES_ASS_A 0xDA
  159. #define TPS80031_PREQ2_RES_ASS_B 0xDB
  160. #define TPS80031_PREQ2_RES_ASS_C 0xDC
  161. #define TPS80031_PREQ3_RES_ASS_A 0xDD
  162. #define TPS80031_PREQ3_RES_ASS_B 0xDE
  163. #define TPS80031_PREQ3_RES_ASS_C 0xDF
  164. /* PMC Slave Module Miscellaneous */
  165. #define TPS80031_SMPS_OFFSET 0xE0
  166. #define TPS80031_SMPS_MULT 0xE3
  167. #define TPS80031_MISC1 0xE4
  168. #define TPS80031_MISC2 0xE5
  169. #define TPS80031_BBSPOR_CFG 0xE6
  170. #define TPS80031_TMP_CFG 0xE7
  171. /* Battery Charging Controller and Indicator LED */
  172. #define TPS80031_CONTROLLER_CTRL2 0xDA
  173. #define TPS80031_CONTROLLER_VSEL_COMP 0xDB
  174. #define TPS80031_CHARGERUSB_VSYSREG 0xDC
  175. #define TPS80031_CHARGERUSB_VICHRG_PC 0xDD
  176. #define TPS80031_LINEAR_CHRG_STS 0xDE
  177. #define TPS80031_CONTROLLER_INT_MASK 0xE0
  178. #define TPS80031_CONTROLLER_CTRL1 0xE1
  179. #define TPS80031_CONTROLLER_WDG 0xE2
  180. #define TPS80031_CONTROLLER_STAT1 0xE3
  181. #define TPS80031_CHARGERUSB_INT_STATUS 0xE4
  182. #define TPS80031_CHARGERUSB_INT_MASK 0xE5
  183. #define TPS80031_CHARGERUSB_STATUS_INT1 0xE6
  184. #define TPS80031_CHARGERUSB_STATUS_INT2 0xE7
  185. #define TPS80031_CHARGERUSB_CTRL1 0xE8
  186. #define TPS80031_CHARGERUSB_CTRL2 0xE9
  187. #define TPS80031_CHARGERUSB_CTRL3 0xEA
  188. #define TPS80031_CHARGERUSB_STAT1 0xEB
  189. #define TPS80031_CHARGERUSB_VOREG 0xEC
  190. #define TPS80031_CHARGERUSB_VICHRG 0xED
  191. #define TPS80031_CHARGERUSB_CINLIMIT 0xEE
  192. #define TPS80031_CHARGERUSB_CTRLLIMIT1 0xEF
  193. #define TPS80031_CHARGERUSB_CTRLLIMIT2 0xF0
  194. #define TPS80031_LED_PWM_CTRL1 0xF4
  195. #define TPS80031_LED_PWM_CTRL2 0xF5
  196. /* USB On-The-Go */
  197. #define TPS80031_BACKUP_REG 0xFA
  198. #define TPS80031_USB_VENDOR_ID_LSB 0x00
  199. #define TPS80031_USB_VENDOR_ID_MSB 0x01
  200. #define TPS80031_USB_PRODUCT_ID_LSB 0x02
  201. #define TPS80031_USB_PRODUCT_ID_MSB 0x03
  202. #define TPS80031_USB_VBUS_CTRL_SET 0x04
  203. #define TPS80031_USB_VBUS_CTRL_CLR 0x05
  204. #define TPS80031_USB_ID_CTRL_SET 0x06
  205. #define TPS80031_USB_ID_CTRL_CLR 0x07
  206. #define TPS80031_USB_VBUS_INT_SRC 0x08
  207. #define TPS80031_USB_VBUS_INT_LATCH_SET 0x09
  208. #define TPS80031_USB_VBUS_INT_LATCH_CLR 0x0A
  209. #define TPS80031_USB_VBUS_INT_EN_LO_SET 0x0B
  210. #define TPS80031_USB_VBUS_INT_EN_LO_CLR 0x0C
  211. #define TPS80031_USB_VBUS_INT_EN_HI_SET 0x0D
  212. #define TPS80031_USB_VBUS_INT_EN_HI_CLR 0x0E
  213. #define TPS80031_USB_ID_INT_SRC 0x0F
  214. #define TPS80031_USB_ID_INT_LATCH_SET 0x10
  215. #define TPS80031_USB_ID_INT_LATCH_CLR 0x11
  216. #define TPS80031_USB_ID_INT_EN_LO_SET 0x12
  217. #define TPS80031_USB_ID_INT_EN_LO_CLR 0x13
  218. #define TPS80031_USB_ID_INT_EN_HI_SET 0x14
  219. #define TPS80031_USB_ID_INT_EN_HI_CLR 0x15
  220. #define TPS80031_USB_OTG_ADP_CTRL 0x16
  221. #define TPS80031_USB_OTG_ADP_HIGH 0x17
  222. #define TPS80031_USB_OTG_ADP_LOW 0x18
  223. #define TPS80031_USB_OTG_ADP_RISE 0x19
  224. #define TPS80031_USB_OTG_REVISION 0x1A
  225. /* Gas Gauge */
  226. #define TPS80031_FG_REG_00 0xC0
  227. #define TPS80031_FG_REG_01 0xC1
  228. #define TPS80031_FG_REG_02 0xC2
  229. #define TPS80031_FG_REG_03 0xC3
  230. #define TPS80031_FG_REG_04 0xC4
  231. #define TPS80031_FG_REG_05 0xC5
  232. #define TPS80031_FG_REG_06 0xC6
  233. #define TPS80031_FG_REG_07 0xC7
  234. #define TPS80031_FG_REG_08 0xC8
  235. #define TPS80031_FG_REG_09 0xC9
  236. #define TPS80031_FG_REG_10 0xCA
  237. #define TPS80031_FG_REG_11 0xCB
  238. /* General Purpose ADC */
  239. #define TPS80031_GPADC_CTRL 0x2E
  240. #define TPS80031_GPADC_CTRL2 0x2F
  241. #define TPS80031_RTSELECT_LSB 0x32
  242. #define TPS80031_RTSELECT_ISB 0x33
  243. #define TPS80031_RTSELECT_MSB 0x34
  244. #define TPS80031_GPSELECT_ISB 0x35
  245. #define TPS80031_CTRL_P1 0x36
  246. #define TPS80031_RTCH0_LSB 0x37
  247. #define TPS80031_RTCH0_MSB 0x38
  248. #define TPS80031_RTCH1_LSB 0x39
  249. #define TPS80031_RTCH1_MSB 0x3A
  250. #define TPS80031_GPCH0_LSB 0x3B
  251. #define TPS80031_GPCH0_MSB 0x3C
  252. /* SIM, MMC and Battery Detection */
  253. #define TPS80031_SIMDEBOUNCING 0xEB
  254. #define TPS80031_SIMCTRL 0xEC
  255. #define TPS80031_MMCDEBOUNCING 0xED
  256. #define TPS80031_MMCCTRL 0xEE
  257. #define TPS80031_BATDEBOUNCING 0xEF
  258. /* Vibrator Driver and PWMs */
  259. #define TPS80031_VIBCTRL 0x9B
  260. #define TPS80031_VIBMODE 0x9C
  261. #define TPS80031_PWM1ON 0xBA
  262. #define TPS80031_PWM1OFF 0xBB
  263. #define TPS80031_PWM2ON 0xBD
  264. #define TPS80031_PWM2OFF 0xBE
  265. /* Control Interface */
  266. #define TPS80031_INT_STS_A 0xD0
  267. #define TPS80031_INT_STS_B 0xD1
  268. #define TPS80031_INT_STS_C 0xD2
  269. #define TPS80031_INT_MSK_LINE_A 0xD3
  270. #define TPS80031_INT_MSK_LINE_B 0xD4
  271. #define TPS80031_INT_MSK_LINE_C 0xD5
  272. #define TPS80031_INT_MSK_STS_A 0xD6
  273. #define TPS80031_INT_MSK_STS_B 0xD7
  274. #define TPS80031_INT_MSK_STS_C 0xD8
  275. #define TPS80031_TOGGLE1 0x90
  276. #define TPS80031_TOGGLE2 0x91
  277. #define TPS80031_TOGGLE3 0x92
  278. #define TPS80031_PWDNSTATUS1 0x93
  279. #define TPS80031_PWDNSTATUS2 0x94
  280. #define TPS80031_VALIDITY0 0x17
  281. #define TPS80031_VALIDITY1 0x18
  282. #define TPS80031_VALIDITY2 0x19
  283. #define TPS80031_VALIDITY3 0x1A
  284. #define TPS80031_VALIDITY4 0x1B
  285. #define TPS80031_VALIDITY5 0x1C
  286. #define TPS80031_VALIDITY6 0x1D
  287. #define TPS80031_VALIDITY7 0x1E
  288. /* Version number related register */
  289. #define TPS80031_JTAGVERNUM 0x87
  290. #define TPS80031_EPROM_REV 0xDF
  291. /* GPADC Trimming Bits. */
  292. #define TPS80031_GPADC_TRIM0 0xCC
  293. #define TPS80031_GPADC_TRIM1 0xCD
  294. #define TPS80031_GPADC_TRIM2 0xCE
  295. #define TPS80031_GPADC_TRIM3 0xCF
  296. #define TPS80031_GPADC_TRIM4 0xD0
  297. #define TPS80031_GPADC_TRIM5 0xD1
  298. #define TPS80031_GPADC_TRIM6 0xD2
  299. #define TPS80031_GPADC_TRIM7 0xD3
  300. #define TPS80031_GPADC_TRIM8 0xD4
  301. #define TPS80031_GPADC_TRIM9 0xD5
  302. #define TPS80031_GPADC_TRIM10 0xD6
  303. #define TPS80031_GPADC_TRIM11 0xD7
  304. #define TPS80031_GPADC_TRIM12 0xD8
  305. #define TPS80031_GPADC_TRIM13 0xD9
  306. #define TPS80031_GPADC_TRIM14 0xDA
  307. #define TPS80031_GPADC_TRIM15 0xDB
  308. #define TPS80031_GPADC_TRIM16 0xDC
  309. #define TPS80031_GPADC_TRIM17 0xDD
  310. #define TPS80031_GPADC_TRIM18 0xDE
  311. /* TPS80031_CONTROLLER_STAT1 bit fields */
  312. #define TPS80031_CONTROLLER_STAT1_BAT_TEMP 0
  313. #define TPS80031_CONTROLLER_STAT1_BAT_REMOVED 1
  314. #define TPS80031_CONTROLLER_STAT1_VBUS_DET 2
  315. #define TPS80031_CONTROLLER_STAT1_VAC_DET 3
  316. #define TPS80031_CONTROLLER_STAT1_FAULT_WDG 4
  317. #define TPS80031_CONTROLLER_STAT1_LINCH_GATED 6
  318. /* TPS80031_CONTROLLER_INT_MASK bit filed */
  319. #define TPS80031_CONTROLLER_INT_MASK_MVAC_DET 0
  320. #define TPS80031_CONTROLLER_INT_MASK_MVBUS_DET 1
  321. #define TPS80031_CONTROLLER_INT_MASK_MBAT_TEMP 2
  322. #define TPS80031_CONTROLLER_INT_MASK_MFAULT_WDG 3
  323. #define TPS80031_CONTROLLER_INT_MASK_MBAT_REMOVED 4
  324. #define TPS80031_CONTROLLER_INT_MASK_MLINCH_GATED 5
  325. #define TPS80031_CHARGE_CONTROL_SUB_INT_MASK 0x3F
  326. /* TPS80031_PHOENIX_DEV_ON bit field */
  327. #define TPS80031_DEVOFF 0x1
  328. #define TPS80031_EXT_CONTROL_CFG_TRANS 0
  329. #define TPS80031_EXT_CONTROL_CFG_STATE 1
  330. /* State register field */
  331. #define TPS80031_STATE_OFF 0x00
  332. #define TPS80031_STATE_ON 0x01
  333. #define TPS80031_STATE_MASK 0x03
  334. /* Trans register field */
  335. #define TPS80031_TRANS_ACTIVE_OFF 0x00
  336. #define TPS80031_TRANS_ACTIVE_ON 0x01
  337. #define TPS80031_TRANS_ACTIVE_MASK 0x03
  338. #define TPS80031_TRANS_SLEEP_OFF 0x00
  339. #define TPS80031_TRANS_SLEEP_ON 0x04
  340. #define TPS80031_TRANS_SLEEP_MASK 0x0C
  341. #define TPS80031_TRANS_OFF_OFF 0x00
  342. #define TPS80031_TRANS_OFF_ACTIVE 0x10
  343. #define TPS80031_TRANS_OFF_MASK 0x30
  344. #define TPS80031_EXT_PWR_REQ (TPS80031_PWR_REQ_INPUT_PREQ1 | \
  345. TPS80031_PWR_REQ_INPUT_PREQ2 | \
  346. TPS80031_PWR_REQ_INPUT_PREQ3)
  347. /* TPS80031_BBSPOR_CFG bit field */
  348. #define TPS80031_BBSPOR_CHG_EN 0x8
  349. #define TPS80031_MAX_REGISTER 0xFF
  350. struct i2c_client;
  351. /* Supported chips */
  352. enum chips {
  353. TPS80031 = 0x00000001,
  354. TPS80032 = 0x00000002,
  355. };
  356. enum {
  357. TPS80031_INT_PWRON,
  358. TPS80031_INT_RPWRON,
  359. TPS80031_INT_SYS_VLOW,
  360. TPS80031_INT_RTC_ALARM,
  361. TPS80031_INT_RTC_PERIOD,
  362. TPS80031_INT_HOT_DIE,
  363. TPS80031_INT_VXX_SHORT,
  364. TPS80031_INT_SPDURATION,
  365. TPS80031_INT_WATCHDOG,
  366. TPS80031_INT_BAT,
  367. TPS80031_INT_SIM,
  368. TPS80031_INT_MMC,
  369. TPS80031_INT_RES,
  370. TPS80031_INT_GPADC_RT,
  371. TPS80031_INT_GPADC_SW2_EOC,
  372. TPS80031_INT_CC_AUTOCAL,
  373. TPS80031_INT_ID_WKUP,
  374. TPS80031_INT_VBUSS_WKUP,
  375. TPS80031_INT_ID,
  376. TPS80031_INT_VBUS,
  377. TPS80031_INT_CHRG_CTRL,
  378. TPS80031_INT_EXT_CHRG,
  379. TPS80031_INT_INT_CHRG,
  380. TPS80031_INT_RES2,
  381. TPS80031_INT_BAT_TEMP_OVRANGE,
  382. TPS80031_INT_BAT_REMOVED,
  383. TPS80031_INT_VBUS_DET,
  384. TPS80031_INT_VAC_DET,
  385. TPS80031_INT_FAULT_WDG,
  386. TPS80031_INT_LINCH_GATED,
  387. /* Last interrupt id to get the end number */
  388. TPS80031_INT_NR,
  389. };
  390. /* TPS80031 Slave IDs */
  391. #define TPS80031_NUM_SLAVES 4
  392. #define TPS80031_SLAVE_ID0 0
  393. #define TPS80031_SLAVE_ID1 1
  394. #define TPS80031_SLAVE_ID2 2
  395. #define TPS80031_SLAVE_ID3 3
  396. /* TPS80031 I2C addresses */
  397. #define TPS80031_I2C_ID0_ADDR 0x12
  398. #define TPS80031_I2C_ID1_ADDR 0x48
  399. #define TPS80031_I2C_ID2_ADDR 0x49
  400. #define TPS80031_I2C_ID3_ADDR 0x4A
  401. enum {
  402. TPS80031_REGULATOR_VIO,
  403. TPS80031_REGULATOR_SMPS1,
  404. TPS80031_REGULATOR_SMPS2,
  405. TPS80031_REGULATOR_SMPS3,
  406. TPS80031_REGULATOR_SMPS4,
  407. TPS80031_REGULATOR_VANA,
  408. TPS80031_REGULATOR_LDO1,
  409. TPS80031_REGULATOR_LDO2,
  410. TPS80031_REGULATOR_LDO3,
  411. TPS80031_REGULATOR_LDO4,
  412. TPS80031_REGULATOR_LDO5,
  413. TPS80031_REGULATOR_LDO6,
  414. TPS80031_REGULATOR_LDO7,
  415. TPS80031_REGULATOR_LDOLN,
  416. TPS80031_REGULATOR_LDOUSB,
  417. TPS80031_REGULATOR_VBUS,
  418. TPS80031_REGULATOR_REGEN1,
  419. TPS80031_REGULATOR_REGEN2,
  420. TPS80031_REGULATOR_SYSEN,
  421. TPS80031_REGULATOR_MAX,
  422. };
  423. /* Different configurations for the rails */
  424. enum {
  425. /* USBLDO input selection */
  426. TPS80031_USBLDO_INPUT_VSYS = 0x00000001,
  427. TPS80031_USBLDO_INPUT_PMID = 0x00000002,
  428. /* LDO3 output mode */
  429. TPS80031_LDO3_OUTPUT_VIB = 0x00000004,
  430. /* VBUS configuration */
  431. TPS80031_VBUS_DISCHRG_EN_PDN = 0x00000004,
  432. TPS80031_VBUS_SW_ONLY = 0x00000008,
  433. TPS80031_VBUS_SW_N_ID = 0x00000010,
  434. };
  435. /* External controls requests */
  436. enum tps80031_ext_control {
  437. TPS80031_PWR_REQ_INPUT_NONE = 0x00000000,
  438. TPS80031_PWR_REQ_INPUT_PREQ1 = 0x00000001,
  439. TPS80031_PWR_REQ_INPUT_PREQ2 = 0x00000002,
  440. TPS80031_PWR_REQ_INPUT_PREQ3 = 0x00000004,
  441. TPS80031_PWR_OFF_ON_SLEEP = 0x00000008,
  442. TPS80031_PWR_ON_ON_SLEEP = 0x00000010,
  443. };
  444. enum tps80031_pupd_pins {
  445. TPS80031_PREQ1 = 0,
  446. TPS80031_PREQ2A,
  447. TPS80031_PREQ2B,
  448. TPS80031_PREQ2C,
  449. TPS80031_PREQ3,
  450. TPS80031_NRES_WARM,
  451. TPS80031_PWM_FORCE,
  452. TPS80031_CHRG_EXT_CHRG_STATZ,
  453. TPS80031_SIM,
  454. TPS80031_MMC,
  455. TPS80031_GPADC_START,
  456. TPS80031_DVSI2C_SCL,
  457. TPS80031_DVSI2C_SDA,
  458. TPS80031_CTLI2C_SCL,
  459. TPS80031_CTLI2C_SDA,
  460. };
  461. enum tps80031_pupd_settings {
  462. TPS80031_PUPD_NORMAL,
  463. TPS80031_PUPD_PULLDOWN,
  464. TPS80031_PUPD_PULLUP,
  465. };
  466. struct tps80031 {
  467. struct device *dev;
  468. unsigned long chip_info;
  469. int es_version;
  470. struct i2c_client *clients[TPS80031_NUM_SLAVES];
  471. struct regmap *regmap[TPS80031_NUM_SLAVES];
  472. struct regmap_irq_chip_data *irq_data;
  473. };
  474. struct tps80031_pupd_init_data {
  475. int input_pin;
  476. int setting;
  477. };
  478. /*
  479. * struct tps80031_regulator_platform_data - tps80031 regulator platform data.
  480. *
  481. * @reg_init_data: The regulator init data.
  482. * @ext_ctrl_flag: External control flag for sleep/power request control.
  483. * @config_flags: Configuration flag to configure the rails.
  484. * It should be ORed of config enums.
  485. */
  486. struct tps80031_regulator_platform_data {
  487. struct regulator_init_data *reg_init_data;
  488. unsigned int ext_ctrl_flag;
  489. unsigned int config_flags;
  490. };
  491. struct tps80031_platform_data {
  492. int irq_base;
  493. bool use_power_off;
  494. struct tps80031_pupd_init_data *pupd_init_data;
  495. int pupd_init_data_size;
  496. struct tps80031_regulator_platform_data
  497. *regulator_pdata[TPS80031_REGULATOR_MAX];
  498. };
  499. static inline int tps80031_write(struct device *dev, int sid,
  500. int reg, uint8_t val)
  501. {
  502. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  503. return regmap_write(tps80031->regmap[sid], reg, val);
  504. }
  505. static inline int tps80031_writes(struct device *dev, int sid, int reg,
  506. int len, uint8_t *val)
  507. {
  508. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  509. return regmap_bulk_write(tps80031->regmap[sid], reg, val, len);
  510. }
  511. static inline int tps80031_read(struct device *dev, int sid,
  512. int reg, uint8_t *val)
  513. {
  514. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  515. unsigned int ival;
  516. int ret;
  517. ret = regmap_read(tps80031->regmap[sid], reg, &ival);
  518. if (ret < 0) {
  519. dev_err(dev, "failed reading from reg 0x%02x\n", reg);
  520. return ret;
  521. }
  522. *val = ival;
  523. return ret;
  524. }
  525. static inline int tps80031_reads(struct device *dev, int sid,
  526. int reg, int len, uint8_t *val)
  527. {
  528. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  529. return regmap_bulk_read(tps80031->regmap[sid], reg, val, len);
  530. }
  531. static inline int tps80031_set_bits(struct device *dev, int sid,
  532. int reg, uint8_t bit_mask)
  533. {
  534. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  535. return regmap_update_bits(tps80031->regmap[sid], reg,
  536. bit_mask, bit_mask);
  537. }
  538. static inline int tps80031_clr_bits(struct device *dev, int sid,
  539. int reg, uint8_t bit_mask)
  540. {
  541. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  542. return regmap_update_bits(tps80031->regmap[sid], reg, bit_mask, 0);
  543. }
  544. static inline int tps80031_update(struct device *dev, int sid,
  545. int reg, uint8_t val, uint8_t mask)
  546. {
  547. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  548. return regmap_update_bits(tps80031->regmap[sid], reg, mask, val);
  549. }
  550. static inline unsigned long tps80031_get_chip_info(struct device *dev)
  551. {
  552. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  553. return tps80031->chip_info;
  554. }
  555. static inline int tps80031_get_pmu_version(struct device *dev)
  556. {
  557. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  558. return tps80031->es_version;
  559. }
  560. static inline int tps80031_irq_get_virq(struct device *dev, int irq)
  561. {
  562. struct tps80031 *tps80031 = dev_get_drvdata(dev);
  563. return regmap_irq_get_virq(tps80031->irq_data, irq);
  564. }
  565. extern int tps80031_ext_power_req_config(struct device *dev,
  566. unsigned long ext_ctrl_flag, int preq_bit,
  567. int state_reg_add, int trans_reg_add);
  568. #endif /*__LINUX_MFD_TPS80031_H */