diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-27 16:04:23 -0700 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-10 11:25:10 +0800 |
commit | df36793115b4f68181877a1c89bac54feadd965d (patch) | |
tree | 2edb5c9d4ad8c6d1e0bc5d2b187c9248c313e6f0 /drivers/regulator | |
parent | f59c8f9fe689790248ae7aa7426579982050638c (diff) |
regulator: core: Provide regmap get/set bypass operations
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 64e16053975e..419805cdd9d7 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2699,6 +2699,47 @@ out: EXPORT_SYMBOL_GPL(regulator_set_optimum_mode); /** + * regulator_set_bypass_regmap - Default set_bypass() using regmap + * + * @rdev: device to operate on. + * @enable: state to set. + */ +int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable) +{ + unsigned int val; + + if (enable) + val = rdev->desc->bypass_mask; + else + val = 0; + + return regmap_update_bits(rdev->regmap, rdev->desc->bypass_reg, + rdev->desc->bypass_mask, val); +} +EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap); + +/** + * regulator_get_bypass_regmap - Default get_bypass() using regmap + * + * @rdev: device to operate on. + * @enable: current state. + */ +int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) +{ + unsigned int val; + int ret; + + ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val); + if (ret != 0) + return ret; + + *enable = val & rdev->desc->bypass_mask; + + return 0; +} +EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap); + +/** * regulator_allow_bypass - allow the regulator to go into bypass mode * * @regulator: Regulator to configure |