From patchwork Thu Aug 24 16:50:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 716765 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA872C6FA8F for ; Thu, 24 Aug 2023 16:50:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242676AbjHXQuX (ORCPT ); Thu, 24 Aug 2023 12:50:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242730AbjHXQuV (ORCPT ); Thu, 24 Aug 2023 12:50:21 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA92E51; Thu, 24 Aug 2023 09:50:20 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1c530d5468bso3087fac.0; Thu, 24 Aug 2023 09:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692895819; x=1693500619; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LQzPJ69QFgZSREU/WQOief2g/Hd/McjGIAtKEDDg4Y4=; b=qHKIXZqy5mAwolyDls8HzGyC7caP01VtcV3dXMQ58Ksd6nIkv3JmZeSltn/CZfthlk kbTbKrKIA+YSGdZs6CJCLGxREU1G4NbE2ZLtdISB7oYgn3hq74MVtLj2m4C/U5QxT1c2 GLexrd0B8Q1FGNiCotoRIkuyWsWmyS1j5x9p16mDLbeh+YE+UwGozYq2ZPkd1tTdxiDS nEpSJvGfNB/Y6m0V9re/c+4qq4697o+yDENLGrLrIFZe6yMhxxnbFRbvlbOgckPDSrid OlnNypE2kUow4uBh6eK89z3HA5XLyu+I1iCuCHaS3PMS9949hl8usew78Gf8OstyNUrr 0epg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692895819; x=1693500619; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LQzPJ69QFgZSREU/WQOief2g/Hd/McjGIAtKEDDg4Y4=; b=ciIAFGVBGCvOtIrUcaveqSjiOGHwpj+8viOSsJCqe3a3n571WsMlx5NsOC64Yv8wdN j++MOD856DrcvEg9Fv4gZPnVXLSkFFqpuuzpGb68bs3Dj5MLFErpQKIlKPRp3MkQ7AOL 043lNCZ/w5WQcMlaEK4eS2FKVx2bvYnYaDOopSOidXPq7LQ93LL1i1o2SgfQhh3vheoo 3mZX737qrn0B1lis04W+9CQBjBPzzie6XK4Gcrf4UJnHShHLSVNYN2B79uAuRjIDPVLH 9Qt6lLUXmSIpjrLnzPDTCatTUYdxk7yyE+6ZDAgivKwUry78x6Lzb3SKyeT+FECr1vKQ TEHw== X-Gm-Message-State: AOJu0YzrkZEBL9J2fj/yLCWaEmIwW/3+LS2fNrJ4mfbBHkrGFDrnSPRE ADJWBQWECvH+00rRe6JVQmQ= X-Google-Smtp-Source: AGHT+IHwtmI4+6vMWUV20/wljnduxoQ+rNOxal9oLmU3GNrp42Ax8ePoatDY25q0ooX9ieGkuCIMsw== X-Received: by 2002:a05:6870:2199:b0:1bf:dfed:c9a4 with SMTP id l25-20020a056870219900b001bfdfedc9a4mr17975969oae.5.1692895819216; Thu, 24 Aug 2023 09:50:19 -0700 (PDT) Received: from fabio-Precision-3551.. ([2804:14c:485:4b61:12f9:9354:2260:4588]) by smtp.gmail.com with ESMTPSA id zf21-20020a0568716a9500b001c51990e2a0sm5697990oab.53.2023.08.24.09.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 09:50:18 -0700 (PDT) From: Fabio Estevam To: daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Fabio Estevam Subject: [PATCH v5 1/2] dt-bindings: imx8mm-thermal: Document nxp,reboot-on-critical Date: Thu, 24 Aug 2023 13:50:10 -0300 Message-Id: <20230824165011.569386-1-festevam@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Fabio Estevam Currently, after the SoC reaches the critical temperature, the board goes through a poweroff mechanism. In some cases, such behavior does not suit well, as the board may be unattended in the field and rebooting may be a better approach. The bootloader may also check the temperature and only allow the boot to proceed when the temperature is below a certain threshold. Introduce the 'nxp,reboot-on-critical' property to indicate that the board will go through a reboot after the critical temperature is reached. When this property is absent, the default behavior of forcing a shutdown is kept. Signed-off-by: Fabio Estevam --- Changes since v4: - None. Went back to using device tree property. .../devicetree/bindings/thermal/imx8mm-thermal.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml b/Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml index d2c1e4573c32..9ac70360fd35 100644 --- a/Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml +++ b/Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml @@ -32,6 +32,12 @@ properties: clocks: maxItems: 1 + nxp,reboot-on-critical: + description: Property to indicate that the system will go through a reboot + after the critical temperature is reached. If absent, the system will + go through shutdown after the critical temperature is reached. + type: boolean + nvmem-cells: maxItems: 1 description: Phandle to the calibration data provided by ocotp From patchwork Thu Aug 24 16:50:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 716764 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23538C3DA6F for ; Thu, 24 Aug 2023 16:51:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242650AbjHXQu6 (ORCPT ); Thu, 24 Aug 2023 12:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242710AbjHXQuY (ORCPT ); Thu, 24 Aug 2023 12:50:24 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBB88199D; Thu, 24 Aug 2023 09:50:22 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6b9cd6876bbso11480a34.1; Thu, 24 Aug 2023 09:50:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692895822; x=1693500622; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rLSqqr6p1MYItW3pXcqRaVAFN1Hp7NsO7h0Ylat3w9g=; b=LPAXhLZXXZZH8GmCW0mAK2QadHlxqFtdJDOqVZlVF2CUwDcv3K7kHt4yRkH35pIdAG geSuzqu5f92nh6liLWSuAZDA/URLeIMgFBORMikaqmE/vXmDx/KTOQxhV/wicis1wGz/ Li9VfutIvJhdXCe1jZ9mDr/+cmXe/Z3OcEMF5vvTV8aocNxJa1/AR2twlLFLHKno0ImW Iwmwl1EYjbfgWIK8zEu5kftBE/j1qq97gSu1WzJtbNhrAysUSklWY71jIq9BNaZYNelW 9j2Qt4R6ysfhY5hRfme37Ru8UOcmlIUCFrWwV4wQNT0ieM7NeSImrspQ0Kai1uB9IrGe 6ZzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692895822; x=1693500622; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rLSqqr6p1MYItW3pXcqRaVAFN1Hp7NsO7h0Ylat3w9g=; b=TVwXySQZgoPTGYGg3SR5oXakt8yY6a5FVopLFuh76SueT4nvssbMpih8A+3dnPVxB9 s7RC00MetobDjc0NbUhoDSPOYal/GzdghccNAJi0D3WMbMTTCTafVOIxMqBLc3vr1Pcb mUEnpFZrSDut75PI4sZFZtchnBOIjOakbK51Se9O7FaqNxwtqYHc0JlQXg44wItZYRY9 pSJxTbb7oshd83AVSmFHKY9otb0cenCCRwSoZUFrZYarbjOTC4Pa5xS9Fl/qsFdGiGlP u8QZblzwoiU4C+EN4EYzjsqr310pM9Cmh8swrfs8471D23+9ODaj0kmGAqqiRqGotN3v Rf2g== X-Gm-Message-State: AOJu0YwGnA9F7HDYTAZULNK1EXSUxZF791oHPaOcHJOqKNcXWq/aNohF svXkC+omoy9H7Cq64B6mlq8= X-Google-Smtp-Source: AGHT+IEoUQ5wLDLKkmmvqArDFW9S9EynUQirmNwH7KZeZFMll0mGOe9K9/g3V+fj0IbdDvXndVba2A== X-Received: by 2002:a05:6870:4690:b0:1b7:613c:2e30 with SMTP id a16-20020a056870469000b001b7613c2e30mr17829758oap.2.1692895822091; Thu, 24 Aug 2023 09:50:22 -0700 (PDT) Received: from fabio-Precision-3551.. ([2804:14c:485:4b61:12f9:9354:2260:4588]) by smtp.gmail.com with ESMTPSA id zf21-20020a0568716a9500b001c51990e2a0sm5697990oab.53.2023.08.24.09.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 09:50:21 -0700 (PDT) From: Fabio Estevam To: daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Fabio Estevam Subject: [PATCH v5 2/2] thermal: imx8mm: Allow reboot after critical temperature Date: Thu, 24 Aug 2023 13:50:11 -0300 Message-Id: <20230824165011.569386-2-festevam@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824165011.569386-1-festevam@gmail.com> References: <20230824165011.569386-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Fabio Estevam Currently, after the SoC reaches the critical temperature, the board goes through a poweroff mechanism. In some cases, such behavior does not suit well, as the board may be unattended in the field and rebooting may be a better approach. The bootloader may also check the temperature and only allow the boot to proceed when the temperature is below a certain threshold. Introduce the 'nxp,reboot-on-critical' property to indicate that the board will go through a reboot after the critical temperature is reached. When this property is absent, the default behavior of forcing a shutdown is kept. Tested on a imx8mm-evk board. Signed-off-by: Fabio Estevam --- Changes since v4: - Went back to the devicetree approach. - Populate tmu_tz_ops.critical inside probe (Daniel). Changes since v3: - Switch to sysfs. Changes since v2: - Populate tmu_tz_ops.critical inside probe (Daniel). Changes since v1: - Use module_param(). drivers/thermal/imx8mm_thermal.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/imx8mm_thermal.c b/drivers/thermal/imx8mm_thermal.c index e89b11b3f2b9..0ca3cba33f39 100644 --- a/drivers/thermal/imx8mm_thermal.c +++ b/drivers/thermal/imx8mm_thermal.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -146,7 +147,7 @@ static int tmu_get_temp(struct thermal_zone_device *tz, int *temp) return tmu->socdata->get_temp(sensor, temp); } -static const struct thermal_zone_device_ops tmu_tz_ops = { +static struct thermal_zone_device_ops tmu_tz_ops = { .get_temp = tmu_get_temp, }; @@ -293,6 +294,13 @@ static int imx8mm_tmu_probe_set_calib(struct platform_device *pdev, return imx8mm_tmu_probe_set_calib_v2(pdev, tmu); } +static void tmu_critical(struct thermal_zone_device *tz) +{ + dev_emerg(thermal_zone_device(tz), "%s: critical temperature reached\n", + thermal_zone_device_type(tz)); + kernel_restart(NULL); +} + static int imx8mm_tmu_probe(struct platform_device *pdev) { const struct thermal_soc_data *data; @@ -313,6 +321,9 @@ static int imx8mm_tmu_probe(struct platform_device *pdev) if (IS_ERR(tmu->base)) return PTR_ERR(tmu->base); + if (of_property_present(pdev->dev.of_node, "nxp,reboot-on-critical")) + tmu_tz_ops.critical = tmu_critical; + tmu->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(tmu->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(tmu->clk),