aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/tps6586x-regulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/tps6586x-regulator.c')
-rw-r--r--drivers/regulator/tps6586x-regulator.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index bb04a75a4c98..dbcf09d5080c 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -332,6 +332,36 @@ static inline int tps6586x_regulator_preinit(struct device *parent,
332 1 << ri->enable_bit[1]); 332 1 << ri->enable_bit[1]);
333} 333}
334 334
335static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev)
336{
337 struct device *parent = pdev->dev.parent;
338 struct regulator_init_data *p = pdev->dev.platform_data;
339 struct tps6586x_settings *setting = p->driver_data;
340 uint8_t reg;
341
342 if (setting == NULL)
343 return 0;
344
345 if (!(setting->slew_rate & TPS6586X_SLEW_RATE_SET))
346 return 0;
347
348 /* only SM0 and SM1 can have the slew rate settings */
349 switch (pdev->id) {
350 case TPS6586X_ID_SM_0:
351 reg = TPS6586X_SM0SL;
352 break;
353 case TPS6586X_ID_SM_1:
354 reg = TPS6586X_SM1SL;
355 break;
356 default:
357 dev_warn(&pdev->dev, "Only SM0/SM1 can set slew rate\n");
358 return -EINVAL;
359 }
360
361 return tps6586x_write(parent, reg,
362 setting->slew_rate & TPS6586X_SLEW_RATE_MASK);
363}
364
335static inline struct tps6586x_regulator *find_regulator_info(int id) 365static inline struct tps6586x_regulator *find_regulator_info(int id)
336{ 366{
337 struct tps6586x_regulator *ri; 367 struct tps6586x_regulator *ri;
@@ -374,7 +404,7 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev)
374 404
375 platform_set_drvdata(pdev, rdev); 405 platform_set_drvdata(pdev, rdev);
376 406
377 return 0; 407 return tps6586x_regulator_set_slew_rate(pdev);
378} 408}
379 409
380static int __devexit tps6586x_regulator_remove(struct platform_device *pdev) 410static int __devexit tps6586x_regulator_remove(struct platform_device *pdev)