regulator: arizona-ldo1: Add processing of init_data from device tree

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
Charles Keepax 2014-04-16 10:01:39 +01:00 коммит произвёл Mark Brown
Родитель 4a8c475f5f
Коммит 2cce4be9e6
1 изменённых файлов: 32 добавлений и 2 удалений

Просмотреть файл

@ -19,6 +19,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/slab.h> #include <linux/slab.h>
@ -178,12 +179,39 @@ static const struct regulator_init_data arizona_ldo1_default = {
.num_consumer_supplies = 1, .num_consumer_supplies = 1,
}; };
static int arizona_ldo1_of_get_pdata(struct arizona *arizona) static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
struct regulator_config *config)
{ {
struct arizona_pdata *pdata = &arizona->pdata; struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_ldo1 *ldo1 = config->driver_data;
struct device_node *init_node, *dcvdd_node;
struct regulator_init_data *init_data;
pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true); pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);
init_node = of_get_child_by_name(arizona->dev->of_node, "ldo1");
dcvdd_node = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0);
if (init_node) {
config->of_node = init_node;
init_data = of_get_regulator_init_data(arizona->dev, init_node);
if (init_data) {
init_data->consumer_supplies = &ldo1->supply;
init_data->num_consumer_supplies = 1;
if (dcvdd_node && dcvdd_node != init_node)
arizona->external_dcvdd = true;
pdata->ldo1 = init_data;
}
} else if (dcvdd_node) {
arizona->external_dcvdd = true;
}
of_node_put(dcvdd_node);
return 0; return 0;
} }
@ -230,7 +258,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
if (IS_ENABLED(CONFIG_OF)) { if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) { if (!dev_get_platdata(arizona->dev)) {
ret = arizona_ldo1_of_get_pdata(arizona); ret = arizona_ldo1_of_get_pdata(arizona, &config);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
@ -258,6 +286,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
return ret; return ret;
} }
of_node_put(config.of_node);
platform_set_drvdata(pdev, ldo1); platform_set_drvdata(pdev, ldo1);
return 0; return 0;