stpmic1.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) STMicroelectronics 2018 - All Rights Reserved
  4. * Author: Philippe Peurichard <[email protected]>,
  5. * Pascal Paillet <[email protected]> for STMicroelectronics.
  6. */
  7. #ifndef __LINUX_MFD_STPMIC1_H
  8. #define __LINUX_MFD_STPMIC1_H
  9. #define TURN_ON_SR 0x1
  10. #define TURN_OFF_SR 0x2
  11. #define ICC_LDO_TURN_OFF_SR 0x3
  12. #define ICC_BUCK_TURN_OFF_SR 0x4
  13. #define RREQ_STATE_SR 0x5
  14. #define VERSION_SR 0x6
  15. #define SWOFF_PWRCTRL_CR 0x10
  16. #define PADS_PULL_CR 0x11
  17. #define BUCKS_PD_CR 0x12
  18. #define LDO14_PD_CR 0x13
  19. #define LDO56_VREF_PD_CR 0x14
  20. #define VBUS_DET_VIN_CR 0x15
  21. #define PKEY_TURNOFF_CR 0x16
  22. #define BUCKS_MASK_RANK_CR 0x17
  23. #define BUCKS_MASK_RESET_CR 0x18
  24. #define LDOS_MASK_RANK_CR 0x19
  25. #define LDOS_MASK_RESET_CR 0x1A
  26. #define WCHDG_CR 0x1B
  27. #define WCHDG_TIMER_CR 0x1C
  28. #define BUCKS_ICCTO_CR 0x1D
  29. #define LDOS_ICCTO_CR 0x1E
  30. #define BUCK1_ACTIVE_CR 0x20
  31. #define BUCK2_ACTIVE_CR 0x21
  32. #define BUCK3_ACTIVE_CR 0x22
  33. #define BUCK4_ACTIVE_CR 0x23
  34. #define VREF_DDR_ACTIVE_CR 0x24
  35. #define LDO1_ACTIVE_CR 0x25
  36. #define LDO2_ACTIVE_CR 0x26
  37. #define LDO3_ACTIVE_CR 0x27
  38. #define LDO4_ACTIVE_CR 0x28
  39. #define LDO5_ACTIVE_CR 0x29
  40. #define LDO6_ACTIVE_CR 0x2A
  41. #define BUCK1_STDBY_CR 0x30
  42. #define BUCK2_STDBY_CR 0x31
  43. #define BUCK3_STDBY_CR 0x32
  44. #define BUCK4_STDBY_CR 0x33
  45. #define VREF_DDR_STDBY_CR 0x34
  46. #define LDO1_STDBY_CR 0x35
  47. #define LDO2_STDBY_CR 0x36
  48. #define LDO3_STDBY_CR 0x37
  49. #define LDO4_STDBY_CR 0x38
  50. #define LDO5_STDBY_CR 0x39
  51. #define LDO6_STDBY_CR 0x3A
  52. #define BST_SW_CR 0x40
  53. #define INT_PENDING_R1 0x50
  54. #define INT_PENDING_R2 0x51
  55. #define INT_PENDING_R3 0x52
  56. #define INT_PENDING_R4 0x53
  57. #define INT_DBG_LATCH_R1 0x60
  58. #define INT_DBG_LATCH_R2 0x61
  59. #define INT_DBG_LATCH_R3 0x62
  60. #define INT_DBG_LATCH_R4 0x63
  61. #define INT_CLEAR_R1 0x70
  62. #define INT_CLEAR_R2 0x71
  63. #define INT_CLEAR_R3 0x72
  64. #define INT_CLEAR_R4 0x73
  65. #define INT_MASK_R1 0x80
  66. #define INT_MASK_R2 0x81
  67. #define INT_MASK_R3 0x82
  68. #define INT_MASK_R4 0x83
  69. #define INT_SET_MASK_R1 0x90
  70. #define INT_SET_MASK_R2 0x91
  71. #define INT_SET_MASK_R3 0x92
  72. #define INT_SET_MASK_R4 0x93
  73. #define INT_CLEAR_MASK_R1 0xA0
  74. #define INT_CLEAR_MASK_R2 0xA1
  75. #define INT_CLEAR_MASK_R3 0xA2
  76. #define INT_CLEAR_MASK_R4 0xA3
  77. #define INT_SRC_R1 0xB0
  78. #define INT_SRC_R2 0xB1
  79. #define INT_SRC_R3 0xB2
  80. #define INT_SRC_R4 0xB3
  81. #define PMIC_MAX_REGISTER_ADDRESS INT_SRC_R4
  82. #define STPMIC1_PMIC_NUM_IRQ_REGS 4
  83. #define TURN_OFF_SR_ICC_EVENT 0x08
  84. #define LDO_VOLTAGE_MASK GENMASK(6, 2)
  85. #define BUCK_VOLTAGE_MASK GENMASK(7, 2)
  86. #define LDO_BUCK_VOLTAGE_SHIFT 2
  87. #define LDO_ENABLE_MASK BIT(0)
  88. #define BUCK_ENABLE_MASK BIT(0)
  89. #define BUCK_HPLP_ENABLE_MASK BIT(1)
  90. #define BUCK_HPLP_SHIFT 1
  91. #define STDBY_ENABLE_MASK BIT(0)
  92. #define BUCKS_PD_CR_REG_MASK GENMASK(7, 0)
  93. #define BUCK_MASK_RANK_REGISTER_MASK GENMASK(3, 0)
  94. #define BUCK_MASK_RESET_REGISTER_MASK GENMASK(3, 0)
  95. #define LDO1234_PULL_DOWN_REGISTER_MASK GENMASK(7, 0)
  96. #define LDO56_VREF_PD_CR_REG_MASK GENMASK(5, 0)
  97. #define LDO_MASK_RANK_REGISTER_MASK GENMASK(5, 0)
  98. #define LDO_MASK_RESET_REGISTER_MASK GENMASK(5, 0)
  99. #define BUCK1_PULL_DOWN_REG BUCKS_PD_CR
  100. #define BUCK1_PULL_DOWN_MASK BIT(0)
  101. #define BUCK2_PULL_DOWN_REG BUCKS_PD_CR
  102. #define BUCK2_PULL_DOWN_MASK BIT(2)
  103. #define BUCK3_PULL_DOWN_REG BUCKS_PD_CR
  104. #define BUCK3_PULL_DOWN_MASK BIT(4)
  105. #define BUCK4_PULL_DOWN_REG BUCKS_PD_CR
  106. #define BUCK4_PULL_DOWN_MASK BIT(6)
  107. #define LDO1_PULL_DOWN_REG LDO14_PD_CR
  108. #define LDO1_PULL_DOWN_MASK BIT(0)
  109. #define LDO2_PULL_DOWN_REG LDO14_PD_CR
  110. #define LDO2_PULL_DOWN_MASK BIT(2)
  111. #define LDO3_PULL_DOWN_REG LDO14_PD_CR
  112. #define LDO3_PULL_DOWN_MASK BIT(4)
  113. #define LDO4_PULL_DOWN_REG LDO14_PD_CR
  114. #define LDO4_PULL_DOWN_MASK BIT(6)
  115. #define LDO5_PULL_DOWN_REG LDO56_VREF_PD_CR
  116. #define LDO5_PULL_DOWN_MASK BIT(0)
  117. #define LDO6_PULL_DOWN_REG LDO56_VREF_PD_CR
  118. #define LDO6_PULL_DOWN_MASK BIT(2)
  119. #define VREF_DDR_PULL_DOWN_REG LDO56_VREF_PD_CR
  120. #define VREF_DDR_PULL_DOWN_MASK BIT(4)
  121. #define BUCKS_ICCTO_CR_REG_MASK GENMASK(6, 0)
  122. #define LDOS_ICCTO_CR_REG_MASK GENMASK(5, 0)
  123. #define LDO_BYPASS_MASK BIT(7)
  124. /* Main PMIC Control Register
  125. * SWOFF_PWRCTRL_CR
  126. * Address : 0x10
  127. */
  128. #define ICC_EVENT_ENABLED BIT(4)
  129. #define PWRCTRL_POLARITY_HIGH BIT(3)
  130. #define PWRCTRL_PIN_VALID BIT(2)
  131. #define RESTART_REQUEST_ENABLED BIT(1)
  132. #define SOFTWARE_SWITCH_OFF_ENABLED BIT(0)
  133. /* Main PMIC PADS Control Register
  134. * PADS_PULL_CR
  135. * Address : 0x11
  136. */
  137. #define WAKEUP_DETECTOR_DISABLED BIT(4)
  138. #define PWRCTRL_PD_ACTIVE BIT(3)
  139. #define PWRCTRL_PU_ACTIVE BIT(2)
  140. #define WAKEUP_PD_ACTIVE BIT(1)
  141. #define PONKEY_PU_INACTIVE BIT(0)
  142. /* Main PMIC VINLOW Control Register
  143. * VBUS_DET_VIN_CRC DMSC
  144. * Address : 0x15
  145. */
  146. #define SWIN_DETECTOR_ENABLED BIT(7)
  147. #define SWOUT_DETECTOR_ENABLED BIT(6)
  148. #define VINLOW_ENABLED BIT(0)
  149. #define VINLOW_CTRL_REG_MASK GENMASK(7, 0)
  150. /* USB Control Register
  151. * Address : 0x40
  152. */
  153. #define BOOST_OVP_DISABLED BIT(7)
  154. #define VBUS_OTG_DETECTION_DISABLED BIT(6)
  155. #define SW_OUT_DISCHARGE BIT(5)
  156. #define VBUS_OTG_DISCHARGE BIT(4)
  157. #define OCP_LIMIT_HIGH BIT(3)
  158. #define SWIN_SWOUT_ENABLED BIT(2)
  159. #define USBSW_OTG_SWITCH_ENABLED BIT(1)
  160. #define BOOST_ENABLED BIT(0)
  161. /* PKEY_TURNOFF_CR
  162. * Address : 0x16
  163. */
  164. #define PONKEY_PWR_OFF BIT(7)
  165. #define PONKEY_CC_FLAG_CLEAR BIT(6)
  166. #define PONKEY_TURNOFF_TIMER_MASK GENMASK(3, 0)
  167. #define PONKEY_TURNOFF_MASK GENMASK(7, 0)
  168. /*
  169. * struct stpmic1 - stpmic1 master device for sub-drivers
  170. * @dev: master device of the chip (can be used to access platform data)
  171. * @irq: main IRQ number
  172. * @regmap_irq_chip_data: irq chip data
  173. */
  174. struct stpmic1 {
  175. struct device *dev;
  176. struct regmap *regmap;
  177. int irq;
  178. struct regmap_irq_chip_data *irq_data;
  179. };
  180. #endif /* __LINUX_MFD_STPMIC1_H */