aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBengt Jonsson <bengt.g.jonsson@stericsson.com>2010-12-10 05:08:44 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-01-12 09:33:02 -0500
commite1159e6d9ac5faf42abedd2fc02234e3d946585a (patch)
tree58b5fe5d7066918550ccfb51f380d7d64b499b19 /drivers
parent2b75151a1041f200ee3f36475ba389da43664bb4 (diff)
regulators: Updated ab8500 variable names, macro names and comments
The regulator enumeration is used for putting the regulator data in correct place in the info array. This should be matched in the board configuration. Variable names are updated to be more consistent, comments are corrected and macros have been edited to be consistent. Signed-off-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com> Acked-by: Linus Walleij <linus.walleij@stericsson.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/ab8500.c161
1 files changed, 82 insertions, 79 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 9a3dc7973ae1..ccb0bfd71f23 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -3,18 +3,13 @@
3 * 3 *
4 * License Terms: GNU General Public License v2 4 * License Terms: GNU General Public License v2
5 * 5 *
6 * Author: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson 6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
7 * 8 *
8 * AB8500 peripheral regulators 9 * AB8500 peripheral regulators
9 * 10 *
10 * AB8500 supports the following regulators, 11 * AB8500 supports the following regulators:
11 * LDOs - VAUDIO, VANAMIC2/2, VDIGMIC, VINTCORE12, VTVOUT, 12 * VAUX1/2/3, VINTCORE, VTVOUT, VAUDIO, VAMIC1/2, VDMIC, VANA
12 * VAUX1/2/3, VANA
13 *
14 * for DB8500 cut 1.0 and previous versions of the silicon, all accesses
15 * to registers are through the DB8500 SPI. In cut 1.1 onwards, these
16 * accesses are through the DB8500 PRCMU I2C
17 *
18 */ 13 */
19#include <linux/init.h> 14#include <linux/init.h>
20#include <linux/kernel.h> 15#include <linux/kernel.h>
@@ -28,6 +23,7 @@
28 23
29/** 24/**
30 * struct ab8500_regulator_info - ab8500 regulator information 25 * struct ab8500_regulator_info - ab8500 regulator information
26 * @dev: device pointer
31 * @desc: regulator description 27 * @desc: regulator description
32 * @regulator_dev: regulator device 28 * @regulator_dev: regulator device
33 * @max_uV: maximum voltage (for variable voltage supplies) 29 * @max_uV: maximum voltage (for variable voltage supplies)
@@ -35,12 +31,12 @@
35 * @fixed_uV: typical voltage (for fixed voltage supplies) 31 * @fixed_uV: typical voltage (for fixed voltage supplies)
36 * @update_bank: bank to control on/off 32 * @update_bank: bank to control on/off
37 * @update_reg: register to control on/off 33 * @update_reg: register to control on/off
38 * @mask: mask to enable/disable regulator 34 * @update_mask: mask to enable/disable regulator
39 * @enable: bits to enable the regulator in normal(high power) mode 35 * @update_val_enable: bits to enable the regulator in normal (high power) mode
40 * @voltage_bank: bank to control regulator voltage 36 * @voltage_bank: bank to control regulator voltage
41 * @voltage_reg: register to control regulator voltage 37 * @voltage_reg: register to control regulator voltage
42 * @voltage_mask: mask to control regulator voltage 38 * @voltage_mask: mask to control regulator voltage
43 * @supported_voltages: supported voltage table 39 * @voltages: supported voltage table
44 * @voltages_len: number of supported voltages for the regulator 40 * @voltages_len: number of supported voltages for the regulator
45 */ 41 */
46struct ab8500_regulator_info { 42struct ab8500_regulator_info {
@@ -52,12 +48,12 @@ struct ab8500_regulator_info {
52 int fixed_uV; 48 int fixed_uV;
53 u8 update_bank; 49 u8 update_bank;
54 u8 update_reg; 50 u8 update_reg;
55 u8 mask; 51 u8 update_mask;
56 u8 enable; 52 u8 update_val_enable;
57 u8 voltage_bank; 53 u8 voltage_bank;
58 u8 voltage_reg; 54 u8 voltage_reg;
59 u8 voltage_mask; 55 u8 voltage_mask;
60 int const *supported_voltages; 56 int const *voltages;
61 int voltages_len; 57 int voltages_len;
62}; 58};
63 59
@@ -112,7 +108,8 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev)
112 return -EINVAL; 108 return -EINVAL;
113 109
114 ret = abx500_mask_and_set_register_interruptible(info->dev, 110 ret = abx500_mask_and_set_register_interruptible(info->dev,
115 info->update_bank, info->update_reg, info->mask, info->enable); 111 info->update_bank, info->update_reg,
112 info->update_mask, info->update_val_enable);
116 if (ret < 0) 113 if (ret < 0)
117 dev_err(rdev_get_dev(rdev), 114 dev_err(rdev_get_dev(rdev),
118 "couldn't set enable bits for regulator\n"); 115 "couldn't set enable bits for regulator\n");
@@ -129,7 +126,8 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)
129 return -EINVAL; 126 return -EINVAL;
130 127
131 ret = abx500_mask_and_set_register_interruptible(info->dev, 128 ret = abx500_mask_and_set_register_interruptible(info->dev,
132 info->update_bank, info->update_reg, info->mask, 0x0); 129 info->update_bank, info->update_reg,
130 info->update_mask, 0x0);
133 if (ret < 0) 131 if (ret < 0)
134 dev_err(rdev_get_dev(rdev), 132 dev_err(rdev_get_dev(rdev),
135 "couldn't set disable bits for regulator\n"); 133 "couldn't set disable bits for regulator\n");
@@ -154,7 +152,7 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
154 return ret; 152 return ret;
155 } 153 }
156 154
157 if (value & info->mask) 155 if (value & info->update_mask)
158 return true; 156 return true;
159 else 157 else
160 return false; 158 return false;
@@ -176,7 +174,7 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
176 if (selector >= info->voltages_len) 174 if (selector >= info->voltages_len)
177 return -EINVAL; 175 return -EINVAL;
178 176
179 return info->supported_voltages[selector]; 177 return info->voltages[selector];
180} 178}
181 179
182static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) 180static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
@@ -200,9 +198,9 @@ static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
200 /* vintcore has a different layout */ 198 /* vintcore has a different layout */
201 value &= info->voltage_mask; 199 value &= info->voltage_mask;
202 if (regulator_id == AB8500_LDO_INTCORE) 200 if (regulator_id == AB8500_LDO_INTCORE)
203 ret = info->supported_voltages[value >> 0x3]; 201 ret = info->voltages[value >> 0x3];
204 else 202 else
205 ret = info->supported_voltages[value]; 203 ret = info->voltages[value];
206 204
207 return ret; 205 return ret;
208} 206}
@@ -215,8 +213,8 @@ static int ab8500_get_best_voltage_index(struct regulator_dev *rdev,
215 213
216 /* check the supported voltage */ 214 /* check the supported voltage */
217 for (i = 0; i < info->voltages_len; i++) { 215 for (i = 0; i < info->voltages_len; i++) {
218 if ((info->supported_voltages[i] >= min_uV) && 216 if ((info->voltages[i] >= min_uV) &&
219 (info->supported_voltages[i] <= max_uV)) 217 (info->voltages[i] <= max_uV))
220 return i; 218 return i;
221 } 219 }
222 220
@@ -284,74 +282,79 @@ static struct regulator_ops ab8500_ldo_fixed_ops = {
284 .list_voltage = ab8500_list_voltage, 282 .list_voltage = ab8500_list_voltage,
285}; 283};
286 284
287#define AB8500_LDO(_id, min, max, bank, reg, reg_mask, \ 285#define AB8500_LDO(_id, _min_mV, _max_mV, \
288 reg_enable, volt_bank, volt_reg, volt_mask, \ 286 _u_bank, _u_reg, _u_mask, _u_val_enable, \
289 voltages, len_volts) \ 287 _v_bank, _v_reg, _v_mask, _v_table, _v_table_len) \
290{ \ 288[AB8500_LDO_##_id] = { \
291 .desc = { \ 289 .desc = { \
292 .name = "LDO-" #_id, \ 290 .name = "LDO-" #_id, \
293 .ops = &ab8500_regulator_ops, \ 291 .ops = &ab8500_regulator_ops, \
294 .type = REGULATOR_VOLTAGE, \ 292 .type = REGULATOR_VOLTAGE, \
295 .id = AB8500_LDO_##_id, \ 293 .id = AB8500_LDO_##_id, \
296 .owner = THIS_MODULE, \ 294 .owner = THIS_MODULE, \
297 }, \ 295 }, \
298 .min_uV = (min) * 1000, \ 296 .min_uV = (_min_mV) * 1000, \
299 .max_uV = (max) * 1000, \ 297 .max_uV = (_max_mV) * 1000, \
300 .update_bank = bank, \ 298 .update_bank = _u_bank, \
301 .update_reg = reg, \ 299 .update_reg = _u_reg, \
302 .mask = reg_mask, \ 300 .update_mask = _u_mask, \
303 .enable = reg_enable, \ 301 .update_val_enable = _u_val_enable, \
304 .voltage_bank = volt_bank, \ 302 .voltage_bank = _v_bank, \
305 .voltage_reg = volt_reg, \ 303 .voltage_reg = _v_reg, \
306 .voltage_mask = volt_mask, \ 304 .voltage_mask = _v_mask, \
307 .supported_voltages = voltages, \ 305 .voltages = _v_table, \
308 .voltages_len = len_volts, \ 306 .voltages_len = _v_table_len, \
309 .fixed_uV = 0, \ 307 .fixed_uV = 0, \
310} 308}
311 309
312#define AB8500_FIXED_LDO(_id, fixed, bank, reg, \ 310#define AB8500_FIXED_LDO(_id, _fixed_mV, \
313 reg_mask, reg_enable) \ 311 _u_bank, _u_reg, _u_mask, _u_val_enable) \
314{ \ 312[AB8500_LDO_##_id] = { \
315 .desc = { \ 313 .desc = { \
316 .name = "LDO-" #_id, \ 314 .name = "LDO-" #_id, \
317 .ops = &ab8500_ldo_fixed_ops, \ 315 .ops = &ab8500_ldo_fixed_ops, \
318 .type = REGULATOR_VOLTAGE, \ 316 .type = REGULATOR_VOLTAGE, \
319 .id = AB8500_LDO_##_id, \ 317 .id = AB8500_LDO_##_id, \
320 .owner = THIS_MODULE, \ 318 .owner = THIS_MODULE, \
321 }, \ 319 }, \
322 .fixed_uV = fixed * 1000, \ 320 .fixed_uV = (_fixed_mV) * 1000, \
323 .update_bank = bank, \ 321 .update_bank = _u_bank, \
324 .update_reg = reg, \ 322 .update_reg = _u_reg, \
325 .mask = reg_mask, \ 323 .update_mask = _u_mask, \
326 .enable = reg_enable, \ 324 .update_val_enable = _u_val_enable, \
327} 325}
328 326
329static struct ab8500_regulator_info ab8500_regulator_info[] = { 327static struct ab8500_regulator_info ab8500_regulator_info[] = {
330 /* 328 /*
331 * Variable Voltage LDOs 329 * Variable Voltage Regulators
332 * name, min uV, max uV, ctrl bank, ctrl reg, reg mask, enable mask, 330 * name, min mV, max mV,
333 * volt ctrl bank, volt ctrl reg, volt ctrl mask, volt table, 331 * update bank, reg, mask, enable val
334 * num supported volts 332 * volt bank, reg, mask, table, table length
335 */ 333 */
336 AB8500_LDO(AUX1, 1100, 3300, 0x04, 0x09, 0x3, 0x1, 0x04, 0x1f, 0xf, 334 AB8500_LDO(AUX1, 1100, 3300,
337 ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), 335 0x04, 0x09, 0x03, 0x01, 0x04, 0x1f, 0x0f,
338 AB8500_LDO(AUX2, 1100, 3300, 0x04, 0x09, 0xc, 0x4, 0x04, 0x20, 0xf, 336 ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
339 ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), 337 AB8500_LDO(AUX2, 1100, 3300,
340 AB8500_LDO(AUX3, 1100, 3300, 0x04, 0x0a, 0x3, 0x1, 0x04, 0x21, 0x7, 338 0x04, 0x09, 0x0c, 0x04, 0x04, 0x20, 0x0f,
341 ldo_vaux3_voltages, ARRAY_SIZE(ldo_vaux3_voltages)), 339 ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
342 AB8500_LDO(INTCORE, 1100, 3300, 0x03, 0x80, 0x44, 0x4, 0x03, 0x80, 0x38, 340 AB8500_LDO(AUX3, 1100, 3300,
341 0x04, 0x0a, 0x03, 0x01, 0x04, 0x21, 0x07,
342 ldo_vaux3_voltages, ARRAY_SIZE(ldo_vaux3_voltages)),
343 AB8500_LDO(INTCORE, 1100, 3300,
344 0x03, 0x80, 0x44, 0x04, 0x03, 0x80, 0x38,
343 ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)), 345 ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)),
344 346
345 /* 347 /*
346 * Fixed Voltage LDOs 348 * Fixed Voltage Regulators
347 * name, o/p uV, ctrl bank, ctrl reg, enable, disable 349 * name, fixed mV,
350 * update bank, reg, mask, enable val
348 */ 351 */
349 AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x82, 0x2), 352 AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x82, 0x02),
350 AB8500_FIXED_LDO(AUDIO, 2000, 0x03, 0x83, 0x2, 0x2), 353 AB8500_FIXED_LDO(AUDIO, 2000, 0x03, 0x83, 0x02, 0x02),
351 AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x08, 0x08), 354 AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x08, 0x08),
352 AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x10, 0x10), 355 AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x10, 0x10),
353 AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x04, 0x04), 356 AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x04, 0x04),
354 AB8500_FIXED_LDO(ANA, 1200, 0x04, 0x06, 0xc, 0x4), 357 AB8500_FIXED_LDO(ANA, 1200, 0x04, 0x06, 0x0c, 0x04),
355}; 358};
356 359
357static __devinit int ab8500_regulator_probe(struct platform_device *pdev) 360static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
@@ -385,7 +388,7 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
385 if (info->desc.id == AB8500_LDO_AUX3) { 388 if (info->desc.id == AB8500_LDO_AUX3) {
386 info->desc.n_voltages = 389 info->desc.n_voltages =
387 ARRAY_SIZE(ldo_vauxn_voltages); 390 ARRAY_SIZE(ldo_vauxn_voltages);
388 info->supported_voltages = ldo_vauxn_voltages; 391 info->voltages = ldo_vauxn_voltages;
389 info->voltages_len = 392 info->voltages_len =
390 ARRAY_SIZE(ldo_vauxn_voltages); 393 ARRAY_SIZE(ldo_vauxn_voltages);
391 info->voltage_mask = 0xf; 394 info->voltage_mask = 0xf;