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

Commit a345317a authored by Santosh Mardi's avatar Santosh Mardi Committed by Aviral Gupta
Browse files

ASoC: msm8x16: add master clock frequency property



8916 ULT audio core can support 9.6 and 12.28 MHz master frequency
and the frequencies can be used differently when internal codec only
or internal codec with external PA.

Add mclk frequency property in dtsi to inform machine driver to
configure master clock based on the value sent from the dtsi.

CRs-Fixed: 662773
Change-Id: I30880e13593477fe7f0c1211907ba6f3a1e2cd36
Signed-off-by: default avatarSantosh Mardi <gsantosh@codeaurora.org>
parent 143be413
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -526,6 +526,8 @@ Required properties:
- qcom,msm-ext-pa : This property is used to inform machine driver about
  the connection of external PA over secondary MI2S interface, val 0 external
  PA is not there, Val 1 external PA is connected.
- qcom,msm-mclk-freq : This property is used to inform machine driver about
mclk frequency needs to be configured for internal and external PA.
- qcom,msm-mbhc-hphl-swh: This property is used to distinguish headset HPHL
switch type on target typically the switch type will be normally open or
normally close, value for this property 0 for normally close and 1 for
@@ -563,6 +565,7 @@ Example:
		qcom,msm-snd-card-id = <0>;
		qcom,msm-codec-type = "internal";
		qcom,msm-ext-pa = <0>;
		qcom,msm-mclk-freq = <12288000>;
		qcom,msm-mbhc-hphl-swh = <0>;
		qcom,msm-mbhc-gnd-swh = <0>;
		qcom,msm-hs-micbias-type = "internal";
+1 −0
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@
		qcom,msm-ext-pa = <0>;
		qcom,msm-mbhc-hphl-swh = <0>;
		qcom,msm-mbhc-gnd-swh = <0>;
		qcom,msm-mclk-freq = <9600000>;
		qcom,msm-hs-micbias-type = "internal";
		qcom,audio-routing =
			"RX_BIAS", "MCLK",
+1 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@
		qcom,msm-snd-card-id = <0>;
		qcom,msm-codec-type = "internal";
		qcom,msm-ext-pa = <0>;
		qcom,msm-mclk-freq = <9600000>;
		qcom,msm-mbhc-hphl-swh = <0>;
		qcom,msm-mbhc-gnd-swh = <0>;
		qcom,msm-hs-micbias-type = "internal";
+11 −3
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@
#define CODEC_DT_MAX_PROP_SIZE			40
#define MSM8X16_DIGITAL_CODEC_REG_SIZE		0x400
#define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH	64
#define TOMBAK_MCLK_CLK_9P6MHZ			9600000

/*
 *50 Milliseconds sufficient for DSP bring up in the modem
@@ -337,7 +336,7 @@ static int __msm8x16_wcd_reg_read(struct snd_soc_codec *codec,
	else if (MSM8X16_WCD_IS_DIGITAL_REG(reg)) {
		mutex_lock(&pdata->cdc_mclk_mutex);
		if (atomic_read(&pdata->dis_work_mclk) == false) {
			pdata->digital_cdc_clk.clk_val = 9600000;
			pdata->digital_cdc_clk.clk_val = pdata->mclk_freq;
			ret = afe_set_digital_codec_core_clock(
					AFE_PORT_ID_PRIMARY_MI2S_RX,
					&pdata->digital_cdc_clk);
@@ -388,7 +387,7 @@ static int __msm8x16_wcd_reg_write(struct snd_soc_codec *codec,
		mutex_lock(&pdata->cdc_mclk_mutex);
		if (atomic_read(&pdata->dis_work_mclk) == false) {
			pr_debug("MCLK not enabled %s:\n", __func__);
			pdata->digital_cdc_clk.clk_val = 9600000;
			pdata->digital_cdc_clk.clk_val = pdata->mclk_freq;
			ret = afe_set_digital_codec_core_clock(
					AFE_PORT_ID_PRIMARY_MI2S_RX,
					&pdata->digital_cdc_clk);
@@ -2324,6 +2323,9 @@ static void msm8x16_wcd_shutdown(struct snd_pcm_substream *substream,
static int msm8x16_wcd_codec_enable_clock_block(struct snd_soc_codec *codec,
						int enable)
{
	struct msm8916_asoc_mach_data *pdata = NULL;

	pdata = snd_soc_card_get_drvdata(codec->card);
	if (enable) {
		snd_soc_update_bits(codec,
			MSM8X16_WCD_A_CDC_CLK_MCLK_CTL, 0x01, 0x01);
@@ -2335,6 +2337,12 @@ static int msm8x16_wcd_codec_enable_clock_block(struct snd_soc_codec *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);
		if (pdata->mclk_freq == 12288000)
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_CDC_TOP_CTL, 0x01, 0x00);
		else if (pdata->mclk_freq == 9600000)
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_CDC_TOP_CTL, 0x01, 0x01);
	} else {
		snd_soc_update_bits(codec,
			MSM8X16_WCD_A_DIGITAL_CDC_TOP_CLK_CTL, 0x0C, 0x00);
+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ struct msm8916_asoc_mach_data {
	int codec_type;
	int ext_pa;
	int us_euro_gpio;
	int mclk_freq;
	atomic_t mclk_rsc_ref;
	atomic_t dis_work_mclk;
	struct mutex cdc_mclk_mutex;
Loading