diff options
author | Mason Wang <masonwang@google.com> | 2022-05-17 12:48:39 +0800 |
---|---|---|
committer | Mason Wang <masonwang@google.com> | 2022-05-18 10:58:20 +0800 |
commit | 0ba8264e89b3e605164eef3e511042435e357fe0 (patch) | |
tree | c25e12fb98aca69cdf2ac3798c06bb577dfeb9f1 | |
parent | 6b1bf96f77a1033f5d0d046fe99d53de3560cccd (diff) | |
download | focaltech_touch-0ba8264e89b3e605164eef3e511042435e357fe0.tar.gz |
touch/focaltech: Check if SPI bus is available before transferring.
Bug: 232640281
Test: Touch operation and touch gesture work well.
Signed-off-by: Mason Wang <masonwang@google.com>
Change-Id: I53c845f491b9a8815d1d334d0ee0d5042cef87c0
-rw-r--r-- | ft3658/focaltech_common.h | 7 | ||||
-rw-r--r-- | ft3658/focaltech_core.c | 15 | ||||
-rw-r--r-- | ft3658/focaltech_core.h | 1 | ||||
-rw-r--r-- | ft3658/focaltech_spi.c | 11 |
4 files changed, 29 insertions, 5 deletions
diff --git a/ft3658/focaltech_common.h b/ft3658/focaltech_common.h index 34cc3b8..1c6a80d 100644 --- a/ft3658/focaltech_common.h +++ b/ft3658/focaltech_common.h @@ -236,6 +236,13 @@ enum FW_PALM_MODE { FW_PALM_FORCE_ENABLE, }; +#if IS_ENABLED(CONFIG_TOUCHSCREEN_TBN) +enum TBN_OWRER { + TBN_AP, + TBN_AOC, +}; +#endif + /***************************************************************************** * DEBUG function define here *****************************************************************************/ diff --git a/ft3658/focaltech_core.c b/ft3658/focaltech_core.c index 22fe86f..6da73d1 100644 --- a/ft3658/focaltech_core.c +++ b/ft3658/focaltech_core.c @@ -2349,8 +2349,11 @@ static void fts_suspend_work(struct work_struct *work) ts_data->power_status = FTS_TS_STATE_SUSPEND; #endif #if IS_ENABLED(CONFIG_TOUCHSCREEN_TBN) - if (ts_data->tbn_register_mask) - tbn_release_bus(ts_data->tbn_register_mask); + if (ts_data->tbn_register_mask) { + int ret = tbn_release_bus(ts_data->tbn_register_mask); + if (ret == 0) + ts_data->tbn_owner = TBN_AOC; + } #endif mutex_unlock(&ts_data->device_mutex); } @@ -2364,8 +2367,11 @@ static void fts_resume_work(struct work_struct *work) mutex_lock(&ts_data->device_mutex); #if IS_ENABLED(CONFIG_TOUCHSCREEN_TBN) - if (ts_data->tbn_register_mask) - tbn_request_bus(ts_data->tbn_register_mask); + if (ts_data->tbn_register_mask) { + int ret = tbn_request_bus(ts_data->tbn_register_mask); + if (ret == 0) + ts_data->tbn_owner = TBN_AP; + } #endif #if IS_ENABLED(CONFIG_TOUCHSCREEN_PANEL_BRIDGE) if (ts_data->power_status == FTS_TS_STATE_POWER_ON) { @@ -2627,6 +2633,7 @@ static int fts_ts_probe_entry(struct fts_ts_data *ts_data) FTS_ERROR("Failed to register tbn context.\n"); goto err_init_tbn; } + ts_data->tbn_owner = TBN_AP; FTS_INFO("tbn_register_mask = %#x.\n", ts_data->tbn_register_mask); #endif diff --git a/ft3658/focaltech_core.h b/ft3658/focaltech_core.h index 450f87a..aeb79e2 100644 --- a/ft3658/focaltech_core.h +++ b/ft3658/focaltech_core.h @@ -319,6 +319,7 @@ struct fts_ts_data { #endif #if IS_ENABLED(CONFIG_TOUCHSCREEN_TBN) u32 tbn_register_mask; + u8 tbn_owner; #endif }; diff --git a/ft3658/focaltech_spi.c b/ft3658/focaltech_spi.c index b9f309b..972c26e 100644 --- a/ft3658/focaltech_spi.c +++ b/ft3658/focaltech_spi.c @@ -80,7 +80,12 @@ static int fts_spi_transfer(u8 *tx_buf, u8 *rx_buf, u32 len) .len = len, .bits_per_word = len >= 64 ? 32 : 8, }; - +#if IS_ENABLED(CONFIG_TOUCHSCREEN_TBN) + if (fts_data->tbn_owner != TBN_AP) { + FTS_ERROR("SPI bus is not available."); + return -EACCES; + } +#endif spi_message_init(&msg); spi_message_add_tail(&xfer, &msg); @@ -230,6 +235,8 @@ int fts_write(u8 *writebuf, u32 writelen) } else { FTS_DEBUG("data write(addr:%x),status:%x,retry:%d,ret:%d", writebuf[0], rxbuf[3], i, ret); + if (ret == -EACCES) + break; ret = -EIO; udelay(CS_HIGH_DELAY); } @@ -349,6 +356,8 @@ int fts_read(u8 *cmd, u32 cmdlen, u8 *data, u32 datalen) } else { FTS_DEBUG("data read(addr:%x) status:%x,retry:%d,ret:%d", cmd[0], rxbuf[3], i, ret); + if (ret == -EACCES) + break; ret = -EIO; udelay(CS_HIGH_DELAY); } |