regulator: wm8994: Pass descriptor instead of GPIO number
Instead of passing a global GPIO number for the enable GPIO, pass
a descriptor looked up from the device tree node or the board file
decriptor table for the regulator.
There is a single board file passing the GPIOs for LDO1 and LDO2
through platform data, so augment this to pass descriptors
associated with the i2c device as well.
The special GPIO enable DT property for the enable GPIO is
nonstandard but this was accomodated in
commit 6a537d4846
"gpio: of: Support regulator nonstandard GPIO properties".
Cc: patches@opensource.cirrus.com
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cette révision appartient à :

révisé par
Mark Brown

Parent
1c984942f0
révision
1d2f46814d
@@ -19,7 +19,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/regulator/driver.h>
|
||||
#include <linux/regulator/machine.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <linux/mfd/wm8994/core.h>
|
||||
@@ -129,6 +129,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
|
||||
int id = pdev->id % ARRAY_SIZE(pdata->ldo);
|
||||
struct regulator_config config = { };
|
||||
struct wm8994_ldo *ldo;
|
||||
struct gpio_desc *gpiod;
|
||||
int ret;
|
||||
|
||||
dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
|
||||
@@ -145,12 +146,15 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
|
||||
config.driver_data = ldo;
|
||||
config.regmap = wm8994->regmap;
|
||||
config.init_data = &ldo->init_data;
|
||||
if (pdata) {
|
||||
config.ena_gpio = pdata->ldo[id].enable;
|
||||
} else if (wm8994->dev->of_node) {
|
||||
config.ena_gpio = wm8994->pdata.ldo[id].enable;
|
||||
config.ena_gpio_initialized = true;
|
||||
}
|
||||
|
||||
/* Look up LDO enable GPIO from the parent device node */
|
||||
gpiod = devm_gpiod_get_optional(pdev->dev.parent,
|
||||
id ? "wlf,ldo2ena" : "wlf,ldo1ena",
|
||||
GPIOD_OUT_LOW |
|
||||
GPIOD_FLAGS_BIT_NONEXCLUSIVE);
|
||||
if (IS_ERR(gpiod))
|
||||
return PTR_ERR(gpiod);
|
||||
config.ena_gpiod = gpiod;
|
||||
|
||||
/* Use default constraints if none set up */
|
||||
if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) {
|
||||
@@ -159,7 +163,7 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
|
||||
|
||||
ldo->init_data = wm8994_ldo_default[id];
|
||||
ldo->init_data.consumer_supplies = &ldo->supply;
|
||||
if (!config.ena_gpio)
|
||||
if (!gpiod)
|
||||
ldo->init_data.constraints.valid_ops_mask = 0;
|
||||
} else {
|
||||
ldo->init_data = *pdata->ldo[id].init_data;
|
||||
|
Référencer dans un nouveau ticket
Bloquer un utilisateur