diff options
author | Wendly Li <wendlyli@google.com> | 2022-03-23 09:29:42 +0000 |
---|---|---|
committer | Wendly Li <wendlyli@google.com> | 2022-03-24 03:40:39 +0000 |
commit | 18ec7081acf4aead3b33708b00188fae2807b4b8 (patch) | |
tree | e3215862a8e1b17a5df5b90ed90db3908f82ad41 /ft3658/focaltech_core.c | |
parent | 8bf43151e1bc346577314114d968ae5a9d3f0362 (diff) | |
download | focaltech_touch-18ec7081acf4aead3b33708b00188fae2807b4b8.tar.gz |
touch/focaltech: fix kernal crash and device is stuck
The bug is caused by SPI bus being stuck by some issues.
But touch driver should handle this situaiton well.
Bug: 225770685
Test: The driver is not stuck when SPI bus is stuck
Change-Id: Iefaec39ebb78f7bf3f3f75e77860181187d3bf10
Diffstat (limited to 'ft3658/focaltech_core.c')
-rw-r--r-- | ft3658/focaltech_core.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/ft3658/focaltech_core.c b/ft3658/focaltech_core.c index 97e8cbf..b0da047 100644 --- a/ft3658/focaltech_core.c +++ b/ft3658/focaltech_core.c @@ -129,17 +129,23 @@ int fts_wait_tp_to_valid(void) do { ret = fts_read_reg(FTS_REG_CHIP_ID, &idh); - if ((idh == chip_idh) || (fts_check_cid(ts_data, idh) == 0)) { + if (ret == -EIO) { + FTS_ERROR("Wait tp with unexpected I/O error, ret: %d", ret); + return ret; + } + + if (ret == 0 && ((idh == chip_idh) || (fts_check_cid(ts_data, idh) == 0))) { FTS_INFO("TP Ready,Device ID:0x%02x", idh); return 0; - } else - FTS_DEBUG("TP Not Ready,ReadData:0x%02x,ret:%d", idh, ret); + } + FTS_DEBUG("TP Not Ready,ReadData:0x%02x,ret:%d", idh, ret); cnt++; msleep(INTERVAL_READ_REG); } while ((cnt * INTERVAL_READ_REG) < TIMEOUT_READ_REG); - return -EIO; + FTS_ERROR("Wait tp timeout"); + return -ETIMEDOUT; } /***************************************************************************** @@ -3179,6 +3185,7 @@ static int fts_ts_suspend(struct device *dev) static int fts_ts_resume(struct device *dev) { struct fts_ts_data *ts_data = fts_data; + int ret = 0; FTS_FUNC_ENTER(); if (!ts_data->suspended) { @@ -3195,7 +3202,15 @@ static int fts_ts_resume(struct device *dev) fts_reset_proc(200); } - fts_wait_tp_to_valid(); + ret = fts_wait_tp_to_valid(); + if (ret != 0) { + FTS_ERROR("Resume has been cancelled by wake up timeout"); +#if FTS_POWER_SOURCE_CUST_EN + fts_power_source_suspend(ts_data); +#endif + return ret; + } + fts_ex_mode_recovery(ts_data); #if FTS_ESDCHECK_EN |