[PATCH 0/4] rockchip: Migrate to use DM_USB_GADGET on RK3328

Jonas Karlman jonas at kwiboo.se
Tue Feb 27 00:08:12 CET 2024


USB gadget is not working fully as expected on RK3328, it uses a
board_usb_init() function to initialize the DWC2 OTG port, as a result
the USB2PHY driver never gets invoked. An issue is that the USB_DWC2
driver is enabled and also gets loaded for the OTG port. A side effect
of that is that the board will freeze if USB gadget is started after USB
host have been stopped, the USB2PHY driver puts the OTG port in suspend
mode on exit.

To improve the situation this series changes to only enable one of
USB_DWC2 (host) or DWC2_OTG (peripheral) depending on most likely usage
of the port. It also migrates to use DM_USB_GADGET instead of
board_usb_init().

First patch fixes and add Product ID for supported Rockchip SoCs.

Second patch prepare board.c for use of DM_USB_GADGET with DWC2_OTG.

Third patch add a g_dnl_bind_fixup() to configure a different Product ID
when UMS is used.

Final patch updates u-boot.dtsi and defconfigs to only use USB_DWC2 for
host or migrate to use DM_USB_GADGET with DWC2_OTG for peripheral. UMS
and ROCKUSB is enabled for all boards with otg port in peripheral mode.

Hopefully current incompatibility between having USB_DWC2, DWC2_OTG and
USB_DWC3_GADGET enabled together is something that could be improved on
in a future series.

Following have been tested on a Rock64, ROC-RK3328-CC, Rock Pi E and
Orange Pi R1 Plus LTS:
- USB host on all host ports: usb start && usb tree && usb stop
- UMS on otg port: ums 0 mmc 1
- RockUSB on otg port: rockusb 0 mmc 1

This series depends on the following series and patches:
- rockchip: rk3328: Update defconfigs, DTs and enable boot from SPI [1]
- rockchip: Read cpuid and generate MAC address from efuse for RK3328
  and RK3399 [2]
- usb: dwc3-generic: Fix build errors when USB_DWC3_GADGET is disabled [3]
- phy: rockchip-inno-usb2: Write to correct GRF [4]

The copy of the series and all its depends can also be found at [5].

[1] https://patchwork.ozlabs.org/cover/1900345/
[2] https://patchwork.ozlabs.org/cover/1897743/
[3] https://patchwork.ozlabs.org/patch/1903946/
[4] https://patchwork.ozlabs.org/cover/1903987/
[5] https://github.com/Kwiboo/u-boot-rockchip/commits/rk3328-gadget-v1

Jonas Karlman (4):
  rockchip: Update the default USB Product ID Kconfig option
  rockchip: board: Prepare for use of DM_USB_GADGET with DWC2_OTG
  rockchip: board: Use a common USB Product ID for UMS
  rockchip: Migrate to use DM_USB_GADGET on RK3328

 arch/arm/dts/rk3328-nanopi-r2s-u-boot.dtsi    |  4 ++
 .../rk3328-orangepi-r1-plus-lts-u-boot.dtsi   |  4 ++
 .../dts/rk3328-orangepi-r1-plus-u-boot.dtsi   |  4 ++
 arch/arm/dts/rk3328-roc-cc-u-boot.dtsi        |  4 ++
 arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi     |  9 ++++
 arch/arm/dts/rk3328-rock64-u-boot.dtsi        |  4 ++
 arch/arm/dts/rk3328-u-boot.dtsi               |  4 --
 arch/arm/dts/rk3328.dtsi                      | 41 ++++++++-----------
 arch/arm/mach-rockchip/board.c                | 19 ++++++++-
 configs/evb-rk3328_defconfig                  |  5 ++-
 configs/nanopi-r2c-plus-rk3328_defconfig      |  5 ++-
 configs/nanopi-r2c-rk3328_defconfig           |  5 ++-
 configs/nanopi-r2s-rk3328_defconfig           |  5 ++-
 configs/orangepi-r1-plus-lts-rk3328_defconfig |  5 ++-
 configs/orangepi-r1-plus-rk3328_defconfig     |  5 ++-
 configs/roc-cc-rk3328_defconfig               |  7 ----
 configs/rock-pi-e-rk3328_defconfig            |  7 ----
 configs/rock64-rk3328_defconfig               |  6 ---
 drivers/usb/gadget/Kconfig                    | 15 +++++--
 19 files changed, 99 insertions(+), 59 deletions(-)

-- 
2.43.0



More information about the U-Boot mailing list