mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 16:41:58 +00:00
regulator: arizona-micsupp: 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:
parent
e4fcb1d614
commit
36bcdf1bb6
@ -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>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
@ -195,6 +196,32 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
|
|||||||
.num_consumer_supplies = 1,
|
.num_consumer_supplies = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
|
||||||
|
struct regulator_config *config)
|
||||||
|
{
|
||||||
|
struct arizona_pdata *pdata = &arizona->pdata;
|
||||||
|
struct arizona_micsupp *micsupp = config->driver_data;
|
||||||
|
struct device_node *np;
|
||||||
|
struct regulator_init_data *init_data;
|
||||||
|
|
||||||
|
np = of_get_child_by_name(arizona->dev->of_node, "micvdd");
|
||||||
|
|
||||||
|
if (np) {
|
||||||
|
config->of_node = np;
|
||||||
|
|
||||||
|
init_data = of_get_regulator_init_data(arizona->dev, np);
|
||||||
|
|
||||||
|
if (init_data) {
|
||||||
|
init_data->consumer_supplies = &micsupp->supply;
|
||||||
|
init_data->num_consumer_supplies = 1;
|
||||||
|
|
||||||
|
pdata->micvdd = init_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int arizona_micsupp_probe(struct platform_device *pdev)
|
static int arizona_micsupp_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
|
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
|
||||||
@ -234,6 +261,14 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
|
|||||||
config.driver_data = micsupp;
|
config.driver_data = micsupp;
|
||||||
config.regmap = arizona->regmap;
|
config.regmap = arizona->regmap;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_OF)) {
|
||||||
|
if (!dev_get_platdata(arizona->dev)) {
|
||||||
|
ret = arizona_micsupp_of_get_pdata(arizona, &config);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (arizona->pdata.micvdd)
|
if (arizona->pdata.micvdd)
|
||||||
config.init_data = arizona->pdata.micvdd;
|
config.init_data = arizona->pdata.micvdd;
|
||||||
else
|
else
|
||||||
@ -253,6 +288,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
of_node_put(config.of_node);
|
||||||
|
|
||||||
platform_set_drvdata(pdev, micsupp);
|
platform_set_drvdata(pdev, micsupp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user