diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx.c b/drivers/input/touchscreen/nt36xxx/nt36xxx.c index 7670528c2e38..34afa81863ad 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx.c +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx.c @@ -761,6 +761,9 @@ static int nvt_ts_bus_get(struct nvt_ts_data *ts) { int rc = 0; + if (atomic_read(&ts->suspend_resume_underway)) + wait_for_completion_interruptible(&ts->touch_suspend_resume); + reinit_completion(&ts->trusted_touch_powerdown); mutex_lock(&ts->nvt_clk_io_ctrl_mutex); rc = pm_runtime_get_sync(ts->client->adapter->dev.parent); @@ -1174,6 +1177,7 @@ static void nvt_ts_trusted_touch_init(struct nvt_ts_data *ts) return; init_completion(&ts->trusted_touch_powerdown); + init_completion(&ts->touch_suspend_resume); /* Get clocks */ ts->core_clk = devm_clk_get(ts->client->dev.parent, @@ -3044,9 +3048,12 @@ static int32_t nvt_ts_suspend(struct device *dev) } #ifdef CONFIG_NOVATEK_TRUSTED_TOUCH - if (atomic_read(&ts->trusted_touch_enabled)) + if (atomic_read(&ts->trusted_touch_underway)) wait_for_completion_interruptible( &ts->trusted_touch_powerdown); + + atomic_set(&ts->suspend_resume_underway, 1); + reinit_completion(&ts->touch_suspend_resume); #endif #if !WAKEUP_GESTURE @@ -3100,7 +3107,10 @@ static int32_t nvt_ts_suspend(struct device *dev) input_sync(ts->input_dev); msleep(50); - +#ifdef CONFIG_NOVATEK_TRUSTED_TOUCH + complete(&ts->touch_suspend_resume); + atomic_set(&ts->suspend_resume_underway, 0); +#endif NVT_LOG("end\n"); return 0; @@ -3123,10 +3133,13 @@ static int32_t nvt_ts_resume(struct device *dev) return 0; } -#ifdef CONFIG_ST_TRUSTED_TOUCH - if (atomic_read(&ts->trusted_touch_enabled)) +#ifdef CONFIG_NOVATEK_TRUSTED_TOUCH + if (atomic_read(&ts->trusted_touch_underway)) wait_for_completion_interruptible( &ts->trusted_touch_powerdown); + + atomic_set(&ts->suspend_resume_underway, 1); + reinit_completion(&ts->touch_suspend_resume); #endif mutex_lock(&ts->lock); @@ -3157,6 +3170,10 @@ static int32_t nvt_ts_resume(struct device *dev) mutex_unlock(&ts->lock); +#ifdef CONFIG_NOVATEK_TRUSTED_TOUCH + complete(&ts->touch_suspend_resume); + atomic_set(&ts->suspend_resume_underway, 0); +#endif NVT_LOG("end\n"); return 0; diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx.h b/drivers/input/touchscreen/nt36xxx/nt36xxx.h index c7ba0dc0bdd0..44321ba9c2e9 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx.h +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx.h @@ -198,11 +198,13 @@ struct nvt_ts_data { struct mutex nvt_clk_io_ctrl_mutex; const char *touch_environment; struct completion trusted_touch_powerdown; + struct completion touch_suspend_resume; struct clk *core_clk; struct clk *iface_clk; atomic_t trusted_touch_initialized; atomic_t trusted_touch_enabled; atomic_t trusted_touch_underway; + atomic_t suspend_resume_underway; atomic_t trusted_touch_event; atomic_t trusted_touch_abort_status; atomic_t delayed_vm_probe_pending;