All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts
@ 2022-05-05 18:10 Adam Ford
  2022-05-05 19:31 ` Tim Harvey
  2022-05-05 19:42 ` Francesco Dolcini
  0 siblings, 2 replies; 4+ messages in thread
From: Adam Ford @ 2022-05-05 18:10 UTC (permalink / raw)
  To: u-boot
  Cc: aford, tharvey, andrejs.cainikovs, Adam Ford, Stefano Babic,
	Fabio Estevam, NXP i.MX U-Boot Team, Peng Fan, Marek Vasut,
	Ye Li, Frieder Schrempf, Ricardo Salveti, Michael Trimarchi

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal
trip points for industrial rated parts.

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 8e23e6da32..619e04a602 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -30,6 +30,7 @@
 #include <fsl_wdog.h>
 #include <imx_sip.h>
 #include <linux/bitops.h>
+#include <imx_thermal.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
 
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+	__maybe_unused int nodeoff;
 #ifdef CONFIG_IMX8MQ
 	int i = 0;
 	int rc;
-	int nodeoff;
 
 	if (get_boot_device() == USB_BOOT) {
 		disable_dcss_nodes(blob);
@@ -1346,6 +1347,24 @@ usb_modify_speed:
 		disable_cpu_nodes(blob, 2);
 #endif
 
+#if defined(CONFIG_IMX_TMU)
+	int minc, maxc, prop;
+
+	nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
+
+	/* Only update Industrial grade parts */
+	if (get_cpu_temp_grade(&minc, &maxc) == TEMP_INDUSTRIAL) {
+		fdt_for_each_subnode(prop, blob, nodeoff) {
+			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);
+		}
+	}
+#endif
+
 	cleanup_nodes_for_efi(blob);
 	return 0;
 }
-- 
2.25.1


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

* Re: [PATCH] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts
  2022-05-05 18:10 [PATCH] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts Adam Ford
@ 2022-05-05 19:31 ` Tim Harvey
  2022-05-05 19:42 ` Francesco Dolcini
  1 sibling, 0 replies; 4+ messages in thread
From: Tim Harvey @ 2022-05-05 19:31 UTC (permalink / raw)
  To: Adam Ford
  Cc: u-boot, Adam Ford-BE, Andrejs Cainikovs, Stefano Babic,
	Fabio Estevam, NXP i.MX U-Boot Team, Peng Fan, Marek Vasut,
	Ye Li, Frieder Schrempf, Ricardo Salveti, Michael Trimarchi

On Thu, May 5, 2022 at 11:10 AM Adam Ford <aford173@gmail.com> wrote:
>
> If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal
> trip points for industrial rated parts.
>
> Signed-off-by: Adam Ford <aford173@gmail.com>
>
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index 8e23e6da32..619e04a602 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -30,6 +30,7 @@
>  #include <fsl_wdog.h>
>  #include <imx_sip.h>
>  #include <linux/bitops.h>
> +#include <imx_thermal.h>
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
>
>  int ft_system_setup(void *blob, struct bd_info *bd)
>  {
> +       __maybe_unused int nodeoff;
>  #ifdef CONFIG_IMX8MQ
>         int i = 0;
>         int rc;
> -       int nodeoff;
>
>         if (get_boot_device() == USB_BOOT) {
>                 disable_dcss_nodes(blob);
> @@ -1346,6 +1347,24 @@ usb_modify_speed:
>                 disable_cpu_nodes(blob, 2);
>  #endif
>
> +#if defined(CONFIG_IMX_TMU)
> +       int minc, maxc, prop;
> +
> +       nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
> +
> +       /* Only update Industrial grade parts */
> +       if (get_cpu_temp_grade(&minc, &maxc) == TEMP_INDUSTRIAL) {
> +               fdt_for_each_subnode(prop, blob, nodeoff) {
> +                       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);
> +               }
> +       }
> +#endif
> +
>         cleanup_nodes_for_efi(blob);
>         return 0;
>  }
> --
> 2.25.1
>

Adam,

Reviewed-by: Tim Harvey <tharvey@gateworks.com>

Best Regards,

Tim

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

* Re: [PATCH] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts
  2022-05-05 18:10 [PATCH] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts Adam Ford
  2022-05-05 19:31 ` Tim Harvey
@ 2022-05-05 19:42 ` Francesco Dolcini
  2022-05-07 11:54   ` Adam Ford
  1 sibling, 1 reply; 4+ messages in thread
From: Francesco Dolcini @ 2022-05-05 19:42 UTC (permalink / raw)
  To: Adam Ford
  Cc: u-boot, aford, tharvey, andrejs.cainikovs, Stefano Babic,
	Fabio Estevam, NXP i.MX U-Boot Team, Peng Fan, Marek Vasut,
	Ye Li, Frieder Schrempf, Ricardo Salveti, Michael Trimarchi

On Thu, May 05, 2022 at 01:10:27PM -0500, Adam Ford wrote:
> If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal
> trip points for industrial rated parts.
Is this supposed to work fine with any i.MX8M? Mini/Plus/... ?

> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index 8e23e6da32..619e04a602 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -30,6 +30,7 @@
>  #include <fsl_wdog.h>
>  #include <imx_sip.h>
>  #include <linux/bitops.h>
> +#include <imx_thermal.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
>  
>  int ft_system_setup(void *blob, struct bd_info *bd)
>  {
> +	__maybe_unused int nodeoff;
>  #ifdef CONFIG_IMX8MQ
>  	int i = 0;
>  	int rc;
> -	int nodeoff;
>  
>  	if (get_boot_device() == USB_BOOT) {
>  		disable_dcss_nodes(blob);
> @@ -1346,6 +1347,24 @@ usb_modify_speed:
>  		disable_cpu_nodes(blob, 2);
>  #endif
>  
> +#if defined(CONFIG_IMX_TMU)
> +	int minc, maxc, prop;
> +
> +	nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
> +
> +	/* Only update Industrial grade parts */
> +	if (get_cpu_temp_grade(&minc, &maxc) == TEMP_INDUSTRIAL) {

I would check for != TEMP_COMMERCIAL. 

> +		fdt_for_each_subnode(prop, blob, nodeoff) {
> +			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);
> +		}
> +	}
> +#endif
> +
>  	cleanup_nodes_for_efi(blob);
>  	return 0;
>  }

Francesco


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

* Re: [PATCH] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts
  2022-05-05 19:42 ` Francesco Dolcini
@ 2022-05-07 11:54   ` Adam Ford
  0 siblings, 0 replies; 4+ messages in thread
From: Adam Ford @ 2022-05-07 11:54 UTC (permalink / raw)
  To: Francesco Dolcini
  Cc: U-Boot Mailing List, Adam Ford-BE, Tim Harvey, andrejs.cainikovs,
	Stefano Babic, Fabio Estevam, NXP i.MX U-Boot Team, Peng Fan,
	Marek Vasut, Ye Li, Frieder Schrempf, Ricardo Salveti,
	Michael Trimarchi

On Thu, May 5, 2022 at 2:42 PM Francesco Dolcini
<francesco.dolcini@toradex.com> wrote:
>
> On Thu, May 05, 2022 at 01:10:27PM -0500, Adam Ford wrote:
> > If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal
> > trip points for industrial rated parts.
> Is this supposed to work fine with any i.MX8M? Mini/Plus/... ?

Yes.  They (8MQ, 8MM, 8MN, and 8MP) all appear to have the same
structure for /thermal-zones/cpu-thermal/trips

>
> >
> > Signed-off-by: Adam Ford <aford173@gmail.com>
> >
> > diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> > index 8e23e6da32..619e04a602 100644
> > --- a/arch/arm/mach-imx/imx8m/soc.c
> > +++ b/arch/arm/mach-imx/imx8m/soc.c
> > @@ -30,6 +30,7 @@
> >  #include <fsl_wdog.h>
> >  #include <imx_sip.h>
> >  #include <linux/bitops.h>
> > +#include <imx_thermal.h>
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > @@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
> >
> >  int ft_system_setup(void *blob, struct bd_info *bd)
> >  {
> > +     __maybe_unused int nodeoff;
> >  #ifdef CONFIG_IMX8MQ
> >       int i = 0;
> >       int rc;
> > -     int nodeoff;
> >
> >       if (get_boot_device() == USB_BOOT) {
> >               disable_dcss_nodes(blob);
> > @@ -1346,6 +1347,24 @@ usb_modify_speed:
> >               disable_cpu_nodes(blob, 2);
> >  #endif
> >
> > +#if defined(CONFIG_IMX_TMU)
> > +     int minc, maxc, prop;
> > +
> > +     nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
> > +
> > +     /* Only update Industrial grade parts */
> > +     if (get_cpu_temp_grade(&minc, &maxc) == TEMP_INDUSTRIAL) {
>
> I would check for != TEMP_COMMERCIAL.

That makes sense.  I had thought about doing that, but I only have
commercial and industrial parts, so I couldn't test anything else.
I'll push a V2.

>
> > +             fdt_for_each_subnode(prop, blob, nodeoff) {
> > +                     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);
> > +             }
> > +     }
> > +#endif
> > +
> >       cleanup_nodes_for_efi(blob);
> >       return 0;
> >  }
>
> Francesco
>

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

end of thread, other threads:[~2022-05-07 11:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 18:10 [PATCH] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts Adam Ford
2022-05-05 19:31 ` Tim Harvey
2022-05-05 19:42 ` Francesco Dolcini
2022-05-07 11:54   ` Adam Ford

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.