From b7612e90e1696436b349ed5b305f93f87188d4d0 Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Mon, 31 Jul 2017 11:42:13 +0100 Subject: [PATCH] extcon: madera: Take external resistance into account for short circuit When checking the minimum value of impedance we can detect we should take any external resistance into account, as we can detect lower impedances if there is some external resistance pushing the detected impedance up. Change-Id: Ic784807c811ab453a7ca8ef2fb115d1bcd884e87 Signed-off-by: Charles Keepax Signed-off-by: Richard Fitzgerald --- drivers/extcon/extcon-madera.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/extcon/extcon-madera.c b/drivers/extcon/extcon-madera.c index fae98b205788..e96dc35a1b43 100644 --- a/drivers/extcon/extcon-madera.c +++ b/drivers/extcon/extcon-madera.c @@ -2859,7 +2859,7 @@ static int madera_extcon_probe(struct platform_device *pdev) struct madera_extcon *info; unsigned int debounce_val, analog_val; int jack_irq_fall, jack_irq_rise; - int ret, mode, i; + int ret, mode, i, hpdet_short; /* quick exit if Madera irqchip driver hasn't completed probe */ if (!madera->irq_dev) { @@ -2946,8 +2946,16 @@ static int madera_extcon_probe(struct platform_device *pdev) if (!pdata->enabled || pdata->output == 0) return -ENODEV; /* no accdet output configured */ - if (pdata->hpdet_short_circuit_imp < MADERA_HP_SHORT_IMPEDANCE_MIN) + hpdet_short = pdata->hpdet_short_circuit_imp + + madera_hohm_to_ohm(pdata->hpdet_ext_res_x100); + + if (hpdet_short < MADERA_HP_SHORT_IMPEDANCE_MIN) { + dev_warn(info->dev, + "Increasing HP short circuit impedance from %d to %d\n", + pdata->hpdet_short_circuit_imp, + MADERA_HP_SHORT_IMPEDANCE_MIN); pdata->hpdet_short_circuit_imp = MADERA_HP_SHORT_IMPEDANCE_MIN; + } info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD"); if (IS_ERR(info->micvdd)) { -- 2.20.1