oxnas: some improvements for Shuttle KD20
authorDaniel Golle <daniel@makrotopia.org>
Sat, 28 Mar 2020 21:55:31 +0000 (21:55 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 31 Mar 2020 20:41:23 +0000 (21:41 +0100)
 * install kmod-hwmon-drivetemp by default
 * wire up thermal zone
 * fix fan GPIO polarity
 * fix i2c-gpio GPIO_OPEN_DRAIN

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/oxnas/config-5.4
target/linux/oxnas/files/arch/arm/boot/dts/ox820-shuttle-kd20.dts
target/linux/oxnas/image/ox820.mk

index 973bbc79dda9cbc563d58319af5b6278db043acd..112d4e43be5f1a674f0af041df247c2dcf2bcbfa 100644 (file)
@@ -328,6 +328,12 @@ CONFIG_SUSPEND=y
 CONFIG_SUSPEND_FREEZER=y
 CONFIG_SWPHY=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_THERMAL=y
+CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
+CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
+CONFIG_THERMAL_GOV_STEP_WISE=y
+CONFIG_THERMAL_HWMON=y
+CONFIG_THERMAL_OF=y
 CONFIG_TICK_CPU_ACCOUNTING=y
 CONFIG_TIMER_OF=y
 CONFIG_TIMER_PROBE=y
index 61ea2b57a74ca483304da439f51ba9bbf81107a1..0bcd2fcf0005fe082e1938d41813f9cceb8914d2 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/thermal/thermal.h>
 
 / {
        model = "Shuttle KD20";
                led-upgrade = &led_warn;
        };
 
+       thermal_zones {
+               chassis-thermal {
+                       /* Poll every 20 seconds */
+                       polling-delay = <20000>;
+                       /* Poll every 2nd second when cooling */
+                       polling-delay-passive = <2000>;
+
+                       thermal-sensors = <&hdd0_temp>, <&hdd1_temp>;
+
+                       trips {
+                               chassis_alert0: chassis-alert0 {
+                                       /* At 43 degrees turn on fan */
+                                       temperature = <43000>;
+                                       hysteresis = <3000>;
+                                       type = "active";
+                               };
+
+                               chassis_alert1: chassis-alert1 {
+                                       /* At 60 degrees emergency shutdown */
+                                       temperature = <60000>;
+                                       hysteresis = <2000>;
+                                       type = "critical";
+                               };
+                       };
+
+                       cooling-maps {
+                               map0 {
+                                       trip = <&chassis_alert0>;
+                                       cooling-device = <&system_fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+                               };
+                       };
+               };
+       };
+
        i2c-gpio {
                compatible = "i2c-gpio";
-               sda-gpios = <&gpio1 9 (GPIO_ACTIVE_HIGH|GPIO_LINE_OPEN_DRAIN)>;
-               sck-gpios = <&gpio1 10 (GPIO_ACTIVE_HIGH|GPIO_LINE_OPEN_DRAIN)>;
+               sda-gpios = <&gpio1 9 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+               sck-gpios = <&gpio1 10 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
                i2c-gpio,delay-us = <10>;
                #address-cells = <1>;
                #size-cells = <0>;
+
                rtc0: rtc@51 {
                        compatible = "nxp,pcf8563";
                        reg = <0x51>;
                gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
        };
 
-       gpio-fan {
+       system_fan: gpio-fan {
                compatible = "gpio-fan";
-               gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
+               gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
                gpio-fan,speed-map = <0    0
                                      3000 1>;
        };
 &sata {
        status = "okay";
        nr-ports = <2>;
+
+       hdd0_temp: sata-port@0 {
+               reg = <0>;
+               #thermal-sensor-cells = <0>;
+       };
+
+       hdd1_temp: sata-port@1 {
+               reg = <1>;
+               #thermal-sensor-cells = <0>;
+       };
 };
 
 &pcie_phy {
index 7a41e1641bc9415aa34d5960f4b2ec56b8bb0585..2a9295bd9719a16179e9edb3a3c36840141592d3 100644 (file)
@@ -73,9 +73,9 @@ define Device/shuttle_kd20
   KERNEL_INITRAMFS = kernel-bin | append-dtb | uImage none | omninas-factory | \
        encrypt-3des sohmuntitnlaes
   DEVICE_PACKAGES := kmod-usb2-oxnas kmod-usb3 kmod-usb-ledtrig-usbport \
-       kmod-i2c-gpio kmod-rtc-pcf8563 kmod-gpio-beeper kmod-hwmon-gpiofan \
-       kmod-ata-oxnas-sata kmod-md-mod kmod-md-raid0 kmod-md-raid1 kmod-fs-ext4 \
-       kmod-fs-xfs
+       kmod-i2c-gpio kmod-rtc-pcf8563 kmod-gpio-beeper kmod-hwmon-drivetemp \
+       kmod-hwmon-gpiofan kmod-ata-oxnas-sata kmod-md-mod kmod-md-raid0 \
+       kmod-md-raid1 kmod-fs-ext4 kmod-fs-xfs
 endef
 TARGET_DEVICES += shuttle_kd20