Merge pull request #2084 from JamieMagee/raspberry-pi-split/pwm0

raspberry-pi: migrate PWM0 to its firmware overlay
This commit is contained in:
Doron Behar authored and GitHub committed 2026-10-26 22:47:27 +00:00
commit 8ba09466dc
1 file changed
+31 -43
+31 -43
View File
@@ -1,50 +1,38 @@
{ config, lib, ... }: { lib, ... }:
let
cfg = config.hardware.raspberry-pi."4".pwm0;
in
{ {
options.hardware = { imports = [
raspberry-pi."4".pwm0 = { (lib.mkRemovedOptionModule
enable = lib.mkEnableOption "support for the hardware pwm0 channel on GPIO_18"; [
}; "hardware"
}; "raspberry-pi"
"4"
"pwm0"
]
''
To enable PWM0 on GPIO18, use the pwm firmware overlay:
config = lib.mkIf cfg.enable { {
hardware.deviceTree = { boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false;
overlays = [ hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
{ {
name = "pwm-overlay"; pwm = {
dtsText = '' pin = 18;
/dts-v1/; func = 2;
/plugin/; clock = 100000000;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&gpio>;
__overlay__ {
pwm_pins: pwm_pins {
brcm,pins = <18>;
brcm,function = <2>; /* Alt5 */
};
}; };
}; }
];
}
fragment@1 { The removed pwm0 module explicitly assigned a 100 MHz clock.
target = <&pwm>; Keep clock = 100000000 to preserve that assignment.
__overlay__ { Without clock, the pwm overlay leaves the base clock configuration unchanged:
pinctrl-names = "default"; https://github.com/raspberrypi/linux/blob/rpi-6.18.y/arch/arm/boot/dts/overlays/pwm-overlay.dts
assigned-clock-rates = <100000000>;
status = "okay";
pinctrl-0 = <&pwm_pins>;
};
};
}; Before switching, migrate any remaining hardware.deviceTree.overlays used only in generation DTBs.
''; For firmware installation, read "Device tree overlays" in raspberry-pi/README.md.
} ''
]; )
}; ];
};
} }