ad7879.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * AD7879/AD7889 based touchscreen and GPIO driver
  4. *
  5. * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc.
  6. *
  7. * History:
  8. * Copyright (c) 2005 David Brownell
  9. * Copyright (c) 2006 Nokia Corporation
  10. * Various changes: Imre Deak <imre.deak@nokia.com>
  11. *
  12. * Using code from:
  13. * - corgi_ts.c
  14. * Copyright (C) 2004-2005 Richard Purdie
  15. * - omap_ts.[hc], ads7846.h, ts_osk.c
  16. * Copyright (C) 2002 MontaVista Software
  17. * Copyright (C) 2004 Texas Instruments
  18. * Copyright (C) 2005 Dirk Behme
  19. * - ad7877.c
  20. * Copyright (C) 2006-2008 Analog Devices Inc.
  21. */
  22. #include <linux/device.h>
  23. #include <linux/delay.h>
  24. #include <linux/export.h>
  25. #include <linux/input.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/irq.h>
  28. #include <linux/property.h>
  29. #include <linux/regmap.h>
  30. #include <linux/slab.h>
  31. #include <linux/gpio/driver.h>
  32. #include <linux/input/touchscreen.h>
  33. #include <linux/module.h>
  34. #include "ad7879.h"
  35. #define AD7879_REG_ZEROS 0
  36. #define AD7879_REG_CTRL1 1
  37. #define AD7879_REG_CTRL2 2
  38. #define AD7879_REG_CTRL3 3
  39. #define AD7879_REG_AUX1HIGH 4
  40. #define AD7879_REG_AUX1LOW 5
  41. #define AD7879_REG_TEMP1HIGH 6
  42. #define AD7879_REG_TEMP1LOW 7
  43. #define AD7879_REG_XPLUS 8
  44. #define AD7879_REG_YPLUS 9
  45. #define AD7879_REG_Z1 10
  46. #define AD7879_REG_Z2 11
  47. #define AD7879_REG_AUXVBAT 12
  48. #define AD7879_REG_TEMP 13
  49. #define AD7879_REG_REVID 14
  50. /* Control REG 1 */
  51. #define AD7879_TMR(x) ((x & 0xFF) << 0)
  52. #define AD7879_ACQ(x) ((x & 0x3) << 8)
  53. #define AD7879_MODE_NOC (0 << 10) /* Do not convert */
  54. #define AD7879_MODE_SCC (1 << 10) /* Single channel conversion */
  55. #define AD7879_MODE_SEQ0 (2 << 10) /* Sequence 0 in Slave Mode */
  56. #define AD7879_MODE_SEQ1 (3 << 10) /* Sequence 1 in Master Mode */
  57. #define AD7879_MODE_INT (1 << 15) /* PENIRQ disabled INT enabled */
  58. /* Control REG 2 */
  59. #define AD7879_FCD(x) ((x & 0x3) << 0)
  60. #define AD7879_RESET (1 << 4)
  61. #define AD7879_MFS(x) ((x & 0x3) << 5)
  62. #define AD7879_AVG(x) ((x & 0x3) << 7)
  63. #define AD7879_SER (1 << 9) /* non-differential */
  64. #define AD7879_DFR (0 << 9) /* differential */
  65. #define AD7879_GPIOPOL (1 << 10)
  66. #define AD7879_GPIODIR (1 << 11)
  67. #define AD7879_GPIO_DATA (1 << 12)
  68. #define AD7879_GPIO_EN (1 << 13)
  69. #define AD7879_PM(x) ((x & 0x3) << 14)
  70. #define AD7879_PM_SHUTDOWN (0)
  71. #define AD7879_PM_DYN (1)
  72. #define AD7879_PM_FULLON (2)
  73. /* Control REG 3 */
  74. #define AD7879_TEMPMASK_BIT (1<<15)
  75. #define AD7879_AUXVBATMASK_BIT (1<<14)
  76. #define AD7879_INTMODE_BIT (1<<13)
  77. #define AD7879_GPIOALERTMASK_BIT (1<<12)
  78. #define AD7879_AUXLOW_BIT (1<<11)
  79. #define AD7879_AUXHIGH_BIT (1<<10)
  80. #define AD7879_TEMPLOW_BIT (1<<9)
  81. #define AD7879_TEMPHIGH_BIT (1<<8)
  82. #define AD7879_YPLUS_BIT (1<<7)
  83. #define AD7879_XPLUS_BIT (1<<6)
  84. #define AD7879_Z1_BIT (1<<5)
  85. #define AD7879_Z2_BIT (1<<4)
  86. #define AD7879_AUX_BIT (1<<3)
  87. #define AD7879_VBAT_BIT (1<<2)
  88. #define AD7879_TEMP_BIT (1<<1)
  89. enum {
  90. AD7879_SEQ_YPOS = 0,
  91. AD7879_SEQ_XPOS = 1,
  92. AD7879_SEQ_Z1 = 2,
  93. AD7879_SEQ_Z2 = 3,
  94. AD7879_NR_SENSE = 4,
  95. };
  96. #define MAX_12BIT ((1<<12)-1)
  97. #define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50)
  98. struct ad7879 {
  99. struct regmap *regmap;
  100. struct device *dev;
  101. struct input_dev *input;
  102. struct timer_list timer;
  103. #ifdef CONFIG_GPIOLIB
  104. struct gpio_chip gc;
  105. struct mutex mutex;
  106. #endif
  107. unsigned int irq;
  108. bool disabled; /* P: input->mutex */
  109. bool suspended; /* P: input->mutex */
  110. bool swap_xy;
  111. u16 conversion_data[AD7879_NR_SENSE];
  112. char phys[32];
  113. u8 first_conversion_delay;
  114. u8 acquisition_time;
  115. u8 averaging;
  116. u8 pen_down_acc_interval;
  117. u8 median;
  118. u16 x_plate_ohms;
  119. u16 cmd_crtl1;
  120. u16 cmd_crtl2;
  121. u16 cmd_crtl3;
  122. int x;
  123. int y;
  124. int Rt;
  125. };
  126. static int ad7879_read(struct ad7879 *ts, u8 reg)
  127. {
  128. unsigned int val;
  129. int error;
  130. error = regmap_read(ts->regmap, reg, &val);
  131. if (error) {
  132. dev_err(ts->dev, "failed to read register %#02x: %d\n",
  133. reg, error);
  134. return error;
  135. }
  136. return val;
  137. }
  138. static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val)
  139. {
  140. int error;
  141. error = regmap_write(ts->regmap, reg, val);
  142. if (error) {
  143. dev_err(ts->dev,
  144. "failed to write %#04x to register %#02x: %d\n",
  145. val, reg, error);
  146. return error;
  147. }
  148. return 0;
  149. }
  150. static int ad7879_report(struct ad7879 *ts)
  151. {
  152. struct input_dev *input_dev = ts->input;
  153. unsigned Rt;
  154. u16 x, y, z1, z2;
  155. x = ts->conversion_data[AD7879_SEQ_XPOS] & MAX_12BIT;
  156. y = ts->conversion_data[AD7879_SEQ_YPOS] & MAX_12BIT;
  157. z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT;
  158. z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT;
  159. if (ts->swap_xy)
  160. swap(x, y);
  161. /*
  162. * The samples processed here are already preprocessed by the AD7879.
  163. * The preprocessing function consists of a median and an averaging
  164. * filter. The combination of these two techniques provides a robust
  165. * solution, discarding the spurious noise in the signal and keeping
  166. * only the data of interest. The size of both filters is
  167. * programmable. (dev.platform_data, see linux/platform_data/ad7879.h)
  168. * Other user-programmable conversion controls include variable
  169. * acquisition time, and first conversion delay. Up to 16 averages can
  170. * be taken per conversion.
  171. */
  172. if (likely(x && z1)) {
  173. /* compute touch pressure resistance using equation #1 */
  174. Rt = (z2 - z1) * x * ts->x_plate_ohms;
  175. Rt /= z1;
  176. Rt = (Rt + 2047) >> 12;
  177. /*
  178. * Sample found inconsistent, pressure is beyond
  179. * the maximum. Don't report it to user space.
  180. */
  181. if (Rt > input_abs_get_max(input_dev, ABS_PRESSURE))
  182. return -EINVAL;
  183. /*
  184. * Note that we delay reporting events by one sample.
  185. * This is done to avoid reporting last sample of the
  186. * touch sequence, which may be incomplete if finger
  187. * leaves the surface before last reading is taken.
  188. */
  189. if (timer_pending(&ts->timer)) {
  190. /* Touch continues */
  191. input_report_key(input_dev, BTN_TOUCH, 1);
  192. input_report_abs(input_dev, ABS_X, ts->x);
  193. input_report_abs(input_dev, ABS_Y, ts->y);
  194. input_report_abs(input_dev, ABS_PRESSURE, ts->Rt);
  195. input_sync(input_dev);
  196. }
  197. ts->x = x;
  198. ts->y = y;
  199. ts->Rt = Rt;
  200. return 0;
  201. }
  202. return -EINVAL;
  203. }
  204. static void ad7879_ts_event_release(struct ad7879 *ts)
  205. {
  206. struct input_dev *input_dev = ts->input;
  207. input_report_abs(input_dev, ABS_PRESSURE, 0);
  208. input_report_key(input_dev, BTN_TOUCH, 0);
  209. input_sync(input_dev);
  210. }
  211. static void ad7879_timer(struct timer_list *t)
  212. {
  213. struct ad7879 *ts = timer_container_of(ts, t, timer);
  214. ad7879_ts_event_release(ts);
  215. }
  216. static irqreturn_t ad7879_irq(int irq, void *handle)
  217. {
  218. struct ad7879 *ts = handle;
  219. int error;
  220. error = regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
  221. ts->conversion_data, AD7879_NR_SENSE);
  222. if (error)
  223. dev_err_ratelimited(ts->dev, "failed to read %#02x: %d\n",
  224. AD7879_REG_XPLUS, error);
  225. else if (!ad7879_report(ts))
  226. mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
  227. return IRQ_HANDLED;
  228. }
  229. static void __ad7879_enable(struct ad7879 *ts)
  230. {
  231. ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2);
  232. ad7879_write(ts, AD7879_REG_CTRL3, ts->cmd_crtl3);
  233. ad7879_write(ts, AD7879_REG_CTRL1, ts->cmd_crtl1);
  234. enable_irq(ts->irq);
  235. }
  236. static void __ad7879_disable(struct ad7879 *ts)
  237. {
  238. u16 reg = (ts->cmd_crtl2 & ~AD7879_PM(-1)) |
  239. AD7879_PM(AD7879_PM_SHUTDOWN);
  240. disable_irq(ts->irq);
  241. if (timer_delete_sync(&ts->timer))
  242. ad7879_ts_event_release(ts);
  243. ad7879_write(ts, AD7879_REG_CTRL2, reg);
  244. }
  245. static int ad7879_open(struct input_dev *input)
  246. {
  247. struct ad7879 *ts = input_get_drvdata(input);
  248. /* protected by input->mutex */
  249. if (!ts->disabled && !ts->suspended)
  250. __ad7879_enable(ts);
  251. return 0;
  252. }
  253. static void ad7879_close(struct input_dev *input)
  254. {
  255. struct ad7879 *ts = input_get_drvdata(input);
  256. /* protected by input->mutex */
  257. if (!ts->disabled && !ts->suspended)
  258. __ad7879_disable(ts);
  259. }
  260. static int __maybe_unused ad7879_suspend(struct device *dev)
  261. {
  262. struct ad7879 *ts = dev_get_drvdata(dev);
  263. mutex_lock(&ts->input->mutex);
  264. if (!ts->suspended && !ts->disabled && input_device_enabled(ts->input))
  265. __ad7879_disable(ts);
  266. ts->suspended = true;
  267. mutex_unlock(&ts->input->mutex);
  268. return 0;
  269. }
  270. static int __maybe_unused ad7879_resume(struct device *dev)
  271. {
  272. struct ad7879 *ts = dev_get_drvdata(dev);
  273. mutex_lock(&ts->input->mutex);
  274. if (ts->suspended && !ts->disabled && input_device_enabled(ts->input))
  275. __ad7879_enable(ts);
  276. ts->suspended = false;
  277. mutex_unlock(&ts->input->mutex);
  278. return 0;
  279. }
  280. SIMPLE_DEV_PM_OPS(ad7879_pm_ops, ad7879_suspend, ad7879_resume);
  281. EXPORT_SYMBOL(ad7879_pm_ops);
  282. static void ad7879_toggle(struct ad7879 *ts, bool disable)
  283. {
  284. mutex_lock(&ts->input->mutex);
  285. if (!ts->suspended && input_device_enabled(ts->input)) {
  286. if (disable) {
  287. if (ts->disabled)
  288. __ad7879_enable(ts);
  289. } else {
  290. if (!ts->disabled)
  291. __ad7879_disable(ts);
  292. }
  293. }
  294. ts->disabled = disable;
  295. mutex_unlock(&ts->input->mutex);
  296. }
  297. static ssize_t ad7879_disable_show(struct device *dev,
  298. struct device_attribute *attr, char *buf)
  299. {
  300. struct ad7879 *ts = dev_get_drvdata(dev);
  301. return sprintf(buf, "%u\n", ts->disabled);
  302. }
  303. static ssize_t ad7879_disable_store(struct device *dev,
  304. struct device_attribute *attr,
  305. const char *buf, size_t count)
  306. {
  307. struct ad7879 *ts = dev_get_drvdata(dev);
  308. unsigned int val;
  309. int error;
  310. error = kstrtouint(buf, 10, &val);
  311. if (error)
  312. return error;
  313. ad7879_toggle(ts, val);
  314. return count;
  315. }
  316. static DEVICE_ATTR(disable, 0664, ad7879_disable_show, ad7879_disable_store);
  317. static struct attribute *ad7879_attributes[] = {
  318. &dev_attr_disable.attr,
  319. NULL
  320. };
  321. static const struct attribute_group ad7879_attr_group = {
  322. .attrs = ad7879_attributes,
  323. };
  324. const struct attribute_group *ad7879_groups[] = {
  325. &ad7879_attr_group,
  326. NULL
  327. };
  328. EXPORT_SYMBOL_GPL(ad7879_groups);
  329. #ifdef CONFIG_GPIOLIB
  330. static int ad7879_gpio_direction_input(struct gpio_chip *chip,
  331. unsigned gpio)
  332. {
  333. struct ad7879 *ts = gpiochip_get_data(chip);
  334. int err;
  335. mutex_lock(&ts->mutex);
  336. ts->cmd_crtl2 |= AD7879_GPIO_EN | AD7879_GPIODIR | AD7879_GPIOPOL;
  337. err = ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2);
  338. mutex_unlock(&ts->mutex);
  339. return err;
  340. }
  341. static int ad7879_gpio_direction_output(struct gpio_chip *chip,
  342. unsigned gpio, int level)
  343. {
  344. struct ad7879 *ts = gpiochip_get_data(chip);
  345. int err;
  346. mutex_lock(&ts->mutex);
  347. ts->cmd_crtl2 &= ~AD7879_GPIODIR;
  348. ts->cmd_crtl2 |= AD7879_GPIO_EN | AD7879_GPIOPOL;
  349. if (level)
  350. ts->cmd_crtl2 |= AD7879_GPIO_DATA;
  351. else
  352. ts->cmd_crtl2 &= ~AD7879_GPIO_DATA;
  353. err = ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2);
  354. mutex_unlock(&ts->mutex);
  355. return err;
  356. }
  357. static int ad7879_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
  358. {
  359. struct ad7879 *ts = gpiochip_get_data(chip);
  360. u16 val;
  361. mutex_lock(&ts->mutex);
  362. val = ad7879_read(ts, AD7879_REG_CTRL2);
  363. mutex_unlock(&ts->mutex);
  364. return !!(val & AD7879_GPIO_DATA);
  365. }
  366. static int ad7879_gpio_set_value(struct gpio_chip *chip, unsigned int gpio,
  367. int value)
  368. {
  369. struct ad7879 *ts = gpiochip_get_data(chip);
  370. int ret;
  371. mutex_lock(&ts->mutex);
  372. if (value)
  373. ts->cmd_crtl2 |= AD7879_GPIO_DATA;
  374. else
  375. ts->cmd_crtl2 &= ~AD7879_GPIO_DATA;
  376. ret = ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2);
  377. mutex_unlock(&ts->mutex);
  378. return ret;
  379. }
  380. static int ad7879_gpio_add(struct ad7879 *ts)
  381. {
  382. int ret = 0;
  383. mutex_init(&ts->mutex);
  384. /* Do not create a chip unless flagged for it */
  385. if (!device_property_read_bool(ts->dev, "gpio-controller"))
  386. return 0;
  387. ts->gc.direction_input = ad7879_gpio_direction_input;
  388. ts->gc.direction_output = ad7879_gpio_direction_output;
  389. ts->gc.get = ad7879_gpio_get_value;
  390. ts->gc.set = ad7879_gpio_set_value;
  391. ts->gc.can_sleep = 1;
  392. ts->gc.base = -1;
  393. ts->gc.ngpio = 1;
  394. ts->gc.label = "AD7879-GPIO";
  395. ts->gc.owner = THIS_MODULE;
  396. ts->gc.parent = ts->dev;
  397. ret = devm_gpiochip_add_data(ts->dev, &ts->gc, ts);
  398. if (ret)
  399. dev_err(ts->dev, "failed to register gpio %d\n",
  400. ts->gc.base);
  401. return ret;
  402. }
  403. #else
  404. static int ad7879_gpio_add(struct ad7879 *ts)
  405. {
  406. return 0;
  407. }
  408. #endif
  409. static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts)
  410. {
  411. int err;
  412. u32 tmp;
  413. err = device_property_read_u32(dev, "adi,resistance-plate-x", &tmp);
  414. if (err) {
  415. dev_err(dev, "failed to get resistance-plate-x property\n");
  416. return err;
  417. }
  418. ts->x_plate_ohms = (u16)tmp;
  419. device_property_read_u8(dev, "adi,first-conversion-delay",
  420. &ts->first_conversion_delay);
  421. device_property_read_u8(dev, "adi,acquisition-time",
  422. &ts->acquisition_time);
  423. device_property_read_u8(dev, "adi,median-filter-size", &ts->median);
  424. device_property_read_u8(dev, "adi,averaging", &ts->averaging);
  425. device_property_read_u8(dev, "adi,conversion-interval",
  426. &ts->pen_down_acc_interval);
  427. ts->swap_xy = device_property_read_bool(dev, "touchscreen-swapped-x-y");
  428. return 0;
  429. }
  430. int ad7879_probe(struct device *dev, struct regmap *regmap,
  431. int irq, u16 bustype, u8 devid)
  432. {
  433. struct ad7879 *ts;
  434. struct input_dev *input_dev;
  435. int err;
  436. u16 revid;
  437. if (irq <= 0) {
  438. dev_err(dev, "No IRQ specified\n");
  439. return -EINVAL;
  440. }
  441. ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
  442. if (!ts)
  443. return -ENOMEM;
  444. err = ad7879_parse_dt(dev, ts);
  445. if (err)
  446. return err;
  447. input_dev = devm_input_allocate_device(dev);
  448. if (!input_dev) {
  449. dev_err(dev, "Failed to allocate input device\n");
  450. return -ENOMEM;
  451. }
  452. ts->dev = dev;
  453. ts->input = input_dev;
  454. ts->irq = irq;
  455. ts->regmap = regmap;
  456. timer_setup(&ts->timer, ad7879_timer, 0);
  457. snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
  458. input_dev->name = "AD7879 Touchscreen";
  459. input_dev->phys = ts->phys;
  460. input_dev->dev.parent = dev;
  461. input_dev->id.bustype = bustype;
  462. input_dev->open = ad7879_open;
  463. input_dev->close = ad7879_close;
  464. input_set_drvdata(input_dev, ts);
  465. input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
  466. input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
  467. input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
  468. input_set_capability(input_dev, EV_ABS, ABS_PRESSURE);
  469. touchscreen_parse_properties(input_dev, false, NULL);
  470. if (!input_abs_get_max(input_dev, ABS_PRESSURE)) {
  471. dev_err(dev, "Touchscreen pressure is not specified\n");
  472. return -EINVAL;
  473. }
  474. err = ad7879_write(ts, AD7879_REG_CTRL2, AD7879_RESET);
  475. if (err < 0) {
  476. dev_err(dev, "Failed to write %s\n", input_dev->name);
  477. return err;
  478. }
  479. revid = ad7879_read(ts, AD7879_REG_REVID);
  480. input_dev->id.product = (revid & 0xff);
  481. input_dev->id.version = revid >> 8;
  482. if (input_dev->id.product != devid) {
  483. dev_err(dev, "Failed to probe %s (%x vs %x)\n",
  484. input_dev->name, devid, revid);
  485. return -ENODEV;
  486. }
  487. ts->cmd_crtl3 = AD7879_YPLUS_BIT |
  488. AD7879_XPLUS_BIT |
  489. AD7879_Z2_BIT |
  490. AD7879_Z1_BIT |
  491. AD7879_TEMPMASK_BIT |
  492. AD7879_AUXVBATMASK_BIT |
  493. AD7879_GPIOALERTMASK_BIT;
  494. ts->cmd_crtl2 = AD7879_PM(AD7879_PM_DYN) | AD7879_DFR |
  495. AD7879_AVG(ts->averaging) |
  496. AD7879_MFS(ts->median) |
  497. AD7879_FCD(ts->first_conversion_delay);
  498. ts->cmd_crtl1 = AD7879_MODE_INT | AD7879_MODE_SEQ1 |
  499. AD7879_ACQ(ts->acquisition_time) |
  500. AD7879_TMR(ts->pen_down_acc_interval);
  501. err = devm_request_threaded_irq(dev, ts->irq, NULL, ad7879_irq,
  502. IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
  503. dev_name(dev), ts);
  504. if (err) {
  505. dev_err(dev, "Failed to request IRQ: %d\n", err);
  506. return err;
  507. }
  508. __ad7879_disable(ts);
  509. err = ad7879_gpio_add(ts);
  510. if (err)
  511. return err;
  512. err = input_register_device(input_dev);
  513. if (err)
  514. return err;
  515. dev_set_drvdata(dev, ts);
  516. return 0;
  517. }
  518. EXPORT_SYMBOL(ad7879_probe);
  519. MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
  520. MODULE_DESCRIPTION("AD7879(-1) touchscreen Driver");
  521. MODULE_LICENSE("GPL");