cyttsp_core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /*
  2. * Core Source for:
  3. * Cypress TrueTouch(TM) Standard Product (TTSP) touchscreen drivers.
  4. * For use with Cypress Txx3xx parts.
  5. * Supported parts include:
  6. * CY8CTST341
  7. * CY8CTMA340
  8. *
  9. * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc.
  10. * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org>
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * version 2, and only version 2, as published by the
  15. * Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License along
  23. * with this program; if not, write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  25. *
  26. * Contact Cypress Semiconductor at www.cypress.com <kev@cypress.com>
  27. *
  28. */
  29. #include <linux/delay.h>
  30. #include <linux/input.h>
  31. #include <linux/input/mt.h>
  32. #include <linux/input/touchscreen.h>
  33. #include <linux/gpio.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/slab.h>
  36. #include <linux/property.h>
  37. #include <linux/gpio/consumer.h>
  38. #include "cyttsp_core.h"
  39. /* Bootloader number of command keys */
  40. #define CY_NUM_BL_KEYS 8
  41. /* helpers */
  42. #define GET_NUM_TOUCHES(x) ((x) & 0x0F)
  43. #define IS_LARGE_AREA(x) (((x) & 0x10) >> 4)
  44. #define IS_BAD_PKT(x) ((x) & 0x20)
  45. #define IS_VALID_APP(x) ((x) & 0x01)
  46. #define IS_OPERATIONAL_ERR(x) ((x) & 0x3F)
  47. #define GET_HSTMODE(reg) (((reg) & 0x70) >> 4)
  48. #define GET_BOOTLOADERMODE(reg) (((reg) & 0x10) >> 4)
  49. #define CY_REG_BASE 0x00
  50. #define CY_REG_ACT_DIST 0x1E
  51. #define CY_REG_ACT_INTRVL 0x1D
  52. #define CY_REG_TCH_TMOUT (CY_REG_ACT_INTRVL + 1)
  53. #define CY_REG_LP_INTRVL (CY_REG_TCH_TMOUT + 1)
  54. #define CY_MAXZ 255
  55. #define CY_DELAY_DFLT 20 /* ms */
  56. #define CY_DELAY_MAX 500
  57. #define CY_ACT_DIST_DFLT 0xF8
  58. #define CY_ACT_DIST_MASK 0x0F
  59. #define CY_HNDSHK_BIT 0x80
  60. /* device mode bits */
  61. #define CY_OPERATE_MODE 0x00
  62. #define CY_SYSINFO_MODE 0x10
  63. /* power mode select bits */
  64. #define CY_SOFT_RESET_MODE 0x01 /* return to Bootloader mode */
  65. #define CY_DEEP_SLEEP_MODE 0x02
  66. #define CY_LOW_POWER_MODE 0x04
  67. /* Slots management */
  68. #define CY_MAX_FINGER 4
  69. #define CY_MAX_ID 16
  70. static const u8 bl_command[] = {
  71. 0x00, /* file offset */
  72. 0xFF, /* command */
  73. 0xA5, /* exit bootloader command */
  74. 0, 1, 2, 3, 4, 5, 6, 7 /* default keys */
  75. };
  76. static int ttsp_read_block_data(struct cyttsp *ts, u8 command,
  77. u8 length, void *buf)
  78. {
  79. int error;
  80. int tries;
  81. for (tries = 0; tries < CY_NUM_RETRY; tries++) {
  82. error = ts->bus_ops->read(ts->dev, ts->xfer_buf, command,
  83. length, buf);
  84. if (!error)
  85. return 0;
  86. msleep(CY_DELAY_DFLT);
  87. }
  88. return -EIO;
  89. }
  90. static int ttsp_write_block_data(struct cyttsp *ts, u8 command,
  91. u8 length, void *buf)
  92. {
  93. int error;
  94. int tries;
  95. for (tries = 0; tries < CY_NUM_RETRY; tries++) {
  96. error = ts->bus_ops->write(ts->dev, ts->xfer_buf, command,
  97. length, buf);
  98. if (!error)
  99. return 0;
  100. msleep(CY_DELAY_DFLT);
  101. }
  102. return -EIO;
  103. }
  104. static int ttsp_send_command(struct cyttsp *ts, u8 cmd)
  105. {
  106. return ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), &cmd);
  107. }
  108. static int cyttsp_handshake(struct cyttsp *ts)
  109. {
  110. if (ts->use_hndshk)
  111. return ttsp_send_command(ts,
  112. ts->xy_data.hst_mode ^ CY_HNDSHK_BIT);
  113. return 0;
  114. }
  115. static int cyttsp_load_bl_regs(struct cyttsp *ts)
  116. {
  117. memset(&ts->bl_data, 0, sizeof(ts->bl_data));
  118. ts->bl_data.bl_status = 0x10;
  119. return ttsp_read_block_data(ts, CY_REG_BASE,
  120. sizeof(ts->bl_data), &ts->bl_data);
  121. }
  122. static int cyttsp_exit_bl_mode(struct cyttsp *ts)
  123. {
  124. int error;
  125. u8 bl_cmd[sizeof(bl_command)];
  126. memcpy(bl_cmd, bl_command, sizeof(bl_command));
  127. if (ts->bl_keys)
  128. memcpy(&bl_cmd[sizeof(bl_command) - CY_NUM_BL_KEYS],
  129. ts->bl_keys, CY_NUM_BL_KEYS);
  130. error = ttsp_write_block_data(ts, CY_REG_BASE,
  131. sizeof(bl_cmd), bl_cmd);
  132. if (error)
  133. return error;
  134. /* wait for TTSP Device to complete the operation */
  135. msleep(CY_DELAY_DFLT);
  136. error = cyttsp_load_bl_regs(ts);
  137. if (error)
  138. return error;
  139. if (GET_BOOTLOADERMODE(ts->bl_data.bl_status))
  140. return -EIO;
  141. return 0;
  142. }
  143. static int cyttsp_set_operational_mode(struct cyttsp *ts)
  144. {
  145. int error;
  146. error = ttsp_send_command(ts, CY_OPERATE_MODE);
  147. if (error)
  148. return error;
  149. /* wait for TTSP Device to complete switch to Operational mode */
  150. error = ttsp_read_block_data(ts, CY_REG_BASE,
  151. sizeof(ts->xy_data), &ts->xy_data);
  152. if (error)
  153. return error;
  154. error = cyttsp_handshake(ts);
  155. if (error)
  156. return error;
  157. return ts->xy_data.act_dist == CY_ACT_DIST_DFLT ? -EIO : 0;
  158. }
  159. static int cyttsp_set_sysinfo_mode(struct cyttsp *ts)
  160. {
  161. int error;
  162. memset(&ts->sysinfo_data, 0, sizeof(ts->sysinfo_data));
  163. /* switch to sysinfo mode */
  164. error = ttsp_send_command(ts, CY_SYSINFO_MODE);
  165. if (error)
  166. return error;
  167. /* read sysinfo registers */
  168. msleep(CY_DELAY_DFLT);
  169. error = ttsp_read_block_data(ts, CY_REG_BASE, sizeof(ts->sysinfo_data),
  170. &ts->sysinfo_data);
  171. if (error)
  172. return error;
  173. error = cyttsp_handshake(ts);
  174. if (error)
  175. return error;
  176. if (!ts->sysinfo_data.tts_verh && !ts->sysinfo_data.tts_verl)
  177. return -EIO;
  178. return 0;
  179. }
  180. static int cyttsp_set_sysinfo_regs(struct cyttsp *ts)
  181. {
  182. int retval = 0;
  183. if (ts->act_intrvl != CY_ACT_INTRVL_DFLT ||
  184. ts->tch_tmout != CY_TCH_TMOUT_DFLT ||
  185. ts->lp_intrvl != CY_LP_INTRVL_DFLT) {
  186. u8 intrvl_ray[] = {
  187. ts->act_intrvl,
  188. ts->tch_tmout,
  189. ts->lp_intrvl
  190. };
  191. /* set intrvl registers */
  192. retval = ttsp_write_block_data(ts, CY_REG_ACT_INTRVL,
  193. sizeof(intrvl_ray), intrvl_ray);
  194. msleep(CY_DELAY_DFLT);
  195. }
  196. return retval;
  197. }
  198. static void cyttsp_hard_reset(struct cyttsp *ts)
  199. {
  200. if (ts->reset_gpio) {
  201. gpiod_set_value_cansleep(ts->reset_gpio, 1);
  202. msleep(CY_DELAY_DFLT);
  203. gpiod_set_value_cansleep(ts->reset_gpio, 0);
  204. msleep(CY_DELAY_DFLT);
  205. }
  206. }
  207. static int cyttsp_soft_reset(struct cyttsp *ts)
  208. {
  209. unsigned long timeout;
  210. int retval;
  211. /* wait for interrupt to set ready completion */
  212. reinit_completion(&ts->bl_ready);
  213. ts->state = CY_BL_STATE;
  214. enable_irq(ts->irq);
  215. retval = ttsp_send_command(ts, CY_SOFT_RESET_MODE);
  216. if (retval)
  217. goto out;
  218. timeout = wait_for_completion_timeout(&ts->bl_ready,
  219. msecs_to_jiffies(CY_DELAY_DFLT * CY_DELAY_MAX));
  220. retval = timeout ? 0 : -EIO;
  221. out:
  222. ts->state = CY_IDLE_STATE;
  223. disable_irq(ts->irq);
  224. return retval;
  225. }
  226. static int cyttsp_act_dist_setup(struct cyttsp *ts)
  227. {
  228. u8 act_dist_setup = ts->act_dist;
  229. /* Init gesture; active distance setup */
  230. return ttsp_write_block_data(ts, CY_REG_ACT_DIST,
  231. sizeof(act_dist_setup), &act_dist_setup);
  232. }
  233. static void cyttsp_extract_track_ids(struct cyttsp_xydata *xy_data, int *ids)
  234. {
  235. ids[0] = xy_data->touch12_id >> 4;
  236. ids[1] = xy_data->touch12_id & 0xF;
  237. ids[2] = xy_data->touch34_id >> 4;
  238. ids[3] = xy_data->touch34_id & 0xF;
  239. }
  240. static const struct cyttsp_tch *cyttsp_get_tch(struct cyttsp_xydata *xy_data,
  241. int idx)
  242. {
  243. switch (idx) {
  244. case 0:
  245. return &xy_data->tch1;
  246. case 1:
  247. return &xy_data->tch2;
  248. case 2:
  249. return &xy_data->tch3;
  250. case 3:
  251. return &xy_data->tch4;
  252. default:
  253. return NULL;
  254. }
  255. }
  256. static void cyttsp_report_tchdata(struct cyttsp *ts)
  257. {
  258. struct cyttsp_xydata *xy_data = &ts->xy_data;
  259. struct input_dev *input = ts->input;
  260. int num_tch = GET_NUM_TOUCHES(xy_data->tt_stat);
  261. const struct cyttsp_tch *tch;
  262. int ids[CY_MAX_ID];
  263. int i;
  264. DECLARE_BITMAP(used, CY_MAX_ID);
  265. if (IS_LARGE_AREA(xy_data->tt_stat) == 1) {
  266. /* terminate all active tracks */
  267. num_tch = 0;
  268. dev_dbg(ts->dev, "%s: Large area detected\n", __func__);
  269. } else if (num_tch > CY_MAX_FINGER) {
  270. /* terminate all active tracks */
  271. num_tch = 0;
  272. dev_dbg(ts->dev, "%s: Num touch error detected\n", __func__);
  273. } else if (IS_BAD_PKT(xy_data->tt_mode)) {
  274. /* terminate all active tracks */
  275. num_tch = 0;
  276. dev_dbg(ts->dev, "%s: Invalid buffer detected\n", __func__);
  277. }
  278. cyttsp_extract_track_ids(xy_data, ids);
  279. bitmap_zero(used, CY_MAX_ID);
  280. for (i = 0; i < num_tch; i++) {
  281. tch = cyttsp_get_tch(xy_data, i);
  282. input_mt_slot(input, ids[i]);
  283. input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
  284. input_report_abs(input, ABS_MT_POSITION_X, be16_to_cpu(tch->x));
  285. input_report_abs(input, ABS_MT_POSITION_Y, be16_to_cpu(tch->y));
  286. input_report_abs(input, ABS_MT_TOUCH_MAJOR, tch->z);
  287. __set_bit(ids[i], used);
  288. }
  289. for (i = 0; i < CY_MAX_ID; i++) {
  290. if (test_bit(i, used))
  291. continue;
  292. input_mt_slot(input, i);
  293. input_mt_report_slot_state(input, MT_TOOL_FINGER, false);
  294. }
  295. input_sync(input);
  296. }
  297. static irqreturn_t cyttsp_irq(int irq, void *handle)
  298. {
  299. struct cyttsp *ts = handle;
  300. int error;
  301. if (unlikely(ts->state == CY_BL_STATE)) {
  302. complete(&ts->bl_ready);
  303. goto out;
  304. }
  305. /* Get touch data from CYTTSP device */
  306. error = ttsp_read_block_data(ts, CY_REG_BASE,
  307. sizeof(struct cyttsp_xydata), &ts->xy_data);
  308. if (error)
  309. goto out;
  310. /* provide flow control handshake */
  311. error = cyttsp_handshake(ts);
  312. if (error)
  313. goto out;
  314. if (unlikely(ts->state == CY_IDLE_STATE))
  315. goto out;
  316. if (GET_BOOTLOADERMODE(ts->xy_data.tt_mode)) {
  317. /*
  318. * TTSP device has reset back to bootloader mode.
  319. * Restore to operational mode.
  320. */
  321. error = cyttsp_exit_bl_mode(ts);
  322. if (error) {
  323. dev_err(ts->dev,
  324. "Could not return to operational mode, err: %d\n",
  325. error);
  326. ts->state = CY_IDLE_STATE;
  327. }
  328. } else {
  329. cyttsp_report_tchdata(ts);
  330. }
  331. out:
  332. return IRQ_HANDLED;
  333. }
  334. static int cyttsp_power_on(struct cyttsp *ts)
  335. {
  336. int error;
  337. error = cyttsp_soft_reset(ts);
  338. if (error)
  339. return error;
  340. error = cyttsp_load_bl_regs(ts);
  341. if (error)
  342. return error;
  343. if (GET_BOOTLOADERMODE(ts->bl_data.bl_status) &&
  344. IS_VALID_APP(ts->bl_data.bl_status)) {
  345. error = cyttsp_exit_bl_mode(ts);
  346. if (error)
  347. return error;
  348. }
  349. if (GET_HSTMODE(ts->bl_data.bl_file) != CY_OPERATE_MODE ||
  350. IS_OPERATIONAL_ERR(ts->bl_data.bl_status)) {
  351. return -ENODEV;
  352. }
  353. error = cyttsp_set_sysinfo_mode(ts);
  354. if (error)
  355. return error;
  356. error = cyttsp_set_sysinfo_regs(ts);
  357. if (error)
  358. return error;
  359. error = cyttsp_set_operational_mode(ts);
  360. if (error)
  361. return error;
  362. /* init active distance */
  363. error = cyttsp_act_dist_setup(ts);
  364. if (error)
  365. return error;
  366. ts->state = CY_ACTIVE_STATE;
  367. return 0;
  368. }
  369. static int cyttsp_enable(struct cyttsp *ts)
  370. {
  371. int error;
  372. /*
  373. * The device firmware can wake on an I2C or SPI memory slave
  374. * address match. So just reading a register is sufficient to
  375. * wake up the device. The first read attempt will fail but it
  376. * will wake it up making the second read attempt successful.
  377. */
  378. error = ttsp_read_block_data(ts, CY_REG_BASE,
  379. sizeof(ts->xy_data), &ts->xy_data);
  380. if (error)
  381. return error;
  382. if (GET_HSTMODE(ts->xy_data.hst_mode))
  383. return -EIO;
  384. enable_irq(ts->irq);
  385. return 0;
  386. }
  387. static int cyttsp_disable(struct cyttsp *ts)
  388. {
  389. int error;
  390. error = ttsp_send_command(ts, CY_LOW_POWER_MODE);
  391. if (error)
  392. return error;
  393. disable_irq(ts->irq);
  394. return 0;
  395. }
  396. static int __maybe_unused cyttsp_suspend(struct device *dev)
  397. {
  398. struct cyttsp *ts = dev_get_drvdata(dev);
  399. int retval = 0;
  400. mutex_lock(&ts->input->mutex);
  401. if (ts->input->users) {
  402. retval = cyttsp_disable(ts);
  403. if (retval == 0)
  404. ts->suspended = true;
  405. }
  406. mutex_unlock(&ts->input->mutex);
  407. return retval;
  408. }
  409. static int __maybe_unused cyttsp_resume(struct device *dev)
  410. {
  411. struct cyttsp *ts = dev_get_drvdata(dev);
  412. mutex_lock(&ts->input->mutex);
  413. if (ts->input->users)
  414. cyttsp_enable(ts);
  415. ts->suspended = false;
  416. mutex_unlock(&ts->input->mutex);
  417. return 0;
  418. }
  419. SIMPLE_DEV_PM_OPS(cyttsp_pm_ops, cyttsp_suspend, cyttsp_resume);
  420. EXPORT_SYMBOL_GPL(cyttsp_pm_ops);
  421. static int cyttsp_open(struct input_dev *dev)
  422. {
  423. struct cyttsp *ts = input_get_drvdata(dev);
  424. int retval = 0;
  425. if (!ts->suspended)
  426. retval = cyttsp_enable(ts);
  427. return retval;
  428. }
  429. static void cyttsp_close(struct input_dev *dev)
  430. {
  431. struct cyttsp *ts = input_get_drvdata(dev);
  432. if (!ts->suspended)
  433. cyttsp_disable(ts);
  434. }
  435. static int cyttsp_parse_properties(struct cyttsp *ts)
  436. {
  437. struct device *dev = ts->dev;
  438. u32 dt_value;
  439. int ret;
  440. ts->bl_keys = devm_kzalloc(dev, CY_NUM_BL_KEYS, GFP_KERNEL);
  441. if (!ts->bl_keys)
  442. return -ENOMEM;
  443. /* Set some default values */
  444. ts->use_hndshk = false;
  445. ts->act_dist = CY_ACT_DIST_DFLT;
  446. ts->act_intrvl = CY_ACT_INTRVL_DFLT;
  447. ts->tch_tmout = CY_TCH_TMOUT_DFLT;
  448. ts->lp_intrvl = CY_LP_INTRVL_DFLT;
  449. ret = device_property_read_u8_array(dev, "bootloader-key",
  450. ts->bl_keys, CY_NUM_BL_KEYS);
  451. if (ret) {
  452. dev_err(dev,
  453. "bootloader-key property could not be retrieved\n");
  454. return ret;
  455. }
  456. ts->use_hndshk = device_property_present(dev, "use-handshake");
  457. if (!device_property_read_u32(dev, "active-distance", &dt_value)) {
  458. if (dt_value > 15) {
  459. dev_err(dev, "active-distance (%u) must be [0-15]\n",
  460. dt_value);
  461. return -EINVAL;
  462. }
  463. ts->act_dist &= ~CY_ACT_DIST_MASK;
  464. ts->act_dist |= dt_value;
  465. }
  466. if (!device_property_read_u32(dev, "active-interval-ms", &dt_value)) {
  467. if (dt_value > 255) {
  468. dev_err(dev, "active-interval-ms (%u) must be [0-255]\n",
  469. dt_value);
  470. return -EINVAL;
  471. }
  472. ts->act_intrvl = dt_value;
  473. }
  474. if (!device_property_read_u32(dev, "lowpower-interval-ms", &dt_value)) {
  475. if (dt_value > 2550) {
  476. dev_err(dev, "lowpower-interval-ms (%u) must be [0-2550]\n",
  477. dt_value);
  478. return -EINVAL;
  479. }
  480. /* Register value is expressed in 0.01s / bit */
  481. ts->lp_intrvl = dt_value / 10;
  482. }
  483. if (!device_property_read_u32(dev, "touch-timeout-ms", &dt_value)) {
  484. if (dt_value > 2550) {
  485. dev_err(dev, "touch-timeout-ms (%u) must be [0-2550]\n",
  486. dt_value);
  487. return -EINVAL;
  488. }
  489. /* Register value is expressed in 0.01s / bit */
  490. ts->tch_tmout = dt_value / 10;
  491. }
  492. return 0;
  493. }
  494. struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
  495. struct device *dev, int irq, size_t xfer_buf_size)
  496. {
  497. struct cyttsp *ts;
  498. struct input_dev *input_dev;
  499. int error;
  500. ts = devm_kzalloc(dev, sizeof(*ts) + xfer_buf_size, GFP_KERNEL);
  501. if (!ts)
  502. return ERR_PTR(-ENOMEM);
  503. input_dev = devm_input_allocate_device(dev);
  504. if (!input_dev)
  505. return ERR_PTR(-ENOMEM);
  506. ts->dev = dev;
  507. ts->input = input_dev;
  508. ts->bus_ops = bus_ops;
  509. ts->irq = irq;
  510. ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
  511. if (IS_ERR(ts->reset_gpio)) {
  512. error = PTR_ERR(ts->reset_gpio);
  513. dev_err(dev, "Failed to request reset gpio, error %d\n", error);
  514. return ERR_PTR(error);
  515. }
  516. error = cyttsp_parse_properties(ts);
  517. if (error)
  518. return ERR_PTR(error);
  519. init_completion(&ts->bl_ready);
  520. snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
  521. input_dev->name = "Cypress TTSP TouchScreen";
  522. input_dev->phys = ts->phys;
  523. input_dev->id.bustype = bus_ops->bustype;
  524. input_dev->dev.parent = ts->dev;
  525. input_dev->open = cyttsp_open;
  526. input_dev->close = cyttsp_close;
  527. input_set_drvdata(input_dev, ts);
  528. input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X);
  529. input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y);
  530. touchscreen_parse_properties(input_dev, true, NULL);
  531. error = input_mt_init_slots(input_dev, CY_MAX_ID, 0);
  532. if (error) {
  533. dev_err(dev, "Unable to init MT slots.\n");
  534. return ERR_PTR(error);
  535. }
  536. error = devm_request_threaded_irq(dev, ts->irq, NULL, cyttsp_irq,
  537. IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
  538. "cyttsp", ts);
  539. if (error) {
  540. dev_err(ts->dev, "failed to request IRQ %d, err: %d\n",
  541. ts->irq, error);
  542. return ERR_PTR(error);
  543. }
  544. disable_irq(ts->irq);
  545. cyttsp_hard_reset(ts);
  546. error = cyttsp_power_on(ts);
  547. if (error)
  548. return ERR_PTR(error);
  549. error = input_register_device(input_dev);
  550. if (error) {
  551. dev_err(ts->dev, "failed to register input device: %d\n",
  552. error);
  553. return ERR_PTR(error);
  554. }
  555. return ts;
  556. }
  557. EXPORT_SYMBOL_GPL(cyttsp_probe);
  558. MODULE_LICENSE("GPL");
  559. MODULE_DESCRIPTION("Cypress TrueTouch(R) Standard touchscreen driver core");
  560. MODULE_AUTHOR("Cypress");