@@ -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,