From patchwork Wed Oct 25 08:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 157936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2454570vqx; Wed, 25 Oct 2023 01:46:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsYnirUlS26dp7+WnPMVDnkcWPOscE8a0MT/uPXboflNgiO1R7g/DvZoXn4iYCgd8pjuoz X-Received: by 2002:a0d:cbc7:0:b0:5a7:ab45:539d with SMTP id n190-20020a0dcbc7000000b005a7ab45539dmr15161495ywd.2.1698223610905; Wed, 25 Oct 2023 01:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698223610; cv=none; d=google.com; s=arc-20160816; b=sl4HdRLO52xtUpa1MtFvHMFTQehs3ty2FwKlgYV3CGjXFg4qGBAkH6T5y8HFgeRqhJ rHm12430mnDMV8rpFAYRdw/Fh/s8ZnJuFCKISLHPPWMcFss2aFNvFGyhaDSUgXfnDhR9 sIJ9SxPpuACnM2Fwzp+TH/5vrryD0rAszDUChJf/qyxVGuxT4tRZXu7TMTXvi5TpP8V2 MS+sJceMvEW5LSdmCgMDkTrBZM0Sban5kUFOotF0wVbLGD66dSB49SspNkgJT2tqRbzS LeHjlvpwUe6tIhETAICdQtRD8Ywm1czoD8RO8xi9jTWVXq1yfrZBxmlG+GkKH9DFJT4y kOng== 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=47O9Jjsec4+wQ0DB2tP8C02KZGhtLIXde46NsjzWOSA=; fh=04ly7V1xWE1eBTBwtRUQiwjHX8ICozxkXNJpuSLZLOA=; b=vJkd6FPDETJJ39dXLSLUT9aHoRgDRkRXki/HeZVvbGmLCpI9Y/sdl+O3fsi3FQMFDf wIXYrkjkuOEx4cFagDTAlP50cVjXa64D8WKRk4dhsYXHruIgten/jeWa+iLwK21+kFI/ 8IUXhrD3qVtPoqsosD40KtDIYTfmp82/fRGjduonmDwyuGwfI4fTK0Vimo6RNLsyAcic A6ZlKu4X9T5Yb3iCT/5YBBEoxwuSIFR0JdYCxmKgnnVUNE6qYvQUhtKADnS5PcSmOi3U bakx/JnXMMPVtdbKJBSC9KHssLmeFJqtYpWtt2OqXCHKNK0sPOBZ+DYffM5FuPXhSRck iu2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j18-20020a819212000000b0059f54066709si10275821ywg.108.2023.10.25.01.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 01:46:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 5727A801BB78; Wed, 25 Oct 2023 01:46:43 -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 S234266AbjJYIqe (ORCPT + 26 others); Wed, 25 Oct 2023 04:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbjJYIq1 (ORCPT ); Wed, 25 Oct 2023 04:46:27 -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 BFEA6130 for ; Wed, 25 Oct 2023 01:46:24 -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 1qvZWq-0002CG-9l; Wed, 25 Oct 2023 10:46:16 +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 1qvZWp-0048Wk-Ec; Wed, 25 Oct 2023 10:46:15 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qvZWp-00CyTR-1C; Wed, 25 Oct 2023 10:46:15 +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 v3 7/7] regulator: Implement uv_survival_time for handling under-voltage events Date: Wed, 25 Oct 2023 10:46:14 +0200 Message-Id: <20231025084614.3092295-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231025084614.3092295-1-o.rempel@pengutronix.de> References: <20231025084614.3092295-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]); Wed, 25 Oct 2023 01:46:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780716521439693998 X-GMAIL-MSGID: 1780716521439693998 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 | 6 ++++++ include/linux/regulator/machine.h | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 903c384f25e3..bb864969fc79 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5077,7 +5077,7 @@ int regulator_notifier_call_chain(struct regulator_dev *rdev, if (rdev->constraints->system_critical && event == REGULATOR_EVENT_UNDER_VOLTAGE) hw_protection_shutdown("System critical voltage drop detected", - REGULATOR_DEF_EMERG_SHUTDWN_TMO); + rdev->constraints->uv_survival_time); _notifier_call_chain(rdev, event, data); return NOTIFY_DONE; diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 3bdd6f1919a4..6463b455ebc5 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -175,6 +175,12 @@ 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_survival_time = pval; + else + constraints->uv_survival_time = REGULATOR_DEF_EMERG_SHUTDWN_TMO; + 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 7332ee36e9d6..daddec83d887 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -158,6 +158,11 @@ struct notification_limit { * regulator_active_discharge values are used for * initialisation. * @enable_time: Turn-on time of the rails (unit: microseconds) + * @uv_survival_time: Survival time post a critical under-voltage event. Time + * the system can operate before the on-board capacitors + * fail, providing a window for necessary actions or + * preparations to be taken before power loss. + * (unit: microseconds) */ struct regulation_constraints { @@ -209,6 +214,7 @@ struct regulation_constraints { unsigned int settling_time_up; unsigned int settling_time_down; unsigned int enable_time; + unsigned int uv_survival_time; unsigned int active_discharge;