Skip to content
Snippets Groups Projects
Commit e1fd9e6b authored by Andy Yan's avatar Andy Yan Committed by Jaehoon Chung
Browse files

power: pwm regulator: support live tree


Use live tree compatible api for pwm regulator.

Signed-off-by: default avatarAndy Yan <andy.yan@rock-chips.com>
Reviewed-by: default avatarKever Yang <kever.yang@rock-chips.com>
parent 55118ec9
No related branches found
No related tags found
No related merge requests found
...@@ -12,9 +12,6 @@ ...@@ -12,9 +12,6 @@
#include <errno.h> #include <errno.h>
#include <pwm.h> #include <pwm.h>
#include <power/regulator.h> #include <power/regulator.h>
#include <linux/libfdt.h>
#include <fdt_support.h>
#include <fdtdec.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -93,13 +90,10 @@ static int pwm_regulator_set_voltage(struct udevice *dev, int uvolt) ...@@ -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) static int pwm_regulator_ofdata_to_platdata(struct udevice *dev)
{ {
struct pwm_regulator_info *priv = dev_get_priv(dev); struct pwm_regulator_info *priv = dev_get_priv(dev);
struct fdtdec_phandle_args args; struct ofnode_phandle_args args;
const void *blob = gd->fdt_blob;
int node = dev_of_offset(dev);
int ret; int ret;
ret = fdtdec_parse_phandle_with_args(blob, node, "pwms", "#pwm-cells", ret = dev_read_phandle_with_args(dev, "pwms", "#pwm-cells", 0, 0, &args);
0, 0, &args);
if (ret) { if (ret) {
debug("%s: Cannot get PWM phandle: ret=%d\n", __func__, ret); debug("%s: Cannot get PWM phandle: ret=%d\n", __func__, ret);
return ret; return ret;
...@@ -108,14 +102,13 @@ static int pwm_regulator_ofdata_to_platdata(struct udevice *dev) ...@@ -108,14 +102,13 @@ static int pwm_regulator_ofdata_to_platdata(struct udevice *dev)
priv->period_ns = args.args[1]; priv->period_ns = args.args[1];
priv->polarity = args.args[2]; priv->polarity = args.args[2];
priv->init_voltage = fdtdec_get_int(blob, node, priv->init_voltage = dev_read_u32_default(dev, "regulator-init-microvolt", -1);
"regulator-init-microvolt", -1);
if (priv->init_voltage < 0) { if (priv->init_voltage < 0) {
printf("Cannot find regulator pwm init_voltage\n"); printf("Cannot find regulator pwm init_voltage\n");
return -EINVAL; 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) { if (ret) {
debug("%s: Cannot get PWM: ret=%d\n", __func__, ret); debug("%s: Cannot get PWM: ret=%d\n", __func__, ret);
return ret; return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment