stmpe.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. #ifdef STMPE_DUMP_BYTES
  10. static inline void stmpe_dump_bytes(const char *str, const void *buf,
  11. size_t len)
  12. {
  13. print_hex_dump_bytes(str, DUMP_PREFIX_OFFSET, buf, len);
  14. }
  15. #else
  16. static inline void stmpe_dump_bytes(const char *str, const void *buf,
  17. size_t len)
  18. {
  19. }
  20. #endif
  21. /**
  22. * struct stmpe_variant_block - information about block
  23. * @cell: base mfd cell
  24. * @irq: interrupt number to be added to each IORESOURCE_IRQ
  25. * in the cell
  26. * @block: block id; used for identification with platform data and for
  27. * enable and altfunc callbacks
  28. */
  29. struct stmpe_variant_block {
  30. struct mfd_cell *cell;
  31. int irq;
  32. enum stmpe_block block;
  33. };
  34. /**
  35. * struct stmpe_variant_info - variant-specific information
  36. * @name: part name
  37. * @id_val: content of CHIPID register
  38. * @id_mask: bits valid in CHIPID register for comparison with id_val
  39. * @num_gpios: number of GPIOS
  40. * @af_bits: number of bits used to specify the alternate function
  41. * @regs: variant specific registers.
  42. * @blocks: list of blocks present on this device
  43. * @num_blocks: number of blocks present on this device
  44. * @num_irqs: number of internal IRQs available on this device
  45. * @enable: callback to enable the specified blocks.
  46. * Called with the I/O lock held.
  47. * @get_altfunc: callback to get the alternate function number for the
  48. * specific block
  49. * @enable_autosleep: callback to configure autosleep with specified timeout
  50. */
  51. struct stmpe_variant_info {
  52. const char *name;
  53. u16 id_val;
  54. u16 id_mask;
  55. int num_gpios;
  56. int af_bits;
  57. const u8 *regs;
  58. struct stmpe_variant_block *blocks;
  59. int num_blocks;
  60. int num_irqs;
  61. int (*enable)(struct stmpe *stmpe, unsigned int blocks, bool enable);
  62. int (*get_altfunc)(struct stmpe *stmpe, enum stmpe_block block);
  63. int (*enable_autosleep)(struct stmpe *stmpe, int autosleep_timeout);
  64. };
  65. #define STMPE_ICR_LSB_HIGH (1 << 2)
  66. #define STMPE_ICR_LSB_EDGE (1 << 1)
  67. #define STMPE_ICR_LSB_GIM (1 << 0)
  68. /*
  69. * STMPE811
  70. */
  71. #define STMPE811_IRQ_TOUCH_DET 0
  72. #define STMPE811_IRQ_FIFO_TH 1
  73. #define STMPE811_IRQ_FIFO_OFLOW 2
  74. #define STMPE811_IRQ_FIFO_FULL 3
  75. #define STMPE811_IRQ_FIFO_EMPTY 4
  76. #define STMPE811_IRQ_TEMP_SENS 5
  77. #define STMPE811_IRQ_ADC 6
  78. #define STMPE811_IRQ_GPIOC 7
  79. #define STMPE811_NR_INTERNAL_IRQS 8
  80. #define STMPE811_REG_CHIP_ID 0x00
  81. #define STMPE811_REG_SYS_CTRL2 0x04
  82. #define STMPE811_REG_INT_CTRL 0x09
  83. #define STMPE811_REG_INT_EN 0x0A
  84. #define STMPE811_REG_INT_STA 0x0B
  85. #define STMPE811_REG_GPIO_INT_EN 0x0C
  86. #define STMPE811_REG_GPIO_INT_STA 0x0D
  87. #define STMPE811_REG_GPIO_SET_PIN 0x10
  88. #define STMPE811_REG_GPIO_CLR_PIN 0x11
  89. #define STMPE811_REG_GPIO_MP_STA 0x12
  90. #define STMPE811_REG_GPIO_DIR 0x13
  91. #define STMPE811_REG_GPIO_ED 0x14
  92. #define STMPE811_REG_GPIO_RE 0x15
  93. #define STMPE811_REG_GPIO_FE 0x16
  94. #define STMPE811_REG_GPIO_AF 0x17
  95. #define STMPE811_SYS_CTRL2_ADC_OFF (1 << 0)
  96. #define STMPE811_SYS_CTRL2_TSC_OFF (1 << 1)
  97. #define STMPE811_SYS_CTRL2_GPIO_OFF (1 << 2)
  98. #define STMPE811_SYS_CTRL2_TS_OFF (1 << 3)
  99. /*
  100. * STMPE1601
  101. */
  102. #define STMPE1601_IRQ_GPIOC 8
  103. #define STMPE1601_IRQ_PWM3 7
  104. #define STMPE1601_IRQ_PWM2 6
  105. #define STMPE1601_IRQ_PWM1 5
  106. #define STMPE1601_IRQ_PWM0 4
  107. #define STMPE1601_IRQ_KEYPAD_OVER 2
  108. #define STMPE1601_IRQ_KEYPAD 1
  109. #define STMPE1601_IRQ_WAKEUP 0
  110. #define STMPE1601_NR_INTERNAL_IRQS 9
  111. #define STMPE1601_REG_SYS_CTRL 0x02
  112. #define STMPE1601_REG_SYS_CTRL2 0x03
  113. #define STMPE1601_REG_ICR_LSB 0x11
  114. #define STMPE1601_REG_IER_LSB 0x13
  115. #define STMPE1601_REG_ISR_MSB 0x14
  116. #define STMPE1601_REG_CHIP_ID 0x80
  117. #define STMPE1601_REG_INT_EN_GPIO_MASK_LSB 0x17
  118. #define STMPE1601_REG_INT_STA_GPIO_MSB 0x18
  119. #define STMPE1601_REG_GPIO_MP_LSB 0x87
  120. #define STMPE1601_REG_GPIO_SET_LSB 0x83
  121. #define STMPE1601_REG_GPIO_CLR_LSB 0x85
  122. #define STMPE1601_REG_GPIO_SET_DIR_LSB 0x89
  123. #define STMPE1601_REG_GPIO_ED_MSB 0x8A
  124. #define STMPE1601_REG_GPIO_RE_LSB 0x8D
  125. #define STMPE1601_REG_GPIO_FE_LSB 0x8F
  126. #define STMPE1601_REG_GPIO_AF_U_MSB 0x92
  127. #define STMPE1601_SYS_CTRL_ENABLE_GPIO (1 << 3)
  128. #define STMPE1601_SYS_CTRL_ENABLE_KPC (1 << 1)
  129. #define STMPE1601_SYSCON_ENABLE_SPWM (1 << 0)
  130. /* The 1601/2403 share the same masks */
  131. #define STMPE1601_AUTOSLEEP_TIMEOUT_MASK (0x7)
  132. #define STPME1601_AUTOSLEEP_ENABLE (1 << 3)
  133. /*
  134. * STMPE24xx
  135. */
  136. #define STMPE24XX_IRQ_GPIOC 8
  137. #define STMPE24XX_IRQ_PWM2 7
  138. #define STMPE24XX_IRQ_PWM1 6
  139. #define STMPE24XX_IRQ_PWM0 5
  140. #define STMPE24XX_IRQ_ROT_OVER 4
  141. #define STMPE24XX_IRQ_ROT 3
  142. #define STMPE24XX_IRQ_KEYPAD_OVER 2
  143. #define STMPE24XX_IRQ_KEYPAD 1
  144. #define STMPE24XX_IRQ_WAKEUP 0
  145. #define STMPE24XX_NR_INTERNAL_IRQS 9
  146. #define STMPE24XX_REG_SYS_CTRL 0x02
  147. #define STMPE24XX_REG_ICR_LSB 0x11
  148. #define STMPE24XX_REG_IER_LSB 0x13
  149. #define STMPE24XX_REG_ISR_MSB 0x14
  150. #define STMPE24XX_REG_CHIP_ID 0x80
  151. #define STMPE24XX_REG_IEGPIOR_LSB 0x18
  152. #define STMPE24XX_REG_ISGPIOR_MSB 0x19
  153. #define STMPE24XX_REG_GPMR_LSB 0xA5
  154. #define STMPE24XX_REG_GPSR_LSB 0x85
  155. #define STMPE24XX_REG_GPCR_LSB 0x88
  156. #define STMPE24XX_REG_GPDR_LSB 0x8B
  157. #define STMPE24XX_REG_GPEDR_MSB 0x8C
  158. #define STMPE24XX_REG_GPRER_LSB 0x91
  159. #define STMPE24XX_REG_GPFER_LSB 0x94
  160. #define STMPE24XX_REG_GPAFR_U_MSB 0x9B
  161. #define STMPE24XX_SYS_CTRL_ENABLE_GPIO (1 << 3)
  162. #define STMPE24XX_SYSCON_ENABLE_PWM (1 << 2)
  163. #define STMPE24XX_SYS_CTRL_ENABLE_KPC (1 << 1)
  164. #define STMPE24XX_SYSCON_ENABLE_ROT (1 << 0)
  165. #endif