max77843-private.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. /*
  2. * Common variables for the Maxim MAX77843 driver
  3. *
  4. * Copyright (C) 2015 Samsung Electronics
  5. * Author: Jaewon Kim <jaewon02.kim@samsung.com>
  6. * Author: Beomho Seo <beomho.seo@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. #ifndef __MAX77843_PRIVATE_H_
  14. #define __MAX77843_PRIVATE_H_
  15. #include <linux/i2c.h>
  16. #include <linux/regmap.h>
  17. #define I2C_ADDR_TOPSYS (0xCC >> 1)
  18. #define I2C_ADDR_CHG (0xD2 >> 1)
  19. #define I2C_ADDR_FG (0x6C >> 1)
  20. #define I2C_ADDR_MUIC (0x4A >> 1)
  21. /* Topsys, Haptic and LED registers */
  22. enum max77843_sys_reg {
  23. MAX77843_SYS_REG_PMICID = 0x00,
  24. MAX77843_SYS_REG_PMICREV = 0x01,
  25. MAX77843_SYS_REG_MAINCTRL1 = 0x02,
  26. MAX77843_SYS_REG_INTSRC = 0x22,
  27. MAX77843_SYS_REG_INTSRCMASK = 0x23,
  28. MAX77843_SYS_REG_SYSINTSRC = 0x24,
  29. MAX77843_SYS_REG_SYSINTMASK = 0x26,
  30. MAX77843_SYS_REG_TOPSYS_STAT = 0x28,
  31. MAX77843_SYS_REG_SAFEOUTCTRL = 0xC6,
  32. MAX77843_SYS_REG_END,
  33. };
  34. enum max77843_haptic_reg {
  35. MAX77843_HAP_REG_MCONFIG = 0x10,
  36. MAX77843_HAP_REG_END,
  37. };
  38. enum max77843_led_reg {
  39. MAX77843_LED_REG_LEDEN = 0x30,
  40. MAX77843_LED_REG_LED0BRT = 0x31,
  41. MAX77843_LED_REG_LED1BRT = 0x32,
  42. MAX77843_LED_REG_LED2BRT = 0x33,
  43. MAX77843_LED_REG_LED3BRT = 0x34,
  44. MAX77843_LED_REG_LEDBLNK = 0x38,
  45. MAX77843_LED_REG_LEDRAMP = 0x36,
  46. MAX77843_LED_REG_END,
  47. };
  48. /* Charger registers */
  49. enum max77843_charger_reg {
  50. MAX77843_CHG_REG_CHG_INT = 0xB0,
  51. MAX77843_CHG_REG_CHG_INT_MASK = 0xB1,
  52. MAX77843_CHG_REG_CHG_INT_OK = 0xB2,
  53. MAX77843_CHG_REG_CHG_DTLS_00 = 0xB3,
  54. MAX77843_CHG_REG_CHG_DTLS_01 = 0xB4,
  55. MAX77843_CHG_REG_CHG_DTLS_02 = 0xB5,
  56. MAX77843_CHG_REG_CHG_CNFG_00 = 0xB7,
  57. MAX77843_CHG_REG_CHG_CNFG_01 = 0xB8,
  58. MAX77843_CHG_REG_CHG_CNFG_02 = 0xB9,
  59. MAX77843_CHG_REG_CHG_CNFG_03 = 0xBA,
  60. MAX77843_CHG_REG_CHG_CNFG_04 = 0xBB,
  61. MAX77843_CHG_REG_CHG_CNFG_06 = 0xBD,
  62. MAX77843_CHG_REG_CHG_CNFG_07 = 0xBE,
  63. MAX77843_CHG_REG_CHG_CNFG_09 = 0xC0,
  64. MAX77843_CHG_REG_CHG_CNFG_10 = 0xC1,
  65. MAX77843_CHG_REG_CHG_CNFG_11 = 0xC2,
  66. MAX77843_CHG_REG_CHG_CNFG_12 = 0xC3,
  67. MAX77843_CHG_REG_END,
  68. };
  69. /* Fuel gauge registers */
  70. enum max77843_fuelgauge {
  71. MAX77843_FG_REG_STATUS = 0x00,
  72. MAX77843_FG_REG_VALRT_TH = 0x01,
  73. MAX77843_FG_REG_TALRT_TH = 0x02,
  74. MAX77843_FG_REG_SALRT_TH = 0x03,
  75. MAX77843_FG_RATE_AT_RATE = 0x04,
  76. MAX77843_FG_REG_REMCAP_REP = 0x05,
  77. MAX77843_FG_REG_SOCREP = 0x06,
  78. MAX77843_FG_REG_AGE = 0x07,
  79. MAX77843_FG_REG_TEMP = 0x08,
  80. MAX77843_FG_REG_VCELL = 0x09,
  81. MAX77843_FG_REG_CURRENT = 0x0A,
  82. MAX77843_FG_REG_AVG_CURRENT = 0x0B,
  83. MAX77843_FG_REG_SOCMIX = 0x0D,
  84. MAX77843_FG_REG_SOCAV = 0x0E,
  85. MAX77843_FG_REG_REMCAP_MIX = 0x0F,
  86. MAX77843_FG_REG_FULLCAP = 0x10,
  87. MAX77843_FG_REG_AVG_TEMP = 0x16,
  88. MAX77843_FG_REG_CYCLES = 0x17,
  89. MAX77843_FG_REG_AVG_VCELL = 0x19,
  90. MAX77843_FG_REG_CONFIG = 0x1D,
  91. MAX77843_FG_REG_REMCAP_AV = 0x1F,
  92. MAX77843_FG_REG_FULLCAP_NOM = 0x23,
  93. MAX77843_FG_REG_MISCCFG = 0x2B,
  94. MAX77843_FG_REG_RCOMP = 0x38,
  95. MAX77843_FG_REG_FSTAT = 0x3D,
  96. MAX77843_FG_REG_DQACC = 0x45,
  97. MAX77843_FG_REG_DPACC = 0x46,
  98. MAX77843_FG_REG_OCV = 0xEE,
  99. MAX77843_FG_REG_VFOCV = 0xFB,
  100. MAX77843_FG_SOCVF = 0xFF,
  101. MAX77843_FG_END,
  102. };
  103. /* MUIC registers */
  104. enum max77843_muic_reg {
  105. MAX77843_MUIC_REG_ID = 0x00,
  106. MAX77843_MUIC_REG_INT1 = 0x01,
  107. MAX77843_MUIC_REG_INT2 = 0x02,
  108. MAX77843_MUIC_REG_INT3 = 0x03,
  109. MAX77843_MUIC_REG_STATUS1 = 0x04,
  110. MAX77843_MUIC_REG_STATUS2 = 0x05,
  111. MAX77843_MUIC_REG_STATUS3 = 0x06,
  112. MAX77843_MUIC_REG_INTMASK1 = 0x07,
  113. MAX77843_MUIC_REG_INTMASK2 = 0x08,
  114. MAX77843_MUIC_REG_INTMASK3 = 0x09,
  115. MAX77843_MUIC_REG_CDETCTRL1 = 0x0A,
  116. MAX77843_MUIC_REG_CDETCTRL2 = 0x0B,
  117. MAX77843_MUIC_REG_CONTROL1 = 0x0C,
  118. MAX77843_MUIC_REG_CONTROL2 = 0x0D,
  119. MAX77843_MUIC_REG_CONTROL3 = 0x0E,
  120. MAX77843_MUIC_REG_CONTROL4 = 0x16,
  121. MAX77843_MUIC_REG_HVCONTROL1 = 0x17,
  122. MAX77843_MUIC_REG_HVCONTROL2 = 0x18,
  123. MAX77843_MUIC_REG_END,
  124. };
  125. enum max77843_irq {
  126. /* Topsys: SYSTEM */
  127. MAX77843_SYS_IRQ_SYSINTSRC_SYSUVLO_INT,
  128. MAX77843_SYS_IRQ_SYSINTSRC_SYSOVLO_INT,
  129. MAX77843_SYS_IRQ_SYSINTSRC_TSHDN_INT,
  130. MAX77843_SYS_IRQ_SYSINTSRC_TM_INT,
  131. /* Charger: CHG_INT */
  132. MAX77843_CHG_IRQ_CHG_INT_BYP_I,
  133. MAX77843_CHG_IRQ_CHG_INT_BATP_I,
  134. MAX77843_CHG_IRQ_CHG_INT_BAT_I,
  135. MAX77843_CHG_IRQ_CHG_INT_CHG_I,
  136. MAX77843_CHG_IRQ_CHG_INT_WCIN_I,
  137. MAX77843_CHG_IRQ_CHG_INT_CHGIN_I,
  138. MAX77843_CHG_IRQ_CHG_INT_AICL_I,
  139. MAX77843_IRQ_NUM,
  140. };
  141. enum max77843_irq_muic {
  142. /* MUIC: INT1 */
  143. MAX77843_MUIC_IRQ_INT1_ADC,
  144. MAX77843_MUIC_IRQ_INT1_ADCERROR,
  145. MAX77843_MUIC_IRQ_INT1_ADC1K,
  146. /* MUIC: INT2 */
  147. MAX77843_MUIC_IRQ_INT2_CHGTYP,
  148. MAX77843_MUIC_IRQ_INT2_CHGDETRUN,
  149. MAX77843_MUIC_IRQ_INT2_DCDTMR,
  150. MAX77843_MUIC_IRQ_INT2_DXOVP,
  151. MAX77843_MUIC_IRQ_INT2_VBVOLT,
  152. /* MUIC: INT3 */
  153. MAX77843_MUIC_IRQ_INT3_VBADC,
  154. MAX77843_MUIC_IRQ_INT3_VDNMON,
  155. MAX77843_MUIC_IRQ_INT3_DNRES,
  156. MAX77843_MUIC_IRQ_INT3_MPNACK,
  157. MAX77843_MUIC_IRQ_INT3_MRXBUFOW,
  158. MAX77843_MUIC_IRQ_INT3_MRXTRF,
  159. MAX77843_MUIC_IRQ_INT3_MRXPERR,
  160. MAX77843_MUIC_IRQ_INT3_MRXRDY,
  161. MAX77843_MUIC_IRQ_NUM,
  162. };
  163. /* MAX77843 interrupts */
  164. #define MAX77843_SYS_IRQ_SYSUVLO_INT BIT(0)
  165. #define MAX77843_SYS_IRQ_SYSOVLO_INT BIT(1)
  166. #define MAX77843_SYS_IRQ_TSHDN_INT BIT(2)
  167. #define MAX77843_SYS_IRQ_TM_INT BIT(3)
  168. /* MAX77843 MAINCTRL1 register */
  169. #define MAINCTRL1_BIASEN_SHIFT 7
  170. #define MAX77843_MAINCTRL1_BIASEN_MASK BIT(MAINCTRL1_BIASEN_SHIFT)
  171. /* MAX77843 MCONFIG register */
  172. #define MCONFIG_MODE_SHIFT 7
  173. #define MCONFIG_MEN_SHIFT 6
  174. #define MCONFIG_PDIV_SHIFT 0
  175. #define MAX77843_MCONFIG_MODE_MASK BIT(MCONFIG_MODE_SHIFT)
  176. #define MAX77843_MCONFIG_MEN_MASK BIT(MCONFIG_MEN_SHIFT)
  177. #define MAX77843_MCONFIG_PDIV_MASK (0x3 << MCONFIG_PDIV_SHIFT)
  178. /* Max77843 charger insterrupts */
  179. #define MAX77843_CHG_BYP_I BIT(0)
  180. #define MAX77843_CHG_BATP_I BIT(2)
  181. #define MAX77843_CHG_BAT_I BIT(3)
  182. #define MAX77843_CHG_CHG_I BIT(4)
  183. #define MAX77843_CHG_WCIN_I BIT(5)
  184. #define MAX77843_CHG_CHGIN_I BIT(6)
  185. #define MAX77843_CHG_AICL_I BIT(7)
  186. /* MAX77843 CHG_INT_OK register */
  187. #define MAX77843_CHG_BYP_OK BIT(0)
  188. #define MAX77843_CHG_BATP_OK BIT(2)
  189. #define MAX77843_CHG_BAT_OK BIT(3)
  190. #define MAX77843_CHG_CHG_OK BIT(4)
  191. #define MAX77843_CHG_WCIN_OK BIT(5)
  192. #define MAX77843_CHG_CHGIN_OK BIT(6)
  193. #define MAX77843_CHG_AICL_OK BIT(7)
  194. /* MAX77843 CHG_DETAILS_00 register */
  195. #define MAX77843_CHG_BAT_DTLS BIT(0)
  196. /* MAX77843 CHG_DETAILS_01 register */
  197. #define MAX77843_CHG_DTLS_MASK 0x0f
  198. #define MAX77843_CHG_PQ_MODE 0x00
  199. #define MAX77843_CHG_CC_MODE 0x01
  200. #define MAX77843_CHG_CV_MODE 0x02
  201. #define MAX77843_CHG_TO_MODE 0x03
  202. #define MAX77843_CHG_DO_MODE 0x04
  203. #define MAX77843_CHG_HT_MODE 0x05
  204. #define MAX77843_CHG_TF_MODE 0x06
  205. #define MAX77843_CHG_TS_MODE 0x07
  206. #define MAX77843_CHG_OFF_MODE 0x08
  207. #define MAX77843_CHG_BAT_DTLS_MASK 0xf0
  208. #define MAX77843_CHG_NO_BAT (0x00 << 4)
  209. #define MAX77843_CHG_LOW_VOLT_BAT (0x01 << 4)
  210. #define MAX77843_CHG_LONG_BAT_TIME (0x02 << 4)
  211. #define MAX77843_CHG_OK_BAT (0x03 << 4)
  212. #define MAX77843_CHG_OK_LOW_VOLT_BAT (0x04 << 4)
  213. #define MAX77843_CHG_OVER_VOLT_BAT (0x05 << 4)
  214. #define MAX77843_CHG_OVER_CURRENT_BAT (0x06 << 4)
  215. /* MAX77843 CHG_CNFG_00 register */
  216. #define MAX77843_CHG_DISABLE 0x00
  217. #define MAX77843_CHG_ENABLE 0x05
  218. #define MAX77843_CHG_MASK 0x01
  219. #define MAX77843_CHG_BUCK_MASK 0x04
  220. /* MAX77843 CHG_CNFG_01 register */
  221. #define MAX77843_CHG_RESTART_THRESHOLD_100 0x00
  222. #define MAX77843_CHG_RESTART_THRESHOLD_150 0x10
  223. #define MAX77843_CHG_RESTART_THRESHOLD_200 0x20
  224. #define MAX77843_CHG_RESTART_THRESHOLD_DISABLE 0x30
  225. /* MAX77843 CHG_CNFG_02 register */
  226. #define MAX77843_CHG_FAST_CHG_CURRENT_MIN 100000
  227. #define MAX77843_CHG_FAST_CHG_CURRENT_MAX 3150000
  228. #define MAX77843_CHG_FAST_CHG_CURRENT_STEP 50000
  229. #define MAX77843_CHG_FAST_CHG_CURRENT_MASK 0x3f
  230. #define MAX77843_CHG_OTG_ILIMIT_500 (0x00 << 6)
  231. #define MAX77843_CHG_OTG_ILIMIT_900 (0x01 << 6)
  232. #define MAX77843_CHG_OTG_ILIMIT_1200 (0x02 << 6)
  233. #define MAX77843_CHG_OTG_ILIMIT_1500 (0x03 << 6)
  234. #define MAX77843_CHG_OTG_ILIMIT_MASK 0xc0
  235. /* MAX77843 CHG_CNFG_03 register */
  236. #define MAX77843_CHG_TOP_OFF_CURRENT_MIN 125000
  237. #define MAX77843_CHG_TOP_OFF_CURRENT_MAX 650000
  238. #define MAX77843_CHG_TOP_OFF_CURRENT_STEP 75000
  239. #define MAX77843_CHG_TOP_OFF_CURRENT_MASK 0x07
  240. /* MAX77843 CHG_CNFG_06 register */
  241. #define MAX77843_CHG_WRITE_CAP_BLOCK 0x10
  242. #define MAX77843_CHG_WRITE_CAP_UNBLOCK 0x0C
  243. /* MAX77843_CHG_CNFG_09_register */
  244. #define MAX77843_CHG_INPUT_CURRENT_LIMIT_MIN 100000
  245. #define MAX77843_CHG_INPUT_CURRENT_LIMIT_MAX 4000000
  246. #define MAX77843_CHG_INPUT_CURRENT_LIMIT_REF 3367000
  247. #define MAX77843_CHG_INPUT_CURRENT_LIMIT_STEP 33000
  248. #define MAX77843_MUIC_ADC BIT(0)
  249. #define MAX77843_MUIC_ADCERROR BIT(2)
  250. #define MAX77843_MUIC_ADC1K BIT(3)
  251. #define MAX77843_MUIC_CHGTYP BIT(0)
  252. #define MAX77843_MUIC_CHGDETRUN BIT(1)
  253. #define MAX77843_MUIC_DCDTMR BIT(2)
  254. #define MAX77843_MUIC_DXOVP BIT(3)
  255. #define MAX77843_MUIC_VBVOLT BIT(4)
  256. #define MAX77843_MUIC_VBADC BIT(0)
  257. #define MAX77843_MUIC_VDNMON BIT(1)
  258. #define MAX77843_MUIC_DNRES BIT(2)
  259. #define MAX77843_MUIC_MPNACK BIT(3)
  260. #define MAX77843_MUIC_MRXBUFOW BIT(4)
  261. #define MAX77843_MUIC_MRXTRF BIT(5)
  262. #define MAX77843_MUIC_MRXPERR BIT(6)
  263. #define MAX77843_MUIC_MRXRDY BIT(7)
  264. /* MAX77843 INTSRCMASK register */
  265. #define MAX77843_INTSRCMASK_CHGR 0
  266. #define MAX77843_INTSRCMASK_SYS 1
  267. #define MAX77843_INTSRCMASK_FG 2
  268. #define MAX77843_INTSRCMASK_MUIC 3
  269. #define MAX77843_INTSRCMASK_CHGR_MASK BIT(MAX77843_INTSRCMASK_CHGR)
  270. #define MAX77843_INTSRCMASK_SYS_MASK BIT(MAX77843_INTSRCMASK_SYS)
  271. #define MAX77843_INTSRCMASK_FG_MASK BIT(MAX77843_INTSRCMASK_FG)
  272. #define MAX77843_INTSRCMASK_MUIC_MASK BIT(MAX77843_INTSRCMASK_MUIC)
  273. #define MAX77843_INTSRC_MASK_MASK \
  274. (MAX77843_INTSRCMASK_MUIC_MASK | MAX77843_INTSRCMASK_FG_MASK | \
  275. MAX77843_INTSRCMASK_SYS_MASK | MAX77843_INTSRCMASK_CHGR_MASK)
  276. /* MAX77843 STATUS register*/
  277. #define MAX77843_MUIC_STATUS1_ADC_SHIFT 0
  278. #define MAX77843_MUIC_STATUS1_ADCERROR_SHIFT 6
  279. #define MAX77843_MUIC_STATUS1_ADC1K_SHIFT 7
  280. #define MAX77843_MUIC_STATUS2_CHGTYP_SHIFT 0
  281. #define MAX77843_MUIC_STATUS2_CHGDETRUN_SHIFT 3
  282. #define MAX77843_MUIC_STATUS2_DCDTMR_SHIFT 4
  283. #define MAX77843_MUIC_STATUS2_DXOVP_SHIFT 5
  284. #define MAX77843_MUIC_STATUS2_VBVOLT_SHIFT 6
  285. #define MAX77843_MUIC_STATUS3_VBADC_SHIFT 0
  286. #define MAX77843_MUIC_STATUS3_VDNMON_SHIFT 4
  287. #define MAX77843_MUIC_STATUS3_DNRES_SHIFT 5
  288. #define MAX77843_MUIC_STATUS3_MPNACK_SHIFT 6
  289. #define MAX77843_MUIC_STATUS1_ADC_MASK (0x1f << MAX77843_MUIC_STATUS1_ADC_SHIFT)
  290. #define MAX77843_MUIC_STATUS1_ADCERROR_MASK BIT(MAX77843_MUIC_STATUS1_ADCERROR_SHIFT)
  291. #define MAX77843_MUIC_STATUS1_ADC1K_MASK BIT(MAX77843_MUIC_STATUS1_ADC1K_SHIFT)
  292. #define MAX77843_MUIC_STATUS2_CHGTYP_MASK (0x7 << MAX77843_MUIC_STATUS2_CHGTYP_SHIFT)
  293. #define MAX77843_MUIC_STATUS2_CHGDETRUN_MASK BIT(MAX77843_MUIC_STATUS2_CHGDETRUN_SHIFT)
  294. #define MAX77843_MUIC_STATUS2_DCDTMR_MASK BIT(MAX77843_MUIC_STATUS2_DCDTMR_SHIFT)
  295. #define MAX77843_MUIC_STATUS2_DXOVP_MASK BIT(MAX77843_MUIC_STATUS2_DXOVP_SHIFT)
  296. #define MAX77843_MUIC_STATUS2_VBVOLT_MASK BIT(MAX77843_MUIC_STATUS2_VBVOLT_SHIFT)
  297. #define MAX77843_MUIC_STATUS3_VBADC_MASK (0xf << MAX77843_MUIC_STATUS3_VBADC_SHIFT)
  298. #define MAX77843_MUIC_STATUS3_VDNMON_MASK BIT(MAX77843_MUIC_STATUS3_VDNMON_SHIFT)
  299. #define MAX77843_MUIC_STATUS3_DNRES_MASK BIT(MAX77843_MUIC_STATUS3_DNRES_SHIFT)
  300. #define MAX77843_MUIC_STATUS3_MPNACK_MASK BIT(MAX77843_MUIC_STATUS3_MPNACK_SHIFT)
  301. /* MAX77843 CONTROL register */
  302. #define MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT 0
  303. #define MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT 3
  304. #define MAX77843_MUIC_CONTROL1_IDBEN_SHIFT 7
  305. #define MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT 0
  306. #define MAX77843_MUIC_CONTROL2_ADCEN_SHIFT 1
  307. #define MAX77843_MUIC_CONTROL2_CPEN_SHIFT 2
  308. #define MAX77843_MUIC_CONTROL2_ACC_DET_SHIFT 5
  309. #define MAX77843_MUIC_CONTROL2_USBCPINT_SHIFT 6
  310. #define MAX77843_MUIC_CONTROL2_RCPS_SHIFT 7
  311. #define MAX77843_MUIC_CONTROL3_JIGSET_SHIFT 0
  312. #define MAX77843_MUIC_CONTROL4_ADCDBSET_SHIFT 0
  313. #define MAX77843_MUIC_CONTROL4_USBAUTO_SHIFT 4
  314. #define MAX77843_MUIC_CONTROL4_FCTAUTO_SHIFT 5
  315. #define MAX77843_MUIC_CONTROL4_ADCMODE_SHIFT 6
  316. #define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT)
  317. #define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT)
  318. #define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(MAX77843_MUIC_CONTROL1_IDBEN_SHIFT)
  319. #define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT)
  320. #define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(MAX77843_MUIC_CONTROL2_ADCEN_SHIFT)
  321. #define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(MAX77843_MUIC_CONTROL2_CPEN_SHIFT)
  322. #define MAX77843_MUIC_CONTROL2_ACC_DET_MASK BIT(MAX77843_MUIC_CONTROL2_ACC_DET_SHIFT)
  323. #define MAX77843_MUIC_CONTROL2_USBCPINT_MASK BIT(MAX77843_MUIC_CONTROL2_USBCPINT_SHIFT)
  324. #define MAX77843_MUIC_CONTROL2_RCPS_MASK BIT(MAX77843_MUIC_CONTROL2_RCPS_SHIFT)
  325. #define MAX77843_MUIC_CONTROL3_JIGSET_MASK (0x3 << MAX77843_MUIC_CONTROL3_JIGSET_SHIFT)
  326. #define MAX77843_MUIC_CONTROL4_ADCDBSET_MASK (0x3 << MAX77843_MUIC_CONTROL4_ADCDBSET_SHIFT)
  327. #define MAX77843_MUIC_CONTROL4_USBAUTO_MASK BIT(MAX77843_MUIC_CONTROL4_USBAUTO_SHIFT)
  328. #define MAX77843_MUIC_CONTROL4_FCTAUTO_MASK BIT(MAX77843_MUIC_CONTROL4_FCTAUTO_SHIFT)
  329. #define MAX77843_MUIC_CONTROL4_ADCMODE_MASK (0x3 << MAX77843_MUIC_CONTROL4_ADCMODE_SHIFT)
  330. /* MAX77843 switch port */
  331. #define COM_OPEN 0
  332. #define COM_USB 1
  333. #define COM_AUDIO 2
  334. #define COM_UART 3
  335. #define COM_AUX_USB 4
  336. #define COM_AUX_UART 5
  337. #define MAX77843_MUIC_CONTROL1_COM_SW \
  338. ((MAX77843_MUIC_CONTROL1_COMP1SW_MASK | \
  339. MAX77843_MUIC_CONTROL1_COMP2SW_MASK))
  340. #define MAX77843_MUIC_CONTROL1_SW_OPEN \
  341. ((COM_OPEN << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
  342. COM_OPEN << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
  343. #define MAX77843_MUIC_CONTROL1_SW_USB \
  344. ((COM_USB << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
  345. COM_USB << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
  346. #define MAX77843_MUIC_CONTROL1_SW_AUDIO \
  347. ((COM_AUDIO << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
  348. COM_AUDIO << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
  349. #define MAX77843_MUIC_CONTROL1_SW_UART \
  350. ((COM_UART << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
  351. COM_UART << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
  352. #define MAX77843_MUIC_CONTROL1_SW_AUX_USB \
  353. ((COM_AUX_USB << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
  354. COM_AUX_USB << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
  355. #define MAX77843_MUIC_CONTROL1_SW_AUX_UART \
  356. ((COM_AUX_UART << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT | \
  357. COM_AUX_UART << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT))
  358. #define MAX77843_DISABLE 0
  359. #define MAX77843_ENABLE 1
  360. #define CONTROL4_AUTO_DISABLE \
  361. ((MAX77843_DISABLE << MAX77843_MUIC_CONTROL4_USBAUTO_SHIFT) | \
  362. (MAX77843_DISABLE << MAX77843_MUIC_CONTROL4_FCTAUTO_SHIFT))
  363. #define CONTROL4_AUTO_ENABLE \
  364. ((MAX77843_ENABLE << MAX77843_MUIC_CONTROL4_USBAUTO_SHIFT) | \
  365. (MAX77843_ENABLE << MAX77843_MUIC_CONTROL4_FCTAUTO_SHIFT))
  366. /* MAX77843 SAFEOUT LDO Control register */
  367. #define SAFEOUTCTRL_SAFEOUT1_SHIFT 0
  368. #define SAFEOUTCTRL_SAFEOUT2_SHIFT 2
  369. #define SAFEOUTCTRL_ENSAFEOUT1_SHIFT 6
  370. #define SAFEOUTCTRL_ENSAFEOUT2_SHIFT 7
  371. #define MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT1 \
  372. BIT(SAFEOUTCTRL_ENSAFEOUT1_SHIFT)
  373. #define MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT2 \
  374. BIT(SAFEOUTCTRL_ENSAFEOUT2_SHIFT)
  375. #define MAX77843_REG_SAFEOUTCTRL_SAFEOUT1_MASK \
  376. (0x3 << SAFEOUTCTRL_SAFEOUT1_SHIFT)
  377. #define MAX77843_REG_SAFEOUTCTRL_SAFEOUT2_MASK \
  378. (0x3 << SAFEOUTCTRL_SAFEOUT2_SHIFT)
  379. #endif /* __MAX77843_H__ */