diff options
author | Lee Jones <lee.jones@linaro.org> | 2012-05-18 04:39:06 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-18 11:38:00 -0400 |
commit | 1bdd670a32a5728502887a5f7e49aae081abdb4b (patch) | |
tree | 4fd9f2ca0199fa26b933f371635cc267182ccb6e /drivers/regulator/db8500-prcmu.c | |
parent | 8986cf8852f16774896fd7b48ec44fa68d29991f (diff) |
regulator: Enable Device Tree for the db8500-prcmu regulator driver
Here we use the previous regulator register code separated from probe to
register each of the regulators mentioned in Device Tree.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/db8500-prcmu.c')
-rw-r--r-- | drivers/regulator/db8500-prcmu.c | 76 |
1 files changed, 69 insertions, 7 deletions
diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c index d6b4d4ce1051..968f97f3cb3d 100644 --- a/drivers/regulator/db8500-prcmu.c +++ b/drivers/regulator/db8500-prcmu.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/regulator/driver.h> | 17 | #include <linux/regulator/driver.h> |
18 | #include <linux/regulator/machine.h> | 18 | #include <linux/regulator/machine.h> |
19 | #include <linux/regulator/db8500-prcmu.h> | 19 | #include <linux/regulator/db8500-prcmu.h> |
20 | #include <linux/regulator/of_regulator.h> | ||
21 | #include <linux/of.h> | ||
20 | #include <linux/module.h> | 22 | #include <linux/module.h> |
21 | #include "dbx500-prcmu.h" | 23 | #include "dbx500-prcmu.h" |
22 | 24 | ||
@@ -449,23 +451,77 @@ static __devinit int db8500_regulator_register(struct platform_device *pdev, | |||
449 | return 0; | 451 | return 0; |
450 | } | 452 | } |
451 | 453 | ||
454 | static struct of_regulator_match db8500_regulator_matches[] = { | ||
455 | { .name = "db8500-vape", .driver_data = (void *) DB8500_REGULATOR_VAPE, }, | ||
456 | { .name = "db8500-varm", .driver_data = (void *) DB8500_REGULATOR_VARM, }, | ||
457 | { .name = "db8500-vmodem", .driver_data = (void *) DB8500_REGULATOR_VMODEM, }, | ||
458 | { .name = "db8500-vpll", .driver_data = (void *) DB8500_REGULATOR_VPLL, }, | ||
459 | { .name = "db8500-vsmps1", .driver_data = (void *) DB8500_REGULATOR_VSMPS1, }, | ||
460 | { .name = "db8500-vsmps2", .driver_data = (void *) DB8500_REGULATOR_VSMPS2, }, | ||
461 | { .name = "db8500-vsmps3", .driver_data = (void *) DB8500_REGULATOR_VSMPS3, }, | ||
462 | { .name = "db8500-vrf1", .driver_data = (void *) DB8500_REGULATOR_VRF1, }, | ||
463 | { .name = "db8500-sva-mmdsp", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSP, }, | ||
464 | { .name = "db8500-sva-mmdsp-ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSPRET, }, | ||
465 | { .name = "db8500-sva-pipe", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAPIPE, }, | ||
466 | { .name = "db8500-sia-mmdsp", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSP, }, | ||
467 | { .name = "db8500-sia-mmdsp-ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSPRET, }, | ||
468 | { .name = "db8500-sia-pipe", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAPIPE, }, | ||
469 | { .name = "db8500-sga", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SGA, }, | ||
470 | { .name = "db8500-b2r2-mcde", .driver_data = (void *) DB8500_REGULATOR_SWITCH_B2R2_MCDE, }, | ||
471 | { .name = "db8500-esram12", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12, }, | ||
472 | { .name = "db8500-esram12-ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12RET, }, | ||
473 | { .name = "db8500-esram34", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34, }, | ||
474 | { .name = "db8500-esram34-ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34RET, }, | ||
475 | }; | ||
476 | |||
477 | static __devinit int | ||
478 | db8500_regulator_of_probe(struct platform_device *pdev, | ||
479 | struct device_node *np) | ||
480 | { | ||
481 | int i, err; | ||
482 | |||
483 | for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) { | ||
484 | err = db8500_regulator_register( | ||
485 | pdev, db8500_regulator_matches[i].init_data, | ||
486 | i, db8500_regulator_matches[i].of_node); | ||
487 | if (err) | ||
488 | return err; | ||
489 | } | ||
490 | |||
491 | return 0; | ||
492 | } | ||
493 | |||
452 | static int __devinit db8500_regulator_probe(struct platform_device *pdev) | 494 | static int __devinit db8500_regulator_probe(struct platform_device *pdev) |
453 | { | 495 | { |
454 | struct regulator_init_data *db8500_init_data = | 496 | struct regulator_init_data *db8500_init_data = |
455 | dev_get_platdata(&pdev->dev); | 497 | dev_get_platdata(&pdev->dev); |
498 | struct device_node *np = pdev->dev.of_node; | ||
456 | int i, err; | 499 | int i, err; |
457 | 500 | ||
458 | /* register all regulators */ | 501 | /* register all regulators */ |
459 | for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) { | 502 | if (np) { |
460 | err = db8500_regulator_register(pdev, | 503 | err = of_regulator_match(&pdev->dev, np, |
461 | &db8500_init_data[i], | 504 | db8500_regulator_matches, |
462 | i, NULL); | 505 | ARRAY_SIZE(db8500_regulator_matches)); |
463 | if (err) | 506 | if (err < 0) { |
507 | dev_err(&pdev->dev, | ||
508 | "Error parsing regulator init data: %d\n", err); | ||
464 | return err; | 509 | return err; |
510 | } | ||
465 | 511 | ||
466 | dev_dbg(rdev_get_dev(info->rdev), | 512 | err = db8500_regulator_of_probe(pdev, np); |
467 | "regulator-%s-probed\n", info->desc.name); | 513 | if (err) |
514 | return err; | ||
515 | } else { | ||
516 | for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) { | ||
517 | err = db8500_regulator_register(pdev, | ||
518 | &db8500_init_data[i], | ||
519 | i, NULL); | ||
520 | if (err) | ||
521 | return err; | ||
522 | } | ||
468 | } | 523 | } |
524 | |||
469 | err = ux500_regulator_debug_init(pdev, | 525 | err = ux500_regulator_debug_init(pdev, |
470 | dbx500_regulator_info, | 526 | dbx500_regulator_info, |
471 | ARRAY_SIZE(dbx500_regulator_info)); | 527 | ARRAY_SIZE(dbx500_regulator_info)); |
@@ -491,10 +547,16 @@ static int __exit db8500_regulator_remove(struct platform_device *pdev) | |||
491 | return 0; | 547 | return 0; |
492 | } | 548 | } |
493 | 549 | ||
550 | static const struct of_device_id db8500_prcmu_regulator_match[] = { | ||
551 | { .compatible = "stericsson,db8500-prcmu-regulator", }, | ||
552 | {} | ||
553 | }; | ||
554 | |||
494 | static struct platform_driver db8500_regulator_driver = { | 555 | static struct platform_driver db8500_regulator_driver = { |
495 | .driver = { | 556 | .driver = { |
496 | .name = "db8500-prcmu-regulators", | 557 | .name = "db8500-prcmu-regulators", |
497 | .owner = THIS_MODULE, | 558 | .owner = THIS_MODULE, |
559 | .of_match_table = db8500_prcmu_regulator_match, | ||
498 | }, | 560 | }, |
499 | .probe = db8500_regulator_probe, | 561 | .probe = db8500_regulator_probe, |
500 | .remove = __exit_p(db8500_regulator_remove), | 562 | .remove = __exit_p(db8500_regulator_remove), |