aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-06-07 12:11:27 -0400
committerMark Brown <broonielinaro.org>2013-06-11 07:50:00 -0400
commit30aa4b26c00f5c5ae6081f85e7adca47dcb24e29 (patch)
tree9eb7873d961c2dca6f2ac926fd2cef2835e63aba
parent5a49b4a527e5b72ae3a4f64f078759f83fbd98b5 (diff)
regulator: ab8500-ext: Enable for Device Tree
Here we use the OF regulator match facility to collect and populate initialisation data from Device Tree if we're booting with it enabled. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Mark Brown <broonielinaro.org>
-rw-r--r--drivers/regulator/ab8500-ext.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c
index 95f495f51d00..4137a2fe42c3 100644
--- a/drivers/regulator/ab8500-ext.c
+++ b/drivers/regulator/ab8500-ext.c
@@ -16,9 +16,11 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/of.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
20#include <linux/regulator/driver.h> 21#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h> 22#include <linux/regulator/machine.h>
23#include <linux/regulator/of_regulator.h>
22#include <linux/mfd/abx500.h> 24#include <linux/mfd/abx500.h>
23#include <linux/mfd/abx500/ab8500.h> 25#include <linux/mfd/abx500/ab8500.h>
24#include <linux/regulator/ab8500.h> 26#include <linux/regulator/ab8500.h>
@@ -333,18 +335,37 @@ static struct ab8500_ext_regulator_info
333 }, 335 },
334}; 336};
335 337
338static struct of_regulator_match ab8500_ext_regulator_match[] = {
339 { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, },
340 { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, },
341 { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, },
342};
343
336int ab8500_ext_regulator_probe(struct platform_device *pdev) 344int ab8500_ext_regulator_probe(struct platform_device *pdev)
337{ 345{
338 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); 346 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
339 struct ab8500_platform_data *ppdata; 347 struct ab8500_platform_data *ppdata;
340 struct ab8500_regulator_platform_data *pdata; 348 struct ab8500_regulator_platform_data *pdata;
349 struct device_node *np = pdev->dev.of_node;
341 struct regulator_config config = { }; 350 struct regulator_config config = { };
342 int i, err; 351 int i, err;
343 352
353 if (np) {
354 err = of_regulator_match(&pdev->dev, np,
355 ab8500_ext_regulator_match,
356 ARRAY_SIZE(ab8500_ext_regulator_match));
357 if (err < 0) {
358 dev_err(&pdev->dev,
359 "Error parsing regulator init data: %d\n", err);
360 return err;
361 }
362 }
363
344 if (!ab8500) { 364 if (!ab8500) {
345 dev_err(&pdev->dev, "null mfd parent\n"); 365 dev_err(&pdev->dev, "null mfd parent\n");
346 return -EINVAL; 366 return -EINVAL;
347 } 367 }
368
348 ppdata = dev_get_platdata(ab8500->dev); 369 ppdata = dev_get_platdata(ab8500->dev);
349 if (!ppdata) { 370 if (!ppdata) {
350 dev_err(&pdev->dev, "null parent pdata\n"); 371 dev_err(&pdev->dev, "null parent pdata\n");
@@ -385,8 +406,11 @@ int ab8500_ext_regulator_probe(struct platform_device *pdev)
385 pdata->ext_regulator[i].driver_data; 406 pdata->ext_regulator[i].driver_data;
386 407
387 config.dev = &pdev->dev; 408 config.dev = &pdev->dev;
388 config.init_data = &pdata->ext_regulator[i];
389 config.driver_data = info; 409 config.driver_data = info;
410 config.of_node = ab8500_ext_regulator_match[i].of_node;
411 config.init_data = (np) ?
412 ab8500_ext_regulator_match[i].init_data :
413 &pdata->ext_regulator[i];
390 414
391 /* register regulator with framework */ 415 /* register regulator with framework */
392 info->rdev = regulator_register(&info->desc, &config); 416 info->rdev = regulator_register(&info->desc, &config);