From: Stephen Warren <[email protected]>

Some regulators need some register bits set or cleared in order to place
them under software control. Add .en_dis_set_mask and .en_dis_clr_mask
fields to struct regulator_desc. These can't be part of the existing
.enable_mask field, whose bits are set when enabled and cleared when
disabled, since the bits in this field need to be set/cleard irrespective
of regulator state.

Signed-off-by: Stephen Warren <[email protected]>
---
v2: New patch

 drivers/regulator/core.c         |   22 +++++++++++++++-------
 include/linux/regulator/driver.h |    4 ++++
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b28221a..457be22 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1762,14 +1762,18 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
  * @rdev: regulator to operate on
  *
  * Regulators that use regmap for their register I/O can set the
- * enable_reg and enable_mask fields in their descriptor and then use
- * this as their enable() operation, saving some code.
+ * enable_reg, enable_mask, en_dis_set_mask, and en_dis_clr_mask fields in
+ * their descriptor and then use this as their enable() operation, saving
+ * some code.
  */
 int regulator_enable_regmap(struct regulator_dev *rdev)
 {
        return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
-                                 rdev->desc->enable_mask,
-                                 rdev->desc->enable_mask);
+                                 rdev->desc->enable_mask |
+                                 rdev->desc->en_dis_set_mask |
+                                 rdev->desc->en_dis_clr_mask,
+                                 rdev->desc->enable_mask |
+                                 rdev->desc->en_dis_set_mask);
 }
 EXPORT_SYMBOL_GPL(regulator_enable_regmap);
 
@@ -1779,13 +1783,17 @@ EXPORT_SYMBOL_GPL(regulator_enable_regmap);
  * @rdev: regulator to operate on
  *
  * Regulators that use regmap for their register I/O can set the
- * enable_reg and enable_mask fields in their descriptor and then use
- * this as their disable() operation, saving some code.
+ * enable_reg, enable_mask, en_dis_set_mask, and en_dis_clr_mask fields in
+ * their descriptor and then use this as their disable() operation, saving
+ * some code.
  */
 int regulator_disable_regmap(struct regulator_dev *rdev)
 {
        return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
-                                 rdev->desc->enable_mask, 0);
+                                 rdev->desc->enable_mask |
+                                 rdev->desc->en_dis_set_mask |
+                                 rdev->desc->en_dis_clr_mask,
+                                 rdev->desc->en_dis_set_mask);
 }
 EXPORT_SYMBOL_GPL(regulator_disable_regmap);
 
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index bac4c87..2c40c86 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -182,6 +182,8 @@ enum regulator_type {
  * @vsel_mask: Mask for register bitfield used for selector
  * @enable_reg: Register for control when using regmap enable/disable ops
  * @enable_mask: Mask for control when using regmap enable/disable ops
+ * @en_dis_set_mask: Mask to always set when using regmap enable/disable ops
+ * @en_dis_clr_mask: Mask to always clear when using regmap enable/disable ops
  *
  * @enable_time: Time taken for initial enable of regulator (in uS).
  */
@@ -205,6 +207,8 @@ struct regulator_desc {
        unsigned int vsel_mask;
        unsigned int enable_reg;
        unsigned int enable_mask;
+       unsigned int en_dis_set_mask;
+       unsigned int en_dis_clr_mask;
 
        unsigned int enable_time;
 };
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to