[PATCH 09/10] Input: atmel_mxt_ts - wait for CHG after bootloader resets

From: Daniel Kurtz
Date: Fri Feb 01 2013 - 03:13:29 EST


From: Benson Leung <bleung@xxxxxxxxxxxx>

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.

This improves firmware update time by 300 ms as we no longer
wait longer than necessary for each reset.

Signed-off-by: Benson Leung <bleung@xxxxxxxxxxxx>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index d0f91ff..ef867d3 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -634,6 +634,7 @@ static bool mxt_is_T9_message(struct mxt_data *data, struct mxt_message *msg)
static int mxt_enter_bl(struct mxt_data *data)
{
struct i2c_client *client = data->client;
+ struct device *dev = &client->dev;
int ret;

if (mxt_in_bootloader(data))
@@ -662,8 +663,19 @@ static int mxt_enter_bl(struct mxt_data *data)
data->input_dev = NULL;
}

+ INIT_COMPLETION(data->bl_completion);
enable_irq(data->irq);
- msleep(MXT_RESET_TIME);
+
+ /* Wait for CHG assert to indicate successful reset into bootloader */
+ ret = mxt_wait_for_chg(data, MXT_RESET_TIME);
+ if (ret) {
+ dev_err(dev, "Failed waiting for reset to bootloader.\n");
+ if (client->addr == MXT_BOOT_LOW)
+ client->addr = MXT_APP_LOW;
+ else
+ client->addr = MXT_APP_HIGH;
+ return ret;
+ }
return 0;
}

@@ -676,10 +688,10 @@ static void mxt_exit_bl(struct mxt_data *data)
if (!mxt_in_bootloader(data))
return;

- disable_irq(data->irq);
/* Wait for reset */
- msleep(MXT_FWRESET_TIME);
+ mxt_wait_for_chg(data, MXT_FWRESET_TIME);

+ disable_irq(data->irq);
if (client->addr == MXT_BOOT_LOW)
client->addr = MXT_APP_LOW;
else
@@ -1122,7 +1134,6 @@ static int mxt_load_fw(struct device *dev, const char *fn)
if (ret)
goto out;

- INIT_COMPLETION(data->bl_completion);
/* Unlock bootloader */
ret = mxt_unlock_bootloader(client);
if (ret)
--
1.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/