Commit f943c74a authored by Nick Dyer's avatar Nick Dyer Committed by Dmitry Torokhov

Input: atmel_mxt_ts - implement bootloader frame retries

Signed-off-by: default avatarNick Dyer <nick.dyer@itdev.co.uk>
Acked-by: default avatarBenson Leung <bleung@chromium.org>
Acked-by: default avatarYufeng Shen <miletus@chromium.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent e57a66aa
...@@ -510,8 +510,12 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state) ...@@ -510,8 +510,12 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state)
val &= ~MXT_BOOT_STATUS_MASK; val &= ~MXT_BOOT_STATUS_MASK;
break; break;
case MXT_FRAME_CRC_PASS: case MXT_FRAME_CRC_PASS:
if (val == MXT_FRAME_CRC_CHECK) if (val == MXT_FRAME_CRC_CHECK) {
goto recheck; goto recheck;
} else if (val == MXT_FRAME_CRC_FAIL) {
dev_err(dev, "Bootloader CRC fail\n");
return -EINVAL;
}
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -1187,6 +1191,7 @@ static int mxt_load_fw(struct device *dev, const char *fn) ...@@ -1187,6 +1191,7 @@ static int mxt_load_fw(struct device *dev, const char *fn)
const struct firmware *fw = NULL; const struct firmware *fw = NULL;
unsigned int frame_size; unsigned int frame_size;
unsigned int pos = 0; unsigned int pos = 0;
unsigned int retry = 0;
int ret; int ret;
ret = request_firmware(&fw, fn, dev); ret = request_firmware(&fw, fn, dev);
...@@ -1224,9 +1229,7 @@ static int mxt_load_fw(struct device *dev, const char *fn) ...@@ -1224,9 +1229,7 @@ static int mxt_load_fw(struct device *dev, const char *fn)
frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1)); frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1));
/* We should add 2 at frame size as the the firmware data is not /* Take account of CRC bytes */
* included the CRC bytes.
*/
frame_size += 2; frame_size += 2;
/* Write one frame to device */ /* Write one frame to device */
...@@ -1235,10 +1238,20 @@ static int mxt_load_fw(struct device *dev, const char *fn) ...@@ -1235,10 +1238,20 @@ static int mxt_load_fw(struct device *dev, const char *fn)
goto disable_irq; goto disable_irq;
ret = mxt_check_bootloader(data, MXT_FRAME_CRC_PASS); ret = mxt_check_bootloader(data, MXT_FRAME_CRC_PASS);
if (ret) if (ret) {
goto disable_irq; retry++;
/* Back off by 20ms per retry */
msleep(retry * 20);
if (retry > 20) {
dev_err(dev, "Retry count exceeded\n");
goto disable_irq;
}
} else {
retry = 0;
pos += frame_size; pos += frame_size;
}
dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size); dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size);
} }
......
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