3ff7c26
From fbac4c05ec1d7c2d949f50baf1e934cbfbb6a494 Mon Sep 17 00:00:00 2001
3ff7c26
From: Hans de Goede <hdegoede@redhat.com>
3ff7c26
Date: Mon, 17 Apr 2017 22:06:25 +0200
3ff7c26
Subject: [PATCH 06/16] Input: axp20x-pek - Add wakeup support
3ff7c26
3ff7c26
At least on devices with the AXP288 PMIC the device is expected to
3ff7c26
wakeup from suspend when the power-button gets pressed, add support
3ff7c26
for this.
3ff7c26
3ff7c26
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
3ff7c26
---
3ff7c26
 drivers/input/misc/axp20x-pek.c | 28 ++++++++++++++++++++++++++++
3ff7c26
 1 file changed, 28 insertions(+)
3ff7c26
3ff7c26
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
3ff7c26
index 400869e61a06..5f16fceaae83 100644
3ff7c26
--- a/drivers/input/misc/axp20x-pek.c
3ff7c26
+++ b/drivers/input/misc/axp20x-pek.c
3ff7c26
@@ -253,6 +253,9 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
3ff7c26
 		return error;
3ff7c26
 	}
3ff7c26
 
3ff7c26
+	if (axp20x_pek->axp20x->variant == AXP288_ID)
3ff7c26
+		enable_irq_wake(axp20x_pek->irq_dbr);
3ff7c26
+
3ff7c26
 	return 0;
3ff7c26
 }
3ff7c26
 
3ff7c26
@@ -331,10 +334,35 @@ static int axp20x_pek_probe(struct platform_device *pdev)
3ff7c26
 	return 0;
3ff7c26
 }
3ff7c26
 
3ff7c26
+static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
3ff7c26
+{
3ff7c26
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
3ff7c26
+
3ff7c26
+	if (axp20x_pek->axp20x->variant != AXP288_ID)
3ff7c26
+		return 0;
3ff7c26
+
3ff7c26
+	/*
3ff7c26
+	 * Clear interrupts from button presses during suspend, to avoid
3ff7c26
+	 * a wakeup power-button press getting reported to userspace.
3ff7c26
+	 */
3ff7c26
+	regmap_write(axp20x_pek->axp20x->regmap,
3ff7c26
+		     AXP20X_IRQ1_STATE + AXP288_IRQ_POKN / 8,
3ff7c26
+		     BIT(AXP288_IRQ_POKN % 8));
3ff7c26
+
3ff7c26
+	return 0;
3ff7c26
+}
3ff7c26
+
3ff7c26
+const struct dev_pm_ops axp20x_pek_pm_ops = {
3ff7c26
+#ifdef CONFIG_PM_SLEEP
3ff7c26
+	.resume_noirq = axp20x_pek_resume_noirq,
3ff7c26
+#endif
3ff7c26
+};
3ff7c26
+
3ff7c26
 static struct platform_driver axp20x_pek_driver = {
3ff7c26
 	.probe		= axp20x_pek_probe,
3ff7c26
 	.driver		= {
3ff7c26
 		.name		= "axp20x-pek",
3ff7c26
+		.pm		= &axp20x_pek_pm_ops,
3ff7c26
 	},
3ff7c26
 };
3ff7c26
 module_platform_driver(axp20x_pek_driver);
3ff7c26
-- 
3ff7c26
2.13.0
3ff7c26