asoc: codecs: Add comparator autozeroing support for rouleur
When current source mode is enabled, comparator auto zeroing should be turned ON by HW. As rouleur codec HW doesn't do this automatically, add this support in SW to set the auto zero enable before FSM enable and reset to auto once FSM is enabled. Disable surge protection before ADC measurements and change HPHL and HPHR thresholds while identifying cross connection for proper accessory identification. Change-Id: Ib775de0f0bdb6c655a3c0eb4775276acfbca1e84 Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
This commit is contained in:

committed by
Akhil Karuturi

vanhempi
c3fd6cc305
commit
313aa17ac4
@@ -37,6 +37,10 @@
|
||||
#define ROULEUR_MBHC_ZDET_CONST (86 * 16384)
|
||||
#define ROULEUR_MBHC_MOISTURE_RREF R_24_KOHM
|
||||
|
||||
/* Cross connection thresholds in mV */
|
||||
#define ROULEUR_HPHL_CROSS_CONN_THRESHOLD 200
|
||||
#define ROULEUR_HPHR_CROSS_CONN_THRESHOLD 200
|
||||
|
||||
static struct wcd_mbhc_register
|
||||
wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
|
||||
WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
|
||||
@@ -320,11 +324,11 @@ static void rouleur_mbhc_micb_ramp_control(struct snd_soc_component *component,
|
||||
0x1C, 0x0C);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_ANA_MBHC_MICB2_RAMP,
|
||||
0xA0, 0x80);
|
||||
0x80, 0x80);
|
||||
} else {
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_ANA_MBHC_MICB2_RAMP,
|
||||
0xA0, 0x00);
|
||||
0x80, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_ANA_MBHC_MICB2_RAMP,
|
||||
0x1C, 0x00);
|
||||
@@ -820,15 +824,6 @@ static void rouleur_mbhc_bcs_enable(struct wcd_mbhc *mbhc,
|
||||
rouleur_disable_bcs_before_slow_insert(mbhc->component, true);
|
||||
}
|
||||
|
||||
static void rouleur_mbhc_hs_vref_max_update(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
/* Update the HS Vref max voltage to 1.7V */
|
||||
snd_soc_component_update_bits(component, ROULEUR_ANA_MBHC_CTL_2,
|
||||
0x03, 0x03);
|
||||
}
|
||||
|
||||
static void rouleur_mbhc_get_micbias_val(struct wcd_mbhc *mbhc, int *mb)
|
||||
{
|
||||
u8 vout_ctl = 0;
|
||||
@@ -843,19 +838,40 @@ static void rouleur_mbhc_get_micbias_val(struct wcd_mbhc *mbhc, int *mb)
|
||||
pr_debug("%s: vout_ctl: %d, micbias: %d\n", __func__, vout_ctl, *mb);
|
||||
}
|
||||
|
||||
static void rouleur_mbhc_micb_pullup_control(
|
||||
struct snd_soc_component *component,
|
||||
bool pullup_enable)
|
||||
static void rouleur_mbhc_comp_autozero_control(struct wcd_mbhc *mbhc,
|
||||
bool az_enable)
|
||||
{
|
||||
if (pullup_enable)
|
||||
rouleur_micbias_control(component, MIC_BIAS_2,
|
||||
MICB_PULLUP_ENABLE, false);
|
||||
if (az_enable)
|
||||
snd_soc_component_update_bits(mbhc->component,
|
||||
ROULEUR_ANA_MBHC_MCLK, 0x08, 0x08);
|
||||
else
|
||||
rouleur_micbias_control(component, MIC_BIAS_2,
|
||||
MICB_PULLUP_DISABLE, false);
|
||||
snd_soc_component_update_bits(mbhc->component,
|
||||
ROULEUR_ANA_MBHC_MCLK, 0x08, 0x00);
|
||||
|
||||
}
|
||||
|
||||
static void rouleur_mbhc_surge_control(struct wcd_mbhc *mbhc,
|
||||
bool surge_enable)
|
||||
{
|
||||
if (surge_enable)
|
||||
snd_soc_component_update_bits(mbhc->component,
|
||||
ROULEUR_ANA_SURGE_EN, 0xC0, 0xC0);
|
||||
else
|
||||
snd_soc_component_update_bits(mbhc->component,
|
||||
ROULEUR_ANA_SURGE_EN, 0xC0, 0x00);
|
||||
|
||||
}
|
||||
|
||||
static void rouleur_mbhc_update_cross_conn_thr(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
mbhc->hphl_cross_conn_thr = ROULEUR_HPHL_CROSS_CONN_THRESHOLD;
|
||||
mbhc->hphr_cross_conn_thr = ROULEUR_HPHR_CROSS_CONN_THRESHOLD;
|
||||
|
||||
pr_debug("%s: Cross connection threshold for hphl: %d, hphr: %d\n",
|
||||
__func__, mbhc->hphl_cross_conn_thr,
|
||||
mbhc->hphr_cross_conn_thr);
|
||||
}
|
||||
|
||||
static const struct wcd_mbhc_cb mbhc_cb = {
|
||||
.request_irq = rouleur_mbhc_request_irq,
|
||||
.irq_control = rouleur_mbhc_irq_control,
|
||||
@@ -880,9 +896,10 @@ static const struct wcd_mbhc_cb mbhc_cb = {
|
||||
.mbhc_get_moisture_status = rouleur_mbhc_get_moisture_status,
|
||||
.mbhc_moisture_detect_en = rouleur_mbhc_moisture_detect_en,
|
||||
.bcs_enable = rouleur_mbhc_bcs_enable,
|
||||
.hs_vref_max_update = rouleur_mbhc_hs_vref_max_update,
|
||||
.get_micbias_val = rouleur_mbhc_get_micbias_val,
|
||||
.mbhc_micb_pullup_control = rouleur_mbhc_micb_pullup_control,
|
||||
.mbhc_comp_autozero_control = rouleur_mbhc_comp_autozero_control,
|
||||
.mbhc_surge_ctl = rouleur_mbhc_surge_control,
|
||||
.update_cross_conn_thr = rouleur_mbhc_update_cross_conn_thr,
|
||||
};
|
||||
|
||||
static int rouleur_get_hph_type(struct snd_kcontrol *kcontrol,
|
||||
|
@@ -107,6 +107,9 @@ static int rouleur_handle_post_irq(void *data)
|
||||
|
||||
static int rouleur_init_reg(struct snd_soc_component *component)
|
||||
{
|
||||
/* Disable HPH OCP */
|
||||
snd_soc_component_update_bits(component, ROULEUR_ANA_HPHPA_CNP_CTL_2,
|
||||
0x03, 0x00);
|
||||
/* Enable surge protection */
|
||||
snd_soc_component_update_bits(component, ROULEUR_ANA_SURGE_EN,
|
||||
0xC0, 0xC0);
|
||||
@@ -354,7 +357,7 @@ static int rouleur_rx_clk_enable(struct snd_soc_component *component)
|
||||
usleep_range(5000, 5100);
|
||||
rouleur_global_mbias_enable(component);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_ANA_HPHPA_FSM_CLK, 0x11, 0x11);
|
||||
ROULEUR_ANA_HPHPA_FSM_CLK, 0x7F, 0x11);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_ANA_HPHPA_FSM_CLK, 0x80, 0x80);
|
||||
snd_soc_component_update_bits(component,
|
||||
@@ -382,14 +385,14 @@ static int rouleur_rx_clk_disable(struct snd_soc_component *component)
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_ANA_HPHPA_FSM_CLK, 0x80, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_ANA_HPHPA_FSM_CLK, 0x11, 0x00);
|
||||
ROULEUR_ANA_HPHPA_FSM_CLK, 0x7F, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_ANA_NCP_EN, 0x01, 0x00);
|
||||
rouleur_global_mbias_disable(component);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_CLK_CTL, 0x20, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_CLK_CTL, 0x10, 0x00);
|
||||
rouleur_global_mbias_disable(component);
|
||||
|
||||
}
|
||||
mutex_unlock(&rouleur->rx_clk_lock);
|
||||
@@ -478,8 +481,15 @@ static int rouleur_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_CLK_CTL,
|
||||
0x01, 0x00);
|
||||
ROULEUR_DIG_SWR_CDC_RX_CLK_CTL,
|
||||
0x01, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_GAIN_CTL,
|
||||
0x04, 0x00);
|
||||
if (rouleur->comp1_enable)
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_COMP_CTL_0,
|
||||
0x02, 0x00);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -544,6 +554,13 @@ static int rouleur_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_CLK_CTL, 0x02, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_GAIN_CTL,
|
||||
0x08, 0x00);
|
||||
if (rouleur->comp2_enable)
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_COMP_CTL_0,
|
||||
0x01, 0x00);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -567,18 +584,21 @@ static int rouleur_codec_ear_lo_dac_event(struct snd_soc_dapm_widget *w,
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX0_CTL,
|
||||
0x7C, 0x7C);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_CLK_CTL,
|
||||
0x01, 0x01);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_GAIN_CTL,
|
||||
0x04, 0x04);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_CLK_CTL,
|
||||
0x01, 0x01);
|
||||
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_CLK_CTL,
|
||||
0x01, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
ROULEUR_DIG_SWR_CDC_RX_GAIN_CTL,
|
||||
0x04, 0x00);
|
||||
|
||||
break;
|
||||
};
|
||||
|
Viittaa uudesa ongelmassa
Block a user