aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/da9052-regulator.c56
1 files changed, 11 insertions, 45 deletions
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index 2678cbe91d9d..f6eee2924de9 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -70,7 +70,6 @@ struct da9052_regulator_info {
70 int min_uV; 70 int min_uV;
71 int max_uV; 71 int max_uV;
72 unsigned char volt_shift; 72 unsigned char volt_shift;
73 unsigned char en_bit;
74 unsigned char activate_bit; 73 unsigned char activate_bit;
75}; 74};
76 75
@@ -89,42 +88,6 @@ static int verify_range(struct da9052_regulator_info *info,
89 return 0; 88 return 0;
90} 89}
91 90
92static int da9052_regulator_enable(struct regulator_dev *rdev)
93{
94 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
95 struct da9052_regulator_info *info = regulator->info;
96 int offset = rdev_get_id(rdev);
97
98 return da9052_reg_update(regulator->da9052,
99 DA9052_BUCKCORE_REG + offset,
100 1 << info->en_bit, 1 << info->en_bit);
101}
102
103static int da9052_regulator_disable(struct regulator_dev *rdev)
104{
105 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
106 struct da9052_regulator_info *info = regulator->info;
107 int offset = rdev_get_id(rdev);
108
109 return da9052_reg_update(regulator->da9052,
110 DA9052_BUCKCORE_REG + offset,
111 1 << info->en_bit, 0);
112}
113
114static int da9052_regulator_is_enabled(struct regulator_dev *rdev)
115{
116 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
117 struct da9052_regulator_info *info = regulator->info;
118 int offset = rdev_get_id(rdev);
119 int ret;
120
121 ret = da9052_reg_read(regulator->da9052, DA9052_BUCKCORE_REG + offset);
122 if (ret < 0)
123 return ret;
124
125 return ret & (1 << info->en_bit);
126}
127
128static int da9052_dcdc_get_current_limit(struct regulator_dev *rdev) 91static int da9052_dcdc_get_current_limit(struct regulator_dev *rdev)
129{ 92{
130 struct da9052_regulator *regulator = rdev_get_drvdata(rdev); 93 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
@@ -291,9 +254,9 @@ static struct regulator_ops da9052_dcdc_ops = {
291 254
292 .list_voltage = da9052_list_voltage, 255 .list_voltage = da9052_list_voltage,
293 .get_voltage_sel = da9052_get_regulator_voltage_sel, 256 .get_voltage_sel = da9052_get_regulator_voltage_sel,
294 .is_enabled = da9052_regulator_is_enabled, 257 .is_enabled = regulator_is_enabled_regmap,
295 .enable = da9052_regulator_enable, 258 .enable = regulator_enable_regmap,
296 .disable = da9052_regulator_disable, 259 .disable = regulator_disable_regmap,
297}; 260};
298 261
299static struct regulator_ops da9052_ldo_ops = { 262static struct regulator_ops da9052_ldo_ops = {
@@ -301,9 +264,9 @@ static struct regulator_ops da9052_ldo_ops = {
301 264
302 .list_voltage = da9052_list_voltage, 265 .list_voltage = da9052_list_voltage,
303 .get_voltage_sel = da9052_get_regulator_voltage_sel, 266 .get_voltage_sel = da9052_get_regulator_voltage_sel,
304 .is_enabled = da9052_regulator_is_enabled, 267 .is_enabled = regulator_is_enabled_regmap,
305 .enable = da9052_regulator_enable, 268 .enable = regulator_enable_regmap,
306 .disable = da9052_regulator_disable, 269 .disable = regulator_disable_regmap,
307}; 270};
308 271
309#define DA9052_LDO(_id, step, min, max, sbits, ebits, abits) \ 272#define DA9052_LDO(_id, step, min, max, sbits, ebits, abits) \
@@ -315,12 +278,13 @@ static struct regulator_ops da9052_ldo_ops = {
315 .id = DA9052_ID_##_id,\ 278 .id = DA9052_ID_##_id,\
316 .n_voltages = (max - min) / step + 1, \ 279 .n_voltages = (max - min) / step + 1, \
317 .owner = THIS_MODULE,\ 280 .owner = THIS_MODULE,\
281 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
282 .enable_mask = 1 << (ebits),\
318 },\ 283 },\
319 .min_uV = (min) * 1000,\ 284 .min_uV = (min) * 1000,\
320 .max_uV = (max) * 1000,\ 285 .max_uV = (max) * 1000,\
321 .step_uV = (step) * 1000,\ 286 .step_uV = (step) * 1000,\
322 .volt_shift = (sbits),\ 287 .volt_shift = (sbits),\
323 .en_bit = (ebits),\
324 .activate_bit = (abits),\ 288 .activate_bit = (abits),\
325} 289}
326 290
@@ -333,12 +297,13 @@ static struct regulator_ops da9052_ldo_ops = {
333 .id = DA9052_ID_##_id,\ 297 .id = DA9052_ID_##_id,\
334 .n_voltages = (max - min) / step + 1, \ 298 .n_voltages = (max - min) / step + 1, \
335 .owner = THIS_MODULE,\ 299 .owner = THIS_MODULE,\
300 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
301 .enable_mask = 1 << (ebits),\
336 },\ 302 },\
337 .min_uV = (min) * 1000,\ 303 .min_uV = (min) * 1000,\
338 .max_uV = (max) * 1000,\ 304 .max_uV = (max) * 1000,\
339 .step_uV = (step) * 1000,\ 305 .step_uV = (step) * 1000,\
340 .volt_shift = (sbits),\ 306 .volt_shift = (sbits),\
341 .en_bit = (ebits),\
342 .activate_bit = (abits),\ 307 .activate_bit = (abits),\
343} 308}
344 309
@@ -429,6 +394,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
429 394
430 config.dev = &pdev->dev; 395 config.dev = &pdev->dev;
431 config.driver_data = regulator; 396 config.driver_data = regulator;
397 config.regmap = da9052->regmap;
432 if (pdata && pdata->regulators) { 398 if (pdata && pdata->regulators) {
433 config.init_data = pdata->regulators[pdev->id]; 399 config.init_data = pdata->regulators[pdev->id];
434 } else { 400 } else {