Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp505043rdh; Thu, 26 Oct 2023 08:04:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHiXt5RbmEuq95kE1oNngKtKcodg+aWnLkqEY3Pv8ooM3E5Vbtuy6NrLnzW9B0Yfasm0dRe X-Received: by 2002:a05:690c:83:b0:5a1:db6a:6459 with SMTP id be3-20020a05690c008300b005a1db6a6459mr20091674ywb.40.1698332682783; Thu, 26 Oct 2023 08:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698332682; cv=none; d=google.com; s=arc-20160816; b=k/+Ol+gTmQKtdVINvLKhgVpeITaq9o7sa9AyFQx5J4OgixXCZFyaYtdDh2FLz8iaQ4 jUgJseraNDxGxMwAFzOO3TsU7UvUaP7D+yflOh+u3RoUcg+zhXoDl4KpckPL5myMjVXz ouctkjuuvpXWu6j5g9wXykp492dlpFSx4jZI85zwMmfgNxPw8btLOEPjUJQdEVIWGxQP P0gYZ3Ex41kVOILSz8R4qhqv/5juOYuljJZf6yiYckYD0losS4pYr/VrSsG81TKqb1dO IET+8NNUsGg0fSpGOkbki8G/u4sCkJV07tUyZcl2kQo1l1Q0z/gxYtYWhJnIz6/c2vJ7 w64A== 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:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t188-20020a815fc5000000b005a1e4d143ccsi15721393ywb.202.2023.10.26.08.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:04:42 -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 54BFD801BF52; Thu, 26 Oct 2023 08:04:34 -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 S1345354AbjJZOsy (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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 08:04:34 -0700 (PDT) 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; -- 2.39.2