aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>2015-10-02 08:29:10 -0400
committerLee Jones <lee.jones@linaro.org>2015-10-30 13:20:13 -0400
commite7811147aafb3d6364b8d60223cbe6c323cdf725 (patch)
tree85645af49ee68389f533790f37ae37171d2872e6
parent18eb3f041addcdf8ef4a4b80547a67557c8826d6 (diff)
mfd: arizona: Factor out DCVDD isolation control
Currently DCVDD isolation is enabled and disabled for runtime_suspend and runtime_resume. Future codecs will not have the isolation control so to prepare for these codecs this patch factors out the isolation control allowing it to be called as needed in the existing codec-specific switch cases. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/mfd/arizona-core.c108
1 files changed, 62 insertions, 46 deletions
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index acf354875338..29be2628352c 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -460,6 +460,33 @@ static int wm5102_clear_write_sequencer(struct arizona *arizona)
460} 460}
461 461
462#ifdef CONFIG_PM 462#ifdef CONFIG_PM
463static int arizona_isolate_dcvdd(struct arizona *arizona)
464{
465 int ret;
466
467 ret = regmap_update_bits(arizona->regmap,
468 ARIZONA_ISOLATION_CONTROL,
469 ARIZONA_ISOLATE_DCVDD1,
470 ARIZONA_ISOLATE_DCVDD1);
471 if (ret != 0)
472 dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n", ret);
473
474 return ret;
475}
476
477static int arizona_connect_dcvdd(struct arizona *arizona)
478{
479 int ret;
480
481 ret = regmap_update_bits(arizona->regmap,
482 ARIZONA_ISOLATION_CONTROL,
483 ARIZONA_ISOLATE_DCVDD1, 0);
484 if (ret != 0)
485 dev_err(arizona->dev, "Failed to connect DCVDD: %d\n", ret);
486
487 return ret;
488}
489
463static int arizona_runtime_resume(struct device *dev) 490static int arizona_runtime_resume(struct device *dev)
464{ 491{
465 struct arizona *arizona = dev_get_drvdata(dev); 492 struct arizona *arizona = dev_get_drvdata(dev);
@@ -499,14 +526,9 @@ static int arizona_runtime_resume(struct device *dev)
499 switch (arizona->type) { 526 switch (arizona->type) {
500 case WM5102: 527 case WM5102:
501 if (arizona->external_dcvdd) { 528 if (arizona->external_dcvdd) {
502 ret = regmap_update_bits(arizona->regmap, 529 ret = arizona_connect_dcvdd(arizona);
503 ARIZONA_ISOLATION_CONTROL, 530 if (ret != 0)
504 ARIZONA_ISOLATE_DCVDD1, 0);
505 if (ret != 0) {
506 dev_err(arizona->dev,
507 "Failed to connect DCVDD: %d\n", ret);
508 goto err; 531 goto err;
509 }
510 } 532 }
511 533
512 ret = wm5102_patch(arizona); 534 ret = wm5102_patch(arizona);
@@ -531,14 +553,9 @@ static int arizona_runtime_resume(struct device *dev)
531 goto err; 553 goto err;
532 554
533 if (arizona->external_dcvdd) { 555 if (arizona->external_dcvdd) {
534 ret = regmap_update_bits(arizona->regmap, 556 ret = arizona_connect_dcvdd(arizona);
535 ARIZONA_ISOLATION_CONTROL, 557 if (ret != 0)
536 ARIZONA_ISOLATE_DCVDD1, 0);
537 if (ret) {
538 dev_err(arizona->dev,
539 "Failed to connect DCVDD: %d\n", ret);
540 goto err; 558 goto err;
541 }
542 } else { 559 } else {
543 /* 560 /*
544 * As this is only called for the internal regulator 561 * As this is only called for the internal regulator
@@ -569,14 +586,9 @@ static int arizona_runtime_resume(struct device *dev)
569 goto err; 586 goto err;
570 587
571 if (arizona->external_dcvdd) { 588 if (arizona->external_dcvdd) {
572 ret = regmap_update_bits(arizona->regmap, 589 ret = arizona_connect_dcvdd(arizona);
573 ARIZONA_ISOLATION_CONTROL, 590 if (ret != 0)
574 ARIZONA_ISOLATE_DCVDD1, 0);
575 if (ret != 0) {
576 dev_err(arizona->dev,
577 "Failed to connect DCVDD: %d\n", ret);
578 goto err; 591 goto err;
579 }
580 } 592 }
581 break; 593 break;
582 } 594 }
@@ -609,37 +621,36 @@ static int arizona_runtime_suspend(struct device *dev)
609 return ret; 621 return ret;
610 } 622 }
611 623
612 if (arizona->external_dcvdd) {
613 ret = regmap_update_bits(arizona->regmap,
614 ARIZONA_ISOLATION_CONTROL,
615 ARIZONA_ISOLATE_DCVDD1,
616 ARIZONA_ISOLATE_DCVDD1);
617 if (ret != 0) {
618 dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n",
619 ret);
620 return ret;
621 }
622 }
623
624 switch (arizona->type) { 624 switch (arizona->type) {
625 case WM5110: 625 case WM5110:
626 case WM8280: 626 case WM8280:
627 if (arizona->external_dcvdd) 627 if (arizona->external_dcvdd) {
628 break; 628 ret = arizona_isolate_dcvdd(arizona);
629 629 if (ret != 0)
630 /* 630 return ret;
631 * As this is only called for the internal regulator 631 } else {
632 * (where we know voltage ranges available) it is ok 632 /*
633 * to request an exact range. 633 * As this is only called for the internal regulator
634 */ 634 * (where we know voltage ranges available) it is ok
635 ret = regulator_set_voltage(arizona->dcvdd, 1175000, 1175000); 635 * to request an exact range.
636 if (ret < 0) { 636 */
637 dev_err(arizona->dev, 637 ret = regulator_set_voltage(arizona->dcvdd,
638 "Failed to set suspend voltage: %d\n", ret); 638 1175000, 1175000);
639 return ret; 639 if (ret < 0) {
640 dev_err(arizona->dev,
641 "Failed to set suspend voltage: %d\n",
642 ret);
643 return ret;
644 }
640 } 645 }
641 break; 646 break;
642 case WM5102: 647 case WM5102:
648 if (arizona->external_dcvdd) {
649 ret = arizona_isolate_dcvdd(arizona);
650 if (ret != 0)
651 return ret;
652 }
653
643 if (!(val & ARIZONA_JD1_ENA)) { 654 if (!(val & ARIZONA_JD1_ENA)) {
644 ret = regmap_write(arizona->regmap, 655 ret = regmap_write(arizona->regmap,
645 ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0); 656 ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0);
@@ -652,6 +663,11 @@ static int arizona_runtime_suspend(struct device *dev)
652 } 663 }
653 break; 664 break;
654 default: 665 default:
666 if (arizona->external_dcvdd) {
667 ret = arizona_isolate_dcvdd(arizona);
668 if (ret != 0)
669 return ret;
670 }
655 break; 671 break;
656 } 672 }
657 673