summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2011-10-19 13:48:34 +0530
committerSimone Willett <swillett@nvidia.com>2011-10-21 14:05:04 -0700
commita096a68b3385661d6613fce45f9f82d8e86661ac (patch)
treea2d866b9f8b94960995fa1fe32cc2fcc4f65f3b5 /drivers
parentd96b951a491b91d8aa0fd6faf0c54c640ac7da6c (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 Change-Id: I50756a13d9b8ff0bb79fe40a6349452a261be54a Reviewed-on: http://git-master/r/58956 Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com> Tested-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Diffstat (limited to 'drivers')
-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 87689d70fafa..f91096af10b9 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)
@@ -804,6 +805,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;
@@ -859,6 +861,50 @@ static void tps6591x_regulator_shutdown(struct platform_device *pdev)
}
}
+static int tps6591x_suspend(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) | (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",
@@ -867,6 +913,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)