bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0893-dtoverlays-Add-i2c-fan-overlay.patch
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
5
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.
10
11 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
12 ---
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
18
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) += \
22 hy28b-2017.dtbo \
23 i-sabre-q2m.dtbo \
24 i2c-bcm2708.dtbo \
25 + i2c-fan.dtbo \
26 i2c-gpio.dtbo \
27 i2c-mux.dtbo \
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
32 Params: <None>
33
34
35 +Name: i2c-fan
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
40 + specified address.
41 +
42 + i2c0 Choose the I2C0 bus on GPIOs 0&1
43 +
44 + i2c_csi_dsi Choose the I2C0 bus on GPIOs 44&45
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)
52 +
53 + midtemp_hyst Temperature delta (in millicelcius) below
54 + mintemp at which the fan will drop to minrpm
55 + (default 2000)
56 +
57 + maxtemp Temperature (in millicelcius) at which the fan
58 + will be held at maxrpm (default 70000)
59 +
60 + maxtemp_hyst Temperature delta (in millicelcius) below
61 + maxtemp at which the fan begins to slow down
62 + (default 2000)
63 +
64 + emc2301 Select the Microchip EMC230x controller family
65 + - EMC2301, EMC2302, EMC2303, EMC2305.
66 +
67 +
68 Name: i2c-gpio
69 Info: Adds support for software i2c controller on gpio pins
70 Load: dtoverlay=i2c-gpio,<param>=<val>
71 --- /dev/null
72 +++ b/arch/arm/boot/dts/overlays/i2c-fan-overlay.dts
73 @@ -0,0 +1,92 @@
74 +// Definitions for I2C based sensors using the Industrial IO or HWMON interface.
75 +/dts-v1/;
76 +/plugin/;
77 +
78 +#include <dt-bindings/thermal/thermal.h>
79 +
80 +/ {
81 + compatible = "brcm,bcm2835";
82 +
83 + fragment@0 {
84 + target = <&i2cbus>;
85 + __dormant__ {
86 + #address-cells = <1>;
87 + #size-cells = <0>;
88 + status = "okay";
89 +
90 + emc2301: emc2301@2f {
91 + compatible = "microchip,emc2301";
92 + reg = <0x2f>;
93 + status = "okay";
94 + #cooling-cells = <0x02>;
95 + };
96 + };
97 + };
98 +
99 + frag100: fragment@100 {
100 + target = <&i2c_arm>;
101 + i2cbus: __overlay__ {
102 + status = "okay";
103 + };
104 + };
105 +
106 + fragment@101 {
107 + target = <&i2c0if>;
108 + __dormant__ {
109 + status = "okay";
110 + };
111 + };
112 +
113 + fragment@102 {
114 + target = <&i2c0mux>;
115 + __dormant__ {
116 + status = "okay";
117 + };
118 + };
119 +
120 + fragment@103 {
121 + target = <&cpu_thermal>;
122 + polling-delay = <2000>; /* milliseconds */
123 + __overlay__ {
124 + trips {
125 + fanmid0: fanmid0 {
126 + temperature = <50000>;
127 + hysteresis = <2000>;
128 + type = "active";
129 + };
130 + fanmax0: fanmax0 {
131 + temperature = <75000>;
132 + hysteresis = <2000>;
133 + type = "active";
134 + };
135 + };
136 + cooling-maps {
137 + map0: map0 {
138 + trip = <&fanmid0>;
139 + cooling-device = <&emc2301 2 6>;
140 + };
141 + map1: map1 {
142 + trip = <&fanmax0>;
143 + cooling-device = <&emc2301 7 THERMAL_NO_LIMIT>;
144 + };
145 + };
146 + };
147 + };
148 +
149 + __overrides__ {
150 + i2c0 = <&frag100>,"target:0=",<&i2c0>;
151 + i2c_csi_dsi = <&frag100>,"target:0=",<&i2c_csi_dsi>,
152 + <0>,"+101+102";
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";
160 +
161 + emc2301 = <0>,"+0",
162 + <&map0>,"cooling-device:0=",<&emc2301>,
163 + <&map1>,"cooling-device:0=",<&emc2301>;
164 + };
165 +};