cyttsp4_core.c 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157
  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 BOOTLADER 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");