aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2014-04-16 05:01:41 -0400
committerMark Brown <broonie@linaro.org>2014-04-18 13:34:49 -0400
commit36bcdf1bb6a16d58f8d60549502fd1da6b27a81a (patch)
treea6d5f3457d9677b2ea8197bac63e7567a27cca67
parente4fcb1d6148284a10c314fce2a488cf19ce886f6 (diff)
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>
-rw-r--r--drivers/regulator/arizona-micsupp.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 6fdd9bf6927f..b80ebbe88bac 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -19,6 +19,7 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h> 20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
22#include <linux/regulator/of_regulator.h>
22#include <linux/gpio.h> 23#include <linux/gpio.h>
23#include <linux/slab.h> 24#include <linux/slab.h>
24#include <linux/workqueue.h> 25#include <linux/workqueue.h>
@@ -195,6 +196,32 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
195 .num_consumer_supplies = 1, 196 .num_consumer_supplies = 1,
196}; 197};
197 198
199static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
200 struct regulator_config *config)
201{
202 struct arizona_pdata *pdata = &arizona->pdata;
203 struct arizona_micsupp *micsupp = config->driver_data;
204 struct device_node *np;
205 struct regulator_init_data *init_data;
206
207 np = of_get_child_by_name(arizona->dev->of_node, "micvdd");
208
209 if (np) {
210 config->of_node = np;
211
212 init_data = of_get_regulator_init_data(arizona->dev, np);
213
214 if (init_data) {
215 init_data->consumer_supplies = &micsupp->supply;
216 init_data->num_consumer_supplies = 1;
217
218 pdata->micvdd = init_data;
219 }
220 }
221
222 return 0;
223}
224
198static int arizona_micsupp_probe(struct platform_device *pdev) 225static int arizona_micsupp_probe(struct platform_device *pdev)
199{ 226{
200 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 227 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
@@ -234,6 +261,14 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
234 config.driver_data = micsupp; 261 config.driver_data = micsupp;
235 config.regmap = arizona->regmap; 262 config.regmap = arizona->regmap;
236 263
264 if (IS_ENABLED(CONFIG_OF)) {
265 if (!dev_get_platdata(arizona->dev)) {
266 ret = arizona_micsupp_of_get_pdata(arizona, &config);
267 if (ret < 0)
268 return ret;
269 }
270 }
271
237 if (arizona->pdata.micvdd) 272 if (arizona->pdata.micvdd)
238 config.init_data = arizona->pdata.micvdd; 273 config.init_data = arizona->pdata.micvdd;
239 else 274 else
@@ -253,6 +288,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
253 return ret; 288 return ret;
254 } 289 }
255 290
291 of_node_put(config.of_node);
292
256 platform_set_drvdata(pdev, micsupp); 293 platform_set_drvdata(pdev, micsupp);
257 294
258 return 0; 295 return 0;