ab8500.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * License Terms: GNU General Public License v2
  5. * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
  6. */
  7. #ifndef MFD_AB8500_H
  8. #define MFD_AB8500_H
  9. #include <linux/device.h>
  10. /*
  11. * AB IC versions
  12. *
  13. * AB8500_VERSION_AB8500 should be 0xFF but will never be read as need a
  14. * non-supported multi-byte I2C access via PRCMU. Set to 0x00 to ease the
  15. * print of version string.
  16. */
  17. enum ab8500_version {
  18. AB8500_VERSION_AB8500 = 0x0,
  19. AB8500_VERSION_AB8505 = 0x1,
  20. AB8500_VERSION_AB9540 = 0x2,
  21. AB8500_VERSION_AB8540 = 0x3,
  22. AB8500_VERSION_UNDEFINED,
  23. };
  24. /* AB8500 CIDs*/
  25. #define AB8500_CUTEARLY 0x00
  26. #define AB8500_CUT1P0 0x10
  27. #define AB8500_CUT1P1 0x11
  28. #define AB8500_CUT2P0 0x20
  29. #define AB8500_CUT3P0 0x30
  30. #define AB8500_CUT3P3 0x33
  31. /*
  32. * AB8500 bank addresses
  33. */
  34. #define AB8500_SYS_CTRL1_BLOCK 0x1
  35. #define AB8500_SYS_CTRL2_BLOCK 0x2
  36. #define AB8500_REGU_CTRL1 0x3
  37. #define AB8500_REGU_CTRL2 0x4
  38. #define AB8500_USB 0x5
  39. #define AB8500_TVOUT 0x6
  40. #define AB8500_DBI 0x7
  41. #define AB8500_ECI_AV_ACC 0x8
  42. #define AB8500_RESERVED 0x9
  43. #define AB8500_GPADC 0xA
  44. #define AB8500_CHARGER 0xB
  45. #define AB8500_GAS_GAUGE 0xC
  46. #define AB8500_AUDIO 0xD
  47. #define AB8500_INTERRUPT 0xE
  48. #define AB8500_RTC 0xF
  49. #define AB8500_MISC 0x10
  50. #define AB8500_DEVELOPMENT 0x11
  51. #define AB8500_DEBUG 0x12
  52. #define AB8500_PROD_TEST 0x13
  53. #define AB8500_OTP_EMUL 0x15
  54. /*
  55. * Interrupts
  56. */
  57. #define AB8500_INT_MAIN_EXT_CH_NOT_OK 0
  58. #define AB8500_INT_UN_PLUG_TV_DET 1
  59. #define AB8500_INT_PLUG_TV_DET 2
  60. #define AB8500_INT_TEMP_WARM 3
  61. #define AB8500_INT_PON_KEY2DB_F 4
  62. #define AB8500_INT_PON_KEY2DB_R 5
  63. #define AB8500_INT_PON_KEY1DB_F 6
  64. #define AB8500_INT_PON_KEY1DB_R 7
  65. #define AB8500_INT_BATT_OVV 8
  66. #define AB8500_INT_MAIN_CH_UNPLUG_DET 10
  67. #define AB8500_INT_MAIN_CH_PLUG_DET 11
  68. #define AB8500_INT_USB_ID_DET_F 12
  69. #define AB8500_INT_USB_ID_DET_R 13
  70. #define AB8500_INT_VBUS_DET_F 14
  71. #define AB8500_INT_VBUS_DET_R 15
  72. #define AB8500_INT_VBUS_CH_DROP_END 16
  73. #define AB8500_INT_RTC_60S 17
  74. #define AB8500_INT_RTC_ALARM 18
  75. #define AB8500_INT_BAT_CTRL_INDB 20
  76. #define AB8500_INT_CH_WD_EXP 21
  77. #define AB8500_INT_VBUS_OVV 22
  78. #define AB8500_INT_MAIN_CH_DROP_END 23
  79. #define AB8500_INT_CCN_CONV_ACC 24
  80. #define AB8500_INT_INT_AUD 25
  81. #define AB8500_INT_CCEOC 26
  82. #define AB8500_INT_CC_INT_CALIB 27
  83. #define AB8500_INT_LOW_BAT_F 28
  84. #define AB8500_INT_LOW_BAT_R 29
  85. #define AB8500_INT_BUP_CHG_NOT_OK 30
  86. #define AB8500_INT_BUP_CHG_OK 31
  87. #define AB8500_INT_GP_HW_ADC_CONV_END 32
  88. #define AB8500_INT_ACC_DETECT_1DB_F 33
  89. #define AB8500_INT_ACC_DETECT_1DB_R 34
  90. #define AB8500_INT_ACC_DETECT_22DB_F 35
  91. #define AB8500_INT_ACC_DETECT_22DB_R 36
  92. #define AB8500_INT_ACC_DETECT_21DB_F 37
  93. #define AB8500_INT_ACC_DETECT_21DB_R 38
  94. #define AB8500_INT_GP_SW_ADC_CONV_END 39
  95. #define AB8500_INT_GPIO6R 40
  96. #define AB8500_INT_GPIO7R 41
  97. #define AB8500_INT_GPIO8R 42
  98. #define AB8500_INT_GPIO9R 43
  99. #define AB8500_INT_GPIO10R 44
  100. #define AB8500_INT_GPIO11R 45
  101. #define AB8500_INT_GPIO12R 46
  102. #define AB8500_INT_GPIO13R 47
  103. #define AB8500_INT_GPIO24R 48
  104. #define AB8500_INT_GPIO25R 49
  105. #define AB8500_INT_GPIO36R 50
  106. #define AB8500_INT_GPIO37R 51
  107. #define AB8500_INT_GPIO38R 52
  108. #define AB8500_INT_GPIO39R 53
  109. #define AB8500_INT_GPIO40R 54
  110. #define AB8500_INT_GPIO41R 55
  111. #define AB8500_INT_GPIO6F 56
  112. #define AB8500_INT_GPIO7F 57
  113. #define AB8500_INT_GPIO8F 58
  114. #define AB8500_INT_GPIO9F 59
  115. #define AB8500_INT_GPIO10F 60
  116. #define AB8500_INT_GPIO11F 61
  117. #define AB8500_INT_GPIO12F 62
  118. #define AB8500_INT_GPIO13F 63
  119. #define AB8500_INT_GPIO24F 64
  120. #define AB8500_INT_GPIO25F 65
  121. #define AB8500_INT_GPIO36F 66
  122. #define AB8500_INT_GPIO37F 67
  123. #define AB8500_INT_GPIO38F 68
  124. #define AB8500_INT_GPIO39F 69
  125. #define AB8500_INT_GPIO40F 70
  126. #define AB8500_INT_GPIO41F 71
  127. #define AB8500_INT_ADP_SOURCE_ERROR 72
  128. #define AB8500_INT_ADP_SINK_ERROR 73
  129. #define AB8500_INT_ADP_PROBE_PLUG 74
  130. #define AB8500_INT_ADP_PROBE_UNPLUG 75
  131. #define AB8500_INT_ADP_SENSE_OFF 76
  132. #define AB8500_INT_USB_PHY_POWER_ERR 78
  133. #define AB8500_INT_USB_LINK_STATUS 79
  134. #define AB8500_INT_BTEMP_LOW 80
  135. #define AB8500_INT_BTEMP_LOW_MEDIUM 81
  136. #define AB8500_INT_BTEMP_MEDIUM_HIGH 82
  137. #define AB8500_INT_BTEMP_HIGH 83
  138. #define AB8500_INT_USB_CHARGER_NOT_OK 89
  139. #define AB8500_INT_ID_WAKEUP_R 90
  140. #define AB8500_INT_ID_DET_R1R 92
  141. #define AB8500_INT_ID_DET_R2R 93
  142. #define AB8500_INT_ID_DET_R3R 94
  143. #define AB8500_INT_ID_DET_R4R 95
  144. #define AB8500_INT_ID_WAKEUP_F 96
  145. #define AB8500_INT_ID_DET_R1F 98
  146. #define AB8500_INT_ID_DET_R2F 99
  147. #define AB8500_INT_ID_DET_R3F 100
  148. #define AB8500_INT_ID_DET_R4F 101
  149. #define AB8500_INT_USB_CHG_DET_DONE 102
  150. #define AB8500_INT_USB_CH_TH_PROT_F 104
  151. #define AB8500_INT_USB_CH_TH_PROT_R 105
  152. #define AB8500_INT_MAIN_CH_TH_PROT_F 106
  153. #define AB8500_INT_MAIN_CH_TH_PROT_R 107
  154. #define AB8500_INT_USB_CHARGER_NOT_OKF 111
  155. #define AB8500_NR_IRQS 112
  156. #define AB8500_NUM_IRQ_REGS 14
  157. /**
  158. * struct ab8500 - ab8500 internal structure
  159. * @dev: parent device
  160. * @lock: read/write operations lock
  161. * @irq_lock: genirq bus lock
  162. * @irq: irq line
  163. * @version: chip version id (e.g. ab8500 or ab9540)
  164. * @chip_id: chip revision id
  165. * @write: register write
  166. * @read: register read
  167. * @rx_buf: rx buf for SPI
  168. * @tx_buf: tx buf for SPI
  169. * @mask: cache of IRQ regs for bus lock
  170. * @oldmask: cache of previous IRQ regs for bus lock
  171. * @mask_size: Actual number of valid entries in mask[], oldmask[] and
  172. * irq_reg_offset
  173. * @irq_reg_offset: Array of offsets into IRQ registers
  174. */
  175. struct ab8500 {
  176. struct device *dev;
  177. struct mutex lock;
  178. struct mutex irq_lock;
  179. int irq_base;
  180. int irq;
  181. enum ab8500_version version;
  182. u8 chip_id;
  183. int (*write) (struct ab8500 *a8500, u16 addr, u8 data);
  184. int (*read) (struct ab8500 *a8500, u16 addr);
  185. unsigned long tx_buf[4];
  186. unsigned long rx_buf[4];
  187. u8 *mask;
  188. u8 *oldmask;
  189. int mask_size;
  190. const int *irq_reg_offset;
  191. };
  192. struct regulator_reg_init;
  193. struct regulator_init_data;
  194. struct ab8500_gpio_platform_data;
  195. /**
  196. * struct ab8500_platform_data - AB8500 platform data
  197. * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used
  198. * @init: board-specific initialization after detection of ab8500
  199. * @num_regulator_reg_init: number of regulator init registers
  200. * @regulator_reg_init: regulator init registers
  201. * @num_regulator: number of regulators
  202. * @regulator: machine-specific constraints for regulators
  203. */
  204. struct ab8500_platform_data {
  205. int irq_base;
  206. void (*init) (struct ab8500 *);
  207. int num_regulator_reg_init;
  208. struct ab8500_regulator_reg_init *regulator_reg_init;
  209. int num_regulator;
  210. struct regulator_init_data *regulator;
  211. struct ab8500_gpio_platform_data *gpio;
  212. };
  213. extern int __devinit ab8500_init(struct ab8500 *ab8500,
  214. enum ab8500_version version);
  215. extern int __devexit ab8500_exit(struct ab8500 *ab8500);
  216. static inline int is_ab8500(struct ab8500 *ab)
  217. {
  218. return ab->version == AB8500_VERSION_AB8500;
  219. }
  220. static inline int is_ab8505(struct ab8500 *ab)
  221. {
  222. return ab->version == AB8500_VERSION_AB8505;
  223. }
  224. static inline int is_ab9540(struct ab8500 *ab)
  225. {
  226. return ab->version == AB8500_VERSION_AB9540;
  227. }
  228. static inline int is_ab8540(struct ab8500 *ab)
  229. {
  230. return ab->version == AB8500_VERSION_AB8540;
  231. }
  232. /* include also ab8505, ab9540... */
  233. static inline int is_ab8500_1p1_or_earlier(struct ab8500 *ab)
  234. {
  235. return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT1P1));
  236. }
  237. /* include also ab8505, ab9540... */
  238. static inline int is_ab8500_2p0_or_earlier(struct ab8500 *ab)
  239. {
  240. return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT2P0));
  241. }
  242. #endif /* MFD_AB8500_H */