diff options
author | Yadwinder Singh Brar <yadi.brar01@gmail.com> | 2012-06-19 03:53:42 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-19 07:06:32 -0400 |
commit | 852abad238da723efac29f3e78dd768c18d6a062 (patch) | |
tree | 0db49bdaf59e013b48528a5849474d6a2617a3ff /drivers/regulator/max77686.c | |
parent | a133829e66d25e1ce293a30bcc3fb8eb653a1519 (diff) |
regulator: max77686: Convert driver to use regulator_set_voltage_time_sel.
This patch converts the driver to use regulator_set_voltage_time_sel() as
.set_voltage_time_sel() callback. It also sets ramp_delay as 100000 uV/us for
LDOs & normal BUCKs and 27500 uV/us(default/reset value) for BUCKs[2/3/4] in
regulator_desc[].
Signed-off-by: Yadwinder Singh Brar <yadi.brar@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 | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 2dd4ac91d283..a29eee33dd7b 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c | |||
@@ -40,6 +40,8 @@ | |||
40 | #define MAX77686_LDO_LOW_UVSTEP 25000 | 40 | #define MAX77686_LDO_LOW_UVSTEP 25000 |
41 | #define MAX77686_BUCK_MINUV 750000 | 41 | #define MAX77686_BUCK_MINUV 750000 |
42 | #define MAX77686_BUCK_UVSTEP 50000 | 42 | #define MAX77686_BUCK_UVSTEP 50000 |
43 | #define MAX77686_RAMP_DELAY 100000 /* uV/us */ | ||
44 | #define MAX77686_DVS_RAMP_DELAY 27500 /* uV/us */ | ||
43 | #define MAX77686_DVS_MINUV 600000 | 45 | #define MAX77686_DVS_MINUV 600000 |
44 | #define MAX77686_DVS_UVSTEP 12500 | 46 | #define MAX77686_DVS_UVSTEP 12500 |
45 | 47 | ||
@@ -66,28 +68,8 @@ struct max77686_data { | |||
66 | struct device *dev; | 68 | struct device *dev; |
67 | struct max77686_dev *iodev; | 69 | struct max77686_dev *iodev; |
68 | struct regulator_dev **rdev; | 70 | struct regulator_dev **rdev; |
69 | int ramp_delay; /* in mV/us */ | ||
70 | }; | 71 | }; |
71 | 72 | ||
72 | static int max77686_set_dvs_voltage_time_sel(struct regulator_dev *rdev, | ||
73 | unsigned int old_selector, unsigned int new_selector) | ||
74 | { | ||
75 | struct max77686_data *max77686 = rdev_get_drvdata(rdev); | ||
76 | int ramp_rate[] = {13, 27, 55, 100}; | ||
77 | |||
78 | return DIV_ROUND_UP(rdev->desc->uV_step * | ||
79 | abs(new_selector - old_selector), | ||
80 | ramp_rate[max77686->ramp_delay] * 1000); | ||
81 | } | ||
82 | |||
83 | static int max77686_set_voltage_time_sel(struct regulator_dev *rdev, | ||
84 | unsigned int old_selector, unsigned int new_selector) | ||
85 | { | ||
86 | /* Unconditionally 100 mV/us */ | ||
87 | return DIV_ROUND_UP(rdev->desc->uV_step * | ||
88 | abs(new_selector - old_selector), 100 * 1000); | ||
89 | } | ||
90 | |||
91 | static struct regulator_ops max77686_ops = { | 73 | static struct regulator_ops max77686_ops = { |
92 | .list_voltage = regulator_list_voltage_linear, | 74 | .list_voltage = regulator_list_voltage_linear, |
93 | .map_voltage = regulator_map_voltage_linear, | 75 | .map_voltage = regulator_map_voltage_linear, |
@@ -96,7 +78,7 @@ static struct regulator_ops max77686_ops = { | |||
96 | .disable = regulator_disable_regmap, | 78 | .disable = regulator_disable_regmap, |
97 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 79 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
98 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 80 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
99 | .set_voltage_time_sel = max77686_set_voltage_time_sel, | 81 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
100 | }; | 82 | }; |
101 | 83 | ||
102 | static struct regulator_ops max77686_buck_dvs_ops = { | 84 | static struct regulator_ops max77686_buck_dvs_ops = { |
@@ -107,7 +89,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
107 | .disable = regulator_disable_regmap, | 89 | .disable = regulator_disable_regmap, |
108 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 90 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
109 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 91 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
110 | .set_voltage_time_sel = max77686_set_dvs_voltage_time_sel, | 92 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
111 | }; | 93 | }; |
112 | 94 | ||
113 | #define regulator_desc_ldo(num) { \ | 95 | #define regulator_desc_ldo(num) { \ |
@@ -118,6 +100,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
118 | .owner = THIS_MODULE, \ | 100 | .owner = THIS_MODULE, \ |
119 | .min_uV = MAX77686_LDO_MINUV, \ | 101 | .min_uV = MAX77686_LDO_MINUV, \ |
120 | .uV_step = MAX77686_LDO_UVSTEP, \ | 102 | .uV_step = MAX77686_LDO_UVSTEP, \ |
103 | .ramp_delay = MAX77686_RAMP_DELAY, \ | ||
121 | .n_voltages = MAX77686_VSEL_MASK + 1, \ | 104 | .n_voltages = MAX77686_VSEL_MASK + 1, \ |
122 | .vsel_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \ | 105 | .vsel_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \ |
123 | .vsel_mask = MAX77686_VSEL_MASK, \ | 106 | .vsel_mask = MAX77686_VSEL_MASK, \ |
@@ -133,6 +116,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
133 | .owner = THIS_MODULE, \ | 116 | .owner = THIS_MODULE, \ |
134 | .min_uV = MAX77686_LDO_LOW_MINUV, \ | 117 | .min_uV = MAX77686_LDO_LOW_MINUV, \ |
135 | .uV_step = MAX77686_LDO_LOW_UVSTEP, \ | 118 | .uV_step = MAX77686_LDO_LOW_UVSTEP, \ |
119 | .ramp_delay = MAX77686_RAMP_DELAY, \ | ||
136 | .n_voltages = MAX77686_VSEL_MASK + 1, \ | 120 | .n_voltages = MAX77686_VSEL_MASK + 1, \ |
137 | .vsel_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \ | 121 | .vsel_reg = MAX77686_REG_LDO1CTRL1 + num - 1, \ |
138 | .vsel_mask = MAX77686_VSEL_MASK, \ | 122 | .vsel_mask = MAX77686_VSEL_MASK, \ |
@@ -148,6 +132,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
148 | .owner = THIS_MODULE, \ | 132 | .owner = THIS_MODULE, \ |
149 | .min_uV = MAX77686_BUCK_MINUV, \ | 133 | .min_uV = MAX77686_BUCK_MINUV, \ |
150 | .uV_step = MAX77686_BUCK_UVSTEP, \ | 134 | .uV_step = MAX77686_BUCK_UVSTEP, \ |
135 | .ramp_delay = MAX77686_RAMP_DELAY, \ | ||
151 | .n_voltages = MAX77686_VSEL_MASK + 1, \ | 136 | .n_voltages = MAX77686_VSEL_MASK + 1, \ |
152 | .vsel_reg = MAX77686_REG_BUCK5OUT + (num - 5) * 2, \ | 137 | .vsel_reg = MAX77686_REG_BUCK5OUT + (num - 5) * 2, \ |
153 | .vsel_mask = MAX77686_VSEL_MASK, \ | 138 | .vsel_mask = MAX77686_VSEL_MASK, \ |
@@ -162,6 +147,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
162 | .owner = THIS_MODULE, \ | 147 | .owner = THIS_MODULE, \ |
163 | .min_uV = MAX77686_BUCK_MINUV, \ | 148 | .min_uV = MAX77686_BUCK_MINUV, \ |
164 | .uV_step = MAX77686_BUCK_UVSTEP, \ | 149 | .uV_step = MAX77686_BUCK_UVSTEP, \ |
150 | .ramp_delay = MAX77686_RAMP_DELAY, \ | ||
165 | .n_voltages = MAX77686_VSEL_MASK + 1, \ | 151 | .n_voltages = MAX77686_VSEL_MASK + 1, \ |
166 | .vsel_reg = MAX77686_REG_BUCK1OUT, \ | 152 | .vsel_reg = MAX77686_REG_BUCK1OUT, \ |
167 | .vsel_mask = MAX77686_VSEL_MASK, \ | 153 | .vsel_mask = MAX77686_VSEL_MASK, \ |
@@ -176,6 +162,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
176 | .owner = THIS_MODULE, \ | 162 | .owner = THIS_MODULE, \ |
177 | .min_uV = MAX77686_DVS_MINUV, \ | 163 | .min_uV = MAX77686_DVS_MINUV, \ |
178 | .uV_step = MAX77686_DVS_UVSTEP, \ | 164 | .uV_step = MAX77686_DVS_UVSTEP, \ |
165 | .ramp_delay = MAX77686_DVS_RAMP_DELAY, \ | ||
179 | .n_voltages = MAX77686_DVS_VSEL_MASK + 1, \ | 166 | .n_voltages = MAX77686_DVS_VSEL_MASK + 1, \ |
180 | .vsel_reg = MAX77686_REG_BUCK2DVS1 + (num - 2) * 10, \ | 167 | .vsel_reg = MAX77686_REG_BUCK2DVS1 + (num - 2) * 10, \ |
181 | .vsel_mask = MAX77686_DVS_VSEL_MASK, \ | 168 | .vsel_mask = MAX77686_DVS_VSEL_MASK, \ |
@@ -255,17 +242,6 @@ static __devinit int max77686_pmic_probe(struct platform_device *pdev) | |||
255 | max77686->iodev = iodev; | 242 | max77686->iodev = iodev; |
256 | platform_set_drvdata(pdev, max77686); | 243 | platform_set_drvdata(pdev, max77686); |
257 | 244 | ||
258 | max77686->ramp_delay = RAMP_RATE_NO_CTRL; /* Set 0x3 for RAMP */ | ||
259 | regmap_update_bits(max77686->iodev->regmap, | ||
260 | MAX77686_REG_BUCK2CTRL1, MAX77686_RAMP_RATE_MASK, | ||
261 | max77686->ramp_delay << 6); | ||
262 | regmap_update_bits(max77686->iodev->regmap, | ||
263 | MAX77686_REG_BUCK3CTRL1, MAX77686_RAMP_RATE_MASK, | ||
264 | max77686->ramp_delay << 6); | ||
265 | regmap_update_bits(max77686->iodev->regmap, | ||
266 | MAX77686_REG_BUCK4CTRL1, MAX77686_RAMP_RATE_MASK, | ||
267 | max77686->ramp_delay << 6); | ||
268 | |||
269 | for (i = 0; i < MAX77686_REGULATORS; i++) { | 245 | for (i = 0; i < MAX77686_REGULATORS; i++) { |
270 | config.dev = max77686->dev; | 246 | config.dev = max77686->dev; |
271 | config.regmap = iodev->regmap; | 247 | config.regmap = iodev->regmap; |