Skip to content

Conversation

@ya-mouse
Copy link
Contributor

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

@ya-mouse ya-mouse requested a review from alchark January 20, 2026 08:06
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a separate change. It's also technically a "HACK", because one doesn't directly edit device trees which reside under dts/upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move it into rk3576-u-boot.dtsi. Should work from there as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. Better still would be to make it work in OTG mode and ensure that a RAM bundle sets the controller to peripheral mode via the boot command, because one may also want to be able to insert a USB drive into the port and boot from it

/* Disable USB3OTG0 U3 port, later enabled by USBDP PHY driver */
writel(0xffff0188, USB_GRF_BASE + USB3OTG0_CON1);
if (read_brom_bootsource_id() == BROM_BOOTSOURCE_USB) {
writel(0x00200020, TOP_CRU_BASE + TOP_CRU_SOFTRST_CON47);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add #define's for all the bit values please? Otherwise it's hard to understand what is going on.

@ya-mouse ya-mouse force-pushed the splram-8c58ad9a branch 2 times, most recently from 672a71a to ae9f9aa Compare January 22, 2026 14:41
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants