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

Commit 99b6bab0 authored by Karthikeyan Mani's avatar Karthikeyan Mani Committed by Banajit Goswami
Browse files

ASoC: msm: qdsp6v2: Add TDM master slave select setting



Add TDM clock id setting in TDM parent node to
select between IBIT and EBIT for TDM operation.
Move dtsi entries from child to parent that are
common to the group.

CRs-fixed: 1116515
Change-Id: I663eb926818c2aae1eaea8c78bdc0a973ecd0ae3
Signed-off-by: default avatarKarthikeyan Mani <kmani@codeaurora.org>
parent 7f43e7eb
Loading
Loading
Loading
Loading
+16 −11
Original line number Diff line number Diff line
@@ -1151,12 +1151,9 @@ Required properties:
				When clock rate is set to zero,
				then external clock is assumed.

 [Second Level Nodes]

Required properties:

 - compatible : "qcom,msm-dai-q6-tdm"
 - qcom,msm-dai-q6-mi2s-dev-id: TDM port ID.
 - qcom,msm-cpudai-tdm-clk-internal: Clock Source.
				0 - EBIT clock from clk tree
				1 - IBIT clock from clk tree

 - qcom,msm-cpudai-tdm-sync-mode: Synchronization setting.
				0 - Short sync bit mode
@@ -1181,6 +1178,13 @@ Required properties:
				1 - 1 bit clock cycle
				2 - 2 bit clock cycle

 [Second Level Nodes]

Required properties:

 - compatible : "qcom,msm-dai-q6-tdm"
 - qcom,msm-dai-q6-mi2s-dev-id: TDM port ID.

 - qcom,msm-cpudai-tdm-data-align: Indicate how data is packed
				within the slot. For example, 32 slot width in case of
				sample bit width is 24.
@@ -1215,17 +1219,18 @@ Example:
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36912>;
		qcom,msm-cpudai-tdm-clk-rate = <12288000>;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <0>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <0>;
		qcom,msm-cpudai-tdm-data-delay = <0>;
		pinctrl-names = "default", "sleep";
		pinctrl-0 = <&quat_tdm_active &quat_tdm_dout_active>;
		pinctrl-1 = <&quat_tdm_sleep &quat_tdm_dout_sleep>;
		dai_quat_tdm_rx_0: qcom,msm-dai-q6-tdm-quat-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36912>;
			qcom,msm-cpudai-tdm-sync-mode = <0>;
			qcom,msm-cpudai-tdm-sync-src = <1>;
			qcom,msm-cpudai-tdm-data-out = <0>;
			qcom,msm-cpudai-tdm-invert-sync = <0>;
			qcom,msm-cpudai-tdm-data-delay = <0>;
			qcom,msm-cpudai-tdm-data-align = <0>;
			qcom,msm-cpudai-tdm-header-start-offset = <0>;
			qcom,msm-cpudai-tdm-header-width = <2>;
+48 −40
Original line number Diff line number Diff line
@@ -377,14 +377,15 @@
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36864>;
		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
		dai_pri_tdm_rx_0: qcom,msm-dai-q6-tdm-pri-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36864>;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <1>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <1>;
		qcom,msm-cpudai-tdm-data-delay = <1>;
		dai_pri_tdm_rx_0: qcom,msm-dai-q6-tdm-pri-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36864>;
			qcom,msm-cpudai-tdm-data-align = <0>;
		};
	};
@@ -395,14 +396,15 @@
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36865>;
		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
		dai_pri_tdm_tx_0: qcom,msm-dai-q6-tdm-pri-tx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36865>;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <1>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <1>;
		qcom,msm-cpudai-tdm-data-delay = <1>;
		dai_pri_tdm_tx_0: qcom,msm-dai-q6-tdm-pri-tx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36865>;
			qcom,msm-cpudai-tdm-data-align = <0>;
		};
	};
@@ -413,14 +415,15 @@
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36880>;
		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
		dai_sec_tdm_rx_0: qcom,msm-dai-q6-tdm-sec-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36880>;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <1>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <1>;
		qcom,msm-cpudai-tdm-data-delay = <1>;
		dai_sec_tdm_rx_0: qcom,msm-dai-q6-tdm-sec-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36880>;
			qcom,msm-cpudai-tdm-data-align = <0>;
		};
	};
@@ -431,14 +434,15 @@
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36881>;
		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
		dai_sec_tdm_tx_0: qcom,msm-dai-q6-tdm-sec-tx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36881>;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <1>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <1>;
		qcom,msm-cpudai-tdm-data-delay = <1>;
		dai_sec_tdm_tx_0: qcom,msm-dai-q6-tdm-sec-tx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36881>;
			qcom,msm-cpudai-tdm-data-align = <0>;
		};
	};
@@ -449,14 +453,15 @@
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36896>;
		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
		dai_tert_tdm_rx_0: qcom,msm-dai-q6-tdm-tert-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36896>;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <1>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <1>;
		qcom,msm-cpudai-tdm-data-delay = <1>;
		dai_tert_tdm_rx_0: qcom,msm-dai-q6-tdm-tert-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36896>;
			qcom,msm-cpudai-tdm-data-align = <0>;
		};
	};
@@ -467,14 +472,15 @@
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36897 >;
		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
		dai_tert_tdm_tx_0: qcom,msm-dai-q6-tdm-tert-tx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36897 >;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <1>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <1>;
		qcom,msm-cpudai-tdm-data-delay = <1>;
		dai_tert_tdm_tx_0: qcom,msm-dai-q6-tdm-tert-tx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36897 >;
			qcom,msm-cpudai-tdm-data-align = <0>;
		};
	};
@@ -485,14 +491,15 @@
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36912>;
		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
		dai_quat_tdm_rx_0: qcom,msm-dai-q6-tdm-quat-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36912>;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <1>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <1>;
		qcom,msm-cpudai-tdm-data-delay = <1>;
		dai_quat_tdm_rx_0: qcom,msm-dai-q6-tdm-quat-rx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36912>;
			qcom,msm-cpudai-tdm-data-align = <0>;
		};
	};
@@ -503,14 +510,15 @@
		qcom,msm-cpudai-tdm-group-num-ports = <1>;
		qcom,msm-cpudai-tdm-group-port-id = <36913 >;
		qcom,msm-cpudai-tdm-clk-rate = <1536000>;
		dai_quat_tdm_tx_0: qcom,msm-dai-q6-tdm-quat-tx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36913 >;
		qcom,msm-cpudai-tdm-clk-internal = <1>;
		qcom,msm-cpudai-tdm-sync-mode = <1>;
		qcom,msm-cpudai-tdm-sync-src = <1>;
		qcom,msm-cpudai-tdm-data-out = <0>;
		qcom,msm-cpudai-tdm-invert-sync = <1>;
		qcom,msm-cpudai-tdm-data-delay = <1>;
		dai_quat_tdm_tx_0: qcom,msm-dai-q6-tdm-quat-tx-0 {
			compatible = "qcom,msm-dai-q6-tdm";
			qcom,msm-cpudai-tdm-dev-id = <36913 >;
			qcom,msm-cpudai-tdm-data-align = <0>;
		};
	};
+66 −47
Original line number Diff line number Diff line
@@ -5010,6 +5010,44 @@ static struct platform_driver msm_dai_q6_spdif_driver = {
	},
};

static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
					struct afe_clk_set *clk_set, u32 mode)
{
	switch (group_id) {
	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
		if (mode)
			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
		else
			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
		break;
	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
		if (mode)
			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
		else
			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
		break;
	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
		if (mode)
			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
		else
			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
		break;
	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
		if (mode)
			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
		else
			clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
		break;
	default:
		return -EINVAL;
	}
	return 0;
}

static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
{
	int rc = 0;
@@ -5017,6 +5055,7 @@ static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
	uint32_t array_length = 0;
	int i = 0;
	int group_idx = 0;
	u32 clk_mode = 0;

	/* extract tdm group info into static */
	rc = of_property_read_u32(pdev->dev.of_node,
@@ -5089,6 +5128,26 @@ 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);

	/* extract tdm clk src master/slave info into static */
	rc = of_property_read_u32(pdev->dev.of_node,
		"qcom,msm-cpudai-tdm-clk-internal",
		&clk_mode);
	if (rc) {
		dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
			__func__, "qcom,msm-cpudai-tdm-clk-internal");
		goto rtn;
	}
	dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
		__func__, clk_mode);

	rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
					  &tdm_clk_set, clk_mode);
	if (rc) {
		dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
			__func__, tdm_group_cfg.group_id);
		goto rtn;
	}

	/* other initializations within device group */
	group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
	if (group_idx < 0) {
@@ -5884,48 +5943,6 @@ static int msm_dai_q6_tdm_set_clk(
{
	int rc = 0;

	switch (dai_data->group_cfg.tdm_cfg.group_id) {
	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
	case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
		if (dai_data->clk_set.clk_freq_in_hz) {
			dai_data->clk_set.clk_id =
				Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
		} else
			dai_data->clk_set.clk_id =
				Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
		break;
	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
	case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
		if (dai_data->clk_set.clk_freq_in_hz) {
			dai_data->clk_set.clk_id =
				Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
		} else
			dai_data->clk_set.clk_id =
				Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
		break;
	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
	case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
		if (dai_data->clk_set.clk_freq_in_hz) {
			dai_data->clk_set.clk_id =
				Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
		} else
			dai_data->clk_set.clk_id =
				Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
		break;
	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
	case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
		if (dai_data->clk_set.clk_freq_in_hz) {
			dai_data->clk_set.clk_id =
				Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
		} else
			dai_data->clk_set.clk_id =
				Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
		break;
	default:
		pr_err("%s: port id 0x%x not supported\n",
			__func__, port_id);
		return -EINVAL;
	}
	dai_data->clk_set.enable = enable;

	rc = afe_set_lpass_clock_v2(port_id,
@@ -7913,6 +7930,7 @@ static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
	int rc = 0;
	u32 tdm_dev_id = 0;
	int port_idx = 0;
	struct device_node *tdm_parent_node = NULL;

	/* retrieve device/afe id */
	rc = of_property_read_u32(pdev->dev.of_node,
@@ -7947,7 +7965,8 @@ static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
	memset(dai_data, 0, sizeof(*dai_data));

	/* TDM CFG */
	rc = of_property_read_u32(pdev->dev.of_node,
	tdm_parent_node = of_get_parent(pdev->dev.of_node);
	rc = of_property_read_u32(tdm_parent_node,
		"qcom,msm-cpudai-tdm-sync-mode",
		(u32 *)&dai_data->port_cfg.tdm.sync_mode);
	if (rc) {
@@ -7958,7 +7977,7 @@ static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
	dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
		__func__, dai_data->port_cfg.tdm.sync_mode);

	rc = of_property_read_u32(pdev->dev.of_node,
	rc = of_property_read_u32(tdm_parent_node,
		"qcom,msm-cpudai-tdm-sync-src",
		(u32 *)&dai_data->port_cfg.tdm.sync_src);
	if (rc) {
@@ -7969,7 +7988,7 @@ static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
	dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
		__func__, dai_data->port_cfg.tdm.sync_src);

	rc = of_property_read_u32(pdev->dev.of_node,
	rc = of_property_read_u32(tdm_parent_node,
		"qcom,msm-cpudai-tdm-data-out",
		(u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
	if (rc) {
@@ -7980,7 +7999,7 @@ static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
	dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
		__func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);

	rc = of_property_read_u32(pdev->dev.of_node,
	rc = of_property_read_u32(tdm_parent_node,
		"qcom,msm-cpudai-tdm-invert-sync",
		(u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
	if (rc) {
@@ -7991,7 +8010,7 @@ static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
	dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
		__func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);

	rc = of_property_read_u32(pdev->dev.of_node,
	rc = of_property_read_u32(tdm_parent_node,
		"qcom,msm-cpudai-tdm-data-delay",
		(u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
	if (rc) {