]> git.sur5r.net Git - u-boot/commitdiff
regulator: fixed: obey startup delay
authorJohn Keeping <john@metanate.com>
Mon, 22 Aug 2016 14:10:09 +0000 (15:10 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 6 Sep 2016 17:18:21 +0000 (13:18 -0400)
When enabling a fixed regulator, it may take some time to rise to the
correct voltage.  If we do not delay here then subsequent operations
will fail.

Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
doc/device-tree-bindings/regulator/fixed.txt
drivers/power/regulator/fixed.c

index 4ff39b8f513dbe4405d9fe3310d6d3ec7bae12bc..8a0d002688d81725a6e2a0dbe69bd41f1ff3b909 100644 (file)
@@ -10,6 +10,7 @@ Required properties:
 
 Optional properties:
 - gpio: GPIO to use for enable control
+- startup-delay-us: startup time in microseconds
 - regulator constraints (binding info: regulator.txt)
 
 Other kernel-style properties, are currently not used.
index d053817fc22706b3abe0397adda56861ff34686f..37b8400903fcbbc9c5321603d756001fe31f4cc6 100644 (file)
@@ -19,6 +19,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct fixed_regulator_platdata {
        struct gpio_desc gpio; /* GPIO for regulator enable control */
+       unsigned int startup_delay_us;
 };
 
 static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
@@ -42,6 +43,11 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
        if (ret)
                debug("Fixed regulator gpio - not found! Error: %d", ret);
 
+       /* Get optional ramp up delay */
+       dev_pdata->startup_delay_us = fdtdec_get_uint(gd->fdt_blob,
+                                                     dev->of_offset,
+                                                     "startup-delay-us", 0);
+
        return 0;
 }
 
@@ -101,6 +107,10 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable)
                      enable);
                return ret;
        }
+
+       if (enable && dev_pdata->startup_delay_us)
+               udelay(dev_pdata->startup_delay_us);
+
        return 0;
 }