aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-08-27 19:04:23 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-09 23:25:10 -0400
commitdf36793115b4f68181877a1c89bac54feadd965d (patch)
tree2edb5c9d4ad8c6d1e0bc5d2b187c9248c313e6f0 /drivers
parentf59c8f9fe689790248ae7aa7426579982050638c (diff)
regulator: core: Provide regmap get/set bypass operations
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/core.c41
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:
2699EXPORT_SYMBOL_GPL(regulator_set_optimum_mode); 2699EXPORT_SYMBOL_GPL(regulator_set_optimum_mode);
2700 2700
2701/** 2701/**
2702 * regulator_set_bypass_regmap - Default set_bypass() using regmap
2703 *
2704 * @rdev: device to operate on.
2705 * @enable: state to set.
2706 */
2707int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable)
2708{
2709 unsigned int val;
2710
2711 if (enable)
2712 val = rdev->desc->bypass_mask;
2713 else
2714 val = 0;
2715
2716 return regmap_update_bits(rdev->regmap, rdev->desc->bypass_reg,
2717 rdev->desc->bypass_mask, val);
2718}
2719EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap);
2720
2721/**
2722 * regulator_get_bypass_regmap - Default get_bypass() using regmap
2723 *
2724 * @rdev: device to operate on.
2725 * @enable: current state.
2726 */
2727int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable)
2728{
2729 unsigned int val;
2730 int ret;
2731
2732 ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val);
2733 if (ret != 0)
2734 return ret;
2735
2736 *enable = val & rdev->desc->bypass_mask;
2737
2738 return 0;
2739}
2740EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap);
2741
2742/**
2702 * regulator_allow_bypass - allow the regulator to go into bypass mode 2743 * regulator_allow_bypass - allow the regulator to go into bypass mode
2703 * 2744 *
2704 * @regulator: Regulator to configure 2745 * @regulator: Regulator to configure