]> git.sur5r.net Git - u-boot/commitdiff
regulator: fixed: Add support to handle enable-active-high DT property
authorVignesh R <vigneshr@ti.com>
Wed, 7 Dec 2016 11:25:06 +0000 (16:55 +0530)
committerTom Rini <trini@konsulko.com>
Tue, 27 Dec 2016 13:22:57 +0000 (08:22 -0500)
Add support to handle enable-active-high DT property. This property is
used to drive the gpio controlling fixed regulator as active high when
claiming gpio line.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>
doc/device-tree-bindings/regulator/fixed.txt
drivers/power/regulator/fixed.c

index 8a0d002688d81725a6e2a0dbe69bd41f1ff3b909..5fd9033fea2d69a672d01fa0aae449f5a91626f0 100644 (file)
@@ -12,6 +12,9 @@ Optional properties:
 - gpio: GPIO to use for enable control
 - startup-delay-us: startup time in microseconds
 - regulator constraints (binding info: regulator.txt)
+- enable-active-high: Polarity of GPIO is Active high. If this property
+  is missing, the default assumed is Active low.
+
 
 Other kernel-style properties, are currently not used.
 
@@ -36,4 +39,5 @@ fixed_regulator@0 {
        regulator-max-microamp = <15000>;
        regulator-always-on;
        regulator-boot-on;
+       enable-active-high;
 };
index 62dc47f769859210be08d823a6f889055301cc5e..3d2d9081c1b1fbb45d4f2b400bd83c06b0a8f269 100644 (file)
@@ -27,6 +27,8 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
        struct dm_regulator_uclass_platdata *uc_pdata;
        struct fixed_regulator_platdata *dev_pdata;
        struct gpio_desc *gpio;
+       const void *blob = gd->fdt_blob;
+       int node = dev->of_offset, flags = GPIOD_IS_OUT;
        int ret;
 
        dev_pdata = dev_get_platdata(dev);
@@ -37,9 +39,12 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
        /* Set type to fixed */
        uc_pdata->type = REGULATOR_TYPE_FIXED;
 
+       if (fdtdec_get_bool(blob, node, "enable-active-high"))
+               flags |= GPIOD_IS_OUT_ACTIVE;
+
        /* Get fixed regulator optional enable GPIO desc */
        gpio = &dev_pdata->gpio;
-       ret = gpio_request_by_name(dev, "gpio", 0, gpio, GPIOD_IS_OUT);
+       ret = gpio_request_by_name(dev, "gpio", 0, gpio, flags);
        if (ret) {
                debug("Fixed regulator optional enable GPIO - not found! Error: %d\n",
                      ret);