Skip to contentSkip to conversation

arm64: dts: rockchip: Enable USB device mode on rk3399-roc-pc-plus

PATCH New Fabio Estevam 2 participants 2 messages Jul 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: dts: rockchip: Enable USB device mode on rk3399-roc-pc-plus

From: Fabio Estevam <[email protected]>

The USB3 OTG controller on the rk3399-roc-pc-plus is forced to host mode. As a result, it does not register a UDC and USB gadget drivers fail with:

UDC core: g_mass_storage: couldn't find an available UDC

Describe the controller as a USB role switch and select peripheral as the default role. This makes DWC3 register a UDC when no external role provider has selected a host role, while retaining OTG operation and both the USB2 and USB3 PHYs inherited from the SoC dtsi.

Tested by binding g_mass_storage and exposing the onboard eMMC to a Linux host.

Fixes 6d9a7bd6a13c ("arm64: dts: rockchip: add support for Firefly ROC-RK3399-PC-PLUS")
---
 arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts +3 -1
index 7e8039b19be7..c733429fd5d9 100644
@@ -270,7 +270,9 @@ bluetooth {
 };
 
 &usbdrd_dwc3_0 {
-	dr_mode = "host";
+	dr_mode = "otg";
+	role-switch-default-mode = "peripheral";
+	usb-role-switch;
 	status = "okay";
 };
 
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Adding `usb-role-switch` breaks existing host mode and automatic OTG role switching for the DWC3…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Adding usb-role-switch breaks existing host mode and automatic OTG role switching for the DWC3 controller due to a missing OF graph connection. --

--- Patch [1]: [PATCH] arm64: dts: rockchip: Enable USB device mode on rk3399-roc-pc-plus --- commit 083559b8c4d210ad85e3dc07a4f89e6cd4079c56
Author: Fabio Estevam <[email protected]>

arm64: dts: rockchip: Enable USB device mode on rk3399-roc-pc-plus

This commit describes the DWC3 controller as a USB role switch and selects peripheral as the default role. This allows DWC3 to register a UDC while retaining OTG operation.

Quoted 3 lines
arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts +0 -0

[ ... ]

arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts &uart0 { · line 208

Quoted 8 lines
arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts +3 -1
@@ -203,7 +203,9 @@ &uart0 {
 };
 
 &usbdrd_dwc3_0 {
-	dr_mode = "host";
+	dr_mode = "otg";
+	role-switch-default-mode = "peripheral";
+	usb-role-switch;

[Severity: High]
Does adding the usb-role-switch property here break existing host mode functionality on the Type-C port?

When usb-role-switch is present, dwc3_drd_init() bypasses its internal hardware OTG initialization and waits indefinitely for a software role switch event.

Without an OF graph connection (a port/endpoint mapping) from the fusb0 Type-C controller to this dwc3 node, the tcpm framework won't be able to locate the USB role switch via fwnode_usb_role_switch_get() when a user plugs in a host adapter.

As a result, the role switch lookup fails and the controller might get permanently stuck in the default peripheral mode.

Should an OF graph connection be added between the Type-C controller and this dwc3 node so the role switch events can be delivered correctly?

Quoted 2 lines
arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts +0 -0
 	status = "okay";
 };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1