Skip to content

Commit a0434b7

Browse files
bleungatchromiumdtor
authored andcommitted
Input: atmel_mxt_ts - wait for CHG after bootloader resets
Rather than msleep for MXT_RESET_TIME and MXT_FWRESET_TIME during the transition to bootloader mode and the transition back from app, wait for the CHG assert to indicate that the transition is done. This change replaces the msleep with a wait for completion that the mxt_interrupt handler signals. Also add CHG poll after last firmware frame - some bootloader versions will assert the interrupt line after the final frame, in testing this meant that the driver attempts to read the info block too early whilst the chip is still resetting. This improves firmware update time as we no longer wait longer than necessary for each reset. Signed-off-by: Benson Leung <bleung@chromium.org> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk> Acked-by: Yufeng Shen <miletus@chromium.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent d79e7e4 commit a0434b7

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

‎drivers/input/touchscreen/atmel_mxt_ts.c‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@
181181
#define MXT_BACKUP_VALUE 0x55
182182
#define MXT_BACKUP_TIME 50 /* msec */
183183
#define MXT_RESET_TIME 200 /* msec */
184-
185-
#define MXT_FWRESET_TIME 175 /* msec */
184+
#define MXT_FW_RESET_TIME 3000 /* msec */
185+
#define MXT_FW_CHG_TIMEOUT 300 /* msec */
186186

187187
/* Command to unlock bootloader */
188188
#define MXT_UNLOCK_CMD_MSB 0xaa
@@ -375,7 +375,7 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state)
375375
* CHG assertion before reading the status byte.
376376
* Once the status byte has been read, the line is deasserted.
377377
*/
378-
ret = mxt_wait_for_chg(data, 300);
378+
ret = mxt_wait_for_chg(data, MXT_FW_CHG_TIMEOUT);
379379
if (ret) {
380380
/*
381381
* TODO: handle -ERESTARTSYS better by terminating
@@ -1047,6 +1047,18 @@ static int mxt_load_fw(struct device *dev, const char *fn)
10471047
dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size);
10481048
}
10491049

1050+
/* Wait for flash. */
1051+
ret = mxt_wait_for_chg(data, MXT_FW_RESET_TIME);
1052+
if (ret)
1053+
goto disable_irq;
1054+
1055+
/*
1056+
* Wait for device to reset. Some bootloader versions do not assert
1057+
* the CHG line after bootloading has finished, so ignore potential
1058+
* errors.
1059+
*/
1060+
mxt_wait_for_chg(data, MXT_FW_RESET_TIME);
1061+
10501062
data->in_bootloader = false;
10511063

10521064
disable_irq:
@@ -1075,10 +1087,6 @@ static ssize_t mxt_update_fw_store(struct device *dev,
10751087
count = error;
10761088
} else {
10771089
dev_dbg(dev, "The firmware update succeeded\n");
1078-
1079-
/* Wait for reset */
1080-
msleep(MXT_FWRESET_TIME);
1081-
10821090
mxt_free_object_table(data);
10831091

10841092
mxt_initialize(data);

0 commit comments

Comments
 (0)