regulator: pca9450: Add SD_VSEL GPIO for LDO5
[linux-2.6-microblaze.git] / drivers / regulator / pca9450-regulator.c
index cb29421..1bba8fd 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
@@ -32,6 +33,7 @@ struct pca9450_regulator_desc {
 struct pca9450 {
        struct device *dev;
        struct regmap *regmap;
+       struct gpio_desc *sd_vsel_gpio;
        enum pca9450_chip_type type;
        unsigned int rcnt;
        int irq;
@@ -795,6 +797,18 @@ static int pca9450_i2c_probe(struct i2c_client *i2c,
                return ret;
        }
 
+       /*
+        * The driver uses the LDO5CTRL_H register to control the LDO5 regulator.
+        * This is only valid if the SD_VSEL input of the PMIC is high. Let's
+        * check if the pin is available as GPIO and set it to high.
+        */
+       pca9450->sd_vsel_gpio = gpiod_get_optional(pca9450->dev, "sd-vsel", GPIOD_OUT_HIGH);
+
+       if (IS_ERR(pca9450->sd_vsel_gpio)) {
+               dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n");
+               return ret;
+       }
+
        dev_info(&i2c->dev, "%s probed.\n",
                type == PCA9450_TYPE_PCA9450A ? "pca9450a" : "pca9450bc");