arm64: dts: rockchip: Enable USB device mode on rk3588s-roc-pc
Subsystems (2)
PATCH 1/1 arm64: dts: rockchip: Enable USB device mode on rk3588s-roc-pc
From: Fabio Estevam <[email protected]>
The USB3 OTG controller on the ROC-PC can be used in device mode, but the board description only enabled the DWC3 controller and USB2 PHY. The USBDP PHY remained disabled and the controller had no role-switch default, so DWC3 did not register a UDC and USB gadget drivers such as g_mass_storage failed to bind.
Enable the USBDP PHY and describe the controller as a USB role switch with peripheral as the default role. This lets the controller register as a UDC when no external role provider has selected a host role.
Tested on a Firefly Station M3 by binding g_mass_storage to expose the eMMC as a USB mass-storage gadget.
--- arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts +6 -0
@@ -833,6 +833,12 @@ &usb_host0_ohci { &usb_host0_xhci { extcon = <&u2phy0>; + role-switch-default-mode = "peripheral"; + usb-role-switch; + status = "okay"; +}; + +&usbdp_phy0 { status = "okay"; };
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Adding `usb-role-switch` nullifies existing `extcon` functionality, permanently breaking…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Adding usb-role-switch nullifies existing extcon functionality, permanently breaking automatic OTG role switching. --
--- Patch [1]: [PATCH] arm64: dts: rockchip: Enable USB device mode on rk3588s-roc-pc --- commit 5791d34a99b00bf3d67aa350284aa7287f468661
Author: Fabio Estevam <[email protected]>
arm64: dts: rockchip: Enable USB device mode on rk3588s-roc-pc
This commit configures the DWC3 controller on the rk3588s-roc-pc to act as a USB role switch defaulting to peripheral mode. It also enables the USBDP PHY to allow the controller to register as a UDC, enabling USB gadget drivers to bind.
arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts &usb_host0_ohci { · line 817
Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts +2
-0@@ -813,6 +813,12 @@ &usb_host0_ohci { &usb_host0_xhci { extcon = <&u2phy0>; + role-switch-default-mode = "peripheral"; + usb-role-switch;
[Severity: Medium]
Will adding usb-role-switch here nullify the existing extcon functionality and permanently break automatic OTG role switching?
During initialization, DWC3's dwc3_drd_init() unconditionally returns early if the usb-role-switch property is set, which skips the extcon_register_notifier() call entirely.
Because the board's PHY driver (phy-rockchip-inno-usb2) broadcasts ID pin state changes exclusively via extcon and does not implement a usb_role_switch provider, it appears DWC3 will never receive role switch events. Will this cause the OTG port to be permanently locked into peripheral mode, preventing USB host mode from functioning when an OTG cable is attached?
Quoted 2 lines
arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts +2
-0+ status = "okay"; +};
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 11 lines · Fabio Estevam
The USB3 OTG controller on the ROC-PC can be used in device mode, but the board description only enabled the DWC3 controller and USB2 PHY. The USBDP PHY remained disabled and the controller had no role-switch default, so DWC3 did not register a UDC and USB gadget drivers such as
g_mass_storagefailed to bind.Enable the USBDP PHY and describe the controller as a USB role switch with peripheral as the default role. This lets the controller register as a UDC when no external role provider has selected a host role.
[...]
Applied, thanks!
[1/1] arm64: dts: rockchip: Enable USB device mode on rk3588s-roc-pc
commit: 9d1e32bfdda1aef3291e47c2949b3b9978162a5c
Best regards,
Signature · 1 line
Heiko Stuebner <[email protected]>