rohm-bd718x7.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /* Copyright (C) 2018 ROHM Semiconductors */
  3. #ifndef __LINUX_MFD_BD718XX_H__
  4. #define __LINUX_MFD_BD718XX_H__
  5. #include <linux/mfd/rohm-generic.h>
  6. #include <linux/regmap.h>
  7. enum {
  8. BD718XX_BUCK1 = 0,
  9. BD718XX_BUCK2,
  10. BD718XX_BUCK3,
  11. BD718XX_BUCK4,
  12. BD718XX_BUCK5,
  13. BD718XX_BUCK6,
  14. BD718XX_BUCK7,
  15. BD718XX_BUCK8,
  16. BD718XX_LDO1,
  17. BD718XX_LDO2,
  18. BD718XX_LDO3,
  19. BD718XX_LDO4,
  20. BD718XX_LDO5,
  21. BD718XX_LDO6,
  22. BD718XX_LDO7,
  23. BD718XX_REGULATOR_AMOUNT,
  24. };
  25. /* Common voltage configurations */
  26. #define BD718XX_DVS_BUCK_VOLTAGE_NUM 0x3D
  27. #define BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM 0x3D
  28. #define BD718XX_LDO1_VOLTAGE_NUM 0x08
  29. #define BD718XX_LDO2_VOLTAGE_NUM 0x02
  30. #define BD718XX_LDO3_VOLTAGE_NUM 0x10
  31. #define BD718XX_LDO4_VOLTAGE_NUM 0x0A
  32. #define BD718XX_LDO6_VOLTAGE_NUM 0x0A
  33. /* BD71837 specific voltage configurations */
  34. #define BD71837_BUCK5_VOLTAGE_NUM 0x10
  35. #define BD71837_BUCK6_VOLTAGE_NUM 0x04
  36. #define BD71837_BUCK7_VOLTAGE_NUM 0x08
  37. #define BD71837_LDO5_VOLTAGE_NUM 0x10
  38. #define BD71837_LDO7_VOLTAGE_NUM 0x10
  39. /* BD71847 specific voltage configurations */
  40. #define BD71847_BUCK3_VOLTAGE_NUM 0x18
  41. #define BD71847_BUCK4_VOLTAGE_NUM 0x08
  42. #define BD71847_LDO5_VOLTAGE_NUM 0x20
  43. /* Registers specific to BD71837 */
  44. enum {
  45. BD71837_REG_BUCK3_CTRL = 0x07,
  46. BD71837_REG_BUCK4_CTRL = 0x08,
  47. BD71837_REG_BUCK3_VOLT_RUN = 0x12,
  48. BD71837_REG_BUCK4_VOLT_RUN = 0x13,
  49. BD71837_REG_LDO7_VOLT = 0x1E,
  50. };
  51. /* Registers common for BD71837 and BD71847 */
  52. enum {
  53. BD718XX_REG_REV = 0x00,
  54. BD718XX_REG_SWRESET = 0x01,
  55. BD718XX_REG_I2C_DEV = 0x02,
  56. BD718XX_REG_PWRCTRL0 = 0x03,
  57. BD718XX_REG_PWRCTRL1 = 0x04,
  58. BD718XX_REG_BUCK1_CTRL = 0x05,
  59. BD718XX_REG_BUCK2_CTRL = 0x06,
  60. BD718XX_REG_1ST_NODVS_BUCK_CTRL = 0x09,
  61. BD718XX_REG_2ND_NODVS_BUCK_CTRL = 0x0A,
  62. BD718XX_REG_3RD_NODVS_BUCK_CTRL = 0x0B,
  63. BD718XX_REG_4TH_NODVS_BUCK_CTRL = 0x0C,
  64. BD718XX_REG_BUCK1_VOLT_RUN = 0x0D,
  65. BD718XX_REG_BUCK1_VOLT_IDLE = 0x0E,
  66. BD718XX_REG_BUCK1_VOLT_SUSP = 0x0F,
  67. BD718XX_REG_BUCK2_VOLT_RUN = 0x10,
  68. BD718XX_REG_BUCK2_VOLT_IDLE = 0x11,
  69. BD718XX_REG_1ST_NODVS_BUCK_VOLT = 0x14,
  70. BD718XX_REG_2ND_NODVS_BUCK_VOLT = 0x15,
  71. BD718XX_REG_3RD_NODVS_BUCK_VOLT = 0x16,
  72. BD718XX_REG_4TH_NODVS_BUCK_VOLT = 0x17,
  73. BD718XX_REG_LDO1_VOLT = 0x18,
  74. BD718XX_REG_LDO2_VOLT = 0x19,
  75. BD718XX_REG_LDO3_VOLT = 0x1A,
  76. BD718XX_REG_LDO4_VOLT = 0x1B,
  77. BD718XX_REG_LDO5_VOLT = 0x1C,
  78. BD718XX_REG_LDO6_VOLT = 0x1D,
  79. BD718XX_REG_TRANS_COND0 = 0x1F,
  80. BD718XX_REG_TRANS_COND1 = 0x20,
  81. BD718XX_REG_VRFAULTEN = 0x21,
  82. BD718XX_REG_MVRFLTMASK0 = 0x22,
  83. BD718XX_REG_MVRFLTMASK1 = 0x23,
  84. BD718XX_REG_MVRFLTMASK2 = 0x24,
  85. BD718XX_REG_RCVCFG = 0x25,
  86. BD718XX_REG_RCVNUM = 0x26,
  87. BD718XX_REG_PWRONCONFIG0 = 0x27,
  88. BD718XX_REG_PWRONCONFIG1 = 0x28,
  89. BD718XX_REG_RESETSRC = 0x29,
  90. BD718XX_REG_MIRQ = 0x2A,
  91. BD718XX_REG_IRQ = 0x2B,
  92. BD718XX_REG_IN_MON = 0x2C,
  93. BD718XX_REG_POW_STATE = 0x2D,
  94. BD718XX_REG_OUT32K = 0x2E,
  95. BD718XX_REG_REGLOCK = 0x2F,
  96. BD718XX_REG_OTPVER = 0xFF,
  97. BD718XX_MAX_REGISTER = 0x100,
  98. };
  99. #define REGLOCK_PWRSEQ 0x1
  100. #define REGLOCK_VREG 0x10
  101. /* Generic BUCK control masks */
  102. #define BD718XX_BUCK_SEL 0x02
  103. #define BD718XX_BUCK_EN 0x01
  104. #define BD718XX_BUCK_RUN_ON 0x04
  105. /* Generic LDO masks */
  106. #define BD718XX_LDO_SEL 0x80
  107. #define BD718XX_LDO_EN 0x40
  108. /* BD71837 BUCK ramp rate CTRL reg bits */
  109. #define BUCK_RAMPRATE_MASK 0xC0
  110. #define BUCK_RAMPRATE_10P00MV 0x0
  111. #define BUCK_RAMPRATE_5P00MV 0x1
  112. #define BUCK_RAMPRATE_2P50MV 0x2
  113. #define BUCK_RAMPRATE_1P25MV 0x3
  114. #define DVS_BUCK_RUN_MASK 0x3F
  115. #define DVS_BUCK_SUSP_MASK 0x3F
  116. #define DVS_BUCK_IDLE_MASK 0x3F
  117. #define BD718XX_1ST_NODVS_BUCK_MASK 0x07
  118. #define BD718XX_3RD_NODVS_BUCK_MASK 0x07
  119. #define BD718XX_4TH_NODVS_BUCK_MASK 0x3F
  120. #define BD71847_BUCK3_MASK 0x07
  121. #define BD71847_BUCK3_RANGE_MASK 0xC0
  122. #define BD71847_BUCK4_MASK 0x03
  123. #define BD71847_BUCK4_RANGE_MASK 0x40
  124. #define BD71837_BUCK5_MASK 0x07
  125. #define BD71837_BUCK5_RANGE_MASK 0x80
  126. #define BD71837_BUCK6_MASK 0x03
  127. #define BD718XX_LDO1_MASK 0x03
  128. #define BD718XX_LDO1_RANGE_MASK 0x20
  129. #define BD718XX_LDO2_MASK 0x20
  130. #define BD718XX_LDO3_MASK 0x0F
  131. #define BD718XX_LDO4_MASK 0x0F
  132. #define BD718XX_LDO6_MASK 0x0F
  133. #define BD71837_LDO5_MASK 0x0F
  134. #define BD71847_LDO5_MASK 0x0F
  135. #define BD71847_LDO5_RANGE_MASK 0x20
  136. #define BD71837_LDO7_MASK 0x0F
  137. /* BD718XX Voltage monitoring masks */
  138. #define BD718XX_BUCK1_VRMON80 0x1
  139. #define BD718XX_BUCK1_VRMON130 0x2
  140. #define BD718XX_BUCK2_VRMON80 0x4
  141. #define BD718XX_BUCK2_VRMON130 0x8
  142. #define BD718XX_1ST_NODVS_BUCK_VRMON80 0x1
  143. #define BD718XX_1ST_NODVS_BUCK_VRMON130 0x2
  144. #define BD718XX_2ND_NODVS_BUCK_VRMON80 0x4
  145. #define BD718XX_2ND_NODVS_BUCK_VRMON130 0x8
  146. #define BD718XX_3RD_NODVS_BUCK_VRMON80 0x10
  147. #define BD718XX_3RD_NODVS_BUCK_VRMON130 0x20
  148. #define BD718XX_4TH_NODVS_BUCK_VRMON80 0x40
  149. #define BD718XX_4TH_NODVS_BUCK_VRMON130 0x80
  150. #define BD718XX_LDO1_VRMON80 0x1
  151. #define BD718XX_LDO2_VRMON80 0x2
  152. #define BD718XX_LDO3_VRMON80 0x4
  153. #define BD718XX_LDO4_VRMON80 0x8
  154. #define BD718XX_LDO5_VRMON80 0x10
  155. #define BD718XX_LDO6_VRMON80 0x20
  156. /* BD71837 specific voltage monitoring masks */
  157. #define BD71837_BUCK3_VRMON80 0x10
  158. #define BD71837_BUCK3_VRMON130 0x20
  159. #define BD71837_BUCK4_VRMON80 0x40
  160. #define BD71837_BUCK4_VRMON130 0x80
  161. #define BD71837_LDO7_VRMON80 0x40
  162. /* BD718XX_REG_IRQ bits */
  163. #define IRQ_SWRST 0x40
  164. #define IRQ_PWRON_S 0x20
  165. #define IRQ_PWRON_L 0x10
  166. #define IRQ_PWRON 0x08
  167. #define IRQ_WDOG 0x04
  168. #define IRQ_ON_REQ 0x02
  169. #define IRQ_STBY_REQ 0x01
  170. /* ROHM BD718XX irqs */
  171. enum {
  172. BD718XX_INT_STBY_REQ,
  173. BD718XX_INT_ON_REQ,
  174. BD718XX_INT_WDOG,
  175. BD718XX_INT_PWRBTN,
  176. BD718XX_INT_PWRBTN_L,
  177. BD718XX_INT_PWRBTN_S,
  178. BD718XX_INT_SWRST
  179. };
  180. /* ROHM BD718XX interrupt masks */
  181. #define BD718XX_INT_SWRST_MASK 0x40
  182. #define BD718XX_INT_PWRBTN_S_MASK 0x20
  183. #define BD718XX_INT_PWRBTN_L_MASK 0x10
  184. #define BD718XX_INT_PWRBTN_MASK 0x8
  185. #define BD718XX_INT_WDOG_MASK 0x4
  186. #define BD718XX_INT_ON_REQ_MASK 0x2
  187. #define BD718XX_INT_STBY_REQ_MASK 0x1
  188. /* Register write induced reset settings */
  189. /*
  190. * Even though the bit zero is not SWRESET type we still want to write zero
  191. * to it when changing type. Bit zero is 'SWRESET' trigger bit and if we
  192. * write 1 to it we will trigger the action. So always write 0 to it when
  193. * changning SWRESET action - no matter what we read from it.
  194. */
  195. #define BD718XX_SWRESET_TYPE_MASK 7
  196. #define BD718XX_SWRESET_TYPE_DISABLED 0
  197. #define BD718XX_SWRESET_TYPE_COLD 4
  198. #define BD718XX_SWRESET_TYPE_WARM 6
  199. #define BD718XX_SWRESET_RESET_MASK 1
  200. #define BD718XX_SWRESET_RESET 1
  201. /* Poweroff state transition conditions */
  202. #define BD718XX_ON_REQ_POWEROFF_MASK 1
  203. #define BD718XX_SWRESET_POWEROFF_MASK 2
  204. #define BD718XX_WDOG_POWEROFF_MASK 4
  205. #define BD718XX_KEY_L_POWEROFF_MASK 8
  206. #define BD718XX_POWOFF_TO_SNVS 0
  207. #define BD718XX_POWOFF_TO_RDY 0xF
  208. #define BD718XX_POWOFF_TIME_MASK 0xF0
  209. enum {
  210. BD718XX_POWOFF_TIME_5MS = 0,
  211. BD718XX_POWOFF_TIME_10MS,
  212. BD718XX_POWOFF_TIME_15MS,
  213. BD718XX_POWOFF_TIME_20MS,
  214. BD718XX_POWOFF_TIME_25MS,
  215. BD718XX_POWOFF_TIME_30MS,
  216. BD718XX_POWOFF_TIME_35MS,
  217. BD718XX_POWOFF_TIME_40MS,
  218. BD718XX_POWOFF_TIME_45MS,
  219. BD718XX_POWOFF_TIME_50MS,
  220. BD718XX_POWOFF_TIME_75MS,
  221. BD718XX_POWOFF_TIME_100MS,
  222. BD718XX_POWOFF_TIME_250MS,
  223. BD718XX_POWOFF_TIME_500MS,
  224. BD718XX_POWOFF_TIME_750MS,
  225. BD718XX_POWOFF_TIME_1500MS
  226. };
  227. /* Poweron sequence state transition conditions */
  228. #define BD718XX_RDY_TO_SNVS_MASK 0xF
  229. #define BD718XX_SNVS_TO_RUN_MASK 0xF0
  230. #define BD718XX_PWR_TRIG_KEY_L 1
  231. #define BD718XX_PWR_TRIG_KEY_S 2
  232. #define BD718XX_PWR_TRIG_PMIC_ON 4
  233. #define BD718XX_PWR_TRIG_VSYS_UVLO 8
  234. #define BD718XX_RDY_TO_SNVS_SIFT 0
  235. #define BD718XX_SNVS_TO_RUN_SIFT 4
  236. #define BD718XX_PWRBTN_PRESS_DURATION_MASK 0xF
  237. /* Timeout value for detecting short press */
  238. enum {
  239. BD718XX_PWRBTN_SHORT_PRESS_10MS = 0,
  240. BD718XX_PWRBTN_SHORT_PRESS_500MS,
  241. BD718XX_PWRBTN_SHORT_PRESS_1000MS,
  242. BD718XX_PWRBTN_SHORT_PRESS_1500MS,
  243. BD718XX_PWRBTN_SHORT_PRESS_2000MS,
  244. BD718XX_PWRBTN_SHORT_PRESS_2500MS,
  245. BD718XX_PWRBTN_SHORT_PRESS_3000MS,
  246. BD718XX_PWRBTN_SHORT_PRESS_3500MS,
  247. BD718XX_PWRBTN_SHORT_PRESS_4000MS,
  248. BD718XX_PWRBTN_SHORT_PRESS_4500MS,
  249. BD718XX_PWRBTN_SHORT_PRESS_5000MS,
  250. BD718XX_PWRBTN_SHORT_PRESS_5500MS,
  251. BD718XX_PWRBTN_SHORT_PRESS_6000MS,
  252. BD718XX_PWRBTN_SHORT_PRESS_6500MS,
  253. BD718XX_PWRBTN_SHORT_PRESS_7000MS,
  254. BD718XX_PWRBTN_SHORT_PRESS_7500MS
  255. };
  256. /* Timeout value for detecting LONG press */
  257. enum {
  258. BD718XX_PWRBTN_LONG_PRESS_10MS = 0,
  259. BD718XX_PWRBTN_LONG_PRESS_1S,
  260. BD718XX_PWRBTN_LONG_PRESS_2S,
  261. BD718XX_PWRBTN_LONG_PRESS_3S,
  262. BD718XX_PWRBTN_LONG_PRESS_4S,
  263. BD718XX_PWRBTN_LONG_PRESS_5S,
  264. BD718XX_PWRBTN_LONG_PRESS_6S,
  265. BD718XX_PWRBTN_LONG_PRESS_7S,
  266. BD718XX_PWRBTN_LONG_PRESS_8S,
  267. BD718XX_PWRBTN_LONG_PRESS_9S,
  268. BD718XX_PWRBTN_LONG_PRESS_10S,
  269. BD718XX_PWRBTN_LONG_PRESS_11S,
  270. BD718XX_PWRBTN_LONG_PRESS_12S,
  271. BD718XX_PWRBTN_LONG_PRESS_13S,
  272. BD718XX_PWRBTN_LONG_PRESS_14S,
  273. BD718XX_PWRBTN_LONG_PRESS_15S
  274. };
  275. #endif /* __LINUX_MFD_BD718XX_H__ */