Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53d316ac authored by Vatsal Bucha's avatar Vatsal Bucha Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: mbhc-adc: Fix fake electrical removal interrupts on rouleur aatc



Auto Zero mode needs to be enabled before fsm enable in sw
if hw dosen't enable auto zero mode. Do this for measure_adc_once
and cross_conn check to resolve fake electrical interrupts after
headset insertion.

Change-Id: I6915440fbccc84cab1c08710829ca5ca4276b4a5
Signed-off-by: default avatarVatsal Bucha <vbucha@codeaurora.org>
parent 5154124e
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -138,7 +138,20 @@ static int wcd_measure_adc_once(struct wcd_mbhc *mbhc, int mux_ctl)
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
	/* Set the appropriate MUX selection */
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, mux_ctl);
	/*
	 * Current source mode requires Auto zeroing to be enabled
	 * automatically. If HW doesn't do it, SW has to take care of this
	 * for button interrupts to work fine and to avoid
	 * fake electrical removal interrupts by enabling autozero before FSM
	 * enable and disable it after FSM enable
	 */
	if (mbhc->mbhc_cb->mbhc_comp_autozero_control)
		mbhc->mbhc_cb->mbhc_comp_autozero_control(mbhc,
							true);
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
	if (mbhc->mbhc_cb->mbhc_comp_autozero_control)
		mbhc->mbhc_cb->mbhc_comp_autozero_control(mbhc,
							false);
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 1);

	while (retry--) {
@@ -351,8 +364,20 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc)
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
	/* Set the MUX selection to Auto */
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, MUX_CTL_AUTO);
	/*
	 * Current source mode requires Auto zeroing to be enabled
	 * automatically. If HW doesn't do it, SW has to take care of this
	 * for button interrupts to work fine and to avoid
	 * fake electrical removal interrupts by enabling autozero before FSM
	 * enable and disable it after FSM enable
	 */
	if (mbhc->mbhc_cb->mbhc_comp_autozero_control)
		mbhc->mbhc_cb->mbhc_comp_autozero_control(mbhc,
							true);
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);

	if (mbhc->mbhc_cb->mbhc_comp_autozero_control)
		mbhc->mbhc_cb->mbhc_comp_autozero_control(mbhc,
							false);
	/* Restore ADC Enable */
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, adc_en);