From 9bb1fdcb91c182eaeda862daea67801bdebb5875 Mon Sep 17 00:00:00 2001 From: Jing Lin Date: Wed, 21 Mar 2012 15:43:45 -0700 Subject: [PATCH] input: atmel_mxt_ts: Zero out config version after firmware upgrade When the touch controller firmware is upgraded, the config data on the controller might require an update too to match the firmware. Since the driver performs config version checking before updating config data and only updates to a newer version, we need to zero out the config version after a firmware upgrade to make sure proper config data will be programmed to the touch controller. Change-Id: If3e22948b1f8eea3ccbfcaa979ec6b42f1ac078a Signed-off-by: Jing Lin --- drivers/input/touchscreen/atmel_mxt_ts.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index b481429ae1c..58e894e38a8 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -346,6 +346,7 @@ struct mxt_data { u8 t15_min_reportid; u8 cfg_version[MXT_CFG_VERSION_LEN]; int cfg_version_idx; + int t38_start_addr; bool update_cfg; const char *fw_name; }; @@ -1054,8 +1055,10 @@ static int mxt_get_object_table(struct mxt_data *data) /* Calculate index for config major version in config array. * Major version is the first byte in object T38. */ - if (object->type == MXT_SPT_USERDATA_T38) + if (object->type == MXT_SPT_USERDATA_T38) { + data->t38_start_addr = object->start_address; found_t38 = true; + } if (!found_t38 && mxt_object_writable(object->type)) data->cfg_version_idx += object->size + 1; } @@ -1653,6 +1656,7 @@ static ssize_t mxt_update_fw_store(struct device *dev, int error; const char *fw_name; u8 bootldr_id; + u8 cfg_version[MXT_CFG_VERSION_LEN] = {0}; /* If fw_name is set, then the existing firmware has an upgrade */ if (!data->fw_name) { @@ -1703,6 +1707,12 @@ static ssize_t mxt_update_fw_store(struct device *dev, data->cfg_version_idx = 0; data->update_cfg = false; + error = __mxt_write_reg(data->client, data->t38_start_addr, + sizeof(cfg_version), cfg_version); + if (error) + dev_err(dev, + "Unable to zero out config version after fw upgrade\n"); + mxt_initialize(data); }