stmpe.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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 __STMPE_H
  8. #define __STMPE_H
  9. #include <linux/device.h>
  10. #include <linux/mfd/core.h>
  11. #include <linux/mfd/stmpe.h>
  12. #include <linux/printk.h>
  13. #include <linux/types.h>
  14. extern const struct dev_pm_ops stmpe_dev_pm_ops;
  15. #ifdef STMPE_DUMP_BYTES
  16. static inline void stmpe_dump_bytes(const char *str, const void *buf,
  17. size_t len)
  18. {
  19. print_hex_dump_bytes(str, DUMP_PREFIX_OFFSET, buf, len);
  20. }
  21. #else
  22. static inline void stmpe_dump_bytes(const char *str, const void *buf,
  23. size_t len)
  24. {
  25. }
  26. #endif
  27. /**
  28. * struct stmpe_variant_block - information about block
  29. * @cell: base mfd cell
  30. * @irq: interrupt number to be added to each IORESOURCE_IRQ
  31. * in the cell
  32. * @block: block id; used for identification with platform data and for
  33. * enable and altfunc callbacks
  34. */
  35. struct stmpe_variant_block {
  36. const struct mfd_cell *cell;
  37. int irq;
  38. enum stmpe_block block;
  39. };
  40. /**
  41. * struct stmpe_variant_info - variant-specific information
  42. * @name: part name
  43. * @id_val: content of CHIPID register
  44. * @id_mask: bits valid in CHIPID register for comparison with id_val
  45. * @num_gpios: number of GPIOS
  46. * @af_bits: number of bits used to specify the alternate function
  47. * @regs: variant specific registers.
  48. * @blocks: list of blocks present on this device
  49. * @num_blocks: number of blocks present on this device
  50. * @num_irqs: number of internal IRQs available on this device
  51. * @enable: callback to enable the specified blocks.
  52. * Called with the I/O lock held.
  53. * @get_altfunc: callback to get the alternate function number for the
  54. * specific block
  55. * @enable_autosleep: callback to configure autosleep with specified timeout
  56. */
  57. struct stmpe_variant_info {
  58. const char *name;
  59. u16 id_val;
  60. u16 id_mask;
  61. int num_gpios;
  62. int af_bits;
  63. const u8 *regs;
  64. struct stmpe_variant_block *blocks;
  65. int num_blocks;
  66. int num_irqs;
  67. int (*enable)(struct stmpe *stmpe, unsigned int blocks, bool enable);
  68. int (*get_altfunc)(struct stmpe *stmpe, enum stmpe_block block);
  69. int (*enable_autosleep)(struct stmpe *stmpe, int autosleep_timeout);
  70. };
  71. /**
  72. * struct stmpe_client_info - i2c or spi specific routines/info
  73. * @data: client specific data
  74. * @read_byte: read single byte
  75. * @write_byte: write single byte
  76. * @read_block: read block or multiple bytes
  77. * @write_block: write block or multiple bytes
  78. * @init: client init routine, called during probe
  79. */
  80. struct stmpe_client_info {
  81. void *data;
  82. int irq;
  83. void *client;
  84. struct device *dev;
  85. int (*read_byte)(struct stmpe *stmpe, u8 reg);
  86. int (*write_byte)(struct stmpe *stmpe, u8 reg, u8 val);
  87. int (*read_block)(struct stmpe *stmpe, u8 reg, u8 len, u8 *values);
  88. int (*write_block)(struct stmpe *stmpe, u8 reg, u8 len,
  89. const u8 *values);
  90. void (*init)(struct stmpe *stmpe);
  91. };
  92. int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum);
  93. int stmpe_remove(struct stmpe *stmpe);
  94. #define STMPE_ICR_LSB_HIGH (1 << 2)
  95. #define STMPE_ICR_LSB_EDGE (1 << 1)
  96. #define STMPE_ICR_LSB_GIM (1 << 0)
  97. /*
  98. * STMPE801
  99. */
  100. #define STMPE801_ID 0x0108
  101. #define STMPE801_NR_INTERNAL_IRQS 1
  102. #define STMPE801_REG_CHIP_ID 0x00
  103. #define STMPE801_REG_VERSION_ID 0x02
  104. #define STMPE801_REG_SYS_CTRL 0x04
  105. #define STMPE801_REG_GPIO_INT_EN 0x08
  106. #define STMPE801_REG_GPIO_INT_STA 0x09
  107. #define STMPE801_REG_GPIO_MP_STA 0x10
  108. #define STMPE801_REG_GPIO_SET_PIN 0x11
  109. #define STMPE801_REG_GPIO_DIR 0x12
  110. #define STMPE801_REG_SYS_CTRL_RESET (1 << 7)
  111. #define STMPE801_REG_SYS_CTRL_INT_EN (1 << 2)
  112. #define STMPE801_REG_SYS_CTRL_INT_HI (1 << 0)
  113. /*
  114. * STMPE811
  115. */
  116. #define STMPE811_IRQ_TOUCH_DET 0
  117. #define STMPE811_IRQ_FIFO_TH 1
  118. #define STMPE811_IRQ_FIFO_OFLOW 2
  119. #define STMPE811_IRQ_FIFO_FULL 3
  120. #define STMPE811_IRQ_FIFO_EMPTY 4
  121. #define STMPE811_IRQ_TEMP_SENS 5
  122. #define STMPE811_IRQ_ADC 6
  123. #define STMPE811_IRQ_GPIOC 7
  124. #define STMPE811_NR_INTERNAL_IRQS 8
  125. #define STMPE811_REG_CHIP_ID 0x00
  126. #define STMPE811_REG_SYS_CTRL2 0x04
  127. #define STMPE811_REG_SPI_CFG 0x08
  128. #define STMPE811_REG_INT_CTRL 0x09
  129. #define STMPE811_REG_INT_EN 0x0A
  130. #define STMPE811_REG_INT_STA 0x0B
  131. #define STMPE811_REG_GPIO_INT_EN 0x0C
  132. #define STMPE811_REG_GPIO_INT_STA 0x0D
  133. #define STMPE811_REG_GPIO_SET_PIN 0x10
  134. #define STMPE811_REG_GPIO_CLR_PIN 0x11
  135. #define STMPE811_REG_GPIO_MP_STA 0x12
  136. #define STMPE811_REG_GPIO_DIR 0x13
  137. #define STMPE811_REG_GPIO_ED 0x14
  138. #define STMPE811_REG_GPIO_RE 0x15
  139. #define STMPE811_REG_GPIO_FE 0x16
  140. #define STMPE811_REG_GPIO_AF 0x17
  141. #define STMPE811_SYS_CTRL2_ADC_OFF (1 << 0)
  142. #define STMPE811_SYS_CTRL2_TSC_OFF (1 << 1)
  143. #define STMPE811_SYS_CTRL2_GPIO_OFF (1 << 2)
  144. #define STMPE811_SYS_CTRL2_TS_OFF (1 << 3)
  145. /*
  146. * STMPE1601
  147. */
  148. #define STMPE1601_IRQ_GPIOC 8
  149. #define STMPE1601_IRQ_PWM3 7
  150. #define STMPE1601_IRQ_PWM2 6
  151. #define STMPE1601_IRQ_PWM1 5
  152. #define STMPE1601_IRQ_PWM0 4
  153. #define STMPE1601_IRQ_KEYPAD_OVER 2
  154. #define STMPE1601_IRQ_KEYPAD 1
  155. #define STMPE1601_IRQ_WAKEUP 0
  156. #define STMPE1601_NR_INTERNAL_IRQS 9
  157. #define STMPE1601_REG_SYS_CTRL 0x02
  158. #define STMPE1601_REG_SYS_CTRL2 0x03
  159. #define STMPE1601_REG_ICR_LSB 0x11
  160. #define STMPE1601_REG_IER_LSB 0x13
  161. #define STMPE1601_REG_ISR_MSB 0x14
  162. #define STMPE1601_REG_CHIP_ID 0x80
  163. #define STMPE1601_REG_INT_EN_GPIO_MASK_LSB 0x17
  164. #define STMPE1601_REG_INT_STA_GPIO_MSB 0x18
  165. #define STMPE1601_REG_GPIO_MP_LSB 0x87
  166. #define STMPE1601_REG_GPIO_SET_LSB 0x83
  167. #define STMPE1601_REG_GPIO_CLR_LSB 0x85
  168. #define STMPE1601_REG_GPIO_SET_DIR_LSB 0x89
  169. #define STMPE1601_REG_GPIO_ED_MSB 0x8A
  170. #define STMPE1601_REG_GPIO_RE_LSB 0x8D
  171. #define STMPE1601_REG_GPIO_FE_LSB 0x8F
  172. #define STMPE1601_REG_GPIO_PU_LSB 0x91
  173. #define STMPE1601_REG_GPIO_AF_U_MSB 0x92
  174. #define STMPE1601_SYS_CTRL_ENABLE_GPIO (1 << 3)
  175. #define STMPE1601_SYS_CTRL_ENABLE_KPC (1 << 1)
  176. #define STMPE1601_SYS_CTRL_ENABLE_SPWM (1 << 0)
  177. /* The 1601/2403 share the same masks */
  178. #define STMPE1601_AUTOSLEEP_TIMEOUT_MASK (0x7)
  179. #define STPME1601_AUTOSLEEP_ENABLE (1 << 3)
  180. /*
  181. * STMPE1801
  182. */
  183. #define STMPE1801_ID 0xc110
  184. #define STMPE1801_NR_INTERNAL_IRQS 5
  185. #define STMPE1801_IRQ_KEYPAD_COMBI 4
  186. #define STMPE1801_IRQ_GPIOC 3
  187. #define STMPE1801_IRQ_KEYPAD_OVER 2
  188. #define STMPE1801_IRQ_KEYPAD 1
  189. #define STMPE1801_IRQ_WAKEUP 0
  190. #define STMPE1801_REG_CHIP_ID 0x00
  191. #define STMPE1801_REG_SYS_CTRL 0x02
  192. #define STMPE1801_REG_INT_CTRL_LOW 0x04
  193. #define STMPE1801_REG_INT_EN_MASK_LOW 0x06
  194. #define STMPE1801_REG_INT_STA_LOW 0x08
  195. #define STMPE1801_REG_INT_EN_GPIO_MASK_LOW 0x0A
  196. #define STMPE1801_REG_INT_EN_GPIO_MASK_MID 0x0B
  197. #define STMPE1801_REG_INT_EN_GPIO_MASK_HIGH 0x0C
  198. #define STMPE1801_REG_INT_STA_GPIO_LOW 0x0D
  199. #define STMPE1801_REG_INT_STA_GPIO_MID 0x0E
  200. #define STMPE1801_REG_INT_STA_GPIO_HIGH 0x0F
  201. #define STMPE1801_REG_GPIO_SET_LOW 0x10
  202. #define STMPE1801_REG_GPIO_SET_MID 0x11
  203. #define STMPE1801_REG_GPIO_SET_HIGH 0x12
  204. #define STMPE1801_REG_GPIO_CLR_LOW 0x13
  205. #define STMPE1801_REG_GPIO_CLR_MID 0x14
  206. #define STMPE1801_REG_GPIO_CLR_HIGH 0x15
  207. #define STMPE1801_REG_GPIO_MP_LOW 0x16
  208. #define STMPE1801_REG_GPIO_MP_MID 0x17
  209. #define STMPE1801_REG_GPIO_MP_HIGH 0x18
  210. #define STMPE1801_REG_GPIO_SET_DIR_LOW 0x19
  211. #define STMPE1801_REG_GPIO_SET_DIR_MID 0x1A
  212. #define STMPE1801_REG_GPIO_SET_DIR_HIGH 0x1B
  213. #define STMPE1801_REG_GPIO_RE_LOW 0x1C
  214. #define STMPE1801_REG_GPIO_RE_MID 0x1D
  215. #define STMPE1801_REG_GPIO_RE_HIGH 0x1E
  216. #define STMPE1801_REG_GPIO_FE_LOW 0x1F
  217. #define STMPE1801_REG_GPIO_FE_MID 0x20
  218. #define STMPE1801_REG_GPIO_FE_HIGH 0x21
  219. #define STMPE1801_REG_GPIO_PULL_UP_LOW 0x22
  220. #define STMPE1801_REG_GPIO_PULL_UP_MID 0x23
  221. #define STMPE1801_REG_GPIO_PULL_UP_HIGH 0x24
  222. #define STMPE1801_MSK_SYS_CTRL_RESET (1 << 7)
  223. #define STMPE1801_MSK_INT_EN_KPC (1 << 1)
  224. #define STMPE1801_MSK_INT_EN_GPIO (1 << 3)
  225. /*
  226. * STMPE24xx
  227. */
  228. #define STMPE24XX_IRQ_GPIOC 8
  229. #define STMPE24XX_IRQ_PWM2 7
  230. #define STMPE24XX_IRQ_PWM1 6
  231. #define STMPE24XX_IRQ_PWM0 5
  232. #define STMPE24XX_IRQ_ROT_OVER 4
  233. #define STMPE24XX_IRQ_ROT 3
  234. #define STMPE24XX_IRQ_KEYPAD_OVER 2
  235. #define STMPE24XX_IRQ_KEYPAD 1
  236. #define STMPE24XX_IRQ_WAKEUP 0
  237. #define STMPE24XX_NR_INTERNAL_IRQS 9
  238. #define STMPE24XX_REG_SYS_CTRL 0x02
  239. #define STMPE24XX_REG_ICR_LSB 0x11
  240. #define STMPE24XX_REG_IER_LSB 0x13
  241. #define STMPE24XX_REG_ISR_MSB 0x14
  242. #define STMPE24XX_REG_CHIP_ID 0x80
  243. #define STMPE24XX_REG_IEGPIOR_LSB 0x18
  244. #define STMPE24XX_REG_ISGPIOR_MSB 0x19
  245. #define STMPE24XX_REG_GPMR_LSB 0xA4
  246. #define STMPE24XX_REG_GPSR_LSB 0x85
  247. #define STMPE24XX_REG_GPCR_LSB 0x88
  248. #define STMPE24XX_REG_GPDR_LSB 0x8B
  249. #define STMPE24XX_REG_GPEDR_MSB 0x8C
  250. #define STMPE24XX_REG_GPRER_LSB 0x91
  251. #define STMPE24XX_REG_GPFER_LSB 0x94
  252. #define STMPE24XX_REG_GPPUR_LSB 0x97
  253. #define STMPE24XX_REG_GPPDR_LSB 0x9a
  254. #define STMPE24XX_REG_GPAFR_U_MSB 0x9B
  255. #define STMPE24XX_SYS_CTRL_ENABLE_GPIO (1 << 3)
  256. #define STMPE24XX_SYSCON_ENABLE_PWM (1 << 2)
  257. #define STMPE24XX_SYS_CTRL_ENABLE_KPC (1 << 1)
  258. #define STMPE24XX_SYSCON_ENABLE_ROT (1 << 0)
  259. #endif