From 402b8106eca604d3e1c150fbde88064d5044cb7c Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 23 Aug 2023 14:59:08 -0300 Subject: thermal: imx_tmu: Fix the polling default 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 --- drivers/thermal/imx_tmu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index 97efc550443..d9a04eaf79f 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) { -- cgit v1.2.3 From 966480fe43ba929373b7449fa5b918d63cca88b3 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 23 Aug 2023 14:59:09 -0300 Subject: thermal: imx_tmu: Increase the log level for high temperatures 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 Reviewed-by: Tom Rini --- drivers/thermal/imx_tmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index d9a04eaf79f..d2ea084d2d2 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); -- cgit v1.2.3 From f4898e4b0ede5929cc1706d0da498d63375b1129 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 23 Aug 2023 14:59:10 -0300 Subject: thermal: imx_tmu: Fix the temperature unit 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 --- drivers/thermal/imx_tmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index d2ea084d2d2..b877ee36878 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) -- cgit v1.2.3 From a79fca7b44d0dee96e14d31de5869b35b587283c Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 23 Aug 2023 14:59:11 -0300 Subject: thermal: imx_tmu: Increase the polling interval 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 --- drivers/thermal/imx_tmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index b877ee36878..4721cfbc021 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 */ -- cgit v1.2.3