From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F037C433EF for ; Wed, 25 May 2022 11:41:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 01804842D2; Wed, 25 May 2022 13:41:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jEMKfujk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 19383842C8; Wed, 25 May 2022 13:41:51 +0200 (CEST) Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 06FF0842D2 for ; Wed, 25 May 2022 13:41:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=aford173@gmail.com Received: by mail-ed1-x531.google.com with SMTP id j28so26600339eda.13 for ; Wed, 25 May 2022 04:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=T6sWwl+cOl5lduso2hdfqfZbB00xCxMgclsqRu83c/c=; b=jEMKfujkzCqjZE9MTwQbmiJACXlYnb1dZzRFNQKhshXwnkRZ2PPlayYu3AyXcb6ghO SKzGC778s9/hdKgriYIDt6c6rv13YsJRT4kz8w8f/zvf0CJBKs9EM4GjK9t7PR6rW7bR LywmdD6Vp3j9nhgKAEyWfTFxb79qlYDtKLkG97rukAbQ6gvWWeijyo9QQ+efNa8Eui53 7qyeTLy/YdJUUbLDM6qiw2EVIwJ/6xnBEjPHJPznYdZ5Mo1RNb2dH93zoMbZH/jLlh9d IJ2P2CclH7aZB4NDUZnNrBRKDZSNIg42B3WUvlhF7yaglFVG9jYkCAPi1d4muLAH48gu NxKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=T6sWwl+cOl5lduso2hdfqfZbB00xCxMgclsqRu83c/c=; b=GtLqbSh1gALzMEcwEqDU7XEfdrnTAaDLQWX3FNm7lKgIRld804Vb4jPLP4L5JllDNy Fw2YHwO1TOmR7IddCxEJXCkMUg1AOLs+tjSY5KunUZ81WinURKRt6bwfQ6Sjvrwy8HcX KHX7t4XO949U6LUOrlLHsDDANzGvhF6UwOYS3/G9laZMcbhgCQNsy4d/OIY8OtnNR2Ud c5pjUIloqmeX5dm0eNwsMtQIpWuxVkWhEhZT+6A8bAA59qSs/VUvdOF9kbCYaV0znixz 80B9fvUla9oqi8xtDkyt6TbPdzkSChMxVfhoIE3DbnN8KA5EWJqYXCgOcBejGdl5XIjR AdSA== X-Gm-Message-State: AOAM533PqJvZiT6iDaXGYGOo1c0IfHe6JQsdT4We7a1R+NCBmgWRLkk8 L7d2ZizSkBT/ZBTobAzAZoz42iNa/mz9ba2ZHGY= X-Google-Smtp-Source: ABdhPJzVNHSKLDXLNEh5ETdzrbEhLFxR2tunJKcBjvzwXFCDkJ34/m2ofVr5o5B7d4zselQv3vL8F8WZxBVaAFy4szY= X-Received: by 2002:a05:6402:4384:b0:42b:5bf6:6d0a with SMTP id o4-20020a056402438400b0042b5bf66d0amr17708716edc.298.1653478907143; Wed, 25 May 2022 04:41:47 -0700 (PDT) MIME-Version: 1.0 References: <3636bdbb-f1aa-7b35-5199-56cff4eb5c64@toradex.com> <20220512101245.15829-2-andrejs.cainikovs@toradex.com> In-Reply-To: <20220512101245.15829-2-andrejs.cainikovs@toradex.com> From: Adam Ford Date: Wed, 25 May 2022 06:41:36 -0500 Message-ID: Subject: Re: [PATCH] imx8m: fixup thermal trips To: Andrejs Cainikovs Cc: Fabio Estevam , Francesco Dolcini , Schrempf Frieder , Marek Vasut , Michael Trimarchi , Peng Fan , Ricardo Salveti , Stefano Babic , Tim Harvey , U-Boot Mailing List , dl-uboot-imx , Ye Li Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Thu, May 12, 2022 at 5:13 AM Andrejs Cainikovs wrote: > > Fixup thermal trips in Linux device tree according to SoC thermal > grade. > > Signed-off-by: Andrejs Cainikovs > --- > 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 >