All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: common: usb-conn-gpio: Allow wakeup from system suspend
@ 2022-05-27  6:49 Prashanth K
  2022-05-27  8:56 ` Pavan Kondeti
  0 siblings, 1 reply; 2+ messages in thread
From: Prashanth K @ 2022-05-27  6:49 UTC (permalink / raw)
  To: Matthias Brugger, Greg Kroah-Hartman
  Cc: Pavankumar Kondeti, Pratham Pratap, linux-usb, linux-kernel, Prashanth K

Currently the VBUS/ID detection interrupts are disabled during system
suspend. So the USB cable connect/disconnect event can't wakeup the
system from low power mode. To allow this, we keep these interrupts
enabled and configure them as wakeup capable. This behavior can be
controlled through device wakeup source policy by the user space.

Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
---
 drivers/usb/common/usb-conn-gpio.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c
index 395f9bb..b39c9f1c 100644
--- a/drivers/usb/common/usb-conn-gpio.c
+++ b/drivers/usb/common/usb-conn-gpio.c
@@ -257,6 +257,7 @@ static int usb_conn_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, info);
+	device_set_wakeup_capable(&pdev->dev, true);
 
 	/* Perform initial detection */
 	usb_conn_queue_dwork(info, 0);
@@ -286,6 +287,14 @@ static int __maybe_unused usb_conn_suspend(struct device *dev)
 {
 	struct usb_conn_info *info = dev_get_drvdata(dev);
 
+	if (device_may_wakeup(dev)) {
+		if (info->id_gpiod)
+			enable_irq_wake(info->id_irq);
+		if (info->vbus_gpiod)
+			enable_irq_wake(info->vbus_irq);
+		return 0;
+	}
+
 	if (info->id_gpiod)
 		disable_irq(info->id_irq);
 	if (info->vbus_gpiod)
@@ -300,6 +309,14 @@ static int __maybe_unused usb_conn_resume(struct device *dev)
 {
 	struct usb_conn_info *info = dev_get_drvdata(dev);
 
+	if (device_may_wakeup(dev)) {
+		if (info->id_gpiod)
+			disable_irq_wake(info->id_irq);
+		if (info->vbus_gpiod)
+			disable_irq_wake(info->vbus_irq);
+		return 0;
+	}
+
 	pinctrl_pm_select_default_state(dev);
 
 	if (info->id_gpiod)
-- 
2.7.4


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

* Re: [PATCH] usb: common: usb-conn-gpio: Allow wakeup from system suspend
  2022-05-27  6:49 [PATCH] usb: common: usb-conn-gpio: Allow wakeup from system suspend Prashanth K
@ 2022-05-27  8:56 ` Pavan Kondeti
  0 siblings, 0 replies; 2+ messages in thread
From: Pavan Kondeti @ 2022-05-27  8:56 UTC (permalink / raw)
  To: Prashanth K
  Cc: Matthias Brugger, Greg Kroah-Hartman, Pavankumar Kondeti,
	Pratham Pratap, linux-usb, linux-kernel

On Fri, May 27, 2022 at 12:19:06PM +0530, Prashanth K wrote:
> Currently the VBUS/ID detection interrupts are disabled during system
> suspend. So the USB cable connect/disconnect event can't wakeup the
> system from low power mode. To allow this, we keep these interrupts
> enabled and configure them as wakeup capable. This behavior can be
> controlled through device wakeup source policy by the user space.
> 
> Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
> ---
>  drivers/usb/common/usb-conn-gpio.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c
> index 395f9bb..b39c9f1c 100644
> --- a/drivers/usb/common/usb-conn-gpio.c
> +++ b/drivers/usb/common/usb-conn-gpio.c
> @@ -257,6 +257,7 @@ static int usb_conn_probe(struct platform_device *pdev)
>  	}
>  
>  	platform_set_drvdata(pdev, info);
> +	device_set_wakeup_capable(&pdev->dev, true);
>  
>  	/* Perform initial detection */
>  	usb_conn_queue_dwork(info, 0);
> @@ -286,6 +287,14 @@ static int __maybe_unused usb_conn_suspend(struct device *dev)
>  {
>  	struct usb_conn_info *info = dev_get_drvdata(dev);
>  
> +	if (device_may_wakeup(dev)) {
> +		if (info->id_gpiod)
> +			enable_irq_wake(info->id_irq);
> +		if (info->vbus_gpiod)
> +			enable_irq_wake(info->vbus_irq);
> +		return 0;
> +	}
> +
>  	if (info->id_gpiod)
>  		disable_irq(info->id_irq);
>  	if (info->vbus_gpiod)
> @@ -300,6 +309,14 @@ static int __maybe_unused usb_conn_resume(struct device *dev)
>  {
>  	struct usb_conn_info *info = dev_get_drvdata(dev);
>  
> +	if (device_may_wakeup(dev)) {
> +		if (info->id_gpiod)
> +			disable_irq_wake(info->id_irq);
> +		if (info->vbus_gpiod)
> +			disable_irq_wake(info->vbus_irq);
> +		return 0;
> +	}
> +
>  	pinctrl_pm_select_default_state(dev);
>  
>  	if (info->id_gpiod)

Looks good to me.

Thanks,
Pavan

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

end of thread, other threads:[~2022-05-27  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27  6:49 [PATCH] usb: common: usb-conn-gpio: Allow wakeup from system suspend Prashanth K
2022-05-27  8:56 ` Pavan Kondeti

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.