ASoC: msm: qdspqv2: enable secondary group based on group count

Enable the secondary port tdm group only if number of groups
is more than one.

CRs-Fixed: 2147847
Change-Id: I989846f611fab78cbb50a3120c94fc44dc50fb46
Signed-off-by: Surendar karka <sukark@codeaurora.org>
diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c
index 23e1db3..cefac86 100644
--- a/asoc/msm-dai-q6-v2.c
+++ b/asoc/msm-dai-q6-v2.c
@@ -7086,6 +7086,10 @@
 			prim_port_id = dai->id;
 			if (dai_data->sec_port_enable) {
 				sec_port_id = AFE_PORT_ID_PRIMARY_TDM_TX;
+				sec_group_ref = &tdm_group_ref[sec_group_idx];
+			}
+			if ((dai_data->num_group_ports > 1) &&
+				(dai_data->sec_port_enable)) {
 				sec_group_id =
 					AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX;
 				sec_group_idx =
@@ -7096,7 +7100,6 @@
 						sec_group_id);
 					goto rtn;
 				}
-				sec_group_ref = &tdm_group_ref[sec_group_idx];
 				if (atomic_read(sec_group_ref) == 0) {
 					rc = afe_port_group_enable(
 							sec_group_id,
@@ -7116,6 +7119,10 @@
 			prim_port_id = dai->id;
 			if (dai_data->sec_port_enable) {
 				sec_port_id = AFE_PORT_ID_PRIMARY_TDM_RX;
+				sec_group_ref = &tdm_group_ref[sec_group_idx];
+			}
+			if ((dai_data->num_group_ports > 1) &&
+				(dai_data->sec_port_enable)) {
 				sec_group_id =
 					AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX;
 				sec_group_idx =
@@ -7126,7 +7133,6 @@
 						sec_group_id);
 					goto rtn;
 				}
-				sec_group_ref = &tdm_group_ref[sec_group_idx];
 				if (atomic_read(sec_group_ref) == 0) {
 					rc = afe_port_group_enable(
 								sec_group_id,
@@ -7245,6 +7251,10 @@
 			prim_port_id = dai->id;
 			if (dai_data->sec_port_enable) {
 				sec_port_id = AFE_PORT_ID_PRIMARY_TDM_TX;
+				sec_group_ref = &tdm_group_ref[sec_group_idx];
+			}
+			if ((dai_data->num_group_ports > 1) &&
+				(dai_data->sec_port_enable)) {
 				sec_group_id =
 					AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX;
 				sec_group_idx =
@@ -7255,12 +7265,15 @@
 						__func__, sec_group_id);
 					return;
 				}
-				sec_group_ref = &tdm_group_ref[sec_group_idx];
 			}
 		} else {
 			prim_port_id = dai->id;
 			if (dai_data->sec_port_enable) {
 				sec_port_id = AFE_PORT_ID_PRIMARY_TDM_RX;
+				sec_group_ref = &tdm_group_ref[sec_group_idx];
+			}
+			if ((dai_data->num_group_ports > 1) &&
+				(dai_data->sec_port_enable)) {
 				sec_group_id =
 					AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX;
 				sec_group_idx =
@@ -7271,7 +7284,6 @@
 						__func__, sec_group_id);
 					return;
 				}
-				sec_group_ref = &tdm_group_ref[sec_group_idx];
 			}
 		}
 
@@ -7310,7 +7322,8 @@
 					__func__, dai->id);
 			}
 		}
-		if (dai_data->sec_port_enable) {
+		if ((dai_data->num_group_ports > 1) &&
+			(dai_data->sec_port_enable)) {
 			if (atomic_read(sec_group_ref) == 0) {
 				rc = afe_port_group_enable(sec_group_id,
 							NULL, false);