diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2016-03-02 11:54:47 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-02 15:13:05 +0100 |
commit | 354794dacc213da7596cefea4dbcd8c094368807 (patch) | |
tree | 51a080d54afeba7ba26d46fd9b00e4e14beae6a5 /drivers/regulator | |
parent | regulator: core: Add support for active-discharge configuration (diff) | |
download | linux-354794dacc213da7596cefea4dbcd8c094368807.tar.xz linux-354794dacc213da7596cefea4dbcd8c094368807.zip |
regulator: helper: Add helper to configure active-discharge using regmap
Add helper function to set the state of active-discharge of
regulator using regmap. The HW regulator driver can directly
use this by providing the necessary information in the regulator
descriptor.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/helpers.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index 3bbb32680a94..b1e32e7482e9 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -465,3 +465,26 @@ int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) return 0; } EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap); + +/** + * regulator_set_active_discharge_regmap - Default set_active_discharge() + * using regmap + * + * @rdev: device to operate on. + * @enable: state to set, 0 to disable and 1 to enable. + */ +int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, + bool enable) +{ + unsigned int val; + + if (enable) + val = rdev->desc->active_discharge_on; + else + val = rdev->desc->active_discharge_off; + + return regmap_update_bits(rdev->regmap, + rdev->desc->active_discharge_reg, + rdev->desc->active_discharge_mask, val); +} +EXPORT_SYMBOL_GPL(regulator_set_active_discharge_regmap); |