[PATCH RFC v3 0/5] regulator: dynamic voltage monitoring support

From: Benjamin Bara
Date: Sun May 21 2023 - 07:47:40 EST


Hi!

This series targets the "automatic" state handling of monitors when the
state of the monitored regulator is changed. This is e.g. necessary for
the da9063, which reaches an invalid state (!PWR_OK) if the voltage
monitor is not disabled before the regulator is disabled. The problem
could also be tackled inside of the driver's "state change ops"
(.enable(), .disable(), ...) but I thought it might be a good idea to
have a "common framework" independent of the driver's implementation.
The new approach takes Matti's feedback regarding the bd718x7 into
account.

1/5 factors out the current monitor handling, to be able to re-use it
during the state changes.
2/5 disables monitoring of disabled regulators, also something mentioned
by Matti as a "requirement" of the bd718x7 driver.
3/5 adds a new op to get the active monitors/protections of a regulator,
which should help users to add enabled protections to their device-tree.
4/5 adds new properties to let the core know on which state changes the
monitors of a regulator need to be en-/disabled.
5/5 is an example how the bd718x7 could be converted to use the new
property (untested, as no hw available).

Thanks & best regards,
Benjamin

---
Changes in v3:
- rebase to v6.4-rc2, to get voltage monitoring of da9063
- re-use the existing monitor handling
- set initial monitoring state to regulator state
- disable monitoring before disabling regulators (if protection is
activated in dt)
- add new op to get the active protections of a regulator
- distinguish between switching to higher or lower voltage
- re-activate old monitoring state if regulator's state change fails
- convert bd718x7 monitor handling to use the state change property

Link to v2: https://lore.kernel.org/r/20230419-dynamic-vmon-v2-0-c303bcc75ebc@xxxxxxxxxxx

Changes in v2:
1/2:
- move from board-specific (machine.h) to driver-specific (driver.h)
- move from own struct to fields/properties in regulator_desc
- handle modes as one "unsupported modes" field
- factor out new monitors_set_state() to handle all (activated) monitors
- move re-enabling of monitor after ramp-delay
- add TODOs for error handling when the action fails (return error from
actual action instead, return state of monitoring to pre-action).
- reword commit message
2/2:
- adapting change to the properties approach

Link to v1: https://lore.kernel.org/r/20230419-dynamic-vmon-v1-0-f48b7438e891@xxxxxxxxxxx

---
Benjamin Bara (5):
regulator: move monitor handling into own function
regulator: disable monitors when regulator is disabled
regulator: add getter for active monitors
regulator: add properties to handle monitoring on state change
regulator: bd718x7: let the core handle the monitors

drivers/regulator/bd718x7-regulator.c | 206 ++++++++++---------------------
drivers/regulator/core.c | 224 ++++++++++++++++++++++++++--------
include/linux/regulator/driver.h | 22 ++++
3 files changed, 262 insertions(+), 190 deletions(-)
---
base-commit: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
change-id: 20230419-dynamic-vmon-e08daa0ac7ad

Best regards,
--
Benjamin Bara <benjamin.bara@xxxxxxxxxxx>