From f6908a5737f8f6862bd21791ffc4b6c00e70f762 Mon Sep 17 00:00:00 2001 From: pantonshire Date: Sun, 22 Oct 2023 08:39:10 +0100 Subject: [PATCH] device tree overlay for fan --- .gitignore | 2 + Makefile | 15 ++++++ overlay/ws_de_mini_pwmfan.dts | 99 +++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 overlay/ws_de_mini_pwmfan.dts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..233b6ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.dtbo + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f32bd0d --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +DTC := dtc + +overlay_dir := overlay +overlay_bins := $(patsubst %.dts, %.dtbo, $(wildcard $(overlay_dir)/*.dts)) + +overlay: $(overlay_bins) + +clean: + $(RM) $(overlay_bins) + +%.dtbo: %.dts + $(DTC) -O dtb -o $@ $< + +.PHONY: overlay clean + diff --git a/overlay/ws_de_mini_pwmfan.dts b/overlay/ws_de_mini_pwmfan.dts new file mode 100644 index 0000000..522f578 --- /dev/null +++ b/overlay/ws_de_mini_pwmfan.dts @@ -0,0 +1,99 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "brcm,bcm2711"; + + fragment@0 { + target = <&gpio>; + __overlay__ { + pwm_pins: pwm_pins { + brcm,pins = <19>; + brcm,function = <2>; + }; + }; + }; + + fragment@1 { + target = <&pwm>; + __overlay__ { + pinctrl-names = "default"; + pinctrl-0 = <&pwm_pins>; + assigned-clock-rates = <100000000>; + status = "okay"; + }; + }; + + fragment@2 { + target-path = "/"; + __overlay__ { + fan: pwm-fan { + compatible = "pwm-fan"; + cooling-min-state = <0>; + cooling-max-state = <4>; + #cooling-cells = <2>; + cooling-levels = <100 125 150 200 255>; + pwms = <&pwm 1 1000000>; + status = "okay"; + }; + }; + }; + + fragment@3 { + target = <&cpu_thermal>; + __overlay__ { + trips { + trip0: trip0 { + temperature = <35000>; + hysteresis = <2000>; + type = "active"; + }; + trip1: trip1 { + temperature = <40000>; + hysteresis = <2000>; + type = "active"; + }; + trip2: trip2 { + temperature = <45000>; + hysteresis = <2000>; + type = "active"; + }; + trip3: trip3 { + temperature = <50000>; + hysteresis = <5000>; + type = "active"; + }; + }; + cooling-maps { + map0 { + trip = <&trip0>; + cooling-device = <&fan 0 1>; + }; + map1 { + trip = <&trip1>; + cooling-device = <&fan 1 2>; + }; + map2 { + trip = <&trip2>; + cooling-device = <&fan 2 3>; + }; + map3 { + trip = <&trip3>; + cooling-device = <&fan 3 4>; + }; + }; + }; + }; + + __overrides__ { + t0 = <&trip0>,"temperature:0"; + t0_hyst = <&trip0>,"hysteresis:0"; + t1 = <&trip1>,"temperature:0"; + t1_hyst = <&trip1>,"hysteresis:0"; + t2 = <&trip2>,"temperature:0"; + t2_hyst = <&trip2>,"hysteresis:0"; + t3 = <&trip3>,"temperature:0"; + t3_hyst = <&trip3>,"hysteresis:0"; + }; +}; +