88pm8607.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * Marvell 88PM8607 Interface
  3. *
  4. * Copyright (C) 2009 Marvell International Ltd.
  5. * Haojian Zhuang <haojian.zhuang@marvell.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef __LINUX_MFD_88PM8607_H
  12. #define __LINUX_MFD_88PM8607_H
  13. enum {
  14. PM8607_ID_BUCK1 = 0,
  15. PM8607_ID_BUCK2,
  16. PM8607_ID_BUCK3,
  17. PM8607_ID_LDO1,
  18. PM8607_ID_LDO2,
  19. PM8607_ID_LDO3,
  20. PM8607_ID_LDO4,
  21. PM8607_ID_LDO5,
  22. PM8607_ID_LDO6,
  23. PM8607_ID_LDO7,
  24. PM8607_ID_LDO8,
  25. PM8607_ID_LDO9,
  26. PM8607_ID_LDO10,
  27. PM8607_ID_LDO12,
  28. PM8607_ID_LDO14,
  29. PM8607_ID_RG_MAX,
  30. };
  31. #define CHIP_ID (0x40)
  32. #define CHIP_ID_MASK (0xF8)
  33. /* Interrupt Registers */
  34. #define PM8607_STATUS_1 (0x01)
  35. #define PM8607_STATUS_2 (0x02)
  36. #define PM8607_INT_STATUS1 (0x03)
  37. #define PM8607_INT_STATUS2 (0x04)
  38. #define PM8607_INT_STATUS3 (0x05)
  39. #define PM8607_INT_MASK_1 (0x06)
  40. #define PM8607_INT_MASK_2 (0x07)
  41. #define PM8607_INT_MASK_3 (0x08)
  42. /* Regulator Control Registers */
  43. #define PM8607_LDO1 (0x10)
  44. #define PM8607_LDO2 (0x11)
  45. #define PM8607_LDO3 (0x12)
  46. #define PM8607_LDO4 (0x13)
  47. #define PM8607_LDO5 (0x14)
  48. #define PM8607_LDO6 (0x15)
  49. #define PM8607_LDO7 (0x16)
  50. #define PM8607_LDO8 (0x17)
  51. #define PM8607_LDO9 (0x18)
  52. #define PM8607_LDO10 (0x19)
  53. #define PM8607_LDO12 (0x1A)
  54. #define PM8607_LDO14 (0x1B)
  55. #define PM8607_SLEEP_MODE1 (0x1C)
  56. #define PM8607_SLEEP_MODE2 (0x1D)
  57. #define PM8607_SLEEP_MODE3 (0x1E)
  58. #define PM8607_SLEEP_MODE4 (0x1F)
  59. #define PM8607_GO (0x20)
  60. #define PM8607_SLEEP_BUCK1 (0x21)
  61. #define PM8607_SLEEP_BUCK2 (0x22)
  62. #define PM8607_SLEEP_BUCK3 (0x23)
  63. #define PM8607_BUCK1 (0x24)
  64. #define PM8607_BUCK2 (0x25)
  65. #define PM8607_BUCK3 (0x26)
  66. #define PM8607_BUCK_CONTROLS (0x27)
  67. #define PM8607_SUPPLIES_EN11 (0x2B)
  68. #define PM8607_SUPPLIES_EN12 (0x2C)
  69. #define PM8607_GROUP1 (0x2D)
  70. #define PM8607_GROUP2 (0x2E)
  71. #define PM8607_GROUP3 (0x2F)
  72. #define PM8607_GROUP4 (0x30)
  73. #define PM8607_GROUP5 (0x31)
  74. #define PM8607_GROUP6 (0x32)
  75. #define PM8607_SUPPLIES_EN21 (0x33)
  76. #define PM8607_SUPPLIES_EN22 (0x34)
  77. /* RTC Control Registers */
  78. #define PM8607_RTC1 (0xA0)
  79. #define PM8607_RTC_COUNTER1 (0xA1)
  80. #define PM8607_RTC_COUNTER2 (0xA2)
  81. #define PM8607_RTC_COUNTER3 (0xA3)
  82. #define PM8607_RTC_COUNTER4 (0xA4)
  83. #define PM8607_RTC_EXPIRE1 (0xA5)
  84. #define PM8607_RTC_EXPIRE2 (0xA6)
  85. #define PM8607_RTC_EXPIRE3 (0xA7)
  86. #define PM8607_RTC_EXPIRE4 (0xA8)
  87. #define PM8607_RTC_TRIM1 (0xA9)
  88. #define PM8607_RTC_TRIM2 (0xAA)
  89. #define PM8607_RTC_TRIM3 (0xAB)
  90. #define PM8607_RTC_TRIM4 (0xAC)
  91. #define PM8607_RTC_MISC1 (0xAD)
  92. #define PM8607_RTC_MISC2 (0xAE)
  93. #define PM8607_RTC_MISC3 (0xAF)
  94. /* Misc Registers */
  95. #define PM8607_CHIP_ID (0x00)
  96. #define PM8607_LDO1 (0x10)
  97. #define PM8607_DVC3 (0x26)
  98. #define PM8607_MISC1 (0x40)
  99. /* bit definitions for PM8607 events */
  100. #define PM8607_EVENT_ONKEY (1 << 0)
  101. #define PM8607_EVENT_EXTON (1 << 1)
  102. #define PM8607_EVENT_CHG (1 << 2)
  103. #define PM8607_EVENT_BAT (1 << 3)
  104. #define PM8607_EVENT_RTC (1 << 4)
  105. #define PM8607_EVENT_CC (1 << 5)
  106. #define PM8607_EVENT_VBAT (1 << 8)
  107. #define PM8607_EVENT_VCHG (1 << 9)
  108. #define PM8607_EVENT_VSYS (1 << 10)
  109. #define PM8607_EVENT_TINT (1 << 11)
  110. #define PM8607_EVENT_GPADC0 (1 << 12)
  111. #define PM8607_EVENT_GPADC1 (1 << 13)
  112. #define PM8607_EVENT_GPADC2 (1 << 14)
  113. #define PM8607_EVENT_GPADC3 (1 << 15)
  114. #define PM8607_EVENT_AUDIO_SHORT (1 << 16)
  115. #define PM8607_EVENT_PEN (1 << 17)
  116. #define PM8607_EVENT_HEADSET (1 << 18)
  117. #define PM8607_EVENT_HOOK (1 << 19)
  118. #define PM8607_EVENT_MICIN (1 << 20)
  119. #define PM8607_EVENT_CHG_TIMEOUT (1 << 21)
  120. #define PM8607_EVENT_CHG_DONE (1 << 22)
  121. #define PM8607_EVENT_CHG_FAULT (1 << 23)
  122. /* bit definitions of Status Query Interface */
  123. #define PM8607_STATUS_CC (1 << 3)
  124. #define PM8607_STATUS_PEN (1 << 4)
  125. #define PM8607_STATUS_HEADSET (1 << 5)
  126. #define PM8607_STATUS_HOOK (1 << 6)
  127. #define PM8607_STATUS_MICIN (1 << 7)
  128. #define PM8607_STATUS_ONKEY (1 << 8)
  129. #define PM8607_STATUS_EXTON (1 << 9)
  130. #define PM8607_STATUS_CHG (1 << 10)
  131. #define PM8607_STATUS_BAT (1 << 11)
  132. #define PM8607_STATUS_VBUS (1 << 12)
  133. #define PM8607_STATUS_OV (1 << 13)
  134. /* bit definitions of BUCK3 */
  135. #define PM8607_BUCK3_DOUBLE (1 << 6)
  136. /* bit definitions of Misc1 */
  137. #define PM8607_MISC1_PI2C (1 << 0)
  138. /* Interrupt Number in 88PM8607 */
  139. enum {
  140. PM8607_IRQ_ONKEY = 0,
  141. PM8607_IRQ_EXTON,
  142. PM8607_IRQ_CHG,
  143. PM8607_IRQ_BAT,
  144. PM8607_IRQ_RTC,
  145. PM8607_IRQ_VBAT = 8,
  146. PM8607_IRQ_VCHG,
  147. PM8607_IRQ_VSYS,
  148. PM8607_IRQ_TINT,
  149. PM8607_IRQ_GPADC0,
  150. PM8607_IRQ_GPADC1,
  151. PM8607_IRQ_GPADC2,
  152. PM8607_IRQ_GPADC3,
  153. PM8607_IRQ_AUDIO_SHORT = 16,
  154. PM8607_IRQ_PEN,
  155. PM8607_IRQ_HEADSET,
  156. PM8607_IRQ_HOOK,
  157. PM8607_IRQ_MICIN,
  158. PM8607_IRQ_CHG_FAIL,
  159. PM8607_IRQ_CHG_DONE,
  160. PM8607_IRQ_CHG_FAULT,
  161. };
  162. enum {
  163. PM8607_CHIP_A0 = 0x40,
  164. PM8607_CHIP_A1 = 0x41,
  165. PM8607_CHIP_B0 = 0x48,
  166. };
  167. struct pm8607_chip {
  168. struct device *dev;
  169. struct mutex io_lock;
  170. struct i2c_client *client;
  171. int (*read)(struct pm8607_chip *chip, int reg, int bytes, void *dest);
  172. int (*write)(struct pm8607_chip *chip, int reg, int bytes, void *src);
  173. int buck3_double; /* DVC ramp slope double */
  174. unsigned char chip_id;
  175. };
  176. #define PM8607_MAX_REGULATOR 15 /* 3 Bucks, 12 LDOs */
  177. enum {
  178. GI2C_PORT = 0,
  179. PI2C_PORT,
  180. };
  181. struct pm8607_platform_data {
  182. int i2c_port; /* Controlled by GI2C or PI2C */
  183. struct regulator_init_data *regulator[PM8607_MAX_REGULATOR];
  184. };
  185. extern int pm8607_reg_read(struct pm8607_chip *, int);
  186. extern int pm8607_reg_write(struct pm8607_chip *, int, unsigned char);
  187. extern int pm8607_bulk_read(struct pm8607_chip *, int, int,
  188. unsigned char *);
  189. extern int pm8607_bulk_write(struct pm8607_chip *, int, int,
  190. unsigned char *);
  191. extern int pm8607_set_bits(struct pm8607_chip *, int, unsigned char,
  192. unsigned char);
  193. #endif /* __LINUX_MFD_88PM8607_H */