1 /* drivers/input/touchscreen/goodix_touch.c
\r
3 * Copyright (C) 2010 - 2011 Goodix, Inc.
\r
5 * This program is free software; you can redistribute it and/or modify
\r
6 * it under the terms of the GNU General Public License as published by
\r
7 * the Free Software Foundation; either version 2 of the License, or
\r
8 * (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful, but WITHOUT
\r
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
16 #include <linux/kernel.h>
\r
17 #include <linux/module.h>
\r
18 #include <linux/time.h>
\r
19 #include <linux/delay.h>
\r
20 #include <linux/device.h>
\r
21 #include <linux/earlysuspend.h>
\r
22 #include <linux/hrtimer.h>
\r
23 #include <linux/i2c.h>
\r
24 #include <linux/input.h>
\r
25 #include <linux/input/mt.h>
\r
27 #include <linux/interrupt.h>
\r
28 #include <linux/io.h>
\r
29 #include <linux/platform_device.h>
\r
30 #include <mach/gpio.h>
\r
32 #include <linux/irq.h>
\r
33 #include <linux/syscalls.h>
\r
34 #include <linux/reboot.h>
\r
35 #include <linux/proc_fs.h>
\r
36 #include "rk29_i2c_goodix.h"
\r
38 #include <linux/vmalloc.h>
\r
39 #include <linux/fs.h>
\r
40 #include <linux/string.h>
\r
41 #include <linux/completion.h>
\r
42 #include <asm/uaccess.h>
\r
43 #include <mach/board.h>
\r
46 #define PEN_RELEASE 0
\r
47 #define PEN_DOWN_UP 2 //fjp
\r
49 static struct rk_touch_info *info_buf;
\r
51 static int dbg_thresd = 0;
\r
52 #define DBG(x...) do { if(unlikely(dbg_thresd)) printk(KERN_INFO x); } while (0)
\r
55 /*******************************************************
\r
57 Read data from the i2c slave device;
\r
58 This operation consisted of 2 i2c_msgs,the first msg used
\r
59 to write the operate address,the second msg used to read data.
\r
63 buf[0]:operate address.
\r
64 buf[1]~buf[len]:read data buffer.
\r
68 numbers of i2c_msgs to transfer
\r
69 *********************************************************/
\r
70 static int goodix_i2c_read_bytes(struct i2c_client *client, uint8_t *buf, int len)
\r
72 struct i2c_msg msgs[2];
\r
76 msgs[0].flags = client->flags;
\r
77 msgs[0].addr=client->addr;
\r
79 msgs[0].buf=&buf[0];
\r
80 msgs[0].udelay = client->udelay;
\r
81 msgs[0].scl_rate=200 * 1000;
\r
83 msgs[1].flags = client->flags | I2C_M_RD;
\r
84 msgs[1].addr=client->addr;
\r
86 msgs[1].buf=&buf[1];
\r
87 msgs[1].udelay = client->udelay;
\r
88 msgs[1].scl_rate=200 * 1000;
\r
90 //disable_irq(client->irq);
\r
93 ret=i2c_transfer(client->adapter,msgs, 2);
\r
97 //enable_irq(client->irq);
\r
101 /*******************************************************
\r
103 write data to the i2c slave device.
\r
106 client: i2c device.
\r
107 buf[0]:operate address.
\r
108 buf[1]~buf[len]:write data buffer.
\r
109 len:operate length.
\r
112 numbers of i2c_msgs to transfer.
\r
113 *********************************************************/
\r
114 static int goodix_i2c_write_bytes(struct i2c_client *client,uint8_t *data,int len)
\r
116 struct i2c_msg msg;
\r
120 msg.flags=!I2C_M_RD;
\r
121 msg.addr=client->addr;
\r
124 msg.udelay = client->udelay;
\r
125 msg.scl_rate=200 * 1000;
\r
127 //disable_irq(client->irq);
\r
130 ret=i2c_transfer(client->adapter,&msg, 1);
\r
134 //enable_irq(client->irq);
\r
138 /*******************************************************
\r
140 Goodix touchscreen initialize function.
\r
143 ts: i2c client private struct.
\r
146 Executive outcomes.0---succeed.
\r
147 *******************************************************/
\r
148 static int goodix_init_panel(struct rk_ts_data *ts)
\r
151 uint8_t rd_cfg_buf[7] = {0x66,};
\r
153 #ifdef GOODIX_1024X768 //for malata 10.1
\r
154 uint8_t config_info[] = {
\r
155 0x65,0x02,0x04,0x00,0x03,0x00,0x0A,0x22,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C,
\r
156 0x41,0x41,0x20,0x09,0x00,0xA0,0xA0,0x3C,0x64,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,
\r
157 0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x1D,0x1C,0x1B,0x1A,0x19,0x18,
\r
158 0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,
\r
159 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
\r
160 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
\r
165 uint8_t config_info[] = {
\r
166 0x65,0x02,0x05,0x00,0x03,0x20,0x0A,0x22,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C,
\r
167 0x42,0x42,0x20,0x00,0x00,0x89,0x89,0x3C,0x64,0x0E,0x0D,0x0C,0x0B,
\r
168 0x0A,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x1D,0x1C,
\r
169 0x1B,0x1A,0x19,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0F,
\r
170 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
\r
171 0x2B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
\r
172 0x00,0x00,0x00,0x00
\r
175 ret=goodix_i2c_write_bytes(ts->client,config_info, (sizeof(config_info)/sizeof(config_info[0])));
\r
177 printk("goodix write cfg info err");
\r
180 ret=goodix_i2c_read_bytes(ts->client, rd_cfg_buf, 7);
\r
183 dev_info(&ts->client->dev, "Read resolution & max_touch_num failed, use default value!\n");
\r
184 ts->max_touch_num = MAX_FINGER_NUM;
\r
185 //ts->int_trigger_type = INT_TRIGGER;
\r
188 ts->abs_x_max = (rd_cfg_buf[1]<<8) + rd_cfg_buf[2];
\r
189 ts->abs_y_max = (rd_cfg_buf[3]<<8) + rd_cfg_buf[4];
\r
190 ts->max_touch_num = rd_cfg_buf[5];
\r
191 //ts->int_trigger_type = rd_cfg_buf[6]&0x03;
\r
192 if((!ts->abs_x_max)||(!ts->abs_y_max)||(!ts->max_touch_num))
\r
194 printk(KERN_INFO "Read invalid resolution & max_touch_num, use default value!\n");
\r
195 ts->max_touch_num = MAX_FINGER_NUM;
\r
198 printk(KERN_INFO "X_MAX = %d,Y_MAX = %d,MAX_TOUCH_NUM = %d\n",ts->abs_x_max,ts->abs_y_max,ts->max_touch_num);
\r
200 rd_cfg_buf[0] = 0x6e;
\r
201 rd_cfg_buf[1] = 0x00;
\r
202 goodix_i2c_read_bytes(ts->client, rd_cfg_buf, 2);
\r
203 if((rd_cfg_buf[1]&0x0f)==0x0f)
\r
205 dev_info(&ts->client->dev, "Need int wake up from green mode!\n");
\r
212 //fjp add ===============================
\r
213 static bool goodix_get_status(char *p1,int*p2)
\r
215 bool status = PEN_DOWN;
\r
216 if((*p2==PEN_DOWN) && (*p1==PEN_RELEASE))
\r
218 *p2 = PEN_DOWN_UP; //¸Õ¸Õµ¯Æð
\r
219 status = PEN_RELEASE;
\r
221 else if((*p2==PEN_RELEASE) && (*p1==PEN_RELEASE))
\r
224 status = PEN_RELEASE;
\r
233 //===================================
\r
234 /*******************************************************
\r
236 Read goodix touchscreen version function.
\r
239 ts: i2c client private struct.
\r
242 Executive outcomes.0---succeed.
\r
243 *******************************************************/
\r
244 static int goodix_read_version(struct rk_ts_data *ts, char **version)
\r
246 int ret = -1, count = 0;
\r
247 char *version_data;
\r
250 *version = (char *)vmalloc(18);
\r
251 version_data = *version;
\r
255 memset(version_data, 0, sizeof(version_data));
\r
256 version_data[0]=240;
\r
257 ret=goodix_i2c_read_bytes(ts->client,version_data, 17);
\r
260 version_data[17]='\0';
\r
266 if((*p > 122) || (*p < 48 && *p != 32) || (*p >57 && *p < 65)
\r
267 ||(*p > 90 && *p < 97 && *p != '_')) //check illeqal character
\r
269 }while(*++p != '\0' );
\r
276 static int last_touch_num = -1;
\r
277 static void goodix_get_touch_info(struct rk_ts_data *ts,char *point_num,struct rk_touch_info* info_buf)
\r
279 uint8_t point_data[(1-READ_COOR_ADDR)+1+2+5*MAX_FINGER_NUM+1]={ 0 }; //read address(1byte)+key index(1byte)+point mask(2bytes)+5bytes*MAX_FINGER_NUM+coor checksum(1byte)
\r
280 uint8_t check_sum = 0;
\r
282 uint16_t finger_current = 0;
\r
283 uint16_t finger_bit = 0;
\r
284 unsigned int count = 0, point_count = 0;
\r
285 unsigned char touch_num = 0;
\r
286 uint8_t chksum_err = 0;
\r
287 unsigned int position = 0;
\r
288 uint8_t track_id[MAX_FINGER_NUM] = {0};
\r
291 point_data[0] = READ_COOR_ADDR; //read coor address
\r
294 ret=goodix_i2c_read_bytes(ts->client, point_data, sizeof(point_data)/sizeof(point_data[0]));
\r
297 printk("goodix read error\n");
\r
299 finger_current = (point_data[3 - READ_COOR_ADDR]<<8) + point_data[2 - READ_COOR_ADDR];
\r
301 DBG("finger_current:%d ==== max_touch_num:%d\n", finger_current,ts->max_touch_num);//add by fjp 2010-9-28
\r
307 finger_bit = finger_current;
\r
308 for(count = 0; (finger_bit != 0) && (count < ts->max_touch_num); count++)//cal how many point touch currntly
\r
310 if(finger_bit & 0x01)
\r
312 track_id[count] = PEN_DOWN;
\r
317 touch_num = point_count;
\r
319 check_sum = point_data[2 - READ_COOR_ADDR] + point_data[3 - READ_COOR_ADDR]; //cal coor checksum
\r
320 count = 4 - READ_COOR_ADDR;
\r
321 for(point_count *= 5; point_count > 0; point_count--)
\r
322 check_sum += point_data[count++];
\r
323 check_sum += point_data[count];
\r
324 if(check_sum != 0) //checksum verify error
\r
326 printk("coor checksum error!\n");
\r
334 //printk("current point num:%d\n",touch_num);
\r
335 *point_num = touch_num;
\r
336 if(touch_num < last_touch_num) //some flinger release
\r
338 //printk("%d flinger release\n",last_touch_num-touch_num);
\r
339 /*for(index = touch_num; index < last_touch_num; index++)
\r
340 info_buf[index].status = 0;*/
\r
341 *point_num = last_touch_num;
\r
342 touch_num = last_touch_num;
\r
344 last_touch_num = touch_num;
\r
345 for(index = 0; index < touch_num; index++)
\r
347 if(goodix_get_status(&track_id[index],&info_buf[index].status))
\r
349 position = 4 - READ_COOR_ADDR + 5*(temp++);
\r
350 info_buf[index].x = (unsigned int) (point_data[position]<<8) + (unsigned int)( point_data[position+1]);
\r
351 info_buf[index].y = (unsigned int)(point_data[position+2]<<8) + (unsigned int) (point_data[position+3]);
\r
352 info_buf[index].press = (unsigned int) (point_data[position+4]);
\r
359 /*******************************************************
\r
361 Goodix touchscreen work function.
\r
364 ts: i2c client private struct.
\r
367 Executive outcomes.0---succeed.
\r
368 *******************************************************/
\r
369 static void rk_ts_work_func(struct work_struct *pwork)
\r
372 //struct rk_touch_info *info_buf;
\r
374 struct rk_ts_data *ts = container_of(to_delayed_work(pwork), struct rk_ts_data, ts_work);
\r
377 printk("container of rk_ts_data fail\n");
\r
380 // info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL);
\r
383 // printk(KERN_ALERT "alloc for rk_touch_info fail\n");
\r
387 if(ts->get_touch_info)
\r
389 ts->get_touch_info(ts,&point_num,info_buf);
\r
391 for(i=0; i< point_num; i++)
\r
393 DBG("info_buf[i].status =====%d\n",info_buf[i].status);
\r
394 if(info_buf[i].status==PEN_DOWN_UP)
\r
396 info_buf[i].status=PEN_RELEASE;
\r
397 DBG("the key %d is up------\n",i);
\r
398 input_mt_slot(ts->input_dev, i);
\r
399 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false);
\r
402 if(info_buf[i].status==PEN_DOWN)
\r
404 input_mt_slot(ts->input_dev, i);
\r
405 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
\r
406 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, info_buf[i].press);
\r
407 input_report_abs(ts->input_dev, ABS_MT_POSITION_X, info_buf[i].x);
\r
408 input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, info_buf[i].y);
\r
409 DBG("touch point %d %d >>x:%d>>y:%d\n",i,info_buf[i].status,info_buf[i].x,info_buf[i].y);//add by fjp 2010-9-28
\r
417 input_sync(ts->input_dev);
\r
419 if(gpio_get_value(ts->irq_pin) == GPIO_LOW)
\r
422 DBG("touch down .............\n");//add by fjp 2010-9-28
\r
423 queue_delayed_work(ts->ts_wq, &ts->ts_work,msecs_to_jiffies(20));
\r
430 DBG("touch up>>x:%d>>y:%d\n",info_buf[0].x,info_buf[0].y);//add by fjp 2010-9-28
\r
431 /*input_mt_slot(ts->input_dev, 0);
\r
432 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
\r
433 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0);
\r
435 input_mt_slot(ts->input_dev, 0);
\r
436 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false);*/
\r
438 DBG("point_num+++++++++++ = %d\n", point_num);//add by fjp 2010-9-28
\r
439 for(i=0; i< point_num; i++)
\r
441 // printk("info_buf[i].status +++++++%d\n",info_buf[i].status);
\r
442 if(info_buf[i].status)
\r
444 input_mt_slot(ts->input_dev, i);//°´ÐòºÅÉϱ¨
\r
445 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false);
\r
446 //input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0);
\r
447 info_buf[i].status= PEN_RELEASE;
\r
450 DBG("release+++++++++++ = %d\n", i);//add by fjp 2010-9-28
\r
454 input_sync(ts->input_dev);
\r
455 ts->pendown =PEN_RELEASE;
\r
456 last_touch_num = 0;
\r
458 enable_irq(ts->irq);
\r
470 /*******************************************************
\r
472 Timer interrupt service routine.
\r
475 timer: timer struct pointer.
\r
478 Timer work mode. HRTIMER_NORESTART---not restart mode
\r
479 *******************************************************/
\r
480 static enum hrtimer_restart goodix_ts_timer_func(struct hrtimer *timer)
\r
482 struct rk_ts_data *ts = container_of(timer, struct rk_ts_data, timer);
\r
483 queue_delayed_work(goodix_wq,&ts->ts_work,0);
\r
484 hrtimer_start(&ts->timer, ktime_set(0, (POLL_TIME+6)*1000000), HRTIMER_MODE_REL);
\r
485 return HRTIMER_NORESTART;
\r
488 /*******************************************************
\r
490 External interrupt service routine.
\r
493 irq: interrupt number.
\r
494 dev_id: private data pointer.
\r
497 irq execute status.
\r
498 *******************************************************/
\r
499 static irqreturn_t rk_ts_irq_handler(int irq, void *dev_id)
\r
502 struct rk_ts_data *ts = (struct rk_ts_data*)dev_id;
\r
503 disable_irq_nosync(ts->irq);
\r
504 queue_delayed_work(ts->ts_wq, &ts->ts_work,0);
\r
506 return IRQ_HANDLED;
\r
509 static int rk_ts_suspend(struct i2c_client *client, pm_message_t mesg)
\r
512 struct rk_ts_data *ts = i2c_get_clientdata(client);
\r
516 disable_irq(ts->irq);
\r
520 ret = ts->power(ts, 0);
\r
522 printk(KERN_ERR "goodix_ts_resume power off failed\n");
\r
528 static int rk_ts_resume(struct i2c_client *client)
\r
531 struct rk_ts_data *ts = i2c_get_clientdata(client);
\r
535 ret = ts->power(ts, 1);
\r
537 printk(KERN_ERR "goodix_ts_resume power on failed\n");
\r
541 enable_irq(client->irq);
\r
548 #ifdef CONFIG_HAS_EARLYSUSPEND
\r
549 static void rk_ts_early_suspend(struct early_suspend *h)
\r
551 struct rk_ts_data *ts;
\r
552 ts = container_of(h, struct rk_ts_data, early_suspend);
\r
553 rk_ts_suspend(ts->client, PMSG_SUSPEND);
\r
556 static void rk_ts_late_resume(struct early_suspend *h)
\r
558 struct rk_ts_data *ts;
\r
559 ts = container_of(h, struct rk_ts_data, early_suspend);
\r
560 rk_ts_resume(ts->client);
\r
564 /*******************************************************
\r
566 Goodix touchscreen power manage function.
\r
569 on: power status.0---suspend;1---resume.
\r
572 Executive outcomes.-1---i2c transfer error;0---succeed.
\r
573 *******************************************************/
\r
574 static int goodix_ts_power(struct rk_ts_data * ts, int on)
\r
577 unsigned char i2c_control_buf[2] = {80, 1}; //suspend cmd
\r
579 if(on != 0 && on !=1)
\r
581 printk(KERN_DEBUG "%s: Cant't support this command.", rk_ts_name);
\r
586 if(on == 0) //suspend
\r
590 ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2);
\r
593 printk(KERN_INFO"touch goodix Send suspend cmd successed \n");
\r
602 else if(on == 1) //resume
\r
604 printk(KERN_INFO"touch goodix int resume\n");
\r
605 gpio_set_value(ts->rst_pin,GPIO_LOW);
\r
607 gpio_set_value(ts->rst_pin,GPIO_HIGH);
\r
614 static int goodix_input_params_init(struct rk_ts_data *ts)
\r
617 ts->input_dev = input_allocate_device();
\r
618 if (ts->input_dev == NULL) {
\r
620 printk(KERN_ALERT "Failed to allocate input device\n");
\r
625 __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit);
\r
626 __set_bit(EV_ABS, ts->input_dev->evbit);
\r
628 input_mt_init_slots(ts->input_dev, ts->max_touch_num);
\r
629 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
\r
630 input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, ts->abs_x_max, 0, 0);
\r
631 input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, ts->abs_y_max, 0, 0);
\r
632 sprintf(ts->phys, "input/rkts");
\r
633 ts->input_dev->name = rk_ts_name;
\r
634 ts->input_dev->phys = ts->phys;
\r
635 ts->input_dev->id.bustype = BUS_I2C;
\r
636 ts->input_dev->id.vendor = 0xDEAD;
\r
637 ts->input_dev->id.product = 0xBEEF;
\r
638 ts->input_dev->id.version = 10427; //screen firmware version
\r
640 ret = input_register_device(ts->input_dev);
\r
642 printk(KERN_ALERT "Probe: Unable to register %s input device\n", ts->input_dev->name);
\r
650 static int goodix_ts_init(struct rk_ts_data *ts)
\r
654 char test_data = 1;
\r
655 char *version_info = NULL;
\r
656 for(retry=0;retry < 30; retry++) //test goodix
\r
658 ret =goodix_i2c_write_bytes(ts->client, &test_data, 1);
\r
664 printk(KERN_INFO "I2C communication ERROR!Goodix touchscreen driver become invalid\n");
\r
669 ret=goodix_init_panel(ts);
\r
671 printk("goodix panel init fail\n");
\r
676 printk(KERN_INFO "%s>>>>>>>max_point %d\n",__func__,ts->max_touch_num);
\r
678 ret = goodix_read_version(ts, &version_info);
\r
681 printk(KERN_INFO"Read version data failed!\n");
\r
685 printk(KERN_INFO"Goodix TouchScreen Version:%s>>>max_point:%d\n", (version_info+1),ts->max_touch_num);
\r
687 vfree(version_info);
\r
688 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
\r
689 goodix_proc_entry = create_proc_entry("goodix-update", 0666, NULL);
\r
690 if(goodix_proc_entry == NULL)
\r
692 printk("Couldn't create proc entry!\n");
\r
698 printk("Create proc entry success!\n");
\r
699 goodix_proc_entry->write_proc = goodix_update_write;
\r
700 goodix_proc_entry->read_proc = goodix_update_read;
\r
701 //goodix_proc_entry->owner = THIS_MODULE;
\r
707 /*******************************************************
\r
709 Goodix touchscreen probe function.
\r
712 client: i2c device struct.
\r
716 Executive outcomes. 0---succeed.
\r
717 *******************************************************/
\r
718 static int rk_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
\r
721 struct rk_ts_data *ts;
\r
722 struct goodix_platform_data *pdata ;
\r
724 printk(KERN_INFO "Install touch driver.\n");
\r
725 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
\r
727 dev_err(&client->dev, "Must have I2C_FUNC_I2C.\n");
\r
732 ts = kzalloc(sizeof(struct rk_ts_data), GFP_KERNEL);
\r
734 printk(KERN_ALERT "alloc for struct rk_ts_data fail\n");
\r
739 pdata = client->dev.platform_data;
\r
740 ts->irq_pin = pdata->irq_pin;
\r
741 ts->rst_pin = pdata->rest_pin;
\r
742 ts->pendown =PEN_RELEASE;
\r
743 ts->client = client;
\r
744 ts->ts_init = goodix_ts_init;
\r
745 ts->power = goodix_ts_power;
\r
746 ts->get_touch_info = goodix_get_touch_info;
\r
747 ts->input_parms_init = goodix_input_params_init;
\r
748 i2c_set_clientdata(client, ts);
\r
751 if (pdata->init_platform_hw)
\r
753 pdata->init_platform_hw();
\r
758 ret = ts->ts_init(ts);
\r
761 printk(KERN_ALERT "rk ts init fail\n");
\r
766 if(ts->input_parms_init)
\r
768 ts->input_parms_init(ts);
\r
771 i2c_connect_client = client;
\r
772 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
\r
773 ts->ts_wq= create_rt_workqueue("rk_ts_wq"); //create a work queue and worker thread
\r
775 ts->ts_wq= create_workqueue("rk_ts_wq");
\r
778 printk(KERN_ALERT "creat touch screen workqueue failed\n");
\r
782 INIT_DELAYED_WORK(&ts->ts_work, rk_ts_work_func);
\r
783 #ifdef CONFIG_HAS_EARLYSUSPEND
\r
784 ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
\r
785 ts->early_suspend.suspend = rk_ts_early_suspend;
\r
786 ts->early_suspend.resume = rk_ts_late_resume;
\r
787 register_early_suspend(&ts->early_suspend);
\r
790 ts->irq=gpio_to_irq(ts->irq_pin) ; //If not defined in client
\r
793 ret = gpio_request(pdata->irq_pin, "TS_IRQ_PIN"); //Request IO
\r
796 printk(KERN_ALERT "Failed to request for touch irq\n");
\r
797 goto err_input_register_device_failed;
\r
801 gpio_direction_input(pdata->irq_pin);
\r
804 ret = request_irq(ts->irq, rk_ts_irq_handler ,IRQ_TYPE_LEVEL_LOW,client->name, ts);
\r
806 printk(KERN_ALERT "Cannot allocate ts INT!ERRNO:%d\n", ret);
\r
807 gpio_free(INT_PORT);
\r
808 goto err_input_register_device_failed;
\r
812 info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL);
\r
815 printk(KERN_ALERT "alloc for rk_touch_info fail\n");
\r
816 goto err_input_register_device_failed;
\r
818 printk("Goodix TS probe successfully!\n");
\r
822 err_input_register_device_failed:
\r
823 input_free_device(ts->input_dev);
\r
824 i2c_set_clientdata(client, NULL);
\r
831 /*******************************************************
\r
833 Goodix touchscreen driver release function.
\r
836 client: i2c device struct.
\r
839 Executive outcomes. 0---succeed.
\r
840 *******************************************************/
\r
841 static int rk_ts_remove(struct i2c_client *client)
\r
843 struct rk_ts_data *ts = i2c_get_clientdata(client);
\r
844 #ifdef CONFIG_HAS_EARLYSUSPEND
\r
845 unregister_early_suspend(&ts->early_suspend);
\r
847 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
\r
848 remove_proc_entry("goodix-update", NULL);
\r
851 gpio_free(ts->irq_pin);
\r
852 free_irq(ts->irq, ts);
\r
853 dev_notice(&client->dev,"The driver is removing...\n");
\r
854 i2c_set_clientdata(client, NULL);
\r
855 input_unregister_device(ts->input_dev);
\r
862 //******************************Begin of firmware update surpport*******************************
\r
863 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
\r
865 @brief CRC cal proc,include : Reflect,init_crc32_table,GenerateCRC32
\r
866 @param global var oldcrc32
\r
869 static unsigned int Reflect(unsigned long int ref, char ch)
\r
871 unsigned int value=0;
\r
873 for(i = 1; i < (ch + 1); i++)
\r
876 value |= 1 << (ch - i);
\r
881 /*---------------------------------------------------------------------------------------------------------*/
\r
882 /* CRC Check Program INIT */
\r
883 /*---------------------------------------------------------------------------------------------------------*/
\r
884 static void init_crc32_table(void)
\r
887 unsigned int t1,t2;
\r
890 for(i = 0; i <= 0xFF; i++)
\r
892 temp=Reflect(i, 8);
\r
893 crc32_table[i]= temp<< 24;
\r
894 for (j = 0; j < 8; j++)
\r
897 flag=crc32_table[i]&0x80000000;
\r
898 t1=(crc32_table[i] << 1);
\r
903 crc32_table[i] =t1^t2 ;
\r
906 crc32_table[i] = Reflect(crc32_table[i], 32);
\r
909 /*---------------------------------------------------------------------------------------------------------*/
\r
910 /* CRC main Program */
\r
911 /*---------------------------------------------------------------------------------------------------------*/
\r
912 static void GenerateCRC32(unsigned char * buf, unsigned int len)
\r
917 for (i = 0; i != len; ++i)
\r
919 t = (oldcrc32 ^ buf[i]) & 0xFF;
\r
920 oldcrc32 = ((oldcrc32 >> 8) & 0xFFFFFF) ^ crc32_table[t];
\r
924 static struct file * update_file_open(char * path, mm_segment_t * old_fs_p)
\r
926 struct file * filp = NULL;
\r
929 filp = filp_open(path, O_RDONLY, 0644);
\r
931 if(!filp || IS_ERR(filp))
\r
936 errno = PTR_ERR(filp);
\r
937 printk(KERN_ERR "The update file for Guitar open error.\n");
\r
940 *old_fs_p = get_fs();
\r
943 filp->f_op->llseek(filp,0,0);
\r
947 static void update_file_close(struct file * filp, mm_segment_t old_fs)
\r
951 filp_close(filp, NULL);
\r
953 static int update_get_flen(char * path)
\r
955 struct file * file_ck = NULL;
\r
956 mm_segment_t old_fs;
\r
959 file_ck = update_file_open(path, &old_fs);
\r
960 if(file_ck == NULL)
\r
963 length = file_ck->f_op->llseek(file_ck, 0, SEEK_END);
\r
964 //printk("File length: %d\n", length);
\r
967 update_file_close(file_ck, old_fs);
\r
970 static int update_file_check(char * path)
\r
972 unsigned char buffer[64] = { 0 } ;
\r
973 struct file * file_ck = NULL;
\r
974 mm_segment_t old_fs;
\r
975 int count, ret, length ;
\r
977 file_ck = update_file_open(path, &old_fs);
\r
980 printk("File Path:%s\n", path);
\r
982 if(file_ck == NULL)
\r
983 return -ERROR_NO_FILE;
\r
985 length = file_ck->f_op->llseek(file_ck, 0, SEEK_END);
\r
986 #ifdef GUITAR_MESSAGE
\r
987 printk(KERN_INFO "gt801 update: File length: %d\n",length);
\r
989 if(length <= 0 || (length%4) != 0)
\r
991 update_file_close(file_ck, old_fs);
\r
992 return -ERROR_FILE_TYPE;
\r
995 //set file point to the begining of the file
\r
996 file_ck->f_op->llseek(file_ck, 0, SEEK_SET);
\r
997 oldcrc32 = 0xFFFFFFFF;
\r
998 init_crc32_table();
\r
1001 ret = file_ck->f_op->read(file_ck, buffer, sizeof(buffer), &file_ck->f_pos);
\r
1004 for(count = 0; count < ret; count++)
\r
1005 GenerateCRC32(&buffer[count],1);
\r
1009 update_file_close(file_ck, old_fs);
\r
1010 return -ERROR_FILE_READ;
\r
1014 oldcrc32 = ~oldcrc32;
\r
1015 #ifdef GUITAR_MESSAGE
\r
1016 printk("CRC_Check: %u\n", oldcrc32);
\r
1018 update_file_close(file_ck, old_fs);
\r
1022 unsigned char wait_slave_ready(struct rk_ts_data *ts, unsigned short *timeout)
\r
1024 unsigned char i2c_state_buf[2] = {ADDR_STA, UNKNOWN_ERROR};
\r
1026 while(*timeout < MAX_TIMEOUT)
\r
1028 ret = goodix_i2c_read_bytes(ts->client, i2c_state_buf, 2);
\r
1030 return ERROR_I2C_TRANSFER;
\r
1031 if(i2c_state_buf[1] & SLAVE_READY)
\r
1033 return i2c_state_buf[1];
\r
1042 static int goodix_update_write(struct file *filp, const char __user *buff, unsigned long len, void *data)
\r
1044 unsigned char cmd[220];
\r
1047 static unsigned char update_path[100];
\r
1048 static unsigned short time_count = 0;
\r
1049 static unsigned int file_len = 0;
\r
1051 unsigned char i2c_control_buf[2] = {ADDR_CMD, 0};
\r
1052 unsigned char i2c_states_buf[2] = {ADDR_STA, 0};
\r
1053 unsigned char i2c_data_buf[PACK_SIZE+1+8] = {ADDR_DAT,};
\r
1054 //unsigned char i2c_rd_buf[1+4+PACK_SIZE+4];
\r
1055 unsigned char i2c_rd_buf[160];
\r
1056 unsigned char retries = 0;
\r
1057 unsigned int rd_len;
\r
1058 unsigned char i = 0;
\r
1059 static unsigned char update_need_config = 0;
\r
1061 unsigned char checksum_error_times = 0;
\r
1062 #ifdef UPDATE_NEW_PROTOCOL
\r
1063 unsigned int frame_checksum = 0;
\r
1064 unsigned int frame_number = 0;
\r
1066 unsigned char send_crc = 0;
\r
1069 struct file * file_data = NULL;
\r
1070 mm_segment_t old_fs;
\r
1071 struct rk_ts_data *ts;
\r
1073 ts = i2c_get_clientdata(i2c_connect_client);
\r
1077 if(copy_from_user(&cmd, buff, len))
\r
1083 case STEP_SET_PATH:
\r
1084 printk(KERN_INFO"Write cmd is:%d,cmd arg is:%s,write len is:%ld\n",cmd[0], &cmd[1], len);
\r
1085 memset(update_path, 0, 100);
\r
1086 strncpy(update_path, cmd+1, 100);
\r
1087 if(update_path[0] == 0)
\r
1091 case STEP_CHECK_FILE:
\r
1092 printk(KERN_INFO"Begin to firmware update ......\n");
\r
1093 ret = update_file_check(update_path);
\r
1096 printk(KERN_INFO"fialed to check update file!\n");
\r
1100 printk(KERN_INFO"Update check file success!\n");
\r
1102 case STEP_WRITE_SYN:
\r
1103 printk(KERN_INFO"STEP1:Write synchronization signal!\n");
\r
1104 i2c_control_buf[1] = UPDATE_START;
\r
1105 ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2);
\r
1108 ret = ERROR_I2C_TRANSFER;
\r
1111 //the time include time(APROM -> LDROM) and time(LDROM init)
\r
1114 case STEP_WAIT_SYN:
\r
1115 printk(KERN_INFO"STEP2:Wait synchronization signal!\n");
\r
1116 while(retries < MAX_I2C_RETRIES)
\r
1118 i2c_states_buf[1] = UNKNOWN_ERROR;
\r
1119 ret = goodix_i2c_read_bytes(ts->client, i2c_states_buf, 2);
\r
1120 printk(KERN_INFO"The read byte is:%d\n", i2c_states_buf[1]);
\r
1121 if(i2c_states_buf[1] & UPDATE_START)
\r
1123 if(i2c_states_buf[1] & NEW_UPDATE_START)
\r
1125 #ifdef UPDATE_NEW_PROTOCOL
\r
1126 update_need_config = 1;
\r
1138 if((retries >= MAX_I2C_RETRIES) && (!(i2c_states_buf[1] & UPDATE_START)))
\r
1146 case STEP_WRITE_LENGTH:
\r
1147 printk(KERN_INFO"STEP3:Write total update file length!\n");
\r
1148 file_len = update_get_flen(update_path);
\r
1151 printk(KERN_INFO"get update file length failed!\n");
\r
1155 i2c_data_buf[1] = (file_len>>24) & 0xff;
\r
1156 i2c_data_buf[2] = (file_len>>16) & 0xff;
\r
1157 i2c_data_buf[3] = (file_len>>8) & 0xff;
\r
1158 i2c_data_buf[4] = file_len & 0xff;
\r
1160 ret = goodix_i2c_write_bytes(ts->client, i2c_data_buf, 5);
\r
1163 ret = ERROR_I2C_TRANSFER;
\r
1167 case STEP_WAIT_READY:
\r
1168 printk(KERN_INFO"STEP4:Wait slave ready!\n");
\r
1169 ret = wait_slave_ready(ts, &time_count);
\r
1170 if(ret == ERROR_I2C_TRANSFER)
\r
1176 printk(KERN_INFO"Slave ready!\n");
\r
1178 case STEP_WRITE_DATA:
\r
1179 #ifdef UPDATE_NEW_PROTOCOL
\r
1180 printk(KERN_INFO"STEP5:Begin to send file data use NEW protocol!\n");
\r
1181 file_data = update_file_open(update_path, &old_fs);
\r
1182 if(file_data == NULL)
\r
1187 while(file_len >= 0)
\r
1189 i2c_data_buf[0] = ADDR_DAT;
\r
1190 rd_len = (file_len >= PACK_SIZE) ? PACK_SIZE : file_len;
\r
1191 frame_checksum = 0;
\r
1194 ret = file_data->f_op->read(file_data, i2c_data_buf+1+4, rd_len, &file_data->f_pos);
\r
1197 printk("[GOODiX_ISP_NEW]:Read File Data Failed!\n");
\r
1200 i2c_data_buf[1] = (frame_number>>24)&0xff;
\r
1201 i2c_data_buf[2] = (frame_number>>16)&0xff;
\r
1202 i2c_data_buf[3] = (frame_number>>8)&0xff;
\r
1203 i2c_data_buf[4] = frame_number&0xff;
\r
1205 frame_checksum = 0;
\r
1206 for(i=0; i<rd_len; i++)
\r
1208 frame_checksum += i2c_data_buf[5+i];
\r
1210 frame_checksum = 0 - frame_checksum;
\r
1211 i2c_data_buf[5+rd_len+0] = frame_checksum&0xff;
\r
1212 i2c_data_buf[5+rd_len+1] = (frame_checksum>>8)&0xff;
\r
1213 i2c_data_buf[5+rd_len+2] = (frame_checksum>>16)&0xff;
\r
1214 i2c_data_buf[5+rd_len+3] = (frame_checksum>>24)&0xff;
\r
1217 printk(KERN_INFO"[GOODiX_ISP_NEW]:%d\n", file_len);
\r
1218 ret = goodix_i2c_write_bytes(ts->client, i2c_data_buf, 1+4+rd_len+4);
\r
1222 printk("[GOODiX_ISP_NEW]:Write File Data Failed!Return:%d\n", ret);
\r
1226 memset(i2c_rd_buf, 0x00, 1+4+rd_len+4);
\r
1227 ret = goodix_i2c_read_bytes(ts->client, i2c_rd_buf, 1+4+rd_len+4);
\r
1230 printk("[GOODiX_ISP_NEW]:Read File Data Failed!Return:%d\n", ret);
\r
1233 for(i=1; i<(1+4+rd_len+4); i++) //check communication
\r
1235 if(i2c_rd_buf[i] != i2c_data_buf[i])
\r
1243 i2c_control_buf[0] = ADDR_CMD;
\r
1244 i2c_control_buf[1] = 0x03;
\r
1245 goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); //communication error
\r
1246 printk("[GOODiX_ISP_NEW]:File Data Frame readback check Error!\n");
\r
1250 i2c_control_buf[1] = 0x04; //let LDROM write flash
\r
1251 goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2);
\r
1254 //Wait for slave ready signal.and read the checksum
\r
1255 ret = wait_slave_ready(ts, &time_count);
\r
1256 if((ret & CHECKSUM_ERROR)||(!i))
\r
1260 printk("[GOODiX_ISP_NEW]:File Data Frame checksum Error!\n");
\r
1262 checksum_error_times++;
\r
1264 if(checksum_error_times > 20) //max retry times.
\r
1268 checksum_error_times = 0;
\r
1269 if(ret & (FRAME_ERROR))
\r
1271 printk("[GOODiX_ISP_NEW]:File Data Frame Miss!\n");
\r
1274 if(ret == ERROR_I2C_TRANSFER)
\r
1280 if(file_len < PACK_SIZE)
\r
1282 update_file_close(file_data, old_fs);
\r
1285 file_len -= rd_len;
\r
1286 }//end of while((file_len >= 0))
\r
1289 printk(KERN_INFO"STEP5:Begin to send file data use OLD protocol!\n");
\r
1290 file_data = update_file_open(update_path, &old_fs);
\r
1291 if(file_data == NULL) //file_data has been opened at the last time
\r
1295 while((file_len >= 0) && (!send_crc))
\r
1297 printk(KERN_INFO"[GOODiX_ISP_OLD]:%d\n", file_len);
\r
1298 i2c_data_buf[0] = ADDR_DAT;
\r
1299 rd_len = (file_len >= PACK_SIZE) ? PACK_SIZE : file_len;
\r
1302 ret = file_data->f_op->read(file_data, i2c_data_buf+1, rd_len, &file_data->f_pos);
\r
1308 if(file_len < PACK_SIZE)
\r
1311 update_file_close(file_data, old_fs);
\r
1312 i2c_data_buf[file_len+1] = oldcrc32&0xff;
\r
1313 i2c_data_buf[file_len+2] = (oldcrc32>>8)&0xff;
\r
1314 i2c_data_buf[file_len+3] = (oldcrc32>>16)&0xff;
\r
1315 i2c_data_buf[file_len+4] = (oldcrc32>>24)&0xff;
\r
1316 ret = goodix_i2c_write_bytes(ts->client, i2c_data_buf, (file_len+1+4));
\r
1320 printk("[GOODiX_ISP_OLD]:Write File Data Failed!Return:%d\n", ret);
\r
1327 ret = goodix_i2c_write_bytes(ts->client, i2c_data_buf, PACK_SIZE+1);
\r
1331 printk("[GOODiX_ISP_OLD]:Write File Data Failed!Return:%d\n", ret);
\r
1335 file_len -= rd_len;
\r
1337 //Wait for slave ready signal.
\r
1338 ret = wait_slave_ready(ts, &time_count);
\r
1339 if(ret == ERROR_I2C_TRANSFER)
\r
1346 }//end of while((file_len >= 0) && (!send_crc))
\r
1349 case STEP_READ_STATUS:
\r
1350 printk(KERN_INFO"STEP6:Read update status!\n");
\r
1351 while(time_count < MAX_TIMEOUT)
\r
1353 ret = goodix_i2c_read_bytes(ts->client, i2c_states_buf, 2);
\r
1358 if(i2c_states_buf[1] & SLAVE_READY)
\r
1360 if(!(i2c_states_buf[1] &0xf0))
\r
1362 printk(KERN_INFO"The firmware updating succeed!update state:0x%x\n",i2c_states_buf[1]);
\r
1367 printk(KERN_INFO"The firmware updating failed!update state:0x%x\n",i2c_states_buf[1]);
\r
1376 case FUN_CLR_VAL: //clear the static val
\r
1379 update_need_config = 0;
\r
1381 case FUN_CMD: //functional command
\r
1382 if(cmd[1] == CMD_DISABLE_TP)
\r
1384 printk(KERN_INFO"Disable TS int!\n");
\r
1386 disable_irq(TS_INT);
\r
1388 else if(cmd[1] == CMD_ENABLE_TP)
\r
1390 printk(KERN_INFO"Enable TS int!\n");
\r
1392 enable_irq(TS_INT);
\r
1394 else if(cmd[1] == CMD_READ_VER)
\r
1396 printk(KERN_INFO"Read version!\n");
\r
1397 ts->read_mode = MODE_RD_VER;
\r
1399 else if(cmd[1] == CMD_READ_RAW)
\r
1401 printk(KERN_INFO"Read raw data!\n");
\r
1402 ts->read_mode = MODE_RD_RAW;
\r
1403 i2c_control_buf[1] = 201;
\r
1404 ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); //read raw data cmd
\r
1407 printk(KERN_INFO"Write read raw data cmd failed!\n");
\r
1412 else if(cmd[1] == CMD_READ_DIF)
\r
1414 printk(KERN_INFO"Read diff data!\n");
\r
1415 ts->read_mode = MODE_RD_DIF;
\r
1416 i2c_control_buf[1] = 202;
\r
1417 ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); //read diff data cmd
\r
1420 printk(KERN_INFO"Write read raw data cmd failed!\n");
\r
1425 else if(cmd[1] == CMD_READ_CFG)
\r
1427 printk(KERN_INFO"Read config info!\n");
\r
1428 ts->read_mode = MODE_RD_CFG;
\r
1429 rd_cfg_addr = cmd[2];
\r
1430 rd_cfg_len = cmd[3];
\r
1432 else if(cmd[1] == CMD_SYS_REBOOT)
\r
1434 printk(KERN_INFO"System reboot!\n");
\r
1437 kernel_restart(NULL);
\r
1440 case FUN_WRITE_CONFIG:
\r
1442 printk(KERN_INFO"Begin write config info!Config length:%d\n",cmd[1]);
\r
1443 for(i=3; i<cmd[1];i++)
\r
1445 //if((i-3)%5 == 0)printk("\n");
\r
1446 printk("(%d):0x%x ", i-3, cmd[i]);
\r
1450 if((cmd[2]>83)&&(cmd[2]<240)&&cmd[1])
\r
1452 checksum_error_times = 0;
\r
1454 ret = goodix_i2c_write_bytes(ts->client, cmd+2, cmd[1]);
\r
1457 printk("Write Config failed!return:%d\n",ret);
\r
1460 if(!update_need_config)return 1;
\r
1462 i2c_rd_buf[0] = cmd[2];
\r
1463 ret = goodix_i2c_read_bytes(ts->client, i2c_rd_buf, cmd[1]);
\r
1466 printk("Read Config failed!return:%d\n",ret);
\r
1469 for(i=0; i<cmd[1]; i++)
\r
1471 if(i2c_rd_buf[i] != cmd[i+2])
\r
1473 printk("Config readback check failed!\n");
\r
1480 i2c_control_buf[0] = ADDR_CMD;
\r
1481 i2c_control_buf[1] = 0x03;
\r
1482 goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); //communication error
\r
1483 checksum_error_times++;
\r
1485 if(checksum_error_times > 20) //max retry times.
\r
1491 i2c_control_buf[0] = ADDR_CMD;
\r
1492 i2c_control_buf[1] = 0x04; //let LDROM write flash
\r
1493 goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2);
\r
1500 printk(KERN_INFO"Invalid config addr!\n");
\r
1509 static int goodix_update_read( char *page, char **start, off_t off, int count, int *eof, void *data )
\r
1512 struct rk_ts_data *ts;
\r
1514 char *version_info = NULL;
\r
1515 unsigned char read_data[1201] = {80, };
\r
1517 ts = i2c_get_clientdata(i2c_connect_client);
\r
1521 if(ts->read_mode == MODE_RD_VER) //read version data
\r
1523 ret = goodix_read_version(ts, &version_info);
\r
1526 printk(KERN_INFO"Read version data failed!\n");
\r
1527 vfree(version_info);
\r
1531 for(len=0;len<100;len++)
\r
1533 if(*(version_info + len) == '\0')
\r
1536 printk(KERN_INFO"GOODiX Touchscreen Version is:%s\n", (version_info+1));
\r
1537 strncpy(page, version_info+1, len + 1);
\r
1538 vfree(version_info);
\r
1542 else if((ts->read_mode == MODE_RD_RAW)||(ts->read_mode == MODE_RD_DIF)) //read raw data or diff
\r
1544 //printk(KERN_INFO"Read raw data\n");
\r
1545 ret = goodix_i2c_read_bytes(ts->client, read_data, 1201);
\r
1548 if(ts->read_mode == 2)
\r
1549 printk(KERN_INFO"Read raw data failed!\n");
\r
1550 if(ts->read_mode == 3)
\r
1551 printk(KERN_INFO"Read diff data failed!\n");
\r
1554 memcpy(page, read_data+1, 1200);
\r
1559 else if(ts->read_mode == MODE_RD_CFG)
\r
1561 if((rd_cfg_addr>83)&&(rd_cfg_addr<240))
\r
1563 read_data[0] = rd_cfg_addr;
\r
1564 printk("read config addr is:%d\n", rd_cfg_addr);
\r
1568 read_data[0] = 101;
\r
1569 printk("invalid read config addr,use default!\n");
\r
1571 if((rd_cfg_len<0)||(rd_cfg_len>156))
\r
1573 printk("invalid read config length,use default!\n");
\r
1574 rd_cfg_len = 239 - read_data[0];
\r
1576 printk("read config length is:%d\n", rd_cfg_len);
\r
1577 ret = goodix_i2c_read_bytes(ts->client, read_data, rd_cfg_len);
\r
1580 printk(KERN_INFO"Read config info failed!\n");
\r
1583 memcpy(page, read_data+1, rd_cfg_len);
\r
1584 return rd_cfg_len;
\r
1590 //******************************End of firmware update surpport*******************************
\r
1591 static const struct i2c_device_id goodix_ts_id[] = {
\r
1592 { "Goodix-TS", 0 },
\r
1596 static struct i2c_driver rk_ts_driver = {
\r
1597 .probe = rk_ts_probe,
\r
1598 .remove = rk_ts_remove,
\r
1599 #ifndef CONFIG_HAS_EARLYSUSPEND
\r
1600 .suspend = rk_ts_suspend,
\r
1601 .resume = rk_ts_resume,
\r
1603 .id_table = goodix_ts_id,
\r
1605 .name = "Goodix-TS",
\r
1606 .owner = THIS_MODULE,
\r
1611 static struct class *ts_debug_class = NULL;
\r
1612 static ssize_t dbg_mode_show(struct class *cls,struct class_attribute *attr, char *_buf)
\r
1614 printk("%s>>>>>>>>\n",__func__);
\r
1618 static ssize_t dbg_mode_store(struct class *cls,struct class_attribute *attr, const char *buf, size_t _count)
\r
1620 dbg_thresd = simple_strtol(buf,NULL,10);
\r
1623 printk(KERN_INFO "ts debug open\n");
\r
1627 printk(KERN_INFO "ts debug close");
\r
1632 static CLASS_ATTR(debug, 0666, dbg_mode_show, dbg_mode_store);
\r
1634 static int dbg_sys_init(void)
\r
1637 ts_debug_class = class_create(THIS_MODULE, "ts_debug");
\r
1638 ret = class_create_file(ts_debug_class, &class_attr_debug);
\r
1641 printk("Fail to creat class hkrkfb.\n");
\r
1647 /*******************************************************
\r
1649 Driver Install function.
\r
1651 Executive Outcomes. 0---succeed.
\r
1652 ********************************************************/
\r
1653 static int __devinit rk_ts_init(void)
\r
1656 ret=i2c_add_driver(&rk_ts_driver);
\r
1657 dbg_sys_init(); //for debug
\r
1661 /*******************************************************
\r
1663 Driver uninstall function.
\r
1665 Executive Outcomes. 0---succeed.
\r
1666 ********************************************************/
\r
1667 static void __exit rk_ts_exit(void)
\r
1669 printk(KERN_ALERT "Touchscreen driver of guitar exited.\n");
\r
1670 i2c_del_driver(&rk_ts_driver);
\r
1673 module_init(rk_ts_init);
\r
1674 module_exit(rk_ts_exit);
\r
1676 MODULE_DESCRIPTION("Goodix Touchscreen Driver");
\r
1677 MODULE_LICENSE("GPL");
\r