summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei-Han Chen <stimim@google.com>2018-09-18 10:14:13 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-09-19 08:59:51 -0700
commit4984591b02c5e3e4d3c2d7bda2d7129dff20fafc (patch)
tree0e0d106460b37bef68a76180771e4c832c3ff16b
parent178d079bb63431078e25c56bb4472fa77b534d5e (diff)
downloadchrome-ec-4984591b02c5e3e4d3c2d7bda2d7129dff20fafc.tar.gz
touchpad_st: handle error type 0xff
When ST touchpad is down, or the SPI interface is not working properly (either hardware or software issue), we might receive events filled with 0xff. In this case, try if resetting touchpad can bring it back. To prevent infinite reboot, if the touchpad is not recovered after 3 reboots, stop it. BRANCH=nocturne BUG=None TEST=manual on device Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I8d2a8f0f4aa305af11f14a63f0bc4d53c2c23a49 Reviewed-on: https://chromium-review.googlesource.com/1230393 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--driver/touchpad_st.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/driver/touchpad_st.c b/driver/touchpad_st.c
index 4f7292e445..9704e8c0ac 100644
--- a/driver/touchpad_st.c
+++ b/driver/touchpad_st.c
@@ -67,6 +67,13 @@ static int tp_control;
#define TP_CONTROL_SHALL_RESET (1 << 1)
#define TP_CONTROL_SHALL_INITIALIZE (1 << 2)
+/*
+ * Number of times we have reset the touchpad because of errors.
+ */
+static int tp_reset_retry_count;
+
+#define MAX_TP_RESET_RETRY_COUNT 3
+
static int dump_memory_on_error;
/*
@@ -636,6 +643,20 @@ static int st_tp_handle_error_report(struct st_tp_event_t *e,
}
/*
+ * When 0xFF is received, it's very likely ST touchpad is down.
+ * Try if touchpad can be recovered by reset.
+ */
+ if (error_type == 0xFF) {
+ if (tp_reset_retry_count < MAX_TP_RESET_RETRY_COUNT) {
+ tp_control |= TP_CONTROL_SHALL_RESET;
+ tp_reset_retry_count++;
+ } else {
+ tp_control |= TP_CONTROL_SHALL_HALT;
+ }
+ return 1;
+ }
+
+ /*
* Otherwise, just ignore it.
*/
return 0;
@@ -695,6 +716,7 @@ static int st_tp_reset(void)
if (e->evt_id == ST_TP_EVENT_ID_CONTROLLER_READY) {
CPRINTS("Touchpad ready");
+ tp_reset_retry_count = 0;
return 0;
}
}