cyttsp4_core.c 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158
  1. /*
  2. * cyttsp4_core.c
  3. * Cypress TrueTouch(TM) Standard Product V4 Core driver module.
  4. * For use with Cypress Txx4xx parts.
  5. * Supported parts include:
  6. * TMA4XX
  7. * TMA1036
  8. *
  9. * Copyright (C) 2012 Cypress Semiconductor
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * version 2, and only version 2, as published by the
  14. * Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * Contact Cypress Semiconductor at www.cypress.com <ttdrivers@cypress.com>
  22. *
  23. */
  24. #include "cyttsp4_core.h"
  25. #include <linux/delay.h>
  26. #include <linux/gpio.h>
  27. #include <linux/input/mt.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/pm_runtime.h>
  30. #include <linux/sched.h>
  31. #include <linux/slab.h>
  32. /* Timeout in ms. */
  33. #define CY_CORE_REQUEST_EXCLUSIVE_TIMEOUT 500
  34. #define CY_CORE_SLEEP_REQUEST_EXCLUSIVE_TIMEOUT 5000
  35. #define CY_CORE_MODE_CHANGE_TIMEOUT 1000
  36. #define CY_CORE_RESET_AND_WAIT_TIMEOUT 500
  37. #define CY_CORE_WAKEUP_TIMEOUT 500
  38. #define CY_CORE_STARTUP_RETRY_COUNT 3
  39. static const u8 ldr_exit[] = {
  40. 0xFF, 0x01, 0x3B, 0x00, 0x00, 0x4F, 0x6D, 0x17
  41. };
  42. static const u8 ldr_err_app[] = {
  43. 0x01, 0x02, 0x00, 0x00, 0x55, 0xDD, 0x17
  44. };
  45. static inline size_t merge_bytes(u8 high, u8 low)
  46. {
  47. return (high << 8) + low;
  48. }
  49. #ifdef VERBOSE_DEBUG
  50. static void cyttsp4_pr_buf(struct device *dev, u8 *pr_buf, u8 *dptr, int size,
  51. const char *data_name)
  52. {
  53. int i, k;
  54. const char fmt[] = "%02X ";
  55. int max;
  56. if (!size)
  57. return;
  58. max = (CY_MAX_PRBUF_SIZE - 1) - sizeof(CY_PR_TRUNCATED);
  59. pr_buf[0] = 0;
  60. for (i = k = 0; i < size && k < max; i++, k += 3)
  61. scnprintf(pr_buf + k, CY_MAX_PRBUF_SIZE, fmt, dptr[i]);
  62. dev_vdbg(dev, "%s: %s[0..%d]=%s%s\n", __func__, data_name, size - 1,
  63. pr_buf, size <= max ? "" : CY_PR_TRUNCATED);
  64. }
  65. #else
  66. #define cyttsp4_pr_buf(dev, pr_buf, dptr, size, data_name) do { } while (0)
  67. #endif
  68. static int cyttsp4_load_status_regs(struct cyttsp4 *cd)
  69. {
  70. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  71. struct device *dev = cd->dev;
  72. int rc;
  73. rc = cyttsp4_adap_read(cd, CY_REG_BASE, si->si_ofs.mode_size,
  74. si->xy_mode);
  75. if (rc < 0)
  76. dev_err(dev, "%s: fail read mode regs r=%d\n",
  77. __func__, rc);
  78. else
  79. cyttsp4_pr_buf(dev, cd->pr_buf, si->xy_mode,
  80. si->si_ofs.mode_size, "xy_mode");
  81. return rc;
  82. }
  83. static int cyttsp4_handshake(struct cyttsp4 *cd, u8 mode)
  84. {
  85. u8 cmd = mode ^ CY_HST_TOGGLE;
  86. int rc;
  87. /*
  88. * Mode change issued, handshaking now will cause endless mode change
  89. * requests, for sync mode modechange will do same with handshake
  90. * */
  91. if (mode & CY_HST_MODE_CHANGE)
  92. return 0;
  93. rc = cyttsp4_adap_write(cd, CY_REG_BASE, sizeof(cmd), &cmd);
  94. if (rc < 0)
  95. dev_err(cd->dev, "%s: bus write fail on handshake (ret=%d)\n",
  96. __func__, rc);
  97. return rc;
  98. }
  99. static int cyttsp4_hw_soft_reset(struct cyttsp4 *cd)
  100. {
  101. u8 cmd = CY_HST_RESET;
  102. int rc = cyttsp4_adap_write(cd, CY_REG_BASE, sizeof(cmd), &cmd);
  103. if (rc < 0) {
  104. dev_err(cd->dev, "%s: FAILED to execute SOFT reset\n",
  105. __func__);
  106. return rc;
  107. }
  108. return 0;
  109. }
  110. static int cyttsp4_hw_hard_reset(struct cyttsp4 *cd)
  111. {
  112. if (cd->cpdata->xres) {
  113. cd->cpdata->xres(cd->cpdata, cd->dev);
  114. dev_dbg(cd->dev, "%s: execute HARD reset\n", __func__);
  115. return 0;
  116. }
  117. dev_err(cd->dev, "%s: FAILED to execute HARD reset\n", __func__);
  118. return -ENOSYS;
  119. }
  120. static int cyttsp4_hw_reset(struct cyttsp4 *cd)
  121. {
  122. int rc = cyttsp4_hw_hard_reset(cd);
  123. if (rc == -ENOSYS)
  124. rc = cyttsp4_hw_soft_reset(cd);
  125. return rc;
  126. }
  127. /*
  128. * Gets number of bits for a touch filed as parameter,
  129. * sets maximum value for field which is used as bit mask
  130. * and returns number of bytes required for that field
  131. */
  132. static int cyttsp4_bits_2_bytes(unsigned int nbits, size_t *max)
  133. {
  134. *max = 1UL << nbits;
  135. return (nbits + 7) / 8;
  136. }
  137. static int cyttsp4_si_data_offsets(struct cyttsp4 *cd)
  138. {
  139. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  140. int rc = cyttsp4_adap_read(cd, CY_REG_BASE, sizeof(si->si_data),
  141. &si->si_data);
  142. if (rc < 0) {
  143. dev_err(cd->dev, "%s: fail read sysinfo data offsets r=%d\n",
  144. __func__, rc);
  145. return rc;
  146. }
  147. /* Print sysinfo data offsets */
  148. cyttsp4_pr_buf(cd->dev, cd->pr_buf, (u8 *)&si->si_data,
  149. sizeof(si->si_data), "sysinfo_data_offsets");
  150. /* convert sysinfo data offset bytes into integers */
  151. si->si_ofs.map_sz = merge_bytes(si->si_data.map_szh,
  152. si->si_data.map_szl);
  153. si->si_ofs.map_sz = merge_bytes(si->si_data.map_szh,
  154. si->si_data.map_szl);
  155. si->si_ofs.cydata_ofs = merge_bytes(si->si_data.cydata_ofsh,
  156. si->si_data.cydata_ofsl);
  157. si->si_ofs.test_ofs = merge_bytes(si->si_data.test_ofsh,
  158. si->si_data.test_ofsl);
  159. si->si_ofs.pcfg_ofs = merge_bytes(si->si_data.pcfg_ofsh,
  160. si->si_data.pcfg_ofsl);
  161. si->si_ofs.opcfg_ofs = merge_bytes(si->si_data.opcfg_ofsh,
  162. si->si_data.opcfg_ofsl);
  163. si->si_ofs.ddata_ofs = merge_bytes(si->si_data.ddata_ofsh,
  164. si->si_data.ddata_ofsl);
  165. si->si_ofs.mdata_ofs = merge_bytes(si->si_data.mdata_ofsh,
  166. si->si_data.mdata_ofsl);
  167. return rc;
  168. }
  169. static int cyttsp4_si_get_cydata(struct cyttsp4 *cd)
  170. {
  171. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  172. int read_offset;
  173. int mfgid_sz, calc_mfgid_sz;
  174. void *p;
  175. int rc;
  176. si->si_ofs.cydata_size = si->si_ofs.test_ofs - si->si_ofs.cydata_ofs;
  177. dev_dbg(cd->dev, "%s: cydata size: %Zd\n", __func__,
  178. si->si_ofs.cydata_size);
  179. p = krealloc(si->si_ptrs.cydata, si->si_ofs.cydata_size, GFP_KERNEL);
  180. if (p == NULL) {
  181. dev_err(cd->dev, "%s: fail alloc cydata memory\n", __func__);
  182. return -ENOMEM;
  183. }
  184. si->si_ptrs.cydata = p;
  185. read_offset = si->si_ofs.cydata_ofs;
  186. /* Read the CYDA registers up to MFGID field */
  187. rc = cyttsp4_adap_read(cd, read_offset,
  188. offsetof(struct cyttsp4_cydata, mfgid_sz)
  189. + sizeof(si->si_ptrs.cydata->mfgid_sz),
  190. si->si_ptrs.cydata);
  191. if (rc < 0) {
  192. dev_err(cd->dev, "%s: fail read cydata r=%d\n",
  193. __func__, rc);
  194. return rc;
  195. }
  196. /* Check MFGID size */
  197. mfgid_sz = si->si_ptrs.cydata->mfgid_sz;
  198. calc_mfgid_sz = si->si_ofs.cydata_size - sizeof(struct cyttsp4_cydata);
  199. if (mfgid_sz != calc_mfgid_sz) {
  200. dev_err(cd->dev, "%s: mismatch in MFGID size, reported:%d calculated:%d\n",
  201. __func__, mfgid_sz, calc_mfgid_sz);
  202. return -EINVAL;
  203. }
  204. read_offset += offsetof(struct cyttsp4_cydata, mfgid_sz)
  205. + sizeof(si->si_ptrs.cydata->mfgid_sz);
  206. /* Read the CYDA registers for MFGID field */
  207. rc = cyttsp4_adap_read(cd, read_offset, si->si_ptrs.cydata->mfgid_sz,
  208. si->si_ptrs.cydata->mfg_id);
  209. if (rc < 0) {
  210. dev_err(cd->dev, "%s: fail read cydata r=%d\n",
  211. __func__, rc);
  212. return rc;
  213. }
  214. read_offset += si->si_ptrs.cydata->mfgid_sz;
  215. /* Read the rest of the CYDA registers */
  216. rc = cyttsp4_adap_read(cd, read_offset,
  217. sizeof(struct cyttsp4_cydata)
  218. - offsetof(struct cyttsp4_cydata, cyito_idh),
  219. &si->si_ptrs.cydata->cyito_idh);
  220. if (rc < 0) {
  221. dev_err(cd->dev, "%s: fail read cydata r=%d\n",
  222. __func__, rc);
  223. return rc;
  224. }
  225. cyttsp4_pr_buf(cd->dev, cd->pr_buf, (u8 *)si->si_ptrs.cydata,
  226. si->si_ofs.cydata_size, "sysinfo_cydata");
  227. return rc;
  228. }
  229. static int cyttsp4_si_get_test_data(struct cyttsp4 *cd)
  230. {
  231. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  232. void *p;
  233. int rc;
  234. si->si_ofs.test_size = si->si_ofs.pcfg_ofs - si->si_ofs.test_ofs;
  235. p = krealloc(si->si_ptrs.test, si->si_ofs.test_size, GFP_KERNEL);
  236. if (p == NULL) {
  237. dev_err(cd->dev, "%s: fail alloc test memory\n", __func__);
  238. return -ENOMEM;
  239. }
  240. si->si_ptrs.test = p;
  241. rc = cyttsp4_adap_read(cd, si->si_ofs.test_ofs, si->si_ofs.test_size,
  242. si->si_ptrs.test);
  243. if (rc < 0) {
  244. dev_err(cd->dev, "%s: fail read test data r=%d\n",
  245. __func__, rc);
  246. return rc;
  247. }
  248. cyttsp4_pr_buf(cd->dev, cd->pr_buf,
  249. (u8 *)si->si_ptrs.test, si->si_ofs.test_size,
  250. "sysinfo_test_data");
  251. if (si->si_ptrs.test->post_codel &
  252. CY_POST_CODEL_WDG_RST)
  253. dev_info(cd->dev, "%s: %s codel=%02X\n",
  254. __func__, "Reset was a WATCHDOG RESET",
  255. si->si_ptrs.test->post_codel);
  256. if (!(si->si_ptrs.test->post_codel &
  257. CY_POST_CODEL_CFG_DATA_CRC_FAIL))
  258. dev_info(cd->dev, "%s: %s codel=%02X\n", __func__,
  259. "Config Data CRC FAIL",
  260. si->si_ptrs.test->post_codel);
  261. if (!(si->si_ptrs.test->post_codel &
  262. CY_POST_CODEL_PANEL_TEST_FAIL))
  263. dev_info(cd->dev, "%s: %s codel=%02X\n",
  264. __func__, "PANEL TEST FAIL",
  265. si->si_ptrs.test->post_codel);
  266. dev_info(cd->dev, "%s: SCANNING is %s codel=%02X\n",
  267. __func__, si->si_ptrs.test->post_codel & 0x08 ?
  268. "ENABLED" : "DISABLED",
  269. si->si_ptrs.test->post_codel);
  270. return rc;
  271. }
  272. static int cyttsp4_si_get_pcfg_data(struct cyttsp4 *cd)
  273. {
  274. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  275. void *p;
  276. int rc;
  277. si->si_ofs.pcfg_size = si->si_ofs.opcfg_ofs - si->si_ofs.pcfg_ofs;
  278. p = krealloc(si->si_ptrs.pcfg, si->si_ofs.pcfg_size, GFP_KERNEL);
  279. if (p == NULL) {
  280. rc = -ENOMEM;
  281. dev_err(cd->dev, "%s: fail alloc pcfg memory r=%d\n",
  282. __func__, rc);
  283. return rc;
  284. }
  285. si->si_ptrs.pcfg = p;
  286. rc = cyttsp4_adap_read(cd, si->si_ofs.pcfg_ofs, si->si_ofs.pcfg_size,
  287. si->si_ptrs.pcfg);
  288. if (rc < 0) {
  289. dev_err(cd->dev, "%s: fail read pcfg data r=%d\n",
  290. __func__, rc);
  291. return rc;
  292. }
  293. si->si_ofs.max_x = merge_bytes((si->si_ptrs.pcfg->res_xh
  294. & CY_PCFG_RESOLUTION_X_MASK), si->si_ptrs.pcfg->res_xl);
  295. si->si_ofs.x_origin = !!(si->si_ptrs.pcfg->res_xh
  296. & CY_PCFG_ORIGIN_X_MASK);
  297. si->si_ofs.max_y = merge_bytes((si->si_ptrs.pcfg->res_yh
  298. & CY_PCFG_RESOLUTION_Y_MASK), si->si_ptrs.pcfg->res_yl);
  299. si->si_ofs.y_origin = !!(si->si_ptrs.pcfg->res_yh
  300. & CY_PCFG_ORIGIN_Y_MASK);
  301. si->si_ofs.max_p = merge_bytes(si->si_ptrs.pcfg->max_zh,
  302. si->si_ptrs.pcfg->max_zl);
  303. cyttsp4_pr_buf(cd->dev, cd->pr_buf,
  304. (u8 *)si->si_ptrs.pcfg,
  305. si->si_ofs.pcfg_size, "sysinfo_pcfg_data");
  306. return rc;
  307. }
  308. static int cyttsp4_si_get_opcfg_data(struct cyttsp4 *cd)
  309. {
  310. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  311. struct cyttsp4_tch_abs_params *tch;
  312. struct cyttsp4_tch_rec_params *tch_old, *tch_new;
  313. enum cyttsp4_tch_abs abs;
  314. int i;
  315. void *p;
  316. int rc;
  317. si->si_ofs.opcfg_size = si->si_ofs.ddata_ofs - si->si_ofs.opcfg_ofs;
  318. p = krealloc(si->si_ptrs.opcfg, si->si_ofs.opcfg_size, GFP_KERNEL);
  319. if (p == NULL) {
  320. dev_err(cd->dev, "%s: fail alloc opcfg memory\n", __func__);
  321. rc = -ENOMEM;
  322. goto cyttsp4_si_get_opcfg_data_exit;
  323. }
  324. si->si_ptrs.opcfg = p;
  325. rc = cyttsp4_adap_read(cd, si->si_ofs.opcfg_ofs, si->si_ofs.opcfg_size,
  326. si->si_ptrs.opcfg);
  327. if (rc < 0) {
  328. dev_err(cd->dev, "%s: fail read opcfg data r=%d\n",
  329. __func__, rc);
  330. goto cyttsp4_si_get_opcfg_data_exit;
  331. }
  332. si->si_ofs.cmd_ofs = si->si_ptrs.opcfg->cmd_ofs;
  333. si->si_ofs.rep_ofs = si->si_ptrs.opcfg->rep_ofs;
  334. si->si_ofs.rep_sz = (si->si_ptrs.opcfg->rep_szh * 256) +
  335. si->si_ptrs.opcfg->rep_szl;
  336. si->si_ofs.num_btns = si->si_ptrs.opcfg->num_btns;
  337. si->si_ofs.num_btn_regs = (si->si_ofs.num_btns +
  338. CY_NUM_BTN_PER_REG - 1) / CY_NUM_BTN_PER_REG;
  339. si->si_ofs.tt_stat_ofs = si->si_ptrs.opcfg->tt_stat_ofs;
  340. si->si_ofs.obj_cfg0 = si->si_ptrs.opcfg->obj_cfg0;
  341. si->si_ofs.max_tchs = si->si_ptrs.opcfg->max_tchs &
  342. CY_BYTE_OFS_MASK;
  343. si->si_ofs.tch_rec_size = si->si_ptrs.opcfg->tch_rec_size &
  344. CY_BYTE_OFS_MASK;
  345. /* Get the old touch fields */
  346. for (abs = CY_TCH_X; abs < CY_NUM_TCH_FIELDS; abs++) {
  347. tch = &si->si_ofs.tch_abs[abs];
  348. tch_old = &si->si_ptrs.opcfg->tch_rec_old[abs];
  349. tch->ofs = tch_old->loc & CY_BYTE_OFS_MASK;
  350. tch->size = cyttsp4_bits_2_bytes(tch_old->size,
  351. &tch->max);
  352. tch->bofs = (tch_old->loc & CY_BOFS_MASK) >> CY_BOFS_SHIFT;
  353. }
  354. /* button fields */
  355. si->si_ofs.btn_rec_size = si->si_ptrs.opcfg->btn_rec_size;
  356. si->si_ofs.btn_diff_ofs = si->si_ptrs.opcfg->btn_diff_ofs;
  357. si->si_ofs.btn_diff_size = si->si_ptrs.opcfg->btn_diff_size;
  358. if (si->si_ofs.tch_rec_size > CY_TMA1036_TCH_REC_SIZE) {
  359. /* Get the extended touch fields */
  360. for (i = 0; i < CY_NUM_EXT_TCH_FIELDS; abs++, i++) {
  361. tch = &si->si_ofs.tch_abs[abs];
  362. tch_new = &si->si_ptrs.opcfg->tch_rec_new[i];
  363. tch->ofs = tch_new->loc & CY_BYTE_OFS_MASK;
  364. tch->size = cyttsp4_bits_2_bytes(tch_new->size,
  365. &tch->max);
  366. tch->bofs = (tch_new->loc & CY_BOFS_MASK) >> CY_BOFS_SHIFT;
  367. }
  368. }
  369. for (abs = 0; abs < CY_TCH_NUM_ABS; abs++) {
  370. dev_dbg(cd->dev, "%s: tch_rec_%s\n", __func__,
  371. cyttsp4_tch_abs_string[abs]);
  372. dev_dbg(cd->dev, "%s: ofs =%2Zd\n", __func__,
  373. si->si_ofs.tch_abs[abs].ofs);
  374. dev_dbg(cd->dev, "%s: siz =%2Zd\n", __func__,
  375. si->si_ofs.tch_abs[abs].size);
  376. dev_dbg(cd->dev, "%s: max =%2Zd\n", __func__,
  377. si->si_ofs.tch_abs[abs].max);
  378. dev_dbg(cd->dev, "%s: bofs=%2Zd\n", __func__,
  379. si->si_ofs.tch_abs[abs].bofs);
  380. }
  381. si->si_ofs.mode_size = si->si_ofs.tt_stat_ofs + 1;
  382. si->si_ofs.data_size = si->si_ofs.max_tchs *
  383. si->si_ptrs.opcfg->tch_rec_size;
  384. cyttsp4_pr_buf(cd->dev, cd->pr_buf, (u8 *)si->si_ptrs.opcfg,
  385. si->si_ofs.opcfg_size, "sysinfo_opcfg_data");
  386. cyttsp4_si_get_opcfg_data_exit:
  387. return rc;
  388. }
  389. static int cyttsp4_si_get_ddata(struct cyttsp4 *cd)
  390. {
  391. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  392. void *p;
  393. int rc;
  394. si->si_ofs.ddata_size = si->si_ofs.mdata_ofs - si->si_ofs.ddata_ofs;
  395. p = krealloc(si->si_ptrs.ddata, si->si_ofs.ddata_size, GFP_KERNEL);
  396. if (p == NULL) {
  397. dev_err(cd->dev, "%s: fail alloc ddata memory\n", __func__);
  398. return -ENOMEM;
  399. }
  400. si->si_ptrs.ddata = p;
  401. rc = cyttsp4_adap_read(cd, si->si_ofs.ddata_ofs, si->si_ofs.ddata_size,
  402. si->si_ptrs.ddata);
  403. if (rc < 0)
  404. dev_err(cd->dev, "%s: fail read ddata data r=%d\n",
  405. __func__, rc);
  406. else
  407. cyttsp4_pr_buf(cd->dev, cd->pr_buf,
  408. (u8 *)si->si_ptrs.ddata,
  409. si->si_ofs.ddata_size, "sysinfo_ddata");
  410. return rc;
  411. }
  412. static int cyttsp4_si_get_mdata(struct cyttsp4 *cd)
  413. {
  414. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  415. void *p;
  416. int rc;
  417. si->si_ofs.mdata_size = si->si_ofs.map_sz - si->si_ofs.mdata_ofs;
  418. p = krealloc(si->si_ptrs.mdata, si->si_ofs.mdata_size, GFP_KERNEL);
  419. if (p == NULL) {
  420. dev_err(cd->dev, "%s: fail alloc mdata memory\n", __func__);
  421. return -ENOMEM;
  422. }
  423. si->si_ptrs.mdata = p;
  424. rc = cyttsp4_adap_read(cd, si->si_ofs.mdata_ofs, si->si_ofs.mdata_size,
  425. si->si_ptrs.mdata);
  426. if (rc < 0)
  427. dev_err(cd->dev, "%s: fail read mdata data r=%d\n",
  428. __func__, rc);
  429. else
  430. cyttsp4_pr_buf(cd->dev, cd->pr_buf,
  431. (u8 *)si->si_ptrs.mdata,
  432. si->si_ofs.mdata_size, "sysinfo_mdata");
  433. return rc;
  434. }
  435. static int cyttsp4_si_get_btn_data(struct cyttsp4 *cd)
  436. {
  437. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  438. int btn;
  439. int num_defined_keys;
  440. u16 *key_table;
  441. void *p;
  442. int rc = 0;
  443. if (si->si_ofs.num_btns) {
  444. si->si_ofs.btn_keys_size = si->si_ofs.num_btns *
  445. sizeof(struct cyttsp4_btn);
  446. p = krealloc(si->btn, si->si_ofs.btn_keys_size,
  447. GFP_KERNEL|__GFP_ZERO);
  448. if (p == NULL) {
  449. dev_err(cd->dev, "%s: %s\n", __func__,
  450. "fail alloc btn_keys memory");
  451. return -ENOMEM;
  452. }
  453. si->btn = p;
  454. if (cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS] == NULL)
  455. num_defined_keys = 0;
  456. else if (cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS]->data == NULL)
  457. num_defined_keys = 0;
  458. else
  459. num_defined_keys = cd->cpdata->sett
  460. [CY_IC_GRPNUM_BTN_KEYS]->size;
  461. for (btn = 0; btn < si->si_ofs.num_btns &&
  462. btn < num_defined_keys; btn++) {
  463. key_table = (u16 *)cd->cpdata->sett
  464. [CY_IC_GRPNUM_BTN_KEYS]->data;
  465. si->btn[btn].key_code = key_table[btn];
  466. si->btn[btn].state = CY_BTN_RELEASED;
  467. si->btn[btn].enabled = true;
  468. }
  469. for (; btn < si->si_ofs.num_btns; btn++) {
  470. si->btn[btn].key_code = KEY_RESERVED;
  471. si->btn[btn].state = CY_BTN_RELEASED;
  472. si->btn[btn].enabled = true;
  473. }
  474. return rc;
  475. }
  476. si->si_ofs.btn_keys_size = 0;
  477. kfree(si->btn);
  478. si->btn = NULL;
  479. return rc;
  480. }
  481. static int cyttsp4_si_get_op_data_ptrs(struct cyttsp4 *cd)
  482. {
  483. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  484. void *p;
  485. p = krealloc(si->xy_mode, si->si_ofs.mode_size, GFP_KERNEL|__GFP_ZERO);
  486. if (p == NULL)
  487. return -ENOMEM;
  488. si->xy_mode = p;
  489. p = krealloc(si->xy_data, si->si_ofs.data_size, GFP_KERNEL|__GFP_ZERO);
  490. if (p == NULL)
  491. return -ENOMEM;
  492. si->xy_data = p;
  493. p = krealloc(si->btn_rec_data,
  494. si->si_ofs.btn_rec_size * si->si_ofs.num_btns,
  495. GFP_KERNEL|__GFP_ZERO);
  496. if (p == NULL)
  497. return -ENOMEM;
  498. si->btn_rec_data = p;
  499. return 0;
  500. }
  501. static void cyttsp4_si_put_log_data(struct cyttsp4 *cd)
  502. {
  503. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  504. dev_dbg(cd->dev, "%s: cydata_ofs =%4Zd siz=%4Zd\n", __func__,
  505. si->si_ofs.cydata_ofs, si->si_ofs.cydata_size);
  506. dev_dbg(cd->dev, "%s: test_ofs =%4Zd siz=%4Zd\n", __func__,
  507. si->si_ofs.test_ofs, si->si_ofs.test_size);
  508. dev_dbg(cd->dev, "%s: pcfg_ofs =%4Zd siz=%4Zd\n", __func__,
  509. si->si_ofs.pcfg_ofs, si->si_ofs.pcfg_size);
  510. dev_dbg(cd->dev, "%s: opcfg_ofs =%4Zd siz=%4Zd\n", __func__,
  511. si->si_ofs.opcfg_ofs, si->si_ofs.opcfg_size);
  512. dev_dbg(cd->dev, "%s: ddata_ofs =%4Zd siz=%4Zd\n", __func__,
  513. si->si_ofs.ddata_ofs, si->si_ofs.ddata_size);
  514. dev_dbg(cd->dev, "%s: mdata_ofs =%4Zd siz=%4Zd\n", __func__,
  515. si->si_ofs.mdata_ofs, si->si_ofs.mdata_size);
  516. dev_dbg(cd->dev, "%s: cmd_ofs =%4Zd\n", __func__,
  517. si->si_ofs.cmd_ofs);
  518. dev_dbg(cd->dev, "%s: rep_ofs =%4Zd\n", __func__,
  519. si->si_ofs.rep_ofs);
  520. dev_dbg(cd->dev, "%s: rep_sz =%4Zd\n", __func__,
  521. si->si_ofs.rep_sz);
  522. dev_dbg(cd->dev, "%s: num_btns =%4Zd\n", __func__,
  523. si->si_ofs.num_btns);
  524. dev_dbg(cd->dev, "%s: num_btn_regs =%4Zd\n", __func__,
  525. si->si_ofs.num_btn_regs);
  526. dev_dbg(cd->dev, "%s: tt_stat_ofs =%4Zd\n", __func__,
  527. si->si_ofs.tt_stat_ofs);
  528. dev_dbg(cd->dev, "%s: tch_rec_size =%4Zd\n", __func__,
  529. si->si_ofs.tch_rec_size);
  530. dev_dbg(cd->dev, "%s: max_tchs =%4Zd\n", __func__,
  531. si->si_ofs.max_tchs);
  532. dev_dbg(cd->dev, "%s: mode_size =%4Zd\n", __func__,
  533. si->si_ofs.mode_size);
  534. dev_dbg(cd->dev, "%s: data_size =%4Zd\n", __func__,
  535. si->si_ofs.data_size);
  536. dev_dbg(cd->dev, "%s: map_sz =%4Zd\n", __func__,
  537. si->si_ofs.map_sz);
  538. dev_dbg(cd->dev, "%s: btn_rec_size =%2Zd\n", __func__,
  539. si->si_ofs.btn_rec_size);
  540. dev_dbg(cd->dev, "%s: btn_diff_ofs =%2Zd\n", __func__,
  541. si->si_ofs.btn_diff_ofs);
  542. dev_dbg(cd->dev, "%s: btn_diff_size =%2Zd\n", __func__,
  543. si->si_ofs.btn_diff_size);
  544. dev_dbg(cd->dev, "%s: max_x = 0x%04ZX (%Zd)\n", __func__,
  545. si->si_ofs.max_x, si->si_ofs.max_x);
  546. dev_dbg(cd->dev, "%s: x_origin = %Zd (%s)\n", __func__,
  547. si->si_ofs.x_origin,
  548. si->si_ofs.x_origin == CY_NORMAL_ORIGIN ?
  549. "left corner" : "right corner");
  550. dev_dbg(cd->dev, "%s: max_y = 0x%04ZX (%Zd)\n", __func__,
  551. si->si_ofs.max_y, si->si_ofs.max_y);
  552. dev_dbg(cd->dev, "%s: y_origin = %Zd (%s)\n", __func__,
  553. si->si_ofs.y_origin,
  554. si->si_ofs.y_origin == CY_NORMAL_ORIGIN ?
  555. "upper corner" : "lower corner");
  556. dev_dbg(cd->dev, "%s: max_p = 0x%04ZX (%Zd)\n", __func__,
  557. si->si_ofs.max_p, si->si_ofs.max_p);
  558. dev_dbg(cd->dev, "%s: xy_mode=%p xy_data=%p\n", __func__,
  559. si->xy_mode, si->xy_data);
  560. }
  561. static int cyttsp4_get_sysinfo_regs(struct cyttsp4 *cd)
  562. {
  563. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  564. int rc;
  565. rc = cyttsp4_si_data_offsets(cd);
  566. if (rc < 0)
  567. return rc;
  568. rc = cyttsp4_si_get_cydata(cd);
  569. if (rc < 0)
  570. return rc;
  571. rc = cyttsp4_si_get_test_data(cd);
  572. if (rc < 0)
  573. return rc;
  574. rc = cyttsp4_si_get_pcfg_data(cd);
  575. if (rc < 0)
  576. return rc;
  577. rc = cyttsp4_si_get_opcfg_data(cd);
  578. if (rc < 0)
  579. return rc;
  580. rc = cyttsp4_si_get_ddata(cd);
  581. if (rc < 0)
  582. return rc;
  583. rc = cyttsp4_si_get_mdata(cd);
  584. if (rc < 0)
  585. return rc;
  586. rc = cyttsp4_si_get_btn_data(cd);
  587. if (rc < 0)
  588. return rc;
  589. rc = cyttsp4_si_get_op_data_ptrs(cd);
  590. if (rc < 0) {
  591. dev_err(cd->dev, "%s: failed to get_op_data\n",
  592. __func__);
  593. return rc;
  594. }
  595. cyttsp4_si_put_log_data(cd);
  596. /* provide flow control handshake */
  597. rc = cyttsp4_handshake(cd, si->si_data.hst_mode);
  598. if (rc < 0)
  599. dev_err(cd->dev, "%s: handshake fail on sysinfo reg\n",
  600. __func__);
  601. si->ready = true;
  602. return rc;
  603. }
  604. static void cyttsp4_queue_startup_(struct cyttsp4 *cd)
  605. {
  606. if (cd->startup_state == STARTUP_NONE) {
  607. cd->startup_state = STARTUP_QUEUED;
  608. schedule_work(&cd->startup_work);
  609. dev_dbg(cd->dev, "%s: cyttsp4_startup queued\n", __func__);
  610. } else {
  611. dev_dbg(cd->dev, "%s: startup_state = %d\n", __func__,
  612. cd->startup_state);
  613. }
  614. }
  615. static void cyttsp4_report_slot_liftoff(struct cyttsp4_mt_data *md,
  616. int max_slots)
  617. {
  618. int t;
  619. if (md->num_prv_tch == 0)
  620. return;
  621. for (t = 0; t < max_slots; t++) {
  622. input_mt_slot(md->input, t);
  623. input_mt_report_slot_state(md->input,
  624. MT_TOOL_FINGER, false);
  625. }
  626. }
  627. static void cyttsp4_lift_all(struct cyttsp4_mt_data *md)
  628. {
  629. if (!md->si)
  630. return;
  631. if (md->num_prv_tch != 0) {
  632. cyttsp4_report_slot_liftoff(md,
  633. md->si->si_ofs.tch_abs[CY_TCH_T].max);
  634. input_sync(md->input);
  635. md->num_prv_tch = 0;
  636. }
  637. }
  638. static void cyttsp4_get_touch_axis(struct cyttsp4_mt_data *md,
  639. int *axis, int size, int max, u8 *xy_data, int bofs)
  640. {
  641. int nbyte;
  642. int next;
  643. for (nbyte = 0, *axis = 0, next = 0; nbyte < size; nbyte++) {
  644. dev_vdbg(&md->input->dev,
  645. "%s: *axis=%02X(%d) size=%d max=%08X xy_data=%p"
  646. " xy_data[%d]=%02X(%d) bofs=%d\n",
  647. __func__, *axis, *axis, size, max, xy_data, next,
  648. xy_data[next], xy_data[next], bofs);
  649. *axis = (*axis * 256) + (xy_data[next] >> bofs);
  650. next++;
  651. }
  652. *axis &= max - 1;
  653. dev_vdbg(&md->input->dev,
  654. "%s: *axis=%02X(%d) size=%d max=%08X xy_data=%p"
  655. " xy_data[%d]=%02X(%d)\n",
  656. __func__, *axis, *axis, size, max, xy_data, next,
  657. xy_data[next], xy_data[next]);
  658. }
  659. static void cyttsp4_get_touch(struct cyttsp4_mt_data *md,
  660. struct cyttsp4_touch *touch, u8 *xy_data)
  661. {
  662. struct device *dev = &md->input->dev;
  663. struct cyttsp4_sysinfo *si = md->si;
  664. enum cyttsp4_tch_abs abs;
  665. bool flipped;
  666. for (abs = CY_TCH_X; abs < CY_TCH_NUM_ABS; abs++) {
  667. cyttsp4_get_touch_axis(md, &touch->abs[abs],
  668. si->si_ofs.tch_abs[abs].size,
  669. si->si_ofs.tch_abs[abs].max,
  670. xy_data + si->si_ofs.tch_abs[abs].ofs,
  671. si->si_ofs.tch_abs[abs].bofs);
  672. dev_vdbg(dev, "%s: get %s=%04X(%d)\n", __func__,
  673. cyttsp4_tch_abs_string[abs],
  674. touch->abs[abs], touch->abs[abs]);
  675. }
  676. if (md->pdata->flags & CY_FLAG_FLIP) {
  677. swap(touch->abs[CY_TCH_X], touch->abs[CY_TCH_Y]);
  678. flipped = true;
  679. } else
  680. flipped = false;
  681. if (md->pdata->flags & CY_FLAG_INV_X) {
  682. if (flipped)
  683. touch->abs[CY_TCH_X] = md->si->si_ofs.max_y -
  684. touch->abs[CY_TCH_X];
  685. else
  686. touch->abs[CY_TCH_X] = md->si->si_ofs.max_x -
  687. touch->abs[CY_TCH_X];
  688. }
  689. if (md->pdata->flags & CY_FLAG_INV_Y) {
  690. if (flipped)
  691. touch->abs[CY_TCH_Y] = md->si->si_ofs.max_x -
  692. touch->abs[CY_TCH_Y];
  693. else
  694. touch->abs[CY_TCH_Y] = md->si->si_ofs.max_y -
  695. touch->abs[CY_TCH_Y];
  696. }
  697. dev_vdbg(dev, "%s: flip=%s inv-x=%s inv-y=%s x=%04X(%d) y=%04X(%d)\n",
  698. __func__, flipped ? "true" : "false",
  699. md->pdata->flags & CY_FLAG_INV_X ? "true" : "false",
  700. md->pdata->flags & CY_FLAG_INV_Y ? "true" : "false",
  701. touch->abs[CY_TCH_X], touch->abs[CY_TCH_X],
  702. touch->abs[CY_TCH_Y], touch->abs[CY_TCH_Y]);
  703. }
  704. static void cyttsp4_final_sync(struct input_dev *input, int max_slots, int *ids)
  705. {
  706. int t;
  707. for (t = 0; t < max_slots; t++) {
  708. if (ids[t])
  709. continue;
  710. input_mt_slot(input, t);
  711. input_mt_report_slot_state(input, MT_TOOL_FINGER, false);
  712. }
  713. input_sync(input);
  714. }
  715. static void cyttsp4_get_mt_touches(struct cyttsp4_mt_data *md, int num_cur_tch)
  716. {
  717. struct device *dev = &md->input->dev;
  718. struct cyttsp4_sysinfo *si = md->si;
  719. struct cyttsp4_touch tch;
  720. int sig;
  721. int i, j, t = 0;
  722. int ids[max(CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)];
  723. memset(ids, 0, si->si_ofs.tch_abs[CY_TCH_T].max * sizeof(int));
  724. for (i = 0; i < num_cur_tch; i++) {
  725. cyttsp4_get_touch(md, &tch, si->xy_data +
  726. (i * si->si_ofs.tch_rec_size));
  727. if ((tch.abs[CY_TCH_T] < md->pdata->frmwrk->abs
  728. [(CY_ABS_ID_OST * CY_NUM_ABS_SET) + CY_MIN_OST]) ||
  729. (tch.abs[CY_TCH_T] > md->pdata->frmwrk->abs
  730. [(CY_ABS_ID_OST * CY_NUM_ABS_SET) + CY_MAX_OST])) {
  731. dev_err(dev, "%s: tch=%d -> bad trk_id=%d max_id=%d\n",
  732. __func__, i, tch.abs[CY_TCH_T],
  733. md->pdata->frmwrk->abs[(CY_ABS_ID_OST *
  734. CY_NUM_ABS_SET) + CY_MAX_OST]);
  735. continue;
  736. }
  737. /* use 0 based track id's */
  738. sig = md->pdata->frmwrk->abs
  739. [(CY_ABS_ID_OST * CY_NUM_ABS_SET) + 0];
  740. if (sig != CY_IGNORE_VALUE) {
  741. t = tch.abs[CY_TCH_T] - md->pdata->frmwrk->abs
  742. [(CY_ABS_ID_OST * CY_NUM_ABS_SET) + CY_MIN_OST];
  743. if (tch.abs[CY_TCH_E] == CY_EV_LIFTOFF) {
  744. dev_dbg(dev, "%s: t=%d e=%d lift-off\n",
  745. __func__, t, tch.abs[CY_TCH_E]);
  746. goto cyttsp4_get_mt_touches_pr_tch;
  747. }
  748. input_mt_slot(md->input, t);
  749. input_mt_report_slot_state(md->input, MT_TOOL_FINGER,
  750. true);
  751. ids[t] = true;
  752. }
  753. /* all devices: position and pressure fields */
  754. for (j = 0; j <= CY_ABS_W_OST; j++) {
  755. sig = md->pdata->frmwrk->abs[((CY_ABS_X_OST + j) *
  756. CY_NUM_ABS_SET) + 0];
  757. if (sig != CY_IGNORE_VALUE)
  758. input_report_abs(md->input, sig,
  759. tch.abs[CY_TCH_X + j]);
  760. }
  761. if (si->si_ofs.tch_rec_size > CY_TMA1036_TCH_REC_SIZE) {
  762. /*
  763. * TMA400 size and orientation fields:
  764. * if pressure is non-zero and major touch
  765. * signal is zero, then set major and minor touch
  766. * signals to minimum non-zero value
  767. */
  768. if (tch.abs[CY_TCH_P] > 0 && tch.abs[CY_TCH_MAJ] == 0)
  769. tch.abs[CY_TCH_MAJ] = tch.abs[CY_TCH_MIN] = 1;
  770. /* Get the extended touch fields */
  771. for (j = 0; j < CY_NUM_EXT_TCH_FIELDS; j++) {
  772. sig = md->pdata->frmwrk->abs
  773. [((CY_ABS_MAJ_OST + j) *
  774. CY_NUM_ABS_SET) + 0];
  775. if (sig != CY_IGNORE_VALUE)
  776. input_report_abs(md->input, sig,
  777. tch.abs[CY_TCH_MAJ + j]);
  778. }
  779. }
  780. cyttsp4_get_mt_touches_pr_tch:
  781. if (si->si_ofs.tch_rec_size > CY_TMA1036_TCH_REC_SIZE)
  782. dev_dbg(dev,
  783. "%s: t=%d x=%d y=%d z=%d M=%d m=%d o=%d e=%d\n",
  784. __func__, t,
  785. tch.abs[CY_TCH_X],
  786. tch.abs[CY_TCH_Y],
  787. tch.abs[CY_TCH_P],
  788. tch.abs[CY_TCH_MAJ],
  789. tch.abs[CY_TCH_MIN],
  790. tch.abs[CY_TCH_OR],
  791. tch.abs[CY_TCH_E]);
  792. else
  793. dev_dbg(dev,
  794. "%s: t=%d x=%d y=%d z=%d e=%d\n", __func__,
  795. t,
  796. tch.abs[CY_TCH_X],
  797. tch.abs[CY_TCH_Y],
  798. tch.abs[CY_TCH_P],
  799. tch.abs[CY_TCH_E]);
  800. }
  801. cyttsp4_final_sync(md->input, si->si_ofs.tch_abs[CY_TCH_T].max, ids);
  802. md->num_prv_tch = num_cur_tch;
  803. return;
  804. }
  805. /* read xy_data for all current touches */
  806. static int cyttsp4_xy_worker(struct cyttsp4 *cd)
  807. {
  808. struct cyttsp4_mt_data *md = &cd->md;
  809. struct device *dev = &md->input->dev;
  810. struct cyttsp4_sysinfo *si = md->si;
  811. u8 num_cur_tch;
  812. u8 hst_mode;
  813. u8 rep_len;
  814. u8 rep_stat;
  815. u8 tt_stat;
  816. int rc = 0;
  817. /*
  818. * Get event data from cyttsp4 device.
  819. * The event data includes all data
  820. * for all active touches.
  821. * Event data also includes button data
  822. */
  823. /*
  824. * Use 2 reads:
  825. * 1st read to get mode + button bytes + touch count (core)
  826. * 2nd read (optional) to get touch 1 - touch n data
  827. */
  828. hst_mode = si->xy_mode[CY_REG_BASE];
  829. rep_len = si->xy_mode[si->si_ofs.rep_ofs];
  830. rep_stat = si->xy_mode[si->si_ofs.rep_ofs + 1];
  831. tt_stat = si->xy_mode[si->si_ofs.tt_stat_ofs];
  832. dev_vdbg(dev, "%s: %s%02X %s%d %s%02X %s%02X\n", __func__,
  833. "hst_mode=", hst_mode, "rep_len=", rep_len,
  834. "rep_stat=", rep_stat, "tt_stat=", tt_stat);
  835. num_cur_tch = GET_NUM_TOUCHES(tt_stat);
  836. dev_vdbg(dev, "%s: num_cur_tch=%d\n", __func__, num_cur_tch);
  837. if (rep_len == 0 && num_cur_tch > 0) {
  838. dev_err(dev, "%s: report length error rep_len=%d num_tch=%d\n",
  839. __func__, rep_len, num_cur_tch);
  840. goto cyttsp4_xy_worker_exit;
  841. }
  842. /* read touches */
  843. if (num_cur_tch > 0) {
  844. rc = cyttsp4_adap_read(cd, si->si_ofs.tt_stat_ofs + 1,
  845. num_cur_tch * si->si_ofs.tch_rec_size,
  846. si->xy_data);
  847. if (rc < 0) {
  848. dev_err(dev, "%s: read fail on touch regs r=%d\n",
  849. __func__, rc);
  850. goto cyttsp4_xy_worker_exit;
  851. }
  852. }
  853. /* print xy data */
  854. cyttsp4_pr_buf(dev, cd->pr_buf, si->xy_data, num_cur_tch *
  855. si->si_ofs.tch_rec_size, "xy_data");
  856. /* check any error conditions */
  857. if (IS_BAD_PKT(rep_stat)) {
  858. dev_dbg(dev, "%s: Invalid buffer detected\n", __func__);
  859. rc = 0;
  860. goto cyttsp4_xy_worker_exit;
  861. }
  862. if (IS_LARGE_AREA(tt_stat))
  863. dev_dbg(dev, "%s: Large area detected\n", __func__);
  864. if (num_cur_tch > si->si_ofs.max_tchs) {
  865. dev_err(dev, "%s: too many tch; set to max tch (n=%d c=%Zd)\n",
  866. __func__, num_cur_tch, si->si_ofs.max_tchs);
  867. num_cur_tch = si->si_ofs.max_tchs;
  868. }
  869. /* extract xy_data for all currently reported touches */
  870. dev_vdbg(dev, "%s: extract data num_cur_tch=%d\n", __func__,
  871. num_cur_tch);
  872. if (num_cur_tch)
  873. cyttsp4_get_mt_touches(md, num_cur_tch);
  874. else
  875. cyttsp4_lift_all(md);
  876. rc = 0;
  877. cyttsp4_xy_worker_exit:
  878. return rc;
  879. }
  880. static int cyttsp4_mt_attention(struct cyttsp4 *cd)
  881. {
  882. struct device *dev = cd->dev;
  883. struct cyttsp4_mt_data *md = &cd->md;
  884. int rc = 0;
  885. if (!md->si)
  886. return 0;
  887. mutex_lock(&md->report_lock);
  888. if (!md->is_suspended) {
  889. /* core handles handshake */
  890. rc = cyttsp4_xy_worker(cd);
  891. } else {
  892. dev_vdbg(dev, "%s: Ignoring report while suspended\n",
  893. __func__);
  894. }
  895. mutex_unlock(&md->report_lock);
  896. if (rc < 0)
  897. dev_err(dev, "%s: xy_worker error r=%d\n", __func__, rc);
  898. return rc;
  899. }
  900. static irqreturn_t cyttsp4_irq(int irq, void *handle)
  901. {
  902. struct cyttsp4 *cd = handle;
  903. struct device *dev = cd->dev;
  904. enum cyttsp4_mode cur_mode;
  905. u8 cmd_ofs = cd->sysinfo.si_ofs.cmd_ofs;
  906. u8 mode[3];
  907. int rc;
  908. /*
  909. * Check whether this IRQ should be ignored (external)
  910. * This should be the very first thing to check since
  911. * ignore_irq may be set for a very short period of time
  912. */
  913. if (atomic_read(&cd->ignore_irq)) {
  914. dev_vdbg(dev, "%s: Ignoring IRQ\n", __func__);
  915. return IRQ_HANDLED;
  916. }
  917. dev_dbg(dev, "%s int:0x%x\n", __func__, cd->int_status);
  918. mutex_lock(&cd->system_lock);
  919. /* Just to debug */
  920. if (cd->sleep_state == SS_SLEEP_ON || cd->sleep_state == SS_SLEEPING)
  921. dev_vdbg(dev, "%s: Received IRQ while in sleep\n", __func__);
  922. rc = cyttsp4_adap_read(cd, CY_REG_BASE, sizeof(mode), mode);
  923. if (rc) {
  924. dev_err(cd->dev, "%s: Fail read adapter r=%d\n", __func__, rc);
  925. goto cyttsp4_irq_exit;
  926. }
  927. dev_vdbg(dev, "%s mode[0-2]:0x%X 0x%X 0x%X\n", __func__,
  928. mode[0], mode[1], mode[2]);
  929. if (IS_BOOTLOADER(mode[0], mode[1])) {
  930. cur_mode = CY_MODE_BOOTLOADER;
  931. dev_vdbg(dev, "%s: bl running\n", __func__);
  932. if (cd->mode == CY_MODE_BOOTLOADER) {
  933. /* Signal bootloader heartbeat heard */
  934. wake_up(&cd->wait_q);
  935. goto cyttsp4_irq_exit;
  936. }
  937. /* switch to bootloader */
  938. dev_dbg(dev, "%s: restart switch to bl m=%d -> m=%d\n",
  939. __func__, cd->mode, cur_mode);
  940. /* catch operation->bl glitch */
  941. if (cd->mode != CY_MODE_UNKNOWN) {
  942. /* Incase startup_state do not let startup_() */
  943. cd->mode = CY_MODE_UNKNOWN;
  944. cyttsp4_queue_startup_(cd);
  945. goto cyttsp4_irq_exit;
  946. }
  947. /*
  948. * do not wake thread on this switch since
  949. * it is possible to get an early heartbeat
  950. * prior to performing the reset
  951. */
  952. cd->mode = cur_mode;
  953. goto cyttsp4_irq_exit;
  954. }
  955. switch (mode[0] & CY_HST_MODE) {
  956. case CY_HST_OPERATE:
  957. cur_mode = CY_MODE_OPERATIONAL;
  958. dev_vdbg(dev, "%s: operational\n", __func__);
  959. break;
  960. case CY_HST_CAT:
  961. cur_mode = CY_MODE_CAT;
  962. dev_vdbg(dev, "%s: CaT\n", __func__);
  963. break;
  964. case CY_HST_SYSINFO:
  965. cur_mode = CY_MODE_SYSINFO;
  966. dev_vdbg(dev, "%s: sysinfo\n", __func__);
  967. break;
  968. default:
  969. cur_mode = CY_MODE_UNKNOWN;
  970. dev_err(dev, "%s: unknown HST mode 0x%02X\n", __func__,
  971. mode[0]);
  972. break;
  973. }
  974. /* Check whether this IRQ should be ignored (internal) */
  975. if (cd->int_status & CY_INT_IGNORE) {
  976. dev_vdbg(dev, "%s: Ignoring IRQ\n", __func__);
  977. goto cyttsp4_irq_exit;
  978. }
  979. /* Check for wake up interrupt */
  980. if (cd->int_status & CY_INT_AWAKE) {
  981. cd->int_status &= ~CY_INT_AWAKE;
  982. wake_up(&cd->wait_q);
  983. dev_vdbg(dev, "%s: Received wake up interrupt\n", __func__);
  984. goto cyttsp4_irq_handshake;
  985. }
  986. /* Expecting mode change interrupt */
  987. if ((cd->int_status & CY_INT_MODE_CHANGE)
  988. && (mode[0] & CY_HST_MODE_CHANGE) == 0) {
  989. cd->int_status &= ~CY_INT_MODE_CHANGE;
  990. dev_dbg(dev, "%s: finish mode switch m=%d -> m=%d\n",
  991. __func__, cd->mode, cur_mode);
  992. cd->mode = cur_mode;
  993. wake_up(&cd->wait_q);
  994. goto cyttsp4_irq_handshake;
  995. }
  996. /* compare current core mode to current device mode */
  997. dev_vdbg(dev, "%s: cd->mode=%d cur_mode=%d\n",
  998. __func__, cd->mode, cur_mode);
  999. if ((mode[0] & CY_HST_MODE_CHANGE) == 0 && cd->mode != cur_mode) {
  1000. /* Unexpected mode change occurred */
  1001. dev_err(dev, "%s %d->%d 0x%x\n", __func__, cd->mode,
  1002. cur_mode, cd->int_status);
  1003. dev_dbg(dev, "%s: Unexpected mode change, startup\n",
  1004. __func__);
  1005. cyttsp4_queue_startup_(cd);
  1006. goto cyttsp4_irq_exit;
  1007. }
  1008. /* Expecting command complete interrupt */
  1009. dev_vdbg(dev, "%s: command byte:0x%x\n", __func__, mode[cmd_ofs]);
  1010. if ((cd->int_status & CY_INT_EXEC_CMD)
  1011. && mode[cmd_ofs] & CY_CMD_COMPLETE) {
  1012. cd->int_status &= ~CY_INT_EXEC_CMD;
  1013. dev_vdbg(dev, "%s: Received command complete interrupt\n",
  1014. __func__);
  1015. wake_up(&cd->wait_q);
  1016. /*
  1017. * It is possible to receive a single interrupt for
  1018. * command complete and touch/button status report.
  1019. * Continue processing for a possible status report.
  1020. */
  1021. }
  1022. /* This should be status report, read status regs */
  1023. if (cd->mode == CY_MODE_OPERATIONAL) {
  1024. dev_vdbg(dev, "%s: Read status registers\n", __func__);
  1025. rc = cyttsp4_load_status_regs(cd);
  1026. if (rc < 0)
  1027. dev_err(dev, "%s: fail read mode regs r=%d\n",
  1028. __func__, rc);
  1029. }
  1030. cyttsp4_mt_attention(cd);
  1031. cyttsp4_irq_handshake:
  1032. /* handshake the event */
  1033. dev_vdbg(dev, "%s: Handshake mode=0x%02X r=%d\n",
  1034. __func__, mode[0], rc);
  1035. rc = cyttsp4_handshake(cd, mode[0]);
  1036. if (rc < 0)
  1037. dev_err(dev, "%s: Fail handshake mode=0x%02X r=%d\n",
  1038. __func__, mode[0], rc);
  1039. /*
  1040. * a non-zero udelay period is required for using
  1041. * IRQF_TRIGGER_LOW in order to delay until the
  1042. * device completes isr deassert
  1043. */
  1044. udelay(cd->cpdata->level_irq_udelay);
  1045. cyttsp4_irq_exit:
  1046. mutex_unlock(&cd->system_lock);
  1047. return IRQ_HANDLED;
  1048. }
  1049. static void cyttsp4_start_wd_timer(struct cyttsp4 *cd)
  1050. {
  1051. if (!CY_WATCHDOG_TIMEOUT)
  1052. return;
  1053. mod_timer(&cd->watchdog_timer, jiffies +
  1054. msecs_to_jiffies(CY_WATCHDOG_TIMEOUT));
  1055. }
  1056. static void cyttsp4_stop_wd_timer(struct cyttsp4 *cd)
  1057. {
  1058. if (!CY_WATCHDOG_TIMEOUT)
  1059. return;
  1060. /*
  1061. * Ensure we wait until the watchdog timer
  1062. * running on a different CPU finishes
  1063. */
  1064. del_timer_sync(&cd->watchdog_timer);
  1065. cancel_work_sync(&cd->watchdog_work);
  1066. del_timer_sync(&cd->watchdog_timer);
  1067. }
  1068. static void cyttsp4_watchdog_timer(unsigned long handle)
  1069. {
  1070. struct cyttsp4 *cd = (struct cyttsp4 *)handle;
  1071. dev_vdbg(cd->dev, "%s: Watchdog timer triggered\n", __func__);
  1072. schedule_work(&cd->watchdog_work);
  1073. return;
  1074. }
  1075. static int cyttsp4_request_exclusive(struct cyttsp4 *cd, void *ownptr,
  1076. int timeout_ms)
  1077. {
  1078. int t = msecs_to_jiffies(timeout_ms);
  1079. bool with_timeout = (timeout_ms != 0);
  1080. mutex_lock(&cd->system_lock);
  1081. if (!cd->exclusive_dev && cd->exclusive_waits == 0) {
  1082. cd->exclusive_dev = ownptr;
  1083. goto exit;
  1084. }
  1085. cd->exclusive_waits++;
  1086. wait:
  1087. mutex_unlock(&cd->system_lock);
  1088. if (with_timeout) {
  1089. t = wait_event_timeout(cd->wait_q, !cd->exclusive_dev, t);
  1090. if (IS_TMO(t)) {
  1091. dev_err(cd->dev, "%s: tmo waiting exclusive access\n",
  1092. __func__);
  1093. mutex_lock(&cd->system_lock);
  1094. cd->exclusive_waits--;
  1095. mutex_unlock(&cd->system_lock);
  1096. return -ETIME;
  1097. }
  1098. } else {
  1099. wait_event(cd->wait_q, !cd->exclusive_dev);
  1100. }
  1101. mutex_lock(&cd->system_lock);
  1102. if (cd->exclusive_dev)
  1103. goto wait;
  1104. cd->exclusive_dev = ownptr;
  1105. cd->exclusive_waits--;
  1106. exit:
  1107. mutex_unlock(&cd->system_lock);
  1108. return 0;
  1109. }
  1110. /*
  1111. * returns error if was not owned
  1112. */
  1113. static int cyttsp4_release_exclusive(struct cyttsp4 *cd, void *ownptr)
  1114. {
  1115. mutex_lock(&cd->system_lock);
  1116. if (cd->exclusive_dev != ownptr) {
  1117. mutex_unlock(&cd->system_lock);
  1118. return -EINVAL;
  1119. }
  1120. dev_vdbg(cd->dev, "%s: exclusive_dev %p freed\n",
  1121. __func__, cd->exclusive_dev);
  1122. cd->exclusive_dev = NULL;
  1123. wake_up(&cd->wait_q);
  1124. mutex_unlock(&cd->system_lock);
  1125. return 0;
  1126. }
  1127. static int cyttsp4_wait_bl_heartbeat(struct cyttsp4 *cd)
  1128. {
  1129. long t;
  1130. int rc = 0;
  1131. /* wait heartbeat */
  1132. dev_vdbg(cd->dev, "%s: wait heartbeat...\n", __func__);
  1133. t = wait_event_timeout(cd->wait_q, cd->mode == CY_MODE_BOOTLOADER,
  1134. msecs_to_jiffies(CY_CORE_RESET_AND_WAIT_TIMEOUT));
  1135. if (IS_TMO(t)) {
  1136. dev_err(cd->dev, "%s: tmo waiting bl heartbeat cd->mode=%d\n",
  1137. __func__, cd->mode);
  1138. rc = -ETIME;
  1139. }
  1140. return rc;
  1141. }
  1142. static int cyttsp4_wait_sysinfo_mode(struct cyttsp4 *cd)
  1143. {
  1144. long t;
  1145. dev_vdbg(cd->dev, "%s: wait sysinfo...\n", __func__);
  1146. t = wait_event_timeout(cd->wait_q, cd->mode == CY_MODE_SYSINFO,
  1147. msecs_to_jiffies(CY_CORE_MODE_CHANGE_TIMEOUT));
  1148. if (IS_TMO(t)) {
  1149. dev_err(cd->dev, "%s: tmo waiting exit bl cd->mode=%d\n",
  1150. __func__, cd->mode);
  1151. mutex_lock(&cd->system_lock);
  1152. cd->int_status &= ~CY_INT_MODE_CHANGE;
  1153. mutex_unlock(&cd->system_lock);
  1154. return -ETIME;
  1155. }
  1156. return 0;
  1157. }
  1158. static int cyttsp4_reset_and_wait(struct cyttsp4 *cd)
  1159. {
  1160. int rc;
  1161. /* reset hardware */
  1162. mutex_lock(&cd->system_lock);
  1163. dev_dbg(cd->dev, "%s: reset hw...\n", __func__);
  1164. rc = cyttsp4_hw_reset(cd);
  1165. cd->mode = CY_MODE_UNKNOWN;
  1166. mutex_unlock(&cd->system_lock);
  1167. if (rc < 0) {
  1168. dev_err(cd->dev, "%s:Fail hw reset r=%d\n", __func__, rc);
  1169. return rc;
  1170. }
  1171. return cyttsp4_wait_bl_heartbeat(cd);
  1172. }
  1173. /*
  1174. * returns err if refused or timeout; block until mode change complete
  1175. * bit is set (mode change interrupt)
  1176. */
  1177. static int cyttsp4_set_mode(struct cyttsp4 *cd, int new_mode)
  1178. {
  1179. u8 new_dev_mode;
  1180. u8 mode;
  1181. long t;
  1182. int rc;
  1183. switch (new_mode) {
  1184. case CY_MODE_OPERATIONAL:
  1185. new_dev_mode = CY_HST_OPERATE;
  1186. break;
  1187. case CY_MODE_SYSINFO:
  1188. new_dev_mode = CY_HST_SYSINFO;
  1189. break;
  1190. case CY_MODE_CAT:
  1191. new_dev_mode = CY_HST_CAT;
  1192. break;
  1193. default:
  1194. dev_err(cd->dev, "%s: invalid mode: %02X(%d)\n",
  1195. __func__, new_mode, new_mode);
  1196. return -EINVAL;
  1197. }
  1198. /* change mode */
  1199. dev_dbg(cd->dev, "%s: %s=%p new_dev_mode=%02X new_mode=%d\n",
  1200. __func__, "have exclusive", cd->exclusive_dev,
  1201. new_dev_mode, new_mode);
  1202. mutex_lock(&cd->system_lock);
  1203. rc = cyttsp4_adap_read(cd, CY_REG_BASE, sizeof(mode), &mode);
  1204. if (rc < 0) {
  1205. mutex_unlock(&cd->system_lock);
  1206. dev_err(cd->dev, "%s: Fail read mode r=%d\n",
  1207. __func__, rc);
  1208. goto exit;
  1209. }
  1210. /* Clear device mode bits and set to new mode */
  1211. mode &= ~CY_HST_MODE;
  1212. mode |= new_dev_mode | CY_HST_MODE_CHANGE;
  1213. cd->int_status |= CY_INT_MODE_CHANGE;
  1214. rc = cyttsp4_adap_write(cd, CY_REG_BASE, sizeof(mode), &mode);
  1215. mutex_unlock(&cd->system_lock);
  1216. if (rc < 0) {
  1217. dev_err(cd->dev, "%s: Fail write mode change r=%d\n",
  1218. __func__, rc);
  1219. goto exit;
  1220. }
  1221. /* wait for mode change done interrupt */
  1222. t = wait_event_timeout(cd->wait_q,
  1223. (cd->int_status & CY_INT_MODE_CHANGE) == 0,
  1224. msecs_to_jiffies(CY_CORE_MODE_CHANGE_TIMEOUT));
  1225. dev_dbg(cd->dev, "%s: back from wait t=%ld cd->mode=%d\n",
  1226. __func__, t, cd->mode);
  1227. if (IS_TMO(t)) {
  1228. dev_err(cd->dev, "%s: %s\n", __func__,
  1229. "tmo waiting mode change");
  1230. mutex_lock(&cd->system_lock);
  1231. cd->int_status &= ~CY_INT_MODE_CHANGE;
  1232. mutex_unlock(&cd->system_lock);
  1233. rc = -EINVAL;
  1234. }
  1235. exit:
  1236. return rc;
  1237. }
  1238. static void cyttsp4_watchdog_work(struct work_struct *work)
  1239. {
  1240. struct cyttsp4 *cd =
  1241. container_of(work, struct cyttsp4, watchdog_work);
  1242. u8 *mode;
  1243. int retval;
  1244. mutex_lock(&cd->system_lock);
  1245. retval = cyttsp4_load_status_regs(cd);
  1246. if (retval < 0) {
  1247. dev_err(cd->dev,
  1248. "%s: failed to access device in watchdog timer r=%d\n",
  1249. __func__, retval);
  1250. cyttsp4_queue_startup_(cd);
  1251. goto cyttsp4_timer_watchdog_exit_error;
  1252. }
  1253. mode = &cd->sysinfo.xy_mode[CY_REG_BASE];
  1254. if (IS_BOOTLOADER(mode[0], mode[1])) {
  1255. dev_err(cd->dev,
  1256. "%s: device found in bootloader mode when operational mode\n",
  1257. __func__);
  1258. cyttsp4_queue_startup_(cd);
  1259. goto cyttsp4_timer_watchdog_exit_error;
  1260. }
  1261. cyttsp4_start_wd_timer(cd);
  1262. cyttsp4_timer_watchdog_exit_error:
  1263. mutex_unlock(&cd->system_lock);
  1264. return;
  1265. }
  1266. static int cyttsp4_core_sleep_(struct cyttsp4 *cd)
  1267. {
  1268. enum cyttsp4_sleep_state ss = SS_SLEEP_ON;
  1269. enum cyttsp4_int_state int_status = CY_INT_IGNORE;
  1270. int rc = 0;
  1271. u8 mode[2];
  1272. /* Already in sleep mode? */
  1273. mutex_lock(&cd->system_lock);
  1274. if (cd->sleep_state == SS_SLEEP_ON) {
  1275. mutex_unlock(&cd->system_lock);
  1276. return 0;
  1277. }
  1278. cd->sleep_state = SS_SLEEPING;
  1279. mutex_unlock(&cd->system_lock);
  1280. cyttsp4_stop_wd_timer(cd);
  1281. /* Wait until currently running IRQ handler exits and disable IRQ */
  1282. disable_irq(cd->irq);
  1283. dev_vdbg(cd->dev, "%s: write DEEP SLEEP...\n", __func__);
  1284. mutex_lock(&cd->system_lock);
  1285. rc = cyttsp4_adap_read(cd, CY_REG_BASE, sizeof(mode), &mode);
  1286. if (rc) {
  1287. mutex_unlock(&cd->system_lock);
  1288. dev_err(cd->dev, "%s: Fail read adapter r=%d\n", __func__, rc);
  1289. goto error;
  1290. }
  1291. if (IS_BOOTLOADER(mode[0], mode[1])) {
  1292. mutex_unlock(&cd->system_lock);
  1293. dev_err(cd->dev, "%s: Device in BOOTLOADER mode.\n", __func__);
  1294. rc = -EINVAL;
  1295. goto error;
  1296. }
  1297. mode[0] |= CY_HST_SLEEP;
  1298. rc = cyttsp4_adap_write(cd, CY_REG_BASE, sizeof(mode[0]), &mode[0]);
  1299. mutex_unlock(&cd->system_lock);
  1300. if (rc) {
  1301. dev_err(cd->dev, "%s: Fail write adapter r=%d\n", __func__, rc);
  1302. goto error;
  1303. }
  1304. dev_vdbg(cd->dev, "%s: write DEEP SLEEP succeeded\n", __func__);
  1305. if (cd->cpdata->power) {
  1306. dev_dbg(cd->dev, "%s: Power down HW\n", __func__);
  1307. rc = cd->cpdata->power(cd->cpdata, 0, cd->dev, &cd->ignore_irq);
  1308. } else {
  1309. dev_dbg(cd->dev, "%s: No power function\n", __func__);
  1310. rc = 0;
  1311. }
  1312. if (rc < 0) {
  1313. dev_err(cd->dev, "%s: HW Power down fails r=%d\n",
  1314. __func__, rc);
  1315. goto error;
  1316. }
  1317. /* Give time to FW to sleep */
  1318. msleep(50);
  1319. goto exit;
  1320. error:
  1321. ss = SS_SLEEP_OFF;
  1322. int_status = CY_INT_NONE;
  1323. cyttsp4_start_wd_timer(cd);
  1324. exit:
  1325. mutex_lock(&cd->system_lock);
  1326. cd->sleep_state = ss;
  1327. cd->int_status |= int_status;
  1328. mutex_unlock(&cd->system_lock);
  1329. enable_irq(cd->irq);
  1330. return rc;
  1331. }
  1332. static int cyttsp4_startup_(struct cyttsp4 *cd)
  1333. {
  1334. int retry = CY_CORE_STARTUP_RETRY_COUNT;
  1335. int rc;
  1336. cyttsp4_stop_wd_timer(cd);
  1337. reset:
  1338. if (retry != CY_CORE_STARTUP_RETRY_COUNT)
  1339. dev_dbg(cd->dev, "%s: Retry %d\n", __func__,
  1340. CY_CORE_STARTUP_RETRY_COUNT - retry);
  1341. /* reset hardware and wait for heartbeat */
  1342. rc = cyttsp4_reset_and_wait(cd);
  1343. if (rc < 0) {
  1344. dev_err(cd->dev, "%s: Error on h/w reset r=%d\n", __func__, rc);
  1345. if (retry--)
  1346. goto reset;
  1347. goto exit;
  1348. }
  1349. /* exit bl into sysinfo mode */
  1350. dev_vdbg(cd->dev, "%s: write exit ldr...\n", __func__);
  1351. mutex_lock(&cd->system_lock);
  1352. cd->int_status &= ~CY_INT_IGNORE;
  1353. cd->int_status |= CY_INT_MODE_CHANGE;
  1354. rc = cyttsp4_adap_write(cd, CY_REG_BASE, sizeof(ldr_exit),
  1355. (u8 *)ldr_exit);
  1356. mutex_unlock(&cd->system_lock);
  1357. if (rc < 0) {
  1358. dev_err(cd->dev, "%s: Fail write r=%d\n", __func__, rc);
  1359. if (retry--)
  1360. goto reset;
  1361. goto exit;
  1362. }
  1363. rc = cyttsp4_wait_sysinfo_mode(cd);
  1364. if (rc < 0) {
  1365. u8 buf[sizeof(ldr_err_app)];
  1366. int rc1;
  1367. /* Check for invalid/corrupted touch application */
  1368. rc1 = cyttsp4_adap_read(cd, CY_REG_BASE, sizeof(ldr_err_app),
  1369. buf);
  1370. if (rc1) {
  1371. dev_err(cd->dev, "%s: Fail read r=%d\n", __func__, rc1);
  1372. } else if (!memcmp(buf, ldr_err_app, sizeof(ldr_err_app))) {
  1373. dev_err(cd->dev, "%s: Error launching touch application\n",
  1374. __func__);
  1375. mutex_lock(&cd->system_lock);
  1376. cd->invalid_touch_app = true;
  1377. mutex_unlock(&cd->system_lock);
  1378. goto exit_no_wd;
  1379. }
  1380. if (retry--)
  1381. goto reset;
  1382. goto exit;
  1383. }
  1384. mutex_lock(&cd->system_lock);
  1385. cd->invalid_touch_app = false;
  1386. mutex_unlock(&cd->system_lock);
  1387. /* read sysinfo data */
  1388. dev_vdbg(cd->dev, "%s: get sysinfo regs..\n", __func__);
  1389. rc = cyttsp4_get_sysinfo_regs(cd);
  1390. if (rc < 0) {
  1391. dev_err(cd->dev, "%s: failed to get sysinfo regs rc=%d\n",
  1392. __func__, rc);
  1393. if (retry--)
  1394. goto reset;
  1395. goto exit;
  1396. }
  1397. rc = cyttsp4_set_mode(cd, CY_MODE_OPERATIONAL);
  1398. if (rc < 0) {
  1399. dev_err(cd->dev, "%s: failed to set mode to operational rc=%d\n",
  1400. __func__, rc);
  1401. if (retry--)
  1402. goto reset;
  1403. goto exit;
  1404. }
  1405. cyttsp4_lift_all(&cd->md);
  1406. /* restore to sleep if was suspended */
  1407. mutex_lock(&cd->system_lock);
  1408. if (cd->sleep_state == SS_SLEEP_ON) {
  1409. cd->sleep_state = SS_SLEEP_OFF;
  1410. mutex_unlock(&cd->system_lock);
  1411. cyttsp4_core_sleep_(cd);
  1412. goto exit_no_wd;
  1413. }
  1414. mutex_unlock(&cd->system_lock);
  1415. exit:
  1416. cyttsp4_start_wd_timer(cd);
  1417. exit_no_wd:
  1418. return rc;
  1419. }
  1420. static int cyttsp4_startup(struct cyttsp4 *cd)
  1421. {
  1422. int rc;
  1423. mutex_lock(&cd->system_lock);
  1424. cd->startup_state = STARTUP_RUNNING;
  1425. mutex_unlock(&cd->system_lock);
  1426. rc = cyttsp4_request_exclusive(cd, cd->dev,
  1427. CY_CORE_REQUEST_EXCLUSIVE_TIMEOUT);
  1428. if (rc < 0) {
  1429. dev_err(cd->dev, "%s: fail get exclusive ex=%p own=%p\n",
  1430. __func__, cd->exclusive_dev, cd->dev);
  1431. goto exit;
  1432. }
  1433. rc = cyttsp4_startup_(cd);
  1434. if (cyttsp4_release_exclusive(cd, cd->dev) < 0)
  1435. /* Don't return fail code, mode is already changed. */
  1436. dev_err(cd->dev, "%s: fail to release exclusive\n", __func__);
  1437. else
  1438. dev_vdbg(cd->dev, "%s: pass release exclusive\n", __func__);
  1439. exit:
  1440. mutex_lock(&cd->system_lock);
  1441. cd->startup_state = STARTUP_NONE;
  1442. mutex_unlock(&cd->system_lock);
  1443. /* Wake the waiters for end of startup */
  1444. wake_up(&cd->wait_q);
  1445. return rc;
  1446. }
  1447. static void cyttsp4_startup_work_function(struct work_struct *work)
  1448. {
  1449. struct cyttsp4 *cd = container_of(work, struct cyttsp4, startup_work);
  1450. int rc;
  1451. rc = cyttsp4_startup(cd);
  1452. if (rc < 0)
  1453. dev_err(cd->dev, "%s: Fail queued startup r=%d\n",
  1454. __func__, rc);
  1455. }
  1456. static void cyttsp4_free_si_ptrs(struct cyttsp4 *cd)
  1457. {
  1458. struct cyttsp4_sysinfo *si = &cd->sysinfo;
  1459. if (!si)
  1460. return;
  1461. kfree(si->si_ptrs.cydata);
  1462. kfree(si->si_ptrs.test);
  1463. kfree(si->si_ptrs.pcfg);
  1464. kfree(si->si_ptrs.opcfg);
  1465. kfree(si->si_ptrs.ddata);
  1466. kfree(si->si_ptrs.mdata);
  1467. kfree(si->btn);
  1468. kfree(si->xy_mode);
  1469. kfree(si->xy_data);
  1470. kfree(si->btn_rec_data);
  1471. }
  1472. #ifdef CONFIG_PM
  1473. static int cyttsp4_core_sleep(struct cyttsp4 *cd)
  1474. {
  1475. int rc;
  1476. rc = cyttsp4_request_exclusive(cd, cd->dev,
  1477. CY_CORE_SLEEP_REQUEST_EXCLUSIVE_TIMEOUT);
  1478. if (rc < 0) {
  1479. dev_err(cd->dev, "%s: fail get exclusive ex=%p own=%p\n",
  1480. __func__, cd->exclusive_dev, cd->dev);
  1481. return 0;
  1482. }
  1483. rc = cyttsp4_core_sleep_(cd);
  1484. if (cyttsp4_release_exclusive(cd, cd->dev) < 0)
  1485. dev_err(cd->dev, "%s: fail to release exclusive\n", __func__);
  1486. else
  1487. dev_vdbg(cd->dev, "%s: pass release exclusive\n", __func__);
  1488. return rc;
  1489. }
  1490. static int cyttsp4_core_wake_(struct cyttsp4 *cd)
  1491. {
  1492. struct device *dev = cd->dev;
  1493. int rc;
  1494. u8 mode;
  1495. int t;
  1496. /* Already woken? */
  1497. mutex_lock(&cd->system_lock);
  1498. if (cd->sleep_state == SS_SLEEP_OFF) {
  1499. mutex_unlock(&cd->system_lock);
  1500. return 0;
  1501. }
  1502. cd->int_status &= ~CY_INT_IGNORE;
  1503. cd->int_status |= CY_INT_AWAKE;
  1504. cd->sleep_state = SS_WAKING;
  1505. if (cd->cpdata->power) {
  1506. dev_dbg(dev, "%s: Power up HW\n", __func__);
  1507. rc = cd->cpdata->power(cd->cpdata, 1, dev, &cd->ignore_irq);
  1508. } else {
  1509. dev_dbg(dev, "%s: No power function\n", __func__);
  1510. rc = -ENOSYS;
  1511. }
  1512. if (rc < 0) {
  1513. dev_err(dev, "%s: HW Power up fails r=%d\n",
  1514. __func__, rc);
  1515. /* Initiate a read transaction to wake up */
  1516. cyttsp4_adap_read(cd, CY_REG_BASE, sizeof(mode), &mode);
  1517. } else
  1518. dev_vdbg(cd->dev, "%s: HW power up succeeds\n",
  1519. __func__);
  1520. mutex_unlock(&cd->system_lock);
  1521. t = wait_event_timeout(cd->wait_q,
  1522. (cd->int_status & CY_INT_AWAKE) == 0,
  1523. msecs_to_jiffies(CY_CORE_WAKEUP_TIMEOUT));
  1524. if (IS_TMO(t)) {
  1525. dev_err(dev, "%s: TMO waiting for wakeup\n", __func__);
  1526. mutex_lock(&cd->system_lock);
  1527. cd->int_status &= ~CY_INT_AWAKE;
  1528. /* Try starting up */
  1529. cyttsp4_queue_startup_(cd);
  1530. mutex_unlock(&cd->system_lock);
  1531. }
  1532. mutex_lock(&cd->system_lock);
  1533. cd->sleep_state = SS_SLEEP_OFF;
  1534. mutex_unlock(&cd->system_lock);
  1535. cyttsp4_start_wd_timer(cd);
  1536. return 0;
  1537. }
  1538. static int cyttsp4_core_wake(struct cyttsp4 *cd)
  1539. {
  1540. int rc;
  1541. rc = cyttsp4_request_exclusive(cd, cd->dev,
  1542. CY_CORE_REQUEST_EXCLUSIVE_TIMEOUT);
  1543. if (rc < 0) {
  1544. dev_err(cd->dev, "%s: fail get exclusive ex=%p own=%p\n",
  1545. __func__, cd->exclusive_dev, cd->dev);
  1546. return 0;
  1547. }
  1548. rc = cyttsp4_core_wake_(cd);
  1549. if (cyttsp4_release_exclusive(cd, cd->dev) < 0)
  1550. dev_err(cd->dev, "%s: fail to release exclusive\n", __func__);
  1551. else
  1552. dev_vdbg(cd->dev, "%s: pass release exclusive\n", __func__);
  1553. return rc;
  1554. }
  1555. static int cyttsp4_core_suspend(struct device *dev)
  1556. {
  1557. struct cyttsp4 *cd = dev_get_drvdata(dev);
  1558. struct cyttsp4_mt_data *md = &cd->md;
  1559. int rc;
  1560. md->is_suspended = true;
  1561. rc = cyttsp4_core_sleep(cd);
  1562. if (rc < 0) {
  1563. dev_err(dev, "%s: Error on sleep\n", __func__);
  1564. return -EAGAIN;
  1565. }
  1566. return 0;
  1567. }
  1568. static int cyttsp4_core_resume(struct device *dev)
  1569. {
  1570. struct cyttsp4 *cd = dev_get_drvdata(dev);
  1571. struct cyttsp4_mt_data *md = &cd->md;
  1572. int rc;
  1573. md->is_suspended = false;
  1574. rc = cyttsp4_core_wake(cd);
  1575. if (rc < 0) {
  1576. dev_err(dev, "%s: Error on wake\n", __func__);
  1577. return -EAGAIN;
  1578. }
  1579. return 0;
  1580. }
  1581. #endif
  1582. const struct dev_pm_ops cyttsp4_pm_ops = {
  1583. SET_SYSTEM_SLEEP_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume)
  1584. SET_RUNTIME_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume, NULL)
  1585. };
  1586. EXPORT_SYMBOL_GPL(cyttsp4_pm_ops);
  1587. static int cyttsp4_mt_open(struct input_dev *input)
  1588. {
  1589. pm_runtime_get(input->dev.parent);
  1590. return 0;
  1591. }
  1592. static void cyttsp4_mt_close(struct input_dev *input)
  1593. {
  1594. struct cyttsp4_mt_data *md = input_get_drvdata(input);
  1595. mutex_lock(&md->report_lock);
  1596. if (!md->is_suspended)
  1597. pm_runtime_put(input->dev.parent);
  1598. mutex_unlock(&md->report_lock);
  1599. }
  1600. static int cyttsp4_setup_input_device(struct cyttsp4 *cd)
  1601. {
  1602. struct device *dev = cd->dev;
  1603. struct cyttsp4_mt_data *md = &cd->md;
  1604. int signal = CY_IGNORE_VALUE;
  1605. int max_x, max_y, max_p, min, max;
  1606. int max_x_tmp, max_y_tmp;
  1607. int i;
  1608. int rc;
  1609. dev_vdbg(dev, "%s: Initialize event signals\n", __func__);
  1610. __set_bit(EV_ABS, md->input->evbit);
  1611. __set_bit(EV_REL, md->input->evbit);
  1612. __set_bit(EV_KEY, md->input->evbit);
  1613. max_x_tmp = md->si->si_ofs.max_x;
  1614. max_y_tmp = md->si->si_ofs.max_y;
  1615. /* get maximum values from the sysinfo data */
  1616. if (md->pdata->flags & CY_FLAG_FLIP) {
  1617. max_x = max_y_tmp - 1;
  1618. max_y = max_x_tmp - 1;
  1619. } else {
  1620. max_x = max_x_tmp - 1;
  1621. max_y = max_y_tmp - 1;
  1622. }
  1623. max_p = md->si->si_ofs.max_p;
  1624. /* set event signal capabilities */
  1625. for (i = 0; i < (md->pdata->frmwrk->size / CY_NUM_ABS_SET); i++) {
  1626. signal = md->pdata->frmwrk->abs
  1627. [(i * CY_NUM_ABS_SET) + CY_SIGNAL_OST];
  1628. if (signal != CY_IGNORE_VALUE) {
  1629. __set_bit(signal, md->input->absbit);
  1630. min = md->pdata->frmwrk->abs
  1631. [(i * CY_NUM_ABS_SET) + CY_MIN_OST];
  1632. max = md->pdata->frmwrk->abs
  1633. [(i * CY_NUM_ABS_SET) + CY_MAX_OST];
  1634. if (i == CY_ABS_ID_OST) {
  1635. /* shift track ids down to start at 0 */
  1636. max = max - min;
  1637. min = min - min;
  1638. } else if (i == CY_ABS_X_OST)
  1639. max = max_x;
  1640. else if (i == CY_ABS_Y_OST)
  1641. max = max_y;
  1642. else if (i == CY_ABS_P_OST)
  1643. max = max_p;
  1644. input_set_abs_params(md->input, signal, min, max,
  1645. md->pdata->frmwrk->abs
  1646. [(i * CY_NUM_ABS_SET) + CY_FUZZ_OST],
  1647. md->pdata->frmwrk->abs
  1648. [(i * CY_NUM_ABS_SET) + CY_FLAT_OST]);
  1649. dev_dbg(dev, "%s: register signal=%02X min=%d max=%d\n",
  1650. __func__, signal, min, max);
  1651. if ((i == CY_ABS_ID_OST) &&
  1652. (md->si->si_ofs.tch_rec_size <
  1653. CY_TMA4XX_TCH_REC_SIZE))
  1654. break;
  1655. }
  1656. }
  1657. input_mt_init_slots(md->input, md->si->si_ofs.tch_abs[CY_TCH_T].max,
  1658. INPUT_MT_DIRECT);
  1659. rc = input_register_device(md->input);
  1660. if (rc < 0)
  1661. dev_err(dev, "%s: Error, failed register input device r=%d\n",
  1662. __func__, rc);
  1663. return rc;
  1664. }
  1665. static int cyttsp4_mt_probe(struct cyttsp4 *cd)
  1666. {
  1667. struct device *dev = cd->dev;
  1668. struct cyttsp4_mt_data *md = &cd->md;
  1669. struct cyttsp4_mt_platform_data *pdata = cd->pdata->mt_pdata;
  1670. int rc = 0;
  1671. mutex_init(&md->report_lock);
  1672. md->pdata = pdata;
  1673. /* Create the input device and register it. */
  1674. dev_vdbg(dev, "%s: Create the input device and register it\n",
  1675. __func__);
  1676. md->input = input_allocate_device();
  1677. if (md->input == NULL) {
  1678. dev_err(dev, "%s: Error, failed to allocate input device\n",
  1679. __func__);
  1680. rc = -ENOSYS;
  1681. goto error_alloc_failed;
  1682. }
  1683. md->input->name = pdata->inp_dev_name;
  1684. scnprintf(md->phys, sizeof(md->phys)-1, "%s", dev_name(dev));
  1685. md->input->phys = md->phys;
  1686. md->input->id.bustype = cd->bus_ops->bustype;
  1687. md->input->dev.parent = dev;
  1688. md->input->open = cyttsp4_mt_open;
  1689. md->input->close = cyttsp4_mt_close;
  1690. input_set_drvdata(md->input, md);
  1691. /* get sysinfo */
  1692. md->si = &cd->sysinfo;
  1693. if (!md->si) {
  1694. dev_err(dev, "%s: Fail get sysinfo pointer from core p=%p\n",
  1695. __func__, md->si);
  1696. goto error_get_sysinfo;
  1697. }
  1698. rc = cyttsp4_setup_input_device(cd);
  1699. if (rc)
  1700. goto error_init_input;
  1701. return 0;
  1702. error_init_input:
  1703. input_free_device(md->input);
  1704. error_get_sysinfo:
  1705. input_set_drvdata(md->input, NULL);
  1706. error_alloc_failed:
  1707. dev_err(dev, "%s failed.\n", __func__);
  1708. return rc;
  1709. }
  1710. struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops,
  1711. struct device *dev, u16 irq, size_t xfer_buf_size)
  1712. {
  1713. struct cyttsp4 *cd;
  1714. struct cyttsp4_platform_data *pdata = dev_get_platdata(dev);
  1715. unsigned long irq_flags;
  1716. int rc = 0;
  1717. if (!pdata || !pdata->core_pdata || !pdata->mt_pdata) {
  1718. dev_err(dev, "%s: Missing platform data\n", __func__);
  1719. rc = -ENODEV;
  1720. goto error_no_pdata;
  1721. }
  1722. cd = kzalloc(sizeof(*cd), GFP_KERNEL);
  1723. if (!cd) {
  1724. dev_err(dev, "%s: Error, kzalloc\n", __func__);
  1725. rc = -ENOMEM;
  1726. goto error_alloc_data;
  1727. }
  1728. cd->xfer_buf = kzalloc(xfer_buf_size, GFP_KERNEL);
  1729. if (!cd->xfer_buf) {
  1730. dev_err(dev, "%s: Error, kzalloc\n", __func__);
  1731. rc = -ENOMEM;
  1732. goto error_free_cd;
  1733. }
  1734. /* Initialize device info */
  1735. cd->dev = dev;
  1736. cd->pdata = pdata;
  1737. cd->cpdata = pdata->core_pdata;
  1738. cd->bus_ops = ops;
  1739. /* Initialize mutexes and spinlocks */
  1740. mutex_init(&cd->system_lock);
  1741. mutex_init(&cd->adap_lock);
  1742. /* Initialize wait queue */
  1743. init_waitqueue_head(&cd->wait_q);
  1744. /* Initialize works */
  1745. INIT_WORK(&cd->startup_work, cyttsp4_startup_work_function);
  1746. INIT_WORK(&cd->watchdog_work, cyttsp4_watchdog_work);
  1747. /* Initialize IRQ */
  1748. cd->irq = gpio_to_irq(cd->cpdata->irq_gpio);
  1749. if (cd->irq < 0) {
  1750. rc = -EINVAL;
  1751. goto error_free_xfer;
  1752. }
  1753. dev_set_drvdata(dev, cd);
  1754. /* Call platform init function */
  1755. if (cd->cpdata->init) {
  1756. dev_dbg(cd->dev, "%s: Init HW\n", __func__);
  1757. rc = cd->cpdata->init(cd->cpdata, 1, cd->dev);
  1758. } else {
  1759. dev_dbg(cd->dev, "%s: No HW INIT function\n", __func__);
  1760. rc = 0;
  1761. }
  1762. if (rc < 0)
  1763. dev_err(cd->dev, "%s: HW Init fail r=%d\n", __func__, rc);
  1764. dev_dbg(dev, "%s: initialize threaded irq=%d\n", __func__, cd->irq);
  1765. if (cd->cpdata->level_irq_udelay > 0)
  1766. /* use level triggered interrupts */
  1767. irq_flags = IRQF_TRIGGER_LOW | IRQF_ONESHOT;
  1768. else
  1769. /* use edge triggered interrupts */
  1770. irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
  1771. rc = request_threaded_irq(cd->irq, NULL, cyttsp4_irq, irq_flags,
  1772. dev_name(dev), cd);
  1773. if (rc < 0) {
  1774. dev_err(dev, "%s: Error, could not request irq\n", __func__);
  1775. goto error_request_irq;
  1776. }
  1777. /* Setup watchdog timer */
  1778. setup_timer(&cd->watchdog_timer, cyttsp4_watchdog_timer,
  1779. (unsigned long)cd);
  1780. /*
  1781. * call startup directly to ensure that the device
  1782. * is tested before leaving the probe
  1783. */
  1784. rc = cyttsp4_startup(cd);
  1785. /* Do not fail probe if startup fails but the device is detected */
  1786. if (rc < 0 && cd->mode == CY_MODE_UNKNOWN) {
  1787. dev_err(cd->dev, "%s: Fail initial startup r=%d\n",
  1788. __func__, rc);
  1789. goto error_startup;
  1790. }
  1791. rc = cyttsp4_mt_probe(cd);
  1792. if (rc < 0) {
  1793. dev_err(dev, "%s: Error, fail mt probe\n", __func__);
  1794. goto error_startup;
  1795. }
  1796. pm_runtime_enable(dev);
  1797. return cd;
  1798. error_startup:
  1799. cancel_work_sync(&cd->startup_work);
  1800. cyttsp4_stop_wd_timer(cd);
  1801. pm_runtime_disable(dev);
  1802. cyttsp4_free_si_ptrs(cd);
  1803. free_irq(cd->irq, cd);
  1804. error_request_irq:
  1805. if (cd->cpdata->init)
  1806. cd->cpdata->init(cd->cpdata, 0, dev);
  1807. error_free_xfer:
  1808. kfree(cd->xfer_buf);
  1809. error_free_cd:
  1810. kfree(cd);
  1811. error_alloc_data:
  1812. error_no_pdata:
  1813. dev_err(dev, "%s failed.\n", __func__);
  1814. return ERR_PTR(rc);
  1815. }
  1816. EXPORT_SYMBOL_GPL(cyttsp4_probe);
  1817. static void cyttsp4_mt_release(struct cyttsp4_mt_data *md)
  1818. {
  1819. input_unregister_device(md->input);
  1820. input_set_drvdata(md->input, NULL);
  1821. }
  1822. int cyttsp4_remove(struct cyttsp4 *cd)
  1823. {
  1824. struct device *dev = cd->dev;
  1825. cyttsp4_mt_release(&cd->md);
  1826. /*
  1827. * Suspend the device before freeing the startup_work and stopping
  1828. * the watchdog since sleep function restarts watchdog on failure
  1829. */
  1830. pm_runtime_suspend(dev);
  1831. pm_runtime_disable(dev);
  1832. cancel_work_sync(&cd->startup_work);
  1833. cyttsp4_stop_wd_timer(cd);
  1834. free_irq(cd->irq, cd);
  1835. if (cd->cpdata->init)
  1836. cd->cpdata->init(cd->cpdata, 0, dev);
  1837. cyttsp4_free_si_ptrs(cd);
  1838. kfree(cd);
  1839. return 0;
  1840. }
  1841. EXPORT_SYMBOL_GPL(cyttsp4_remove);
  1842. MODULE_LICENSE("GPL");
  1843. MODULE_DESCRIPTION("Cypress TrueTouch(R) Standard touchscreen core driver");
  1844. MODULE_AUTHOR("Cypress");