aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-24 06:11:33 -0400
committerMark Brown <broonie@linaro.org>2013-10-24 06:11:33 -0400
commit2a86e8e753766f2b3e615c0a885e72293b6fca84 (patch)
tree2176339a4f381101a15eba61c2e83c455faca999
parent81e439f476a397af695e8141df6e7324a8ac4893 (diff)
parentd706b1e4930fec12cc3b8d6e0e28d9e8321abcea (diff)
Merge remote-tracking branch 'regulator/topic/da9052' into regulator-next
-rw-r--r--drivers/regulator/da9052-regulator.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index c427e42472e8..3adeaeffc485 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -70,6 +70,7 @@ struct da9052_regulator_info {
70 int step_uV; 70 int step_uV;
71 int min_uV; 71 int min_uV;
72 int max_uV; 72 int max_uV;
73 unsigned char activate_bit;
73}; 74};
74 75
75struct da9052_regulator { 76struct da9052_regulator {
@@ -209,6 +210,36 @@ static int da9052_map_voltage(struct regulator_dev *rdev,
209 return sel; 210 return sel;
210} 211}
211 212
213static int da9052_regulator_set_voltage_sel(struct regulator_dev *rdev,
214 unsigned int selector)
215{
216 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
217 struct da9052_regulator_info *info = regulator->info;
218 int id = rdev_get_id(rdev);
219 int ret;
220
221 ret = da9052_reg_update(regulator->da9052, rdev->desc->vsel_reg,
222 rdev->desc->vsel_mask, selector);
223 if (ret < 0)
224 return ret;
225
226 /* Some LDOs and DCDCs are DVC controlled which requires enabling of
227 * the activate bit to implment the changes on the output.
228 */
229 switch (id) {
230 case DA9052_ID_BUCK1:
231 case DA9052_ID_BUCK2:
232 case DA9052_ID_BUCK3:
233 case DA9052_ID_LDO2:
234 case DA9052_ID_LDO3:
235 ret = da9052_reg_update(regulator->da9052, DA9052_SUPPLY_REG,
236 info->activate_bit, info->activate_bit);
237 break;
238 }
239
240 return ret;
241}
242
212static struct regulator_ops da9052_dcdc_ops = { 243static struct regulator_ops da9052_dcdc_ops = {
213 .get_current_limit = da9052_dcdc_get_current_limit, 244 .get_current_limit = da9052_dcdc_get_current_limit,
214 .set_current_limit = da9052_dcdc_set_current_limit, 245 .set_current_limit = da9052_dcdc_set_current_limit,
@@ -216,7 +247,7 @@ static struct regulator_ops da9052_dcdc_ops = {
216 .list_voltage = da9052_list_voltage, 247 .list_voltage = da9052_list_voltage,
217 .map_voltage = da9052_map_voltage, 248 .map_voltage = da9052_map_voltage,
218 .get_voltage_sel = regulator_get_voltage_sel_regmap, 249 .get_voltage_sel = regulator_get_voltage_sel_regmap,
219 .set_voltage_sel = regulator_set_voltage_sel_regmap, 250 .set_voltage_sel = da9052_regulator_set_voltage_sel,
220 .is_enabled = regulator_is_enabled_regmap, 251 .is_enabled = regulator_is_enabled_regmap,
221 .enable = regulator_enable_regmap, 252 .enable = regulator_enable_regmap,
222 .disable = regulator_disable_regmap, 253 .disable = regulator_disable_regmap,
@@ -226,7 +257,7 @@ static struct regulator_ops da9052_ldo_ops = {
226 .list_voltage = da9052_list_voltage, 257 .list_voltage = da9052_list_voltage,
227 .map_voltage = da9052_map_voltage, 258 .map_voltage = da9052_map_voltage,
228 .get_voltage_sel = regulator_get_voltage_sel_regmap, 259 .get_voltage_sel = regulator_get_voltage_sel_regmap,
229 .set_voltage_sel = regulator_set_voltage_sel_regmap, 260 .set_voltage_sel = da9052_regulator_set_voltage_sel,
230 .is_enabled = regulator_is_enabled_regmap, 261 .is_enabled = regulator_is_enabled_regmap,
231 .enable = regulator_enable_regmap, 262 .enable = regulator_enable_regmap,
232 .disable = regulator_disable_regmap, 263 .disable = regulator_disable_regmap,
@@ -243,14 +274,13 @@ static struct regulator_ops da9052_ldo_ops = {
243 .owner = THIS_MODULE,\ 274 .owner = THIS_MODULE,\
244 .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ 275 .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
245 .vsel_mask = (1 << (sbits)) - 1,\ 276 .vsel_mask = (1 << (sbits)) - 1,\
246 .apply_reg = DA9052_SUPPLY_REG, \
247 .apply_bit = (abits), \
248 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ 277 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
249 .enable_mask = 1 << (ebits),\ 278 .enable_mask = 1 << (ebits),\
250 },\ 279 },\
251 .min_uV = (min) * 1000,\ 280 .min_uV = (min) * 1000,\
252 .max_uV = (max) * 1000,\ 281 .max_uV = (max) * 1000,\
253 .step_uV = (step) * 1000,\ 282 .step_uV = (step) * 1000,\
283 .activate_bit = (abits),\
254} 284}
255 285
256#define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \ 286#define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \
@@ -264,14 +294,13 @@ static struct regulator_ops da9052_ldo_ops = {
264 .owner = THIS_MODULE,\ 294 .owner = THIS_MODULE,\
265 .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ 295 .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
266 .vsel_mask = (1 << (sbits)) - 1,\ 296 .vsel_mask = (1 << (sbits)) - 1,\
267 .apply_reg = DA9052_SUPPLY_REG, \
268 .apply_bit = (abits), \
269 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ 297 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
270 .enable_mask = 1 << (ebits),\ 298 .enable_mask = 1 << (ebits),\
271 },\ 299 },\
272 .min_uV = (min) * 1000,\ 300 .min_uV = (min) * 1000,\
273 .max_uV = (max) * 1000,\ 301 .max_uV = (max) * 1000,\
274 .step_uV = (step) * 1000,\ 302 .step_uV = (step) * 1000,\
303 .activate_bit = (abits),\
275} 304}
276 305
277static struct da9052_regulator_info da9052_regulator_info[] = { 306static struct da9052_regulator_info da9052_regulator_info[] = {