raspberry-pi: remove DWC2 module

This commit is contained in:
Jamie Magee committed 2026-09-01 16:17:21 -07:00
1 parent dc3f0cfde2
commit 02545c60be
2 files changed
+63 -80

No files matched your search

+26 -78
View File
@@ -1,86 +1,34 @@
{ config, lib, ... }:
{ lib, ... }:
let
cfg = config.hardware.raspberry-pi."4".dwc2;
in
{
options.hardware = {
raspberry-pi."4".dwc2 = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = ''
Enable the UDC controller to support USB OTG gadget functions.
imports = [
(lib.mkRemovedOptionModule
[
"hardware"
"raspberry-pi"
"4"
"dwc2"
]
''
Use the stock dwc2 firmware overlay instead:
In order to verify that this works, connect the Raspberry Pi with
another computer via the USB C cable, and then do one of:
{
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree =
false;
- `modprobe g_serial`
- `modprobe g_mass_storage file=/path/to/some/iso-file.iso`
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
{ dwc2 = { }; }
];
}
On the Raspberry Pi, `dmesg` should then show success-indicating output
that is related to the dwc2 and g_serial/g_mass_storage modules.
On the other computer, a serial/mass-storage device should pop up in
the system logs.
If you set dr_mode on the old option, add it to the overlay. For
example:
For more information about what gadget functions exist along with handy
guides on how to test them, please refer to:
https://www.kernel.org/doc/Documentation/usb/gadget-testing.txt
'';
};
dr_mode = lib.mkOption {
type = lib.types.enum [
"host"
"peripheral"
"otg"
];
default = "otg";
description = ''
Dual role mode setting for the dwc2 USB controller driver.
'';
};
};
};
{ dwc2.dr_mode = "host"; }
config = lib.mkIf cfg.enable {
# Configure for modesetting in the device tree
hardware.deviceTree = {
overlays = [
# this *should* be equivalent to (which doesn't work):
# https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/dwc2-overlay.dts
# but actually it's obtained using
# dtc -I dtb -O dts ${config.hardware.deviceTree.kernelPackage}/dtbs/overlays/dwc2.dtbo
# (changes: modified top-level "compatible" field)
# which is slightly different and works
{
name = "dwc2-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&usb>;
#address-cells = <0x01>;
#size-cells = <0x01>;
__overlay__ {
compatible = "brcm,bcm2835-usb";
dr_mode = "${cfg.dr_mode}";
g-np-tx-fifo-size = <0x20>;
g-rx-fifo-size = <0x22e>;
g-tx-fifo-size = <0x200 0x200 0x200 0x200 0x200 0x100 0x100>;
status = "okay";
phandle = <0x01>;
};
};
};
'';
}
];
};
};
For CM4 and firmware-partition setup, see "DWC2 USB controller" in
raspberry-pi/README.md.
''
)
];
}