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

Commit 78cd56d3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: wcd934x: Update DSD register sequence for v1.1"

parents d887e436 7eb661ba
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@
#define DSD_VOLUME_STEP_DELAY_US    ((1000 * DSD_VOLUME_UPDATE_DELAY_MS) / \
				     (2 * DSD_VOLUME_STEPS))

#define TAVIL_VERSION_1_0  0
#define TAVIL_VERSION_1_1  1

static const DECLARE_TLV_DB_MINMAX(tavil_dsd_db_scale, DSD_VOLUME_MIN_M110dB,
				   DSD_VOLUME_MAX_0dB);

@@ -369,6 +372,14 @@ static void tavil_dsd_data_pull(struct snd_soc_codec *codec, int dsd_num,
	}
}

static void tavil_dsd_update_volume(struct tavil_dsd_config *dsd_conf)
{
	snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0,
			    0x01, 0x01);
	snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0,
			    0x01, 0x00);
}

static int tavil_enable_dsd(struct snd_soc_dapm_widget *w,
			    struct snd_kcontrol *kcontrol, int event)
{
@@ -429,6 +440,8 @@ static int tavil_enable_dsd(struct snd_soc_dapm_widget *w,
			/* Apply Gain */
			snd_soc_write(codec, WCD934X_CDC_DSD0_CFG1,
				      dsd_conf->volume[DSD0]);
			if (dsd_conf->version == TAVIL_VERSION_1_1)
				tavil_dsd_update_volume(dsd_conf);

		} else if (w->shift == DSD1) {
			snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
@@ -440,6 +453,8 @@ static int tavil_enable_dsd(struct snd_soc_dapm_widget *w,
			/* Apply Gain */
			snd_soc_write(codec, WCD934X_CDC_DSD1_CFG1,
				      dsd_conf->volume[DSD1]);
			if (dsd_conf->version == TAVIL_VERSION_1_1)
				tavil_dsd_update_volume(dsd_conf);
		}
		/* 10msec sleep required after DSD clock is set */
		usleep_range(10000, 10100);
@@ -538,16 +553,23 @@ static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol,
			snd_soc_write(codec,
				      WCD934X_CDC_DSD0_CFG1 + 16 * dsd_idx,
				      nv1);
			if (dsd_conf->version == TAVIL_VERSION_1_1)
				tavil_dsd_update_volume(dsd_conf);

			/* sleep required after each volume step */
			usleep_range(DSD_VOLUME_STEP_DELAY_US,
				     (DSD_VOLUME_STEP_DELAY_US +
				      DSD_VOLUME_USLEEP_MARGIN_US));
		}
		if (nv1 != nv[dsd_idx])
		if (nv1 != nv[dsd_idx]) {
			snd_soc_write(codec,
				      WCD934X_CDC_DSD0_CFG1 + 16 * dsd_idx,
				      nv[dsd_idx]);

			if (dsd_conf->version == TAVIL_VERSION_1_1)
				tavil_dsd_update_volume(dsd_conf);
		}

		dsd_conf->volume[dsd_idx] = nv[dsd_idx];
	}

@@ -629,9 +651,14 @@ struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec)

	dsd_conf->codec = codec;

	/* Read version */
	dsd_conf->version = snd_soc_read(codec,
					 WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0);
	/* DSD registers init */
	if (dsd_conf->version == TAVIL_VERSION_1_0) {
		snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x02, 0x00);
		snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x02, 0x00);
	}
	/* DSD0: Mute EN */
	snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x04, 0x04);
	/* DSD1: Mute EN */
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ struct tavil_dsd_config {
	u32 base_sample_rate[DSD_MAX];
	int volume[DSD_MAX];
	struct mutex vol_mutex;
	int version;
};

#ifdef CONFIG_SND_SOC_WCD934X_DSD
+74 −28
Original line number Diff line number Diff line
@@ -1859,6 +1859,7 @@ static int tavil_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,

	switch (event) {
	case SND_SOC_DAPM_PRE_PMU:
		if (TAVIL_IS_1_0(tavil->wcd9xxx))
			snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL,
					    0x06, (0x03 << 1));
		set_bit(HPH_PA_DELAY, &tavil->status_mask);
@@ -1922,6 +1923,7 @@ static int tavil_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
		blocking_notifier_call_chain(&tavil->mbhc->notifier,
					     WCD_EVENT_POST_HPHR_PA_OFF,
					     &tavil->mbhc->wcd_mbhc);
		if (TAVIL_IS_1_0(tavil->wcd9xxx))
			snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL,
					    0x06, 0x0);
		break;
@@ -1942,6 +1944,7 @@ static int tavil_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,

	switch (event) {
	case SND_SOC_DAPM_PRE_PMU:
		if (TAVIL_IS_1_0(tavil->wcd9xxx))
			snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL,
					    0x06, (0x03 << 1));
		set_bit(HPH_PA_DELAY, &tavil->status_mask);
@@ -2004,6 +2007,7 @@ static int tavil_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
		blocking_notifier_call_chain(&tavil->mbhc->notifier,
					     WCD_EVENT_POST_HPHL_PA_OFF,
					     &tavil->mbhc->wcd_mbhc);
		if (TAVIL_IS_1_0(tavil->wcd9xxx))
			snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL,
					    0x06, 0x0);
		break;
@@ -2130,9 +2134,10 @@ static int tavil_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1,
				    0x02, 0x00);
		/* Set RDAC gain */
		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
		if (TAVIL_IS_1_0(tavil->wcd9xxx))
			snd_soc_update_bits(codec,
					    WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
					    0xF0, 0x40);

		if (dsd_conf &&
		    (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01))
			hph_mode = CLS_H_HIFI;
@@ -2155,7 +2160,9 @@ static int tavil_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
					    WCD934X_SIDO_NEW_VOUT_D_FREQ2,
					    0x01, 0x0);
		/* Re-set RDAC gain */
		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
		if (TAVIL_IS_1_0(tavil->wcd9xxx))
			snd_soc_update_bits(codec,
					    WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
					    0xF0, 0x0);
		break;
	default:
@@ -2199,7 +2206,9 @@ static int tavil_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1,
				    0x02, 0x00);
		/* Set RDAC gain */
		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
		if (TAVIL_IS_1_0(tavil->wcd9xxx))
			snd_soc_update_bits(codec,
					    WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
					    0xF0, 0x40);
		if (dsd_conf &&
		    (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01))
@@ -2223,7 +2232,9 @@ static int tavil_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
					    WCD934X_SIDO_NEW_VOUT_D_FREQ2,
					    0x01, 0x0);
		/* Re-set RDAC gain */
		snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
		if (TAVIL_IS_1_0(tavil->wcd9xxx))
			snd_soc_update_bits(codec,
					    WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL,
					    0xF0, 0x0);
		break;
	default:
@@ -2820,11 +2831,15 @@ static void tavil_codec_hphdelay_lutbypass(struct snd_soc_codec *codec,
	}
}

static void tavil_codec_hd2_control(struct snd_soc_codec *codec,
static void tavil_codec_hd2_control(struct tavil_priv *priv,
				    u16 interp_idx, int event)
{
	u16 hd2_scale_reg;
	u16 hd2_enable_reg = 0;
	struct snd_soc_codec *codec = priv->codec;

	if (TAVIL_IS_1_1(priv->wcd9xxx))
		return;

	switch (interp_idx) {
	case INTERP_HPHL:
@@ -3002,7 +3017,7 @@ int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
			snd_soc_update_bits(codec, main_reg, 0x20, 0x20);
			tavil_codec_idle_detect_control(codec, interp_idx,
							event);
			tavil_codec_hd2_control(codec, interp_idx, event);
			tavil_codec_hd2_control(tavil, interp_idx, event);
			tavil_codec_hphdelay_lutbypass(codec, interp_idx,
						       event);
			tavil_config_compander(codec, interp_idx, event);
@@ -3017,7 +3032,7 @@ int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
			tavil_config_compander(codec, interp_idx, event);
			tavil_codec_hphdelay_lutbypass(codec, interp_idx,
						       event);
			tavil_codec_hd2_control(codec, interp_idx, event);
			tavil_codec_hd2_control(tavil, interp_idx, event);
			tavil_codec_idle_detect_control(codec, interp_idx,
							event);
			/* Clk Disable */
@@ -7837,7 +7852,11 @@ static const struct wcd_resmgr_cb tavil_resmgr_cb = {
	.cdc_rco_ctrl = __tavil_codec_internal_rco_ctrl,
};

static const struct tavil_reg_mask_val tavil_codec_mclk2_defaults[] = {
static const struct tavil_reg_mask_val tavil_codec_mclk2_1_1_defaults[] = {
	{WCD934X_CLK_SYS_MCLK2_PRG1, 0x60, 0x20},
};

static const struct tavil_reg_mask_val tavil_codec_mclk2_1_0_defaults[] = {
	/*
	 * PLL Settings:
	 * Clock Root: MCLK2,
@@ -7896,6 +7915,13 @@ static const struct tavil_reg_mask_val tavil_codec_reg_defaults[] = {
	{WCD934X_HPH_R_TEST, 0x01, 0x01},
};

static const struct tavil_reg_mask_val tavil_codec_reg_init_1_1_val[] = {
	{WCD934X_CDC_COMPANDER1_CTL7, 0x1E, 0x06},
	{WCD934X_CDC_COMPANDER2_CTL7, 0x1E, 0x06},
	{WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0xFF, 0x84},
	{WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0xFF, 0x84},
};

static const struct tavil_reg_mask_val tavil_codec_reg_init_common_val[] = {
	{WCD934X_CDC_CLSH_K2_MSB, 0x0F, 0x00},
	{WCD934X_CDC_CLSH_K2_LSB, 0xFF, 0x60},
@@ -7922,8 +7948,9 @@ static const struct tavil_reg_mask_val tavil_codec_reg_init_common_val[] = {
	{WCD934X_CPE_SS_SVA_CFG, 0x60, 0x00},
};

static void tavil_codec_init_reg(struct snd_soc_codec *codec)
static void tavil_codec_init_reg(struct tavil_priv *priv)
{
	struct snd_soc_codec *codec = priv->codec;
	u32 i;

	for (i = 0; i < ARRAY_SIZE(tavil_codec_reg_init_common_val); i++)
@@ -7931,6 +7958,14 @@ static void tavil_codec_init_reg(struct snd_soc_codec *codec)
				    tavil_codec_reg_init_common_val[i].reg,
				    tavil_codec_reg_init_common_val[i].mask,
				    tavil_codec_reg_init_common_val[i].val);

	if (TAVIL_IS_1_1(priv->wcd9xxx)) {
		for (i = 0; i < ARRAY_SIZE(tavil_codec_reg_init_1_1_val); i++)
			snd_soc_update_bits(codec,
					tavil_codec_reg_init_1_1_val[i].reg,
					tavil_codec_reg_init_1_1_val[i].mask,
					tavil_codec_reg_init_1_1_val[i].val);
	}
}

static void tavil_update_reg_defaults(struct tavil_priv *tavil)
@@ -8367,11 +8402,22 @@ static void tavil_mclk2_reg_defaults(struct tavil_priv *tavil)
	int i;
	struct snd_soc_codec *codec = tavil->codec;

	if (TAVIL_IS_1_0(tavil->wcd9xxx)) {
		/* MCLK2 configuration */
	for (i = 0; i < ARRAY_SIZE(tavil_codec_mclk2_defaults); i++)
		snd_soc_update_bits(codec, tavil_codec_mclk2_defaults[i].reg,
				    tavil_codec_mclk2_defaults[i].mask,
				    tavil_codec_mclk2_defaults[i].val);
		for (i = 0; i < ARRAY_SIZE(tavil_codec_mclk2_1_0_defaults); i++)
			snd_soc_update_bits(codec,
					tavil_codec_mclk2_1_0_defaults[i].reg,
					tavil_codec_mclk2_1_0_defaults[i].mask,
					tavil_codec_mclk2_1_0_defaults[i].val);
	}
	if (TAVIL_IS_1_1(tavil->wcd9xxx)) {
		/* MCLK2 configuration */
		for (i = 0; i < ARRAY_SIZE(tavil_codec_mclk2_1_1_defaults); i++)
			snd_soc_update_bits(codec,
					tavil_codec_mclk2_1_1_defaults[i].reg,
					tavil_codec_mclk2_1_1_defaults[i].mask,
					tavil_codec_mclk2_1_1_defaults[i].val);
	}
}

static int tavil_soc_codec_probe(struct snd_soc_codec *codec)
@@ -8429,7 +8475,7 @@ static int tavil_soc_codec_probe(struct snd_soc_codec *codec)
	for (i = 0; i < COMPANDER_MAX; i++)
		tavil->comp_enabled[i] = 0;

	tavil_codec_init_reg(codec);
	tavil_codec_init_reg(tavil);
	tavil_enable_sido_buck(codec);

	pdata = dev_get_platdata(codec->dev->parent);
+3 −2
Original line number Diff line number Diff line
@@ -369,6 +369,7 @@ static inline void wcd_clsh_gm3_boost_disable(struct snd_soc_codec *codec,

	if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
	    mode == CLS_AB_HIFI || mode == CLS_AB) {
		if (TAVIL_IS_1_0(wcd9xxx))
			snd_soc_update_bits(codec, WCD9XXX_HPH_CNP_WG_CTL,
					    0x80, 0x0); /* disable GM3 Boost */
		snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4,