summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrejs Cainikovs <andrejs.cainikovs@toradex.com>2022-05-10 14:41:45 +0200
committerAndrejs Cainikovs <andrejs.cainikovs@toradex.com>2022-05-10 17:22:25 +0200
commit6b020e53c02f064ca0b932679abf2619a9049995 (patch)
treeb8a0bafcd3f1ef0e1d8c36763284a26926e809c6
parent44d5a7a61b4dacb105afb5bd1cd30036ba603581 (diff)
imx8m: fixup thermal trips
Fixup thermal trips in Linux device tree according to SoC thermal grade. Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
-rw-r--r--arch/arm/mach-imx/imx8m/soc.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index e93ecd2846..b451ece91f 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void *blob, u32 disabled_cores)
return 0;
}
+int fixup_thermal_trips(void *blob, const char *name)
+{
+ int minc, maxc;
+ int node, trip;
+
+ node = fdt_path_offset(blob, "/thermal-zones");
+ if (node < 0)
+ return node;
+
+ node = fdt_subnode_offset(blob, node, name);
+ if (node < 0)
+ return node;
+
+ node = fdt_subnode_offset(blob, node, "trips");
+ if (node < 0)
+ return node;
+
+ get_cpu_temp_grade(&minc, &maxc);
+
+ fdt_for_each_subnode(trip, blob, node) {
+ const char *type;
+ int temp, ret;
+
+ type = fdt_getprop(blob, trip, "type", NULL);
+ if (!type)
+ continue;
+
+ temp = 0;
+ if (!strcmp(type, "critical")) {
+ temp = 1000 * maxc;
+ } else if (!strcmp(type, "passive")) {
+ temp = 1000 * (maxc - 10);
+ }
+ if (temp) {
+ ret = fdt_setprop_u32(blob, trip, "temperature", temp);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
int ft_system_setup(void *blob, bd_t *bd)
{
#ifdef CONFIG_IMX8MQ
@@ -1128,6 +1171,13 @@ usb_modify_speed:
disable_cpu_nodes(blob, 2);
#endif
+ if (fixup_thermal_trips(blob, "cpu-thermal"))
+ printf("Failed to update cpu-thermal trip(s)");
+#ifdef CONFIG_IMX8MP
+ if (fixup_thermal_trips(blob, "soc-thermal"))
+ printf("Failed to update soc-thermal trip(s)");
+#endif
+
return ft_add_optee_node(blob, bd);
}
#endif