fts_ts.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. #ifndef _LINUX_FTS_TS_H_
  2. #define _LINUX_FTS_TS_H_
  3. #include <linux/device.h>
  4. #include <linux/hrtimer.h>
  5. #include <linux/i2c/fts.h>
  6. #ifdef CONFIG_HAS_EARLYSUSPEND
  7. #include <linux/earlysuspend.h>
  8. #endif
  9. #ifdef CONFIG_SEC_DEBUG_TSP_LOG
  10. #include <mach/sec_debug.h>
  11. #endif
  12. #ifdef CONFIG_SEC_DEBUG_TSP_LOG
  13. #define tsp_debug_dbg(mode, dev, fmt, ...) \
  14. ({ \
  15. if (mode) { \
  16. dev_dbg(dev, fmt, ## __VA_ARGS__); \
  17. sec_debug_tsp_log(fmt, ## __VA_ARGS__); \
  18. } \
  19. else \
  20. dev_dbg(dev, fmt, ## __VA_ARGS__); \
  21. })
  22. #define tsp_debug_info(mode, dev, fmt, ...) \
  23. ({ \
  24. if (mode) { \
  25. dev_info(dev, fmt, ## __VA_ARGS__); \
  26. sec_debug_tsp_log(fmt, ## __VA_ARGS__); \
  27. } \
  28. else \
  29. dev_info(dev, fmt, ## __VA_ARGS__); \
  30. })
  31. #define tsp_debug_err(mode, dev, fmt, ...) \
  32. ({ \
  33. if (mode) { \
  34. dev_err(dev, fmt, ## __VA_ARGS__); \
  35. sec_debug_tsp_log(fmt, ## __VA_ARGS__); \
  36. } \
  37. else \
  38. dev_err(dev, fmt, ## __VA_ARGS__); \
  39. })
  40. #else
  41. #define tsp_debug_dbg(mode, dev, fmt, ...) dev_dbg(dev, fmt, ## __VA_ARGS__)
  42. #define tsp_debug_info(mode, dev, fmt, ...) dev_info(dev, fmt, ## __VA_ARGS__)
  43. #define tsp_debug_err(mode, dev, fmt, ...) dev_err(dev, fmt, ## __VA_ARGS__)
  44. #endif
  45. #define USE_OPEN_CLOSE
  46. //#ifdef CONFIG_SEC_DVFS
  47. #include <linux/cpufreq.h>
  48. #define TOUCH_BOOSTER_DVFS
  49. #ifdef CONFIG_SEC_S_PROJECT
  50. #define DVFS_STAGE_NINTH 9
  51. #define DVFS_STAGE_PENTA 5
  52. #endif
  53. #define DVFS_STAGE_TRIPLE 3
  54. #define DVFS_STAGE_DUAL 2
  55. #define DVFS_STAGE_SINGLE 1
  56. #define DVFS_STAGE_NONE 0
  57. //#endif
  58. #ifdef TOUCH_BOOSTER_DVFS
  59. #define TOUCH_BOOSTER_OFF_TIME 500
  60. #define TOUCH_BOOSTER_CHG_TIME 300//130
  61. #ifdef CONFIG_SEC_S_PROJECT
  62. #define INPUT_BOOSTER_HIGH_OFF_TIME_TSP 1000
  63. #define INPUT_BOOSTER_HIGH_CHG_TIME_TSP 500
  64. #endif
  65. #endif
  66. #ifdef USE_OPEN_DWORK
  67. #define TOUCH_OPEN_DWORK_TIME 10
  68. #endif
  69. #define FIRMWARE_IC "fts_ic"
  70. #define FTS_MAX_FW_PATH 64
  71. #define FTS_TS_DRV_NAME "fts_touch"
  72. #define FTS_TS_DRV_VERSION "0132"
  73. #define STM_DEVICE_NAME "STM"
  74. #define FTS_ID0 0x39
  75. #define FTS_ID1 0x80
  76. #define FTS_FIFO_MAX 32
  77. #define FTS_EVENT_SIZE 8
  78. #define PRESSURE_MIN 0
  79. #define PRESSURE_MAX 127
  80. #define P70_PATCH_ADDR_START 0x00420000
  81. #define FINGER_MAX 10
  82. #define AREA_MIN PRESSURE_MIN
  83. #define AREA_MAX PRESSURE_MAX
  84. #define EVENTID_NO_EVENT 0x00
  85. #define EVENTID_ENTER_POINTER 0x03
  86. #define EVENTID_LEAVE_POINTER 0x04
  87. #define EVENTID_MOTION_POINTER 0x05
  88. #define EVENTID_HOVER_ENTER_POINTER 0x07
  89. #define EVENTID_HOVER_LEAVE_POINTER 0x08
  90. #define EVENTID_HOVER_MOTION_POINTER 0x09
  91. #define EVENTID_PROXIMITY_IN 0x0B
  92. #define EVENTID_PROXIMITY_OUT 0x0C
  93. #define EVENTID_MSKEY 0x0E
  94. #define EVENTID_ERROR 0x0F
  95. #define EVENTID_CONTROLLER_READY 0x10
  96. #define EVENTID_SLEEPOUT_CONTROLLER_READY 0x11
  97. #define EVENTID_RESULT_READ_REGISTER 0x12
  98. #define EVENTID_STATUS_EVENT 0x16
  99. #define EVENTID_INTERNAL_RELEASE_INFO 0x19
  100. #define EVENTID_EXTERNAL_RELEASE_INFO 0x1A
  101. #define EVENTID_GESTURE 0x20
  102. #define INT_ENABLE 0x41
  103. #define INT_DISABLE 0x00
  104. #define READ_STATUS 0x84
  105. #define READ_ONE_EVENT 0x85
  106. #define READ_ALL_EVENT 0x86
  107. #define SLEEPIN 0x90
  108. #define SLEEPOUT 0x91
  109. #define SENSEOFF 0x92
  110. #define SENSEON 0x93
  111. #define SENSEON_SLOW 0x9C
  112. #define FTS_CMD_HOVER_OFF 0x94
  113. #define FTS_CMD_HOVER_ON 0x95
  114. #if defined(CONFIG_SEC_S_PROJECT)
  115. #define FTS_CMD_FAST_SCAN 0x98
  116. #define FTS_CMD_SLOW_SCAN 0x99
  117. #define FTS_CMD_FLIPCOVER_OFF 0x9C
  118. #define FTS_CMD_FLIPCOVER_ON 0x9D
  119. #define FTS_RETRY_COUNT 10
  120. #else
  121. #define FTS_CMD_FLIPCOVER_OFF 0x96
  122. #define FTS_CMD_FLIPCOVER_ON 0x97
  123. #define FTS_RETRY_COUNT 30
  124. #endif
  125. #define FTS_CMD_KEY_SENSE_ON 0x9B
  126. #define FTS_CMD_SET_FAST_GLOVE_MODE 0x9D
  127. #define FTS_CMD_MSHOVER_OFF 0x9E
  128. #define FTS_CMD_MSHOVER_ON 0x9F
  129. #define FTS_CMD_SET_NOR_GLOVE_MODE 0x9F
  130. #define FLUSHBUFFER 0xA1
  131. #define FORCECALIBRATION 0xA2
  132. #define CX_TUNNING 0xA3
  133. #define SELF_AUTO_TUNE 0xA4
  134. #define KEY_CX_TUNNING 0x96
  135. #define FTS_CMD_CHARGER_PLUGGED 0xA8
  136. #define FTS_CMD_CHARGER_UNPLUGGED 0xAB
  137. #define FTS_CMD_RELEASEINFO 0xAA
  138. #define FTS_CMD_STYLUS_OFF 0xAB
  139. #define FTS_CMD_STYLUS_ON 0xAC
  140. #define FTS_CMD_WRITE_PRAM 0xF0
  141. #define FTS_CMD_BURN_PROG_FLASH 0xF2
  142. #define FTS_CMD_ERASE_PROG_FLASH 0xF3
  143. #define FTS_CMD_READ_FLASH_STAT 0xF4
  144. #define FTS_CMD_UNLOCK_FLASH 0xF7
  145. #define FTS_CMD_SAVE_FWCONFIG 0xFB
  146. #define FTS_CMD_SAVE_CX_TUNING 0xFC
  147. #define TSP_BUF_SIZE 1024
  148. #define CMD_STR_LEN 32
  149. #define CMD_PARAM_NUM 8
  150. #define RAW_MAX 3750
  151. // all #if !defined(CONFIG_SEC_LOCALE_KOR_FRESCO) && !defined(CONFIG_MACH_FRESCONEOLTE_CTC) && !defined(CONFIG_SEC_T10_PROJECT)
  152. #undef TSP_INIT_COMPLETE
  153. //#endif
  154. #if defined(CONFIG_SEC_LOCALE_KOR_FRESCO) ||defined(CONFIG_SEC_T10_PROJECT)
  155. #define READ_LCD_ID
  156. #endif
  157. /**
  158. * struct fts_finger - Represents fingers.
  159. * @ state: finger status (Event ID).
  160. * @ mcount: moving counter for debug.
  161. */
  162. struct fts_finger {
  163. unsigned char state;
  164. unsigned short mcount;
  165. };
  166. struct fts_ts_platform_data {
  167. u32 gpio_int;
  168. u32 gpio_ldo_en;
  169. #if defined(CONFIG_SEC_LOCALE_KOR_FRESCO)
  170. u32 oled_id;
  171. #endif
  172. #if defined(CONFIG_SEC_T10_PROJECT)
  173. int tsp_vendor1;
  174. int tsp_vendor2;
  175. #endif
  176. #if defined(CONFIG_SEC_S_PROJECT)
  177. int scl_gpio;
  178. int sda_gpio;
  179. int tsp_id;
  180. const char *name_of_supply;
  181. #endif
  182. };
  183. struct fts_ts_info {
  184. struct device *dev;
  185. struct i2c_client *client;
  186. struct fts_ts_platform_data *pdata;
  187. struct input_dev *input_dev;
  188. struct hrtimer timer;
  189. struct timer_list timer_charger;
  190. struct timer_list timer_firmware;
  191. struct work_struct work;
  192. int irq;
  193. int irq_type;
  194. bool irq_enabled;
  195. //const struct fts_i2c_platform_data *board;
  196. struct fts_i2c_platform_data *board;
  197. void (*register_cb) (void *);
  198. #ifdef FTS_SUPPORT_TA_MODE
  199. struct fts_callbacks callbacks;
  200. #endif
  201. struct mutex lock;
  202. bool enabled;
  203. #ifdef CONFIG_HAS_EARLYSUSPEND
  204. struct early_suspend early_suspend;
  205. #endif
  206. #ifdef SEC_TSP_FACTORY_TEST
  207. struct device *fac_dev_ts;
  208. struct list_head cmd_list_head;
  209. u8 cmd_state;
  210. char cmd[CMD_STR_LEN];
  211. int cmd_param[CMD_PARAM_NUM];
  212. char *cmd_result;
  213. int cmd_buffer_size;
  214. struct mutex cmd_lock;
  215. bool cmd_is_running;
  216. int SenseChannelLength;
  217. int ForceChannelLength;
  218. short *pFrame;
  219. #endif
  220. #ifdef TOUCH_BOOSTER_DVFS
  221. struct delayed_work work_dvfs_off;
  222. struct delayed_work work_dvfs_chg;
  223. struct mutex dvfs_lock;
  224. bool dvfs_lock_status;
  225. int dvfs_boost_mode;
  226. int dvfs_freq;
  227. int dvfs_old_stauts;
  228. bool stay_awake;
  229. #endif
  230. struct completion init_done;
  231. bool slow_report_rate;
  232. bool hover_ready;
  233. bool hover_enabled;
  234. bool mshover_enabled;
  235. bool fast_mshover_enabled;
  236. bool flip_enable;
  237. #ifdef FTS_SUPPORT_TA_MODE
  238. bool TA_Pluged;
  239. #endif
  240. int touch_count;
  241. struct fts_finger finger[FINGER_MAX];
  242. int touch_mode;
  243. int ic_product_id; /* product id of ic */
  244. int ic_revision_of_ic; /* revision of reading from IC */
  245. int fw_version_of_ic; /* firmware version of IC */
  246. int ic_revision_of_bin; /* revision of reading from binary */
  247. int fw_version_of_bin; /* firmware version of binary */
  248. int config_version_of_ic; /* Config release data from IC */
  249. int config_version_of_bin; /* Config release data from IC */
  250. unsigned short fw_main_version_of_ic; /* firmware main version of IC */
  251. unsigned short fw_main_version_of_bin; /* firmware main version of binary */
  252. int panel_revision; /* Octa panel revision */
  253. #ifdef USE_OPEN_DWORK
  254. struct delayed_work open_work;
  255. #endif
  256. #ifdef FTS_SUPPORT_NOISE_PARAM
  257. struct fts_noise_param noise_param;
  258. int (*fts_get_noise_param_address) (struct fts_ts_info *info);
  259. #endif
  260. struct mutex i2c_mutex;
  261. struct mutex device_mutex;
  262. bool touch_stopped;
  263. bool reinit_done;
  264. #ifdef FTS_SUPPORT_TOUCH_KEY
  265. unsigned char tsp_keystatus;
  266. bool report_dummy_key;
  267. bool ignore_menu_key;
  268. bool ignore_back_key;
  269. bool ignore_menu_key_by_back;
  270. bool ignore_back_key_by_menu;
  271. int touchkey_threshold;
  272. #endif // FTS_SUPPORT_TOUCH_KEY
  273. unsigned char data[FTS_EVENT_SIZE * FTS_FIFO_MAX];
  274. int (*stop_device) (struct fts_ts_info * info);
  275. int (*start_device) (struct fts_ts_info * info);
  276. int (*fts_write_reg)(struct fts_ts_info *info, unsigned char *reg, unsigned short num_com);
  277. int (*fts_read_reg)(struct fts_ts_info *info, unsigned char *reg, int cnum, unsigned char *buf, int num);
  278. void (*fts_systemreset)(struct fts_ts_info *info);
  279. int (*fts_wait_for_ready)(struct fts_ts_info *info);
  280. void (*fts_command)(struct fts_ts_info *info, unsigned char cmd);
  281. int (*fts_get_version_info)(struct fts_ts_info *info);
  282. #ifdef READ_LCD_ID
  283. int lcd_id;
  284. #endif
  285. };
  286. int fts_fw_update_on_probe(struct fts_ts_info *info);
  287. int fts_fw_update_on_hidden_menu(struct fts_ts_info *info, int update_type);
  288. void fts_fw_init(struct fts_ts_info *info);
  289. int GetSystemStatus(struct fts_ts_info *info, unsigned char *val1, unsigned char *val2);
  290. #endif //_LINUX_FTS_TS_H_