rockchip: rk3568: Use dwc3-generic driver
Subsystems (3)
v4 cover rockchip: rk3568: Use dwc3-generic driver
This series add support for rk3568 in dwc3-generic driver and change to use the dwc3-generic driver for rk3568 devices having usb enabled.
After these changes it should be possible to support usb gadget on rk3568 with e.g.:
# CONFIG_USB_FUNCTION_FASTBOOT is not set
CONFIG_DM_USB_GADGET=y
CONFIG_USB_GADGET=y
Patch 1 reverts addition of now unnecessary regulator-boot-on props. Patch 2 improve support for childless glue/ctrl dt node. Patch 3 relax a hard error when usb gadget support is not enabled. Patch 4 add support for the glue/ctrl dt node used by rk3568. Patch 5 change rk3568 devices to use dwc3-generic driver.
Changes in v4:
- Rebase on u-boot-rockchip/master and v2 of the series "rockchip: rk3568: Device Tree updates"
- Add fixes tag
- Update nanopi-r5c-rk3568 and nanopi-r5s-rk3568
- Collect r-b tag
Changes in v3:
- Update debug message to include dr_mode (Marek Vasut)
- Collect r-b tag
Changes in v2:
- Change to use CONFIG_IS_ENABLED for USB_HOST
- Refactor switch to if statements (Marek Vasut)
- Update commit message
- Collect r-b tag
This series is also available at [1]
[1] https://github.com/Kwiboo/u-boot-rockchip/commits/rk3568-dwc3-generic-v4
Jonas Karlman (5):
Revert "arm: dts: rockchip: radxa-cm3-io, rock-3a: enable regulators
for usb"
usb: dwc3-generic: Return early when there is no child node
usb: dwc3-generic: Relax unsupported dr_mode check
usb: dwc3-generic: Add rk3568 support
rockchip: rk3568: Use dwc3-generic driver
arch/arm/dts/rk3566-radxa-cm3-io-u-boot.dtsi | 4 -- arch/arm/dts/rk3568-rock-3a-u-boot.dtsi | 8 ---- configs/nanopi-r5c-rk3568_defconfig | 3 +- configs/nanopi-r5s-rk3568_defconfig | 3 +- configs/radxa-cm3-io-rk3566_defconfig | 2 +- configs/rock-3a-rk3568_defconfig | 2 +- drivers/usb/dwc3/dwc3-generic.c | 50 +++++++++++--------- 7 files changed, 32 insertions(+), 40 deletions(-)
Signature · 1 line
2.41.0
PATCH v4 1/5 Revert "arm: dts: rockchip: radxa-cm3-io, rock-3a: enable regulators for usb"
Remove regulator-boot-on prop from regulators now that the phy core has support for phy-supply after the commit c57e0dcd9384 ("phy: add support for phy-supply").
This reverts commit 7911f409ff20dce5995cc1b703a6e30c94022f6b.
---
v4:
- Rebase on u-boot-rockchip/master and v2 of the series "rockchip: rk3568: Device Tree updates"
v3:
- No change
v2:
- No change
arch/arm/dts/rk3566-radxa-cm3-io-u-boot.dtsi | 4 ---- arch/arm/dts/rk3568-rock-3a-u-boot.dtsi | 8 -------- 2 files changed, 12 deletions(-)
arch/arm/dts/rk3566-radxa-cm3-io-u-boot.dtsi +0 -4
@@ -21,7 +21,3 @@ bootph-all; status = "okay"; }; - -&vcc5v0_usb30 { - regulator-boot-on; -};
arch/arm/dts/rk3568-rock-3a-u-boot.dtsi +0 -8
@@ -66,11 +66,3 @@ bootph-all; status = "okay"; }; - -&vcc5v0_usb_host { - regulator-boot-on; -}; - -&vcc5v0_usb_hub { - regulator-boot-on; -};
Signature · 1 line
2.41.0
PATCH v4 2/5 usb: dwc3-generic: Return early when there is no child node
In reply to Jonas KarlmanThe current error check for device_find_first_child is not working as expected, the documentation for device_find_first_child mention:
@devp: Returns first child device, or NULL if none
Return: 0
Change to return early when there is no child node to avoid any possible null pointer dereference.
---
v4:
- Collect r-b tag
v3:
- Collect r-b tag
v2:
- Update commit message
drivers/usb/dwc3/dwc3-generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/dwc3/dwc3-generic.c +3 -3
@@ -558,9 +558,9 @@ int dwc3_glue_probe(struct udevice *dev)return ret; } - ret =device_find_first_child (dev, &child); -if (ret) -return ret; +device_find_first_child (dev, &child); +if (!child) +return 0 ;if (glue->clks.count ==0 ) { ret =dwc3_glue_clk_init (child, glue);
Signature · 1 line
2.41.0
PATCH v4 3/5 usb: dwc3-generic: Relax unsupported dr_mode check
In reply to Jonas KarlmanWhen dr_mode is peripheral or otg and U-Boot has not been built with DM_USB_GADGET support, booting such device may end up with:
dwc3_glue_bind_common: subnode name: usb@fcc00000
Error binding driver 'dwc3-generic-wrapper': -6
Some drivers failed to bind
initcall sequence 00000000effbca08 failed at call 0000000000a217c8 (err=-6) ### ERROR ### Please RESET the board ###
Instead fail gracfully with ENODEV to allow board continue booting.
dwc3_glue_bind_common: subnode name: usb@fcc00000
dwc3_glue_bind_common: unsupported dr_mode 3
Also use CONFIG_IS_ENABLED(USB_HOST) and change switch to if statements to improve readability of the code.
---
v4:
- Add fixes tag
v3:
- Update debug message to include dr_mode (Marek Vasut) v2:
- Change to use CONFIG_IS_ENABLED for USB_HOST
- Refactor switch to if statements (Marek Vasut)
drivers/usb/dwc3/dwc3-generic.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/usb/dwc3/dwc3-generic.c +8 -19
@@ -226,8 +226,7 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = { };#endif -#if defined(CONFIG_SPL_USB_HOST ) || \ - !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_USB_HOST ) +#if CONFIG_IS_ENABLED (USB_HOST )static int dwc3_generic_host_probe (struct udevice *dev) {struct xhci_hcor *hcor;
@@ -409,7 +408,7 @@ struct dwc3_glue_ops ti_ops = {static int dwc3_glue_bind_common (struct udevice *parent,ofnode node) {const char *name =ofnode_get_name (node); -const char *driver =NULL ; +const char *driver;enum usb_dr_mode dr_mode;struct udevice *dev;int ret;
@@ -421,27 +420,17 @@ static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)if (!dr_mode) dr_mode =usb_get_dr_mode (node); -switch (dr_mode) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG : -#if CONFIG_IS_ENABLED (DM_USB_GADGET ) +if (CONFIG_IS_ENABLED (DM_USB_GADGET ) && + (dr_mode ==USB_DR_MODE_PERIPHERAL || dr_mode ==USB_DR_MODE_OTG )) {debug ("%s: dr_mode: OTG or Peripheral\n" , __func__); driver ="dwc3-generic-peripheral" ; -#endif -break ; -#if defined(CONFIG_SPL_USB_HOST ) || !defined(CONFIG_SPL_BUILD ) -case USB_DR_MODE_HOST : + }else if (CONFIG_IS_ENABLED (USB_HOST ) && dr_mode ==USB_DR_MODE_HOST ) {debug ("%s: dr_mode: HOST\n" , __func__); driver ="dwc3-generic-host" ; -break ; -#endif -default : -debug ("%s: unsupported dr_mode\n" , __func__); + }else { +debug ("%s: unsupported dr_mode %d\n" , __func__, dr_mode);return -ENODEV ; - }; - -if (!driver) -return -ENXIO ; + } ret =device_bind_driver_to_node (parent, driver, name, node, &dev);
Signature · 1 line
2.41.0
Re: [PATCH v4 3/5] usb: dwc3-generic: Relax unsupported dr_mode check
Quoted 11 lines · Jonas Karlman
When
dr_modeis peripheral or otg and U-Boot has not been built withDM_USB_GADGETsupport, booting such device may end up with:
dwc3_glue_bind_common: subnode name: usb@fcc00000
Error binding driver 'dwc3-generic-wrapper': -6
Some drivers failed to bind
initcall sequence00000000effbca08failed at call0000000000a217c8(err=-6) ### ERROR ### Please RESET the board ###Instead fail gracfully with ENODEV to allow board continue booting.
Quoted 8 lines
dwc3_glue_bind_common: subnode name: usb@fcc00000
dwc3_glue_bind_common: unsupporteddr_mode3Also use
CONFIG_IS_ENABLED(USB_HOST)and change switch to if statements to improve readability of the code.Fixes 446e3a205b87 ("dwc3-generic: Handle the PHYs, the clocks and the reset lines")Signed-off-by Jonas Karlman <[email protected]>
PATCH v4 4/5 usb: dwc3-generic: Add rk3568 support
In reply to Jonas KarlmanRK3568 share glue and ctrl in a single node. Use glue_get_ctrl_dev to return the glue node as the ctrl node.
---
v4:
- No change
v3:
- No change
v2:
- No change
- Collect r-b tag
drivers/usb/dwc3/dwc3-generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/usb/dwc3/dwc3-generic.c +17 -0
@@ -405,6 +405,22 @@ struct dwc3_glue_ops ti_ops = { .glue_configure = dwc3_ti_glue_configure, }; +static int dwc3_rk_glue_get_ctrl_dev (struct udevice *dev,ofnode *node) +{ +if (!device_is_compatible (dev,"snps,dwc3" )) +return -EINVAL ; + + *node =dev_ofnode (dev); +if (!ofnode_valid (*node)) +return -EINVAL ; + +return 0 ; +} + +struct dwc3_glue_ops rk_ops = { + .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, +}; +static int dwc3_glue_bind_common (struct udevice *parent,ofnode node) {const char *name =ofnode_get_name (node);
@@ -596,6 +612,7 @@ static const struct udevice_id dwc3_glue_ids[] = { { .compatible = "ti,am654-dwc3" }, { .compatible = "rockchip,rk3328-dwc3" }, { .compatible = "rockchip,rk3399-dwc3" }, + { .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops }, { .compatible = "qcom,dwc3" }, { .compatible = "fsl,imx8mp-dwc3", .data = (ulong)&imx8mp_ops }, { .compatible = "fsl,imx8mq-dwc3" },
Signature · 1 line
2.41.0
Re: [PATCH v4 4/5] usb: dwc3-generic: Add rk3568 support
Quoted 22 lines · Jonas Karlman
RK3568 share glue and ctrl in a single node. Use
glue_get_ctrl_devto return the glue node as the ctrl node.Signed-off-by Jonas Karlman <[email protected]>Reviewed-by Jagan Teki <[email protected]>---
v4:
- No change
v3:
- No change
v2:
- No change
- Collect r-b tagdrivers/usb/dwc3/dwc3-generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/usb/dwc3/dwc3-generic.c +0
-0
drivers/usb/dwc3/dwc3-generic.c struct dwc3_glue_ops ti_ops = { · line 411
Quoted 7 lines
drivers/usb/dwc3/dwc3-generic.c +4
-0@@ -405,6 +405,22 @@ struct dwc3_glue_ops ti_ops = { .glue_configure = dwc3_ti_glue_configure, }; +static int dwc3_rk_glue_get_ctrl_dev (struct udevice *dev,ofnode *node) +{ +if (!device_is_compatible (dev,"snps,dwc3" )) +return -EINVAL ;
Can this ever happen ?
Re: [PATCH v4 4/5] usb: dwc3-generic: Add rk3568 support
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Jonas Karlman
RK3568 share glue and ctrl in a single node. Use
glue_get_ctrl_devto return the glue node as the ctrl node.Signed-off-by Jonas Karlman <[email protected]>Reviewed-by Jagan Teki <[email protected]>---
v4:
- No change
v3:
- No change
v2:
- No change
- Collect r-b tagdrivers/usb/dwc3/dwc3-generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/usb/dwc3/dwc3-generic.c +0
-0@@ -405,6 +405,22 @@ struct dwc3_glue_ops ti_ops = { .glue_configure = dwc3_ti_glue_configure, };
Quoted 6 lines
drivers/usb/dwc3/dwc3-generic.c struct dwc3_glue_ops ti_ops = { · line 411
Quoted 4 lines
drivers/usb/dwc3/dwc3-generic.c +4
-0+static int dwc3_rk_glue_get_ctrl_dev (struct udevice *dev,ofnode *node) +{ +if (!device_is_compatible (dev,"snps,dwc3" )) +return -EINVAL ;Can this ever happen ?
In normal case, probably not, in case someone e.g. try to use wrong compatible or a bad/strange device tree, sure it can.
Added the check to make sure this ops only returns a valid ctrl node.
Regards,
Jonas
Re: [PATCH v4 4/5] usb: dwc3-generic: Add rk3568 support
Quoted 34 lines · Jonas Karlman
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Jonas Karlman
RK3568 share glue and ctrl in a single node. Use
glue_get_ctrl_devto return the glue node as the ctrl node.Signed-off-by Jonas Karlman <[email protected]>Reviewed-by Jagan Teki <[email protected]>---
v4:
- No change
v3:
- No change
v2:
- No change
- Collect r-b tagdrivers/usb/dwc3/dwc3-generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/usb/dwc3/dwc3-generic.c +0
-0@@ -405,6 +405,22 @@ struct dwc3_glue_ops ti_ops = { .glue_configure = dwc3_ti_glue_configure, };Quoted 6 lines
drivers/usb/dwc3/dwc3-generic.c struct dwc3_glue_ops ti_ops = { · line 411
Quoted 4 lines
drivers/usb/dwc3/dwc3-generic.c +4
-0+static int dwc3_rk_glue_get_ctrl_dev (struct udevice *dev,ofnode *node) +{ +if (!device_is_compatible (dev,"snps,dwc3" )) +return -EINVAL ;Can this ever happen ?
Quoted 4 lines
In normal case, probably not, in case someone e.g. try to use wrong compatible or a bad/strange device tree, sure it can.
Added the check to make sure this ops only returns a valid ctrl node.
The driver should already only bind to compatibles listed in dwc3_glue_ids , so what kind of DT would that be ?
Re: [PATCH v4 4/5] usb: dwc3-generic: Add rk3568 support
Quoted 35 lines · Marek Vasut
Quoted 34 lines · Jonas Karlman
Quoted 32 lines · Marek Vasut
Quoted 22 lines · Jonas Karlman
RK3568 share glue and ctrl in a single node. Use
glue_get_ctrl_devto return the glue node as the ctrl node.Signed-off-by Jonas Karlman <[email protected]>Reviewed-by Jagan Teki <[email protected]>---
v4:
- No change
v3:
- No change
v2:
- No change
- Collect r-b tagdrivers/usb/dwc3/dwc3-generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/usb/dwc3/dwc3-generic.c +0
-0drivers/usb/dwc3/dwc3-generic.c struct dwc3_glue_ops ti_ops = { · line 411
Quoted 7 lines
drivers/usb/dwc3/dwc3-generic.c +4
-0@@ -405,6 +405,22 @@ struct dwc3_glue_ops ti_ops = { .glue_configure = dwc3_ti_glue_configure, }; +static int dwc3_rk_glue_get_ctrl_dev (struct udevice *dev,ofnode *node) +{ +if (!device_is_compatible (dev,"snps,dwc3" )) +return -EINVAL ;Can this ever happen ?
Quoted 7 lines
Quoted 4 lines
In normal case, probably not, in case someone e.g. try to use wrong compatible or a bad/strange device tree, sure it can.
Added the check to make sure this ops only returns a valid ctrl node.
The driver should already only bind to compatibles listed in
dwc3_glue_ids, so what kind of DT would that be ?
Not sure, hence I added the check to be extra safe the code would not break. I can however now see that bindings look like following, after a pending rk3588 compatible gets added.
compatible:
items:
- enum:
- rockchip,rk3328-dwc3
- rockchip,rk3568-dwc3
- rockchip,rk3588-dwc3
- const: snps,dwc3
So I guess we can assume that for these compatible this check should always pass.
Do you want this check/part of the code removed?
Regards,
Jonas
Re: [PATCH v4 4/5] usb: dwc3-generic: Add rk3568 support
Quoted 56 lines · Jonas Karlman
Quoted 35 lines · Marek Vasut
Quoted 34 lines · Jonas Karlman
Quoted 32 lines · Marek Vasut
Quoted 22 lines · Jonas Karlman
RK3568 share glue and ctrl in a single node. Use
glue_get_ctrl_devto return the glue node as the ctrl node.Signed-off-by Jonas Karlman <[email protected]>Reviewed-by Jagan Teki <[email protected]>---
v4:
- No change
v3:
- No change
v2:
- No change
- Collect r-b tagdrivers/usb/dwc3/dwc3-generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/usb/dwc3/dwc3-generic.c +0
-0drivers/usb/dwc3/dwc3-generic.c struct dwc3_glue_ops ti_ops = { · line 411
Quoted 7 lines
drivers/usb/dwc3/dwc3-generic.c +4
-0@@ -405,6 +405,22 @@ struct dwc3_glue_ops ti_ops = { .glue_configure = dwc3_ti_glue_configure, }; +static int dwc3_rk_glue_get_ctrl_dev (struct udevice *dev,ofnode *node) +{ +if (!device_is_compatible (dev,"snps,dwc3" )) +return -EINVAL ;Can this ever happen ?
Quoted 7 lines
Quoted 4 lines
In normal case, probably not, in case someone e.g. try to use wrong compatible or a bad/strange device tree, sure it can.
Added the check to make sure this ops only returns a valid ctrl node.
The driver should already only bind to compatibles listed in
dwc3_glue_ids, so what kind of DT would that be ?Not sure, hence I added the check to be extra safe the code would not break. I can however now see that bindings look like following, after a pending rk3588 compatible gets added.
compatible:
items:
- enum:
- rockchip,rk3328-dwc3
- rockchip,rk3568-dwc3
- rockchip,rk3588-dwc3
- const: snps,dwc3
Quoted 4 lines
So I guess we can assume that for these compatible this check should always pass.
Do you want this check/part of the code removed?
Since the check seem to make little sense, yes please.
PATCH v4 5/5 rockchip: rk3568: Use dwc3-generic driver
In reply to Jonas KarlmanChange RK3568 devices to use the newer dwc3-generic driver instead of the old xhci-dwc3 driver for USB 3.0 support.
---
v4:
- Rebase on u-boot-rockchip/master and include change to nanopi-r5c-rk3568 and nanopi-r5s-rk3568
- Collect r-b tag
v3:
- No change
v2:
- No change
configs/nanopi-r5c-rk3568_defconfig | 3 +-- configs/nanopi-r5s-rk3568_defconfig | 3 +-- configs/radxa-cm3-io-rk3566_defconfig | 2 +- configs/rock-3a-rk3568_defconfig | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-)
configs/nanopi-r5c-rk3568_defconfig +1 -2
@@ -13,7 +13,6 @@ CONFIG_ROCKCHIP_RK3568=y CONFIG_SPL_ROCKCHIP_COMMON_BOARD=y CONFIG_SPL_SERIAL=y CONFIG_SPL_STACK_R_ADDR=0x600000 -CONFIG_TARGET_EVB_RK3568=y CONFIG_SPL_STACK=0x400000 CONFIG_DEBUG_UART_BASE=0xFE660000 CONFIG_DEBUG_UART_CLOCK=24000000
@@ -76,10 +75,10 @@ CONFIG_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y -CONFIG_USB_XHCI_DWC3=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y CONFIG_ERRNO_STR=y
configs/nanopi-r5s-rk3568_defconfig +1 -2
@@ -13,7 +13,6 @@ CONFIG_ROCKCHIP_RK3568=y CONFIG_SPL_ROCKCHIP_COMMON_BOARD=y CONFIG_SPL_SERIAL=y CONFIG_SPL_STACK_R_ADDR=0x600000 -CONFIG_TARGET_EVB_RK3568=y CONFIG_SPL_STACK=0x400000 CONFIG_DEBUG_UART_BASE=0xFE660000 CONFIG_DEBUG_UART_CLOCK=24000000
@@ -76,10 +75,10 @@ CONFIG_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y -CONFIG_USB_XHCI_DWC3=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y CONFIG_ERRNO_STR=y
configs/radxa-cm3-io-rk3566_defconfig +1 -1
@@ -75,8 +75,8 @@ CONFIG_SYS_NS16550_MEM32=y CONFIG_SYSRESET=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y -CONFIG_USB_XHCI_DWC3=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y CONFIG_ERRNO_STR=y
configs/rock-3a-rk3568_defconfig +1 -1
@@ -97,10 +97,10 @@ CONFIG_ROCKCHIP_SFC=y CONFIG_SYSRESET=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y -CONFIG_USB_XHCI_DWC3=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y CONFIG_ERRNO_STR=y
Signature · 1 line
2.41.0