1 From 4bf62f8dc97e24dadda64762ab47c299ac6eb8cb Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Tue, 3 May 2022 17:20:11 +0100
4 Subject: [PATCH] dtoverlays: Add i2c-fan overlay
6 Add an i2c-fan overlay, initially with support for the EMC2301
7 fan controller found on the CM4IO board.
8 Based on the overlay from Traverse Technologies, but modified for
9 the EMC2305 driver submitted to linux-hwmon.
11 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
13 arch/arm/boot/dts/overlays/Makefile | 1 +
14 arch/arm/boot/dts/overlays/README | 33 +++++++
15 .../arm/boot/dts/overlays/i2c-fan-overlay.dts | 92 +++++++++++++++++++
16 3 files changed, 126 insertions(+)
17 create mode 100644 arch/arm/boot/dts/overlays/i2c-fan-overlay.dts
19 --- a/arch/arm/boot/dts/overlays/Makefile
20 +++ b/arch/arm/boot/dts/overlays/Makefile
21 @@ -85,6 +85,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
28 i2c-pwm-pca9685a.dtbo \
29 --- a/arch/arm/boot/dts/overlays/README
30 +++ b/arch/arm/boot/dts/overlays/README
31 @@ -1530,6 +1530,39 @@ Load: dtoverlay=i2c-bcm2708
36 +Info: Adds support for a number of I2C fan controllers
37 +Load: dtoverlay=i2c-fan,<param>=<val>
38 +Params: addr Sets the address for the fan controller. Note
39 + that the device must be configured to use the
42 + i2c0 Choose the I2C0 bus on GPIOs 0&1
44 + i2c_csi_dsi Choose the I2C0 bus on GPIOs 44&45
46 + minpwm PWM setting for the fan when the SoC is below
47 + mintemp (range 0-255. default 0)
48 + maxpwm PWM setting for the fan when the SoC is above
49 + maxtemp (range 0-255. default 255)
50 + midtemp Temperature (in millicelcius) at which the fan
51 + begins to speed up (default 50000)
53 + midtemp_hyst Temperature delta (in millicelcius) below
54 + mintemp at which the fan will drop to minrpm
57 + maxtemp Temperature (in millicelcius) at which the fan
58 + will be held at maxrpm (default 70000)
60 + maxtemp_hyst Temperature delta (in millicelcius) below
61 + maxtemp at which the fan begins to slow down
64 + emc2301 Select the Microchip EMC230x controller family
65 + - EMC2301, EMC2302, EMC2303, EMC2305.
69 Info: Adds support for software i2c controller on gpio pins
70 Load: dtoverlay=i2c-gpio,<param>=<val>
72 +++ b/arch/arm/boot/dts/overlays/i2c-fan-overlay.dts
74 +// Definitions for I2C based sensors using the Industrial IO or HWMON interface.
78 +#include <dt-bindings/thermal/thermal.h>
81 + compatible = "brcm,bcm2835";
86 + #address-cells = <1>;
90 + emc2301: emc2301@2f {
91 + compatible = "microchip,emc2301";
94 + #cooling-cells = <0x02>;
99 + frag100: fragment@100 {
100 + target = <&i2c_arm>;
101 + i2cbus: __overlay__ {
107 + target = <&i2c0if>;
114 + target = <&i2c0mux>;
121 + target = <&cpu_thermal>;
122 + polling-delay = <2000>; /* milliseconds */
126 + temperature = <50000>;
127 + hysteresis = <2000>;
131 + temperature = <75000>;
132 + hysteresis = <2000>;
139 + cooling-device = <&emc2301 2 6>;
143 + cooling-device = <&emc2301 7 THERMAL_NO_LIMIT>;
150 + i2c0 = <&frag100>,"target:0=",<&i2c0>;
151 + i2c_csi_dsi = <&frag100>,"target:0=",<&i2c_csi_dsi>,
153 + addr = <&emc2301>,"reg:0";
154 + minpwm = <&emc2301>,"emc2305,pwm-min;0";
155 + maxpwm = <&emc2301>,"emc2305,pwm-max;0";
156 + midtemp = <&fanmid0>,"temperature:0";
157 + midtemp_hyst = <&fanmid0>,"hysteresis:0";
158 + maxtemp = <&fanmax0>,"temperature:0";
159 + maxtemp_hyst = <&fanmax0>,"hysteresis:0";
161 + emc2301 = <0>,"+0",
162 + <&map0>,"cooling-device:0=",<&emc2301>,
163 + <&map1>,"cooling-device:0=",<&emc2301>;