summaryrefslogtreecommitdiff
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
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
-rwxr-xr-xdrivers/regulator/tps6591x-regulator.c72
-rw-r--r--include/linux/regulator/tps6591x-regulator.h45
2 files changed, 113 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);
diff --git a/include/linux/regulator/tps6591x-regulator.h b/include/linux/regulator/tps6591x-regulator.h
new file mode 100644
index 000000000000..ade9978b3cb6
--- /dev/null
+++ b/include/linux/regulator/tps6591x-regulator.h
@@ -0,0 +1,45 @@
+/*
+ * include/linux/regulator/tps6591x-regulator.h
+ *
+ * Interface for regulator driver for TI TPS6591x PMIC family
+ *
+ * Copyright (C) 2011 NVIDIA Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __REGULATOR_TPS6591X_H
+#define __REGULATOR_TPS6591X_H
+
+#include <linux/regulator/machine.h>
+
+/*
+ * struct tps6591x_regulator_platform_data - tps6591x regulator platform data.
+ *
+ * @regulator: The regulator init data.
+ * @init_uV: initial micro volts which need to be set.
+ * @init_enable: Enable or do not enable the rails during initialization.
+ * @init_apply: Init parameter applied or not.
+ */
+
+struct tps6591x_regulator_platform_data {
+ struct regulator_init_data regulator;
+ int init_uV;
+ unsigned init_enable:1;
+ unsigned init_apply:1;
+};
+
+#endif /* __REGULATOR_TPS6591X_H */