[U-Boot] [PATCH v3 45/72] dm: regulator: Update fixed regulator to support livetree.

Simon Glass sjg at chromium.org
Fri May 19 02:09:35 UTC 2017


Update this driver to support a live device tree.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v3: None
Changes in v2: None

 drivers/power/regulator/fixed.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index cd5213766d..656371b235 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -7,7 +7,6 @@
  */
 
 #include <common.h>
-#include <fdtdec.h>
 #include <errno.h>
 #include <dm.h>
 #include <i2c.h>
@@ -27,8 +26,7 @@ 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(dev), flags = GPIOD_IS_OUT;
+	int flags = GPIOD_IS_OUT;
 	int ret;
 
 	dev_pdata = dev_get_platdata(dev);
@@ -39,7 +37,7 @@ 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"))
+	if (dev_read_bool(dev, "enable-active-high"))
 		flags |= GPIOD_IS_OUT_ACTIVE;
 
 	/* Get fixed regulator optional enable GPIO desc */
@@ -53,9 +51,8 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
 	}
 
 	/* Get optional ramp up delay */
-	dev_pdata->startup_delay_us = fdtdec_get_uint(gd->fdt_blob,
-						      dev_of_offset(dev),
-						      "startup-delay-us", 0);
+	dev_pdata->startup_delay_us = dev_read_u32_default(dev,
+							"startup-delay-us", 0);
 
 	return 0;
 }
@@ -108,8 +105,11 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable)
 	struct fixed_regulator_platdata *dev_pdata = dev_get_platdata(dev);
 	int ret;
 
+	debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__,
+	      dev->name, enable, dev_pdata->startup_delay_us,
+	      dm_gpio_is_valid(&dev_pdata->gpio));
 	/* Enable GPIO is optional */
-	if (!dev_pdata->gpio.dev) {
+	if (!dm_gpio_is_valid(&dev_pdata->gpio)) {
 		if (!enable)
 			return -ENOSYS;
 		return 0;
@@ -124,6 +124,7 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable)
 
 	if (enable && dev_pdata->startup_delay_us)
 		udelay(dev_pdata->startup_delay_us);
+	debug("%s: done\n", __func__);
 
 	return 0;
 }
-- 
2.13.0.303.g4ebf302169-goog



More information about the U-Boot mailing list