max14577-private.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. /*
  2. * max14577-private.h - Common API for the Maxim 14577/77836 internal sub chip
  3. *
  4. * Copyright (C) 2014 Samsung Electrnoics
  5. * Chanwoo Choi <cw00.choi@samsung.com>
  6. * Krzysztof Kozlowski <k.kozlowski@samsung.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #ifndef __MAX14577_PRIVATE_H__
  19. #define __MAX14577_PRIVATE_H__
  20. #include <linux/i2c.h>
  21. #include <linux/regmap.h>
  22. #define I2C_ADDR_PMIC (0x46 >> 1)
  23. #define I2C_ADDR_MUIC (0x4A >> 1)
  24. #define I2C_ADDR_FG (0x6C >> 1)
  25. enum maxim_device_type {
  26. MAXIM_DEVICE_TYPE_UNKNOWN = 0,
  27. MAXIM_DEVICE_TYPE_MAX14577,
  28. MAXIM_DEVICE_TYPE_MAX77836,
  29. MAXIM_DEVICE_TYPE_NUM,
  30. };
  31. /* Slave addr = 0x4A: MUIC and Charger */
  32. enum max14577_reg {
  33. MAX14577_REG_DEVICEID = 0x00,
  34. MAX14577_REG_INT1 = 0x01,
  35. MAX14577_REG_INT2 = 0x02,
  36. MAX14577_REG_INT3 = 0x03,
  37. MAX14577_REG_STATUS1 = 0x04,
  38. MAX14577_REG_STATUS2 = 0x05,
  39. MAX14577_REG_STATUS3 = 0x06,
  40. MAX14577_REG_INTMASK1 = 0x07,
  41. MAX14577_REG_INTMASK2 = 0x08,
  42. MAX14577_REG_INTMASK3 = 0x09,
  43. MAX14577_REG_CDETCTRL1 = 0x0A,
  44. MAX14577_REG_RFU = 0x0B,
  45. MAX14577_REG_CONTROL1 = 0x0C,
  46. MAX14577_REG_CONTROL2 = 0x0D,
  47. MAX14577_REG_CONTROL3 = 0x0E,
  48. MAX14577_REG_CHGCTRL1 = 0x0F,
  49. MAX14577_REG_CHGCTRL2 = 0x10,
  50. MAX14577_REG_CHGCTRL3 = 0x11,
  51. MAX14577_REG_CHGCTRL4 = 0x12,
  52. MAX14577_REG_CHGCTRL5 = 0x13,
  53. MAX14577_REG_CHGCTRL6 = 0x14,
  54. MAX14577_REG_CHGCTRL7 = 0x15,
  55. MAX14577_REG_END,
  56. };
  57. /* Slave addr = 0x4A: MUIC */
  58. enum max14577_muic_reg {
  59. MAX14577_MUIC_REG_STATUS1 = 0x04,
  60. MAX14577_MUIC_REG_STATUS2 = 0x05,
  61. MAX14577_MUIC_REG_CONTROL1 = 0x0C,
  62. MAX14577_MUIC_REG_CONTROL3 = 0x0E,
  63. MAX14577_MUIC_REG_END,
  64. };
  65. /*
  66. * Combined charger types for max14577 and max77836.
  67. *
  68. * On max14577 three lower bits map to STATUS2/CHGTYP field.
  69. * However the max77836 has different two last values of STATUS2/CHGTYP.
  70. * To indicate the difference enum has two additional values for max77836.
  71. * These values are just a register value bitwise OR with 0x8.
  72. */
  73. enum max14577_muic_charger_type {
  74. MAX14577_CHARGER_TYPE_NONE = 0x0,
  75. MAX14577_CHARGER_TYPE_USB = 0x1,
  76. MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT = 0x2,
  77. MAX14577_CHARGER_TYPE_DEDICATED_CHG = 0x3,
  78. MAX14577_CHARGER_TYPE_SPECIAL_500MA = 0x4,
  79. /* Special 1A or 2A charger */
  80. MAX14577_CHARGER_TYPE_SPECIAL_1A = 0x5,
  81. /* max14577: reserved, used on max77836 */
  82. MAX14577_CHARGER_TYPE_RESERVED = 0x6,
  83. /* max14577: dead-battery charing with maximum current 100mA */
  84. MAX14577_CHARGER_TYPE_DEAD_BATTERY = 0x7,
  85. /*
  86. * max77836: special charger (bias on D+/D-),
  87. * matches register value of 0x6
  88. */
  89. MAX77836_CHARGER_TYPE_SPECIAL_BIAS = 0xe,
  90. /* max77836: reserved, register value 0x7 */
  91. MAX77836_CHARGER_TYPE_RESERVED = 0xf,
  92. };
  93. /* MAX14577 interrupts */
  94. #define MAX14577_INT1_ADC_MASK BIT(0)
  95. #define MAX14577_INT1_ADCLOW_MASK BIT(1)
  96. #define MAX14577_INT1_ADCERR_MASK BIT(2)
  97. #define MAX77836_INT1_ADC1K_MASK BIT(3)
  98. #define MAX14577_INT2_CHGTYP_MASK BIT(0)
  99. #define MAX14577_INT2_CHGDETRUN_MASK BIT(1)
  100. #define MAX14577_INT2_DCDTMR_MASK BIT(2)
  101. #define MAX14577_INT2_DBCHG_MASK BIT(3)
  102. #define MAX14577_INT2_VBVOLT_MASK BIT(4)
  103. #define MAX77836_INT2_VIDRM_MASK BIT(5)
  104. #define MAX14577_INT3_EOC_MASK BIT(0)
  105. #define MAX14577_INT3_CGMBC_MASK BIT(1)
  106. #define MAX14577_INT3_OVP_MASK BIT(2)
  107. #define MAX14577_INT3_MBCCHGERR_MASK BIT(3)
  108. /* MAX14577 DEVICE ID register */
  109. #define DEVID_VENDORID_SHIFT 0
  110. #define DEVID_DEVICEID_SHIFT 3
  111. #define DEVID_VENDORID_MASK (0x07 << DEVID_VENDORID_SHIFT)
  112. #define DEVID_DEVICEID_MASK (0x1f << DEVID_DEVICEID_SHIFT)
  113. /* MAX14577 STATUS1 register */
  114. #define STATUS1_ADC_SHIFT 0
  115. #define STATUS1_ADCLOW_SHIFT 5
  116. #define STATUS1_ADCERR_SHIFT 6
  117. #define MAX77836_STATUS1_ADC1K_SHIFT 7
  118. #define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT)
  119. #define STATUS1_ADCLOW_MASK BIT(STATUS1_ADCLOW_SHIFT)
  120. #define STATUS1_ADCERR_MASK BIT(STATUS1_ADCERR_SHIFT)
  121. #define MAX77836_STATUS1_ADC1K_MASK BIT(MAX77836_STATUS1_ADC1K_SHIFT)
  122. /* MAX14577 STATUS2 register */
  123. #define STATUS2_CHGTYP_SHIFT 0
  124. #define STATUS2_CHGDETRUN_SHIFT 3
  125. #define STATUS2_DCDTMR_SHIFT 4
  126. #define MAX14577_STATUS2_DBCHG_SHIFT 5
  127. #define MAX77836_STATUS2_DXOVP_SHIFT 5
  128. #define STATUS2_VBVOLT_SHIFT 6
  129. #define MAX77836_STATUS2_VIDRM_SHIFT 7
  130. #define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT)
  131. #define STATUS2_CHGDETRUN_MASK BIT(STATUS2_CHGDETRUN_SHIFT)
  132. #define STATUS2_DCDTMR_MASK BIT(STATUS2_DCDTMR_SHIFT)
  133. #define MAX14577_STATUS2_DBCHG_MASK BIT(MAX14577_STATUS2_DBCHG_SHIFT)
  134. #define MAX77836_STATUS2_DXOVP_MASK BIT(MAX77836_STATUS2_DXOVP_SHIFT)
  135. #define STATUS2_VBVOLT_MASK BIT(STATUS2_VBVOLT_SHIFT)
  136. #define MAX77836_STATUS2_VIDRM_MASK BIT(MAX77836_STATUS2_VIDRM_SHIFT)
  137. /* MAX14577 CONTROL1 register */
  138. #define COMN1SW_SHIFT 0
  139. #define COMP2SW_SHIFT 3
  140. #define MICEN_SHIFT 6
  141. #define IDBEN_SHIFT 7
  142. #define COMN1SW_MASK (0x7 << COMN1SW_SHIFT)
  143. #define COMP2SW_MASK (0x7 << COMP2SW_SHIFT)
  144. #define MICEN_MASK BIT(MICEN_SHIFT)
  145. #define IDBEN_MASK BIT(IDBEN_SHIFT)
  146. #define CLEAR_IDBEN_MICEN_MASK (COMN1SW_MASK | COMP2SW_MASK)
  147. #define CTRL1_SW_USB ((1 << COMP2SW_SHIFT) \
  148. | (1 << COMN1SW_SHIFT))
  149. #define CTRL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \
  150. | (2 << COMN1SW_SHIFT))
  151. #define CTRL1_SW_UART ((3 << COMP2SW_SHIFT) \
  152. | (3 << COMN1SW_SHIFT))
  153. #define CTRL1_SW_OPEN ((0 << COMP2SW_SHIFT) \
  154. | (0 << COMN1SW_SHIFT))
  155. /* MAX14577 CONTROL2 register */
  156. #define CTRL2_LOWPWR_SHIFT (0)
  157. #define CTRL2_ADCEN_SHIFT (1)
  158. #define CTRL2_CPEN_SHIFT (2)
  159. #define CTRL2_SFOUTASRT_SHIFT (3)
  160. #define CTRL2_SFOUTORD_SHIFT (4)
  161. #define CTRL2_ACCDET_SHIFT (5)
  162. #define CTRL2_USBCPINT_SHIFT (6)
  163. #define CTRL2_RCPS_SHIFT (7)
  164. #define CTRL2_LOWPWR_MASK BIT(CTRL2_LOWPWR_SHIFT)
  165. #define CTRL2_ADCEN_MASK BIT(CTRL2_ADCEN_SHIFT)
  166. #define CTRL2_CPEN_MASK BIT(CTRL2_CPEN_SHIFT)
  167. #define CTRL2_SFOUTASRT_MASK BIT(CTRL2_SFOUTASRT_SHIFT)
  168. #define CTRL2_SFOUTORD_MASK BIT(CTRL2_SFOUTORD_SHIFT)
  169. #define CTRL2_ACCDET_MASK BIT(CTRL2_ACCDET_SHIFT)
  170. #define CTRL2_USBCPINT_MASK BIT(CTRL2_USBCPINT_SHIFT)
  171. #define CTRL2_RCPS_MASK BIT(CTRL2_RCPS_SHIFT)
  172. #define CTRL2_CPEN1_LOWPWR0 ((1 << CTRL2_CPEN_SHIFT) | \
  173. (0 << CTRL2_LOWPWR_SHIFT))
  174. #define CTRL2_CPEN0_LOWPWR1 ((0 << CTRL2_CPEN_SHIFT) | \
  175. (1 << CTRL2_LOWPWR_SHIFT))
  176. /* MAX14577 CONTROL3 register */
  177. #define CTRL3_JIGSET_SHIFT 0
  178. #define CTRL3_BOOTSET_SHIFT 2
  179. #define CTRL3_ADCDBSET_SHIFT 4
  180. #define CTRL3_WBTH_SHIFT 6
  181. #define CTRL3_JIGSET_MASK (0x3 << CTRL3_JIGSET_SHIFT)
  182. #define CTRL3_BOOTSET_MASK (0x3 << CTRL3_BOOTSET_SHIFT)
  183. #define CTRL3_ADCDBSET_MASK (0x3 << CTRL3_ADCDBSET_SHIFT)
  184. #define CTRL3_WBTH_MASK (0x3 << CTRL3_WBTH_SHIFT)
  185. /* Slave addr = 0x4A: Charger */
  186. enum max14577_charger_reg {
  187. MAX14577_CHG_REG_STATUS3 = 0x06,
  188. MAX14577_CHG_REG_CHG_CTRL1 = 0x0F,
  189. MAX14577_CHG_REG_CHG_CTRL2 = 0x10,
  190. MAX14577_CHG_REG_CHG_CTRL3 = 0x11,
  191. MAX14577_CHG_REG_CHG_CTRL4 = 0x12,
  192. MAX14577_CHG_REG_CHG_CTRL5 = 0x13,
  193. MAX14577_CHG_REG_CHG_CTRL6 = 0x14,
  194. MAX14577_CHG_REG_CHG_CTRL7 = 0x15,
  195. MAX14577_CHG_REG_END,
  196. };
  197. /* MAX14577 STATUS3 register */
  198. #define STATUS3_EOC_SHIFT 0
  199. #define STATUS3_CGMBC_SHIFT 1
  200. #define STATUS3_OVP_SHIFT 2
  201. #define STATUS3_MBCCHGERR_SHIFT 3
  202. #define STATUS3_EOC_MASK (0x1 << STATUS3_EOC_SHIFT)
  203. #define STATUS3_CGMBC_MASK (0x1 << STATUS3_CGMBC_SHIFT)
  204. #define STATUS3_OVP_MASK (0x1 << STATUS3_OVP_SHIFT)
  205. #define STATUS3_MBCCHGERR_MASK (0x1 << STATUS3_MBCCHGERR_SHIFT)
  206. /* MAX14577 CDETCTRL1 register */
  207. #define CDETCTRL1_CHGDETEN_SHIFT 0
  208. #define CDETCTRL1_CHGTYPMAN_SHIFT 1
  209. #define CDETCTRL1_DCDEN_SHIFT 2
  210. #define CDETCTRL1_DCD2SCT_SHIFT 3
  211. #define MAX14577_CDETCTRL1_DCHKTM_SHIFT 4
  212. #define MAX77836_CDETCTRL1_CDLY_SHIFT 4
  213. #define MAX14577_CDETCTRL1_DBEXIT_SHIFT 5
  214. #define MAX77836_CDETCTRL1_DCDCPL_SHIFT 5
  215. #define CDETCTRL1_DBIDLE_SHIFT 6
  216. #define CDETCTRL1_CDPDET_SHIFT 7
  217. #define CDETCTRL1_CHGDETEN_MASK BIT(CDETCTRL1_CHGDETEN_SHIFT)
  218. #define CDETCTRL1_CHGTYPMAN_MASK BIT(CDETCTRL1_CHGTYPMAN_SHIFT)
  219. #define CDETCTRL1_DCDEN_MASK BIT(CDETCTRL1_DCDEN_SHIFT)
  220. #define CDETCTRL1_DCD2SCT_MASK BIT(CDETCTRL1_DCD2SCT_SHIFT)
  221. #define MAX14577_CDETCTRL1_DCHKTM_MASK BIT(MAX14577_CDETCTRL1_DCHKTM_SHIFT)
  222. #define MAX77836_CDETCTRL1_CDDLY_MASK BIT(MAX77836_CDETCTRL1_CDDLY_SHIFT)
  223. #define MAX14577_CDETCTRL1_DBEXIT_MASK BIT(MAX14577_CDETCTRL1_DBEXIT_SHIFT)
  224. #define MAX77836_CDETCTRL1_DCDCPL_MASK BIT(MAX77836_CDETCTRL1_DCDCPL_SHIFT)
  225. #define CDETCTRL1_DBIDLE_MASK BIT(CDETCTRL1_DBIDLE_SHIFT)
  226. #define CDETCTRL1_CDPDET_MASK BIT(CDETCTRL1_CDPDET_SHIFT)
  227. /* MAX14577 CHGCTRL1 register */
  228. #define CHGCTRL1_TCHW_SHIFT 4
  229. #define CHGCTRL1_TCHW_MASK (0x7 << CHGCTRL1_TCHW_SHIFT)
  230. /* MAX14577 CHGCTRL2 register */
  231. #define CHGCTRL2_MBCHOSTEN_SHIFT 6
  232. #define CHGCTRL2_MBCHOSTEN_MASK BIT(CHGCTRL2_MBCHOSTEN_SHIFT)
  233. #define CHGCTRL2_VCHGR_RC_SHIFT 7
  234. #define CHGCTRL2_VCHGR_RC_MASK BIT(CHGCTRL2_VCHGR_RC_SHIFT)
  235. /* MAX14577 CHGCTRL3 register */
  236. #define CHGCTRL3_MBCCVWRC_SHIFT 0
  237. #define CHGCTRL3_MBCCVWRC_MASK (0xf << CHGCTRL3_MBCCVWRC_SHIFT)
  238. /* MAX14577 CHGCTRL4 register */
  239. #define CHGCTRL4_MBCICHWRCH_SHIFT 0
  240. #define CHGCTRL4_MBCICHWRCH_MASK (0xf << CHGCTRL4_MBCICHWRCH_SHIFT)
  241. #define CHGCTRL4_MBCICHWRCL_SHIFT 4
  242. #define CHGCTRL4_MBCICHWRCL_MASK BIT(CHGCTRL4_MBCICHWRCL_SHIFT)
  243. /* MAX14577 CHGCTRL5 register */
  244. #define CHGCTRL5_EOCS_SHIFT 0
  245. #define CHGCTRL5_EOCS_MASK (0xf << CHGCTRL5_EOCS_SHIFT)
  246. /* MAX14577 CHGCTRL6 register */
  247. #define CHGCTRL6_AUTOSTOP_SHIFT 5
  248. #define CHGCTRL6_AUTOSTOP_MASK BIT(CHGCTRL6_AUTOSTOP_SHIFT)
  249. /* MAX14577 CHGCTRL7 register */
  250. #define CHGCTRL7_OTPCGHCVS_SHIFT 0
  251. #define CHGCTRL7_OTPCGHCVS_MASK (0x3 << CHGCTRL7_OTPCGHCVS_SHIFT)
  252. /* MAX14577 charger current limits (as in CHGCTRL4 register), uA */
  253. #define MAX14577_CHARGER_CURRENT_LIMIT_MIN 90000U
  254. #define MAX14577_CHARGER_CURRENT_LIMIT_HIGH_START 200000U
  255. #define MAX14577_CHARGER_CURRENT_LIMIT_HIGH_STEP 50000U
  256. #define MAX14577_CHARGER_CURRENT_LIMIT_MAX 950000U
  257. /* MAX77836 charger current limits (as in CHGCTRL4 register), uA */
  258. #define MAX77836_CHARGER_CURRENT_LIMIT_MIN 45000U
  259. #define MAX77836_CHARGER_CURRENT_LIMIT_HIGH_START 100000U
  260. #define MAX77836_CHARGER_CURRENT_LIMIT_HIGH_STEP 25000U
  261. #define MAX77836_CHARGER_CURRENT_LIMIT_MAX 475000U
  262. /*
  263. * MAX14577 charger End-Of-Charge current limits
  264. * (as in CHGCTRL5 register), uA
  265. */
  266. #define MAX14577_CHARGER_EOC_CURRENT_LIMIT_MIN 50000U
  267. #define MAX14577_CHARGER_EOC_CURRENT_LIMIT_STEP 10000U
  268. #define MAX14577_CHARGER_EOC_CURRENT_LIMIT_MAX 200000U
  269. /*
  270. * MAX14577/MAX77836 Battery Constant Voltage
  271. * (as in CHGCTRL3 register), uV
  272. */
  273. #define MAXIM_CHARGER_CONSTANT_VOLTAGE_MIN 4000000U
  274. #define MAXIM_CHARGER_CONSTANT_VOLTAGE_STEP 20000U
  275. #define MAXIM_CHARGER_CONSTANT_VOLTAGE_MAX 4350000U
  276. /* Default value for fast charge timer, in hours */
  277. #define MAXIM_CHARGER_FAST_CHARGE_TIMER_DEFAULT 5
  278. /* MAX14577 regulator SFOUT LDO voltage, fixed, uV */
  279. #define MAX14577_REGULATOR_SAFEOUT_VOLTAGE 4900000
  280. /* MAX77836 regulator LDOx voltage, uV */
  281. #define MAX77836_REGULATOR_LDO_VOLTAGE_MIN 800000
  282. #define MAX77836_REGULATOR_LDO_VOLTAGE_MAX 3950000
  283. #define MAX77836_REGULATOR_LDO_VOLTAGE_STEP 50000
  284. #define MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM 64
  285. /* Slave addr = 0x46: PMIC */
  286. enum max77836_pmic_reg {
  287. MAX77836_PMIC_REG_PMIC_ID = 0x20,
  288. MAX77836_PMIC_REG_PMIC_REV = 0x21,
  289. MAX77836_PMIC_REG_INTSRC = 0x22,
  290. MAX77836_PMIC_REG_INTSRC_MASK = 0x23,
  291. MAX77836_PMIC_REG_TOPSYS_INT = 0x24,
  292. MAX77836_PMIC_REG_TOPSYS_INT_MASK = 0x26,
  293. MAX77836_PMIC_REG_TOPSYS_STAT = 0x28,
  294. MAX77836_PMIC_REG_MRSTB_CNTL = 0x2A,
  295. MAX77836_PMIC_REG_LSCNFG = 0x2B,
  296. MAX77836_LDO_REG_CNFG1_LDO1 = 0x51,
  297. MAX77836_LDO_REG_CNFG2_LDO1 = 0x52,
  298. MAX77836_LDO_REG_CNFG1_LDO2 = 0x53,
  299. MAX77836_LDO_REG_CNFG2_LDO2 = 0x54,
  300. MAX77836_LDO_REG_CNFG_LDO_BIAS = 0x55,
  301. MAX77836_COMP_REG_COMP1 = 0x60,
  302. MAX77836_PMIC_REG_END,
  303. };
  304. #define MAX77836_INTSRC_MASK_TOP_INT_SHIFT 1
  305. #define MAX77836_INTSRC_MASK_MUIC_CHG_INT_SHIFT 3
  306. #define MAX77836_INTSRC_MASK_TOP_INT_MASK BIT(MAX77836_INTSRC_MASK_TOP_INT_SHIFT)
  307. #define MAX77836_INTSRC_MASK_MUIC_CHG_INT_MASK BIT(MAX77836_INTSRC_MASK_MUIC_CHG_INT_SHIFT)
  308. /* MAX77836 PMIC interrupts */
  309. #define MAX77836_TOPSYS_INT_T120C_SHIFT 0
  310. #define MAX77836_TOPSYS_INT_T140C_SHIFT 1
  311. #define MAX77836_TOPSYS_INT_T120C_MASK BIT(MAX77836_TOPSYS_INT_T120C_SHIFT)
  312. #define MAX77836_TOPSYS_INT_T140C_MASK BIT(MAX77836_TOPSYS_INT_T140C_SHIFT)
  313. /* LDO1/LDO2 CONFIG1 register */
  314. #define MAX77836_CNFG1_LDO_PWRMD_SHIFT 6
  315. #define MAX77836_CNFG1_LDO_TV_SHIFT 0
  316. #define MAX77836_CNFG1_LDO_PWRMD_MASK (0x3 << MAX77836_CNFG1_LDO_PWRMD_SHIFT)
  317. #define MAX77836_CNFG1_LDO_TV_MASK (0x3f << MAX77836_CNFG1_LDO_TV_SHIFT)
  318. /* LDO1/LDO2 CONFIG2 register */
  319. #define MAX77836_CNFG2_LDO_OVCLMPEN_SHIFT 7
  320. #define MAX77836_CNFG2_LDO_ALPMEN_SHIFT 6
  321. #define MAX77836_CNFG2_LDO_COMP_SHIFT 4
  322. #define MAX77836_CNFG2_LDO_POK_SHIFT 3
  323. #define MAX77836_CNFG2_LDO_ADE_SHIFT 1
  324. #define MAX77836_CNFG2_LDO_SS_SHIFT 0
  325. #define MAX77836_CNFG2_LDO_OVCLMPEN_MASK BIT(MAX77836_CNFG2_LDO_OVCLMPEN_SHIFT)
  326. #define MAX77836_CNFG2_LDO_ALPMEN_MASK BIT(MAX77836_CNFG2_LDO_ALPMEN_SHIFT)
  327. #define MAX77836_CNFG2_LDO_COMP_MASK (0x3 << MAX77836_CNFG2_LDO_COMP_SHIFT)
  328. #define MAX77836_CNFG2_LDO_POK_MASK BIT(MAX77836_CNFG2_LDO_POK_SHIFT)
  329. #define MAX77836_CNFG2_LDO_ADE_MASK BIT(MAX77836_CNFG2_LDO_ADE_SHIFT)
  330. #define MAX77836_CNFG2_LDO_SS_MASK BIT(MAX77836_CNFG2_LDO_SS_SHIFT)
  331. /* Slave addr = 0x6C: Fuel-Gauge/Battery */
  332. enum max77836_fg_reg {
  333. MAX77836_FG_REG_VCELL_MSB = 0x02,
  334. MAX77836_FG_REG_VCELL_LSB = 0x03,
  335. MAX77836_FG_REG_SOC_MSB = 0x04,
  336. MAX77836_FG_REG_SOC_LSB = 0x05,
  337. MAX77836_FG_REG_MODE_H = 0x06,
  338. MAX77836_FG_REG_MODE_L = 0x07,
  339. MAX77836_FG_REG_VERSION_MSB = 0x08,
  340. MAX77836_FG_REG_VERSION_LSB = 0x09,
  341. MAX77836_FG_REG_HIBRT_H = 0x0A,
  342. MAX77836_FG_REG_HIBRT_L = 0x0B,
  343. MAX77836_FG_REG_CONFIG_H = 0x0C,
  344. MAX77836_FG_REG_CONFIG_L = 0x0D,
  345. MAX77836_FG_REG_VALRT_MIN = 0x14,
  346. MAX77836_FG_REG_VALRT_MAX = 0x15,
  347. MAX77836_FG_REG_CRATE_MSB = 0x16,
  348. MAX77836_FG_REG_CRATE_LSB = 0x17,
  349. MAX77836_FG_REG_VRESET = 0x18,
  350. MAX77836_FG_REG_FGID = 0x19,
  351. MAX77836_FG_REG_STATUS_H = 0x1A,
  352. MAX77836_FG_REG_STATUS_L = 0x1B,
  353. /*
  354. * TODO: TABLE registers
  355. * TODO: CMD register
  356. */
  357. MAX77836_FG_REG_END,
  358. };
  359. enum max14577_irq {
  360. /* INT1 */
  361. MAX14577_IRQ_INT1_ADC,
  362. MAX14577_IRQ_INT1_ADCLOW,
  363. MAX14577_IRQ_INT1_ADCERR,
  364. MAX77836_IRQ_INT1_ADC1K,
  365. /* INT2 */
  366. MAX14577_IRQ_INT2_CHGTYP,
  367. MAX14577_IRQ_INT2_CHGDETRUN,
  368. MAX14577_IRQ_INT2_DCDTMR,
  369. MAX14577_IRQ_INT2_DBCHG,
  370. MAX14577_IRQ_INT2_VBVOLT,
  371. MAX77836_IRQ_INT2_VIDRM,
  372. /* INT3 */
  373. MAX14577_IRQ_INT3_EOC,
  374. MAX14577_IRQ_INT3_CGMBC,
  375. MAX14577_IRQ_INT3_OVP,
  376. MAX14577_IRQ_INT3_MBCCHGERR,
  377. /* TOPSYS_INT, only MAX77836 */
  378. MAX77836_IRQ_TOPSYS_T140C,
  379. MAX77836_IRQ_TOPSYS_T120C,
  380. MAX14577_IRQ_NUM,
  381. };
  382. struct max14577 {
  383. struct device *dev;
  384. struct i2c_client *i2c; /* Slave addr = 0x4A */
  385. struct i2c_client *i2c_pmic; /* Slave addr = 0x46 */
  386. enum maxim_device_type dev_type;
  387. struct regmap *regmap; /* For MUIC and Charger */
  388. struct regmap *regmap_pmic;
  389. struct regmap_irq_chip_data *irq_data; /* For MUIC and Charger */
  390. struct regmap_irq_chip_data *irq_data_pmic;
  391. int irq;
  392. };
  393. /* MAX14577 shared regmap API function */
  394. static inline int max14577_read_reg(struct regmap *map, u8 reg, u8 *dest)
  395. {
  396. unsigned int val;
  397. int ret;
  398. ret = regmap_read(map, reg, &val);
  399. *dest = val;
  400. return ret;
  401. }
  402. static inline int max14577_bulk_read(struct regmap *map, u8 reg, u8 *buf,
  403. int count)
  404. {
  405. return regmap_bulk_read(map, reg, buf, count);
  406. }
  407. static inline int max14577_write_reg(struct regmap *map, u8 reg, u8 value)
  408. {
  409. return regmap_write(map, reg, value);
  410. }
  411. static inline int max14577_bulk_write(struct regmap *map, u8 reg, u8 *buf,
  412. int count)
  413. {
  414. return regmap_bulk_write(map, reg, buf, count);
  415. }
  416. static inline int max14577_update_reg(struct regmap *map, u8 reg, u8 mask,
  417. u8 val)
  418. {
  419. return regmap_update_bits(map, reg, mask, val);
  420. }
  421. #endif /* __MAX14577_PRIVATE_H__ */