aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>2015-10-02 08:29:11 -0400
committerLee Jones <lee.jones@linaro.org>2015-10-30 13:20:20 -0400
commite3424273545bef85ebf959c90091d60ba3fc2efc (patch)
treee150ab274aa067a260aec58c4493ec1b9b96b219
parente7811147aafb3d6364b8d60223cbe6c323cdf725 (diff)
mfd: arizona: Factor out checking of jack detection state
Currently runtime_suspend will fully power off the codec if the jack detection is not enabled. Not all future codecs will have jack detection so to prepare for these codecs this patch factors out the check so that it 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.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 29be2628352c..e32d0d30e9cd 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -487,6 +487,23 @@ static int arizona_connect_dcvdd(struct arizona *arizona)
487 return ret; 487 return ret;
488} 488}
489 489
490static int arizona_is_jack_det_active(struct arizona *arizona)
491{
492 unsigned int val;
493 int ret;
494
495 ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val);
496 if (ret) {
497 dev_err(arizona->dev,
498 "Failed to check jack det status: %d\n", ret);
499 return ret;
500 } else if (val & ARIZONA_JD1_ENA) {
501 return 1;
502 } else {
503 return 0;
504 }
505}
506
490static int arizona_runtime_resume(struct device *dev) 507static int arizona_runtime_resume(struct device *dev)
491{ 508{
492 struct arizona *arizona = dev_get_drvdata(dev); 509 struct arizona *arizona = dev_get_drvdata(dev);
@@ -610,20 +627,18 @@ err:
610static int arizona_runtime_suspend(struct device *dev) 627static int arizona_runtime_suspend(struct device *dev)
611{ 628{
612 struct arizona *arizona = dev_get_drvdata(dev); 629 struct arizona *arizona = dev_get_drvdata(dev);
613 unsigned int val; 630 unsigned int jd_active = 0;
614 int ret; 631 int ret;
615 632
616 dev_dbg(arizona->dev, "Entering AoD mode\n"); 633 dev_dbg(arizona->dev, "Entering AoD mode\n");
617 634
618 ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val);
619 if (ret) {
620 dev_err(dev, "Failed to check jack det status: %d\n", ret);
621 return ret;
622 }
623
624 switch (arizona->type) { 635 switch (arizona->type) {
625 case WM5110: 636 case WM5110:
626 case WM8280: 637 case WM8280:
638 jd_active = arizona_is_jack_det_active(arizona);
639 if (jd_active < 0)
640 return jd_active;
641
627 if (arizona->external_dcvdd) { 642 if (arizona->external_dcvdd) {
628 ret = arizona_isolate_dcvdd(arizona); 643 ret = arizona_isolate_dcvdd(arizona);
629 if (ret != 0) 644 if (ret != 0)
@@ -645,13 +660,17 @@ static int arizona_runtime_suspend(struct device *dev)
645 } 660 }
646 break; 661 break;
647 case WM5102: 662 case WM5102:
663 jd_active = arizona_is_jack_det_active(arizona);
664 if (jd_active < 0)
665 return jd_active;
666
648 if (arizona->external_dcvdd) { 667 if (arizona->external_dcvdd) {
649 ret = arizona_isolate_dcvdd(arizona); 668 ret = arizona_isolate_dcvdd(arizona);
650 if (ret != 0) 669 if (ret != 0)
651 return ret; 670 return ret;
652 } 671 }
653 672
654 if (!(val & ARIZONA_JD1_ENA)) { 673 if (!jd_active) {
655 ret = regmap_write(arizona->regmap, 674 ret = regmap_write(arizona->regmap,
656 ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0); 675 ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0);
657 if (ret) { 676 if (ret) {
@@ -663,6 +682,10 @@ static int arizona_runtime_suspend(struct device *dev)
663 } 682 }
664 break; 683 break;
665 default: 684 default:
685 jd_active = arizona_is_jack_det_active(arizona);
686 if (jd_active < 0)
687 return jd_active;
688
666 if (arizona->external_dcvdd) { 689 if (arizona->external_dcvdd) {
667 ret = arizona_isolate_dcvdd(arizona); 690 ret = arizona_isolate_dcvdd(arizona);
668 if (ret != 0) 691 if (ret != 0)
@@ -676,7 +699,7 @@ static int arizona_runtime_suspend(struct device *dev)
676 regulator_disable(arizona->dcvdd); 699 regulator_disable(arizona->dcvdd);
677 700
678 /* Allow us to completely power down if no jack detection */ 701 /* Allow us to completely power down if no jack detection */
679 if (!(val & ARIZONA_JD1_ENA)) { 702 if (!jd_active) {
680 dev_dbg(arizona->dev, "Fully powering off\n"); 703 dev_dbg(arizona->dev, "Fully powering off\n");
681 704
682 arizona->has_fully_powered_off = true; 705 arizona->has_fully_powered_off = true;