Commit a0434b75 authored by Benson Leung's avatar Benson Leung Committed by Dmitry Torokhov

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: default avatarBenson Leung <bleung@chromium.org>
Signed-off-by: default avatarDaniel Kurtz <djkurtz@chromium.org>
Signed-off-by: default avatarNick Dyer <nick.dyer@itdev.co.uk>
Acked-by: default avatarYufeng Shen <miletus@chromium.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent d79e7e47
......@@ -181,8 +181,8 @@
#define MXT_BACKUP_VALUE 0x55
#define MXT_BACKUP_TIME 50 /* msec */
#define MXT_RESET_TIME 200 /* msec */
#define MXT_FWRESET_TIME 175 /* msec */
#define MXT_FW_RESET_TIME 3000 /* msec */
#define MXT_FW_CHG_TIMEOUT 300 /* msec */
/* Command to unlock bootloader */
#define MXT_UNLOCK_CMD_MSB 0xaa
......@@ -375,7 +375,7 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state)
* CHG assertion before reading the status byte.
* Once the status byte has been read, the line is deasserted.
*/
ret = mxt_wait_for_chg(data, 300);
ret = mxt_wait_for_chg(data, MXT_FW_CHG_TIMEOUT);
if (ret) {
/*
* TODO: handle -ERESTARTSYS better by terminating
......@@ -1047,6 +1047,18 @@ static int mxt_load_fw(struct device *dev, const char *fn)
dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size);
}
/* Wait for flash. */
ret = mxt_wait_for_chg(data, MXT_FW_RESET_TIME);
if (ret)
goto disable_irq;
/*
* Wait for device to reset. Some bootloader versions do not assert
* the CHG line after bootloading has finished, so ignore potential
* errors.
*/
mxt_wait_for_chg(data, MXT_FW_RESET_TIME);
data->in_bootloader = false;
disable_irq:
......@@ -1075,10 +1087,6 @@ static ssize_t mxt_update_fw_store(struct device *dev,
count = error;
} else {
dev_dbg(dev, "The firmware update succeeded\n");
/* Wait for reset */
msleep(MXT_FWRESET_TIME);
mxt_free_object_table(data);
mxt_initialize(data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment