From 36cbda5bb65ca3eb66b97ca0c05a58718e3f2e30 Mon Sep 17 00:00:00 2001 From: Wen Xie Date: Fri, 15 Feb 2019 16:34:21 +0800 Subject: [PATCH] haptic: update aw8624 vibrator driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug2go turns on the vibrator,Kenel is in suspend process at this time. After the vibration time is over,Kenel suspend the I2C bus. Causes the driver to shut down the vibrator to fail. Change-Id: If6a5c7ca42be7a55c17f45c47748f785dbc317b1 Signed-off-by: Wen Xie Reviewed-on: https://gerrit.mot.com/1309316 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Weilong Wu Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- drivers/misc/awinic/aw8624/aw8624.c | 15 ++++++++++++++- drivers/misc/awinic/aw8624/aw8624.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/misc/awinic/aw8624/aw8624.c b/drivers/misc/awinic/aw8624/aw8624.c index 2211da964b66..eb948d537a51 100644 --- a/drivers/misc/awinic/aw8624/aw8624.c +++ b/drivers/misc/awinic/aw8624/aw8624.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include "aw8624.h" #include "aw8624_reg.h" @@ -38,7 +40,7 @@ ******************************************************/ #define AW8624_I2C_NAME "aw8624_haptic" #define AW8624_HAPTIC_NAME "aw8624_haptic" -#define AW8624_VERSION "v1.0.4" +#define AW8624_VERSION "v1.0.5" #define AWINIC_RAM_UPDATE_DELAY #define AW_I2C_RETRIES 2 #define AW_I2C_RETRY_DELAY 2 @@ -2337,6 +2339,13 @@ static void aw8624_vibrator_work_routine(struct work_struct *work) hrtimer_start(&aw8624->timer, ktime_set(aw8624->duration / 1000, (aw8624->duration % 1000) * 1000000), HRTIMER_MODE_REL); + wake_lock(&aw8624->wk_lock); + aw8624->wk_lock_flag = 1; + } else { + if (aw8624->wk_lock_flag == 1) { + wake_unlock(&aw8624->wk_lock); + aw8624->wk_lock_flag = 0; + } } mutex_unlock(&aw8624->lock); @@ -2780,6 +2789,8 @@ static int aw8624_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id * g_aw8624 = aw8624; + wake_lock_init(&aw8624->wk_lock, WAKE_LOCK_SUSPEND, "aw8624_wakelock"); + aw8624_vibrator_init(aw8624); aw8624_haptic_init(aw8624); aw8624_ram_init(aw8624); @@ -2819,6 +2830,8 @@ static int aw8624_i2c_remove(struct i2c_client *i2c) mutex_destroy(&aw8624->lock); mutex_destroy(&aw8624->haptic_audio.lock); + wake_lock_destroy(&aw8624->wk_lock); + sysfs_remove_group(&i2c->dev.kobj, &aw8624_attribute_group); sysfs_remove_group(&i2c->dev.kobj, &aw8624_vibrator_attribute_group); diff --git a/drivers/misc/awinic/aw8624/aw8624.h b/drivers/misc/awinic/aw8624/aw8624.h index 0b6163df209f..8f6b3a4fb5b1 100644 --- a/drivers/misc/awinic/aw8624/aw8624.h +++ b/drivers/misc/awinic/aw8624/aw8624.h @@ -164,6 +164,8 @@ struct aw8624 { struct device *dev; struct mutex lock; + struct wake_lock wk_lock; + unsigned char wk_lock_flag; struct hrtimer timer; struct work_struct vibrator_work; struct work_struct irq_work;