rockchip: rk3588: add support for DFU in SPL
Subsystems (5)
v2 cover rockchip: rk3588: add support for DFU in SPL
This series adds support for DFU in SPL for rockchip rk3588 on rock5b board.
Namely, when SPL is loaded via rockusb (thus via USB), having the same-as-spl boot order item, after having detected that it was loaded from USB, it will lookup the gadget USB node in DT and boot via DFU.
Some changes were required namely:
- DFU needs environment, hence adding environment variables into DFU
- added bootph-all to nodes such that they are available in SPL
- insert gadget into boot order
I had to port one patch for DWC3 from Linux, and include in this series the patches that are floating from Venkatesh that fixup the DWC3
(https://marc.info/?l=u-boot&m=168351919807081&w=2 )
I know that Marek NAKed them and I am fine with it, I am not trying to sneak in any patches, they are not to be merged, also this patch usb: dwc3: Increase DWC3 controller halt timeout is in the same bucket so Marek you can NAK this one as well, no problem, I am just sending out all the series so maybe the rockchip part for the gadget can be picked up and if people want to use the DFU SPL gadget can also manually pick the DWC3 patches. The branch with all the patches is available here :
https://gitlab.collabora.com/hardware-enablement/rockchip-3588/u-boot
Thanks!
Changes in v2:
- rebased on latest upstream which caused a change in the config patch.
Eugen Hristev (7):
rockchip: allow env defines for SPL build
usb: dwc3: Increase DWC3 controller halt timeout
ARM: dts: rockchip: rk3588-rock-5b-u-boot: add bootph-all to gadget
nodes
ARM: mach-rockchip: spl-boot-order: add possibility to DFU
ARM: mach-rockchip: rk3588: add gadget device to the boot order
rockchip: rk3588: prepare env for DFU
configs: rockchip: rock5b-rk3588: enable DFU and related configs
Venkatesh Yadav Abbarapu (3):
usb: dwc3: core: improve reset sequence
usb: dwc3: gadget: Don't send unintended link state change
usb: dwc3: core: Only handle soft-reset in DCTL
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 6 +++++ arch/arm/mach-rockchip/rk3588/rk3588.c | 1 + arch/arm/mach-rockchip/spl-boot-order.c | 3 +++ configs/rock5b-rk3588_defconfig | 18 +++++++++++--- drivers/usb/dwc3/core.c | 32 +++++++++++++++---------- drivers/usb/dwc3/gadget.c | 20 +++++++--------- drivers/usb/dwc3/gadget.h | 14 +++++++++++ include/configs/rk3588_common.h | 9 ++++++- include/configs/rockchip-common.h | 4 ---- 9 files changed, 76 insertions(+), 31 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/10 rockchip: allow env defines for SPL build
For environment in SPL, all these defines are required, otherwise build fails:
[...]include/env_default.h:120:9: note: in expansion of macro ‘CFG_EXTRA_ENV_SETTINGS’
120 | CFG_EXTRA_ENV_SETTINGS
| ^~~~~~~~~~~~~~~~~~~~~~In file included from env/common.c:32:
[...]
Environment in SPL is needed e.g. for DFU, as dfu_alt is kept as env variable.
--- include/configs/rockchip-common.h | 4 ---- 1 file changed, 4 deletions(-)
include/configs/rockchip-common.h +0 -4
@@ -11,8 +11,6 @@#define CFG_CPUID_OFFSET 0x7#endif -#ifndef CONFIG_SPL_BUILD -#define BOOT_TARGETS "mmc1 mmc0 nvme scsi usb pxe dhcp spi"#ifdef CONFIG_ARM64
@@ -28,6 +26,4 @@"name=boot,size=112M,bootable,uuid=${uuid_gpt_boot};" \ "name=rootfs,size=-,uuid="ROOT_UUID -#endif -#endif /* _ROCKCHIP_COMMON_H_ */
Signature · 1 line
2.34.1
Re: [PATCH v2 01/10] rockchip: allow env defines for SPL build
Quoted 7 lines · Eugen Hristev
For environment in SPL, all these defines are required, otherwise build fails:
[...]
include/env_default.h:120:9: note: in expansion of macro ‘CFG_EXTRA_ENV_SETTINGS’120 | CFG_EXTRA_ENV_SETTINGS | ^~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines
In file included from
env/common.c:32:
[...]Environment in SPL is needed e.g. for DFU, as
dfu_altis kept as env variable.Signed-off-by Eugen Hristev <[email protected]>
Thanks,
- Kever
Quoted 24 lines
--- include/configs/rockchip-common.h | 4 ---- 1 file changed, 4 deletions(-)include/configs/rockchip-common.h +0
-4@@ -11,8 +11,6 @@#define CFG_CPUID_OFFSET 0x7#endif -#ifndef CONFIG_SPL_BUILD -#define BOOT_TARGETS "mmc1 mmc0 nvme scsi usb pxe dhcp spi"#ifdef CONFIG_ARM64 @@ -28,6 +26,4 @@"name=boot,size=112M,bootable,uuid=${uuid_gpt_boot};" \ "name=rootfs,size=-,uuid="ROOT_UUID -#endif -#endif /* _ROCKCHIP_COMMON_H_ */
PATCH v2 2/10 usb: dwc3: core: improve reset sequence
In reply to Eugen HristevFrom: Venkatesh Yadav Abbarapu <[email protected]>
[ Felipe: Ported from Linux kernel commit
f59dcab17629 ("usb: dwc3: core: improve reset sequence") ]According to Synopsys Databook, we shouldn't be relying on GCTL.CORESOFTRESET bit as that's only for debugging purposes. Instead, let's use DCTL.CSFTRST if we're OTG or PERIPHERAL mode.
Host side block will be reset by XHCI driver if necessary. Note that this reduces amount of time spent on dwc3_probe() by a long margin.
We're still gonna wait for reset to finish for a long time (default to 1ms max), but tests show that the reset polling loop executed at most 19 times (modprobe dwc3 && modprobe -r dwc3 executed 1000 times in a row).
Without proper core reset, observing random issues like when the USB(DWC3) is in device mode, the host device is not able to detect the USB device.
---
Not to be merged, I know Marek does not apply any patches to DWC3.
drivers/usb/dwc3/core.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/usb/dwc3/core.c +19 -12
@@ -60,17 +60,24 @@ static void dwc3_set_mode(struct dwc3 *dwc, u32 mode)static int dwc3_core_soft_reset (struct dwc3 *dwc) {u32 reg; +int retries =1000 ; -/* Before Resetting PHY, put Core in Reset */ - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); - reg |=DWC3_GCTL_CORESOFTRESET ; -dwc3_writel (dwc->regs,DWC3_GCTL , reg); +/* +* We're resetting only the device side because, if we're in host mode, +* XHCI driver will reset the host block. If dwc3 was configured for +* host-only mode, then we can return early. +*/ +if (dwc->dr_mode ==USB_DR_MODE_HOST ) +return 0 ; + + reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg |=DWC3_DCTL_CSFTRST ; +dwc3_writel (dwc->regs,DWC3_DCTL , reg);/* Assert USB3 PHY reset */ reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 )); reg |=DWC3_GUSB3PIPECTL_PHYSOFTRST ;dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); -/* Assert USB2 PHY reset */ reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); reg |=DWC3_GUSB2PHYCFG_PHYSOFTRST ;
@@ -88,14 +95,14 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) reg &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST ;dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); -mdelay (100 ); - -/* After PHYs are stable we can take Core out of reset state */ - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); - reg &= ~DWC3_GCTL_CORESOFTRESET ; -dwc3_writel (dwc->regs,DWC3_GCTL , reg); +do { + reg =dwc3_readl (dwc->regs,DWC3_DCTL ); +if (!(reg &DWC3_DCTL_CSFTRST )) +return 0 ; +udelay (1 ); + }while (--retries); -return 0 ; +return -ETIMEDOUT ; }/*
Signature · 1 line
2.34.1
Marek Vasut
NAKRe: [PATCH v2 02/10] usb: dwc3: core: improve reset sequence
Quoted 17 lines · Eugen Hristev
From: Venkatesh Yadav Abbarapu <[email protected]>
[ Felipe: Ported from Linux kernel commit
f59dcab17629 ("usb: dwc3: core: improve reset sequence") ]According to Synopsys Databook, we shouldn't be relying on GCTL.CORESOFTRESET bit as that's only for debugging purposes. Instead, let's use DCTL.CSFTRST if we're OTG or PERIPHERAL mode.
Host side block will be reset by XHCI driver if necessary. Note that this reduces amount of time spent on
dwc3_probe()by a long margin.We're still gonna wait for reset to finish for a long time (default to 1ms max), but tests show that the reset polling loop executed at most 19 times (modprobe dwc3 && modprobe -r dwc3 executed 1000 times in a row).
Quoted 7 lines
Without proper core reset, observing random issues like when the USB(DWC3) is in device mode, the host device is not able to detect the USB device.
Signed-off-by Venkatesh Yadav Abbarapu <[email protected]>[[email protected]: keep the PHY resets code]Signed-off-by Eugen Hristev <[email protected]>
NAK
Quoted 2 lines
---
Not to be merged, I know Marek does not apply any patches to DWC3.
That is not true and taken out of context.
What needs to happen is, someone needs to sync the DWC3 with Linux instead of picking random subsets patches and turning the driver into a total unmaintainable mess, which will be horribly difficult to sync in the future due to these random patches mixed in the history. I explained how to do it to Xilinx, it is a trivial thing to do, but it seems they did not even bother to try the method.
PATCH v2 3/10 usb: dwc3: gadget: Don't send unintended link state change
In reply to Eugen HristevFrom: Venkatesh Yadav Abbarapu <[email protected]>
[ Nguyen/Felipe/Greg: Ported from Linux kernel commit
5b738211fb59 ("usb: dwc3: gadget: Don't send
unintended link state change") ]DCTL.ULSTCHNGREQ is a write-only field. When doing a read-modify-write to DCTL, the driver must make sure that there's no unintended link state change request from whatever is read from DCTL.ULSTCHNGREQ. Set link state change to no-action when the driver writes to DCTL.
---
Not to be merged, I know Marek does not apply any patches to DWC3.
drivers/usb/dwc3/gadget.c | 16 +++++++--------- drivers/usb/dwc3/gadget.h | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-)
drivers/usb/dwc3/gadget.c +7 -9
@@ -62,7 +62,7 @@ int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode)return -EINVAL ; } -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_gadget_dctl_write_safe (dwc, reg);return 0 ; }
@@ -1382,7 +1382,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) dwc->pullups_connected = false; } -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_gadget_dctl_write_safe (dwc, reg); do { reg = dwc3_readl(dwc->regs, DWC3_DSTS);
@@ -2047,10 +2047,8 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_DCTL ); reg &= ~DWC3_DCTL_INITU1ENA ; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); - reg &= ~DWC3_DCTL_INITU2ENA ; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_gadget_dctl_write_safe (dwc, reg);dwc3_disconnect_gadget (dwc); dwc->start_config_issued = false;
@@ -2099,7 +2097,7 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_DCTL ); reg &= ~DWC3_DCTL_TSTCTRL_MASK ; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_gadget_dctl_write_safe (dwc, reg); dwc->test_mode = false;dwc3_stop_active_transfers (dwc);
@@ -2215,11 +2213,11 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)if (dwc->has_lpm_erratum && dwc->revision >=DWC3_REVISION_240A ) reg |=DWC3_DCTL_LPM_ERRATA (dwc->lpm_nyet_threshold); -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_gadget_dctl_write_safe (dwc, reg); }else { reg =dwc3_readl (dwc->regs,DWC3_DCTL ); reg &= ~DWC3_DCTL_HIRD_THRES_MASK ; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_gadget_dctl_write_safe (dwc, reg); } dep = dwc->eps[0 ];
@@ -2327,7 +2325,7 @@ static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc, reg &= ~u1u2; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_gadget_dctl_write_safe (dwc, reg);break ;default :/* do nothing */
drivers/usb/dwc3/gadget.h +14 -0
@@ -104,4 +104,18 @@ static inline u32 dwc3_gadget_ep_get_transfer_index(struct dwc3 *dwc, u8 number) return DWC3_DEPCMD_GET_RSC_IDX(res_id); } +/** +* dwc3_gadget_dctl_write_safe - write to DCTL safe from link state change +* @dwc: pointer to our context structure +* @value: value to write to DCTL +* +* Use this function when doing read-modify-write to DCTL. It will not +* send link state change request. +*/ +static inline void dwc3_gadget_dctl_write_safe (struct dwc3 *dwc,u32 value) +{ + value &= ~DWC3_DCTL_ULSTCHNGREQ_MASK ; +dwc3_writel (dwc->regs,DWC3_DCTL , value); +} +#endif /* __DRIVERS_USB_DWC3_GADGET_H */
Signature · 1 line
2.34.1
Re: [PATCH v2 03/10] usb: dwc3: gadget: Don't send unintended link state change
Quoted 6 lines · Eugen Hristev
From: Venkatesh Yadav Abbarapu <[email protected]>
[ Nguyen/Felipe/Greg: Ported from Linux kernel commit
5b738211fb59 ("usb: dwc3: gadget: Don't send unintended link state change") ]
Quoted 8 lines
DCTL.ULSTCHNGREQ is a write-only field. When doing a read-modify-write to DCTL, the driver must make sure that there's no unintended link state change request from whatever is read from DCTL.ULSTCHNGREQ. Set link state change to no-action when the driver writes to DCTL.
Signed-off-by Venkatesh Yadav Abbarapu <[email protected]>---
Not to be merged, I know Marek does not apply any patches to DWC3.
NAK. The statement above is not true, see patch 02/10 .
PATCH v2 4/10 usb: dwc3: core: Only handle soft-reset in DCTL
In reply to Eugen HristevFrom: Venkatesh Yadav Abbarapu <[email protected]>
[ Nguyen/Greg: Ported from Linux kernel commit
f4fd84ae0765a ("usb: dwc3: core: Only handle soft-reset in DCTL") ]Make sure not to set run_stop bit or link state change request while initiating soft-reset. Register read-modify-write operation may unintentionally start the controller before the initialization completes with its previous DCTL value, which can cause initialization failure.
---
Not to be merged, I know Marek does not apply any patches to DWC3.
drivers/usb/dwc3/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +2 -1
@@ -72,7 +72,8 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_DCTL ); reg |=DWC3_DCTL_CSFTRST ; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); + reg &= ~DWC3_DCTL_RUN_STOP ; +dwc3_gadget_dctl_write_safe (dwc, reg);/* Assert USB3 PHY reset */ reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 ));
Signature · 1 line
2.34.1
Re: [PATCH v2 04/10] usb: dwc3: core: Only handle soft-reset in DCTL
Quoted 5 lines · Eugen Hristev
From: Venkatesh Yadav Abbarapu <[email protected]>
[ Nguyen/Greg: Ported from Linux kernel commit
f4fd84ae0765a ("usb: dwc3: core: Only handle soft-reset in DCTL") ]
Quoted 8 lines
Make sure not to set
run_stopbit or link state change request while initiating soft-reset. Register read-modify-write operation may unintentionally start the controller before the initialization completes with its previous DCTL value, which can cause initialization failure.Signed-off-by Venkatesh Yadav Abbarapu <[email protected]>---
Not to be merged, I know Marek does not apply any patches to DWC3.
NAK. The statement above is not true, see patch 02/10 .
PATCH v2 5/10 usb: dwc3: Increase DWC3 controller halt timeout
In reply to Eugen HristevSince EP0 transactions need to be completed before the controller halt sequence is finished, this may take some time depending on the host and the enabled functions. Increase the controller halt timeout, so that we give the controller sufficient time to handle EP0 transfers.
Cherry-picked from Linux: 461ee467507c ("usb: dwc3: Increase DWC3 controller halt timeout")
---
Not to be merged, I know Marek does not apply any patches to DWC3.
drivers/usb/dwc3/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/gadget.c +2 -2
@@ -1356,7 +1356,7 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g,static int dwc3_gadget_run_stop (struct dwc3 *dwc,int is_on,int suspend) {u32 reg; -u32 timeout =500 ; +u32 timeout =2000 ; reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (is_on) {
@@ -1385,6 +1385,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)dwc3_gadget_dctl_write_safe (dwc, reg); do { + mdelay(2); reg = dwc3_readl(dwc->regs, DWC3_DSTS); if (is_on) { if (!(reg & DWC3_DSTS_DEVCTRLHLT))
@@ -1396,7 +1397,6 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) timeout--;if (!timeout)return -ETIMEDOUT ; -udelay (1 ); }while (1 ); dev_vdbg(dwc->dev, "gadget %s data soft-%s\n",
Signature · 1 line
2.34.1
Re: [PATCH v2 05/10] usb: dwc3: Increase DWC3 controller halt timeout
Quoted 11 lines · Eugen Hristev
Since EP0 transactions need to be completed before the controller halt sequence is finished, this may take some time depending on the host and the enabled functions. Increase the controller halt timeout, so that we give the controller sufficient time to handle EP0 transfers.
Signed-off-by Wesley Cheng <[email protected]>Cherry-picked from Linux:
461ee467507c("usb: dwc3: Increase DWC3 controller halt timeout")Signed-off-by Eugen Hristev <[email protected]>---
Not to be merged, I know Marek does not apply any patches to DWC3.
NAK. The statement above is not true, see patch 02/10 .
PATCH v2 6/10 ARM: dts: rockchip: rk3588-rock-5b-u-boot: add bootph-all to gadget nodes
In reply to Eugen HristevAdd bootph-all to gadget nodes to have the gadget available in SPL.
--- arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi +6 -0
@@ -221,10 +221,12 @@ }; &u2phy0 { + bootph-all; status = "okay"; }; &u2phy0_otg { + bootph-all; rockchip,typec-vbus-det; status = "okay"; };
@@ -271,6 +273,7 @@ }; &usbdp_phy0 { + bootph-all; orientation-switch; svid = <0xff01>; sbu1-dc-gpios = <&gpio4 RK_PA6 GPIO_ACTIVE_HIGH>;
@@ -293,14 +296,17 @@ }; &usbdp_phy0_u3 { + bootph-all; status = "okay"; }; &usbdrd3_0 { + bootph-all; status = "okay"; }; &usbdrd_dwc3_0 { + bootph-all; dr_mode = "otg"; usb-role-switch;
Signature · 1 line
2.34.1
Re: [PATCH v2 06/10] ARM: dts: rockchip: rk3588-rock-5b-u-boot: add bootph-all to gadget nodes
Hi Eugen,
Quoted 1 line · Eugen Hristev
Add bootph-all to gadget nodes to have the gadget available in SPL.
Does this gadget available on both USB2 and USB3? I think only USB2 is enough?
Thanks,
- Kever
Quoted 49 lines
Signed-off-by Eugen Hristev <[email protected]>--- arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm/dts/rk3588-rock-5b-u-boot.dtsi +6
-0@@ -221,10 +221,12 @@ }; &u2phy0 { + bootph-all; status = "okay"; }; &u2phy0_otg { + bootph-all; rockchip,typec-vbus-det; status = "okay"; };@@ -271,6 +273,7 @@ }; &usbdp_phy0 { + bootph-all; orientation-switch; svid = <0xff01>; sbu1-dc-gpios = <&gpio4 RK_PA6 GPIO_ACTIVE_HIGH>;@@ -293,14 +296,17 @@ }; &usbdp_phy0_u3 { + bootph-all; status = "okay"; }; &usbdrd3_0 { + bootph-all; status = "okay"; }; &usbdrd_dwc3_0 { + bootph-all; dr_mode = "otg"; usb-role-switch;
Re: [PATCH v2 06/10] ARM: dts: rockchip: rk3588-rock-5b-u-boot: add bootph-all to gadget nodes
Quoted 7 lines · Kever Yang
Hi Eugen,
Quoted 1 line · Eugen Hristev
Add bootph-all to gadget nodes to have the gadget available in SPL.
Does this gadget available on both USB2 and USB3? I think only USB2 is enough?
Hi Kever,
This board has one USB type C that is connected on USB3. This type C port is used for maskrom, to flash using rkdeveloptool and to power the board. It is only natural that this port is used for gadget, because everyone who boot this board, use rockusb to boot, will already have a cable connected to the host.
Also, on this device RK3588 USB2 controller does not support gadget mode, only host, so I am forced to use USB3 anyway.
Eugen
Quoted 47 lines
Thanks,
- Kever
Quoted 42 lines
Signed-off-by Eugen Hristev <[email protected]>---
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi| 6 ++++++1 file changed, 6 insertions(+)arch/arm/dts/rk3588-rock-5b-u-boot.dtsi +6
-0@@ -221,10 +221,12 @@ }; &u2phy0 { + bootph-all; status = "okay"; }; &u2phy0_otg { + bootph-all; rockchip,typec-vbus-det; status = "okay"; };@@ -271,6 +273,7 @@ }; &usbdp_phy0 { + bootph-all; orientation-switch; svid = <0xff01>; sbu1-dc-gpios = <&gpio4 RK_PA6 GPIO_ACTIVE_HIGH>;@@ -293,14 +296,17 @@ }; &usbdp_phy0_u3 { + bootph-all; status = "okay"; }; &usbdrd3_0 { + bootph-all; status = "okay"; }; &usbdrd_dwc3_0 { + bootph-all; dr_mode = "otg"; usb-role-switch;
PATCH v2 7/10 ARM: mach-rockchip: spl-boot-order: add possibility to DFU
In reply to Eugen HristevAdd DFU as a possible SPL boot media if the boot device is a gadget device.
--- arch/arm/mach-rockchip/spl-boot-order.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-rockchip/spl-boot-order.c +3 -0
@@ -66,6 +66,9 @@ static int spl_node_to_boot_device(int node) }else if (!uclass_get_device_by_of_offset (UCLASS_SPI_FLASH , node, &parent)) {return BOOT_DEVICE_SPI ; + }else if (!uclass_get_device_by_of_offset (UCLASS_USB_GADGET_GENERIC , + node, &parent)) { +return BOOT_DEVICE_DFU ; }/*
Signature · 1 line
2.34.1
Re: [PATCH v2 07/10] ARM: mach-rockchip: spl-boot-order: add possibility to DFU
Quoted 4 lines · Eugen Hristev
Add DFU as a possible SPL boot media if the boot device is a gadget device.
Signed-off-by Eugen Hristev <[email protected]>
Thanks,
- Kever
Quoted 18 lines
--- arch/arm/mach-rockchip/spl-boot-order.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-rockchip/spl-boot-order.c +3
-0@@ -66,6 +66,9 @@ static int spl_node_to_boot_device(int node) }else if (!uclass_get_device_by_of_offset (UCLASS_SPI_FLASH , node, &parent)) {return BOOT_DEVICE_SPI ; + }else if (!uclass_get_device_by_of_offset (UCLASS_USB_GADGET_GENERIC , + node, &parent)) { +return BOOT_DEVICE_DFU ; }/*
PATCH v2 8/10 ARM: mach-rockchip: rk3588: add gadget device to the boot order
In reply to Eugen HristevIn case SPL was booted from USB, add the gadget as the boot device for the 'same-as-spl' boot order next device.
--- arch/arm/mach-rockchip/rk3588/rk3588.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-rockchip/rk3588/rk3588.c +1 -0
@@ -42,6 +42,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { [BROM_BOOTSOURCE_SPINOR] = "/spi@fe2b0000/flash@0", [BROM_BOOTSOURCE_SD] = "/mmc@fe2c0000", [BROM_BOOTSOURCE_SPINOR_RK3588] = "/spi@fe2b0000/flash@0", + [BROM_BOOTSOURCE_USB] = "/usbdrd3_0/usb@fc000000", };static struct mm_region rk3588_mem_map[] = {
Signature · 1 line
2.34.1
PATCH v2 9/10 rockchip: rk3588: prepare env for DFU
In reply to Eugen HristevPrepare env variables for DFU
--- include/configs/rk3588_common.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
include/configs/rk3588_common.h +8 -1
@@ -7,6 +7,7 @@#ifndef __CONFIG_RK3588_COMMON_H#define __CONFIG_RK3588_COMMON_H +#include <linux/stringify.h> #include "rockchip-common.h" #define CFG_IRAM_BASE 0xff000000
@@ -31,6 +32,12 @@"partitions=" PARTS_DEFAULT \ENV_MEM_LAYOUT_SETTINGS \ROCKCHIP_DEVICE_SETTINGS \ - "boot_targets=" BOOT_TARGETS "\0" +"boot_targets=" BOOT_TARGETS "\0" \ +"dfu_alt_info=ram ram0=ram ram " \ + __stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " " \ + __stringify(CONFIG_SYS_DFU_DATA_BUF_SIZE) "\0" \ +"dfu_alt_info_ram=u-boot.itb ram " \ + __stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " " \ + __stringify(CONFIG_SYS_DFU_DATA_BUF_SIZE)#endif /* __CONFIG_RK3588_COMMON_H */
Signature · 1 line
2.34.1
PATCH v2 10/10 configs: rockchip: rock5b-rk3588: enable DFU and related configs
In reply to Eugen HristevEnable DFU and related configs, expand stack and buffers to hold downloaded image.
---
Changes in v2:
- added # CONFIG_SPL_BINMAN_UBOOT_SYMBOLS is not set because with the configs enabled here, this is automatically set as =y and this causes a build failure.
configs/rock5b-rk3588_defconfig | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
configs/rock5b-rk3588_defconfig +15 -3
@@ -4,6 +4,7 @@ CONFIG_SYS_HAS_NONCACHED_MEMORY=y CONFIG_COUNTER_FREQUENCY=24000000 CONFIG_ARCH_ROCKCHIP=y CONFIG_TEXT_BASE=0x00a00000 +CONFIG_SYS_MALLOC_F_LEN=0x500000 CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_NR_DRAM_BANKS=2
@@ -16,9 +17,9 @@ CONFIG_ROCKCHIP_RK3588=y CONFIG_SPL_ROCKCHIP_COMMON_BOARD=y CONFIG_ROCKCHIP_SPI_IMAGE=y CONFIG_SPL_SERIAL=y -CONFIG_SPL_STACK_R_ADDR=0x600000 +CONFIG_SPL_STACK_R_ADDR=0x1000000 CONFIG_TARGET_ROCK5B_RK3588=y -CONFIG_SPL_STACK=0x400000 +CONFIG_SPL_STACK=0x1000000 CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_SPL_SPI_FLASH_SUPPORT=y
@@ -30,6 +31,7 @@ CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y CONFIG_SPL_LOAD_FIT=y +CONFIG_SPL_LOAD_FIT_ADDRESS=0x50000000 CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_OF_BOARD_SETUP=y CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-rock-5b.dtb"
@@ -41,12 +43,17 @@ CONFIG_SPL_PAD_TO=0x7f8000 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y CONFIG_SPL_BSS_START_ADDR=0x4000000 CONFIG_SPL_BSS_MAX_SIZE=0x4000 +# CONFIG_SPL_BINMAN_UBOOT_SYMBOLS is not set # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_STACK_R=y +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x300000 +CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_RAM_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000 CONFIG_SPL_ATF=y +CONFIG_CMD_DFU=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y
@@ -59,10 +66,12 @@ CONFIG_CMD_REGULATOR=y # CONFIG_SPL_DOS_PARTITION is not set CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIVE=y -CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" +CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_SPL_REGMAP=y CONFIG_SPL_SYSCON=y CONFIG_SPL_CLK=y +CONFIG_DFU_RAM=y +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x200000 # CONFIG_USB_FUNCTION_FASTBOOT is not set CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y
@@ -93,6 +102,7 @@ CONFIG_ROCKCHIP_SFC=y CONFIG_SYSRESET=y CONFIG_USB=y CONFIG_DM_USB_GADGET=y +CONFIG_SPL_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y # CONFIG_USB_XHCI_DWC3_OF_SIMPLE is not set CONFIG_USB_EHCI_HCD=y
@@ -111,7 +121,9 @@ CONFIG_USB_ETHER_MCS7830=y CONFIG_USB_ETHER_RTL8152=y CONFIG_USB_ETHER_SMSC95XX=y CONFIG_USB_GADGET=y +CONFIG_SPL_USB_GADGET=y CONFIG_USB_GADGET_PRODUCT_NUM=0x350b CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_ROCKUSB=y +CONFIG_SPL_DFU=y CONFIG_ERRNO_STR=y
Signature · 1 line
2.34.1
Re: [PATCH v2 10/10] configs: rockchip: rock5b-rk3588: enable DFU and related configs
Quoted 4 lines · Eugen Hristev
Enable DFU and related configs, expand stack and buffers to hold downloaded image.
Signed-off-by Eugen Hristev <[email protected]>
Thanks,
- Kever
Quoted 91 lines
---
Changes in v2:
- added #CONFIG_SPL_BINMAN_UBOOT_SYMBOLSis not set because with the configs enabled here, this is automatically set as =y and this causes a build failure.configs/rock5b-rk3588_defconfig | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)configs/rock5b-rk3588_defconfig +15
-3@@ -4,6 +4,7 @@ CONFIG_SYS_HAS_NONCACHED_MEMORY=y CONFIG_COUNTER_FREQUENCY=24000000 CONFIG_ARCH_ROCKCHIP=y CONFIG_TEXT_BASE=0x00a00000 +CONFIG_SYS_MALLOC_F_LEN=0x500000 CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_NR_DRAM_BANKS=2@@ -16,9 +17,9 @@ CONFIG_ROCKCHIP_RK3588=y CONFIG_SPL_ROCKCHIP_COMMON_BOARD=y CONFIG_ROCKCHIP_SPI_IMAGE=y CONFIG_SPL_SERIAL=y -CONFIG_SPL_STACK_R_ADDR=0x600000 +CONFIG_SPL_STACK_R_ADDR=0x1000000 CONFIG_TARGET_ROCK5B_RK3588=y -CONFIG_SPL_STACK=0x400000 +CONFIG_SPL_STACK=0x1000000 CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_SPL_SPI_FLASH_SUPPORT=y@@ -30,6 +31,7 @@ CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y CONFIG_SPL_LOAD_FIT=y +CONFIG_SPL_LOAD_FIT_ADDRESS=0x50000000 CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_OF_BOARD_SETUP=y CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-rock-5b.dtb"@@ -41,12 +43,17 @@ CONFIG_SPL_PAD_TO=0x7f8000 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y CONFIG_SPL_BSS_START_ADDR=0x4000000 CONFIG_SPL_BSS_MAX_SIZE=0x4000 +# CONFIG_SPL_BINMAN_UBOOT_SYMBOLS is not set # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set CONFIG_SPL_STACK_R=y +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x300000 +CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_RAM_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000 CONFIG_SPL_ATF=y +CONFIG_CMD_DFU=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y@@ -59,10 +66,12 @@ CONFIG_CMD_REGULATOR=y # CONFIG_SPL_DOS_PARTITION is not set CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIVE=y -CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" +CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_SPL_REGMAP=y CONFIG_SPL_SYSCON=y CONFIG_SPL_CLK=y +CONFIG_DFU_RAM=y +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x200000 # CONFIG_USB_FUNCTION_FASTBOOT is not set CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y@@ -93,6 +102,7 @@ CONFIG_ROCKCHIP_SFC=y CONFIG_SYSRESET=y CONFIG_USB=y CONFIG_DM_USB_GADGET=y +CONFIG_SPL_DM_USB_GADGET=y CONFIG_USB_XHCI_HCD=y # CONFIG_USB_XHCI_DWC3_OF_SIMPLE is not set CONFIG_USB_EHCI_HCD=y@@ -111,7 +121,9 @@ CONFIG_USB_ETHER_MCS7830=y CONFIG_USB_ETHER_RTL8152=y CONFIG_USB_ETHER_SMSC95XX=y CONFIG_USB_GADGET=y +CONFIG_SPL_USB_GADGET=y CONFIG_USB_GADGET_PRODUCT_NUM=0x350b CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_ROCKUSB=y +CONFIG_SPL_DFU=y CONFIG_ERRNO_STR=y
Quoted 47 lines · Eugen Hristev
This series adds support for DFU in SPL for rockchip rk3588 on rock5b board.
Namely, when SPL is loaded via rockusb (thus via USB), having the
same-as-splboot order item, after having detected that it was loaded from USB, it will lookup the gadget USB node in DT and boot via DFU.Some changes were required namely:
- DFU needs environment, hence adding environment variables into DFU
- added bootph-all to nodes such that they are available in SPL
- insert gadget into boot orderI had to port one patch for DWC3 from Linux, and include in this series the patches that are floating from Venkatesh that fixup the DWC3
(https://marc.info/?l=u-boot&m=168351919807081&w=2 )I know that Marek NAKed them and I am fine with it, I am not trying to sneak in any patches, they are not to be merged, also this patch
usb: dwc3: Increase DWC3 controller halt timeoutis in the same bucket so Marek you can NAK this one as well, no problem, I am just sending out all the series so maybe the rockchip part for the gadget can be picked up and if people want to use the DFU SPL gadget can also manually pick the DWC3 patches. The branch with all the patches is available here :https://gitlab.collabora.com/hardware-enablement/rockchip-3588/u-boot
Thanks!
Changes in v2:
- rebased on latest upstream which caused a change in the config patch.Eugen Hristev (7):
rockchip: allow env defines for SPL build
usb: dwc3: Increase DWC3 controller halt timeout
ARM: dts: rockchip: rk3588-rock-5b-u-boot: add bootph-all to gadget
nodes
ARM: mach-rockchip: spl-boot-order: add possibility to DFU
ARM: mach-rockchip: rk3588: add gadget device to the boot order
rockchip: rk3588: prepare env for DFU
configs: rockchip: rock5b-rk3588: enable DFU and related configsVenkatesh Yadav Abbarapu (3):
usb: dwc3: core: improve reset sequence
usb: dwc3: gadget: Don't send unintended link state change
usb: dwc3: core: Only handle soft-reset in DCTL
Quoted 11 lines
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 6 +++++ arch/arm/mach-rockchip/rk3588/rk3588.c | 1 + arch/arm/mach-rockchip/spl-boot-order.c | 3 +++ configs/rock5b-rk3588_defconfig | 18 +++++++++++--- drivers/usb/dwc3/core.c | 32 +++++++++++++++---------- drivers/usb/dwc3/gadget.c | 20 +++++++--------- drivers/usb/dwc3/gadget.h | 14 +++++++++++ include/configs/rk3588_common.h | 9 ++++++- include/configs/rockchip-common.h | 4 ---- 9 files changed, 76 insertions(+), 31 deletions(-)
Hello Kever,
I see in patchwork this series is marked as 'Changes requested'.
Do you wish to tell me which are the changes you requested, as I did not see anything in your replies. I am interested to see the patches related to rockchip (not the DWC3), if it's fine for you to merge them.
Thanks,
Eugen
Quoted 61 lines · Eugen Hristev
Quoted 56 lines · Eugen Hristev
This series adds support for DFU in SPL for rockchip rk3588 on rock5b board.
Namely, when SPL is loaded via rockusb (thus via USB), having the
same-as-splboot order item, after having detected that it was loaded from USB, it will lookup the gadget USB node in DT and boot via DFU.Some changes were required namely:
- DFU needs environment, hence adding environment variables into DFU
- added bootph-all to nodes such that they are available in SPL
- insert gadget into boot orderI had to port one patch for DWC3 from Linux, and include in this series the patches that are floating from Venkatesh that fixup the DWC3
(https://marc.info/?l=u-boot&m=168351919807081&w=2 )I know that Marek NAKed them and I am fine with it, I am not trying to sneak in any patches, they are not to be merged, also this patch
usb: dwc3: Increase DWC3 controller halt timeoutis in the same bucket so Marek you can NAK this one as well, no problem, I am just sending out all the series so maybe the rockchip part for the gadget can be picked up and if people want to use the DFU SPL gadget can also manually pick the DWC3 patches. The branch with all the patches is available here :https://gitlab.collabora.com/hardware-enablement/rockchip-3588/u-boot
Thanks!
Changes in v2:
- rebased on latest upstream which caused a change in the config patch.Eugen Hristev (7):
rockchip: allow env defines for SPL build
usb: dwc3: Increase DWC3 controller halt timeout
ARM: dts: rockchip: rk3588-rock-5b-u-boot: add bootph-all to gadget nodes
ARM: mach-rockchip: spl-boot-order: add possibility to DFU
ARM: mach-rockchip: rk3588: add gadget device to the boot order
rockchip: rk3588: prepare env for DFU
configs: rockchip: rock5b-rk3588: enable DFU and related configsVenkatesh Yadav Abbarapu (3):
usb: dwc3: core: improve reset sequence
usb: dwc3: gadget: Don't send unintended link state change
usb: dwc3: core: Only handle soft-reset in DCTL
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi| 6 +++++ arch/arm/mach-rockchip/rk3588/rk3588.c | 1 +arch/arm/mach-rockchip/spl-boot-order.c| 3 +++ configs/rock5b-rk3588_defconfig | 18 +++++++++++--- drivers/usb/dwc3/core.c | 32 +++++++++++++++---------- drivers/usb/dwc3/gadget.c | 20 +++++++--------- drivers/usb/dwc3/gadget.h | 14 +++++++++++ include/configs/rk3588_common.h | 9 ++++++- include/configs/rockchip-common.h | 4 ----Quoted 2 lines
9 files changed, 76 insertions(+), 31 deletions(-)
Quoted 5 lines
Hello Kever,
I see in patchwork this series is marked as 'Changes requested'.
Do you wish to tell me which are the changes you requested, as I did not see anything in your replies. I am interested to see the patches related to rockchip (not the DWC3), if it's fine for you to merge them.
Hi Eugen,
For rockchip platform part is fine to me, but as a patchset, the dwc3 part is NAKed by Marek, so patch set
not able to merge.
If rockchip part can work without dwc3 change, you can send a separate patch set for it, so that I can merge it.
Thanks,
- Kever
Quoted 3 lines
Thanks,
Eugen
Quoted 71 lines · Kever Yang
Quoted 61 lines · Eugen Hristev
Quoted 56 lines · Eugen Hristev
This series adds support for DFU in SPL for rockchip rk3588 on rock5b board.
Namely, when SPL is loaded via rockusb (thus via USB), having the
same-as-splboot order item, after having detected that it was loaded from USB, it will lookup the gadget USB node in DT and boot via DFU.Some changes were required namely:
- DFU needs environment, hence adding environment variables into DFU
- added bootph-all to nodes such that they are available in SPL
- insert gadget into boot orderI had to port one patch for DWC3 from Linux, and include in this series the patches that are floating from Venkatesh that fixup the DWC3
(https://marc.info/?l=u-boot&m=168351919807081&w=2 )I know that Marek NAKed them and I am fine with it, I am not trying to sneak in any patches, they are not to be merged, also this patch
usb: dwc3: Increase DWC3 controller halt timeoutis in the same bucket so Marek you can NAK this one as well, no problem, I am just sending out all the series so maybe the rockchip part for the gadget can be picked up and if people want to use the DFU SPL gadget can also manually pick the DWC3 patches. The branch with all the patches is available here :https://gitlab.collabora.com/hardware-enablement/rockchip-3588/u-boot
Thanks!
Changes in v2:
- rebased on latest upstream which caused a change in the config patch.Eugen Hristev (7):
rockchip: allow env defines for SPL build
usb: dwc3: Increase DWC3 controller halt timeout
ARM: dts: rockchip: rk3588-rock-5b-u-boot: add bootph-all to gadget nodes
ARM: mach-rockchip: spl-boot-order: add possibility to DFU
ARM: mach-rockchip: rk3588: add gadget device to the boot order
rockchip: rk3588: prepare env for DFU
configs: rockchip: rock5b-rk3588: enable DFU and related configsVenkatesh Yadav Abbarapu (3):
usb: dwc3: core: improve reset sequence
usb: dwc3: gadget: Don't send unintended link state change
usb: dwc3: core: Only handle soft-reset in DCTL
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi| 6 +++++ arch/arm/mach-rockchip/rk3588/rk3588.c | 1 +arch/arm/mach-rockchip/spl-boot-order.c| 3 +++ configs/rock5b-rk3588_defconfig | 18 +++++++++++--- drivers/usb/dwc3/core.c | 32 +++++++++++++++---------- drivers/usb/dwc3/gadget.c | 20 +++++++--------- drivers/usb/dwc3/gadget.h | 14 +++++++++++ include/configs/rk3588_common.h | 9 ++++++- include/configs/rockchip-common.h | 4 ----Quoted 2 lines
9 files changed, 76 insertions(+), 31 deletions(-)Quoted 5 lines
Hello Kever,
I see in patchwork this series is marked as 'Changes requested'.
Do you wish to tell me which are the changes you requested, as I did not see anything in your replies. I am interested to see the patches related to rockchip (not the DWC3), if it's fine for you to merge them.Hi Eugen,
Quoted 7 lines
For rockchip platform part is fine to me, but as a patchset, the
dwc3 part is NAKed by Marek, so patch setnot able to merge.
If rockchip part can work without dwc3 change, you can send a
separate patch set for it, so that I can merge it.
Hi Kever,
The rockchip part works except the fact that sometimes the dwc3 gadget does not power up correctly (hence the three patches that fix the problem).
If you are fine to take the rockchip part I can resend it as a separate series. It would be useful for people to have the gadget devicetree and configs in upstream, and only the DWC3 part missing. Otherwise, this series will float until someone brings DWC3 up to date in U-boot as Marek requested. Let me know what do you think.
Thanks,
Eugen
Quoted 9 lines
Thanks,
- Kever
Quoted 3 lines
Thanks,
Eugen