ASoC: wcd-mbhc: set moisture thresholds for NO jack

Set moisture threshold values depending on the HW
configuration for NO Jack.

CRs-Fixed: 1099543
Change-Id: If995d462f1aeffb443471580520b1c8b5abca811
Signed-off-by: Yeleswarapu Nagaradhesh <nagaradh@codeaurora.org>
This commit is contained in:
Yeleswarapu Nagaradhesh 2016-12-22 10:50:05 +05:30
parent e379f786aa
commit a47c09691b
5 changed files with 33 additions and 9 deletions

View file

@ -1663,6 +1663,10 @@ mclk frequency needs to be configured for internal and external PA.
- qcom,cdc-comp-gpios : phandle for compander gpios. - qcom,cdc-comp-gpios : phandle for compander gpios.
- qcom,cdc-dmic-gpios : phandle for Digital mic clk and data gpios. - qcom,cdc-dmic-gpios : phandle for Digital mic clk and data gpios.
- qcom,cdc-sdw-gpios : phandle for soundwire clk and data gpios. - qcom,cdc-sdw-gpios : phandle for soundwire clk and data gpios.
- qcom,msm-mbhc-moist-cfg: This property is used to set moisture detection
threshold values for different codecs. First parameter is V(voltage)
second one is i(current), third one is r (resistance). Depending on the
codec set corresponding element in array and set others to 0.
Example: Example:
sound { sound {
@ -1671,6 +1675,7 @@ Example:
qcom,msm-mclk-freq = <9600000>; qcom,msm-mclk-freq = <9600000>;
qcom,msm-mbhc-hphl-swh = <0>; qcom,msm-mbhc-hphl-swh = <0>;
qcom,msm-mbhc-gnd-swh = <0>; qcom,msm-mbhc-gnd-swh = <0>;
qcom,msm-mbhc-moist-cfg = <1>, <3>, <0>;
qcom,msm-hs-micbias-type = "internal"; qcom,msm-hs-micbias-type = "internal";
qcom,msm-micbias1-ext-cap; qcom,msm-micbias1-ext-cap;
qcom,audio-routing = qcom,audio-routing =

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
@ -2380,6 +2380,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
int ret = 0; int ret = 0;
int hph_swh = 0; int hph_swh = 0;
int gnd_swh = 0; int gnd_swh = 0;
u32 hph_moist_config[3];
struct snd_soc_card *card = codec->component.card; struct snd_soc_card *card = codec->component.card;
const char *hph_switch = "qcom,msm-mbhc-hphl-swh"; const char *hph_switch = "qcom,msm-mbhc-hphl-swh";
const char *gnd_switch = "qcom,msm-mbhc-gnd-swh"; const char *gnd_switch = "qcom,msm-mbhc-gnd-swh";
@ -2400,6 +2401,21 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
goto err; goto err;
} }
ret = of_property_read_u32_array(card->dev->of_node,
"qcom,msm-mbhc-moist-cfg",
hph_moist_config, 3);
if (ret) {
dev_dbg(card->dev, "%s: no qcom,msm-mbhc-moist-cfg in DT\n",
__func__);
mbhc->moist_vref = V_45_MV;
mbhc->moist_iref = I_3P0_UA;
mbhc->moist_rref = R_24_KOHM;
} else {
mbhc->moist_vref = hph_moist_config[0];
mbhc->moist_iref = hph_moist_config[1];
mbhc->moist_rref = hph_moist_config[2];
}
mbhc->in_swch_irq_handler = false; mbhc->in_swch_irq_handler = false;
mbhc->current_plug = MBHC_PLUG_TYPE_NONE; mbhc->current_plug = MBHC_PLUG_TYPE_NONE;
mbhc->is_btn_press = false; mbhc->is_btn_press = false;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
@ -393,6 +393,9 @@ struct wcd_mbhc {
bool in_swch_irq_handler; bool in_swch_irq_handler;
bool hphl_swh; /*track HPHL switch NC / NO */ bool hphl_swh; /*track HPHL switch NC / NO */
bool gnd_swh; /*track GND switch NC / NO */ bool gnd_swh; /*track GND switch NC / NO */
u32 moist_vref;
u32 moist_iref;
u32 moist_rref;
u8 micbias1_cap_mode; /* track ext cap setting */ u8 micbias1_cap_mode; /* track ext cap setting */
u8 micbias2_cap_mode; /* track ext cap setting */ u8 micbias2_cap_mode; /* track ext cap setting */
bool hs_detect_work_stop; bool hs_detect_work_stop;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
@ -2202,7 +2202,7 @@ static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
{ {
struct snd_soc_codec *codec = mbhc->codec; struct snd_soc_codec *codec = mbhc->codec;
if (TASHA_MBHC_MOISTURE_VREF == V_OFF) if (mbhc->moist_vref == V_OFF)
return; return;
/* Donot enable moisture detection if jack type is NC */ /* Donot enable moisture detection if jack type is NC */
@ -2213,8 +2213,8 @@ static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
} }
snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2, snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2,
0x0C, TASHA_MBHC_MOISTURE_VREF << 2); 0x0C, mbhc->moist_vref << 2);
tasha_mbhc_hph_l_pull_up_control(codec, TASHA_MBHC_MOISTURE_IREF); tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref);
} }
static const struct wcd_mbhc_cb mbhc_cb = { static const struct wcd_mbhc_cb mbhc_cb = {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
@ -772,7 +772,7 @@ static void tavil_mbhc_moisture_config(struct wcd_mbhc *mbhc)
{ {
struct snd_soc_codec *codec = mbhc->codec; struct snd_soc_codec *codec = mbhc->codec;
if (TAVIL_MBHC_MOISTURE_RREF == R_OFF) if (mbhc->moist_rref == R_OFF)
return; return;
/* Donot enable moisture detection if jack type is NC */ /* Donot enable moisture detection if jack type is NC */
@ -783,7 +783,7 @@ static void tavil_mbhc_moisture_config(struct wcd_mbhc *mbhc)
} }
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2, snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2,
0x0C, TAVIL_MBHC_MOISTURE_RREF << 2); 0x0C, mbhc->moist_rref << 2);
} }
static bool tavil_hph_register_recovery(struct wcd_mbhc *mbhc) static bool tavil_hph_register_recovery(struct wcd_mbhc *mbhc)