regulator: rohm-regulator: add helper for restricted voltage setting
authorMatti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Thu, 18 Nov 2021 11:48:47 +0000 (13:48 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 18 Nov 2021 13:57:47 +0000 (13:57 +0000)
Few ROHM PMICs have regulators where voltage setting can be done only
when regulator is disabled. Add helper for those PMICs.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Link: https://lore.kernel.org/r/6f51871e9fea611d133b5dd2560f4a7ee1ede9cd.1637233864.git.matti.vaittinen@fi.rohmeurope.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/rohm-regulator.c
include/linux/mfd/rohm-generic.h

index 6e0d9c08ec1ca8df7407baef7521237d58040f53..f97a9a51ee7650bddfc16cbd972847244d1d3b91 100644 (file)
@@ -112,6 +112,22 @@ int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
 }
 EXPORT_SYMBOL(rohm_regulator_set_dvs_levels);
 
+/*
+ * Few ROHM PMIC ICs have constrains on voltage changing:
+ * BD71837 - only buck 1-4 voltages can be changed when they are enabled.
+ * Other bucks and all LDOs must be disabled when voltage is changed.
+ * BD96801 - LDO voltage levels can be changed when LDOs are disabled.
+ */
+int rohm_regulator_set_voltage_sel_restricted(struct regulator_dev *rdev,
+                                             unsigned int sel)
+{
+       if (rdev->desc->ops->is_enabled(rdev))
+               return -EBUSY;
+
+       return regulator_set_voltage_sel_regmap(rdev, sel);
+}
+EXPORT_SYMBOL_GPL(rohm_regulator_set_voltage_sel_restricted);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
 MODULE_DESCRIPTION("Generic helpers for ROHM PMIC regulator drivers");
index 35b392a0d73a1482ac8129e1f99fb2718579c96d..35c5866f48b7c179a903b682afd8193399d92b26 100644 (file)
@@ -80,6 +80,8 @@ int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
                                  const struct regulator_desc *desc,
                                  struct regmap *regmap);
 
+int rohm_regulator_set_voltage_sel_restricted(struct regulator_dev *rdev,
+                                             unsigned int sel);
 #else
 static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
                                                struct device_node *np,
@@ -88,6 +90,11 @@ static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dv
 {
        return 0;
 }
+static int rohm_regulator_set_voltage_sel_restricted(struct regulator_dev *rdev,
+                                                    unsigned int sel)
+{
+       return 0;
+}
 #endif
 
 #endif