From patchwork Thu Oct 26 14:48:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 158573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp731151vqb; Thu, 26 Oct 2023 07:49:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFw2ixSUaQoXeHe++H1v95ql0WZmTpu1QDJQaLL3d1NIg2/zboJI2IPR++sr0jNwQOInps7 X-Received: by 2002:a81:ad1d:0:b0:5a8:1a54:ba4b with SMTP id l29-20020a81ad1d000000b005a81a54ba4bmr5485646ywh.13.1698331740056; Thu, 26 Oct 2023 07:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698331740; cv=none; d=google.com; s=arc-20160816; b=VnWWOa+hrmDbIKfZLyxNpU4fHsvMBgoo8y00DRYeEoECcPBC74TZVrdvKrlWrvfmp6 t5QIooEJCxYlX1Cl3rVV/ywAZFJFrjyA01Ep5QXrHJ0PJa+b4L++4KAFl6zY7ZsWxPcc osXf06NFadmYTAm/UG7EKzyCpKdBX3fkuyx31W+R84UNcgX0kIe1YoboXgVus2n/Ifxd kiNt8Z2C7Mqno1rX7So7aOeDCkXQLVzcySDhUGqqUdpuLS5x6xO1GhxM5BtBhHrBClHf t/IIoN8Xp2UBfKeqVWzywFuyOhKsRaN+3cauu1ZXV4aBxm2Uyh4ScZRTX+yKIYWNRsc/ CSBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Lnc2KVUyb4x1u1jlntjXSArFV694c2LHLfQvkepsnF4=; fh=04ly7V1xWE1eBTBwtRUQiwjHX8ICozxkXNJpuSLZLOA=; b=QJ3zB2BjR7zgBNJ/mT+u4BE93c28JyOXtURGSN0lKZT5i3EX4CeiF05fvwPMCIQtWD NW8h185mNcvqe0MYDl0z8MTcN4mtbfNM7Ye3bimUCKwxDmeI4KyoqGzejx33nIUPeW0K EtwlwWjgaIvyo6UFLO3255Z2KfKH/aYwsVNG3PVVnPk17lbV0diG22WRQr7bL8z+dPZp Lp9x3ZKIuq7cARq2VAqGJ5xHWIi6EeCXPavRmKJVaVFTY/2IgbJc5RqMF7C187Qw8R97 oR/cm1TbeDSVgN2SndX4Sj8j5NKrAOEVinqVpRFOm52wSrzA2HOy00qacl5VkLPXPYiB ur3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t206-20020a815fd7000000b0058d204bfc15si16273764ywb.384.2023.10.26.07.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E76EA81B93E6; Thu, 26 Oct 2023 07:48:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345343AbjJZOsx (ORCPT + 26 others); Thu, 26 Oct 2023 10:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235101AbjJZOsn (ORCPT ); Thu, 26 Oct 2023 10:48:43 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BEE81B1 for ; Thu, 26 Oct 2023 07:48:41 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qw1es-0005Zp-2C; Thu, 26 Oct 2023 16:48:26 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qw1er-004Qq3-Hs; Thu, 26 Oct 2023 16:48:25 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qw1er-00H3XZ-1c; Thu, 26 Oct 2023 16:48:25 +0200 From: Oleksij Rempel To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 1/5] regulator: dt-bindings: Add system-critical-regulator property Date: Thu, 26 Oct 2023 16:48:20 +0200 Message-Id: <20231026144824.4065145-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026144824.4065145-1-o.rempel@pengutronix.de> References: <20231026144824.4065145-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 26 Oct 2023 07:48:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780829902530044639 X-GMAIL-MSGID: 1780829902530044639 Introduce a new Device Tree property 'system-critical-regulator' for marking a regulator as crucial for system stability or functionality. This helps in distinguishing regulators that are vital for system operations and may require special handling in under-voltage scenarios. Signed-off-by: Oleksij Rempel Acked-by: Rob Herring --- Documentation/devicetree/bindings/regulator/regulator.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/regulator.yaml b/Documentation/devicetree/bindings/regulator/regulator.yaml index 9daf0fc2465f..5b8d55f7c43b 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/regulator.yaml @@ -114,6 +114,11 @@ properties: description: Enable pull down resistor when the regulator is disabled. type: boolean + system-critical-regulator: + description: Set if the regulator is critical to system stability or + functionality. + type: boolean + regulator-over-current-protection: description: Enable over current protection. type: boolean From patchwork Thu Oct 26 14:48:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 158574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp731349vqb; Thu, 26 Oct 2023 07:49:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELQK3qV7H0qbzus5qR9mSwNx7JDQcjacmMJRsGl0a/WdGw9F+617oONmDUuyfLe5ESsySc X-Received: by 2002:a81:6c0b:0:b0:5ad:43b3:e737 with SMTP id h11-20020a816c0b000000b005ad43b3e737mr8270003ywc.22.1698331759577; Thu, 26 Oct 2023 07:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698331759; cv=none; d=google.com; s=arc-20160816; b=yWNh3vMCRYDuUEnWntBmmzju/FYI1lKpEitmyS94Ypax43g2DkuYMyoGlMeUnnu8z/ qkrwV8/FIHE4AtQjYvwJVgbp63EE43ySERe5zD0jtdezNYt8CDH3sBXmbtN7yfQbs/78 iDu6YyizV8PD1sdclvMGkHtfAvASO/t9WZw3j327HiHpqP6RMPGlwUHGgA1LuosPbBpT XtjtTOmvqZ0wDjUESVbKfyYn9TVsF0H7QgJXKV8rEqFPhk4t8ppvqeNTnYqbakv/Ugrf kMb8DNSIt/kXUUqzXeCucHiDIcBRL6P3kQMwXES7IvDMMlXulRpEqQYwpxPw/PPbXhlB RcxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zmGI0/NFxwrkRqlhkTuCqCzfiplMqO+QUaeu7sIVFcA=; fh=04ly7V1xWE1eBTBwtRUQiwjHX8ICozxkXNJpuSLZLOA=; b=KD9U1mGeYtpI22Mw0GQvc4G/SdzOpuBFSuBB9RYIaQrFUf/15tJiuuXKodRbHCOTxE H1/NKbDagiEaKr0HKuy8KoHC5CJEhWi3K0c7KbzNNrfQxNFGNymibiOoM/lEIWif2Hsf 9EmXPltxErnPpCl4m9X6gl1TiWN5yM71NuPeFjizT3kaeTTYCbhrgBdMwxlQcvdmUMRG LgJAGWcsA3Du/2jIUMVGmiR+MNUBmA9e5ZnpysP65bHCOE6K7R2+WuYJp5J1IFs/bXKh c1cECp449vte3gvuPk5rXRY+d4kCZ+DNWo6rM+iNq509pxQ+gfNqF7twkmr2Ah+qcv3d WDEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a207-20020a0dd8d8000000b005a7c1d0303fsi15617864ywe.105.2023.10.26.07.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:49:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4997281CC860; Thu, 26 Oct 2023 07:49:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345351AbjJZOs5 (ORCPT + 26 others); Thu, 26 Oct 2023 10:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235105AbjJZOso (ORCPT ); Thu, 26 Oct 2023 10:48:44 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15F151AE for ; Thu, 26 Oct 2023 07:48:41 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qw1es-0005Zq-2D; Thu, 26 Oct 2023 16:48:26 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qw1er-004Qq4-JD; Thu, 26 Oct 2023 16:48:25 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qw1er-00H3Xj-1g; Thu, 26 Oct 2023 16:48:25 +0200 From: Oleksij Rempel To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 2/5] regulator: Introduce handling for system-critical under-voltage events Date: Thu, 26 Oct 2023 16:48:21 +0200 Message-Id: <20231026144824.4065145-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026144824.4065145-1-o.rempel@pengutronix.de> References: <20231026144824.4065145-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 26 Oct 2023 07:49:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780829923074292267 X-GMAIL-MSGID: 1780829923074292267 Handle under-voltage events for crucial regulators to maintain system stability and avoid issues during power drops. Signed-off-by: Oleksij Rempel --- drivers/regulator/core.c | 38 +++++++++++++++++++++++++++++++ drivers/regulator/of_regulator.c | 2 ++ include/linux/regulator/machine.h | 10 ++++++++ 3 files changed, 50 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 3137e40fcd3e..a072f721f288 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -5061,6 +5062,41 @@ void regulator_bulk_free(int num_consumers, } EXPORT_SYMBOL_GPL(regulator_bulk_free); +/** + * regulator_handle_critical - Handle events for system-critical regulators. + * @rdev: The regulator device. + * @event: The event being handled. + * + * This function handles critical events such as under-voltage, over-current, + * and unknown errors for regulators deemed system-critical. On detecting such + * events, it triggers a hardware protection shutdown with a defined timeout. + */ +static void regulator_handle_critical(struct regulator_dev *rdev, + unsigned long event) +{ + const char *reason = NULL; + + if (!rdev->constraints->system_critical) + return; + + switch (event) { + case REGULATOR_EVENT_UNDER_VOLTAGE: + reason = "System critical regulator: voltage drop detected"; + break; + case REGULATOR_EVENT_OVER_CURRENT: + reason = "System critical regulator: over-current detected"; + break; + case REGULATOR_EVENT_FAIL: + reason = "System critical regulator: unknown error"; + } + + if (!reason) + return; + + hw_protection_shutdown(reason, + REGULATOR_DEF_UV_LESS_CRITICAL_WINDOW_MS); +} + /** * regulator_notifier_call_chain - call regulator event notifier * @rdev: regulator source @@ -5073,6 +5109,8 @@ EXPORT_SYMBOL_GPL(regulator_bulk_free); int regulator_notifier_call_chain(struct regulator_dev *rdev, unsigned long event, void *data) { + regulator_handle_critical(rdev, event); + _notifier_call_chain(rdev, event, data); return NOTIFY_DONE; diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 1b65e5e4e40f..3bdd6f1919a4 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -131,6 +131,8 @@ static int of_get_regulation_constraints(struct device *dev, constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; constraints->pull_down = of_property_read_bool(np, "regulator-pull-down"); + constraints->system_critical = of_property_read_bool(np, + "system-critical-regulator"); if (of_property_read_bool(np, "regulator-allow-bypass")) constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 621b7f4a3639..e0ddfb5593c9 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -49,6 +49,13 @@ struct regulator; #define DISABLE_IN_SUSPEND 1 #define ENABLE_IN_SUSPEND 2 +/* + * Default time window (in milliseconds) following a critical under-voltage + * event during which less critical actions can be safely carried out by the + * system. + */ +#define REGULATOR_DEF_UV_LESS_CRITICAL_WINDOW_MS 10 + /* Regulator active discharge flags */ enum regulator_active_discharge { REGULATOR_ACTIVE_DISCHARGE_DEFAULT, @@ -127,6 +134,8 @@ struct notification_limit { * @ramp_disable: Disable ramp delay when initialising or when setting voltage. * @soft_start: Enable soft start so that voltage ramps slowly. * @pull_down: Enable pull down when regulator is disabled. + * @system_critical: Set if the regulator is critical to system stability or + * functionality. * @over_current_protection: Auto disable on over current event. * * @over_current_detection: Configure over current limits. @@ -214,6 +223,7 @@ struct regulation_constraints { unsigned ramp_disable:1; /* disable ramp delay */ unsigned soft_start:1; /* ramp voltage slowly */ unsigned pull_down:1; /* pull down resistor when regulator off */ + unsigned system_critical:1; /* critical to system stability */ unsigned over_current_protection:1; /* auto disable on over current */ unsigned over_current_detection:1; /* notify on over current */ unsigned over_voltage_detection:1; /* notify on over voltage */ From patchwork Thu Oct 26 14:48:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 158576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp731719vqb; Thu, 26 Oct 2023 07:49:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFg/CxNUzC/49TLjYnv2sFx8d9cLkeDLyrbhR8zlpV3d9CHSSiyvEWe9S3O6CyCQKOn8xeR X-Received: by 2002:a0d:df42:0:b0:5a7:be23:6a7c with SMTP id i63-20020a0ddf42000000b005a7be236a7cmr21471112ywe.6.1698331796441; Thu, 26 Oct 2023 07:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698331796; cv=none; d=google.com; s=arc-20160816; b=vCdi2NzBRXG3bwO/hASPEHao9XYkpTkGe+1aBooEffDztWunh9qRR0oTsMbxY/y/ED tlvp9xK6heKSESus6un6hZo0TrmGXPQ/0WQxQYinjhaM34lvgpRo4KaaHJl05GFsvTG6 2E2Z9GoDdk/4ksHtFwOoBgGpqQQCO3D8PCfPlGAoDZBWAbUPgc5ldXGrZ1/XD60Hc0/X dZ0fwjLnHheewAjB7x6xi8uWdFJgvbU5Ahl6LaLUje9/+TYCDinyinVOWayWCYjMCSLI 1XcwqTjLmxl7Lld3T5Zn0xMbZj95EQLqeMZObBgrGNA8aXRKvI5LIKv3dYBgfm0126IH KfUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CrcSlbVoc5cXe6M94dD8rtZfS72OfXFCEFZ/hUgWQuo=; fh=04ly7V1xWE1eBTBwtRUQiwjHX8ICozxkXNJpuSLZLOA=; b=sBPHT8gBalJTYSN/ZJMXFqm2eMBo0vYhNzzZ7iDgcM1C6WYG7eSEXkltN/gzPtU3wS nFlyfmA7/MdVRxMLNPrDbWmz4iJLQNUBYtka1CB7bPGA+vdlIGQKuq4ldO/YN54bjDG3 UJFNti42Gzj5yFrieEDAoVVS8gFBsD79UiVPuGpSe59SUTwLUF0lsMjpouEszGMI3Uol DznuLHUPzIINaTY5Af5qhfJtzOd8kP37Azan9lSHhqSXNS++xuS7EFvoiRRyI5V4me0N S7xAE/M9vMEoxWwThwDxISaJ728DzYUNqcjb/rq5d4aBTvFz4z2VXrfeTET/jicEvMRa 7oDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id j7-20020a816e07000000b005a4f6997b2csi14847298ywc.58.2023.10.26.07.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:49:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C12BE8220117; Thu, 26 Oct 2023 07:49:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345331AbjJZOsv (ORCPT + 26 others); Thu, 26 Oct 2023 10:48:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235100AbjJZOsn (ORCPT ); Thu, 26 Oct 2023 10:48:43 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A3B21B4 for ; Thu, 26 Oct 2023 07:48:41 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qw1es-0005Zr-2C; Thu, 26 Oct 2023 16:48:26 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qw1er-004Qq5-JY; Thu, 26 Oct 2023 16:48:25 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qw1er-00H3Xt-1l; Thu, 26 Oct 2023 16:48:25 +0200 From: Oleksij Rempel To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 3/5] regulator: dt-bindings: Allow system-critical marking for fixed-regulator Date: Thu, 26 Oct 2023 16:48:22 +0200 Message-Id: <20231026144824.4065145-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026144824.4065145-1-o.rempel@pengutronix.de> References: <20231026144824.4065145-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 07:49:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780829961581639520 X-GMAIL-MSGID: 1780829961581639520 In certain projects, the main system regulator, composed of simple components including an under-voltage detector and capacitors, can be aptly described as a fixed regulator in the device tree. To cater to such use cases, this patch extends the fixed regulator binding to support the 'system-critical-regulator' property. This property signifies that the fixed-regulator is vital for system stability. Signed-off-by: Oleksij Rempel Acked-by: Rob Herring --- .../devicetree/bindings/regulator/fixed-regulator.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml b/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml index ce7751b9129c..9ff9abf2691a 100644 --- a/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml @@ -105,6 +105,8 @@ properties: description: Interrupt signaling a critical under-voltage event. + system-critical-regulator: true + required: - compatible - regulator-name From patchwork Thu Oct 26 14:48:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 158575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp731671vqb; Thu, 26 Oct 2023 07:49:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1E9hKG09cvK+sBnyvHaQyBCV9CxZtxtnYBULNPcZejSAgcbY45+IqxvaGVNZpbQA2Dq2O X-Received: by 2002:a25:7105:0:b0:da0:aa1b:80f3 with SMTP id m5-20020a257105000000b00da0aa1b80f3mr3862079ybc.10.1698331791389; Thu, 26 Oct 2023 07:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698331791; cv=none; d=google.com; s=arc-20160816; b=B1iWCM56Qjmg3uJgxYBsOmrAlevBYKI/ZbuG5Zv2A153HMCwC6qxtw9CG9pjbyYCMW PTb6AFJebHG62Ptjuhg5jrObHSMT2bNBmS4CX8t6VJN+icn2Z05a7BR/pdCK9UXcU/Rl zfQdsKfnjcwiHchUMEh9UlNzZYIqrrqYrfzKlY67BitxZyhXystrK9NQJ7C628pg522P P+CrxyXzCF54mcwgekm8sZCy4kIc4Hl9F49WSL6upybO866cDEfP8iGVMwtMpfol3Hd2 sHzUnjQdFc0ddYFzeryUuJ7E4WdcEsLF8iHVspBHzIw2SjBeX+3tyqu5MNQ6A4kh1kpg 5Vxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Uekl2pKBNpqO7PfDuK2I4RyNq5HhhDY5rLzSVuDboDg=; fh=04ly7V1xWE1eBTBwtRUQiwjHX8ICozxkXNJpuSLZLOA=; b=MmRot1pYUdI4wIIwgcu2kUv9GaWJ8ZzlJK8tDhIIs8JE/UamI+07rzfSwIgTBmb5N9 yhUEBT5T2uIu32FasL1zeGGVCQpaTczAsVsksPo+nYdYCBS4BmVAluxt+imKOaWcTORF 7RzU/8i1LM5pr2n8zq9RBbbeylWwbGiMZopo3fDHPB8F7JbM0B1usT2ttk88cyg4rqGW lk6xKdKuyULvseUhXsWp/JPYhrcokR8ZCLz4ur08AcxUUZR8vUJBEWij+jI/TeEqJtYh k2ABpHB+W4RUOy8y3DsCbgPCOx+zxzVGGBKuCPKpBOTx/Ol8nvx0EVQcmR0kdPpWiE7Z gKpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id b129-20020a253487000000b00d9a3739239fsi13632385yba.313.2023.10.26.07.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:49:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 74DF682D8781; Thu, 26 Oct 2023 07:49:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345378AbjJZOs4 (ORCPT + 26 others); Thu, 26 Oct 2023 10:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235107AbjJZOso (ORCPT ); Thu, 26 Oct 2023 10:48:44 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 592281B3 for ; Thu, 26 Oct 2023 07:48:41 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qw1es-0005Zs-2A; Thu, 26 Oct 2023 16:48:26 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qw1er-004Qq7-KK; Thu, 26 Oct 2023 16:48:25 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qw1er-00H3Y3-1o; Thu, 26 Oct 2023 16:48:25 +0200 From: Oleksij Rempel To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 4/5] regulator: dt-bindings: Add 'regulator-uv-less-critical-window-ms' property Date: Thu, 26 Oct 2023 16:48:23 +0200 Message-Id: <20231026144824.4065145-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026144824.4065145-1-o.rempel@pengutronix.de> References: <20231026144824.4065145-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 26 Oct 2023 07:49:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780829956894973697 X-GMAIL-MSGID: 1780829956894973697 Introduces a new devicetree property to specifies the time window (in milliseconds) following a critical under-voltage (UV) event during which less critical actions can be safely carried out by the system. Less Critical Actions: - Logging the under-voltage event for later analysis. - Saving less critical data that may be useful for diagnosing issues or for audit purposes. More Critical Actions (post the less critical window): - Initiating procedures to properly shutdown hardware to prevent damage. The 'regulator-uv-less-critical-window-ms' property is crucial for conveying board-specific hardware characteristics, not for enforcing a certain policy. The time window represented by this property is derived from the physical attributes of the hardware like the capacity of on-board capacitors, the power consumption of the components, and the time needed to safely shut down hardware to prevent damage. These attributes can significantly vary between different boards, making it a board-specific property rather than a policy directive. By providing a precise representation of the time available for less critical actions post an under-voltage event, this property enables the kernel to make informed decisions on action prioritization, ensuring that essential preventative measures are taken to avoid hardware damage while also allowing for data capture and analysis. Signed-off-by: Oleksij Rempel Acked-by: Rob Herring --- .../devicetree/bindings/regulator/regulator.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/regulator.yaml b/Documentation/devicetree/bindings/regulator/regulator.yaml index 5b8d55f7c43b..1ef380d1515e 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/regulator.yaml @@ -186,6 +186,14 @@ properties: be enabled but limit setting can be omitted. Limit is given as microvolt offset from voltage set to regulator. + regulator-uv-less-critical-window-ms: + description: Specifies the time window (in milliseconds) following a + critical under-voltage event during which the system can continue to + operate safely while performing less critical operations. This property + provides a defined duration before a more severe reaction to the + under-voltage event is needed, allowing for certain non-urgent actions to + be carried out in preparation for potential power loss. + regulator-temp-protection-kelvin: description: Set over temperature protection limit. This is a limit where hardware performs emergency shutdown. Zero can be passed to disable From patchwork Thu Oct 26 14:48:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 158578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp742205vqb; Thu, 26 Oct 2023 08:04:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPLvyAHydYPG9DRfYalnENXBY6EvdocSQFH6UyW24JJT5WC7A5l40CLQgYBB8fHJ2fBA71 X-Received: by 2002:a05:6808:9bc:b0:3b2:f275:18a8 with SMTP id e28-20020a05680809bc00b003b2f27518a8mr18260525oig.22.1698332673628; Thu, 26 Oct 2023 08:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698332673; cv=none; d=google.com; s=arc-20160816; b=jTVDaqs6etug3Z3JJpaC1PsHMeGfAzHG60oYgebD09jnn8vftqvqK06OJvotvGowZE dPd2POB9nwmd6e7acbyRF+rwvtj2FA90W26lBtETUrLuwYOji0GTCEzZRJNbkKvNAXlz veQm1W+0p/QhfbLVBMR1HqSh+ZvumUe5RJjpZ9fBXmf0X4Ha6Ld66aE6ppQu8RI3QlYd 4l4dio6XdruXgjkyzmasst5fYO6qTObeA/bgDKOte11lyroBjfdBKEr2Quhz0DrAwxfW dFAWEIwbAQviHiLc3m/fqheOmHhR4w9Dr2X4MeztjS8xgK08/Rt6enQALUmqsNkpee5b aonw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LBShwAR96x+RiJcgt0UtgWazP3yFL0cj2rF1nrzRzak=; fh=04ly7V1xWE1eBTBwtRUQiwjHX8ICozxkXNJpuSLZLOA=; b=e9/GkscgVCgP7zEXIQR6l+P2v4dP33rtZqgDfs2EXdG18W/0HhE6+Mpu5126C4OBlP 4h85kXgPpCh7RP49wtOXucSBU2o0D/Btf6lIv9QFPLtGfxgPGWQVwhzyFANhsT3Qil9/ UPYIeKBvy9PZ/NzeIQSfh7sIWqHUtRnHJtthKe+/UkpcnbgK28/9Om0aJxD4QiT7f4jS PX6anHsh92p2x+ZYzUhanoHFDK9hTTeaCmFfRYxo6Od6u5tXhhTsTNUgQqhpEuMBP/wu N6gsaCxdQyIvCVHzHw+fnFs7akFT1fDuSnng7ZyxoV5Taa/CEKDKjwiCvbc/q6ECriWk GYeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id x9-20020a67fc89000000b00454568ed0ffsi1558181vsp.191.2023.10.26.08.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:04:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8300C80491F8; Thu, 26 Oct 2023 08:04:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345355AbjJZOsy (ORCPT + 26 others); Thu, 26 Oct 2023 10:48:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235103AbjJZOsn (ORCPT ); Thu, 26 Oct 2023 10:48:43 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14D911AB for ; Thu, 26 Oct 2023 07:48:41 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qw1es-0005Zt-2b; Thu, 26 Oct 2023 16:48:26 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qw1er-004Qq9-Ke; Thu, 26 Oct 2023 16:48:25 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qw1er-00H3YE-1s; Thu, 26 Oct 2023 16:48:25 +0200 From: Oleksij Rempel To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 5/5] regulator: Implement uv_survival_time for handling under-voltage events Date: Thu, 26 Oct 2023 16:48:24 +0200 Message-Id: <20231026144824.4065145-6-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026144824.4065145-1-o.rempel@pengutronix.de> References: <20231026144824.4065145-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 26 Oct 2023 08:04:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780830881695815530 X-GMAIL-MSGID: 1780830881695815530 Add 'uv_survival_time' field to regulation_constraints for specifying survival time post critical under-voltage event. Update the regulator notifier call chain and Device Tree property parsing to use this new field, allowing a configurable timeout before emergency shutdown. Signed-off-by: Oleksij Rempel --- drivers/regulator/core.c | 2 +- drivers/regulator/of_regulator.c | 7 +++++++ include/linux/regulator/machine.h | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a072f721f288..a6cb84af989e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5094,7 +5094,7 @@ static void regulator_handle_critical(struct regulator_dev *rdev, return; hw_protection_shutdown(reason, - REGULATOR_DEF_UV_LESS_CRITICAL_WINDOW_MS); + rdev->constraints->uv_less_critical_window_ms); } /** diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 3bdd6f1919a4..03afc160fc72 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -175,6 +175,13 @@ static int of_get_regulation_constraints(struct device *dev, if (!ret) constraints->enable_time = pval; + ret = of_property_read_u32(np, "regulator-uv-survival-time-ms", &pval); + if (!ret) + constraints->uv_less_critical_window_ms = pval; + else + constraints->uv_less_critical_window_ms = + REGULATOR_DEF_UV_LESS_CRITICAL_WINDOW_MS; + constraints->soft_start = of_property_read_bool(np, "regulator-soft-start"); ret = of_property_read_u32(np, "regulator-active-discharge", &pval); diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index e0ddfb5593c9..0cd76d264727 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -162,6 +162,13 @@ struct notification_limit { * regulator_active_discharge values are used for * initialisation. * @enable_time: Turn-on time of the rails (unit: microseconds) + * @uv_less_critical_window_ms: Specifies the time window (in milliseconds) + * following a critical under-voltage (UV) event + * during which less critical actions can be + * safely carried out by the system (for example + * logging). After this time window more critical + * actions should be done (for example prevent + * HW damage). */ struct regulation_constraints { @@ -213,6 +220,7 @@ struct regulation_constraints { unsigned int settling_time_up; unsigned int settling_time_down; unsigned int enable_time; + unsigned int uv_less_critical_window_ms; unsigned int active_discharge;