mc13xxx.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. * Copyright 2009-2010 Pengutronix
  3. * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it under
  6. * the terms of the GNU General Public License version 2 as published by the
  7. * Free Software Foundation.
  8. */
  9. #ifndef __LINUX_MFD_MC13XXX_H
  10. #define __LINUX_MFD_MC13XXX_H
  11. #include <linux/interrupt.h>
  12. struct mc13xxx;
  13. void mc13xxx_lock(struct mc13xxx *mc13xxx);
  14. void mc13xxx_unlock(struct mc13xxx *mc13xxx);
  15. int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val);
  16. int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val);
  17. int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset,
  18. u32 mask, u32 val);
  19. int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq,
  20. irq_handler_t handler, const char *name, void *dev);
  21. int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev);
  22. int mc13xxx_irq_status(struct mc13xxx *mc13xxx, int irq,
  23. int *enabled, int *pending);
  24. int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
  25. int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
  26. unsigned int mode, unsigned int channel,
  27. u8 ato, bool atox, unsigned int *sample);
  28. /* Deprecated calls */
  29. static inline int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq)
  30. {
  31. return 0;
  32. }
  33. static inline int mc13xxx_irq_request_nounmask(struct mc13xxx *mc13xxx, int irq,
  34. irq_handler_t handler,
  35. const char *name, void *dev)
  36. {
  37. return mc13xxx_irq_request(mc13xxx, irq, handler, name, dev);
  38. }
  39. int mc13xxx_irq_mask(struct mc13xxx *mc13xxx, int irq);
  40. int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq);
  41. #define MC13783_AUDIO_RX0 36
  42. #define MC13783_AUDIO_RX1 37
  43. #define MC13783_AUDIO_TX 38
  44. #define MC13783_SSI_NETWORK 39
  45. #define MC13783_AUDIO_CODEC 40
  46. #define MC13783_AUDIO_DAC 41
  47. #define MC13XXX_IRQ_ADCDONE 0
  48. #define MC13XXX_IRQ_ADCBISDONE 1
  49. #define MC13XXX_IRQ_TS 2
  50. #define MC13XXX_IRQ_CHGDET 6
  51. #define MC13XXX_IRQ_CHGREV 8
  52. #define MC13XXX_IRQ_CHGSHORT 9
  53. #define MC13XXX_IRQ_CCCV 10
  54. #define MC13XXX_IRQ_CHGCURR 11
  55. #define MC13XXX_IRQ_BPON 12
  56. #define MC13XXX_IRQ_LOBATL 13
  57. #define MC13XXX_IRQ_LOBATH 14
  58. #define MC13XXX_IRQ_1HZ 24
  59. #define MC13XXX_IRQ_TODA 25
  60. #define MC13XXX_IRQ_SYSRST 30
  61. #define MC13XXX_IRQ_RTCRST 31
  62. #define MC13XXX_IRQ_PC 32
  63. #define MC13XXX_IRQ_WARM 33
  64. #define MC13XXX_IRQ_MEMHLD 34
  65. #define MC13XXX_IRQ_THWARNL 36
  66. #define MC13XXX_IRQ_THWARNH 37
  67. #define MC13XXX_IRQ_CLK 38
  68. struct regulator_init_data;
  69. struct mc13xxx_regulator_init_data {
  70. int id;
  71. struct regulator_init_data *init_data;
  72. struct device_node *node;
  73. };
  74. struct mc13xxx_regulator_platform_data {
  75. int num_regulators;
  76. struct mc13xxx_regulator_init_data *regulators;
  77. };
  78. enum {
  79. /* MC13783 LED IDs */
  80. MC13783_LED_MD,
  81. MC13783_LED_AD,
  82. MC13783_LED_KP,
  83. MC13783_LED_R1,
  84. MC13783_LED_G1,
  85. MC13783_LED_B1,
  86. MC13783_LED_R2,
  87. MC13783_LED_G2,
  88. MC13783_LED_B2,
  89. MC13783_LED_R3,
  90. MC13783_LED_G3,
  91. MC13783_LED_B3,
  92. /* MC13892 LED IDs */
  93. MC13892_LED_MD,
  94. MC13892_LED_AD,
  95. MC13892_LED_KP,
  96. MC13892_LED_R,
  97. MC13892_LED_G,
  98. MC13892_LED_B,
  99. /* MC34708 LED IDs */
  100. MC34708_LED_R,
  101. MC34708_LED_G,
  102. };
  103. struct mc13xxx_led_platform_data {
  104. int id;
  105. const char *name;
  106. const char *default_trigger;
  107. };
  108. #define MAX_LED_CONTROL_REGS 6
  109. /* MC13783 LED Control 0 */
  110. #define MC13783_LED_C0_ENABLE (1 << 0)
  111. #define MC13783_LED_C0_TRIODE_MD (1 << 7)
  112. #define MC13783_LED_C0_TRIODE_AD (1 << 8)
  113. #define MC13783_LED_C0_TRIODE_KP (1 << 9)
  114. #define MC13783_LED_C0_BOOST (1 << 10)
  115. #define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11)
  116. #define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14)
  117. /* MC13783 LED Control 1 */
  118. #define MC13783_LED_C1_TC1HALF (1 << 18)
  119. #define MC13783_LED_C1_SLEWLIM (1 << 23)
  120. /* MC13783 LED Control 2 */
  121. #define MC13783_LED_C2_CURRENT_MD(x) (((x) & 0x7) << 0)
  122. #define MC13783_LED_C2_CURRENT_AD(x) (((x) & 0x7) << 3)
  123. #define MC13783_LED_C2_CURRENT_KP(x) (((x) & 0x7) << 6)
  124. #define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21)
  125. #define MC13783_LED_C2_SLEWLIM (1 << 23)
  126. /* MC13783 LED Control 3 */
  127. #define MC13783_LED_C3_CURRENT_R1(x) (((x) & 0x3) << 0)
  128. #define MC13783_LED_C3_CURRENT_G1(x) (((x) & 0x3) << 2)
  129. #define MC13783_LED_C3_CURRENT_B1(x) (((x) & 0x3) << 4)
  130. #define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21)
  131. #define MC13783_LED_C3_TRIODE_TC1 (1 << 23)
  132. /* MC13783 LED Control 4 */
  133. #define MC13783_LED_C4_CURRENT_R2(x) (((x) & 0x3) << 0)
  134. #define MC13783_LED_C4_CURRENT_G2(x) (((x) & 0x3) << 2)
  135. #define MC13783_LED_C4_CURRENT_B2(x) (((x) & 0x3) << 4)
  136. #define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21)
  137. #define MC13783_LED_C4_TRIODE_TC2 (1 << 23)
  138. /* MC13783 LED Control 5 */
  139. #define MC13783_LED_C5_CURRENT_R3(x) (((x) & 0x3) << 0)
  140. #define MC13783_LED_C5_CURRENT_G3(x) (((x) & 0x3) << 2)
  141. #define MC13783_LED_C5_CURRENT_B3(x) (((x) & 0x3) << 4)
  142. #define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21)
  143. #define MC13783_LED_C5_TRIODE_TC3 (1 << 23)
  144. /* MC13892 LED Control 0 */
  145. #define MC13892_LED_C0_CURRENT_MD(x) (((x) & 0x7) << 9)
  146. #define MC13892_LED_C0_CURRENT_AD(x) (((x) & 0x7) << 21)
  147. /* MC13892 LED Control 1 */
  148. #define MC13892_LED_C1_CURRENT_KP(x) (((x) & 0x7) << 9)
  149. /* MC13892 LED Control 2 */
  150. #define MC13892_LED_C2_CURRENT_R(x) (((x) & 0x7) << 9)
  151. #define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21)
  152. /* MC13892 LED Control 3 */
  153. #define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9)
  154. /* MC34708 LED Control 0 */
  155. #define MC34708_LED_C0_CURRENT_R(x) (((x) & 0x3) << 9)
  156. #define MC34708_LED_C0_CURRENT_G(x) (((x) & 0x3) << 21)
  157. struct mc13xxx_leds_platform_data {
  158. struct mc13xxx_led_platform_data *led;
  159. int num_leds;
  160. u32 led_control[MAX_LED_CONTROL_REGS];
  161. };
  162. #define MC13783_BUTTON_DBNC_0MS 0
  163. #define MC13783_BUTTON_DBNC_30MS 1
  164. #define MC13783_BUTTON_DBNC_150MS 2
  165. #define MC13783_BUTTON_DBNC_750MS 3
  166. #define MC13783_BUTTON_ENABLE (1 << 2)
  167. #define MC13783_BUTTON_POL_INVERT (1 << 3)
  168. #define MC13783_BUTTON_RESET_EN (1 << 4)
  169. struct mc13xxx_buttons_platform_data {
  170. int b1on_flags;
  171. unsigned short b1on_key;
  172. int b2on_flags;
  173. unsigned short b2on_key;
  174. int b3on_flags;
  175. unsigned short b3on_key;
  176. };
  177. #define MC13783_TS_ATO_FIRST false
  178. #define MC13783_TS_ATO_EACH true
  179. struct mc13xxx_ts_platform_data {
  180. /* Delay between Touchscreen polarization and ADC Conversion.
  181. * Given in clock ticks of a 32 kHz clock which gives a granularity of
  182. * about 30.5ms */
  183. u8 ato;
  184. /* Use the ATO delay only for the first conversion or for each one */
  185. bool atox;
  186. };
  187. enum mc13783_ssi_port {
  188. MC13783_SSI1_PORT,
  189. MC13783_SSI2_PORT,
  190. };
  191. struct mc13xxx_codec_platform_data {
  192. enum mc13783_ssi_port adc_ssi_port;
  193. enum mc13783_ssi_port dac_ssi_port;
  194. };
  195. #define MC13XXX_USE_TOUCHSCREEN (1 << 0)
  196. #define MC13XXX_USE_CODEC (1 << 1)
  197. #define MC13XXX_USE_ADC (1 << 2)
  198. #define MC13XXX_USE_RTC (1 << 3)
  199. struct mc13xxx_platform_data {
  200. unsigned int flags;
  201. struct mc13xxx_regulator_platform_data regulators;
  202. struct mc13xxx_leds_platform_data *leds;
  203. struct mc13xxx_buttons_platform_data *buttons;
  204. struct mc13xxx_ts_platform_data touch;
  205. struct mc13xxx_codec_platform_data *codec;
  206. };
  207. #define MC13XXX_ADC_MODE_TS 1
  208. #define MC13XXX_ADC_MODE_SINGLE_CHAN 2
  209. #define MC13XXX_ADC_MODE_MULT_CHAN 3
  210. #define MC13XXX_ADC0 43
  211. #define MC13XXX_ADC0_LICELLCON (1 << 0)
  212. #define MC13XXX_ADC0_CHRGICON (1 << 1)
  213. #define MC13XXX_ADC0_BATICON (1 << 2)
  214. #define MC13XXX_ADC0_ADREFEN (1 << 10)
  215. #define MC13XXX_ADC0_TSMOD0 (1 << 12)
  216. #define MC13XXX_ADC0_TSMOD1 (1 << 13)
  217. #define MC13XXX_ADC0_TSMOD2 (1 << 14)
  218. #define MC13XXX_ADC0_ADINC1 (1 << 16)
  219. #define MC13XXX_ADC0_ADINC2 (1 << 17)
  220. #define MC13XXX_ADC0_TSMOD_MASK (MC13XXX_ADC0_TSMOD0 | \
  221. MC13XXX_ADC0_TSMOD1 | \
  222. MC13XXX_ADC0_TSMOD2)
  223. #define MC13XXX_ADC0_CONFIG_MASK (MC13XXX_ADC0_TSMOD_MASK | \
  224. MC13XXX_ADC0_LICELLCON | \
  225. MC13XXX_ADC0_CHRGICON | \
  226. MC13XXX_ADC0_BATICON)
  227. #endif /* ifndef __LINUX_MFD_MC13XXX_H */