From: Peter Chen <peter.chen@kernel.org>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Cc: balbi@kernel.org, bjorn.andersson@linaro.org, agross@kernel.org,
gregkh@linuxfoundation.org, jackp@codeaurora.org,
wcheng@codeaurora.org, linux-usb@vger.kernel.org,
linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 2/3] usb: dwc3: Add role switch relay support
Date: Tue, 6 Jul 2021 10:51:30 +0800 [thread overview]
Message-ID: <20210706025130.GA19460@nchen> (raw)
In-Reply-To: <20210704013314.200951-3-bryan.odonoghue@linaro.org>
On 21-07-04 02:33:13, Bryan O'Donoghue wrote:
> Add the ability to relay a role switch message from the core to the parent
> device of the controller.
>
> This is useful for the qcom-dwc3 wrapper which wants to receive role-switch
> notifications in order to waggle internal SoC UTMI signals.
>
> Having the core trigger the parent wrapper has the advantage of keeping the
> connector mechanism agnostic from dwc3 wrapper code and means that any
> other wrapper implementation on any other SoC or architecture need not
> write custom code to find various types of Type-C role switch mechanisms.
If I understand correctly, the call trace like below:
Connector (GPIO/Type-C, usb_role_switch_set_role) -> dwc3 core (func: dwc3_usb_role_switch_set)
-> dwc3 qcom glue (func: dwc3_qcom_usb_role_switch_set)
And, at dts, the property "usb-role-switch" will be at both dwc3 glue and core node
dwc3 core is the connector (GPIO/Type-C)'s role switch
dwc3 glue is the dwc3 core's role switch
right?
Peter
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
> drivers/usb/dwc3/core.h | 2 ++
> drivers/usb/dwc3/drd.c | 10 ++++++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index dccdf13b5f9e..974104cc16f7 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -993,6 +993,7 @@ struct dwc3_scratchpad_array {
> * - USBPHY_INTERFACE_MODE_UTMI
> * - USBPHY_INTERFACE_MODE_UTMIW
> * @role_sw: usb_role_switch handle
> + * @role_sw_relay: usb_role_switch relay handle
> * @role_switch_default_mode: default operation mode of controller while
> * usb role is USB_ROLE_NONE.
> * @usb_psy: pointer to power supply interface.
> @@ -1136,6 +1137,7 @@ struct dwc3 {
> struct notifier_block edev_nb;
> enum usb_phy_interface hsphy_mode;
> struct usb_role_switch *role_sw;
> + struct usb_role_switch *role_sw_relay;
> enum usb_dr_mode role_switch_default_mode;
>
> struct power_supply *usb_psy;
> diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
> index 8fcbac10510c..74293861bd8f 100644
> --- a/drivers/usb/dwc3/drd.c
> +++ b/drivers/usb/dwc3/drd.c
> @@ -507,6 +507,9 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw,
> }
>
> dwc3_set_mode(dwc, mode);
> + if (dwc->role_sw_relay)
> + usb_role_switch_set_role(dwc->role_sw_relay, role);
> +
> return 0;
> }
>
> @@ -563,6 +566,10 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
> if (IS_ERR(dwc->role_sw))
> return PTR_ERR(dwc->role_sw);
>
> + dwc->role_sw_relay = usb_role_switch_get(dwc->dev);
> + if (IS_ERR(dwc->role_sw_relay))
> + return PTR_ERR(dwc->role_sw_relay);
> +
> dwc3_set_mode(dwc, mode);
> return 0;
> }
> @@ -630,6 +637,9 @@ void dwc3_drd_exit(struct dwc3 *dwc)
> {
> unsigned long flags;
>
> + if (dwc->role_sw_relay)
> + usb_role_switch_put(dwc->role_sw_relay);
> +
> if (dwc->role_sw)
> usb_role_switch_unregister(dwc->role_sw);
>
> --
> 2.30.1
>
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2021-07-06 2:51 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-04 1:33 [PATCH 0/3] Implement role-switch notifications from dwc3-drd to dwc3-qcom Bryan O'Donoghue
2021-07-04 1:33 ` [PATCH 1/3] usb: dwc3: dwc3-qcom: Fix typo in the dwc3 vbus override API Bryan O'Donoghue
2021-07-07 5:06 ` Bjorn Andersson
2021-07-04 1:33 ` [PATCH 2/3] usb: dwc3: Add role switch relay support Bryan O'Donoghue
2021-07-06 2:51 ` Peter Chen [this message]
2021-07-06 10:07 ` Bryan O'Donoghue
2021-07-07 5:14 ` Bjorn Andersson
2021-07-07 9:49 ` Bryan O'Donoghue
2021-07-07 9:51 ` Bryan O'Donoghue
2021-07-04 1:33 ` [PATCH 3/3] usb: dwc3: dwc3-qcom: Make dwc3-qcom a role-switch signal recipient Bryan O'Donoghue
2021-07-07 1:57 ` [PATCH 0/3] Implement role-switch notifications from dwc3-drd to dwc3-qcom Peter Chen
2021-07-07 19:03 ` Bjorn Andersson
2021-07-08 3:06 ` Peter Chen
2021-07-08 3:54 ` Bjorn Andersson
2021-07-08 10:17 ` Bryan O'Donoghue
2021-08-24 23:52 ` Bjorn Andersson
2021-08-24 23:58 ` Bryan O'Donoghue
2021-08-25 0:01 ` Bjorn Andersson
2021-08-25 0:17 ` Bryan O'Donoghue
2021-08-24 23:37 ` Bjorn Andersson
2021-08-25 5:51 ` Felipe Balbi
2021-08-25 8:18 ` Bryan O'Donoghue
2021-08-25 15:53 ` Bjorn Andersson
2021-08-25 16:43 ` Heikki Krogerus
2021-08-25 17:04 ` Bjorn Andersson
2021-08-25 17:59 ` Bryan O'Donoghue
2021-08-25 20:06 ` Bjorn Andersson
2021-08-26 6:15 ` Felipe Balbi
2021-09-15 13:53 ` Bjorn Andersson
2021-09-17 12:33 ` Heikki Krogerus
2021-08-25 20:11 ` Dmitry Baryshkov
2021-08-25 12:12 ` Rob Herring
2021-08-25 15:20 ` Felipe Balbi
2021-08-25 13:16 ` Bjorn Andersson
2021-08-25 15:22 ` Felipe Balbi
2021-08-25 16:33 ` Bjorn Andersson
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=20210706025130.GA19460@nchen \
--to=peter.chen@kernel.org \
--cc=agross@kernel.org \
--cc=balbi@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=bryan.odonoghue@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jackp@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=wcheng@codeaurora.org \
/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;
as well as URLs for NNTP newsgroup(s).