aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/wm8400-regulator.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-03-10 12:28:35 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2009-03-31 04:56:26 -0400
commit216765d92acaeabdad6561254a5a676325105a37 (patch)
tree079b55870ce08264e539acabc510a3e3ce681868 /drivers/regulator/wm8400-regulator.c
parent5c13941acc513669c7d07b28789c3f9ba66ddddf (diff)
regulator: Implement list_voltage() for WM8400 DCDCs and LDOs
All DCDCs and LDOs are identical. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/wm8400-regulator.c')
-rw-r--r--drivers/regulator/wm8400-regulator.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 6ed43b0dbdfc..157426029071 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -43,6 +43,18 @@ static int wm8400_ldo_disable(struct regulator_dev *dev)
43 WM8400_LDO1_ENA, 0); 43 WM8400_LDO1_ENA, 0);
44} 44}
45 45
46static int wm8400_ldo_list_voltage(struct regulator_dev *dev,
47 unsigned selector)
48{
49 if (selector > WM8400_LDO1_VSEL_MASK)
50 return -EINVAL;
51
52 if (selector < 15)
53 return 900000 + (selector * 50000);
54 else
55 return 1600000 + ((selector - 14) * 100000);
56}
57
46static int wm8400_ldo_get_voltage(struct regulator_dev *dev) 58static int wm8400_ldo_get_voltage(struct regulator_dev *dev)
47{ 59{
48 struct wm8400 *wm8400 = rdev_get_drvdata(dev); 60 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
@@ -51,10 +63,7 @@ static int wm8400_ldo_get_voltage(struct regulator_dev *dev)
51 val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev)); 63 val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev));
52 val &= WM8400_LDO1_VSEL_MASK; 64 val &= WM8400_LDO1_VSEL_MASK;
53 65
54 if (val < 15) 66 return wm8400_ldo_list_voltage(dev, val);
55 return 900000 + (val * 50000);
56 else
57 return 1600000 + ((val - 14) * 100000);
58} 67}
59 68
60static int wm8400_ldo_set_voltage(struct regulator_dev *dev, 69static int wm8400_ldo_set_voltage(struct regulator_dev *dev,
@@ -92,6 +101,7 @@ static struct regulator_ops wm8400_ldo_ops = {
92 .is_enabled = wm8400_ldo_is_enabled, 101 .is_enabled = wm8400_ldo_is_enabled,
93 .enable = wm8400_ldo_enable, 102 .enable = wm8400_ldo_enable,
94 .disable = wm8400_ldo_disable, 103 .disable = wm8400_ldo_disable,
104 .list_voltage = wm8400_ldo_list_voltage,
95 .get_voltage = wm8400_ldo_get_voltage, 105 .get_voltage = wm8400_ldo_get_voltage,
96 .set_voltage = wm8400_ldo_set_voltage, 106 .set_voltage = wm8400_ldo_set_voltage,
97}; 107};
@@ -124,6 +134,15 @@ static int wm8400_dcdc_disable(struct regulator_dev *dev)
124 WM8400_DC1_ENA, 0); 134 WM8400_DC1_ENA, 0);
125} 135}
126 136
137static int wm8400_dcdc_list_voltage(struct regulator_dev *dev,
138 unsigned selector)
139{
140 if (selector > WM8400_DC1_VSEL_MASK)
141 return -EINVAL;
142
143 return 850000 + (selector * 25000);
144}
145
127static int wm8400_dcdc_get_voltage(struct regulator_dev *dev) 146static int wm8400_dcdc_get_voltage(struct regulator_dev *dev)
128{ 147{
129 struct wm8400 *wm8400 = rdev_get_drvdata(dev); 148 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
@@ -237,6 +256,7 @@ static struct regulator_ops wm8400_dcdc_ops = {
237 .is_enabled = wm8400_dcdc_is_enabled, 256 .is_enabled = wm8400_dcdc_is_enabled,
238 .enable = wm8400_dcdc_enable, 257 .enable = wm8400_dcdc_enable,
239 .disable = wm8400_dcdc_disable, 258 .disable = wm8400_dcdc_disable,
259 .list_voltage = wm8400_dcdc_list_voltage,
240 .get_voltage = wm8400_dcdc_get_voltage, 260 .get_voltage = wm8400_dcdc_get_voltage,
241 .set_voltage = wm8400_dcdc_set_voltage, 261 .set_voltage = wm8400_dcdc_set_voltage,
242 .get_mode = wm8400_dcdc_get_mode, 262 .get_mode = wm8400_dcdc_get_mode,
@@ -249,6 +269,7 @@ static struct regulator_desc regulators[] = {
249 .name = "LDO1", 269 .name = "LDO1",
250 .id = WM8400_LDO1, 270 .id = WM8400_LDO1,
251 .ops = &wm8400_ldo_ops, 271 .ops = &wm8400_ldo_ops,
272 .n_voltages = WM8400_LDO1_VSEL_MASK + 1,
252 .type = REGULATOR_VOLTAGE, 273 .type = REGULATOR_VOLTAGE,
253 .owner = THIS_MODULE, 274 .owner = THIS_MODULE,
254 }, 275 },
@@ -256,6 +277,7 @@ static struct regulator_desc regulators[] = {
256 .name = "LDO2", 277 .name = "LDO2",
257 .id = WM8400_LDO2, 278 .id = WM8400_LDO2,
258 .ops = &wm8400_ldo_ops, 279 .ops = &wm8400_ldo_ops,
280 .n_voltages = WM8400_LDO2_VSEL_MASK + 1,
259 .type = REGULATOR_VOLTAGE, 281 .type = REGULATOR_VOLTAGE,
260 .owner = THIS_MODULE, 282 .owner = THIS_MODULE,
261 }, 283 },
@@ -263,6 +285,7 @@ static struct regulator_desc regulators[] = {
263 .name = "LDO3", 285 .name = "LDO3",
264 .id = WM8400_LDO3, 286 .id = WM8400_LDO3,
265 .ops = &wm8400_ldo_ops, 287 .ops = &wm8400_ldo_ops,
288 .n_voltages = WM8400_LDO3_VSEL_MASK + 1,
266 .type = REGULATOR_VOLTAGE, 289 .type = REGULATOR_VOLTAGE,
267 .owner = THIS_MODULE, 290 .owner = THIS_MODULE,
268 }, 291 },
@@ -270,6 +293,7 @@ static struct regulator_desc regulators[] = {
270 .name = "LDO4", 293 .name = "LDO4",
271 .id = WM8400_LDO4, 294 .id = WM8400_LDO4,
272 .ops = &wm8400_ldo_ops, 295 .ops = &wm8400_ldo_ops,
296 .n_voltages = WM8400_LDO4_VSEL_MASK + 1,
273 .type = REGULATOR_VOLTAGE, 297 .type = REGULATOR_VOLTAGE,
274 .owner = THIS_MODULE, 298 .owner = THIS_MODULE,
275 }, 299 },
@@ -277,6 +301,7 @@ static struct regulator_desc regulators[] = {
277 .name = "DCDC1", 301 .name = "DCDC1",
278 .id = WM8400_DCDC1, 302 .id = WM8400_DCDC1,
279 .ops = &wm8400_dcdc_ops, 303 .ops = &wm8400_dcdc_ops,
304 .n_voltages = WM8400_DC1_VSEL_MASK + 1,
280 .type = REGULATOR_VOLTAGE, 305 .type = REGULATOR_VOLTAGE,
281 .owner = THIS_MODULE, 306 .owner = THIS_MODULE,
282 }, 307 },
@@ -284,6 +309,7 @@ static struct regulator_desc regulators[] = {
284 .name = "DCDC2", 309 .name = "DCDC2",
285 .id = WM8400_DCDC2, 310 .id = WM8400_DCDC2,
286 .ops = &wm8400_dcdc_ops, 311 .ops = &wm8400_dcdc_ops,
312 .n_voltages = WM8400_DC2_VSEL_MASK + 1,
287 .type = REGULATOR_VOLTAGE, 313 .type = REGULATOR_VOLTAGE,
288 .owner = THIS_MODULE, 314 .owner = THIS_MODULE,
289 }, 315 },