public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: "Peter Chen (CIX)" <peter.chen@kernel.org>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: gregkh@linuxfoundation.org, jun.li@nxp.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev
Subject: Re: [PATCH 1/3] usb: chipidea: udc: add a helper ci_udc_enable_vbus_irq()
Date: Wed, 22 Apr 2026 09:17:22 +0800	[thread overview]
Message-ID: <aegholg3FV38sLts@nchen-desktop> (raw)
In-Reply-To: <20260421082436.1264442-1-xu.yang_2@nxp.com>

On 26-04-21 16:24:34, Xu Yang wrote:
> The VBUS interrupt is configured in multiple places, add a helper function
> ci_udc_enable_vbus_irq() to simplify the code.
> 
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

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

Peter
> ---
>  drivers/usb/chipidea/udc.c | 32 +++++++++++++++++---------------
>  1 file changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index f2de86d0ce40..d4277d6611ee 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -1835,6 +1835,20 @@ static const struct usb_ep_ops usb_ep_ops = {
>   * GADGET block
>   *****************************************************************************/
>  
> +static void ci_udc_enable_vbus_irq(struct ci_hdrc *ci, bool enable)
> +{
> +	u32 reg = OTGSC_BSVIS;
> +
> +	if (!ci->is_otg)
> +		return;
> +
> +	if (enable)
> +		reg |= OTGSC_BSVIE;
> +
> +	/* Clear pending BSVIS and enable/disable BSVIE */
> +	hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, reg);
> +}
> +
>  static int ci_udc_get_frame(struct usb_gadget *_gadget)
>  {
>  	struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
> @@ -2352,23 +2366,13 @@ static int udc_id_switch_for_device(struct ci_hdrc *ci)
>  		pinctrl_select_state(ci->platdata->pctl,
>  				     ci->platdata->pins_device);
>  
> -	if (ci->is_otg)
> -		/* Clear and enable BSV irq */
> -		hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
> -					OTGSC_BSVIS | OTGSC_BSVIE);
> -
> +	ci_udc_enable_vbus_irq(ci, true);
>  	return 0;
>  }
>  
>  static void udc_id_switch_for_host(struct ci_hdrc *ci)
>  {
> -	/*
> -	 * host doesn't care B_SESSION_VALID event
> -	 * so clear and disable BSV irq
> -	 */
> -	if (ci->is_otg)
> -		hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS);
> -
> +	ci_udc_enable_vbus_irq(ci, false);
>  	ci->vbus_active = 0;
>  
>  	if (ci->platdata->pins_device && ci->platdata->pins_default)
> @@ -2395,9 +2399,7 @@ static void udc_suspend(struct ci_hdrc *ci)
>  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);
> +		ci_udc_enable_vbus_irq(ci, true);
>  		if (ci->vbus_active)
>  			usb_gadget_vbus_disconnect(&ci->gadget);
>  	} else if (ci->vbus_active && ci->driver &&
> -- 
> 2.34.1
> 

-- 

Best regards,
Peter

      parent reply	other threads:[~2026-04-22  1:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21  8:24 [PATCH 1/3] usb: chipidea: udc: add a helper ci_udc_enable_vbus_irq() Xu Yang
2026-04-21  8:24 ` [PATCH 2/3] usb: chipidea: udc: support dynamic gadget add/remove Xu Yang
2026-04-22  2:58   ` Peter Chen (CIX)
2026-04-22  3:05   ` Frank Li
2026-04-21  8:24 ` [PATCH 3/3] usb: chipidea: core: convert ci_role_switch to local variable Xu Yang
2026-04-22  2:29   ` Frank Li
2026-04-22  2:59   ` Peter Chen (CIX)
2026-04-21  9:28 ` [PATCH 1/3] usb: chipidea: udc: add a helper ci_udc_enable_vbus_irq() Frank Li
2026-04-22  1:17 ` Peter Chen (CIX) [this message]

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=aegholg3FV38sLts@nchen-desktop \
    --to=peter.chen@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox