From 01a86d28951e400e9b80ca9468da063790234882 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Thu, 11 Jul 2019 16:36:46 +0530 Subject: [PATCH] ASoC: codec: Disable surge protection before impedance detection If surge protection is enabled, it interferes with HPHL and does not give proper impedance for high impedance cable. Disable surge protection before impedance detection and enable it again after impedance detection on wcd937x and wcd938x. Change-Id: I13840b0ba9fd9ce16b90f42dcd1a25ffb928b504 Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd937x/wcd937x-mbhc.c | 9 +++++++++ asoc/codecs/wcd938x/wcd938x-mbhc.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/asoc/codecs/wcd937x/wcd937x-mbhc.c b/asoc/codecs/wcd937x/wcd937x-mbhc.c index 4ad8683a49..cec70e7ff3 100644 --- a/asoc/codecs/wcd937x/wcd937x-mbhc.c +++ b/asoc/codecs/wcd937x/wcd937x-mbhc.c @@ -547,6 +547,12 @@ static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, regmap_update_bits(wcd937x->regmap, WCD937X_ANA_MBHC_MECH, 0x01, 0x00); + /* Disable surge protection before impedance detection. + * This is done to give correct value for high impedance. + */ + regmap_update_bits(wcd937x->regmap, + WCD937X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0x00); + /* First get impedance on Left */ d1 = d1_a[1]; zdet_param_ptr = &zdet_param[1]; @@ -663,6 +669,9 @@ right_ch_impedance: mbhc->hph_type = WCD_MBHC_HPH_MONO; } + /* Enable surge protection again after impedance detection */ + regmap_update_bits(wcd937x->regmap, + WCD937X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0xC0); zdet_complete: snd_soc_component_write(component, WCD937X_ANA_MBHC_BTN5, reg0); snd_soc_component_write(component, WCD937X_ANA_MBHC_BTN6, reg1); diff --git a/asoc/codecs/wcd938x/wcd938x-mbhc.c b/asoc/codecs/wcd938x/wcd938x-mbhc.c index 08a2b228df..9c49755935 100644 --- a/asoc/codecs/wcd938x/wcd938x-mbhc.c +++ b/asoc/codecs/wcd938x/wcd938x-mbhc.c @@ -547,6 +547,12 @@ static void wcd938x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MBHC_MECH, 0x01, 0x00); + /* Disable surge protection before impedance detection. + * This is done to give correct value for high impedance. + */ + regmap_update_bits(wcd938x->regmap, + WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0x00); + /* First get impedance on Left */ d1 = d1_a[1]; zdet_param_ptr = &zdet_param[1]; @@ -656,6 +662,9 @@ right_ch_impedance: mbhc->hph_type = WCD_MBHC_HPH_MONO; } + /* Enable surge protection again after impedance detection */ + regmap_update_bits(wcd938x->regmap, + WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0xC0); zdet_complete: snd_soc_component_write(component, WCD938X_ANA_MBHC_BTN5, reg0); snd_soc_component_write(component, WCD938X_ANA_MBHC_BTN6, reg1);