blob: ac76cde61e978b07a6ef12e6c11b256e6c3cdcab [file] [log] [blame]
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -05001/*
2 * drivers/input/touchscreen/tsc2007.c
3 *
4 * Copyright (c) 2008 MtekVision Co., Ltd.
5 * Kwangwoo Lee <kwlee@mtekvision.com>
6 *
7 * Using code from:
8 * - ads7846.c
9 * Copyright (c) 2005 David Brownell
10 * Copyright (c) 2006 Nokia Corporation
11 * - corgi_ts.c
12 * Copyright (C) 2004-2005 Richard Purdie
13 * - omap_ts.[hc], ads7846.h, ts_osk.c
14 * Copyright (C) 2002 MontaVista Software
15 * Copyright (C) 2004 Texas Instruments
16 * Copyright (C) 2005 Dirk Behme
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License version 2 as
20 * published by the Free Software Foundation.
21 */
22
23#include <linux/module.h>
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050024#include <linux/slab.h>
25#include <linux/input.h>
26#include <linux/interrupt.h>
27#include <linux/i2c.h>
28#include <linux/i2c/tsc2007.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029#include <linux/pm.h>
30
31#if defined(CONFIG_HAS_EARLYSUSPEND)
32#include <linux/earlysuspend.h>
33#define TSC2007_SUSPEND_LEVEL 1
34#endif
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050035
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050036#define TSC2007_MEASURE_TEMP0 (0x0 << 4)
37#define TSC2007_MEASURE_AUX (0x2 << 4)
38#define TSC2007_MEASURE_TEMP1 (0x4 << 4)
39#define TSC2007_ACTIVATE_XN (0x8 << 4)
40#define TSC2007_ACTIVATE_YN (0x9 << 4)
41#define TSC2007_ACTIVATE_YP_XN (0xa << 4)
42#define TSC2007_SETUP (0xb << 4)
43#define TSC2007_MEASURE_X (0xc << 4)
44#define TSC2007_MEASURE_Y (0xd << 4)
45#define TSC2007_MEASURE_Z1 (0xe << 4)
46#define TSC2007_MEASURE_Z2 (0xf << 4)
47
48#define TSC2007_POWER_OFF_IRQ_EN (0x0 << 2)
49#define TSC2007_ADC_ON_IRQ_DIS0 (0x1 << 2)
50#define TSC2007_ADC_OFF_IRQ_EN (0x2 << 2)
51#define TSC2007_ADC_ON_IRQ_DIS1 (0x3 << 2)
52
53#define TSC2007_12BIT (0x0 << 1)
54#define TSC2007_8BIT (0x1 << 1)
55
56#define MAX_12BIT ((1 << 12) - 1)
57
58#define ADC_ON_12BIT (TSC2007_12BIT | TSC2007_ADC_ON_IRQ_DIS0)
59
60#define READ_Y (ADC_ON_12BIT | TSC2007_MEASURE_Y)
61#define READ_Z1 (ADC_ON_12BIT | TSC2007_MEASURE_Z1)
62#define READ_Z2 (ADC_ON_12BIT | TSC2007_MEASURE_Z2)
63#define READ_X (ADC_ON_12BIT | TSC2007_MEASURE_X)
64#define PWRDOWN (TSC2007_12BIT | TSC2007_POWER_OFF_IRQ_EN)
65
66struct ts_event {
67 u16 x;
68 u16 y;
69 u16 z1, z2;
70};
71
72struct tsc2007 {
73 struct input_dev *input;
74 char phys[32];
Richard Röjfors75fba3b2009-07-24 22:01:39 -070075 struct delayed_work work;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050076
77 struct i2c_client *client;
78
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050079 u16 model;
80 u16 x_plate_ohms;
Thierry Reding84005eb2011-05-17 09:31:01 -070081 u16 max_rt;
Thierry Reding2d137c7e2011-05-17 09:31:33 -070082 unsigned long poll_delay;
Thierry Reding1af38ea2011-05-17 09:32:02 -070083 unsigned long poll_period;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050084
Dmitry Torokhov141586bc2009-07-24 23:14:16 -070085 bool pendown;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050086 int irq;
87
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088 bool invert_x;
89 bool invert_y;
90 bool invert_z1;
91 bool invert_z2;
92
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050093 int (*get_pendown_state)(void);
94 void (*clear_penirq)(void);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095 int (*power_shutdown)(bool);
96#if defined(CONFIG_HAS_EARLYSUSPEND)
97 struct early_suspend early_suspend;
98#endif
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -050099};
100
101static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
102{
103 s32 data;
104 u16 val;
105
106 data = i2c_smbus_read_word_data(tsc->client, cmd);
107 if (data < 0) {
108 dev_err(&tsc->client->dev, "i2c io error: %d\n", data);
109 return data;
110 }
111
112 /* The protocol and raw data format from i2c interface:
113 * S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
114 * Where DataLow has [D11-D4], DataHigh has [D3-D0 << 4 | Dummy 4bit].
115 */
116 val = swab16(data) >> 4;
117
118 dev_dbg(&tsc->client->dev, "data: 0x%x, val: 0x%x\n", data, val);
119
120 return val;
121}
122
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700123static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500124{
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700125 /* y- still on; turn on only y+ (and ADC) */
126 tc->y = tsc2007_xfer(tsc, READ_Y);
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500127
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700128 /* turn y- off, x+ on, then leave in lowpower */
129 tc->x = tsc2007_xfer(tsc, READ_X);
130
131 /* turn y+ off, x- on; we'll use formula #1 */
132 tc->z1 = tsc2007_xfer(tsc, READ_Z1);
133 tc->z2 = tsc2007_xfer(tsc, READ_Z2);
134
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700135 if (tsc->invert_x == true)
136 tc->x = MAX_12BIT - tc->x;
137
138 if (tsc->invert_y == true)
139 tc->y = MAX_12BIT - tc->y;
140
141 if (tsc->invert_z1 == true)
142 tc->z1 = MAX_12BIT - tc->z1;
143
144 if (tsc->invert_z2 == true)
145 tc->z2 = MAX_12BIT - tc->z2;
146
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700147 /* Prepare for next touch reading - power down ADC, enable PENIRQ */
148 tsc2007_xfer(tsc, PWRDOWN);
149}
150
151static u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
152{
153 u32 rt = 0;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500154
155 /* range filtering */
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700156 if (tc->x == MAX_12BIT)
157 tc->x = 0;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500158
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700159 if (likely(tc->x && tc->z1)) {
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500160 /* compute touch pressure resistance using equation #1 */
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700161 rt = tc->z2 - tc->z1;
162 rt *= tc->x;
163 rt *= tsc->x_plate_ohms;
164 rt /= tc->z1;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500165 rt = (rt + 2047) >> 12;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500166 }
167
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700168 return rt;
169}
170
171static void tsc2007_send_up_event(struct tsc2007 *tsc)
172{
173 struct input_dev *input = tsc->input;
174
175 dev_dbg(&tsc->client->dev, "UP\n");
176
177 input_report_key(input, BTN_TOUCH, 0);
178 input_report_abs(input, ABS_PRESSURE, 0);
179 input_sync(input);
180}
181
182static void tsc2007_work(struct work_struct *work)
183{
184 struct tsc2007 *ts =
185 container_of(to_delayed_work(work), struct tsc2007, work);
Thierry Reding4a1a42a2011-05-17 09:29:45 -0700186 bool debounced = false;
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700187 struct ts_event tc;
188 u32 rt;
189
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700190 /*
191 * NOTE: We can't rely on the pressure to determine the pen down
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700192 * state, even though this controller has a pressure sensor.
193 * The pressure value can fluctuate for quite a while after
194 * lifting the pen and in some cases may not even settle at the
195 * expected value.
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500196 *
197 * The only safe way to check for the pen up condition is in the
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700198 * work function by reading the pen signal state (it's a GPIO
199 * and IRQ). Unfortunately such callback is not always available,
200 * in that case we have rely on the pressure anyway.
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500201 */
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700202 if (ts->get_pendown_state) {
203 if (unlikely(!ts->get_pendown_state())) {
204 tsc2007_send_up_event(ts);
205 ts->pendown = false;
206 goto out;
207 }
208
209 dev_dbg(&ts->client->dev, "pen is still down\n");
210 }
211
212 tsc2007_read_values(ts, &tc);
213
214 rt = tsc2007_calculate_pressure(ts, &tc);
Thierry Reding84005eb2011-05-17 09:31:01 -0700215 if (rt > ts->max_rt) {
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700216 /*
217 * Sample found inconsistent by debouncing or pressure is
218 * beyond the maximum. Don't report it to user space,
219 * repeat at least once more the measurement.
220 */
221 dev_dbg(&ts->client->dev, "ignored pressure %d\n", rt);
Thierry Reding4a1a42a2011-05-17 09:29:45 -0700222 debounced = true;
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700223 goto out;
224
225 }
226
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500227 if (rt) {
228 struct input_dev *input = ts->input;
229
230 if (!ts->pendown) {
231 dev_dbg(&ts->client->dev, "DOWN\n");
232
233 input_report_key(input, BTN_TOUCH, 1);
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700234 ts->pendown = true;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500235 }
236
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700237 input_report_abs(input, ABS_X, tc.x);
238 input_report_abs(input, ABS_Y, tc.y);
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500239 input_report_abs(input, ABS_PRESSURE, rt);
240
241 input_sync(input);
242
243 dev_dbg(&ts->client->dev, "point(%4d,%4d), pressure (%4u)\n",
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700244 tc.x, tc.y, rt);
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500245
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700246 } else if (!ts->get_pendown_state && ts->pendown) {
247 /*
248 * We don't have callback to check pendown state, so we
249 * have to assume that since pressure reported is 0 the
250 * pen was lifted up.
251 */
252 tsc2007_send_up_event(ts);
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700253 ts->pendown = false;
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700254 }
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500255
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700256 out:
Thierry Reding4a1a42a2011-05-17 09:29:45 -0700257 if (ts->pendown || debounced)
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700258 schedule_delayed_work(&ts->work,
Thierry Reding1af38ea2011-05-17 09:32:02 -0700259 msecs_to_jiffies(ts->poll_period));
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700260 else
261 enable_irq(ts->irq);
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500262}
263
264static irqreturn_t tsc2007_irq(int irq, void *handle)
265{
266 struct tsc2007 *ts = handle;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500267
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700268 if (!ts->get_pendown_state || likely(ts->get_pendown_state())) {
Ben Nizette29fa98b2009-04-17 20:35:57 -0700269 disable_irq_nosync(ts->irq);
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700270 schedule_delayed_work(&ts->work,
Thierry Reding2d137c7e2011-05-17 09:31:33 -0700271 msecs_to_jiffies(ts->poll_delay));
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500272 }
273
274 if (ts->clear_penirq)
275 ts->clear_penirq();
276
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500277 return IRQ_HANDLED;
278}
279
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700280static void tsc2007_free_irq(struct tsc2007 *ts)
281{
282 free_irq(ts->irq, ts);
283 if (cancel_delayed_work_sync(&ts->work)) {
284 /*
285 * Work was pending, therefore we need to enable
286 * IRQ here to balance the disable_irq() done in the
287 * interrupt handler.
288 */
289 enable_irq(ts->irq);
290 }
291}
292
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700293#ifdef CONFIG_PM
294static int tsc2007_suspend(struct device *dev)
295{
296 int rc;
297 struct tsc2007 *ts = dev_get_drvdata(dev);
298
299 disable_irq(ts->irq);
300
301 if (cancel_delayed_work_sync(&ts->work))
302 enable_irq(ts->irq);
303
304 if (ts->power_shutdown) {
305 rc = ts->power_shutdown(true);
306 if (rc) {
307 pr_err("%s: Power off failed, suspend failed (%d)\n",
308 __func__, rc);
309 return rc;
310 }
311 }
312
313 return 0;
314}
315
316static int tsc2007_resume(struct device *dev)
317{
318 int rc;
319 struct tsc2007 *ts = dev_get_drvdata(dev);
320
321 if (ts->power_shutdown) {
322 rc = ts->power_shutdown(false);
323 if (rc) {
324 pr_err("%s: Power on failed, resume failed (%d)\n",
325 __func__, rc);
326 return rc;
327 }
328 }
329
330 enable_irq(ts->irq);
331
332 return 0;
333}
334
335#ifdef CONFIG_HAS_EARLYSUSPEND
336static void tsc2007_early_suspend(struct early_suspend *h)
337{
338 struct tsc2007 *ts = container_of(h, struct tsc2007, early_suspend);
339
340 tsc2007_suspend(&ts->client->dev);
341}
342
343static void tsc2007_late_resume(struct early_suspend *h)
344{
345 struct tsc2007 *ts = container_of(h, struct tsc2007, early_suspend);
346
347 tsc2007_resume(&ts->client->dev);
348}
349#endif
350
351static const struct dev_pm_ops tsc2007_pm_ops = {
352#ifndef CONFIG_HAS_EARLYSUSPEND
353 .suspend = tsc2007_suspend,
354 .resume = tsc2007_resume,
355#endif
356};
357#endif
358
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700359static int __devinit tsc2007_probe(struct i2c_client *client,
360 const struct i2c_device_id *id)
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500361{
362 struct tsc2007 *ts;
Axel Linb496acb2010-09-02 19:52:41 -0700363 struct tsc2007_platform_data *pdata = client->dev.platform_data;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500364 struct input_dev *input_dev;
365 int err;
366
Dmitry Torokhovd570e9e2009-08-04 22:07:26 -0700367 if (!pdata) {
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500368 dev_err(&client->dev, "platform data is required!\n");
369 return -EINVAL;
370 }
371
372 if (!i2c_check_functionality(client->adapter,
373 I2C_FUNC_SMBUS_READ_WORD_DATA))
374 return -EIO;
375
376 ts = kzalloc(sizeof(struct tsc2007), GFP_KERNEL);
377 input_dev = input_allocate_device();
378 if (!ts || !input_dev) {
379 err = -ENOMEM;
380 goto err_free_mem;
381 }
382
383 ts->client = client;
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700384 ts->irq = client->irq;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500385 ts->input = input_dev;
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700386 INIT_DELAYED_WORK(&ts->work, tsc2007_work);
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500387
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500388 ts->model = pdata->model;
389 ts->x_plate_ohms = pdata->x_plate_ohms;
Thierry Reding84005eb2011-05-17 09:31:01 -0700390 ts->max_rt = pdata->max_rt ? : MAX_12BIT;
Thierry Reding2d137c7e2011-05-17 09:31:33 -0700391 ts->poll_delay = pdata->poll_delay ? : 1;
Thierry Reding1af38ea2011-05-17 09:32:02 -0700392 ts->poll_period = pdata->poll_period ? : 1;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500393 ts->get_pendown_state = pdata->get_pendown_state;
394 ts->clear_penirq = pdata->clear_penirq;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700395 ts->invert_x = pdata->invert_x;
396 ts->invert_y = pdata->invert_y;
397 ts->invert_z1 = pdata->invert_z1;
398 ts->invert_z2 = pdata->invert_z2;
399 ts->power_shutdown = pdata->power_shutdown;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500400
Kay Sievers4e8718a2009-01-29 22:56:08 -0800401 snprintf(ts->phys, sizeof(ts->phys),
402 "%s/input0", dev_name(&client->dev));
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500403
404 input_dev->name = "TSC2007 Touchscreen";
405 input_dev->phys = ts->phys;
406 input_dev->id.bustype = BUS_I2C;
407
408 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
409 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
410
Thierry Reding891e3762011-05-17 09:32:29 -0700411 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, pdata->fuzzx, 0);
412 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, pdata->fuzzy, 0);
413 input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
414 pdata->fuzzz, 0);
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500415
Richard Röjforscad065f2009-07-24 23:14:17 -0700416 if (pdata->init_platform_hw)
417 pdata->init_platform_hw();
Richard Röjfors75fba3b2009-07-24 22:01:39 -0700418
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700419 err = request_irq(ts->irq, tsc2007_irq, pdata->irq_flags,
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500420 client->dev.driver->name, ts);
421 if (err < 0) {
422 dev_err(&client->dev, "irq %d busy?\n", ts->irq);
423 goto err_free_mem;
424 }
425
Richard Röjforscf5f4392009-08-04 22:34:10 -0700426 /* Prepare for touch readings - power down ADC and enable PENIRQ */
427 err = tsc2007_xfer(ts, PWRDOWN);
428 if (err < 0)
429 goto err_free_irq;
430
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500431 err = input_register_device(input_dev);
432 if (err)
433 goto err_free_irq;
434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700435#ifdef CONFIG_HAS_EARLYSUSPEND
436 ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN +
437 TSC2007_SUSPEND_LEVEL;
438 ts->early_suspend.suspend = tsc2007_early_suspend;
439 ts->early_suspend.resume = tsc2007_late_resume;
440 register_early_suspend(&ts->early_suspend);
441#endif
442
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700443 i2c_set_clientdata(client, ts);
444
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500445 return 0;
446
447 err_free_irq:
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700448 tsc2007_free_irq(ts);
Richard Röjforscad065f2009-07-24 23:14:17 -0700449 if (pdata->exit_platform_hw)
450 pdata->exit_platform_hw();
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500451 err_free_mem:
452 input_free_device(input_dev);
453 kfree(ts);
454 return err;
455}
456
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700457static int __devexit tsc2007_remove(struct i2c_client *client)
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500458{
459 struct tsc2007 *ts = i2c_get_clientdata(client);
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700460 struct tsc2007_platform_data *pdata = client->dev.platform_data;
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500461
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700462 tsc2007_free_irq(ts);
Richard Röjfors75fba3b2009-07-24 22:01:39 -0700463
Richard Röjforscad065f2009-07-24 23:14:17 -0700464 if (pdata->exit_platform_hw)
465 pdata->exit_platform_hw();
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700467#ifdef CONFIG_HAS_EARLYSUSPEND
468 unregister_early_suspend(&ts->early_suspend);
469#endif
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500470 input_unregister_device(ts->input);
471 kfree(ts);
472
473 return 0;
474}
475
Márton Némethce7b39a2010-01-09 23:23:02 -0800476static const struct i2c_device_id tsc2007_idtable[] = {
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500477 { "tsc2007", 0 },
478 { }
479};
480
481MODULE_DEVICE_TABLE(i2c, tsc2007_idtable);
482
483static struct i2c_driver tsc2007_driver = {
484 .driver = {
485 .owner = THIS_MODULE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700486 .name = "tsc2007",
487#ifdef CONFIG_PM
488 .pm = &tsc2007_pm_ops,
489#endif
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500490 },
491 .id_table = tsc2007_idtable,
492 .probe = tsc2007_probe,
Dmitry Torokhov141586bc2009-07-24 23:14:16 -0700493 .remove = __devexit_p(tsc2007_remove),
Kwangwoo Lee50b6f1f2008-12-20 04:26:01 -0500494};
495
496static int __init tsc2007_init(void)
497{
498 return i2c_add_driver(&tsc2007_driver);
499}
500
501static void __exit tsc2007_exit(void)
502{
503 i2c_del_driver(&tsc2007_driver);
504}
505
506module_init(tsc2007_init);
507module_exit(tsc2007_exit);
508
509MODULE_AUTHOR("Kwangwoo Lee <kwlee@mtekvision.com>");
510MODULE_DESCRIPTION("TSC2007 TouchScreen Driver");
511MODULE_LICENSE("GPL");