U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: John Keeping <john@metanate.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] regulator: fixed: obey startup delay
Date: Mon, 22 Aug 2016 15:10:09 +0100	[thread overview]
Message-ID: <20160822141009.7174-1-john@metanate.com> (raw)

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(+)

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;
 }
 
-- 
2.9.3.728.g30b24b4.dirty

             reply	other threads:[~2016-08-22 14:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22 14:10 John Keeping [this message]
2016-08-22 14:49 ` [U-Boot] [PATCH] regulator: fixed: obey startup delay Tom Rini
2016-08-23  3:34 ` Simon Glass
2016-09-07 17:58 ` [U-Boot] " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160822141009.7174-1-john@metanate.com \
    --to=john@metanate.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox