2021-06-03 02:47:23 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2022-08-07 11:16:37 +02:00
|
|
|
let
|
2021-06-03 02:47:23 +02:00
|
|
|
cfg = config.hardware.raspberry-pi."4".poe-hat;
|
|
|
|
in {
|
|
|
|
options.hardware = {
|
|
|
|
raspberry-pi."4".poe-hat = {
|
|
|
|
enable = lib.mkEnableOption ''
|
2021-07-30 19:26:52 +02:00
|
|
|
support for the Raspberry Pi POE Hat.
|
2021-06-03 02:47:23 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2022-08-07 11:16:37 +02:00
|
|
|
hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true;
|
|
|
|
|
2021-06-03 02:47:23 +02:00
|
|
|
hardware.deviceTree = {
|
|
|
|
overlays = [
|
2022-08-07 11:16:37 +02:00
|
|
|
# Equivalent to: https://github.com/raspberrypi/linux/blob/rpi-5.15.y/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts
|
2021-06-03 02:47:23 +02:00
|
|
|
{
|
|
|
|
name = "rpi-poe-overlay";
|
|
|
|
dtsText = ''
|
|
|
|
/*
|
|
|
|
* Overlay for the Raspberry Pi POE HAT.
|
|
|
|
*/
|
|
|
|
/dts-v1/;
|
|
|
|
/plugin/;
|
|
|
|
|
|
|
|
/ {
|
|
|
|
compatible = "brcm,bcm2711";
|
|
|
|
|
|
|
|
fragment@0 {
|
|
|
|
target-path = "/";
|
|
|
|
__overlay__ {
|
2022-08-07 11:16:37 +02:00
|
|
|
fan: pwm-fan {
|
|
|
|
compatible = "pwm-fan";
|
2021-06-03 02:47:23 +02:00
|
|
|
cooling-levels = <0 1 10 100 255>;
|
2022-08-07 11:16:37 +02:00
|
|
|
#cooling-cells = <2>;
|
|
|
|
pwms = <&fwpwm 0 80000>;
|
2021-06-03 02:47:23 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fragment@1 {
|
|
|
|
target = <&cpu_thermal>;
|
|
|
|
__overlay__ {
|
|
|
|
trips {
|
|
|
|
trip0: trip0 {
|
|
|
|
temperature = <40000>;
|
|
|
|
hysteresis = <2000>;
|
|
|
|
type = "active";
|
|
|
|
};
|
|
|
|
trip1: trip1 {
|
|
|
|
temperature = <45000>;
|
|
|
|
hysteresis = <2000>;
|
|
|
|
type = "active";
|
|
|
|
};
|
|
|
|
trip2: trip2 {
|
|
|
|
temperature = <50000>;
|
|
|
|
hysteresis = <2000>;
|
|
|
|
type = "active";
|
|
|
|
};
|
|
|
|
trip3: trip3 {
|
|
|
|
temperature = <55000>;
|
|
|
|
hysteresis = <5000>;
|
|
|
|
type = "active";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
cooling-maps {
|
|
|
|
map0 {
|
|
|
|
trip = <&trip0>;
|
2022-08-07 11:16:37 +02:00
|
|
|
cooling-device = <&fan 0 1>;
|
2021-06-03 02:47:23 +02:00
|
|
|
};
|
|
|
|
map1 {
|
|
|
|
trip = <&trip1>;
|
2022-08-07 11:16:37 +02:00
|
|
|
cooling-device = <&fan 1 2>;
|
2021-06-03 02:47:23 +02:00
|
|
|
};
|
|
|
|
map2 {
|
|
|
|
trip = <&trip2>;
|
2022-08-07 11:16:37 +02:00
|
|
|
cooling-device = <&fan 2 3>;
|
2021-06-03 02:47:23 +02:00
|
|
|
};
|
|
|
|
map3 {
|
|
|
|
trip = <&trip3>;
|
2022-08-07 11:16:37 +02:00
|
|
|
cooling-device = <&fan 3 4>;
|
2021-06-03 02:47:23 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fragment@2 {
|
|
|
|
target-path = "/__overrides__";
|
2022-08-07 11:16:37 +02:00
|
|
|
params: __overlay__ {
|
2021-06-03 02:47:23 +02:00
|
|
|
poe_fan_temp0 = <&trip0>,"temperature:0";
|
|
|
|
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
|
|
|
|
poe_fan_temp1 = <&trip1>,"temperature:0";
|
|
|
|
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
|
|
|
|
poe_fan_temp2 = <&trip2>,"temperature:0";
|
|
|
|
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
|
|
|
|
poe_fan_temp3 = <&trip3>,"temperature:0";
|
|
|
|
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
|
2022-08-07 11:16:37 +02:00
|
|
|
poe_fan_i2c = <&fwpwm>,"status=disabled",
|
|
|
|
<&poe_mfd>,"status=okay",
|
|
|
|
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fragment@3 {
|
|
|
|
target = <&firmware>;
|
|
|
|
__overlay__ {
|
|
|
|
fwpwm: pwm {
|
|
|
|
compatible = "raspberrypi,firmware-poe-pwm";
|
|
|
|
#pwm-cells = <2>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fragment@4 {
|
|
|
|
target = <&i2c0>;
|
|
|
|
i2c_bus: __overlay__ {
|
|
|
|
#address-cells = <1>;
|
|
|
|
#size-cells = <0>;
|
|
|
|
|
|
|
|
poe_mfd: poe@51 {
|
|
|
|
compatible = "raspberrypi,poe-core";
|
|
|
|
reg = <0x51>;
|
|
|
|
status = "disabled";
|
|
|
|
|
|
|
|
poe_mfd_pwm: poe_pwm@f0 {
|
|
|
|
compatible = "raspberrypi,poe-pwm";
|
|
|
|
reg = <0xf0>;
|
|
|
|
status = "okay";
|
|
|
|
#pwm-cells = <2>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fragment@5 {
|
|
|
|
target = <&i2c0if>;
|
|
|
|
__dormant__ {
|
|
|
|
status = "okay";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fragment@6 {
|
|
|
|
target = <&i2c0mux>;
|
|
|
|
__dormant__ {
|
|
|
|
status = "okay";
|
2021-06-03 02:47:23 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
__overrides__ {
|
|
|
|
poe_fan_temp0 = <&trip0>,"temperature:0";
|
|
|
|
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
|
|
|
|
poe_fan_temp1 = <&trip1>,"temperature:0";
|
|
|
|
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
|
|
|
|
poe_fan_temp2 = <&trip2>,"temperature:0";
|
|
|
|
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
|
|
|
|
poe_fan_temp3 = <&trip3>,"temperature:0";
|
|
|
|
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
|
2022-08-07 11:16:37 +02:00
|
|
|
i2c = <0>, "+5+6",
|
|
|
|
<&fwpwm>,"status=disabled",
|
|
|
|
<&i2c_bus>,"status=okay",
|
|
|
|
<&poe_mfd>,"status=okay",
|
|
|
|
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
|
2021-06-03 02:47:23 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|