From b0a456b8245366f18f480f347524346cbefef7de Mon Sep 17 00:00:00 2001 From: James Walker Date: Wed, 19 May 2021 21:15:38 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=8A=20get=20rpi=20poe=20fans=20working?= =?UTF-8?q?!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hosts/aristotle/configuration.nix | 1 + hosts/aristotle/hardware-configuration.nix | 2 +- hosts/aristotle/rpi-poe.nix | 109 +++++++++++++++++++++ nix/sources.json | 12 +-- 4 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 hosts/aristotle/rpi-poe.nix diff --git a/hosts/aristotle/configuration.nix b/hosts/aristotle/configuration.nix index 8a1b1d0..c7435f2 100644 --- a/hosts/aristotle/configuration.nix +++ b/hosts/aristotle/configuration.nix @@ -3,6 +3,7 @@ { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ./rpi-poe.nix ]; # Use the extlinux boot loader. (NixOS wants to enable GRUB by default) diff --git a/hosts/aristotle/hardware-configuration.nix b/hosts/aristotle/hardware-configuration.nix index bb1fa45..3285e7b 100644 --- a/hosts/aristotle/hardware-configuration.nix +++ b/hosts/aristotle/hardware-configuration.nix @@ -12,7 +12,7 @@ boot.extraModulePackages = [ ]; fileSystems."/" = { - device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888"; + device = "/dev/disk/by-label/NIXOS_SD"; fsType = "ext4"; }; diff --git a/hosts/aristotle/rpi-poe.nix b/hosts/aristotle/rpi-poe.nix new file mode 100644 index 0000000..116b6b0 --- /dev/null +++ b/hosts/aristotle/rpi-poe.nix @@ -0,0 +1,109 @@ +{ config, lib, pkgs, ... }: + +{ + hardware = { + deviceTree = { + filter = "bcm2711-rpi-*.dtb"; + overlays = [{ + name = "rpi-poe"; + dtsText = '' + /* + * Overlay for the Raspberry Pi POE HAT. + */ + /dts-v1/; + /plugin/; + + / { + compatible = "brcm,bcm2711"; + + fragment@0 { + target-path = "/"; + __overlay__ { + fan0: rpi-poe-fan@0 { + compatible = "raspberrypi,rpi-poe-fan"; + firmware = <&firmware>; + cooling-min-state = <0>; + cooling-max-state = <4>; + #cooling-cells = <2>; + cooling-levels = <0 1 10 100 255>; + status = "okay"; + }; + }; + }; + + 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>; + cooling-device = <&fan0 0 1>; + }; + map1 { + trip = <&trip1>; + cooling-device = <&fan0 1 2>; + }; + map2 { + trip = <&trip2>; + cooling-device = <&fan0 2 3>; + }; + map3 { + trip = <&trip3>; + cooling-device = <&fan0 3 4>; + }; + }; + }; + }; + + fragment@2 { + target-path = "/__overrides__"; + __overlay__ { + 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"; + }; + }; + + __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"; + }; + }; + ''; + }]; + }; + }; +} diff --git a/nix/sources.json b/nix/sources.json index 063e136..c00a119 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": "https://github.com/nmattia/niv", "owner": "nmattia", "repo": "niv", - "rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e", - "sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n", + "rev": "94080ae8286024820c570a2a24ed7c36d7ad04a9", + "sha256": "0wlk52zwlrq727x3z1vg9d9qq4zw62ab5jzg4068iqb6hyb0cr0w", "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz", + "url": "https://github.com/nmattia/niv/archive/94080ae8286024820c570a2a24ed7c36d7ad04a9.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { @@ -17,10 +17,10 @@ "homepage": "", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1c16013bd6e94da748b41cc123c6b509a23eb440", - "sha256": "1m2wif0qnci0q14plbqlb95vx214pxqgw5li86lyw6hsiy7y3zfn", + "rev": "7013a0f2791da4c38c7e6f56d48139aeb344991b", + "sha256": "1az617wpx535nfn0rz63cyvv8b5rlsp80cdq07da2dws8zzylnbm", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/1c16013bd6e94da748b41cc123c6b509a23eb440.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/7013a0f2791da4c38c7e6f56d48139aeb344991b.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } }