axp20x.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Functions and registers to access AXP20X power management chip.
  3. *
  4. * Copyright (C) 2013, Carlo Caione <carlo@caione.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __LINUX_MFD_AXP20X_H
  11. #define __LINUX_MFD_AXP20X_H
  12. enum {
  13. AXP202_ID = 0,
  14. AXP209_ID,
  15. };
  16. #define AXP20X_DATACACHE(m) (0x04 + (m))
  17. /* Power supply */
  18. #define AXP20X_PWR_INPUT_STATUS 0x00
  19. #define AXP20X_PWR_OP_MODE 0x01
  20. #define AXP20X_USB_OTG_STATUS 0x02
  21. #define AXP20X_PWR_OUT_CTRL 0x12
  22. #define AXP20X_DCDC2_V_OUT 0x23
  23. #define AXP20X_DCDC2_LDO3_V_SCAL 0x25
  24. #define AXP20X_DCDC3_V_OUT 0x27
  25. #define AXP20X_LDO24_V_OUT 0x28
  26. #define AXP20X_LDO3_V_OUT 0x29
  27. #define AXP20X_VBUS_IPSOUT_MGMT 0x30
  28. #define AXP20X_V_OFF 0x31
  29. #define AXP20X_OFF_CTRL 0x32
  30. #define AXP20X_CHRG_CTRL1 0x33
  31. #define AXP20X_CHRG_CTRL2 0x34
  32. #define AXP20X_CHRG_BAK_CTRL 0x35
  33. #define AXP20X_PEK_KEY 0x36
  34. #define AXP20X_DCDC_FREQ 0x37
  35. #define AXP20X_V_LTF_CHRG 0x38
  36. #define AXP20X_V_HTF_CHRG 0x39
  37. #define AXP20X_APS_WARN_L1 0x3a
  38. #define AXP20X_APS_WARN_L2 0x3b
  39. #define AXP20X_V_LTF_DISCHRG 0x3c
  40. #define AXP20X_V_HTF_DISCHRG 0x3d
  41. /* Interrupt */
  42. #define AXP20X_IRQ1_EN 0x40
  43. #define AXP20X_IRQ2_EN 0x41
  44. #define AXP20X_IRQ3_EN 0x42
  45. #define AXP20X_IRQ4_EN 0x43
  46. #define AXP20X_IRQ5_EN 0x44
  47. #define AXP20X_IRQ1_STATE 0x48
  48. #define AXP20X_IRQ2_STATE 0x49
  49. #define AXP20X_IRQ3_STATE 0x4a
  50. #define AXP20X_IRQ4_STATE 0x4b
  51. #define AXP20X_IRQ5_STATE 0x4c
  52. /* ADC */
  53. #define AXP20X_ACIN_V_ADC_H 0x56
  54. #define AXP20X_ACIN_V_ADC_L 0x57
  55. #define AXP20X_ACIN_I_ADC_H 0x58
  56. #define AXP20X_ACIN_I_ADC_L 0x59
  57. #define AXP20X_VBUS_V_ADC_H 0x5a
  58. #define AXP20X_VBUS_V_ADC_L 0x5b
  59. #define AXP20X_VBUS_I_ADC_H 0x5c
  60. #define AXP20X_VBUS_I_ADC_L 0x5d
  61. #define AXP20X_TEMP_ADC_H 0x5e
  62. #define AXP20X_TEMP_ADC_L 0x5f
  63. #define AXP20X_TS_IN_H 0x62
  64. #define AXP20X_TS_IN_L 0x63
  65. #define AXP20X_GPIO0_V_ADC_H 0x64
  66. #define AXP20X_GPIO0_V_ADC_L 0x65
  67. #define AXP20X_GPIO1_V_ADC_H 0x66
  68. #define AXP20X_GPIO1_V_ADC_L 0x67
  69. #define AXP20X_PWR_BATT_H 0x70
  70. #define AXP20X_PWR_BATT_M 0x71
  71. #define AXP20X_PWR_BATT_L 0x72
  72. #define AXP20X_BATT_V_H 0x78
  73. #define AXP20X_BATT_V_L 0x79
  74. #define AXP20X_BATT_CHRG_I_H 0x7a
  75. #define AXP20X_BATT_CHRG_I_L 0x7b
  76. #define AXP20X_BATT_DISCHRG_I_H 0x7c
  77. #define AXP20X_BATT_DISCHRG_I_L 0x7d
  78. #define AXP20X_IPSOUT_V_HIGH_H 0x7e
  79. #define AXP20X_IPSOUT_V_HIGH_L 0x7f
  80. /* Power supply */
  81. #define AXP20X_DCDC_MODE 0x80
  82. #define AXP20X_ADC_EN1 0x82
  83. #define AXP20X_ADC_EN2 0x83
  84. #define AXP20X_ADC_RATE 0x84
  85. #define AXP20X_GPIO10_IN_RANGE 0x85
  86. #define AXP20X_GPIO1_ADC_IRQ_RIS 0x86
  87. #define AXP20X_GPIO1_ADC_IRQ_FAL 0x87
  88. #define AXP20X_TIMER_CTRL 0x8a
  89. #define AXP20X_VBUS_MON 0x8b
  90. #define AXP20X_OVER_TMP 0x8f
  91. /* GPIO */
  92. #define AXP20X_GPIO0_CTRL 0x90
  93. #define AXP20X_LDO5_V_OUT 0x91
  94. #define AXP20X_GPIO1_CTRL 0x92
  95. #define AXP20X_GPIO2_CTRL 0x93
  96. #define AXP20X_GPIO20_SS 0x94
  97. #define AXP20X_GPIO3_CTRL 0x95
  98. /* Battery */
  99. #define AXP20X_CHRG_CC_31_24 0xb0
  100. #define AXP20X_CHRG_CC_23_16 0xb1
  101. #define AXP20X_CHRG_CC_15_8 0xb2
  102. #define AXP20X_CHRG_CC_7_0 0xb3
  103. #define AXP20X_DISCHRG_CC_31_24 0xb4
  104. #define AXP20X_DISCHRG_CC_23_16 0xb5
  105. #define AXP20X_DISCHRG_CC_15_8 0xb6
  106. #define AXP20X_DISCHRG_CC_7_0 0xb7
  107. #define AXP20X_CC_CTRL 0xb8
  108. #define AXP20X_FG_RES 0xb9
  109. /* Regulators IDs */
  110. enum {
  111. AXP20X_LDO1 = 0,
  112. AXP20X_LDO2,
  113. AXP20X_LDO3,
  114. AXP20X_LDO4,
  115. AXP20X_LDO5,
  116. AXP20X_DCDC2,
  117. AXP20X_DCDC3,
  118. AXP20X_REG_ID_MAX,
  119. };
  120. /* IRQs */
  121. enum {
  122. AXP20X_IRQ_ACIN_OVER_V = 1,
  123. AXP20X_IRQ_ACIN_PLUGIN,
  124. AXP20X_IRQ_ACIN_REMOVAL,
  125. AXP20X_IRQ_VBUS_OVER_V,
  126. AXP20X_IRQ_VBUS_PLUGIN,
  127. AXP20X_IRQ_VBUS_REMOVAL,
  128. AXP20X_IRQ_VBUS_V_LOW,
  129. AXP20X_IRQ_BATT_PLUGIN,
  130. AXP20X_IRQ_BATT_REMOVAL,
  131. AXP20X_IRQ_BATT_ENT_ACT_MODE,
  132. AXP20X_IRQ_BATT_EXIT_ACT_MODE,
  133. AXP20X_IRQ_CHARG,
  134. AXP20X_IRQ_CHARG_DONE,
  135. AXP20X_IRQ_BATT_TEMP_HIGH,
  136. AXP20X_IRQ_BATT_TEMP_LOW,
  137. AXP20X_IRQ_DIE_TEMP_HIGH,
  138. AXP20X_IRQ_CHARG_I_LOW,
  139. AXP20X_IRQ_DCDC1_V_LONG,
  140. AXP20X_IRQ_DCDC2_V_LONG,
  141. AXP20X_IRQ_DCDC3_V_LONG,
  142. AXP20X_IRQ_PEK_SHORT = 22,
  143. AXP20X_IRQ_PEK_LONG,
  144. AXP20X_IRQ_N_OE_PWR_ON,
  145. AXP20X_IRQ_N_OE_PWR_OFF,
  146. AXP20X_IRQ_VBUS_VALID,
  147. AXP20X_IRQ_VBUS_NOT_VALID,
  148. AXP20X_IRQ_VBUS_SESS_VALID,
  149. AXP20X_IRQ_VBUS_SESS_END,
  150. AXP20X_IRQ_LOW_PWR_LVL1,
  151. AXP20X_IRQ_LOW_PWR_LVL2,
  152. AXP20X_IRQ_TIMER,
  153. AXP20X_IRQ_PEK_RIS_EDGE,
  154. AXP20X_IRQ_PEK_FAL_EDGE,
  155. AXP20X_IRQ_GPIO3_INPUT,
  156. AXP20X_IRQ_GPIO2_INPUT,
  157. AXP20X_IRQ_GPIO1_INPUT,
  158. AXP20X_IRQ_GPIO0_INPUT,
  159. };
  160. struct axp20x_dev {
  161. struct device *dev;
  162. struct i2c_client *i2c_client;
  163. struct regmap *regmap;
  164. struct regmap_irq_chip_data *regmap_irqc;
  165. long variant;
  166. };
  167. #endif /* __LINUX_MFD_AXP20X_H */