]> git.karo-electronics.de Git - linux-beck.git/commitdiff
regulator: core: Provide regmap get/set bypass operations
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 27 Aug 2012 23:04:23 +0000 (16:04 -0700)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 10 Sep 2012 03:25:10 +0000 (11:25 +0800)
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/core.c
include/linux/regulator/driver.h

index 64e16053975e27bded5a5018893f2d8f883b047a..419805cdd9d7abfd291b3cd0f00126af4c03ea6c 100644 (file)
@@ -2698,6 +2698,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
  *
index c9869cfbf2615426f1916968f4205b7c25e39f2c..7274a469e8d902b1b7c8b39980b2d1c3b85858ee 100644 (file)
@@ -214,6 +214,8 @@ struct regulator_desc {
        unsigned int vsel_mask;
        unsigned int enable_reg;
        unsigned int enable_mask;
+       unsigned int bypass_reg;
+       unsigned int bypass_mask;
 
        unsigned int enable_time;
 };
@@ -320,6 +322,8 @@ int regulator_disable_regmap(struct regulator_dev *rdev);
 int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
                                   unsigned int old_selector,
                                   unsigned int new_selector);
+int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable);
+int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable);
 
 void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);