max77693-private.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. /*
  2. * max77693-private.h - Voltage regulator driver for the Maxim 77693
  3. *
  4. * Copyright (C) 2012 Samsung Electrnoics
  5. * SangYoung Son <hello.son@samsung.com>
  6. *
  7. * This program is not provided / owned by Maxim Integrated Products.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #ifndef __LINUX_MFD_MAX77693_PRIV_H
  24. #define __LINUX_MFD_MAX77693_PRIV_H
  25. #include <linux/i2c.h>
  26. #define MAX77693_REG_INVALID (0xff)
  27. /* Slave addr = 0xCC: PMIC, Charger, Flash LED */
  28. enum max77693_pmic_reg {
  29. MAX77693_LED_REG_IFLASH1 = 0x00,
  30. MAX77693_LED_REG_IFLASH2 = 0x01,
  31. MAX77693_LED_REG_ITORCH = 0x02,
  32. MAX77693_LED_REG_ITORCHTIMER = 0x03,
  33. MAX77693_LED_REG_FLASH_TIMER = 0x04,
  34. MAX77693_LED_REG_FLASH_EN = 0x05,
  35. MAX77693_LED_REG_MAX_FLASH1 = 0x06,
  36. MAX77693_LED_REG_MAX_FLASH2 = 0x07,
  37. MAX77693_LED_REG_MAX_FLASH3 = 0x08,
  38. MAX77693_LED_REG_MAX_FLASH4 = 0x09,
  39. MAX77693_LED_REG_VOUT_CNTL = 0x0A,
  40. MAX77693_LED_REG_VOUT_FLASH1 = 0x0B,
  41. MAX77693_LED_REG_VOUT_FLASH2 = 0x0C,
  42. MAX77693_LED_REG_FLASH_INT = 0x0E,
  43. MAX77693_LED_REG_FLASH_INT_MASK = 0x0F,
  44. MAX77693_LED_REG_FLASH_STATUS = 0x10,
  45. MAX77693_PMIC_REG_PMIC_ID1 = 0x20,
  46. MAX77693_PMIC_REG_PMIC_ID2 = 0x21,
  47. MAX77693_PMIC_REG_INTSRC = 0x22,
  48. MAX77693_PMIC_REG_INTSRC_MASK = 0x23,
  49. MAX77693_PMIC_REG_TOPSYS_INT = 0x24,
  50. MAX77693_PMIC_REG_TOPSYS_INT_MASK = 0x26,
  51. MAX77693_PMIC_REG_TOPSYS_STAT = 0x28,
  52. MAX77693_PMIC_REG_MAINCTRL1 = 0x2A,
  53. MAX77693_PMIC_REG_LSCNFG = 0x2B,
  54. MAX77693_CHG_REG_CHG_INT = 0xB0,
  55. MAX77693_CHG_REG_CHG_INT_MASK = 0xB1,
  56. MAX77693_CHG_REG_CHG_INT_OK = 0xB2,
  57. MAX77693_CHG_REG_CHG_DETAILS_00 = 0xB3,
  58. MAX77693_CHG_REG_CHG_DETAILS_01 = 0xB4,
  59. MAX77693_CHG_REG_CHG_DETAILS_02 = 0xB5,
  60. MAX77693_CHG_REG_CHG_DETAILS_03 = 0xB6,
  61. MAX77693_CHG_REG_CHG_CNFG_00 = 0xB7,
  62. MAX77693_CHG_REG_CHG_CNFG_01 = 0xB8,
  63. MAX77693_CHG_REG_CHG_CNFG_02 = 0xB9,
  64. MAX77693_CHG_REG_CHG_CNFG_03 = 0xBA,
  65. MAX77693_CHG_REG_CHG_CNFG_04 = 0xBB,
  66. MAX77693_CHG_REG_CHG_CNFG_05 = 0xBC,
  67. MAX77693_CHG_REG_CHG_CNFG_06 = 0xBD,
  68. MAX77693_CHG_REG_CHG_CNFG_07 = 0xBE,
  69. MAX77693_CHG_REG_CHG_CNFG_08 = 0xBF,
  70. MAX77693_CHG_REG_CHG_CNFG_09 = 0xC0,
  71. MAX77693_CHG_REG_CHG_CNFG_10 = 0xC1,
  72. MAX77693_CHG_REG_CHG_CNFG_11 = 0xC2,
  73. MAX77693_CHG_REG_CHG_CNFG_12 = 0xC3,
  74. MAX77693_CHG_REG_CHG_CNFG_13 = 0xC4,
  75. MAX77693_CHG_REG_CHG_CNFG_14 = 0xC5,
  76. MAX77693_CHG_REG_SAFEOUT_CTRL = 0xC6,
  77. MAX77693_PMIC_REG_END,
  78. };
  79. /* MAX77693 ITORCH register */
  80. #define TORCH_IOUT1_SHIFT 0
  81. #define TORCH_IOUT2_SHIFT 4
  82. #define TORCH_IOUT_MASK(x) (0xf << (x))
  83. #define TORCH_IOUT_MIN 15625
  84. #define TORCH_IOUT_MAX 250000
  85. #define TORCH_IOUT_STEP 15625
  86. /* MAX77693 IFLASH1 and IFLASH2 registers */
  87. #define FLASH_IOUT_MIN 15625
  88. #define FLASH_IOUT_MAX_1LED 1000000
  89. #define FLASH_IOUT_MAX_2LEDS 625000
  90. #define FLASH_IOUT_STEP 15625
  91. /* MAX77693 TORCH_TIMER register */
  92. #define TORCH_TMR_NO_TIMER 0x40
  93. #define TORCH_TIMEOUT_MIN 262000
  94. #define TORCH_TIMEOUT_MAX 15728000
  95. /* MAX77693 FLASH_TIMER register */
  96. #define FLASH_TMR_LEVEL 0x80
  97. #define FLASH_TIMEOUT_MIN 62500
  98. #define FLASH_TIMEOUT_MAX 1000000
  99. #define FLASH_TIMEOUT_STEP 62500
  100. /* MAX77693 FLASH_EN register */
  101. #define FLASH_EN_OFF 0x0
  102. #define FLASH_EN_FLASH 0x1
  103. #define FLASH_EN_TORCH 0x2
  104. #define FLASH_EN_ON 0x3
  105. #define FLASH_EN_SHIFT(x) (6 - (x) * 2)
  106. #define TORCH_EN_SHIFT(x) (2 - (x) * 2)
  107. /* MAX77693 MAX_FLASH1 register */
  108. #define MAX_FLASH1_MAX_FL_EN 0x80
  109. #define MAX_FLASH1_VSYS_MIN 2400
  110. #define MAX_FLASH1_VSYS_MAX 3400
  111. #define MAX_FLASH1_VSYS_STEP 33
  112. /* MAX77693 VOUT_CNTL register */
  113. #define FLASH_BOOST_FIXED 0x04
  114. #define FLASH_BOOST_LEDNUM_2 0x80
  115. /* MAX77693 VOUT_FLASH1 register */
  116. #define FLASH_VOUT_MIN 3300
  117. #define FLASH_VOUT_MAX 5500
  118. #define FLASH_VOUT_STEP 25
  119. #define FLASH_VOUT_RMIN 0x0c
  120. /* MAX77693 FLASH_STATUS register */
  121. #define FLASH_STATUS_FLASH_ON BIT(3)
  122. #define FLASH_STATUS_TORCH_ON BIT(2)
  123. /* MAX77693 FLASH_INT register */
  124. #define FLASH_INT_FLED2_OPEN BIT(0)
  125. #define FLASH_INT_FLED2_SHORT BIT(1)
  126. #define FLASH_INT_FLED1_OPEN BIT(2)
  127. #define FLASH_INT_FLED1_SHORT BIT(3)
  128. #define FLASH_INT_OVER_CURRENT BIT(4)
  129. /* Fast charge timer in in hours */
  130. #define DEFAULT_FAST_CHARGE_TIMER 4
  131. /* microamps */
  132. #define DEFAULT_TOP_OFF_THRESHOLD_CURRENT 150000
  133. /* minutes */
  134. #define DEFAULT_TOP_OFF_TIMER 30
  135. /* microvolts */
  136. #define DEFAULT_CONSTANT_VOLT 4200000
  137. /* microvolts */
  138. #define DEFAULT_MIN_SYSTEM_VOLT 3600000
  139. /* celsius */
  140. #define DEFAULT_THERMAL_REGULATION_TEMP 100
  141. /* microamps */
  142. #define DEFAULT_BATTERY_OVERCURRENT 3500000
  143. /* microvolts */
  144. #define DEFAULT_CHARGER_INPUT_THRESHOLD_VOLT 4300000
  145. /* MAX77693_CHG_REG_CHG_INT_OK register */
  146. #define CHG_INT_OK_BYP_SHIFT 0
  147. #define CHG_INT_OK_BAT_SHIFT 3
  148. #define CHG_INT_OK_CHG_SHIFT 4
  149. #define CHG_INT_OK_CHGIN_SHIFT 6
  150. #define CHG_INT_OK_DETBAT_SHIFT 7
  151. #define CHG_INT_OK_BYP_MASK BIT(CHG_INT_OK_BYP_SHIFT)
  152. #define CHG_INT_OK_BAT_MASK BIT(CHG_INT_OK_BAT_SHIFT)
  153. #define CHG_INT_OK_CHG_MASK BIT(CHG_INT_OK_CHG_SHIFT)
  154. #define CHG_INT_OK_CHGIN_MASK BIT(CHG_INT_OK_CHGIN_SHIFT)
  155. #define CHG_INT_OK_DETBAT_MASK BIT(CHG_INT_OK_DETBAT_SHIFT)
  156. /* MAX77693_CHG_REG_CHG_DETAILS_00 register */
  157. #define CHG_DETAILS_00_CHGIN_SHIFT 5
  158. #define CHG_DETAILS_00_CHGIN_MASK (0x3 << CHG_DETAILS_00_CHGIN_SHIFT)
  159. /* MAX77693_CHG_REG_CHG_DETAILS_01 register */
  160. #define CHG_DETAILS_01_CHG_SHIFT 0
  161. #define CHG_DETAILS_01_BAT_SHIFT 4
  162. #define CHG_DETAILS_01_TREG_SHIFT 7
  163. #define CHG_DETAILS_01_CHG_MASK (0xf << CHG_DETAILS_01_CHG_SHIFT)
  164. #define CHG_DETAILS_01_BAT_MASK (0x7 << CHG_DETAILS_01_BAT_SHIFT)
  165. #define CHG_DETAILS_01_TREG_MASK BIT(7)
  166. /* MAX77693_CHG_REG_CHG_DETAILS_01/CHG field */
  167. enum max77693_charger_charging_state {
  168. MAX77693_CHARGING_PREQUALIFICATION = 0x0,
  169. MAX77693_CHARGING_FAST_CONST_CURRENT,
  170. MAX77693_CHARGING_FAST_CONST_VOLTAGE,
  171. MAX77693_CHARGING_TOP_OFF,
  172. MAX77693_CHARGING_DONE,
  173. MAX77693_CHARGING_HIGH_TEMP,
  174. MAX77693_CHARGING_TIMER_EXPIRED,
  175. MAX77693_CHARGING_THERMISTOR_SUSPEND,
  176. MAX77693_CHARGING_OFF,
  177. MAX77693_CHARGING_RESERVED,
  178. MAX77693_CHARGING_OVER_TEMP,
  179. MAX77693_CHARGING_WATCHDOG_EXPIRED,
  180. };
  181. /* MAX77693_CHG_REG_CHG_DETAILS_01/BAT field */
  182. enum max77693_charger_battery_state {
  183. MAX77693_BATTERY_NOBAT = 0x0,
  184. /* Dead-battery or low-battery prequalification */
  185. MAX77693_BATTERY_PREQUALIFICATION,
  186. MAX77693_BATTERY_TIMER_EXPIRED,
  187. MAX77693_BATTERY_GOOD,
  188. MAX77693_BATTERY_LOWVOLTAGE,
  189. MAX77693_BATTERY_OVERVOLTAGE,
  190. MAX77693_BATTERY_OVERCURRENT,
  191. MAX77693_BATTERY_RESERVED,
  192. };
  193. /* MAX77693_CHG_REG_CHG_DETAILS_02 register */
  194. #define CHG_DETAILS_02_BYP_SHIFT 0
  195. #define CHG_DETAILS_02_BYP_MASK (0xf << CHG_DETAILS_02_BYP_SHIFT)
  196. /* MAX77693 CHG_CNFG_00 register */
  197. #define CHG_CNFG_00_CHG_MASK 0x1
  198. #define CHG_CNFG_00_BUCK_MASK 0x4
  199. /* MAX77693_CHG_REG_CHG_CNFG_01 register */
  200. #define CHG_CNFG_01_FCHGTIME_SHIFT 0
  201. #define CHG_CNFG_01_CHGRSTRT_SHIFT 4
  202. #define CHG_CNFG_01_PQEN_SHIFT 7
  203. #define CHG_CNFG_01_FCHGTIME_MASK (0x7 << CHG_CNFG_01_FCHGTIME_SHIFT)
  204. #define CHG_CNFG_01_CHGRSTRT_MASK (0x3 << CHG_CNFG_01_CHGRSTRT_SHIFT)
  205. #define CHG_CNFG_01_PQEN_MAKS BIT(CHG_CNFG_01_PQEN_SHIFT)
  206. /* MAX77693_CHG_REG_CHG_CNFG_03 register */
  207. #define CHG_CNFG_03_TOITH_SHIFT 0
  208. #define CHG_CNFG_03_TOTIME_SHIFT 3
  209. #define CHG_CNFG_03_TOITH_MASK (0x7 << CHG_CNFG_03_TOITH_SHIFT)
  210. #define CHG_CNFG_03_TOTIME_MASK (0x7 << CHG_CNFG_03_TOTIME_SHIFT)
  211. /* MAX77693_CHG_REG_CHG_CNFG_04 register */
  212. #define CHG_CNFG_04_CHGCVPRM_SHIFT 0
  213. #define CHG_CNFG_04_MINVSYS_SHIFT 5
  214. #define CHG_CNFG_04_CHGCVPRM_MASK (0x1f << CHG_CNFG_04_CHGCVPRM_SHIFT)
  215. #define CHG_CNFG_04_MINVSYS_MASK (0x7 << CHG_CNFG_04_MINVSYS_SHIFT)
  216. /* MAX77693_CHG_REG_CHG_CNFG_06 register */
  217. #define CHG_CNFG_06_CHGPROT_SHIFT 2
  218. #define CHG_CNFG_06_CHGPROT_MASK (0x3 << CHG_CNFG_06_CHGPROT_SHIFT)
  219. /* MAX77693_CHG_REG_CHG_CNFG_07 register */
  220. #define CHG_CNFG_07_REGTEMP_SHIFT 5
  221. #define CHG_CNFG_07_REGTEMP_MASK (0x3 << CHG_CNFG_07_REGTEMP_SHIFT)
  222. /* MAX77693_CHG_REG_CHG_CNFG_12 register */
  223. #define CHG_CNFG_12_B2SOVRC_SHIFT 0
  224. #define CHG_CNFG_12_VCHGINREG_SHIFT 3
  225. #define CHG_CNFG_12_B2SOVRC_MASK (0x7 << CHG_CNFG_12_B2SOVRC_SHIFT)
  226. #define CHG_CNFG_12_VCHGINREG_MASK (0x3 << CHG_CNFG_12_VCHGINREG_SHIFT)
  227. /* MAX77693 CHG_CNFG_09 Register */
  228. #define CHG_CNFG_09_CHGIN_ILIM_MASK 0x7F
  229. /* MAX77693 CHG_CTRL Register */
  230. #define SAFEOUT_CTRL_SAFEOUT1_MASK 0x3
  231. #define SAFEOUT_CTRL_SAFEOUT2_MASK 0xC
  232. #define SAFEOUT_CTRL_ENSAFEOUT1_MASK 0x40
  233. #define SAFEOUT_CTRL_ENSAFEOUT2_MASK 0x80
  234. /* Slave addr = 0x4A: MUIC */
  235. enum max77693_muic_reg {
  236. MAX77693_MUIC_REG_ID = 0x00,
  237. MAX77693_MUIC_REG_INT1 = 0x01,
  238. MAX77693_MUIC_REG_INT2 = 0x02,
  239. MAX77693_MUIC_REG_INT3 = 0x03,
  240. MAX77693_MUIC_REG_STATUS1 = 0x04,
  241. MAX77693_MUIC_REG_STATUS2 = 0x05,
  242. MAX77693_MUIC_REG_STATUS3 = 0x06,
  243. MAX77693_MUIC_REG_INTMASK1 = 0x07,
  244. MAX77693_MUIC_REG_INTMASK2 = 0x08,
  245. MAX77693_MUIC_REG_INTMASK3 = 0x09,
  246. MAX77693_MUIC_REG_CDETCTRL1 = 0x0A,
  247. MAX77693_MUIC_REG_CDETCTRL2 = 0x0B,
  248. MAX77693_MUIC_REG_CTRL1 = 0x0C,
  249. MAX77693_MUIC_REG_CTRL2 = 0x0D,
  250. MAX77693_MUIC_REG_CTRL3 = 0x0E,
  251. MAX77693_MUIC_REG_END,
  252. };
  253. /* MAX77693 INTMASK1~2 Register */
  254. #define INTMASK1_ADC1K_SHIFT 3
  255. #define INTMASK1_ADCERR_SHIFT 2
  256. #define INTMASK1_ADCLOW_SHIFT 1
  257. #define INTMASK1_ADC_SHIFT 0
  258. #define INTMASK1_ADC1K_MASK (1 << INTMASK1_ADC1K_SHIFT)
  259. #define INTMASK1_ADCERR_MASK (1 << INTMASK1_ADCERR_SHIFT)
  260. #define INTMASK1_ADCLOW_MASK (1 << INTMASK1_ADCLOW_SHIFT)
  261. #define INTMASK1_ADC_MASK (1 << INTMASK1_ADC_SHIFT)
  262. #define INTMASK2_VIDRM_SHIFT 5
  263. #define INTMASK2_VBVOLT_SHIFT 4
  264. #define INTMASK2_DXOVP_SHIFT 3
  265. #define INTMASK2_DCDTMR_SHIFT 2
  266. #define INTMASK2_CHGDETRUN_SHIFT 1
  267. #define INTMASK2_CHGTYP_SHIFT 0
  268. #define INTMASK2_VIDRM_MASK (1 << INTMASK2_VIDRM_SHIFT)
  269. #define INTMASK2_VBVOLT_MASK (1 << INTMASK2_VBVOLT_SHIFT)
  270. #define INTMASK2_DXOVP_MASK (1 << INTMASK2_DXOVP_SHIFT)
  271. #define INTMASK2_DCDTMR_MASK (1 << INTMASK2_DCDTMR_SHIFT)
  272. #define INTMASK2_CHGDETRUN_MASK (1 << INTMASK2_CHGDETRUN_SHIFT)
  273. #define INTMASK2_CHGTYP_MASK (1 << INTMASK2_CHGTYP_SHIFT)
  274. /* MAX77693 MUIC - STATUS1~3 Register */
  275. #define MAX77693_STATUS1_ADC_SHIFT 0
  276. #define MAX77693_STATUS1_ADCLOW_SHIFT 5
  277. #define MAX77693_STATUS1_ADCERR_SHIFT 6
  278. #define MAX77693_STATUS1_ADC1K_SHIFT 7
  279. #define MAX77693_STATUS1_ADC_MASK (0x1f << MAX77693_STATUS1_ADC_SHIFT)
  280. #define MAX77693_STATUS1_ADCLOW_MASK BIT(MAX77693_STATUS1_ADCLOW_SHIFT)
  281. #define MAX77693_STATUS1_ADCERR_MASK BIT(MAX77693_STATUS1_ADCERR_SHIFT)
  282. #define MAX77693_STATUS1_ADC1K_MASK BIT(MAX77693_STATUS1_ADC1K_SHIFT)
  283. #define MAX77693_STATUS2_CHGTYP_SHIFT 0
  284. #define MAX77693_STATUS2_CHGDETRUN_SHIFT 3
  285. #define MAX77693_STATUS2_DCDTMR_SHIFT 4
  286. #define MAX77693_STATUS2_DXOVP_SHIFT 5
  287. #define MAX77693_STATUS2_VBVOLT_SHIFT 6
  288. #define MAX77693_STATUS2_VIDRM_SHIFT 7
  289. #define MAX77693_STATUS2_CHGTYP_MASK (0x7 << MAX77693_STATUS2_CHGTYP_SHIFT)
  290. #define MAX77693_STATUS2_CHGDETRUN_MASK BIT(MAX77693_STATUS2_CHGDETRUN_SHIFT)
  291. #define MAX77693_STATUS2_DCDTMR_MASK BIT(MAX77693_STATUS2_DCDTMR_SHIFT)
  292. #define MAX77693_STATUS2_DXOVP_MASK BIT(MAX77693_STATUS2_DXOVP_SHIFT)
  293. #define MAX77693_STATUS2_VBVOLT_MASK BIT(MAX77693_STATUS2_VBVOLT_SHIFT)
  294. #define MAX77693_STATUS2_VIDRM_MASK BIT(MAX77693_STATUS2_VIDRM_SHIFT)
  295. #define MAX77693_STATUS3_OVP_SHIFT 2
  296. #define MAX77693_STATUS3_OVP_MASK BIT(MAX77693_STATUS3_OVP_SHIFT)
  297. /* MAX77693 CDETCTRL1~2 register */
  298. #define CDETCTRL1_CHGDETEN_SHIFT (0)
  299. #define CDETCTRL1_CHGTYPMAN_SHIFT (1)
  300. #define CDETCTRL1_DCDEN_SHIFT (2)
  301. #define CDETCTRL1_DCD2SCT_SHIFT (3)
  302. #define CDETCTRL1_CDDELAY_SHIFT (4)
  303. #define CDETCTRL1_DCDCPL_SHIFT (5)
  304. #define CDETCTRL1_CDPDET_SHIFT (7)
  305. #define CDETCTRL1_CHGDETEN_MASK (0x1 << CDETCTRL1_CHGDETEN_SHIFT)
  306. #define CDETCTRL1_CHGTYPMAN_MASK (0x1 << CDETCTRL1_CHGTYPMAN_SHIFT)
  307. #define CDETCTRL1_DCDEN_MASK (0x1 << CDETCTRL1_DCDEN_SHIFT)
  308. #define CDETCTRL1_DCD2SCT_MASK (0x1 << CDETCTRL1_DCD2SCT_SHIFT)
  309. #define CDETCTRL1_CDDELAY_MASK (0x1 << CDETCTRL1_CDDELAY_SHIFT)
  310. #define CDETCTRL1_DCDCPL_MASK (0x1 << CDETCTRL1_DCDCPL_SHIFT)
  311. #define CDETCTRL1_CDPDET_MASK (0x1 << CDETCTRL1_CDPDET_SHIFT)
  312. #define CDETCTRL2_VIDRMEN_SHIFT (1)
  313. #define CDETCTRL2_DXOVPEN_SHIFT (3)
  314. #define CDETCTRL2_VIDRMEN_MASK (0x1 << CDETCTRL2_VIDRMEN_SHIFT)
  315. #define CDETCTRL2_DXOVPEN_MASK (0x1 << CDETCTRL2_DXOVPEN_SHIFT)
  316. /* MAX77693 MUIC - CONTROL1~3 register */
  317. #define COMN1SW_SHIFT (0)
  318. #define COMP2SW_SHIFT (3)
  319. #define COMN1SW_MASK (0x7 << COMN1SW_SHIFT)
  320. #define COMP2SW_MASK (0x7 << COMP2SW_SHIFT)
  321. #define COMP_SW_MASK (COMP2SW_MASK | COMN1SW_MASK)
  322. #define MAX77693_CONTROL1_SW_USB ((1 << COMP2SW_SHIFT) \
  323. | (1 << COMN1SW_SHIFT))
  324. #define MAX77693_CONTROL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \
  325. | (2 << COMN1SW_SHIFT))
  326. #define MAX77693_CONTROL1_SW_UART ((3 << COMP2SW_SHIFT) \
  327. | (3 << COMN1SW_SHIFT))
  328. #define MAX77693_CONTROL1_SW_OPEN ((0 << COMP2SW_SHIFT) \
  329. | (0 << COMN1SW_SHIFT))
  330. #define MAX77693_CONTROL2_LOWPWR_SHIFT 0
  331. #define MAX77693_CONTROL2_ADCEN_SHIFT 1
  332. #define MAX77693_CONTROL2_CPEN_SHIFT 2
  333. #define MAX77693_CONTROL2_SFOUTASRT_SHIFT 3
  334. #define MAX77693_CONTROL2_SFOUTORD_SHIFT 4
  335. #define MAX77693_CONTROL2_ACCDET_SHIFT 5
  336. #define MAX77693_CONTROL2_USBCPINT_SHIFT 6
  337. #define MAX77693_CONTROL2_RCPS_SHIFT 7
  338. #define MAX77693_CONTROL2_LOWPWR_MASK BIT(MAX77693_CONTROL2_LOWPWR_SHIFT)
  339. #define MAX77693_CONTROL2_ADCEN_MASK BIT(MAX77693_CONTROL2_ADCEN_SHIFT)
  340. #define MAX77693_CONTROL2_CPEN_MASK BIT(MAX77693_CONTROL2_CPEN_SHIFT)
  341. #define MAX77693_CONTROL2_SFOUTASRT_MASK BIT(MAX77693_CONTROL2_SFOUTASRT_SHIFT)
  342. #define MAX77693_CONTROL2_SFOUTORD_MASK BIT(MAX77693_CONTROL2_SFOUTORD_SHIFT)
  343. #define MAX77693_CONTROL2_ACCDET_MASK BIT(MAX77693_CONTROL2_ACCDET_SHIFT)
  344. #define MAX77693_CONTROL2_USBCPINT_MASK BIT(MAX77693_CONTROL2_USBCPINT_SHIFT)
  345. #define MAX77693_CONTROL2_RCPS_MASK BIT(MAX77693_CONTROL2_RCPS_SHIFT)
  346. #define MAX77693_CONTROL3_JIGSET_SHIFT 0
  347. #define MAX77693_CONTROL3_BTLDSET_SHIFT 2
  348. #define MAX77693_CONTROL3_ADCDBSET_SHIFT 4
  349. #define MAX77693_CONTROL3_JIGSET_MASK (0x3 << MAX77693_CONTROL3_JIGSET_SHIFT)
  350. #define MAX77693_CONTROL3_BTLDSET_MASK (0x3 << MAX77693_CONTROL3_BTLDSET_SHIFT)
  351. #define MAX77693_CONTROL3_ADCDBSET_MASK (0x3 << MAX77693_CONTROL3_ADCDBSET_SHIFT)
  352. /* Slave addr = 0x90: Haptic */
  353. enum max77693_haptic_reg {
  354. MAX77693_HAPTIC_REG_STATUS = 0x00,
  355. MAX77693_HAPTIC_REG_CONFIG1 = 0x01,
  356. MAX77693_HAPTIC_REG_CONFIG2 = 0x02,
  357. MAX77693_HAPTIC_REG_CONFIG_CHNL = 0x03,
  358. MAX77693_HAPTIC_REG_CONFG_CYC1 = 0x04,
  359. MAX77693_HAPTIC_REG_CONFG_CYC2 = 0x05,
  360. MAX77693_HAPTIC_REG_CONFIG_PER1 = 0x06,
  361. MAX77693_HAPTIC_REG_CONFIG_PER2 = 0x07,
  362. MAX77693_HAPTIC_REG_CONFIG_PER3 = 0x08,
  363. MAX77693_HAPTIC_REG_CONFIG_PER4 = 0x09,
  364. MAX77693_HAPTIC_REG_CONFIG_DUTY1 = 0x0A,
  365. MAX77693_HAPTIC_REG_CONFIG_DUTY2 = 0x0B,
  366. MAX77693_HAPTIC_REG_CONFIG_PWM1 = 0x0C,
  367. MAX77693_HAPTIC_REG_CONFIG_PWM2 = 0x0D,
  368. MAX77693_HAPTIC_REG_CONFIG_PWM3 = 0x0E,
  369. MAX77693_HAPTIC_REG_CONFIG_PWM4 = 0x0F,
  370. MAX77693_HAPTIC_REG_REV = 0x10,
  371. MAX77693_HAPTIC_REG_END,
  372. };
  373. /* max77693-pmic LSCNFG configuraton register */
  374. #define MAX77693_PMIC_LOW_SYS_MASK 0x80
  375. #define MAX77693_PMIC_LOW_SYS_SHIFT 7
  376. /* max77693-haptic configuration register */
  377. #define MAX77693_CONFIG2_MODE 7
  378. #define MAX77693_CONFIG2_MEN 6
  379. #define MAX77693_CONFIG2_HTYP 5
  380. enum max77693_irq_source {
  381. LED_INT = 0,
  382. TOPSYS_INT,
  383. CHG_INT,
  384. MUIC_INT1,
  385. MUIC_INT2,
  386. MUIC_INT3,
  387. MAX77693_IRQ_GROUP_NR,
  388. };
  389. #define SRC_IRQ_CHARGER BIT(0)
  390. #define SRC_IRQ_TOP BIT(1)
  391. #define SRC_IRQ_FLASH BIT(2)
  392. #define SRC_IRQ_MUIC BIT(3)
  393. #define SRC_IRQ_ALL (SRC_IRQ_CHARGER | SRC_IRQ_TOP \
  394. | SRC_IRQ_FLASH | SRC_IRQ_MUIC)
  395. #define LED_IRQ_FLED2_OPEN BIT(0)
  396. #define LED_IRQ_FLED2_SHORT BIT(1)
  397. #define LED_IRQ_FLED1_OPEN BIT(2)
  398. #define LED_IRQ_FLED1_SHORT BIT(3)
  399. #define LED_IRQ_MAX_FLASH BIT(4)
  400. #define TOPSYS_IRQ_T120C_INT BIT(0)
  401. #define TOPSYS_IRQ_T140C_INT BIT(1)
  402. #define TOPSYS_IRQ_LOWSYS_INT BIT(3)
  403. #define CHG_IRQ_BYP_I BIT(0)
  404. #define CHG_IRQ_THM_I BIT(2)
  405. #define CHG_IRQ_BAT_I BIT(3)
  406. #define CHG_IRQ_CHG_I BIT(4)
  407. #define CHG_IRQ_CHGIN_I BIT(6)
  408. #define MUIC_IRQ_INT1_ADC BIT(0)
  409. #define MUIC_IRQ_INT1_ADC_LOW BIT(1)
  410. #define MUIC_IRQ_INT1_ADC_ERR BIT(2)
  411. #define MUIC_IRQ_INT1_ADC1K BIT(3)
  412. #define MUIC_IRQ_INT2_CHGTYP BIT(0)
  413. #define MUIC_IRQ_INT2_CHGDETREUN BIT(1)
  414. #define MUIC_IRQ_INT2_DCDTMR BIT(2)
  415. #define MUIC_IRQ_INT2_DXOVP BIT(3)
  416. #define MUIC_IRQ_INT2_VBVOLT BIT(4)
  417. #define MUIC_IRQ_INT2_VIDRM BIT(5)
  418. #define MUIC_IRQ_INT3_EOC BIT(0)
  419. #define MUIC_IRQ_INT3_CGMBC BIT(1)
  420. #define MUIC_IRQ_INT3_OVP BIT(2)
  421. #define MUIC_IRQ_INT3_MBCCHG_ERR BIT(3)
  422. #define MUIC_IRQ_INT3_CHG_ENABLED BIT(4)
  423. #define MUIC_IRQ_INT3_BAT_DET BIT(5)
  424. enum max77693_irq {
  425. /* PMIC - FLASH */
  426. MAX77693_LED_IRQ_FLED2_OPEN,
  427. MAX77693_LED_IRQ_FLED2_SHORT,
  428. MAX77693_LED_IRQ_FLED1_OPEN,
  429. MAX77693_LED_IRQ_FLED1_SHORT,
  430. MAX77693_LED_IRQ_MAX_FLASH,
  431. /* PMIC - TOPSYS */
  432. MAX77693_TOPSYS_IRQ_T120C_INT,
  433. MAX77693_TOPSYS_IRQ_T140C_INT,
  434. MAX77693_TOPSYS_IRQ_LOWSYS_INT,
  435. /* PMIC - Charger */
  436. MAX77693_CHG_IRQ_BYP_I,
  437. MAX77693_CHG_IRQ_THM_I,
  438. MAX77693_CHG_IRQ_BAT_I,
  439. MAX77693_CHG_IRQ_CHG_I,
  440. MAX77693_CHG_IRQ_CHGIN_I,
  441. MAX77693_IRQ_NR,
  442. };
  443. enum max77693_irq_muic {
  444. /* MUIC INT1 */
  445. MAX77693_MUIC_IRQ_INT1_ADC,
  446. MAX77693_MUIC_IRQ_INT1_ADC_LOW,
  447. MAX77693_MUIC_IRQ_INT1_ADC_ERR,
  448. MAX77693_MUIC_IRQ_INT1_ADC1K,
  449. /* MUIC INT2 */
  450. MAX77693_MUIC_IRQ_INT2_CHGTYP,
  451. MAX77693_MUIC_IRQ_INT2_CHGDETREUN,
  452. MAX77693_MUIC_IRQ_INT2_DCDTMR,
  453. MAX77693_MUIC_IRQ_INT2_DXOVP,
  454. MAX77693_MUIC_IRQ_INT2_VBVOLT,
  455. MAX77693_MUIC_IRQ_INT2_VIDRM,
  456. /* MUIC INT3 */
  457. MAX77693_MUIC_IRQ_INT3_EOC,
  458. MAX77693_MUIC_IRQ_INT3_CGMBC,
  459. MAX77693_MUIC_IRQ_INT3_OVP,
  460. MAX77693_MUIC_IRQ_INT3_MBCCHG_ERR,
  461. MAX77693_MUIC_IRQ_INT3_CHG_ENABLED,
  462. MAX77693_MUIC_IRQ_INT3_BAT_DET,
  463. MAX77693_MUIC_IRQ_NR,
  464. };
  465. #endif /* __LINUX_MFD_MAX77693_PRIV_H */