blob: c0a2483b30cb04972e9fce77150bc2ebe40dab36 [file] [log] [blame]
Heiko Stübner5245db42011-12-27 21:21:17 -08001/*
2 * Driver for AUO in-cell touchscreens
3 *
4 * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de>
5 *
6 * loosely based on auo_touch.c from Dell Streak vendor-kernel
7 *
8 * Copyright (c) 2008 QUALCOMM Incorporated.
9 * Copyright (c) 2008 QUALCOMM USA, INC.
10 *
11 *
12 * This software is licensed under the terms of the GNU General Public
13 * License version 2, as published by the Free Software Foundation, and
14 * may be copied, distributed, and modified under those terms.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/interrupt.h>
26#include <linux/slab.h>
27#include <linux/input.h>
28#include <linux/jiffies.h>
29#include <linux/i2c.h>
30#include <linux/mutex.h>
31#include <linux/delay.h>
32#include <linux/gpio.h>
33#include <linux/input/auo-pixcir-ts.h>
34
35/*
36 * Coordinate calculation:
37 * X1 = X1_LSB + X1_MSB*256
38 * Y1 = Y1_LSB + Y1_MSB*256
39 * X2 = X2_LSB + X2_MSB*256
40 * Y2 = Y2_LSB + Y2_MSB*256
41 */
42#define AUO_PIXCIR_REG_X1_LSB 0x00
43#define AUO_PIXCIR_REG_X1_MSB 0x01
44#define AUO_PIXCIR_REG_Y1_LSB 0x02
45#define AUO_PIXCIR_REG_Y1_MSB 0x03
46#define AUO_PIXCIR_REG_X2_LSB 0x04
47#define AUO_PIXCIR_REG_X2_MSB 0x05
48#define AUO_PIXCIR_REG_Y2_LSB 0x06
49#define AUO_PIXCIR_REG_Y2_MSB 0x07
50
51#define AUO_PIXCIR_REG_STRENGTH 0x0d
52#define AUO_PIXCIR_REG_STRENGTH_X1_LSB 0x0e
53#define AUO_PIXCIR_REG_STRENGTH_X1_MSB 0x0f
54
55#define AUO_PIXCIR_REG_RAW_DATA_X 0x2b
56#define AUO_PIXCIR_REG_RAW_DATA_Y 0x4f
57
58#define AUO_PIXCIR_REG_X_SENSITIVITY 0x6f
59#define AUO_PIXCIR_REG_Y_SENSITIVITY 0x70
60#define AUO_PIXCIR_REG_INT_SETTING 0x71
61#define AUO_PIXCIR_REG_INT_WIDTH 0x72
62#define AUO_PIXCIR_REG_POWER_MODE 0x73
63
64#define AUO_PIXCIR_REG_VERSION 0x77
65#define AUO_PIXCIR_REG_CALIBRATE 0x78
66
67#define AUO_PIXCIR_REG_TOUCHAREA_X1 0x1e
68#define AUO_PIXCIR_REG_TOUCHAREA_Y1 0x1f
69#define AUO_PIXCIR_REG_TOUCHAREA_X2 0x20
70#define AUO_PIXCIR_REG_TOUCHAREA_Y2 0x21
71
72#define AUO_PIXCIR_REG_EEPROM_CALIB_X 0x42
73#define AUO_PIXCIR_REG_EEPROM_CALIB_Y 0xad
74
75#define AUO_PIXCIR_INT_TPNUM_MASK 0xe0
76#define AUO_PIXCIR_INT_TPNUM_SHIFT 5
77#define AUO_PIXCIR_INT_RELEASE (1 << 4)
78#define AUO_PIXCIR_INT_ENABLE (1 << 3)
79#define AUO_PIXCIR_INT_POL_HIGH (1 << 2)
80#define AUO_PIXCIR_INT_MODE_MASK 0x03
81
82/*
83 * Power modes:
84 * active: scan speed 60Hz
85 * sleep: scan speed 10Hz can be auto-activated, wakeup on 1st touch
86 * deep sleep: scan speed 1Hz can only be entered or left manually.
87 */
88#define AUO_PIXCIR_POWER_ACTIVE 0x00
89#define AUO_PIXCIR_POWER_SLEEP 0x01
90#define AUO_PIXCIR_POWER_DEEP_SLEEP 0x02
91#define AUO_PIXCIR_POWER_MASK 0x03
92
93#define AUO_PIXCIR_POWER_ALLOW_SLEEP (1 << 2)
94#define AUO_PIXCIR_POWER_IDLE_TIME(ms) ((ms & 0xf) << 4)
95
96#define AUO_PIXCIR_CALIBRATE 0x03
97
98#define AUO_PIXCIR_EEPROM_CALIB_X_LEN 62
99#define AUO_PIXCIR_EEPROM_CALIB_Y_LEN 36
100
101#define AUO_PIXCIR_RAW_DATA_X_LEN 18
102#define AUO_PIXCIR_RAW_DATA_Y_LEN 11
103
104#define AUO_PIXCIR_STRENGTH_ENABLE (1 << 0)
105
106/* Touchscreen absolute values */
107#define AUO_PIXCIR_REPORT_POINTS 2
108#define AUO_PIXCIR_MAX_AREA 0xff
109#define AUO_PIXCIR_PENUP_TIMEOUT_MS 10
110
111struct auo_pixcir_ts {
112 struct i2c_client *client;
113 struct input_dev *input;
Heiko Stübner38e83f72013-02-23 12:06:48 -0800114 const struct auo_pixcir_ts_platdata *pdata;
Heiko Stübner5245db42011-12-27 21:21:17 -0800115 char phys[32];
116
117 /* special handling for touch_indicate interupt mode */
118 bool touch_ind_mode;
119
120 wait_queue_head_t wait;
121 bool stopped;
122};
123
124struct auo_point_t {
125 int coord_x;
126 int coord_y;
127 int area_major;
128 int area_minor;
129 int orientation;
130};
131
132static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts,
133 struct auo_point_t *point)
134{
135 struct i2c_client *client = ts->client;
Heiko Stübner38e83f72013-02-23 12:06:48 -0800136 const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
Heiko Stübner5245db42011-12-27 21:21:17 -0800137 uint8_t raw_coord[8];
138 uint8_t raw_area[4];
139 int i, ret;
140
141 /* touch coordinates */
142 ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_X1_LSB,
143 8, raw_coord);
144 if (ret < 0) {
145 dev_err(&client->dev, "failed to read coordinate, %d\n", ret);
146 return ret;
147 }
148
149 /* touch area */
150 ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_TOUCHAREA_X1,
151 4, raw_area);
152 if (ret < 0) {
153 dev_err(&client->dev, "could not read touch area, %d\n", ret);
154 return ret;
155 }
156
157 for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) {
158 point[i].coord_x =
159 raw_coord[4 * i + 1] << 8 | raw_coord[4 * i];
160 point[i].coord_y =
161 raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2];
162
163 if (point[i].coord_x > pdata->x_max ||
164 point[i].coord_y > pdata->y_max) {
165 dev_warn(&client->dev, "coordinates (%d,%d) invalid\n",
166 point[i].coord_x, point[i].coord_y);
167 point[i].coord_x = point[i].coord_y = 0;
168 }
169
170 /* determine touch major, minor and orientation */
171 point[i].area_major = max(raw_area[2 * i], raw_area[2 * i + 1]);
172 point[i].area_minor = min(raw_area[2 * i], raw_area[2 * i + 1]);
173 point[i].orientation = raw_area[2 * i] > raw_area[2 * i + 1];
174 }
175
176 return 0;
177}
178
179static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
180{
181 struct auo_pixcir_ts *ts = dev_id;
Heiko Stübner38e83f72013-02-23 12:06:48 -0800182 const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
Heiko Stübner5245db42011-12-27 21:21:17 -0800183 struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS];
184 int i;
185 int ret;
186 int fingers = 0;
187 int abs = -1;
188
189 while (!ts->stopped) {
190
191 /* check for up event in touch touch_ind_mode */
192 if (ts->touch_ind_mode) {
193 if (gpio_get_value(pdata->gpio_int) == 0) {
194 input_mt_sync(ts->input);
195 input_report_key(ts->input, BTN_TOUCH, 0);
196 input_sync(ts->input);
197 break;
198 }
199 }
200
201 ret = auo_pixcir_collect_data(ts, point);
202 if (ret < 0) {
203 /* we want to loop only in touch_ind_mode */
204 if (!ts->touch_ind_mode)
205 break;
206
207 wait_event_timeout(ts->wait, ts->stopped,
208 msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS));
209 continue;
210 }
211
212 for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) {
213 if (point[i].coord_x > 0 || point[i].coord_y > 0) {
214 input_report_abs(ts->input, ABS_MT_POSITION_X,
215 point[i].coord_x);
216 input_report_abs(ts->input, ABS_MT_POSITION_Y,
217 point[i].coord_y);
218 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR,
219 point[i].area_major);
220 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR,
221 point[i].area_minor);
222 input_report_abs(ts->input, ABS_MT_ORIENTATION,
223 point[i].orientation);
224 input_mt_sync(ts->input);
225
226 /* use first finger as source for singletouch */
227 if (fingers == 0)
228 abs = i;
229
230 /* number of touch points could also be queried
231 * via i2c but would require an additional call
232 */
233 fingers++;
234 }
235 }
236
237 input_report_key(ts->input, BTN_TOUCH, fingers > 0);
238
239 if (abs > -1) {
240 input_report_abs(ts->input, ABS_X, point[abs].coord_x);
241 input_report_abs(ts->input, ABS_Y, point[abs].coord_y);
242 }
243
244 input_sync(ts->input);
245
246 /* we want to loop only in touch_ind_mode */
247 if (!ts->touch_ind_mode)
248 break;
249
250 wait_event_timeout(ts->wait, ts->stopped,
251 msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS));
252 }
253
254 return IRQ_HANDLED;
255}
256
257/*
258 * Set the power mode of the device.
259 * Valid modes are
260 * - AUO_PIXCIR_POWER_ACTIVE
261 * - AUO_PIXCIR_POWER_SLEEP - automatically left on first touch
262 * - AUO_PIXCIR_POWER_DEEP_SLEEP
263 */
264static int auo_pixcir_power_mode(struct auo_pixcir_ts *ts, int mode)
265{
266 struct i2c_client *client = ts->client;
267 int ret;
268
269 ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_POWER_MODE);
270 if (ret < 0) {
271 dev_err(&client->dev, "unable to read reg %Xh, %d\n",
272 AUO_PIXCIR_REG_POWER_MODE, ret);
273 return ret;
274 }
275
276 ret &= ~AUO_PIXCIR_POWER_MASK;
277 ret |= mode;
278
279 ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_POWER_MODE, ret);
280 if (ret) {
281 dev_err(&client->dev, "unable to write reg %Xh, %d\n",
282 AUO_PIXCIR_REG_POWER_MODE, ret);
283 return ret;
284 }
285
286 return 0;
287}
288
Bill Pemberton5298cc42012-11-23 21:38:25 -0800289static int auo_pixcir_int_config(struct auo_pixcir_ts *ts,
Heiko Stübner5245db42011-12-27 21:21:17 -0800290 int int_setting)
291{
292 struct i2c_client *client = ts->client;
Heiko Stübner38e83f72013-02-23 12:06:48 -0800293 const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
Heiko Stübner5245db42011-12-27 21:21:17 -0800294 int ret;
295
296 ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING);
297 if (ret < 0) {
298 dev_err(&client->dev, "unable to read reg %Xh, %d\n",
299 AUO_PIXCIR_REG_INT_SETTING, ret);
300 return ret;
301 }
302
303 ret &= ~AUO_PIXCIR_INT_MODE_MASK;
304 ret |= int_setting;
305 ret |= AUO_PIXCIR_INT_POL_HIGH; /* always use high for interrupts */
306
307 ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING,
308 ret);
309 if (ret < 0) {
310 dev_err(&client->dev, "unable to write reg %Xh, %d\n",
311 AUO_PIXCIR_REG_INT_SETTING, ret);
312 return ret;
313 }
314
315 ts->touch_ind_mode = pdata->int_setting == AUO_PIXCIR_INT_TOUCH_IND;
316
317 return 0;
318}
319
320/* control the generation of interrupts on the device side */
321static int auo_pixcir_int_toggle(struct auo_pixcir_ts *ts, bool enable)
322{
323 struct i2c_client *client = ts->client;
324 int ret;
325
326 ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING);
327 if (ret < 0) {
328 dev_err(&client->dev, "unable to read reg %Xh, %d\n",
329 AUO_PIXCIR_REG_INT_SETTING, ret);
330 return ret;
331 }
332
333 if (enable)
334 ret |= AUO_PIXCIR_INT_ENABLE;
335 else
336 ret &= ~AUO_PIXCIR_INT_ENABLE;
337
338 ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING,
339 ret);
340 if (ret < 0) {
341 dev_err(&client->dev, "unable to write reg %Xh, %d\n",
342 AUO_PIXCIR_REG_INT_SETTING, ret);
343 return ret;
344 }
345
346 return 0;
347}
348
349static int auo_pixcir_start(struct auo_pixcir_ts *ts)
350{
351 struct i2c_client *client = ts->client;
352 int ret;
353
354 ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_ACTIVE);
355 if (ret < 0) {
356 dev_err(&client->dev, "could not set power mode, %d\n",
357 ret);
358 return ret;
359 }
360
361 ts->stopped = false;
362 mb();
363 enable_irq(client->irq);
364
365 ret = auo_pixcir_int_toggle(ts, 1);
366 if (ret < 0) {
367 dev_err(&client->dev, "could not enable interrupt, %d\n",
368 ret);
369 disable_irq(client->irq);
370 return ret;
371 }
372
373 return 0;
374}
375
376static int auo_pixcir_stop(struct auo_pixcir_ts *ts)
377{
378 struct i2c_client *client = ts->client;
379 int ret;
380
381 ret = auo_pixcir_int_toggle(ts, 0);
382 if (ret < 0) {
383 dev_err(&client->dev, "could not disable interrupt, %d\n",
384 ret);
385 return ret;
386 }
387
388 /* disable receiving of interrupts */
389 disable_irq(client->irq);
390 ts->stopped = true;
391 mb();
392 wake_up(&ts->wait);
393
394 return auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_DEEP_SLEEP);
395}
396
397static int auo_pixcir_input_open(struct input_dev *dev)
398{
399 struct auo_pixcir_ts *ts = input_get_drvdata(dev);
400 int ret;
401
402 ret = auo_pixcir_start(ts);
403 if (ret)
404 return ret;
405
406 return 0;
407}
408
409static void auo_pixcir_input_close(struct input_dev *dev)
410{
411 struct auo_pixcir_ts *ts = input_get_drvdata(dev);
412
413 auo_pixcir_stop(ts);
414
415 return;
416}
417
418#ifdef CONFIG_PM_SLEEP
419static int auo_pixcir_suspend(struct device *dev)
420{
421 struct i2c_client *client = to_i2c_client(dev);
422 struct auo_pixcir_ts *ts = i2c_get_clientdata(client);
423 struct input_dev *input = ts->input;
424 int ret = 0;
425
426 mutex_lock(&input->mutex);
427
428 /* when configured as wakeup source, device should always wake system
429 * therefore start device if necessary
430 */
431 if (device_may_wakeup(&client->dev)) {
432 /* need to start device if not open, to be wakeup source */
433 if (!input->users) {
434 ret = auo_pixcir_start(ts);
435 if (ret)
436 goto unlock;
437 }
438
439 enable_irq_wake(client->irq);
440 ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_SLEEP);
441 } else if (input->users) {
442 ret = auo_pixcir_stop(ts);
443 }
444
445unlock:
446 mutex_unlock(&input->mutex);
447
448 return ret;
449}
450
451static int auo_pixcir_resume(struct device *dev)
452{
453 struct i2c_client *client = to_i2c_client(dev);
454 struct auo_pixcir_ts *ts = i2c_get_clientdata(client);
455 struct input_dev *input = ts->input;
456 int ret = 0;
457
458 mutex_lock(&input->mutex);
459
460 if (device_may_wakeup(&client->dev)) {
461 disable_irq_wake(client->irq);
462
463 /* need to stop device if it was not open on suspend */
464 if (!input->users) {
465 ret = auo_pixcir_stop(ts);
466 if (ret)
467 goto unlock;
468 }
469
470 /* device wakes automatically from SLEEP */
471 } else if (input->users) {
472 ret = auo_pixcir_start(ts);
473 }
474
475unlock:
476 mutex_unlock(&input->mutex);
477
478 return ret;
479}
480#endif
481
482static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, auo_pixcir_suspend,
483 auo_pixcir_resume);
484
Bill Pemberton5298cc42012-11-23 21:38:25 -0800485static int auo_pixcir_probe(struct i2c_client *client,
Heiko Stübner5245db42011-12-27 21:21:17 -0800486 const struct i2c_device_id *id)
487{
488 const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data;
489 struct auo_pixcir_ts *ts;
490 struct input_dev *input_dev;
491 int ret;
492
493 if (!pdata)
494 return -EINVAL;
495
496 ts = kzalloc(sizeof(struct auo_pixcir_ts), GFP_KERNEL);
497 if (!ts)
498 return -ENOMEM;
499
500 ret = gpio_request(pdata->gpio_int, "auo_pixcir_ts_int");
501 if (ret) {
502 dev_err(&client->dev, "request of gpio %d failed, %d\n",
503 pdata->gpio_int, ret);
504 goto err_gpio_int;
505 }
506
Heiko Stübnerfa656302013-02-23 12:06:34 -0800507 ret = gpio_direction_input(pdata->gpio_int);
508 if (ret) {
509 dev_err(&client->dev, "setting direction of gpio %d failed %d\n",
510 pdata->gpio_int, ret);
511 goto err_gpio_dir;
512 }
513
Heiko Stübner27cef8b2013-02-23 12:06:44 -0800514 ret = gpio_request(pdata->gpio_rst, "auo_pixcir_ts_rst");
515 if (ret) {
516 dev_err(&client->dev, "request of gpio %d failed, %d\n",
517 pdata->gpio_rst, ret);
518 goto err_gpio_dir;
519 }
520
521 ret = gpio_direction_output(pdata->gpio_rst, 1);
522 if (ret) {
523 dev_err(&client->dev, "setting direction of gpio %d failed %d\n",
524 pdata->gpio_rst, ret);
525 goto err_gpio_rst;
526 }
527
528 msleep(200);
Heiko Stübner5245db42011-12-27 21:21:17 -0800529
Heiko Stübner38e83f72013-02-23 12:06:48 -0800530 ts->pdata = pdata;
Heiko Stübner5245db42011-12-27 21:21:17 -0800531 ts->client = client;
532 ts->touch_ind_mode = 0;
533 init_waitqueue_head(&ts->wait);
534
535 snprintf(ts->phys, sizeof(ts->phys),
536 "%s/input0", dev_name(&client->dev));
537
538 input_dev = input_allocate_device();
539 if (!input_dev) {
540 dev_err(&client->dev, "could not allocate input device\n");
541 goto err_input_alloc;
542 }
543
544 ts->input = input_dev;
545
546 input_dev->name = "AUO-Pixcir touchscreen";
547 input_dev->phys = ts->phys;
548 input_dev->id.bustype = BUS_I2C;
549 input_dev->dev.parent = &client->dev;
550
551 input_dev->open = auo_pixcir_input_open;
552 input_dev->close = auo_pixcir_input_close;
553
554 __set_bit(EV_ABS, input_dev->evbit);
555 __set_bit(EV_KEY, input_dev->evbit);
556
557 __set_bit(BTN_TOUCH, input_dev->keybit);
558
559 /* For single touch */
560 input_set_abs_params(input_dev, ABS_X, 0, pdata->x_max, 0, 0);
561 input_set_abs_params(input_dev, ABS_Y, 0, pdata->y_max, 0, 0);
562
563 /* For multi touch */
564 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
565 pdata->x_max, 0, 0);
566 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
567 pdata->y_max, 0, 0);
568 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
569 AUO_PIXCIR_MAX_AREA, 0, 0);
570 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0,
571 AUO_PIXCIR_MAX_AREA, 0, 0);
572 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
573
574 ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_VERSION);
575 if (ret < 0)
576 goto err_fw_vers;
577 dev_info(&client->dev, "firmware version 0x%X\n", ret);
578
579 ret = auo_pixcir_int_config(ts, pdata->int_setting);
580 if (ret)
581 goto err_fw_vers;
582
583 input_set_drvdata(ts->input, ts);
584 ts->stopped = true;
585
586 ret = request_threaded_irq(client->irq, NULL, auo_pixcir_interrupt,
587 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
588 input_dev->name, ts);
589 if (ret) {
590 dev_err(&client->dev, "irq %d requested failed\n", client->irq);
591 goto err_fw_vers;
592 }
593
594 /* stop device and put it into deep sleep until it is opened */
595 ret = auo_pixcir_stop(ts);
596 if (ret < 0)
597 goto err_input_register;
598
599 ret = input_register_device(input_dev);
600 if (ret) {
601 dev_err(&client->dev, "could not register input device\n");
602 goto err_input_register;
603 }
604
605 i2c_set_clientdata(client, ts);
606
607 return 0;
608
609err_input_register:
610 free_irq(client->irq, ts);
611err_fw_vers:
612 input_free_device(input_dev);
613err_input_alloc:
Heiko Stübner27cef8b2013-02-23 12:06:44 -0800614 gpio_set_value(pdata->gpio_rst, 0);
615err_gpio_rst:
616 gpio_free(pdata->gpio_rst);
Heiko Stübnerfa656302013-02-23 12:06:34 -0800617err_gpio_dir:
Heiko Stübner5245db42011-12-27 21:21:17 -0800618 gpio_free(pdata->gpio_int);
619err_gpio_int:
620 kfree(ts);
621
622 return ret;
623}
624
Bill Pembertone2619cf2012-11-23 21:50:47 -0800625static int auo_pixcir_remove(struct i2c_client *client)
Heiko Stübner5245db42011-12-27 21:21:17 -0800626{
627 struct auo_pixcir_ts *ts = i2c_get_clientdata(client);
Heiko Stübner38e83f72013-02-23 12:06:48 -0800628 const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
Heiko Stübner5245db42011-12-27 21:21:17 -0800629
630 free_irq(client->irq, ts);
631
632 input_unregister_device(ts->input);
633
Heiko Stübner27cef8b2013-02-23 12:06:44 -0800634 gpio_set_value(pdata->gpio_rst, 0);
635 gpio_free(pdata->gpio_rst);
Heiko Stübner5245db42011-12-27 21:21:17 -0800636
637 gpio_free(pdata->gpio_int);
638
639 kfree(ts);
640
641 return 0;
642}
643
644static const struct i2c_device_id auo_pixcir_idtable[] = {
645 { "auo_pixcir_ts", 0 },
646 { }
647};
648MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable);
649
650static struct i2c_driver auo_pixcir_driver = {
651 .driver = {
652 .owner = THIS_MODULE,
653 .name = "auo_pixcir_ts",
654 .pm = &auo_pixcir_pm_ops,
655 },
656 .probe = auo_pixcir_probe,
Bill Pemberton1cb0aa82012-11-23 21:27:39 -0800657 .remove = auo_pixcir_remove,
Heiko Stübner5245db42011-12-27 21:21:17 -0800658 .id_table = auo_pixcir_idtable,
659};
660
Dmitry Torokhov4a533832012-03-16 23:05:44 -0700661module_i2c_driver(auo_pixcir_driver);
Heiko Stübner5245db42011-12-27 21:21:17 -0800662
663MODULE_DESCRIPTION("AUO-PIXCIR touchscreen driver");
664MODULE_LICENSE("GPL v2");
665MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");