All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
Cc: Fabio Estevam <festevam@gmail.com>,
	Francesco Dolcini <francesco.dolcini@toradex.com>,
	 Schrempf Frieder <frieder.schrempf@kontron.de>,
	Marek Vasut <marex@denx.de>,
	 Michael Trimarchi <michael@amarulasolutions.com>,
	Peng Fan <peng.fan@nxp.com>,
	 Ricardo Salveti <ricardo@foundries.io>,
	Stefano Babic <sbabic@denx.de>,
	 Tim Harvey <tharvey@gateworks.com>,
	U-Boot Mailing List <u-boot@lists.denx.de>,
	dl-uboot-imx <uboot-imx@nxp.com>, Ye Li <ye.li@nxp.com>
Subject: Re: [PATCH] imx8m: fixup thermal trips
Date: Wed, 25 May 2022 06:41:36 -0500	[thread overview]
Message-ID: <CAHCN7xLxQfKAD6gkvOjd=0kUuQiE3Dzc9PhHvJ4pzrwA8Qq=2Q@mail.gmail.com> (raw)
In-Reply-To: <20220512101245.15829-2-andrejs.cainikovs@toradex.com>

On Thu, May 12, 2022 at 5:13 AM Andrejs Cainikovs
<andrejs.cainikovs@toradex.com> wrote:
>
> Fixup thermal trips in Linux device tree according to SoC thermal
> grade.
>
> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@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
>

  reply	other threads:[~2022-05-25 11:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07 12:04 [PATCH V2] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts Adam Ford
2022-05-07 22:00 ` Marek Vasut
2022-05-08  2:59   ` Adam Ford
2022-05-08 13:42     ` Marek Vasut
2022-05-08 16:55       ` Francesco Dolcini
2022-05-09  7:38 ` Andrejs Cainikovs
2022-05-12 10:12   ` Andrejs Cainikovs
2022-05-12 10:12   ` [PATCH] imx8m: fixup thermal trips Andrejs Cainikovs
2022-05-25 11:41     ` Adam Ford [this message]
2022-05-25 12:19       ` Andrejs Cainikovs
2022-05-25 12:21         ` Adam Ford
2022-05-25 12:24           ` Andrejs Cainikovs
2022-05-25 12:26             ` Adam Ford
2022-05-25 12:28               ` Andrejs Cainikovs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHCN7xLxQfKAD6gkvOjd=0kUuQiE3Dzc9PhHvJ4pzrwA8Qq=2Q@mail.gmail.com' \
    --to=aford173@gmail.com \
    --cc=andrejs.cainikovs@toradex.com \
    --cc=festevam@gmail.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=marex@denx.de \
    --cc=michael@amarulasolutions.com \
    --cc=peng.fan@nxp.com \
    --cc=ricardo@foundries.io \
    --cc=sbabic@denx.de \
    --cc=tharvey@gateworks.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    --cc=ye.li@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.