Skip to contentSkip to conversation

ARM: imx: imx8m: Adjust thermal trip points for Industrial parts

PATCH Superseded Adam Ford 3 participants 4 messages May 5, 2022 – May 7, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH 1/1 ARM: imx: imx8m: Adjust thermal trip points for Industrial parts

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts.

arch/arm/mach-imx/imx8m/soc.c +20 -1
index 8e23e6da32..619e04a602 100644
@@ -30,6 +30,7 @@
 #include <fsl_wdog.h>
 #include <imx_sip.h>
 #include <linux/bitops.h>
+#include <imx_thermal.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
 
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+	__maybe_unused int nodeoff;
 #ifdef CONFIG_IMX8MQ
 	int i = 0;
 	int rc;
-	int nodeoff;
 
 	if (get_boot_device() == USB_BOOT) {
 		disable_dcss_nodes(blob);
@@ -1346,6 +1347,24 @@ usb_modify_speed:
 		disable_cpu_nodes(blob, 2);
 #endif
 
+#if defined(CONFIG_IMX_TMU)
+	int minc, maxc, prop;
+
+	nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
+
+	/* Only update Industrial grade parts */
+	if (get_cpu_temp_grade(&minc, &maxc) == TEMP_INDUSTRIAL) {
+		fdt_for_each_subnode(prop, blob, nodeoff) {
+			const char *type = fdt_getprop(blob, prop, "type", NULL);
+
+			if (type && (!strcmp("critical", type)))
+				fdt_setprop_u32(blob, prop, "temperature", maxc * 1000);
+			else if (type && (!strcmp("passive", type)))
+				fdt_setprop_u32(blob, prop, "temperature", (maxc - 10) * 1000);
+		}
+	}
+#endif
+
 	cleanup_nodes_for_efi(blob);
 	return 0;
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 56 lines · Adam Ford

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts.

arch/arm/mach-imx/imx8m/soc.c +20 -2
index 8e23e6da32..619e04a602 100644
@@ -30,6 +30,7 @@
 #include <fsl_wdog.h>
 #include <imx_sip.h>
 #include <linux/bitops.h>
+#include <imx_thermal.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
 
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+       __maybe_unused int nodeoff;
 #ifdef CONFIG_IMX8MQ
        int i = 0;
        int rc;
-       int nodeoff;
 
        if (get_boot_device() == USB_BOOT) {
                disable_dcss_nodes(blob);
@@ -1346,6 +1347,24 @@ usb_modify_speed:
                disable_cpu_nodes(blob, 2);
 #endif
 
+#if defined(CONFIG_IMX_TMU)
+       int minc, maxc, prop;
+
+       nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
+
+       /* Only update Industrial grade parts */
+       if (get_cpu_temp_grade(&minc, &maxc) == TEMP_INDUSTRIAL) {
+               fdt_for_each_subnode(prop, blob, nodeoff) {
+                       const char *type = fdt_getprop(blob, prop, "type", NULL);
+
+                       if (type && (!strcmp("critical", type)))
+                               fdt_setprop_u32(blob, prop, "temperature", maxc * 1000);
+                       else if (type && (!strcmp("passive", type)))
+                               fdt_setprop_u32(blob, prop, "temperature", (maxc - 10) * 1000);
+               }
+       }
+#endif
+
        cleanup_nodes_for_efi(blob);
        return 0;
 }
--
Quoted 2 lines

2.25.1

Adam,

Best Regards,

Tim

#2 lore raw
In reply to Adam Ford
Quoted 2 lines · Adam Ford

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts.

Is this supposed to work fine with any i.MX8M? Mini/Plus/... ?

Quoted 28 lines
arch/arm/mach-imx/imx8m/soc.c +2 -1
index 8e23e6da32..619e04a602 100644
@@ -30,6 +30,7 @@
 #include <fsl_wdog.h>
 #include <imx_sip.h>
 #include <linux/bitops.h>
+#include <imx_thermal.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
 
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+	__maybe_unused int nodeoff;
 #ifdef CONFIG_IMX8MQ
 	int i = 0;
 	int rc;
-	int nodeoff;
 
 	if (get_boot_device() == USB_BOOT) {
 		disable_dcss_nodes(blob);

arch/arm/mach-imx/imx8m/soc.c usb_modify_speed: · line 1356

Quoted 10 lines
arch/arm/mach-imx/imx8m/soc.c +7 -0
@@ -1346,6 +1347,24 @@ usb_modify_speed:
 		disable_cpu_nodes(blob, 2);
 #endif
 
+#if defined(CONFIG_IMX_TMU)
+	int minc, maxc, prop;
+
+	nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
+
+	/* Only update Industrial grade parts */
+	if (get_cpu_temp_grade(&minc, &maxc) == TEMP_INDUSTRIAL) {

I would check for != TEMP_COMMERCIAL.

Quoted 4 lines
arch/arm/mach-imx/imx8m/soc.c +4 -0
+		fdt_for_each_subnode(prop, blob, nodeoff) {
+			const char *type = fdt_getprop(blob, prop, "type", NULL);
+
+			if (type && (!strcmp("critical", type)))

arch/arm/mach-imx/imx8m/soc.c usb_modify_speed: · line 1370

Quoted 10 lines
arch/arm/mach-imx/imx8m/soc.c +7 -0
+				fdt_setprop_u32(blob, prop, "temperature", maxc * 1000);
+			else if (type && (!strcmp("passive", type)))
+				fdt_setprop_u32(blob, prop, "temperature", (maxc - 10) * 1000);
+		}
+	}
+#endif
+
 	cleanup_nodes_for_efi(blob);
 	return 0;
 }

Francesco

author
#3 lore raw
Quoted 5 lines · Francesco Dolcini
Quoted 2 lines · Adam Ford

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts.

Is this supposed to work fine with any i.MX8M? Mini/Plus/... ?

Yes. They (8MQ, 8MM, 8MN, and 8MP) all appear to have the same structure for /thermal-zones/cpu-thermal/trips

Quoted 32 lines
Quoted 32 lines
arch/arm/mach-imx/imx8m/soc.c +2 -1
index 8e23e6da32..619e04a602 100644
@@ -30,6 +30,7 @@
 #include <fsl_wdog.h>
 #include <imx_sip.h>
 #include <linux/bitops.h>
+#include <imx_thermal.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
 
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+     __maybe_unused int nodeoff;
 #ifdef CONFIG_IMX8MQ
      int i = 0;
      int rc;
-     int nodeoff;
 
      if (get_boot_device() == USB_BOOT) {
              disable_dcss_nodes(blob);
@@ -1346,6 +1347,24 @@ usb_modify_speed:
              disable_cpu_nodes(blob, 2);
 #endif
 
Quoted 9 lines

arch/arm/mach-imx/imx8m/soc.c usb_modify_speed: · line 1356

Quoted 7 lines
arch/arm/mach-imx/imx8m/soc.c +7 -0
+#if defined(CONFIG_IMX_TMU)
+     int minc, maxc, prop;
+
+     nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
+
+     /* Only update Industrial grade parts */
+     if (get_cpu_temp_grade(&minc, &maxc) == TEMP_INDUSTRIAL) {

I would check for != TEMP_COMMERCIAL.

That makes sense. I had thought about doing that, but I only have commercial and industrial parts, so I couldn't test anything else. I'll push a V2.

Quoted 18 lines
Quoted 5 lines
arch/arm/mach-imx/imx8m/soc.c +4 -0
+             fdt_for_each_subnode(prop, blob, nodeoff) {
+                     const char *type = fdt_getprop(blob, prop, "type", NULL);
+
+                     if (type && (!strcmp("critical", type)))

arch/arm/mach-imx/imx8m/soc.c usb_modify_speed: · line 1370

Quoted 10 lines
arch/arm/mach-imx/imx8m/soc.c +7 -0
+                             fdt_setprop_u32(blob, prop, "temperature", maxc * 1000);
+                     else if (type && (!strcmp("passive", type)))
+                             fdt_setprop_u32(blob, prop, "temperature", (maxc - 10) * 1000);
+             }
+     }
+#endif
+
      cleanup_nodes_for_efi(blob);
      return 0;
 }

Francesco