diff mbox series

[v2,3/8] usb: chipidea: host: add suspend/resume support for host controller

Message ID 20221013151442.3262951-4-xu.yang_2@nxp.com (mailing list archive)
State Accepted
Commit 2f64d6a6cdfbd992e8a8c481ebf79bfa9a71325b
Headers show
Series add power lost support during system suspend/resume | expand

Commit Message

Xu Yang Oct. 13, 2022, 3:14 p.m. UTC
The controller's power may be powered off during system suspend. This
will add suspend/resume support when the controller suffers power lost.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Changes since v1:
- wrap suspend/resume functions with CONFIG_PM_SLEEP.
---
 drivers/usb/chipidea/host.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Peter Chen Oct. 17, 2022, 1:06 a.m. UTC | #1
On 22-10-13 23:14:37, Xu Yang wrote:
> The controller's power may be powered off during system suspend. This
> will add suspend/resume support when the controller suffers power lost.
> 
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> 
> ---
> Changes since v1:
> - wrap suspend/resume functions with CONFIG_PM_SLEEP.
> ---
>  drivers/usb/chipidea/host.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
> index bc3634a54c6b..ebe7400243b1 100644
> --- a/drivers/usb/chipidea/host.c
> +++ b/drivers/usb/chipidea/host.c
> @@ -459,6 +459,18 @@ static void ci_hdrc_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
>  	ci_hdrc_free_dma_aligned_buffer(urb);
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static void ci_hdrc_host_suspend(struct ci_hdrc *ci)
> +{
> +	ehci_suspend(ci->hcd, device_may_wakeup(ci->dev));
> +}
> +
> +static void ci_hdrc_host_resume(struct ci_hdrc *ci, bool power_lost)
> +{
> +	ehci_resume(ci->hcd, power_lost);
> +}
> +#endif
> +

This code seems doesn't the same with the code at source.codeaurora.org,
please make sure it could work for all platforms.

Peter

>  int ci_hdrc_host_init(struct ci_hdrc *ci)
>  {
>  	struct ci_role_driver *rdrv;
> @@ -472,6 +484,10 @@ int ci_hdrc_host_init(struct ci_hdrc *ci)
>  
>  	rdrv->start	= host_start;
>  	rdrv->stop	= host_stop;
> +#ifdef CONFIG_PM_SLEEP
> +	rdrv->suspend	= ci_hdrc_host_suspend;
> +	rdrv->resume	= ci_hdrc_host_resume;
> +#endif
>  	rdrv->irq	= host_irq;
>  	rdrv->name	= "host";
>  	ci->roles[CI_ROLE_HOST] = rdrv;
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index bc3634a54c6b..ebe7400243b1 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -459,6 +459,18 @@  static void ci_hdrc_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
 	ci_hdrc_free_dma_aligned_buffer(urb);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static void ci_hdrc_host_suspend(struct ci_hdrc *ci)
+{
+	ehci_suspend(ci->hcd, device_may_wakeup(ci->dev));
+}
+
+static void ci_hdrc_host_resume(struct ci_hdrc *ci, bool power_lost)
+{
+	ehci_resume(ci->hcd, power_lost);
+}
+#endif
+
 int ci_hdrc_host_init(struct ci_hdrc *ci)
 {
 	struct ci_role_driver *rdrv;
@@ -472,6 +484,10 @@  int ci_hdrc_host_init(struct ci_hdrc *ci)
 
 	rdrv->start	= host_start;
 	rdrv->stop	= host_stop;
+#ifdef CONFIG_PM_SLEEP
+	rdrv->suspend	= ci_hdrc_host_suspend;
+	rdrv->resume	= ci_hdrc_host_resume;
+#endif
 	rdrv->irq	= host_irq;
 	rdrv->name	= "host";
 	ci->roles[CI_ROLE_HOST] = rdrv;