aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@marvell.com>2011-03-07 10:43:11 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2011-03-23 05:42:06 -0400
commit22aad0011e4728a29bf3775b6f5e2f9677abd8c0 (patch)
tree5553cb04e439928218906e7072b620095e5e4ee3 /drivers/regulator
parent3154c344696e58b7e15317cd624816dbe3832ad1 (diff)
mfd: Adopt mfd_data in 88pm860x regulator
Copy 88pm860x platform data into different mfd_data structure for regulator driver. So move the identification of device node from regulator driver to mfd driver. Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/88pm8607.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index dd6308499bd4..859251250b55 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -15,6 +15,7 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h> 16#include <linux/regulator/driver.h>
17#include <linux/regulator/machine.h> 17#include <linux/regulator/machine.h>
18#include <linux/mfd/core.h>
18#include <linux/mfd/88pm860x.h> 19#include <linux/mfd/88pm860x.h>
19 20
20struct pm8607_regulator_info { 21struct pm8607_regulator_info {
@@ -394,47 +395,48 @@ static struct pm8607_regulator_info pm8607_regulator_info[] = {
394 PM8607_LDO(14, LDO14, 0, 4, SUPPLIES_EN12, 6), 395 PM8607_LDO(14, LDO14, 0, 4, SUPPLIES_EN12, 6),
395}; 396};
396 397
397static inline struct pm8607_regulator_info *find_regulator_info(int id) 398static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
398{ 399{
399 struct pm8607_regulator_info *info; 400 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
401 struct pm8607_regulator_info *info = NULL;
402 struct regulator_init_data *pdata;
403 struct mfd_cell *cell;
400 int i; 404 int i;
401 405
406 cell = pdev->dev.platform_data;
407 if (cell == NULL)
408 return -ENODEV;
409 pdata = cell->mfd_data;
410 if (pdata == NULL)
411 return -EINVAL;
412
402 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) { 413 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
403 info = &pm8607_regulator_info[i]; 414 info = &pm8607_regulator_info[i];
404 if (info->desc.id == id) 415 if (!strcmp(info->desc.name, pdata->constraints.name))
405 return info; 416 break;
406 } 417 }
407 return NULL; 418 if (i > ARRAY_SIZE(pm8607_regulator_info)) {
408} 419 dev_err(&pdev->dev, "Failed to find regulator %s\n",
409 420 pdata->constraints.name);
410static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
411{
412 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
413 struct pm860x_platform_data *pdata = chip->dev->platform_data;
414 struct pm8607_regulator_info *info = NULL;
415
416 info = find_regulator_info(pdev->id);
417 if (info == NULL) {
418 dev_err(&pdev->dev, "invalid regulator ID specified\n");
419 return -EINVAL; 421 return -EINVAL;
420 } 422 }
421 423
422 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; 424 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
423 info->chip = chip; 425 info->chip = chip;
424 426
427 /* check DVC ramp slope double */
428 if (!strcmp(info->desc.name, "BUCK3"))
429 if (info->chip->buck3_double)
430 info->slope_double = 1;
431
425 info->regulator = regulator_register(&info->desc, &pdev->dev, 432 info->regulator = regulator_register(&info->desc, &pdev->dev,
426 pdata->regulator[pdev->id], info); 433 pdata, info);
427 if (IS_ERR(info->regulator)) { 434 if (IS_ERR(info->regulator)) {
428 dev_err(&pdev->dev, "failed to register regulator %s\n", 435 dev_err(&pdev->dev, "failed to register regulator %s\n",
429 info->desc.name); 436 info->desc.name);
430 return PTR_ERR(info->regulator); 437 return PTR_ERR(info->regulator);
431 } 438 }
432 439
433 /* check DVC ramp slope double */
434 if (info->desc.id == PM8607_ID_BUCK3)
435 if (info->chip->buck3_double)
436 info->slope_double = 1;
437
438 platform_set_drvdata(pdev, info); 440 platform_set_drvdata(pdev, info);
439 return 0; 441 return 0;
440} 442}