summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWendly Li <wendlyli@google.com>2023-02-16 08:36:54 +0000
committerWendly Li <wendlyli@google.com>2023-02-22 06:22:54 +0000
commit9a1bdd15f21249e755ef38ce2439e6ca407ca54c (patch)
treea96d3dee384d9ae7b5986e02425204a14a7b8eec
parent01bc79a67eafe0013dbbb9843301e6e1ba8b97ac (diff)
downloadgoodix_touch-9a1bdd15f21249e755ef38ce2439e6ca407ca54c.tar.gz
touch/goodix: fix double reset
ESD check will fail on firmware reset. When ESD check is failed, it will reset firmware again. Skip ESD check to avoid double reset. Double reset may cause self-test failure and other unexpected issues. Bug: 267991839 Test: Check self-test works properly Change-Id: I17063445e71832077766d3d9aa3e6457f4b9e4b7 Signed-off-by: Wendly Li <wendlyli@google.com>
-rw-r--r--goodix_brl_hw.c6
-rw-r--r--goodix_ts_core.c11
-rw-r--r--goodix_ts_core.h3
3 files changed, 16 insertions, 4 deletions
diff --git a/goodix_brl_hw.c b/goodix_brl_hw.c
index 5e282ad..505e8ec 100644
--- a/goodix_brl_hw.c
+++ b/goodix_brl_hw.c
@@ -324,6 +324,12 @@ static int brl_reset(struct goodix_ts_core *cd, int delay)
{
ts_info("chip_reset");
+ /*
+ * ESD check will fail on firmware reset. When ESD check is failed,
+ * it will reset firmware again. Skip ESD check to avoid double reset.
+ */
+ cd->ts_esd.skip_once = true;
+
gpio_direction_output(cd->board_data.reset_gpio, 0);
usleep_range(2000, 2100);
gpio_direction_output(cd->board_data.reset_gpio, 1);
diff --git a/goodix_ts_core.c b/goodix_ts_core.c
index 7294aab..c86c0b7 100644
--- a/goodix_ts_core.c
+++ b/goodix_ts_core.c
@@ -1876,7 +1876,12 @@ static irqreturn_t goodix_ts_threadirq_func(int irq, void *data)
}
#endif
- ts_esd->irq_status = true;
+ /*
+ * Since we received an interrupt from touch firmware, it means touch
+ * firmware is still alive. So skip esd check once.
+ */
+ ts_esd->skip_once = true;
+
core_data->irq_trig_cnt++;
/* inform external module */
mutex_lock(&goodix_modules.mutex);
@@ -2290,7 +2295,7 @@ static void goodix_ts_esd_work(struct work_struct *work)
const struct goodix_ts_hw_ops *hw_ops = cd->hw_ops;
int ret = 0;
- if (ts_esd->irq_status)
+ if (ts_esd->skip_once)
goto exit;
if (!atomic_read(&ts_esd->esd_on) || atomic_read(&cd->suspended))
@@ -2321,7 +2326,7 @@ static void goodix_ts_esd_work(struct work_struct *work)
}
exit:
- ts_esd->irq_status = false;
+ ts_esd->skip_once = false;
if (atomic_read(&ts_esd->esd_on))
schedule_delayed_work(&ts_esd->esd_work, 2 * HZ);
}
diff --git a/goodix_ts_core.h b/goodix_ts_core.h
index 06e089e..44f136c 100644
--- a/goodix_ts_core.h
+++ b/goodix_ts_core.h
@@ -679,9 +679,10 @@ struct goodix_ts_hw_ops {
* @esd_work: esd delayed work
* @esd_on: 1 - turn on esd protection, 0 - turn
* off esd protection
+ * @skip_once: skip once if the check is no need this time.
*/
struct goodix_ts_esd {
- bool irq_status;
+ bool skip_once;
atomic_t esd_on;
struct delayed_work esd_work;
struct notifier_block esd_notifier;