stmpe.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * License Terms: GNU General Public License, version 2
  5. * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
  6. */
  7. #ifndef __LINUX_MFD_STMPE_H
  8. #define __LINUX_MFD_STMPE_H
  9. #include <linux/mutex.h>
  10. struct device;
  11. struct regulator;
  12. enum stmpe_block {
  13. STMPE_BLOCK_GPIO = 1 << 0,
  14. STMPE_BLOCK_KEYPAD = 1 << 1,
  15. STMPE_BLOCK_TOUCHSCREEN = 1 << 2,
  16. STMPE_BLOCK_ADC = 1 << 3,
  17. STMPE_BLOCK_PWM = 1 << 4,
  18. STMPE_BLOCK_ROTATOR = 1 << 5,
  19. };
  20. enum stmpe_partnum {
  21. STMPE610,
  22. STMPE801,
  23. STMPE811,
  24. STMPE1601,
  25. STMPE1801,
  26. STMPE2401,
  27. STMPE2403,
  28. STMPE_NBR_PARTS
  29. };
  30. /*
  31. * For registers whose locations differ on variants, the correct address is
  32. * obtained by indexing stmpe->regs with one of the following.
  33. */
  34. enum {
  35. STMPE_IDX_CHIP_ID,
  36. STMPE_IDX_ICR_LSB,
  37. STMPE_IDX_IER_LSB,
  38. STMPE_IDX_ISR_LSB,
  39. STMPE_IDX_ISR_MSB,
  40. STMPE_IDX_GPMR_LSB,
  41. STMPE_IDX_GPSR_LSB,
  42. STMPE_IDX_GPCR_LSB,
  43. STMPE_IDX_GPDR_LSB,
  44. STMPE_IDX_GPEDR_MSB,
  45. STMPE_IDX_GPRER_LSB,
  46. STMPE_IDX_GPFER_LSB,
  47. STMPE_IDX_GPPUR_LSB,
  48. STMPE_IDX_GPPDR_LSB,
  49. STMPE_IDX_GPAFR_U_MSB,
  50. STMPE_IDX_IEGPIOR_LSB,
  51. STMPE_IDX_ISGPIOR_LSB,
  52. STMPE_IDX_ISGPIOR_MSB,
  53. STMPE_IDX_MAX,
  54. };
  55. struct stmpe_variant_info;
  56. struct stmpe_client_info;
  57. /**
  58. * struct stmpe - STMPE MFD structure
  59. * @vcc: optional VCC regulator
  60. * @vio: optional VIO regulator
  61. * @lock: lock protecting I/O operations
  62. * @irq_lock: IRQ bus lock
  63. * @dev: device, mostly for dev_dbg()
  64. * @irq_domain: IRQ domain
  65. * @client: client - i2c or spi
  66. * @ci: client specific information
  67. * @partnum: part number
  68. * @variant: the detected STMPE model number
  69. * @regs: list of addresses of registers which are at different addresses on
  70. * different variants. Indexed by one of STMPE_IDX_*.
  71. * @irq: irq number for stmpe
  72. * @num_gpios: number of gpios, differs for variants
  73. * @ier: cache of IER registers for bus_lock
  74. * @oldier: cache of IER registers for bus_lock
  75. * @pdata: platform data
  76. */
  77. struct stmpe {
  78. struct regulator *vcc;
  79. struct regulator *vio;
  80. struct mutex lock;
  81. struct mutex irq_lock;
  82. struct device *dev;
  83. struct irq_domain *domain;
  84. void *client;
  85. struct stmpe_client_info *ci;
  86. enum stmpe_partnum partnum;
  87. struct stmpe_variant_info *variant;
  88. const u8 *regs;
  89. int irq;
  90. int num_gpios;
  91. u8 ier[2];
  92. u8 oldier[2];
  93. struct stmpe_platform_data *pdata;
  94. };
  95. extern int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 data);
  96. extern int stmpe_reg_read(struct stmpe *stmpe, u8 reg);
  97. extern int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length,
  98. u8 *values);
  99. extern int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length,
  100. const u8 *values);
  101. extern int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val);
  102. extern int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins,
  103. enum stmpe_block block);
  104. extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks);
  105. extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks);
  106. #define STMPE_GPIO_NOREQ_811_TOUCH (0xf0)
  107. /**
  108. * struct stmpe_ts_platform_data - stmpe811 touch screen controller platform
  109. * data
  110. * @sample_time: ADC converstion time in number of clock.
  111. * (0 -> 36 clocks, 1 -> 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks,
  112. * 4 -> 80 clocks, 5 -> 96 clocks, 6 -> 144 clocks),
  113. * recommended is 4.
  114. * @mod_12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC)
  115. * @ref_sel: ADC reference source
  116. * (0 -> internal reference, 1 -> external reference)
  117. * @adc_freq: ADC Clock speed
  118. * (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz)
  119. * @ave_ctrl: Sample average control
  120. * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples)
  121. * @touch_det_delay: Touch detect interrupt delay
  122. * (0 -> 10 us, 1 -> 50 us, 2 -> 100 us, 3 -> 500 us,
  123. * 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms)
  124. * recommended is 3
  125. * @settling: Panel driver settling time
  126. * (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3 -> 1 ms,
  127. * 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms)
  128. * recommended is 2
  129. * @fraction_z: Length of the fractional part in z
  130. * (fraction_z ([0..7]) = Count of the fractional part)
  131. * recommended is 7
  132. * @i_drive: current limit value of the touchscreen drivers
  133. * (0 -> 20 mA typical 35 mA max, 1 -> 50 mA typical 80 mA max)
  134. *
  135. * */
  136. struct stmpe_ts_platform_data {
  137. u8 sample_time;
  138. u8 mod_12b;
  139. u8 ref_sel;
  140. u8 adc_freq;
  141. u8 ave_ctrl;
  142. u8 touch_det_delay;
  143. u8 settling;
  144. u8 fraction_z;
  145. u8 i_drive;
  146. };
  147. /**
  148. * struct stmpe_platform_data - STMPE platform data
  149. * @id: device id to distinguish between multiple STMPEs on the same board
  150. * @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*)
  151. * @irq_trigger: IRQ trigger to use for the interrupt to the host
  152. * @autosleep: bool to enable/disable stmpe autosleep
  153. * @autosleep_timeout: inactivity timeout in milliseconds for autosleep
  154. * @irq_over_gpio: true if gpio is used to get irq
  155. * @irq_gpio: gpio number over which irq will be requested (significant only if
  156. * irq_over_gpio is true)
  157. * @ts: touchscreen-specific platform data
  158. */
  159. struct stmpe_platform_data {
  160. int id;
  161. unsigned int blocks;
  162. unsigned int irq_trigger;
  163. bool autosleep;
  164. bool irq_over_gpio;
  165. int irq_gpio;
  166. int autosleep_timeout;
  167. struct stmpe_ts_platform_data *ts;
  168. };
  169. #endif