mirror of
https://github.com/NixOS/nixos-hardware.git
synced 2026-11-30 13:03:30 +01:00
Merge pull request #2084 from JamieMagee/raspberry-pi-split/pwm0
raspberry-pi: migrate PWM0 to its firmware overlay
This commit is contained in:
1 file changed
+31
-43
+31
-43
@@ -1,50 +1,38 @@
|
||||
{ config, lib, ... }:
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.hardware.raspberry-pi."4".pwm0;
|
||||
in
|
||||
{
|
||||
options.hardware = {
|
||||
raspberry-pi."4".pwm0 = {
|
||||
enable = lib.mkEnableOption "support for the hardware pwm0 channel on GPIO_18";
|
||||
};
|
||||
};
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule
|
||||
[
|
||||
"hardware"
|
||||
"raspberry-pi"
|
||||
"4"
|
||||
"pwm0"
|
||||
]
|
||||
''
|
||||
To enable PWM0 on GPIO18, use the pwm firmware overlay:
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware.deviceTree = {
|
||||
overlays = [
|
||||
{
|
||||
name = "pwm-overlay";
|
||||
dtsText = ''
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
/ {
|
||||
compatible = "brcm,bcm2711";
|
||||
|
||||
fragment@0 {
|
||||
target = <&gpio>;
|
||||
__overlay__ {
|
||||
pwm_pins: pwm_pins {
|
||||
brcm,pins = <18>;
|
||||
brcm,function = <2>; /* Alt5 */
|
||||
};
|
||||
{
|
||||
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false;
|
||||
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
|
||||
{
|
||||
pwm = {
|
||||
pin = 18;
|
||||
func = 2;
|
||||
clock = 100000000;
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
fragment@1 {
|
||||
target = <&pwm>;
|
||||
__overlay__ {
|
||||
pinctrl-names = "default";
|
||||
assigned-clock-rates = <100000000>;
|
||||
status = "okay";
|
||||
pinctrl-0 = <&pwm_pins>;
|
||||
};
|
||||
};
|
||||
The removed pwm0 module explicitly assigned a 100 MHz clock.
|
||||
Keep clock = 100000000 to preserve that assignment.
|
||||
Without clock, the pwm overlay leaves the base clock configuration unchanged:
|
||||
https://github.com/raspberrypi/linux/blob/rpi-6.18.y/arch/arm/boot/dts/overlays/pwm-overlay.dts
|
||||
|
||||
};
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
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.
|
||||
''
|
||||
)
|
||||
];
|
||||
}
|
||||
Reference in new issue
Block a user