rockchip: Migrate to use DM_USB_GADGET on RK3328
Subsystems (4)
cover rockchip: Migrate to use DM_USB_GADGET on RK3328
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(-)
Signature · 1 line
2.43.0
PATCH 1/4 rockchip: Update the default USB Product ID value
RK3036 is using the USB product id normally used by RK3066B, and RK3328 is using the product id normally used by RK3368.
Fix this and update the default USB_GADGET_PRODUCT_NUM Kconfig option for remaining supported Rockchip SoCs to match the product id used in Mask ROM mode. Also remove a reference to the unknown ROCKCHIP_RK3229 symbol.
--- drivers/usb/gadget/Kconfig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/usb/gadget/Kconfig +12 -3
@@ -70,12 +70,21 @@ config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" default 0x701a if ARCH_TEGRA default 0x1010 if ARCH_SUNXI - default 0x310a if ROCKCHIP_RK3036 + default 0x110a if ROCKCHIP_RV1108 + default 0x110b if ROCKCHIP_RV1126 default 0x300a if ROCKCHIP_RK3066 + default 0x301a if ROCKCHIP_RK3036 + default 0x310b if ROCKCHIP_RK3188 default 0x310c if ROCKCHIP_RK3128 - default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 - default 0x330a if ROCKCHIP_RK3328 + default 0x320a if ROCKCHIP_RK3288 + default 0x320b if ROCKCHIP_RK322X + default 0x320c if ROCKCHIP_RK3328 + default 0x330a if ROCKCHIP_RK3368 default 0x330c if ROCKCHIP_RK3399 + default 0x330d if ROCKCHIP_PX30 + default 0x330e if ROCKCHIP_RK3308 + default 0x350a if ROCKCHIP_RK3568 + default 0x350b if ROCKCHIP_RK3588 default 0x0 help Product ID of the USB device emulated, reported to the host device.
Signature · 1 line
2.43.0
Re: [PATCH 1/4] rockchip: Update the default USB Product ID value
Hi Jonas,
Thanks for your patch.
Quoted 7 lines · Jonas Karlman
RK3036 is using the USB product id normally used by RK3066B, and RK3328 is using the product id normally used by RK3368.
Fix this and update the default
USB_GADGET_PRODUCT_NUMKconfigoption for remaining supported Rockchip SoCs to match the product id used in Mask ROM mode. Also remove a reference to the unknownROCKCHIP_RK3229symbol.
RK3229 belongs to RK322X which is reuse with RK3228.
Note that this ID is used for rockusb gadget, if work as mass storage, it should use other
ID, or else it will confuse the driver in host side, eg. the Windows driver may not able to
recognize the device if using two different gadget type with the same ID.
Thanks,
- Kever
Quoted 35 lines
Signed-off-by Jonas Karlman <[email protected]>--- drivers/usb/gadget/Kconfig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/usb/gadget/Kconfig +12
-3@@ -70,12 +70,21 @@ config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" default 0x701a if ARCH_TEGRA default 0x1010 if ARCH_SUNXI - default 0x310a if ROCKCHIP_RK3036 + default 0x110a if ROCKCHIP_RV1108 + default 0x110b if ROCKCHIP_RV1126 default 0x300a if ROCKCHIP_RK3066 + default 0x301a if ROCKCHIP_RK3036 + default 0x310b if ROCKCHIP_RK3188 default 0x310c if ROCKCHIP_RK3128 - default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 - default 0x330a if ROCKCHIP_RK3328 + default 0x320a if ROCKCHIP_RK3288 + default 0x320b if ROCKCHIP_RK322X + default 0x320c if ROCKCHIP_RK3328 + default 0x330a if ROCKCHIP_RK3368 default 0x330c if ROCKCHIP_RK3399 + default 0x330d if ROCKCHIP_PX30 + default 0x330e if ROCKCHIP_RK3308 + default 0x350a if ROCKCHIP_RK3568 + default 0x350b if ROCKCHIP_RK3588 default 0x0 help Product ID of the USB device emulated, reported to the host device.
Re: [PATCH 1/4] rockchip: Update the default USB Product ID value
Hi Kever,
Quoted 15 lines · Kever Yang
Hi Jonas,
Thanks for your patch.
Quoted 7 lines · Jonas Karlman
RK3036 is using the USB product id normally used by RK3066B, and RK3328 is using the product id normally used by RK3368.
Fix this and update the default
USB_GADGET_PRODUCT_NUMKconfigoption for remaining supported Rockchip SoCs to match the product id used in Mask ROM mode. Also remove a reference to the unknownROCKCHIP_RK3229symbol.RK3229 belongs to RK322X which is reuse with RK3228.
Quoted 7 lines
Note that this ID is used for rockusb gadget, if work as mass storage, it should use other
ID, or else it will confuse the driver in host side, eg. the Windows driver may not able to
recognize the device if using two different gadget type with the same ID.
Patch 3 in this series will change to use 0x0010 product id when ums mode is enabled and fall back to use the USB_GADGET_PRODUCT_NUM for any other gadget mode.
The ROCKCHIP_RK3229 symbol is not defined or used anywhere U-Boot so the change in this patch to remove it from the condition should have no impact. If RK3229 need a special product id separate from 0x320b used by ROCKCHIP_RK322X, it can be defined in the defconfig for such board.
I tested this on Windows with rockusb and ums on RK3308, RK3328, RK3399 RK356x and RK3588 boards, switching between ums and rockusb should work as intended, rockusb driver was used in rockusb mode and in ums mode the device would show up as a disk.
=> rockusb 0 mmc 1
=> ums 0 mmc 1
I think all product id below is correct, but I have not been able to runtime validate for other SoCs then the ones listed above.
Regards,
Jonas
Quoted 39 lines
Thanks,
- KeverQuoted 35 lines
Signed-off-by Jonas Karlman <[email protected]>--- drivers/usb/gadget/Kconfig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/usb/gadget/Kconfig +12
-3@@ -70,12 +70,21 @@ config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" default 0x701a if ARCH_TEGRA default 0x1010 if ARCH_SUNXI - default 0x310a if ROCKCHIP_RK3036 + default 0x110a if ROCKCHIP_RV1108 + default 0x110b if ROCKCHIP_RV1126 default 0x300a if ROCKCHIP_RK3066 + default 0x301a if ROCKCHIP_RK3036 + default 0x310b if ROCKCHIP_RK3188 default 0x310c if ROCKCHIP_RK3128 - default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 - default 0x330a if ROCKCHIP_RK3328 + default 0x320a if ROCKCHIP_RK3288 + default 0x320b if ROCKCHIP_RK322X + default 0x320c if ROCKCHIP_RK3328 + default 0x330a if ROCKCHIP_RK3368 default 0x330c if ROCKCHIP_RK3399 + default 0x330d if ROCKCHIP_PX30 + default 0x330e if ROCKCHIP_RK3308 + default 0x350a if ROCKCHIP_RK3568 + default 0x350b if ROCKCHIP_RK3588 default 0x0 help Product ID of the USB device emulated, reported to the host device.
Re: [PATCH 1/4] rockchip: Update the default USB Product ID value
Hi Jonas,
Quoted 20 lines · Jonas Karlman
Hi Kever,
Quoted 17 lines · Kever Yang
Hi Jonas,
Thanks for your patch.
Quoted 7 lines · Jonas Karlman
RK3036 is using the USB product id normally used by RK3066B, and RK3328 is using the product id normally used by RK3368.
Fix this and update the default
USB_GADGET_PRODUCT_NUMKconfigoption for remaining supported Rockchip SoCs to match the product id used in Mask ROM mode. Also remove a reference to the unknownROCKCHIP_RK3229symbol.RK3229 belongs to RK322X which is reuse with RK3228.
Note that this ID is used for rockusb gadget, if work as mass storage, it should use other
Quoted 7 lines
Quoted 4 lines
ID, or else it will confuse the driver in host side, eg. the Windows driver may not able to
recognize the device if using two different gadget type with the same ID.
Patch 3 in this series will change to use
0x0010product id when ums mode is enabled and fall back to use theUSB_GADGET_PRODUCT_NUMfor any other gadget mode.
Yes, I see that a few seconds after I send that mail.
Quoted 5 lines
The
ROCKCHIP_RK3229symbol is not defined or used anywhere U-Boot so the change in this patch to remove it from the condition should have no impact. If RK3229 need a special product id separate from0x320bused byROCKCHIP_RK322X, it can be defined in the defconfig for such board.
ROCKCHIP_RK3229 does not need any more, because it's included in Rk322X.
So please update the commit message with " remove ROCKCHIP_RK3229 because it's included in ROCKCHIP_RK322X" instead of "unknown ROCKCHIP_RK3229".
Quoted 10 lines
I tested this on Windows with rockusb and ums on RK3308, RK3328, RK3399 RK356x and RK3588 boards, switching between ums and rockusb should work as intended, rockusb driver was used in rockusb mode and in ums mode the device would show up as a disk.
=> rockusb 0 mmc 1
=> ums 0 mmc 1I think all product id below is correct,
Yes, I have check these IDs, they are correct.
Thanks,
- Kever
Quoted 43 lines
but I have not been able to
runtime validate for other SoCs then the ones listed above.Regards,
JonasQuoted 37 lines
Thanks,
- KeverQuoted 34 lines
Signed-off-by Jonas Karlman <[email protected]>--- drivers/usb/gadget/Kconfig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/usb/gadget/Kconfig +12
-3@@ -70,12 +70,21 @@ config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" default 0x701a if ARCH_TEGRA default 0x1010 if ARCH_SUNXI - default 0x310a if ROCKCHIP_RK3036 + default 0x110a if ROCKCHIP_RV1108 + default 0x110b if ROCKCHIP_RV1126 default 0x300a if ROCKCHIP_RK3066 + default 0x301a if ROCKCHIP_RK3036 + default 0x310b if ROCKCHIP_RK3188 default 0x310c if ROCKCHIP_RK3128 - default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 - default 0x330a if ROCKCHIP_RK3328 + default 0x320a if ROCKCHIP_RK3288 + default 0x320b if ROCKCHIP_RK322X + default 0x320c if ROCKCHIP_RK3328 + default 0x330a if ROCKCHIP_RK3368 default 0x330c if ROCKCHIP_RK3399 + default 0x330d if ROCKCHIP_PX30 + default 0x330e if ROCKCHIP_RK3308 + default 0x350a if ROCKCHIP_RK3568 + default 0x350b if ROCKCHIP_RK3588 default 0x0 help Product ID of the USB device emulated, reported to the host device.
Re: [PATCH 1/4] rockchip: Update the default USB Product ID value
Hi Kever,
Quoted 37 lines · Kever Yang
Hi Jonas,
Quoted 20 lines · Jonas Karlman
Hi Kever,
Quoted 17 lines · Kever Yang
Hi Jonas,
Thanks for your patch.
Quoted 7 lines · Jonas Karlman
RK3036 is using the USB product id normally used by RK3066B, and RK3328 is using the product id normally used by RK3368.
Fix this and update the default
USB_GADGET_PRODUCT_NUMKconfigoption for remaining supported Rockchip SoCs to match the product id used in Mask ROM mode. Also remove a reference to the unknownROCKCHIP_RK3229symbol.RK3229 belongs to RK322X which is reuse with RK3228.
Note that this ID is used for rockusb gadget, if work as mass storage, it should use other
Quoted 7 lines
Quoted 4 lines
ID, or else it will confuse the driver in host side, eg. the Windows driver may not able to
recognize the device if using two different gadget type with the same ID.
Patch 3 in this series will change to use
0x0010product id when ums mode is enabled and fall back to use theUSB_GADGET_PRODUCT_NUMfor any other gadget mode.Yes, I see that a few seconds after I send that mail.
Quoted 5 lines
The
ROCKCHIP_RK3229symbol is not defined or used anywhere U-Boot so the change in this patch to remove it from the condition should have no impact. If RK3229 need a special product id separate from0x320bused byROCKCHIP_RK322X, it can be defined in the defconfig for such board.
Quoted 4 lines
ROCKCHIP_RK3229does not need any more, because it's included in Rk322X.So please update the commit message with " remove
ROCKCHIP_RK3229because it's included inROCKCHIP_RK322X" instead of "unknownROCKCHIP_RK3229".
I have recently sent a v2 using the following message, let me know if you want me to send a v3 with your suggested message instead.
"Also remove a reference to an undefined ROCKCHIP_RK3229 Kconfig symbol."
Quoted 7 lines
Quoted 7 lines
I tested this on Windows with rockusb and ums on RK3308, RK3328, RK3399 RK356x and RK3588 boards, switching between ums and rockusb should work as intended, rockusb driver was used in rockusb mode and in ums mode the device would show up as a disk.
Quoted 6 lines
Quoted 4 lines
=> rockusb 0 mmc 1
=> ums 0 mmc 1I think all product id below is correct,
Yes, I have check these IDs, they are correct.
Great!
Regards,
Jonas
Quoted 47 lines
Thanks,
- KeverQuoted 43 lines
but I have not been able to
runtime validate for other SoCs then the ones listed above.Regards,
JonasQuoted 37 lines
Thanks,
- KeverQuoted 34 lines
Signed-off-by Jonas Karlman <[email protected]>--- drivers/usb/gadget/Kconfig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/usb/gadget/Kconfig +12
-3@@ -70,12 +70,21 @@ config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" default 0x701a if ARCH_TEGRA default 0x1010 if ARCH_SUNXI - default 0x310a if ROCKCHIP_RK3036 + default 0x110a if ROCKCHIP_RV1108 + default 0x110b if ROCKCHIP_RV1126 default 0x300a if ROCKCHIP_RK3066 + default 0x301a if ROCKCHIP_RK3036 + default 0x310b if ROCKCHIP_RK3188 default 0x310c if ROCKCHIP_RK3128 - default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 - default 0x330a if ROCKCHIP_RK3328 + default 0x320a if ROCKCHIP_RK3288 + default 0x320b if ROCKCHIP_RK322X + default 0x320c if ROCKCHIP_RK3328 + default 0x330a if ROCKCHIP_RK3368 default 0x330c if ROCKCHIP_RK3399 + default 0x330d if ROCKCHIP_PX30 + default 0x330e if ROCKCHIP_RK3308 + default 0x350a if ROCKCHIP_RK3568 + default 0x350b if ROCKCHIP_RK3588 default 0x0 help Product ID of the USB device emulated, reported to the host device.
Re: [PATCH 1/4] rockchip: Update the default USB Product ID value
In reply to Jonas KarlmanQuoted 9 lines · Jonas Karlman
RK3036 is using the USB product id normally used by RK3066B, and RK3328 is using the product id normally used by RK3368.
Fix this and update the default
USB_GADGET_PRODUCT_NUMKconfigoption for remaining supported Rockchip SoCs to match the product id used in Mask ROM mode. Also remove a reference to the unknownROCKCHIP_RK3229symbol.Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 33 lines
--- drivers/usb/gadget/Kconfig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/usb/gadget/Kconfig +12
-3@@ -70,12 +70,21 @@ config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" default 0x701a if ARCH_TEGRA default 0x1010 if ARCH_SUNXI - default 0x310a if ROCKCHIP_RK3036 + default 0x110a if ROCKCHIP_RV1108 + default 0x110b if ROCKCHIP_RV1126 default 0x300a if ROCKCHIP_RK3066 + default 0x301a if ROCKCHIP_RK3036 + default 0x310b if ROCKCHIP_RK3188 default 0x310c if ROCKCHIP_RK3128 - default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 - default 0x330a if ROCKCHIP_RK3328 + default 0x320a if ROCKCHIP_RK3288 + default 0x320b if ROCKCHIP_RK322X + default 0x320c if ROCKCHIP_RK3328 + default 0x330a if ROCKCHIP_RK3368 default 0x330c if ROCKCHIP_RK3399 + default 0x330d if ROCKCHIP_PX30 + default 0x330e if ROCKCHIP_RK3308 + default 0x350a if ROCKCHIP_RK3568 + default 0x350b if ROCKCHIP_RK3588 default 0x0 help Product ID of the USB device emulated, reported to the host device.
PATCH 2/4 rockchip: board: Prepare for use of DM_USB_GADGET with DWC2_OTG
In reply to Jonas KarlmanThe board_usb_init() and board_usb_cleanup() functions is always included when USB_GADGET and USB_GADGET_DWC2_OTG is enabled.
Prepare for a change to use DM_USB_GADGET with DWC2_OTG by adding an extra ifdef condition. The extra separate ifdef for USB_GADGET prepare for next patch that adds a g_dnl_bind_fixup() function.
--- arch/arm/mach-rockchip/board.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/board.c +3 -1
@@ -220,7 +220,8 @@ void enable_caches(void) }#endif -#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG ) +#if IS_ENABLED (CONFIG_USB_GADGET ) +#if IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG ) && !IS_ENABLED (CONFIG_DM_USB_GADGET )#include <usb.h> #include <linux/usb/otg.h> #include <usb/dwc2_udc.h>
@@ -296,6 +297,7 @@ int board_usb_cleanup(int index, enum usb_init_type init)return 0 ; }#endif /* CONFIG_USB_GADGET_DWC2_OTG */ +#endif /* CONFIG_USB_GADGET */ #if IS_ENABLED (CONFIG_FASTBOOT )int fastboot_set_reboot_flag (enum fastboot_reboot_reason reason)
Signature · 1 line
2.43.0
Re: [PATCH 2/4] rockchip: board: Prepare for use of DM_USB_GADGET with DWC2_OTG
Quoted 8 lines · Jonas Karlman
The
board_usb_init()andboard_usb_cleanup()functions is always included whenUSB_GADGETandUSB_GADGET_DWC2_OTGis enabled.Prepare for a change to use
DM_USB_GADGETwithDWC2_OTGby adding an extra ifdef condition. The extra separate ifdef forUSB_GADGETprepare for next patch that adds ag_dnl_bind_fixup()function.Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 26 lines
--- arch/arm/mach-rockchip/board.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/arm/mach-rockchip/board.c +3
-1@@ -220,7 +220,8 @@ void enable_caches(void) }#endif -#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG ) +#if IS_ENABLED (CONFIG_USB_GADGET ) +#if IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG ) && !IS_ENABLED (CONFIG_DM_USB_GADGET )#include <usb.h> #include <linux/usb/otg.h> #include <usb/dwc2_udc.h> @@ -296,6 +297,7 @@ int board_usb_cleanup(int index, enum usb_init_type init)return 0 ; }#endif /* CONFIG_USB_GADGET_DWC2_OTG */ +#endif /* CONFIG_USB_GADGET */ #if IS_ENABLED (CONFIG_FASTBOOT )int fastboot_set_reboot_flag (enum fastboot_reboot_reason reason)
PATCH 3/4 rockchip: board: Use a common USB Product ID for UMS
In reply to Jonas KarlmanChange to use the common Product ID 0x0010 when the ums command is used.
This matches downstream vendor U-Boot and is a Product ID that tools such as rkdeveloptool and RKDevTool will identify as MSC mode.
--- arch/arm/mach-rockchip/board.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/board.c +16 -1
@@ -221,8 +221,23 @@ void enable_caches(void)#endif #if IS_ENABLED (CONFIG_USB_GADGET ) -#if IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG ) && !IS_ENABLED (CONFIG_DM_USB_GADGET )#include <usb.h> + +#if IS_ENABLED (CONFIG_USB_GADGET_DOWNLOAD ) +#define ROCKCHIP_G_DNL_UMS_PRODUCT_NUM 0x0010 + +int g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) +{ +if (!strcmp (name,"usb_dnl_ums" )) +put_unaligned (ROCKCHIP_G_DNL_UMS_PRODUCT_NUM , &dev->idProduct); +else +put_unaligned (CONFIG_USB_GADGET_PRODUCT_NUM , &dev->idProduct); + +return 0 ; +} +#endif /* CONFIG_USB_GADGET_DOWNLOAD */ + +#if IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG ) && !IS_ENABLED (CONFIG_DM_USB_GADGET )#include <linux/usb/otg.h> #include <usb/dwc2_udc.h>
Signature · 1 line
2.43.0
Re: [PATCH 3/4] rockchip: board: Use a common USB Product ID for UMS
Quoted 6 lines · Jonas Karlman
Change to use the common Product ID
0x0010when the ums command is used.This matches downstream vendor U-Boot and is a Product ID that tools such as rkdeveloptool and RKDevTool will identify as MSC mode.
Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 33 lines
--- arch/arm/mach-rockchip/board.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/arm/mach-rockchip/board.c +16
-1@@ -221,8 +221,23 @@ void enable_caches(void)#endif #if IS_ENABLED (CONFIG_USB_GADGET ) -#if IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG ) && !IS_ENABLED (CONFIG_DM_USB_GADGET )#include <usb.h> + +#if IS_ENABLED (CONFIG_USB_GADGET_DOWNLOAD ) +#define ROCKCHIP_G_DNL_UMS_PRODUCT_NUM 0x0010 + +int g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) +{ +if (!strcmp (name,"usb_dnl_ums" )) +put_unaligned (ROCKCHIP_G_DNL_UMS_PRODUCT_NUM , &dev->idProduct); +else +put_unaligned (CONFIG_USB_GADGET_PRODUCT_NUM , &dev->idProduct); + +return 0 ; +} +#endif /* CONFIG_USB_GADGET_DOWNLOAD */ + +#if IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG ) && !IS_ENABLED (CONFIG_DM_USB_GADGET )#include <linux/usb/otg.h> #include <usb/dwc2_udc.h>
PATCH 4/4 rockchip: Migrate to use DM_USB_GADGET on RK3328
In reply to Jonas KarlmanUSB gadget is not working fully as expected on RK3328, it uses a board_usb_init() function to initialize the DWC2 OTG port.
The board_usb_init() function does not intgrate with the generic phy framework and as a result the USB phy is not properly configured before or after USB gadget use.
Having both USB_DWC2 and DWC2_OTG enabled for the same board is also causing some issues.
Trying to use rockusb or ums command after usb stop result in a freeze due to usb stop is putting the phy in a suspended state.
=> usb start
=> usb stop
=> ums 0 mmc 0
--> freeze due to usb phy is suspended <--
Fix this by only using one of USB_DWC2 (host) or DWC2_OTG (peripheral) depending on the most likely usage of the otg port.
The nanopi-r2 and orangepi-r1-plus variants share OTG and power using a Type-C connector, mark these boards dr_mode as peripheral, the most likely usage is for recovery and image download.
The rock64 and roc-cc currently use dr_mode as host, remove the DWC2_OTG driver from these boards to ensure that the USB_DWC2 driver is used.
The rock-pi-e board does not enable the usb20_otg node so both USB_DWC2 and DWC2_OTG is removed from this board.
Enable RockUSB and UMS on all boards with a otg port in peripheral mode.
Also with the migration to DM_USB_GADGET completed the U-Boot specific change to reorder usb nodes in the device tree can be reverted.
--- 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 ++++++++----------- 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 --- 17 files changed, 69 insertions(+), 55 deletions(-)
arch/arm/dts/rk3328-nanopi-r2s-u-boot.dtsi +4 -0
@@ -15,6 +15,10 @@ bootph-all; }; +&usb20_otg { + dr_mode = "peripheral"; +}; + &vcc_io_sdio { bootph-pre-ram; };
arch/arm/dts/rk3328-orangepi-r1-plus-lts-u-boot.dtsi +4 -0
@@ -33,6 +33,10 @@ bootph-pre-ram; }; +&usb20_otg { + dr_mode = "peripheral"; +}; + &vcc_sd { bootph-pre-ram; };
arch/arm/dts/rk3328-orangepi-r1-plus-u-boot.dtsi +4 -0
@@ -33,6 +33,10 @@ bootph-pre-ram; }; +&usb20_otg { + dr_mode = "peripheral"; +}; + &vcc_sd { bootph-pre-ram; };
arch/arm/dts/rk3328-roc-cc-u-boot.dtsi +4 -0
@@ -29,6 +29,10 @@ }; }; +&usb20_otg { + hnp-srp-disable; +}; + &vcc_sd { bootph-pre-ram; };
arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi +9 -0
@@ -29,6 +29,15 @@ }; }; +&u2phy_host { + phy-supply = <&vcc_host_5v>; +}; + +&vcc_host_5v { + /delete-property/ regulator-always-on; + /delete-property/ regulator-boot-on; +}; + &vcc_sd { bootph-pre-ram; };
arch/arm/dts/rk3328-rock64-u-boot.dtsi +4 -0
@@ -55,6 +55,10 @@ bootph-pre-ram; }; +&usb20_otg { + hnp-srp-disable; +}; + &vcc_sd { bootph-pre-ram; };
arch/arm/dts/rk3328-u-boot.dtsi +0 -4
@@ -130,10 +130,6 @@ bootph-all; }; -&usb20_otg { - hnp-srp-disable; -}; - #ifdef CONFIG_ROCKCHIP_SPI_IMAGE &binman { simple-bin-spi {
arch/arm/dts/rk3328.dtsi +16 -25
53 lines not on this page · raw message
configs/evb-rk3328_defconfig +4 -1
@@ -31,6 +31,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y
@@ -83,17 +85,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
configs/nanopi-r2c-plus-rk3328_defconfig +4 -1
@@ -33,6 +33,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y
@@ -90,17 +92,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
configs/nanopi-r2c-rk3328_defconfig +4 -1
@@ -33,6 +33,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y
@@ -90,17 +92,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
configs/nanopi-r2s-rk3328_defconfig +4 -1
@@ -33,6 +33,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y
@@ -90,17 +92,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
configs/orangepi-r1-plus-lts-rk3328_defconfig +4 -1
@@ -38,6 +38,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y
@@ -100,17 +102,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
configs/orangepi-r1-plus-rk3328_defconfig +4 -1
@@ -38,6 +38,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y
@@ -100,17 +102,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
configs/roc-cc-rk3328_defconfig +0 -7
@@ -13,7 +13,6 @@ CONFIG_DEBUG_UART_BASE=0xFF130000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_DEBUG_UART=y -# CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y
@@ -34,7 +33,6 @@ CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_POWEROFF=y CONFIG_CMD_USB=y -CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y
@@ -55,8 +53,6 @@ CONFIG_SPL_SYSCON=y CONFIG_TPL_SYSCON=y CONFIG_CLK=y CONFIG_SPL_CLK=y -CONFIG_FASTBOOT_BUF_ADDR=0x800800 -CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y
@@ -97,10 +93,7 @@ CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y -# CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y -CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_DWC2_OTG=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
configs/rock-pi-e-rk3328_defconfig +0 -7
@@ -13,7 +13,6 @@ CONFIG_DEBUG_UART_BASE=0xFF130000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_DEBUG_UART=y -# CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y
@@ -52,8 +51,6 @@ CONFIG_SPL_SYSCON=y CONFIG_TPL_SYSCON=y CONFIG_CLK=y CONFIG_SPL_CLK=y -CONFIG_FASTBOOT_BUF_ADDR=0x800800 -CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y
@@ -92,12 +89,8 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y -# CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y -CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_DWC2_OTG=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
configs/rock64-rk3328_defconfig +0 -6
@@ -16,7 +16,6 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_DEBUG_UART=y -# CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y
@@ -59,8 +58,6 @@ CONFIG_SPL_SYSCON=y CONFIG_TPL_SYSCON=y CONFIG_CLK=y CONFIG_SPL_CLK=y -CONFIG_FASTBOOT_BUF_ADDR=0x800800 -CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y
@@ -106,10 +103,7 @@ CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y -# CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y -CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_DWC2_OTG=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
Signature · 1 line
2.43.0
Quoted 31 lines · Jonas Karlman
USB gadget is not working fully as expected on RK3328, it uses a
board_usb_init()function to initialize the DWC2 OTG port.The
board_usb_init()function does not intgrate with the generic phy framework and as a result the USB phy is not properly configured before or after USB gadget use.Having both
USB_DWC2andDWC2_OTGenabled for the same board is also causing some issues.Trying to use rockusb or ums command after usb stop result in a freeze due to usb stop is putting the phy in a suspended state.
=> usb start
=> usb stop
=> ums 0 mmc 0
--> freeze due to usb phy is suspended <--Fix this by only using one of
USB_DWC2(host) orDWC2_OTG(peripheral) depending on the most likely usage of the otg port.The nanopi-r2 and orangepi-r1-plus variants share OTG and power using a Type-C connector, mark these boards
dr_modeas peripheral, the most likely usage is for recovery and image download.The rock64 and roc-cc currently use
dr_modeas host, remove theDWC2_OTGdriver from these boards to ensure that theUSB_DWC2driver is used.The rock-pi-e board does not enable the
usb20_otgnode so bothUSB_DWC2andDWC2_OTGis removed from this board.
Quoted 6 lines
Enable RockUSB and UMS on all boards with a otg port in peripheral mode.
Also with the migration to
DM_USB_GADGETcompleted the U-Boot specific change to reorder usb nodes in the device tree can be reverted.Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 493 lines
--- 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 ++++++++----------- 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 --- 17 files changed, 69 insertions(+), 55 deletions(-)arch/arm/dts/rk3328-nanopi-r2s-u-boot.dtsi +4
-0@@ -15,6 +15,10 @@ bootph-all; }; +&usb20_otg { + dr_mode = "peripheral"; +}; + &vcc_io_sdio { bootph-pre-ram; };arch/arm/dts/rk3328-orangepi-r1-plus-lts-u-boot.dtsi +4
-0@@ -33,6 +33,10 @@ bootph-pre-ram; }; +&usb20_otg { + dr_mode = "peripheral"; +}; + &vcc_sd { bootph-pre-ram; };arch/arm/dts/rk3328-orangepi-r1-plus-u-boot.dtsi +4
-0@@ -33,6 +33,10 @@ bootph-pre-ram; }; +&usb20_otg { + dr_mode = "peripheral"; +}; + &vcc_sd { bootph-pre-ram; };arch/arm/dts/rk3328-roc-cc-u-boot.dtsi +4
-0@@ -29,6 +29,10 @@ }; }; +&usb20_otg { + hnp-srp-disable; +}; + &vcc_sd { bootph-pre-ram; };arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi +9
-0@@ -29,6 +29,15 @@ }; }; +&u2phy_host { + phy-supply = <&vcc_host_5v>; +}; + +&vcc_host_5v { + /delete-property/ regulator-always-on; + /delete-property/ regulator-boot-on; +}; + &vcc_sd { bootph-pre-ram; };arch/arm/dts/rk3328-rock64-u-boot.dtsi +4
-0@@ -55,6 +55,10 @@ bootph-pre-ram; }; +&usb20_otg { + hnp-srp-disable; +}; + &vcc_sd { bootph-pre-ram; };arch/arm/dts/rk3328-u-boot.dtsi +0
-4@@ -130,10 +130,6 @@ bootph-all; }; -&usb20_otg { - hnp-srp-disable; -}; - #ifdef CONFIG_ROCKCHIP_SPI_IMAGE &binman { simple-bin-spi {arch/arm/dts/rk3328.dtsi +16
-25@@ -965,6 +965,22 @@ }; }; + usb20_otg: usb@ff580000 { + compatible = "rockchip,rk3328-usb", "rockchip,rk3066-usb", + "snps,dwc2"; + reg = <0x0 0xff580000 0x0 0x40000>; + interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cru HCLK_OTG>; + clock-names = "otg"; + dr_mode = "otg"; + g-np-tx-fifo-size = <16>; + g-rx-fifo-size = <280>; + g-tx-fifo-size = <256 128 128 64 32 16>; + phys = <&u2phy_otg>; + phy-names = "usb2-phy"; + status = "disabled"; + }; + usb_host0_ehci: usb@ff5c0000 { compatible = "generic-ehci"; reg = <0x0 0xff5c0000 0x0 0x10000>;@@ -1004,31 +1020,6 @@ status = "disabled"; }; - /* - * U-Boot Specific Change - * - * The OTG controller must come after the USB host pair for it - * to work. This is likely due to lack of support for the USB - * PHYs. This must be manually changed after each device tree - * sync. There is no clean way to handle this in -u-boot.dtsi - * files. - */ - usb20_otg: usb@ff580000 { - compatible = "rockchip,rk3328-usb", "rockchip,rk3066-usb", - "snps,dwc2"; - reg = <0x0 0xff580000 0x0 0x40000>; - interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&cru HCLK_OTG>; - clock-names = "otg"; - dr_mode = "otg"; - g-np-tx-fifo-size = <16>; - g-rx-fifo-size = <280>; - g-tx-fifo-size = <256 128 128 64 32 16>; - phys = <&u2phy_otg>; - phy-names = "usb2-phy"; - status = "disabled"; - }; - gic: interrupt-controller@ff811000 { compatible = "arm,gic-400"; #interrupt-cells = <3>;configs/evb-rk3328_defconfig +4
-1@@ -31,6 +31,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y@@ -83,17 +85,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=yconfigs/nanopi-r2c-plus-rk3328_defconfig +4
-1@@ -33,6 +33,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y@@ -90,17 +92,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=yconfigs/nanopi-r2c-rk3328_defconfig +4
-1@@ -33,6 +33,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y@@ -90,17 +92,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=yconfigs/nanopi-r2s-rk3328_defconfig +4
-1@@ -33,6 +33,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y@@ -90,17 +92,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=yconfigs/orangepi-r1-plus-lts-rk3328_defconfig +4
-1@@ -38,6 +38,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y@@ -100,17 +102,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=yconfigs/orangepi-r1-plus-rk3328_defconfig +4
-1@@ -38,6 +38,8 @@ CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y@@ -100,17 +102,18 @@ CONFIG_SYSINFO=y CONFIG_SYSRESET=y # CONFIG_TPL_SYSRESET is not set CONFIG_USB=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_ROCKUSB=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=yconfigs/roc-cc-rk3328_defconfig +0
-7@@ -13,7 +13,6 @@ CONFIG_DEBUG_UART_BASE=0xFF130000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_DEBUG_UART=y -# CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y@@ -34,7 +33,6 @@ CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_POWEROFF=y CONFIG_CMD_USB=y -CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_REGULATOR=y@@ -55,8 +53,6 @@ CONFIG_SPL_SYSCON=y CONFIG_TPL_SYSCON=y CONFIG_CLK=y CONFIG_SPL_CLK=y -CONFIG_FASTBOOT_BUF_ADDR=0x800800 -CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y@@ -97,10 +93,7 @@ CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y -# CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y -CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_DWC2_OTG=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=yconfigs/rock-pi-e-rk3328_defconfig +0
-7@@ -13,7 +13,6 @@ CONFIG_DEBUG_UART_BASE=0xFF130000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_DEBUG_UART=y -# CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y@@ -52,8 +51,6 @@ CONFIG_SPL_SYSCON=y CONFIG_TPL_SYSCON=y CONFIG_CLK=y CONFIG_SPL_CLK=y -CONFIG_FASTBOOT_BUF_ADDR=0x800800 -CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y@@ -92,12 +89,8 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y -CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y -# CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y -CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_DWC2_OTG=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=yconfigs/rock64-rk3328_defconfig +0
-6@@ -16,7 +16,6 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_DEBUG_UART=y -# CONFIG_ANDROID_BOOT_IMAGE is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y@@ -59,8 +58,6 @@ CONFIG_SPL_SYSCON=y CONFIG_TPL_SYSCON=y CONFIG_CLK=y CONFIG_SPL_CLK=y -CONFIG_FASTBOOT_BUF_ADDR=0x800800 -CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y@@ -106,10 +103,7 @@ CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y CONFIG_USB_DWC2=y CONFIG_USB_DWC3=y -# CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_DWC3_GENERIC=y -CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_DWC2_OTG=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y
Hi Kever,
Quoted 33 lines · Kever Yang
Quoted 31 lines · Jonas Karlman
USB gadget is not working fully as expected on RK3328, it uses a
board_usb_init()function to initialize the DWC2 OTG port.The
board_usb_init()function does not intgrate with the generic phy framework and as a result the USB phy is not properly configured before or after USB gadget use.Having both
USB_DWC2andDWC2_OTGenabled for the same board is also causing some issues.Trying to use rockusb or ums command after usb stop result in a freeze due to usb stop is putting the phy in a suspended state.
=> usb start
=> usb stop
=> ums 0 mmc 0
--> freeze due to usb phy is suspended <--Fix this by only using one of
USB_DWC2(host) orDWC2_OTG(peripheral) depending on the most likely usage of the otg port.The nanopi-r2 and orangepi-r1-plus variants share OTG and power using a Type-C connector, mark these boards
dr_modeas peripheral, the most likely usage is for recovery and image download.The rock64 and roc-cc currently use
dr_modeas host, remove theDWC2_OTGdriver from these boards to ensure that theUSB_DWC2driver is used.The rock-pi-e board does not enable the
usb20_otgnode so bothUSB_DWC2andDWC2_OTGis removed from this board.
Quoted 7 lines
Quoted 6 lines
Enable RockUSB and UMS on all boards with a otg port in peripheral mode.
Also with the migration to
DM_USB_GADGETcompleted the U-Boot specific change to reorder usb nodes in the device tree can be reverted.Signed-off-by Jonas Karlman <[email protected]>Reviewed-by Kever Yang <[email protected]>
Thanks, I will send a v2 of this patch, that will change to use XHCI_DWC3 for USB 3.0 host mode instead of DWC3_GENERIC to avoid generating a build error with dependent patch [1] being rejected.
[1] https://patchwork.ozlabs.org/patch/1903946/
Regards,
Jonas
Quoted 3 lines
Thanks,
- Kever
[snip]