Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 1/3] usb: dwc3: core: Introduce glue callbacks for flattened implementations
Date: Thu, 7 Aug 2025 01:08:44 +0000	[thread overview]
Message-ID: <20250807010844.sudnpnule6k7vdn4@synopsys.com> (raw)
In-Reply-To: <20250806095828.1582917-2-krishna.kurapati@oss.qualcomm.com>

On Wed, Aug 06, 2025, Krishna Kurapati wrote:
> In certain situations like role switching, the glue layers need to be
> informed of these events, so that they can take any necessary action.
> But in non-flattened implementations, the glue drivers have no data on
> when the core driver probe was successful post invoking of_platform_
> populate. Now that the core driver supports flattened implementations
> as well, introduce vendor callbacks that can be passed on from glue to
> core before invoking dwc3_core_probe.
> 
> Introduce callbacks to notify glue layer of role_switch and run_stop
> changes. These can be used by flattened implementation of Qualcomm
> glue layer to generate connect/disconnect events in controller during
> cable connect and run stop modifications by udc in device mode.
> 
> Signed-off-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
> ---
>  drivers/usb/dwc3/core.c   |  1 +
>  drivers/usb/dwc3/core.h   | 26 ++++++++++++++++++++++++++
>  drivers/usb/dwc3/drd.c    |  1 +
>  drivers/usb/dwc3/gadget.c |  1 +
>  4 files changed, 29 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 8002c23a5a02..392ba86c69f5 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -2351,6 +2351,7 @@ static int dwc3_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	dwc->dev = &pdev->dev;
> +	dwc->glue_ops = NULL;
>  
>  	probe_data.dwc = dwc;
>  	probe_data.res = res;
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index d5b985fa12f4..095311e636c5 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -992,6 +992,17 @@ struct dwc3_scratchpad_array {
>  	__le64	dma_adr[DWC3_MAX_HIBER_SCRATCHBUFS];
>  };
>  
> +/**
> + * struct dwc3_glue_ops - The ops indicate the notifications that
> + *				need to be passed on to glue layer
> + * @notify_set_role: Notify glue of role switch notifications
> + * @notify_run_stop: Notify run stop enable/disable information to glue

Update the names.

> + */
> +struct dwc3_glue_ops {
> +	void	(*pre_set_role)(struct dwc3 *dwc, enum usb_role role);
> +	void	(*pre_run_stop)(struct dwc3 *dwc, bool is_on);
> +};
> +
>  /**
>   * struct dwc3 - representation of our controller
>   * @drd_work: workqueue used for role swapping
> @@ -1168,6 +1179,7 @@ struct dwc3_scratchpad_array {
>   * @wakeup_pending_funcs: Indicates whether any interface has requested for
>   *			 function wakeup in bitmap format where bit position
>   *			 represents interface_id.
> + * @glue_ops: Vendor callbacks for flattened device implementations.

Update the placement.

>   */
>  struct dwc3 {
>  	struct work_struct	drd_work;
> @@ -1197,6 +1209,8 @@ struct dwc3 {
>  	struct usb_gadget	*gadget;
>  	struct usb_gadget_driver *gadget_driver;
>  
> +	const struct dwc3_glue_ops	*glue_ops;
> +
>  	struct clk		*bus_clk;
>  	struct clk		*ref_clk;
>  	struct clk		*susp_clk;
> @@ -1614,6 +1628,18 @@ void dwc3_event_buffers_cleanup(struct dwc3 *dwc);
>  int dwc3_core_soft_reset(struct dwc3 *dwc);
>  void dwc3_enable_susphy(struct dwc3 *dwc, bool enable);
>  
> +static inline void dwc3_pre_set_role(struct dwc3 *dwc, enum usb_role role)
> +{
> +	if (dwc->glue_ops && dwc->glue_ops->pre_set_role)
> +		dwc->glue_ops->pre_set_role(dwc, role);
> +}
> +
> +static inline void dwc3_pre_run_stop(struct dwc3 *dwc, bool is_on)
> +{
> +	if (dwc->glue_ops && dwc->glue_ops->pre_run_stop)
> +		dwc->glue_ops->pre_run_stop(dwc, is_on);
> +}
> +
>  #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
>  int dwc3_host_init(struct dwc3 *dwc);
>  void dwc3_host_exit(struct dwc3 *dwc);
> diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
> index 7977860932b1..4c91240eb429 100644
> --- a/drivers/usb/dwc3/drd.c
> +++ b/drivers/usb/dwc3/drd.c
> @@ -464,6 +464,7 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw,
>  		break;
>  	}
>  
> +	dwc3_pre_set_role(dwc, role);
>  	dwc3_set_mode(dwc, mode);
>  	return 0;
>  }
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 25db36c63951..999b2e436622 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2658,6 +2658,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on)
>  		dwc->pullups_connected = false;
>  	}
>  
> +	dwc3_pre_run_stop(dwc, is_on);
>  	dwc3_gadget_dctl_write_safe(dwc, reg);
>  
>  	do {
> -- 
> 2.34.1
> 

The rest looks fine here.

BR,
Thinh

  reply	other threads:[~2025-08-07  1:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06  9:58 [PATCH v3 0/3] usb: dwc3: Modify role-switching QC drd usb controllers Krishna Kurapati
2025-08-06  9:58 ` [PATCH v3 1/3] usb: dwc3: core: Introduce glue callbacks for flattened implementations Krishna Kurapati
2025-08-07  1:08   ` Thinh Nguyen [this message]
2025-08-06  9:58 ` [PATCH v3 2/3] usb: dwc3: qcom: Implement glue callbacks to facilitate runtime suspend Krishna Kurapati
2025-08-06 10:32   ` Konrad Dybcio
2025-08-07  5:17     ` Krishna Kurapati
2025-08-07 12:56       ` Konrad Dybcio
2025-08-06  9:58 ` [PATCH v3 3/3] usb: xhci: plat: Facilitate using autosuspend for xhci plat devices Krishna Kurapati

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=20250807010844.sudnpnule6k7vdn4@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=bjorn.andersson@oss.qualcomm.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=krishna.kurapati@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.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