Input: elants_i2c - disable idle mode before updating firmware
authorJames Chen <james.chen@emc.com.tw>
Mon, 20 Jul 2015 18:16:36 +0000 (11:16 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 5 Aug 2015 18:09:56 +0000 (11:09 -0700)
If the device is in idle mode and is in the middle of a scan it may not
have a chance to react to the reset and then IAP commands within required
time interval and firmware update may fail. Let's bring the device out of
idle mode before attempting to reset it so that the scan period is smaller
and thus it can react to the command quicker.

Signed-off-by: James Chen <james.chen@emc.com.tw>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/elants_i2c.c

index 7461376..42e43f1 100644 (file)
@@ -605,6 +605,7 @@ static int elants_i2c_do_update_firmware(struct i2c_client *client,
        const u8 enter_iap[] = { 0x45, 0x49, 0x41, 0x50 };
        const u8 enter_iap2[] = { 0x54, 0x00, 0x12, 0x34 };
        const u8 iap_ack[] = { 0x55, 0xaa, 0x33, 0xcc };
+       const u8 close_idle[] = {0x54, 0x2c, 0x01, 0x01};
        u8 buf[HEADER_SIZE];
        u16 send_id;
        int page, n_fw_pages;
@@ -617,8 +618,13 @@ static int elants_i2c_do_update_firmware(struct i2c_client *client,
        } else {
                /* Start IAP Procedure */
                dev_dbg(&client->dev, "Normal IAP procedure\n");
+               /* Close idle mode */
+               error = elants_i2c_send(client, close_idle, sizeof(close_idle));
+               if (error)
+                       dev_err(&client->dev, "Failed close idle: %d\n", error);
+               msleep(60);
                elants_i2c_sw_reset(client);
-
+               msleep(20);
                error = elants_i2c_send(client, enter_iap, sizeof(enter_iap));
        }