]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
imx8ulp: implement to obtain the SoC current temperature
authorAlice Guo <alice.guo@nxp.com>
Fri, 29 Oct 2021 01:46:32 +0000 (09:46 +0800)
committerStefano Babic <sbabic@denx.de>
Sat, 5 Feb 2022 12:38:39 +0000 (13:38 +0100)
Obatin the SoC current temperature in print_cpuinfo().

Reviewed-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Alice Guo <alice.guo@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
arch/arm/mach-imx/imx8ulp/soc.c

index 943ea7fb7ef9adba4e6bbd7e1582feb704b5428e..934b0ef038ce83dc2830d5458c975cc50869668e 100644 (file)
@@ -24,6 +24,7 @@
 #include <dm/device.h>
 #include <dm/uclass-internal.h>
 #include <fuse.h>
+#include <thermal.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -216,6 +217,22 @@ int print_cpuinfo(void)
               (cpurev & 0x000F0) >> 4, (cpurev & 0x0000F) >> 0,
               mxc_get_clock(MXC_ARM_CLK) / 1000000);
 
+#if defined(CONFIG_IMX_PMC_TEMPERATURE)
+       struct udevice *udev;
+       int ret, temp;
+
+       ret = uclass_get_device(UCLASS_THERMAL, 0, &udev);
+       if (!ret) {
+               ret = thermal_get_temp(udev, &temp);
+               if (!ret)
+                       printf("CPU current temperature: %d\n", temp);
+               else
+                       debug(" - failed to get CPU current temperature\n");
+       } else {
+               debug(" - failed to get CPU current temperature\n");
+       }
+#endif
+
        printf("Reset cause: %s\n", get_reset_cause(cause));
 
        printf("Boot mode: ");