1 /*---------------------------------------------------------------------------------------------------------
2 * driver/input/touchscreen/goodix_touch.c
4 * Copyright(c) 2010 Goodix Technology Corp. All rights reserved.
8 *---------------------------------------------------------------------------------------------------------*/
9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/time.h>
12 #include <linux/delay.h>
13 #include <linux/device.h>
14 #include <linux/earlysuspend.h>
15 #include <linux/hrtimer.h>
16 #include <linux/i2c.h>
17 #include <linux/input.h>
18 #include <linux/interrupt.h>
20 #include <linux/platform_device.h>
21 //#include <mach/gpio.h>
22 //#include <plat/gpio-cfg.h>
23 //#include <plat/gpio-bank-l.h>
24 //#include <plat/gpio-bank-f.h>
25 #include <linux/irq.h>
26 #include <linux/gpio.h>
27 #include <mach/iomux.h>
28 #include <linux/goodix_touch.h>
29 #include <linux/goodix_queue.h>
32 #error The code does not match the hardware version.
35 static struct workqueue_struct *goodix_wq;
37 /********************************************
38 * 管理当前手指状态的伪队列,对当前手指根据时间顺序排序
40 static struct point_queue finger_list; //record the fingers list
41 /*************************************************/
43 const char *rk29_ts_name = "Goodix TouchScreen of GT80X";
44 /*used by guitar_update module */
45 struct i2c_client * i2c_connect_client = NULL;
46 EXPORT_SYMBOL(i2c_connect_client);
48 #ifdef CONFIG_HAS_EARLYSUSPEND
49 static void goodix_ts_early_suspend(struct early_suspend *h);
50 static void goodix_ts_late_resume(struct early_suspend *h);
53 /*read the gt80x register ,used i2c bus*/
54 static int gt80x_read_regs(struct i2c_client *client, u8 reg, u8 buf[], unsigned len)
57 ret =i2c_master_reg8_recv(client, reg, buf, len, 200*1000);
59 dev_err(&client->dev,"i2c_read fail =%d\n",ret);
62 /* set the gt80x registe,used i2c bus*/
63 static int gt80x_write_regs(struct i2c_client *client, u8 reg, u8 const buf[], unsigned short len)
66 ret = i2c_master_reg8_send(client,reg, buf, len, 200*1000);
68 dev_err(&client->dev,"i2c_write fail =%d\n",ret);
73 /*******************************************************
76 每个读操作用两条i2c_msg组成,第1条消息用于发送从机地址,
77 第2条用于发送读取地址和取回数据;每条消息前发送起始信号
85 *********************************************************/
86 /*Function as i2c_master_send */
87 static int i2c_read_bytes(struct i2c_client *client, uint8_t *buf, int len)
89 struct i2c_msg msgs[2];
92 msgs[0].flags=!I2C_M_RD;//写消息
93 msgs[0].addr=client->addr;
97 msgs[1].flags=I2C_M_RD;//读消息
98 msgs[1].addr=client->addr;
102 ret=i2c_transfer(client->adapter,msgs,2);
106 /*******************************************************
112 buf[1]~buf[len]:数据缓冲区
116 *******************************************************/
117 /*Function as i2c_master_send */
118 static int i2c_write_bytes(struct i2c_client *client,uint8_t *data,int len)
123 msg.flags=!I2C_M_RD;//写消息
124 msg.addr=client->addr;
128 ret=i2c_transfer(client->adapter,&msg,1);
132 /*******************************************************
134 Guitar初始化函数,用于发送配置信息,获取版本信息
139 *******************************************************/
140 static int goodix_init_panel(struct goodix_ts_data *ts)
145 uint8_t config_info[53] = {
146 0x13,0x05,0x04,0x28,0x02,0x14,0x14,0x10,0x50,0xBA,
147 0x14,0x00,0x1E,0x00,0x01,0x23,0x45,0x67,0x89,0xAB,
148 0xCD,0xE1,0x00,0x00,0x00,0x00,0x4D,0xC1,0x20,0x01,
149 0x01,0x83,0x50,0x3C,0x1E,0xB4,0x00,0x33,0x2C,0x01,
150 0xEC,0x3C,0x64,0x32,0x71,0x00,0x00,0x00,0x00,0x00,
154 ret = gt80x_write_regs(ts->client, start_reg, config_info, 53);
156 printk("download gt80x firmware err %d\n", ret);
157 goto error_i2c_transfer;
161 ret = gt80x_read_regs(ts->client, start_reg, buf, 53);
164 printk("\n--%s--Read Register values error !!!\n",__FUNCTION__);
167 for (i = 0; i < 53; i++)
169 if (buf[i] != config_info[i])
171 dev_err(&ts->client->dev,"may be i2c errorat reg_add[%d] = %#x current value = %#x expect value = %#x\n",
172 i, 0x30 + i, buf[i], config_info[i]);
183 static int goodix_read_version(struct goodix_ts_data *ts)
188 //uint8_t version[2]={0x69,0xff}; //command of reading Guitar's version
189 uint8_t version[1]={0xff}; //command of reading Guitar's version
190 //uint8_t version_data[41]; //store touchscreen version infomation
191 uint8_t version_data[40]; //store touchscreen version infomation
192 memset(version_data, 0 , sizeof(version_data));
193 //version_data[0]=0x6A;
194 //ret=i2c_write_bytes(ts->client,version,2);
195 ret = gt80x_write_regs(ts->client, reg1, version, 1);
197 goto error_i2c_version;
200 //ret=i2c_read_bytes(ts->client,version_data, 40);
201 ret = gt80x_read_regs(ts->client, reg2, version_data, 40);
203 goto error_i2c_version;
204 //dev_info(&ts->client->dev," Guitar Version: %s\n", &version_data[1]);
205 printk("%s: Guitar Version: %s\n", __func__, version_data);
207 version[0] = 0x00; //cancel the command
208 //i2c_write_bytes(ts->client, version, 2);
209 ret = gt80x_write_regs(ts->client, reg1, version, 1);
216 /*******************************************************
219 由中断触发,接受1组坐标数据,校验后再分析输出
224 ********************************************************/
225 static void goodix_ts_work_func(struct work_struct *work)
227 static uint8_t finger_bit = 0; //last time fingers' state
228 uint8_t read_position = 0;
229 uint8_t point_data[35] = {0};
230 uint8_t finger = 0; //record which finger is changed
234 //unsigned char start_reg = 0x00;
235 struct goodix_ts_data *ts = container_of(work, struct goodix_ts_data, work);
236 struct goodix_i2c_rmi_platform_data *pdata = ts->client->dev.platform_data;
238 //#ifdef SHUTDOWN_PORT
239 if (pdata && pdata->shutdown_pin) {
240 //if (gpio_get_value(SHUTDOWN_PORT))
241 if (gpio_get_value(pdata->shutdown_pin))
243 //printk(KERN_ALERT "Guitar stop working.The data is invalid. \n");
249 //if i2c transfer is failed, let it restart less than 10 times
251 if(!ts->use_irq && (ts->timer.state != HRTIMER_STATE_INACTIVE))
252 hrtimer_cancel(&ts->timer);
253 dev_info(&(ts->client->dev), "Because of transfer error, %s stop working.\n",rk29_ts_name);
259 ret = gt80x_read_regs(ts->client, point_data[0], &point_data[1], 34);
262 //dev_err(&(ts->client->dev),"I2C transfer error. Number:%d\n ", ret);
272 goodix_init_panel(ts);
279 //The bit indicate which fingers pressed down
280 switch (point_data[1] & 0x1f)
284 for (count = 1; count < 8; count++)
285 check_sum += (int)point_data[count];
286 if ((check_sum % 256) != point_data[8])
291 for ( count = 1; count < 13; count++)
292 check_sum += (int)point_data[count];
293 if ((check_sum % 256) != point_data[13])
296 default: //(point_data[1]& 0x1f) > 3
297 for (count = 1; count < 34; count++)
298 check_sum += (int)point_data[count];
299 if ((check_sum % 256) != point_data[34])
303 point_data[1] &= 0x1f;
304 finger = finger_bit ^ point_data[1];
305 if (finger == 0 && point_data[1] == 0)
306 goto NO_ACTION; //no fingers and no action
307 else if(finger == 0) //the same as last time
309 //check which point(s) DOWN or UP
310 for (count = 0; (finger != 0) && (count < MAX_FINGER_NUM); count++)
312 if ((finger & 0x01) == 1) //current bit is 1, so NO.postion finger is change
314 if (((finger_bit >> count) & 0x01) ==1 ) //NO.postion finger is UP
315 set_up_point(&finger_list, count);
317 add_point(&finger_list, count);
323 for(count = 0; count < finger_list.length; count++)
325 if(finger_list.pointer[count].state == FLAG_UP)
327 finger_list.pointer[count].x = finger_list.pointer[count].y = 0;
328 finger_list.pointer[count].pressure = 0;
332 if(finger_list.pointer[count].num < 3)
333 read_position = finger_list.pointer[count].num*5 + 3;
334 else if (finger_list.pointer[count].num == 4)
337 if(finger_list.pointer[count].num != 3)
339 finger_list.pointer[count].x = (unsigned int) (point_data[read_position]<<8) + (unsigned int)( point_data[read_position+1]);
340 finger_list.pointer[count].y = (unsigned int)(point_data[read_position+2]<<8) + (unsigned int) (point_data[read_position+3]);
341 finger_list.pointer[count].pressure = (unsigned int) (point_data[read_position+4]);
345 finger_list.pointer[count].x = (unsigned int) (point_data[18]<<8) + (unsigned int)( point_data[25]);
346 finger_list.pointer[count].y = (unsigned int)(point_data[26]<<8) + (unsigned int) (point_data[27]);
347 finger_list.pointer[count].pressure = (unsigned int) (point_data[28]);
350 // 将触摸屏的坐标映射到LCD坐标上. 触摸屏短边为X轴,LCD坐标一般长边为X轴,可能需要调整原点位置
351 finger_list.pointer[count].x = (TOUCH_MAX_WIDTH - finger_list.pointer[count].x)*SCREEN_MAX_WIDTH/TOUCH_MAX_WIDTH;//y
352 finger_list.pointer[count].y = finger_list.pointer[count].y*SCREEN_MAX_HEIGHT/TOUCH_MAX_HEIGHT ; //x
353 gt80xy_swap(finger_list.pointer[count].x, finger_list.pointer[count].y);
355 //printk("%s: dx = %d dy = %d\n", __func__,
356 // finger_list.pointer[count].x, finger_list.pointer[count].y);
360 #ifndef GOODIX_MULTI_TOUCH
361 if(finger_list.pointer[0].state == FLAG_DOWN)
363 input_report_abs(ts->input_dev, ABS_X, finger_list.pointer[0].x);
364 input_report_abs(ts->input_dev, ABS_Y, finger_list.pointer[0].y);
366 input_report_abs(ts->input_dev, ABS_PRESSURE, pressure[0]);
367 input_report_key(ts->input_dev, BTN_TOUCH, finger_list.pointer[0].state);
370 /* ABS_MT_TOUCH_MAJOR is used as ABS_MT_PRESSURE in android. */
371 for(count = 0; count < (finger_list.length); count++)
373 if(finger_list.pointer[count].state == FLAG_DOWN)
375 input_report_abs(ts->input_dev, ABS_MT_POSITION_X, finger_list.pointer[count].x);
376 input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, finger_list.pointer[count].y);
378 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, finger_list.pointer[count].pressure);
379 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, finger_list.pointer[count].pressure);
380 input_mt_sync(ts->input_dev);
383 read_position = finger_list.length-1;
384 if(finger_list.length > 0 && finger_list.pointer[read_position].state == FLAG_DOWN)
386 input_report_abs(ts->input_dev, ABS_MT_POSITION_X, finger_list.pointer[read_position].x);
387 input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, finger_list.pointer[read_position].y);
389 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, finger_list.pointer[read_position].pressure);
390 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, finger_list.pointer[read_position].pressure);
391 input_mt_sync(ts->input_dev);
394 input_sync(ts->input_dev);
396 del_point(&finger_list);
397 finger_bit=point_data[1];
402 enable_irq(ts->client->irq);
406 /*******************************************************
409 由计时器触发,调度触摸屏工作函数运行;之后重新计时
413 计时器工作模式,HRTIMER_NORESTART表示不需要自动重启
414 ********************************************************/
415 static enum hrtimer_restart goodix_ts_timer_func(struct hrtimer *timer)
417 struct goodix_ts_data *ts = container_of(timer, struct goodix_ts_data, timer);
418 queue_work(goodix_wq, &ts->work);
419 if(ts->timer.state != HRTIMER_STATE_INACTIVE)
420 hrtimer_start(&ts->timer, ktime_set(0, 16000000), HRTIMER_MODE_REL);
421 return HRTIMER_NORESTART;
424 /*******************************************************
431 计时器工作模式,HRTIMER_NORESTART表示不需要自动重启
432 ********************************************************/
433 //#if defined(INT_PORT)
434 static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
436 struct goodix_ts_data *ts = dev_id;
438 disable_irq_nosync(ts->client->irq);
439 queue_work(goodix_wq, &ts->work);
445 /*******************************************************
449 on:设置GT80X运行模式,0为进入Sleep模式
452 ********************************************************/
453 //#if defined(SHUTDOWN_PORT)
454 static int goodix_ts_power(struct goodix_ts_data * ts, int on)
457 struct goodix_i2c_rmi_platform_data *pdata = NULL;
459 if(ts == NULL || (ts && !ts->use_shutdown))
462 pdata = ts->client->dev.platform_data;
467 gpio_set_value(pdata->shutdown_pin, 1);
469 if(gpio_get_value(pdata->shutdown_pin)) //has been suspend
473 gpio_set_value(pdata->shutdown_pin, 0);
475 if(gpio_get_value(pdata->shutdown_pin)) //has been suspend
479 ret = goodix_init_panel(ts);
484 //default:printk("Command ERROR.\n");
486 printk(on?"Set Guitar's Shutdown LOW\n":"Set Guitar's Shutdown HIGH\n");
491 /*******************************************************
494 在注册驱动时调用(要求存在对应的client);
495 用于IO,中断等资源申请;设备注册;触摸屏初始化等工作
501 ********************************************************/
502 static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
504 struct goodix_ts_data *ts;
509 u8 test_buf[] = {0x01};
511 struct goodix_i2c_rmi_platform_data *pdata;
512 pdata = client->dev.platform_data;
514 dev_dbg(&client->dev,"Install touchscreen driver for guitar.\n");
516 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
518 dev_err(&client->dev, "System need I2C function.\n");
520 goto err_check_functionality_failed;
523 ts = kzalloc(sizeof(*ts), GFP_KERNEL);
526 goto err_alloc_data_failed;
529 //#ifdef SHUTDOWN_PORT
530 if (pdata && pdata->shutdown_pin) {
531 //ret = gpio_request(SHUTDOWN_PORT, "TS_SHUTDOWN"); //Request IO
532 ret = gpio_request(pdata->shutdown_pin, "TS_SHUTDOWN"); //Request IO
535 //printk(KERN_ALERT "Failed to request GPIO:%d, ERRNO:%d\n",(int)SHUTDOWN_PORT,ret);
536 printk(KERN_ALERT "Failed to request GPIO:%d, ERRNO:%d\n",(int)pdata->shutdown_pin,ret);
537 goto err_gpio_request;
539 //gpio_direction_output(SHUTDOWN_PORT, 0); //Touchscreen is waiting to wakeup
540 //ret = gpio_get_value(SHUTDOWN_PORT);
541 gpio_direction_output(pdata->shutdown_pin, 0); //Touchscreen is waiting to wakeup
542 ret = gpio_get_value(pdata->shutdown_pin);
545 printk(KERN_ALERT "Cannot set touchscreen to work.\n");
551 i2c_connect_client = client; //used by Guitar Updating.
554 for (retry = 0; retry < 5; retry++)
556 ret = gt80x_write_regs(client, test_reg, test_buf, 1); //Test i2c.
562 dev_err(&client->dev, "Warnning: I2C connection might be something wrong!\n");
566 //#ifdef SHUTDOWN_PORT
567 if (pdata && pdata->shutdown_pin) {
568 ts->use_shutdown = 1;
569 //gpio_set_value(SHUTDOWN_PORT, 1);
570 gpio_set_value(pdata->shutdown_pin, 1);
574 INIT_WORK(&ts->work, goodix_ts_work_func);
576 i2c_set_clientdata(client, ts);
577 //pdata = client->dev.platform_data;
579 ts->input_dev = input_allocate_device();
580 if (ts->input_dev == NULL) {
582 dev_dbg(&client->dev,"Failed to allocate input device\n");
583 goto err_input_dev_alloc_failed;
586 ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ;
587 #ifndef GOODIX_MULTI_TOUCH
588 ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
589 ts->input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
590 // | BIT_MASK(ABS_MT_TOUCH_MAJOR)| BIT_MASK(ABS_MT_WIDTH_MAJOR)
591 // BIT_MASK(ABS_MT_POSITION_X) |
592 // BIT_MASK(ABS_MT_POSITION_Y); // for android
594 input_set_abs_params(ts->input_dev, ABS_X, 0, SCREEN_MAX_HEIGHT, 0, 0);
595 input_set_abs_params(ts->input_dev, ABS_Y, 0, SCREEN_MAX_WIDTH, 0, 0);
596 input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, 0, 0);
598 input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
599 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
600 input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, SCREEN_MAX_HEIGHT, 0, 0);
601 input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, SCREEN_MAX_WIDTH, 0, 0);
604 sprintf(ts->phys, "input/ts)");
605 ts->input_dev->name = rk29_ts_name;
606 ts->input_dev->phys = ts->phys;
607 ts->input_dev->id.bustype = BUS_I2C;
608 ts->input_dev->id.vendor = 0xDEAD;
609 ts->input_dev->id.product = 0xBEEF;
610 ts->input_dev->id.version = 10427;
612 finger_list.length = 0;
613 ret = input_register_device(ts->input_dev);
615 dev_err(&client->dev,"Probe: Unable to register %s input device\n", ts->input_dev->name);
616 goto err_input_register_device_failed;
622 //#if defined(INT_PORT)
623 //client->irq=TS_INT;
624 //gpio_set_value(TS_INT, 0);
626 if (pdata && pdata->irq_pin) {
627 client->irq = gpio_to_irq(client->irq);
630 //ret = gpio_request(INT_PORT, "TS_INT"); //Request IO
631 ret = gpio_request(pdata->irq_pin, "TS_INT"); //Request IO
634 //dev_err(&client->dev, "Failed to request GPIO:%d, ERRNO:%d\n",(int)INT_PORT,ret);
635 dev_err(&client->dev, "Failed to request GPIO:%d, ERRNO:%d\n", (int)pdata->irq_pin, ret);
636 goto err_int_request_failed;
638 //ret = s3c_gpio_cfgpin(INT_PORT, INT_CFG); //Set IO port function
639 ret = request_irq(client->irq, goodix_ts_irq_handler , IRQ_TYPE_EDGE_RISING,
642 dev_err(&client->dev,"Can't allocate touchscreen's interrupt!ERRNO:%d\n", ret);
643 //gpio_direction_input(INT_PORT);
644 //gpio_free(INT_PORT);
645 gpio_direction_input(pdata->irq_pin);
646 gpio_free(pdata->irq_pin);
647 goto err_int_request_failed;
651 //disable_irq(TS_INT);
652 disable_irq(client->irq);
654 dev_dbg(&client->dev,"Reques EIRQ %d succesd on GPIO:%d\n",client->irq, pdata->irq_pin);
660 err_int_request_failed:
663 hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
664 ts->timer.function = goodix_ts_timer_func;
665 hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
668 //#ifdef SHUTDOWN_PORT
669 if (pdata && pdata->shutdown_pin) {
670 //gpio_set_value(SHUTDOWN_PORT, 0);
671 gpio_set_value(pdata->shutdown_pin, 0);
673 ts->power = goodix_ts_power;
676 for(count = 0; count < 3; count++)
678 ret = goodix_init_panel(ts);
679 if(ret != 0) //Initiall failed
684 enable_irq(client->irq);
685 //enable_irq(TS_INT);
691 goto err_init_godix_ts;
693 goodix_read_version(ts);
696 #ifdef CONFIG_HAS_EARLYSUSPEND
697 ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
698 ts->early_suspend.suspend = goodix_ts_early_suspend;
699 ts->early_suspend.resume = goodix_ts_late_resume;
700 register_early_suspend(&ts->early_suspend);
702 dev_info(&client->dev,"Start %s in %s mode\n",
703 ts->input_dev->name, ts->use_irq ? "Interrupt" : "Polling");
709 //free_irq(TS_INT,ts);
710 free_irq(client->irq,ts);
711 //#if defined(INT_PORT)
712 if (pdata && pdata->irq_pin)
713 gpio_free(pdata->irq_pin);
717 err_input_register_device_failed:
718 input_free_device(ts->input_dev);
720 err_input_dev_alloc_failed:
721 i2c_set_clientdata(client, NULL);
723 //#ifdef SHUTDOWN_PORT
724 if (pdata && pdata->shutdown_pin) {
725 //gpio_direction_input(SHUTDOWN_PORT);
726 //gpio_free(SHUTDOWN_PORT);
727 gpio_direction_input(pdata->shutdown_pin);
728 gpio_free(pdata->shutdown_pin);
733 err_alloc_data_failed:
734 err_check_functionality_failed:
739 /*******************************************************
746 ********************************************************/
747 static int goodix_ts_remove(struct i2c_client *client)
749 struct goodix_ts_data *ts = i2c_get_clientdata(client);
750 struct goodix_i2c_rmi_platform_data *pdata;
751 pdata = client->dev.platform_data;
752 #ifdef CONFIG_HAS_EARLYSUSPEND
753 unregister_early_suspend(&ts->early_suspend);
757 free_irq(client->irq, ts);
758 //#if defined(INT_PORT)
759 if (pdata && pdata->irq_pin)
760 gpio_free(pdata->irq_pin);
761 //gpio_free(INT_PORT);
765 hrtimer_cancel(&ts->timer);
767 //#ifdef SHUTDOWN_PORT
768 if (pdata && pdata->shutdown_pin) {
771 //gpio_direction_input(SHUTDOWN_PORT);
772 //gpio_free(SHUTDOWN_PORT);
773 gpio_direction_input(pdata->shutdown_pin);
774 gpio_free(pdata->shutdown_pin);
778 dev_notice(&client->dev,"The driver is removing...\n");
779 i2c_set_clientdata(client, NULL);
780 input_unregister_device(ts->input_dev);
782 kfree(ts->input_dev);
788 static int goodix_ts_suspend(struct i2c_client *client, pm_message_t mesg)
791 struct goodix_ts_data *ts = i2c_get_clientdata(client);
794 disable_irq(client->irq);
795 else if(ts->timer.state)
796 hrtimer_cancel(&ts->timer);
797 ret = cancel_work_sync(&ts->work);
798 if(ret && ts->use_irq)
799 enable_irq(client->irq);
801 ret = ts->power(ts,0);
803 printk(KERN_ERR "%s power off failed\n", rk29_ts_name);
808 static int goodix_ts_resume(struct i2c_client *client)
811 struct goodix_ts_data *ts = i2c_get_clientdata(client);
814 ret = ts->power(ts, 1);
816 printk(KERN_ERR "%s power on failed\n", rk29_ts_name);
820 enable_irq(client->irq);
822 hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
826 #ifdef CONFIG_HAS_EARLYSUSPEND
827 static void goodix_ts_early_suspend(struct early_suspend *h)
829 struct goodix_ts_data *ts;
830 ts = container_of(h, struct goodix_ts_data, early_suspend);
831 goodix_ts_suspend(ts->client, PMSG_SUSPEND);
834 static void goodix_ts_late_resume(struct early_suspend *h)
836 struct goodix_ts_data *ts;
837 ts = container_of(h, struct goodix_ts_data, early_suspend);
838 goodix_ts_resume(ts->client);
842 //可用于该驱动的 设备名—设备ID 列表
844 static const struct i2c_device_id goodix_ts_id[] = {
845 { GOODIX_I2C_NAME, 0 },
850 static struct i2c_driver goodix_ts_driver = {
851 .probe = goodix_ts_probe,
852 .remove = goodix_ts_remove,
853 #ifndef CONFIG_HAS_EARLYSUSPEND
854 .suspend = goodix_ts_suspend,
855 .resume = goodix_ts_resume,
857 .id_table = goodix_ts_id,
859 .name = GOODIX_I2C_NAME,
860 .owner = THIS_MODULE,
864 /*******************************************************
869 ********************************************************/
870 static int __devinit goodix_ts_init(void)
873 //printk(KERN_DEBUG "%s is installing...\n", rk29_ts_name);
874 goodix_wq = create_workqueue("goodix_wq");
876 printk(KERN_ALERT "Creat workqueue faiked\n");
880 ret=i2c_add_driver(&goodix_ts_driver);
884 /*******************************************************
889 ********************************************************/
890 static void __exit goodix_ts_exit(void)
892 printk(KERN_DEBUG "%s is exiting...\n", rk29_ts_name);
893 i2c_del_driver(&goodix_ts_driver);
895 destroy_workqueue(goodix_wq);
898 late_initcall(goodix_ts_init);
899 module_exit(goodix_ts_exit);
901 MODULE_DESCRIPTION("Goodix Touchscreen Driver");
902 MODULE_LICENSE("GPL");