blob: ae00604a6a81d8c1cf37d65823d14eb728e36e3a [file] [log] [blame]
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001/*
Iiro Valkonen7686b102011-02-02 23:21:58 -08002 * Atmel maXTouch Touchscreen driver
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07003 *
4 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/firmware.h>
18#include <linux/i2c.h>
Dmitry Torokhov964de522011-02-02 23:21:58 -080019#include <linux/i2c/atmel_mxt_ts.h>
Joonyoung Shim8b86c1c2011-04-12 23:18:59 -070020#include <linux/input/mt.h>
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070021#include <linux/interrupt.h>
22#include <linux/slab.h>
23
24/* Version */
Iiro Valkonen7686b102011-02-02 23:21:58 -080025#define MXT_VER_20 20
26#define MXT_VER_21 21
27#define MXT_VER_22 22
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070028
29/* Slave addresses */
Iiro Valkonen7686b102011-02-02 23:21:58 -080030#define MXT_APP_LOW 0x4a
31#define MXT_APP_HIGH 0x4b
32#define MXT_BOOT_LOW 0x24
33#define MXT_BOOT_HIGH 0x25
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070034
35/* Firmware */
Iiro Valkonen7686b102011-02-02 23:21:58 -080036#define MXT_FW_NAME "maxtouch.fw"
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070037
38/* Registers */
Iiro Valkonen7686b102011-02-02 23:21:58 -080039#define MXT_FAMILY_ID 0x00
40#define MXT_VARIANT_ID 0x01
41#define MXT_VERSION 0x02
42#define MXT_BUILD 0x03
43#define MXT_MATRIX_X_SIZE 0x04
44#define MXT_MATRIX_Y_SIZE 0x05
45#define MXT_OBJECT_NUM 0x06
46#define MXT_OBJECT_START 0x07
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070047
Iiro Valkonen7686b102011-02-02 23:21:58 -080048#define MXT_OBJECT_SIZE 6
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070049
50/* Object types */
Iiro Valkonen81c88a72011-07-04 03:08:25 -070051#define MXT_DEBUG_DIAGNOSTIC_T37 37
52#define MXT_GEN_MESSAGE_T5 5
53#define MXT_GEN_COMMAND_T6 6
54#define MXT_GEN_POWER_T7 7
55#define MXT_GEN_ACQUIRE_T8 8
56#define MXT_GEN_DATASOURCE_T53 53
57#define MXT_TOUCH_MULTI_T9 9
58#define MXT_TOUCH_KEYARRAY_T15 15
59#define MXT_TOUCH_PROXIMITY_T23 23
60#define MXT_TOUCH_PROXKEY_T52 52
61#define MXT_PROCI_GRIPFACE_T20 20
62#define MXT_PROCG_NOISE_T22 22
63#define MXT_PROCI_ONETOUCH_T24 24
64#define MXT_PROCI_TWOTOUCH_T27 27
65#define MXT_PROCI_GRIP_T40 40
66#define MXT_PROCI_PALM_T41 41
67#define MXT_PROCI_TOUCHSUPPRESSION_T42 42
68#define MXT_PROCI_STYLUS_T47 47
69#define MXT_PROCG_NOISESUPPRESSION_T48 48
70#define MXT_SPT_COMMSCONFIG_T18 18
71#define MXT_SPT_GPIOPWM_T19 19
72#define MXT_SPT_SELFTEST_T25 25
73#define MXT_SPT_CTECONFIG_T28 28
74#define MXT_SPT_USERDATA_T38 38
75#define MXT_SPT_DIGITIZER_T43 43
76#define MXT_SPT_MESSAGECOUNT_T44 44
77#define MXT_SPT_CTECONFIG_T46 46
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070078
Iiro Valkonen81c88a72011-07-04 03:08:25 -070079/* MXT_GEN_COMMAND_T6 field */
Iiro Valkonen7686b102011-02-02 23:21:58 -080080#define MXT_COMMAND_RESET 0
81#define MXT_COMMAND_BACKUPNV 1
82#define MXT_COMMAND_CALIBRATE 2
83#define MXT_COMMAND_REPORTALL 3
84#define MXT_COMMAND_DIAGNOSTIC 5
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070085
Iiro Valkonen81c88a72011-07-04 03:08:25 -070086/* MXT_GEN_POWER_T7 field */
Iiro Valkonen7686b102011-02-02 23:21:58 -080087#define MXT_POWER_IDLEACQINT 0
88#define MXT_POWER_ACTVACQINT 1
89#define MXT_POWER_ACTV2IDLETO 2
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070090
Iiro Valkonen81c88a72011-07-04 03:08:25 -070091/* MXT_GEN_ACQUIRE_T8 field */
Iiro Valkonen7686b102011-02-02 23:21:58 -080092#define MXT_ACQUIRE_CHRGTIME 0
93#define MXT_ACQUIRE_TCHDRIFT 2
94#define MXT_ACQUIRE_DRIFTST 3
95#define MXT_ACQUIRE_TCHAUTOCAL 4
96#define MXT_ACQUIRE_SYNC 5
97#define MXT_ACQUIRE_ATCHCALST 6
98#define MXT_ACQUIRE_ATCHCALSTHR 7
Joonyoung Shim4cf51c32010-07-14 21:55:30 -070099
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700100/* MXT_TOUCH_MULTI_T9 field */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800101#define MXT_TOUCH_CTRL 0
102#define MXT_TOUCH_XORIGIN 1
103#define MXT_TOUCH_YORIGIN 2
104#define MXT_TOUCH_XSIZE 3
105#define MXT_TOUCH_YSIZE 4
106#define MXT_TOUCH_BLEN 6
107#define MXT_TOUCH_TCHTHR 7
108#define MXT_TOUCH_TCHDI 8
109#define MXT_TOUCH_ORIENT 9
110#define MXT_TOUCH_MOVHYSTI 11
111#define MXT_TOUCH_MOVHYSTN 12
112#define MXT_TOUCH_NUMTOUCH 14
113#define MXT_TOUCH_MRGHYST 15
114#define MXT_TOUCH_MRGTHR 16
115#define MXT_TOUCH_AMPHYST 17
116#define MXT_TOUCH_XRANGE_LSB 18
117#define MXT_TOUCH_XRANGE_MSB 19
118#define MXT_TOUCH_YRANGE_LSB 20
119#define MXT_TOUCH_YRANGE_MSB 21
120#define MXT_TOUCH_XLOCLIP 22
121#define MXT_TOUCH_XHICLIP 23
122#define MXT_TOUCH_YLOCLIP 24
123#define MXT_TOUCH_YHICLIP 25
124#define MXT_TOUCH_XEDGECTRL 26
125#define MXT_TOUCH_XEDGEDIST 27
126#define MXT_TOUCH_YEDGECTRL 28
127#define MXT_TOUCH_YEDGEDIST 29
Joonyoung Shim979a72d2011-03-14 21:41:34 -0700128#define MXT_TOUCH_JUMPLIMIT 30
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700129
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700130/* MXT_PROCI_GRIPFACE_T20 field */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800131#define MXT_GRIPFACE_CTRL 0
132#define MXT_GRIPFACE_XLOGRIP 1
133#define MXT_GRIPFACE_XHIGRIP 2
134#define MXT_GRIPFACE_YLOGRIP 3
135#define MXT_GRIPFACE_YHIGRIP 4
136#define MXT_GRIPFACE_MAXTCHS 5
137#define MXT_GRIPFACE_SZTHR1 7
138#define MXT_GRIPFACE_SZTHR2 8
139#define MXT_GRIPFACE_SHPTHR1 9
140#define MXT_GRIPFACE_SHPTHR2 10
141#define MXT_GRIPFACE_SUPEXTTO 11
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700142
Iiro Valkonen7686b102011-02-02 23:21:58 -0800143/* MXT_PROCI_NOISE field */
144#define MXT_NOISE_CTRL 0
145#define MXT_NOISE_OUTFLEN 1
146#define MXT_NOISE_GCAFUL_LSB 3
147#define MXT_NOISE_GCAFUL_MSB 4
148#define MXT_NOISE_GCAFLL_LSB 5
149#define MXT_NOISE_GCAFLL_MSB 6
150#define MXT_NOISE_ACTVGCAFVALID 7
151#define MXT_NOISE_NOISETHR 8
152#define MXT_NOISE_FREQHOPSCALE 10
153#define MXT_NOISE_FREQ0 11
154#define MXT_NOISE_FREQ1 12
155#define MXT_NOISE_FREQ2 13
156#define MXT_NOISE_FREQ3 14
157#define MXT_NOISE_FREQ4 15
158#define MXT_NOISE_IDLEGCAFVALID 16
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700159
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700160/* MXT_SPT_COMMSCONFIG_T18 */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800161#define MXT_COMMS_CTRL 0
162#define MXT_COMMS_CMD 1
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700163
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700164/* MXT_SPT_CTECONFIG_T28 field */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800165#define MXT_CTE_CTRL 0
166#define MXT_CTE_CMD 1
167#define MXT_CTE_MODE 2
168#define MXT_CTE_IDLEGCAFDEPTH 3
169#define MXT_CTE_ACTVGCAFDEPTH 4
Joonyoung Shim979a72d2011-03-14 21:41:34 -0700170#define MXT_CTE_VOLTAGE 5
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700171
Iiro Valkonen7686b102011-02-02 23:21:58 -0800172#define MXT_VOLTAGE_DEFAULT 2700000
173#define MXT_VOLTAGE_STEP 10000
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700174
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700175/* Define for MXT_GEN_COMMAND_T6 */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800176#define MXT_BOOT_VALUE 0xa5
177#define MXT_BACKUP_VALUE 0x55
178#define MXT_BACKUP_TIME 25 /* msec */
179#define MXT_RESET_TIME 65 /* msec */
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700180
Iiro Valkonen7686b102011-02-02 23:21:58 -0800181#define MXT_FWRESET_TIME 175 /* msec */
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700182
183/* Command to unlock bootloader */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800184#define MXT_UNLOCK_CMD_MSB 0xaa
185#define MXT_UNLOCK_CMD_LSB 0xdc
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700186
187/* Bootloader mode status */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800188#define MXT_WAITING_BOOTLOAD_CMD 0xc0 /* valid 7 6 bit only */
189#define MXT_WAITING_FRAME_DATA 0x80 /* valid 7 6 bit only */
190#define MXT_FRAME_CRC_CHECK 0x02
191#define MXT_FRAME_CRC_FAIL 0x03
192#define MXT_FRAME_CRC_PASS 0x04
193#define MXT_APP_CRC_FAIL 0x40 /* valid 7 8 bit only */
194#define MXT_BOOT_STATUS_MASK 0x3f
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700195
196/* Touch status */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800197#define MXT_SUPPRESS (1 << 1)
198#define MXT_AMP (1 << 2)
199#define MXT_VECTOR (1 << 3)
200#define MXT_MOVE (1 << 4)
201#define MXT_RELEASE (1 << 5)
202#define MXT_PRESS (1 << 6)
203#define MXT_DETECT (1 << 7)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700204
Joonyoung Shim910d8052011-04-12 23:14:38 -0700205/* Touch orient bits */
206#define MXT_XY_SWITCH (1 << 0)
207#define MXT_X_INVERT (1 << 1)
208#define MXT_Y_INVERT (1 << 2)
209
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700210/* Touchscreen absolute values */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800211#define MXT_MAX_AREA 0xff
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700212
Iiro Valkonen7686b102011-02-02 23:21:58 -0800213#define MXT_MAX_FINGER 10
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700214
Iiro Valkonen7686b102011-02-02 23:21:58 -0800215struct mxt_info {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700216 u8 family_id;
217 u8 variant_id;
218 u8 version;
219 u8 build;
220 u8 matrix_xsize;
221 u8 matrix_ysize;
222 u8 object_num;
223};
224
Iiro Valkonen7686b102011-02-02 23:21:58 -0800225struct mxt_object {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700226 u8 type;
227 u16 start_address;
228 u8 size;
229 u8 instances;
230 u8 num_report_ids;
231
232 /* to map object and message */
233 u8 max_reportid;
234};
235
Iiro Valkonen7686b102011-02-02 23:21:58 -0800236struct mxt_message {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700237 u8 reportid;
238 u8 message[7];
239 u8 checksum;
240};
241
Iiro Valkonen7686b102011-02-02 23:21:58 -0800242struct mxt_finger {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700243 int status;
244 int x;
245 int y;
246 int area;
247};
248
249/* Each client has this additional data */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800250struct mxt_data {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700251 struct i2c_client *client;
252 struct input_dev *input_dev;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800253 const struct mxt_platform_data *pdata;
254 struct mxt_object *object_table;
255 struct mxt_info info;
256 struct mxt_finger finger[MXT_MAX_FINGER];
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700257 unsigned int irq;
Joonyoung Shim910d8052011-04-12 23:14:38 -0700258 unsigned int max_x;
259 unsigned int max_y;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700260};
261
Iiro Valkonen7686b102011-02-02 23:21:58 -0800262static bool mxt_object_readable(unsigned int type)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700263{
264 switch (type) {
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700265 case MXT_GEN_MESSAGE_T5:
266 case MXT_GEN_COMMAND_T6:
267 case MXT_GEN_POWER_T7:
268 case MXT_GEN_ACQUIRE_T8:
269 case MXT_GEN_DATASOURCE_T53:
270 case MXT_TOUCH_MULTI_T9:
271 case MXT_TOUCH_KEYARRAY_T15:
272 case MXT_TOUCH_PROXIMITY_T23:
273 case MXT_TOUCH_PROXKEY_T52:
274 case MXT_PROCI_GRIPFACE_T20:
275 case MXT_PROCG_NOISE_T22:
276 case MXT_PROCI_ONETOUCH_T24:
277 case MXT_PROCI_TWOTOUCH_T27:
278 case MXT_PROCI_GRIP_T40:
279 case MXT_PROCI_PALM_T41:
280 case MXT_PROCI_TOUCHSUPPRESSION_T42:
281 case MXT_PROCI_STYLUS_T47:
282 case MXT_PROCG_NOISESUPPRESSION_T48:
283 case MXT_SPT_COMMSCONFIG_T18:
284 case MXT_SPT_GPIOPWM_T19:
285 case MXT_SPT_SELFTEST_T25:
286 case MXT_SPT_CTECONFIG_T28:
287 case MXT_SPT_USERDATA_T38:
288 case MXT_SPT_DIGITIZER_T43:
289 case MXT_SPT_CTECONFIG_T46:
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700290 return true;
291 default:
292 return false;
293 }
294}
295
Iiro Valkonen7686b102011-02-02 23:21:58 -0800296static bool mxt_object_writable(unsigned int type)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700297{
298 switch (type) {
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700299 case MXT_GEN_COMMAND_T6:
300 case MXT_GEN_POWER_T7:
301 case MXT_GEN_ACQUIRE_T8:
302 case MXT_TOUCH_MULTI_T9:
303 case MXT_TOUCH_KEYARRAY_T15:
304 case MXT_TOUCH_PROXIMITY_T23:
305 case MXT_TOUCH_PROXKEY_T52:
306 case MXT_PROCI_GRIPFACE_T20:
307 case MXT_PROCG_NOISE_T22:
308 case MXT_PROCI_ONETOUCH_T24:
309 case MXT_PROCI_TWOTOUCH_T27:
310 case MXT_PROCI_GRIP_T40:
311 case MXT_PROCI_PALM_T41:
312 case MXT_PROCI_TOUCHSUPPRESSION_T42:
313 case MXT_PROCI_STYLUS_T47:
314 case MXT_PROCG_NOISESUPPRESSION_T48:
315 case MXT_SPT_COMMSCONFIG_T18:
316 case MXT_SPT_GPIOPWM_T19:
317 case MXT_SPT_SELFTEST_T25:
318 case MXT_SPT_CTECONFIG_T28:
319 case MXT_SPT_DIGITIZER_T43:
320 case MXT_SPT_CTECONFIG_T46:
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700321 return true;
322 default:
323 return false;
324 }
325}
326
Iiro Valkonen7686b102011-02-02 23:21:58 -0800327static void mxt_dump_message(struct device *dev,
328 struct mxt_message *message)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700329{
330 dev_dbg(dev, "reportid:\t0x%x\n", message->reportid);
331 dev_dbg(dev, "message1:\t0x%x\n", message->message[0]);
332 dev_dbg(dev, "message2:\t0x%x\n", message->message[1]);
333 dev_dbg(dev, "message3:\t0x%x\n", message->message[2]);
334 dev_dbg(dev, "message4:\t0x%x\n", message->message[3]);
335 dev_dbg(dev, "message5:\t0x%x\n", message->message[4]);
336 dev_dbg(dev, "message6:\t0x%x\n", message->message[5]);
337 dev_dbg(dev, "message7:\t0x%x\n", message->message[6]);
338 dev_dbg(dev, "checksum:\t0x%x\n", message->checksum);
339}
340
Iiro Valkonen7686b102011-02-02 23:21:58 -0800341static int mxt_check_bootloader(struct i2c_client *client,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700342 unsigned int state)
343{
344 u8 val;
345
346recheck:
347 if (i2c_master_recv(client, &val, 1) != 1) {
348 dev_err(&client->dev, "%s: i2c recv failed\n", __func__);
349 return -EIO;
350 }
351
352 switch (state) {
Iiro Valkonen7686b102011-02-02 23:21:58 -0800353 case MXT_WAITING_BOOTLOAD_CMD:
354 case MXT_WAITING_FRAME_DATA:
355 val &= ~MXT_BOOT_STATUS_MASK;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700356 break;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800357 case MXT_FRAME_CRC_PASS:
358 if (val == MXT_FRAME_CRC_CHECK)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700359 goto recheck;
360 break;
361 default:
362 return -EINVAL;
363 }
364
365 if (val != state) {
366 dev_err(&client->dev, "Unvalid bootloader mode state\n");
367 return -EINVAL;
368 }
369
370 return 0;
371}
372
Iiro Valkonen7686b102011-02-02 23:21:58 -0800373static int mxt_unlock_bootloader(struct i2c_client *client)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700374{
375 u8 buf[2];
376
Iiro Valkonen7686b102011-02-02 23:21:58 -0800377 buf[0] = MXT_UNLOCK_CMD_LSB;
378 buf[1] = MXT_UNLOCK_CMD_MSB;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700379
380 if (i2c_master_send(client, buf, 2) != 2) {
381 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
382 return -EIO;
383 }
384
385 return 0;
386}
387
Iiro Valkonen7686b102011-02-02 23:21:58 -0800388static int mxt_fw_write(struct i2c_client *client,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700389 const u8 *data, unsigned int frame_size)
390{
391 if (i2c_master_send(client, data, frame_size) != frame_size) {
392 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
393 return -EIO;
394 }
395
396 return 0;
397}
398
Iiro Valkonen7686b102011-02-02 23:21:58 -0800399static int __mxt_read_reg(struct i2c_client *client,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700400 u16 reg, u16 len, void *val)
401{
402 struct i2c_msg xfer[2];
403 u8 buf[2];
404
405 buf[0] = reg & 0xff;
406 buf[1] = (reg >> 8) & 0xff;
407
408 /* Write register */
409 xfer[0].addr = client->addr;
410 xfer[0].flags = 0;
411 xfer[0].len = 2;
412 xfer[0].buf = buf;
413
414 /* Read data */
415 xfer[1].addr = client->addr;
416 xfer[1].flags = I2C_M_RD;
417 xfer[1].len = len;
418 xfer[1].buf = val;
419
420 if (i2c_transfer(client->adapter, xfer, 2) != 2) {
421 dev_err(&client->dev, "%s: i2c transfer failed\n", __func__);
422 return -EIO;
423 }
424
425 return 0;
426}
427
Iiro Valkonen7686b102011-02-02 23:21:58 -0800428static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700429{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800430 return __mxt_read_reg(client, reg, 1, val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700431}
432
Iiro Valkonen7686b102011-02-02 23:21:58 -0800433static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700434{
435 u8 buf[3];
436
437 buf[0] = reg & 0xff;
438 buf[1] = (reg >> 8) & 0xff;
439 buf[2] = val;
440
441 if (i2c_master_send(client, buf, 3) != 3) {
442 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
443 return -EIO;
444 }
445
446 return 0;
447}
448
Iiro Valkonen7686b102011-02-02 23:21:58 -0800449static int mxt_read_object_table(struct i2c_client *client,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700450 u16 reg, u8 *object_buf)
451{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800452 return __mxt_read_reg(client, reg, MXT_OBJECT_SIZE,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700453 object_buf);
454}
455
Iiro Valkonen7686b102011-02-02 23:21:58 -0800456static struct mxt_object *
457mxt_get_object(struct mxt_data *data, u8 type)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700458{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800459 struct mxt_object *object;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700460 int i;
461
462 for (i = 0; i < data->info.object_num; i++) {
463 object = data->object_table + i;
464 if (object->type == type)
465 return object;
466 }
467
468 dev_err(&data->client->dev, "Invalid object type\n");
469 return NULL;
470}
471
Iiro Valkonen7686b102011-02-02 23:21:58 -0800472static int mxt_read_message(struct mxt_data *data,
473 struct mxt_message *message)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700474{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800475 struct mxt_object *object;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700476 u16 reg;
477
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700478 object = mxt_get_object(data, MXT_GEN_MESSAGE_T5);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700479 if (!object)
480 return -EINVAL;
481
482 reg = object->start_address;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800483 return __mxt_read_reg(data->client, reg,
484 sizeof(struct mxt_message), message);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700485}
486
Iiro Valkonen7686b102011-02-02 23:21:58 -0800487static int mxt_read_object(struct mxt_data *data,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700488 u8 type, u8 offset, u8 *val)
489{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800490 struct mxt_object *object;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700491 u16 reg;
492
Iiro Valkonen7686b102011-02-02 23:21:58 -0800493 object = mxt_get_object(data, type);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700494 if (!object)
495 return -EINVAL;
496
497 reg = object->start_address;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800498 return __mxt_read_reg(data->client, reg + offset, 1, val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700499}
500
Iiro Valkonen7686b102011-02-02 23:21:58 -0800501static int mxt_write_object(struct mxt_data *data,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700502 u8 type, u8 offset, u8 val)
503{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800504 struct mxt_object *object;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700505 u16 reg;
506
Iiro Valkonen7686b102011-02-02 23:21:58 -0800507 object = mxt_get_object(data, type);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700508 if (!object)
509 return -EINVAL;
510
511 reg = object->start_address;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800512 return mxt_write_reg(data->client, reg + offset, val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700513}
514
Iiro Valkonen7686b102011-02-02 23:21:58 -0800515static void mxt_input_report(struct mxt_data *data, int single_id)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700516{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800517 struct mxt_finger *finger = data->finger;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700518 struct input_dev *input_dev = data->input_dev;
519 int status = finger[single_id].status;
520 int finger_num = 0;
521 int id;
522
Iiro Valkonen7686b102011-02-02 23:21:58 -0800523 for (id = 0; id < MXT_MAX_FINGER; id++) {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700524 if (!finger[id].status)
525 continue;
526
Joonyoung Shim8b86c1c2011-04-12 23:18:59 -0700527 input_mt_slot(input_dev, id);
528 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER,
529 finger[id].status != MXT_RELEASE);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700530
Joonyoung Shim8b86c1c2011-04-12 23:18:59 -0700531 if (finger[id].status != MXT_RELEASE) {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700532 finger_num++;
Joonyoung Shim8b86c1c2011-04-12 23:18:59 -0700533 input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
534 finger[id].area);
535 input_report_abs(input_dev, ABS_MT_POSITION_X,
536 finger[id].x);
537 input_report_abs(input_dev, ABS_MT_POSITION_Y,
538 finger[id].y);
539 } else {
540 finger[id].status = 0;
541 }
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700542 }
543
544 input_report_key(input_dev, BTN_TOUCH, finger_num > 0);
545
Iiro Valkonen7686b102011-02-02 23:21:58 -0800546 if (status != MXT_RELEASE) {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700547 input_report_abs(input_dev, ABS_X, finger[single_id].x);
548 input_report_abs(input_dev, ABS_Y, finger[single_id].y);
549 }
550
551 input_sync(input_dev);
552}
553
Iiro Valkonen7686b102011-02-02 23:21:58 -0800554static void mxt_input_touchevent(struct mxt_data *data,
555 struct mxt_message *message, int id)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700556{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800557 struct mxt_finger *finger = data->finger;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700558 struct device *dev = &data->client->dev;
559 u8 status = message->message[0];
560 int x;
561 int y;
562 int area;
563
564 /* Check the touch is present on the screen */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800565 if (!(status & MXT_DETECT)) {
566 if (status & MXT_RELEASE) {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700567 dev_dbg(dev, "[%d] released\n", id);
568
Iiro Valkonen7686b102011-02-02 23:21:58 -0800569 finger[id].status = MXT_RELEASE;
570 mxt_input_report(data, id);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700571 }
572 return;
573 }
574
575 /* Check only AMP detection */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800576 if (!(status & (MXT_PRESS | MXT_MOVE)))
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700577 return;
578
Joonyoung Shim910d8052011-04-12 23:14:38 -0700579 x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf);
580 y = (message->message[2] << 4) | ((message->message[3] & 0xf));
581 if (data->max_x < 1024)
582 x = x >> 2;
583 if (data->max_y < 1024)
584 y = y >> 2;
585
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700586 area = message->message[4];
587
588 dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800589 status & MXT_MOVE ? "moved" : "pressed",
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700590 x, y, area);
591
Iiro Valkonen7686b102011-02-02 23:21:58 -0800592 finger[id].status = status & MXT_MOVE ?
593 MXT_MOVE : MXT_PRESS;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700594 finger[id].x = x;
595 finger[id].y = y;
596 finger[id].area = area;
597
Iiro Valkonen7686b102011-02-02 23:21:58 -0800598 mxt_input_report(data, id);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700599}
600
Iiro Valkonen7686b102011-02-02 23:21:58 -0800601static irqreturn_t mxt_interrupt(int irq, void *dev_id)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700602{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800603 struct mxt_data *data = dev_id;
604 struct mxt_message message;
605 struct mxt_object *object;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700606 struct device *dev = &data->client->dev;
607 int id;
608 u8 reportid;
609 u8 max_reportid;
610 u8 min_reportid;
611
612 do {
Iiro Valkonen7686b102011-02-02 23:21:58 -0800613 if (mxt_read_message(data, &message)) {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700614 dev_err(dev, "Failed to read message\n");
615 goto end;
616 }
617
618 reportid = message.reportid;
619
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700620 /* whether reportid is thing of MXT_TOUCH_MULTI_T9 */
621 object = mxt_get_object(data, MXT_TOUCH_MULTI_T9);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700622 if (!object)
623 goto end;
624
625 max_reportid = object->max_reportid;
626 min_reportid = max_reportid - object->num_report_ids + 1;
627 id = reportid - min_reportid;
628
629 if (reportid >= min_reportid && reportid <= max_reportid)
Iiro Valkonen7686b102011-02-02 23:21:58 -0800630 mxt_input_touchevent(data, &message, id);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700631 else
Iiro Valkonen7686b102011-02-02 23:21:58 -0800632 mxt_dump_message(dev, &message);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700633 } while (reportid != 0xff);
634
635end:
636 return IRQ_HANDLED;
637}
638
Iiro Valkonen7686b102011-02-02 23:21:58 -0800639static int mxt_check_reg_init(struct mxt_data *data)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700640{
Iiro Valkonen71749f52011-02-15 13:36:52 -0800641 const struct mxt_platform_data *pdata = data->pdata;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800642 struct mxt_object *object;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700643 struct device *dev = &data->client->dev;
644 int index = 0;
Iiro Valkonen71749f52011-02-15 13:36:52 -0800645 int i, j, config_offset;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700646
Iiro Valkonen71749f52011-02-15 13:36:52 -0800647 if (!pdata->config) {
648 dev_dbg(dev, "No cfg data defined, skipping reg init\n");
649 return 0;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700650 }
651
652 for (i = 0; i < data->info.object_num; i++) {
653 object = data->object_table + i;
654
Iiro Valkonen7686b102011-02-02 23:21:58 -0800655 if (!mxt_object_writable(object->type))
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700656 continue;
657
Iiro Valkonena93d4f22011-07-04 03:16:25 -0700658 for (j = 0;
659 j < (object->size + 1) * (object->instances + 1);
660 j++) {
Iiro Valkonen71749f52011-02-15 13:36:52 -0800661 config_offset = index + j;
662 if (config_offset > pdata->config_length) {
663 dev_err(dev, "Not enough config data!\n");
664 return -EINVAL;
665 }
Iiro Valkonen7686b102011-02-02 23:21:58 -0800666 mxt_write_object(data, object->type, j,
Iiro Valkonen71749f52011-02-15 13:36:52 -0800667 pdata->config[config_offset]);
668 }
Iiro Valkonena93d4f22011-07-04 03:16:25 -0700669 index += (object->size + 1) * (object->instances + 1);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700670 }
671
672 return 0;
673}
674
Iiro Valkonen7686b102011-02-02 23:21:58 -0800675static int mxt_make_highchg(struct mxt_data *data)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700676{
677 struct device *dev = &data->client->dev;
Iiro Valkonen26cdb1a2011-02-04 00:51:05 -0800678 struct mxt_message message;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700679 int count = 10;
680 int error;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700681
682 /* Read dummy message to make high CHG pin */
683 do {
Iiro Valkonen26cdb1a2011-02-04 00:51:05 -0800684 error = mxt_read_message(data, &message);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700685 if (error)
686 return error;
Iiro Valkonen26cdb1a2011-02-04 00:51:05 -0800687 } while (message.reportid != 0xff && --count);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700688
689 if (!count) {
690 dev_err(dev, "CHG pin isn't cleared\n");
691 return -EBUSY;
692 }
693
694 return 0;
695}
696
Iiro Valkonen7686b102011-02-02 23:21:58 -0800697static void mxt_handle_pdata(struct mxt_data *data)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700698{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800699 const struct mxt_platform_data *pdata = data->pdata;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700700 u8 voltage;
701
702 /* Set touchscreen lines */
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700703 mxt_write_object(data, MXT_TOUCH_MULTI_T9, MXT_TOUCH_XSIZE,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700704 pdata->x_line);
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700705 mxt_write_object(data, MXT_TOUCH_MULTI_T9, MXT_TOUCH_YSIZE,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700706 pdata->y_line);
707
708 /* Set touchscreen orient */
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700709 mxt_write_object(data, MXT_TOUCH_MULTI_T9, MXT_TOUCH_ORIENT,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700710 pdata->orient);
711
712 /* Set touchscreen burst length */
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700713 mxt_write_object(data, MXT_TOUCH_MULTI_T9,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800714 MXT_TOUCH_BLEN, pdata->blen);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700715
716 /* Set touchscreen threshold */
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700717 mxt_write_object(data, MXT_TOUCH_MULTI_T9,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800718 MXT_TOUCH_TCHTHR, pdata->threshold);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700719
720 /* Set touchscreen resolution */
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700721 mxt_write_object(data, MXT_TOUCH_MULTI_T9,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800722 MXT_TOUCH_XRANGE_LSB, (pdata->x_size - 1) & 0xff);
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700723 mxt_write_object(data, MXT_TOUCH_MULTI_T9,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800724 MXT_TOUCH_XRANGE_MSB, (pdata->x_size - 1) >> 8);
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700725 mxt_write_object(data, MXT_TOUCH_MULTI_T9,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800726 MXT_TOUCH_YRANGE_LSB, (pdata->y_size - 1) & 0xff);
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700727 mxt_write_object(data, MXT_TOUCH_MULTI_T9,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800728 MXT_TOUCH_YRANGE_MSB, (pdata->y_size - 1) >> 8);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700729
730 /* Set touchscreen voltage */
Joonyoung Shim979a72d2011-03-14 21:41:34 -0700731 if (pdata->voltage) {
Iiro Valkonen7686b102011-02-02 23:21:58 -0800732 if (pdata->voltage < MXT_VOLTAGE_DEFAULT) {
733 voltage = (MXT_VOLTAGE_DEFAULT - pdata->voltage) /
734 MXT_VOLTAGE_STEP;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700735 voltage = 0xff - voltage + 1;
736 } else
Iiro Valkonen7686b102011-02-02 23:21:58 -0800737 voltage = (pdata->voltage - MXT_VOLTAGE_DEFAULT) /
738 MXT_VOLTAGE_STEP;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700739
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700740 mxt_write_object(data, MXT_SPT_CTECONFIG_T28,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800741 MXT_CTE_VOLTAGE, voltage);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700742 }
743}
744
Iiro Valkonen7686b102011-02-02 23:21:58 -0800745static int mxt_get_info(struct mxt_data *data)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700746{
747 struct i2c_client *client = data->client;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800748 struct mxt_info *info = &data->info;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700749 int error;
750 u8 val;
751
Iiro Valkonen7686b102011-02-02 23:21:58 -0800752 error = mxt_read_reg(client, MXT_FAMILY_ID, &val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700753 if (error)
754 return error;
755 info->family_id = val;
756
Iiro Valkonen7686b102011-02-02 23:21:58 -0800757 error = mxt_read_reg(client, MXT_VARIANT_ID, &val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700758 if (error)
759 return error;
760 info->variant_id = val;
761
Iiro Valkonen7686b102011-02-02 23:21:58 -0800762 error = mxt_read_reg(client, MXT_VERSION, &val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700763 if (error)
764 return error;
765 info->version = val;
766
Iiro Valkonen7686b102011-02-02 23:21:58 -0800767 error = mxt_read_reg(client, MXT_BUILD, &val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700768 if (error)
769 return error;
770 info->build = val;
771
Iiro Valkonen7686b102011-02-02 23:21:58 -0800772 error = mxt_read_reg(client, MXT_OBJECT_NUM, &val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700773 if (error)
774 return error;
775 info->object_num = val;
776
777 return 0;
778}
779
Iiro Valkonen7686b102011-02-02 23:21:58 -0800780static int mxt_get_object_table(struct mxt_data *data)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700781{
782 int error;
783 int i;
784 u16 reg;
785 u8 reportid = 0;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800786 u8 buf[MXT_OBJECT_SIZE];
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700787
788 for (i = 0; i < data->info.object_num; i++) {
Iiro Valkonen7686b102011-02-02 23:21:58 -0800789 struct mxt_object *object = data->object_table + i;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700790
Iiro Valkonen7686b102011-02-02 23:21:58 -0800791 reg = MXT_OBJECT_START + MXT_OBJECT_SIZE * i;
792 error = mxt_read_object_table(data->client, reg, buf);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700793 if (error)
794 return error;
795
796 object->type = buf[0];
797 object->start_address = (buf[2] << 8) | buf[1];
798 object->size = buf[3];
799 object->instances = buf[4];
800 object->num_report_ids = buf[5];
801
802 if (object->num_report_ids) {
803 reportid += object->num_report_ids *
804 (object->instances + 1);
805 object->max_reportid = reportid;
806 }
807 }
808
809 return 0;
810}
811
Iiro Valkonen7686b102011-02-02 23:21:58 -0800812static int mxt_initialize(struct mxt_data *data)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700813{
814 struct i2c_client *client = data->client;
Iiro Valkonen7686b102011-02-02 23:21:58 -0800815 struct mxt_info *info = &data->info;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700816 int error;
817 u8 val;
818
Iiro Valkonen7686b102011-02-02 23:21:58 -0800819 error = mxt_get_info(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700820 if (error)
821 return error;
822
823 data->object_table = kcalloc(info->object_num,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800824 sizeof(struct mxt_object),
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700825 GFP_KERNEL);
826 if (!data->object_table) {
827 dev_err(&client->dev, "Failed to allocate memory\n");
828 return -ENOMEM;
829 }
830
831 /* Get object table information */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800832 error = mxt_get_object_table(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700833 if (error)
834 return error;
835
836 /* Check register init values */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800837 error = mxt_check_reg_init(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700838 if (error)
839 return error;
840
Iiro Valkonen7686b102011-02-02 23:21:58 -0800841 mxt_handle_pdata(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700842
843 /* Backup to memory */
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700844 mxt_write_object(data, MXT_GEN_COMMAND_T6,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800845 MXT_COMMAND_BACKUPNV,
846 MXT_BACKUP_VALUE);
847 msleep(MXT_BACKUP_TIME);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700848
849 /* Soft reset */
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700850 mxt_write_object(data, MXT_GEN_COMMAND_T6,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800851 MXT_COMMAND_RESET, 1);
852 msleep(MXT_RESET_TIME);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700853
854 /* Update matrix size at info struct */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800855 error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700856 if (error)
857 return error;
858 info->matrix_xsize = val;
859
Iiro Valkonen7686b102011-02-02 23:21:58 -0800860 error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700861 if (error)
862 return error;
863 info->matrix_ysize = val;
864
865 dev_info(&client->dev,
866 "Family ID: %d Variant ID: %d Version: %d Build: %d\n",
867 info->family_id, info->variant_id, info->version,
868 info->build);
869
870 dev_info(&client->dev,
871 "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
872 info->matrix_xsize, info->matrix_ysize,
873 info->object_num);
874
875 return 0;
876}
877
Joonyoung Shim910d8052011-04-12 23:14:38 -0700878static void mxt_calc_resolution(struct mxt_data *data)
879{
880 unsigned int max_x = data->pdata->x_size - 1;
881 unsigned int max_y = data->pdata->y_size - 1;
882
883 if (data->pdata->orient & MXT_XY_SWITCH) {
884 data->max_x = max_y;
885 data->max_y = max_x;
886 } else {
887 data->max_x = max_x;
888 data->max_y = max_y;
889 }
890}
891
Iiro Valkonen7686b102011-02-02 23:21:58 -0800892static ssize_t mxt_object_show(struct device *dev,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700893 struct device_attribute *attr, char *buf)
894{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800895 struct mxt_data *data = dev_get_drvdata(dev);
896 struct mxt_object *object;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700897 int count = 0;
898 int i, j;
899 int error;
900 u8 val;
901
902 for (i = 0; i < data->info.object_num; i++) {
903 object = data->object_table + i;
904
905 count += sprintf(buf + count,
906 "Object Table Element %d(Type %d)\n",
907 i + 1, object->type);
908
Iiro Valkonen7686b102011-02-02 23:21:58 -0800909 if (!mxt_object_readable(object->type)) {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700910 count += sprintf(buf + count, "\n");
911 continue;
912 }
913
914 for (j = 0; j < object->size + 1; j++) {
Iiro Valkonen7686b102011-02-02 23:21:58 -0800915 error = mxt_read_object(data,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700916 object->type, j, &val);
917 if (error)
918 return error;
919
920 count += sprintf(buf + count,
921 " Byte %d: 0x%x (%d)\n", j, val, val);
922 }
923
924 count += sprintf(buf + count, "\n");
925 }
926
927 return count;
928}
929
Iiro Valkonen7686b102011-02-02 23:21:58 -0800930static int mxt_load_fw(struct device *dev, const char *fn)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700931{
Iiro Valkonen7686b102011-02-02 23:21:58 -0800932 struct mxt_data *data = dev_get_drvdata(dev);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700933 struct i2c_client *client = data->client;
934 const struct firmware *fw = NULL;
935 unsigned int frame_size;
936 unsigned int pos = 0;
937 int ret;
938
939 ret = request_firmware(&fw, fn, dev);
940 if (ret) {
941 dev_err(dev, "Unable to open firmware %s\n", fn);
942 return ret;
943 }
944
945 /* Change to the bootloader mode */
Iiro Valkonen81c88a72011-07-04 03:08:25 -0700946 mxt_write_object(data, MXT_GEN_COMMAND_T6,
Iiro Valkonen7686b102011-02-02 23:21:58 -0800947 MXT_COMMAND_RESET, MXT_BOOT_VALUE);
948 msleep(MXT_RESET_TIME);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700949
950 /* Change to slave address of bootloader */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800951 if (client->addr == MXT_APP_LOW)
952 client->addr = MXT_BOOT_LOW;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700953 else
Iiro Valkonen7686b102011-02-02 23:21:58 -0800954 client->addr = MXT_BOOT_HIGH;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700955
Iiro Valkonen7686b102011-02-02 23:21:58 -0800956 ret = mxt_check_bootloader(client, MXT_WAITING_BOOTLOAD_CMD);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700957 if (ret)
958 goto out;
959
960 /* Unlock bootloader */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800961 mxt_unlock_bootloader(client);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700962
963 while (pos < fw->size) {
Iiro Valkonen7686b102011-02-02 23:21:58 -0800964 ret = mxt_check_bootloader(client,
965 MXT_WAITING_FRAME_DATA);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700966 if (ret)
967 goto out;
968
969 frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1));
970
971 /* We should add 2 at frame size as the the firmware data is not
972 * included the CRC bytes.
973 */
974 frame_size += 2;
975
976 /* Write one frame to device */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800977 mxt_fw_write(client, fw->data + pos, frame_size);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700978
Iiro Valkonen7686b102011-02-02 23:21:58 -0800979 ret = mxt_check_bootloader(client,
980 MXT_FRAME_CRC_PASS);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700981 if (ret)
982 goto out;
983
984 pos += frame_size;
985
986 dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size);
987 }
988
989out:
990 release_firmware(fw);
991
992 /* Change to slave address of application */
Iiro Valkonen7686b102011-02-02 23:21:58 -0800993 if (client->addr == MXT_BOOT_LOW)
994 client->addr = MXT_APP_LOW;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700995 else
Iiro Valkonen7686b102011-02-02 23:21:58 -0800996 client->addr = MXT_APP_HIGH;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -0700997
998 return ret;
999}
1000
Iiro Valkonen7686b102011-02-02 23:21:58 -08001001static ssize_t mxt_update_fw_store(struct device *dev,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001002 struct device_attribute *attr,
1003 const char *buf, size_t count)
1004{
Iiro Valkonen7686b102011-02-02 23:21:58 -08001005 struct mxt_data *data = dev_get_drvdata(dev);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001006 int error;
1007
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001008 disable_irq(data->irq);
1009
Iiro Valkonen7686b102011-02-02 23:21:58 -08001010 error = mxt_load_fw(dev, MXT_FW_NAME);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001011 if (error) {
1012 dev_err(dev, "The firmware update failed(%d)\n", error);
1013 count = error;
1014 } else {
1015 dev_dbg(dev, "The firmware update succeeded\n");
1016
1017 /* Wait for reset */
Iiro Valkonen7686b102011-02-02 23:21:58 -08001018 msleep(MXT_FWRESET_TIME);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001019
1020 kfree(data->object_table);
1021 data->object_table = NULL;
1022
Iiro Valkonen7686b102011-02-02 23:21:58 -08001023 mxt_initialize(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001024 }
1025
1026 enable_irq(data->irq);
1027
Iiro Valkonen08960a02011-04-12 23:16:40 -07001028 error = mxt_make_highchg(data);
1029 if (error)
1030 return error;
1031
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001032 return count;
1033}
1034
Iiro Valkonen7686b102011-02-02 23:21:58 -08001035static DEVICE_ATTR(object, 0444, mxt_object_show, NULL);
1036static DEVICE_ATTR(update_fw, 0664, NULL, mxt_update_fw_store);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001037
Iiro Valkonen7686b102011-02-02 23:21:58 -08001038static struct attribute *mxt_attrs[] = {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001039 &dev_attr_object.attr,
1040 &dev_attr_update_fw.attr,
1041 NULL
1042};
1043
Iiro Valkonen7686b102011-02-02 23:21:58 -08001044static const struct attribute_group mxt_attr_group = {
1045 .attrs = mxt_attrs,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001046};
1047
Iiro Valkonen7686b102011-02-02 23:21:58 -08001048static void mxt_start(struct mxt_data *data)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001049{
1050 /* Touch enable */
Iiro Valkonen7686b102011-02-02 23:21:58 -08001051 mxt_write_object(data,
Iiro Valkonen81c88a72011-07-04 03:08:25 -07001052 MXT_TOUCH_MULTI_T9, MXT_TOUCH_CTRL, 0x83);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001053}
1054
Iiro Valkonen7686b102011-02-02 23:21:58 -08001055static void mxt_stop(struct mxt_data *data)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001056{
1057 /* Touch disable */
Iiro Valkonen7686b102011-02-02 23:21:58 -08001058 mxt_write_object(data,
Iiro Valkonen81c88a72011-07-04 03:08:25 -07001059 MXT_TOUCH_MULTI_T9, MXT_TOUCH_CTRL, 0);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001060}
1061
Iiro Valkonen7686b102011-02-02 23:21:58 -08001062static int mxt_input_open(struct input_dev *dev)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001063{
Iiro Valkonen7686b102011-02-02 23:21:58 -08001064 struct mxt_data *data = input_get_drvdata(dev);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001065
Iiro Valkonen7686b102011-02-02 23:21:58 -08001066 mxt_start(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001067
1068 return 0;
1069}
1070
Iiro Valkonen7686b102011-02-02 23:21:58 -08001071static void mxt_input_close(struct input_dev *dev)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001072{
Iiro Valkonen7686b102011-02-02 23:21:58 -08001073 struct mxt_data *data = input_get_drvdata(dev);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001074
Iiro Valkonen7686b102011-02-02 23:21:58 -08001075 mxt_stop(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001076}
1077
Iiro Valkonen7686b102011-02-02 23:21:58 -08001078static int __devinit mxt_probe(struct i2c_client *client,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001079 const struct i2c_device_id *id)
1080{
Iiro Valkonen919ed892011-02-15 13:36:52 -08001081 const struct mxt_platform_data *pdata = client->dev.platform_data;
Iiro Valkonen7686b102011-02-02 23:21:58 -08001082 struct mxt_data *data;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001083 struct input_dev *input_dev;
1084 int error;
1085
Iiro Valkonen919ed892011-02-15 13:36:52 -08001086 if (!pdata)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001087 return -EINVAL;
1088
Iiro Valkonen7686b102011-02-02 23:21:58 -08001089 data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001090 input_dev = input_allocate_device();
1091 if (!data || !input_dev) {
1092 dev_err(&client->dev, "Failed to allocate memory\n");
1093 error = -ENOMEM;
1094 goto err_free_mem;
1095 }
1096
Iiro Valkonen7686b102011-02-02 23:21:58 -08001097 input_dev->name = "Atmel maXTouch Touchscreen";
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001098 input_dev->id.bustype = BUS_I2C;
1099 input_dev->dev.parent = &client->dev;
Iiro Valkonen7686b102011-02-02 23:21:58 -08001100 input_dev->open = mxt_input_open;
1101 input_dev->close = mxt_input_close;
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001102
Joonyoung Shim910d8052011-04-12 23:14:38 -07001103 data->client = client;
1104 data->input_dev = input_dev;
1105 data->pdata = pdata;
1106 data->irq = client->irq;
1107
1108 mxt_calc_resolution(data);
1109
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001110 __set_bit(EV_ABS, input_dev->evbit);
1111 __set_bit(EV_KEY, input_dev->evbit);
1112 __set_bit(BTN_TOUCH, input_dev->keybit);
1113
1114 /* For single touch */
1115 input_set_abs_params(input_dev, ABS_X,
Joonyoung Shim910d8052011-04-12 23:14:38 -07001116 0, data->max_x, 0, 0);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001117 input_set_abs_params(input_dev, ABS_Y,
Joonyoung Shim910d8052011-04-12 23:14:38 -07001118 0, data->max_y, 0, 0);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001119
1120 /* For multi touch */
Joonyoung Shim8b86c1c2011-04-12 23:18:59 -07001121 input_mt_init_slots(input_dev, MXT_MAX_FINGER);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001122 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
Iiro Valkonen7686b102011-02-02 23:21:58 -08001123 0, MXT_MAX_AREA, 0, 0);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001124 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
Joonyoung Shim910d8052011-04-12 23:14:38 -07001125 0, data->max_x, 0, 0);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001126 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
Joonyoung Shim910d8052011-04-12 23:14:38 -07001127 0, data->max_y, 0, 0);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001128
1129 input_set_drvdata(input_dev, data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001130 i2c_set_clientdata(client, data);
1131
Iiro Valkonen7686b102011-02-02 23:21:58 -08001132 error = mxt_initialize(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001133 if (error)
1134 goto err_free_object;
1135
Iiro Valkonen7686b102011-02-02 23:21:58 -08001136 error = request_threaded_irq(client->irq, NULL, mxt_interrupt,
Iiro Valkonen919ed892011-02-15 13:36:52 -08001137 pdata->irqflags, client->dev.driver->name, data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001138 if (error) {
1139 dev_err(&client->dev, "Failed to register interrupt\n");
1140 goto err_free_object;
1141 }
1142
Iiro Valkonen08960a02011-04-12 23:16:40 -07001143 error = mxt_make_highchg(data);
1144 if (error)
1145 goto err_free_irq;
1146
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001147 error = input_register_device(input_dev);
1148 if (error)
1149 goto err_free_irq;
1150
Iiro Valkonen7686b102011-02-02 23:21:58 -08001151 error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001152 if (error)
1153 goto err_unregister_device;
1154
1155 return 0;
1156
1157err_unregister_device:
1158 input_unregister_device(input_dev);
1159 input_dev = NULL;
1160err_free_irq:
1161 free_irq(client->irq, data);
1162err_free_object:
1163 kfree(data->object_table);
1164err_free_mem:
1165 input_free_device(input_dev);
1166 kfree(data);
1167 return error;
1168}
1169
Iiro Valkonen7686b102011-02-02 23:21:58 -08001170static int __devexit mxt_remove(struct i2c_client *client)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001171{
Iiro Valkonen7686b102011-02-02 23:21:58 -08001172 struct mxt_data *data = i2c_get_clientdata(client);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001173
Iiro Valkonen7686b102011-02-02 23:21:58 -08001174 sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001175 free_irq(data->irq, data);
1176 input_unregister_device(data->input_dev);
1177 kfree(data->object_table);
1178 kfree(data);
1179
1180 return 0;
1181}
1182
1183#ifdef CONFIG_PM
Iiro Valkonen7686b102011-02-02 23:21:58 -08001184static int mxt_suspend(struct device *dev)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001185{
Dmitry Torokhov8b5fce02010-11-18 00:14:03 -08001186 struct i2c_client *client = to_i2c_client(dev);
Iiro Valkonen7686b102011-02-02 23:21:58 -08001187 struct mxt_data *data = i2c_get_clientdata(client);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001188 struct input_dev *input_dev = data->input_dev;
1189
1190 mutex_lock(&input_dev->mutex);
1191
1192 if (input_dev->users)
Iiro Valkonen7686b102011-02-02 23:21:58 -08001193 mxt_stop(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001194
1195 mutex_unlock(&input_dev->mutex);
1196
1197 return 0;
1198}
1199
Iiro Valkonen7686b102011-02-02 23:21:58 -08001200static int mxt_resume(struct device *dev)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001201{
Dmitry Torokhov8b5fce02010-11-18 00:14:03 -08001202 struct i2c_client *client = to_i2c_client(dev);
Iiro Valkonen7686b102011-02-02 23:21:58 -08001203 struct mxt_data *data = i2c_get_clientdata(client);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001204 struct input_dev *input_dev = data->input_dev;
1205
1206 /* Soft reset */
Iiro Valkonen81c88a72011-07-04 03:08:25 -07001207 mxt_write_object(data, MXT_GEN_COMMAND_T6,
Iiro Valkonen7686b102011-02-02 23:21:58 -08001208 MXT_COMMAND_RESET, 1);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001209
Iiro Valkonen7686b102011-02-02 23:21:58 -08001210 msleep(MXT_RESET_TIME);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001211
1212 mutex_lock(&input_dev->mutex);
1213
1214 if (input_dev->users)
Iiro Valkonen7686b102011-02-02 23:21:58 -08001215 mxt_start(data);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001216
1217 mutex_unlock(&input_dev->mutex);
1218
1219 return 0;
1220}
Dmitry Torokhov8b5fce02010-11-18 00:14:03 -08001221
Iiro Valkonen7686b102011-02-02 23:21:58 -08001222static const struct dev_pm_ops mxt_pm_ops = {
1223 .suspend = mxt_suspend,
1224 .resume = mxt_resume,
Dmitry Torokhov8b5fce02010-11-18 00:14:03 -08001225};
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001226#endif
1227
Iiro Valkonen7686b102011-02-02 23:21:58 -08001228static const struct i2c_device_id mxt_id[] = {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001229 { "qt602240_ts", 0 },
Iiro Valkonen7686b102011-02-02 23:21:58 -08001230 { "atmel_mxt_ts", 0 },
Chris Leech46ee2a02011-02-15 13:36:52 -08001231 { "mXT224", 0 },
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001232 { }
1233};
Iiro Valkonen7686b102011-02-02 23:21:58 -08001234MODULE_DEVICE_TABLE(i2c, mxt_id);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001235
Iiro Valkonen7686b102011-02-02 23:21:58 -08001236static struct i2c_driver mxt_driver = {
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001237 .driver = {
Iiro Valkonen7686b102011-02-02 23:21:58 -08001238 .name = "atmel_mxt_ts",
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001239 .owner = THIS_MODULE,
Dmitry Torokhov8b5fce02010-11-18 00:14:03 -08001240#ifdef CONFIG_PM
Iiro Valkonen7686b102011-02-02 23:21:58 -08001241 .pm = &mxt_pm_ops,
Dmitry Torokhov8b5fce02010-11-18 00:14:03 -08001242#endif
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001243 },
Iiro Valkonen7686b102011-02-02 23:21:58 -08001244 .probe = mxt_probe,
1245 .remove = __devexit_p(mxt_remove),
1246 .id_table = mxt_id,
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001247};
1248
Iiro Valkonen7686b102011-02-02 23:21:58 -08001249static int __init mxt_init(void)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001250{
Iiro Valkonen7686b102011-02-02 23:21:58 -08001251 return i2c_add_driver(&mxt_driver);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001252}
1253
Iiro Valkonen7686b102011-02-02 23:21:58 -08001254static void __exit mxt_exit(void)
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001255{
Iiro Valkonen7686b102011-02-02 23:21:58 -08001256 i2c_del_driver(&mxt_driver);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001257}
1258
Iiro Valkonen7686b102011-02-02 23:21:58 -08001259module_init(mxt_init);
1260module_exit(mxt_exit);
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001261
1262/* Module information */
1263MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
Iiro Valkonen7686b102011-02-02 23:21:58 -08001264MODULE_DESCRIPTION("Atmel maXTouch Touchscreen driver");
Joonyoung Shim4cf51c32010-07-14 21:55:30 -07001265MODULE_LICENSE("GPL");