aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/tps65023-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-06-19 05:14:31 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-19 07:14:11 -0400
commite90a84473ee941c0056c773923e9cc90a550c266 (patch)
treebb2bd486525cfa1a4444846b89e2f32d9d828a0a /drivers/regulator/tps65023-regulator.c
parentc848bc8538cd29e92223d5e72e8fb60e6f2e176e (diff)
regulator: tps65023: Convert tps65023_ldo_ops to regulator_[get|set]_voltage_sel_regmap
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/tps65023-regulator.c')
-rw-r--r--drivers/regulator/tps65023-regulator.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c
index 4b6f1b2b9481..6998d579d07b 100644
--- a/drivers/regulator/tps65023-regulator.c
+++ b/drivers/regulator/tps65023-regulator.c
@@ -69,10 +69,6 @@
69#define TPS65023_REG_CTRL2_DCDC1 BIT(1) 69#define TPS65023_REG_CTRL2_DCDC1 BIT(1)
70#define TPS65023_REG_CTRL2_DCDC3 BIT(0) 70#define TPS65023_REG_CTRL2_DCDC3 BIT(0)
71 71
72/* LDO_CTRL bitfields */
73#define TPS65023_LDO_CTRL_LDOx_SHIFT(ldo_id) ((ldo_id)*4)
74#define TPS65023_LDO_CTRL_LDOx_MASK(ldo_id) (0x0F << ((ldo_id)*4))
75
76/* Number of step-down converters available */ 72/* Number of step-down converters available */
77#define TPS65023_NUM_DCDC 3 73#define TPS65023_NUM_DCDC 3
78/* Number of LDO voltage regulators available */ 74/* Number of LDO voltage regulators available */
@@ -198,35 +194,6 @@ out:
198 return ret; 194 return ret;
199} 195}
200 196
201static int tps65023_ldo_get_voltage_sel(struct regulator_dev *dev)
202{
203 struct tps_pmic *tps = rdev_get_drvdata(dev);
204 int data, ldo = rdev_get_id(dev);
205 int ret;
206
207 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
208 return -EINVAL;
209
210 ret = regmap_read(tps->regmap, TPS65023_REG_LDO_CTRL, &data);
211 if (ret != 0)
212 return ret;
213
214 data >>= (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1));
215 data &= (tps->info[ldo]->table_len - 1);
216 return data;
217}
218
219static int tps65023_ldo_set_voltage_sel(struct regulator_dev *dev,
220 unsigned selector)
221{
222 struct tps_pmic *tps = rdev_get_drvdata(dev);
223 int ldo_index = rdev_get_id(dev) - TPS65023_LDO_1;
224
225 return regmap_update_bits(tps->regmap, TPS65023_REG_LDO_CTRL,
226 TPS65023_LDO_CTRL_LDOx_MASK(ldo_index),
227 selector << TPS65023_LDO_CTRL_LDOx_SHIFT(ldo_index));
228}
229
230/* Operations permitted on VDCDCx */ 197/* Operations permitted on VDCDCx */
231static struct regulator_ops tps65023_dcdc_ops = { 198static struct regulator_ops tps65023_dcdc_ops = {
232 .is_enabled = regulator_is_enabled_regmap, 199 .is_enabled = regulator_is_enabled_regmap,
@@ -242,8 +209,8 @@ static struct regulator_ops tps65023_ldo_ops = {
242 .is_enabled = regulator_is_enabled_regmap, 209 .is_enabled = regulator_is_enabled_regmap,
243 .enable = regulator_enable_regmap, 210 .enable = regulator_enable_regmap,
244 .disable = regulator_disable_regmap, 211 .disable = regulator_disable_regmap,
245 .get_voltage_sel = tps65023_ldo_get_voltage_sel, 212 .get_voltage_sel = regulator_get_voltage_sel_regmap,
246 .set_voltage_sel = tps65023_ldo_set_voltage_sel, 213 .set_voltage_sel = regulator_set_voltage_sel_regmap,
247 .list_voltage = regulator_list_voltage_table, 214 .list_voltage = regulator_list_voltage_table,
248}; 215};
249 216
@@ -304,13 +271,21 @@ static int __devinit tps_65023_probe(struct i2c_client *client,
304 tps->desc[i].owner = THIS_MODULE; 271 tps->desc[i].owner = THIS_MODULE;
305 272
306 tps->desc[i].enable_reg = TPS65023_REG_REG_CTRL; 273 tps->desc[i].enable_reg = TPS65023_REG_REG_CTRL;
307 if (i == TPS65023_LDO_1) 274 switch (i) {
275 case TPS65023_LDO_1:
276 tps->desc[i].vsel_reg = TPS65023_REG_LDO_CTRL;
277 tps->desc[i].vsel_mask = 0x07;
308 tps->desc[i].enable_mask = 1 << 1; 278 tps->desc[i].enable_mask = 1 << 1;
309 else if (i == TPS65023_LDO_2) 279 break;
280 case TPS65023_LDO_2:
281 tps->desc[i].vsel_reg = TPS65023_REG_LDO_CTRL;
282 tps->desc[i].vsel_mask = 0x70;
310 tps->desc[i].enable_mask = 1 << 2; 283 tps->desc[i].enable_mask = 1 << 2;
311 else /* DCDCx */ 284 break;
285 default: /* DCDCx */
312 tps->desc[i].enable_mask = 286 tps->desc[i].enable_mask =
313 1 << (TPS65023_NUM_REGULATOR - i); 287 1 << (TPS65023_NUM_REGULATOR - i);
288 }
314 289
315 config.dev = &client->dev; 290 config.dev = &client->dev;
316 config.init_data = init_data; 291 config.init_data = init_data;