aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/88pm8607.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@gmail.com>2012-09-21 06:06:52 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-10-02 05:43:13 -0400
commit2e57d56747e601b3e0ff6697e524025d0504d161 (patch)
tree29a7c677878d39f64e90dfbdf7063a11c08d4c15 /drivers/regulator/88pm8607.c
parent837c8293ba24d08cd7438d82ad9bb8d2fb0f8a5b (diff)
mfd: 88pm860x: Device tree support
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/regulator/88pm8607.c')
-rw-r--r--drivers/regulator/88pm8607.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index f96fbe38ff6f..1c5ab0172ea2 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -12,6 +12,8 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/of.h>
16#include <linux/regulator/of_regulator.h>
15#include <linux/platform_device.h> 17#include <linux/platform_device.h>
16#include <linux/regulator/driver.h> 18#include <linux/regulator/driver.h>
17#include <linux/regulator/machine.h> 19#include <linux/regulator/machine.h>
@@ -364,6 +366,34 @@ static struct pm8607_regulator_info pm8606_regulator_info[] = {
364 PM8606_PREG(PREREGULATORB, 5), 366 PM8606_PREG(PREREGULATORB, 5),
365}; 367};
366 368
369#ifdef CONFIG_OF
370static int pm8607_regulator_dt_init(struct platform_device *pdev,
371 struct pm8607_regulator_info *info,
372 struct regulator_config *config)
373{
374 struct device_node *nproot, *np;
375 nproot = pdev->dev.parent->of_node;
376 if (!nproot)
377 return -ENODEV;
378 nproot = of_find_node_by_name(nproot, "regulators");
379 if (!nproot) {
380 dev_err(&pdev->dev, "failed to find regulators node\n");
381 return -ENODEV;
382 }
383 for_each_child_of_node(nproot, np) {
384 if (!of_node_cmp(np->name, info->desc.name)) {
385 config->init_data =
386 of_get_regulator_init_data(&pdev->dev, np);
387 config->of_node = np;
388 break;
389 }
390 }
391 return 0;
392}
393#else
394#define pm8607_regulator_dt_init(x, y, z) (-1)
395#endif
396
367static int __devinit pm8607_regulator_probe(struct platform_device *pdev) 397static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
368{ 398{
369 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 399 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -402,9 +432,12 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
402 info->slope_double = 1; 432 info->slope_double = 1;
403 433
404 config.dev = &pdev->dev; 434 config.dev = &pdev->dev;
405 config.init_data = pdata;
406 config.driver_data = info; 435 config.driver_data = info;
407 436
437 if (pm8607_regulator_dt_init(pdev, info, &config))
438 if (pdata)
439 config.init_data = pdata;
440
408 if (chip->id == CHIP_PM8607) 441 if (chip->id == CHIP_PM8607)
409 config.regmap = chip->regmap; 442 config.regmap = chip->regmap;
410 else 443 else