aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/extcon-arizona.c58
1 files changed, 46 insertions, 12 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 2ad0e4a35a23..cfd206c4797c 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -489,6 +489,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
489 struct arizona *arizona = info->arizona; 489 struct arizona *arizona = info->arizona;
490 int id_gpio = arizona->pdata.hpdet_id_gpio; 490 int id_gpio = arizona->pdata.hpdet_id_gpio;
491 int report = ARIZONA_CABLE_HEADPHONE; 491 int report = ARIZONA_CABLE_HEADPHONE;
492 unsigned int val;
492 int ret, reading; 493 int ret, reading;
493 494
494 mutex_lock(&info->lock); 495 mutex_lock(&info->lock);
@@ -543,13 +544,28 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
543 dev_err(arizona->dev, "Failed to report HP/line: %d\n", 544 dev_err(arizona->dev, "Failed to report HP/line: %d\n",
544 ret); 545 ret);
545 546
546 ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0); 547 mutex_lock(&arizona->dapm->card->dapm_mutex);
547 if (ret != 0)
548 dev_warn(arizona->dev, "Failed to undo magic: %d\n", ret);
549 548
550 ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0); 549 ret = regmap_read(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, &val);
551 if (ret != 0) 550 if (ret != 0) {
552 dev_warn(arizona->dev, "Failed to undo magic: %d\n", ret); 551 dev_err(arizona->dev, "Failed to read output enables: %d\n",
552 ret);
553 val = 0;
554 }
555
556 if (!(val & (ARIZONA_OUT1L_ENA | ARIZONA_OUT1R_ENA))) {
557 ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0);
558 if (ret != 0)
559 dev_warn(arizona->dev, "Failed to undo magic: %d\n",
560 ret);
561
562 ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0);
563 if (ret != 0)
564 dev_warn(arizona->dev, "Failed to undo magic: %d\n",
565 ret);
566 }
567
568 mutex_unlock(&arizona->dapm->card->dapm_mutex);
553 569
554done: 570done:
555 if (id_gpio) 571 if (id_gpio)
@@ -637,6 +653,7 @@ err:
637static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info) 653static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
638{ 654{
639 struct arizona *arizona = info->arizona; 655 struct arizona *arizona = info->arizona;
656 unsigned int val;
640 int ret; 657 int ret;
641 658
642 dev_dbg(arizona->dev, "Starting identification via HPDET\n"); 659 dev_dbg(arizona->dev, "Starting identification via HPDET\n");
@@ -648,13 +665,30 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
648 665
649 arizona_extcon_pulse_micbias(info); 666 arizona_extcon_pulse_micbias(info);
650 667
651 ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0x4000); 668 mutex_lock(&arizona->dapm->card->dapm_mutex);
652 if (ret != 0)
653 dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);
654 669
655 ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0x4000); 670 ret = regmap_read(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, &val);
656 if (ret != 0) 671 if (ret != 0) {
657 dev_warn(arizona->dev, "Failed to do magic: %d\n", ret); 672 dev_err(arizona->dev, "Failed to read output enables: %d\n",
673 ret);
674 val = 0;
675 }
676
677 if (!(val & (ARIZONA_OUT1L_ENA | ARIZONA_OUT1R_ENA))) {
678 ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000,
679 0x4000);
680 if (ret != 0)
681 dev_warn(arizona->dev, "Failed to do magic: %d\n",
682 ret);
683
684 ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000,
685 0x4000);
686 if (ret != 0)
687 dev_warn(arizona->dev, "Failed to do magic: %d\n",
688 ret);
689 }
690
691 mutex_unlock(&arizona->dapm->card->dapm_mutex);
658 692
659 ret = regmap_update_bits(arizona->regmap, 693 ret = regmap_update_bits(arizona->regmap,
660 ARIZONA_ACCESSORY_DETECT_MODE_1, 694 ARIZONA_ACCESSORY_DETECT_MODE_1,