pt_regs.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732
  1. /*
  2. * pt_regs.h
  3. * Parade TrueTouch(TM) Standard Product Registers.
  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.paradetech.com <[email protected]>
  28. *
  29. */
  30. #ifndef _PT_REGS_H
  31. #define _PT_REGS_H
  32. #define PT_PANEL_ID_DEFAULT 0
  33. #define PT_MAX_PATH_SIZE 128
  34. #define PT_PIP2_BIN_FILE_PATH "/data/ttdl/pt_fw.bin"
  35. #define PT_SUPPRESS_AUTO_BL 0
  36. #define PT_ALLOW_AUTO_BL 1
  37. #define PT_PIP2_MAX_FILE_SIZE 0x18000
  38. #define PT_PIP2_FILE_SECTOR_SIZE 0x1000
  39. #include <linux/device.h>
  40. #ifdef CONFIG_HAS_EARLYSUSPEND
  41. #include <linux/earlysuspend.h>
  42. #elif defined(CONFIG_FB)
  43. #include <linux/notifier.h>
  44. #include <linux/fb.h>
  45. #endif
  46. #include <asm/unaligned.h>
  47. #include <linux/debugfs.h>
  48. #include <linux/delay.h>
  49. #include <linux/err.h>
  50. #include <linux/gpio.h>
  51. #include <linux/hid.h>
  52. #include <linux/input.h>
  53. #include <linux/interrupt.h>
  54. #include <linux/irq.h>
  55. #include <linux/kernel.h>
  56. #include <linux/limits.h>
  57. #include <linux/module.h>
  58. #include <linux/of_device.h>
  59. #include <linux/of.h>
  60. #include <linux/pm_runtime.h>
  61. #include <linux/sched.h>
  62. #include <linux/slab.h>
  63. #include <linux/suspend.h>
  64. #include <linux/stringify.h>
  65. #include <linux/types.h>
  66. #include <linux/uaccess.h>
  67. #include <linux/workqueue.h>
  68. #include <linux/version.h>
  69. #include <linux/pt_core.h>
  70. #include <linux/i2c.h>
  71. #include <linux/of_gpio.h>
  72. #include <linux/timer.h>
  73. #include <linux/timex.h>
  74. #include <linux/rtc.h>
  75. #include <linux/regulator/consumer.h>
  76. #define STATUS_SUCCESS 0
  77. #define STATUS_FAIL -1
  78. #define PT_FW_FILE_PREFIX "tt_fw"
  79. #define PT_FW_FILE_SUFFIX ".bin"
  80. #define PT_FW_FILE_NAME "tt_fw.bin"
  81. #define PT_FW_RAM_FILE_NAME "tt_fw_ram.bin"
  82. /* Enable special TTDL features */
  83. #ifndef TTHE_TUNER_SUPPORT
  84. #define TTHE_TUNER_SUPPORT
  85. #endif
  86. #ifndef TTDL_DIAGNOSTICS
  87. #define TTDL_DIAGNOSTICS
  88. #endif
  89. #ifndef EASYWAKE_TSG6
  90. #define EASYWAKE_TSG6
  91. #endif
  92. #ifdef TTHE_TUNER_SUPPORT
  93. #define PT_TTHE_TUNER_FILE_NAME "tthe_tuner"
  94. #endif
  95. #define PT_MAX_PRBUF_SIZE PIPE_BUF
  96. #define PT_PR_TRUNCATED " truncated..."
  97. #define PT_DEFAULT_CORE_ID "pt_core0"
  98. #define PT_MAX_NUM_CORE_DEVS 5
  99. #define PT_IRQ_ASSERTED_VALUE 0
  100. #ifdef PT_ENABLE_MAX_ELEN
  101. #define PT_MAX_ELEN 100
  102. #endif
  103. /* Power Management Macros Enablement */
  104. #ifndef CONFIG_PM_SLEEP
  105. #define CONFIG_PM_SLEEP
  106. #endif
  107. /* Pin Control Macro Enablement */
  108. #ifndef PT_PINCTRL_EN
  109. #define PT_PINCTRL_EN
  110. #endif
  111. #ifndef TT7XXX_EXAMPLE
  112. #define TT7XXX_EXAMPLE
  113. #endif
  114. /*
  115. * The largest PIP message is the PIP2 FILE_WRITE which has:
  116. * 2 byte register
  117. * 4 byte header
  118. * 256 byte payload
  119. * 2 byte CRC
  120. */
  121. #define PT_MAX_PIP2_MSG_SIZE 264
  122. #define PT_MAX_PIP1_MSG_SIZE 255
  123. /*
  124. * The minimun size of PIP2 packet includes:
  125. * 2 byte length
  126. * 1 byte sequence
  127. * 1 byte command ID
  128. * 2 byte CRC
  129. */
  130. #define PT_MIN_PIP2_PACKET_SIZE 6
  131. static const u8 pt_data_block_security_key[] = {
  132. 0xA5, 0x01, 0x02, 0x03, 0xFF, 0xFE, 0xFD, 0x5A
  133. };
  134. /* Enum for debug reporting levels */
  135. enum PT_DEBUG_LEVEL {
  136. DL_QUIET = 0,
  137. DL_ERROR = 1,
  138. DL_WARN = 2,
  139. DL_INFO = 3,
  140. DL_DEBUG = 4,
  141. DL_MAX
  142. };
  143. #define PT_INITIAL_DEBUG_LEVEL DL_WARN
  144. /* Startup DUT enum status bitmask */
  145. enum PT_STARTUP_STATUS {
  146. STARTUP_STATUS_START = 0,
  147. STARTUP_STATUS_BL_RESET_SENTINEL = 0x001,
  148. STARTUP_STATUS_FW_RESET_SENTINEL = 0x002,
  149. STARTUP_STATUS_GET_DESC = 0x004,
  150. STARTUP_STATUS_FW_OUT_OF_BOOT = 0x008,
  151. STARTUP_STATUS_GET_RPT_DESC = 0x010,
  152. STARTUP_STATUS_GET_SYS_INFO = 0x020,
  153. STARTUP_STATUS_GET_CFG_CRC = 0x040,
  154. STARTUP_STATUS_RESTORE_PARM = 0x080,
  155. STARTUP_STATUS_COMPLETE = 0x100,
  156. STARTUP_STATUS_FULL = 0x1FF
  157. };
  158. #define PT_INITIAL_SHOW_TIME_STAMP 0
  159. /*
  160. * Print out all debug prints that are less then or equal to set level.
  161. */
  162. #define pt_debug(dev, dlevel, format, arg...) \
  163. do { \
  164. struct pt_core_data *cd_tmp = dev_get_drvdata(dev);\
  165. if (cd_tmp->debug_level >= dlevel) {\
  166. if (dlevel == DL_ERROR)\
  167. dev_err(dev, "[%d] "format, dlevel, ##arg);\
  168. else\
  169. dev_info(dev, "[%d] "format, dlevel, ##arg);\
  170. } \
  171. } while (0)
  172. enum PT_PIP_REPORT_ID {
  173. PT_PIP_INVALID_REPORT_ID = 0x00,
  174. PT_PIP_TOUCH_REPORT_ID = 0x01,
  175. PT_PIP_TOUCH_REPORT_WIN8_ID = 0x02,
  176. PT_PIP_CAPSENSE_BTN_REPORT_ID = 0x03,
  177. PT_PIP_WAKEUP_REPORT_ID = 0x04,
  178. PT_PIP_NOISE_METRIC_REPORT_ID = 0x05,
  179. PT_PIP_PUSH_BUTTON_REPORT_ID = 0x06,
  180. PT_PIP_SELFCAP_INPUT_REPORT_ID = 0x0D,
  181. PT_PIP_TRACKING_HEATMAP_REPORT_ID = 0x0E,
  182. PT_PIP_SENSOR_DATA_REPORT_ID = 0x0F,
  183. PT_PIP_NON_HID_RESPONSE_ID = 0x1F,
  184. PT_PIP_NON_HID_COMMAND_ID = 0x2F,
  185. PT_PIP_BL_RESPONSE_REPORT_ID = 0x30,
  186. PT_PIP_BL_COMMAND_REPORT_ID = 0x40
  187. };
  188. enum PT_HID_REPORT_ID {
  189. PT_HID_FINGER_REPORT_ID = 0x01,
  190. PT_HID_PEN_REPORT_ID = 0x02
  191. };
  192. /* HID IDs and commands */
  193. #define HID_VENDOR_ID 0x04B4
  194. #define HID_APP_PRODUCT_ID 0xC101
  195. #define HID_VERSION 0x0100
  196. #define HID_APP_REPORT_ID 0xF7
  197. #define HID_BL_REPORT_ID 0xFF
  198. #define HID_RESPONSE_REPORT_ID 0xF0
  199. #define HID_POWER_ON 0x0
  200. #define HID_POWER_SLEEP 0x1
  201. #define HID_POWER_STANDBY 0x2
  202. /* PIP1 offsets and masks */
  203. #define PIP1_RESP_REPORT_ID_OFFSET 2
  204. #define PIP1_RESP_COMMAND_ID_OFFSET 4
  205. #define PIP1_RESP_COMMAND_ID_MASK 0x7F
  206. #define PIP1_CMD_COMMAND_ID_OFFSET 6
  207. #define PIP1_CMD_COMMAND_ID_MASK 0x7F
  208. #define PIP1_SYSINFO_TTDATA_OFFSET 5
  209. #define PIP1_SYSINFO_SENSING_OFFSET 33
  210. #define PIP1_SYSINFO_BTN_OFFSET 48
  211. #define PIP1_SYSINFO_BTN_MASK 0xFF
  212. #define PIP1_SYSINFO_MAX_BTN 8
  213. /* Timeouts in ms */
  214. #define PT_PTSBC_INIT_WATCHDOG_TIMEOUT 20000
  215. #define PT_REQUEST_EXCLUSIVE_TIMEOUT 8000
  216. #define PT_WATCHDOG_TIMEOUT 2000
  217. #define PT_FW_EXIT_BOOT_MODE_TIMEOUT 1000
  218. #define PT_BL_WAIT_FOR_SENTINEL 500
  219. #define PT_REQUEST_ENUM_TIMEOUT 4000
  220. #define PT_GET_HID_DESCRIPTOR_TIMEOUT 500
  221. #define PT_HID_CMD_DEFAULT_TIMEOUT 500
  222. #define PT_PIP_CMD_DEFAULT_TIMEOUT 2000
  223. #define PT_PIP1_CMD_DEFAULT_TIMEOUT 1000
  224. #define PT_PIP1_START_BOOTLOADER_TIMEOUT 2000
  225. #define PT_PIP1_CMD_GET_SYSINFO_TIMEOUT 500
  226. #define PT_PIP1_CMD_CALIBRATE_IDAC_TIMEOUT 5000
  227. #define PT_PIP1_CMD_CALIBRATE_EXT_TIMEOUT 5000
  228. #define PT_PIP1_CMD_WRITE_CONF_BLOCK_TIMEOUT 400
  229. #define PT_PIP1_CMD_RUN_SELF_TEST_TIMEOUT 10000
  230. #define PT_PIP1_CMD_INITIATE_BL_TIMEOUT 20000
  231. #define PT_PIP1_CMD_PROGRAM_AND_VERIFY_TIMEOUT 400
  232. #define PT_PIP2_CMD_FILE_ERASE_TIMEOUT 3000
  233. /* Max counts */
  234. #define PT_WATCHDOG_RETRY_COUNT 30
  235. #define PT_BUS_READ_INPUT_RETRY_COUNT 2
  236. #define PT_FLUSH_BUS_BASED_ON_LEN 0
  237. #define PT_FLUSH_BUS_FULL_256_READ 1
  238. /* maximum number of concurrent tracks */
  239. #define TOUCH_REPORT_SIZE 10
  240. #define TOUCH_INPUT_HEADER_SIZE 7
  241. #define TOUCH_COUNT_BYTE_OFFSET 5
  242. #define BTN_REPORT_SIZE 9
  243. #define BTN_INPUT_HEADER_SIZE 5
  244. #define SENSOR_REPORT_SIZE 150
  245. #define SENSOR_HEADER_SIZE 4
  246. /* helpers */
  247. #define GET_NUM_TOUCHES(x) ((x) & 0x1F)
  248. #define IS_LARGE_AREA(x) ((x) & 0x20)
  249. #define IS_BAD_PKT(x) ((x) & 0x20)
  250. #define IS_TMO(t) ((t) == 0)
  251. #define HI_BYTE(x) (u8)(((x) >> 8) & 0xFF)
  252. #define LOW_BYTE(x) (u8)((x) & 0xFF)
  253. #define SET_CMD_LOW(byte, bits) \
  254. ((byte) = (((byte) & 0xF0) | ((bits) & 0x0F)))
  255. #define SET_CMD_HIGH(byte, bits)\
  256. ((byte) = (((byte) & 0x0F) | ((bits) & 0xF0)))
  257. #define GET_MASK(length) \
  258. ((1 << length) - 1)
  259. #define GET_FIELD(name, length, shift) \
  260. ((name >> shift) & GET_MASK(length))
  261. #define _base(x) ((x >= '0' && x <= '9') ? '0' : \
  262. (x >= 'a' && x <= 'f') ? 'a' - 10 : \
  263. (x >= 'A' && x <= 'F') ? 'A' - 10 : \
  264. '\255')
  265. #define HEXOF(x) (x - _base(x))
  266. #define IS_EASY_WAKE_CONFIGURED(x) \
  267. ((x) != 0 && (x) != 0xFF)
  268. #define IS_PIP_VER_GE(p, maj, min) \
  269. ((p)->ttdata.pip_ver_major > (maj) ? \
  270. 1 : \
  271. (((p)->ttdata.pip_ver_major == (maj) ? \
  272. ((p)->ttdata.pip_ver_minor >= (min) ? \
  273. 1 : 0) : \
  274. 0)))
  275. #define IS_PIP_VER_EQ(p, maj, min) \
  276. ((p)->ttdata.pip_ver_major == (maj) ? \
  277. ((p)->ttdata.pip_ver_minor == (min) ? \
  278. 1 : \
  279. 0 : \
  280. 0))
  281. #define PT_PANEL_ID_BITMASK 0x0000000C
  282. #define PT_PANEL_ID_SHIFT 2
  283. #define TTDL_PTVIRTDUT_SUPPORT 1
  284. /* DUT Debug commands (dut_debug sysfs) */
  285. #define PT_DUT_DBG_HID_RESET 50
  286. #define PT_DUT_DBG_HID_GET_REPORT 51 /* depricated */
  287. #define PT_DUT_DBG_HID_SET_REPORT 52 /* depricated */
  288. #define PT_DUT_DBG_HID_SET_POWER_ON 53
  289. #define PT_DUT_DBG_HID_SET_POWER_SLEEP 54
  290. #define PT_DUT_DBG_HID_SET_POWER_STANDBY 55
  291. #define PT_DUT_DBG_PIP_SOFT_RESET 97
  292. #define PT_DUT_DBG_RESET 98
  293. #define PT_DUT_DBG_PIP_NULL 100
  294. #define PT_DUT_DBG_PIP_ENTER_BL 101
  295. #define PT_DUT_DBG_HID_SYSINFO 102
  296. #define PT_DUT_DBG_PIP_SUSPEND_SCAN 103
  297. #define PT_DUT_DBG_PIP_RESUME_SCAN 104
  298. #define PT_DUT_DBG_HID_DESC 109
  299. /* Driver Debug commands (drv_debug sysfs) */
  300. #define PT_DRV_DBG_SUSPEND 4
  301. #define PT_DRV_DBG_RESUME 5
  302. #define PT_DRV_DBG_STOP_WD 105
  303. #define PT_DRV_DBG_START_WD 106
  304. #define PT_DRV_DBG_TTHE_TUNER_EXIT 107
  305. #define PT_DRV_DBG_TTHE_BUF_CLEAN 108
  306. #define PT_DRV_DBG_CLEAR_PARM_LIST 110
  307. #define PT_DRV_DBG_FORCE_BUS_READ 111
  308. #define PT_DRV_DBG_CLEAR_CAL_DATA 112
  309. /*
  310. * Commands that require additional parameters
  311. * will be in the 200 range. Commands that do not
  312. * require additional parameters remain below 200.
  313. */
  314. #define PT_DRV_DBG_REPORT_LEVEL 200
  315. #define PT_DRV_DBG_WATCHDOG_INTERVAL 201
  316. #define PT_DRV_DBG_SHOW_TIMESTAMP 202
  317. #define PT_DRV_DBG_SET_GENERATION 210
  318. #ifdef TTDL_DIAGNOSTICS
  319. #define PT_DRV_DBG_FLUSH_BUS 204 /* deprecated */
  320. #define PT_DRV_DBG_SETUP_PWR 205
  321. #define PT_DRV_DBG_GET_PUT_SYNC 206
  322. #define PT_DRV_DBG_SET_PIP2_LAUNCH_APP 207 /* deprecated */
  323. #define PT_DRV_DBG_SET_TT_DATA 208
  324. #define PT_DRV_DBG_SET_RUN_FW_PIN 209 /* deprecated */
  325. #define PT_DRV_DBG_SET_BRIDGE_MODE 211
  326. #define PT_DRV_DBG_SET_I2C_ADDRESS 212
  327. #define PT_DRV_DBG_SET_FLASHLESS_DUT 213
  328. #define PT_DRV_DBG_SET_FORCE_SEQ 214
  329. #define PT_DRV_DBG_BL_WITH_NO_INT 215
  330. #define PT_DRV_DBG_CAL_CACHE_IN_HOST 216
  331. #define PT_DRV_DBG_MULTI_CHIP 217
  332. #define PT_DRV_DBG_SET_PANEL_ID_TYPE 218
  333. #define PT_DRV_DBG_PIP_TIMEOUT 219
  334. #define PT_DRV_DBG_TTHE_HID_USB_FORMAT 220
  335. #ifdef TTDL_PTVIRTDUT_SUPPORT
  336. #define PT_DRV_DBG_SET_HW_DETECT 298
  337. #define PT_DRV_DBG_VIRTUAL_I2C_DUT 299
  338. #endif /* TTDL_PTVIRTDUT_SUPPORT */
  339. /* TTDL Built In Self Test selection bit masks */
  340. #define PT_TTDL_BIST_BUS_TEST 0x01
  341. #define PT_TTDL_BIST_IRQ_TEST 0x02
  342. #define PT_TTDL_BIST_TP_XRES_TEST 0x04
  343. #define PT_TTDL_BIST_SLAVE_BUS_TEST 0x08
  344. #define PT_TTDL_BIST_SLAVE_IRQ_TEST 0x10
  345. #define PT_TTDL_BIST_SLAVE_XRES_TEST 0x20
  346. #define SLAVE_DETECT_MASK 0x01
  347. #define VIRT_MAX_IRQ_RELEASE_TIME_US 500000
  348. #endif /* TTDL DIAGNOSTICS */
  349. /* Recognized usages */
  350. /* undef them first for possible redefinition in Linux */
  351. #undef HID_DI_PRESSURE
  352. #undef HID_DI_TIP
  353. #undef HID_DI_CONTACTID
  354. #undef HID_DI_CONTACTCOUNT
  355. #undef HID_DI_SCANTIME
  356. #define HID_DI_PRESSURE 0x000d0030
  357. #define HID_DI_TIP 0x000d0042
  358. #define HID_DI_CONTACTID 0x000d0051
  359. #define HID_DI_CONTACTCOUNT 0x000d0054
  360. #define HID_DI_SCANTIME 0x000d0056
  361. /* Parade vendor specific usages */
  362. #define HID_PT_UNDEFINED 0xff010000
  363. #define HID_PT_BOOTLOADER 0xff010001
  364. #define HID_PT_TOUCHAPPLICATION 0xff010002
  365. #define HID_PT_BUTTONS 0xff010020
  366. #define HID_PT_GENERICITEM 0xff010030
  367. #define HID_PT_LARGEOBJECT 0xff010040
  368. #define HID_PT_NOISEEFFECTS 0xff010041
  369. #define HID_PT_REPORTCOUNTER 0xff010042
  370. #define HID_PT_TOUCHTYPE 0xff010060
  371. #define HID_PT_EVENTID 0xff010061
  372. #define HID_PT_MAJORAXISLENGTH 0xff010062
  373. #define HID_PT_MINORAXISLENGTH 0xff010063
  374. #define HID_PT_ORIENTATION 0xff010064
  375. #define HID_PT_BUTTONSIGNAL 0xff010065
  376. #define HID_PT_MAJOR_CONTACT_AXIS_LENGTH 0xff010066
  377. #define HID_PT_MINOR_CONTACT_AXIS_LENGTH 0xff010067
  378. #define HID_PT_TCH_COL_USAGE_PG 0x000D0022
  379. #define HID_PT_BTN_COL_USAGE_PG 0xFF010020
  380. #define PANEL_ID_NOT_ENABLED 0xFF
  381. #ifdef EASYWAKE_TSG6
  382. #define GESTURE_DOUBLE_TAP (1)
  383. #define GESTURE_TWO_FINGERS_SLIDE (2)
  384. #define GESTURE_TOUCH_DETECTED (3)
  385. #define GESTURE_PUSH_BUTTON (4)
  386. #define GESTURE_SINGLE_SLIDE_DE_TX (5)
  387. #define GESTURE_SINGLE_SLIDE_IN_TX (6)
  388. #define GESTURE_SINGLE_SLIDE_DE_RX (7)
  389. #define GESTURE_SINGLE_SLIDE_IN_RX (8)
  390. #endif
  391. /* FW RAM parameters */
  392. #define PT_RAM_ID_TOUCHMODE_ENABLED 0x02
  393. #define PT_RAM_ID_PROXIMITY_ENABLE 0x20
  394. #define PT_RAM_ID_TOUCHMODE_ENABLED_SIZE 1
  395. #define PT_RAM_ID_PROXIMITY_ENABLE_SIZE 1
  396. /* abs signal capabilities offsets in the frameworks array */
  397. enum pt_sig_caps {
  398. PT_SIGNAL_OST,
  399. PT_MIN_OST,
  400. PT_MAX_OST,
  401. PT_FUZZ_OST,
  402. PT_FLAT_OST,
  403. PT_NUM_ABS_SET /* number of signal capability fields */
  404. };
  405. /* helpers */
  406. #define NUM_SIGNALS(frmwrk) ((frmwrk)->size / PT_NUM_ABS_SET)
  407. #define PARAM(frmwrk, sig_ost, cap_ost) \
  408. ((frmwrk)->abs[((sig_ost) * PT_NUM_ABS_SET) + (cap_ost)])
  409. #define PARAM_SIGNAL(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, PT_SIGNAL_OST)
  410. #define PARAM_MIN(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, PT_MIN_OST)
  411. #define PARAM_MAX(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, PT_MAX_OST)
  412. #define PARAM_FUZZ(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, PT_FUZZ_OST)
  413. #define PARAM_FLAT(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, PT_FLAT_OST)
  414. /* abs axis signal offsets in the framworks array */
  415. enum pt_sig_ost {
  416. PT_ABS_X_OST,
  417. PT_ABS_Y_OST,
  418. PT_ABS_P_OST,
  419. PT_ABS_W_OST,
  420. PT_ABS_ID_OST,
  421. PT_ABS_MAJ_OST,
  422. PT_ABS_MIN_OST,
  423. PT_ABS_OR_OST,
  424. PT_ABS_TOOL_OST,
  425. PT_ABS_D_OST,
  426. PT_NUM_ABS_OST /* number of abs signals */
  427. };
  428. enum hid_command {
  429. HID_CMD_RESERVED = 0x0,
  430. HID_CMD_RESET = 0x1,
  431. HID_CMD_GET_REPORT = 0x2,
  432. HID_CMD_SET_REPORT = 0x3,
  433. HID_CMD_GET_IDLE = 0x4,
  434. HID_CMD_SET_IDLE = 0x5,
  435. HID_CMD_GET_PROTOCOL = 0x6,
  436. HID_CMD_SET_PROTOCOL = 0x7,
  437. HID_CMD_SET_POWER = 0x8,
  438. HID_CMD_VENDOR = 0xE,
  439. };
  440. enum PIP1_cmd_type {
  441. PIP1_CMD_TYPE_FW,
  442. PIP1_CMD_TYPE_BL,
  443. };
  444. /* PIP BL cmd IDs and input for dut_debug sysfs */
  445. enum pip1_bl_cmd_id {
  446. PIP1_BL_CMD_ID_VERIFY_APP_INTEGRITY = 0x31, /* 49 */
  447. PIP1_BL_CMD_ID_GET_INFO = 0x38, /* 56 */
  448. PIP1_BL_CMD_ID_PROGRAM_AND_VERIFY = 0x39, /* 57 */
  449. PIP1_BL_CMD_ID_LAUNCH_APP = 0x3B, /* 59 */
  450. PIP1_BL_CMD_ID_GET_PANEL_ID = 0x3E, /* 62 */
  451. PIP1_BL_CMD_ID_INITIATE_BL = 0x48, /* 72 */
  452. PIP1_BL_CMD_ID_LAST,
  453. };
  454. #define PIP1_BL_SOP 0x1
  455. #define PIP1_BL_EOP 0x17
  456. /* PIP1 Command/Response IDs */
  457. enum PIP1_CMD_ID {
  458. PIP1_CMD_ID_NULL = 0x00,
  459. PIP1_CMD_ID_START_BOOTLOADER = 0x01,
  460. PIP1_CMD_ID_GET_SYSINFO = 0x02,
  461. PIP1_CMD_ID_SUSPEND_SCANNING = 0x03,
  462. PIP1_CMD_ID_RESUME_SCANNING = 0x04,
  463. PIP1_CMD_ID_GET_PARAM = 0x05,
  464. PIP1_CMD_ID_SET_PARAM = 0x06,
  465. PIP1_CMD_ID_GET_NOISE_METRICS = 0x07,
  466. PIP1_CMD_ID_RESERVED = 0x08,
  467. PIP1_CMD_ID_ENTER_EASYWAKE_STATE = 0x09,
  468. PIP1_CMD_ID_VERIFY_CONFIG_BLOCK_CRC = 0x20,
  469. PIP1_CMD_ID_GET_CONFIG_ROW_SIZE = 0x21,
  470. PIP1_CMD_ID_READ_DATA_BLOCK = 0x22,
  471. PIP1_CMD_ID_WRITE_DATA_BLOCK = 0x23,
  472. PIP1_CMD_ID_GET_DATA_STRUCTURE = 0x24,
  473. PIP1_CMD_ID_LOAD_SELF_TEST_PARAM = 0x25,
  474. PIP1_CMD_ID_RUN_SELF_TEST = 0x26,
  475. PIP1_CMD_ID_GET_SELF_TEST_RESULT = 0x27,
  476. PIP1_CMD_ID_CALIBRATE_IDACS = 0x28,
  477. PIP1_CMD_ID_INITIALIZE_BASELINES = 0x29,
  478. PIP1_CMD_ID_EXEC_PANEL_SCAN = 0x2A,
  479. PIP1_CMD_ID_RETRIEVE_PANEL_SCAN = 0x2B,
  480. PIP1_CMD_ID_START_SENSOR_DATA_MODE = 0x2C,
  481. PIP1_CMD_ID_STOP_SENSOR_DATA_MODE = 0x2D,
  482. PIP1_CMD_ID_START_TRACKING_HEATMAP_MODE = 0x2E,
  483. PIP1_CMD_ID_START_SELF_CAP_RPT_MODE = 0x2F,
  484. PIP1_CMD_ID_CALIBRATE_DEVICE_EXTENDED = 0x30,
  485. PIP1_CMD_ID_INT_PIN_OVERRIDE = 0x40,
  486. PIP1_CMD_ID_STORE_PANEL_SCAN = 0x60,
  487. PIP1_CMD_ID_PROCESS_PANEL_SCAN = 0x61,
  488. PIP1_CMD_ID_DISCARD_INPUT_REPORT,
  489. PIP1_CMD_ID_LAST,
  490. PIP1_CMD_ID_USER_CMD,
  491. };
  492. /* PIP2 Command/Response data and structures */
  493. enum PIP2_CMD_ID {
  494. PIP2_CMD_ID_PING = 0x00,
  495. PIP2_CMD_ID_STATUS = 0x01,
  496. PIP2_CMD_ID_CTRL = 0x02,
  497. PIP2_CMD_ID_CONFIG = 0x03,
  498. PIP2_CMD_ID_RESERVE = 0x04,
  499. PIP2_CMD_ID_CLEAR = 0x05,
  500. PIP2_CMD_ID_RESET = 0x06,
  501. PIP2_CMD_ID_VERSION = 0x07,
  502. PIP2_CMD_ID_FILE_OPEN = 0x10,
  503. PIP2_CMD_ID_FILE_CLOSE = 0x11,
  504. PIP2_CMD_ID_FILE_READ = 0x12,
  505. PIP2_CMD_ID_FILE_WRITE = 0x13,
  506. PIP2_CMD_ID_FILE_IOCTL = 0x14,
  507. PIP2_CMD_ID_FLASH_INFO = 0x15,
  508. PIP2_CMD_ID_EXECUTE = 0x16,
  509. PIP2_CMD_ID_GET_LAST_ERRNO = 0x17,
  510. PIP2_CMD_ID_EXIT_HOST_MODE = 0x18,
  511. PIP2_CMD_ID_READ_GPIO = 0x19,
  512. PIP2_CMD_EXECUTE_SCAN = 0x21,
  513. PIP2_CMD_SET_PARAMETER = 0x40,
  514. PIP2_CMD_GET_PARAMETER = 0x41,
  515. PIP2_CMD_SET_DDI_REG = 0x42,
  516. PIP2_CMD_GET_DDI_REG = 0x43,
  517. PIP2_CMD_ID_END = 0x7F
  518. };
  519. enum PIP2_STATUS_EXEC_RUNNING {
  520. PIP2_STATUS_BOOT_EXEC = 0x00,
  521. PIP2_STATUS_APP_EXEC = 0x01,
  522. };
  523. /* FW_SYS_MODE_UNDEFINED must be 1 greater than FW_SYS_MODE_MAX */
  524. enum PIP2_FW_SYSTEM_MODE {
  525. FW_SYS_MODE_BOOT = 0x00,
  526. FW_SYS_MODE_SCANNING = 0x01,
  527. FW_SYS_MODE_DEEP_SLEEP = 0x02,
  528. FW_SYS_MODE_TEST = 0x03,
  529. FW_SYS_MODE_DEEP_STANDBY = 0x04,
  530. FW_SYS_MODE_MAX = FW_SYS_MODE_DEEP_STANDBY,
  531. FW_SYS_MODE_UNDEFINED = FW_SYS_MODE_MAX + 1,
  532. };
  533. /* PIP2 Command/Response data and structures */
  534. enum PIP2_FILE_ID {
  535. PIP2_RAM_FILE = 0x00,
  536. PIP2_FW_FILE = 0x01,
  537. PIP2_CONFIG_FILE = 0x02,
  538. PIP2_FILE_3 = 0x03,
  539. PIP2_FILE_4 = 0x04,
  540. PIP2_FILE_5 = 0x05,
  541. PIP2_FILE_6 = 0x06,
  542. PIP2_FILE_7 = 0x07,
  543. PIP2_FILE_MAX = PIP2_FILE_7,
  544. };
  545. /* Optimize packet sizes per Allwinner H3 bus drivers */
  546. #define PIP2_FILE_WRITE_LEN_PER_PACKET 245
  547. #define PIP2_BL_I2C_FILE_WRITE_LEN_PER_PACKET 245
  548. #define PIP2_BL_SPI_FILE_WRITE_LEN_PER_PACKET 256
  549. enum DUT_GENERATION {
  550. DUT_UNKNOWN = 0x00,
  551. DUT_PIP1_ONLY = 0x01,
  552. DUT_PIP2_CAPABLE = 0x02,
  553. };
  554. enum PIP2_RSP_ERR {
  555. PIP2_RSP_ERR_NONE = 0x00,
  556. PIP2_RSP_ERR_BUSY = 0x01,
  557. PIP2_RSP_ERR_INIT_FAILURE = 0x02,
  558. PIP2_RSP_ERR_ALREADY_OPEN = 0x03,
  559. PIP2_RSP_ERR_NOT_OPEN = 0x04,
  560. PIP2_RSP_ERR_IO_FAILURE = 0x05,
  561. PIP2_RSP_ERR_UNKNOWN_IOCTL = 0x06,
  562. PIP2_RSP_ERR_BAD_ADDRESS = 0x07,
  563. PIP2_RSP_ERR_BAD_FILE = 0x08,
  564. PIP2_RSP_ERR_END_OF_FILE = 0x09,
  565. PIP2_RSP_ERR_TOO_MANY_FILES = 0x0A,
  566. PIP2_RSP_ERR_TIMEOUT = 0x0B,
  567. PIP2_RSP_ERR_ABORTED = 0x0C,
  568. PIP2_RSP_ERR_CRC = 0x0D,
  569. PIP2_RSP_ERR_UNKNOWN_REC_TYPE = 0x0E,
  570. PIP2_RSP_ERR_BAD_FRAME = 0x0F,
  571. PIP2_RSP_ERR_NO_PERMISSION = 0x10,
  572. PIP2_RSP_ERR_UNKNOWN_COMMAND = 0x11,
  573. PIP2_RSP_ERR_INVALID_PARAM = 0x12,
  574. PIP2_RSP_ERR_IO_ALREADY_ACTIVE = 0x13,
  575. PIP2_RSP_ERR_SHUTDOWN = 0x14,
  576. PIP2_RSP_ERR_INVALID_IMAGE = 0x15,
  577. PIP2_RSP_ERR_UNKNOWN_REGISTER = 0x16,
  578. PIP2_RSP_ERR_BAD_LENGTH = 0x17,
  579. PIP2_RSP_ERR_TRIM_FAILURE = 0x18,
  580. };
  581. /*
  582. * Extra bytes for PIP2 = 4 + 2:
  583. * 4 byte header - (len_lsb, len_msb, report ID, Tag, Sequence)
  584. * 2 byte footer - (crc_lsb, crc_msb)
  585. */
  586. #define PIP2_CMD_COMMAND_ID_OFFSET 5
  587. #define PIP2_CMD_COMMAND_ID_MASK 0x7F
  588. #define PIP2_RESP_COMMAND_ID_OFFSET 3
  589. #define PIP2_RESP_SEQUENCE_OFFSET 2
  590. #define PIP2_RESP_SEQUENCE_MASK 0x0F
  591. #define PIP2_RESP_REPORT_ID_OFFSET 3
  592. #define PIP2_RESP_STATUS_OFFSET 4
  593. #define PIP2_RESP_BODY_OFFSET 5
  594. #define PIP2_CRC_SIZE 2
  595. #define PIP2_LEN_FIELD_SIZE 2
  596. #define PIP2_VERSION_CHIP_REV_OFFSET 14
  597. #define PIP2_EXTRA_BYTES_NUM (PIP2_RESP_STATUS_OFFSET + PIP2_CRC_SIZE)
  598. /* File IOCTL commands */
  599. #define PIP2_FILE_IOCTL_CODE_ERASE_FILE 0
  600. #define PIP2_FILE_IOCTL_CODE_SEEK_POINTER 1
  601. #define PIP2_FILE_IOCTL_CODE_AES_CONTROL 2
  602. #define PIP2_FILE_IOCTL_CODE_FILE_STATS 3
  603. #define PIP2_FILE_IOCTL_CODE_FILE_CRC 4
  604. struct pip2_cmd_structure {
  605. u8 reg[2];
  606. u16 len;
  607. u8 id;
  608. u8 seq;
  609. u8 *data;
  610. u8 crc[2]; /* MSB:crc[0], LSB:crc[1] */
  611. };
  612. struct pip2_cmd_response_structure {
  613. u8 id;
  614. u16 response_len;
  615. u32 response_time_min;
  616. u32 response_time_max;
  617. };
  618. enum pip1_bl_status {
  619. ERROR_SUCCESS,
  620. ERROR_KEY,
  621. ERROR_VERIFICATION,
  622. ERROR_LENGTH,
  623. ERROR_DATA,
  624. ERROR_COMMAND,
  625. ERROR_CRC = 8,
  626. ERROR_FLASH_ARRAY,
  627. ERROR_FLASH_ROW,
  628. ERROR_FLASH_PROTECTION,
  629. ERROR_UNKNOWN = 15,
  630. ERROR_INVALID,
  631. };
  632. enum pt_mode {
  633. PT_MODE_UNKNOWN = 0,
  634. PT_MODE_BOOTLOADER = 1,
  635. PT_MODE_OPERATIONAL = 2,
  636. PT_MODE_IGNORE = 255,
  637. };
  638. enum PT_ENTER_BL_RESULT {
  639. PT_ENTER_BL_PASS = 0,
  640. PT_ENTER_BL_ERROR = 1,
  641. PT_ENTER_BL_RESET_FAIL = 2,
  642. PT_ENTER_BL_HID_START_BL_FAIL = 3,
  643. PT_ENTER_BL_CONFIRM_FAIL = 4,
  644. PT_ENTER_BL_GET_FLASH_INFO_FAIL = 5,
  645. };
  646. enum TTDL_EXTENDED_ERROR_CODES {
  647. EX_ERR_FREAD = 400,
  648. EX_ERR_FWRITE = 401,
  649. EX_ERR_FOPEN = 402,
  650. EX_ERR_FCLOSE = 403,
  651. EX_ERR_FLEN = 404,
  652. };
  653. enum pt_cmd_status {
  654. PT_CMD_STATUS_SUCCESS = 0,
  655. PT_CMD_STATUS_FAILURE = 1,
  656. };
  657. enum {
  658. PT_IC_GRPNUM_RESERVED,
  659. PT_IC_GRPNUM_CMD_REGS,
  660. PT_IC_GRPNUM_TCH_REP,
  661. PT_IC_GRPNUM_DATA_REC,
  662. PT_IC_GRPNUM_TEST_REC,
  663. PT_IC_GRPNUM_PCFG_REC,
  664. PT_IC_GRPNUM_TCH_PARM_VAL,
  665. PT_IC_GRPNUM_TCH_PARM_SIZE,
  666. PT_IC_GRPNUM_RESERVED1,
  667. PT_IC_GRPNUM_RESERVED2,
  668. PT_IC_GRPNUM_OPCFG_REC,
  669. PT_IC_GRPNUM_DDATA_REC,
  670. PT_IC_GRPNUM_MDATA_REC,
  671. PT_IC_GRPNUM_TEST_REGS,
  672. PT_IC_GRPNUM_BTN_KEYS,
  673. PT_IC_GRPNUM_TTHE_REGS,
  674. PT_IC_GRPNUM_SENSING_CONF,
  675. PT_IC_GRPNUM_NUM,
  676. };
  677. enum pt_event_id {
  678. PT_EV_NO_EVENT,
  679. PT_EV_TOUCHDOWN,
  680. PT_EV_MOVE, /* significant displacement (> act dist) */
  681. PT_EV_LIFTOFF, /* record reports last position */
  682. };
  683. enum pt_object_id {
  684. PT_OBJ_STANDARD_FINGER,
  685. PT_OBJ_PROXIMITY,
  686. PT_OBJ_STYLUS,
  687. PT_OBJ_GLOVE,
  688. };
  689. enum pt_self_test_result {
  690. PT_ST_RESULT_PASS = 0,
  691. PT_ST_RESULT_FAIL = 1,
  692. PT_ST_RESULT_ABORTED = 2,
  693. PT_ST_RESULT_PARAM_ERR = 3,
  694. PT_ST_RESULT_CFG_ERR = 4,
  695. PT_ST_RESULT_CAL_ERR = 5,
  696. PT_ST_RESULT_DDI_STATE_ERR = 6,
  697. PT_ST_RESULT_HOST_MUST_INTERPRET = 0xFF,
  698. };
  699. #define PT_ST_PRINT_RESULTS true
  700. #define PT_ST_NOPRINT false
  701. #define PT_ST_GET_RESULTS true
  702. #define PT_ST_DONT_GET_RESULTS false
  703. /*
  704. * Maximum number of parameters for the fw_self_test sysfs (255 - 12 + 2)
  705. * 255 - Max PIP message size
  706. * 12 - Header size for PIP message 0x25 (Load Self Test Parameters)
  707. * 2 - Additional parameters for fw_self_test for test_id and format
  708. */
  709. #define PT_FW_SELF_TEST_MAX_PARM 245
  710. enum pt_self_test_id {
  711. PT_ST_ID_NULL = 0,
  712. PT_ST_ID_BIST = 1,
  713. PT_ST_ID_SHORTS = 2,
  714. PT_ST_ID_OPENS = 3,
  715. PT_ST_ID_AUTOSHORTS = 4,
  716. PT_ST_ID_CM_PANEL = 5,
  717. PT_ST_ID_CP_PANEL = 6,
  718. PT_ST_ID_CM_BUTTON = 7,
  719. PT_ST_ID_CP_BUTTON = 8,
  720. PT_ST_ID_FORCE = 9,
  721. PT_ST_ID_OPENS_HIZ = 10,
  722. PT_ST_ID_OPENS_GND = 11,
  723. PT_ST_ID_CP_LFT = 12,
  724. PT_ST_ID_SC_NOISE = 13,
  725. PT_ST_ID_LFT_NOISE = 14,
  726. PT_ST_ID_CP_CHIP_ROUTE_PARASITIC_CAP = 15,
  727. PT_ST_ID_NORMALIZED_RAW_CNT_PANEL = 16,
  728. PT_ST_ID_NORMALIZED_RAW_CNT_LFT = 17,
  729. PT_ST_ID_INVALID = 255
  730. };
  731. enum pt_scan_state {
  732. PT_SCAN_STATE_UNKNOWN = 0,
  733. PT_SCAN_STATE_ACTIVE = 1,
  734. PT_SCAN_STATE_INACTIVE = 2,
  735. };
  736. #define PT_CAL_DATA_MAX_SIZE 2048
  737. #define PT_CAL_DATA_ROW_SIZE 128
  738. #define PT_WAFER_LOT_SIZE 5
  739. #define PT_UID_SIZE 12
  740. enum pt_cal_data_actions {
  741. PT_CAL_DATA_SAVE = 0,
  742. PT_CAL_DATA_RESTORE = 1,
  743. PT_CAL_DATA_CLEAR = 2,
  744. PT_CAL_DATA_INFO = 3
  745. };
  746. enum pt_feature_enable_state {
  747. PT_FEATURE_DISABLE = 0,
  748. PT_FEATURE_ENABLE = 1
  749. };
  750. #define PT_NUM_MFGID 8
  751. /* System Information interface definitions */
  752. struct pt_ttdata_dev {
  753. u8 pip_ver_major;
  754. u8 pip_ver_minor;
  755. __le16 fw_pid;
  756. u8 fw_ver_major;
  757. u8 fw_ver_minor;
  758. __le32 revctrl;
  759. __le16 fw_ver_conf;
  760. u8 bl_ver_major;
  761. u8 bl_ver_minor;
  762. __le16 jtag_si_id_l;
  763. __le16 jtag_si_id_h;
  764. u8 mfg_id[PT_NUM_MFGID];
  765. __le16 post_code;
  766. } __packed;
  767. /* Struct to cast over PIP2 VERSION response */
  768. struct pt_pip2_version_full {
  769. u8 status_code;
  770. u8 pip2_version_lsb;
  771. u8 pip2_version_msb;
  772. u8 fw_version_lsb;
  773. u8 fw_version_msb;
  774. u8 bl_version_lsb;
  775. u8 bl_version_msb;
  776. __le16 chip_rev;
  777. __le16 chip_id;
  778. u8 uid[PT_UID_SIZE];
  779. } __packed;
  780. struct pt_pip2_version {
  781. u8 status_code;
  782. u8 pip2_version_lsb;
  783. u8 pip2_version_msb;
  784. u8 bl_version_lsb;
  785. u8 bl_version_msb;
  786. u8 fw_version_lsb;
  787. u8 fw_version_msb;
  788. __le16 chip_id;
  789. __le16 chip_rev;
  790. } __packed;
  791. struct pt_sensing_conf_data_dev {
  792. u8 electrodes_x;
  793. u8 electrodes_y;
  794. __le16 len_x;
  795. __le16 len_y;
  796. __le16 res_x;
  797. __le16 res_y;
  798. __le16 max_z;
  799. u8 origin_x;
  800. u8 origin_y;
  801. u8 panel_id;
  802. u8 btn;
  803. u8 scan_mode;
  804. u8 max_num_of_tch_per_refresh_cycle;
  805. } __packed;
  806. struct pt_ttdata {
  807. u8 pip_ver_major;
  808. u8 pip_ver_minor;
  809. u8 bl_ver_major;
  810. u8 bl_ver_minor;
  811. u8 fw_ver_major;
  812. u8 fw_ver_minor;
  813. u16 fw_pid;
  814. u16 fw_ver_conf;
  815. u16 post_code;
  816. u32 revctrl;
  817. u16 jtag_id_l;
  818. u16 jtag_id_h;
  819. u8 mfg_id[PT_NUM_MFGID];
  820. u16 chip_rev;
  821. u16 chip_id;
  822. u8 uid[PT_UID_SIZE];
  823. };
  824. struct pt_sensing_conf_data {
  825. u16 res_x;
  826. u16 res_y;
  827. u16 max_z;
  828. u16 len_x;
  829. u16 len_y;
  830. u8 electrodes_x;
  831. u8 electrodes_y;
  832. u8 origin_x;
  833. u8 origin_y;
  834. u8 panel_id;
  835. u8 btn;
  836. u8 scan_mode;
  837. u8 max_tch;
  838. u8 rx_num;
  839. u8 tx_num;
  840. };
  841. enum pt_tch_abs { /* for ordering within the extracted touch data array */
  842. PT_TCH_X, /* X */
  843. PT_TCH_Y, /* Y */
  844. PT_TCH_P, /* P (Z) */
  845. PT_TCH_T, /* TOUCH ID */
  846. PT_TCH_E, /* EVENT ID */
  847. PT_TCH_O, /* OBJECT ID */
  848. PT_TCH_TIP, /* OBJECT ID */
  849. PT_TCH_MAJ, /* TOUCH_MAJOR */
  850. PT_TCH_MIN, /* TOUCH_MINOR */
  851. PT_TCH_OR, /* ORIENTATION */
  852. PT_TCH_NUM_ABS,
  853. };
  854. enum pt_tch_hdr {
  855. PT_TCH_TIME, /* SCAN TIME */
  856. PT_TCH_NUM, /* NUMBER OF RECORDS */
  857. PT_TCH_LO, /* LARGE OBJECT */
  858. PT_TCH_NOISE, /* NOISE EFFECT */
  859. PT_TCH_COUNTER, /* REPORT_COUNTER */
  860. PT_TCH_NUM_HDR,
  861. };
  862. static const char * const pt_tch_abs_string[] = {
  863. [PT_TCH_X] = "X",
  864. [PT_TCH_Y] = "Y",
  865. [PT_TCH_P] = "P",
  866. [PT_TCH_T] = "T",
  867. [PT_TCH_E] = "E",
  868. [PT_TCH_O] = "O",
  869. [PT_TCH_TIP] = "TIP",
  870. [PT_TCH_MAJ] = "MAJ",
  871. [PT_TCH_MIN] = "MIN",
  872. [PT_TCH_OR] = "OR",
  873. [PT_TCH_NUM_ABS] = "INVALID",
  874. };
  875. static const char * const pt_tch_hdr_string[] = {
  876. [PT_TCH_TIME] = "SCAN TIME",
  877. [PT_TCH_NUM] = "NUMBER OF RECORDS",
  878. [PT_TCH_LO] = "LARGE OBJECT",
  879. [PT_TCH_NOISE] = "NOISE EFFECT",
  880. [PT_TCH_COUNTER] = "REPORT_COUNTER",
  881. [PT_TCH_NUM_HDR] = "INVALID",
  882. };
  883. static const int pt_tch_abs_field_map[] = {
  884. [PT_TCH_X] = 0x00010030 /* HID_GD_X */,
  885. [PT_TCH_Y] = 0x00010031 /* HID_GD_Y */,
  886. [PT_TCH_P] = HID_DI_PRESSURE,
  887. [PT_TCH_T] = HID_DI_CONTACTID,
  888. [PT_TCH_E] = HID_PT_EVENTID,
  889. [PT_TCH_O] = HID_PT_TOUCHTYPE,
  890. [PT_TCH_TIP] = HID_DI_TIP,
  891. [PT_TCH_MAJ] = HID_PT_MAJORAXISLENGTH,
  892. [PT_TCH_MIN] = HID_PT_MINORAXISLENGTH,
  893. [PT_TCH_OR] = HID_PT_ORIENTATION,
  894. [PT_TCH_NUM_ABS] = 0,
  895. };
  896. static const int pt_tch_hdr_field_map[] = {
  897. [PT_TCH_TIME] = HID_DI_SCANTIME,
  898. [PT_TCH_NUM] = HID_DI_CONTACTCOUNT,
  899. [PT_TCH_LO] = HID_PT_LARGEOBJECT,
  900. [PT_TCH_NOISE] = HID_PT_NOISEEFFECTS,
  901. [PT_TCH_COUNTER] = HID_PT_REPORTCOUNTER,
  902. [PT_TCH_NUM_HDR] = 0,
  903. };
  904. #define PT_TOUCH_ID_MAX 32
  905. #define PT_NUM_EXT_TCH_FIELDS 3
  906. struct pt_tch_abs_params {
  907. size_t ofs; /* abs byte offset */
  908. size_t size; /* size in bits */
  909. size_t min; /* min value */
  910. size_t max; /* max value */
  911. size_t bofs; /* bit offset */
  912. u8 report;
  913. };
  914. struct pt_touch {
  915. int hdr[PT_TCH_NUM_HDR];
  916. int abs[PT_TCH_NUM_ABS];
  917. };
  918. /* button to keycode support */
  919. #define PT_BITS_PER_BTN 1
  920. #define PT_NUM_BTN_EVENT_ID ((1 << PT_BITS_PER_BTN) - 1)
  921. enum pt_btn_state {
  922. PT_BTN_RELEASED = 0,
  923. PT_BTN_PRESSED = 1,
  924. PT_BTN_NUM_STATE
  925. };
  926. struct pt_btn {
  927. bool enabled;
  928. int state; /* PT_BTN_PRESSED, PT_BTN_RELEASED */
  929. int key_code;
  930. };
  931. enum pt_ic_ebid {
  932. PT_TCH_PARM_EBID = 0x00,
  933. PT_MDATA_EBID = 0x01,
  934. PT_DDATA_EBID = 0x02,
  935. PT_CAL_EBID = 0xF0,
  936. };
  937. /* ttconfig block */
  938. #define PT_TTCONFIG_VERSION_OFFSET 8
  939. #define PT_TTCONFIG_VERSION_SIZE 2
  940. #define PT_TTCONFIG_VERSION_ROW 0
  941. struct pt_ttconfig {
  942. u16 version;
  943. u16 crc;
  944. };
  945. struct pt_report_desc_data {
  946. u16 tch_report_id;
  947. u16 tch_record_size;
  948. u16 tch_header_size;
  949. u16 btn_report_id;
  950. };
  951. struct pt_sysinfo {
  952. bool ready;
  953. struct pt_ttdata ttdata;
  954. struct pt_sensing_conf_data sensing_conf_data;
  955. struct pt_report_desc_data desc;
  956. int num_btns;
  957. struct pt_btn *btn;
  958. struct pt_ttconfig ttconfig;
  959. struct pt_tch_abs_params tch_hdr[PT_TCH_NUM_HDR];
  960. struct pt_tch_abs_params tch_abs[PT_TCH_NUM_ABS];
  961. u8 *xy_mode;
  962. u8 *xy_data;
  963. };
  964. struct pt_bl_info {
  965. bool ready;
  966. u16 chip_id;
  967. };
  968. enum pt_atten_type {
  969. PT_ATTEN_IRQ,
  970. PT_ATTEN_STARTUP,
  971. PT_ATTEN_EXCLUSIVE,
  972. PT_ATTEN_WAKE,
  973. PT_ATTEN_LOADER,
  974. PT_ATTEN_SUSPEND,
  975. PT_ATTEN_RESUME,
  976. PT_ATTEN_CANCEL_LOADER,
  977. PT_ATTEN_NUM_ATTEN,
  978. };
  979. enum pt_sleep_state {
  980. SS_SLEEP_OFF,
  981. SS_SLEEP_ON,
  982. SS_SLEEPING,
  983. SS_WAKING,
  984. };
  985. enum pt_fb_state {
  986. FB_ON,
  987. FB_OFF,
  988. };
  989. enum pt_startup_state {
  990. STARTUP_NONE,
  991. STARTUP_QUEUED,
  992. STARTUP_RUNNING,
  993. STARTUP_ILLEGAL,
  994. };
  995. struct pt_hid_desc {
  996. __le16 hid_desc_len;
  997. u8 packet_id;
  998. u8 reserved_byte;
  999. __le16 bcd_version;
  1000. __le16 report_desc_len;
  1001. __le16 report_desc_register;
  1002. __le16 input_register;
  1003. __le16 max_input_len;
  1004. __le16 output_register;
  1005. __le16 max_output_len;
  1006. __le16 command_register;
  1007. __le16 data_register;
  1008. __le16 vendor_id;
  1009. __le16 product_id;
  1010. __le16 version_id;
  1011. u8 reserved[4];
  1012. } __packed;
  1013. struct pt_hid_core {
  1014. u16 hid_vendor_id;
  1015. u16 hid_product_id;
  1016. __le16 hid_desc_register;
  1017. u16 hid_report_desc_len;
  1018. u16 hid_max_input_len;
  1019. u16 hid_max_output_len;
  1020. };
  1021. #define PT_HID_MAX_REPORTS 8
  1022. #define PT_HID_MAX_FIELDS 128
  1023. #define PT_HID_MAX_COLLECTIONS 3
  1024. #define PT_HID_MAX_NESTED_COLLECTIONS PT_HID_MAX_COLLECTIONS
  1025. /* Max input is for ASCII representation of hex characters */
  1026. #define PT_MAX_INPUT (PT_MAX_PIP2_MSG_SIZE * 2)
  1027. #define PT_PIP_1P7_EMPTY_BUF 0xFF00
  1028. enum pt_module_id {
  1029. PT_MODULE_MT,
  1030. PT_MODULE_BTN,
  1031. PT_MODULE_PROX,
  1032. PT_MODULE_LAST,
  1033. };
  1034. struct pt_mt_data;
  1035. struct pt_mt_function {
  1036. int (*mt_release)(struct device *dev);
  1037. int (*mt_probe)(struct device *dev, struct pt_mt_data *md);
  1038. void (*report_slot_liftoff)(struct pt_mt_data *md, int max_slots);
  1039. void (*input_sync)(struct input_dev *input);
  1040. void (*input_report)(struct input_dev *input, int sig, int t, int type);
  1041. void (*final_sync)(struct input_dev *input, int max_slots,
  1042. int mt_sync_count, unsigned long *ids);
  1043. int (*input_register_device)(struct input_dev *input, int max_slots);
  1044. };
  1045. struct pt_mt_data {
  1046. struct device *dev;
  1047. struct pt_mt_platform_data *pdata;
  1048. struct pt_sysinfo *si;
  1049. struct input_dev *input;
  1050. struct pt_mt_function mt_function;
  1051. struct mutex mt_lock;
  1052. bool is_suspended;
  1053. bool input_device_registered;
  1054. bool input_device_allocated;
  1055. char phys[NAME_MAX];
  1056. int num_prv_rec;
  1057. int or_min;
  1058. int or_max;
  1059. int t_min;
  1060. int t_max;
  1061. };
  1062. struct pt_btn_data {
  1063. struct device *dev;
  1064. struct pt_btn_platform_data *pdata;
  1065. struct pt_sysinfo *si;
  1066. struct input_dev *input;
  1067. struct mutex btn_lock;
  1068. bool is_suspended;
  1069. bool input_device_registered;
  1070. bool input_device_allocated;
  1071. char phys[NAME_MAX];
  1072. };
  1073. struct pt_proximity_data {
  1074. struct device *dev;
  1075. struct pt_proximity_platform_data *pdata;
  1076. struct pt_sysinfo *si;
  1077. struct input_dev *input;
  1078. struct mutex prox_lock;
  1079. struct mutex sysfs_lock;
  1080. int enable_count;
  1081. bool input_device_registered;
  1082. bool input_device_allocated;
  1083. char phys[NAME_MAX];
  1084. };
  1085. enum pt_calibrate_idacs_sensing_mode {
  1086. PT_CI_SM_MUTCAP_FINE,
  1087. PT_CI_SM_MUTCAP_BUTTON,
  1088. PT_CI_SM_SELFCAP,
  1089. };
  1090. enum pt_initialize_baselines_sensing_mode {
  1091. PT_IB_SM_MUTCAP = 1,
  1092. PT_IB_SM_BUTTON = 2,
  1093. PT_IB_SM_SELFCAP = 4,
  1094. PT_IB_SM_BALANCED = 8,
  1095. };
  1096. /* parameters for extended calibrate command(0x30)*/
  1097. struct pt_cal_ext_data {
  1098. u8 mode;
  1099. u8 data0;
  1100. u8 data1;
  1101. u8 data2;
  1102. } __packed;
  1103. #define PT_CAL_EXT_MODE_UNDEFINED 0xFF
  1104. #define PT_BIN_FILE_MIN_HDR_LENGTH 14
  1105. #define PT_BIN_FILE_MAX_HDR_LENGTH 18
  1106. struct pt_bin_file_hdr {
  1107. u8 length;
  1108. u16 ttpid;
  1109. u8 fw_major;
  1110. u8 fw_minor;
  1111. u32 fw_rev_ctrl;
  1112. u32 fw_crc;
  1113. u16 si_rev;
  1114. u16 si_id;
  1115. u16 config_ver;
  1116. u32 hex_file_size;
  1117. };
  1118. struct pt_core_nonhid_cmd {
  1119. int (*start_bl)(struct device *dev, int protect);
  1120. int (*suspend_scanning)(struct device *dev, int protect);
  1121. int (*resume_scanning)(struct device *dev, int protect);
  1122. int (*get_param)(struct device *dev, int protect, u8 param_id,
  1123. u32 *value);
  1124. int (*set_param)(struct device *dev, int protect, u8 param_id,
  1125. u32 value, u8 size);
  1126. int (*verify_cfg_block_crc)(struct device *dev, int protect,
  1127. u8 ebid, u8 *status, u16 *calculated_crc,
  1128. u16 *stored_crc);
  1129. int (*get_config_row_size)(struct device *dev, int protect,
  1130. u16 *row_size);
  1131. int (*get_data_structure)(struct device *dev, int protect,
  1132. u16 read_offset, u16 read_length, u8 data_id,
  1133. u8 *status, u8 *data_format, u16 *actual_read_len,
  1134. u8 *data);
  1135. int (*run_selftest)(struct device *dev, int protect, u8 test_id,
  1136. u8 write_idacs_to_flash, u8 *status, u8 *summary_result,
  1137. u8 *results_available);
  1138. int (*get_selftest_result)(struct device *dev, int protect,
  1139. u16 read_offset, u16 read_length, u8 test_id, u8 *status,
  1140. u16 *actual_read_len, u8 *data);
  1141. int (*load_self_test_param)(struct device *dev, int protect,
  1142. u8 self_test_id, u16 load_offset, u16 load_length,
  1143. u8 *parameters, u8 *status, u8 *ret_test_id, u16 *act_load_len);
  1144. int (*calibrate_idacs)(struct device *dev, int protect, u8 mode,
  1145. u8 *status);
  1146. int (*calibrate_ext)(struct device *dev,
  1147. int protect, struct pt_cal_ext_data *cal_data, u8 *status);
  1148. int (*initialize_baselines)(struct device *dev, int protect,
  1149. u8 test_id, u8 *status);
  1150. int (*exec_panel_scan)(struct device *dev, int protect, u8 scan_type);
  1151. int (*retrieve_panel_scan)(struct device *dev, int protect,
  1152. u16 read_offset, u16 read_count, u8 data_id,
  1153. u8 *response, u8 *config, u16 *actual_read_len,
  1154. u8 *read_buf);
  1155. int (*read_data_block)(struct device *dev, u16 row_number,
  1156. u16 length, u8 ebid, u16 *actual_read_len,
  1157. u8 *read_buf, u16 read_buf_size, u16 *crc);
  1158. int (*write_data_block)(struct device *dev, u16 row_number,
  1159. u16 write_length, u8 ebid, u8 *write_buf,
  1160. u8 *security_key, u16 *actual_write_len);
  1161. int (*user_cmd)(struct device *dev, int protect, u16 read_len,
  1162. u8 *read_buf, u16 write_len, u8 *write_buf,
  1163. u16 *actual_read_len);
  1164. int (*get_bl_info)(struct device *dev, int protect, u8 *return_data);
  1165. int (*initiate_bl)(struct device *dev, int protect, u16 key_size,
  1166. u8 *key_buf, u16 row_size, u8 *metadata_row_buf);
  1167. int (*launch_app)(struct device *dev, int protect);
  1168. int (*prog_and_verify)(struct device *dev, int protect, u16 data_len,
  1169. u8 *data_buf);
  1170. int (*verify_app_integrity)(struct device *dev, int protect,
  1171. u8 *result);
  1172. int (*get_panel_id)(struct device *dev, int protect, u8 *panel_id);
  1173. int (*pip2_send_cmd)(struct device *dev, int protect,
  1174. u8 id, u8 *data, u16 report_body_len, u8 *read_buf,
  1175. u16 *actual_read_len);
  1176. int (*pip2_send_cmd_no_int)(struct device *dev, int protect,
  1177. u8 id, u8 *data, u16 report_body_len, u8 *read_buf,
  1178. u16 *actual_read_len);
  1179. int (*get_bl_pip2_version)(struct device *dev);
  1180. int (*pip2_file_open)(struct device *dev, u8 file_no);
  1181. int (*pip2_file_close)(struct device *dev, u8 file_no);
  1182. int (*pip2_file_erase)(struct device *dev, u8 file_no, int *status);
  1183. int (*read_us_file)(struct device *dev, u8 *file_path, u8 *buf,
  1184. int *size);
  1185. int (*pip2_file_read)(struct device *dev, u8 file_no,
  1186. u16 num_bytes, u8 *read_buf);
  1187. int (*pip2_file_seek_offset)(struct device *dev, u8 file_no,
  1188. u32 read_offset, u32 write_offset);
  1189. int (*pip2_file_get_stats)(struct device *dev, u8 file_no,
  1190. u32 *address, u32 *file_size);
  1191. int (*pip2_file_crc)(struct device *dev, u8 file_no,
  1192. u32 offset, u32 length, u8 *read_buf);
  1193. int (*manage_cal_data)(struct device *dev, u8 action, u16 *size,
  1194. unsigned short *crc);
  1195. unsigned short (*calc_crc)(unsigned char *q, int len);
  1196. };
  1197. typedef int (*pt_atten_func) (struct device *);
  1198. struct pt_core_commands {
  1199. int (*subscribe_attention)(struct device *dev,
  1200. enum pt_atten_type type, char *id,
  1201. pt_atten_func func, int flags);
  1202. int (*unsubscribe_attention)(struct device *dev,
  1203. enum pt_atten_type type, char *id,
  1204. pt_atten_func func, int flags);
  1205. int (*request_exclusive)(struct device *dev, int timeout_ms);
  1206. int (*release_exclusive)(struct device *dev);
  1207. int (*request_reset)(struct device *dev, int protect);
  1208. int (*request_pip2_launch_app)(struct device *dev, int protect);
  1209. int (*request_enum)(struct device *dev, bool wait);
  1210. struct pt_sysinfo * (*request_sysinfo)(struct device *dev);
  1211. struct pt_loader_platform_data
  1212. *(*request_loader_pdata)(struct device *dev);
  1213. int (*request_stop_wd)(struct device *dev);
  1214. int (*request_start_wd)(struct device *dev);
  1215. int (*request_get_mode)(struct device *dev, int protect, u8 *mode);
  1216. int (*request_pip2_get_mode_sysmode)(struct device *dev, int protect,
  1217. u8 *mode, u8 *sys_mode);
  1218. int (*request_active_pip_prot)(struct device *dev, int protect,
  1219. u8 *pip_version_major, u8 *pip_version_minor);
  1220. int (*request_enable_scan_type)(struct device *dev, u8 scan_type);
  1221. int (*request_disable_scan_type)(struct device *dev, u8 scan_type);
  1222. int (*request_pip2_enter_bl)(struct device *dev, u8 *start_mode,
  1223. int *result);
  1224. int (*request_pip2_bin_hdr)(struct device *dev,
  1225. struct pt_bin_file_hdr *hdr);
  1226. int (*request_dut_generation)(struct device *dev);
  1227. int (*request_hw_version)(struct device *dev, char *hw_version);
  1228. int (*parse_sysfs_input)(struct device *dev,
  1229. const char *buf, size_t buf_size,
  1230. u32 *out_buf, size_t out_buf_size);
  1231. #ifdef TTHE_TUNER_SUPPORT
  1232. int (*request_tthe_print)(struct device *dev, u8 *buf, int buf_len,
  1233. const u8 *data_name);
  1234. #endif
  1235. #ifdef TTDL_DIAGNOSTICS
  1236. void (*request_toggle_err_gpio)(struct device *dev, u8 type);
  1237. #endif
  1238. struct pt_core_nonhid_cmd *nonhid_cmd;
  1239. int (*request_get_fw_mode)(struct device *dev, int protect,
  1240. u8 *sys_mode, u8 *mode);
  1241. };
  1242. enum core_command_protected_status {
  1243. PT_CORE_CMD_UNPROTECTED = 0,
  1244. PT_CORE_CMD_PROTECTED = 1
  1245. };
  1246. enum pt_err_gpio_type {
  1247. PT_ERR_GPIO_NONE = 0,
  1248. PT_ERR_GPIO_I2C_TRANS = 1,
  1249. PT_ERR_GPIO_IRQ_STUCK = 2,
  1250. PT_ERR_GPIO_EXCLUSIVE_ACCESS = 3,
  1251. PT_ERR_GPIO_EMPTY_PACKET = 4,
  1252. PT_ERR_GPIO_BL_RETRY_PACKET = 5,
  1253. PT_ERR_GPIO_MAX_TYPE = PT_ERR_GPIO_BL_RETRY_PACKET,
  1254. };
  1255. struct pt_features {
  1256. uint8_t easywake;
  1257. uint8_t noise_metric;
  1258. uint8_t tracking_heatmap;
  1259. uint8_t sensor_data;
  1260. };
  1261. #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PM_RUNTIME)
  1262. #if (KERNEL_VERSION(3, 3, 0) > LINUX_VERSION_CODE)
  1263. #define NEED_SUSPEND_NOTIFIER
  1264. #endif /* CONFIG_PM_SLEEP && CONFIG_PM_RUNTIME */
  1265. #endif /* LINUX_VERSION_CODE */
  1266. struct pt_module {
  1267. struct list_head node;
  1268. char *name;
  1269. int (*probe)(struct device *dev, void **data);
  1270. void (*release)(struct device *dev, void *data);
  1271. };
  1272. struct pt_bus_ops {
  1273. u16 bustype;
  1274. int (*read_default)(struct device *dev, void *buf, int size);
  1275. int (*read_default_nosize)(struct device *dev, u8 *buf, u32 max);
  1276. int (*write_read_specific)(struct device *dev, u16 write_len,
  1277. u8 *write_buf, u8 *read_buf);
  1278. };
  1279. struct pt_core_data {
  1280. struct pinctrl *ts_pinctrl;
  1281. struct pinctrl_state *pinctrl_state_active;
  1282. struct pinctrl_state *pinctrl_state_suspend;
  1283. struct pinctrl_state *pinctrl_state_release;
  1284. struct regulator *vdd;
  1285. struct regulator *vcc_i2c;
  1286. struct list_head node;
  1287. struct list_head module_list; /* List of probed modules */
  1288. char core_id[20];
  1289. struct device *dev;
  1290. struct list_head atten_list[PT_ATTEN_NUM_ATTEN];
  1291. struct list_head param_list;
  1292. struct mutex module_list_lock;
  1293. struct mutex system_lock;
  1294. struct mutex sysfs_lock;
  1295. struct mutex ttdl_restart_lock;
  1296. struct mutex firmware_class_lock;
  1297. enum pt_mode mode;
  1298. spinlock_t spinlock;
  1299. struct pt_mt_data md;
  1300. struct pt_btn_data bd;
  1301. struct pt_proximity_data pd;
  1302. int phys_num;
  1303. int pip_cmd_timeout;
  1304. int pip_cmd_timeout_default;
  1305. void *pt_dynamic_data[PT_MODULE_LAST];
  1306. struct pt_platform_data *pdata;
  1307. struct pt_core_platform_data *cpdata;
  1308. const struct pt_bus_ops *bus_ops;
  1309. wait_queue_head_t wait_q;
  1310. enum pt_sleep_state sleep_state;
  1311. enum pt_startup_state startup_state;
  1312. int irq;
  1313. bool irq_enabled;
  1314. bool irq_wake;
  1315. bool irq_disabled;
  1316. bool hw_detected;
  1317. u8 easy_wakeup_gesture;
  1318. #ifdef EASYWAKE_TSG6
  1319. u8 gesture_id;
  1320. u8 gesture_data_length;
  1321. u8 gesture_data[80];
  1322. #endif
  1323. bool wait_until_wake;
  1324. u8 pid_for_loader;
  1325. char hw_version[13];
  1326. #ifdef NEED_SUSPEND_NOTIFIER
  1327. /*
  1328. * This notifier is used to receive suspend prepare events
  1329. * When device is PM runtime suspended, pm_generic_suspend()
  1330. * does not call our PM suspend callback for kernels with
  1331. * version less than 3.3.0.
  1332. */
  1333. struct notifier_block pm_notifier;
  1334. #endif
  1335. struct pt_sysinfo sysinfo;
  1336. struct pt_bl_info bl_info;
  1337. void *exclusive_dev;
  1338. int exclusive_waits;
  1339. struct timer_list watchdog_timer;
  1340. struct work_struct watchdog_work;
  1341. struct work_struct enum_work;
  1342. struct work_struct ttdl_restart_work;
  1343. u16 startup_retry_count;
  1344. struct pt_hid_core hid_core;
  1345. int hid_cmd_state;
  1346. int hid_reset_cmd_state; /* reset can happen any time */
  1347. struct pt_hid_desc hid_desc;
  1348. struct pt_features features;
  1349. #define PT_PREALLOCATED_CMD_BUFFER 32
  1350. u8 cmd_buf[PT_PREALLOCATED_CMD_BUFFER];
  1351. u8 input_buf[PT_MAX_INPUT];
  1352. u8 response_buf[PT_MAX_INPUT];
  1353. u8 cmd_rsp_buf[PT_MAX_INPUT];
  1354. u16 cmd_rsp_buf_len;
  1355. int raw_cmd_status;
  1356. #ifdef CONFIG_HAS_EARLYSUSPEND
  1357. struct early_suspend es;
  1358. #elif defined(CONFIG_FB)
  1359. struct notifier_block fb_notifier;
  1360. enum pt_fb_state fb_state;
  1361. #endif
  1362. #ifdef TTHE_TUNER_SUPPORT
  1363. struct dentry *tthe_debugfs;
  1364. u8 *tthe_buf;
  1365. u32 tthe_buf_len;
  1366. u32 tthe_buf_size;
  1367. struct mutex tthe_lock;
  1368. u8 tthe_exit;
  1369. #endif
  1370. u8 debug_level;
  1371. u8 watchdog_enabled;
  1372. bool watchdog_force_stop;
  1373. u32 watchdog_interval;
  1374. u8 show_timestamp;
  1375. u32 startup_status;
  1376. u8 pip2_cmd_tag_seq;
  1377. u8 pip2_prot_active;
  1378. u8 pip2_send_user_cmd;
  1379. u8 get_param_id;
  1380. bool bl_pip_ver_ready;
  1381. bool app_pip_ver_ready;
  1382. u8 core_probe_complete;
  1383. u8 active_dut_generation;
  1384. bool set_dut_generation;
  1385. u8 fw_system_mode;
  1386. u8 flashless_dut;
  1387. u8 bl_with_no_int;
  1388. u8 cal_cache_in_host;
  1389. u8 multi_chip;
  1390. u8 tthe_hid_usb_format;
  1391. u8 flashless_auto_bl;
  1392. u8 pip2_us_file_path[PT_MAX_PATH_SIZE];
  1393. bool fw_updating;
  1394. bool fw_sys_mode_in_standby_state;
  1395. #ifdef TTDL_PTVIRTDUT_SUPPORT
  1396. u8 route_bus_virt_dut;
  1397. #endif /* TTDL_PTVIRTDUT_SUPPORT */
  1398. u8 panel_id_support;
  1399. #ifdef TTDL_DIAGNOSTICS
  1400. u8 t_refresh_active;
  1401. u8 flush_bus_type;
  1402. u8 ttdl_bist_select;
  1403. u8 force_pip2_seq;
  1404. u16 ping_test_size;
  1405. u16 pip2_crc_error_count;
  1406. u16 t_refresh_count;
  1407. u16 t_refresh_total;
  1408. u16 wd_xres_count;
  1409. u32 watchdog_count;
  1410. u32 watchdog_irq_stuck_count;
  1411. u32 watchdog_failed_access_count;
  1412. u32 bus_transmit_error_count;
  1413. u32 irq_count;
  1414. u32 bl_retry_packet_count;
  1415. u32 file_erase_timeout_count;
  1416. unsigned long t_refresh_time;
  1417. u16 err_gpio;
  1418. u16 err_gpio_type;
  1419. bool show_tt_data;
  1420. bool bridge_mode;
  1421. bool hw_detect_enabled;
  1422. #endif
  1423. };
  1424. struct gd_sensor {
  1425. int32_t cm_min;
  1426. int32_t cm_max;
  1427. int32_t cm_ave;
  1428. int32_t cm_min_exclude_edge;
  1429. int32_t cm_max_exclude_edge;
  1430. int32_t cm_ave_exclude_edge;
  1431. int32_t gradient_val;
  1432. };
  1433. #ifdef TTHE_TUNER_SUPPORT
  1434. #define PT_CMD_RET_PANEL_IN_DATA_OFFSET 0
  1435. #define PT_CMD_RET_PANEL_ELMNT_SZ_MASK 0x07
  1436. #define PT_CMD_RET_PANEL_HDR 0x0A
  1437. #define PT_CMD_RET_PANEL_ELMNT_SZ_MAX 0x2
  1438. enum scan_data_type_list {
  1439. PT_MUT_RAW,
  1440. PT_MUT_BASE,
  1441. PT_MUT_DIFF,
  1442. PT_SELF_RAW,
  1443. PT_SELF_BASE,
  1444. PT_SELF_DIFF,
  1445. PT_BAL_RAW,
  1446. PT_BAL_BASE,
  1447. PT_BAL_DIFF,
  1448. };
  1449. #endif
  1450. static inline int pt_adap_read_default(struct pt_core_data *cd,
  1451. void *buf, int size)
  1452. {
  1453. return cd->bus_ops->read_default(cd->dev, buf, size);
  1454. }
  1455. static inline int pt_adap_read_default_nosize(struct pt_core_data *cd,
  1456. void *buf, int max)
  1457. {
  1458. return cd->bus_ops->read_default_nosize(cd->dev, buf, max);
  1459. }
  1460. static inline int pt_adap_write_read_specific(struct pt_core_data *cd,
  1461. u16 write_len, u8 *write_buf, u8 *read_buf)
  1462. {
  1463. return cd->bus_ops->write_read_specific(cd->dev, write_len, write_buf,
  1464. read_buf);
  1465. }
  1466. static inline void *pt_get_dynamic_data(struct device *dev, int id)
  1467. {
  1468. struct pt_core_data *cd = dev_get_drvdata(dev);
  1469. return cd->pt_dynamic_data[id];
  1470. }
  1471. int request_exclusive(struct pt_core_data *cd, void *ownptr,
  1472. int timeout_ms);
  1473. int release_exclusive(struct pt_core_data *cd, void *ownptr);
  1474. int _pt_request_pip_get_param(struct device *dev,
  1475. int protect, u8 param_id, u32 *value);
  1476. int _pt_request_pip_set_param(struct device *dev,
  1477. int protect, u8 param_id, u32 value, u8 size);
  1478. static inline int pt_request_exclusive(struct device *dev, int timeout_ms)
  1479. {
  1480. struct pt_core_data *cd = dev_get_drvdata(dev);
  1481. return request_exclusive(cd, dev, timeout_ms);
  1482. }
  1483. static inline int pt_release_exclusive(struct device *dev)
  1484. {
  1485. struct pt_core_data *cd = dev_get_drvdata(dev);
  1486. return release_exclusive(cd, dev);
  1487. }
  1488. static inline int pt_request_nonhid_get_param(struct device *dev,
  1489. int protect, u8 param_id, u32 *value)
  1490. {
  1491. return _pt_request_pip_get_param(dev, protect, param_id,
  1492. value);
  1493. }
  1494. static inline int pt_request_nonhid_set_param(struct device *dev,
  1495. int protect, u8 param_id, u32 value, u8 size)
  1496. {
  1497. return _pt_request_pip_set_param(dev, protect, param_id,
  1498. value, size);
  1499. }
  1500. void pt_pr_buf(struct device *dev, u8 debug_level, u8 *buf,
  1501. u16 buf_len, const char *data_name);
  1502. #ifdef CONFIG_TOUCHSCREEN_PARADE_DEVICETREE_SUPPORT
  1503. int pt_devtree_create_and_get_pdata(struct device *adap_dev);
  1504. int pt_devtree_clean_pdata(struct device *adap_dev);
  1505. #else
  1506. static inline int pt_devtree_create_and_get_pdata(struct device *adap_dev)
  1507. {
  1508. return 0;
  1509. }
  1510. static inline int pt_devtree_clean_pdata(struct device *adap_dev)
  1511. {
  1512. return 0;
  1513. }
  1514. #endif
  1515. int pt_probe(const struct pt_bus_ops *ops, struct device *dev,
  1516. u16 irq, size_t xfer_buf_size);
  1517. int pt_release(struct pt_core_data *cd);
  1518. struct pt_core_commands *pt_get_commands(void);
  1519. struct pt_core_data *pt_get_core_data(char *id);
  1520. int pt_mt_release(struct device *dev);
  1521. int pt_mt_probe(struct device *dev);
  1522. #ifdef CONFIG_TOUCHSCREEN_PARADE_BUTTON
  1523. int pt_btn_probe(struct device *dev);
  1524. int pt_btn_release(struct device *dev);
  1525. #else
  1526. static inline int pt_btn_probe(struct device *dev) { return 0; }
  1527. static inline int pt_btn_release(struct device *dev) { return 0; }
  1528. #endif
  1529. #ifdef CONFIG_TOUCHSCREEN_PARADE_PROXIMITY
  1530. int pt_proximity_probe(struct device *dev);
  1531. int pt_proximity_release(struct device *dev);
  1532. #else
  1533. static inline int pt_proximity_probe(struct device *dev) { return 0; }
  1534. static inline int pt_proximity_release(struct device *dev) { return 0; }
  1535. #endif
  1536. static inline unsigned int pt_get_time_stamp(void)
  1537. {
  1538. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
  1539. struct timespec ts;
  1540. getnstimeofday(&ts);
  1541. return (ts.tv_sec*1000 + ts.tv_nsec/1000000);
  1542. #else
  1543. struct timeval tv;
  1544. do_gettimeofday(&tv);
  1545. return (tv.tv_sec*1000 + tv.tv_usec/1000);
  1546. #endif
  1547. }
  1548. void pt_init_function_ptrs(struct pt_mt_data *md);
  1549. int _pt_subscribe_attention(struct device *dev,
  1550. enum pt_atten_type type, char *id, int (*func)(struct device *),
  1551. int mode);
  1552. int _pt_unsubscribe_attention(struct device *dev,
  1553. enum pt_atten_type type, char *id, int (*func)(struct device *),
  1554. int mode);
  1555. struct pt_sysinfo *_pt_request_sysinfo(struct device *dev);
  1556. extern const struct dev_pm_ops pt_pm_ops;
  1557. int pt_register_module(struct pt_module *module);
  1558. void pt_unregister_module(struct pt_module *module);
  1559. void *pt_get_module_data(struct device *dev,
  1560. struct pt_module *module);
  1561. #endif /* _PT_REGS_H */