fsl-imx25-tcq.c 15 KB

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