From 0c587df2a6af6185fc163da47e941b274e3ab7d7 Mon Sep 17 00:00:00 2001 From: zhuwg1 Date: Thu, 7 Apr 2022 17:47:14 +0800 Subject: [PATCH] Fix enable gesture mode error on panel off state When on panel off state,enable or disable gesture mode will cause suspend and resume error,recording touch IC power state to correct. Change-Id: I71283abc65386b3a448782c1d122bcbb33c584cd Signed-off-by: zhuwg1 Reviewed-on: https://gerrit.mot.com/2236143 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: litong Reviewed-by: Jichao Zou Submit-Approved: Jira Key --- .../parade_tma5xx_mmi/cyttsp5_core.c | 41 ++++++++++++++++++- .../parade_tma5xx_mmi/cyttsp5_regs.h | 8 ++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_core.c b/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_core.c index 977883b313b9..e170d6e15055 100644 --- a/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_core.c +++ b/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_core.c @@ -3873,6 +3873,10 @@ static int cyttsp5_put_device_into_easy_wakeup_(struct cyttsp5_core_data *cd) if (rc || status == 0) return -EBUSY; + mutex_lock(&cd->system_lock); + cd->pm_mode = CYTTSP5_PM_EASY_WAKEUP; + mutex_unlock(&cd->system_lock); + return rc; } @@ -3883,6 +3887,12 @@ static int cyttsp5_put_device_into_deep_sleep_(struct cyttsp5_core_data *cd) rc = cyttsp5_hid_cmd_set_power_(cd, HID_POWER_SLEEP); if (rc) rc = -EBUSY; + else { + mutex_lock(&cd->system_lock); + cd->pm_mode = CYTTSP5_PM_DEEPSLEEP; + mutex_unlock(&cd->system_lock); + } + return rc; } @@ -3911,6 +3921,12 @@ static int cyttsp5_core_poweroff_device_(struct cyttsp5_core_data *cd) if (rc < 0) dev_err(cd->dev, "%s: HW Power down fails r=%d\n", __func__, rc); + else { + mutex_lock(&cd->system_lock); + cd->pm_mode = CYTTSP5_PM_POWEROFF; + mutex_unlock(&cd->system_lock); + } + return rc; } @@ -4697,15 +4713,19 @@ static int cyttsp5_core_wake_(struct cyttsp5_core_data *cd) mutex_unlock(&cd->system_lock); if (!IS_DEEP_SLEEP_CONFIGURED(cd->easy_wakeup_gesture) && - (cd->should_enable_gesture ==1)) { + (cd->should_enable_gesture ==1) && + (cd->pm_mode == CYTTSP5_PM_DEEPSLEEP || + cd->pm_mode == CYTTSP5_PM_EASY_WAKEUP)) { rc = cyttsp5_core_wake_device_(cd); - } else if (cd->cpdata->flags & CY_CORE_FLAG_POWEROFF_ON_SLEEP) + } else if ((cd->cpdata->flags & CY_CORE_FLAG_POWEROFF_ON_SLEEP) && + (cd->pm_mode == CYTTSP5_PM_POWEROFF)) rc = cyttsp5_core_poweron_device_(cd); else rc = cyttsp5_core_wake_device_(cd); mutex_lock(&cd->system_lock); cd->sleep_state = SS_SLEEP_OFF; + cd->pm_mode = CYTTSP5_PM_ACTIVE; mutex_unlock(&cd->system_lock); cyttsp5_start_wd_timer(cd); @@ -5110,6 +5130,12 @@ int cyttsp5_core_suspend(struct device *dev) } } + dev_info(dev, "%s: suspend power state %s \n", __func__, + cd->pm_mode == CYTTSP5_PM_POWEROFF ? "CYTTSP5_PM_POWEROFF" : + (cd->pm_mode == CYTTSP5_PM_DEEPSLEEP ? "CYTTSP5_PM_DEEPSLEEP" : + (cd->pm_mode == CYTTSP5_PM_EASY_WAKEUP ? "CYTTSP5_PM_EASY_WAKEUP" : + (cd->pm_mode == CYTTSP5_PM_ACTIVE ? "CYTTSP5_PM_ACTIVE" : "Unknown")))); + return 0; } @@ -5145,6 +5171,12 @@ int cyttsp5_core_resume(struct device *dev) exit: cyttsp5_core_wake(cd); + dev_info(dev, "%s: resume power state %s \n", __func__, + cd->pm_mode == CYTTSP5_PM_POWEROFF ? "CYTTSP5_PM_POWEROFF" : + (cd->pm_mode == CYTTSP5_PM_DEEPSLEEP ? "CYTTSP5_PM_DEEPSLEEP" : + (cd->pm_mode == CYTTSP5_PM_EASY_WAKEUP ? "CYTTSP5_PM_EASY_WAKEUP" : + (cd->pm_mode == CYTTSP5_PM_ACTIVE ? "CYTTSP5_PM_ACTIVE" : "Unknown")))); + return 0; } #endif @@ -6808,6 +6840,11 @@ int cyttsp5_probe(const struct cyttsp5_bus_ops *ops, struct device *dev, } if (rc < 0) dev_err(cd->dev, "%s: HW Init fail r=%d\n", __func__, rc); + else { + mutex_lock(&cd->system_lock); + cd->pm_mode = CYTTSP5_PM_ACTIVE; + mutex_unlock(&cd->system_lock); + } /* Call platform detect function */ if (cd->cpdata->detect) { diff --git a/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_regs.h b/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_regs.h index d903d788ccde..ef2baa8b9f78 100644 --- a/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_regs.h +++ b/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_regs.h @@ -956,6 +956,13 @@ struct cyttsp5_sensor_platform_data { }; #endif +enum cyttsp5_pm_mode { + CYTTSP5_PM_POWEROFF = 0, + CYTTSP5_PM_DEEPSLEEP, + CYTTSP5_PM_EASY_WAKEUP, + CYTTSP5_PM_ACTIVE, +}; + struct cyttsp5_core_data { struct list_head node; struct list_head module_list; /* List of probed modules */ @@ -1036,6 +1043,7 @@ struct cyttsp5_core_data { struct mutex tthe_lock; u8 tthe_exit; #endif + enum cyttsp5_pm_mode pm_mode; bool should_enable_gesture; #ifdef CYTTSP5_SENSOR_EN struct mutex state_mutex;