[PATCH v3 7/7] regulator: Implement uv_survival_time for handling under-voltage events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <o.rempel@xxxxxxxxxxxxxx>
---
 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;
 
-- 
2.39.2





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux