From: Peter Chen Date: Wed, 4 Jan 2017 07:19:51 +0000 (+0800) Subject: extcon: usb-gpio: Add pinctrl operation during system PM X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=bcb7440e76a96c8a244bd683142a38f7d5cecb93;p=linux.git extcon: usb-gpio: Add pinctrl operation during system PM 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 Signed-off-by: Chanwoo Choi --- diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c index d589c5feff3d7..a5e1882b4ca66 100644 --- a/drivers/extcon/extcon-usb-gpio.c +++ b/drivers/extcon/extcon-usb-gpio.c @@ -27,6 +27,7 @@ #include #include #include +#include #define USB_GPIO_DEBOUNCE_MS 20 /* ms */ @@ -245,6 +246,9 @@ static int usb_extcon_suspend(struct device *dev) if (info->vbus_gpiod) disable_irq(info->vbus_irq); + if (!device_may_wakeup(dev)) + pinctrl_pm_select_sleep_state(dev); + return ret; } @@ -253,6 +257,9 @@ static int usb_extcon_resume(struct device *dev) struct usb_extcon_info *info = dev_get_drvdata(dev); int ret = 0; + if (!device_may_wakeup(dev)) + pinctrl_pm_select_default_state(dev); + if (device_may_wakeup(dev)) { if (info->id_gpiod) { ret = disable_irq_wake(info->id_irq);