Skip to content

Commit 8b6e885

Browse files
M-Vaittinenbroonie
authored andcommitted
regulator: rohm-regulator: add helper for restricted voltage setting
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 <[email protected]> Link: https://lore.kernel.org/r/6f51871e9fea611d133b5dd2560f4a7ee1ede9cd.1637233864.git.matti.vaittinen@fi.rohmeurope.com Signed-off-by: Mark Brown <[email protected]>
1 parent 4950486 commit 8b6e885

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

drivers/regulator/rohm-regulator.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
112112
}
113113
EXPORT_SYMBOL(rohm_regulator_set_dvs_levels);
114114

115+
/*
116+
* Few ROHM PMIC ICs have constrains on voltage changing:
117+
* BD71837 - only buck 1-4 voltages can be changed when they are enabled.
118+
* Other bucks and all LDOs must be disabled when voltage is changed.
119+
* BD96801 - LDO voltage levels can be changed when LDOs are disabled.
120+
*/
121+
int rohm_regulator_set_voltage_sel_restricted(struct regulator_dev *rdev,
122+
unsigned int sel)
123+
{
124+
if (rdev->desc->ops->is_enabled(rdev))
125+
return -EBUSY;
126+
127+
return regulator_set_voltage_sel_regmap(rdev, sel);
128+
}
129+
EXPORT_SYMBOL_GPL(rohm_regulator_set_voltage_sel_restricted);
130+
115131
MODULE_LICENSE("GPL v2");
116132
MODULE_AUTHOR("Matti Vaittinen <[email protected]>");
117133
MODULE_DESCRIPTION("Generic helpers for ROHM PMIC regulator drivers");

include/linux/mfd/rohm-generic.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
8080
const struct regulator_desc *desc,
8181
struct regmap *regmap);
8282

83+
int rohm_regulator_set_voltage_sel_restricted(struct regulator_dev *rdev,
84+
unsigned int sel);
8385
#else
8486
static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
8587
struct device_node *np,
@@ -88,6 +90,11 @@ static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dv
8890
{
8991
return 0;
9092
}
93+
static int rohm_regulator_set_voltage_sel_restricted(struct regulator_dev *rdev,
94+
unsigned int sel)
95+
{
96+
return 0;
97+
}
9198
#endif
9299

93100
#endif

0 commit comments

Comments
 (0)