]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
extcon: axp288: Add wakeup support
authorHans de Goede <hdegoede@redhat.com>
Mon, 23 Mar 2020 21:59:39 +0000 (22:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Apr 2020 07:10:01 +0000 (09:10 +0200)
commit 9c94553099efb2ba873cbdddfd416a8a09d0e5f1 upstream.

On devices with an AXP288, we need to wakeup from suspend when a charger
is plugged in, so that we can do charger-type detection and so that the
axp288-charger driver, which listens for our extcon events, can configure
the input-current-limit accordingly.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/extcon/extcon-axp288.c

index a7f216191493095b8766aa35e95023a63debd235..710a3bb66e958ba7f4c7eb26850ffd83d9fecbc7 100644 (file)
@@ -443,9 +443,40 @@ static int axp288_extcon_probe(struct platform_device *pdev)
        /* Start charger cable type detection */
        axp288_extcon_enable(info);
 
+       device_init_wakeup(dev, true);
+       platform_set_drvdata(pdev, info);
+
+       return 0;
+}
+
+static int __maybe_unused axp288_extcon_suspend(struct device *dev)
+{
+       struct axp288_extcon_info *info = dev_get_drvdata(dev);
+
+       if (device_may_wakeup(dev))
+               enable_irq_wake(info->irq[VBUS_RISING_IRQ]);
+
        return 0;
 }
 
+static int __maybe_unused axp288_extcon_resume(struct device *dev)
+{
+       struct axp288_extcon_info *info = dev_get_drvdata(dev);
+
+       /*
+        * Wakeup when a charger is connected to do charger-type
+        * connection and generate an extcon event which makes the
+        * axp288 charger driver set the input current limit.
+        */
+       if (device_may_wakeup(dev))
+               disable_irq_wake(info->irq[VBUS_RISING_IRQ]);
+
+       return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(axp288_extcon_pm_ops, axp288_extcon_suspend,
+                        axp288_extcon_resume);
+
 static const struct platform_device_id axp288_extcon_table[] = {
        { .name = "axp288_extcon" },
        {},
@@ -457,6 +488,7 @@ static struct platform_driver axp288_extcon_driver = {
        .id_table = axp288_extcon_table,
        .driver = {
                .name = "axp288_extcon",
+               .pm = &axp288_extcon_pm_ops,
        },
 };