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/irq.h>
22 #include <asm/mach/irq.h>
23 #include <linux/slab.h>
24 #include <linux/i2c.h>
25 #include <linux/input.h>
26 #include "ft5x0x_i2c_ts.h"
27 #include <linux/interrupt.h>
28 #include <linux/delay.h>
29 #include <linux/platform_device.h>
30 #include <linux/async.h>
31 #include <mach/gpio.h>
32 #include <mach/board.h>
33 #include <linux/earlysuspend.h>
34 #include <linux/input/mt.h>
36 struct FTS_TS_DATA_T {
37 struct i2c_client *client;
38 struct input_dev *input_dev;
39 struct FTS_TS_EVENT_T event;
40 struct work_struct pen_event_work;
41 struct workqueue_struct *ts_workqueue;
42 struct early_suspend early_suspend;
45 /* -------------- global variable definition -----------*/
46 static struct i2c_client *this_client;
47 static REPORT_FINGER_INFO_T _st_finger_infos[CFG_MAX_POINT_NUM];
48 //static unsigned int _sui_irq_num= IRQ_EINT(6);
49 static int _si_touch_num = 0;
51 int tsp_keycodes[CFG_NUMOFKEYS] ={
59 char *tsp_keyname[CFG_NUMOFKEYS] ={
67 static bool tsp_keystatus[CFG_NUMOFKEYS];
70 #ifdef CONFIG_HAS_EARLYSUSPEND
71 static void ft5x0x_ts_early_suspend(struct early_suspend *h);
72 static void ft5x0x_ts_late_resume(struct early_suspend *h);
76 /***********************************************************************
78 callback: read data from ctpm by i2c interface;
80 buffer[in]: data buffer;
81 length[in]: the length of the data buffer;
85 ************************************************************************/
86 static bool i2c_read_interface(u8* pbt_buf, int dw_lenth)
90 ret=i2c_master_recv(this_client, pbt_buf, dw_lenth);
94 printk("[TSP]i2c_read_interface error\n");
103 /***********************************************************************
105 callback: write data to ctpm by i2c interface;
107 buffer[in]: data buffer;
108 length[in]: the length of the data buffer;
112 ************************************************************************/
113 static bool i2c_write_interface(u8* pbt_buf, int dw_lenth)
116 ret=i2c_master_send(this_client, pbt_buf, dw_lenth);
119 printk("[TSP]i2c_write_interface error line = %d, ret = %d\n", __LINE__, ret);
128 /***********************************************************************
130 callback: read register value ftom ctpm by i2c interface;
132 reg_name[in]: the register which you want to read;
133 rx_buf[in]: data buffer which is used to store register value;
134 rx_length[in]: the length of the data buffer;
138 ************************************************************************/
139 static bool fts_register_read(u8 reg_name, u8* rx_buf, int rx_length)
144 read_cmd[0] = reg_name;
147 /*send register addr*/
148 if(!i2c_write_interface(&read_cmd[0], cmd_len))
153 /*call the read callback function to get the register value*/
154 if(!i2c_read_interface(rx_buf, rx_length))
164 /***********************************************************************
166 callback: read register value ftom ctpm by i2c interface;
168 reg_name[in]: the register which you want to write;
169 tx_buf[in]: buffer which is contained of the writing value;
173 ************************************************************************/
174 static bool fts_register_write(u8 reg_name, u8* tx_buf)
176 u8 write_cmd[2] = {0};
178 write_cmd[0] = reg_name;
179 write_cmd[1] = *tx_buf;
181 /*call the write callback function*/
182 return i2c_write_interface(write_cmd, 2);
188 /***********************************************************************
190 callback: report to the input system that the finger is put up;
195 ************************************************************************/
196 static void fts_ts_release(void)
198 struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client);
201 for ( i= 0; i<CFG_MAX_POINT_NUM; ++i )
203 if ( _st_finger_infos[i].u2_pressure == -1 )
206 input_mt_slot(data->input_dev, i);
207 input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, false);
210 input_report_abs(data->input_dev, ABS_MT_POSITION_X, _st_finger_infos[i].i2_x);
211 input_report_abs(data->input_dev, ABS_MT_POSITION_Y, _st_finger_infos[i].i2_y);
212 input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, _st_finger_infos[i].u2_pressure);
213 input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, _st_finger_infos[i].ui2_id);
214 input_mt_sync(data->input_dev);
218 if ( _st_finger_infos[i].u2_pressure == 0 )
219 _st_finger_infos[i].u2_pressure= -1;
224 input_sync(data->input_dev);
235 /***********************************************************************
237 callback: read touch data ftom ctpm by i2c interface;
239 rxdata[in]: data buffer which is used to store touch data;
240 length[in]: the length of the data buffer;
244 ************************************************************************/
245 static int fts_i2c_rxdata(u8 *rxdata, int length)
251 msg.addr = this_client->addr;
255 msg.scl_rate = FT5X0X_I2C_SPEED;
257 ret = i2c_transfer(this_client->adapter, &msg, 1);
260 pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
263 pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
267 msg.addr = this_client->addr;
268 msg.flags = I2C_M_RD;
271 msg.scl_rate = FT5X0X_I2C_SPEED;
272 ret = i2c_transfer(this_client->adapter, &msg, 1);
275 pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
278 pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
289 /***********************************************************************
291 callback: send data to ctpm by i2c interface;
293 txdata[in]: data buffer which is used to send data;
294 length[in]: the length of the data buffer;
298 ************************************************************************/
299 static int fts_i2c_txdata(u8 *txdata, int length)
305 msg.addr = this_client->addr;
309 msg.scl_rate = FT5X0X_I2C_SPEED;
311 ret = i2c_transfer(this_client->adapter, &msg, 1);
314 pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
317 pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
326 /***********************************************************************
328 callback: gather the finger information and calculate the X,Y
329 coordinate then report them to the input system;
334 ************************************************************************/
335 int fts_read_data(void)
337 struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client);
339 // static int key_id=0x80;
341 int id,i_count,ret = -1;
342 int touch_point_num = 0, touch_event, x, y;
343 int tmp, swap ,sync_flag = 0;
346 ret = fts_i2c_rxdata(buf, 1);
348 touch_point_num = buf[0]&0xf;
350 printk(KERN_ERR "get fingers failed!\n");
352 // printk(KERN_INFO "touch_point_num=%d\n", touch_point_num);
353 if(touch_point_num > CFG_MAX_POINT_NUM)
354 printk("[Warning],+++++Touch number[%d] readed is larger than max point number+++++++++++++\n",touch_point_num);
358 if(touch_point_num != 0)
361 ret=fts_i2c_rxdata(buf, 6*touch_point_num);
366 id = buf[2+i_count*6]>>4;
367 if(id <0 || id>CFG_MAX_POINT_NUM)
368 printk("[ERROR] Touch ID readed is illegal!!\n");
370 touch_event = buf[i_count*6]>>6;
371 x =((buf[i_count*6]& 0x0f)<<8) |buf[i_count*6+1];
372 y =( (buf[i_count*6+2]& 0x0f)<<8) | buf[i_count*6+3];
384 if (touch_event == 0) //down
386 _st_finger_infos[i_count].u2_pressure= 1;//pressure;
387 _st_finger_infos[i_count].i2_x= (int16_t)x;
388 _st_finger_infos[i_count].i2_y= (int16_t)y;
390 else if (touch_event == 1) //up event
392 _st_finger_infos[i_count].u2_pressure= 0;
394 else if (touch_event == 2) //move
396 _st_finger_infos[i_count].u2_pressure= 1;//pressure;
397 _st_finger_infos[i_count].i2_x= (int16_t)x;
398 _st_finger_infos[i_count].i2_y= (int16_t)y;
400 else /*bad event, ignore*/
402 printk("Bad event, ignore!!!\n");
407 if(_st_finger_infos[i_count].u2_pressure == 1)//down
409 input_mt_slot(data->input_dev, id);
410 input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, true);
411 input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 1);
412 input_report_abs(data->input_dev, ABS_MT_POSITION_X, _st_finger_infos[i_count].i2_x);
413 input_report_abs(data->input_dev, ABS_MT_POSITION_Y, _st_finger_infos[i_count].i2_y);
416 else if(_st_finger_infos[i_count].u2_pressure == 0)//up
418 input_mt_slot(data->input_dev, id);
419 input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, false);
424 if(_st_finger_infos[i_count].u2_pressure == 0 )
426 _st_finger_infos[i_count].u2_pressure= -1;
429 input_sync(data->input_dev);
432 }while(i_count < touch_point_num);
435 input_sync(data->input_dev);
440 printk("[LAIBAO] ERROR: in %s, line %d, ret = %d\n",
441 __FUNCTION__, __LINE__, ret);
445 //If touch number is zero then release touch.
446 if(touch_point_num == 0 )
456 static void fts_work_func(struct work_struct *work)
459 enable_irq(this_client->irq);
465 static irqreturn_t fts_ts_irq(int irq, void *dev_id)
467 struct FTS_TS_DATA_T *ft5x0x_ts = dev_id;
468 // printk(KERN_ALERT "fts_tp_irq\n");
469 if (!work_pending(&ft5x0x_ts->pen_event_work)) {
470 disable_irq_nosync(this_client->irq);
471 queue_work(ft5x0x_ts->ts_workqueue, &ft5x0x_ts->pen_event_work);
479 /***********************************************************************
481 callback: send a command to ctpm.
483 btcmd[in]: command code;
484 btPara1[in]: parameter 1;
485 btPara2[in]: parameter 2;
486 btPara3[in]: parameter 3;
487 num[in]: the valid input parameter numbers,
488 if only command code needed and no
489 parameters followed,then the num is 1;
493 ************************************************************************/
494 static bool cmd_write(u8 btcmd,u8 btPara1,u8 btPara2,u8 btPara3,u8 num)
496 u8 write_cmd[4] = {0};
498 write_cmd[0] = btcmd;
499 write_cmd[1] = btPara1;
500 write_cmd[2] = btPara2;
501 write_cmd[3] = btPara3;
502 return i2c_write_interface(write_cmd, num);
508 /***********************************************************************
510 callback: write a byte data to ctpm;
512 buffer[in]: write buffer;
513 length[in]: the size of write data;
517 ************************************************************************/
518 static bool byte_write(u8* buffer, int length)
521 return i2c_write_interface(buffer, length);
527 /***********************************************************************
529 callback: read a byte data from ctpm;
531 buffer[in]: read buffer;
532 length[in]: the size of read data;
536 ************************************************************************/
537 static bool byte_read(u8* buffer, int length)
539 return i2c_read_interface(buffer, length);
546 #define FTS_PACKET_LENGTH 128
548 static unsigned char CTPM_FW[]=
550 //#include "ft_app.i"
556 /***********************************************************************
558 callback: burn the FW to ctpm.
560 pbt_buf[in]: point to Head+FW ;
561 dw_lenth[in]: the length of the FW + 6(the Head length);
564 ERR_MODE: fail to switch to UPDATE mode;
565 ERR_READID: read id fail;
566 ERR_ERASE: erase chip fail;
567 ERR_STATUS: status error;
569 ************************************************************************/
570 E_UPGRADE_ERR_TYPE fts_ctpm_fw_upgrade(u8* pbt_buf, int dw_lenth)
572 u8 cmd,reg_val[2] = {0};
573 u8 packet_buf[FTS_PACKET_LENGTH + 6];
574 u8 auc_i2c_write_buf[10];
577 int j,temp,lenght,i_ret,packet_number, i = 0;
578 int i_is_new_protocol = 0;
581 /******write 0xaa to register 0xfc******/
583 fts_register_write(0xfc,&cmd);
586 /******write 0x55 to register 0xfc******/
588 fts_register_write(0xfc,&cmd);
589 printk("[TSP] Step 1: Reset CTPM test\n");
594 /*******Step 2:Enter upgrade mode ****/
595 printk("\n[TSP] Step 2:enter new update mode\n");
596 auc_i2c_write_buf[0] = 0x55;
597 auc_i2c_write_buf[1] = 0xaa;
601 i_ret = fts_i2c_txdata(auc_i2c_write_buf, 2);
603 }while(i_ret <= 0 && i < 10 );
607 i_is_new_protocol = 1;
610 /********Step 3:check READ-ID********/
611 cmd_write(0x90,0x00,0x00,0x00,4);
612 byte_read(reg_val,2);
613 if (reg_val[0] == 0x79 && reg_val[1] == 0x3)
615 printk("[TSP] Step 3: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]);
620 //i_is_new_protocol = 1;
624 /*********Step 4:erase app**********/
625 if (i_is_new_protocol)
627 cmd_write(0x61,0x00,0x00,0x00,1);
631 cmd_write(0x60,0x00,0x00,0x00,1);
634 printk("[TSP] Step 4: erase. \n");
638 /*Step 5:write firmware(FW) to ctpm flash*/
640 printk("[TSP] Step 5: start upgrade. \n");
641 dw_lenth = dw_lenth - 8;
642 packet_number = (dw_lenth) / FTS_PACKET_LENGTH;
643 packet_buf[0] = 0xbf;
644 packet_buf[1] = 0x00;
645 for (j=0;j<packet_number;j++)
647 temp = j * FTS_PACKET_LENGTH;
648 packet_buf[2] = (FTS_BYTE)(temp>>8);
649 packet_buf[3] = (FTS_BYTE)temp;
650 lenght = FTS_PACKET_LENGTH;
651 packet_buf[4] = (FTS_BYTE)(lenght>>8);
652 packet_buf[5] = (FTS_BYTE)lenght;
654 for (i=0;i<FTS_PACKET_LENGTH;i++)
656 packet_buf[6+i] = pbt_buf[j*FTS_PACKET_LENGTH + i];
657 bt_ecc ^= packet_buf[6+i];
660 byte_write(&packet_buf[0],FTS_PACKET_LENGTH + 6);
661 mdelay(FTS_PACKET_LENGTH/6 + 1);
662 if ((j * FTS_PACKET_LENGTH % 1024) == 0)
664 printk("[TSP] upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_LENGTH);
668 if ((dw_lenth) % FTS_PACKET_LENGTH > 0)
670 temp = packet_number * FTS_PACKET_LENGTH;
671 packet_buf[2] = (FTS_BYTE)(temp>>8);
672 packet_buf[3] = (FTS_BYTE)temp;
674 temp = (dw_lenth) % FTS_PACKET_LENGTH;
675 packet_buf[4] = (FTS_BYTE)(temp>>8);
676 packet_buf[5] = (FTS_BYTE)temp;
680 packet_buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_LENGTH + i];
681 bt_ecc ^= packet_buf[6+i];
684 byte_write(&packet_buf[0],temp+6);
688 /***********send the last six byte**********/
689 for (i = 0; i<6; i++)
692 packet_buf[2] = (FTS_BYTE)(temp>>8);
693 packet_buf[3] = (FTS_BYTE)temp;
695 packet_buf[4] = (FTS_BYTE)(temp>>8);
696 packet_buf[5] = (FTS_BYTE)temp;
697 packet_buf[6] = pbt_buf[ dw_lenth + i];
698 bt_ecc ^= packet_buf[6];
700 byte_write(&packet_buf[0],7);
704 /********send the opration head************/
705 cmd_write(0xcc,0x00,0x00,0x00,1);
706 byte_read(reg_val,1);
707 printk("[TSP] Step 6: ecc read 0x%x, new firmware 0x%x. \n", reg_val[0], bt_ecc);
708 if(reg_val[0] != bt_ecc)
713 /*******Step 7: reset the new FW**********/
714 cmd_write(0x07,0x00,0x00,0x00,1);
722 int fts_ctpm_fw_upgrade_with_i_file(void)
724 u8* pbt_buf = FTS_NULL;
728 i_ret = fts_ctpm_fw_upgrade(pbt_buf,sizeof(CTPM_FW));
733 unsigned char fts_ctpm_get_upg_ver(void)
737 ui_sz = sizeof(CTPM_FW);
740 return CTPM_FW[ui_sz - 2];
747 void ft5x0x_ts_set_standby(struct i2c_client *client, int enable)
749 struct laibao_platform_data *mach_info = client->dev.platform_data;
750 unsigned pwr_pin = mach_info->pwr_pin;
751 unsigned pwr_on_value = mach_info->pwr_on_value;
752 unsigned reset_pin = mach_info->reset_pin;
753 unsigned reset_value = mach_info->reset_value;
755 printk("%s : %s, enable = %d\n", __FILE__, __FUNCTION__,enable);
756 if(pwr_pin != INVALID_GPIO)
758 gpio_direction_output(pwr_pin, 0);
759 gpio_set_value(pwr_pin, enable ? pwr_on_value : !pwr_on_value);
761 if(reset_pin != INVALID_GPIO)
763 gpio_direction_output(reset_pin, enable ? reset_value : !reset_value);
764 gpio_set_value(reset_pin, enable ? reset_value : !reset_value);
768 #ifdef CONFIG_HAS_EARLYSUSPEND
769 static void ft5x0x_ts_early_suspend(struct early_suspend *h)
771 struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client);
774 printk("enter ft5x0x_ts_early_suspend\n");
776 cancel_work_sync(&data->pen_event_work);
778 disable_irq(this_client->irq);
781 ft5x0x_ts_set_standby(this_client,0);
785 static void ft5x0x_ts_late_resume(struct early_suspend *h)
787 struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client);
789 ft5x0x_ts_set_standby(this_client,1);
791 enable_irq(this_client->irq);
793 printk("ft5x0x_ts_late_resume finish\n");
798 #define ft5x0x_ts_early_suspend NULL
799 #define ft5x0x_ts_late_resume NULL
803 static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
805 struct FTS_TS_DATA_T *ft5x0x_ts;
806 struct input_dev *input_dev;
809 unsigned char reg_value;
810 unsigned char reg_version;
813 struct laibao_platform_data *pdata = client->dev.platform_data;
815 printk("[LAIBAO] file(%s), function (%s), --probe start\n", __FILE__, __FUNCTION__);
817 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
819 goto exit_check_functionality_failed;
822 if (pdata->init_platform_hw) {
823 err = pdata->init_platform_hw();
825 printk("[LAIBAO] init_platform_hw failed\n");
826 goto exit_init_platform_hw_failed;
832 this_client = client;
833 err = i2c_master_reg8_recv(this_client, FT5X0X_REG_FIRMID, ®_version, 1, 200*1000);
835 printk("[LAIBAO] Device not found\n");
836 goto exit_device_not_found;
839 client->irq = gpio_to_irq(client->irq);
840 _sui_irq_num = client->irq;
842 ft5x0x_ts = kzalloc(sizeof(*ft5x0x_ts), GFP_KERNEL);
845 goto exit_alloc_data_failed;
848 //this_client = client;
849 ft5x0x_ts->client = client;
850 i2c_set_clientdata(client, ft5x0x_ts);
852 INIT_WORK(&ft5x0x_ts->pen_event_work, fts_work_func);
854 ft5x0x_ts->ts_workqueue = create_singlethread_workqueue(dev_name(&client->dev));
855 if (!ft5x0x_ts->ts_workqueue) {
857 goto exit_create_singlethread;
860 /***wait CTP to bootup normally***/
863 //fts_register_read(FT5X0X_REG_FIRMID, ®_version,1);
864 i2c_master_reg8_recv(this_client, FT5X0X_REG_FIRMID, ®_version, 1, 200*1000);
865 printk("[LAIBAO] firmware version = 0x%2x\n", reg_version);
866 //fts_register_read(FT5X0X_REG_REPORT_RATE, ®_value,1);
867 i2c_master_reg8_recv(this_client, FT5X0X_REG_REPORT_RATE, ®_value, 1, 200*1000);
868 printk("[LAIBAO] firmware report rate = %dHz\n", reg_value*10);
869 //fts_register_read(FT5X0X_REG_THRES, ®_value,1);
870 i2c_master_reg8_recv(this_client, FT5X0X_REG_THRES, ®_value, 1, 200*1000);
871 printk("[LAIBAO] firmware threshold = %d\n", reg_value * 4);
872 //fts_register_read(FT5X0X_REG_NOISE_MODE, ®_value,1);
873 i2c_master_reg8_recv(this_client, FT5X0X_REG_NOISE_MODE, ®_value, 1, 200*1000);
874 printk("[LAIBAO] nosie mode = 0x%2x\n", reg_value);
877 if (fts_ctpm_get_upg_ver() != reg_version)
879 printk("[LAIBAO] start upgrade new verison 0x%2x\n", fts_ctpm_get_upg_ver());
881 err = fts_ctpm_fw_upgrade_with_i_file();
884 printk("[LAIBAO] ugrade successfuly.\n");
886 fts_register_read(FT5X0X_REG_FIRMID, ®_value,1);
887 printk("FTS_DBG from old version 0x%2x to new version = 0x%2x\n", reg_version, reg_value);
891 printk("[LAIBAO] ugrade fail err=%d, line = %d.\n",
897 printk("[LAIBAO]=========================_sui_irq_num = %d ================\n",_sui_irq_num);
898 printk("[LAIBAO]=========================client->dev.driver->name = %s ================\n",client->dev.driver->name);
899 err = request_irq(_sui_irq_num, fts_ts_irq, GPIOEdgelFalling, client->dev.driver->name, ft5x0x_ts);
902 dev_err(&client->dev, "[LAIBAO] ft5x0x_probe: request irq failed\n");
903 printk("[LAIBAO]=========================err = %d ================\n",err);
904 goto exit_irq_request_failed;
906 disable_irq(_sui_irq_num);
909 input_dev = input_allocate_device();
912 dev_err(&client->dev, "[LAIBAO]failed to allocate input device\n");
913 goto exit_input_dev_alloc_failed;
916 ft5x0x_ts->input_dev = input_dev;
918 /***setup coordinate area******/
919 //set_bit(EV_ABS, input_dev->evbit);
920 //set_bit(ABS_MT_TOUCH_MAJOR, input_dev->absbit);
921 //set_bit(ABS_MT_POSITION_X, input_dev->absbit);
922 //set_bit(ABS_MT_POSITION_Y, input_dev->absbit);
923 //set_bit(ABS_MT_WIDTH_MAJOR, input_dev->absbit);
925 // input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
927 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
928 __set_bit(EV_ABS, input_dev->evbit);
930 /****** for multi-touch *******/
931 for (i=0; i<CFG_MAX_POINT_NUM; i++)
932 _st_finger_infos[i].u2_pressure = -1;
934 input_set_abs_params(input_dev,
935 ABS_MT_POSITION_X, 0, SCREEN_MAX_X + SCREEN_BOUNDARY_ADJUST_VALUE, 0, 0);
936 input_set_abs_params(input_dev,
937 ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y + SCREEN_BOUNDARY_ADJUST_VALUE, 0, 0);
938 // input_set_abs_params(input_dev,
939 // ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
940 //input_set_abs_params(input_dev,
941 // ABS_MT_TRACKING_ID, 0, 30, 0, 0);
942 // input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
944 input_mt_init_slots(input_dev, CFG_MAX_POINT_NUM);
945 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
947 /*****setup key code area******/
948 //set_bit(EV_SYN, input_dev->evbit);
949 //set_bit(EV_KEY, input_dev->evbit);
950 //set_bit(BTN_TOUCH, input_dev->keybit);
951 //input_dev->keycode = tsp_keycodes;
952 //for(i = 0; i < CFG_NUMOFKEYS; i++)
954 // input_set_capability(input_dev, EV_KEY, ((int*)input_dev->keycode)[i]);
955 // tsp_keystatus[i] = KEY_RELEASE;
958 input_dev->name = FT5X0X_NAME;
959 input_dev->id.bustype = BUS_I2C;
960 input_dev->id.vendor = 0xdead;
961 input_dev->id.product = 0xbeef;
962 input_dev->id.version = 10427;
964 err = input_register_device(input_dev);
966 dev_err(&client->dev,
967 "fts_ts_probe: failed to register input device: %s\n",
968 dev_name(&client->dev));
969 goto exit_input_register_device_failed;
973 #ifdef CONFIG_HAS_EARLYSUSPEND
974 ft5x0x_ts->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1;
975 ft5x0x_ts->early_suspend.suspend = ft5x0x_ts_early_suspend;
976 ft5x0x_ts->early_suspend.resume = ft5x0x_ts_late_resume;
977 register_early_suspend(&ft5x0x_ts->early_suspend);
981 enable_irq(_sui_irq_num);
982 printk("[LAIBAO] file(%s), function (%s), -- end\n", __FILE__, __FUNCTION__);
985 exit_input_register_device_failed:
986 input_free_device(input_dev);
987 exit_input_dev_alloc_failed:
988 free_irq(_sui_irq_num, ft5x0x_ts);
989 exit_irq_request_failed:
990 cancel_work_sync(&ft5x0x_ts->pen_event_work);
991 destroy_workqueue(ft5x0x_ts->ts_workqueue);
992 exit_create_singlethread:
993 i2c_set_clientdata(client, NULL);
995 exit_alloc_data_failed:
996 exit_device_not_found:
997 if (pdata->exit_platform_hw)
998 pdata->exit_platform_hw();
1000 exit_init_platform_hw_failed:
1001 exit_check_functionality_failed:
1007 static int __devexit fts_ts_remove(struct i2c_client *client)
1009 struct FTS_TS_DATA_T *ft5x0x_ts;
1010 int _sui_irq_num=client->irq;
1012 ft5x0x_ts = (struct FTS_TS_DATA_T *)i2c_get_clientdata(client);
1013 free_irq(_sui_irq_num, ft5x0x_ts);
1014 input_unregister_device(ft5x0x_ts->input_dev);
1016 cancel_work_sync(&ft5x0x_ts->pen_event_work);
1017 destroy_workqueue(ft5x0x_ts->ts_workqueue);
1018 i2c_set_clientdata(client, NULL);
1023 static const struct i2c_device_id ft5x0x_ts_id[] = {
1029 MODULE_DEVICE_TABLE(i2c, ft5x0x_ts_id);
1031 static struct i2c_driver fts_ts_driver = {
1032 .probe = fts_ts_probe,
1033 .remove = fts_ts_remove,//devexit_p(fts_ts_remove),
1034 .id_table = ft5x0x_ts_id,
1036 .name = FT5X0X_NAME,
1040 static void __init fts_ts_initasync(void *unused, async_cookie_t cookie)
1042 i2c_add_driver(&fts_ts_driver);
1045 static int __init fts_ts_init(void)
1047 async_schedule(fts_ts_initasync, NULL);
1051 static void __exit fts_ts_exit(void)
1053 i2c_del_driver(&fts_ts_driver);
1056 module_init(fts_ts_init);
1057 module_exit(fts_ts_exit);
1059 MODULE_AUTHOR("<duxx@Focaltech-systems.com>");
1060 MODULE_DESCRIPTION("FocalTech ft5x0x TouchScreen driver");
1061 MODULE_LICENSE("GPL");