bcm2838_xhci: add module

bcm2838_xhci(4) is a shim for the XHCI controller on the Raspberry Pi 4B
SoC.  It loads the controller's firmware before passing control to the
normal xhci(4) driver.

When xhci(4) is built as a module (and not in the kernel), bcm2838_xhci
is not built at all and the RPi4's XHCI controller won't attach due to
missing firmware.

To fix this, build a new module, bcm2838_xhci.ko, which depends on
xhci.ko.  For the dependency to work correctly, also modify xhci to
provide the 'xhci' module in addition to the 'xhci_pci' module it
already provided.

Since bcm2838_xhci is specific to a quirk of the RPi4 SoC, only build
the module for AArch64.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1142
This commit is contained in:
Lexi Winter 2024-04-09 21:11:36 -06:00 committed by Warner Losh
parent 054a472059
commit ac83063d37
4 changed files with 22 additions and 1 deletions

View file

@ -212,3 +212,5 @@ DEFINE_CLASS_1(bcm_xhci, bcm_xhci_driver, bcm_xhci_methods,
DRIVER_MODULE(bcm_xhci, pci, bcm_xhci_driver, 0, 0);
MODULE_DEPEND(bcm_xhci, usb, 1, 1, 1);
MODULE_DEPEND(bcm_xhci, pci, 1, 1, 1);
MODULE_DEPEND(bcm_xhci, xhci, 1, 1, 1);

View file

@ -4406,3 +4406,5 @@ static const struct usb_bus_methods xhci_bus_methods = {
.set_hw_power_sleep = xhci_set_hw_power_sleep,
.set_endpoint_mode = xhci_set_endpoint_mode,
};
MODULE_VERSION(xhci, 1);

View file

@ -44,7 +44,7 @@ MAKE+=" DEBUG_FLAGS+=-DUSB_REQ_DEBUG"
SUBDIR = usb
SUBDIR += ${_dwc_otg} ehci ${_musb} ohci uhci xhci ${_uss820dci} \
${_atmegadci} ${_avr32dci} ${_rsu} ${_rsufw}
${_atmegadci} ${_avr32dci} ${_rsu} ${_rsufw} ${_bcm2838_xhci}
SUBDIR += ${_rum} ${_run} ${_runfw} ${_uath} upgt usie ural ${_zyd} ${_urtw}
SUBDIR += atp cfumass uhid uhid_snes ukbd ums udbp uep wmt wsp ugold uled \
usbhid
@ -98,6 +98,11 @@ _urtw= urtw
_avr32dci= avr32dci
.endif
.if ${MACHINE_CPUARCH} == "aarch64"
# The bcm2838_xhci shim is specific to the Raspberry Pi 4 SoC.
_bcm2838_xhci= bcm2838_xhci
.endif
.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
${MACHINE_CPUARCH} == "i386"
_uacpi= uacpi

View file

@ -0,0 +1,12 @@
# Copyright (c) 2024 Lexi Winter.
#
# SPDX-License-Identifier: BSD-2-Clause
S= ${SRCTOP}/sys
.PATH: $S/arm/broadcom/bcm2835
KMOD= bcm2838_xhci
SRCS= bcm2838_xhci.c
.include <bsd.kmod.mk>