1 /****************************************************************************************
2 * driver/input/touchscreen/atmel_mxt224.c
3 *Copyright :ROCKCHIP Inc
8 ********************************************************************************************/
9 #include <linux/module.h>
10 #include <linux/delay.h>
11 #include <linux/earlysuspend.h>
12 #include <linux/hrtimer.h>
13 #include <linux/i2c.h>
14 #include <linux/input.h>
15 #include <linux/interrupt.h>
17 #include <linux/platform_device.h>
18 #include <linux/async.h>
19 #include <mach/gpio.h>
20 #include <linux/irq.h>
21 #include <mach/board.h>
23 #define FEATURE_CFG_DUMP
25 static int mxt224_i2c_write(struct i2c_client *client, u16 offset,void *buf,int size);
26 static int mxt224_i2c_read(struct i2c_client *client, u16 offset,void *buf,int size);
27 static int mXT224_probe(struct i2c_client *client, const struct i2c_device_id *id);
28 static int mXT224_remove(struct i2c_client *client);
30 #ifdef FEATURE_CFG_DUMP
31 static int total_size = 0;
35 #define local_debug //printk
37 #define ID_INFORMATION_SIZE 0x7
38 #define OBJECT_TABLE_ELEMENT_SIZE 0x6
40 #define TABLE_SIZE_ADDR ID_INFORMATION_SIZE-1
41 #define MESSAGE_T5 0x5
43 #define MXT224_REPORTID_T9_OFFSET 9
44 #define MXT224_MT_SCAN_POINTS 2
46 struct mxt224_id_info{
56 struct mxt224_table_info{
65 #define CFGERR_MASK (0x01<<3)
92 struct mxt224_id_info *id_info;
94 struct mxt224_table_info *table_info;
108 //struct hrtimer timer;
109 struct i2c_client *client;
110 struct input_dev *input_dev;
111 struct delayed_work work;
112 struct workqueue_struct *mxt224_wq;
114 int (*power)(int on);
115 /* Object table relation */
116 struct mxt224_obj obj;
119 static struct mXT224_info ts_data = {
120 .int_gpio = RK29_PIN0_PA2,
121 .reset_gpio = RK29_PIN6_PC3,
127 struct report_id_table{
133 static struct report_id_table* id_table = NULL;
134 static u8 T9_cfg[31] = {0};
142 struct mxt224_key_info{
147 const struct mxt224_key_info key_info[] = {
155 const u8 T7[] = {0xff, 0xff, 0x32};
156 const u8 T8[] = {0x08, 0x05, 0x14, 0x14, 0x00, 0x00, 0x0a, 0x0f};
157 const u8 T9[] = {0x83, 0x00, 0x00, 0x0D, 0x0A, 0x00, 0x11, 0x28,
158 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x0A, 0x0A,
159 0x0A, 0x0A, 0x01, 0x5A, 0x00, 0xEF, 0x00, 0x00,
160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
161 ///////////////////////////////////////
162 //0x83, 0x0D, 0x0A, 0x03, 0x03, 0x00, 0x11, 0x28,
163 //0x02, 0x03, 0x00, 0x01, 0x01, 0x00, 0x0A, 0x0A,
164 //0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165 //0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167 const u8 T15[] = {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x41, 0x1E,
169 const u8 T18[] = {0x00, 0x00 };
170 const u8 T19[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
172 const u8 T20[] = {0x00, 0x64, 0x64, 0x64, 0x64, 0x00, 0x00, 0x00,
173 0x00, 0x00, 0x00, 0x00 };
174 const u8 T22[] = {0x15, 0x00, 0x00, 0x00, 0x19, 0xFF, 0xE7, 0x04,
175 0x32, 0x00, 0x01, 0x0A, 0x0F, 0x14, 0x19, 0x1E,
177 /////////////////////////////////////
178 //0x15, 0x00, 0x00, 0x00, 0x19, 0xff, 0xe7, 0x04,
179 //0x32, 0x00, 0x01, 0x0a, 0x0f, 0x14, 0x19, 0x1e,
182 const u8 T23[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
183 0x00, 0x00, 0x00, 0x00, 0x00 };
184 const u8 T24[] = {0x03, 0x04, 0x03, 0xFF, 0x00, 0x64, 0x64, 0x01,
185 0x0A, 0x14, 0x28, 0x00, 0x4B, 0x00, 0x02, 0x00,
187 const u8 T25[] = {0x00, 0x00, 0x2E, 0xE0, 0x1B, 0x58, 0x36, 0xB0,
188 0x01, 0xF4, 0x00, 0x00, 0x00, 0x00 };
189 const u8 T27[] = {0x03, 0x02, 0x00, 0xE0, 0x03, 0x00, 0x23};
190 const u8 T28[] = {0x00, 0x00, 0x00, 0x04, 0x08, 0xF6 };
191 const u8 T38[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
193 const struct mxt224_cfg cfg_table[] = {
197 {15, T15, sizeof(T15)},
198 {18, T18, sizeof(T18)},
199 {19, T19, sizeof(T19)},
200 {20, T20, sizeof(T20)},
201 {22, T22, sizeof(T22)},
202 {23, T23, sizeof(T23)},
203 {24, T24, sizeof(T24)},
204 {25, T25, sizeof(T25)},
205 {27, T27, sizeof(T27)},
206 {28, T28, sizeof(T28)},
207 {38, T38, sizeof(T38)}
227 enum mXT224_touch_status{
233 u32 static crc24(u32 crc, u8 firstbyte, u8 secondbyte)
235 const u32 crcpoly = 0x80001b;
239 data_word = (u16)((u16)(secondbyte<<8u)|firstbyte);
240 result = ((crc<<1u)^(u32)data_word);
241 if(result & 0x1000000){
247 u32 static get_crc24(const u8* src, int cnt)
252 while(index < (cnt-1)){
253 crc = crc24(crc, *(src+index), *(src+index+1));
258 crc = crc24(crc, *(src+index), 0);
260 crc = (crc & 0x00ffffff);
264 static u32 mXT224_cfg_crc(void)
271 for(index=0; index<((sizeof(cfg_table)/sizeof(cfg_table[0]))-1); index++){
272 const u8* data = cfg_table[index].data;
273 while(sub_index <(cfg_table[index].size-1)){
274 crc = crc24(crc, *(data+sub_index), *(data+sub_index+1));
277 if(sub_index != cfg_table[index].size){
278 if(index == ((sizeof(cfg_table)/sizeof(cfg_table[0]))-1)){
279 crc = crc24(crc, *(data+sub_index), 0);
281 const u8* next_data = cfg_table[index+1].data;
282 crc = crc24(crc, *(data+sub_index), *(next_data));
283 crc = (crc & 0x00ffffff);
289 crc = (crc & 0x00ffffff);
292 //crc = crc24(crc, 0, 0);
293 crc = (crc & 0x00ffffff);
297 static void mxt224_mem_dbg(const void *src, int cnt)
301 const u8* disp = (u8*)src;
302 local_debug(KERN_INFO "%s: start...\n", __func__);
303 for(index=0; index < cnt; index++){
304 local_debug(KERN_INFO "0x%2x ", disp[index]);
306 local_debug(KERN_INFO "\n%s: ...end\n", __func__);
312 static irqreturn_t mXT224_ts_interrupt(int irq, void *handle)
314 struct mXT224_info *ts = handle;
315 local_debug(KERN_INFO "%s\n", __func__);
317 disable_irq_nosync(ts->int_gpio);
318 queue_delayed_work(ts->mxt224_wq, &ts->work, 0);
324 static u16 mXT224_get_obj_addr(u8 type, struct mxt224_table_info *info, u8 info_size)
329 for(index=0; index < info_size; index++){
330 if(type == info[index].obj_type){
331 addr = info[index].start_addr_msb;
333 addr |= info[index].start_addr_lsb;
341 static struct report_id_table* mXT224_build_report_id_table(
342 struct mxt224_table_info *info, u8 info_size)
347 id_table = (struct report_id_table*)kzalloc(info_size*sizeof(struct report_id_table), GFP_KERNEL);
350 local_debug(KERN_INFO "%s: Can't get memory!\n", __func__);
356 for(index = 0; index < info_size; index++){
357 #ifdef FEATURE_CFG_DUMP
358 total_size += ((info[index].size+1)*(info[index].instance+1));
360 if(info[index].obj_type == 0x5)
362 if(info[index].report_id == 0x00)
365 id_table[write_index].obj_type = info[index].obj_type;
366 id_table[write_index].report_start = (offset+1);
367 id_table[write_index].report_end = id_table[write_index].report_start+
368 info[index].report_id*(info[index].instance+1)-1;
370 offset = id_table[write_index].report_end;
374 #ifdef FEATURE_CFG_DUMP
375 for(index = 0; index < info_size; index++){
376 local_debug(KERN_INFO "%s: Object type:%d, size:[%d]\n", __func__,
377 info[index].obj_type, info[index].size+1);
385 static u8 mXT224_get_obj_type(u8 id, struct report_id_table* table, u8 table_size)
389 for(index=0; index < table_size; index++){
390 local_debug(KERN_INFO "%s: ID:%d, start:[%d], end:[%d], type:[%d]\n", __func__,
391 id, table[index].report_start, table[index].report_end,
392 table[index].obj_type);
393 if(id>=table[index].report_start && id<=table[index].report_end){
398 switch(table[index].obj_type){
404 int t9_offset = id-table[index].report_start;
405 if(t9_offset < MXT224_REPORTID_T9_OFFSET){
406 return MSG_T9_MT_1+t9_offset;
413 return MSG_T9_KEY_PRESS;
421 #define TS_POLL_PERIOD 10000*1000
425 static void mXT224_load_cfg(void)
432 local_debug(KERN_INFO "%s\n", __func__);
434 if(ts_data.cfg_delay){
437 ts_data.cfg_delay = 1;
439 // hrtimer_start(&ts_data.timer, ktime_set(0, TS_POLL_PERIOD), HRTIMER_MODE_REL);
441 for(index=0; index<(sizeof(cfg_table)/sizeof(cfg_table[0])); index++){
443 const u8* data = cfg_table[index].data;
444 u16 addr = mXT224_get_obj_addr(cfg_table[index].type, ts_data.obj.table_info,
445 ts_data.obj.table_size);
446 rc = mxt224_i2c_write(ts_data.client, addr, data, cfg_table[index].size);
448 local_debug(KERN_INFO "%s: Load mXT224 config failed, addr: 0x%x!\n", __func__, addr);
452 addr = mXT224_get_obj_addr(6, ts_data.obj.table_info, ts_data.obj.table_size);
457 rc = mxt224_i2c_write(ts_data.client, addr, buf, 6);
460 local_debug(KERN_INFO "%s: Back up NV failed!\n", __func__);
466 gpio_set_value(ts_data.reset_gpio, 0);
469 gpio_set_value(ts_data.reset_gpio, 1);
476 #define DETECT_MASK (0x01<<7)
477 #define RELEASE_MASK (0x01<<5)
478 #define MOVE_MASK (0x01<<4)
484 static int mXT224_process_msg(u8 id, u8 *msg)
490 local_debug(KERN_INFO "%s: Process mXT224 msg MSG_T6!\n", __func__);
491 u32 checksum = ((union msg_body*)msg)->t6.checksum;
493 u8 status = ((union msg_body*)msg)->t6.status;
495 if(status & CFGERR_MASK){
496 local_debug(KERN_INFO "%s: Process mXT224 cfg error!\n", __func__);
497 // mXT224_load_cfg();
500 if(checksum!=cfg_crc){
501 local_debug(KERN_INFO "%s: Process mXT224 cfg CRC error!\n", __func__);
502 local_debug(KERN_INFO "%s: Read CRC:[0x%x], Our CRC:[0x%x]\n", __func__, checksum, cfg_crc);
517 local_debug(KERN_INFO "%s: Process mXT224 msg MSG_T9_MT!\n", __func__);
520 x = ((union msg_body*)msg)->t9.x_msb;
522 x |= (((union msg_body*)msg)->t9.xy_poslisb>>4);
524 y = ((union msg_body*)msg)->t9.y_msb;
526 ((union msg_body*)msg)->t9.xy_poslisb &= 0x0f;
528 y |= ((union msg_body*)msg)->t9.xy_poslisb;
530 local_debug(KERN_INFO "%s: X[%d], Y[%d]\n", __func__, x, y);
532 if(((union msg_body*)msg)->t9.status & DETECT_MASK)
534 tcStatus = STATUS_PRESS;
535 }else if(((union msg_body*)msg)->t9.status & RELEASE_MASK)
537 tcStatus = STATUS_RELEASE;
540 input_report_abs(ts_data.input_dev, ABS_MT_TRACKING_ID, id - 1);
541 input_report_abs(ts_data.input_dev, ABS_MT_TOUCH_MAJOR, tcStatus);
542 input_report_abs(ts_data.input_dev, ABS_MT_WIDTH_MAJOR, 0);
543 input_report_abs(ts_data.input_dev, ABS_MT_POSITION_X, x);
544 input_report_abs(ts_data.input_dev, ABS_MT_POSITION_Y, y);
545 input_mt_sync(ts_data.input_dev);
546 local_debug(KERN_INFO "%s,input_report_abs x is %d,y is %d. status is [%d].\n", __func__, x, y, tcStatus);
549 case MSG_T9_KEY_PRESS:
551 int keyStatus, keyIndex;
553 keyStatus = ((union msg_body*)msg)->t9.status >> 7;
554 if(keyStatus) //press.
556 keyIndex = ((union msg_body*)msg)->t9.x_msb;
557 ts_data.last_key_index = keyIndex;
559 keyIndex = ts_data.last_key_index;
583 local_debug(KERN_INFO "%s: Default keyIndex [0x%x]\n", __func__, keyIndex);
587 local_debug(KERN_INFO "%s: Touch KEY code is [%d], keyStatus is [%d]\n", __func__, key_info[keyIndex].code, keyStatus);
589 input_report_key(ts_data.input_dev, key_info[keyIndex].code, keyStatus);
596 local_debug(KERN_INFO "%s: Default id[0x%x]\n", __func__, id);
606 static void mXT224_work_func(struct work_struct *work)
608 u8 track[MXT224_MT_SCAN_POINTS];
609 int index, ret, read_points;
610 struct message_t5 msg_t5_array[MXT224_MT_SCAN_POINTS];
612 local_debug(KERN_INFO "%s\n", __func__);
615 ret = mxt224_i2c_read(ts_data.client, ts_data.obj.msg_t5_addr,
616 (u8*)&msg_t5_array[0], sizeof(struct message_t5) * MXT224_MT_SCAN_POINTS);
617 read_points = ret / sizeof(struct message_t5);
619 local_debug(KERN_INFO "%s, this time read_points is %d\n", __func__, read_points);
620 mxt224_mem_dbg((u8*)&msg_t5_array[0], sizeof(struct message_t5) * read_points);
622 for(index = 0; index < read_points; index++)
624 if(msg_t5_array[index].report_id == 0xFF) // dirty message, don't process.
629 track[index] = mXT224_get_obj_type(msg_t5_array[index].report_id, id_table, ts_data.obj.table_size);
631 if(track[index] == 0){
632 local_debug(KERN_INFO "%s: Get object type failed!, report id[0x%x]\n", __func__, msg_t5_array[index].report_id);
636 local_debug(KERN_INFO "%s,object's msg type is %d.\n", __func__, track[index]);
639 for(index = 0; index < read_points; index++)
641 if(track[index] == 0xFF)
643 mXT224_process_msg(track[index], (u8*)&msg_t5_array[index].body);
644 if(track[index] == track[read_points - 1] || track[read_points - 1] == 0xFF)
646 input_sync(ts_data.input_dev);
647 local_debug(KERN_INFO "%s,input_sync ts_data.input_dev.\n", __func__);
652 enable_irq(ts_data.int_gpio);
656 static int mxt224_i2c_write(struct i2c_client *client, u16 offset,void *buf,int size)
658 unsigned char objectAddr[2+size];
661 objectAddr[0] = offset & 0x00FF;
662 objectAddr[1] = offset >> 8;
663 memcpy(&objectAddr[2], (char *)buf, size);
664 retlen = i2c_master_normal_send(client, objectAddr,2 + size, 200*1000);
669 static int mxt224_i2c_read(struct i2c_client *client, u16 offset,void *buf,int size)
671 unsigned char objectAddr[2];
674 if(ts_data.last_read_addr != offset)
676 ts_data.last_read_addr = offset;
677 objectAddr[0] = offset & 0x00FF;
678 objectAddr[1] = offset >> 8;
679 retlen = i2c_master_normal_send(client, objectAddr,2, 200*1000);
683 retlen = i2c_master_normal_recv(client, (char *)buf, size, 200*1000);
688 static int mXT224_probe(struct i2c_client *client, const struct i2c_device_id *id)
696 struct message_t5 msg_t5;
698 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
701 rc = gpio_request(ts_data.int_gpio, "Touch_int");
705 local_debug(KERN_INFO "%s: Request GPIO failed!\n", __func__);
709 rc = gpio_request(ts_data.reset_gpio, "Touch_reset");
713 local_debug(KERN_INFO "%s: Request mXT224 reset GPIO failed!\n", __func__);
717 /* store the value */
718 i2c_set_clientdata(client, &ts_data);
719 ts_data.client = client;
720 ts_data.int_gpio= client->irq;
721 //client->driver = &mXT224_driver;
723 ts_data.mxt224_wq = create_rt_workqueue("mxt224_wq");
724 INIT_DELAYED_WORK(&ts_data.work, mXT224_work_func);
727 gpio_pull_updown(ts_data.int_gpio, 1);
729 gpio_direction_output(ts_data.reset_gpio, 0);
730 gpio_set_value(ts_data.reset_gpio, GPIO_LOW);
732 gpio_set_value(ts_data.reset_gpio, GPIO_HIGH);
736 /* Try get mXT224 table size */
738 rc = mxt224_i2c_read(client, TABLE_SIZE_ADDR, &ts_data.obj.table_size, 1);
742 local_debug(KERN_INFO "%s: Get table size failed!\n", __func__);
748 /* Try get mXT224 device info */
749 info_size = CRC_SIZE+ID_INFORMATION_SIZE+ts_data.obj.table_size*OBJECT_TABLE_ELEMENT_SIZE;
751 ts_data.obj.table_info_byte = (u8*)kzalloc(info_size, GFP_KERNEL);
753 if(!ts_data.obj.table_info_byte)
755 local_debug(KERN_INFO "%s: Can't get memory!\n", __func__);
760 rc = mxt224_i2c_read(client, 0, ts_data.obj.table_info_byte, info_size);
764 local_debug(KERN_INFO "%s: Get mXT224 info failed!\n", __func__);
765 goto get_info_failed;
768 ts_data.obj.table_info = (struct mxt224_table_info*)(ts_data.obj.table_info_byte+ID_INFORMATION_SIZE);
769 mxt224_mem_dbg(ts_data.obj.table_info_byte, info_size);
774 /* Try get and check CRC */
775 ts_data.obj.info_crc = (ts_data.obj.table_info_byte[info_size-3])|
776 (ts_data.obj.table_info_byte[info_size-2]<<8)|
777 (ts_data.obj.table_info_byte[info_size-1]<<16);
778 crc = get_crc24(ts_data.obj.table_info_byte, info_size-CRC_SIZE);
780 if(ts_data.obj.info_crc != crc)
782 //1 TODO: Need set config table
784 local_debug(KERN_INFO "%s:CRC failed, read CRC:[0x%x], get CRC:[0x%x]\n", __func__, ts_data.obj.info_crc, crc);
791 cfg_crc = mXT224_cfg_crc();
796 /* Build report id table */
797 mXT224_build_report_id_table(ts_data.obj.table_info, ts_data.obj.table_size);
801 /* Dump mXT224 config setting */
802 #ifdef FEATURE_CFG_DUMP
804 local_debug(KERN_INFO "%s: Config size: %d\n", __func__, total_size);
806 cfg_dmup = (u8*)kzalloc(info_size+total_size, GFP_KERNEL);
810 local_debug(KERN_INFO "%s: Cannot get memory!\n", __func__);
814 mxt224_i2c_read(client, 0, cfg_dmup, info_size+total_size);
815 mxt224_mem_dbg(cfg_dmup, info_size+total_size);
820 /* Try get message T5 info */
821 if(gpio_get_value(ts_data.int_gpio))
823 //1 TODO: Need check touch interrput pin
825 local_debug(KERN_INFO "%s: GPIO status error!\n", __func__);
831 ts_data.obj.msg_t5_addr = mXT224_get_obj_addr(0x5, ts_data.obj.table_info, ts_data.obj.table_size);
833 rc = mxt224_i2c_read(client, ts_data.obj.msg_t5_addr, (u8*)&msg_t5, sizeof(struct message_t5));
837 local_debug(KERN_INFO "%s:Can't get message T5!\n", __func__);
841 mxt224_mem_dbg((u8*)&msg_t5, sizeof(struct message_t5));
842 mXT224_process_msg(mXT224_get_obj_type(msg_t5.report_id, id_table, ts_data.obj.table_size), (u8*)&msg_t5.body);
844 object_addr = mXT224_get_obj_addr(0x9, ts_data.obj.table_info, ts_data.obj.table_size);
846 rc = mxt224_i2c_read(client, object_addr, (u8*)&T9_cfg[0], 31);
850 local_debug(KERN_INFO "%s:Can't get message T9!\n", __func__);
854 mxt224_mem_dbg((u8*)&T9_cfg[0], 31);
856 local_debug(KERN_INFO "%s:Change T9 orient to [0]!\n", __func__);
859 rc = mxt224_i2c_write(client, object_addr, (u8*)&T9_cfg[0], 31);
862 local_debug(KERN_INFO "%s:Can't write message T9!\n", __func__);
866 rc = mxt224_i2c_read(client, object_addr, (u8*)&T9_cfg[0], 31);
870 local_debug(KERN_INFO "%s:Can't get message T9!\n", __func__);
873 mxt224_mem_dbg((u8*)&T9_cfg[0], 31);
875 //local_debug(KERN_INFO "%s:Find obj report: 0x%x\n", __func__,
876 // mXT224_get_obj_type(msg_t5.report_id, id_table, obj_table_size));
879 if(gpio_get_value(ts_data.int_gpio))
881 local_debug(KERN_INFO "%s: GPIO value is high\n", __func__);
885 ts_data.input_dev = input_allocate_device();
886 if (!ts_data.input_dev)
892 input_set_drvdata(ts_data.input_dev, &ts_data);
894 snprintf(ts_data.phys, sizeof(ts_data.phys),
895 "%s/input0", dev_name(&client->dev));
897 ts_data.input_dev->name = "mXT224_touch";
898 ts_data.input_dev->id.bustype = BUS_I2C;
899 ts_data.input_dev->phys = ts_data.phys;
902 set_bit(EV_SYN, ts_data.input_dev->evbit);
903 set_bit(EV_KEY, ts_data.input_dev->evbit);
904 set_bit(BTN_TOUCH, ts_data.input_dev->keybit);
905 set_bit(BTN_2, ts_data.input_dev->keybit);
906 set_bit(EV_ABS, ts_data.input_dev->evbit);
908 input_set_abs_params(ts_data.input_dev, ABS_X, 0, 240, 0, 0);
909 input_set_abs_params(ts_data.input_dev, ABS_Y, 0, 320, 0, 0);
911 for(index=0; index<(sizeof(key_info)/sizeof(key_info[0])); index++)
913 input_set_capability(ts_data.input_dev, EV_KEY, key_info[index].code);
916 ts_data.input_dev->evbit[0] = BIT_MASK(EV_ABS)|BIT_MASK(EV_KEY)|BIT_MASK(EV_SYN);
917 ts_data.input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
918 //ts_data.input_dev->keybit[BIT_WORD(BTN_2)] = BIT_MASK(BTN_2);
920 for(index=0; index<(sizeof(key_info)/sizeof(key_info[0])); index++)
922 input_set_capability(ts_data.input_dev, EV_KEY, key_info[index].code);
924 input_set_abs_params(ts_data.input_dev, ABS_X, 0, CONFIG_MXT224_MAX_X, 0, 0);
925 input_set_abs_params(ts_data.input_dev, ABS_Y, 0, CONFIG_MXT224_MAX_Y, 0, 0);
926 input_set_abs_params(ts_data.input_dev, ABS_PRESSURE, 0, 255, 0, 0);
927 input_set_abs_params(ts_data.input_dev, ABS_TOOL_WIDTH, 0, 15, 0, 0);
928 input_set_abs_params(ts_data.input_dev, ABS_HAT0X, 0, CONFIG_MXT224_MAX_X, 0, 0);
929 input_set_abs_params(ts_data.input_dev, ABS_HAT0Y, 0, CONFIG_MXT224_MAX_Y, 0, 0);
930 input_set_abs_params(ts_data.input_dev, ABS_MT_POSITION_X,0, CONFIG_MXT224_MAX_X, 0, 0);
931 input_set_abs_params(ts_data.input_dev, ABS_MT_POSITION_Y, 0, CONFIG_MXT224_MAX_Y, 0, 0);
932 input_set_abs_params(ts_data.input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
933 input_set_abs_params(ts_data.input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
934 input_set_abs_params(ts_data.input_dev, ABS_MT_TRACKING_ID, 0, 10, 0, 0);
937 rc = input_register_device(ts_data.input_dev);
941 dev_err(&client->dev, "mXT224: input_register_device rc=%d\n", rc);
945 ts_data.int_gpio = gpio_to_irq(ts_data.int_gpio);
947 rc = request_irq(ts_data.int_gpio, mXT224_ts_interrupt,
948 IRQF_TRIGGER_FALLING, "mXT224_touch", &ts_data);
951 local_debug(KERN_INFO "mXT224 request interrput failed!\n");
953 local_debug(KERN_INFO "mXT224 request interrput successed!\n");
960 /* Free mXT224 info */
963 if(ts_data.input_dev != NULL)
964 input_free_device(ts_data.input_dev);
966 #ifdef FEATURE_CFG_DUMP
969 kfree(ts_data.obj.table_info_byte);
981 static int __devexit mXT224_remove(struct i2c_client *client)
983 struct mXT224_info *ts = i2c_get_clientdata(client);
985 free_irq(ts->int_gpio, ts);
986 if (cancel_delayed_work_sync(&ts->work)) {
988 * Work was pending, therefore we need to enable
989 * IRQ here to balance the disable_irq() done in the
992 enable_irq(ts->int_gpio);
995 input_unregister_device(ts->input_dev);
1005 static const struct i2c_device_id mXT224_ts_id[] = {
1006 { "mXT224_touch", 0 },
1010 MODULE_DEVICE_TABLE(i2c, mXT224_ts_id);
1012 static struct i2c_driver mXT224_driver = {
1014 .owner = THIS_MODULE,
1015 .name = "mXT224_touch"
1017 .id_table = mXT224_ts_id,
1018 .probe = mXT224_probe,
1019 .remove = __devexit_p(mXT224_remove),
1022 static void __init mXT_init_async(void *unused, async_cookie_t cookie)
1024 local_debug("--------> %s <-------------\n",__func__);
1025 i2c_add_driver(&mXT224_driver);
1029 static int __init mXT_init(void)
1031 async_schedule(mXT_init_async, NULL);
1036 static void __exit mXT_exit(void)
1038 i2c_del_driver(&mXT224_driver);
1042 module_init(mXT_init);
1043 module_exit(mXT_exit);
1045 MODULE_LICENSE("GPL");