auo-pixcir-ts.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Driver for AUO in-cell touchscreens
  4. *
  5. * Copyright (c) 2011 Heiko Stuebner <[email protected]>
  6. *
  7. * loosely based on auo_touch.c from Dell Streak vendor-kernel
  8. *
  9. * Copyright (c) 2008 QUALCOMM Incorporated.
  10. * Copyright (c) 2008 QUALCOMM USA, INC.
  11. */
  12. #include <linux/err.h>
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/slab.h>
  17. #include <linux/input.h>
  18. #include <linux/jiffies.h>
  19. #include <linux/i2c.h>
  20. #include <linux/mutex.h>
  21. #include <linux/delay.h>
  22. #include <linux/gpio/consumer.h>
  23. #include <linux/of.h>
  24. #include <linux/property.h>
  25. /*
  26. * Coordinate calculation:
  27. * X1 = X1_LSB + X1_MSB*256
  28. * Y1 = Y1_LSB + Y1_MSB*256
  29. * X2 = X2_LSB + X2_MSB*256
  30. * Y2 = Y2_LSB + Y2_MSB*256
  31. */
  32. #define AUO_PIXCIR_REG_X1_LSB 0x00
  33. #define AUO_PIXCIR_REG_X1_MSB 0x01
  34. #define AUO_PIXCIR_REG_Y1_LSB 0x02
  35. #define AUO_PIXCIR_REG_Y1_MSB 0x03
  36. #define AUO_PIXCIR_REG_X2_LSB 0x04
  37. #define AUO_PIXCIR_REG_X2_MSB 0x05
  38. #define AUO_PIXCIR_REG_Y2_LSB 0x06
  39. #define AUO_PIXCIR_REG_Y2_MSB 0x07
  40. #define AUO_PIXCIR_REG_STRENGTH 0x0d
  41. #define AUO_PIXCIR_REG_STRENGTH_X1_LSB 0x0e
  42. #define AUO_PIXCIR_REG_STRENGTH_X1_MSB 0x0f
  43. #define AUO_PIXCIR_REG_RAW_DATA_X 0x2b
  44. #define AUO_PIXCIR_REG_RAW_DATA_Y 0x4f
  45. #define AUO_PIXCIR_REG_X_SENSITIVITY 0x6f
  46. #define AUO_PIXCIR_REG_Y_SENSITIVITY 0x70
  47. #define AUO_PIXCIR_REG_INT_SETTING 0x71
  48. #define AUO_PIXCIR_REG_INT_WIDTH 0x72
  49. #define AUO_PIXCIR_REG_POWER_MODE 0x73
  50. #define AUO_PIXCIR_REG_VERSION 0x77
  51. #define AUO_PIXCIR_REG_CALIBRATE 0x78
  52. #define AUO_PIXCIR_REG_TOUCHAREA_X1 0x1e
  53. #define AUO_PIXCIR_REG_TOUCHAREA_Y1 0x1f
  54. #define AUO_PIXCIR_REG_TOUCHAREA_X2 0x20
  55. #define AUO_PIXCIR_REG_TOUCHAREA_Y2 0x21
  56. #define AUO_PIXCIR_REG_EEPROM_CALIB_X 0x42
  57. #define AUO_PIXCIR_REG_EEPROM_CALIB_Y 0xad
  58. #define AUO_PIXCIR_INT_TPNUM_MASK 0xe0
  59. #define AUO_PIXCIR_INT_TPNUM_SHIFT 5
  60. #define AUO_PIXCIR_INT_RELEASE (1 << 4)
  61. #define AUO_PIXCIR_INT_ENABLE (1 << 3)
  62. #define AUO_PIXCIR_INT_POL_HIGH (1 << 2)
  63. /*
  64. * Interrupt modes:
  65. * periodical: interrupt is asserted periodicaly
  66. * compare coordinates: interrupt is asserted when coordinates change
  67. * indicate touch: interrupt is asserted during touch
  68. */
  69. #define AUO_PIXCIR_INT_PERIODICAL 0x00
  70. #define AUO_PIXCIR_INT_COMP_COORD 0x01
  71. #define AUO_PIXCIR_INT_TOUCH_IND 0x02
  72. #define AUO_PIXCIR_INT_MODE_MASK 0x03
  73. /*
  74. * Power modes:
  75. * active: scan speed 60Hz
  76. * sleep: scan speed 10Hz can be auto-activated, wakeup on 1st touch
  77. * deep sleep: scan speed 1Hz can only be entered or left manually.
  78. */
  79. #define AUO_PIXCIR_POWER_ACTIVE 0x00
  80. #define AUO_PIXCIR_POWER_SLEEP 0x01
  81. #define AUO_PIXCIR_POWER_DEEP_SLEEP 0x02
  82. #define AUO_PIXCIR_POWER_MASK 0x03
  83. #define AUO_PIXCIR_POWER_ALLOW_SLEEP (1 << 2)
  84. #define AUO_PIXCIR_POWER_IDLE_TIME(ms) ((ms & 0xf) << 4)
  85. #define AUO_PIXCIR_CALIBRATE 0x03
  86. #define AUO_PIXCIR_EEPROM_CALIB_X_LEN 62
  87. #define AUO_PIXCIR_EEPROM_CALIB_Y_LEN 36
  88. #define AUO_PIXCIR_RAW_DATA_X_LEN 18
  89. #define AUO_PIXCIR_RAW_DATA_Y_LEN 11
  90. #define AUO_PIXCIR_STRENGTH_ENABLE (1 << 0)
  91. /* Touchscreen absolute values */
  92. #define AUO_PIXCIR_REPORT_POINTS 2
  93. #define AUO_PIXCIR_MAX_AREA 0xff
  94. #define AUO_PIXCIR_PENUP_TIMEOUT_MS 10
  95. struct auo_pixcir_ts {
  96. struct i2c_client *client;
  97. struct input_dev *input;
  98. struct gpio_desc *gpio_int;
  99. struct gpio_desc *gpio_rst;
  100. char phys[32];
  101. unsigned int x_max;
  102. unsigned int y_max;
  103. /* special handling for touch_indicate interrupt mode */
  104. bool touch_ind_mode;
  105. wait_queue_head_t wait;
  106. bool stopped;
  107. };
  108. struct auo_point_t {
  109. int coord_x;
  110. int coord_y;
  111. int area_major;
  112. int area_minor;
  113. int orientation;
  114. };
  115. static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts,
  116. struct auo_point_t *point)
  117. {
  118. struct i2c_client *client = ts->client;
  119. uint8_t raw_coord[8];
  120. uint8_t raw_area[4];
  121. int i, ret;
  122. /* touch coordinates */
  123. ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_X1_LSB,
  124. 8, raw_coord);
  125. if (ret < 0) {
  126. dev_err(&client->dev, "failed to read coordinate, %d\n", ret);
  127. return ret;
  128. }
  129. /* touch area */
  130. ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_TOUCHAREA_X1,
  131. 4, raw_area);
  132. if (ret < 0) {
  133. dev_err(&client->dev, "could not read touch area, %d\n", ret);
  134. return ret;
  135. }
  136. for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) {
  137. point[i].coord_x =
  138. raw_coord[4 * i + 1] << 8 | raw_coord[4 * i];
  139. point[i].coord_y =
  140. raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2];
  141. if (point[i].coord_x > ts->x_max ||
  142. point[i].coord_y > ts->y_max) {
  143. dev_warn(&client->dev, "coordinates (%d,%d) invalid\n",
  144. point[i].coord_x, point[i].coord_y);
  145. point[i].coord_x = point[i].coord_y = 0;
  146. }
  147. /* determine touch major, minor and orientation */
  148. point[i].area_major = max(raw_area[2 * i], raw_area[2 * i + 1]);
  149. point[i].area_minor = min(raw_area[2 * i], raw_area[2 * i + 1]);
  150. point[i].orientation = raw_area[2 * i] > raw_area[2 * i + 1];
  151. }
  152. return 0;
  153. }
  154. static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
  155. {
  156. struct auo_pixcir_ts *ts = dev_id;
  157. struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS];
  158. int i;
  159. int ret;
  160. int fingers = 0;
  161. int abs = -1;
  162. while (!ts->stopped) {
  163. /* check for up event in touch touch_ind_mode */
  164. if (ts->touch_ind_mode) {
  165. if (gpiod_get_value_cansleep(ts->gpio_int) == 0) {
  166. input_mt_sync(ts->input);
  167. input_report_key(ts->input, BTN_TOUCH, 0);
  168. input_sync(ts->input);
  169. break;
  170. }
  171. }
  172. ret = auo_pixcir_collect_data(ts, point);
  173. if (ret < 0) {
  174. /* we want to loop only in touch_ind_mode */
  175. if (!ts->touch_ind_mode)
  176. break;
  177. wait_event_timeout(ts->wait, ts->stopped,
  178. msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS));
  179. continue;
  180. }
  181. for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) {
  182. if (point[i].coord_x > 0 || point[i].coord_y > 0) {
  183. input_report_abs(ts->input, ABS_MT_POSITION_X,
  184. point[i].coord_x);
  185. input_report_abs(ts->input, ABS_MT_POSITION_Y,
  186. point[i].coord_y);
  187. input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR,
  188. point[i].area_major);
  189. input_report_abs(ts->input, ABS_MT_TOUCH_MINOR,
  190. point[i].area_minor);
  191. input_report_abs(ts->input, ABS_MT_ORIENTATION,
  192. point[i].orientation);
  193. input_mt_sync(ts->input);
  194. /* use first finger as source for singletouch */
  195. if (fingers == 0)
  196. abs = i;
  197. /* number of touch points could also be queried
  198. * via i2c but would require an additional call
  199. */
  200. fingers++;
  201. }
  202. }
  203. input_report_key(ts->input, BTN_TOUCH, fingers > 0);
  204. if (abs > -1) {
  205. input_report_abs(ts->input, ABS_X, point[abs].coord_x);
  206. input_report_abs(ts->input, ABS_Y, point[abs].coord_y);
  207. }
  208. input_sync(ts->input);
  209. /* we want to loop only in touch_ind_mode */
  210. if (!ts->touch_ind_mode)
  211. break;
  212. wait_event_timeout(ts->wait, ts->stopped,
  213. msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS));
  214. }
  215. return IRQ_HANDLED;
  216. }
  217. /*
  218. * Set the power mode of the device.
  219. * Valid modes are
  220. * - AUO_PIXCIR_POWER_ACTIVE
  221. * - AUO_PIXCIR_POWER_SLEEP - automatically left on first touch
  222. * - AUO_PIXCIR_POWER_DEEP_SLEEP
  223. */
  224. static int auo_pixcir_power_mode(struct auo_pixcir_ts *ts, int mode)
  225. {
  226. struct i2c_client *client = ts->client;
  227. int ret;
  228. ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_POWER_MODE);
  229. if (ret < 0) {
  230. dev_err(&client->dev, "unable to read reg %Xh, %d\n",
  231. AUO_PIXCIR_REG_POWER_MODE, ret);
  232. return ret;
  233. }
  234. ret &= ~AUO_PIXCIR_POWER_MASK;
  235. ret |= mode;
  236. ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_POWER_MODE, ret);
  237. if (ret) {
  238. dev_err(&client->dev, "unable to write reg %Xh, %d\n",
  239. AUO_PIXCIR_REG_POWER_MODE, ret);
  240. return ret;
  241. }
  242. return 0;
  243. }
  244. static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, int int_setting)
  245. {
  246. struct i2c_client *client = ts->client;
  247. int ret;
  248. ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING);
  249. if (ret < 0) {
  250. dev_err(&client->dev, "unable to read reg %Xh, %d\n",
  251. AUO_PIXCIR_REG_INT_SETTING, ret);
  252. return ret;
  253. }
  254. ret &= ~AUO_PIXCIR_INT_MODE_MASK;
  255. ret |= int_setting;
  256. ret |= AUO_PIXCIR_INT_POL_HIGH; /* always use high for interrupts */
  257. ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING,
  258. ret);
  259. if (ret < 0) {
  260. dev_err(&client->dev, "unable to write reg %Xh, %d\n",
  261. AUO_PIXCIR_REG_INT_SETTING, ret);
  262. return ret;
  263. }
  264. ts->touch_ind_mode = int_setting == AUO_PIXCIR_INT_TOUCH_IND;
  265. return 0;
  266. }
  267. /* control the generation of interrupts on the device side */
  268. static int auo_pixcir_int_toggle(struct auo_pixcir_ts *ts, bool enable)
  269. {
  270. struct i2c_client *client = ts->client;
  271. int ret;
  272. ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING);
  273. if (ret < 0) {
  274. dev_err(&client->dev, "unable to read reg %Xh, %d\n",
  275. AUO_PIXCIR_REG_INT_SETTING, ret);
  276. return ret;
  277. }
  278. if (enable)
  279. ret |= AUO_PIXCIR_INT_ENABLE;
  280. else
  281. ret &= ~AUO_PIXCIR_INT_ENABLE;
  282. ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING,
  283. ret);
  284. if (ret < 0) {
  285. dev_err(&client->dev, "unable to write reg %Xh, %d\n",
  286. AUO_PIXCIR_REG_INT_SETTING, ret);
  287. return ret;
  288. }
  289. return 0;
  290. }
  291. static int auo_pixcir_start(struct auo_pixcir_ts *ts)
  292. {
  293. struct i2c_client *client = ts->client;
  294. int ret;
  295. ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_ACTIVE);
  296. if (ret < 0) {
  297. dev_err(&client->dev, "could not set power mode, %d\n",
  298. ret);
  299. return ret;
  300. }
  301. ts->stopped = false;
  302. mb();
  303. enable_irq(client->irq);
  304. ret = auo_pixcir_int_toggle(ts, 1);
  305. if (ret < 0) {
  306. dev_err(&client->dev, "could not enable interrupt, %d\n",
  307. ret);
  308. disable_irq(client->irq);
  309. return ret;
  310. }
  311. return 0;
  312. }
  313. static int auo_pixcir_stop(struct auo_pixcir_ts *ts)
  314. {
  315. struct i2c_client *client = ts->client;
  316. int ret;
  317. ret = auo_pixcir_int_toggle(ts, 0);
  318. if (ret < 0) {
  319. dev_err(&client->dev, "could not disable interrupt, %d\n",
  320. ret);
  321. return ret;
  322. }
  323. /* disable receiving of interrupts */
  324. disable_irq(client->irq);
  325. ts->stopped = true;
  326. mb();
  327. wake_up(&ts->wait);
  328. return auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_DEEP_SLEEP);
  329. }
  330. static int auo_pixcir_input_open(struct input_dev *dev)
  331. {
  332. struct auo_pixcir_ts *ts = input_get_drvdata(dev);
  333. return auo_pixcir_start(ts);
  334. }
  335. static void auo_pixcir_input_close(struct input_dev *dev)
  336. {
  337. struct auo_pixcir_ts *ts = input_get_drvdata(dev);
  338. auo_pixcir_stop(ts);
  339. }
  340. static int __maybe_unused auo_pixcir_suspend(struct device *dev)
  341. {
  342. struct i2c_client *client = to_i2c_client(dev);
  343. struct auo_pixcir_ts *ts = i2c_get_clientdata(client);
  344. struct input_dev *input = ts->input;
  345. int ret = 0;
  346. mutex_lock(&input->mutex);
  347. /* when configured as wakeup source, device should always wake system
  348. * therefore start device if necessary
  349. */
  350. if (device_may_wakeup(&client->dev)) {
  351. /* need to start device if not open, to be wakeup source */
  352. if (!input_device_enabled(input)) {
  353. ret = auo_pixcir_start(ts);
  354. if (ret)
  355. goto unlock;
  356. }
  357. enable_irq_wake(client->irq);
  358. ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_SLEEP);
  359. } else if (input_device_enabled(input)) {
  360. ret = auo_pixcir_stop(ts);
  361. }
  362. unlock:
  363. mutex_unlock(&input->mutex);
  364. return ret;
  365. }
  366. static int __maybe_unused auo_pixcir_resume(struct device *dev)
  367. {
  368. struct i2c_client *client = to_i2c_client(dev);
  369. struct auo_pixcir_ts *ts = i2c_get_clientdata(client);
  370. struct input_dev *input = ts->input;
  371. int ret = 0;
  372. mutex_lock(&input->mutex);
  373. if (device_may_wakeup(&client->dev)) {
  374. disable_irq_wake(client->irq);
  375. /* need to stop device if it was not open on suspend */
  376. if (!input_device_enabled(input)) {
  377. ret = auo_pixcir_stop(ts);
  378. if (ret)
  379. goto unlock;
  380. }
  381. /* device wakes automatically from SLEEP */
  382. } else if (input_device_enabled(input)) {
  383. ret = auo_pixcir_start(ts);
  384. }
  385. unlock:
  386. mutex_unlock(&input->mutex);
  387. return ret;
  388. }
  389. static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops,
  390. auo_pixcir_suspend, auo_pixcir_resume);
  391. static void auo_pixcir_reset(void *data)
  392. {
  393. struct auo_pixcir_ts *ts = data;
  394. gpiod_set_value_cansleep(ts->gpio_rst, 1);
  395. }
  396. static int auo_pixcir_probe(struct i2c_client *client,
  397. const struct i2c_device_id *id)
  398. {
  399. struct auo_pixcir_ts *ts;
  400. struct input_dev *input_dev;
  401. int version;
  402. int error;
  403. ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
  404. if (!ts)
  405. return -ENOMEM;
  406. input_dev = devm_input_allocate_device(&client->dev);
  407. if (!input_dev) {
  408. dev_err(&client->dev, "could not allocate input device\n");
  409. return -ENOMEM;
  410. }
  411. ts->client = client;
  412. ts->input = input_dev;
  413. ts->touch_ind_mode = 0;
  414. ts->stopped = true;
  415. init_waitqueue_head(&ts->wait);
  416. snprintf(ts->phys, sizeof(ts->phys),
  417. "%s/input0", dev_name(&client->dev));
  418. if (device_property_read_u32(&client->dev, "x-size", &ts->x_max)) {
  419. dev_err(&client->dev, "failed to get x-size property\n");
  420. return -EINVAL;
  421. }
  422. if (device_property_read_u32(&client->dev, "y-size", &ts->y_max)) {
  423. dev_err(&client->dev, "failed to get y-size property\n");
  424. return -EINVAL;
  425. }
  426. input_dev->name = "AUO-Pixcir touchscreen";
  427. input_dev->phys = ts->phys;
  428. input_dev->id.bustype = BUS_I2C;
  429. input_dev->open = auo_pixcir_input_open;
  430. input_dev->close = auo_pixcir_input_close;
  431. __set_bit(EV_ABS, input_dev->evbit);
  432. __set_bit(EV_KEY, input_dev->evbit);
  433. __set_bit(BTN_TOUCH, input_dev->keybit);
  434. /* For single touch */
  435. input_set_abs_params(input_dev, ABS_X, 0, ts->x_max, 0, 0);
  436. input_set_abs_params(input_dev, ABS_Y, 0, ts->y_max, 0, 0);
  437. /* For multi touch */
  438. input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
  439. input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0);
  440. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
  441. 0, AUO_PIXCIR_MAX_AREA, 0, 0);
  442. input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
  443. 0, AUO_PIXCIR_MAX_AREA, 0, 0);
  444. input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
  445. input_set_drvdata(ts->input, ts);
  446. ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN);
  447. error = PTR_ERR_OR_ZERO(ts->gpio_int);
  448. if (error) {
  449. dev_err(&client->dev,
  450. "request of int gpio failed: %d\n", error);
  451. return error;
  452. }
  453. gpiod_set_consumer_name(ts->gpio_int, "auo_pixcir_ts_int");
  454. /* Take the chip out of reset */
  455. ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1,
  456. GPIOD_OUT_LOW);
  457. error = PTR_ERR_OR_ZERO(ts->gpio_rst);
  458. if (error) {
  459. dev_err(&client->dev,
  460. "request of reset gpio failed: %d\n", error);
  461. return error;
  462. }
  463. gpiod_set_consumer_name(ts->gpio_rst, "auo_pixcir_ts_rst");
  464. error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts);
  465. if (error) {
  466. dev_err(&client->dev, "failed to register reset action, %d\n",
  467. error);
  468. return error;
  469. }
  470. msleep(200);
  471. version = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_VERSION);
  472. if (version < 0) {
  473. error = version;
  474. return error;
  475. }
  476. dev_info(&client->dev, "firmware version 0x%X\n", version);
  477. /* default to asserting the interrupt when the screen is touched */
  478. error = auo_pixcir_int_config(ts, AUO_PIXCIR_INT_TOUCH_IND);
  479. if (error)
  480. return error;
  481. error = devm_request_threaded_irq(&client->dev, client->irq,
  482. NULL, auo_pixcir_interrupt,
  483. IRQF_ONESHOT,
  484. input_dev->name, ts);
  485. if (error) {
  486. dev_err(&client->dev, "irq %d requested failed, %d\n",
  487. client->irq, error);
  488. return error;
  489. }
  490. /* stop device and put it into deep sleep until it is opened */
  491. error = auo_pixcir_stop(ts);
  492. if (error)
  493. return error;
  494. error = input_register_device(input_dev);
  495. if (error) {
  496. dev_err(&client->dev, "could not register input device, %d\n",
  497. error);
  498. return error;
  499. }
  500. i2c_set_clientdata(client, ts);
  501. return 0;
  502. }
  503. static const struct i2c_device_id auo_pixcir_idtable[] = {
  504. { "auo_pixcir_ts", 0 },
  505. { }
  506. };
  507. MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable);
  508. #ifdef CONFIG_OF
  509. static const struct of_device_id auo_pixcir_ts_dt_idtable[] = {
  510. { .compatible = "auo,auo_pixcir_ts" },
  511. {},
  512. };
  513. MODULE_DEVICE_TABLE(of, auo_pixcir_ts_dt_idtable);
  514. #endif
  515. static struct i2c_driver auo_pixcir_driver = {
  516. .driver = {
  517. .name = "auo_pixcir_ts",
  518. .pm = &auo_pixcir_pm_ops,
  519. .of_match_table = of_match_ptr(auo_pixcir_ts_dt_idtable),
  520. },
  521. .probe = auo_pixcir_probe,
  522. .id_table = auo_pixcir_idtable,
  523. };
  524. module_i2c_driver(auo_pixcir_driver);
  525. MODULE_DESCRIPTION("AUO-PIXCIR touchscreen driver");
  526. MODULE_LICENSE("GPL v2");
  527. MODULE_AUTHOR("Heiko Stuebner <[email protected]>");