Solve goodix tp firmware upgrade problem

1. In the case of firmware damage, the input device is directly released
when probe, and the input device is accessed when the system is
suspended, causing the system crash.
2. When the firmware is damaged, because the product information cannot
be read, the touch upgrade script cannot repair the firmware.
So we need to use the ic_name in the dtbo file.
3. When probing, if obtaining the configuration file fails, reflash the
configuration file after the firmware upgrade is completed.

Change-Id: I10cf96e3721d539d6e15f4c6cc490eb0f4328700
Reviewed-on: https://gerrit.mot.com/2095432
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
litong20 2021-10-21 14:21:39 +08:00 • committed by litong
commit 54686bafb0
3 changed files with 45 additions and 13 deletions

View file

@ -1726,6 +1726,10 @@ void goodix_ts_release_connects(struct goodix_ts_core *core_data)
struct input_dev *input_dev = core_data->input_dev;
int i;
if (!input_dev) {
ts_err("Invalid input device");
return;
}
mutex_lock(&input_dev->mutex);
for (i = 0; i < GOODIX_MAX_TOUCH; i++) {
@ -1962,6 +1966,15 @@ static int goodix_generic_noti_callback(struct notifier_block *self,
hw_ops->irq_enable(cd, 0);
break;
case NOTIFY_FWUPDATE_SUCCESS:
#ifdef CONFIG_INPUT_TOUCHSCREEN_MMI
if (cd->need_update_cfg) {
if (goodix_get_config_proc(cd)) {
ts_info("no valid ic config found");
hw_ops->irq_enable(cd, 1);
break;
}
}
#endif
ret = hw_ops->get_ic_info(cd, &cd->ic_info);
if (ret)
ts_err("invalid ic info [ignore]");
@ -2076,19 +2089,22 @@ static int goodix_later_init_thread(void *data)
struct goodix_ts_core *cd = data;
struct goodix_ts_hw_ops *hw_ops = cd->hw_ops;
/* setp 1: get config data from config bin */
if (goodix_get_config_proc(cd))
ts_info("no valid ic config found");
else
ts_info("success get valid ic config");
/* setp 2: init fw struct add try do fw upgrade */
/* setp 1: init fw struct add try do fw upgrade */
ret = goodix_fw_update_init(cd);
if (ret) {
ts_err("failed init fw update module");
goto err_out;
}
/* setp 2: get config data from config bin */
if (goodix_get_config_proc(cd)) {
ts_info("no valid ic config found");
#ifdef CONFIG_INPUT_TOUCHSCREEN_MMI
cd->need_update_cfg = 1;
#endif
} else
ts_info("success get valid ic config");
#ifndef CONFIG_INPUT_TOUCHSCREEN_MMI
ret = goodix_do_fw_update(cd->ic_configs[CONFIG_TYPE_NORMAL],
UPDATE_MODE_BLOCK | UPDATE_MODE_SRC_REQUEST);
@ -2103,11 +2119,17 @@ static int goodix_later_init_thread(void *data)
ret = hw_ops->read_version(cd, &cd->fw_version);
if (ret) {
ts_err("invalid fw version, abort");
#ifdef CONFIG_INPUT_TOUCHSCREEN_MMI
goto stage2_init;
#endif
goto uninit_fw;
}
ret = hw_ops->get_ic_info(cd, &cd->ic_info);
if (ret) {
ts_err("invalid ic info, abort");
#ifdef CONFIG_INPUT_TOUCHSCREEN_MMI
goto stage2_init;
#endif
goto uninit_fw;
}
@ -2116,6 +2138,9 @@ static int goodix_later_init_thread(void *data)
*/
goodix_send_ic_config(cd, CONFIG_TYPE_NORMAL);
#ifdef CONFIG_INPUT_TOUCHSCREEN_MMI
stage2_init:
#endif
/* init other resources */
ret = goodix_ts_stage2_init(cd);
if (ret) {

View file

@ -488,6 +488,7 @@ struct goodix_ts_core {
int update_status;
int gesture_enabled;
const char *supplier;
bool need_update_cfg;
};
/* external module structures */

View file

@ -129,18 +129,24 @@ static int goodix_ts_mmi_methods_get_vendor(struct device *dev, void *cdata) {
return scnprintf(TO_CHARP(cdata), TS_MMI_MAX_VENDOR_LEN, "%s", "goodix");
}
#define TS_MMI_CHIP_INFO_LEN 7 /* GT9916 */
static int goodix_ts_mmi_methods_get_productinfo(struct device *dev, void *cdata) {
int ret;
struct platform_device *pdev;
struct goodix_ts_core *core_data;
struct goodix_fw_version fw_version;
struct goodix_ts_board_data *ts_bdata;
char* ic_info;
GET_GOODIX_DATA(dev);
ret = core_data->hw_ops->read_version(core_data, &fw_version);
return scnprintf(TO_CHARP(cdata), TS_MMI_CHIP_INFO_LEN, "GT%s",
fw_version.patch_pid);
ts_bdata = board_data(core_data);
if (!ts_bdata) {
ts_err("Failed to get ts board data");
return -ENODEV;
}
ic_info = strstr(ts_bdata->ic_name, ",");
ic_info++;
return scnprintf(TO_CHARP(cdata), TS_MMI_MAX_VENDOR_LEN, "%s", ic_info);
}
#define TOUCH_CFG_VERSION_ADDR 0x10076