diff options
| author | Jonas Karlman <[email protected]> | 2026-07-09 23:02:39 +0000 |
|---|---|---|
| committer | Peng Fan <[email protected]> | 2026-07-12 16:18:32 +0800 |
| commit | 0663b4f553789f8d38220a543116563885693120 (patch) | |
| tree | 1489ab9e163db08b39b80e8d6cd9cb3acd724db0 /include | |
| parent | 5badf4e82a529e0212479c1b0f8fd695d0be95be (diff) | |
power: regulator: Add helper to set voltage within an acceptable range
Add regulator_set_value_clamp() that clamps a requested target voltage
to both caller-provided limits and the regulator constraints before
setting the regulator voltage value.
Return -EINVAL when the caller limits cannot be satisfied by the
regulator constraints or when the requested range is invalid.
This helper will initially be used to set vqmmc-supply voltage within an
acceptable range according to SD Standards, i.e. 1.70V-1.95V and
2.7V-3.6V.
Signed-off-by: Jonas Karlman <[email protected]>
Signed-off-by: Peng Fan <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/power/regulator.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/power/regulator.h b/include/power/regulator.h index 4011fb1d254..b8023721a16 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -316,6 +316,18 @@ int regulator_set_suspend_value(struct udevice *dev, int uV); int regulator_get_suspend_value(struct udevice *dev); /** + * regulator_set_value_clamp: set clamped microvoltage value of a given regulator + * + * @dev - pointer to the regulator device + * @min_uV - the minimum output value to set [micro Volts] + * @target_uV - the target output value to set [micro Volts] + * @max_uV - the maximum output value to set [micro Volts] + * Return: - 0 on success or -errno val if fails + */ +int regulator_set_value_clamp(struct udevice *dev, + int min_uV, int target_uV, int max_uV); + +/** * regulator_set_value_force: set the microvoltage value of a given regulator * without any min-,max condition check * @@ -550,6 +562,12 @@ static inline int regulator_get_suspend_value(struct udevice *dev) return -ENOSYS; } +static inline int regulator_set_value_clamp(struct udevice *dev, + int min_uV, int target_uV, int max_uV) +{ + return -ENOSYS; +} + static inline int regulator_set_value_force(struct udevice *dev, int uV) { return -ENOSYS; |
