diff options
author | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> | 2013-04-01 14:06:29 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-04-02 06:53:57 -0400 |
commit | e2c0f476ec90dbb020b1da7e399072e062ad6c9e (patch) | |
tree | ec88305240054f6a9e2fbdf22a810f7517d94851 /drivers/extcon/extcon-arizona.c | |
parent | a3e2078d6a14bc67e733f7dbd32d1bc4051c9d90 (diff) |
extcon: arizona: Check we report a valid impedance
Occasionally we can trigger an interrupt before we have completed
impedance measurement, although the valid bit will still be set. This
patch spins reading the impedance value until a valid value is seen.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/extcon/extcon-arizona.c')
-rw-r--r-- | drivers/extcon/extcon-arizona.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 9e4bffe610b6..4022fe207926 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c | |||
@@ -737,22 +737,30 @@ static irqreturn_t arizona_micdet(int irq, void *data) | |||
737 | { | 737 | { |
738 | struct arizona_extcon_info *info = data; | 738 | struct arizona_extcon_info *info = data; |
739 | struct arizona *arizona = info->arizona; | 739 | struct arizona *arizona = info->arizona; |
740 | unsigned int val, lvl; | 740 | unsigned int val = 0, lvl; |
741 | int ret, i, key; | 741 | int ret, i, key; |
742 | 742 | ||
743 | mutex_lock(&info->lock); | 743 | mutex_lock(&info->lock); |
744 | 744 | ||
745 | ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); | 745 | for (i = 0; i < 10 && !(val & 0x7fc); i++) { |
746 | if (ret != 0) { | 746 | ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); |
747 | dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret); | 747 | if (ret != 0) { |
748 | mutex_unlock(&info->lock); | 748 | dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret); |
749 | return IRQ_NONE; | 749 | mutex_unlock(&info->lock); |
750 | } | 750 | return IRQ_NONE; |
751 | } | ||
752 | |||
753 | dev_dbg(arizona->dev, "MICDET: %x\n", val); | ||
751 | 754 | ||
752 | dev_dbg(arizona->dev, "MICDET: %x\n", val); | 755 | if (!(val & ARIZONA_MICD_VALID)) { |
756 | dev_warn(arizona->dev, "Microphone detection state invalid\n"); | ||
757 | mutex_unlock(&info->lock); | ||
758 | return IRQ_NONE; | ||
759 | } | ||
760 | } | ||
753 | 761 | ||
754 | if (!(val & ARIZONA_MICD_VALID)) { | 762 | if (i == 10 && !(val & 0x7fc)) { |
755 | dev_warn(arizona->dev, "Microphone detection state invalid\n"); | 763 | dev_err(arizona->dev, "Failed to get valid MICDET value\n"); |
756 | mutex_unlock(&info->lock); | 764 | mutex_unlock(&info->lock); |
757 | return IRQ_NONE; | 765 | return IRQ_NONE; |
758 | } | 766 | } |