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

Commit a0bb8542 authored by Laxminath Kasam's avatar Laxminath Kasam Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: wcd: update sequences to handle boost during SSR



In SSR, soft resets are not toggled correctly. Update the
toggling logic to use soft resets as expected. Also
add logic to handle boost turn off properly in all boost
options before and after SSR.

Change-Id: I4faefb8b15511a5a8d92670fc85a02c8ce0723ac
Signed-off-by: default avatarLaxminath Kasam <lkasam@codeaurora.org>
parent 52e55f37
Loading
Loading
Loading
Loading
+69 −11
Original line number Diff line number Diff line
@@ -648,12 +648,12 @@ static void msm8x16_wcd_boost_on(struct snd_soc_codec *codec)
	snd_soc_update_bits(codec,
		MSM8X16_WCD_A_DIGITAL_PERPH_RESET_CTL3,
		0x0F, 0x0F);
	snd_soc_update_bits(codec,
	snd_soc_write(codec,
		MSM8X16_WCD_A_ANALOG_SEC_ACCESS,
		0xA5, 0xA5);
	snd_soc_update_bits(codec,
		0xA5);
	snd_soc_write(codec,
		MSM8X16_WCD_A_ANALOG_PERPH_RESET_CTL3,
		0x0F, 0x0F);
		0x0F);
	snd_soc_write(codec,
		MSM8X16_WCD_A_ANALOG_MASTER_BIAS_CTL,
		0x30);
@@ -697,12 +697,12 @@ static void msm8x16_wcd_boost_off(struct snd_soc_codec *codec)

static void msm8x16_wcd_bypass_on(struct snd_soc_codec *codec)
{
	snd_soc_update_bits(codec,
	snd_soc_write(codec,
		MSM8X16_WCD_A_ANALOG_SEC_ACCESS,
		0xA5, 0xA5);
	snd_soc_update_bits(codec,
		0xA5);
	snd_soc_write(codec,
		MSM8X16_WCD_A_ANALOG_PERPH_RESET_CTL3,
		0x07, 0x07);
		0x07);
	snd_soc_update_bits(codec,
		MSM8X16_WCD_A_ANALOG_BYPASS_MODE,
		0x02, 0x02);
@@ -4010,8 +4010,22 @@ static void msm8x16_wcd_codec_init_reg(struct snd_soc_codec *codec)

static int msm8x16_wcd_bringup(struct snd_soc_codec *codec)
{
	snd_soc_write(codec,
		MSM8X16_WCD_A_DIGITAL_SEC_ACCESS,
		0xA5);
	snd_soc_write(codec, MSM8X16_WCD_A_DIGITAL_PERPH_RESET_CTL4, 0x01);
	snd_soc_write(codec,
		MSM8X16_WCD_A_ANALOG_SEC_ACCESS,
		0xA5);
	snd_soc_write(codec, MSM8X16_WCD_A_ANALOG_PERPH_RESET_CTL4, 0x01);
	snd_soc_write(codec,
		MSM8X16_WCD_A_DIGITAL_SEC_ACCESS,
		0xA5);
	snd_soc_write(codec, MSM8X16_WCD_A_DIGITAL_PERPH_RESET_CTL4, 0x00);
	snd_soc_write(codec,
		MSM8X16_WCD_A_ANALOG_SEC_ACCESS,
		0xA5);
	snd_soc_write(codec, MSM8X16_WCD_A_ANALOG_PERPH_RESET_CTL4, 0x00);
	return 0;
}

@@ -4043,6 +4057,47 @@ static int msm8x16_wcd_device_down(struct snd_soc_codec *codec)
		MSM8X16_WCD_A_ANALOG_TX_1_EN, 0x3);
	msm8x16_wcd_write(codec,
		MSM8X16_WCD_A_ANALOG_TX_2_EN, 0x3);
	if (msm8x16_wcd_priv->boost_option == BOOST_ON_FOREVER) {
		if ((snd_soc_read(codec, MSM8X16_WCD_A_ANALOG_SPKR_DRV_CTL)
			& 0x80) == 0) {
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_CDC_CLK_MCLK_CTL,	0x01, 0x01);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_CDC_CLK_PDM_CTL, 0x03, 0x03);
			snd_soc_write(codec,
				MSM8X16_WCD_A_ANALOG_MASTER_BIAS_CTL, 0x30);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_DIGITAL_CDC_RST_CTL, 0x80, 0x80);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_DIGITAL_CDC_TOP_CLK_CTL,
				0x0C, 0x0C);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_DIGITAL_CDC_DIG_CLK_CTL,
				0x84, 0x84);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_DIGITAL_CDC_ANA_CLK_CTL,
				0x10, 0x10);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_ANALOG_SPKR_PWRSTG_CTL,
				0x1F, 0x1F);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_ANALOG_RX_COM_BIAS_DAC,
				0x90, 0x90);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_ANALOG_RX_EAR_CTL,
				0xFF, 0xFF);
			usleep_range(20, 21);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_ANALOG_SPKR_PWRSTG_CTL,
				0xFF, 0xFF);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_ANALOG_SPKR_DRV_CTL,
				0xE9, 0xE9);
		}
	}
	msm8x16_wcd_boost_off(codec);
	/* 40ms to allow boost to discharge */
	msleep(40);
	/* Disable PA to avoid pop during codec bring up */
	snd_soc_update_bits(codec, MSM8X16_WCD_A_ANALOG_RX_HPH_CNP_EN,
			0x30, 0x00);
@@ -4057,8 +4112,7 @@ static int msm8x16_wcd_device_down(struct snd_soc_codec *codec)
	msm8x16_wcd_write(codec,
		MSM8X16_WCD_A_ANALOG_SPKR_DAC_CTL, 0x93);

	msm8x16_wcd_write(codec, MSM8X16_WCD_A_DIGITAL_PERPH_RESET_CTL4, 0x1);
	msm8x16_wcd_write(codec, MSM8X16_WCD_A_ANALOG_PERPH_RESET_CTL4, 0x1);
	msm8x16_wcd_bringup(codec);
	atomic_set(&pdata->mclk_enabled, false);
	set_bit(BUS_DOWN, &msm8x16_wcd_priv->status_mask);
	snd_soc_card_change_online_state(codec->card, 0);
@@ -4097,13 +4151,17 @@ static int msm8x16_wcd_device_up(struct snd_soc_codec *codec)
	/* delay is required to make sure sound card state updated */
	usleep_range(5000, 5100);

	msm8x16_wcd_bringup(codec);
	msm8x16_wcd_codec_init_reg(codec);
	msm8x16_wcd_update_reg_defaults(codec);

	msm8x16_wcd_set_boost_v(codec);

	msm8x16_wcd_set_micb_v(codec);
	if (msm8x16_wcd_priv->boost_option == BOOST_ON_FOREVER)
		msm8x16_wcd_boost_on(codec);
	else if (msm8x16_wcd_priv->boost_option == BYPASS_ALWAYS)
		msm8x16_wcd_bypass_on(codec);

	msm8x16_wcd_configure_cap(codec, false, false);
	wcd_mbhc_stop(&msm8x16_wcd_priv->mbhc);
	wcd_mbhc_start(&msm8x16_wcd_priv->mbhc,