All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@kernel.org>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: jun.li@nxp.com, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org, linux-imx@nxp.com
Subject: Re: [PATCH v2 4/8] usb: chipidea: udc: add suspend/resume support for device controller
Date: Mon, 17 Oct 2022 09:07:03 +0800	[thread overview]
Message-ID: <20221017010703.GG12701@nchen-desktop> (raw)
In-Reply-To: <20221013151442.3262951-5-xu.yang_2@nxp.com>

On 22-10-13 23:14:38, 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>
> 

Acked-by: Peter Chen <peter.chen@kernel.org>

Peter
> ---
> Changes since v1:
> - wrap suspend/resume functions with CONFIG_PM_SLEEP.
> ---
>  drivers/usb/chipidea/udc.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index 8c3e3a635ac2..54c09245ad05 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -2181,6 +2181,34 @@ static void udc_id_switch_for_host(struct ci_hdrc *ci)
>  				     ci->platdata->pins_default);
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static void udc_suspend(struct ci_hdrc *ci)
> +{
> +	/*
> +	 * Set OP_ENDPTLISTADDR to be non-zero for
> +	 * checking if controller resume from power lost
> +	 * in non-host mode.
> +	 */
> +	if (hw_read(ci, OP_ENDPTLISTADDR, ~0) == 0)
> +		hw_write(ci, OP_ENDPTLISTADDR, ~0, ~0);
> +}
> +
> +static void udc_resume(struct ci_hdrc *ci, bool power_lost)
> +{
> +	if (power_lost) {
> +		if (ci->is_otg)
> +			hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
> +					OTGSC_BSVIS | OTGSC_BSVIE);
> +		if (ci->vbus_active)
> +			usb_gadget_vbus_disconnect(&ci->gadget);
> +	}
> +
> +	/* Restore value 0 if it was set for power lost check */
> +	if (hw_read(ci, OP_ENDPTLISTADDR, ~0) == 0xFFFFFFFF)
> +		hw_write(ci, OP_ENDPTLISTADDR, ~0, 0);
> +}
> +#endif
> +
>  /**
>   * ci_hdrc_gadget_init - initialize device related bits
>   * @ci: the controller
> @@ -2201,6 +2229,10 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci)
>  
>  	rdrv->start	= udc_id_switch_for_device;
>  	rdrv->stop	= udc_id_switch_for_host;
> +#ifdef CONFIG_PM_SLEEP
> +	rdrv->suspend	= udc_suspend;
> +	rdrv->resume	= udc_resume;
> +#endif
>  	rdrv->irq	= udc_irq;
>  	rdrv->name	= "gadget";
>  
> -- 
> 2.34.1
> 

-- 

Thanks,
Peter Chen

  reply	other threads:[~2022-10-17  1:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 15:14 [PATCH v2 0/8] add power lost support during system suspend/resume Xu Yang
2022-10-13 15:14 ` [PATCH v2 1/8] usb: chipidea: core: add controller resume support when controller is powered off Xu Yang
2022-10-17  0:56   ` Peter Chen
2022-10-25 13:47   ` Conor Dooley
2022-10-26  2:50     ` [EXT] " Xu Yang
2022-10-13 15:14 ` [PATCH v2 2/8] usb: chipidea: core: handle suspend/resume for each role Xu Yang
2022-10-17  0:57   ` Peter Chen
2022-10-13 15:14 ` [PATCH v2 3/8] usb: chipidea: host: add suspend/resume support for host controller Xu Yang
2022-10-17  1:06   ` Peter Chen
2022-10-13 15:14 ` [PATCH v2 4/8] usb: chipidea: udc: add suspend/resume support for device controller Xu Yang
2022-10-17  1:07   ` Peter Chen [this message]
2022-10-13 15:14 ` [PATCH v2 5/8] usb: chipidea: usbmisc: group usbmisc operations for PM Xu Yang
2022-10-13 15:14 ` [PATCH v2 6/8] usb: chipidea: usbmisc: add power lost check for imx6sx Xu Yang
2022-10-13 15:14 ` [PATCH v2 7/8] usb: chipidea: usbmisc: add power lost check for imx7d Xu Yang
2022-10-13 15:14 ` [PATCH v2 8/8] usb: chipidea: usbmisc: add power lost check for imx7ulp Xu Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221017010703.GG12701@nchen-desktop \
    --to=peter.chen@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jun.li@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=xu.yang_2@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.