MLK-13638-3 extcon: usb-gpio: add pinctrl operation during system PM
authorPeter Chen <peter.chen@nxp.com>
Thu, 22 Dec 2016 03:11:31 +0000 (11:11 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:58:19 +0000 (14:58 -0500)
At some systems, the pinctrl setting will be lost or needs to
set as "sleep" state to save power consumption. So, we need to
configure pinctrl as "sleep" state when system enters suspend,
and as "default" state after system resumes. In this way, the
pinctrl value can be recovered as "default" state after resuming.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
drivers/extcon/extcon-usb-gpio.c

index a27d350..a72ad07 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of_gpio.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_wakeirq.h>
 #include <linux/slab.h>
@@ -176,6 +177,7 @@ static int usb_extcon_suspend(struct device *dev)
         * accessible until resume completes. So disable IRQ.
         */
        disable_irq(info->id_irq);
+       pinctrl_pm_select_sleep_state(dev);
 
        return ret;
 }
@@ -185,6 +187,7 @@ static int usb_extcon_resume(struct device *dev)
        struct usb_extcon_info *info = dev_get_drvdata(dev);
        int ret = 0;
 
+       pinctrl_pm_select_default_state(dev);
        enable_irq(info->id_irq);
        if (!device_may_wakeup(dev))
                queue_delayed_work(system_power_efficient_wq,