pt_core.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * pt_core.h
  3. * Parade TrueTouch(TM) Standard Product Core Module.
  4. * For use with Parade touchscreen controllers.
  5. * Supported parts include:
  6. * TMA5XX
  7. * TMA448
  8. * TMA445A
  9. * TT21XXX
  10. * TT31XXX
  11. * TT4XXXX
  12. * TT7XXX
  13. * TC3XXX
  14. *
  15. * Copyright (C) 2015-2020 Parade Technologies
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License
  19. * version 2, and only version 2, as published by the
  20. * Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * Contact Parade Technologies at www.parade.com <[email protected]>
  28. */
  29. #ifndef _LINUX_PT_CORE_H
  30. #define _LINUX_PT_CORE_H
  31. #include <linux/stringify.h>
  32. #include <drm/drm_panel.h>
  33. #define PT_I2C_NAME "pt_i2c_adapter"
  34. #define PT_SPI_NAME "pt_spi_adapter"
  35. #define PT_CORE_NAME "pt_core"
  36. #define PT_MT_NAME "pt_mt"
  37. #define PT_BTN_NAME "pt_btn"
  38. #define PT_PROXIMITY_NAME "pt_proximity"
  39. #define PT_DRIVER_NAME TTDL
  40. #define PT_DRIVER_MAJOR 04
  41. #define PT_DRIVER_MINOR 11
  42. #define PT_DRIVER_REVCTRL 977092
  43. #define PT_DRIVER_VERSION \
  44. __stringify(PT_DRIVER_NAME) \
  45. "." __stringify(PT_DRIVER_MAJOR) \
  46. "." __stringify(PT_DRIVER_MINOR) \
  47. "." __stringify(PT_DRIVER_REVCTRL)
  48. #define PT_DRIVER_DATE "20201210"
  49. /* abs settings */
  50. #define PT_IGNORE_VALUE -1
  51. enum pt_core_platform_flags {
  52. PT_CORE_FLAG_NONE,
  53. PT_CORE_FLAG_POWEROFF_ON_SLEEP = 0x02,
  54. PT_CORE_FLAG_RESTORE_PARAMETERS = 0x04,
  55. PT_CORE_FLAG_DEEP_STANDBY = 0x08,
  56. PT_CORE_FLAG_SKIP_SYS_SLEEP = 0x10,
  57. PT_CORE_FLAG_SKIP_RUNTIME = 0x20,
  58. PT_CORE_FLAG_SKIP_RESUME = 0x40,
  59. };
  60. enum pt_core_platform_easy_wakeup_gesture {
  61. PT_CORE_EWG_NONE,
  62. PT_CORE_EWG_TAP_TAP,
  63. PT_CORE_EWG_TWO_FINGER_SLIDE,
  64. PT_CORE_EWG_RESERVED,
  65. PT_CORE_EWG_WAKE_ON_INT_FROM_HOST = 0xFF,
  66. };
  67. enum pt_loader_platform_flags {
  68. PT_LOADER_FLAG_NONE,
  69. PT_LOADER_FLAG_CALIBRATE_AFTER_FW_UPGRADE,
  70. /* Use CONFIG_VER field in TT_CFG to decide TT_CFG update */
  71. PT_LOADER_FLAG_CHECK_TTCONFIG_VERSION,
  72. PT_LOADER_FLAG_CALIBRATE_AFTER_TTCONFIG_UPGRADE,
  73. };
  74. enum CONFIG_DUT_GENERATION {
  75. CONFIG_DUT_AUTO_DETECT = 0x00,
  76. CONFIG_DUT_PIP1_ONLY = 0x01,
  77. CONFIG_DUT_PIP2_CAPABLE = 0x02,
  78. };
  79. enum pt_core_platform_panel_id_flags {
  80. PT_PANEL_ID_DISABLE = 0x00,
  81. PT_PANEL_ID_BY_BL = 0x01,
  82. PT_PANEL_ID_BY_SYS_INFO = 0x02,
  83. PT_PANEL_ID_BY_MFG_DATA = 0x04,
  84. };
  85. struct touch_settings {
  86. const uint8_t *data;
  87. uint32_t size;
  88. uint8_t tag;
  89. };
  90. struct pt_touch_firmware {
  91. const uint8_t *img;
  92. uint32_t size;
  93. const uint8_t *ver;
  94. uint8_t vsize;
  95. uint8_t panel_id;
  96. };
  97. struct pt_touch_config {
  98. struct touch_settings *param_regs;
  99. struct touch_settings *param_size;
  100. const uint8_t *fw_ver;
  101. uint8_t fw_vsize;
  102. uint8_t panel_id;
  103. };
  104. struct pt_loader_platform_data {
  105. struct pt_touch_firmware *fw;
  106. struct pt_touch_config *ttconfig;
  107. struct pt_touch_firmware **fws;
  108. struct pt_touch_config **ttconfigs;
  109. u32 flags;
  110. };
  111. typedef int (*pt_platform_read) (struct device *dev, void *buf, int size);
  112. #define PT_TOUCH_SETTINGS_MAX 32
  113. struct pt_core_platform_data {
  114. int irq_gpio;
  115. u32 irq_gpio_flags;
  116. int rst_gpio;
  117. u32 rst_gpio_flags;
  118. int ddi_rst_gpio;
  119. int vddi_gpio;
  120. int vcc_gpio;
  121. int avdd_gpio;
  122. int avee_gpio;
  123. int level_irq_udelay;
  124. u16 hid_desc_register;
  125. u16 vendor_id;
  126. u16 product_id;
  127. int (*xres)(struct pt_core_platform_data *pdata,
  128. struct device *dev);
  129. int (*init)(struct pt_core_platform_data *pdata,
  130. int on, struct device *dev);
  131. int (*power)(struct pt_core_platform_data *pdata,
  132. int on, struct device *dev, atomic_t *ignore_irq);
  133. int (*detect)(struct pt_core_platform_data *pdata,
  134. struct device *dev, pt_platform_read read);
  135. int (*irq_stat)(struct pt_core_platform_data *pdata,
  136. struct device *dev);
  137. int (*setup_power)(struct pt_core_platform_data *pdata,
  138. int on, struct device *dev);
  139. int (*setup_irq)(struct pt_core_platform_data *pdata,
  140. int on, struct device *dev);
  141. struct touch_settings *sett[PT_TOUCH_SETTINGS_MAX];
  142. u32 flags;
  143. u8 easy_wakeup_gesture;
  144. u8 config_dut_generation;
  145. u8 watchdog_force_stop;
  146. u8 panel_id_support;
  147. struct device_node *node;
  148. struct pinctrl *pinctrl;
  149. struct pinctrl_state *pins_active;
  150. struct pinctrl_state *pins_suspend;
  151. struct pinctrl_state *pins_release;
  152. struct drm_panel *active_panel;
  153. };
  154. struct touch_framework {
  155. const int16_t *abs;
  156. uint8_t size;
  157. uint8_t enable_vkeys;
  158. } __packed;
  159. enum pt_mt_platform_power_state {
  160. PT_MT_POWER_OFF = 0x00,
  161. PT_MT_POWER_ON = 0x01
  162. };
  163. enum pt_mt_platform_irq_state {
  164. PT_MT_IRQ_FREE = 0x00,
  165. PT_MT_IRQ_REG = 0x01
  166. };
  167. enum pt_mt_platform_flags {
  168. PT_MT_FLAG_NONE,
  169. PT_MT_FLAG_HOVER = 0x04,
  170. PT_MT_FLAG_FLIP = 0x08,
  171. PT_MT_FLAG_INV_X = 0x10,
  172. PT_MT_FLAG_INV_Y = 0x20,
  173. PT_MT_FLAG_VKEYS = 0x40,
  174. PT_MT_FLAG_NO_TOUCH_ON_LO = 0x80,
  175. };
  176. struct pt_mt_platform_data {
  177. struct touch_framework *frmwrk;
  178. unsigned short flags;
  179. char const *inp_dev_name;
  180. int vkeys_x;
  181. int vkeys_y;
  182. };
  183. struct pt_btn_platform_data {
  184. char const *inp_dev_name;
  185. };
  186. struct pt_proximity_platform_data {
  187. struct touch_framework *frmwrk;
  188. char const *inp_dev_name;
  189. };
  190. struct pt_platform_data {
  191. struct pt_core_platform_data *core_pdata;
  192. struct pt_mt_platform_data *mt_pdata;
  193. struct pt_btn_platform_data *btn_pdata;
  194. struct pt_proximity_platform_data *prox_pdata;
  195. struct pt_loader_platform_data *loader_pdata;
  196. };
  197. #endif /* _LINUX_PT_CORE_H */