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>
35 struct FTS_TS_DATA_T {
36 struct i2c_client *client;
37 struct input_dev *input_dev;
38 struct FTS_TS_EVENT_T event;
39 struct work_struct pen_event_work;
40 struct workqueue_struct *ts_workqueue;
41 struct early_suspend early_suspend;
44 /* -------------- global variable definition -----------*/
45 static struct i2c_client *this_client;
46 static REPORT_FINGER_INFO_T _st_finger_infos[CFG_MAX_POINT_NUM];
47 //static unsigned int _sui_irq_num= IRQ_EINT(6);
48 static int _si_touch_num = 0;
50 int tsp_keycodes[CFG_NUMOFKEYS] ={
58 char *tsp_keyname[CFG_NUMOFKEYS] ={
66 static bool tsp_keystatus[CFG_NUMOFKEYS];
69 #ifdef CONFIG_HAS_EARLYSUSPEND
70 static void ft5x0x_ts_early_suspend(struct early_suspend *h);
71 static void ft5x0x_ts_late_resume(struct early_suspend *h);
75 /***********************************************************************
77 callback: read data from ctpm by i2c interface;
79 buffer[in]: data buffer;
80 length[in]: the length of the data buffer;
84 ************************************************************************/
85 static bool i2c_read_interface(u8* pbt_buf, int dw_lenth)
89 ret=i2c_master_recv(this_client, pbt_buf, dw_lenth);
93 printk("[TSP]i2c_read_interface error\n");
102 /***********************************************************************
104 callback: write data to ctpm by i2c interface;
106 buffer[in]: data buffer;
107 length[in]: the length of the data buffer;
111 ************************************************************************/
112 static bool i2c_write_interface(u8* pbt_buf, int dw_lenth)
115 ret=i2c_master_send(this_client, pbt_buf, dw_lenth);
118 printk("[TSP]i2c_write_interface error line = %d, ret = %d\n", __LINE__, ret);
127 /***********************************************************************
129 callback: read register value ftom ctpm by i2c interface;
131 reg_name[in]: the register which you want to read;
132 rx_buf[in]: data buffer which is used to store register value;
133 rx_length[in]: the length of the data buffer;
137 ************************************************************************/
138 static bool fts_register_read(u8 reg_name, u8* rx_buf, int rx_length)
143 read_cmd[0] = reg_name;
146 /*send register addr*/
147 if(!i2c_write_interface(&read_cmd[0], cmd_len))
152 /*call the read callback function to get the register value*/
153 if(!i2c_read_interface(rx_buf, rx_length))
163 /***********************************************************************
165 callback: read register value ftom ctpm by i2c interface;
167 reg_name[in]: the register which you want to write;
168 tx_buf[in]: buffer which is contained of the writing value;
172 ************************************************************************/
173 static bool fts_register_write(u8 reg_name, u8* tx_buf)
175 u8 write_cmd[2] = {0};
177 write_cmd[0] = reg_name;
178 write_cmd[1] = *tx_buf;
180 /*call the write callback function*/
181 return i2c_write_interface(write_cmd, 2);
187 /***********************************************************************
189 callback: report to the input system that the finger is put up;
194 ************************************************************************/
195 static void fts_ts_release(void)
197 struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client);
200 for ( i= 0; i<CFG_MAX_POINT_NUM; ++i )
202 if ( _st_finger_infos[i].u2_pressure == -1 )
205 _st_finger_infos[i].u2_pressure = 0;
207 input_report_abs(data->input_dev, ABS_MT_POSITION_X, SCREEN_MAX_X - _st_finger_infos[i].i2_x);
208 input_report_abs(data->input_dev, ABS_MT_POSITION_Y, _st_finger_infos[i].i2_y);
209 input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, _st_finger_infos[i].u2_pressure);
210 input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, _st_finger_infos[i].ui2_id);
211 input_mt_sync(data->input_dev);
215 if ( _st_finger_infos[i].u2_pressure == 0 )
216 _st_finger_infos[i].u2_pressure= -1;
221 input_sync(data->input_dev);
232 /***********************************************************************
234 callback: read touch data ftom ctpm by i2c interface;
236 rxdata[in]: data buffer which is used to store touch data;
237 length[in]: the length of the data buffer;
241 ************************************************************************/
242 static int fts_i2c_rxdata(u8 *rxdata, int length)
248 msg.addr = this_client->addr;
252 ret = i2c_transfer(this_client->adapter, &msg, 1);
255 pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
257 msg.addr = this_client->addr;
258 msg.flags = I2C_M_RD;
261 ret = i2c_transfer(this_client->adapter, &msg, 1);
263 pr_err("msg %s line:%d i2c write error: %d\n", __func__,__LINE__, ret);
272 /***********************************************************************
274 callback: send data to ctpm by i2c interface;
276 txdata[in]: data buffer which is used to send data;
277 length[in]: the length of the data buffer;
281 ************************************************************************/
282 static int fts_i2c_txdata(u8 *txdata, int length)
288 msg.addr = this_client->addr;
292 ret = i2c_transfer(this_client->adapter, &msg, 1);
294 pr_err("%s i2c write error: %d\n", __func__, ret);
301 /***********************************************************************
303 callback: gather the finger information and calculate the X,Y
304 coordinate then report them to the input system;
309 ************************************************************************/
310 int fts_read_data(void)
312 struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client);
313 struct FTS_TS_EVENT_T *event = &data->event;
315 static int key_id=0x80;
317 int i,id,temp,i_count,ret = -1;
318 int touch_point_num = 0, touch_event, x, y, pressure, size;
319 REPORT_FINGER_INFO_T touch_info[CFG_MAX_POINT_NUM];
330 ret=fts_i2c_rxdata(buf, 6);
335 //printk("\n--the id number is %d---\n",id);
336 touch_event = buf[0]>>6;
337 if (id >= 0 && id< CFG_MAX_POINT_NUM)
342 temp = temp | buf[1];
345 temp = (buf[2])& 0x0f;
347 temp = temp | buf[3];
353 //x = (768-x)*600/768;
360 //x = 1024 - x;////////////////////////////
365 pressure = buf[4] & 0x3f;
368 touch_event = buf[0]>>6;
370 if (touch_event == 0) //press down
376 _st_finger_infos[id].u2_pressure= 1;//pressure;
377 _st_finger_infos[id].i2_x= (int16_t)x;
378 _st_finger_infos[id].i2_y= (int16_t)y;
379 _st_finger_infos[id].ui2_id = size;
381 // printk("\n--report x position is %d,pressure=%d----\n",_st_finger_infos[id].i2_x, pressure);
382 // printk("\n--report y position is %d,pressure=%d----\n",_st_finger_infos[id].i2_y, pressure);
386 else if(y>=850 && y<=860)
391 printk("\n---virtual key 1 press---");
393 else if ( x>=185 && x<=200)
396 printk("\n---virtual key 2 press---");
398 else if (x>=290 && x<=305)
401 printk("\n---virtual key 3 press---");
403 else if ( x>=405 && x<=420)
406 printk("\n---virtual key 4 press---");
410 input_report_key(data->input_dev, tsp_keycodes[key_id], 1);
411 tsp_keystatus[key_id] = KEY_PRESS;
417 else if (touch_event == 1) //up event
420 _st_finger_infos[id].u2_pressure= 0;
426 printk("\n---virtual key %d release---\n",++i);
428 input_report_key(data->input_dev, tsp_keycodes[key_id], 0);
435 else if (touch_event == 2) //move
437 // printk("[TSP]id=%d move\n", id);
438 _st_finger_infos[id].u2_pressure= 1;//pressure;
439 _st_finger_infos[id].i2_x= (int16_t)x;
440 _st_finger_infos[id].i2_y= (int16_t)y;
441 _st_finger_infos[id].ui2_id = size;
444 else /*bad event, ignore*/
447 if ( (touch_event==1) )
449 // printk("[TSP]id=%d up\n", id);
453 for( i= 0; i<CFG_MAX_POINT_NUM; ++i )
455 input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, _st_finger_infos[i].ui2_id);
456 input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, _st_finger_infos[i].u2_pressure);
457 input_report_abs(data->input_dev, ABS_MT_POSITION_X, SCREEN_MAX_X - _st_finger_infos[i].i2_x);
458 input_report_abs(data->input_dev, ABS_MT_POSITION_Y, _st_finger_infos[i].i2_y);
459 input_mt_sync(data->input_dev);
461 if(_st_finger_infos[i].u2_pressure == 0 )
463 _st_finger_infos[i].u2_pressure= -1;
468 input_sync(data->input_dev);
470 if (_si_touch_num == 0 )
481 printk("[TSP] ERROR: in %s, line %d, ret = %d\n",
482 __FUNCTION__, __LINE__, ret);
486 }while( id != 0xf && i_count < 12);
488 event->touch_point = touch_point_num;
489 if (event->touch_point == 0)
492 switch (event->touch_point) {
494 event->x5 = touch_info[4].i2_x;
495 event->y5 = touch_info[4].i2_y;
496 event->pressure5 = touch_info[4].u2_pressure;
498 event->x4 = touch_info[3].i2_x;
499 event->y4 = touch_info[3].i2_y;
500 event->pressure4= touch_info[3].u2_pressure;
502 event->x3 = touch_info[2].i2_x;
503 event->y3 = touch_info[2].i2_y;
504 event->pressure3= touch_info[2].u2_pressure;
506 event->x2 = touch_info[1].i2_x;
507 event->y2 = touch_info[1].i2_y;
508 event->pressure2= touch_info[1].u2_pressure;
510 event->x1 = touch_info[0].i2_x;
511 event->y1 = touch_info[0].i2_y;
512 event->pressure1= touch_info[0].u2_pressure;
523 static void fts_work_func(struct work_struct *work)
526 enable_irq(this_client->irq);
532 static irqreturn_t fts_ts_irq(int irq, void *dev_id)
534 struct FTS_TS_DATA_T *ft5x0x_ts = dev_id;
535 // printk(KERN_ALERT "fts_tp_irq\n");
536 if (!work_pending(&ft5x0x_ts->pen_event_work)) {
537 disable_irq_nosync(this_client->irq);
538 queue_work(ft5x0x_ts->ts_workqueue, &ft5x0x_ts->pen_event_work);
546 /***********************************************************************
548 callback: send a command to ctpm.
550 btcmd[in]: command code;
551 btPara1[in]: parameter 1;
552 btPara2[in]: parameter 2;
553 btPara3[in]: parameter 3;
554 num[in]: the valid input parameter numbers,
555 if only command code needed and no
556 parameters followed,then the num is 1;
560 ************************************************************************/
561 static bool cmd_write(u8 btcmd,u8 btPara1,u8 btPara2,u8 btPara3,u8 num)
563 u8 write_cmd[4] = {0};
565 write_cmd[0] = btcmd;
566 write_cmd[1] = btPara1;
567 write_cmd[2] = btPara2;
568 write_cmd[3] = btPara3;
569 return i2c_write_interface(write_cmd, num);
575 /***********************************************************************
577 callback: write a byte data to ctpm;
579 buffer[in]: write buffer;
580 length[in]: the size of write data;
584 ************************************************************************/
585 static bool byte_write(u8* buffer, int length)
588 return i2c_write_interface(buffer, length);
594 /***********************************************************************
596 callback: read a byte data from ctpm;
598 buffer[in]: read buffer;
599 length[in]: the size of read data;
603 ************************************************************************/
604 static bool byte_read(u8* buffer, int length)
606 return i2c_read_interface(buffer, length);
613 #define FTS_PACKET_LENGTH 128
615 static unsigned char CTPM_FW[]=
617 //#include "ft_app.i"
623 /***********************************************************************
625 callback: burn the FW to ctpm.
627 pbt_buf[in]: point to Head+FW ;
628 dw_lenth[in]: the length of the FW + 6(the Head length);
631 ERR_MODE: fail to switch to UPDATE mode;
632 ERR_READID: read id fail;
633 ERR_ERASE: erase chip fail;
634 ERR_STATUS: status error;
636 ************************************************************************/
637 E_UPGRADE_ERR_TYPE fts_ctpm_fw_upgrade(u8* pbt_buf, int dw_lenth)
639 u8 cmd,reg_val[2] = {0};
640 u8 packet_buf[FTS_PACKET_LENGTH + 6];
641 u8 auc_i2c_write_buf[10];
644 int j,temp,lenght,i_ret,packet_number, i = 0;
645 int i_is_new_protocol = 0;
648 /******write 0xaa to register 0xfc******/
650 fts_register_write(0xfc,&cmd);
653 /******write 0x55 to register 0xfc******/
655 fts_register_write(0xfc,&cmd);
656 printk("[TSP] Step 1: Reset CTPM test\n");
661 /*******Step 2:Enter upgrade mode ****/
662 printk("\n[TSP] Step 2:enter new update mode\n");
663 auc_i2c_write_buf[0] = 0x55;
664 auc_i2c_write_buf[1] = 0xaa;
668 i_ret = fts_i2c_txdata(auc_i2c_write_buf, 2);
670 }while(i_ret <= 0 && i < 10 );
674 i_is_new_protocol = 1;
677 /********Step 3:check READ-ID********/
678 cmd_write(0x90,0x00,0x00,0x00,4);
679 byte_read(reg_val,2);
680 if (reg_val[0] == 0x79 && reg_val[1] == 0x3)
682 printk("[TSP] Step 3: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]);
687 //i_is_new_protocol = 1;
691 /*********Step 4:erase app**********/
692 if (i_is_new_protocol)
694 cmd_write(0x61,0x00,0x00,0x00,1);
698 cmd_write(0x60,0x00,0x00,0x00,1);
701 printk("[TSP] Step 4: erase. \n");
705 /*Step 5:write firmware(FW) to ctpm flash*/
707 printk("[TSP] Step 5: start upgrade. \n");
708 dw_lenth = dw_lenth - 8;
709 packet_number = (dw_lenth) / FTS_PACKET_LENGTH;
710 packet_buf[0] = 0xbf;
711 packet_buf[1] = 0x00;
712 for (j=0;j<packet_number;j++)
714 temp = j * FTS_PACKET_LENGTH;
715 packet_buf[2] = (FTS_BYTE)(temp>>8);
716 packet_buf[3] = (FTS_BYTE)temp;
717 lenght = FTS_PACKET_LENGTH;
718 packet_buf[4] = (FTS_BYTE)(lenght>>8);
719 packet_buf[5] = (FTS_BYTE)lenght;
721 for (i=0;i<FTS_PACKET_LENGTH;i++)
723 packet_buf[6+i] = pbt_buf[j*FTS_PACKET_LENGTH + i];
724 bt_ecc ^= packet_buf[6+i];
727 byte_write(&packet_buf[0],FTS_PACKET_LENGTH + 6);
728 mdelay(FTS_PACKET_LENGTH/6 + 1);
729 if ((j * FTS_PACKET_LENGTH % 1024) == 0)
731 printk("[TSP] upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_LENGTH);
735 if ((dw_lenth) % FTS_PACKET_LENGTH > 0)
737 temp = packet_number * FTS_PACKET_LENGTH;
738 packet_buf[2] = (FTS_BYTE)(temp>>8);
739 packet_buf[3] = (FTS_BYTE)temp;
741 temp = (dw_lenth) % FTS_PACKET_LENGTH;
742 packet_buf[4] = (FTS_BYTE)(temp>>8);
743 packet_buf[5] = (FTS_BYTE)temp;
747 packet_buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_LENGTH + i];
748 bt_ecc ^= packet_buf[6+i];
751 byte_write(&packet_buf[0],temp+6);
755 /***********send the last six byte**********/
756 for (i = 0; i<6; i++)
759 packet_buf[2] = (FTS_BYTE)(temp>>8);
760 packet_buf[3] = (FTS_BYTE)temp;
762 packet_buf[4] = (FTS_BYTE)(temp>>8);
763 packet_buf[5] = (FTS_BYTE)temp;
764 packet_buf[6] = pbt_buf[ dw_lenth + i];
765 bt_ecc ^= packet_buf[6];
767 byte_write(&packet_buf[0],7);
771 /********send the opration head************/
772 cmd_write(0xcc,0x00,0x00,0x00,1);
773 byte_read(reg_val,1);
774 printk("[TSP] Step 6: ecc read 0x%x, new firmware 0x%x. \n", reg_val[0], bt_ecc);
775 if(reg_val[0] != bt_ecc)
780 /*******Step 7: reset the new FW**********/
781 cmd_write(0x07,0x00,0x00,0x00,1);
789 int fts_ctpm_fw_upgrade_with_i_file(void)
791 u8* pbt_buf = FTS_NULL;
795 i_ret = fts_ctpm_fw_upgrade(pbt_buf,sizeof(CTPM_FW));
800 unsigned char fts_ctpm_get_upg_ver(void)
804 ui_sz = sizeof(CTPM_FW);
807 return CTPM_FW[ui_sz - 2];
814 void ft5x0x_ts_set_standby(struct i2c_client *client, int enable)
816 struct laibao_platform_data *mach_info = client->dev.platform_data;
817 unsigned display_on = mach_info->lcd_disp_on_pin;
818 unsigned lcd_cs = mach_info->lcd_cs_pin;
820 int display_on_pol = mach_info->disp_on_value;
821 int lcd_cs_pol = mach_info->lcd_cs_value;
823 printk("%s : %s, enable = %d", __FILE__, __FUNCTION__,enable);
824 if(display_on != INVALID_GPIO)
826 gpio_direction_output(display_on, 0);
827 gpio_set_value(display_on, enable ? display_on_pol : !display_on_pol);
829 if(lcd_cs != INVALID_GPIO)
831 gpio_direction_output(lcd_cs, 0);
832 gpio_set_value(lcd_cs, enable ? lcd_cs_pol : !lcd_cs_pol);
836 #ifdef CONFIG_HAS_EARLYSUSPEND
837 static void ft5x0x_ts_early_suspend(struct early_suspend *h)
839 struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client);
842 printk("enter ft5x0x_ts_early_suspend\n");
844 disable_irq_nosync(this_client->irq);
846 cancel_work_sync(&data->pen_event_work);
848 ft5x0x_ts_set_standby(this_client,0);
852 static void ft5x0x_ts_late_resume(struct early_suspend *h)
854 struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client);
856 ft5x0x_ts_set_standby(this_client,1);
858 if(!work_pending(&data->pen_event_work)){
859 PREPARE_WORK(&data->pen_event_work, fts_work_func);
860 queue_work(data->ts_workqueue, &data->pen_event_work);
863 enable_irq(this_client->irq);
865 printk("ft5x0x_ts_late_resume finish\n");
870 #define egalax_i2c_suspend NULL
871 #define egalax_i2c_resume NULL
875 static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
877 struct FTS_TS_DATA_T *ft5x0x_ts;
878 struct input_dev *input_dev;
881 unsigned char reg_value;
882 unsigned char reg_version;
885 struct laibao_platform_data *pdata = client->dev.platform_data;
887 client->irq = gpio_to_irq(client->irq);
888 _sui_irq_num = client->irq;
890 printk("[TSP] file(%s), function (%s), --probe start\n", __FILE__, __FUNCTION__);
892 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
894 goto exit_check_functionality_failed;
897 ft5x0x_ts = kzalloc(sizeof(*ft5x0x_ts), GFP_KERNEL);
900 goto exit_alloc_data_failed;
903 this_client = client;
904 ft5x0x_ts->client = client;
905 i2c_set_clientdata(client, ft5x0x_ts);
907 INIT_WORK(&ft5x0x_ts->pen_event_work, fts_work_func);
909 ft5x0x_ts->ts_workqueue = create_singlethread_workqueue(dev_name(&client->dev));
910 if (!ft5x0x_ts->ts_workqueue) {
912 goto exit_create_singlethread;
915 if (pdata->init_platform_hw)
916 pdata->init_platform_hw();
920 /***wait CTP to bootup normally***/
923 //fts_register_read(FT5X0X_REG_FIRMID, ®_version,1);
924 i2c_master_reg8_recv(this_client, FT5X0X_REG_FIRMID, ®_version, 1, 200*1000);
925 printk("[TSP] firmware version = 0x%2x\n", reg_version);
926 //fts_register_read(FT5X0X_REG_REPORT_RATE, ®_value,1);
927 i2c_master_reg8_recv(this_client, FT5X0X_REG_REPORT_RATE, ®_value, 1, 200*1000);
928 printk("[TSP]firmware report rate = %dHz\n", reg_value*10);
929 //fts_register_read(FT5X0X_REG_THRES, ®_value,1);
930 i2c_master_reg8_recv(this_client, FT5X0X_REG_THRES, ®_value, 1, 200*1000);
931 printk("[TSP]firmware threshold = %d\n", reg_value * 4);
932 //fts_register_read(FT5X0X_REG_NOISE_MODE, ®_value,1);
933 i2c_master_reg8_recv(this_client, FT5X0X_REG_NOISE_MODE, ®_value, 1, 200*1000);
934 printk("[TSP]nosie mode = 0x%2x\n", reg_value);
937 if (fts_ctpm_get_upg_ver() != reg_version)
939 printk("[TSP] start upgrade new verison 0x%2x\n", fts_ctpm_get_upg_ver());
941 err = fts_ctpm_fw_upgrade_with_i_file();
944 printk("[TSP] ugrade successfuly.\n");
946 fts_register_read(FT5X0X_REG_FIRMID, ®_value,1);
947 printk("FTS_DBG from old version 0x%2x to new version = 0x%2x\n", reg_version, reg_value);
951 printk("[TSP] ugrade fail err=%d, line = %d.\n",
957 printk("[TSP]=========================_sui_irq_num = %d ================\n",_sui_irq_num);
958 printk("[TSP]=========================client->dev.driver->name = %s ================\n",client->dev.driver->name);
959 err = request_irq(_sui_irq_num, fts_ts_irq, GPIOEdgelFalling, client->dev.driver->name, ft5x0x_ts);
962 dev_err(&client->dev, "[TSP]ft5x0x_probe: request irq failed\n");
963 printk("[TSP]=========================err = %d ================\n",err);
964 goto exit_irq_request_failed;
966 disable_irq(_sui_irq_num);
968 input_dev = input_allocate_device();
971 dev_err(&client->dev, "[TSP]failed to allocate input device\n");
972 goto exit_input_dev_alloc_failed;
975 ft5x0x_ts->input_dev = input_dev;
977 /***setup coordinate area******/
978 //set_bit(EV_ABS, input_dev->evbit);
979 //set_bit(ABS_MT_TOUCH_MAJOR, input_dev->absbit);
980 //set_bit(ABS_MT_POSITION_X, input_dev->absbit);
981 //set_bit(ABS_MT_POSITION_Y, input_dev->absbit);
982 //set_bit(ABS_MT_WIDTH_MAJOR, input_dev->absbit);
983 input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
985 /****** for multi-touch *******/
986 for (i=0; i<CFG_MAX_POINT_NUM; i++)
987 _st_finger_infos[i].u2_pressure = -1;
989 input_set_abs_params(input_dev,
990 ABS_MT_POSITION_X, 0, SCREEN_MAX_X, 0, 0);
991 input_set_abs_params(input_dev,
992 ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y, 0, 0);
993 input_set_abs_params(input_dev,
994 ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
995 //input_set_abs_params(input_dev,
996 // ABS_MT_TRACKING_ID, 0, 30, 0, 0);
997 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
998 /*****setup key code area******/
999 //set_bit(EV_SYN, input_dev->evbit);
1000 //set_bit(EV_KEY, input_dev->evbit);
1001 //set_bit(BTN_TOUCH, input_dev->keybit);
1002 //input_dev->keycode = tsp_keycodes;
1003 //for(i = 0; i < CFG_NUMOFKEYS; i++)
1005 // input_set_capability(input_dev, EV_KEY, ((int*)input_dev->keycode)[i]);
1006 // tsp_keystatus[i] = KEY_RELEASE;
1009 input_dev->name = FT5X0X_NAME;
1010 input_dev->id.bustype = BUS_I2C;
1011 input_dev->id.vendor = 0xdead;
1012 input_dev->id.product = 0xbeef;
1013 input_dev->id.version = 10427;
1015 err = input_register_device(input_dev);
1017 dev_err(&client->dev,
1018 "fts_ts_probe: failed to register input device: %s\n",
1019 dev_name(&client->dev));
1020 goto exit_input_register_device_failed;
1024 #ifdef CONFIG_HAS_EARLYSUSPEND
1025 ft5x0x_ts->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1;
1026 ft5x0x_ts->early_suspend.suspend = ft5x0x_ts_early_suspend;
1027 ft5x0x_ts->early_suspend.resume = ft5x0x_ts_late_resume;
1028 register_early_suspend(&ft5x0x_ts->early_suspend);
1032 enable_irq(_sui_irq_num);
1033 printk("[TSP] file(%s), function (%s), -- end\n", __FILE__, __FUNCTION__);
1036 exit_input_register_device_failed:
1037 input_free_device(input_dev);
1038 exit_input_dev_alloc_failed:
1039 free_irq(_sui_irq_num, ft5x0x_ts);
1040 exit_irq_request_failed:
1041 cancel_work_sync(&ft5x0x_ts->pen_event_work);
1042 destroy_workqueue(ft5x0x_ts->ts_workqueue);
1043 exit_create_singlethread:
1044 printk("[TSP] ==singlethread error =\n");
1045 i2c_set_clientdata(client, NULL);
1047 exit_alloc_data_failed:
1048 exit_check_functionality_failed:
1054 static int __devexit fts_ts_remove(struct i2c_client *client)
1056 struct FTS_TS_DATA_T *ft5x0x_ts;
1057 int _sui_irq_num=client->irq;
1059 ft5x0x_ts = (struct FTS_TS_DATA_T *)i2c_get_clientdata(client);
1060 free_irq(_sui_irq_num, ft5x0x_ts);
1061 input_unregister_device(ft5x0x_ts->input_dev);
1063 cancel_work_sync(&ft5x0x_ts->pen_event_work);
1064 destroy_workqueue(ft5x0x_ts->ts_workqueue);
1065 i2c_set_clientdata(client, NULL);
1070 static const struct i2c_device_id ft5x0x_ts_id[] = {
1076 MODULE_DEVICE_TABLE(i2c, ft5x0x_ts_id);
1078 static struct i2c_driver fts_ts_driver = {
1079 .probe = fts_ts_probe,
1080 .remove = fts_ts_remove,//devexit_p(fts_ts_remove),
1081 .id_table = ft5x0x_ts_id,
1083 .name = FT5X0X_NAME,
1087 static void __init fts_ts_initasync(void *unused, async_cookie_t cookie)
1089 i2c_add_driver(&fts_ts_driver);
1092 static int __init fts_ts_init(void)
1094 async_schedule(fts_ts_initasync, NULL);
1098 static void __exit fts_ts_exit(void)
1100 i2c_del_driver(&fts_ts_driver);
1103 module_init(fts_ts_init);
1104 module_exit(fts_ts_exit);
1106 MODULE_AUTHOR("<duxx@Focaltech-systems.com>");
1107 MODULE_DESCRIPTION("FocalTech ft5x0x TouchScreen driver");
1108 MODULE_LICENSE("GPL");