From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Markus Niebel <Markus.Niebel@ew.tq-group.com>,
linux-usb@vger.kernel.org,
Alexander Stein <alexander.stein@ew.tq-group.com>
Subject: [PATCH 1/1] usb: dwc3: let role switch handle initial state
Date: Tue, 17 Oct 2023 07:57:26 +0200 [thread overview]
Message-ID: <20231017055726.904133-1-alexander.stein@ew.tq-group.com> (raw)
From: Markus Niebel <Markus.Niebel@ew.tq-group.com>
When we have a role switch device attached, we should not configure our
initial role. Leave this up to the role switch device, that should
detect and signal the initial role.
This fixes situations where a Type-A plug is connected already when the
driver is loaded but the default role is set to none or device. In this
case only an disconnect / reconnect gets the correct mode.
Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
I couldn't find any information whether USB role switch drivers are
supposed to call usb_role_switch_set_role() during their probe.
But this seems sensible, otherwise the actual/initial state is unknown.
drivers/usb/dwc3/drd.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index 039bf241769af..1c2e504a5d8ba 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -496,15 +496,8 @@ static enum usb_role dwc3_usb_role_switch_get(struct usb_role_switch *sw)
static int dwc3_setup_role_switch(struct dwc3 *dwc)
{
struct usb_role_switch_desc dwc3_role_switch = {NULL};
- u32 mode;
dwc->role_switch_default_mode = usb_get_role_switch_default_mode(dwc->dev);
- if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) {
- mode = DWC3_GCTL_PRTCAP_HOST;
- } else {
- dwc->role_switch_default_mode = USB_DR_MODE_PERIPHERAL;
- mode = DWC3_GCTL_PRTCAP_DEVICE;
- }
dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
dwc3_role_switch.set = dwc3_usb_role_switch_set;
@@ -526,7 +519,11 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
}
}
- dwc3_set_mode(dwc, mode);
+ /*
+ * usb_role_switch should implement initial detection and call
+ * dwc3_usb_role_switch_set to get the state machine running
+ */
+
return 0;
}
#else
--
2.34.1
next reply other threads:[~2023-10-17 5:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 5:57 Alexander Stein [this message]
2023-10-20 22:43 ` [PATCH 1/1] usb: dwc3: let role switch handle initial state Thinh Nguyen
2023-10-25 8:05 ` Alexander Stein
2023-10-31 23:28 ` Thinh Nguyen
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=20231017055726.904133-1-alexander.stein@ew.tq-group.com \
--to=alexander.stein@ew.tq-group.com \
--cc=Markus.Niebel@ew.tq-group.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.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