diff mbox series

[v2,4/5] board: gateworks: venice: update thermal temp thresholds per cpu grade

Message ID 20210818222431.13862-4-tharvey@gateworks.com
State Accepted
Commit f8a792e51d17c32b62e957d10be93d6ab9008f53
Delegated to: Stefano Babic
Headers show
Series [v2,1/5] board: gateworks: venice: display hwmon details by default | expand

Commit Message

Tim Harvey Aug. 18, 2021, 10:24 p.m. UTC
Update the passive/critical thermal zone dt config per CPU temperature
grade.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
v2: no changes
---
 board/gateworks/venice/imx8mm_venice.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Stefano Babic Oct. 7, 2021, 2:14 p.m. UTC | #1
> Update the passive/critical thermal zone dt config per CPU temperature
> grade.
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/board/gateworks/venice/imx8mm_venice.c b/board/gateworks/venice/imx8mm_venice.c
index 46f4bff925..4e05802b6f 100644
--- a/board/gateworks/venice/imx8mm_venice.c
+++ b/board/gateworks/venice/imx8mm_venice.c
@@ -156,8 +156,26 @@  int board_mmc_get_env_dev(int devno)
 
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
+	int off;
+
 	/* set board model dt prop */
 	fdt_setprop_string(blob, 0, "board", gsc_get_model());
 
+	/* update temp thresholds */
+	off = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
+	if (off >= 0) {
+		int minc, maxc, prop;
+
+		get_cpu_temp_grade(&minc, &maxc);
+		fdt_for_each_subnode(prop, blob, off) {
+			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);
+		}
+	}
+
 	return 0;
 }