aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/tps65023-regulator.c112
1 files changed, 16 insertions, 96 deletions
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c
index 2db71497b74..a1fd65682f4 100644
--- a/drivers/regulator/tps65023-regulator.c
+++ b/drivers/regulator/tps65023-regulator.c
@@ -151,96 +151,6 @@ struct tps_driver_data {
151 u8 core_regulator; 151 u8 core_regulator;
152}; 152};
153 153
154static int tps65023_dcdc_is_enabled(struct regulator_dev *dev)
155{
156 struct tps_pmic *tps = rdev_get_drvdata(dev);
157 int data, dcdc = rdev_get_id(dev);
158 int ret;
159 u8 shift;
160
161 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
162 return -EINVAL;
163
164 shift = TPS65023_NUM_REGULATOR - dcdc;
165 ret = regmap_read(tps->regmap, TPS65023_REG_REG_CTRL, &data);
166
167 if (ret != 0)
168 return ret;
169 else
170 return (data & 1<<shift) ? 1 : 0;
171}
172
173static int tps65023_ldo_is_enabled(struct regulator_dev *dev)
174{
175 struct tps_pmic *tps = rdev_get_drvdata(dev);
176 int data, ldo = rdev_get_id(dev);
177 int ret;
178 u8 shift;
179
180 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
181 return -EINVAL;
182
183 shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
184 ret = regmap_read(tps->regmap, TPS65023_REG_REG_CTRL, &data);
185
186 if (ret != 0)
187 return ret;
188 else
189 return (data & 1<<shift) ? 1 : 0;
190}
191
192static int tps65023_dcdc_enable(struct regulator_dev *dev)
193{
194 struct tps_pmic *tps = rdev_get_drvdata(dev);
195 int dcdc = rdev_get_id(dev);
196 u8 shift;
197
198 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
199 return -EINVAL;
200
201 shift = TPS65023_NUM_REGULATOR - dcdc;
202 return regmap_update_bits(tps->regmap, TPS65023_REG_REG_CTRL, 1 << shift, 1 << shift);
203}
204
205static int tps65023_dcdc_disable(struct regulator_dev *dev)
206{
207 struct tps_pmic *tps = rdev_get_drvdata(dev);
208 int dcdc = rdev_get_id(dev);
209 u8 shift;
210
211 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
212 return -EINVAL;
213
214 shift = TPS65023_NUM_REGULATOR - dcdc;
215 return regmap_update_bits(tps->regmap, TPS65023_REG_REG_CTRL, 1 << shift, 0);
216}
217
218static int tps65023_ldo_enable(struct regulator_dev *dev)
219{
220 struct tps_pmic *tps = rdev_get_drvdata(dev);
221 int ldo = rdev_get_id(dev);
222 u8 shift;
223
224 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
225 return -EINVAL;
226
227 shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
228 return regmap_update_bits(tps->regmap, TPS65023_REG_REG_CTRL, 1 << shift, 1 << shift);
229}
230
231static int tps65023_ldo_disable(struct regulator_dev *dev)
232{
233 struct tps_pmic *tps = rdev_get_drvdata(dev);
234 int ldo = rdev_get_id(dev);
235 u8 shift;
236
237 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
238 return -EINVAL;
239
240 shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
241 return regmap_update_bits(tps->regmap, TPS65023_REG_REG_CTRL, 1 << shift, 0);
242}
243
244static int tps65023_dcdc_get_voltage(struct regulator_dev *dev) 154static int tps65023_dcdc_get_voltage(struct regulator_dev *dev)
245{ 155{
246 struct tps_pmic *tps = rdev_get_drvdata(dev); 156 struct tps_pmic *tps = rdev_get_drvdata(dev);
@@ -348,9 +258,9 @@ static int tps65023_ldo_list_voltage(struct regulator_dev *dev,
348 258
349/* Operations permitted on VDCDCx */ 259/* Operations permitted on VDCDCx */
350static struct regulator_ops tps65023_dcdc_ops = { 260static struct regulator_ops tps65023_dcdc_ops = {
351 .is_enabled = tps65023_dcdc_is_enabled, 261 .is_enabled = regulator_is_enabled_regmap,
352 .enable = tps65023_dcdc_enable, 262 .enable = regulator_enable_regmap,
353 .disable = tps65023_dcdc_disable, 263 .disable = regulator_disable_regmap,
354 .get_voltage = tps65023_dcdc_get_voltage, 264 .get_voltage = tps65023_dcdc_get_voltage,
355 .set_voltage_sel = tps65023_dcdc_set_voltage_sel, 265 .set_voltage_sel = tps65023_dcdc_set_voltage_sel,
356 .list_voltage = tps65023_dcdc_list_voltage, 266 .list_voltage = tps65023_dcdc_list_voltage,
@@ -358,9 +268,9 @@ static struct regulator_ops tps65023_dcdc_ops = {
358 268
359/* Operations permitted on LDOx */ 269/* Operations permitted on LDOx */
360static struct regulator_ops tps65023_ldo_ops = { 270static struct regulator_ops tps65023_ldo_ops = {
361 .is_enabled = tps65023_ldo_is_enabled, 271 .is_enabled = regulator_is_enabled_regmap,
362 .enable = tps65023_ldo_enable, 272 .enable = regulator_enable_regmap,
363 .disable = tps65023_ldo_disable, 273 .disable = regulator_disable_regmap,
364 .get_voltage = tps65023_ldo_get_voltage, 274 .get_voltage = tps65023_ldo_get_voltage,
365 .set_voltage_sel = tps65023_ldo_set_voltage_sel, 275 .set_voltage_sel = tps65023_ldo_set_voltage_sel,
366 .list_voltage = tps65023_ldo_list_voltage, 276 .list_voltage = tps65023_ldo_list_voltage,
@@ -421,9 +331,19 @@ static int __devinit tps_65023_probe(struct i2c_client *client,
421 tps->desc[i].type = REGULATOR_VOLTAGE; 331 tps->desc[i].type = REGULATOR_VOLTAGE;
422 tps->desc[i].owner = THIS_MODULE; 332 tps->desc[i].owner = THIS_MODULE;
423 333
334 tps->desc[i].enable_reg = TPS65023_REG_REG_CTRL;
335 if (i == TPS65023_LDO_1)
336 tps->desc[i].enable_mask = 1 << 1;
337 else if (i == TPS65023_LDO_2)
338 tps->desc[i].enable_mask = 1 << 2;
339 else /* DCDCx */
340 tps->desc[i].enable_mask =
341 1 << (TPS65023_NUM_REGULATOR - i);
342
424 config.dev = &client->dev; 343 config.dev = &client->dev;
425 config.init_data = init_data; 344 config.init_data = init_data;
426 config.driver_data = tps; 345 config.driver_data = tps;
346 config.regmap = tps->regmap;
427 347
428 /* Register the regulators */ 348 /* Register the regulators */
429 rdev = regulator_register(&tps->desc[i], &config); 349 rdev = regulator_register(&tps->desc[i], &config);