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 #include <linux/earlysuspend.h>
63 static struct early_suspend ft5406_power;
68 #define CONFIG_FT5X0X_MULTITOUCH 1
70 #define FT5406_IIC_SPEED 400*1000 //300*1000
71 #define TOUCH_RESET_PIN RK29_PIN6_PC3
72 #define FT5X0X_REG_THRES 0x80 /* Thresshold, the threshold be low, the sensitivy will be high */
73 #define FT5X0X_REG_REPORT_RATE 0x88 /* **************report rate, in unit of 10Hz **************/
74 #define FT5X0X_REG_PMODE 0xA5 /* Power Consume Mode 0 -- active, 1 -- monitor, 3 -- sleep */
75 #define FT5X0X_REG_FIRMID 0xA6 /* ***************firmware version **********************/
76 #define FT5X0X_REG_NOISE_MODE 0xb2 /* to enable or disable power noise, 1 -- enable, 0 -- disable */
77 #define SCREEN_MAX_X 800
78 #define SCREEN_MAX_Y 480
80 #define FT5X0X_NAME "ft5x0x_ts"//"synaptics_i2c_rmi"//"synaptics-rmi-ts"//
81 #define TOUCH_MAJOR_MAX 200
82 #define WIDTH_MAJOR_MAX 200
84 #define PMODE_ACTIVE 0x00
85 #define PMODE_MONITOR 0x01
86 #define PMODE_STANDBY 0x02
87 #define PMODE_HIBERNATE 0x03
120 struct ft5x0x_ts_data {
121 struct i2c_client *client;
122 struct input_dev *input_dev;
124 struct ts_event event;
125 struct work_struct pen_event_work;
126 struct workqueue_struct *ts_workqueue;
128 static struct i2c_client *this_client;
130 /***********************************************************************/
132 #define FTS_PACKET_LENGTH 128
153 /***********************************************************************/
155 /***********************************************************************
157 callback: send data to ctpm by i2c interface;
159 txdata[in]: data buffer which is used to send data;
160 length[in]: the length of the data buffer;
164 ************************************************************************/
165 static int fts_i2c_txdata(u8 *txdata, int length)
171 msg.addr = this_client->addr;
175 ret = i2c_transfer(this_client->adapter, &msg, 1);
177 pr_err("%s i2c write error: %d\n", __func__, ret);
182 /***********************************************************************
184 callback: write data to ctpm by i2c interface;
186 buffer[in]: data buffer;
187 length[in]: the length of the data buffer;
191 ************************************************************************/
192 static bool i2c_write_interface(u8* pbt_buf, int dw_lenth)
195 ret=i2c_master_send(this_client, pbt_buf, dw_lenth);
198 printk("[TSP]i2c_write_interface error line = %d, ret = %d\n", __LINE__, ret);
205 /***********************************************************************
207 callback: read register value ftom ctpm by i2c interface;
209 reg_name[in]: the register which you want to write;
210 tx_buf[in]: buffer which is contained of the writing value;
214 ************************************************************************/
215 static bool fts_register_write(u8 reg_name, u8* tx_buf)
217 u8 write_cmd[2] = {0};
219 write_cmd[0] = reg_name;
220 write_cmd[1] = *tx_buf;
222 /*call the write callback function*/
223 return i2c_write_interface(write_cmd, 2);
226 /***********************************************************************
228 callback: send a command to ctpm.
230 btcmd[in]: command code;
231 btPara1[in]: parameter 1;
232 btPara2[in]: parameter 2;
233 btPara3[in]: parameter 3;
234 num[in]: the valid input parameter numbers,
235 if only command code needed and no
236 parameters followed,then the num is 1;
240 ************************************************************************/
241 static bool cmd_write(u8 btcmd,u8 btPara1,u8 btPara2,u8 btPara3,u8 num)
243 u8 write_cmd[4] = {0};
245 write_cmd[0] = btcmd;
246 write_cmd[1] = btPara1;
247 write_cmd[2] = btPara2;
248 write_cmd[3] = btPara3;
249 return i2c_write_interface(write_cmd, num);
252 /***********************************************************************
254 callback: read data from ctpm by i2c interface;
256 buffer[in]: data buffer;
257 length[in]: the length of the data buffer;
261 ************************************************************************/
262 static bool i2c_read_interface(u8* pbt_buf, int dw_lenth)
266 ret=i2c_master_recv(this_client, pbt_buf, dw_lenth);
270 printk("[TSP]i2c_read_interface error\n");
278 /***********************************************************************
280 callback: read a byte data from ctpm;
282 buffer[in]: read buffer;
283 length[in]: the size of read data;
287 ************************************************************************/
288 static bool byte_read(u8* buffer, int length)
290 return i2c_read_interface(buffer, length);
293 /***********************************************************************
295 callback: write a byte data to ctpm;
297 buffer[in]: write buffer;
298 length[in]: the size of write data;
302 ************************************************************************/
303 static bool byte_write(u8* buffer, int length)
306 return i2c_write_interface(buffer, length);
309 /***********************************************************************
311 callback: read register value ftom ctpm by i2c interface;
313 reg_name[in]: the register which you want to read;
314 rx_buf[in]: data buffer which is used to store register value;
315 rx_length[in]: the length of the data buffer;
319 ************************************************************************/
320 static bool fts_register_read(u8 reg_name, u8* rx_buf, int rx_length)
325 read_cmd[0] = reg_name;
328 /*send register addr*/
329 if(!i2c_write_interface(&read_cmd[0], cmd_len))
334 /*call the read callback function to get the register value*/
335 if(!i2c_read_interface(rx_buf, rx_length))
344 /***********************************************************************
346 callback: burn the FW to ctpm.
348 pbt_buf[in]: point to Head+FW ;
349 dw_lenth[in]: the length of the FW + 6(the Head length);
352 ERR_MODE: fail to switch to UPDATE mode;
353 ERR_READID: read id fail;
354 ERR_ERASE: erase chip fail;
355 ERR_STATUS: status error;
357 ************************************************************************/
358 E_UPGRADE_ERR_TYPE fts_ctpm_fw_upgrade(u8* pbt_buf, int dw_lenth)
360 u8 cmd,reg_val[2] = {0};
362 u8 packet_buf[FTS_PACKET_LENGTH + 6];
363 u8 auc_i2c_write_buf[10];
366 int j,temp,lenght,i_ret,packet_number, i = 0;
367 int i_is_new_protocol = 0;
370 /******write 0xaa to register 0xfc******/
372 fts_register_write(0xfc,&cmd);
375 /******write 0x55 to register 0xfc******/
377 fts_register_write(0xfc,&cmd);
378 printk("[TSP] Step 1: Reset CTPM test\n");
383 /*******Step 2:Enter upgrade mode ****/
384 printk("\n[TSP] Step 2:enter new update mode\n");
385 auc_i2c_write_buf[0] = 0x55;
386 auc_i2c_write_buf[1] = 0xaa;
390 i_ret = fts_i2c_txdata(auc_i2c_write_buf, 2);
392 }while(i_ret <= 0 && i < 10 );
396 i_is_new_protocol = 1;
399 /********Step 3:check READ-ID********/
400 cmd_write(0x90,0x00,0x00,0x00,4);
401 byte_read(reg_val,2);
402 if (reg_val[0] == 0x79 && reg_val[1] == 0x3)
404 printk("[TSP] Step 3: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]);
409 //i_is_new_protocol = 1;
413 /*********Step 4:erase app**********/
414 if (i_is_new_protocol)
416 cmd_write(0x61,0x00,0x00,0x00,1);
420 cmd_write(0x60,0x00,0x00,0x00,1);
423 printk("[TSP] Step 4: erase. \n");
427 /*Step 5:write firmware(FW) to ctpm flash*/
429 printk("[TSP] Step 5: start upgrade. \n");
430 dw_lenth = dw_lenth - 8;
431 packet_number = (dw_lenth) / FTS_PACKET_LENGTH;
432 packet_buf[0] = 0xbf;
433 packet_buf[1] = 0x00;
434 for (j=0;j<packet_number;j++)
436 temp = j * FTS_PACKET_LENGTH;
437 packet_buf[2] = (u8)(temp>>8);
438 packet_buf[3] = (u8)temp;
439 lenght = FTS_PACKET_LENGTH;
440 packet_buf[4] = (u8)(lenght>>8);
441 packet_buf[5] = (u8)lenght;
443 for (i=0;i<FTS_PACKET_LENGTH;i++)
445 packet_buf[6+i] = pbt_buf[j*FTS_PACKET_LENGTH + i];
446 bt_ecc ^= packet_buf[6+i];
449 byte_write(&packet_buf[0],FTS_PACKET_LENGTH + 6);
450 mdelay(FTS_PACKET_LENGTH/6 + 1);
451 if ((j * FTS_PACKET_LENGTH % 1024) == 0)
453 printk("[TSP] upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_LENGTH);
457 if ((dw_lenth) % FTS_PACKET_LENGTH > 0)
459 temp = packet_number * FTS_PACKET_LENGTH;
460 packet_buf[2] = (u8)(temp>>8);
461 packet_buf[3] = (u8)temp;
463 temp = (dw_lenth) % FTS_PACKET_LENGTH;
464 packet_buf[4] = (u8)(temp>>8);
465 packet_buf[5] = (u8)temp;
469 packet_buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_LENGTH + i];
470 bt_ecc ^= packet_buf[6+i];
473 byte_write(&packet_buf[0],temp+6);
477 /***********send the last six byte**********/
478 for (i = 0; i<6; i++)
481 packet_buf[2] = (u8)(temp>>8);
482 packet_buf[3] = (u8)temp;
484 packet_buf[4] = (u8)(temp>>8);
485 packet_buf[5] = (u8)temp;
486 packet_buf[6] = pbt_buf[ dw_lenth + i];
487 bt_ecc ^= packet_buf[6];
489 byte_write(&packet_buf[0],7);
493 /********send the opration head************/
494 cmd_write(0xcc,0x00,0x00,0x00,1);
495 byte_read(reg_val,1);
496 printk("[TSP] Step 6: ecc read 0x%x, new firmware 0x%x. \n", reg_val[0], bt_ecc);
497 if(reg_val[0] != bt_ecc)
502 /*******Step 7: reset the new FW**********/
503 cmd_write(0x07,0x00,0x00,0x00,1);
505 fts_register_read(0xfc, buffer, 1);
509 fts_register_write(0xfc, &cmd);
510 mdelay(2500);//2500ms
513 fts_register_read(0xfc, buffer, 1);
515 }while (buffer[0] != 1);
521 /***********************************************************************/
523 int fts_ctpm_fw_upgrade_with_i_file(void)
529 i_ret = fts_ctpm_fw_upgrade(pbt_buf,sizeof(CTPM_FW));
534 /***********************************************************************/
536 unsigned char fts_ctpm_get_upg_ver(void)
540 ui_sz = sizeof(CTPM_FW);
543 return CTPM_FW[ui_sz - 2];
550 /*read the it7260 register ,used i2c bus*/
551 static int ft5406_read_regs(struct i2c_client *client, u8 reg, u8 buf[], unsigned len)
554 ret = i2c_master_reg8_recv(client, reg, buf, len, FT5406_IIC_SPEED);
559 /* set the it7260 registe,used i2c bus*/
560 static int ft5406_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], unsigned short len)
563 ret = i2c_master_reg8_send(client, reg, buf, (int)len, FT5406_IIC_SPEED);
567 static void ft5406_queue_work(struct work_struct *work)
569 struct ft5x0x_ts_data *data = container_of(work, struct ft5x0x_ts_data, pen_event_work);
570 struct tp_event event;
573 int ret,i,offset,points;
575 #if CONFIG_FT5X0X_MULTITOUCH
576 ret = ft5406_read_regs(data->client,start_reg, buf, 6*MAX_POINT+1);
578 ret = ft5406_read_regs(data->client,start_reg, buf, 7);
581 dev_err(&data->client->dev, "ft5406_read_regs fail:%d!\n",ret);
582 enable_irq(data->irq);
586 for (i=0; i<32; i++) {
587 printk("buf[%d] = 0x%x \n", i, buf[i]);
591 points = buf[2] & 0x07;
592 //dev_info(&data->client->dev, "ft5406_read_and_report_data points = %d\n",points);
594 #if CONFIG_FT5X0X_MULTITOUCH
595 input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 0);
596 input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 0);
597 //input_mt_sync(data->input_dev);
599 input_report_abs(data->input_dev, ABS_PRESSURE, 0);
600 input_report_key(data->input_dev, BTN_TOUCH, 0);
602 input_sync(data->input_dev);
603 enable_irq(data->irq);
604 dev_info(&data->client->dev, "ft5406 touch release\n");
607 memset(&event, 0, sizeof(struct tp_event));
608 #if CONFIG_FT5X0X_MULTITOUCH
609 for(i=0;i<points;i++){
611 event.x = (((s16)(buf[offset+0] & 0x0F))<<8) | ((s16)buf[offset+1]);
612 event.y = (((s16)(buf[offset+2] & 0x0F))<<8) | ((s16)buf[offset+3]);
613 event.id = (s16)(buf[offset+2] & 0xF0)>>4;
614 event.flag = ((buf[offset+0] & 0xc0) >> 6);
615 event.pressure = 200;
616 if(event.x<=SCREEN_MAX_X && event.y<=SCREEN_MAX_Y){
617 //dev_info(&data->client->dev,
618 // "ft5406 multiple report event[%d]:x = %d,y = %d,id = %d,flag = %d,pressure = %d\n",
619 // i,event.x,event.y,event.id,event.flag,event.pressure);
620 input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 200);
621 input_report_abs(data->input_dev, ABS_MT_POSITION_X, event.x);
622 input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event.y);
623 input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, event.id);
624 input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
625 input_mt_sync(data->input_dev);
629 event.x = (s16)(buf[3] & 0x0F)<<8 | (s16)buf[4];
630 event.y = (s16)(buf[5] & 0x0F)<<8 | (s16)buf[6];
632 input_report_abs(data->input_dev, ABS_X, event.x);
633 input_report_abs(data->input_dev, ABS_Y, event.y);
634 input_report_abs(data->input_dev, ABS_PRESSURE, event.pressure);
635 input_report_key(data->input_dev, BTN_TOUCH, 1);
636 //dev_info(&data->client->dev, "ft5406 single report event:x = %d,y = %d\n",event.x,event.y);
638 //dev_info(&data->client->dev, "ft5406 sync\n",event.x,event.y);
639 input_sync(data->input_dev);
640 enable_irq(data->irq);
644 static irqreturn_t ft5406_interrupt(int irq, void *dev_id)
646 struct ft5x0x_ts_data *ft5x0x_ts = dev_id;
648 disable_irq_nosync(ft5x0x_ts->irq);
649 if (!work_pending(&ft5x0x_ts->pen_event_work))
650 queue_work(ft5x0x_ts->ts_workqueue, &ft5x0x_ts->pen_event_work);
654 static int ft5406_suspend(struct i2c_client *client, pm_message_t mesg)
656 struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client);
657 struct ft5406_platform_data *pdata = client->dev.platform_data;
659 if (pdata->platform_sleep)
660 pdata->platform_sleep();
661 disable_irq(ft5x0x_ts->irq);
666 static int ft5406_resume(struct i2c_client *client)
668 struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client);
669 struct ft5406_platform_data *pdata = client->dev.platform_data;
671 enable_irq(ft5x0x_ts->irq);
672 if (pdata->platform_wakeup)
673 pdata->platform_wakeup();
677 static void ft5406_suspend_early(struct early_suspend *h)
679 ft5406_suspend(this_client,PMSG_SUSPEND);
682 static void ft5406_resume_early(struct early_suspend *h)
684 ft5406_resume(this_client);
686 static int __devexit ft5406_remove(struct i2c_client *client)
688 struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client);
690 free_irq(ft5x0x_ts->irq, ft5x0x_ts);
691 input_unregister_device(ft5x0x_ts->input_dev);
693 cancel_work_sync(&ft5x0x_ts->pen_event_work);
694 destroy_workqueue(ft5x0x_ts->ts_workqueue);
695 i2c_set_clientdata(client, NULL);
696 unregister_early_suspend(&ft5406_power);
701 static int ft5406_probe(struct i2c_client *client ,const struct i2c_device_id *id)
703 struct ft5x0x_ts_data *ft5x0x_ts;
704 struct input_dev *input_dev;
705 struct ft5406_platform_data *pdata = client->dev.platform_data;
711 const u8 buf_test[1] = {0};
712 unsigned char reg_value;
713 unsigned char reg_version;
715 dev_info(&client->dev, "ft5x0x_ts_probe!\n");
717 dev_err(&client->dev, "platform data is required!\n");
721 if (pdata->init_platform_hw)
722 pdata->init_platform_hw();
724 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)){
725 dev_err(&client->dev, "Must have I2C_FUNC_I2C.\n");
729 ft5x0x_ts = kzalloc(sizeof(*ft5x0x_ts), GFP_KERNEL);
736 ret=ft5406_set_regs(client,FT5X0X_REG_PMODE, buf_test,1);
742 printk("FT5406 I2C TEST ERROR!\n");
744 goto exit_i2c_test_fail;
747 input_dev = input_allocate_device();
750 printk("failed to allocate input device\n");
751 goto exit_input_dev_alloc_failed;
753 ft5x0x_ts->client = this_client = client;
754 ft5x0x_ts->irq = client->irq;
755 ft5x0x_ts->input_dev = input_dev;
757 #if CONFIG_FT5X0X_MULTITOUCH
758 set_bit(ABS_MT_POSITION_X, input_dev->absbit);
759 set_bit(ABS_MT_POSITION_Y, input_dev->absbit);
760 set_bit(ABS_MT_TOUCH_MAJOR, input_dev->absbit);
761 set_bit(ABS_MT_TRACKING_ID, input_dev->absbit);
762 set_bit(ABS_MT_WIDTH_MAJOR, input_dev->absbit);
763 input_set_abs_params(input_dev,ABS_MT_POSITION_X, 0, SCREEN_MAX_X, 0, 0);
764 input_set_abs_params(input_dev,ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y, 0, 0);
765 input_set_abs_params(input_dev,ABS_MT_TOUCH_MAJOR, 0, TOUCH_MAJOR_MAX, 0, 0);
766 input_set_abs_params(input_dev,ABS_MT_TRACKING_ID, 0, MAX_POINT, 0, 0);
767 input_set_abs_params(input_dev,ABS_MT_WIDTH_MAJOR, 0, WIDTH_MAJOR_MAX, 0, 0);
769 set_bit(ABS_X, input_dev->absbit);
770 set_bit(ABS_Y, input_dev->absbit);
771 set_bit(ABS_PRESSURE, input_dev->absbit);
772 set_bit(BTN_TOUCH, input_dev->keybit);
773 input_set_abs_params(input_dev, ABS_X, 0, SCREEN_MAX_X, 0, 0);
774 input_set_abs_params(input_dev, ABS_Y, 0, SCREEN_MAX_Y, 0, 0);
775 input_set_abs_params(input_dev, ABS_PRESSURE, 0, PRESS_MAX, 0 , 0);
779 set_bit(EV_ABS, input_dev->evbit);
780 set_bit(EV_KEY, input_dev->evbit);
782 input_dev->name = FT5X0X_NAME; //dev_name(&client->dev)
783 err = input_register_device(input_dev);
785 printk("ft5x0x_ts_probe: failed to register input device: \n");
786 goto exit_input_register_device_failed;
789 if (!ft5x0x_ts->irq) {
791 dev_err(&ft5x0x_ts->client->dev, "no IRQ?\n");
792 goto exit_no_irq_fail;
794 ft5x0x_ts->irq = gpio_to_irq(ft5x0x_ts->irq);
797 //INIT_WORK(&ft5x0x_ts->pen_event_work, ft5406_ts_pen_irq_work);
798 INIT_WORK(&ft5x0x_ts->pen_event_work, ft5406_queue_work);
799 ft5x0x_ts->ts_workqueue = create_singlethread_workqueue("ft5x0x_ts");
800 if (!ft5x0x_ts->ts_workqueue) {
802 goto exit_create_singlethread;
805 /***wait CTP to bootup normally***/
808 fts_register_read(FT5X0X_REG_FIRMID, ®_version,1);
809 printk("[TSP] firmware version = 0x%2x\n", reg_version);
810 fts_register_read(FT5X0X_REG_REPORT_RATE, ®_value,1);
811 printk("[TSP]firmware report rate = %dHz\n", reg_value*10);
812 fts_register_read(FT5X0X_REG_THRES, ®_value,1);
813 printk("[TSP]firmware threshold = %d\n", reg_value * 4);
814 fts_register_read(FT5X0X_REG_NOISE_MODE, ®_value,1);
815 printk("[TSP]nosie mode = 0x%2x\n", reg_value);
817 if (fts_ctpm_get_upg_ver() != reg_version)
819 printk("[TSP] start upgrade new verison 0x%2x\n", fts_ctpm_get_upg_ver());
821 err = fts_ctpm_fw_upgrade_with_i_file();
824 printk("[TSP] ugrade successfuly.\n");
826 fts_register_read(FT5X0X_REG_FIRMID, ®_value,1);
827 printk("FTS_DBG from old version 0x%2x to new version = 0x%2x\n", reg_version, reg_value);
831 printk("[TSP] ugrade fail err=%d, line = %d.\n",err, __LINE__);
836 //printk("client->dev.driver->name %s ,%d \n",client->dev.driver->name,ft5x0x_ts->irq);
837 ret = request_irq(ft5x0x_ts->irq, ft5406_interrupt, IRQF_TRIGGER_FALLING, client->dev.driver->name, ft5x0x_ts);
839 dev_err(&client->dev, "irq %d busy?\n", ft5x0x_ts->irq);
840 goto exit_irq_request_fail;
843 i2c_set_clientdata(client, ft5x0x_ts);
844 ft5406_power.suspend =ft5406_suspend_early;
845 ft5406_power.resume =ft5406_resume_early;
846 ft5406_power.level = 0x2;
847 register_early_suspend(&ft5406_power);
850 err = ft5406_set_regs(client,0x88,buf_w,1);
852 err = ft5406_read_regs(client,0x88,buf_r,1);
853 // printk("read buf[0x88] = %d\n", buf_r[0]);
856 i2c_set_clientdata(client, NULL);
857 free_irq(ft5x0x_ts->irq,ft5x0x_ts);
858 exit_irq_request_fail:
859 cancel_work_sync(&ft5x0x_ts->pen_event_work);
860 destroy_workqueue(ft5x0x_ts->ts_workqueue);
861 exit_create_singlethread:
863 input_unregister_device(input_dev);
864 exit_input_register_device_failed:
865 input_free_device(input_dev);
866 exit_input_dev_alloc_failed:
868 if (pdata->exit_platform_hw)
869 pdata->exit_platform_hw();
876 static struct i2c_device_id ft5406_idtable[] = {
881 MODULE_DEVICE_TABLE(i2c, ft5406_idtable);
883 static struct i2c_driver ft5406_driver = {
885 .owner = THIS_MODULE,
888 .id_table = ft5406_idtable,
889 .probe = ft5406_probe,
890 .remove = __devexit_p(ft5406_remove),
893 static int __init ft5406_ts_init(void)
895 return i2c_add_driver(&ft5406_driver);
898 static void __exit ft5406_ts_exit(void)
900 printk("Touchscreen driver of ft5406 exited.\n");
901 i2c_del_driver(&ft5406_driver);
905 /***********************************************************************/
907 module_init(ft5406_ts_init);
908 module_exit(ft5406_ts_exit);
910 MODULE_AUTHOR("<wenfs@Focaltech-systems.com>");
911 MODULE_DESCRIPTION("FocalTech ft5x0x TouchScreen driver");