From 905d07601f7288ccbe6dec30930c10670357f94e Mon Sep 17 00:00:00 2001 From: litong Date: Fri, 7 Feb 2020 16:38:11 +0800 Subject: [PATCH] Add touch suspend_noirq process Because there is no disable-irq in LPM mode, I2C communication may occur when system suspends, resulting in conflict, which may lead to system crash. So we disable-irq when PM suspend, and then enable-irq again in the suspend_noirq phase. Change-Id: Ib9ca3f1f2a6d2da0142c6203acedb617535fc4a0 Reviewed-on: https://gerrit.mot.com/1494642 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jialei Hao Reviewed-by: Jianqi Yang Submit-Approved: Jira Key --- drivers/input/touchscreen/sec_mmi/Kbuild | 3 +- drivers/input/touchscreen/sec_mmi/sec_ts.c | 47 ++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/sec_mmi/Kbuild b/drivers/input/touchscreen/sec_mmi/Kbuild index 6acb006d199b..e81e931b661d 100644 --- a/drivers/input/touchscreen/sec_mmi/Kbuild +++ b/drivers/input/touchscreen/sec_mmi/Kbuild @@ -11,7 +11,8 @@ obj-m := sec_mmi.o sec_mmi-objs = sec_ts.o sec_ts_fn.o sec_ts_fw.o sec_cmd.o sec_ts_only_vendor.o ifneq ($(filter m y,$(CONFIG_INPUT_TOUCHSCREEN_MMI)),) - EXTRA_CFLAGS += -DCONFIG_PANEL_NOTIFICATIONS -DCONFIG_INPUT_TOUCHSCREEN_MMI + EXTRA_CFLAGS += -DCONFIG_PANEL_NOTIFICATIONS -DCONFIG_INPUT_TOUCHSCREEN_MMI \ + -DCONFIG_PM sec_mmi-objs += sec_ts_mmi_class.o else EXTRA_CFLAGS += -DUSE_STUBS diff --git a/drivers/input/touchscreen/sec_mmi/sec_ts.c b/drivers/input/touchscreen/sec_mmi/sec_ts.c index ce34f7ea0582..3ee6aff5b8ab 100644 --- a/drivers/input/touchscreen/sec_mmi/sec_ts.c +++ b/drivers/input/touchscreen/sec_mmi/sec_ts.c @@ -2486,14 +2486,34 @@ out: return ret; } -#if defined(CONFIG_PM) && !defined(CONFIG_DRM) +#if defined(CONFIG_PM) static int sec_ts_pm_suspend(struct device *dev) { struct sec_ts_data *ts = dev_get_drvdata(dev); + input_dbg(true, &ts->client->dev, "%s:Into PM suspend\n", __func__); + +#if !defined(CONFIG_DRM) if (ts->lowpower_mode) reinit_completion(&ts->resume_done); +#endif + if (ts->power_status == SEC_TS_STATE_LPM) { + input_dbg(true, &ts->client->dev, "%s: Disable-irq\n", __func__); + sec_ts_irq_enable(ts, false); + } + return 0; +} + +static int sec_ts_pm_suspend_noirq(struct device *dev) +{ + struct sec_ts_data *ts = dev_get_drvdata(dev); + + input_dbg(true, &ts->client->dev, "%s: Into PM suspend_noirq\n", __func__); + if (ts->power_status == SEC_TS_STATE_LPM) { + input_dbg(true, &ts->client->dev, "%s: Enable-irq\n", __func__); + sec_ts_irq_enable(ts, true); + } return 0; } @@ -2501,9 +2521,28 @@ static int sec_ts_pm_resume(struct device *dev) { struct sec_ts_data *ts = dev_get_drvdata(dev); + input_dbg(true, &ts->client->dev, "%s: Into PM resume\n", __func__); + if (ts->power_status == SEC_TS_STATE_LPM) { + input_dbg(true, &ts->client->dev, "%s: Enable-irq\n", __func__); + sec_ts_irq_enable(ts, true); + } + +#if !defined(CONFIG_DRM) if (ts->lowpower_mode) complete_all(&ts->resume_done); +#endif + return 0; +} +static int sec_ts_pm_resume_noirq(struct device *dev) +{ + struct sec_ts_data *ts = dev_get_drvdata(dev); + + input_dbg(true, &ts->client->dev, "%s: Into PM resume_noirq\n", __func__); + if (ts->power_status == SEC_TS_STATE_LPM) { + input_dbg(true, &ts->client->dev, "%s: Disable-irq\n", __func__); + sec_ts_irq_enable(ts, false); + } return 0; } #endif @@ -2513,10 +2552,12 @@ static const struct i2c_device_id sec_ts_id[] = { { }, }; -#if defined(CONFIG_PM) && !defined(CONFIG_DRM) +#if defined(CONFIG_PM) static const struct dev_pm_ops sec_ts_dev_pm_ops = { .suspend = sec_ts_pm_suspend, + .suspend_noirq = sec_ts_pm_suspend_noirq, .resume = sec_ts_pm_resume, + .resume_noirq = sec_ts_pm_resume_noirq, }; #endif @@ -2540,7 +2581,7 @@ static struct i2c_driver sec_ts_driver = { #ifdef CONFIG_OF .of_match_table = sec_ts_match_table, #endif -#if defined(CONFIG_PM) && !defined(CONFIG_DRM) +#if defined(CONFIG_PM) .pm = &sec_ts_dev_pm_ops, #endif },