[PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU

From: Fabio Estevam festevam@denx.de
Select the i.MX8MM thermal driver as it is useful for displaying the CPU temperature and its grading:
CPU: Commercial temperature grade (0C to 95C) at 38C
It also prevents booting when the temperature is above the alert point.
Signed-off-by: Fabio Estevam festevam@denx.de --- Changes since v1: - None
configs/imx8mm_evk_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/imx8mm_evk_defconfig b/configs/imx8mm_evk_defconfig index ac9810fe1b..822c2fbfab 100644 --- a/configs/imx8mm_evk_defconfig +++ b/configs/imx8mm_evk_defconfig @@ -104,6 +104,7 @@ CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y +CONFIG_IMX_TMU=y CONFIG_USB=y CONFIG_SPL_USB_HOST=y CONFIG_USB_EHCI_HCD=y

From: Fabio Estevam festevam@denx.de
When the 'polling-delay' property is not passed via devicetree, pdata->polling_delay keeps at 0. This causes the imx_tmu driver to get stuck inside the busy while() loop when the CPU temperature is above the alert point.
Fix this problem by passing a one second polling interval, which provides a proper delay to let the system to cool down and exit the while() loop when the temperature is below the alert point.
Signed-off-by: Fabio Estevam festevam@denx.de --- Changes since v1: - None
drivers/thermal/imx_tmu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index 97efc55044..d9a04eaf79 100644 --- a/drivers/thermal/imx_tmu.c +++ b/drivers/thermal/imx_tmu.c @@ -37,6 +37,7 @@ DECLARE_GLOBAL_DATA_PTR; #define TER_ADC_PD 0x40000000 #define TER_ALPF 0x3
+#define IMX_TMU_POLLING_DELAY_MS 1000 /* * i.MX TMU Registers */ @@ -574,6 +575,8 @@ static int imx_tmu_parse_fdt(struct udevice *dev)
dev_dbg(dev, "%s\n", __func__);
+ pdata->polling_delay = IMX_TMU_POLLING_DELAY_MS; + if (pdata->zone_node) { pdata->regs = (union tmu_regs *)dev_read_addr_ptr(dev);
@@ -602,7 +605,8 @@ static int imx_tmu_parse_fdt(struct udevice *dev)
dev_dbg(dev, "args.args_count %d, id %d\n", args.args_count, pdata->id);
- pdata->polling_delay = dev_read_u32_default(dev, "polling-delay", 1000); + pdata->polling_delay = dev_read_u32_default(dev, "polling-delay", + IMX_TMU_POLLING_DELAY_MS);
trips_np = ofnode_path("/thermal-zones/cpu-thermal/trips"); ofnode_for_each_subnode(trips_np, trips_np) {

From: Fabio Estevam festevam@denx.de When the 'polling-delay' property is not passed via devicetree, pdata->polling_delay keeps at 0. This causes the imx_tmu driver to get stuck inside the busy while() loop when the CPU temperature is above the alert point. Fix this problem by passing a one second polling interval, which provides a proper delay to let the system to cool down and exit the while() loop when the temperature is below the alert point. Signed-off-by: Fabio Estevam festevam@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic

From: Fabio Estevam festevam@denx.de
dev_info() message is not printed by default. Increase the log level to dev_crit(). This allows the critical messages related to the temperature getting beyong the alert threshold to be displayed.
Signed-off-by: Fabio Estevam festevam@denx.de --- Changes since v1: - Use dev_crit() instead of selecting LOG via Kconfig. (Tom)
drivers/thermal/imx_tmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index d9a04eaf79fb..d2ea084d2d2f 100644 --- a/drivers/thermal/imx_tmu.c +++ b/drivers/thermal/imx_tmu.c @@ -238,7 +238,7 @@ int imx_tmu_get_temp(struct udevice *dev, int *temp) return ret;
while (cpu_tmp >= pdata->alert) { - dev_info(dev, "CPU Temperature (%dC) has beyond alert (%dC), close to critical (%dC) waiting...\n", + dev_crit(dev, "CPU Temperature (%dC) has beyond alert (%dC), close to critical (%dC) waiting...\n", cpu_tmp, pdata->alert, pdata->critical); mdelay(pdata->polling_delay); ret = read_temperature(dev, &cpu_tmp);

On Wed, Aug 23, 2023 at 02:59:09PM -0300, Fabio Estevam wrote:
From: Fabio Estevam festevam@denx.de
dev_info() message is not printed by default. Increase the log level to dev_crit(). This allows the critical messages related to the temperature getting beyong the alert threshold to be displayed.
Signed-off-by: Fabio Estevam festevam@denx.de
Reviewed-by: Tom Rini trini@konsulko.com

From: Fabio Estevam festevam@denx.de dev_info() message is not printed by default. Increase the log level to dev_crit(). This allows the critical messages related to the temperature getting beyong the alert threshold to be displayed. Signed-off-by: Fabio Estevam festevam@denx.de Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic

From: Fabio Estevam festevam@denx.de
The temperature unit is millidegree Celsius, so divide by 1000 to correctly print the temperature values in Celsius.
While at it, also change a typo: "has beyond" to "is beyond".
Signed-off-by: Fabio Estevam festevam@denx.de --- Changes since v1: - Rebased.
drivers/thermal/imx_tmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index d2ea084d2d2f..b877ee36878f 100644 --- a/drivers/thermal/imx_tmu.c +++ b/drivers/thermal/imx_tmu.c @@ -238,8 +238,8 @@ int imx_tmu_get_temp(struct udevice *dev, int *temp) return ret;
while (cpu_tmp >= pdata->alert) { - dev_crit(dev, "CPU Temperature (%dC) has beyond alert (%dC), close to critical (%dC) waiting...\n", - cpu_tmp, pdata->alert, pdata->critical); + dev_crit(dev, "CPU Temperature (%dC) is beyond alert (%dC), close to critical (%dC) waiting...\n", + cpu_tmp / 1000, pdata->alert / 1000, pdata->critical / 1000); mdelay(pdata->polling_delay); ret = read_temperature(dev, &cpu_tmp); if (ret)

From: Fabio Estevam festevam@denx.de The temperature unit is millidegree Celsius, so divide by 1000 to correctly print the temperature values in Celsius. While at it, also change a typo: "has beyond" to "is beyond". Signed-off-by: Fabio Estevam festevam@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic

From: Fabio Estevam festevam@denx.de
Polling every second to check whether the CPU has cooled down is too frequent.
Allow more time for the CPU to cool down by increasing the polling interval to 5 seconds by defaut.
This value is used in the absence of the 'polling-delay' devicetree property.
Signed-off-by: Fabio Estevam festevam@denx.de --- Changes since v1: - None
drivers/thermal/imx_tmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index f79b583811..15e01b6166 100644 --- a/drivers/thermal/imx_tmu.c +++ b/drivers/thermal/imx_tmu.c @@ -37,7 +37,7 @@ DECLARE_GLOBAL_DATA_PTR; #define TER_ADC_PD 0x40000000 #define TER_ALPF 0x3
-#define IMX_TMU_POLLING_DELAY_MS 1000 +#define IMX_TMU_POLLING_DELAY_MS 5000 /* * i.MX TMU Registers */

From: Fabio Estevam festevam@denx.de Polling every second to check whether the CPU has cooled down is too frequent. Allow more time for the CPU to cool down by increasing the polling interval to 5 seconds by defaut. This value is used in the absence of the 'polling-delay' devicetree property. Signed-off-by: Fabio Estevam festevam@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic

From: Fabio Estevam festevam@denx.de Select the i.MX8MM thermal driver as it is useful for displaying the CPU temperature and its grading: CPU: Commercial temperature grade (0C to 95C) at 38C It also prevents booting when the temperature is above the alert point. Signed-off-by: Fabio Estevam festevam@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic
participants (3)
-
Fabio Estevam
-
sbabic@denx.de
-
Tom Rini