All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] extcon: usb-gpio: add pinctrl operation during system PM
@ 2017-01-04  7:19 ` Peter Chen
  2017-01-06  8:30   ` Chanwoo Choi
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Chen @ 2017-01-04  7:19 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi; +Cc: rogerq, linux-kernel, Peter Chen

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>
---
Changes for v2:
- Add header file for pinctrl to avoid build error
- Only set pin as "sleep" state when the wakeup is not requested

 drivers/extcon/extcon-usb-gpio.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index d589c5f..a5e1882 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/acpi.h>
+#include <linux/pinctrl/consumer.h>
 
 #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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 1/1] extcon: usb-gpio: add pinctrl operation during system PM
  2017-01-04  7:19 ` [PATCH v2 1/1] extcon: usb-gpio: add pinctrl operation during system PM Peter Chen
@ 2017-01-06  8:30   ` Chanwoo Choi
  0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2017-01-06  8:30 UTC (permalink / raw)
  To: Peter Chen, myungjoo.ham; +Cc: rogerq, linux-kernel

Hi Peter,

On 2017년 01월 04일 16:19, Peter Chen wrote:
> 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>
> ---
> Changes for v2:
> - Add header file for pinctrl to avoid build error
> - Only set pin as "sleep" state when the wakeup is not requested
> 
>  drivers/extcon/extcon-usb-gpio.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
S/W Center, Samsung Electronics

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-06  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170104071934epcas4p390f218107287b6096a6fe861ea730c31@epcas4p3.samsung.com>
2017-01-04  7:19 ` [PATCH v2 1/1] extcon: usb-gpio: add pinctrl operation during system PM Peter Chen
2017-01-06  8:30   ` Chanwoo Choi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.