[PATCH] imx8m: fixup thermal trips

Adam Ford aford173 at gmail.com
Wed May 25 13:41:36 CEST 2022


On Thu, May 12, 2022 at 5:13 AM Andrejs Cainikovs
<andrejs.cainikovs at toradex.com> wrote:
>
> Fixup thermal trips in Linux device tree according to SoC thermal
> grade.
>
> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs at toradex.com>
> ---
>  arch/arm/mach-imx/imx8m/soc.c | 50 +++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
>
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index e93ecd2846..b451ece91f 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void *blob, u32 disabled_cores)
>         return 0;
>  }
>
> +int fixup_thermal_trips(void *blob, const char *name)

Is there any reason this function cannot be static?

> +{
> +       int minc, maxc;
> +       int node, trip;
> +
> +       node = fdt_path_offset(blob, "/thermal-zones");
> +       if (node < 0)
> +               return node;
> +
> +       node = fdt_subnode_offset(blob, node, name);
> +       if (node < 0)
> +               return node;
> +
> +       node = fdt_subnode_offset(blob, node, "trips");
> +       if (node < 0)
> +               return node;
> +
> +       get_cpu_temp_grade(&minc, &maxc);
> +
> +       fdt_for_each_subnode(trip, blob, node) {
> +               const char *type;
> +               int temp, ret;
> +
> +               type = fdt_getprop(blob, trip, "type", NULL);
> +               if (!type)
> +                       continue;
> +
> +               temp = 0;
> +               if (!strcmp(type, "critical")) {
> +                       temp = 1000 * maxc;
> +               } else if (!strcmp(type, "passive")) {
> +                       temp = 1000 * (maxc - 10);
> +               }
> +               if (temp) {
> +                       ret = fdt_setprop_u32(blob, trip, "temperature", temp);
> +                       if (ret)
> +                               return ret;
> +               }
> +       }
> +
> +       return 0;
> +}
> +
>  int ft_system_setup(void *blob, bd_t *bd)
>  {
>  #ifdef CONFIG_IMX8MQ
> @@ -1128,6 +1171,13 @@ usb_modify_speed:
>                 disable_cpu_nodes(blob, 2);
>  #endif
>
> +       if (fixup_thermal_trips(blob, "cpu-thermal"))
> +               printf("Failed to update cpu-thermal trip(s)");
> +#ifdef CONFIG_IMX8MP
> +       if (fixup_thermal_trips(blob, "soc-thermal"))
> +               printf("Failed to update soc-thermal trip(s)");
> +#endif
> +
>         return ft_add_optee_node(blob, bd);
>  }
>  #endif
> --
> 2.34.1
>


More information about the U-Boot mailing list