diff options
author | Lukasz Majewski <l.majewski@samsung.com> | 2010-09-27 08:32:23 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-10-28 18:30:06 -0400 |
commit | 9d92492fb753f01caa31dc502f69c189c0c22ad0 (patch) | |
tree | 1bdc879e0f447bc59228da104b60a299480a21cd /drivers/regulator | |
parent | 8e52e279b241d3a22d52c10a5f934db18b7d0a1b (diff) |
regulator: Separate set_voltage for max8998 ldo and buck
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/max8998.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 7f5fe6f198cf..1e5bd504fbad 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -297,7 +297,44 @@ static int max8998_get_voltage(struct regulator_dev *rdev) | |||
297 | return max8998_list_voltage(rdev, val); | 297 | return max8998_list_voltage(rdev, val); |
298 | } | 298 | } |
299 | 299 | ||
300 | static int max8998_set_voltage(struct regulator_dev *rdev, | 300 | static int max8998_set_voltage_ldo(struct regulator_dev *rdev, |
301 | int min_uV, int max_uV) | ||
302 | { | ||
303 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | ||
304 | struct i2c_client *i2c = max8998->iodev->i2c; | ||
305 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; | ||
306 | const struct voltage_map_desc *desc; | ||
307 | int ldo = max8998_get_ldo(rdev); | ||
308 | int reg, shift = 0, mask, ret; | ||
309 | int i = 0; | ||
310 | |||
311 | if (ldo >= ARRAY_SIZE(ldo_voltage_map)) | ||
312 | return -EINVAL; | ||
313 | |||
314 | desc = ldo_voltage_map[ldo]; | ||
315 | if (desc == NULL) | ||
316 | return -EINVAL; | ||
317 | |||
318 | if (max_vol < desc->min || min_vol > desc->max) | ||
319 | return -EINVAL; | ||
320 | |||
321 | while (desc->min + desc->step*i < min_vol && | ||
322 | desc->min + desc->step*i < desc->max) | ||
323 | i++; | ||
324 | |||
325 | if (desc->min + desc->step*i > max_vol) | ||
326 | return -EINVAL; | ||
327 | |||
328 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); | ||
329 | if (ret) | ||
330 | return ret; | ||
331 | |||
332 | ret = max8998_update_reg(i2c, reg, i<<shift, mask<<shift); | ||
333 | |||
334 | return ret; | ||
335 | } | ||
336 | |||
337 | static int max8998_set_voltage_buck(struct regulator_dev *rdev, | ||
301 | int min_uV, int max_uV) | 338 | int min_uV, int max_uV) |
302 | { | 339 | { |
303 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 340 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
@@ -359,7 +396,7 @@ static struct regulator_ops max8998_ldo_ops = { | |||
359 | .enable = max8998_ldo_enable, | 396 | .enable = max8998_ldo_enable, |
360 | .disable = max8998_ldo_disable, | 397 | .disable = max8998_ldo_disable, |
361 | .get_voltage = max8998_get_voltage, | 398 | .get_voltage = max8998_get_voltage, |
362 | .set_voltage = max8998_set_voltage, | 399 | .set_voltage = max8998_set_voltage_ldo, |
363 | .set_suspend_enable = max8998_ldo_enable, | 400 | .set_suspend_enable = max8998_ldo_enable, |
364 | .set_suspend_disable = max8998_ldo_disable, | 401 | .set_suspend_disable = max8998_ldo_disable, |
365 | }; | 402 | }; |
@@ -370,7 +407,7 @@ static struct regulator_ops max8998_buck_ops = { | |||
370 | .enable = max8998_ldo_enable, | 407 | .enable = max8998_ldo_enable, |
371 | .disable = max8998_ldo_disable, | 408 | .disable = max8998_ldo_disable, |
372 | .get_voltage = max8998_get_voltage, | 409 | .get_voltage = max8998_get_voltage, |
373 | .set_voltage = max8998_set_voltage, | 410 | .set_voltage = max8998_set_voltage_buck, |
374 | .set_suspend_enable = max8998_ldo_enable, | 411 | .set_suspend_enable = max8998_ldo_enable, |
375 | .set_suspend_disable = max8998_ldo_disable, | 412 | .set_suspend_disable = max8998_ldo_disable, |
376 | }; | 413 | }; |