2 * drivers/input/touchscreen/gslX680.c
4 * Copyright (c) 2012 Shanghai Basewin
5 * Guan Yuwei<guanyuwei@basewin.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/delay.h>
15 #include <linux/earlysuspend.h>
16 #include <linux/hrtimer.h>
17 #include <linux/i2c.h>
18 #include <linux/input.h>
19 #include <linux/interrupt.h>
21 #include <linux/platform_device.h>
22 #include <linux/async.h>
23 #include <mach/gpio.h>
24 #include <mach/iomux.h>
25 #include <linux/irq.h>
26 #include <mach/board.h>
27 #include <linux/workqueue.h>
28 #include <linux/proc_fs.h>
29 #include <linux/input/mt.h>
31 #include "rockchip_gslX680_rk3168.h"
35 #define REPORT_DATA_ANDROID_4_0
37 //#define HAVE_TOUCH_KEY
39 #define GSLX680_I2C_NAME "gslX680"
40 #define GSLX680_I2C_ADDR 0x40
42 #define IRQ_PORT RK2928_PIN1_PB0
43 #define WAKE_PORT RK2928_PIN0_PD3
45 #define GSL_DATA_REG 0x80
46 #define GSL_STATUS_REG 0xe0
47 #define GSL_PAGE_REG 0xf0
51 #define MAX_CONTACTS 10
52 #define DMA_TRANS_LEN 0x20
53 //#define FILTER_POINT
58 #define I2C_SPEED 200*1000
62 static int key_state_flag = 0;
71 const u16 key_array[]={
77 #define MAX_KEY_NUM (sizeof(key_array)/sizeof(key_array[0]))
79 struct key_data gsl_key_data[MAX_KEY_NUM] = {
80 {KEY_BACK, 2048, 2048, 2048, 2048},
81 {KEY_HOME, 2048, 2048, 2048, 2048},
82 {KEY_MENU, 2048, 2048, 2048, 2048},
83 {KEY_SEARCH, 2048, 2048, 2048, 2048},
102 static struct gsl_ts_data devices[] = {
108 .data_reg = GSL_DATA_REG,
109 .status_reg = GSL_STATUS_REG,
112 .touch_meta_data = 4,
118 struct i2c_client *client;
119 struct input_dev *input;
120 struct delayed_work work;
121 struct workqueue_struct *wq;
122 struct gsl_ts_data *dd;
128 struct mutex sus_lock;
129 // uint32_t gpio_irq;
131 #if defined(CONFIG_HAS_EARLYSUSPEND)
132 struct early_suspend early_suspend;
135 struct timer_list gsl_timer;
137 int reset_gpio; //lizhengwei
142 #define print_info(fmt, args...) \
144 printk(fmt, ##args); \
147 #define print_info(fmt, args...)
150 static int ts_global_reset_pin; //lizhengwei add
152 static u32 id_sign[MAX_CONTACTS+1] = {0};
153 static u8 id_state_flag[MAX_CONTACTS+1] = {0};
154 static u8 id_state_old_flag[MAX_CONTACTS+1] = {0};
155 static u16 x_old[MAX_CONTACTS+1] = {0};
156 static u16 y_old[MAX_CONTACTS+1] = {0};
157 static u16 x_new = 0;
158 static u16 y_new = 0;
160 static int gslX680_chip_init(void)
163 gpio_free(WAKE_PORT);
164 if (gpio_request(WAKE_PORT, "gslx680 wake")) {
165 printk("pjf gpio_request(WAKE_PORT) error\n");
166 goto exit_alloc_gpio_wake_failed;
169 gpio_direction_output(WAKE_PORT, 0);
170 gpio_set_value(WAKE_PORT,GPIO_HIGH);
174 if (gpio_request(IRQ_PORT, "gslx680 irq")) {
175 printk("pjf gpio_request(IRQ_PORT) error\n");
176 goto exit_alloc_gpio_irg_failed;
179 gpio_pull_updown(IRQ_PORT, 1);
184 exit_alloc_gpio_irg_failed:
186 exit_alloc_gpio_wake_failed:
187 gpio_free(WAKE_PORT);
191 static int gslX680_shutdown_low(void)
193 gpio_direction_output(ts_global_reset_pin, 0);
194 gpio_set_value(ts_global_reset_pin,GPIO_LOW);
198 static int gslX680_shutdown_high(void)
200 gpio_direction_output(ts_global_reset_pin, 0);
201 gpio_set_value(ts_global_reset_pin,GPIO_HIGH);
205 static inline u16 join_bytes(u8 a, u8 b)
213 static u32 gsl_read_interface(struct i2c_client *client, u8 reg, u8 *buf, u32 num)
215 struct i2c_msg xfer_msg[2];
217 xfer_msg[0].addr = client->addr;
219 xfer_msg[0].flags = client->flags & I2C_M_TEN;
220 xfer_msg[0].buf = ®
222 xfer_msg[1].addr = client->addr;
223 xfer_msg[1].len = num;
224 xfer_msg[1].flags |= I2C_M_RD;
225 xfer_msg[1].buf = buf;
228 i2c_transfer(client->adapter, xfer_msg, ARRAY_SIZE(xfer_msg));
232 return i2c_transfer(client->adapter, xfer_msg, ARRAY_SIZE(xfer_msg)) == ARRAY_SIZE(xfer_msg) ? 0 : -EFAULT;
235 static u32 gsl_write_interface(struct i2c_client *client, const u8 reg, u8 *buf, u32 num)
237 struct i2c_msg xfer_msg[1];
241 xfer_msg[0].addr = client->addr;
242 xfer_msg[0].len = num + 1;
243 xfer_msg[0].flags = client->flags & I2C_M_TEN;
244 xfer_msg[0].buf = buf;
245 xfer_msg[0].scl_rate = I2C_SPEED;
247 return i2c_transfer(client->adapter, xfer_msg, 1) == 1 ? 0 : -EFAULT;
250 static int gsl_ts_write(struct i2c_client *client, u8 addr, u8 *pdata, int datalen)
254 unsigned int bytelen = 0;
257 printk("%s too big datalen = %d!\n", __func__, datalen);
264 if (datalen != 0 && pdata != NULL)
266 memcpy(&tmp_buf[bytelen], pdata, datalen);
270 ret = i2c_master_send(client, tmp_buf, bytelen);
274 static int gsl_ts_read(struct i2c_client *client, u8 addr, u8 *pdata, unsigned int datalen)
280 printk("%s too big datalen = %d!\n", __func__, datalen);
284 ret = gsl_ts_write(client, addr, NULL, 0);
287 printk("%s set data address fail!\n", __func__);
291 return i2c_master_recv(client, pdata, datalen);
295 static __inline__ void fw2buf(u8 *buf, const u32 *fw)
297 u32 *u32_buf = (int *)buf;
301 static void gsl_load_fw(struct i2c_client *client)
303 u8 buf[DMA_TRANS_LEN*4 + 1] = {0};
308 u8 read_buf[4] = {0};
309 struct fw_data *ptr_fw;
311 printk("=============gsl_load_fw start==============\n");
313 #ifdef GSL1680E_COMPATIBLE
315 gsl_ts_read(client, 0xfc, read_buf, 4);
316 //printk("read 0xfc = %x %x %x %x\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
318 if(read_buf[2] != 0x82 && read_buf[2] != 0x88)
321 gsl_ts_read(client, 0xfc, read_buf, 4);
322 //printk("read 0xfc = %x %x %x %x\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
325 if(read_buf[2] == 0x82)
327 ptr_fw = GSL1680E_FW;
328 source_len = ARRAY_SIZE(GSL1680E_FW);
334 source_len = ARRAY_SIZE(GSLX680_FW);
337 for (source_line = 0; source_line < source_len; source_line++)
339 /* init page trans, set the page val */
340 if (GSL_PAGE_REG == ptr_fw[source_line].offset)
342 fw2buf(cur, &ptr_fw[source_line].val);
343 gsl_write_interface(client, GSL_PAGE_REG, buf, 4);
348 if (1 == send_flag % (DMA_TRANS_LEN < 0x20 ? DMA_TRANS_LEN : 0x20))
349 buf[0] = (u8)ptr_fw[source_line].offset;
351 fw2buf(cur, &ptr_fw[source_line].val);
354 if (0 == send_flag % (DMA_TRANS_LEN < 0x20 ? DMA_TRANS_LEN : 0x20))
356 gsl_write_interface(client, buf[0], buf, cur - buf - 1);
364 printk("=============gsl_load_fw end==============\n");
369 static void test_i2c(struct i2c_client *client)
374 ret = gsl_ts_read( client, 0xf0, &read_buf, sizeof(read_buf) );
377 pr_info("I2C transfer error!\n");
381 pr_info("I read reg 0xf0 is %x\n", read_buf);
385 ret = gsl_ts_write(client, 0xf0, &write_buf, sizeof(write_buf));
388 pr_info("I2C transfer error!\n");
392 pr_info("I write reg 0xf0 0x12\n");
396 ret = gsl_ts_read( client, 0xf0, &read_buf, sizeof(read_buf) );
399 pr_info("I2C transfer error!\n");
403 pr_info("I read reg 0xf0 is 0x%x\n", read_buf);
410 static void startup_chip(struct i2c_client *client)
413 gsl_ts_write(client, 0xe0, &tmp, 1);
417 static void reset_chip(struct i2c_client *client)
421 gsl_ts_write(client, 0xe0, &tmp, sizeof(tmp));
425 gsl_ts_write(client, 0xe4, &tmp, sizeof(tmp));
428 gsl_ts_write(client, 0xbc, buf, sizeof(buf));
432 static void init_chip(struct i2c_client *client)
434 gslX680_shutdown_low();
436 gslX680_shutdown_high();
440 startup_chip(client);
442 startup_chip(client);
445 static void check_mem_data(struct i2c_client *client)
448 char read_buf[4] = {0};
452 gsl_ts_write(client,0xf0, &write_buf, sizeof(write_buf));
453 gsl_ts_read(client,0x00, read_buf, sizeof(read_buf));
454 gsl_ts_read(client,0x00, read_buf, sizeof(read_buf));
455 if (read_buf[3] != 0x1 || read_buf[2] != 0 || read_buf[1] != 0 || read_buf[0] != 0)
457 printk("!!!!!!!!!!!page: %x offset: %x val: %x %x %x %x\n",0x0, 0x0, read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
463 static void filter_point(u16 x, u16 y , u8 id)
467 u16 filter_step_x = 0, filter_step_y = 0;
469 id_sign[id] = id_sign[id] + 1;
476 x_err = x > x_old[id] ? (x -x_old[id]) : (x_old[id] - x);
477 y_err = y > y_old[id] ? (y -y_old[id]) : (y_old[id] - y);
479 if( (x_err > FILTER_MAX && y_err > FILTER_MAX/3) || (x_err > FILTER_MAX/3 && y_err > FILTER_MAX) )
481 filter_step_x = x_err;
482 filter_step_y = y_err;
486 if(x_err > FILTER_MAX)
487 filter_step_x = x_err;
488 if(y_err> FILTER_MAX)
489 filter_step_y = y_err;
492 if(x_err <= 2*FILTER_MAX && y_err <= 2*FILTER_MAX)
497 else if(x_err <= 3*FILTER_MAX && y_err <= 3*FILTER_MAX)
503 x_new = x > x_old[id] ? (x_old[id] + filter_step_x) : (x_old[id] - filter_step_x);
504 y_new = y > y_old[id] ? (y_old[id] + filter_step_y) : (y_old[id] - filter_step_y);
511 static void record_point(u16 x, u16 y , u8 id)
516 id_sign[id]=id_sign[id]+1;
523 x = (x_old[id] + x)/2;
524 y = (y_old[id] + y)/2;
540 if( (x_err > 3 && y_err > 1) || (x_err > 1 && y_err > 3) ){
541 x_new = x; x_old[id] = x;
542 y_new = y; y_old[id] = y;
546 x_new = x; x_old[id] = x;
551 y_new = y; y_old[id] = y;
565 #ifdef HAVE_TOUCH_KEY
566 static void report_key(struct gsl_ts *ts, u16 x, u16 y)
570 for(i = 0; i < MAX_KEY_NUM; i++)
572 if((gsl_key_data[i].x_min < x) && (x < gsl_key_data[i].x_max)&&(gsl_key_data[i].y_min < y) && (y < gsl_key_data[i].y_max))
574 key = gsl_key_data[i].key;
575 input_report_key(ts->input, key, 1);
576 input_sync(ts->input);
584 static void report_data(struct gsl_ts *ts, u16 x, u16 y, u8 pressure, u8 id)
588 print_info("#####id=%d,x=%d,y=%d######\n",id,x,y);
590 if(x>=SCREEN_MAX_X||y>=SCREEN_MAX_Y)
592 #ifdef HAVE_TOUCH_KEY
598 #ifdef REPORT_DATA_ANDROID_4_0
599 input_mt_slot(ts->input, id);
600 input_report_abs(ts->input, ABS_MT_TRACKING_ID, id);
601 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure);
602 input_report_abs(ts->input, ABS_MT_POSITION_X, x);
603 input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
604 input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1);
606 input_report_abs(ts->input, ABS_MT_TRACKING_ID, id);
607 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure);
608 input_report_abs(ts->input, ABS_MT_POSITION_X,x);
609 input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
610 input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1);
611 input_mt_sync(ts->input);
615 static void process_gslX680_data(struct gsl_ts *ts)
621 touches = ts->touch_data[ts->dd->touch_index];
622 for(i=1;i<=MAX_CONTACTS;i++)
626 id_state_flag[i] = 0;
628 for(i= 0;i < (touches > MAX_FINGERS ? MAX_FINGERS : touches);i ++)
630 x = join_bytes( ( ts->touch_data[ts->dd->x_index + 4 * i + 1] & 0xf),
631 ts->touch_data[ts->dd->x_index + 4 * i]);
632 y = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1],
633 ts->touch_data[ts->dd->y_index + 4 * i ]);
634 id = ts->touch_data[ts->dd->id_index + 4 * i] >> 4;
636 if(1 <=id && id <= MAX_CONTACTS)
639 filter_point(x, y ,id);
641 record_point(x, y , id);
643 report_data(ts, x_new, y_new, 50, id);
644 id_state_flag[id] = 1;
647 for(i=1;i<=MAX_CONTACTS;i++)
649 if( (0 == touches) || ((0 != id_state_old_flag[i]) && (0 == id_state_flag[i])) )
651 #ifdef REPORT_DATA_ANDROID_4_0
652 input_mt_slot(ts->input, i);
653 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
654 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
658 id_state_old_flag[i] = id_state_flag[i];
660 #ifndef REPORT_DATA_ANDROID_4_0
663 input_mt_sync(ts->input);
664 #ifdef HAVE_TOUCH_KEY
667 input_report_key(ts->input, key, 0);
668 input_sync(ts->input);
674 input_sync(ts->input);
675 ts->prev_touches = touches;
679 static void gsl_ts_xy_worker(struct work_struct *work)
682 u8 read_buf[4] = {0};
684 struct gsl_ts *ts = container_of(work, struct gsl_ts,work);
686 print_info("---gsl_ts_xy_worker---\n");
688 /* read data from DATA_REG */
689 rc = gsl_ts_read(ts->client, 0x80, ts->touch_data, ts->dd->data_size);
690 print_info("---touches: %d ---\n",ts->touch_data[0]);
694 dev_err(&ts->client->dev, "read failed\n");
698 if (ts->touch_data[ts->dd->touch_index] == 0xff) {
702 rc = gsl_ts_read( ts->client, 0xbc, read_buf, sizeof(read_buf));
705 dev_err(&ts->client->dev, "read 0xbc failed\n");
708 print_info("//////// reg %x : %x %x %x %x\n",0xbc, read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
710 if (read_buf[3] == 0 && read_buf[2] == 0 && read_buf[1] == 0 && read_buf[0] == 0)
712 process_gslX680_data(ts);
716 reset_chip(ts->client);
717 startup_chip(ts->client);
725 static irqreturn_t gsl_ts_irq(int irq, void *dev_id)
727 struct gsl_ts *ts = dev_id;
729 print_info("==========GSLX680 Interrupt============\n");
731 disable_irq_nosync(ts->irq);
733 // if (!work_pending(&ts->work))
735 queue_delayed_work(ts->wq, &ts->work,msecs_to_jiffies(10));
743 static void gsl_timer_handle(unsigned long data)
745 struct gsl_ts *ts = (struct gsl_ts *)data;
748 printk("----------------gsl_timer_handle-----------------\n");
751 disable_irq_nosync(ts->irq);
752 check_mem_data(ts->client);
753 ts->gsl_timer.expires = jiffies + 3 * HZ;
754 add_timer(&ts->gsl_timer);
760 static int gsl_ts_init_ts(struct i2c_client *client, struct gsl_ts *ts)
762 struct input_dev *input_device;
765 printk("[GSLX680] Enter %s\n", __func__);
768 ts->dd = &devices[ts->device_id];
770 if (ts->device_id == 0) {
771 ts->dd->data_size = MAX_FINGERS * ts->dd->touch_bytes + ts->dd->touch_meta_data;
772 ts->dd->touch_index = 0;
775 ts->touch_data = kzalloc(ts->dd->data_size, GFP_KERNEL);
776 if (!ts->touch_data) {
777 pr_err("%s: Unable to allocate memory\n", __func__);
781 ts->prev_touches = 0;
783 input_device = input_allocate_device();
786 goto error_alloc_dev;
789 ts->input = input_device;
790 input_device->name = GSLX680_I2C_NAME;
791 input_device->id.bustype = BUS_I2C;
792 input_device->dev.parent = &client->dev;
793 input_set_drvdata(input_device, ts);
795 #ifdef REPORT_DATA_ANDROID_4_0
796 __set_bit(EV_ABS, input_device->evbit);
797 __set_bit(EV_KEY, input_device->evbit);
798 __set_bit(EV_REP, input_device->evbit);
799 __set_bit(INPUT_PROP_DIRECT, input_device->propbit);
800 input_mt_init_slots(input_device, (MAX_CONTACTS+1));
802 input_set_abs_params(input_device,ABS_MT_TRACKING_ID, 0, (MAX_CONTACTS+1), 0, 0);
803 set_bit(EV_ABS, input_device->evbit);
804 set_bit(EV_KEY, input_device->evbit);
807 #ifdef HAVE_TOUCH_KEY
808 input_device->evbit[0] = BIT_MASK(EV_KEY);
809 //input_device->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
810 for (i = 0; i < MAX_KEY_NUM; i++)
811 set_bit(key_array[i], input_device->keybit);
814 set_bit(ABS_MT_POSITION_X, input_device->absbit);
815 set_bit(ABS_MT_POSITION_Y, input_device->absbit);
816 set_bit(ABS_MT_TOUCH_MAJOR, input_device->absbit);
817 set_bit(ABS_MT_WIDTH_MAJOR, input_device->absbit);
819 input_set_abs_params(input_device,ABS_MT_POSITION_X, 0, SCREEN_MAX_X, 0, 0);
820 input_set_abs_params(input_device,ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y, 0, 0);
821 input_set_abs_params(input_device,ABS_MT_TOUCH_MAJOR, 0, PRESS_MAX, 0, 0);
822 input_set_abs_params(input_device,ABS_MT_WIDTH_MAJOR, 0, 200, 0, 0);
824 client->irq = ts->irq; //IRQ_PORT,
825 //ts->irq = client->irq;
827 ts->wq = create_singlethread_workqueue("kworkqueue_ts");
829 dev_err(&client->dev, "Could not create workqueue\n");
830 goto error_wq_create;
832 flush_workqueue(ts->wq);
834 INIT_DELAYED_WORK(&ts->work, gsl_ts_xy_worker);
836 rc = input_register_device(input_device);
838 goto error_unreg_device;
843 destroy_workqueue(ts->wq);
845 input_free_device(input_device);
847 kfree(ts->touch_data);
851 static int gsl_ts_suspend(struct device *dev)
853 struct gsl_ts *ts = dev_get_drvdata(dev);
856 printk("I'am in gsl_ts_suspend() start\n");
859 printk( "gsl_ts_suspend () : delete gsl_timer\n");
861 del_timer(&ts->gsl_timer);
863 disable_irq_nosync(ts->irq);
865 gslX680_shutdown_low();
870 static int gsl_ts_resume(struct device *dev)
872 struct gsl_ts *ts = dev_get_drvdata(dev);
875 printk("I'am in gsl_ts_resume() start\n");
877 gslX680_shutdown_low();
879 gslX680_shutdown_high();
881 reset_chip(ts->client);
882 startup_chip(ts->client);
883 check_mem_data(ts->client);
886 printk( "gsl_ts_resume () : add gsl_timer\n");
888 init_timer(&ts->gsl_timer);
889 ts->gsl_timer.expires = jiffies + 3 * HZ;
890 ts->gsl_timer.function = &gsl_timer_handle;
891 ts->gsl_timer.data = (unsigned long)ts;
892 add_timer(&ts->gsl_timer);
900 #ifdef CONFIG_HAS_EARLYSUSPEND
901 static void gsl_ts_early_suspend(struct early_suspend *h)
903 struct gsl_ts *ts = container_of(h, struct gsl_ts, early_suspend);
904 printk("[GSL1680] Enter %s\n", __func__);
905 gsl_ts_suspend(&ts->client->dev);
908 static void gsl_ts_late_resume(struct early_suspend *h)
910 struct gsl_ts *ts = container_of(h, struct gsl_ts, early_suspend);
911 printk("[GSL1680] Enter %s\n", __func__);
912 gsl_ts_resume(&ts->client->dev);
916 static int __devinit gsl_ts_probe(struct i2c_client *client,
917 const struct i2c_device_id *id)
919 struct ts_hw_data *pdata = client->dev.platform_data;
924 printk("GSLX680 Enter %s\n", __func__);
925 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
926 dev_err(&client->dev, "I2C functionality not supported\n");
930 ts = kzalloc(sizeof(*ts), GFP_KERNEL);
933 printk("==kzalloc success=\n");
936 ts->device_id = id->driver_data;
938 ts->is_suspended = false;
939 ts->int_pending = false;
940 ts->reset_gpio = pdata->reset_gpio; //lizhengwei
941 ts->irq= gpio_to_irq(pdata->touch_en_gpio); //lizhengwei
942 mutex_init(&ts->sus_lock);
944 ts_global_reset_pin=ts->reset_gpio;
946 i2c_set_clientdata(client, ts);
948 if (pdata->init_platform_hw)
949 pdata->init_platform_hw();
951 rc = gsl_ts_init_ts(client, ts);
953 dev_err(&client->dev, "GSLX680 init failed\n");
954 goto error_mutex_destroy;
957 rc= request_irq(client->irq, gsl_ts_irq, IRQF_TRIGGER_RISING, client->name, ts);
959 printk( "gsl_probe: request irq failed\n");
960 goto error_req_irq_fail;
968 ret = gsl_ts_read( client, 0xf0, &read_buf, sizeof(read_buf) );
971 pr_info("gslx680 I2C transfer error!\n");
972 goto error_req_irq_fail;
977 //gslX680_chip_init();
978 init_chip(ts->client);
979 check_mem_data(ts->client);
983 printk( "gsl_ts_probe () : add gsl_timer\n");
985 init_timer(&ts->gsl_timer);
986 ts->gsl_timer.expires = jiffies + 3 * HZ; //¶¨Ê±3 ÃëÖÓ
987 ts->gsl_timer.function = &gsl_timer_handle;
988 ts->gsl_timer.data = (unsigned long)ts;
989 add_timer(&ts->gsl_timer);
992 /* create debug attribute */
993 //rc = device_create_file(&ts->input->dev, &dev_attr_debug_enable);
995 #ifdef CONFIG_HAS_EARLYSUSPEND
996 ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
997 ts->early_suspend.suspend = gsl_ts_early_suspend;
998 ts->early_suspend.resume = gsl_ts_late_resume;
999 register_early_suspend(&ts->early_suspend);
1002 printk("[GSLX680] End %s\n", __func__);
1006 //exit_set_irq_mode:
1008 free_irq(ts->irq, ts);
1010 error_mutex_destroy:
1011 mutex_destroy(&ts->sus_lock);
1012 input_free_device(ts->input);
1017 static int __devexit gsl_ts_remove(struct i2c_client *client)
1019 struct gsl_ts *ts = i2c_get_clientdata(client);
1020 printk("==gsl_ts_remove=\n");
1022 #ifdef CONFIG_HAS_EARLYSUSPEND
1023 unregister_early_suspend(&ts->early_suspend);
1026 device_init_wakeup(&client->dev, 0);
1027 cancel_delayed_work_sync(&ts->work);
1028 free_irq(ts->irq, ts);
1029 destroy_workqueue(ts->wq);
1030 input_unregister_device(ts->input);
1031 mutex_destroy(&ts->sus_lock);
1033 //device_remove_file(&ts->input->dev, &dev_attr_debug_enable);
1035 kfree(ts->touch_data);
1041 static const struct i2c_device_id gsl_ts_id[] = {
1042 {GSLX680_I2C_NAME, 0},
1045 MODULE_DEVICE_TABLE(i2c, gsl_ts_id);
1048 static struct i2c_driver gsl_ts_driver = {
1050 .name = GSLX680_I2C_NAME,
1051 .owner = THIS_MODULE,
1053 #ifndef CONFIG_HAS_EARLYSUSPEND
1054 .suspend = gsl_ts_suspend,
1055 .resume = gsl_ts_resume,
1057 .probe = gsl_ts_probe,
1058 .remove = __devexit_p(gsl_ts_remove),
1059 .id_table = gsl_ts_id,
1062 static int __init gsl_ts_init(void)
1065 printk("==gsl_ts_init==\n");
1066 ret = i2c_add_driver(&gsl_ts_driver);
1067 printk("ret=%d\n",ret);
1070 static void __exit gsl_ts_exit(void)
1072 printk("==gsl_ts_exit==\n");
1073 i2c_del_driver(&gsl_ts_driver);
1077 module_init(gsl_ts_init);
1078 module_exit(gsl_ts_exit);
1080 MODULE_LICENSE("GPL");
1081 MODULE_DESCRIPTION("GSLX680 touchscreen controller driver");
1082 MODULE_AUTHOR("Guan Yuwei, guanyuwei@basewin.com");
1083 MODULE_ALIAS("platform:gsl_ts");