regulator: tps51632: add support for GPIO to control rails
Laxman Dewangan [Tue, 6 Aug 2013 09:59:18 +0000 (14:59 +0530)]
The TPS51632 regulator is externally controlled by default and
this can be connected to the GPIO on some system.

Add support to pass the GPIO number to control the rail through
GPIOs.

Change-Id: I602a6a3e5c489b54dc9ead75476429c0d44f76d0
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/258664

drivers/regulator/tps51632-regulator.c
include/linux/regulator/tps51632-regulator.h

index f91ede3..a30e986 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/gpio.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -385,7 +386,13 @@ static int tps51632_probe(struct i2c_client *client,
        config.driver_data = tps;
        config.regmap = tps->regmap;
        config.of_node = client->dev.of_node;
-
+       if (pdata->ena_gpio) {
+               config.ena_gpio = pdata->ena_gpio;
+               config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
+       } else {
+               config.ena_gpio = -EINVAL;
+               config.ena_gpio_flags = 0;
+       }
        rdev = regulator_register(&tps->desc, &config);
        if (IS_ERR(rdev)) {
                dev_err(tps->dev, "regulator register failed\n");
index d00841e..3bd53ba 100644 (file)
@@ -35,6 +35,7 @@
  * @dvfs_step_20mV: Step for DVFS is 20mV or 10mV.
  * @max_voltage_uV: Maximum possible voltage in PWM-DVFS mode.
  * @base_voltage_uV: Base voltage when PWM-DVFS enabled.
+ * @ena_gpio: Enable gpio for the rail.
  */
 struct tps51632_regulator_platform_data {
        struct regulator_init_data *reg_init_data;
@@ -42,6 +43,7 @@ struct tps51632_regulator_platform_data {
        bool dvfs_step_20mV;
        int max_voltage_uV;
        int base_voltage_uV;
+       int ena_gpio;
 };
 
 #endif /* __LINUX_REGULATOR_TPS51632_H */