max8925.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. * Maxim8925 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_MAX8925_H
  12. #define __LINUX_MFD_MAX8925_H
  13. #include <linux/mutex.h>
  14. #include <linux/interrupt.h>
  15. /* Unified sub device IDs for MAX8925 */
  16. enum {
  17. MAX8925_ID_SD1,
  18. MAX8925_ID_SD2,
  19. MAX8925_ID_SD3,
  20. MAX8925_ID_LDO1,
  21. MAX8925_ID_LDO2,
  22. MAX8925_ID_LDO3,
  23. MAX8925_ID_LDO4,
  24. MAX8925_ID_LDO5,
  25. MAX8925_ID_LDO6,
  26. MAX8925_ID_LDO7,
  27. MAX8925_ID_LDO8,
  28. MAX8925_ID_LDO9,
  29. MAX8925_ID_LDO10,
  30. MAX8925_ID_LDO11,
  31. MAX8925_ID_LDO12,
  32. MAX8925_ID_LDO13,
  33. MAX8925_ID_LDO14,
  34. MAX8925_ID_LDO15,
  35. MAX8925_ID_LDO16,
  36. MAX8925_ID_LDO17,
  37. MAX8925_ID_LDO18,
  38. MAX8925_ID_LDO19,
  39. MAX8925_ID_LDO20,
  40. MAX8925_ID_MAX,
  41. };
  42. enum {
  43. /*
  44. * Charging current threshold trigger going from fast charge
  45. * to TOPOFF charge. From 5% to 20% of fasting charging current.
  46. */
  47. MAX8925_TOPOFF_THR_5PER,
  48. MAX8925_TOPOFF_THR_10PER,
  49. MAX8925_TOPOFF_THR_15PER,
  50. MAX8925_TOPOFF_THR_20PER,
  51. };
  52. enum {
  53. /* Fast charging current */
  54. MAX8925_FCHG_85MA,
  55. MAX8925_FCHG_300MA,
  56. MAX8925_FCHG_460MA,
  57. MAX8925_FCHG_600MA,
  58. MAX8925_FCHG_700MA,
  59. MAX8925_FCHG_800MA,
  60. MAX8925_FCHG_900MA,
  61. MAX8925_FCHG_1000MA,
  62. };
  63. /* Charger registers */
  64. #define MAX8925_CHG_IRQ1 (0x7e)
  65. #define MAX8925_CHG_IRQ2 (0x7f)
  66. #define MAX8925_CHG_IRQ1_MASK (0x80)
  67. #define MAX8925_CHG_IRQ2_MASK (0x81)
  68. #define MAX8925_CHG_STATUS (0x82)
  69. /* GPM registers */
  70. #define MAX8925_SYSENSEL (0x00)
  71. #define MAX8925_ON_OFF_IRQ1 (0x01)
  72. #define MAX8925_ON_OFF_IRQ1_MASK (0x02)
  73. #define MAX8925_ON_OFF_STATUS (0x03)
  74. #define MAX8925_ON_OFF_IRQ2 (0x0d)
  75. #define MAX8925_ON_OFF_IRQ2_MASK (0x0e)
  76. #define MAX8925_RESET_CNFG (0x0f)
  77. /* Touch registers */
  78. #define MAX8925_TSC_IRQ (0x00)
  79. #define MAX8925_TSC_IRQ_MASK (0x01)
  80. #define MAX8925_TSC_CNFG1 (0x02)
  81. #define MAX8925_ADC_SCHED (0x10)
  82. #define MAX8925_ADC_RES_END (0x6f)
  83. #define MAX8925_NREF_OK (1 << 4)
  84. /* RTC registers */
  85. #define MAX8925_ALARM0_CNTL (0x18)
  86. #define MAX8925_ALARM1_CNTL (0x19)
  87. #define MAX8925_RTC_IRQ (0x1c)
  88. #define MAX8925_RTC_IRQ_MASK (0x1d)
  89. #define MAX8925_MPL_CNTL (0x1e)
  90. /* WLED registers */
  91. #define MAX8925_WLED_MODE_CNTL (0x84)
  92. #define MAX8925_WLED_CNTL (0x85)
  93. /* MAX8925 Registers */
  94. #define MAX8925_SDCTL1 (0x04)
  95. #define MAX8925_SDCTL2 (0x07)
  96. #define MAX8925_SDCTL3 (0x0A)
  97. #define MAX8925_SDV1 (0x06)
  98. #define MAX8925_SDV2 (0x09)
  99. #define MAX8925_SDV3 (0x0C)
  100. #define MAX8925_LDOCTL1 (0x18)
  101. #define MAX8925_LDOCTL2 (0x1C)
  102. #define MAX8925_LDOCTL3 (0x20)
  103. #define MAX8925_LDOCTL4 (0x24)
  104. #define MAX8925_LDOCTL5 (0x28)
  105. #define MAX8925_LDOCTL6 (0x2C)
  106. #define MAX8925_LDOCTL7 (0x30)
  107. #define MAX8925_LDOCTL8 (0x34)
  108. #define MAX8925_LDOCTL9 (0x38)
  109. #define MAX8925_LDOCTL10 (0x3C)
  110. #define MAX8925_LDOCTL11 (0x40)
  111. #define MAX8925_LDOCTL12 (0x44)
  112. #define MAX8925_LDOCTL13 (0x48)
  113. #define MAX8925_LDOCTL14 (0x4C)
  114. #define MAX8925_LDOCTL15 (0x50)
  115. #define MAX8925_LDOCTL16 (0x10)
  116. #define MAX8925_LDOCTL17 (0x14)
  117. #define MAX8925_LDOCTL18 (0x72)
  118. #define MAX8925_LDOCTL19 (0x5C)
  119. #define MAX8925_LDOCTL20 (0x9C)
  120. #define MAX8925_LDOVOUT1 (0x1A)
  121. #define MAX8925_LDOVOUT2 (0x1E)
  122. #define MAX8925_LDOVOUT3 (0x22)
  123. #define MAX8925_LDOVOUT4 (0x26)
  124. #define MAX8925_LDOVOUT5 (0x2A)
  125. #define MAX8925_LDOVOUT6 (0x2E)
  126. #define MAX8925_LDOVOUT7 (0x32)
  127. #define MAX8925_LDOVOUT8 (0x36)
  128. #define MAX8925_LDOVOUT9 (0x3A)
  129. #define MAX8925_LDOVOUT10 (0x3E)
  130. #define MAX8925_LDOVOUT11 (0x42)
  131. #define MAX8925_LDOVOUT12 (0x46)
  132. #define MAX8925_LDOVOUT13 (0x4A)
  133. #define MAX8925_LDOVOUT14 (0x4E)
  134. #define MAX8925_LDOVOUT15 (0x52)
  135. #define MAX8925_LDOVOUT16 (0x12)
  136. #define MAX8925_LDOVOUT17 (0x16)
  137. #define MAX8925_LDOVOUT18 (0x74)
  138. #define MAX8925_LDOVOUT19 (0x5E)
  139. #define MAX8925_LDOVOUT20 (0x9E)
  140. /* bit definitions */
  141. #define CHG_IRQ1_MASK (0x07)
  142. #define CHG_IRQ2_MASK (0xff)
  143. #define ON_OFF_IRQ1_MASK (0xff)
  144. #define ON_OFF_IRQ2_MASK (0x03)
  145. #define TSC_IRQ_MASK (0x03)
  146. #define RTC_IRQ_MASK (0x0c)
  147. #define MAX8925_NAME_SIZE (32)
  148. /* IRQ definitions */
  149. enum {
  150. MAX8925_IRQ_VCHG_DC_OVP,
  151. MAX8925_IRQ_VCHG_DC_F,
  152. MAX8925_IRQ_VCHG_DC_R,
  153. MAX8925_IRQ_VCHG_THM_OK_R,
  154. MAX8925_IRQ_VCHG_THM_OK_F,
  155. MAX8925_IRQ_VCHG_SYSLOW_F,
  156. MAX8925_IRQ_VCHG_SYSLOW_R,
  157. MAX8925_IRQ_VCHG_RST,
  158. MAX8925_IRQ_VCHG_DONE,
  159. MAX8925_IRQ_VCHG_TOPOFF,
  160. MAX8925_IRQ_VCHG_TMR_FAULT,
  161. MAX8925_IRQ_GPM_RSTIN,
  162. MAX8925_IRQ_GPM_MPL,
  163. MAX8925_IRQ_GPM_SW_3SEC,
  164. MAX8925_IRQ_GPM_EXTON_F,
  165. MAX8925_IRQ_GPM_EXTON_R,
  166. MAX8925_IRQ_GPM_SW_1SEC,
  167. MAX8925_IRQ_GPM_SW_F,
  168. MAX8925_IRQ_GPM_SW_R,
  169. MAX8925_IRQ_GPM_SYSCKEN_F,
  170. MAX8925_IRQ_GPM_SYSCKEN_R,
  171. MAX8925_IRQ_RTC_ALARM1,
  172. MAX8925_IRQ_RTC_ALARM0,
  173. MAX8925_IRQ_TSC_STICK,
  174. MAX8925_IRQ_TSC_NSTICK,
  175. MAX8925_NR_IRQS,
  176. };
  177. struct max8925_chip {
  178. struct device *dev;
  179. struct i2c_client *i2c;
  180. struct i2c_client *adc;
  181. struct i2c_client *rtc;
  182. struct mutex io_lock;
  183. struct mutex irq_lock;
  184. int irq_base;
  185. int core_irq;
  186. int tsc_irq;
  187. unsigned int wakeup_flag;
  188. };
  189. struct max8925_backlight_pdata {
  190. int lxw_scl; /* 0/1 -- 0.8Ohm/0.4Ohm */
  191. int lxw_freq; /* 700KHz ~ 1400KHz */
  192. int dual_string; /* 0/1 -- single/dual string */
  193. };
  194. struct max8925_touch_pdata {
  195. unsigned int flags;
  196. };
  197. struct max8925_power_pdata {
  198. int (*set_charger)(int);
  199. unsigned batt_detect:1;
  200. unsigned topoff_threshold:2;
  201. unsigned fast_charge:3; /* charge current */
  202. unsigned no_temp_support:1; /* set if no temperature detect */
  203. unsigned no_insert_detect:1; /* set if no ac insert detect */
  204. char **supplied_to;
  205. int num_supplicants;
  206. };
  207. /*
  208. * irq_base: stores IRQ base number of MAX8925 in platform
  209. * tsc_irq: stores IRQ number of MAX8925 TSC
  210. */
  211. struct max8925_platform_data {
  212. struct max8925_backlight_pdata *backlight;
  213. struct max8925_touch_pdata *touch;
  214. struct max8925_power_pdata *power;
  215. struct regulator_init_data *sd1;
  216. struct regulator_init_data *sd2;
  217. struct regulator_init_data *sd3;
  218. struct regulator_init_data *ldo1;
  219. struct regulator_init_data *ldo2;
  220. struct regulator_init_data *ldo3;
  221. struct regulator_init_data *ldo4;
  222. struct regulator_init_data *ldo5;
  223. struct regulator_init_data *ldo6;
  224. struct regulator_init_data *ldo7;
  225. struct regulator_init_data *ldo8;
  226. struct regulator_init_data *ldo9;
  227. struct regulator_init_data *ldo10;
  228. struct regulator_init_data *ldo11;
  229. struct regulator_init_data *ldo12;
  230. struct regulator_init_data *ldo13;
  231. struct regulator_init_data *ldo14;
  232. struct regulator_init_data *ldo15;
  233. struct regulator_init_data *ldo16;
  234. struct regulator_init_data *ldo17;
  235. struct regulator_init_data *ldo18;
  236. struct regulator_init_data *ldo19;
  237. struct regulator_init_data *ldo20;
  238. int irq_base;
  239. int tsc_irq;
  240. };
  241. extern int max8925_reg_read(struct i2c_client *, int);
  242. extern int max8925_reg_write(struct i2c_client *, int, unsigned char);
  243. extern int max8925_bulk_read(struct i2c_client *, int, int, unsigned char *);
  244. extern int max8925_bulk_write(struct i2c_client *, int, int, unsigned char *);
  245. extern int max8925_set_bits(struct i2c_client *, int, unsigned char,
  246. unsigned char);
  247. extern int max8925_device_init(struct max8925_chip *,
  248. struct max8925_platform_data *);
  249. extern void max8925_device_exit(struct max8925_chip *);
  250. #endif /* __LINUX_MFD_MAX8925_H */