fsl-imx25-tcq.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (C) 2014-2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de>
  4. // Based on driver from 2011:
  5. // Juergen Beisert, Pengutronix <kernel@pengutronix.de>
  6. //
  7. // This is the driver for the imx25 TCQ (Touchscreen Conversion Queue)
  8. // connected to the imx25 ADC.
  9. #include <linux/clk.h>
  10. #include <linux/device.h>
  11. #include <linux/input.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/mfd/imx25-tsadc.h>
  14. #include <linux/module.h>
  15. #include <linux/of.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/regmap.h>
  18. static const char mx25_tcq_name[] = "mx25-tcq";
  19. enum mx25_tcq_mode {
  20. MX25_TS_4WIRE,
  21. };
  22. struct mx25_tcq_priv {
  23. struct regmap *regs;
  24. struct regmap *core_regs;
  25. struct input_dev *idev;
  26. enum mx25_tcq_mode mode;
  27. unsigned int pen_threshold;
  28. unsigned int sample_count;
  29. unsigned int expected_samples;
  30. unsigned int pen_debounce;
  31. unsigned int settling_time;
  32. struct clk *clk;
  33. int irq;
  34. struct device *dev;
  35. };
  36. static const struct regmap_config mx25_tcq_regconfig = {
  37. .max_register = 0x5c,
  38. .reg_bits = 32,
  39. .val_bits = 32,
  40. .reg_stride = 4,
  41. };
  42. static const struct of_device_id mx25_tcq_ids[] = {
  43. { .compatible = "fsl,imx25-tcq", },
  44. { /* Sentinel */ }
  45. };
  46. MODULE_DEVICE_TABLE(of, mx25_tcq_ids);
  47. #define TSC_4WIRE_PRE_INDEX 0
  48. #define TSC_4WIRE_X_INDEX 1
  49. #define TSC_4WIRE_Y_INDEX 2
  50. #define TSC_4WIRE_POST_INDEX 3
  51. #define TSC_4WIRE_LEAVE 4
  52. #define MX25_TSC_DEF_THRESHOLD 80
  53. #define TSC_MAX_SAMPLES 16
  54. #define MX25_TSC_REPEAT_WAIT 14
  55. enum mx25_adc_configurations {
  56. MX25_CFG_PRECHARGE = 0,
  57. MX25_CFG_TOUCH_DETECT,
  58. MX25_CFG_X_MEASUREMENT,
  59. MX25_CFG_Y_MEASUREMENT,
  60. };
  61. #define MX25_PRECHARGE_VALUE (\
  62. MX25_ADCQ_CFG_YPLL_OFF | \
  63. MX25_ADCQ_CFG_XNUR_OFF | \
  64. MX25_ADCQ_CFG_XPUL_HIGH | \
  65. MX25_ADCQ_CFG_REFP_INT | \
  66. MX25_ADCQ_CFG_IN_XP | \
  67. MX25_ADCQ_CFG_REFN_NGND2 | \
  68. MX25_ADCQ_CFG_IGS)
  69. #define MX25_TOUCH_DETECT_VALUE (\
  70. MX25_ADCQ_CFG_YNLR | \
  71. MX25_ADCQ_CFG_YPLL_OFF | \
  72. MX25_ADCQ_CFG_XNUR_OFF | \
  73. MX25_ADCQ_CFG_XPUL_OFF | \
  74. MX25_ADCQ_CFG_REFP_INT | \
  75. MX25_ADCQ_CFG_IN_XP | \
  76. MX25_ADCQ_CFG_REFN_NGND2 | \
  77. MX25_ADCQ_CFG_PENIACK)
  78. static void imx25_setup_queue_cfgs(struct mx25_tcq_priv *priv,
  79. unsigned int settling_cnt)
  80. {
  81. u32 precharge_cfg =
  82. MX25_PRECHARGE_VALUE |
  83. MX25_ADCQ_CFG_SETTLING_TIME(settling_cnt);
  84. u32 touch_detect_cfg =
  85. MX25_TOUCH_DETECT_VALUE |
  86. MX25_ADCQ_CFG_NOS(1) |
  87. MX25_ADCQ_CFG_SETTLING_TIME(settling_cnt);
  88. regmap_write(priv->core_regs, MX25_TSC_TICR, precharge_cfg);
  89. /* PRECHARGE */
  90. regmap_write(priv->regs, MX25_ADCQ_CFG(MX25_CFG_PRECHARGE),
  91. precharge_cfg);
  92. /* TOUCH_DETECT */
  93. regmap_write(priv->regs, MX25_ADCQ_CFG(MX25_CFG_TOUCH_DETECT),
  94. touch_detect_cfg);
  95. /* X Measurement */
  96. regmap_write(priv->regs, MX25_ADCQ_CFG(MX25_CFG_X_MEASUREMENT),
  97. MX25_ADCQ_CFG_YPLL_OFF |
  98. MX25_ADCQ_CFG_XNUR_LOW |
  99. MX25_ADCQ_CFG_XPUL_HIGH |
  100. MX25_ADCQ_CFG_REFP_XP |
  101. MX25_ADCQ_CFG_IN_YP |
  102. MX25_ADCQ_CFG_REFN_XN |
  103. MX25_ADCQ_CFG_NOS(priv->sample_count) |
  104. MX25_ADCQ_CFG_SETTLING_TIME(settling_cnt));
  105. /* Y Measurement */
  106. regmap_write(priv->regs, MX25_ADCQ_CFG(MX25_CFG_Y_MEASUREMENT),
  107. MX25_ADCQ_CFG_YNLR |
  108. MX25_ADCQ_CFG_YPLL_HIGH |
  109. MX25_ADCQ_CFG_XNUR_OFF |
  110. MX25_ADCQ_CFG_XPUL_OFF |
  111. MX25_ADCQ_CFG_REFP_YP |
  112. MX25_ADCQ_CFG_IN_XP |
  113. MX25_ADCQ_CFG_REFN_YN |
  114. MX25_ADCQ_CFG_NOS(priv->sample_count) |
  115. MX25_ADCQ_CFG_SETTLING_TIME(settling_cnt));
  116. /* Enable the touch detection right now */
  117. regmap_write(priv->core_regs, MX25_TSC_TICR, touch_detect_cfg |
  118. MX25_ADCQ_CFG_IGS);
  119. }
  120. static int imx25_setup_queue_4wire(struct mx25_tcq_priv *priv,
  121. unsigned settling_cnt, int *items)
  122. {
  123. imx25_setup_queue_cfgs(priv, settling_cnt);
  124. /* Setup the conversion queue */
  125. regmap_write(priv->regs, MX25_ADCQ_ITEM_7_0,
  126. MX25_ADCQ_ITEM(0, MX25_CFG_PRECHARGE) |
  127. MX25_ADCQ_ITEM(1, MX25_CFG_TOUCH_DETECT) |
  128. MX25_ADCQ_ITEM(2, MX25_CFG_X_MEASUREMENT) |
  129. MX25_ADCQ_ITEM(3, MX25_CFG_Y_MEASUREMENT) |
  130. MX25_ADCQ_ITEM(4, MX25_CFG_PRECHARGE) |
  131. MX25_ADCQ_ITEM(5, MX25_CFG_TOUCH_DETECT));
  132. /*
  133. * We measure X/Y with 'sample_count' number of samples and execute a
  134. * touch detection twice, with 1 sample each
  135. */
  136. priv->expected_samples = priv->sample_count * 2 + 2;
  137. *items = 6;
  138. return 0;
  139. }
  140. static void mx25_tcq_disable_touch_irq(struct mx25_tcq_priv *priv)
  141. {
  142. regmap_update_bits(priv->regs, MX25_ADCQ_CR, MX25_ADCQ_CR_PDMSK,
  143. MX25_ADCQ_CR_PDMSK);
  144. }
  145. static void mx25_tcq_enable_touch_irq(struct mx25_tcq_priv *priv)
  146. {
  147. regmap_update_bits(priv->regs, MX25_ADCQ_CR, MX25_ADCQ_CR_PDMSK, 0);
  148. }
  149. static void mx25_tcq_disable_fifo_irq(struct mx25_tcq_priv *priv)
  150. {
  151. regmap_update_bits(priv->regs, MX25_ADCQ_MR, MX25_ADCQ_MR_FDRY_IRQ,
  152. MX25_ADCQ_MR_FDRY_IRQ);
  153. }
  154. static void mx25_tcq_enable_fifo_irq(struct mx25_tcq_priv *priv)
  155. {
  156. regmap_update_bits(priv->regs, MX25_ADCQ_MR, MX25_ADCQ_MR_FDRY_IRQ, 0);
  157. }
  158. static void mx25_tcq_force_queue_start(struct mx25_tcq_priv *priv)
  159. {
  160. regmap_update_bits(priv->regs, MX25_ADCQ_CR,
  161. MX25_ADCQ_CR_FQS,
  162. MX25_ADCQ_CR_FQS);
  163. }
  164. static void mx25_tcq_force_queue_stop(struct mx25_tcq_priv *priv)
  165. {
  166. regmap_update_bits(priv->regs, MX25_ADCQ_CR,
  167. MX25_ADCQ_CR_FQS, 0);
  168. }
  169. static void mx25_tcq_fifo_reset(struct mx25_tcq_priv *priv)
  170. {
  171. u32 tcqcr;
  172. regmap_read(priv->regs, MX25_ADCQ_CR, &tcqcr);
  173. regmap_update_bits(priv->regs, MX25_ADCQ_CR, MX25_ADCQ_CR_FRST,
  174. MX25_ADCQ_CR_FRST);
  175. regmap_update_bits(priv->regs, MX25_ADCQ_CR, MX25_ADCQ_CR_FRST, 0);
  176. regmap_write(priv->regs, MX25_ADCQ_CR, tcqcr);
  177. }
  178. static void mx25_tcq_re_enable_touch_detection(struct mx25_tcq_priv *priv)
  179. {
  180. /* stop the queue from looping */
  181. mx25_tcq_force_queue_stop(priv);
  182. /* for a clean touch detection, preload the X plane */
  183. regmap_write(priv->core_regs, MX25_TSC_TICR, MX25_PRECHARGE_VALUE);
  184. /* waste some time now to pre-load the X plate to high voltage */
  185. mx25_tcq_fifo_reset(priv);
  186. /* re-enable the detection right now */
  187. regmap_write(priv->core_regs, MX25_TSC_TICR,
  188. MX25_TOUCH_DETECT_VALUE | MX25_ADCQ_CFG_IGS);
  189. regmap_update_bits(priv->regs, MX25_ADCQ_SR, MX25_ADCQ_SR_PD,
  190. MX25_ADCQ_SR_PD);
  191. /* enable the pen down event to be a source for the interrupt */
  192. regmap_update_bits(priv->regs, MX25_ADCQ_MR, MX25_ADCQ_MR_PD_IRQ, 0);
  193. /* lets fire the next IRQ if someone touches the touchscreen */
  194. mx25_tcq_enable_touch_irq(priv);
  195. }
  196. static void mx25_tcq_create_event_for_4wire(struct mx25_tcq_priv *priv,
  197. u32 *sample_buf,
  198. unsigned int samples)
  199. {
  200. unsigned int x_pos = 0;
  201. unsigned int y_pos = 0;
  202. unsigned int touch_pre = 0;
  203. unsigned int touch_post = 0;
  204. unsigned int i;
  205. for (i = 0; i < samples; i++) {
  206. unsigned int index = MX25_ADCQ_FIFO_ID(sample_buf[i]);
  207. unsigned int val = MX25_ADCQ_FIFO_DATA(sample_buf[i]);
  208. switch (index) {
  209. case 1:
  210. touch_pre = val;
  211. break;
  212. case 2:
  213. x_pos = val;
  214. break;
  215. case 3:
  216. y_pos = val;
  217. break;
  218. case 5:
  219. touch_post = val;
  220. break;
  221. default:
  222. dev_dbg(priv->dev, "Dropped samples because of invalid index %d\n",
  223. index);
  224. return;
  225. }
  226. }
  227. if (samples != 0) {
  228. /*
  229. * only if both touch measures are below a threshold,
  230. * the position is valid
  231. */
  232. if (touch_pre < priv->pen_threshold &&
  233. touch_post < priv->pen_threshold) {
  234. /* valid samples, generate a report */
  235. x_pos /= priv->sample_count;
  236. y_pos /= priv->sample_count;
  237. input_report_abs(priv->idev, ABS_X, x_pos);
  238. input_report_abs(priv->idev, ABS_Y, y_pos);
  239. input_report_key(priv->idev, BTN_TOUCH, 1);
  240. input_sync(priv->idev);
  241. /* get next sample */
  242. mx25_tcq_enable_fifo_irq(priv);
  243. } else if (touch_pre >= priv->pen_threshold &&
  244. touch_post >= priv->pen_threshold) {
  245. /*
  246. * if both samples are invalid,
  247. * generate a release report
  248. */
  249. input_report_key(priv->idev, BTN_TOUCH, 0);
  250. input_sync(priv->idev);
  251. mx25_tcq_re_enable_touch_detection(priv);
  252. } else {
  253. /*
  254. * if only one of both touch measurements are
  255. * below the threshold, still some bouncing
  256. * happens. Take additional samples in this
  257. * case to be sure
  258. */
  259. mx25_tcq_enable_fifo_irq(priv);
  260. }
  261. }
  262. }
  263. static irqreturn_t mx25_tcq_irq_thread(int irq, void *dev_id)
  264. {
  265. struct mx25_tcq_priv *priv = dev_id;
  266. u32 sample_buf[TSC_MAX_SAMPLES];
  267. unsigned int samples;
  268. u32 stats;
  269. unsigned int i;
  270. /*
  271. * Check how many samples are available. We always have to read exactly
  272. * sample_count samples from the fifo, or a multiple of sample_count.
  273. * Otherwise we mixup samples into different touch events.
  274. */
  275. regmap_read(priv->regs, MX25_ADCQ_SR, &stats);
  276. samples = MX25_ADCQ_SR_FDN(stats);
  277. samples -= samples % priv->sample_count;
  278. if (!samples)
  279. return IRQ_HANDLED;
  280. for (i = 0; i != samples; ++i)
  281. regmap_read(priv->regs, MX25_ADCQ_FIFO, &sample_buf[i]);
  282. mx25_tcq_create_event_for_4wire(priv, sample_buf, samples);
  283. return IRQ_HANDLED;
  284. }
  285. static irqreturn_t mx25_tcq_irq(int irq, void *dev_id)
  286. {
  287. struct mx25_tcq_priv *priv = dev_id;
  288. u32 stat;
  289. int ret = IRQ_HANDLED;
  290. regmap_read(priv->regs, MX25_ADCQ_SR, &stat);
  291. if (stat & (MX25_ADCQ_SR_FRR | MX25_ADCQ_SR_FUR | MX25_ADCQ_SR_FOR))
  292. mx25_tcq_re_enable_touch_detection(priv);
  293. if (stat & MX25_ADCQ_SR_PD) {
  294. mx25_tcq_disable_touch_irq(priv);
  295. mx25_tcq_force_queue_start(priv);
  296. mx25_tcq_enable_fifo_irq(priv);
  297. }
  298. if (stat & MX25_ADCQ_SR_FDRY) {
  299. mx25_tcq_disable_fifo_irq(priv);
  300. ret = IRQ_WAKE_THREAD;
  301. }
  302. regmap_update_bits(priv->regs, MX25_ADCQ_SR, MX25_ADCQ_SR_FRR |
  303. MX25_ADCQ_SR_FUR | MX25_ADCQ_SR_FOR |
  304. MX25_ADCQ_SR_PD,
  305. MX25_ADCQ_SR_FRR | MX25_ADCQ_SR_FUR |
  306. MX25_ADCQ_SR_FOR | MX25_ADCQ_SR_PD);
  307. return ret;
  308. }
  309. /* configure the state machine for a 4-wire touchscreen */
  310. static int mx25_tcq_init(struct mx25_tcq_priv *priv)
  311. {
  312. u32 tgcr;
  313. unsigned int ipg_div;
  314. unsigned int adc_period;
  315. unsigned int debounce_cnt;
  316. unsigned int settling_cnt;
  317. int itemct;
  318. int error;
  319. regmap_read(priv->core_regs, MX25_TSC_TGCR, &tgcr);
  320. ipg_div = max_t(unsigned int, 4, MX25_TGCR_GET_ADCCLK(tgcr));
  321. adc_period = USEC_PER_SEC * ipg_div * 2 + 2;
  322. adc_period /= clk_get_rate(priv->clk) / 1000 + 1;
  323. debounce_cnt = DIV_ROUND_UP(priv->pen_debounce, adc_period * 8) - 1;
  324. settling_cnt = DIV_ROUND_UP(priv->settling_time, adc_period * 8) - 1;
  325. /* Reset */
  326. regmap_write(priv->regs, MX25_ADCQ_CR,
  327. MX25_ADCQ_CR_QRST | MX25_ADCQ_CR_FRST);
  328. regmap_update_bits(priv->regs, MX25_ADCQ_CR,
  329. MX25_ADCQ_CR_QRST | MX25_ADCQ_CR_FRST, 0);
  330. /* up to 128 * 8 ADC clocks are possible */
  331. if (debounce_cnt > 127)
  332. debounce_cnt = 127;
  333. /* up to 255 * 8 ADC clocks are possible */
  334. if (settling_cnt > 255)
  335. settling_cnt = 255;
  336. error = imx25_setup_queue_4wire(priv, settling_cnt, &itemct);
  337. if (error)
  338. return error;
  339. regmap_update_bits(priv->regs, MX25_ADCQ_CR,
  340. MX25_ADCQ_CR_LITEMID_MASK | MX25_ADCQ_CR_WMRK_MASK,
  341. MX25_ADCQ_CR_LITEMID(itemct - 1) |
  342. MX25_ADCQ_CR_WMRK(priv->expected_samples - 1));
  343. /* setup debounce count */
  344. regmap_update_bits(priv->core_regs, MX25_TSC_TGCR,
  345. MX25_TGCR_PDBTIME_MASK,
  346. MX25_TGCR_PDBTIME(debounce_cnt));
  347. /* enable debounce */
  348. regmap_update_bits(priv->core_regs, MX25_TSC_TGCR, MX25_TGCR_PDBEN,
  349. MX25_TGCR_PDBEN);
  350. regmap_update_bits(priv->core_regs, MX25_TSC_TGCR, MX25_TGCR_PDEN,
  351. MX25_TGCR_PDEN);
  352. /* enable the engine on demand */
  353. regmap_update_bits(priv->regs, MX25_ADCQ_CR, MX25_ADCQ_CR_QSM_MASK,
  354. MX25_ADCQ_CR_QSM_FQS);
  355. /* Enable repeat and repeat wait */
  356. regmap_update_bits(priv->regs, MX25_ADCQ_CR,
  357. MX25_ADCQ_CR_RPT | MX25_ADCQ_CR_RWAIT_MASK,
  358. MX25_ADCQ_CR_RPT |
  359. MX25_ADCQ_CR_RWAIT(MX25_TSC_REPEAT_WAIT));
  360. return 0;
  361. }
  362. static int mx25_tcq_parse_dt(struct platform_device *pdev,
  363. struct mx25_tcq_priv *priv)
  364. {
  365. struct device_node *np = pdev->dev.of_node;
  366. u32 wires;
  367. int error;
  368. /* Setup defaults */
  369. priv->pen_threshold = 500;
  370. priv->sample_count = 3;
  371. priv->pen_debounce = 1000000;
  372. priv->settling_time = 250000;
  373. error = of_property_read_u32(np, "fsl,wires", &wires);
  374. if (error) {
  375. dev_err(&pdev->dev, "Failed to find fsl,wires properties\n");
  376. return error;
  377. }
  378. if (wires == 4) {
  379. priv->mode = MX25_TS_4WIRE;
  380. } else {
  381. dev_err(&pdev->dev, "%u-wire mode not supported\n", wires);
  382. return -EINVAL;
  383. }
  384. /* These are optional, we don't care about the return values */
  385. of_property_read_u32(np, "fsl,pen-threshold", &priv->pen_threshold);
  386. of_property_read_u32(np, "fsl,settling-time-ns", &priv->settling_time);
  387. of_property_read_u32(np, "fsl,pen-debounce-ns", &priv->pen_debounce);
  388. return 0;
  389. }
  390. static int mx25_tcq_open(struct input_dev *idev)
  391. {
  392. struct device *dev = &idev->dev;
  393. struct mx25_tcq_priv *priv = dev_get_drvdata(dev);
  394. int error;
  395. error = clk_prepare_enable(priv->clk);
  396. if (error) {
  397. dev_err(dev, "Failed to enable ipg clock\n");
  398. return error;
  399. }
  400. error = mx25_tcq_init(priv);
  401. if (error) {
  402. dev_err(dev, "Failed to init tcq\n");
  403. clk_disable_unprepare(priv->clk);
  404. return error;
  405. }
  406. mx25_tcq_re_enable_touch_detection(priv);
  407. return 0;
  408. }
  409. static void mx25_tcq_close(struct input_dev *idev)
  410. {
  411. struct mx25_tcq_priv *priv = input_get_drvdata(idev);
  412. mx25_tcq_force_queue_stop(priv);
  413. mx25_tcq_disable_touch_irq(priv);
  414. mx25_tcq_disable_fifo_irq(priv);
  415. clk_disable_unprepare(priv->clk);
  416. }
  417. static int mx25_tcq_probe(struct platform_device *pdev)
  418. {
  419. struct device *dev = &pdev->dev;
  420. struct input_dev *idev;
  421. struct mx25_tcq_priv *priv;
  422. struct mx25_tsadc *tsadc = dev_get_drvdata(dev->parent);
  423. void __iomem *mem;
  424. int error;
  425. priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  426. if (!priv)
  427. return -ENOMEM;
  428. priv->dev = dev;
  429. mem = devm_platform_ioremap_resource(pdev, 0);
  430. if (IS_ERR(mem))
  431. return PTR_ERR(mem);
  432. error = mx25_tcq_parse_dt(pdev, priv);
  433. if (error)
  434. return error;
  435. priv->regs = devm_regmap_init_mmio(dev, mem, &mx25_tcq_regconfig);
  436. if (IS_ERR(priv->regs)) {
  437. dev_err(dev, "Failed to initialize regmap\n");
  438. return PTR_ERR(priv->regs);
  439. }
  440. priv->irq = platform_get_irq(pdev, 0);
  441. if (priv->irq <= 0)
  442. return priv->irq;
  443. idev = devm_input_allocate_device(dev);
  444. if (!idev) {
  445. dev_err(dev, "Failed to allocate input device\n");
  446. return -ENOMEM;
  447. }
  448. idev->name = mx25_tcq_name;
  449. input_set_capability(idev, EV_KEY, BTN_TOUCH);
  450. input_set_abs_params(idev, ABS_X, 0, 0xfff, 0, 0);
  451. input_set_abs_params(idev, ABS_Y, 0, 0xfff, 0, 0);
  452. idev->id.bustype = BUS_HOST;
  453. idev->open = mx25_tcq_open;
  454. idev->close = mx25_tcq_close;
  455. priv->idev = idev;
  456. input_set_drvdata(idev, priv);
  457. priv->core_regs = tsadc->regs;
  458. if (!priv->core_regs)
  459. return -EINVAL;
  460. priv->clk = tsadc->clk;
  461. if (!priv->clk)
  462. return -EINVAL;
  463. platform_set_drvdata(pdev, priv);
  464. error = devm_request_threaded_irq(dev, priv->irq, mx25_tcq_irq,
  465. mx25_tcq_irq_thread, 0, pdev->name,
  466. priv);
  467. if (error) {
  468. dev_err(dev, "Failed requesting IRQ\n");
  469. return error;
  470. }
  471. error = input_register_device(idev);
  472. if (error) {
  473. dev_err(dev, "Failed to register input device\n");
  474. return error;
  475. }
  476. return 0;
  477. }
  478. static struct platform_driver mx25_tcq_driver = {
  479. .driver = {
  480. .name = "mx25-tcq",
  481. .of_match_table = mx25_tcq_ids,
  482. },
  483. .probe = mx25_tcq_probe,
  484. };
  485. module_platform_driver(mx25_tcq_driver);
  486. MODULE_DESCRIPTION("TS input driver for Freescale mx25");
  487. MODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>");
  488. MODULE_LICENSE("GPL v2");