diff mbox series

[1/2] ipq807x: ZyXEL NBG7815: add fan support

Message ID 20230217235652.2184875-2-mrkiko.rs@gmail.com
State New
Headers show
Series ipq807x: ZyXEL NBG7815: add fan support | expand

Commit Message

Enrico Mioso Feb. 17, 2023, 11:56 p.m. UTC
Add on/off fan support for the ZyXEL NBG7815. Single CPU cores, cluster
CPU temperatures and the Aquantia PHY temperature sensor are monitored. The
tmp103 sensor is missing from this patch, and can be added later, when kernel
is bumped to 6.x, as it seems to require non-trivial hwmon backporting.
Add kmod-phy-aquantia as default package while at it.

Note: this patch has been marked RFT, since temperature values tuning is
needed from someone actively using this device in high load conditions.
Thanks to robimarko for helping me out.

CC: Andre Valentin <avalentin@marcant.net>
CC: Karol Przybylski <karol.przybylski@esm-technology.pl>
Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
---
 .../arm64/boot/dts/qcom/ipq8074-nbg7815.dts   | 119 ++++++++++++++++++
 target/linux/ipq807x/image/generic.mk         |   2 +-
 2 files changed, 120 insertions(+), 1 deletion(-)

Comments

Robert Marko Feb. 18, 2023, 11:50 a.m. UTC | #1
On Sat, 18 Feb 2023 at 00:58, Enrico Mioso <mrkiko.rs@gmail.com> wrote:
>
> Add on/off fan support for the ZyXEL NBG7815. Single CPU cores, cluster
> CPU temperatures and the Aquantia PHY temperature sensor are monitored. The
> tmp103 sensor is missing from this patch, and can be added later, when kernel
> is bumped to 6.x, as it seems to require non-trivial hwmon backporting.
> Add kmod-phy-aquantia as default package while at it.
>
> Note: this patch has been marked RFT, since temperature values tuning is
> needed from someone actively using this device in high load conditions.
> Thanks to robimarko for helping me out.
>
> CC: Andre Valentin <avalentin@marcant.net>
> CC: Karol Przybylski <karol.przybylski@esm-technology.pl>
> Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
> ---
>  .../arm64/boot/dts/qcom/ipq8074-nbg7815.dts   | 119 ++++++++++++++++++
>  target/linux/ipq807x/image/generic.mk         |   2 +-
>  2 files changed, 120 insertions(+), 1 deletion(-)
>
> diff --git a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
> index 537dd52032..0ec602cf31 100644
> --- a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
> +++ b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
> @@ -39,6 +39,22 @@
>                         gpios = <&tlmm 54 GPIO_ACTIVE_LOW>;
>                 };
>         };
> +
> +       fan: gpio_fan {
> +               compatible = "gpio-fan";
> +               gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>;
> +               gpio-fan,speed-map = <0    0
> +                                                       4500 1>;
> +               #cooling-cells = <2>;
> +       };
> +
> +       thermal-zones {
> +               aqr_thermal: aqr-thermal {

This is weird, why are you adding only the thermal zone here, then
using the label to add the trips and cooling device
down in the DTS?

> +                       polling-delay-passive = <1000>;
> +                       polling-delay = <1000>;
> +                       thermal-sensors = <&aqr113c>;
> +               };
> +       };
>  };
>
>  &tlmm {
> @@ -291,6 +307,7 @@
>                 compatible = "ethernet-phy-ieee802.3-c45";
>                 reg = <8>;
>                 reset-gpios = <&tlmm 63 GPIO_ACTIVE_LOW>;
> +               #thermal-sensor-cells = <0>;
>         };
>  };
>
> @@ -443,3 +460,105 @@
>
>         qcom,ath11k-calibration-variant = "Zyxel-NBG7815";
>  };
> +
> +&cpu0_thermal {
> +       trips {
> +               cpu0_active: cpu0-active {
> +                       temperature = <70000>;
> +                       hysteresis = <5000>;
> +                       type = "active";
> +               };
> +       };
> +
> +       cooling-maps {
> +               map1 {
> +                       trip = <&cpu0_active>;
> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
> +               };
> +       };
> +};
> +
> +&cpu1_thermal {
> +       trips {
> +               cpu1_active: cpu1-active {
> +                       temperature = <70000>;
> +                       hysteresis = <5000>;
> +                       type = "active";
> +               };
> +       };
> +
> +       cooling-maps {
> +               map1 {
> +                       trip = <&cpu1_active>;
> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
> +               };
> +       };
> +};
> +
> +&cpu2_thermal {
> +       trips {
> +               cpu2_active: cpu2-active {
> +                       temperature = <70000>;
> +                       hysteresis = <5000>;
> +                       type = "active";
> +               };
> +       };
> +
> +       cooling-maps {
> +               map1 {
> +                       trip = <&cpu2_active>;
> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
> +               };
> +       };
> +};
> +
> +&cpu3_thermal {
> +       trips {
> +               cpu3_active: cpu3-active {
> +                       temperature = <70000>;
> +                       hysteresis = <5000>;
> +                       type = "active";
> +               };
> +       };
> +
> +       cooling-maps {
> +               map1 {
> +                       trip = <&cpu3_active>;
> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
> +               };
> +       };
> +};
> +
> +&cluster_thermal {
> +       trips {
> +               cluster_active: cluster-active {
> +                       temperature = <70000>;
> +                       hysteresis = <5000>;
> +                       type = "active";
> +               };
> +       };
> +
> +       cooling-maps {
> +               map1 {
> +                       trip = <&cluster_active>;
> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
> +               };
> +       };
> +};
> +
> +&aqr_thermal {

This ties into my question for the zone, why not just add it directly
in the node?
> +       trips {
> +               aqr_thermal_active: aqr-thermal-active {
> +                       temperature = <70000>;
> +                       hysteresis = <5000>;
> +                       type = "active";
> +               };
> +       };
> +
> +       cooling-maps {
> +               map1 {
> +                       trip = <&aqr_thermal_active>;
> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
> +               };
> +       };
> +};
> diff --git a/target/linux/ipq807x/image/generic.mk b/target/linux/ipq807x/image/generic.mk
> index 38770a5f24..bbdb8c5d8b 100644
> --- a/target/linux/ipq807x/image/generic.mk
> +++ b/target/linux/ipq807x/image/generic.mk
> @@ -141,6 +141,6 @@ define Device/zyxel_nbg7815
>         IMAGES += factory.bin sysupgrade.bin
>         IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 64k
>         IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to 64k | sysupgrade-tar rootfs=$$$$@ | append-metadata
> -       DEVICE_PACKAGES := ipq-wifi-zyxel_nbg7815 kmod-ath11k-pci e2fsprogs kmod-fs-ext4 losetup kmod-hwmon-tmp103
> +       DEVICE_PACKAGES := ipq-wifi-zyxel_nbg7815 kmod-ath11k-pci e2fsprogs kmod-fs-ext4 losetup kmod-hwmon-tmp103 kmod-hwmon-gpiofan kmod-phy-aquantia
>  endef

No need to add AQR kmod as it's included by default on the target.

Regards,
Robert
>  TARGET_DEVICES += zyxel_nbg7815
> --
> 2.39.2
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Enrico Mioso Feb. 18, 2023, 8:43 p.m. UTC | #2
On Sat, 18 Feb 2023, Robert Marko wrote:

> Date: Sat, 18 Feb 2023 12:50:19
> From: Robert Marko <robimarko@gmail.com>
> To: Enrico Mioso <mrkiko.rs@gmail.com>
> Cc: openwrt-devel@lists.openwrt.org, Andre Valentin <avalentin@marcant.net>,
>     Karol Przybylski <karol.przybylski@esm-technology.pl>
> Subject: Re: [PATCH 1/2] ipq807x: ZyXEL NBG7815: add fan support
> 
> On Sat, 18 Feb 2023 at 00:58, Enrico Mioso <mrkiko.rs@gmail.com> wrote:
>>
>> Add on/off fan support for the ZyXEL NBG7815. Single CPU cores, cluster
>> CPU temperatures and the Aquantia PHY temperature sensor are monitored. The
>> tmp103 sensor is missing from this patch, and can be added later, when kernel
>> is bumped to 6.x, as it seems to require non-trivial hwmon backporting.
>> Add kmod-phy-aquantia as default package while at it.
>>
>> Note: this patch has been marked RFT, since temperature values tuning is
>> needed from someone actively using this device in high load conditions.
>> Thanks to robimarko for helping me out.
>>
>> CC: Andre Valentin <avalentin@marcant.net>
>> CC: Karol Przybylski <karol.przybylski@esm-technology.pl>
>> Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
>> ---
>>  .../arm64/boot/dts/qcom/ipq8074-nbg7815.dts   | 119 ++++++++++++++++++
>>  target/linux/ipq807x/image/generic.mk         |   2 +-
>>  2 files changed, 120 insertions(+), 1 deletion(-)
>>
>> diff --git a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
>> index 537dd52032..0ec602cf31 100644
>> --- a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
>> +++ b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
>> @@ -39,6 +39,22 @@
>>                         gpios = <&tlmm 54 GPIO_ACTIVE_LOW>;
>>                 };
>>         };
>> +
>> +       fan: gpio_fan {
>> +               compatible = "gpio-fan";
>> +               gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>;
>> +               gpio-fan,speed-map = <0    0
>> +                                                       4500 1>;
>> +               #cooling-cells = <2>;
>> +       };
>> +
>> +       thermal-zones {
>> +               aqr_thermal: aqr-thermal {
>
> This is weird, why are you adding only the thermal zone here, then
> using the label to add the trips and cooling device
> down in the DTS?
>
>> +                       polling-delay-passive = <1000>;
>> +                       polling-delay = <1000>;
>> +                       thermal-sensors = <&aqr113c>;
>> +               };
>> +       };
>>  };
>>
>>  &tlmm {
>> @@ -291,6 +307,7 @@
>>                 compatible = "ethernet-phy-ieee802.3-c45";
>>                 reg = <8>;
>>                 reset-gpios = <&tlmm 63 GPIO_ACTIVE_LOW>;
>> +               #thermal-sensor-cells = <0>;
>>         };
>>  };
>>
>> @@ -443,3 +460,105 @@
>>
>>         qcom,ath11k-calibration-variant = "Zyxel-NBG7815";
>>  };
>> +
>> +&cpu0_thermal {
>> +       trips {
>> +               cpu0_active: cpu0-active {
>> +                       temperature = <70000>;
>> +                       hysteresis = <5000>;
>> +                       type = "active";
>> +               };
>> +       };
>> +
>> +       cooling-maps {
>> +               map1 {
>> +                       trip = <&cpu0_active>;
>> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
>> +               };
>> +       };
>> +};
>> +
>> +&cpu1_thermal {
>> +       trips {
>> +               cpu1_active: cpu1-active {
>> +                       temperature = <70000>;
>> +                       hysteresis = <5000>;
>> +                       type = "active";
>> +               };
>> +       };
>> +
>> +       cooling-maps {
>> +               map1 {
>> +                       trip = <&cpu1_active>;
>> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
>> +               };
>> +       };
>> +};
>> +
>> +&cpu2_thermal {
>> +       trips {
>> +               cpu2_active: cpu2-active {
>> +                       temperature = <70000>;
>> +                       hysteresis = <5000>;
>> +                       type = "active";
>> +               };
>> +       };
>> +
>> +       cooling-maps {
>> +               map1 {
>> +                       trip = <&cpu2_active>;
>> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
>> +               };
>> +       };
>> +};
>> +
>> +&cpu3_thermal {
>> +       trips {
>> +               cpu3_active: cpu3-active {
>> +                       temperature = <70000>;
>> +                       hysteresis = <5000>;
>> +                       type = "active";
>> +               };
>> +       };
>> +
>> +       cooling-maps {
>> +               map1 {
>> +                       trip = <&cpu3_active>;
>> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
>> +               };
>> +       };
>> +};
>> +
>> +&cluster_thermal {
>> +       trips {
>> +               cluster_active: cluster-active {
>> +                       temperature = <70000>;
>> +                       hysteresis = <5000>;
>> +                       type = "active";
>> +               };
>> +       };
>> +
>> +       cooling-maps {
>> +               map1 {
>> +                       trip = <&cluster_active>;
>> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
>> +               };
>> +       };
>> +};
>> +
>> +&aqr_thermal {
>
> This ties into my question for the zone, why not just add it directly

Thanks for your review and feedback! :)

Well - there is no particular reason - it was just a matter of taste; I tought it was nicer to be able to see / tune temp values in a single zone of the file.
I will however move this up in the thermal zone next revision.

Thanks again,
Enrico

> in the node?
>> +       trips {
>> +               aqr_thermal_active: aqr-thermal-active {
>> +                       temperature = <70000>;
>> +                       hysteresis = <5000>;
>> +                       type = "active";
>> +               };
>> +       };
>> +
>> +       cooling-maps {
>> +               map1 {
>> +                       trip = <&aqr_thermal_active>;
>> +                       cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
>> +               };
>> +       };
>> +};
>> diff --git a/target/linux/ipq807x/image/generic.mk b/target/linux/ipq807x/image/generic.mk
>> index 38770a5f24..bbdb8c5d8b 100644
>> --- a/target/linux/ipq807x/image/generic.mk
>> +++ b/target/linux/ipq807x/image/generic.mk
>> @@ -141,6 +141,6 @@ define Device/zyxel_nbg7815
>>         IMAGES += factory.bin sysupgrade.bin
>>         IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 64k
>>         IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to 64k | sysupgrade-tar rootfs=$$$$@ | append-metadata
>> -       DEVICE_PACKAGES := ipq-wifi-zyxel_nbg7815 kmod-ath11k-pci e2fsprogs kmod-fs-ext4 losetup kmod-hwmon-tmp103
>> +       DEVICE_PACKAGES := ipq-wifi-zyxel_nbg7815 kmod-ath11k-pci e2fsprogs kmod-fs-ext4 losetup kmod-hwmon-tmp103 kmod-hwmon-gpiofan kmod-phy-aquantia
>>  endef
>
> No need to add AQR kmod as it's included by default on the target.
>
> Regards,
> Robert
>>  TARGET_DEVICES += zyxel_nbg7815
>> --
>> 2.39.2
>>
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel@lists.openwrt.org
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>
diff mbox series

Patch

diff --git a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
index 537dd52032..0ec602cf31 100644
--- a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
+++ b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8074-nbg7815.dts
@@ -39,6 +39,22 @@ 
 			gpios = <&tlmm 54 GPIO_ACTIVE_LOW>;
 		};
 	};
+
+	fan: gpio_fan {
+		compatible = "gpio-fan";
+		gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>;
+		gpio-fan,speed-map = <0    0
+							4500 1>;
+		#cooling-cells = <2>;
+	};
+
+	thermal-zones {
+		aqr_thermal: aqr-thermal {
+			polling-delay-passive = <1000>;
+			polling-delay = <1000>;
+			thermal-sensors = <&aqr113c>;
+		};
+	};
 };
 
 &tlmm {
@@ -291,6 +307,7 @@ 
 		compatible = "ethernet-phy-ieee802.3-c45";
 		reg = <8>;
 		reset-gpios = <&tlmm 63 GPIO_ACTIVE_LOW>;
+		#thermal-sensor-cells = <0>;
 	};
 };
 
@@ -443,3 +460,105 @@ 
 
 	qcom,ath11k-calibration-variant = "Zyxel-NBG7815";
 };
+
+&cpu0_thermal {
+	trips {
+		cpu0_active: cpu0-active {
+			temperature = <70000>;
+			hysteresis = <5000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map1 {
+			trip = <&cpu0_active>;
+			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
+&cpu1_thermal {
+	trips {
+		cpu1_active: cpu1-active {
+			temperature = <70000>;
+			hysteresis = <5000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map1 {
+			trip = <&cpu1_active>;
+			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
+&cpu2_thermal {
+	trips {
+		cpu2_active: cpu2-active {
+			temperature = <70000>;
+			hysteresis = <5000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map1 {
+			trip = <&cpu2_active>;
+			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
+&cpu3_thermal {
+	trips {
+		cpu3_active: cpu3-active {
+			temperature = <70000>;
+			hysteresis = <5000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map1 {
+			trip = <&cpu3_active>;
+			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
+&cluster_thermal {
+	trips {
+		cluster_active: cluster-active {
+			temperature = <70000>;
+			hysteresis = <5000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map1 {
+			trip = <&cluster_active>;
+			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
+&aqr_thermal {
+	trips {
+		aqr_thermal_active: aqr-thermal-active {
+			temperature = <70000>;
+			hysteresis = <5000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map1 {
+			trip = <&aqr_thermal_active>;
+			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
diff --git a/target/linux/ipq807x/image/generic.mk b/target/linux/ipq807x/image/generic.mk
index 38770a5f24..bbdb8c5d8b 100644
--- a/target/linux/ipq807x/image/generic.mk
+++ b/target/linux/ipq807x/image/generic.mk
@@ -141,6 +141,6 @@  define Device/zyxel_nbg7815
 	IMAGES += factory.bin sysupgrade.bin
 	IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 64k
 	IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to 64k | sysupgrade-tar rootfs=$$$$@ | append-metadata
-	DEVICE_PACKAGES := ipq-wifi-zyxel_nbg7815 kmod-ath11k-pci e2fsprogs kmod-fs-ext4 losetup kmod-hwmon-tmp103
+	DEVICE_PACKAGES := ipq-wifi-zyxel_nbg7815 kmod-ath11k-pci e2fsprogs kmod-fs-ext4 losetup kmod-hwmon-tmp103 kmod-hwmon-gpiofan kmod-phy-aquantia
 endef
 TARGET_DEVICES += zyxel_nbg7815