Merge tag 'v5.15.57' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / arch / arm / boot / dts / overlays / gpio-fan-overlay.dts
1 /*
2  * Overlay for the Raspberry Pi GPIO Fan @ BCM GPIO12.
3  * References: 
4  *      - https://www.raspberrypi.org/forums/viewtopic.php?f=107&p=1367135#p1365084
5  *
6  * Optional parameters:
7  *      - "gpiopin"     - BCM number of the pin driving the fan, default 12 (GPIO12);
8  *      - "temp"        - CPU temperature at which fan is started in millicelsius, default 55000;
9  *
10  * Requires:
11  *      - kernel configurations: CONFIG_SENSORS_GPIO_FAN=m;
12  *      - kernel rebuild;
13  *      - N-MOSFET connected to gpiopin, 2N7002-[https://en.wikipedia.org/wiki/2N7000];
14  *      - DC Fan connected to N-MOSFET Drain terminal, a 12V fan is working fine and quite silently;
15  *        [https://www.tme.eu/en/details/ee40101s1-999-a/dc12v-fans/sunon/ee40101s1-1000u-999/]
16  *
17  *                   ┌─────────────────────┐
18  *                   │Fan negative terminal│
19  *                   └┬────────────────────┘
20  *                    │D
21  *             G   │──┘
22  * [GPIO12]──────┤ │<─┐  2N7002
23  *                 │──┤
24  *                    │S
25  *                   ─┴─
26  *                   GND
27  *
28  * Build:
29  *      - `sudo dtc -W no-unit_address_vs_reg -@ -I dts -O dtb -o /boot/overlays/gpio-fan.dtbo gpio-fan-overlay.dts`
30  * Activate:
31  *      - sudo nano /boot/config.txt add "dtoverlay=gpio-fan" or "dtoverlay=gpio-fan,gpiopin=12,temp=45000"
32  *       or
33  *      - sudo sh -c 'printf "\n# Enable PI GPIO-Fan Default\ndtoverlay=gpio-fan\n" >> /boot/config.txt'
34  *      - sudo sh -c 'printf "\n# Enable PI GPIO-Fan Custom\ndtoverlay=gpio-fan,gpiopin=12,temp=45000\n" >> /boot/config.txt'
35  *
36  */
37 /dts-v1/;
38 /plugin/;
39
40 / {
41         compatible = "brcm,bcm2835";
42
43         fragment@0 {
44                 target-path = "/";
45                 __overlay__ {
46                         fan0: gpio-fan@0 {
47                                 compatible = "gpio-fan";
48                                 gpios = <&gpio 12 0>;
49                                 gpio-fan,speed-map = <0    0>,
50                                                                          <5000 1>;
51                                 #cooling-cells = <2>;
52                         };
53                 };
54         };
55
56         fragment@1 {
57                 target = <&cpu_thermal>;
58                 polling-delay = <2000>; /* milliseconds */
59                 __overlay__ {
60                         trips {
61                                 cpu_hot: trip-point@0 {
62                                         temperature = <55000>;  /* (millicelsius) Fan started at 55°C */
63                                         hysteresis = <10000>;   /* (millicelsius) Fan stopped at 45°C */
64                                         type = "active";
65                                 };
66                         };
67                         cooling-maps {
68                                 map0 {
69                                         trip = <&cpu_hot>;
70                                         cooling-device = <&fan0 1 1>;
71                                 };
72                         };
73                 };
74         };
75         __overrides__ {
76                 gpiopin = <&fan0>,"gpios:4", <&fan0>,"brcm,pins:0";
77                 temp = <&cpu_hot>,"temperature:0";
78                 hyst = <&cpu_hot>,"hysteresis:0";
79         };
80 };