aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2014-11-05 04:47:49 -0500
committerMark Brown <broonie@kernel.org>2014-11-26 15:38:32 -0500
commitff633bea47751f660aad1afd22790cbbd47ca9fc (patch)
tree9bef9df5a450577695de1960774740bc7c3e2ebc
parentcf2394f70cf7774a107fbaa1ef5010db4bd69baa (diff)
regulator: max77802: Remove support for board files
The driver is used only on Exynos based boards with DTS support. Simplify the driver and remove dead (unused) entries in platform_data structure. Convert the driver to DTS-only version. Parse all regulators at once, not one-by-one. Remove dependency on data provided by max77686 MFD driver. Use new DT style parsing method for regulators init data. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Acked-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/max77802.c92
1 files changed, 19 insertions, 73 deletions
diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index 9e2183c8566c..0766615c60bc 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -70,6 +70,7 @@ static unsigned int ramp_table_77802_4bit[] = {
70}; 70};
71 71
72struct max77802_regulator_prv { 72struct max77802_regulator_prv {
73 /* Array indexed by regulator id */
73 unsigned int opmode[MAX77802_REG_MAX]; 74 unsigned int opmode[MAX77802_REG_MAX];
74}; 75};
75 76
@@ -362,6 +363,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
362/* LDOs 3-7, 9-14, 18-26, 28, 29, 32-34 */ 363/* LDOs 3-7, 9-14, 18-26, 28, 29, 32-34 */
363#define regulator_77802_desc_p_ldo(num, supply, log) { \ 364#define regulator_77802_desc_p_ldo(num, supply, log) { \
364 .name = "LDO"#num, \ 365 .name = "LDO"#num, \
366 .of_match = of_match_ptr("LDO"#num), \
367 .regulators_node = of_match_ptr("regulators"), \
365 .id = MAX77802_LDO##num, \ 368 .id = MAX77802_LDO##num, \
366 .supply_name = "inl"#supply, \ 369 .supply_name = "inl"#supply, \
367 .ops = &max77802_ldo_ops_logic##log, \ 370 .ops = &max77802_ldo_ops_logic##log, \
@@ -381,6 +384,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
381/* LDOs 1, 2, 8, 15, 17, 27, 30, 35 */ 384/* LDOs 1, 2, 8, 15, 17, 27, 30, 35 */
382#define regulator_77802_desc_n_ldo(num, supply, log) { \ 385#define regulator_77802_desc_n_ldo(num, supply, log) { \
383 .name = "LDO"#num, \ 386 .name = "LDO"#num, \
387 .of_match = of_match_ptr("LDO"#num), \
388 .regulators_node = of_match_ptr("regulators"), \
384 .id = MAX77802_LDO##num, \ 389 .id = MAX77802_LDO##num, \
385 .supply_name = "inl"#supply, \ 390 .supply_name = "inl"#supply, \
386 .ops = &max77802_ldo_ops_logic##log, \ 391 .ops = &max77802_ldo_ops_logic##log, \
@@ -400,6 +405,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
400/* BUCKs 1, 6 */ 405/* BUCKs 1, 6 */
401#define regulator_77802_desc_16_buck(num) { \ 406#define regulator_77802_desc_16_buck(num) { \
402 .name = "BUCK"#num, \ 407 .name = "BUCK"#num, \
408 .of_match = of_match_ptr("BUCK"#num), \
409 .regulators_node = of_match_ptr("regulators"), \
403 .id = MAX77802_BUCK##num, \ 410 .id = MAX77802_BUCK##num, \
404 .supply_name = "inb"#num, \ 411 .supply_name = "inb"#num, \
405 .ops = &max77802_buck_16_dvs_ops, \ 412 .ops = &max77802_buck_16_dvs_ops, \
@@ -419,6 +426,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
419/* BUCKS 2-4 */ 426/* BUCKS 2-4 */
420#define regulator_77802_desc_234_buck(num) { \ 427#define regulator_77802_desc_234_buck(num) { \
421 .name = "BUCK"#num, \ 428 .name = "BUCK"#num, \
429 .of_match = of_match_ptr("BUCK"#num), \
430 .regulators_node = of_match_ptr("regulators"), \
422 .id = MAX77802_BUCK##num, \ 431 .id = MAX77802_BUCK##num, \
423 .supply_name = "inb"#num, \ 432 .supply_name = "inb"#num, \
424 .ops = &max77802_buck_234_ops, \ 433 .ops = &max77802_buck_234_ops, \
@@ -439,6 +448,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
439/* BUCK 5 */ 448/* BUCK 5 */
440#define regulator_77802_desc_buck5(num) { \ 449#define regulator_77802_desc_buck5(num) { \
441 .name = "BUCK"#num, \ 450 .name = "BUCK"#num, \
451 .of_match = of_match_ptr("BUCK"#num), \
452 .regulators_node = of_match_ptr("regulators"), \
442 .id = MAX77802_BUCK##num, \ 453 .id = MAX77802_BUCK##num, \
443 .supply_name = "inb"#num, \ 454 .supply_name = "inb"#num, \
444 .ops = &max77802_buck_dvs_ops, \ 455 .ops = &max77802_buck_dvs_ops, \
@@ -458,6 +469,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
458/* BUCKs 7-10 */ 469/* BUCKs 7-10 */
459#define regulator_77802_desc_buck7_10(num) { \ 470#define regulator_77802_desc_buck7_10(num) { \
460 .name = "BUCK"#num, \ 471 .name = "BUCK"#num, \
472 .of_match = of_match_ptr("BUCK"#num), \
473 .regulators_node = of_match_ptr("regulators"), \
461 .id = MAX77802_BUCK##num, \ 474 .id = MAX77802_BUCK##num, \
462 .supply_name = "inb"#num, \ 475 .supply_name = "inb"#num, \
463 .ops = &max77802_buck_dvs_ops, \ 476 .ops = &max77802_buck_dvs_ops, \
@@ -519,85 +532,19 @@ static const struct regulator_desc regulators[] = {
519 regulator_77802_desc_n_ldo(35, 2, 1), 532 regulator_77802_desc_n_ldo(35, 2, 1),
520}; 533};
521 534
522#ifdef CONFIG_OF
523static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev,
524 struct max77686_platform_data *pdata)
525{
526 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
527 struct device_node *pmic_np, *regulators_np;
528 struct max77686_regulator_data *rdata;
529 struct of_regulator_match rmatch = { };
530 unsigned int i;
531
532 pmic_np = iodev->dev->of_node;
533 regulators_np = of_get_child_by_name(pmic_np, "regulators");
534 if (!regulators_np) {
535 dev_err(&pdev->dev, "could not find regulators sub-node\n");
536 return -EINVAL;
537 }
538
539 pdata->num_regulators = ARRAY_SIZE(regulators);
540 rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
541 pdata->num_regulators, GFP_KERNEL);
542 if (!rdata) {
543 of_node_put(regulators_np);
544 return -ENOMEM;
545 }
546
547 for (i = 0; i < pdata->num_regulators; i++) {
548 rmatch.name = regulators[i].name;
549 rmatch.init_data = NULL;
550 rmatch.of_node = NULL;
551 if (of_regulator_match(&pdev->dev, regulators_np, &rmatch,
552 1) != 1) {
553 dev_warn(&pdev->dev, "No matching regulator for '%s'\n",
554 rmatch.name);
555 continue;
556 }
557 rdata[i].initdata = rmatch.init_data;
558 rdata[i].of_node = rmatch.of_node;
559 rdata[i].id = regulators[i].id;
560 }
561
562 pdata->regulators = rdata;
563 of_node_put(regulators_np);
564
565 return 0;
566}
567#else
568static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev,
569 struct max77686_platform_data *pdata)
570{
571 return 0;
572}
573#endif /* CONFIG_OF */
574
575static int max77802_pmic_probe(struct platform_device *pdev) 535static int max77802_pmic_probe(struct platform_device *pdev)
576{ 536{
577 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); 537 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
578 struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
579 struct max77802_regulator_prv *max77802; 538 struct max77802_regulator_prv *max77802;
580 int i, ret = 0, val; 539 int i, val;
581 struct regulator_config config = { }; 540 struct regulator_config config = { };
582 541
583 /* This is allocated by the MFD driver */
584 if (!pdata) {
585 dev_err(&pdev->dev, "no platform data found for regulator\n");
586 return -ENODEV;
587 }
588
589 max77802 = devm_kzalloc(&pdev->dev, 542 max77802 = devm_kzalloc(&pdev->dev,
590 sizeof(struct max77802_regulator_prv), 543 sizeof(struct max77802_regulator_prv),
591 GFP_KERNEL); 544 GFP_KERNEL);
592 if (!max77802) 545 if (!max77802)
593 return -ENOMEM; 546 return -ENOMEM;
594 547
595 if (iodev->dev->of_node) {
596 ret = max77802_pmic_dt_parse_pdata(pdev, pdata);
597 if (ret)
598 return ret;
599 }
600
601 config.dev = iodev->dev; 548 config.dev = iodev->dev;
602 config.regmap = iodev->regmap; 549 config.regmap = iodev->regmap;
603 config.driver_data = max77802; 550 config.driver_data = max77802;
@@ -605,11 +552,9 @@ static int max77802_pmic_probe(struct platform_device *pdev)
605 552
606 for (i = 0; i < MAX77802_REG_MAX; i++) { 553 for (i = 0; i < MAX77802_REG_MAX; i++) {
607 struct regulator_dev *rdev; 554 struct regulator_dev *rdev;
608 int id = pdata->regulators[i].id; 555 int id = regulators[i].id;
609 int shift = max77802_get_opmode_shift(id); 556 int shift = max77802_get_opmode_shift(id);
610 557 int ret;
611 config.init_data = pdata->regulators[i].initdata;
612 config.of_node = pdata->regulators[i].of_node;
613 558
614 ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); 559 ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val);
615 if (ret < 0) { 560 if (ret < 0) {
@@ -633,9 +578,10 @@ static int max77802_pmic_probe(struct platform_device *pdev)
633 rdev = devm_regulator_register(&pdev->dev, 578 rdev = devm_regulator_register(&pdev->dev,
634 &regulators[i], &config); 579 &regulators[i], &config);
635 if (IS_ERR(rdev)) { 580 if (IS_ERR(rdev)) {
581 ret = PTR_ERR(rdev);
636 dev_err(&pdev->dev, 582 dev_err(&pdev->dev,
637 "regulator init failed for %d\n", i); 583 "regulator init failed for %d: %d\n", i, ret);
638 return PTR_ERR(rdev); 584 return ret;
639 } 585 }
640 } 586 }
641 587