public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU
@ 2023-08-23 17:59 Fabio Estevam
  2023-08-23 17:59 ` [PATCH v2 2/5] thermal: imx_tmu: Fix the polling default Fabio Estevam
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Fabio Estevam @ 2023-08-23 17:59 UTC (permalink / raw)
  To: sbabic; +Cc: peng.fan, trini, u-boot, Fabio Estevam

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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 2/5] thermal: imx_tmu: Fix the polling default
  2023-08-23 17:59 [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU Fabio Estevam
@ 2023-08-23 17:59 ` Fabio Estevam
  2023-09-05  7:39   ` sbabic
  2023-08-23 17:59 ` [PATCH v2 3/5] thermal: imx_tmu: Increase the log level for high temperatures Fabio Estevam
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2023-08-23 17:59 UTC (permalink / raw)
  To: sbabic; +Cc: peng.fan, trini, u-boot, Fabio Estevam

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) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 3/5] thermal: imx_tmu: Increase the log level for high temperatures
  2023-08-23 17:59 [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU Fabio Estevam
  2023-08-23 17:59 ` [PATCH v2 2/5] thermal: imx_tmu: Fix the polling default Fabio Estevam
@ 2023-08-23 17:59 ` Fabio Estevam
  2023-08-23 17:59   ` Tom Rini
  2023-09-05  7:39   ` sbabic
  2023-08-23 17:59 ` [PATCH v2 4/5] thermal: imx_tmu: Fix the temperature unit Fabio Estevam
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Fabio Estevam @ 2023-08-23 17:59 UTC (permalink / raw)
  To: sbabic; +Cc: peng.fan, trini, u-boot, Fabio Estevam

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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 4/5] thermal: imx_tmu: Fix the temperature unit
  2023-08-23 17:59 [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU Fabio Estevam
  2023-08-23 17:59 ` [PATCH v2 2/5] thermal: imx_tmu: Fix the polling default Fabio Estevam
  2023-08-23 17:59 ` [PATCH v2 3/5] thermal: imx_tmu: Increase the log level for high temperatures Fabio Estevam
@ 2023-08-23 17:59 ` Fabio Estevam
  2023-09-05  7:39   ` sbabic
  2023-08-23 17:59 ` [PATCH v2 5/5] thermal: imx_tmu: Increase the polling interval Fabio Estevam
  2023-09-05  7:39 ` [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU sbabic
  4 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2023-08-23 17:59 UTC (permalink / raw)
  To: sbabic; +Cc: peng.fan, trini, u-boot, Fabio Estevam

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)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 5/5] thermal: imx_tmu: Increase the polling interval
  2023-08-23 17:59 [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU Fabio Estevam
                   ` (2 preceding siblings ...)
  2023-08-23 17:59 ` [PATCH v2 4/5] thermal: imx_tmu: Fix the temperature unit Fabio Estevam
@ 2023-08-23 17:59 ` Fabio Estevam
  2023-09-05  7:39   ` sbabic
  2023-09-05  7:39 ` [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU sbabic
  4 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2023-08-23 17:59 UTC (permalink / raw)
  To: sbabic; +Cc: peng.fan, trini, u-boot, Fabio Estevam

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
  */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 3/5] thermal: imx_tmu: Increase the log level for high temperatures
  2023-08-23 17:59 ` [PATCH v2 3/5] thermal: imx_tmu: Increase the log level for high temperatures Fabio Estevam
@ 2023-08-23 17:59   ` Tom Rini
  2023-09-05  7:39   ` sbabic
  1 sibling, 0 replies; 11+ messages in thread
From: Tom Rini @ 2023-08-23 17:59 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: sbabic, peng.fan, u-boot, Fabio Estevam

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

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>

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 2/5] thermal: imx_tmu: Fix the polling default
  2023-08-23 17:59 ` [PATCH v2 2/5] thermal: imx_tmu: Fix the polling default Fabio Estevam
@ 2023-09-05  7:39   ` sbabic
  0 siblings, 0 replies; 11+ messages in thread
From: sbabic @ 2023-09-05  7:39 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> 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

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 4/5] thermal: imx_tmu: Fix the temperature unit
  2023-08-23 17:59 ` [PATCH v2 4/5] thermal: imx_tmu: Fix the temperature unit Fabio Estevam
@ 2023-09-05  7:39   ` sbabic
  0 siblings, 0 replies; 11+ messages in thread
From: sbabic @ 2023-09-05  7:39 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> 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

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 5/5] thermal: imx_tmu: Increase the polling interval
  2023-08-23 17:59 ` [PATCH v2 5/5] thermal: imx_tmu: Increase the polling interval Fabio Estevam
@ 2023-09-05  7:39   ` sbabic
  0 siblings, 0 replies; 11+ messages in thread
From: sbabic @ 2023-09-05  7:39 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> 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

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 3/5] thermal: imx_tmu: Increase the log level for high temperatures
  2023-08-23 17:59 ` [PATCH v2 3/5] thermal: imx_tmu: Increase the log level for high temperatures Fabio Estevam
  2023-08-23 17:59   ` Tom Rini
@ 2023-09-05  7:39   ` sbabic
  1 sibling, 0 replies; 11+ messages in thread
From: sbabic @ 2023-09-05  7:39 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> 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

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU
  2023-08-23 17:59 [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU Fabio Estevam
                   ` (3 preceding siblings ...)
  2023-08-23 17:59 ` [PATCH v2 5/5] thermal: imx_tmu: Increase the polling interval Fabio Estevam
@ 2023-09-05  7:39 ` sbabic
  4 siblings, 0 replies; 11+ messages in thread
From: sbabic @ 2023-09-05  7:39 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> 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

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-09-05  7:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-23 17:59 [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU Fabio Estevam
2023-08-23 17:59 ` [PATCH v2 2/5] thermal: imx_tmu: Fix the polling default Fabio Estevam
2023-09-05  7:39   ` sbabic
2023-08-23 17:59 ` [PATCH v2 3/5] thermal: imx_tmu: Increase the log level for high temperatures Fabio Estevam
2023-08-23 17:59   ` Tom Rini
2023-09-05  7:39   ` sbabic
2023-08-23 17:59 ` [PATCH v2 4/5] thermal: imx_tmu: Fix the temperature unit Fabio Estevam
2023-09-05  7:39   ` sbabic
2023-08-23 17:59 ` [PATCH v2 5/5] thermal: imx_tmu: Increase the polling interval Fabio Estevam
2023-09-05  7:39   ` sbabic
2023-09-05  7:39 ` [PATCH v2 1/5] imx8mm_evk_defconfig: Select CONFIG_IMX_TMU sbabic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox