da903x.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. #ifndef __LINUX_PMIC_DA903X_H
  2. #define __LINUX_PMIC_DA903X_H
  3. /* Unified sub device IDs for DA9030/DA9034/DA9035 */
  4. enum {
  5. DA9030_ID_LED_1,
  6. DA9030_ID_LED_2,
  7. DA9030_ID_LED_3,
  8. DA9030_ID_LED_4,
  9. DA9030_ID_LED_PC,
  10. DA9030_ID_VIBRA,
  11. DA9030_ID_WLED,
  12. DA9030_ID_BUCK1,
  13. DA9030_ID_BUCK2,
  14. DA9030_ID_LDO1,
  15. DA9030_ID_LDO2,
  16. DA9030_ID_LDO3,
  17. DA9030_ID_LDO4,
  18. DA9030_ID_LDO5,
  19. DA9030_ID_LDO6,
  20. DA9030_ID_LDO7,
  21. DA9030_ID_LDO8,
  22. DA9030_ID_LDO9,
  23. DA9030_ID_LDO10,
  24. DA9030_ID_LDO11,
  25. DA9030_ID_LDO12,
  26. DA9030_ID_LDO13,
  27. DA9030_ID_LDO14,
  28. DA9030_ID_LDO15,
  29. DA9030_ID_LDO16,
  30. DA9030_ID_LDO17,
  31. DA9030_ID_LDO18,
  32. DA9030_ID_LDO19,
  33. DA9030_ID_LDO_INT, /* LDO Internal */
  34. DA9030_ID_BAT, /* battery charger */
  35. DA9034_ID_LED_1,
  36. DA9034_ID_LED_2,
  37. DA9034_ID_VIBRA,
  38. DA9034_ID_WLED,
  39. DA9034_ID_TOUCH,
  40. DA9034_ID_BUCK1,
  41. DA9034_ID_BUCK2,
  42. DA9034_ID_LDO1,
  43. DA9034_ID_LDO2,
  44. DA9034_ID_LDO3,
  45. DA9034_ID_LDO4,
  46. DA9034_ID_LDO5,
  47. DA9034_ID_LDO6,
  48. DA9034_ID_LDO7,
  49. DA9034_ID_LDO8,
  50. DA9034_ID_LDO9,
  51. DA9034_ID_LDO10,
  52. DA9034_ID_LDO11,
  53. DA9034_ID_LDO12,
  54. DA9034_ID_LDO13,
  55. DA9034_ID_LDO14,
  56. DA9034_ID_LDO15,
  57. DA9035_ID_BUCK3,
  58. };
  59. /*
  60. * DA9030/DA9034 LEDs sub-devices uses generic "struct led_info"
  61. * as the platform_data
  62. */
  63. /* DA9030 flags for "struct led_info"
  64. */
  65. #define DA9030_LED_RATE_ON (0 << 5)
  66. #define DA9030_LED_RATE_052S (1 << 5)
  67. #define DA9030_LED_DUTY_1_16 (0 << 3)
  68. #define DA9030_LED_DUTY_1_8 (1 << 3)
  69. #define DA9030_LED_DUTY_1_4 (2 << 3)
  70. #define DA9030_LED_DUTY_1_2 (3 << 3)
  71. #define DA9030_VIBRA_MODE_1P3V (0 << 1)
  72. #define DA9030_VIBRA_MODE_2P7V (1 << 1)
  73. #define DA9030_VIBRA_FREQ_1HZ (0 << 2)
  74. #define DA9030_VIBRA_FREQ_2HZ (1 << 2)
  75. #define DA9030_VIBRA_FREQ_4HZ (2 << 2)
  76. #define DA9030_VIBRA_FREQ_8HZ (3 << 2)
  77. #define DA9030_VIBRA_DUTY_ON (0 << 4)
  78. #define DA9030_VIBRA_DUTY_75P (1 << 4)
  79. #define DA9030_VIBRA_DUTY_50P (2 << 4)
  80. #define DA9030_VIBRA_DUTY_25P (3 << 4)
  81. /* DA9034 flags for "struct led_info" */
  82. #define DA9034_LED_RAMP (1 << 7)
  83. /* DA9034 touch screen platform data */
  84. struct da9034_touch_pdata {
  85. int interval_ms; /* sampling interval while pen down */
  86. int x_inverted;
  87. int y_inverted;
  88. };
  89. struct da9034_backlight_pdata {
  90. int output_current; /* output current of WLED, from 0-31 (in mA) */
  91. };
  92. /* DA9030 battery charger data */
  93. struct power_supply_info;
  94. struct da9030_battery_info {
  95. /* battery parameters */
  96. struct power_supply_info *battery_info;
  97. /* current and voltage to use for battery charging */
  98. unsigned int charge_milliamp;
  99. unsigned int charge_millivolt;
  100. /* voltage thresholds (in millivolts) */
  101. int vbat_low;
  102. int vbat_crit;
  103. int vbat_charge_start;
  104. int vbat_charge_stop;
  105. int vbat_charge_restart;
  106. /* battery nominal minimal and maximal voltages in millivolts */
  107. int vcharge_min;
  108. int vcharge_max;
  109. /* Temperature thresholds. These are DA9030 register values
  110. "as is" and should be measured for each battery type */
  111. int tbat_low;
  112. int tbat_high;
  113. int tbat_restart;
  114. /* battery monitor interval (seconds) */
  115. unsigned int batmon_interval;
  116. /* platform callbacks for battery low and critical events */
  117. void (*battery_low)(void);
  118. void (*battery_critical)(void);
  119. };
  120. struct da903x_subdev_info {
  121. int id;
  122. const char *name;
  123. void *platform_data;
  124. };
  125. struct da903x_platform_data {
  126. int num_subdevs;
  127. struct da903x_subdev_info *subdevs;
  128. };
  129. /* bit definitions for DA9030 events */
  130. #define DA9030_EVENT_ONKEY (1 << 0)
  131. #define DA9030_EVENT_PWREN (1 << 1)
  132. #define DA9030_EVENT_EXTON (1 << 2)
  133. #define DA9030_EVENT_CHDET (1 << 3)
  134. #define DA9030_EVENT_TBAT (1 << 4)
  135. #define DA9030_EVENT_VBATMON (1 << 5)
  136. #define DA9030_EVENT_VBATMON_TXON (1 << 6)
  137. #define DA9030_EVENT_CHIOVER (1 << 7)
  138. #define DA9030_EVENT_TCTO (1 << 8)
  139. #define DA9030_EVENT_CCTO (1 << 9)
  140. #define DA9030_EVENT_ADC_READY (1 << 10)
  141. #define DA9030_EVENT_VBUS_4P4 (1 << 11)
  142. #define DA9030_EVENT_VBUS_4P0 (1 << 12)
  143. #define DA9030_EVENT_SESS_VALID (1 << 13)
  144. #define DA9030_EVENT_SRP_DETECT (1 << 14)
  145. #define DA9030_EVENT_WATCHDOG (1 << 15)
  146. #define DA9030_EVENT_LDO15 (1 << 16)
  147. #define DA9030_EVENT_LDO16 (1 << 17)
  148. #define DA9030_EVENT_LDO17 (1 << 18)
  149. #define DA9030_EVENT_LDO18 (1 << 19)
  150. #define DA9030_EVENT_LDO19 (1 << 20)
  151. #define DA9030_EVENT_BUCK2 (1 << 21)
  152. /* bit definitions for DA9034 events */
  153. #define DA9034_EVENT_ONKEY (1 << 0)
  154. #define DA9034_EVENT_EXTON (1 << 2)
  155. #define DA9034_EVENT_CHDET (1 << 3)
  156. #define DA9034_EVENT_TBAT (1 << 4)
  157. #define DA9034_EVENT_VBATMON (1 << 5)
  158. #define DA9034_EVENT_REV_IOVER (1 << 6)
  159. #define DA9034_EVENT_CH_IOVER (1 << 7)
  160. #define DA9034_EVENT_CH_TCTO (1 << 8)
  161. #define DA9034_EVENT_CH_CCTO (1 << 9)
  162. #define DA9034_EVENT_USB_DEV (1 << 10)
  163. #define DA9034_EVENT_OTGCP_IOVER (1 << 11)
  164. #define DA9034_EVENT_VBUS_4P55 (1 << 12)
  165. #define DA9034_EVENT_VBUS_3P8 (1 << 13)
  166. #define DA9034_EVENT_SESS_1P8 (1 << 14)
  167. #define DA9034_EVENT_SRP_READY (1 << 15)
  168. #define DA9034_EVENT_ADC_MAN (1 << 16)
  169. #define DA9034_EVENT_ADC_AUTO4 (1 << 17)
  170. #define DA9034_EVENT_ADC_AUTO5 (1 << 18)
  171. #define DA9034_EVENT_ADC_AUTO6 (1 << 19)
  172. #define DA9034_EVENT_PEN_DOWN (1 << 20)
  173. #define DA9034_EVENT_TSI_READY (1 << 21)
  174. #define DA9034_EVENT_UART_TX (1 << 22)
  175. #define DA9034_EVENT_UART_RX (1 << 23)
  176. #define DA9034_EVENT_HEADSET (1 << 25)
  177. #define DA9034_EVENT_HOOKSWITCH (1 << 26)
  178. #define DA9034_EVENT_WATCHDOG (1 << 27)
  179. extern int da903x_register_notifier(struct device *dev,
  180. struct notifier_block *nb, unsigned int events);
  181. extern int da903x_unregister_notifier(struct device *dev,
  182. struct notifier_block *nb, unsigned int events);
  183. /* Status Query Interface */
  184. #define DA9030_STATUS_ONKEY (1 << 0)
  185. #define DA9030_STATUS_PWREN1 (1 << 1)
  186. #define DA9030_STATUS_EXTON (1 << 2)
  187. #define DA9030_STATUS_CHDET (1 << 3)
  188. #define DA9030_STATUS_TBAT (1 << 4)
  189. #define DA9030_STATUS_VBATMON (1 << 5)
  190. #define DA9030_STATUS_VBATMON_TXON (1 << 6)
  191. #define DA9030_STATUS_MCLKDET (1 << 7)
  192. #define DA9034_STATUS_ONKEY (1 << 0)
  193. #define DA9034_STATUS_EXTON (1 << 2)
  194. #define DA9034_STATUS_CHDET (1 << 3)
  195. #define DA9034_STATUS_TBAT (1 << 4)
  196. #define DA9034_STATUS_VBATMON (1 << 5)
  197. #define DA9034_STATUS_PEN_DOWN (1 << 6)
  198. #define DA9034_STATUS_MCLKDET (1 << 7)
  199. #define DA9034_STATUS_USB_DEV (1 << 8)
  200. #define DA9034_STATUS_HEADSET (1 << 9)
  201. #define DA9034_STATUS_HOOKSWITCH (1 << 10)
  202. #define DA9034_STATUS_REMCON (1 << 11)
  203. #define DA9034_STATUS_VBUS_VALID_4P55 (1 << 12)
  204. #define DA9034_STATUS_VBUS_VALID_3P8 (1 << 13)
  205. #define DA9034_STATUS_SESS_VALID_1P8 (1 << 14)
  206. #define DA9034_STATUS_SRP_READY (1 << 15)
  207. extern int da903x_query_status(struct device *dev, unsigned int status);
  208. /* NOTE: the functions below are not intended for use outside
  209. * of the DA903x sub-device drivers
  210. */
  211. extern int da903x_write(struct device *dev, int reg, uint8_t val);
  212. extern int da903x_writes(struct device *dev, int reg, int len, uint8_t *val);
  213. extern int da903x_read(struct device *dev, int reg, uint8_t *val);
  214. extern int da903x_reads(struct device *dev, int reg, int len, uint8_t *val);
  215. extern int da903x_update(struct device *dev, int reg, uint8_t val, uint8_t mask);
  216. extern int da903x_set_bits(struct device *dev, int reg, uint8_t bit_mask);
  217. extern int da903x_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
  218. #endif /* __LINUX_PMIC_DA903X_H */