pm2301_charger.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2012
  3. *
  4. * PM2301 power supply interface
  5. *
  6. * License terms: GNU General Public License (GPL), version 2
  7. */
  8. #ifndef PM2301_CHARGER_H
  9. #define PM2301_CHARGER_H
  10. /* Watchdog timeout constant */
  11. #define WD_TIMER 0x30 /* 4min */
  12. #define WD_KICK_INTERVAL (30 * HZ)
  13. #define PM2XXX_NUM_INT_REG 0x6
  14. /* Constant voltage/current */
  15. #define PM2XXX_CONST_CURR 0x0
  16. #define PM2XXX_CONST_VOLT 0x1
  17. /* Lowest charger voltage is 3.39V -> 0x4E */
  18. #define LOW_VOLT_REG 0x4E
  19. #define PM2XXX_BATT_CTRL_REG1 0x00
  20. #define PM2XXX_BATT_CTRL_REG2 0x01
  21. #define PM2XXX_BATT_CTRL_REG3 0x02
  22. #define PM2XXX_BATT_CTRL_REG4 0x03
  23. #define PM2XXX_BATT_CTRL_REG5 0x04
  24. #define PM2XXX_BATT_CTRL_REG6 0x05
  25. #define PM2XXX_BATT_CTRL_REG7 0x06
  26. #define PM2XXX_BATT_CTRL_REG8 0x07
  27. #define PM2XXX_NTC_CTRL_REG1 0x08
  28. #define PM2XXX_NTC_CTRL_REG2 0x09
  29. #define PM2XXX_BATT_CTRL_REG9 0x0A
  30. #define PM2XXX_BATT_STAT_REG1 0x0B
  31. #define PM2XXX_INP_VOLT_VPWR2 0x11
  32. #define PM2XXX_INP_DROP_VPWR2 0x13
  33. #define PM2XXX_INP_VOLT_VPWR1 0x15
  34. #define PM2XXX_INP_DROP_VPWR1 0x17
  35. #define PM2XXX_INP_MODE_VPWR 0x18
  36. #define PM2XXX_BATT_WD_KICK 0x70
  37. #define PM2XXX_DEV_VER_STAT 0x0C
  38. #define PM2XXX_THERM_WARN_CTRL_REG 0x20
  39. #define PM2XXX_BATT_DISC_REG 0x21
  40. #define PM2XXX_BATT_LOW_LEV_COMP_REG 0x22
  41. #define PM2XXX_BATT_LOW_LEV_VAL_REG 0x23
  42. #define PM2XXX_I2C_PAD_CTRL_REG 0x24
  43. #define PM2XXX_SW_CTRL_REG 0x26
  44. #define PM2XXX_LED_CTRL_REG 0x28
  45. #define PM2XXX_REG_INT1 0x40
  46. #define PM2XXX_MASK_REG_INT1 0x50
  47. #define PM2XXX_SRCE_REG_INT1 0x60
  48. #define PM2XXX_REG_INT2 0x41
  49. #define PM2XXX_MASK_REG_INT2 0x51
  50. #define PM2XXX_SRCE_REG_INT2 0x61
  51. #define PM2XXX_REG_INT3 0x42
  52. #define PM2XXX_MASK_REG_INT3 0x52
  53. #define PM2XXX_SRCE_REG_INT3 0x62
  54. #define PM2XXX_REG_INT4 0x43
  55. #define PM2XXX_MASK_REG_INT4 0x53
  56. #define PM2XXX_SRCE_REG_INT4 0x63
  57. #define PM2XXX_REG_INT5 0x44
  58. #define PM2XXX_MASK_REG_INT5 0x54
  59. #define PM2XXX_SRCE_REG_INT5 0x64
  60. #define PM2XXX_REG_INT6 0x45
  61. #define PM2XXX_MASK_REG_INT6 0x55
  62. #define PM2XXX_SRCE_REG_INT6 0x65
  63. #define VPWR_OVV 0x0
  64. #define VSYSTEM_OVV 0x1
  65. /* control Reg 1 */
  66. #define PM2XXX_CH_RESUME_EN 0x1
  67. #define PM2XXX_CH_RESUME_DIS 0x0
  68. /* control Reg 2 */
  69. #define PM2XXX_CH_AUTO_RESUME_EN 0X2
  70. #define PM2XXX_CH_AUTO_RESUME_DIS 0X0
  71. #define PM2XXX_CHARGER_ENA 0x4
  72. #define PM2XXX_CHARGER_DIS 0x0
  73. /* control Reg 3 */
  74. #define PM2XXX_CH_WD_CC_PHASE_OFF 0x0
  75. #define PM2XXX_CH_WD_CC_PHASE_5MIN 0x1
  76. #define PM2XXX_CH_WD_CC_PHASE_10MIN 0x2
  77. #define PM2XXX_CH_WD_CC_PHASE_30MIN 0x3
  78. #define PM2XXX_CH_WD_CC_PHASE_60MIN 0x4
  79. #define PM2XXX_CH_WD_CC_PHASE_120MIN 0x5
  80. #define PM2XXX_CH_WD_CC_PHASE_240MIN 0x6
  81. #define PM2XXX_CH_WD_CC_PHASE_360MIN 0x7
  82. #define PM2XXX_CH_WD_CV_PHASE_OFF (0x0<<3)
  83. #define PM2XXX_CH_WD_CV_PHASE_5MIN (0x1<<3)
  84. #define PM2XXX_CH_WD_CV_PHASE_10MIN (0x2<<3)
  85. #define PM2XXX_CH_WD_CV_PHASE_30MIN (0x3<<3)
  86. #define PM2XXX_CH_WD_CV_PHASE_60MIN (0x4<<3)
  87. #define PM2XXX_CH_WD_CV_PHASE_120MIN (0x5<<3)
  88. #define PM2XXX_CH_WD_CV_PHASE_240MIN (0x6<<3)
  89. #define PM2XXX_CH_WD_CV_PHASE_360MIN (0x7<<3)
  90. /* control Reg 4 */
  91. #define PM2XXX_CH_WD_PRECH_PHASE_OFF 0x0
  92. #define PM2XXX_CH_WD_PRECH_PHASE_1MIN 0x1
  93. #define PM2XXX_CH_WD_PRECH_PHASE_5MIN 0x2
  94. #define PM2XXX_CH_WD_PRECH_PHASE_10MIN 0x3
  95. #define PM2XXX_CH_WD_PRECH_PHASE_30MIN 0x4
  96. #define PM2XXX_CH_WD_PRECH_PHASE_60MIN 0x5
  97. #define PM2XXX_CH_WD_PRECH_PHASE_120MIN 0x6
  98. #define PM2XXX_CH_WD_PRECH_PHASE_240MIN 0x7
  99. /* control Reg 5 */
  100. #define PM2XXX_CH_WD_AUTO_TIMEOUT_NONE 0x0
  101. #define PM2XXX_CH_WD_AUTO_TIMEOUT_20MIN 0x1
  102. /* control Reg 6 */
  103. #define PM2XXX_DIR_CH_CC_CURRENT_MASK 0x0F
  104. #define PM2XXX_DIR_CH_CC_CURRENT_200MA 0x0
  105. #define PM2XXX_DIR_CH_CC_CURRENT_400MA 0x2
  106. #define PM2XXX_DIR_CH_CC_CURRENT_600MA 0x3
  107. #define PM2XXX_DIR_CH_CC_CURRENT_800MA 0x4
  108. #define PM2XXX_DIR_CH_CC_CURRENT_1000MA 0x5
  109. #define PM2XXX_DIR_CH_CC_CURRENT_1200MA 0x6
  110. #define PM2XXX_DIR_CH_CC_CURRENT_1400MA 0x7
  111. #define PM2XXX_DIR_CH_CC_CURRENT_1600MA 0x8
  112. #define PM2XXX_DIR_CH_CC_CURRENT_1800MA 0x9
  113. #define PM2XXX_DIR_CH_CC_CURRENT_2000MA 0xA
  114. #define PM2XXX_DIR_CH_CC_CURRENT_2200MA 0xB
  115. #define PM2XXX_DIR_CH_CC_CURRENT_2400MA 0xC
  116. #define PM2XXX_DIR_CH_CC_CURRENT_2600MA 0xD
  117. #define PM2XXX_DIR_CH_CC_CURRENT_2800MA 0xE
  118. #define PM2XXX_DIR_CH_CC_CURRENT_3000MA 0xF
  119. #define PM2XXX_CH_PRECH_CURRENT_MASK 0x30
  120. #define PM2XXX_CH_PRECH_CURRENT_25MA (0x0<<4)
  121. #define PM2XXX_CH_PRECH_CURRENT_50MA (0x1<<4)
  122. #define PM2XXX_CH_PRECH_CURRENT_75MA (0x2<<4)
  123. #define PM2XXX_CH_PRECH_CURRENT_100MA (0x3<<4)
  124. #define PM2XXX_CH_EOC_CURRENT_MASK 0xC0
  125. #define PM2XXX_CH_EOC_CURRENT_100MA (0x0<<6)
  126. #define PM2XXX_CH_EOC_CURRENT_150MA (0x1<<6)
  127. #define PM2XXX_CH_EOC_CURRENT_300MA (0x2<<6)
  128. #define PM2XXX_CH_EOC_CURRENT_400MA (0x3<<6)
  129. /* control Reg 7 */
  130. #define PM2XXX_CH_PRECH_VOL_2_5 0x0
  131. #define PM2XXX_CH_PRECH_VOL_2_7 0x1
  132. #define PM2XXX_CH_PRECH_VOL_2_9 0x2
  133. #define PM2XXX_CH_PRECH_VOL_3_1 0x3
  134. #define PM2XXX_CH_VRESUME_VOL_3_2 (0x0<<2)
  135. #define PM2XXX_CH_VRESUME_VOL_3_4 (0x1<<2)
  136. #define PM2XXX_CH_VRESUME_VOL_3_6 (0x2<<2)
  137. #define PM2XXX_CH_VRESUME_VOL_3_8 (0x3<<2)
  138. /* control Reg 8 */
  139. #define PM2XXX_CH_VOLT_MASK 0x3F
  140. #define PM2XXX_CH_VOLT_3_5 0x0
  141. #define PM2XXX_CH_VOLT_3_5225 0x1
  142. #define PM2XXX_CH_VOLT_3_6 0x4
  143. #define PM2XXX_CH_VOLT_3_7 0x8
  144. #define PM2XXX_CH_VOLT_4_0 0x14
  145. #define PM2XXX_CH_VOLT_4_175 0x1B
  146. #define PM2XXX_CH_VOLT_4_2 0x1C
  147. #define PM2XXX_CH_VOLT_4_275 0x1F
  148. #define PM2XXX_CH_VOLT_4_3 0x20
  149. /*NTC control register 1*/
  150. #define PM2XXX_BTEMP_HIGH_TH_45 0x0
  151. #define PM2XXX_BTEMP_HIGH_TH_50 0x1
  152. #define PM2XXX_BTEMP_HIGH_TH_55 0x2
  153. #define PM2XXX_BTEMP_HIGH_TH_60 0x3
  154. #define PM2XXX_BTEMP_HIGH_TH_65 0x4
  155. #define PM2XXX_BTEMP_LOW_TH_N5 (0x0<<3)
  156. #define PM2XXX_BTEMP_LOW_TH_0 (0x1<<3)
  157. #define PM2XXX_BTEMP_LOW_TH_5 (0x2<<3)
  158. #define PM2XXX_BTEMP_LOW_TH_10 (0x3<<3)
  159. /*NTC control register 2*/
  160. #define PM2XXX_NTC_BETA_COEFF_3477 0x0
  161. #define PM2XXX_NTC_BETA_COEFF_3964 0x1
  162. #define PM2XXX_NTC_RES_10K (0x0<<2)
  163. #define PM2XXX_NTC_RES_47K (0x1<<2)
  164. #define PM2XXX_NTC_RES_100K (0x2<<2)
  165. #define PM2XXX_NTC_RES_NO_NTC (0x3<<2)
  166. /* control Reg 9 */
  167. #define PM2XXX_CH_CC_MODEDROP_EN 1
  168. #define PM2XXX_CH_CC_MODEDROP_DIS 0
  169. #define PM2XXX_CH_CC_REDUCED_CURRENT_100MA (0x0<<1)
  170. #define PM2XXX_CH_CC_REDUCED_CURRENT_200MA (0x1<<1)
  171. #define PM2XXX_CH_CC_REDUCED_CURRENT_400MA (0x2<<1)
  172. #define PM2XXX_CH_CC_REDUCED_CURRENT_IDENT (0x3<<1)
  173. #define PM2XXX_CHARCHING_INFO_DIS (0<<3)
  174. #define PM2XXX_CHARCHING_INFO_EN (1<<3)
  175. #define PM2XXX_CH_150MV_DROP_300MV (0<<4)
  176. #define PM2XXX_CH_150MV_DROP_150MV (1<<4)
  177. /* charger status register */
  178. #define PM2XXX_CHG_STATUS_OFF 0x0
  179. #define PM2XXX_CHG_STATUS_ON 0x1
  180. #define PM2XXX_CHG_STATUS_FULL 0x2
  181. #define PM2XXX_CHG_STATUS_ERR 0x3
  182. #define PM2XXX_CHG_STATUS_WAIT 0x4
  183. #define PM2XXX_CHG_STATUS_NOBAT 0x5
  184. /* Input charger voltage VPWR2 */
  185. #define PM2XXX_VPWR2_OVV_6_0 0x0
  186. #define PM2XXX_VPWR2_OVV_6_3 0x1
  187. #define PM2XXX_VPWR2_OVV_10 0x2
  188. #define PM2XXX_VPWR2_OVV_NONE 0x3
  189. /* Input charger drop VPWR2 */
  190. #define PM2XXX_VPWR2_HW_OPT_EN (0x1<<4)
  191. #define PM2XXX_VPWR2_HW_OPT_DIS (0x0<<4)
  192. #define PM2XXX_VPWR2_VALID_EN (0x1<<3)
  193. #define PM2XXX_VPWR2_VALID_DIS (0x0<<3)
  194. #define PM2XXX_VPWR2_DROP_EN (0x1<<2)
  195. #define PM2XXX_VPWR2_DROP_DIS (0x0<<2)
  196. /* Input charger voltage VPWR1 */
  197. #define PM2XXX_VPWR1_OVV_6_0 0x0
  198. #define PM2XXX_VPWR1_OVV_6_3 0x1
  199. #define PM2XXX_VPWR1_OVV_10 0x2
  200. #define PM2XXX_VPWR1_OVV_NONE 0x3
  201. /* Input charger drop VPWR1 */
  202. #define PM2XXX_VPWR1_HW_OPT_EN (0x1<<4)
  203. #define PM2XXX_VPWR1_HW_OPT_DIS (0x0<<4)
  204. #define PM2XXX_VPWR1_VALID_EN (0x1<<3)
  205. #define PM2XXX_VPWR1_VALID_DIS (0x0<<3)
  206. #define PM2XXX_VPWR1_DROP_EN (0x1<<2)
  207. #define PM2XXX_VPWR1_DROP_DIS (0x0<<2)
  208. /* Battery low level comparator control register */
  209. #define PM2XXX_VBAT_LOW_MONITORING_DIS 0x0
  210. #define PM2XXX_VBAT_LOW_MONITORING_ENA 0x1
  211. /* Battery low level value control register */
  212. #define PM2XXX_VBAT_LOW_LEVEL_2_3 0x0
  213. #define PM2XXX_VBAT_LOW_LEVEL_2_4 0x1
  214. #define PM2XXX_VBAT_LOW_LEVEL_2_5 0x2
  215. #define PM2XXX_VBAT_LOW_LEVEL_2_6 0x3
  216. #define PM2XXX_VBAT_LOW_LEVEL_2_7 0x4
  217. #define PM2XXX_VBAT_LOW_LEVEL_2_8 0x5
  218. #define PM2XXX_VBAT_LOW_LEVEL_2_9 0x6
  219. #define PM2XXX_VBAT_LOW_LEVEL_3_0 0x7
  220. #define PM2XXX_VBAT_LOW_LEVEL_3_1 0x8
  221. #define PM2XXX_VBAT_LOW_LEVEL_3_2 0x9
  222. #define PM2XXX_VBAT_LOW_LEVEL_3_3 0xA
  223. #define PM2XXX_VBAT_LOW_LEVEL_3_4 0xB
  224. #define PM2XXX_VBAT_LOW_LEVEL_3_5 0xC
  225. #define PM2XXX_VBAT_LOW_LEVEL_3_6 0xD
  226. #define PM2XXX_VBAT_LOW_LEVEL_3_7 0xE
  227. #define PM2XXX_VBAT_LOW_LEVEL_3_8 0xF
  228. #define PM2XXX_VBAT_LOW_LEVEL_3_9 0x10
  229. #define PM2XXX_VBAT_LOW_LEVEL_4_0 0x11
  230. #define PM2XXX_VBAT_LOW_LEVEL_4_1 0x12
  231. #define PM2XXX_VBAT_LOW_LEVEL_4_2 0x13
  232. /* SW CTRL */
  233. #define PM2XXX_SWCTRL_HW 0x0
  234. #define PM2XXX_SWCTRL_SW 0x1
  235. /* LED Driver Control */
  236. #define PM2XXX_LED_CURRENT_MASK 0x0C
  237. #define PM2XXX_LED_CURRENT_2_5MA (0X0<<2)
  238. #define PM2XXX_LED_CURRENT_1MA (0X1<<2)
  239. #define PM2XXX_LED_CURRENT_5MA (0X2<<2)
  240. #define PM2XXX_LED_CURRENT_10MA (0X3<<2)
  241. #define PM2XXX_LED_SELECT_MASK 0x02
  242. #define PM2XXX_LED_SELECT_EN (0X0<<1)
  243. #define PM2XXX_LED_SELECT_DIS (0X1<<1)
  244. #define PM2XXX_ANTI_OVERSHOOT_MASK 0x01
  245. #define PM2XXX_ANTI_OVERSHOOT_DIS 0X0
  246. #define PM2XXX_ANTI_OVERSHOOT_EN 0X1
  247. enum pm2xxx_reg_int1 {
  248. PM2XXX_INT1_ITVBATDISCONNECT = 0x02,
  249. PM2XXX_INT1_ITVBATLOWR = 0x04,
  250. PM2XXX_INT1_ITVBATLOWF = 0x08,
  251. };
  252. enum pm2xxx_mask_reg_int1 {
  253. PM2XXX_INT1_M_ITVBATDISCONNECT = 0x02,
  254. PM2XXX_INT1_M_ITVBATLOWR = 0x04,
  255. PM2XXX_INT1_M_ITVBATLOWF = 0x08,
  256. };
  257. enum pm2xxx_source_reg_int1 {
  258. PM2XXX_INT1_S_ITVBATDISCONNECT = 0x02,
  259. PM2XXX_INT1_S_ITVBATLOWR = 0x04,
  260. PM2XXX_INT1_S_ITVBATLOWF = 0x08,
  261. };
  262. enum pm2xxx_reg_int2 {
  263. PM2XXX_INT2_ITVPWR2PLUG = 0x01,
  264. PM2XXX_INT2_ITVPWR2UNPLUG = 0x02,
  265. PM2XXX_INT2_ITVPWR1PLUG = 0x04,
  266. PM2XXX_INT2_ITVPWR1UNPLUG = 0x08,
  267. };
  268. enum pm2xxx_mask_reg_int2 {
  269. PM2XXX_INT2_M_ITVPWR2PLUG = 0x01,
  270. PM2XXX_INT2_M_ITVPWR2UNPLUG = 0x02,
  271. PM2XXX_INT2_M_ITVPWR1PLUG = 0x04,
  272. PM2XXX_INT2_M_ITVPWR1UNPLUG = 0x08,
  273. };
  274. enum pm2xxx_source_reg_int2 {
  275. PM2XXX_INT2_S_ITVPWR2PLUG = 0x03,
  276. PM2XXX_INT2_S_ITVPWR1PLUG = 0x0c,
  277. };
  278. enum pm2xxx_reg_int3 {
  279. PM2XXX_INT3_ITCHPRECHARGEWD = 0x01,
  280. PM2XXX_INT3_ITCHCCWD = 0x02,
  281. PM2XXX_INT3_ITCHCVWD = 0x04,
  282. PM2XXX_INT3_ITAUTOTIMEOUTWD = 0x08,
  283. };
  284. enum pm2xxx_mask_reg_int3 {
  285. PM2XXX_INT3_M_ITCHPRECHARGEWD = 0x01,
  286. PM2XXX_INT3_M_ITCHCCWD = 0x02,
  287. PM2XXX_INT3_M_ITCHCVWD = 0x04,
  288. PM2XXX_INT3_M_ITAUTOTIMEOUTWD = 0x08,
  289. };
  290. enum pm2xxx_source_reg_int3 {
  291. PM2XXX_INT3_S_ITCHPRECHARGEWD = 0x01,
  292. PM2XXX_INT3_S_ITCHCCWD = 0x02,
  293. PM2XXX_INT3_S_ITCHCVWD = 0x04,
  294. PM2XXX_INT3_S_ITAUTOTIMEOUTWD = 0x08,
  295. };
  296. enum pm2xxx_reg_int4 {
  297. PM2XXX_INT4_ITBATTEMPCOLD = 0x01,
  298. PM2XXX_INT4_ITBATTEMPHOT = 0x02,
  299. PM2XXX_INT4_ITVPWR2OVV = 0x04,
  300. PM2XXX_INT4_ITVPWR1OVV = 0x08,
  301. PM2XXX_INT4_ITCHARGINGON = 0x10,
  302. PM2XXX_INT4_ITVRESUME = 0x20,
  303. PM2XXX_INT4_ITBATTFULL = 0x40,
  304. PM2XXX_INT4_ITCVPHASE = 0x80,
  305. };
  306. enum pm2xxx_mask_reg_int4 {
  307. PM2XXX_INT4_M_ITBATTEMPCOLD = 0x01,
  308. PM2XXX_INT4_M_ITBATTEMPHOT = 0x02,
  309. PM2XXX_INT4_M_ITVPWR2OVV = 0x04,
  310. PM2XXX_INT4_M_ITVPWR1OVV = 0x08,
  311. PM2XXX_INT4_M_ITCHARGINGON = 0x10,
  312. PM2XXX_INT4_M_ITVRESUME = 0x20,
  313. PM2XXX_INT4_M_ITBATTFULL = 0x40,
  314. PM2XXX_INT4_M_ITCVPHASE = 0x80,
  315. };
  316. enum pm2xxx_source_reg_int4 {
  317. PM2XXX_INT4_S_ITBATTEMPCOLD = 0x01,
  318. PM2XXX_INT4_S_ITBATTEMPHOT = 0x02,
  319. PM2XXX_INT4_S_ITVPWR2OVV = 0x04,
  320. PM2XXX_INT4_S_ITVPWR1OVV = 0x08,
  321. PM2XXX_INT4_S_ITCHARGINGON = 0x10,
  322. PM2XXX_INT4_S_ITVRESUME = 0x20,
  323. PM2XXX_INT4_S_ITBATTFULL = 0x40,
  324. PM2XXX_INT4_S_ITCVPHASE = 0x80,
  325. };
  326. enum pm2xxx_reg_int5 {
  327. PM2XXX_INT5_ITTHERMALSHUTDOWNRISE = 0x01,
  328. PM2XXX_INT5_ITTHERMALSHUTDOWNFALL = 0x02,
  329. PM2XXX_INT5_ITTHERMALWARNINGRISE = 0x04,
  330. PM2XXX_INT5_ITTHERMALWARNINGFALL = 0x08,
  331. PM2XXX_INT5_ITVSYSTEMOVV = 0x10,
  332. };
  333. enum pm2xxx_mask_reg_int5 {
  334. PM2XXX_INT5_M_ITTHERMALSHUTDOWNRISE = 0x01,
  335. PM2XXX_INT5_M_ITTHERMALSHUTDOWNFALL = 0x02,
  336. PM2XXX_INT5_M_ITTHERMALWARNINGRISE = 0x04,
  337. PM2XXX_INT5_M_ITTHERMALWARNINGFALL = 0x08,
  338. PM2XXX_INT5_M_ITVSYSTEMOVV = 0x10,
  339. };
  340. enum pm2xxx_source_reg_int5 {
  341. PM2XXX_INT5_S_ITTHERMALSHUTDOWNRISE = 0x01,
  342. PM2XXX_INT5_S_ITTHERMALSHUTDOWNFALL = 0x02,
  343. PM2XXX_INT5_S_ITTHERMALWARNINGRISE = 0x04,
  344. PM2XXX_INT5_S_ITTHERMALWARNINGFALL = 0x08,
  345. PM2XXX_INT5_S_ITVSYSTEMOVV = 0x10,
  346. };
  347. enum pm2xxx_reg_int6 {
  348. PM2XXX_INT6_ITVPWR2DROP = 0x01,
  349. PM2XXX_INT6_ITVPWR1DROP = 0x02,
  350. PM2XXX_INT6_ITVPWR2VALIDRISE = 0x04,
  351. PM2XXX_INT6_ITVPWR2VALIDFALL = 0x08,
  352. PM2XXX_INT6_ITVPWR1VALIDRISE = 0x10,
  353. PM2XXX_INT6_ITVPWR1VALIDFALL = 0x20,
  354. };
  355. enum pm2xxx_mask_reg_int6 {
  356. PM2XXX_INT6_M_ITVPWR2DROP = 0x01,
  357. PM2XXX_INT6_M_ITVPWR1DROP = 0x02,
  358. PM2XXX_INT6_M_ITVPWR2VALIDRISE = 0x04,
  359. PM2XXX_INT6_M_ITVPWR2VALIDFALL = 0x08,
  360. PM2XXX_INT6_M_ITVPWR1VALIDRISE = 0x10,
  361. PM2XXX_INT6_M_ITVPWR1VALIDFALL = 0x20,
  362. };
  363. enum pm2xxx_source_reg_int6 {
  364. PM2XXX_INT6_S_ITVPWR2DROP = 0x01,
  365. PM2XXX_INT6_S_ITVPWR1DROP = 0x02,
  366. PM2XXX_INT6_S_ITVPWR2VALIDRISE = 0x04,
  367. PM2XXX_INT6_S_ITVPWR2VALIDFALL = 0x08,
  368. PM2XXX_INT6_S_ITVPWR1VALIDRISE = 0x10,
  369. PM2XXX_INT6_S_ITVPWR1VALIDFALL = 0x20,
  370. };
  371. struct pm2xxx_charger_info {
  372. int charger_connected;
  373. int charger_online;
  374. int cv_active;
  375. bool wd_expired;
  376. };
  377. struct pm2xxx_charger_event_flags {
  378. bool mainextchnotok;
  379. bool main_thermal_prot;
  380. bool ovv;
  381. bool chgwdexp;
  382. };
  383. struct pm2xxx_interrupts {
  384. u8 reg[PM2XXX_NUM_INT_REG];
  385. int (*handler[PM2XXX_NUM_INT_REG])(void *, int);
  386. };
  387. struct pm2xxx_config {
  388. struct i2c_client *pm2xxx_i2c;
  389. struct i2c_device_id *pm2xxx_id;
  390. };
  391. struct pm2xxx_irq {
  392. char *name;
  393. irqreturn_t (*isr)(int irq, void *data);
  394. };
  395. struct pm2xxx_charger {
  396. struct device *dev;
  397. u8 chip_id;
  398. bool vddadc_en_ac;
  399. struct pm2xxx_config config;
  400. bool ac_conn;
  401. unsigned int gpio_irq;
  402. int vbat;
  403. int old_vbat;
  404. int failure_case;
  405. int failure_input_ovv;
  406. unsigned int lpn_pin;
  407. struct pm2xxx_interrupts *pm2_int;
  408. struct regulator *regu;
  409. struct pm2xxx_bm_data *bat;
  410. struct mutex lock;
  411. struct ab8500 *parent;
  412. struct pm2xxx_charger_info ac;
  413. struct pm2xxx_charger_platform_data *pdata;
  414. struct workqueue_struct *charger_wq;
  415. struct delayed_work check_vbat_work;
  416. struct work_struct ac_work;
  417. struct work_struct check_main_thermal_prot_work;
  418. struct delayed_work check_hw_failure_work;
  419. struct ux500_charger ac_chg;
  420. struct power_supply_desc ac_chg_desc;
  421. struct pm2xxx_charger_event_flags flags;
  422. };
  423. #endif /* PM2301_CHARGER_H */