newton:add gt819 checksum when firmware update,modiry suspend and resume for ft5406...
author蔡枫 <cf@rock-chips.com>
Thu, 4 Aug 2011 03:44:39 +0000 (11:44 +0800)
committer蔡枫 <cf@rock-chips.com>
Thu, 4 Aug 2011 03:44:39 +0000 (11:44 +0800)
arch/arm/mach-rk29/board-rk29-newton.c
drivers/input/touchscreen/ft5406_ts.c
drivers/input/touchscreen/gt819.c

index 1edd780de8c9f75f6cb41a0971cd99ebe5b65dd3..6033f91b9bb6916323db5556afdc0d2d9ab6d266 100755 (executable)
@@ -560,10 +560,12 @@ int ft5406_init_platform_hw(void)
     }
 
        gpio_direction_output(TOUCH_RESET_PIN, 0);
-       gpio_direction_output(TOUCH_INT_PIN, 0);
-       gpio_set_value(TOUCH_INT_PIN,GPIO_HIGH);
+       gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
+       mdelay(10);
+       gpio_direction_input(TOUCH_INT_PIN);
+       mdelay(10);
        gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
-       gpio_pull_updown(TOUCH_INT_PIN, 0);  
+       msleep(300);
     return 0;
 }
 
@@ -617,15 +619,11 @@ int gt819_init_platform_hw(void)
     }
        gpio_direction_output(TOUCH_RESET_PIN, 0);
        gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
-       msleep(100);
-       gpio_direction_output(TOUCH_INT_PIN, 0);
-       gpio_set_value(TOUCH_INT_PIN,GPIO_LOW);
        mdelay(10);
-       msleep(50);
+       gpio_direction_input(TOUCH_INT_PIN);
+       mdelay(10);
        gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
-       msleep(100);
-       gpio_direction_output(TOUCH_INT_PIN, 1);
-       gpio_pull_updown(TOUCH_INT_PIN, 0);  
+       msleep(300);
     return 0;
 }
 
index 3a27a81a2114406925cf4e7c3abb76f8bce69a77..51317a5c769c6ae403d90fffa45fd6357128d736 100755 (executable)
@@ -360,6 +360,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 +503,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;
 }
 
index 27ea80568ddb200c96e289e4f6aacdf0b1ac6b75..76de84ba119a095e34dd0c3344dc5d4fd234dc00 100755 (executable)
@@ -125,6 +125,15 @@ static int gt819_read_regs(struct i2c_client *client, u8 reg, u8 buf[], unsigned
        if(ret>0)
                return ret; 
        ret = i2c_master_reg8_recv(client, reg, buf, len, GT819_IIC_SPEED);
+       if(ret>0)
+               return ret; 
+       ret = i2c_master_reg8_recv(client, reg, buf, len, GT819_IIC_SPEED);
+       if(ret>0)
+               return ret; 
+       ret = i2c_master_reg8_recv(client, reg, buf, len, GT819_IIC_SPEED);
+       if(ret>0)
+               return ret; 
+       ret = i2c_master_reg8_recv(client, reg, buf, len, GT819_IIC_SPEED);
        return ret;
 }
 
@@ -136,6 +145,15 @@ static int gt819_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], uns
        if(ret>0)
                return ret; 
        ret = i2c_master_reg8_send(client, reg, buf, (int)len, GT819_IIC_SPEED);
+       if(ret>0)
+               return ret; 
+       ret = i2c_master_reg8_send(client, reg, buf, (int)len, GT819_IIC_SPEED);
+       if(ret>0)
+               return ret; 
+       ret = i2c_master_reg8_send(client, reg, buf, (int)len, GT819_IIC_SPEED);
+       if(ret>0)
+               return ret; 
+       ret = i2c_master_reg8_send(client, reg, buf, (int)len, GT819_IIC_SPEED);
        return ret;
 }
 
@@ -406,14 +424,18 @@ static void gt819_queue_work(struct work_struct *work)
        struct goodix_ts_data *ts = container_of(work, struct goodix_ts_data, work);
        uint8_t  point_data[53]={ 0 };
        int ret,i,offset,points;
+       int points_chect;
        int x,y,w;
+       unsigned int  count = 0;
+       uint8_t  check_sum = 0;
        
-       ret = gt819_read_regs(ts->client,1, point_data, 1);
+       ret = gt819_read_regs(ts->client,1, point_data, 2);
        if (ret < 0) {
                dev_err(&ts->client->dev, "i2c_read_bytes fail:%d!\n",ret);
                enable_irq(ts->irq);
                return;
        }
+       check_sum =point_data[0]+point_data[1];
        
        points = point_data[0] & 0x1f;
        //dev_info(&ts->client->dev, "points = %d\n",points);
@@ -429,12 +451,26 @@ static void gt819_queue_work(struct work_struct *work)
        for(i=0;0!=points;i++)
                points>>=1;
        points = i;
-       ret = gt819_read_regs(ts->client,3, point_data, points*5);
+       points_chect = points;
+       ret = gt819_read_regs(ts->client,3, point_data, points*5+1);
        if (ret < 0) {
                dev_err(&ts->client->dev, "i2c_read_bytes fail:%d!\n",ret);
                enable_irq(ts->irq);
                return;
        }
+       //add by Nitiion
+       for(points_chect *= 5; points_chect > 0; points_chect--)
+               {
+               check_sum += point_data[count++];
+               }
+               check_sum += point_data[count];
+       if(check_sum  != 0)                     //checksum verify error
+               {
+                       printk("coor checksum error!\n");
+                       enable_irq(ts->irq);
+                       return;
+               }
+               
        for(i=0;i<points;i++){
                offset = i*5;
                x = (((s16)(point_data[offset+0]))<<8) | ((s16)point_data[offset+1]);