Commit e2c0f476 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

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: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent a3e2078d
...@@ -737,11 +737,12 @@ static irqreturn_t arizona_micdet(int irq, void *data) ...@@ -737,11 +737,12 @@ static irqreturn_t arizona_micdet(int irq, void *data)
{ {
struct arizona_extcon_info *info = data; struct arizona_extcon_info *info = data;
struct arizona *arizona = info->arizona; struct arizona *arizona = info->arizona;
unsigned int val, lvl; unsigned int val = 0, lvl;
int ret, i, key; int ret, i, key;
mutex_lock(&info->lock); mutex_lock(&info->lock);
for (i = 0; i < 10 && !(val & 0x7fc); i++) {
ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
if (ret != 0) { if (ret != 0) {
dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret); dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret);
...@@ -756,6 +757,13 @@ static irqreturn_t arizona_micdet(int irq, void *data) ...@@ -756,6 +757,13 @@ static irqreturn_t arizona_micdet(int irq, void *data)
mutex_unlock(&info->lock); mutex_unlock(&info->lock);
return IRQ_NONE; return IRQ_NONE;
} }
}
if (i == 10 && !(val & 0x7fc)) {
dev_err(arizona->dev, "Failed to get valid MICDET value\n");
mutex_unlock(&info->lock);
return IRQ_NONE;
}
/* Due to jack detect this should never happen */ /* Due to jack detect this should never happen */
if (!(val & ARIZONA_MICD_STS)) { if (!(val & ARIZONA_MICD_STS)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment