]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: regulator: Update fixed regulator to support livetree.
authorSimon Glass <sjg@chromium.org>
Fri, 19 May 2017 02:09:35 +0000 (20:09 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 1 Jun 2017 13:03:13 +0000 (07:03 -0600)
Update this driver to support a live device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/power/regulator/fixed.c

index cd5213766dc8707a6fe4a637a4f965a263d27a05..656371b2351955cb35791ecdc3550a35309f9d03 100644 (file)
@@ -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;
 }