]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
power: pwm regulator: support live tree
authorAndy Yan <andy.yan@rock-chips.com>
Tue, 27 Mar 2018 11:39:38 +0000 (19:39 +0800)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 8 May 2018 04:12:33 +0000 (13:12 +0900)
Use live tree compatible api for pwm regulator.

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/power/regulator/pwm_regulator.c

index f353c38a04da218a72e28377a3a4803187a77321..cd05c9b6035dfd0d41e3bb5d04c2dcb7fea7ffca 100644 (file)
@@ -12,9 +12,6 @@
 #include <errno.h>
 #include <pwm.h>
 #include <power/regulator.h>
-#include <linux/libfdt.h>
-#include <fdt_support.h>
-#include <fdtdec.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -93,13 +90,10 @@ static int pwm_regulator_set_voltage(struct udevice *dev, int uvolt)
 static int pwm_regulator_ofdata_to_platdata(struct udevice *dev)
 {
        struct pwm_regulator_info *priv = dev_get_priv(dev);
-       struct fdtdec_phandle_args args;
-       const void *blob = gd->fdt_blob;
-       int node = dev_of_offset(dev);
+       struct ofnode_phandle_args args;
        int ret;
 
-       ret = fdtdec_parse_phandle_with_args(blob, node, "pwms", "#pwm-cells",
-                                            0, 0, &args);
+       ret = dev_read_phandle_with_args(dev, "pwms", "#pwm-cells", 0, 0, &args);
        if (ret) {
                debug("%s: Cannot get PWM phandle: ret=%d\n", __func__, ret);
                return ret;
@@ -108,14 +102,13 @@ static int pwm_regulator_ofdata_to_platdata(struct udevice *dev)
        priv->period_ns = args.args[1];
        priv->polarity = args.args[2];
 
-       priv->init_voltage = fdtdec_get_int(blob, node,
-                       "regulator-init-microvolt", -1);
+       priv->init_voltage = dev_read_u32_default(dev, "regulator-init-microvolt", -1);
        if (priv->init_voltage < 0) {
                printf("Cannot find regulator pwm init_voltage\n");
                return -EINVAL;
        }
 
-       ret = uclass_get_device_by_of_offset(UCLASS_PWM, args.node, &priv->pwm);
+       ret = uclass_get_device_by_ofnode(UCLASS_PWM, args.node, &priv->pwm);
        if (ret) {
                debug("%s: Cannot get PWM: ret=%d\n", __func__, ret);
                return ret;