mxts.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /*
  2. * Copyright (C) 2012, Samsung Electronics Co. Ltd. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #ifndef __MXT_H__
  16. #define __MXT_H__
  17. #ifdef CONFIG_HAS_EARLYSUSPEND
  18. #include <linux/earlysuspend.h>
  19. #endif
  20. #if defined(CONFIG_TOUCHSCREEN_ATMEL_MXT224S)
  21. #define MXT_DEV_NAME "Atmel MXT224S"
  22. #elif defined(CONFIG_TOUCHSCREEN_ATMEL_MXT540S)
  23. #define MXT_DEV_NAME "Atmel MXT540S"
  24. #elif defined(CONFIG_TOUCHSCREEN_ATMEL_MXT1664S)
  25. #define MXT_DEV_NAME "atmel_mxt_1664s"
  26. #else
  27. #define MXT_DEV_NAME "Atmel MXTXXXS"
  28. #endif
  29. #include <asm/system_info.h>
  30. #if defined(CONFIG_SEC_LT03_PROJECT)
  31. #define MXT_FIRMWARE_NAME "mXT1664S_n.fw"
  32. #define WORKAROUND_THRESHOLD /* Former HW revision device changes register value to reduce the RF noise */
  33. /* Only KOR */
  34. #if defined(CONFIG_MACH_LT03SKT) || defined(CONFIG_MACH_LT03LGT) || defined(CONFIG_MACH_LT03KTT)
  35. #define KOR_REVISION
  36. #endif
  37. #elif defined(CONFIG_SEC_PICASSO_PROJECT)
  38. #define MXT_FIRMWARE_NAME "mXT1664S_n.fw"
  39. #define PALM_TUNING
  40. #elif defined(CONFIG_SEC_VIENNA_PROJECT)
  41. #define MXT_FIRMWARE_NAME "mXT1664S_v.fw"
  42. #elif defined(CONFIG_SEC_V2_PROJECT)
  43. #define MXT_FIRMWARE_NAME "mXT1664S_v2.fw"
  44. #else
  45. #undef USE_MENU_TOUCHKEY /* default: recent key (since KK) */
  46. #define MXT_FIRMWARE_NAME NULL
  47. #endif
  48. #define MXT_DEFAULT_FIRMWARE_NAME "MXTS.fw"
  49. #define MXT_FIRMWARE_INKERNEL_PATH "tsp_atmel/"
  50. #define MXT_MAX_FW_PATH 30
  51. #define MXT_FIRMWARE_UPDATE_TYPE true
  52. #define MXT_BOOT_ADDRESS 0x24
  53. #define MXT_APP_ADDRESS 0x4A
  54. #define MXT_BACKUP_TIME 25 /* msec */
  55. #define MXT_RESET_INTEVAL_TIME 50 /* msec */
  56. #define MXT_SW_RESET_TIME 300 /* msec */
  57. #define MXT_HW_RESET_TIME 80 /* msec */
  58. enum {
  59. MXT_RESERVED_T0 = 0,
  60. MXT_RESERVED_T1,
  61. MXT_DEBUG_DELTAS_T2,
  62. MXT_DEBUG_REFERENCES_T3,
  63. MXT_DEBUG_SIGNALS_T4,
  64. MXT_GEN_MESSAGEPROCESSOR_T5,
  65. MXT_GEN_COMMANDPROCESSOR_T6,
  66. MXT_GEN_POWERCONFIG_T7,
  67. MXT_GEN_ACQUISITIONCONFIG_T8,
  68. MXT_TOUCH_MULTITOUCHSCREEN_T9,
  69. MXT_TOUCH_SINGLETOUCHSCREEN_T10,
  70. MXT_TOUCH_XSLIDER_T11,
  71. MXT_TOUCH_YSLIDER_T12,
  72. MXT_TOUCH_XWHEEL_T13,
  73. MXT_TOUCH_YWHEEL_T14,
  74. MXT_TOUCH_KEYARRAY_T15,
  75. MXT_PROCG_SIGNALFILTER_T16,
  76. MXT_PROCI_LINEARIZATIONTABLE_T17,
  77. MXT_SPT_COMCONFIG_T18,
  78. MXT_SPT_GPIOPWM_T19,
  79. MXT_PROCI_GRIPFACESUPPRESSION_T20,
  80. MXT_RESERVED_T21,
  81. MXT_PROCG_NOISESUPPRESSION_T22,
  82. MXT_TOUCH_PROXIMITY_T23,
  83. MXT_PROCI_ONETOUCHGESTUREPROCESSOR_T24,
  84. MXT_SPT_SELFTEST_T25,
  85. MXT_DEBUG_CTERANGE_T26,
  86. MXT_PROCI_TWOTOUCHGESTUREPROCESSOR_T27,
  87. MXT_SPT_CTECONFIG_T28,
  88. MXT_SPT_GPI_T29,
  89. MXT_SPT_GATE_T30,
  90. MXT_TOUCH_KEYSET_T31,
  91. MXT_TOUCH_XSLIDERSET_T32,
  92. MXT_RESERVED_T33,
  93. MXT_GEN_MESSAGEBLOCK_T34,
  94. MXT_SPT_GENERICDATA_T35,
  95. MXT_RESERVED_T36,
  96. MXT_DEBUG_DIAGNOSTIC_T37,
  97. MXT_SPT_USERDATA_T38,
  98. MXT_SPARE_T39,
  99. MXT_PROCI_GRIPSUPPRESSION_T40,
  100. MXT_SPARE_T41,
  101. MXT_PROCI_TOUCHSUPPRESSION_T42,
  102. MXT_SPT_DIGITIZER_T43,
  103. MXT_SPARE_T44,
  104. MXT_SPARE_T45,
  105. MXT_SPT_CTECONFIG_T46,
  106. MXT_PROCI_STYLUS_T47,
  107. MXT_PROCG_NOISESUPPRESSION_T48,
  108. MXT_SPARE_T49,
  109. MXT_SPARE_T50,
  110. MXT_SPARE_T51,
  111. MXT_TOUCH_PROXIMITY_KEY_T52,
  112. MXT_GEN_DATASOURCE_T53,
  113. MXT_SPARE_T54,
  114. MXT_ADAPTIVE_T55,
  115. MXT_PROCI_SHIELDLESS_T56,
  116. MXT_PROCI_EXTRATOUCHSCREENDATA_T57,
  117. MXT_SPARE_T58,
  118. MXT_SPARE_T59,
  119. MXT_SPARE_T60,
  120. MXT_SPT_TIMER_T61,
  121. MXT_PROCG_NOISESUPPRESSION_T62,
  122. MXT_PROCI_ACTIVESTYLUS_T63,
  123. MXT_SPARE_T64,
  124. MXT_PROCI_LENSBENDING_T65,
  125. MXT_SPT_GOLDENREFERENCES_T66,
  126. MXT_SPARE_T67,
  127. MXT_SPARE_T68,
  128. MXT_PROCI_PALMGESTUREPROCESSOR_T69,
  129. MXT_SPT_DYNAMICCONFIGURATIONCONTROLLER_T70,
  130. MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71,
  131. MXT_PROCG_NOISESUPPRESSION_T72,
  132. MXT_TOUCH_MULTITOUCHSCREEN_T100 = 100,
  133. MXT_SPT_TOUCHSCREENHOVER_T101,
  134. MXT_SPT_SELFCAPHOVERCTECONFIG_T102,
  135. MXT_RESERVED_T255 = 255,
  136. };
  137. #define MXT_INFOMATION_BLOCK_SIZE 7
  138. #define MXT_OBJECT_TABLE_ELEMENT_SIZE 6
  139. #define MXT_OBJECT_TABLE_START_ADDRESS 7
  140. #define MXT_MAX_FINGER 10
  141. #define MXT_AREA_MAX 255
  142. #define MXT_AMPLITUDE_MAX 255
  143. /* Information of each Object */
  144. /* MXT_GEN_COMMAND_T6 Field */
  145. #define MXT_COMMAND_RESET 0
  146. #define MXT_COMMAND_BACKUPNV 1
  147. #define MXT_COMMAND_CALIBRATE 2
  148. #define MXT_COMMAND_REPORTALL 3
  149. #define MXT_COMMAND_DEBUGCTL 4
  150. #define MXT_COMMAND_DIAGNOSTIC 5
  151. /* Define for MXT_GEN_COMMAND_T6 */
  152. #define MXT_RESET_VALUE 0x01
  153. #define MXT_BOOT_VALUE 0xa5
  154. /*
  155. * If the firmware can support dynamic configuration,
  156. * 0x55 : backup configuration data and resume event handling.
  157. * 0x44 : restore configuration data
  158. * 0x33 : restore configuration data and stop event handiling.
  159. *
  160. * if the firmware did not support dynamic configuration,
  161. * 0x33, 0x44 is not affect.
  162. */
  163. #define MXT_BACKUP_VALUE 0x55
  164. #define MXT_RESTORE_VALUE 0x44
  165. #define MXT_DISALEEVT_VALUE 0x33
  166. /* MXT_GEN_POWER_T7 Field */
  167. #define MXT_POWER_IDLEACQINT 0
  168. #define MXT_POWER_ACTACQINT 1
  169. /* MXT_TOUCH_MULTI_T9 Field */
  170. #define MXT_TOUCH_CTRL 0
  171. #define MXT_TOUCH_XSIZE 3
  172. #define MXT_TOUCH_YSIZE 4
  173. #define MXT_TOUCH_ORIENT 9
  174. #define MXT_TOUCH_XRANGE_LSB 18
  175. #define MXT_TOUCH_XRANGE_MSB 19
  176. #define MXT_TOUCH_YRANGE_LSB 20
  177. #define MXT_TOUCH_YRANGE_MSB 21
  178. #define MXT_TOUCH_MOVFILTER2 36
  179. /* MXT_TOUCH_KEYARRAY_T15 Field */
  180. #define MXT_KEYARRY_CTRL 0
  181. #define MXT_KEYARRY_XORIGIN 1
  182. #define MXT_KEYARRY_YORIGIN 2
  183. #define MXT_DIAG_KEYDELTA_MODE 0xFD
  184. /* Touch message bit masking value */
  185. #define MXT_SUPPRESS_MSG_MASK (1 << 1)
  186. #define MXT_AMPLITUDE_MSG_MASK (1 << 2)
  187. #define MXT_VECTOR_MSG_MASK (1 << 3)
  188. #define MXT_MOVE_MSG_MASK (1 << 4)
  189. #define MXT_RELEASE_MSG_MASK (1 << 5)
  190. #define MXT_PRESS_MSG_MASK (1 << 6)
  191. #define MXT_DETECT_MSG_MASK (1 << 7)
  192. /* Slave addresses */
  193. #define MXT_APP_LOW 0x4a
  194. #define MXT_APP_HIGH 0x4b
  195. #define MXT_BOOT_LOW 0x26
  196. #define MXT_BOOT_HIGH 0x27
  197. /* Bootloader mode status */
  198. #define MXT_WAITING_BOOTLOAD_CMD 0xc0
  199. #define MXT_WAITING_FRAME_DATA 0x80
  200. #define MXT_FRAME_CRC_CHECK 0x02
  201. #define MXT_FRAME_CRC_FAIL 0x03
  202. #define MXT_FRAME_CRC_PASS 0x04
  203. #define MXT_APP_CRC_FAIL 0x40
  204. #define MXT_BOOT_STATUS_MASK 0x3f
  205. /* Bootloader ID */
  206. #define MXT_BOOT_EXTENDED_ID 0x20
  207. #define MXT_BOOT_ID_MASK 0x1f
  208. /* Command to unlock bootloader */
  209. #define MXT_UNLOCK_CMD_MSB 0xaa
  210. #define MXT_UNLOCK_CMD_LSB 0xdc
  211. #define MXT_STATE_INACTIVE 0
  212. #define MXT_STATE_RELEASE 1
  213. #define MXT_STATE_PRESS 2
  214. #define MXT_STATE_MOVE 3
  215. /* Diagnostic command defines */
  216. #define MXT_DIAG_PAGE_UP 0x01
  217. #define MXT_DIAG_PAGE_DOWN 0x02
  218. #define MXT_DIAG_DELTA_MODE 0x10
  219. #define MXT_DIAG_REFERENCE_MODE 0x11
  220. #define MXT_DIAG_CTE_MODE 0x31
  221. #define MXT_DIAG_IDENTIFICATION_MODE 0x80
  222. #define MXT_DIAG_TOCH_THRESHOLD_MODE 0xF4
  223. #define MXT_DIAG_MODE_MASK 0xFC
  224. #define MXT_DIAGNOSTIC_MODE 0
  225. #define MXT_DIAGNOSTIC_PAGE 1
  226. #define MXT_CONFIG_VERSION_LENGTH 30
  227. /* Touchscreen configuration infomation */
  228. #define MXT_FW_MAGIC 0x4D3C2B1A
  229. /* Message type of T100 object */
  230. #define MXT_T100_SCREEN_MSG_FIRST_RPT_ID 0
  231. #define MXT_T100_SCREEN_MSG_SECOND_RPT_ID 1
  232. #define MXT_T100_SCREEN_MESSAGE_NUM_RPT_ID 2
  233. /* Event Types of T100 object */
  234. #define MXT_T100_DETECT_MSG_MASK 7
  235. #define MXT_T100_EVENT_NONE 0
  236. #define MXT_T100_EVENT_MOVE 1
  237. #define MXT_T100_EVENT_UNSUPPRESS 2
  238. #define MXT_T100_EVENT_SUPPESS 3
  239. #define MXT_T100_EVENT_DOWN 4
  240. #define MXT_T100_EVENT_UP 5
  241. #define MXT_T100_EVENT_UNSUPSUP 6
  242. #define MXT_T100_EVENT_UNSUPUP 7
  243. #define MXT_T100_EVENT_DOWNSUP 8
  244. #define MXT_T100_EVENT_DOWNUP 9
  245. /* Tool types of T100 object */
  246. #define MXT_T100_TYPE_RESERVED 0
  247. #define MXT_T100_TYPE_FINGER 1
  248. #define MXT_T100_TYPE_PASSIVE_STYLUS 2
  249. #define MXT_T100_TYPE_ACTIVE_STYLUS 3
  250. #define MXT_T100_TYPE_HOVERING_FINGER 4
  251. /* Revision info of Touch IC
  252. *
  253. * Revision / Bootloader ID
  254. * G 0x2103
  255. * I 0x3303
  256. */
  257. #define MXT_REVISION_G 0
  258. #define MXT_REVISION_I 1 /* Support hovering */
  259. /************** Feature **************/
  260. #define TSP_PATCH 1
  261. #define TSP_BOOSTER 1
  262. #define MXT_TKEY_BOOSTER 1
  263. #define TSP_SEC_FACTORY 1
  264. #define TSP_INFORM_CHARGER 1
  265. #define TSP_USE_SHAPETOUCH 1
  266. #define ENABLE_TOUCH_KEY 1
  267. #define USE_FOR_SUFACE 1
  268. #define TSP_BRING_UP
  269. #define TSP_HOVER_WORKAROUND 0
  270. #define TSP_CHANGE_CONFIG_FOR_INPUT 1
  271. #ifdef CONFIG_SEC_FACTORY
  272. #define TSP_USE_PALM_FLAG 0
  273. #else
  274. #define TSP_USE_PALM_FLAG 1
  275. #endif
  276. #undef TSP_INIT_COMPLETE
  277. /* TODO TEMP_HOVER : Need to check and modify
  278. * it can be changed related potocol of hover So current
  279. * implementation is temporary code.
  280. */
  281. /* TSP_USE_ATMELDBG feature just for atmel tunning app
  282. * so it should be disabled after finishing tunning
  283. * because it use other write permission. it will be cause
  284. * failure of CTS
  285. */
  286. #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
  287. #define TSP_USE_ATMELDBG 1
  288. #else
  289. #define TSP_USE_ATMELDBG 0
  290. #endif
  291. /************** Feature - **************/
  292. #if TSP_USE_SHAPETOUCH
  293. #define MXT_PALM_MAX 1
  294. #define MXT_COMPONENT_MAX 255
  295. #define MXT_SUMSIZE_MAX (16 * 26)
  296. #endif
  297. #if TSP_SEC_FACTORY
  298. #define TSP_BUF_SIZE 1024
  299. #define NODE_PER_PAGE 64
  300. #define DATA_PER_NODE 2
  301. #define REF_OFFSET_VALUE 16384
  302. #define REF_MIN_VALUE (19744 - REF_OFFSET_VALUE)
  303. #define REF_MAX_VALUE (28884 - REF_OFFSET_VALUE)
  304. #define TSP_CMD_STR_LEN 32
  305. #define TSP_CMD_RESULT_STR_LEN 512
  306. #define TSP_CMD_PARAM_NUM 8
  307. /* Related Golden Reference */
  308. #define MXT_FCALCMD(x) ((x) << 2)
  309. #define MXT_FCALCMD_NONE 0
  310. #define MXT_FCALCMD_PRIME 1
  311. #define MXT_FCALCMD_GENERATE 2
  312. #define MXT_FCALCMD_STORE 3
  313. #define MXT_FCALSTATE(x) (((x) & 0x06) >> 1)
  314. #define MXT_FCALSTATE_IDLE 0
  315. #define MXT_FCALSTATE_PRIMED 1
  316. #define MXT_FCALSTATE_GENERATED 2
  317. #define MXT_FCALSTATUS_FAIL 0x80
  318. #define MXT_FCALSTATUS_PASS 0x40
  319. #define MXT_FCALSTATUS_SEQDONE 0x20
  320. #define MXT_FCALSTATUS_SEQTO 0x10
  321. #define MXT_FCALSTATUS_SEQERR 0x08
  322. #define MXT_FCALSTATUS_BADSTORED 0x01
  323. #define FCALSEQDONE_MAGIC 0x7777
  324. enum CMD_STATUS {
  325. CMD_STATUS_WAITING = 0,
  326. CMD_STATUS_RUNNING,
  327. CMD_STATUS_OK,
  328. CMD_STATUS_FAIL,
  329. CMD_STATUS_NOT_APPLICABLE,
  330. };
  331. enum {
  332. MXT_FW_FROM_BUILT_IN = 0,
  333. MXT_FW_FROM_UMS,
  334. MXT_FW_FROM_REQ_FW,
  335. };
  336. #endif
  337. #if TSP_BOOSTER || MXT_TKEY_BOOSTER
  338. #define DVFS_STAGE_NINTH 9
  339. #define DVFS_STAGE_TRIPLE 3
  340. #define DVFS_STAGE_DUAL 2
  341. #define DVFS_STAGE_SINGLE 1
  342. #define DVFS_STAGE_NONE 0
  343. #include <linux/cpufreq.h>
  344. #define TOUCH_BOOSTER_OFF_TIME 500
  345. #define TOUCH_BOOSTER_CHG_TIME 130
  346. #define TOUCH_BOOSTER_HIGH_OFF_TIME 1000
  347. #define TOUCH_BOOSTER_HIGH_CHG_TIME 500
  348. #endif
  349. #if ENABLE_TOUCH_KEY
  350. /* MXT_TOUCH_KEYARRAY_T15 Message address definitions */
  351. #define MXT_MSG_T15_STATUS 0x00
  352. #define MXT_MSG_T15_KEYSTATE 0x01
  353. #define MXT_MSGB_T15_DETECT 0x80
  354. /* TSP Key Feature*/
  355. #define KEY_PRESS 1
  356. #define KEY_RELEASE 0
  357. #define TOUCH_KEY_NULL 0
  358. struct mxt_touchkey {
  359. unsigned int value;
  360. unsigned int keycode;
  361. char *name;
  362. unsigned int xnode;
  363. unsigned int ynode;
  364. unsigned int deltaobj;
  365. int key_skipped;
  366. int key_pressed;
  367. };
  368. #endif
  369. struct mxt_callbacks {
  370. void (*inform_charger)(struct mxt_callbacks *, bool);
  371. };
  372. struct mxt_power_data {
  373. int tsp_en;
  374. int tsp_en1;
  375. int tsp_int;
  376. int vdd_io_1p8;
  377. int tsp_rst;
  378. };
  379. struct mxt_platform_data {
  380. unsigned char num_xnode;
  381. unsigned char num_ynode;
  382. unsigned int max_x;
  383. unsigned int max_y;
  384. unsigned long irqflags;
  385. unsigned char boot_address;
  386. unsigned char revision;
  387. int tsp_en; /* enable LDO 3.3V */
  388. int tsp_en1; /* enable LDO 8.2V */
  389. int tsp_int; /* Interrupt GPIO */
  390. int vdd_io_1p8; /* enable Regulator 1.8V */
  391. int tsp_rst; /* reset GPIO */
  392. const char *firmware_name;
  393. const char *project_name;
  394. const char *model_name;
  395. const u8 **config;
  396. int (*read_chg)(void);
  397. int (*power_onoff) (bool);
  398. int (*power_reset) (void);
  399. void (*register_cb) (void *);
  400. #if ENABLE_TOUCH_KEY
  401. unsigned int num_touchkey;
  402. struct mxt_touchkey *touchkey;
  403. int (*led_power_onoff) (bool);
  404. #endif
  405. };
  406. struct mxt_object {
  407. u8 type;
  408. u16 start_address;
  409. u8 size;
  410. u8 instances;
  411. u8 num_report_ids;
  412. /* added for mapping obj to report id*/
  413. u8 max_reportid;
  414. };
  415. struct mxt_info {
  416. u8 family_id;
  417. u8 variant_id;
  418. u8 version;
  419. u8 build;
  420. u8 matrix_xsize;
  421. u8 matrix_ysize;
  422. u8 object_num;
  423. };
  424. struct mxt_message {
  425. u8 reportid;
  426. u8 message[8];
  427. };
  428. /**
  429. * struct mxt_finger - Represents fingers.
  430. * @ x: x position.
  431. * @ y: y position.
  432. * @ w: size of touch.
  433. * @ z: touch amplitude(sum of measured deltas).
  434. * @ component: vector info.
  435. * @ state: finger status.
  436. * @ type: type of touch. if firmware can support.
  437. * @ mcount: moving counter for debug.
  438. */
  439. struct mxt_finger {
  440. u16 x;
  441. u16 y;
  442. u16 w;
  443. u16 z;
  444. #if TSP_USE_SHAPETOUCH
  445. u16 component;
  446. #endif
  447. u8 state;
  448. u8 type;
  449. u8 event;
  450. u16 mcount;
  451. };
  452. struct mxt_reportid {
  453. u8 type;
  454. u8 index;
  455. };
  456. #if TSP_USE_ATMELDBG
  457. struct atmel_dbg {
  458. u16 last_read_addr;
  459. u8 stop_sync; /* to disable input sync report */
  460. u8 display_log; /* to display raw message */
  461. u8 block_access; /* to prevent access IC with I2c */
  462. };
  463. #endif
  464. #if TSP_SEC_FACTORY
  465. struct mxt_fac_data {
  466. struct device *fac_dev_ts;
  467. #if ENABLE_TOUCH_KEY
  468. struct device *touchkey_dev_ts;
  469. #endif
  470. struct list_head cmd_list_head;
  471. u8 cmd_state;
  472. char cmd[TSP_CMD_STR_LEN];
  473. int cmd_param[TSP_CMD_PARAM_NUM];
  474. char cmd_param_str[TSP_CMD_PARAM_NUM][TSP_CMD_RESULT_STR_LEN];
  475. char cmd_result[TSP_CMD_RESULT_STR_LEN];
  476. struct mutex cmd_lock;
  477. bool cmd_is_running;
  478. u8 num_xnode;
  479. u8 num_ynode;
  480. u16 num_nodes;
  481. u16 *reference;
  482. s16 *delta;
  483. u32 ref_max_data;
  484. u32 ref_min_data;
  485. s16 delta_max_data;
  486. u16 delta_max_node;
  487. u8 fw_ver;
  488. u8 build_ver;
  489. };
  490. #endif
  491. #if TSP_PATCH
  492. struct mxt_patch{
  493. u8* patch;
  494. u16* stage_addr;
  495. u16* tline_addr;
  496. u16* trigger_addr;
  497. u16* event_addr;
  498. u16* src_item;
  499. u16* check_cnt;
  500. u16 period;
  501. u8 stage_cnt;
  502. u8 tline_cnt;
  503. u8 trigger_cnt;
  504. u8 event_cnt;
  505. u8 option;
  506. u8 debug;
  507. u8 timer_id;
  508. u8 cur_stage;
  509. u8 cur_stage_opt;
  510. u8 run_stage;
  511. u8 start;
  512. u8 finger_cnt;
  513. u8 start_stage; //0904
  514. u8 skip_test; //0908
  515. u32 stage_timestamp;
  516. };
  517. #endif
  518. struct mxt_data {
  519. struct i2c_client *client;
  520. struct i2c_client *client_boot;
  521. struct input_dev *input_dev;
  522. const struct mxt_platform_data *pdata;
  523. struct mxt_info info;
  524. struct mxt_object *objects;
  525. struct mxt_reportid *reportids;
  526. #ifdef TSP_INIT_COMPLETE
  527. struct completion init_done;
  528. #endif
  529. struct mxt_finger fingers[MXT_MAX_FINGER];
  530. struct mxt_power_data *pwrdata;
  531. u8 max_reportid;
  532. u8 finger_mask ;
  533. bool mxt_enabled;
  534. #ifdef CONFIG_HAS_EARLYSUSPEND
  535. struct early_suspend early_suspend;
  536. #endif
  537. #if TSP_BOOSTER
  538. struct delayed_work work_dvfs_off;
  539. struct delayed_work work_dvfs_chg;
  540. struct mutex dvfs_lock;
  541. bool dvfs_lock_status;
  542. int dvfs_old_stauts;
  543. int dvfs_boost_mode;
  544. int dvfs_freq;
  545. #endif
  546. #if MXT_TKEY_BOOSTER
  547. struct delayed_work work_tkey_dvfs_off;
  548. struct delayed_work work_tkey_dvfs_chg;
  549. struct mutex tkey_dvfs_lock;
  550. bool tkey_dvfs_lock_status;
  551. int tkey_dvfs_old_stauts;
  552. int tkey_dvfs_boost_mode;
  553. int tkey_dvfs_freq;
  554. #endif
  555. #if TSP_USE_ATMELDBG
  556. struct atmel_dbg atmeldbg;
  557. #endif
  558. #if TSP_SEC_FACTORY
  559. struct mxt_fac_data *fdata;
  560. #endif
  561. #if TSP_USE_SHAPETOUCH
  562. bool palm;
  563. u16 sumsize;
  564. #endif
  565. #if TSP_INFORM_CHARGER
  566. void (*register_cb) (struct mxt_callbacks *);
  567. struct mxt_callbacks callbacks;
  568. struct delayed_work noti_dwork;
  569. bool charging_mode;
  570. u8 chargin_status;
  571. #endif
  572. #if TSP_HOVER_WORKAROUND
  573. /* TODO HOVER : Current firmware need to current calibration for hover manually
  574. * I think it is should to move into IC level, and it is completed,
  575. * remove below boolean...*/
  576. bool cur_cal_status;
  577. #endif
  578. #if ENABLE_TOUCH_KEY
  579. u16 tsp_keystatus;
  580. bool report_dummy_key;
  581. bool ignore_menu_key;
  582. bool ignore_back_key;
  583. bool threshold_cmd_reversed;
  584. int setdata;
  585. #endif
  586. #ifdef TSP_CHECK_ATCH
  587. struct mxt_atch atch;
  588. #endif
  589. #ifndef TSP_INIT_COMPLETE
  590. struct delayed_work work_init_power_on;
  591. #endif
  592. #if TSP_PATCH
  593. struct mxt_patch patch;
  594. #endif
  595. #if TSP_CHANGE_CONFIG_FOR_INPUT
  596. bool is_inputmethod;
  597. #endif
  598. };
  599. /**
  600. * struct mxt_fw_image - Represents a firmware file.
  601. * @ magic_code: Identifier of file type.
  602. * @ hdr_len: Size of file header (struct mxt_fw_image).
  603. * @ cfg_len: Size of configuration data.
  604. * @ fw_len: Size of firmware data.
  605. * @ cfg_crc: CRC of configuration settings.
  606. * @ fw_ver: Version of firmware.
  607. * @ build_ver: Build version of firmware.
  608. * @ data: Configuration data followed by firmware image.
  609. */
  610. struct mxt_fw_image {
  611. __le32 magic_code;
  612. __le32 hdr_len;
  613. __le32 cfg_len;
  614. __le32 fw_len;
  615. __le32 cfg_crc;
  616. u8 fw_ver;
  617. u8 build_ver;
  618. u8 data[0];
  619. } __packed;
  620. /**
  621. * struct mxt_cfg_data - Represents a configuration data item.
  622. * @ type: Type of object.
  623. * @ instance: Instance number of object.
  624. * @ size: Size of object.
  625. * @ register_val: Series of register values for object.
  626. */
  627. struct mxt_cfg_data {
  628. u8 type;
  629. u8 instance;
  630. u8 size;
  631. u8 register_val[0];
  632. } __packed;
  633. struct mxt_fw_info {
  634. u8 fw_ver;
  635. u8 build_ver;
  636. u32 hdr_len;
  637. u32 cfg_len;
  638. u32 fw_len;
  639. u32 cfg_crc;
  640. const u8 *cfg_raw_data; /* start address of configuration data */
  641. const u8 *fw_raw_data; /* start address of firmware data */
  642. struct mxt_data *data;
  643. };
  644. #if TSP_SEC_FACTORY
  645. extern struct class *sec_class;
  646. int mxt_read_all_diagnostic_data(struct mxt_data *data, u8 dbg_mode);
  647. #endif
  648. #ifdef CONFIG_SAMSUNG_LPM_MODE
  649. extern int poweroff_charging;
  650. #endif
  651. #if TSP_BOOSTER
  652. extern void mxt_set_dvfs_lock(struct mxt_data *data , int mode);
  653. extern void mxt_init_dvfs(struct mxt_data *data);
  654. #endif
  655. #if MXT_TKEY_BOOSTER
  656. extern void mxt_tkey_set_dvfs_lock(struct mxt_data *data , int mode);
  657. extern void mxt_tkey_init_dvfs(struct mxt_data *data);
  658. #endif
  659. bool set_threshold(void *device_data);
  660. #endif