From 8a49c2bd4fd8c7ae0dfb64e4109d1dd9922c1f54 Mon Sep 17 00:00:00 2001 From: Weilong Wu Date: Mon, 9 Mar 2020 11:22:31 +0800 Subject: [PATCH] dlkm: aw8695: fix enter standby mode failture Sometimes we find that the IC can't enter standby mode. The root casue is that the period between go bit operation and standby mode operation was less than 2ms. Add wakelock to avoid this concurrent issue. Change-Id: I318741acd2e60a019a32da3e91a6b373fe2d3020 Signed-off-by: Weilong Wu Reviewed-on: https://gerrit.mot.com/1508966 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jianqi Yang Submit-Approved: Jira Key --- drivers/misc/awinic/aw8695/aw8695.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/misc/awinic/aw8695/aw8695.c b/drivers/misc/awinic/aw8695/aw8695.c index 6ebbcc3db4ef..689efe5ac2d9 100644 --- a/drivers/misc/awinic/aw8695/aw8695.c +++ b/drivers/misc/awinic/aw8695/aw8695.c @@ -1,7 +1,7 @@ /* * aw8695.c aw8695 haptic module * - * Version: v1.3.4 + * Version: v1.3.6 * * Copyright (c) 2018 AWINIC Technology CO., LTD * @@ -41,7 +41,7 @@ #define AW8695_I2C_NAME "aw8695_haptic" #define AW8695_HAPTIC_NAME "aw8695_haptic" -#define AW8695_VERSION "v1.3.5" +#define AW8695_VERSION "v1.3.6" #define AWINIC_RAM_UPDATE_DELAY @@ -1138,6 +1138,7 @@ static unsigned char aw8695_haptic_rtp_get_fifo_afi(struct aw8695 *aw8695) static int aw8695_haptic_rtp_init(struct aw8695 *aw8695) { unsigned int buf_len = 0; + unsigned char reg_val = 0; pr_info("%s enter\n", __func__); @@ -1146,6 +1147,10 @@ static int aw8695_haptic_rtp_init(struct aw8695 *aw8695) while ((!aw8695_haptic_rtp_get_fifo_afi(aw8695)) && (aw8695->play_mode == AW8695_HAPTIC_RTP_MODE)) { pr_info("%s rtp cnt = %d\n", __func__, aw8695->rtp_cnt); + if (!aw8695_rtp) { + pr_info("%s:aw8695_rtp is null break\n", __func__); + break; + } if ((aw8695_rtp->len - aw8695->rtp_cnt) < (aw8695->ram.base_addr >> 2)) { buf_len = aw8695_rtp->len - aw8695->rtp_cnt; } else { @@ -1154,7 +1159,9 @@ static int aw8695_haptic_rtp_init(struct aw8695 *aw8695) aw8695_i2c_writes(aw8695, AW8695_REG_RTP_DATA, &aw8695_rtp->data[aw8695->rtp_cnt], buf_len); aw8695->rtp_cnt += buf_len; - if (aw8695->rtp_cnt == aw8695_rtp->len) { + + aw8695_i2c_read(aw8695, AW8695_REG_GLB_STATE, ®_val); + if ((aw8695->rtp_cnt == aw8695_rtp->len) || ((reg_val & 0x0f) == 0x00)) { pr_info("%s: rtp update complete\n", __func__); aw8695->rtp_cnt = 0; return 0; @@ -1201,6 +1208,8 @@ static void aw8695_rtp_work_routine(struct work_struct *work) memcpy(aw8695_rtp->data, rtp_file->data, rtp_file->size); release_firmware(rtp_file); + mutex_lock(&aw8695->lock); + aw8695->rtp_init = 1; /* gain */ @@ -1212,6 +1221,8 @@ static void aw8695_rtp_work_routine(struct work_struct *work) /* haptic start */ aw8695_haptic_start(aw8695); + mutex_unlock(&aw8695->lock); + aw8695_haptic_rtp_init(aw8695); } @@ -3290,6 +3301,7 @@ static irqreturn_t aw8695_irq(int irq, void *data) unsigned char reg_val = 0; unsigned char dbg_val = 0; unsigned int buf_len = 0; + unsigned char glb_state = 0; pr_debug("%s enter\n", __func__); @@ -3329,7 +3341,8 @@ static irqreturn_t aw8695_irq(int irq, void *data) aw8695_i2c_writes(aw8695, AW8695_REG_RTP_DATA, &aw8695_rtp->data[aw8695->rtp_cnt], buf_len); aw8695->rtp_cnt += buf_len; - if (aw8695->rtp_cnt == aw8695_rtp->len) { + aw8695_i2c_read(aw8695, AW8695_REG_GLB_STATE, &glb_state); + if ((aw8695->rtp_cnt == aw8695_rtp->len) || ((glb_state & 0x0f) == 0x00)) { pr_info("%s: rtp update complete\n", __func__); aw8695_haptic_set_rtp_aei(aw8695, false); aw8695->rtp_cnt = 0;