diff options
author | Yadwinder Singh Brar <yadi.brar01@gmail.com> | 2012-06-20 01:20:51 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-20 06:15:13 -0400 |
commit | f503071b03dcac6908fb7e051cfc9c45bea084c0 (patch) | |
tree | f84998c05c4422e63c6dab80726d655ad0fd9ff3 /drivers/regulator/max77686.c | |
parent | c59d2a6b20aef4660a9ed89224bd17eec6a54751 (diff) |
regulator: max77686: Implement .set_ramp_delay() callback
This patch implements the .set_ramp_delay callback to set the ramp_delay on
hardware for BUCK2/3/4 if ramp_delay is set in regulator constraints.
This patch also do some cleaning work for unrequired members of
struct max77686_data.
Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max77686.c')
-rw-r--r-- | drivers/regulator/max77686.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 877d4bff1120..23f956a6c5f2 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c | |||
@@ -65,11 +65,34 @@ enum max77686_ramp_rate { | |||
65 | }; | 65 | }; |
66 | 66 | ||
67 | struct max77686_data { | 67 | struct max77686_data { |
68 | struct device *dev; | ||
69 | struct max77686_dev *iodev; | ||
70 | struct regulator_dev **rdev; | 68 | struct regulator_dev **rdev; |
71 | }; | 69 | }; |
72 | 70 | ||
71 | static int max77686_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) | ||
72 | { | ||
73 | unsigned int ramp_value = RAMP_RATE_NO_CTRL; | ||
74 | |||
75 | switch (ramp_delay) { | ||
76 | case 1 ... 13750: | ||
77 | ramp_value = RAMP_RATE_13P75MV; | ||
78 | break; | ||
79 | case 13751 ... 27500: | ||
80 | ramp_value = RAMP_RATE_27P5MV; | ||
81 | break; | ||
82 | case 27501 ... 55000: | ||
83 | ramp_value = RAMP_RATE_55MV; | ||
84 | break; | ||
85 | case 55001 ... 100000: | ||
86 | break; | ||
87 | default: | ||
88 | pr_warn("%s: ramp_delay: %d not supported, setting 100000\n", | ||
89 | rdev->desc->name, ramp_delay); | ||
90 | } | ||
91 | |||
92 | return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, | ||
93 | MAX77686_RAMP_RATE_MASK, ramp_value << 6); | ||
94 | } | ||
95 | |||
73 | static struct regulator_ops max77686_ops = { | 96 | static struct regulator_ops max77686_ops = { |
74 | .list_voltage = regulator_list_voltage_linear, | 97 | .list_voltage = regulator_list_voltage_linear, |
75 | .map_voltage = regulator_map_voltage_linear, | 98 | .map_voltage = regulator_map_voltage_linear, |
@@ -90,6 +113,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
90 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 113 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
91 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 114 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
92 | .set_voltage_time_sel = regulator_set_voltage_time_sel, | 115 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
116 | .set_ramp_delay = max77686_set_ramp_delay, | ||
93 | }; | 117 | }; |
94 | 118 | ||
95 | #define regulator_desc_ldo(num) { \ | 119 | #define regulator_desc_ldo(num) { \ |
@@ -238,20 +262,17 @@ static __devinit int max77686_pmic_probe(struct platform_device *pdev) | |||
238 | return -ENOMEM; | 262 | return -ENOMEM; |
239 | 263 | ||
240 | rdev = max77686->rdev; | 264 | rdev = max77686->rdev; |
241 | max77686->dev = &pdev->dev; | 265 | config.dev = &pdev->dev; |
242 | max77686->iodev = iodev; | 266 | config.regmap = iodev->regmap; |
243 | platform_set_drvdata(pdev, max77686); | 267 | platform_set_drvdata(pdev, max77686); |
244 | 268 | ||
245 | for (i = 0; i < MAX77686_REGULATORS; i++) { | 269 | for (i = 0; i < MAX77686_REGULATORS; i++) { |
246 | config.dev = max77686->dev; | ||
247 | config.regmap = iodev->regmap; | ||
248 | config.driver_data = max77686; | ||
249 | config.init_data = pdata->regulators[i].initdata; | 270 | config.init_data = pdata->regulators[i].initdata; |
250 | 271 | ||
251 | rdev[i] = regulator_register(®ulators[i], &config); | 272 | rdev[i] = regulator_register(®ulators[i], &config); |
252 | if (IS_ERR(rdev[i])) { | 273 | if (IS_ERR(rdev[i])) { |
253 | ret = PTR_ERR(rdev[i]); | 274 | ret = PTR_ERR(rdev[i]); |
254 | dev_err(max77686->dev, | 275 | dev_err(&pdev->dev, |
255 | "regulator init failed for %d\n", i); | 276 | "regulator init failed for %d\n", i); |
256 | rdev[i] = NULL; | 277 | rdev[i] = NULL; |
257 | goto err; | 278 | goto err; |