td8801: fixup multitouch of pixcir_tp in kernel-3.0
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / ft5406_ts.c
index 4812aac4b396608ac3d04af00044932fd3305b53..991507fb51b5f2b0a3a812aa6070605f97412227 100755 (executable)
 #include <media/soc_camera.h>                               /* ddl@rock-chips.com : camera support */
 #include <mach/vpu_mem.h>
 #include <mach/sram.h>
-#ifdef CONFIG_HAS_EARLYSUSPEND
 #include <linux/earlysuspend.h>
-static struct early_suspend ft5406_early_suspend;
-#endif
+static struct early_suspend ft5406_power;
 
 
 
@@ -360,6 +358,7 @@ static bool fts_register_read(u8 reg_name, u8* rx_buf, int rx_length)
 E_UPGRADE_ERR_TYPE  fts_ctpm_fw_upgrade(u8* pbt_buf, int dw_lenth)
 {
     u8  cmd,reg_val[2] = {0};
+       u8  buffer[2] = {0};
     u8  packet_buf[FTS_PACKET_LENGTH + 6];
     u8  auc_i2c_write_buf[10];
     u8  bt_ecc;
@@ -502,7 +501,19 @@ E_UPGRADE_ERR_TYPE  fts_ctpm_fw_upgrade(u8* pbt_buf, int dw_lenth)
 
     /*******Step 7: reset the new FW**********/
     cmd_write(0x07,0x00,0x00,0x00,1);
-
+       mdelay(100);//100ms     
+       fts_register_read(0xfc, buffer, 1);     
+       if (buffer[0] == 1)
+       {
+       cmd=4;
+       fts_register_write(0xfc, &cmd);
+       mdelay(2500);//2500ms   
+        do     
+        {      
+        fts_register_read(0xfc, buffer, 1);    
+        mdelay(100);//100ms    
+        }while (buffer[0] != 1);                       
+       }
     return ERR_OK;
 }
 
@@ -568,6 +579,7 @@ static void ft5406_queue_work(struct work_struct *work)
 #endif
        if (ret < 0) {
                dev_err(&data->client->dev, "ft5406_read_regs fail:%d!\n",ret);
+               enable_irq(data->irq);
                return;
        }
 #if 0
@@ -662,6 +674,15 @@ static int ft5406_resume(struct i2c_client *client)
        return 0;
 }
 
+static void ft5406_suspend_early(struct early_suspend *h)
+{
+       ft5406_suspend(this_client,PMSG_SUSPEND);
+}
+
+static void ft5406_resume_early(struct early_suspend *h)
+{
+       ft5406_resume(this_client);
+}
 static int __devexit ft5406_remove(struct i2c_client *client)
 {
        struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client);
@@ -672,9 +693,7 @@ static int __devexit ft5406_remove(struct i2c_client *client)
        cancel_work_sync(&ft5x0x_ts->pen_event_work);
        destroy_workqueue(ft5x0x_ts->ts_workqueue);
        i2c_set_clientdata(client, NULL);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-    unregister_early_suspend(&ft5406_early_suspend);
-#endif 
+    unregister_early_suspend(&ft5406_power);
     this_client = NULL;
        return 0;
 }
@@ -822,12 +841,10 @@ static int  ft5406_probe(struct i2c_client *client ,const struct i2c_device_id *
        }
        
        i2c_set_clientdata(client, ft5x0x_ts);
-#if 0//def CONFIG_HAS_EARLYSUSPEND
-       ft5406_early_suspend.suspend =ft5406_ts_suspend;
-       ft5406_early_suspend.resume =ft5406_ts_resume;
-       ft5406_early_suspend.level = 0x2;
-       register_early_suspend(&ft5406_early_suspend);
-#endif
+       ft5406_power.suspend =ft5406_suspend_early;
+       ft5406_power.resume =ft5406_resume_early;
+       ft5406_power.level = 0x2;
+       register_early_suspend(&ft5406_power);
 
        buf_w[0] = 6;
        err = ft5406_set_regs(client,0x88,buf_w,1);
@@ -870,8 +887,6 @@ static struct i2c_driver ft5406_driver  = {
        },
        .id_table       = ft5406_idtable,
        .probe      = ft5406_probe,
-    .suspend   = ft5406_suspend,
-       .resume     = ft5406_resume,
        .remove         = __devexit_p(ft5406_remove),
 };