Skip to content

Commit ae9f9aa

Browse files
committed
rockchip: rk3576: Properly handle USB controller takeover from BootROM
When booting via USB download mode (Maskrom), the BootROM leaves the USB3OTG0 controller in an active state. U-Boot must properly reset the controller before reinitializing it for fastboot or other USB gadget functions. Changes: 1. Detect USB boot source using read_brom_bootsource_id() 2. When booted from USB: - Assert USB3OTG0 reset via TOP_CRU_SOFTRST_CON47 - Wait 1ms for reset to complete - Deassert reset - Wait 1ms for controller to stabilize - Configure USB_GRF for proper operation 3. When booted from other sources: - Keep existing behavior of disabling U3 port initially (USBDP PHY driver enables it later when needed) Also update rk3576-evb1-v10.dts to set dr_mode = "peripheral" for usb_drd0_dwc3 to support fastboot gadget mode by default. Without this fix, USB fastboot fails when U-Boot is loaded via Maskrom USB download because the controller state is inconsistent. Change-Id: e22b349e-fdde-40e8-a991-b3a49e37e645 Signed-off-by: Anton Burticica <mouse@ya.ru>
1 parent cb2e54d commit ae9f9aa

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

arch/arm/mach-rockchip/rk3576/rk3576.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <dm.h>
99
#include <misc.h>
10+
#include <linux/delay.h>
1011
#include <asm/armv8/mmu.h>
1112
#include <asm/arch-rockchip/bootrom.h>
1213
#include <asm/arch-rockchip/hardware.h>
@@ -39,6 +40,10 @@
3940
#define USB_GRF_BASE 0x2601E000
4041
#define USB3OTG0_CON1 0x0030
4142

43+
#define TOP_CRU_BASE 0x27200000
44+
#define TOP_CRU_SOFTRST_CON47 0x0abc
45+
46+
4247
enum {
4348
BROM_BOOTSOURCE_FSPI0 = 3,
4449
BROM_BOOTSOURCE_FSPI1_M1 = 6,
@@ -190,8 +195,16 @@ int arch_cpu_init(void)
190195
*/
191196
writel(0xffffff00, SYS_SGRF_BASE + SYS_SGRF_SOC_CON20);
192197

193-
/* Disable USB3OTG0 U3 port, later enabled by USBDP PHY driver */
194-
writel(0xffff0188, USB_GRF_BASE + USB3OTG0_CON1);
198+
if (read_brom_bootsource_id() == BROM_BOOTSOURCE_USB) {
199+
writel(0x00200020, TOP_CRU_BASE + TOP_CRU_SOFTRST_CON47);
200+
udelay(1000);
201+
writel(0x00200000, TOP_CRU_BASE + TOP_CRU_SOFTRST_CON47);
202+
udelay(1000);
203+
writel(0x000c0008, USB_GRF_BASE + USB3OTG0_CON1);
204+
} else {
205+
/* Disable USB3OTG0 U3 port, later enabled by USBDP PHY driver */
206+
writel(0xffff0188, USB_GRF_BASE + USB3OTG0_CON1);
207+
}
195208

196209
return 0;
197210
}

dts/upstream/src/arm64/rockchip/rk3576-evb1-v10.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@
914914
};
915915

916916
&usb_drd0_dwc3 {
917-
dr_mode = "host";
917+
dr_mode = "peripheral";
918918
status = "okay";
919919
};
920920

0 commit comments

Comments
 (0)