From: Simon Glass Date: Fri, 19 May 2017 02:09:35 +0000 (-0600) Subject: dm: regulator: Update fixed regulator to support livetree. X-Git-Tag: v2017.07-rc1~123 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a5493f828ee5392697628a767d9f2c7d4e9d3628;p=oweals%2Fu-boot.git dm: regulator: Update fixed regulator to support livetree. Update this driver to support a live device tree. Signed-off-by: Simon Glass --- 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 -#include #include #include #include @@ -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; }