diff options
-rw-r--r-- | drivers/regulator/lp872x.c | 38 | ||||
-rw-r--r-- | include/linux/regulator/lp872x.h | 14 |
2 files changed, 22 insertions, 30 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; diff --git a/include/linux/regulator/lp872x.h b/include/linux/regulator/lp872x.h index d780dbb8b423..8e7e0343c6e1 100644 --- a/include/linux/regulator/lp872x.h +++ b/include/linux/regulator/lp872x.h @@ -10,7 +10,7 @@ #include <linux/regulator/machine.h> #include <linux/platform_device.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #define LP872X_MAX_REGULATORS 9 @@ -41,8 +41,8 @@ enum lp872x_regulator_id { }; enum lp872x_dvs_state { - DVS_LOW = GPIOF_OUT_INIT_LOW, - DVS_HIGH = GPIOF_OUT_INIT_HIGH, + DVS_LOW = GPIOD_OUT_LOW, + DVS_HIGH = GPIOD_OUT_HIGH, }; enum lp872x_dvs_sel { @@ -52,12 +52,12 @@ enum lp872x_dvs_sel { /** * lp872x_dvs - * @gpio : gpio pin number for dvs control + * @gpio : gpio descriptor for dvs control * @vsel : dvs selector for buck v1 or buck v2 register * @init_state : initial dvs pin state */ struct lp872x_dvs { - int gpio; + struct gpio_desc *gpio; enum lp872x_dvs_sel vsel; enum lp872x_dvs_state init_state; }; @@ -78,14 +78,14 @@ struct lp872x_regulator_data { * @update_config : if LP872X_GENERAL_CFG register is updated, set true * @regulator_data : platform regulator id and init data * @dvs : dvs data for buck voltage control - * @enable_gpio : gpio pin number for enable control + * @enable_gpio : gpio descriptor for enable control */ struct lp872x_platform_data { u8 general_config; bool update_config; struct lp872x_regulator_data regulator_data[LP872X_MAX_REGULATORS]; struct lp872x_dvs *dvs; - int enable_gpio; + struct gpio_desc *enable_gpio; }; #endif |