mc13xxx.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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_get_flags(struct mc13xxx *mc13xxx);
  20. int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq,
  21. irq_handler_t handler, const char *name, void *dev);
  22. int mc13xxx_irq_request_nounmask(struct mc13xxx *mc13xxx, int irq,
  23. irq_handler_t handler, const char *name, void *dev);
  24. int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev);
  25. int mc13xxx_irq_mask(struct mc13xxx *mc13xxx, int irq);
  26. int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq);
  27. int mc13xxx_irq_status(struct mc13xxx *mc13xxx, int irq,
  28. int *enabled, int *pending);
  29. int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq);
  30. int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
  31. int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
  32. unsigned int mode, unsigned int channel,
  33. u8 ato, bool atox, unsigned int *sample);
  34. #define MC13783_AUDIO_RX0 36
  35. #define MC13783_AUDIO_RX1 37
  36. #define MC13783_AUDIO_TX 38
  37. #define MC13783_SSI_NETWORK 39
  38. #define MC13783_AUDIO_CODEC 40
  39. #define MC13783_AUDIO_DAC 41
  40. #define MC13XXX_IRQ_ADCDONE 0
  41. #define MC13XXX_IRQ_ADCBISDONE 1
  42. #define MC13XXX_IRQ_TS 2
  43. #define MC13XXX_IRQ_CHGDET 6
  44. #define MC13XXX_IRQ_CHGREV 8
  45. #define MC13XXX_IRQ_CHGSHORT 9
  46. #define MC13XXX_IRQ_CCCV 10
  47. #define MC13XXX_IRQ_CHGCURR 11
  48. #define MC13XXX_IRQ_BPON 12
  49. #define MC13XXX_IRQ_LOBATL 13
  50. #define MC13XXX_IRQ_LOBATH 14
  51. #define MC13XXX_IRQ_1HZ 24
  52. #define MC13XXX_IRQ_TODA 25
  53. #define MC13XXX_IRQ_SYSRST 30
  54. #define MC13XXX_IRQ_RTCRST 31
  55. #define MC13XXX_IRQ_PC 32
  56. #define MC13XXX_IRQ_WARM 33
  57. #define MC13XXX_IRQ_MEMHLD 34
  58. #define MC13XXX_IRQ_THWARNL 36
  59. #define MC13XXX_IRQ_THWARNH 37
  60. #define MC13XXX_IRQ_CLK 38
  61. #define MC13XXX_NUM_IRQ 46
  62. struct regulator_init_data;
  63. struct mc13xxx_regulator_init_data {
  64. int id;
  65. struct regulator_init_data *init_data;
  66. struct device_node *node;
  67. };
  68. struct mc13xxx_regulator_platform_data {
  69. int num_regulators;
  70. struct mc13xxx_regulator_init_data *regulators;
  71. };
  72. enum {
  73. /* MC13783 LED IDs */
  74. MC13783_LED_MD,
  75. MC13783_LED_AD,
  76. MC13783_LED_KP,
  77. MC13783_LED_R1,
  78. MC13783_LED_G1,
  79. MC13783_LED_B1,
  80. MC13783_LED_R2,
  81. MC13783_LED_G2,
  82. MC13783_LED_B2,
  83. MC13783_LED_R3,
  84. MC13783_LED_G3,
  85. MC13783_LED_B3,
  86. /* MC13892 LED IDs */
  87. MC13892_LED_MD,
  88. MC13892_LED_AD,
  89. MC13892_LED_KP,
  90. MC13892_LED_R,
  91. MC13892_LED_G,
  92. MC13892_LED_B,
  93. };
  94. struct mc13xxx_led_platform_data {
  95. int id;
  96. const char *name;
  97. const char *default_trigger;
  98. /* Three or two bits current selection depending on the led */
  99. char max_current;
  100. };
  101. #define MAX_LED_CONTROL_REGS 6
  102. struct mc13xxx_leds_platform_data {
  103. struct mc13xxx_led_platform_data *led;
  104. int num_leds;
  105. /* LED Control 0 */
  106. #define MC13783_LED_C0_ENABLE (1 << 0)
  107. #define MC13783_LED_C0_TRIODE_MD (1 << 7)
  108. #define MC13783_LED_C0_TRIODE_AD (1 << 8)
  109. #define MC13783_LED_C0_TRIODE_KP (1 << 9)
  110. #define MC13783_LED_C0_BOOST (1 << 10)
  111. #define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11)
  112. #define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14)
  113. /* LED Control 1 */
  114. #define MC13783_LED_C1_TC1HALF (1 << 18)
  115. #define MC13783_LED_C1_SLEWLIM (1 << 23)
  116. /* LED Control 2 */
  117. #define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21)
  118. #define MC13783_LED_C2_SLEWLIM (1 << 23)
  119. /* LED Control 3 */
  120. #define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21)
  121. #define MC13783_LED_C3_TRIODE_TC1 (1 << 23)
  122. /* LED Control 4 */
  123. #define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21)
  124. #define MC13783_LED_C4_TRIODE_TC2 (1 << 23)
  125. /* LED Control 5 */
  126. #define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21)
  127. #define MC13783_LED_C5_TRIODE_TC3 (1 << 23)
  128. u32 led_control[MAX_LED_CONTROL_REGS];
  129. };
  130. struct mc13xxx_buttons_platform_data {
  131. #define MC13783_BUTTON_DBNC_0MS 0
  132. #define MC13783_BUTTON_DBNC_30MS 1
  133. #define MC13783_BUTTON_DBNC_150MS 2
  134. #define MC13783_BUTTON_DBNC_750MS 3
  135. #define MC13783_BUTTON_ENABLE (1 << 2)
  136. #define MC13783_BUTTON_POL_INVERT (1 << 3)
  137. #define MC13783_BUTTON_RESET_EN (1 << 4)
  138. int b1on_flags;
  139. unsigned short b1on_key;
  140. int b2on_flags;
  141. unsigned short b2on_key;
  142. int b3on_flags;
  143. unsigned short b3on_key;
  144. };
  145. struct mc13xxx_ts_platform_data {
  146. /* Delay between Touchscreen polarization and ADC Conversion.
  147. * Given in clock ticks of a 32 kHz clock which gives a granularity of
  148. * about 30.5ms */
  149. u8 ato;
  150. #define MC13783_TS_ATO_FIRST false
  151. #define MC13783_TS_ATO_EACH true
  152. /* Use the ATO delay only for the first conversion or for each one */
  153. bool atox;
  154. };
  155. enum mc13783_ssi_port {
  156. MC13783_SSI1_PORT,
  157. MC13783_SSI2_PORT,
  158. };
  159. struct mc13xxx_codec_platform_data {
  160. enum mc13783_ssi_port adc_ssi_port;
  161. enum mc13783_ssi_port dac_ssi_port;
  162. };
  163. struct mc13xxx_platform_data {
  164. #define MC13XXX_USE_TOUCHSCREEN (1 << 0)
  165. #define MC13XXX_USE_CODEC (1 << 1)
  166. #define MC13XXX_USE_ADC (1 << 2)
  167. #define MC13XXX_USE_RTC (1 << 3)
  168. unsigned int flags;
  169. struct mc13xxx_regulator_platform_data regulators;
  170. struct mc13xxx_leds_platform_data *leds;
  171. struct mc13xxx_buttons_platform_data *buttons;
  172. struct mc13xxx_ts_platform_data touch;
  173. struct mc13xxx_codec_platform_data *codec;
  174. };
  175. #define MC13XXX_ADC_MODE_TS 1
  176. #define MC13XXX_ADC_MODE_SINGLE_CHAN 2
  177. #define MC13XXX_ADC_MODE_MULT_CHAN 3
  178. #define MC13XXX_ADC0 43
  179. #define MC13XXX_ADC0_LICELLCON (1 << 0)
  180. #define MC13XXX_ADC0_CHRGICON (1 << 1)
  181. #define MC13XXX_ADC0_BATICON (1 << 2)
  182. #define MC13XXX_ADC0_ADREFEN (1 << 10)
  183. #define MC13XXX_ADC0_TSMOD0 (1 << 12)
  184. #define MC13XXX_ADC0_TSMOD1 (1 << 13)
  185. #define MC13XXX_ADC0_TSMOD2 (1 << 14)
  186. #define MC13XXX_ADC0_ADINC1 (1 << 16)
  187. #define MC13XXX_ADC0_ADINC2 (1 << 17)
  188. #define MC13XXX_ADC0_TSMOD_MASK (MC13XXX_ADC0_TSMOD0 | \
  189. MC13XXX_ADC0_TSMOD1 | \
  190. MC13XXX_ADC0_TSMOD2)
  191. #define MC13XXX_ADC0_CONFIG_MASK (MC13XXX_ADC0_TSMOD_MASK | \
  192. MC13XXX_ADC0_LICELLCON | \
  193. MC13XXX_ADC0_CHRGICON | \
  194. MC13XXX_ADC0_BATICON)
  195. #endif /* ifndef __LINUX_MFD_MC13XXX_H */