Skip to content

Commit 239f6e9

Browse files
XECDesignpopcornmix
authored andcommitted
Add rpi-poe-fan driver
Signed-off-by: Serge Schneider <[email protected]> PoE HAT driver cleanup * Fix undeclared variable in rpi_poe_fan_suspend * Add SPDX-License-Identifier * Expand PoE acronym in Kconfig help * Give clearer error message on of_property_count_u32_elems fail * Add documentation * Add vendor to of_device_id compatible string. * Rename m_data_s struct to fw_data_s * Fix typos Fixes: #2665 Signed-off-by: Serge Schneider <[email protected]>
1 parent 52ca680 commit 239f6e9

File tree

11 files changed

+590
-0
lines changed

11 files changed

+590
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Bindings for the Raspberry Pi PoE HAT fan
2+
3+
Required properties:
4+
- compatible : "raspberrypi,rpi-poe-fan"
5+
- firmware : Reference to the RPi firmware device node
6+
- pwms : the PWM that is used to control the PWM fan
7+
- cooling-levels : PWM duty cycle values in a range from 0 to 255
8+
which correspond to thermal cooling states
9+
10+
Example:
11+
fan0: rpi-poe-fan@0 {
12+
compatible = "raspberrypi,rpi-poe-fan";
13+
firmware = <&firmware>;
14+
cooling-min-state = <0>;
15+
cooling-max-state = <3>;
16+
#cooling-cells = <2>;
17+
cooling-levels = <0 50 150 255>;
18+
status = "okay";
19+
};
20+
21+
thermal-zones {
22+
cpu_thermal: cpu-thermal {
23+
trips {
24+
threshold: trip-point@0 {
25+
temperature = <45000>;
26+
hysteresis = <5000>;
27+
type = "active";
28+
};
29+
target: trip-point@1 {
30+
temperature = <50000>;
31+
hysteresis = <2000>;
32+
type = "active";
33+
};
34+
cpu_hot: cpu_hot@0 {
35+
temperature = <55000>;
36+
hysteresis = <2000>;
37+
type = "active";
38+
};
39+
};
40+
cooling-maps {
41+
map0 {
42+
trip = <&threshold>;
43+
cooling-device = <&fan0 0 1>;
44+
};
45+
map1 {
46+
trip = <&target>;
47+
cooling-device = <&fan0 1 2>;
48+
};
49+
map2 {
50+
trip = <&cpu_hot>;
51+
cooling-device = <&fan0 2 3>;
52+
};
53+
};
54+
};
55+
};

Documentation/hwmon/rpi-poe-fan

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Kernel driver rpi-poe-fan
2+
=====================
3+
4+
This driver enables the use of the Raspberry Pi PoE HAT fan.
5+
6+
Author: Serge Schneider <[email protected]>
7+
8+
Description
9+
-----------
10+
11+
The driver implements a simple interface for driving the Raspberry Pi PoE
12+
(Power over Ethernet) HAT fan. The driver passes commands to the Raspberry Pi
13+
firmware through the mailbox property interface. The firmware then forwards
14+
the commands to the board over I2C on the ID_EEPROM pins. The driver exposes
15+
the fan to the user space through the hwmon sysfs interface.

arch/arm/boot/dts/overlays/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
100100
rpi-dac.dtbo \
101101
rpi-display.dtbo \
102102
rpi-ft5406.dtbo \
103+
rpi-poe.dtbo \
103104
rpi-proto.dtbo \
104105
rpi-sense.dtbo \
105106
rpi-tv.dtbo \

arch/arm/boot/dts/overlays/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,12 @@ Params: touchscreen-size-x Touchscreen X resolution (default 800)
15151515
touchscreen-swapped-x-y Swap X and Y cordinates (default 0);
15161516

15171517

1518+
Name: rpi-poe
1519+
Info: Raspberry Pi POE HAT
1520+
Load: dtoverlay=rpi-poe
1521+
Params: <None>
1522+
1523+
15181524
Name: rpi-proto
15191525
Info: Configures the RPi Proto audio card
15201526
Load: dtoverlay=rpi-proto
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Overlay for the Raspberry Pi POE HAT.
3+
*/
4+
/dts-v1/;
5+
/plugin/;
6+
7+
/ {
8+
compatible = "brcm,bcm2708";
9+
10+
fragment@0 {
11+
target-path = "/";
12+
__overlay__ {
13+
fan0: rpi-poe-fan@0 {
14+
compatible = "raspberrypi,rpi-poe-fan";
15+
firmware = <&firmware>;
16+
cooling-min-state = <0>;
17+
cooling-max-state = <3>;
18+
#cooling-cells = <2>;
19+
cooling-levels = <0 50 150 255>;
20+
status = "okay";
21+
};
22+
};
23+
};
24+
25+
fragment@1 {
26+
target = <&cpu_thermal>;
27+
__overlay__ {
28+
trips {
29+
threshold: trip-point@0 {
30+
temperature = <45000>;
31+
hysteresis = <5000>;
32+
type = "active";
33+
};
34+
target: trip-point@1 {
35+
temperature = <50000>;
36+
hysteresis = <2000>;
37+
type = "active";
38+
};
39+
cpu_hot: cpu_hot@0 {
40+
temperature = <55000>;
41+
hysteresis = <2000>;
42+
type = "active";
43+
};
44+
};
45+
cooling-maps {
46+
map0 {
47+
trip = <&threshold>;
48+
cooling-device = <&fan0 0 1>;
49+
};
50+
map1 {
51+
trip = <&target>;
52+
cooling-device = <&fan0 1 2>;
53+
};
54+
map2 {
55+
trip = <&cpu_hot>;
56+
cooling-device = <&fan0 2 3>;
57+
};
58+
};
59+
};
60+
};
61+
};

arch/arm/configs/bcm2709_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ CONFIG_HWMON=m
659659
CONFIG_SENSORS_DS1621=m
660660
CONFIG_SENSORS_JC42=m
661661
CONFIG_SENSORS_LM75=m
662+
CONFIG_SENSORS_RPI_POE_FAN=m
662663
CONFIG_SENSORS_SHT21=m
663664
CONFIG_SENSORS_SHT3x=m
664665
CONFIG_SENSORS_SHTC1=m

arch/arm/configs/bcmrpi_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ CONFIG_HWMON=m
652652
CONFIG_SENSORS_DS1621=m
653653
CONFIG_SENSORS_JC42=m
654654
CONFIG_SENSORS_LM75=m
655+
CONFIG_SENSORS_RPI_POE_FAN=m
655656
CONFIG_SENSORS_SHT21=m
656657
CONFIG_SENSORS_SHT3x=m
657658
CONFIG_SENSORS_SHTC1=m

drivers/hwmon/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,17 @@ config SENSORS_RASPBERRYPI_HWMON
13301330
This driver can also be built as a module. If so, the module
13311331
will be called raspberrypi-hwmon.
13321332

1333+
config SENSORS_RPI_POE_FAN
1334+
tristate "Raspberry Pi PoE HAT fan"
1335+
depends on RASPBERRYPI_FIRMWARE
1336+
depends on THERMAL || THERMAL=n
1337+
help
1338+
If you say yes here you get support for Raspberry Pi PoE (Power over
1339+
Ethernet) HAT fan.
1340+
1341+
This driver can also be built as a module. If so, the module
1342+
will be called rpi-poe-fan.
1343+
13331344
config SENSORS_SHT15
13341345
tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
13351346
depends on GPIOLIB || COMPILE_TEST

drivers/hwmon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
144144
obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o
145145
obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o
146146
obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o
147+
obj-$(CONFIG_SENSORS_RPI_POE_FAN) += rpi-poe-fan.o
147148
obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o
148149
obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o
149150
obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o

0 commit comments

Comments
 (0)