lp873x.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Functions to access LP873X power management chip.
  4. *
  5. * Copyright (C) 2016 Texas Instruments Incorporated - https://www.ti.com/
  6. */
  7. #ifndef __LINUX_MFD_LP873X_H
  8. #define __LINUX_MFD_LP873X_H
  9. #include <linux/i2c.h>
  10. #include <linux/regulator/driver.h>
  11. #include <linux/regulator/machine.h>
  12. /* LP873x chip id list */
  13. #define LP873X 0x00
  14. /* All register addresses */
  15. #define LP873X_REG_DEV_REV 0X00
  16. #define LP873X_REG_OTP_REV 0X01
  17. #define LP873X_REG_BUCK0_CTRL_1 0X02
  18. #define LP873X_REG_BUCK0_CTRL_2 0X03
  19. #define LP873X_REG_BUCK1_CTRL_1 0X04
  20. #define LP873X_REG_BUCK1_CTRL_2 0X05
  21. #define LP873X_REG_BUCK0_VOUT 0X06
  22. #define LP873X_REG_BUCK1_VOUT 0X07
  23. #define LP873X_REG_LDO0_CTRL 0X08
  24. #define LP873X_REG_LDO1_CTRL 0X09
  25. #define LP873X_REG_LDO0_VOUT 0X0A
  26. #define LP873X_REG_LDO1_VOUT 0X0B
  27. #define LP873X_REG_BUCK0_DELAY 0X0C
  28. #define LP873X_REG_BUCK1_DELAY 0X0D
  29. #define LP873X_REG_LDO0_DELAY 0X0E
  30. #define LP873X_REG_LDO1_DELAY 0X0F
  31. #define LP873X_REG_GPO_DELAY 0X10
  32. #define LP873X_REG_GPO2_DELAY 0X11
  33. #define LP873X_REG_GPO_CTRL 0X12
  34. #define LP873X_REG_CONFIG 0X13
  35. #define LP873X_REG_PLL_CTRL 0X14
  36. #define LP873X_REG_PGOOD_CTRL1 0X15
  37. #define LP873X_REG_PGOOD_CTRL2 0X16
  38. #define LP873X_REG_PG_FAULT 0X17
  39. #define LP873X_REG_RESET 0X18
  40. #define LP873X_REG_INT_TOP_1 0X19
  41. #define LP873X_REG_INT_TOP_2 0X1A
  42. #define LP873X_REG_INT_BUCK 0X1B
  43. #define LP873X_REG_INT_LDO 0X1C
  44. #define LP873X_REG_TOP_STAT 0X1D
  45. #define LP873X_REG_BUCK_STAT 0X1E
  46. #define LP873X_REG_LDO_STAT 0x1F
  47. #define LP873X_REG_TOP_MASK_1 0x20
  48. #define LP873X_REG_TOP_MASK_2 0x21
  49. #define LP873X_REG_BUCK_MASK 0x22
  50. #define LP873X_REG_LDO_MASK 0x23
  51. #define LP873X_REG_SEL_I_LOAD 0x24
  52. #define LP873X_REG_I_LOAD_2 0x25
  53. #define LP873X_REG_I_LOAD_1 0x26
  54. #define LP873X_REG_MAX LP873X_REG_I_LOAD_1
  55. /* Register field definitions */
  56. #define LP873X_DEV_REV_DEV_ID 0xC0
  57. #define LP873X_DEV_REV_ALL_LAYER 0x30
  58. #define LP873X_DEV_REV_METAL_LAYER 0x0F
  59. #define LP873X_OTP_REV_OTP_ID 0xFF
  60. #define LP873X_BUCK0_CTRL_1_BUCK0_FPWM BIT(3)
  61. #define LP873X_BUCK0_CTRL_1_BUCK0_RDIS_EN BIT(2)
  62. #define LP873X_BUCK0_CTRL_1_BUCK0_EN_PIN_CTRL BIT(1)
  63. #define LP873X_BUCK0_CTRL_1_BUCK0_EN BIT(0)
  64. #define LP873X_BUCK0_CTRL_2_BUCK0_ILIM 0x38
  65. #define LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE 0x07
  66. #define LP873X_BUCK1_CTRL_1_BUCK1_FPWM BIT(3)
  67. #define LP873X_BUCK1_CTRL_1_BUCK1_RDIS_EN BIT(2)
  68. #define LP873X_BUCK1_CTRL_1_BUCK1_EN_PIN_CTRL BIT(1)
  69. #define LP873X_BUCK1_CTRL_1_BUCK1_EN BIT(0)
  70. #define LP873X_BUCK1_CTRL_2_BUCK1_ILIM 0x38
  71. #define LP873X_BUCK1_CTRL_2_BUCK1_SLEW_RATE 0x07
  72. #define LP873X_BUCK0_VOUT_BUCK0_VSET 0xFF
  73. #define LP873X_BUCK1_VOUT_BUCK1_VSET 0xFF
  74. #define LP873X_LDO0_CTRL_LDO0_RDIS_EN BIT(2)
  75. #define LP873X_LDO0_CTRL_LDO0_EN_PIN_CTRL BIT(1)
  76. #define LP873X_LDO0_CTRL_LDO0_EN BIT(0)
  77. #define LP873X_LDO1_CTRL_LDO1_RDIS_EN BIT(2)
  78. #define LP873X_LDO1_CTRL_LDO1_EN_PIN_CTRL BIT(1)
  79. #define LP873X_LDO1_CTRL_LDO1_EN BIT(0)
  80. #define LP873X_LDO0_VOUT_LDO0_VSET 0x1F
  81. #define LP873X_LDO1_VOUT_LDO1_VSET 0x1F
  82. #define LP873X_BUCK0_DELAY_BUCK0_SD_DELAY 0xF0
  83. #define LP873X_BUCK0_DELAY_BUCK0_SU_DELAY 0x0F
  84. #define LP873X_BUCK1_DELAY_BUCK1_SD_DELAY 0xF0
  85. #define LP873X_BUCK1_DELAY_BUCK1_SU_DELAY 0x0F
  86. #define LP873X_LDO0_DELAY_LDO0_SD_DELAY 0xF0
  87. #define LP873X_LDO0_DELAY_LDO0_SU_DELAY 0x0F
  88. #define LP873X_LDO1_DELAY_LDO1_SD_DELAY 0xF0
  89. #define LP873X_LDO1_DELAY_LDO1_SU_DELAY 0x0F
  90. #define LP873X_GPO_DELAY_GPO_SD_DELAY 0xF0
  91. #define LP873X_GPO_DELAY_GPO_SU_DELAY 0x0F
  92. #define LP873X_GPO2_DELAY_GPO2_SD_DELAY 0xF0
  93. #define LP873X_GPO2_DELAY_GPO2_SU_DELAY 0x0F
  94. #define LP873X_GPO_CTRL_GPO2_OD BIT(6)
  95. #define LP873X_GPO_CTRL_GPO2_EN_PIN_CTRL BIT(5)
  96. #define LP873X_GPO_CTRL_GPO2_EN BIT(4)
  97. #define LP873X_GPO_CTRL_GPO_OD BIT(2)
  98. #define LP873X_GPO_CTRL_GPO_EN_PIN_CTRL BIT(1)
  99. #define LP873X_GPO_CTRL_GPO_EN BIT(0)
  100. #define LP873X_CONFIG_SU_DELAY_SEL BIT(6)
  101. #define LP873X_CONFIG_SD_DELAY_SEL BIT(5)
  102. #define LP873X_CONFIG_CLKIN_PIN_SEL BIT(4)
  103. #define LP873X_CONFIG_CLKIN_PD BIT(3)
  104. #define LP873X_CONFIG_EN_PD BIT(2)
  105. #define LP873X_CONFIG_TDIE_WARN_LEVEL BIT(1)
  106. #define LP873X_EN_SPREAD_SPEC BIT(0)
  107. #define LP873X_PLL_CTRL_EN_PLL BIT(6)
  108. #define LP873X_EXT_CLK_FREQ 0x1F
  109. #define LP873X_PGOOD_CTRL1_PGOOD_POL BIT(7)
  110. #define LP873X_PGOOD_CTRL1_PGOOD_OD BIT(6)
  111. #define LP873X_PGOOD_CTRL1_PGOOD_WINDOW_LDO BIT(5)
  112. #define LP873X_PGOOD_CTRL1_PGOOD_WINDOWN_BUCK BIT(4)
  113. #define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO1 BIT(3)
  114. #define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO0 BIT(2)
  115. #define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK1 BIT(1)
  116. #define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK0 BIT(0)
  117. #define LP873X_PGOOD_CTRL2_EN_PGOOD_TWARN BIT(2)
  118. #define LP873X_PGOOD_CTRL2_EN_PG_FAULT_GATE BIT(1)
  119. #define LP873X_PGOOD_CTRL2_PGOOD_MODE BIT(0)
  120. #define LP873X_PG_FAULT_PG_FAULT_LDO1 BIT(3)
  121. #define LP873X_PG_FAULT_PG_FAULT_LDO0 BIT(2)
  122. #define LP873X_PG_FAULT_PG_FAULT_BUCK1 BIT(1)
  123. #define LP873X_PG_FAULT_PG_FAULT_BUCK0 BIT(0)
  124. #define LP873X_RESET_SW_RESET BIT(0)
  125. #define LP873X_INT_TOP_1_PGOOD_INT BIT(7)
  126. #define LP873X_INT_TOP_1_LDO_INT BIT(6)
  127. #define LP873X_INT_TOP_1_BUCK_INT BIT(5)
  128. #define LP873X_INT_TOP_1_SYNC_CLK_INT BIT(4)
  129. #define LP873X_INT_TOP_1_TDIE_SD_INT BIT(3)
  130. #define LP873X_INT_TOP_1_TDIE_WARN_INT BIT(2)
  131. #define LP873X_INT_TOP_1_OVP_INT BIT(1)
  132. #define LP873X_INT_TOP_1_I_MEAS_INT BIT(0)
  133. #define LP873X_INT_TOP_2_RESET_REG_INT BIT(0)
  134. #define LP873X_INT_BUCK_BUCK1_PG_INT BIT(6)
  135. #define LP873X_INT_BUCK_BUCK1_SC_INT BIT(5)
  136. #define LP873X_INT_BUCK_BUCK1_ILIM_INT BIT(4)
  137. #define LP873X_INT_BUCK_BUCK0_PG_INT BIT(2)
  138. #define LP873X_INT_BUCK_BUCK0_SC_INT BIT(1)
  139. #define LP873X_INT_BUCK_BUCK0_ILIM_INT BIT(0)
  140. #define LP873X_INT_LDO_LDO1_PG_INT BIT(6)
  141. #define LP873X_INT_LDO_LDO1_SC_INT BIT(5)
  142. #define LP873X_INT_LDO_LDO1_ILIM_INT BIT(4)
  143. #define LP873X_INT_LDO_LDO0_PG_INT BIT(2)
  144. #define LP873X_INT_LDO_LDO0_SC_INT BIT(1)
  145. #define LP873X_INT_LDO_LDO0_ILIM_INT BIT(0)
  146. #define LP873X_TOP_STAT_PGOOD_STAT BIT(7)
  147. #define LP873X_TOP_STAT_SYNC_CLK_STAT BIT(4)
  148. #define LP873X_TOP_STAT_TDIE_SD_STAT BIT(3)
  149. #define LP873X_TOP_STAT_TDIE_WARN_STAT BIT(2)
  150. #define LP873X_TOP_STAT_OVP_STAT BIT(1)
  151. #define LP873X_BUCK_STAT_BUCK1_STAT BIT(7)
  152. #define LP873X_BUCK_STAT_BUCK1_PG_STAT BIT(6)
  153. #define LP873X_BUCK_STAT_BUCK1_ILIM_STAT BIT(4)
  154. #define LP873X_BUCK_STAT_BUCK0_STAT BIT(3)
  155. #define LP873X_BUCK_STAT_BUCK0_PG_STAT BIT(2)
  156. #define LP873X_BUCK_STAT_BUCK0_ILIM_STAT BIT(0)
  157. #define LP873X_LDO_STAT_LDO1_STAT BIT(7)
  158. #define LP873X_LDO_STAT_LDO1_PG_STAT BIT(6)
  159. #define LP873X_LDO_STAT_LDO1_ILIM_STAT BIT(4)
  160. #define LP873X_LDO_STAT_LDO0_STAT BIT(3)
  161. #define LP873X_LDO_STAT_LDO0_PG_STAT BIT(2)
  162. #define LP873X_LDO_STAT_LDO0_ILIM_STAT BIT(0)
  163. #define LP873X_TOP_MASK_1_PGOOD_INT_MASK BIT(7)
  164. #define LP873X_TOP_MASK_1_SYNC_CLK_MASK BIT(4)
  165. #define LP873X_TOP_MASK_1_TDIE_WARN_MASK BIT(2)
  166. #define LP873X_TOP_MASK_1_I_MEAS_MASK BIT(0)
  167. #define LP873X_TOP_MASK_2_RESET_REG_MASK BIT(0)
  168. #define LP873X_BUCK_MASK_BUCK1_PGF_MASK BIT(7)
  169. #define LP873X_BUCK_MASK_BUCK1_PGR_MASK BIT(6)
  170. #define LP873X_BUCK_MASK_BUCK1_ILIM_MASK BIT(4)
  171. #define LP873X_BUCK_MASK_BUCK0_PGF_MASK BIT(3)
  172. #define LP873X_BUCK_MASK_BUCK0_PGR_MASK BIT(2)
  173. #define LP873X_BUCK_MASK_BUCK0_ILIM_MASK BIT(0)
  174. #define LP873X_LDO_MASK_LDO1_PGF_MASK BIT(7)
  175. #define LP873X_LDO_MASK_LDO1_PGR_MASK BIT(6)
  176. #define LP873X_LDO_MASK_LDO1_ILIM_MASK BIT(4)
  177. #define LP873X_LDO_MASK_LDO0_PGF_MASK BIT(3)
  178. #define LP873X_LDO_MASK_LDO0_PGR_MASK BIT(2)
  179. #define LP873X_LDO_MASK_LDO0_ILIM_MASK BIT(0)
  180. #define LP873X_SEL_I_LOAD_CURRENT_BUCK_SELECT BIT(0)
  181. #define LP873X_I_LOAD_2_BUCK_LOAD_CURRENT BIT(0)
  182. #define LP873X_I_LOAD_1_BUCK_LOAD_CURRENT 0xFF
  183. #define LP873X_MAX_REG_ID LP873X_LDO_1
  184. /* Number of step-down converters available */
  185. #define LP873X_NUM_BUCK 2
  186. /* Number of LDO voltage regulators available */
  187. #define LP873X_NUM_LDO 2
  188. /* Number of total regulators available */
  189. #define LP873X_NUM_REGULATOR (LP873X_NUM_BUCK + LP873X_NUM_LDO)
  190. enum lp873x_regulator_id {
  191. /* BUCK's */
  192. LP873X_BUCK_0,
  193. LP873X_BUCK_1,
  194. /* LDOs */
  195. LP873X_LDO_0,
  196. LP873X_LDO_1,
  197. };
  198. /**
  199. * struct lp873x - state holder for the lp873x driver
  200. * @dev: struct device pointer for MFD device
  201. * @rev: revision of the lp873x
  202. * @lock: lock guarding the data structure
  203. * @regmap: register map of the lp873x PMIC
  204. *
  205. * Device data may be used to access the LP873X chip
  206. */
  207. struct lp873x {
  208. struct device *dev;
  209. u8 rev;
  210. struct regmap *regmap;
  211. };
  212. #endif /* __LINUX_MFD_LP873X_H */