diff mbox

[U-Boot] regulator: fixed: obey startup delay

Message ID 20160822141009.7174-1-john@metanate.com
State Accepted
Commit 7302fbb31d1ba8b208ae5e400028c692167c7072
Delegated to: Tom Rini
Headers show

Commit Message

John Keeping Aug. 22, 2016, 2:10 p.m. UTC
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>
---
 doc/device-tree-bindings/regulator/fixed.txt |  1 +
 drivers/power/regulator/fixed.c              | 10 ++++++++++
 2 files changed, 11 insertions(+)

Comments

Tom Rini Aug. 22, 2016, 2:49 p.m. UTC | #1
On Mon, Aug 22, 2016 at 03:10:09PM +0100, John Keeping wrote:

> 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>

As this matches the kernel binding:

Reviewed-by: Tom Rini <trini@konsulko.com>
Simon Glass Aug. 23, 2016, 3:34 a.m. UTC | #2
On 22 August 2016 at 08:10, John Keeping <john@metanate.com> wrote:
>
> 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>
> ---
>  doc/device-tree-bindings/regulator/fixed.txt |  1 +
>  drivers/power/regulator/fixed.c              | 10 ++++++++++
>  2 files changed, 11 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Sept. 7, 2016, 5:58 p.m. UTC | #3
On Mon, Aug 22, 2016 at 03:10:09PM +0100, John Keeping wrote:

> 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>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/doc/device-tree-bindings/regulator/fixed.txt b/doc/device-tree-bindings/regulator/fixed.txt
index 4ff39b8..8a0d002 100644
--- a/doc/device-tree-bindings/regulator/fixed.txt
+++ b/doc/device-tree-bindings/regulator/fixed.txt
@@ -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.
diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index d053817..37b8400 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -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;
 }