diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-16 23:32:57 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-23 08:19:50 -0400 |
commit | ef26e0dbe8bebd8dc559d39ed804720002225fc3 (patch) | |
tree | 4818250c2c6535783bc889db26708da953549678 /drivers/regulator/88pm8607.c | |
parent | 11bb88ec221b70374c48c034bc147af20e40ba15 (diff) |
regulator: 88pm8607: Use generic regmap enable/disable operations
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 | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index d04fbe953dd8..ad748db22890 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -31,8 +31,6 @@ struct pm8607_regulator_info { | |||
31 | int vol_shift; | 31 | int vol_shift; |
32 | int update_reg; | 32 | int update_reg; |
33 | int update_bit; | 33 | int update_bit; |
34 | int enable_reg; | ||
35 | int enable_bit; | ||
36 | int slope_double; | 34 | int slope_double; |
37 | }; | 35 | }; |
38 | 36 | ||
@@ -262,42 +260,13 @@ static int pm8607_get_voltage_sel(struct regulator_dev *rdev) | |||
262 | return val; | 260 | return val; |
263 | } | 261 | } |
264 | 262 | ||
265 | static int pm8607_enable(struct regulator_dev *rdev) | ||
266 | { | ||
267 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | ||
268 | |||
269 | return pm860x_set_bits(info->i2c, info->enable_reg, | ||
270 | 1 << info->enable_bit, | ||
271 | 1 << info->enable_bit); | ||
272 | } | ||
273 | |||
274 | static int pm8607_disable(struct regulator_dev *rdev) | ||
275 | { | ||
276 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | ||
277 | |||
278 | return pm860x_set_bits(info->i2c, info->enable_reg, | ||
279 | 1 << info->enable_bit, 0); | ||
280 | } | ||
281 | |||
282 | static int pm8607_is_enabled(struct regulator_dev *rdev) | ||
283 | { | ||
284 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | ||
285 | int ret; | ||
286 | |||
287 | ret = pm860x_reg_read(info->i2c, info->enable_reg); | ||
288 | if (ret < 0) | ||
289 | return ret; | ||
290 | |||
291 | return !!((unsigned char)ret & (1 << info->enable_bit)); | ||
292 | } | ||
293 | |||
294 | static struct regulator_ops pm8607_regulator_ops = { | 263 | static struct regulator_ops pm8607_regulator_ops = { |
295 | .list_voltage = pm8607_list_voltage, | 264 | .list_voltage = pm8607_list_voltage, |
296 | .set_voltage_sel = pm8607_set_voltage_sel, | 265 | .set_voltage_sel = pm8607_set_voltage_sel, |
297 | .get_voltage_sel = pm8607_get_voltage_sel, | 266 | .get_voltage_sel = pm8607_get_voltage_sel, |
298 | .enable = pm8607_enable, | 267 | .enable = regulator_enable_regmap, |
299 | .disable = pm8607_disable, | 268 | .disable = regulator_disable_regmap, |
300 | .is_enabled = pm8607_is_enabled, | 269 | .is_enabled = regulator_is_enabled_regmap, |
301 | }; | 270 | }; |
302 | 271 | ||
303 | #define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \ | 272 | #define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \ |
@@ -309,13 +278,13 @@ static struct regulator_ops pm8607_regulator_ops = { | |||
309 | .id = PM8607_ID_##vreg, \ | 278 | .id = PM8607_ID_##vreg, \ |
310 | .owner = THIS_MODULE, \ | 279 | .owner = THIS_MODULE, \ |
311 | .n_voltages = ARRAY_SIZE(vreg##_table), \ | 280 | .n_voltages = ARRAY_SIZE(vreg##_table), \ |
281 | .enable_reg = PM8607_##ereg, \ | ||
282 | .enable_mask = 1 << (ebit), \ | ||
312 | }, \ | 283 | }, \ |
313 | .vol_reg = PM8607_##vreg, \ | 284 | .vol_reg = PM8607_##vreg, \ |
314 | .vol_shift = (0), \ | 285 | .vol_shift = (0), \ |
315 | .update_reg = PM8607_##ureg, \ | 286 | .update_reg = PM8607_##ureg, \ |
316 | .update_bit = (ubit), \ | 287 | .update_bit = (ubit), \ |
317 | .enable_reg = PM8607_##ereg, \ | ||
318 | .enable_bit = (ebit), \ | ||
319 | .slope_double = (0), \ | 288 | .slope_double = (0), \ |
320 | .vol_table = (unsigned int *)&vreg##_table, \ | 289 | .vol_table = (unsigned int *)&vreg##_table, \ |
321 | .vol_suspend = (unsigned int *)&vreg##_suspend_table, \ | 290 | .vol_suspend = (unsigned int *)&vreg##_suspend_table, \ |
@@ -330,11 +299,11 @@ static struct regulator_ops pm8607_regulator_ops = { | |||
330 | .id = PM8607_ID_LDO##_id, \ | 299 | .id = PM8607_ID_LDO##_id, \ |
331 | .owner = THIS_MODULE, \ | 300 | .owner = THIS_MODULE, \ |
332 | .n_voltages = ARRAY_SIZE(LDO##_id##_table), \ | 301 | .n_voltages = ARRAY_SIZE(LDO##_id##_table), \ |
302 | .enable_reg = PM8607_##ereg, \ | ||
303 | .enable_mask = 1 << (ebit), \ | ||
333 | }, \ | 304 | }, \ |
334 | .vol_reg = PM8607_##vreg, \ | 305 | .vol_reg = PM8607_##vreg, \ |
335 | .vol_shift = (shift), \ | 306 | .vol_shift = (shift), \ |
336 | .enable_reg = PM8607_##ereg, \ | ||
337 | .enable_bit = (ebit), \ | ||
338 | .slope_double = (0), \ | 307 | .slope_double = (0), \ |
339 | .vol_table = (unsigned int *)&LDO##_id##_table, \ | 308 | .vol_table = (unsigned int *)&LDO##_id##_table, \ |
340 | .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \ | 309 | .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \ |
@@ -395,6 +364,11 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev) | |||
395 | config.init_data = pdata; | 364 | config.init_data = pdata; |
396 | config.driver_data = info; | 365 | config.driver_data = info; |
397 | 366 | ||
367 | if (chip->id == CHIP_PM8607) | ||
368 | config.regmap = chip->regmap; | ||
369 | else | ||
370 | config.regmap = chip->regmap_companion; | ||
371 | |||
398 | /* replace driver_data with info */ | 372 | /* replace driver_data with info */ |
399 | info->regulator = regulator_register(&info->desc, &config); | 373 | info->regulator = regulator_register(&info->desc, &config); |
400 | if (IS_ERR(info->regulator)) { | 374 | if (IS_ERR(info->regulator)) { |