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

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

Merge "ASoc: msm: Support TDM dai clk attribute and freq configuration"

parents e673df7b 15903eb6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1311,6 +1311,13 @@ Optional properties:

 - pinctrl-x: Defines pinctrl state for each pin group.

 - qcom,msm-cpudai-tdm-clk-attribute: Clock attribute for tdm.
				0 - Clk invalid attribute
				1 - Clk attribute couple no
				2 - Clk attribute couple dividend
				3 - Clk attribute couple divisor
				4 - Clk attribute invert couple no

Example:

	qcom,msm-dai-tdm-quat-rx {
+57 −0
Original line number Diff line number Diff line
@@ -5147,6 +5147,27 @@ static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
	dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
		__func__, tdm_clk_set.clk_freq_in_hz);

	/* initialize static tdm clk attribute to default value */
	tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;

	/* extract tdm clk attribute into static */
	if (of_find_property(pdev->dev.of_node,
			"qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
		rc = of_property_read_u16(pdev->dev.of_node,
			"qcom,msm-cpudai-tdm-clk-attribute",
			&tdm_clk_set.clk_attri);
		if (rc) {
			dev_err(&pdev->dev, "%s: clk attribute from DT file %s\n",
				__func__, "qcom,msm-cpudai-tdm-clk-attribute");
			goto rtn;
		}
		dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
			__func__, tdm_clk_set.clk_attri);
	} else {
		dev_dbg(&pdev->dev, "%s: No optional clk attribute found\n",
			__func__);
	}

	/* extract tdm clk src master/slave info into static */
	rc = of_property_read_u32(pdev->dev.of_node,
		"qcom,msm-cpudai-tdm-clk-internal",
@@ -6226,6 +6247,41 @@ static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
	return rc;
}

static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
				int clk_id, unsigned int freq, int dir)
{
	struct msm_dai_q6_tdm_dai_data *dai_data =
		dev_get_drvdata(dai->dev);

	switch (dai->id) {
	case AFE_PORT_ID_PRIMARY_TDM_RX:
	case AFE_PORT_ID_PRIMARY_TDM_RX_1:
	case AFE_PORT_ID_PRIMARY_TDM_RX_2:
	case AFE_PORT_ID_PRIMARY_TDM_RX_3:
	case AFE_PORT_ID_PRIMARY_TDM_RX_4:
	case AFE_PORT_ID_PRIMARY_TDM_RX_5:
	case AFE_PORT_ID_PRIMARY_TDM_RX_6:
	case AFE_PORT_ID_PRIMARY_TDM_RX_7:
	case AFE_PORT_ID_PRIMARY_TDM_TX:
	case AFE_PORT_ID_PRIMARY_TDM_TX_1:
	case AFE_PORT_ID_PRIMARY_TDM_TX_2:
	case AFE_PORT_ID_PRIMARY_TDM_TX_3:
	case AFE_PORT_ID_PRIMARY_TDM_TX_4:
	case AFE_PORT_ID_PRIMARY_TDM_TX_5:
	case AFE_PORT_ID_PRIMARY_TDM_TX_6:
	case AFE_PORT_ID_PRIMARY_TDM_TX_7:
		dai_data->clk_set.clk_freq_in_hz = freq;
		break;
	default:
		return 0;
	}

	dev_dbg(dai->dev, "%s: dai id = 0x%x group clk_freq %d\n",
			__func__, dai->id, freq);
	return 0;
}


static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
				unsigned int tx_num, unsigned int *tx_slot,
				unsigned int rx_num, unsigned int *rx_slot)
@@ -6653,6 +6709,7 @@ static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
	.hw_params        = msm_dai_q6_tdm_hw_params,
	.set_tdm_slot     = msm_dai_q6_tdm_set_tdm_slot,
	.set_channel_map  = msm_dai_q6_tdm_set_channel_map,
	.set_sysclk       = msm_dai_q6_tdm_set_sysclk,
	.shutdown         = msm_dai_q6_tdm_shutdown,
};