]> git.sur5r.net Git - u-boot/blobdiff - drivers/power/regulator/pwm_regulator.c
power: regulator: Add support for stm32-vrefbuf
[u-boot] / drivers / power / regulator / pwm_regulator.c
index a6c9fccd68e7c16c4340e574f0037d098b03603e..f353c38a04da218a72e28377a3a4803187a77321 100644 (file)
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Rockchip Electronics Co., Ltd
  *
  * Based on kernel drivers/regulator/pwm-regulator.c
  * Copyright (C) 2014 - STMicroelectronics Inc.
  * Author: Lee Jones <lee.jones@linaro.org>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -13,7 +12,7 @@
 #include <errno.h>
 #include <pwm.h>
 #include <power/regulator.h>
-#include <libfdt.h>
+#include <linux/libfdt.h>
 #include <fdt_support.h>
 #include <fdtdec.h>
 
@@ -32,13 +31,13 @@ struct pwm_regulator_info {
        bool polarity;
        struct udevice *pwm;
        /* initialize voltage of regulator */
-       unsigned int init_voltage;
+       int init_voltage;
        /* the maximum voltage of regulator */
-       unsigned int max_voltage;
+       int max_voltage;
        /* the minimum voltage of regulator */
-       unsigned int min_voltage;
+       int min_voltage;
        /* the current voltage of regulator */
-       unsigned int volt_uV;
+       int volt_uV;
 };
 
 static int pwm_regulator_enable(struct udevice *dev, bool enable)
@@ -80,18 +79,14 @@ static int pwm_regulator_set_voltage(struct udevice *dev, int uvolt)
        }
 
        ret = pwm_set_config(priv->pwm, priv->pwm_id,
-                       (priv->period_ns / 100) * duty_cycle, priv->period_ns);
+                       priv->period_ns, (priv->period_ns / 100) * duty_cycle);
        if (ret) {
                dev_err(dev, "Failed to configure PWM\n");
                return ret;
        }
 
-       ret = pwm_set_enable(priv->pwm, priv->pwm_id, true);
-       if (ret) {
-               dev_err(dev, "Failed to enable PWM\n");
-               return ret;
-       }
        priv->volt_uV = uvolt;
+
        return ret;
 }
 
@@ -144,8 +139,6 @@ static int pwm_regulator_probe(struct udevice *dev)
        if (priv->init_voltage)
                pwm_regulator_set_voltage(dev, priv->init_voltage);
 
-       pwm_regulator_enable(dev, 1);
-
        return 0;
 }