Skip to content

Commit 1e22152

Browse files
olerembroonie
authored andcommitted
regulator: Implement uv_survival_time for handling under-voltage events
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@pengutronix.de> Link: https://lore.kernel.org/r/20231026144824.4065145-6-o.rempel@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 759e2bd commit 1e22152

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5094,7 +5094,7 @@ static void regulator_handle_critical(struct regulator_dev *rdev,
50945094
return;
50955095

50965096
hw_protection_shutdown(reason,
5097-
REGULATOR_DEF_UV_LESS_CRITICAL_WINDOW_MS);
5097+
rdev->constraints->uv_less_critical_window_ms);
50985098
}
50995099

51005100
/**

drivers/regulator/of_regulator.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ static int of_get_regulation_constraints(struct device *dev,
175175
if (!ret)
176176
constraints->enable_time = pval;
177177

178+
ret = of_property_read_u32(np, "regulator-uv-survival-time-ms", &pval);
179+
if (!ret)
180+
constraints->uv_less_critical_window_ms = pval;
181+
else
182+
constraints->uv_less_critical_window_ms =
183+
REGULATOR_DEF_UV_LESS_CRITICAL_WINDOW_MS;
184+
178185
constraints->soft_start = of_property_read_bool(np,
179186
"regulator-soft-start");
180187
ret = of_property_read_u32(np, "regulator-active-discharge", &pval);

include/linux/regulator/machine.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ struct notification_limit {
162162
* regulator_active_discharge values are used for
163163
* initialisation.
164164
* @enable_time: Turn-on time of the rails (unit: microseconds)
165+
* @uv_less_critical_window_ms: Specifies the time window (in milliseconds)
166+
* following a critical under-voltage (UV) event
167+
* during which less critical actions can be
168+
* safely carried out by the system (for example
169+
* logging). After this time window more critical
170+
* actions should be done (for example prevent
171+
* HW damage).
165172
*/
166173
struct regulation_constraints {
167174

@@ -213,6 +220,7 @@ struct regulation_constraints {
213220
unsigned int settling_time_up;
214221
unsigned int settling_time_down;
215222
unsigned int enable_time;
223+
unsigned int uv_less_critical_window_ms;
216224

217225
unsigned int active_discharge;
218226

0 commit comments

Comments
 (0)