diff options
author | Biju Das <biju.das.jz@bp.renesas.com> | 2024-06-16 11:53:55 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-06-26 18:17:05 +0100 |
commit | 1cb7d29157603561af4c38535e936850ceb99f0f (patch) | |
tree | 32f6a232bd55180c80c317636403549141e2c2c4 /drivers/regulator | |
parent | f2661062f16b2de5d7b6a5c42a9a5c96326b8454 (diff) | |
download | linux-1cb7d29157603561af4c38535e936850ceb99f0f.tar.gz linux-1cb7d29157603561af4c38535e936850ceb99f0f.tar.bz2 linux-1cb7d29157603561af4c38535e936850ceb99f0f.zip |
regulator: core: Add helper for allow HW access to enable/disable regulator
Add a helper function that allow regulator consumers to allow low-level
HW access, in order to enable/disable regulator in atomic context.
The use-case for RZ/G2L SoC is to enable VBUS selection register based
on vbus detection that happens in interrupt context.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://patch.msgid.link/20240616105402.45211-4-biju.das.jz@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 844e9587a880..7674b7f2df14 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3409,6 +3409,34 @@ int regulator_list_hardware_vsel(struct regulator *regulator, EXPORT_SYMBOL_GPL(regulator_list_hardware_vsel); /** + * regulator_hardware_enable - access the HW for enable/disable regulator + * @regulator: regulator source + * @enable: true for enable, false for disable + * + * Request that the regulator be enabled/disabled with the regulator output at + * the predefined voltage or current value. + * + * On success 0 is returned, otherwise a negative errno is returned. + */ +int regulator_hardware_enable(struct regulator *regulator, bool enable) +{ + struct regulator_dev *rdev = regulator->rdev; + const struct regulator_ops *ops = rdev->desc->ops; + int ret = -EOPNOTSUPP; + + if (!rdev->exclusive || !ops || !ops->enable || !ops->disable) + return ret; + + if (enable) + ret = ops->enable(rdev); + else + ret = ops->disable(rdev); + + return ret; +} +EXPORT_SYMBOL_GPL(regulator_hardware_enable); + +/** * regulator_get_linear_step - return the voltage step size between VSEL values * @regulator: regulator source * |