[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240716205612.1502608-2-Frank.Li@nxp.com>
Date: Tue, 16 Jul 2024 16:56:10 -0400
From: Frank Li <Frank.Li@....com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Dong Aisheng <aisheng.dong@....com>,
Joy Zou <joy.zou@....com>,
Robin Gong <yibin.gong@....com>,
Shawn Guo <shawn.guo@...aro.org>,
linux-input@...r.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...),
linux-kernel@...r.kernel.org (open list)
Cc: imx@...ts.linux.dev
Subject: [PATCH 2/2] input: keyboard: snvs_pwrkey: Fix missed key press after suspend
Report input event directly on wakeup to ensure no press event is missed
when resuming from suspend.
Fixes: d3dc6e232215 ("input: keyboard: imx: add snvs power key driver")
Signed-off-by: Dong Aisheng <aisheng.dong@....com>
Signed-off-by: Joy Zou <joy.zou@....com>
Signed-off-by: Frank Li <Frank.Li@....com>
---
drivers/input/keyboard/snvs_pwrkey.c | 37 ++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index b352148a0cfb2..a1c04fe8fe05c 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -37,6 +37,7 @@ struct pwrkey_drv_data {
int keycode;
int keystate; /* 1:pressed */
int wakeup;
+ bool suspended;
struct clk *clk;
struct timer_list check_timer;
struct input_dev *input;
@@ -79,6 +80,18 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id)
pm_wakeup_event(input->dev.parent, 0);
+ /*
+ * Directly report press event in interrupt handler after suspend
+ * to ensure no press event miss.
+ */
+ if (pdata->suspended) {
+ pdata->keystate = 1;
+ input_event(input, EV_KEY, pdata->keycode, 1);
+ input_sync(input);
+ /* Fire at most once per suspend/resume cycle */
+ pdata->suspended = false;
+ }
+
regmap_read(pdata->snvs, SNVS_LPSR_REG, &lp_status);
if (lp_status & SNVS_LPSR_SPO) {
if (pdata->minor_rev == 0) {
@@ -236,6 +249,29 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
return 0;
}
+static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
+
+ pdata->suspended = true;
+
+ return 0;
+}
+
+static int __maybe_unused imx_snvs_pwrkey_resume(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
+
+ pdata->suspended = false;
+
+ return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(imx_snvs_pwrkey_pm_ops, imx_snvs_pwrkey_suspend,
+ imx_snvs_pwrkey_resume);
+
static const struct of_device_id imx_snvs_pwrkey_ids[] = {
{ .compatible = "fsl,sec-v4.0-pwrkey" },
{ /* sentinel */ }
@@ -245,6 +281,7 @@ MODULE_DEVICE_TABLE(of, imx_snvs_pwrkey_ids);
static struct platform_driver imx_snvs_pwrkey_driver = {
.driver = {
.name = "snvs_pwrkey",
+ .pm = &imx_snvs_pwrkey_pm_ops,
.of_match_table = imx_snvs_pwrkey_ids,
},
.probe = imx_snvs_pwrkey_probe,
--
2.34.1
Powered by blists - more mailing lists