summaryrefslogtreecommitdiff
path: root/drivers/regulator/tps6591x-regulator.c
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2011-10-19 13:48:34 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:49:44 -0800
commit61fc54aed862e0502b618ce8b81a07f4ae76f6a6 (patch)
tree3feb4c763cd37624c6189bdfd176c5dd6caab07f /drivers/regulator/tps6591x-regulator.c
parente2d4c6ec61841cd84552919ee54f77e2f3287bad (diff)
regulator: tps6591x: Support to put LDO in low power in suspend
Adding the configuration flag to put the ldos in the low power mode when it is suspended. The option can be provided through platform data. bug 890770 Reviewed-on: http://git-master/r/60408 (cherry picked from commit e317af259582d04c4eba2feabb757eb05d174002) Change-Id: I65ee0ef9ae963cf3d9f73ed9c5bb7c7fa4af77c8 Reviewed-on: http://git-master/r/61435 Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com> Tested-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Bitan Biswas <bbiswas@nvidia.com> Rebase-Id: R869a6c46008af761bc3eec1a3fbb50681786b7de
Diffstat (limited to 'drivers/regulator/tps6591x-regulator.c')
-rw-r--r--drivers/regulator/tps6591x-regulator.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/regulator/tps6591x-regulator.c b/drivers/regulator/tps6591x-regulator.c
index 6a4dba8a997e..5336f3d82576 100644
--- a/drivers/regulator/tps6591x-regulator.c
+++ b/drivers/regulator/tps6591x-regulator.c
@@ -92,6 +92,7 @@ struct tps6591x_regulator {
/* Time (micro sec) taken for 1uV change */
int voltage_change_uv_per_us;
+ unsigned int config_flags;
};
static inline struct device *to_tps6591x_dev(struct regulator_dev *rdev)
@@ -825,6 +826,7 @@ static int __devinit tps6591x_regulator_probe(struct platform_device *pdev)
}
tps_pdata = pdev->dev.platform_data;
ri->ectrl = tps_pdata->ectrl;
+ ri->config_flags = tps_pdata->flags;
if (tps_pdata->slew_rate_uV_per_us)
ri->voltage_change_uv_per_us = tps_pdata->slew_rate_uV_per_us;
@@ -880,6 +882,50 @@ static void tps6591x_regulator_shutdown(struct platform_device *pdev)
}
}
+static int tps6591x_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ struct regulator_dev *rdev = platform_get_drvdata(pdev);
+ struct tps6591x_regulator *ri = rdev_get_drvdata(rdev);
+ struct device *parent = to_tps6591x_dev(rdev);
+ int ret = 0;
+ uint8_t reg_val;
+
+ if (ri->config_flags & LDO_LOW_POWER_ON_SUSPEND) {
+ ret = tps6591x_clr_bits(parent, ri->en1_reg.addr,
+ (1 << ri->en1_reg.shift_bits));
+ reg_val = ri->supply_reg.cache_val;
+ reg_val = (reg_val & ~0x3) | (0x3);
+ ret = tps6591x_write(parent, ri->supply_reg.addr, reg_val);
+ if (ret >= 0)
+ ri->supply_reg.cache_val = reg_val;
+ else
+ dev_err(&pdev->dev, "Error in updating the supply state\n");
+ }
+ return ret;
+}
+
+static int tps6591x_resume(struct platform_device *pdev)
+{
+ struct regulator_dev *rdev = platform_get_drvdata(pdev);
+ struct tps6591x_regulator *ri = rdev_get_drvdata(rdev);
+ struct device *parent = to_tps6591x_dev(rdev);
+ int ret = 0;
+ uint8_t reg_val;
+
+ if (ri->config_flags & LDO_LOW_POWER_ON_SUSPEND) {
+ ret = tps6591x_clr_bits(parent, ri->en1_reg.addr,
+ (1 << ri->en1_reg.shift_bits));
+ reg_val = ri->supply_reg.cache_val;
+ reg_val = (reg_val & ~0x3) | (0x1);
+ ret = tps6591x_write(parent, ri->supply_reg.addr, reg_val);
+ if (ret >= 0)
+ ri->supply_reg.cache_val = reg_val;
+ else
+ dev_err(&pdev->dev, "Error in updating the supply state\n");
+ }
+ return ret;
+}
+
static struct platform_driver tps6591x_regulator_driver = {
.driver = {
.name = "tps6591x-regulator",
@@ -888,6 +934,8 @@ static struct platform_driver tps6591x_regulator_driver = {
.probe = tps6591x_regulator_probe,
.remove = __devexit_p(tps6591x_regulator_remove),
.shutdown = tps6591x_regulator_shutdown,
+ .suspend = tps6591x_suspend,
+ .resume = tps6591x_resume,
};
static int __init tps6591x_regulator_init(void)