Skip to content

Commit

Permalink
Merge to official Raspberry Pi repository
Browse files Browse the repository at this point in the history
  • Loading branch information
herbingk authored Jan 1, 2025
1 parent 6e775b3 commit 539d633
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 33 deletions.
50 changes: 37 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
> [!NOTE]
> This device-tree overlay has been merged to the official Raspberry Pi repository on 01/01/2025 and should be part of Raspberry Pi OS Bookworm with the next firmware release. Below information does still apply, but copying the pwm-gpio-fan.dtbo to /boot/firmware/overlays will not longer be necessary.
# pwm-gpio-fan overlay

Raspberry Pi device-tree overlay for a GPIO connected PWM cooling fan controlled by the software-based GPIO PWM kernel module
Expand Down Expand Up @@ -47,19 +50,40 @@ This made me write the **pwm-gpio-fan** overlay for my own use and publish it he

There are several parameters you can specifity in the /boot/firmware/config.txt command line to customize the behaviour of the overlay:

- "fan_gpio" BCM number of the pin driving the fan, default 18 (GPIO 18)
- "fan_temp0" CPU temperature at which fan is started with low speed in millicelsius, default 55000 (55 °C)
- "fan_temp1" CPU temperature at which fan is switched to medium speed in millicelsius, default 60000 (60 °C)
- "fan_temp2" CPU temperature at which fan is switched to high speed in millicelsius, default 67500 (67.5 °C)
- "fan_temp3" CPU temperature at which fan is switched to max speed in millicelsius, default 75000 (75 °C)
- "fan_temp0_hyst" Temperature hysteris at which fan is stopped in millicelsius, default 5000 (resulting in 50 °C)
- "fan_temp1_hyst" Temperature hysteris at which fan is switched back to low speed in millicelsius, default 5000 (resulting in 55 °C)
- "fan_temp2_hyst" Temperature hysteris at which fan is switched back to medium speed in millicelsius, default 5000 (resulting in 62.5 °C)
- "fan_temp3_hyst" Temperature hysteris at which fan is switched back to high speed in millicelsius, default 5000 (resulting in 70 °C)
- "fan_temp0_speed" Fan speed for low cooling state in range 0 to 255, default 114 (45% PWM duty cycle)
- "fan_temp1_speed" Fan speed for medium cooling state in range 0 to 255, default 152 (60% PWM duty cycle)
- "fan_temp2_speed" Fan speed for high cooling state in range 0 to 255, default 204 (80% PWM duty cycle)
- "fan_temp3_speed" Fan speed for max cooling state in range 0 to 255, default 255 (100% PWM duty cycle)
fan_gpio BCM number of the pin driving the fan,
default 18 (GPIO 18)
fan_temp0 CPU temperature at which fan is started with
low speed in millicelsius,
default 55000 (55 °C)
fan_temp1 CPU temperature at which fan is switched
to medium speed in millicelsius,
default 60000 (60 °C)
fan_temp2 CPU temperature at which fan is switched
to high speed in millicelsius,
default 67500 (67.5 °C)
fan_temp3 CPU temperature at which fan is switched
to max speed in millicelsius,
default 75000 (75 °C)
fan_temp0_hyst Temperature hysteris at which fan is stopped
in millicelsius,default 5000 (resulting
in 50 °C)
fan_temp1_hyst Temperature hysteris at which fan is switched
back to low speed in millicelsius,
default 5000 (resulting in 55 °C)
fan_temp2_hyst Temperature hysteris at which fan is switched
back to medium speed in millicelsius,
default 5000 (resulting in 62.5 °C)
fan_temp3_hyst Temperature hysteris at which fan is switched
back to high speed in millicelsius,
default 5000 (resulting in 70 °C)
fan_temp0_speed Fan speed for low cooling state in range
0 to 255, default 114 (45% PWM duty cycle)
fan_temp1_speed Fan speed for medium cooling state in range
0 to 255, default 152 (60% PWM duty cycle)
fan_temp2_speed Fan speed for high cooling state in range
0 to 255, default 204 (80% PWM duty cycle)
fan_temp3_speed Fan speed for max cooling state in range
0 to 255, default 255 (100% PWM duty cycle)

> [!NOTE]
> Lowest temperature default is set to 55 °C, to keep the fan off when the Pi is idle. PWM duty cycles start from a rather high 45% to ensure the fan is started reliable. Many small fans have difficulties to start reliable at low duty cycle values.
Expand Down
53 changes: 33 additions & 20 deletions pwm-gpio-fan-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@
*
* Optional parameters:
* - "fan_gpio" BCM number of the pin driving the fan, default 18 (GPIO18)
* - "fan_temp0" CPU temperature at which fan is started with low speed in millicelsius, default 55000 (55 °C)
* - "fan_temp1" CPU temperature at which fan is switched to medium speed in millicelsius, default 60000 (60 °C)
* - "fan_temp2" CPU temperature at which fan is switched to high speed in millicelsius, default 67500 (67.5 °C)
* - "fan_temp3" CPU temperature at which fan is switched to max speed in millicelsius, default 75000 (75 °C)
* - "fan_temp0_hyst" Temperature hysteris at which fan is stopped in millicelsius, default 5000 (resulting in 50 °C)
* - "fan_temp1_hyst" Temperature hysteris at which fan is switched back to low speed in millicelsius, default 5000 (resulting in 55 °C)
* - "fan_temp2_hyst" Temperature hysteris at which fan is switched back to medium speed in millicelsius, default 5000 (resulting in 62.5 °C)
* - "fan_temp3_hyst" Temperature hysteris at which fan is switched back to high speed in millicelsius, default 5000 (resulting in 70 °C)
* - "fan_temp0_speed" Fan speed for low cooling state in range 0 to 255, default 114 (45% PWM duty cycle)
* - "fan_temp1_speed" Fan speed for medium cooling state in range 0 to 255, default 152 (60% PWM duty cycle)
* - "fan_temp2_speed" Fan speed for high cooling state in range 0 to 255, default 204 (80% PWM duty cycle)
* - "fan_temp3_speed" Fan speed for max cooling state in range 0 to 255, default 255 (100% PWM duty cycle)
*
* - "fan_temp0" CPU temperature at which fan is started with low speed in millicelsius,
* default 55000 (55 °C)
* - "fan_temp1" CPU temperature at which fan is switched to medium speed in millicelsius,
* default 60000 (60 °C)
* - "fan_temp2" CPU temperature at which fan is switched to high speed in millicelsius,
* default 67500 (67.5 °C)
* - "fan_temp3" CPU temperature at which fan is switched to max speed in millicelsius,
* default 75000 (75 °C)
* - "fan_temp0_hyst" Temperature hysteris at which fan is stopped in millicelsius,
* default 5000 (resulting in 50 °C)
* - "fan_temp1_hyst" Temperature hysteris at which fan is switched back to low speed
* in millicelsius, default 5000 (resulting in 55 °C)
* - "fan_temp2_hyst" Temperature hysteris at which fan is switched back to medium speed
* in millicelsius, default 5000 (resulting in 62.5 °C)
* - "fan_temp3_hyst" Temperature hysteris at which fan is switched back to high speed
* in millicelsius, default 5000 (resulting in 70 °C)
* - "fan_temp0_speed" Fan speed for low cooling state in range 0 to 255,
* default 114 (45% PWM duty cycle)
* - "fan_temp1_speed" Fan speed for medium cooling state in range 0 to 255,
* default 152 (60% PWM duty cycle)
* - "fan_temp2_speed" Fan speed for high cooling state in range 0 to 255,
* default 204 (80% PWM duty cycle)
* - "fan_temp3_speed" Fan speed for max cooling state in range 0 to 255,
* default 255 (100% PWM duty cycle)
*
* N.B.
* - Uses the software GPIO PWM kernel module instead of the Pis hardware PWMs (PWM0/PWM1).
Expand Down Expand Up @@ -73,8 +86,8 @@

cooling-min-state = <0>;
cooling-max-state = <4>;
/* PWM duty cycle values in a range from 0 to 255
which correspond to thermal cooling states 0 to 4 */
/* PWM duty cycle values in a range from 0 to 255 */
/* which correspond to thermal cooling states 0 to 4 */
cooling-levels = <0 114 152 204 255>;
};
};
Expand Down Expand Up @@ -138,20 +151,20 @@
};

__overrides__ {
fan_gpio = <&pwm_gpio>,"gpios:4",
fan_gpio = <&pwm_gpio>,"gpios:4",
<&pwm_gpio_pins>,"brcm,pins:0";
fan_temp0 = <&trip0>,"temperature:0";
fan_temp0_hyst = <&trip0>,"hysteresis:0";
fan_temp0_speed = <&fan0>,"cooling-levels:4";
fan_temp0_speed = <&fan0>,"cooling-levels:4";
fan_temp1 = <&trip1>,"temperature:0";
fan_temp1_hyst = <&trip1>,"hysteresis:0";
fan_temp1_speed = <&fan0>,"cooling-levels:8";
fan_temp1_speed = <&fan0>,"cooling-levels:8";
fan_temp2 = <&trip2>,"temperature:0";
fan_temp2_hyst = <&trip2>,"hysteresis:0";
fan_temp2_speed = <&fan0>,"cooling-levels:12";
fan_temp2_speed = <&fan0>,"cooling-levels:12";
fan_temp3 = <&trip3>,"temperature:0";
fan_temp3_hyst = <&trip3>,"hysteresis:0";
fan_temp3_speed = <&fan0>,"cooling-levels:16";
fan_temp3_speed = <&fan0>,"cooling-levels:16";
};

};

0 comments on commit 539d633

Please sign in to comment.