summaryrefslogtreecommitdiff
path: root/drivers/regulator/tps6591x-regulator.c
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2011-02-10 16:14:46 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:43:11 -0800
commit933e339fc6259cb3b8460a75b59c32c351382f80 (patch)
tree6fce5021981b5d33e9f6bde31aafa6aaf27b2715 /drivers/regulator/tps6591x-regulator.c
parent528ea9a404ad63e726bb3f72ce2f1d28e1906b18 (diff)
regulator: tps6591x: supporting init state of output through board
Supporting init state of the output power rails from tps6591x through board files to enable/disable and setting required voltage level. Original-Change-Id: Ifdf3c4fea889c1fed465db0bdb39df079bf1afa8 Reviewed-on: http://git-master/r/19061 Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com> Tested-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Hanumanth Venkateswa Moganty <vmoganty@nvidia.com> Original-Change-Id: I198d471ab98aa5bff125b77ccfa99c9104a86426 Rebase-Id: R2199888f87cb319ab257d5aad832bec5496fb64e
Diffstat (limited to 'drivers/regulator/tps6591x-regulator.c')
-rwxr-xr-xdrivers/regulator/tps6591x-regulator.c72
1 files changed, 68 insertions, 4 deletions
diff --git a/drivers/regulator/tps6591x-regulator.c b/drivers/regulator/tps6591x-regulator.c
index 89fcbf9301e9..6931d92ee27f 100755
--- a/drivers/regulator/tps6591x-regulator.c
+++ b/drivers/regulator/tps6591x-regulator.c
@@ -28,6 +28,7 @@
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
+#include <linux/regulator/tps6591x-regulator.h>
#include <linux/mfd/tps6591x.h>
/* supply control and voltage setting */
@@ -513,9 +514,70 @@ static struct tps6591x_regulator tps6591x_regulator[] = {
};
static inline int tps6591x_regulator_preinit(struct device *parent,
- struct tps6591x_regulator *ri)
+ struct tps6591x_regulator *ri,
+ struct tps6591x_regulator_platform_data *tps6591x_pdata)
{
- return tps6591x_set_bits(parent, ri->supply_reg.addr, 0x1);
+ int ret;
+
+ if (!tps6591x_pdata->init_apply)
+ return 0;
+
+ if (tps6591x_pdata->init_uV >= 0) {
+ switch (ri->desc.id) {
+ case TPS6591X_ID_VIO:
+ ret = __tps6591x_vio_set_voltage(parent, ri,
+ tps6591x_pdata->init_uV,
+ tps6591x_pdata->init_uV);
+ break;
+
+ case TPS6591X_ID_LDO_1:
+ case TPS6591X_ID_LDO_2:
+ case TPS6591X_ID_LDO_4:
+ ret = __tps6591x_ldo1_set_voltage(parent, ri,
+ tps6591x_pdata->init_uV,
+ tps6591x_pdata->init_uV);
+ break;
+
+ case TPS6591X_ID_LDO_3:
+ case TPS6591X_ID_LDO_5:
+ case TPS6591X_ID_LDO_6:
+ case TPS6591X_ID_LDO_7:
+ case TPS6591X_ID_LDO_8:
+ ret = __tps6591x_ldo3_set_voltage(parent, ri,
+ tps6591x_pdata->init_uV,
+ tps6591x_pdata->init_uV);
+ break;
+
+ case TPS6591X_ID_VDD_1:
+ case TPS6591X_ID_VDD_2:
+ case TPS6591X_ID_VDDCTRL:
+ ret = __tps6591x_vdd_set_voltage(parent, ri,
+ tps6591x_pdata->init_uV,
+ tps6591x_pdata->init_uV);
+ break;
+
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ if (ret < 0) {
+ pr_err("Not able to initialize voltage %d for rail "
+ "%d err %d\n", tps6591x_pdata->init_uV,
+ ri->desc.id, ret);
+ return ret;
+ }
+ }
+
+ if (tps6591x_pdata->init_enable)
+ ret = tps6591x_set_bits(parent, ri->supply_reg.addr, 0x1);
+ else
+ ret = tps6591x_clr_bits(parent, ri->supply_reg.addr, 0x1);
+
+ if (ret < 0)
+ pr_err("Not able to %s rail %d err %d\n",
+ (tps6591x_pdata->init_enable) ? "enable" : "disable",
+ ri->desc.id, ret);
+ return ret;
}
static inline struct tps6591x_regulator *find_regulator_info(int id)
@@ -535,6 +597,7 @@ static int __devinit tps6591x_regulator_probe(struct platform_device *pdev)
{
struct tps6591x_regulator *ri = NULL;
struct regulator_dev *rdev;
+ struct tps6591x_regulator_platform_data *tps_pdata;
int id = pdev->id;
int err;
@@ -545,13 +608,14 @@ static int __devinit tps6591x_regulator_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "invalid regulator ID specified\n");
return -EINVAL;
}
+ tps_pdata = pdev->dev.platform_data;
- err = tps6591x_regulator_preinit(pdev->dev.parent, ri);
+ err = tps6591x_regulator_preinit(pdev->dev.parent, ri, tps_pdata);
if (err)
return err;
rdev = regulator_register(&ri->desc, &pdev->dev,
- pdev->dev.platform_data, ri);
+ &tps_pdata->regulator, ri);
if (IS_ERR_OR_NULL(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
ri->desc.name);