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

Commit 446929c0 authored by Yeleswarapu Nagaradhesh's avatar Yeleswarapu Nagaradhesh Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: wcd: add support for wcd9326 codec



Use efuse register values, to differentiate between
wcd9326 and wcd9335 codecs.

Change-Id: I68e7ae5eb1717dccd0af975670ac3644304996b9
Signed-off-by: default avatarYeleswarapu Nagaradhesh <nagaradh@codeaurora.org>
Signed-off-by: default avatarSimmi Pateriya <simmip@codeaurora.org>
parent 49c2753f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ enum codec_variant {
	WCD9XXX,
	WCD9330,
	WCD9335,
	WCD9326,
};

enum {
+64 −0
Original line number Diff line number Diff line
@@ -152,6 +152,8 @@ enum tasha_sido_voltage {
	SIDO_VOLTAGE_NOMINAL_MV = 1100,
};

static enum codec_variant codec_ver;

static int dig_core_collapse_enable = 1;
module_param(dig_core_collapse_enable, int,
		S_IRUGO | S_IWUSR | S_IWGRP);
@@ -12302,6 +12304,65 @@ err:
	return;
}

/*
 * tasha_codec_ver: to get tasha codec version
 * @codec: handle to snd_soc_codec *
 * return enum codec_variant - version
 */
enum codec_variant tasha_codec_ver(void)
{
	return codec_ver;
}
EXPORT_SYMBOL(tasha_codec_ver);

static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
{
	__tasha_cdc_mclk_enable(tasha, true);

	wcd9xxx_reg_update_bits(&tasha->wcd9xxx->core_res,
			WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
	wcd9xxx_reg_update_bits(&tasha->wcd9xxx->core_res,
			WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);

	/*
	 * 5ms sleep required after enabling efuse control
	 * before checking the status.
	 */
	usleep_range(5000, 5500);
	if (!(wcd9xxx_reg_read(&tasha->wcd9xxx->core_res,
				WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
		WARN(1, "%s: Efuse sense is not complete\n", __func__);

	__tasha_cdc_mclk_enable(tasha, false);

	return 0;
}

void tasha_get_codec_ver(struct tasha_priv *tasha)
{
	int i;
	u8 val;
	struct tasha_reg_mask_val codec_reg[] = {
		{WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
		{WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
		{WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
	};

	__tasha_enable_efuse_sensing(tasha);
	for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
		val = wcd9xxx_reg_read(&tasha->wcd9xxx->core_res,
				codec_reg[i].reg);
		if (!(val && codec_reg[i].val)) {
			codec_ver = WCD9335;
			goto ret;
		}
	}
	codec_ver = WCD9326;
ret:
	pr_debug("%s: codec is %d\n", __func__, codec_ver);
}
EXPORT_SYMBOL(tasha_get_codec_ver);

static int tasha_probe(struct platform_device *pdev)
{
	int ret = 0;
@@ -12394,6 +12455,9 @@ static int tasha_probe(struct platform_device *pdev)
	/* Update codec register default values */
	tasha_update_reg_defaults(tasha);
	schedule_work(&tasha->swr_add_devices_work);

	tasha_get_codec_ver(tasha);

	return ret;

resmgr_remove:
+1 −0
Original line number Diff line number Diff line
@@ -144,4 +144,5 @@ extern int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
						 bool enable);
extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode);
extern int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
extern enum codec_variant tasha_codec_ver(void);
#endif