input: atmel-mxt-ts: Provide firmware name via platform data
This allows firmware upgrade only when a firmware name is provided.
The platform data (config data) of the latest firmware will point
to a NULL string which prevents auto firmware upgrade at boot
(if enabled by the userspace).
Change-Id: Ifef57a9dab9306cf4f1fe7a6c7e52c5e92a25d4a
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 697dcdb..2058a54 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -339,6 +339,7 @@
u8 t15_min_reportid;
u8 curr_cfg_version;
int cfg_version_idx;
+ const char *fw_name;
};
static struct dentry *debug_base;
@@ -1034,11 +1035,13 @@
if (data->curr_cfg_version == cfg_version ||
!version_match) {
data->config_info = cfg_info;
+ data->fw_name = pdata->config_array[i].fw_name;
return 0;
}
}
}
+ data->fw_name = NULL;
dev_info(&data->client->dev,
"Config not found: F: %d, V: %d, FW: %d.%d.%d, CFG: %d\n",
info->family_id, info->variant_id,
@@ -1394,9 +1397,17 @@
struct mxt_data *data = dev_get_drvdata(dev);
int error;
+ /* If fw_name is set, then the existing firmware has an upgrade */
+ if (!data->fw_name) {
+ dev_err(dev, "Firmware name not specifed in platform data\n");
+ return -EINVAL;
+ }
+
+ dev_info(dev, "Upgrading the firmware file to %s\n", data->fw_name);
+
disable_irq(data->irq);
- error = mxt_load_fw(dev, MXT_FW_NAME);
+ error = mxt_load_fw(dev, data->fw_name);
if (error) {
dev_err(dev, "The firmware update failed(%d)\n", error);
count = error;
diff --git a/include/linux/i2c/atmel_mxt_ts.h b/include/linux/i2c/atmel_mxt_ts.h
index 500ee6b..3ac41bc 100644
--- a/include/linux/i2c/atmel_mxt_ts.h
+++ b/include/linux/i2c/atmel_mxt_ts.h
@@ -37,6 +37,8 @@
u8 variant_id;
u8 version;
u8 build;
+ /* Points to the firmware name to be upgraded to */
+ const char *fw_name;
};
/* The platform data for the Atmel maXTouch touchscreen driver */