diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-23 21:52:32 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-04 08:32:06 -0400 |
commit | c006b21f7fec8d5fe256011f29f14065cf26aefc (patch) | |
tree | 7d678c3e37cf45f750fb878ca8716d648adce0b4 /drivers/regulator/88pm8607.c | |
parent | 15b397d7e7e72d9b37a29758711afec5e774381a (diff) |
regulator: 88pm8607: Use regulator_get_voltage_sel_regmap()
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/88pm8607.c')
-rw-r--r-- | drivers/regulator/88pm8607.c | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index ad748db22890..c3482b954cb7 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -27,8 +27,6 @@ struct pm8607_regulator_info { | |||
27 | unsigned int *vol_table; | 27 | unsigned int *vol_table; |
28 | unsigned int *vol_suspend; | 28 | unsigned int *vol_suspend; |
29 | 29 | ||
30 | int vol_reg; | ||
31 | int vol_shift; | ||
32 | int update_reg; | 30 | int update_reg; |
33 | int update_bit; | 31 | int update_bit; |
34 | int slope_double; | 32 | int slope_double; |
@@ -224,13 +222,13 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
224 | static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) | 222 | static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) |
225 | { | 223 | { |
226 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | 224 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); |
227 | uint8_t val, mask; | 225 | uint8_t val; |
228 | int ret; | 226 | int ret; |
229 | 227 | ||
230 | val = (uint8_t)(selector << info->vol_shift); | 228 | val = (uint8_t)(selector << (ffs(rdev->desc->vsel_mask) - 1)); |
231 | mask = (rdev->desc->n_voltages - 1) << info->vol_shift; | ||
232 | 229 | ||
233 | ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, selector); | 230 | ret = pm860x_set_bits(info->i2c, rdev->desc->vsel_reg, |
231 | rdev->desc->vsel_mask, val); | ||
234 | if (ret) | 232 | if (ret) |
235 | return ret; | 233 | return ret; |
236 | switch (info->desc.id) { | 234 | switch (info->desc.id) { |
@@ -244,26 +242,10 @@ static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) | |||
244 | return ret; | 242 | return ret; |
245 | } | 243 | } |
246 | 244 | ||
247 | static int pm8607_get_voltage_sel(struct regulator_dev *rdev) | ||
248 | { | ||
249 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | ||
250 | uint8_t val, mask; | ||
251 | int ret; | ||
252 | |||
253 | ret = pm860x_reg_read(info->i2c, info->vol_reg); | ||
254 | if (ret < 0) | ||
255 | return ret; | ||
256 | |||
257 | mask = (rdev->desc->n_voltages - 1) << info->vol_shift; | ||
258 | val = ((unsigned char)ret & mask) >> info->vol_shift; | ||
259 | |||
260 | return val; | ||
261 | } | ||
262 | |||
263 | static struct regulator_ops pm8607_regulator_ops = { | 245 | static struct regulator_ops pm8607_regulator_ops = { |
264 | .list_voltage = pm8607_list_voltage, | 246 | .list_voltage = pm8607_list_voltage, |
265 | .set_voltage_sel = pm8607_set_voltage_sel, | 247 | .set_voltage_sel = pm8607_set_voltage_sel, |
266 | .get_voltage_sel = pm8607_get_voltage_sel, | 248 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
267 | .enable = regulator_enable_regmap, | 249 | .enable = regulator_enable_regmap, |
268 | .disable = regulator_disable_regmap, | 250 | .disable = regulator_disable_regmap, |
269 | .is_enabled = regulator_is_enabled_regmap, | 251 | .is_enabled = regulator_is_enabled_regmap, |
@@ -278,11 +260,11 @@ static struct regulator_ops pm8607_regulator_ops = { | |||
278 | .id = PM8607_ID_##vreg, \ | 260 | .id = PM8607_ID_##vreg, \ |
279 | .owner = THIS_MODULE, \ | 261 | .owner = THIS_MODULE, \ |
280 | .n_voltages = ARRAY_SIZE(vreg##_table), \ | 262 | .n_voltages = ARRAY_SIZE(vreg##_table), \ |
263 | .vsel_reg = PM8607_##vreg, \ | ||
264 | .vsel_mask = ARRAY_SIZE(vreg##_table) - 1, \ | ||
281 | .enable_reg = PM8607_##ereg, \ | 265 | .enable_reg = PM8607_##ereg, \ |
282 | .enable_mask = 1 << (ebit), \ | 266 | .enable_mask = 1 << (ebit), \ |
283 | }, \ | 267 | }, \ |
284 | .vol_reg = PM8607_##vreg, \ | ||
285 | .vol_shift = (0), \ | ||
286 | .update_reg = PM8607_##ureg, \ | 268 | .update_reg = PM8607_##ureg, \ |
287 | .update_bit = (ubit), \ | 269 | .update_bit = (ubit), \ |
288 | .slope_double = (0), \ | 270 | .slope_double = (0), \ |
@@ -299,11 +281,11 @@ static struct regulator_ops pm8607_regulator_ops = { | |||
299 | .id = PM8607_ID_LDO##_id, \ | 281 | .id = PM8607_ID_LDO##_id, \ |
300 | .owner = THIS_MODULE, \ | 282 | .owner = THIS_MODULE, \ |
301 | .n_voltages = ARRAY_SIZE(LDO##_id##_table), \ | 283 | .n_voltages = ARRAY_SIZE(LDO##_id##_table), \ |
284 | .vsel_reg = PM8607_##vreg, \ | ||
285 | .vsel_mask = (ARRAY_SIZE(LDO##_id##_table) - 1) << (shift), \ | ||
302 | .enable_reg = PM8607_##ereg, \ | 286 | .enable_reg = PM8607_##ereg, \ |
303 | .enable_mask = 1 << (ebit), \ | 287 | .enable_mask = 1 << (ebit), \ |
304 | }, \ | 288 | }, \ |
305 | .vol_reg = PM8607_##vreg, \ | ||
306 | .vol_shift = (shift), \ | ||
307 | .slope_double = (0), \ | 289 | .slope_double = (0), \ |
308 | .vol_table = (unsigned int *)&LDO##_id##_table, \ | 290 | .vol_table = (unsigned int *)&LDO##_id##_table, \ |
309 | .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \ | 291 | .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \ |