Sunday, October 30, 2022

sysutils/u-boot: Enable USB-boot on Raspberry Pi CM4

Hi,

The patch below enables USB boot on the Raspberry Pi CM4. See https://forums.raspberrypi.com/viewtopic.php?t=308542 for further explanation. Note that on recent CM4's booting may also require an updated start4.elf.

Kind regards,
Willemijn Coene


diff -uraN a/sysutils/u-boot/patches/patch-configs_rpi_arm64_defconfig b/sysutils/u-boot/patches/patch-configs_rpi_arm64_defconfig
Index: sysutils/u-boot/patches/patch-configs_rpi_arm64_defconfig
--- a/sysutils/u-boot/patches/patch-configs_rpi_arm64_defconfig Thu Jan 1 01:00:00 1970
+++ b/sysutils/u-boot/patches/patch-configs_rpi_arm64_defconfig Sun Oct 30 14:56:46 2022
@@ -0,0 +1,23 @@
+rpi: Add support for Broadcom xHCI host-only USB 2.0 controller
+
+The BCM2711 SoC in the Raspberry Pi 4, 400 and CM4 has two USB controllers:
+
+* a Synopsys DWC2 USB 2.0 controller capable of both host and gadget mode;
+* a Broadcom xHCI host-only USB 2.0 controller.
+
+Either controller can be mux'ed to the USB pins on the SoC at boot time.
+Usually this would be the DWC2 controller. However, when the CM4 boots from
+USB, the firmware switches to the generic xHCI controller, disabling the
+DWC2 until next boot. This patch turns on support for the generic xHCI
+controller, enabling USB boot on the CM4.
+
+--- configs/rpi_arm64_defconfig.orig
++++ configs/rpi_arm64_defconfig
+@@ -40,6 +40,7 @@ CONFIG_SYSINFO_SMBIOS=y
+ CONFIG_USB=y
+ CONFIG_USB_XHCI_HCD=y
+ CONFIG_USB_XHCI_PCI=y
++CONFIG_USB_XHCI_BRCM=y
+ CONFIG_USB_DWC2=y
+ CONFIG_USB_KEYBOARD=y
+ CONFIG_USB_HOST_ETHER=y
diff -uraN a/sysutils/u-boot/patches/patch-drivers_usb_host_xhci-brcm_c b/sysutils/u-boot/patches/patch-drivers_usb_host_xhci-brcm_c
Index: sysutils/u-boot/patches/patch-drivers_usb_host_xhci-brcm_c
--- a/sysutils/u-boot/patches/patch-drivers_usb_host_xhci-brcm_c Thu Jan 1 01:00:00 1970
+++ b/sysutils/u-boot/patches/patch-drivers_usb_host_xhci-brcm_c Sun Oct 30 14:55:33 2022
@@ -0,0 +1,28 @@
+rpi: Fix support for Broadcom xHCI host-only USB 2.0 controller
+
+The BCM2711 SoC in the Raspberry Pi 4, 400 and CM4 has two USB controllers:
+
+* a Synopsys DWC2 USB 2.0 controller capable of both host and gadget mode;
+* a Broadcom xHCI host-only USB 2.0 controller.
+
+This patch fixes compilation of the driver for the latter controller.
+
+--- drivers/usb/host/xhci-brcm.c.orig
++++ drivers/usb/host/xhci-brcm.c
+@@ -9,6 +9,7 @@
+ #include <usb.h>
+ #include <asm/io.h>
+ #include <usb/xhci.h>
++#include <dm/device_compat.h>
+
+ #define DRD2U3H_XHC_REGS_AXIWRA 0xC08
+ #define DRD2U3H_XHC_REGS_AXIRDA 0xC0C
+@@ -81,7 +82,7 @@ static int xhci_brcm_deregister(struct udevice *dev)
+ }
+
+ static const struct udevice_id xhci_brcm_ids[] = {
+- { .compatible = "brcm,generic-xhci" },
++ { .compatible = "generic-xhci" },
+ { }
+ };
+

No comments:

Post a Comment