2 * drivers/input/touchscreen/ft5x0x_ts.c
4 * FocalTech ft5x0x TouchScreen driver.
6 * Copyright (c) 2010 Focal tech Ltd.
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 * note: only support mulititouch Wenfs 2010-10-01
21 #include <linux/input.h>
22 #include <linux/module.h>
23 #include <linux/init.h>
24 #include <linux/interrupt.h>
25 #include <linux/kernel.h>
26 #include <linux/platform_device.h>
27 #include <linux/spi/spi.h>
28 #include <linux/slab.h>
29 #include <linux/fcntl.h>
30 #include <linux/delay.h>
31 #include <linux/device.h>
32 #include <linux/timer.h>
33 #include <linux/jiffies.h>
34 #include <linux/miscdevice.h>
35 #include <linux/types.h>
37 #include <linux/delay.h>
38 #include <linux/ioport.h>
39 #include <linux/input-polldev.h>
40 #include <linux/i2c.h>
41 #include <linux/workqueue.h>
42 #ifdef CONFIG_ANDROID_POWER
43 #include <linux/android_power.h>
45 #include <mach/hardware.h>
46 #include <asm/setup.h>
47 #include <asm/mach-types.h>
48 #include <asm/mach/arch.h>
49 #include <asm/mach/map.h>
50 #include <asm/mach/flash.h>
51 #include <asm/hardware/gic.h>
52 #include <mach/iomux.h>
53 #include <mach/gpio.h>
54 #include <mach/irqs.h>
55 #include <mach/rk29_iomap.h>
56 #include <mach/board.h>
57 #include <mach/rk29_nand.h>
58 #include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */
59 #include <media/soc_camera.h> /* ddl@rock-chips.com : camera support */
60 #include <mach/vpu_mem.h>
61 #include <mach/sram.h>
62 #ifdef CONFIG_HAS_EARLYSUSPEND
63 #include <linux/earlysuspend.h>
64 static struct early_suspend ft5406_early_suspend;
70 #define CONFIG_FT5X0X_MULTITOUCH 1
72 #define FT5406_IIC_SPEED 400*1000 //300*1000
73 #define TOUCH_RESET_PIN RK29_PIN6_PC3
74 #define FT5X0X_REG_THRES 0x80 /* Thresshold, the threshold be low, the sensitivy will be high */
75 #define FT5X0X_REG_REPORT_RATE 0x88 /* **************report rate, in unit of 10Hz **************/
76 #define FT5X0X_REG_PMODE 0xA5 /* Power Consume Mode 0 -- active, 1 -- monitor, 3 -- sleep */
77 #define FT5X0X_REG_FIRMID 0xA6 /* ***************firmware version **********************/
78 #define FT5X0X_REG_NOISE_MODE 0xb2 /* to enable or disable power noise, 1 -- enable, 0 -- disable */
79 #define SCREEN_MAX_X 800
80 #define SCREEN_MAX_Y 480
82 #define FT5X0X_NAME "ft5x0x_ts"//"synaptics_i2c_rmi"//"synaptics-rmi-ts"//
83 #define TOUCH_MAJOR_MAX 200
84 #define WIDTH_MAJOR_MAX 200
86 #define PMODE_ACTIVE 0x00
87 #define PMODE_MONITOR 0x01
88 #define PMODE_STANDBY 0x02
89 #define PMODE_HIBERNATE 0x03
122 struct ft5x0x_ts_data {
123 struct i2c_client *client;
124 struct input_dev *input_dev;
126 struct ts_event event;
127 struct work_struct pen_event_work;
128 struct workqueue_struct *ts_workqueue;
130 static struct i2c_client *this_client;
132 /***********************************************************************/
134 #define FTS_PACKET_LENGTH 128
155 /***********************************************************************/
157 /***********************************************************************
159 callback: send data to ctpm by i2c interface;
161 txdata[in]: data buffer which is used to send data;
162 length[in]: the length of the data buffer;
166 ************************************************************************/
167 static int fts_i2c_txdata(u8 *txdata, int length)
173 msg.addr = this_client->addr;
177 ret = i2c_transfer(this_client->adapter, &msg, 1);
179 pr_err("%s i2c write error: %d\n", __func__, ret);
184 /***********************************************************************
186 callback: write data to ctpm by i2c interface;
188 buffer[in]: data buffer;
189 length[in]: the length of the data buffer;
193 ************************************************************************/
194 static bool i2c_write_interface(u8* pbt_buf, int dw_lenth)
197 ret=i2c_master_send(this_client, pbt_buf, dw_lenth);
200 printk("[TSP]i2c_write_interface error line = %d, ret = %d\n", __LINE__, ret);
207 /***********************************************************************
209 callback: read register value ftom ctpm by i2c interface;
211 reg_name[in]: the register which you want to write;
212 tx_buf[in]: buffer which is contained of the writing value;
216 ************************************************************************/
217 static bool fts_register_write(u8 reg_name, u8* tx_buf)
219 u8 write_cmd[2] = {0};
221 write_cmd[0] = reg_name;
222 write_cmd[1] = *tx_buf;
224 /*call the write callback function*/
225 return i2c_write_interface(write_cmd, 2);
228 /***********************************************************************
230 callback: send a command to ctpm.
232 btcmd[in]: command code;
233 btPara1[in]: parameter 1;
234 btPara2[in]: parameter 2;
235 btPara3[in]: parameter 3;
236 num[in]: the valid input parameter numbers,
237 if only command code needed and no
238 parameters followed,then the num is 1;
242 ************************************************************************/
243 static bool cmd_write(u8 btcmd,u8 btPara1,u8 btPara2,u8 btPara3,u8 num)
245 u8 write_cmd[4] = {0};
247 write_cmd[0] = btcmd;
248 write_cmd[1] = btPara1;
249 write_cmd[2] = btPara2;
250 write_cmd[3] = btPara3;
251 return i2c_write_interface(write_cmd, num);
254 /***********************************************************************
256 callback: read data from ctpm by i2c interface;
258 buffer[in]: data buffer;
259 length[in]: the length of the data buffer;
263 ************************************************************************/
264 static bool i2c_read_interface(u8* pbt_buf, int dw_lenth)
268 ret=i2c_master_recv(this_client, pbt_buf, dw_lenth);
272 printk("[TSP]i2c_read_interface error\n");
280 /***********************************************************************
282 callback: read a byte data from ctpm;
284 buffer[in]: read buffer;
285 length[in]: the size of read data;
289 ************************************************************************/
290 static bool byte_read(u8* buffer, int length)
292 return i2c_read_interface(buffer, length);
295 /***********************************************************************
297 callback: write a byte data to ctpm;
299 buffer[in]: write buffer;
300 length[in]: the size of write data;
304 ************************************************************************/
305 static bool byte_write(u8* buffer, int length)
308 return i2c_write_interface(buffer, length);
311 /***********************************************************************
313 callback: read register value ftom ctpm by i2c interface;
315 reg_name[in]: the register which you want to read;
316 rx_buf[in]: data buffer which is used to store register value;
317 rx_length[in]: the length of the data buffer;
321 ************************************************************************/
322 static bool fts_register_read(u8 reg_name, u8* rx_buf, int rx_length)
327 read_cmd[0] = reg_name;
330 /*send register addr*/
331 if(!i2c_write_interface(&read_cmd[0], cmd_len))
336 /*call the read callback function to get the register value*/
337 if(!i2c_read_interface(rx_buf, rx_length))
346 /***********************************************************************
348 callback: burn the FW to ctpm.
350 pbt_buf[in]: point to Head+FW ;
351 dw_lenth[in]: the length of the FW + 6(the Head length);
354 ERR_MODE: fail to switch to UPDATE mode;
355 ERR_READID: read id fail;
356 ERR_ERASE: erase chip fail;
357 ERR_STATUS: status error;
359 ************************************************************************/
360 E_UPGRADE_ERR_TYPE fts_ctpm_fw_upgrade(u8* pbt_buf, int dw_lenth)
362 u8 cmd,reg_val[2] = {0};
363 u8 packet_buf[FTS_PACKET_LENGTH + 6];
364 u8 auc_i2c_write_buf[10];
367 int j,temp,lenght,i_ret,packet_number, i = 0;
368 int i_is_new_protocol = 0;
371 /******write 0xaa to register 0xfc******/
373 fts_register_write(0xfc,&cmd);
376 /******write 0x55 to register 0xfc******/
378 fts_register_write(0xfc,&cmd);
379 printk("[TSP] Step 1: Reset CTPM test\n");
384 /*******Step 2:Enter upgrade mode ****/
385 printk("\n[TSP] Step 2:enter new update mode\n");
386 auc_i2c_write_buf[0] = 0x55;
387 auc_i2c_write_buf[1] = 0xaa;
391 i_ret = fts_i2c_txdata(auc_i2c_write_buf, 2);
393 }while(i_ret <= 0 && i < 10 );
397 i_is_new_protocol = 1;
400 /********Step 3:check READ-ID********/
401 cmd_write(0x90,0x00,0x00,0x00,4);
402 byte_read(reg_val,2);
403 if (reg_val[0] == 0x79 && reg_val[1] == 0x3)
405 printk("[TSP] Step 3: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]);
410 //i_is_new_protocol = 1;
414 /*********Step 4:erase app**********/
415 if (i_is_new_protocol)
417 cmd_write(0x61,0x00,0x00,0x00,1);
421 cmd_write(0x60,0x00,0x00,0x00,1);
424 printk("[TSP] Step 4: erase. \n");
428 /*Step 5:write firmware(FW) to ctpm flash*/
430 printk("[TSP] Step 5: start upgrade. \n");
431 dw_lenth = dw_lenth - 8;
432 packet_number = (dw_lenth) / FTS_PACKET_LENGTH;
433 packet_buf[0] = 0xbf;
434 packet_buf[1] = 0x00;
435 for (j=0;j<packet_number;j++)
437 temp = j * FTS_PACKET_LENGTH;
438 packet_buf[2] = (u8)(temp>>8);
439 packet_buf[3] = (u8)temp;
440 lenght = FTS_PACKET_LENGTH;
441 packet_buf[4] = (u8)(lenght>>8);
442 packet_buf[5] = (u8)lenght;
444 for (i=0;i<FTS_PACKET_LENGTH;i++)
446 packet_buf[6+i] = pbt_buf[j*FTS_PACKET_LENGTH + i];
447 bt_ecc ^= packet_buf[6+i];
450 byte_write(&packet_buf[0],FTS_PACKET_LENGTH + 6);
451 mdelay(FTS_PACKET_LENGTH/6 + 1);
452 if ((j * FTS_PACKET_LENGTH % 1024) == 0)
454 printk("[TSP] upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_LENGTH);
458 if ((dw_lenth) % FTS_PACKET_LENGTH > 0)
460 temp = packet_number * FTS_PACKET_LENGTH;
461 packet_buf[2] = (u8)(temp>>8);
462 packet_buf[3] = (u8)temp;
464 temp = (dw_lenth) % FTS_PACKET_LENGTH;
465 packet_buf[4] = (u8)(temp>>8);
466 packet_buf[5] = (u8)temp;
470 packet_buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_LENGTH + i];
471 bt_ecc ^= packet_buf[6+i];
474 byte_write(&packet_buf[0],temp+6);
478 /***********send the last six byte**********/
479 for (i = 0; i<6; i++)
482 packet_buf[2] = (u8)(temp>>8);
483 packet_buf[3] = (u8)temp;
485 packet_buf[4] = (u8)(temp>>8);
486 packet_buf[5] = (u8)temp;
487 packet_buf[6] = pbt_buf[ dw_lenth + i];
488 bt_ecc ^= packet_buf[6];
490 byte_write(&packet_buf[0],7);
494 /********send the opration head************/
495 cmd_write(0xcc,0x00,0x00,0x00,1);
496 byte_read(reg_val,1);
497 printk("[TSP] Step 6: ecc read 0x%x, new firmware 0x%x. \n", reg_val[0], bt_ecc);
498 if(reg_val[0] != bt_ecc)
503 /*******Step 7: reset the new FW**********/
504 cmd_write(0x07,0x00,0x00,0x00,1);
510 /***********************************************************************/
512 int fts_ctpm_fw_upgrade_with_i_file(void)
518 i_ret = fts_ctpm_fw_upgrade(pbt_buf,sizeof(CTPM_FW));
523 /***********************************************************************/
525 unsigned char fts_ctpm_get_upg_ver(void)
529 ui_sz = sizeof(CTPM_FW);
532 return CTPM_FW[ui_sz - 2];
539 /*read the it7260 register ,used i2c bus*/
540 static int ft5406_read_regs(struct i2c_client *client, u8 reg, u8 buf[], unsigned len)
543 ret = i2c_master_reg8_recv(client, reg, buf, len, FT5406_IIC_SPEED);
548 /* set the it7260 registe,used i2c bus*/
549 static int ft5406_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], unsigned short len)
552 ret = i2c_master_reg8_send(client, reg, buf, (int)len, FT5406_IIC_SPEED);
556 static void ft5406_queue_work(struct work_struct *work)
558 struct ft5x0x_ts_data *data = container_of(work, struct ft5x0x_ts_data, pen_event_work);
559 struct tp_event event;
562 int ret,i,offset,points;
564 #if CONFIG_FT5X0X_MULTITOUCH
565 ret = ft5406_read_regs(data->client,start_reg, buf, 6*MAX_POINT+1);
567 ret = ft5406_read_regs(data->client,start_reg, buf, 7);
570 dev_err(&data->client->dev, "ft5406_read_regs fail:%d!\n",ret);
574 for (i=0; i<32; i++) {
575 printk("buf[%d] = 0x%x \n", i, buf[i]);
579 points = buf[2] & 0x07;
580 //dev_info(&data->client->dev, "ft5406_read_and_report_data points = %d\n",points);
582 #if CONFIG_FT5X0X_MULTITOUCH
583 input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 0);
584 input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 0);
585 //input_mt_sync(data->input_dev);
587 input_report_abs(data->input_dev, ABS_PRESSURE, 0);
588 input_report_key(data->input_dev, BTN_TOUCH, 0);
590 input_sync(data->input_dev);
591 enable_irq(data->irq);
592 dev_info(&data->client->dev, "ft5406 touch release\n");
595 memset(&event, 0, sizeof(struct tp_event));
596 #if CONFIG_FT5X0X_MULTITOUCH
597 for(i=0;i<points;i++){
599 event.x = (((s16)(buf[offset+0] & 0x0F))<<8) | ((s16)buf[offset+1]);
600 event.y = (((s16)(buf[offset+2] & 0x0F))<<8) | ((s16)buf[offset+3]);
601 event.id = (s16)(buf[offset+2] & 0xF0)>>4;
602 event.flag = ((buf[offset+0] & 0xc0) >> 6);
603 event.pressure = 200;
604 if(event.x<=SCREEN_MAX_X && event.y<=SCREEN_MAX_Y){
605 //dev_info(&data->client->dev,
606 // "ft5406 multiple report event[%d]:x = %d,y = %d,id = %d,flag = %d,pressure = %d\n",
607 // i,event.x,event.y,event.id,event.flag,event.pressure);
608 input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 200);
609 input_report_abs(data->input_dev, ABS_MT_POSITION_X, event.x);
610 input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event.y);
611 input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, event.id);
612 input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
613 input_mt_sync(data->input_dev);
617 event.x = (s16)(buf[3] & 0x0F)<<8 | (s16)buf[4];
618 event.y = (s16)(buf[5] & 0x0F)<<8 | (s16)buf[6];
620 input_report_abs(data->input_dev, ABS_X, event.x);
621 input_report_abs(data->input_dev, ABS_Y, event.y);
622 input_report_abs(data->input_dev, ABS_PRESSURE, event.pressure);
623 input_report_key(data->input_dev, BTN_TOUCH, 1);
624 //dev_info(&data->client->dev, "ft5406 single report event:x = %d,y = %d\n",event.x,event.y);
626 //dev_info(&data->client->dev, "ft5406 sync\n",event.x,event.y);
627 input_sync(data->input_dev);
628 enable_irq(data->irq);
632 static irqreturn_t ft5406_interrupt(int irq, void *dev_id)
634 struct ft5x0x_ts_data *ft5x0x_ts = dev_id;
636 disable_irq_nosync(ft5x0x_ts->irq);
637 if (!work_pending(&ft5x0x_ts->pen_event_work))
638 queue_work(ft5x0x_ts->ts_workqueue, &ft5x0x_ts->pen_event_work);
642 static int ft5406_suspend(struct i2c_client *client, pm_message_t mesg)
644 struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client);
645 struct ft5406_platform_data *pdata = client->dev.platform_data;
647 if (pdata->platform_sleep)
648 pdata->platform_sleep();
649 disable_irq(ft5x0x_ts->irq);
654 static int ft5406_resume(struct i2c_client *client)
656 struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client);
657 struct ft5406_platform_data *pdata = client->dev.platform_data;
659 enable_irq(ft5x0x_ts->irq);
660 if (pdata->platform_wakeup)
661 pdata->platform_wakeup();
665 static int __devexit ft5406_remove(struct i2c_client *client)
667 struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client);
669 free_irq(ft5x0x_ts->irq, ft5x0x_ts);
670 input_unregister_device(ft5x0x_ts->input_dev);
672 cancel_work_sync(&ft5x0x_ts->pen_event_work);
673 destroy_workqueue(ft5x0x_ts->ts_workqueue);
674 i2c_set_clientdata(client, NULL);
675 #ifdef CONFIG_HAS_EARLYSUSPEND
676 unregister_early_suspend(&ft5406_early_suspend);
682 static int ft5406_probe(struct i2c_client *client ,const struct i2c_device_id *id)
684 struct ft5x0x_ts_data *ft5x0x_ts;
685 struct input_dev *input_dev;
686 struct ft5406_platform_data *pdata = client->dev.platform_data;
692 const u8 buf_test[1] = {0};
693 unsigned char reg_value;
694 unsigned char reg_version;
696 dev_info(&client->dev, "ft5x0x_ts_probe!\n");
698 dev_err(&client->dev, "platform data is required!\n");
702 if (pdata->init_platform_hw)
703 pdata->init_platform_hw();
705 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)){
706 dev_err(&client->dev, "Must have I2C_FUNC_I2C.\n");
710 ft5x0x_ts = kzalloc(sizeof(*ft5x0x_ts), GFP_KERNEL);
717 ret=ft5406_set_regs(client,FT5X0X_REG_PMODE, buf_test,1);
723 printk("FT5406 I2C TEST ERROR!\n");
725 goto exit_i2c_test_fail;
728 input_dev = input_allocate_device();
731 printk("failed to allocate input device\n");
732 goto exit_input_dev_alloc_failed;
734 ft5x0x_ts->client = this_client = client;
735 ft5x0x_ts->irq = client->irq;
736 ft5x0x_ts->input_dev = input_dev;
738 #if CONFIG_FT5X0X_MULTITOUCH
739 set_bit(ABS_MT_POSITION_X, input_dev->absbit);
740 set_bit(ABS_MT_POSITION_Y, input_dev->absbit);
741 set_bit(ABS_MT_TOUCH_MAJOR, input_dev->absbit);
742 set_bit(ABS_MT_TRACKING_ID, input_dev->absbit);
743 set_bit(ABS_MT_WIDTH_MAJOR, input_dev->absbit);
744 input_set_abs_params(input_dev,ABS_MT_POSITION_X, 0, SCREEN_MAX_X, 0, 0);
745 input_set_abs_params(input_dev,ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y, 0, 0);
746 input_set_abs_params(input_dev,ABS_MT_TOUCH_MAJOR, 0, TOUCH_MAJOR_MAX, 0, 0);
747 input_set_abs_params(input_dev,ABS_MT_TRACKING_ID, 0, MAX_POINT, 0, 0);
748 input_set_abs_params(input_dev,ABS_MT_WIDTH_MAJOR, 0, WIDTH_MAJOR_MAX, 0, 0);
750 set_bit(ABS_X, input_dev->absbit);
751 set_bit(ABS_Y, input_dev->absbit);
752 set_bit(ABS_PRESSURE, input_dev->absbit);
753 set_bit(BTN_TOUCH, input_dev->keybit);
754 input_set_abs_params(input_dev, ABS_X, 0, SCREEN_MAX_X, 0, 0);
755 input_set_abs_params(input_dev, ABS_Y, 0, SCREEN_MAX_Y, 0, 0);
756 input_set_abs_params(input_dev, ABS_PRESSURE, 0, PRESS_MAX, 0 , 0);
760 set_bit(EV_ABS, input_dev->evbit);
761 set_bit(EV_KEY, input_dev->evbit);
763 input_dev->name = FT5X0X_NAME; //dev_name(&client->dev)
764 err = input_register_device(input_dev);
766 printk("ft5x0x_ts_probe: failed to register input device: \n");
767 goto exit_input_register_device_failed;
770 if (!ft5x0x_ts->irq) {
772 dev_err(&ft5x0x_ts->client->dev, "no IRQ?\n");
773 goto exit_no_irq_fail;
775 ft5x0x_ts->irq = gpio_to_irq(ft5x0x_ts->irq);
778 //INIT_WORK(&ft5x0x_ts->pen_event_work, ft5406_ts_pen_irq_work);
779 INIT_WORK(&ft5x0x_ts->pen_event_work, ft5406_queue_work);
780 ft5x0x_ts->ts_workqueue = create_singlethread_workqueue("ft5x0x_ts");
781 if (!ft5x0x_ts->ts_workqueue) {
783 goto exit_create_singlethread;
786 /***wait CTP to bootup normally***/
789 fts_register_read(FT5X0X_REG_FIRMID, ®_version,1);
790 printk("[TSP] firmware version = 0x%2x\n", reg_version);
791 fts_register_read(FT5X0X_REG_REPORT_RATE, ®_value,1);
792 printk("[TSP]firmware report rate = %dHz\n", reg_value*10);
793 fts_register_read(FT5X0X_REG_THRES, ®_value,1);
794 printk("[TSP]firmware threshold = %d\n", reg_value * 4);
795 fts_register_read(FT5X0X_REG_NOISE_MODE, ®_value,1);
796 printk("[TSP]nosie mode = 0x%2x\n", reg_value);
798 if (fts_ctpm_get_upg_ver() != reg_version)
800 printk("[TSP] start upgrade new verison 0x%2x\n", fts_ctpm_get_upg_ver());
802 err = fts_ctpm_fw_upgrade_with_i_file();
805 printk("[TSP] ugrade successfuly.\n");
807 fts_register_read(FT5X0X_REG_FIRMID, ®_value,1);
808 printk("FTS_DBG from old version 0x%2x to new version = 0x%2x\n", reg_version, reg_value);
812 printk("[TSP] ugrade fail err=%d, line = %d.\n",err, __LINE__);
817 //printk("client->dev.driver->name %s ,%d \n",client->dev.driver->name,ft5x0x_ts->irq);
818 ret = request_irq(ft5x0x_ts->irq, ft5406_interrupt, IRQF_TRIGGER_FALLING, client->dev.driver->name, ft5x0x_ts);
820 dev_err(&client->dev, "irq %d busy?\n", ft5x0x_ts->irq);
821 goto exit_irq_request_fail;
824 i2c_set_clientdata(client, ft5x0x_ts);
825 #if 0//def CONFIG_HAS_EARLYSUSPEND
826 ft5406_early_suspend.suspend =ft5406_ts_suspend;
827 ft5406_early_suspend.resume =ft5406_ts_resume;
828 ft5406_early_suspend.level = 0x2;
829 register_early_suspend(&ft5406_early_suspend);
833 err = ft5406_set_regs(client,0x88,buf_w,1);
835 err = ft5406_read_regs(client,0x88,buf_r,1);
836 // printk("read buf[0x88] = %d\n", buf_r[0]);
839 i2c_set_clientdata(client, NULL);
840 free_irq(ft5x0x_ts->irq,ft5x0x_ts);
841 exit_irq_request_fail:
842 cancel_work_sync(&ft5x0x_ts->pen_event_work);
843 destroy_workqueue(ft5x0x_ts->ts_workqueue);
844 exit_create_singlethread:
846 input_unregister_device(input_dev);
847 exit_input_register_device_failed:
848 input_free_device(input_dev);
849 exit_input_dev_alloc_failed:
851 if (pdata->exit_platform_hw)
852 pdata->exit_platform_hw();
859 static struct i2c_device_id ft5406_idtable[] = {
864 MODULE_DEVICE_TABLE(i2c, ft5406_idtable);
866 static struct i2c_driver ft5406_driver = {
868 .owner = THIS_MODULE,
871 .id_table = ft5406_idtable,
872 .probe = ft5406_probe,
873 .suspend = ft5406_suspend,
874 .resume = ft5406_resume,
875 .remove = __devexit_p(ft5406_remove),
878 static int __init ft5406_ts_init(void)
880 return i2c_add_driver(&ft5406_driver);
883 static void __exit ft5406_ts_exit(void)
885 printk("Touchscreen driver of ft5406 exited.\n");
886 i2c_del_driver(&ft5406_driver);
890 /***********************************************************************/
892 module_init(ft5406_ts_init);
893 module_exit(ft5406_ts_exit);
895 MODULE_AUTHOR("<wenfs@Focaltech-systems.com>");
896 MODULE_DESCRIPTION("FocalTech ft5x0x TouchScreen driver");