diff options
Diffstat (limited to 'drivers/regulator/lp872x.c')
-rw-r--r-- | drivers/regulator/lp872x.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index e84be29533f4..1dba5dbcd461 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c @@ -10,13 +10,12 @@ #include <linux/i2c.h> #include <linux/regmap.h> #include <linux/err.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/regulator/lp872x.h> #include <linux/regulator/driver.h> #include <linux/platform_device.h> #include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/regulator/of_regulator.h> /* Registers : LP8720/8725 shared */ @@ -250,12 +249,12 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev) } static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel, - int gpio) + struct gpio_desc *gpio) { enum lp872x_dvs_state state; state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW; - gpio_set_value(gpio, state); + gpiod_set_value(gpio, state); lp->dvs_pin = state; } @@ -321,7 +320,7 @@ static int lp872x_buck_set_voltage_sel(struct regulator_dev *rdev, u8 addr, mask = LP872X_VOUT_M; struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; - if (dvs && gpio_is_valid(dvs->gpio)) + if (dvs && dvs->gpio) lp872x_set_dvs(lp, dvs->vsel, dvs->gpio); addr = lp872x_select_buck_vout_addr(lp, buck); @@ -675,7 +674,6 @@ static const struct regulator_desc lp8725_regulator_desc[] = { static int lp872x_init_dvs(struct lp872x *lp) { - int ret, gpio; struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; enum lp872x_dvs_state pinstate; u8 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M }; @@ -684,15 +682,15 @@ static int lp872x_init_dvs(struct lp872x *lp) if (!dvs) goto set_default_dvs_mode; - gpio = dvs->gpio; - if (!gpio_is_valid(gpio)) + if (!dvs->gpio) goto set_default_dvs_mode; pinstate = dvs->init_state; - ret = devm_gpio_request_one(lp->dev, gpio, pinstate, "LP872X DVS"); - if (ret) { - dev_err(lp->dev, "gpio request err: %d\n", ret); - return ret; + dvs->gpio = devm_gpiod_get_optional(lp->dev, "ti,dvs", pinstate); + + if (IS_ERR(dvs->gpio)) { + dev_err(lp->dev, "gpio request err: %ld\n", PTR_ERR(dvs->gpio)); + return PTR_ERR(dvs->gpio); } lp->dvs_pin = pinstate; @@ -706,20 +704,17 @@ set_default_dvs_mode: static int lp872x_hw_enable(struct lp872x *lp) { - int ret, gpio; - if (!lp->pdata) return -EINVAL; - gpio = lp->pdata->enable_gpio; - if (!gpio_is_valid(gpio)) + if (!lp->pdata->enable_gpio) return 0; /* Always set enable GPIO high. */ - ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X EN"); - if (ret) { - dev_err(lp->dev, "gpio request err: %d\n", ret); - return ret; + lp->pdata->enable_gpio = devm_gpiod_get_optional(lp->dev, "enable", GPIOD_OUT_HIGH); + if (IS_ERR(lp->pdata->enable_gpio)) { + dev_err(lp->dev, "gpio request err: %ld\n", PTR_ERR(lp->pdata->enable_gpio)); + return PTR_ERR(lp->pdata->enable_gpio); } /* Each chip has a different enable delay. */ @@ -844,13 +839,10 @@ static struct lp872x_platform_data if (!pdata->dvs) return ERR_PTR(-ENOMEM); - pdata->dvs->gpio = of_get_named_gpio(np, "ti,dvs-gpio", 0); of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); of_property_read_u8(np, "ti,dvs-state", &dvs_state); pdata->dvs->init_state = dvs_state ? DVS_HIGH : DVS_LOW; - pdata->enable_gpio = of_get_named_gpio(np, "enable-gpios", 0); - if (of_get_child_count(np) == 0) goto out; |