Prechádzať zdrojové kódy

asoc: lpass-cdc: Update core voting before gfmux access

GFMUX access in va clock supported in lpass-cdc v2p5
onwards. Ensure add core voting before access.

Change-Id: I36c8db86a2e7f265ab293dd6cd1f1ee3ac7722a5
Signed-off-by: Laxminath Kasam <[email protected]>
Laxminath Kasam 3 rokov pred
rodič
commit
5a96e4bc5b

+ 21 - 3
asoc/codecs/lpass-cdc/lpass-cdc-rx-macro.c

@@ -1352,7 +1352,13 @@ static int lpass_cdc_rx_macro_mclk_enable(
 		if (rx_priv->rx_mclk_users == 0) {
 			if (rx_priv->is_native_on)
 				rx_priv->clk_id = RX_CORE_CLK;
-			lpass_cdc_rx_macro_core_vote(rx_priv, true);
+			ret = lpass_cdc_rx_macro_core_vote(rx_priv, true);
+			if (ret < 0) {
+				dev_err(rx_priv->dev,
+					"%s: rx request core vote failed\n",
+					__func__);
+				goto exit;
+			}
 			ret = lpass_cdc_clk_rsc_request_clock(rx_priv->dev,
 							   rx_priv->default_clk_id,
 							   rx_priv->clk_id,
@@ -1407,7 +1413,13 @@ static int lpass_cdc_rx_macro_mclk_enable(
 				0x01, 0x00);
 			lpass_cdc_clk_rsc_fs_gen_request(rx_priv->dev,
 			   false);
-			lpass_cdc_rx_macro_core_vote(rx_priv, true);
+			ret = lpass_cdc_rx_macro_core_vote(rx_priv, true);
+			if (ret < 0) {
+				dev_err(rx_priv->dev,
+					"%s: rx request core vote failed\n",
+					__func__);
+				goto exit;
+			}
 			lpass_cdc_clk_rsc_request_clock(rx_priv->dev,
 						 rx_priv->default_clk_id,
 						 rx_priv->clk_id,
@@ -1522,7 +1534,13 @@ static int lpass_cdc_rx_macro_event_handler(struct snd_soc_component *component,
 		}
 		break;
 	case LPASS_CDC_MACRO_EVT_PRE_SSR_UP:
-		lpass_cdc_rx_macro_core_vote(rx_priv, true);
+		ret = lpass_cdc_rx_macro_core_vote(rx_priv, true);
+		if (ret < 0) {
+			dev_err(rx_priv->dev,
+				"%s: rx request core vote failed\n",
+				__func__);
+			break;
+		}
 		/* enable&disable RX_CORE_CLK to reset GFMUX reg */
 		ret = lpass_cdc_clk_rsc_request_clock(rx_priv->dev,
 						rx_priv->default_clk_id,

+ 39 - 1
asoc/codecs/lpass-cdc/lpass-cdc-va-macro.c

@@ -228,10 +228,18 @@ static int lpass_cdc_va_macro_mclk_enable(
 
 	mutex_lock(&va_priv->mclk_lock);
 	if (mclk_enable) {
+		ret = lpass_cdc_va_macro_core_vote(va_priv, true);
+		if (ret < 0) {
+			dev_err(va_priv->dev,
+				"%s: va request core vote failed\n",
+				__func__);
+			goto exit;
+		}
 		ret = lpass_cdc_clk_rsc_request_clock(va_priv->dev,
 						   va_priv->default_clk_id,
 						   va_priv->clk_id,
 						   true);
+		lpass_cdc_va_macro_core_vote(va_priv, false);
 		if (ret < 0) {
 			dev_err(va_priv->dev,
 				"%s: va request clock en failed\n",
@@ -257,10 +265,18 @@ static int lpass_cdc_va_macro_mclk_enable(
 		va_priv->va_mclk_users--;
 		lpass_cdc_clk_rsc_fs_gen_request(va_priv->dev,
 					  false);
+		ret = lpass_cdc_va_macro_core_vote(va_priv, true);
+		if (ret < 0) {
+			dev_err(va_priv->dev,
+				"%s: va request core vote failed\n",
+				__func__);
+			goto exit;
+		}
 		lpass_cdc_clk_rsc_request_clock(va_priv->dev,
 					va_priv->default_clk_id,
 					va_priv->clk_id,
 					false);
+		lpass_cdc_va_macro_core_vote(va_priv, false);
 	}
 exit:
 	mutex_unlock(&va_priv->mclk_lock);
@@ -302,7 +318,13 @@ static int lpass_cdc_va_macro_event_handler(struct snd_soc_component *component,
 		break;
 	case LPASS_CDC_MACRO_EVT_PRE_SSR_UP:
 		/* enable&disable VA_CORE_CLK to reset GFMUX reg */
-		lpass_cdc_va_macro_core_vote(va_priv, true);
+		ret = lpass_cdc_va_macro_core_vote(va_priv, true);
+		if (ret < 0) {
+			dev_err(va_priv->dev,
+				"%s: va request core vote failed\n",
+				__func__);
+			break;
+		}
 		ret = lpass_cdc_clk_rsc_request_clock(va_priv->dev,
 						va_priv->default_clk_id,
 						VA_CORE_CLK, true);
@@ -399,10 +421,18 @@ static int lpass_cdc_va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
 	switch (event) {
 	case SND_SOC_DAPM_PRE_PMU:
 		if (va_priv->default_clk_id != VA_CORE_CLK) {
+			ret = lpass_cdc_va_macro_core_vote(va_priv, true);
+			if (ret < 0) {
+				dev_err(va_priv->dev,
+					"%s: va request core vote failed\n",
+					__func__);
+				break;
+			}
 			ret = lpass_cdc_clk_rsc_request_clock(va_priv->dev,
 					va_priv->default_clk_id,
 					VA_CORE_CLK,
 					true);
+			lpass_cdc_va_macro_core_vote(va_priv, false);
 			if (ret) {
 				dev_dbg(component->dev,
 					"%s: request clock VA_CLK enable failed\n",
@@ -437,10 +467,18 @@ static int lpass_cdc_va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
 					__func__);
 				break;
 			}
+			ret = lpass_cdc_va_macro_core_vote(va_priv, true);
+			if (ret < 0) {
+				dev_err(va_priv->dev,
+					"%s: va request core vote failed\n",
+					__func__);
+				break;
+			}
 			ret = lpass_cdc_clk_rsc_request_clock(va_priv->dev,
 					va_priv->default_clk_id,
 					VA_CORE_CLK,
 					false);
+			lpass_cdc_va_macro_core_vote(va_priv, false);
 			if (ret) {
 				dev_dbg(component->dev,
 					"%s: request clock VA_CLK disable failed\n",

+ 0 - 14
asoc/codecs/lpass-cdc/lpass-cdc-wsa-macro.c

@@ -963,20 +963,6 @@ static int lpass_cdc_wsa_macro_event_handler(struct snd_soc_component *component
 		}
 		break;
 	case LPASS_CDC_MACRO_EVT_PRE_SSR_UP:
-		/* enable&disable WSA_CORE_CLK to reset GFMUX reg */
-		lpass_cdc_wsa_macro_core_vote(wsa_priv, true);
-		ret = lpass_cdc_clk_rsc_request_clock(wsa_priv->dev,
-						wsa_priv->default_clk_id,
-						WSA_CORE_CLK, true);
-		if (ret < 0)
-			dev_err_ratelimited(wsa_priv->dev,
-				"%s, failed to enable clk, ret:%d\n",
-				__func__, ret);
-		else
-			lpass_cdc_clk_rsc_request_clock(wsa_priv->dev,
-						wsa_priv->default_clk_id,
-						WSA_CORE_CLK, false);
-		lpass_cdc_wsa_macro_core_vote(wsa_priv, false);
 		break;
 	case LPASS_CDC_MACRO_EVT_SSR_UP:
 		trace_printk("%s, enter SSR up\n", __func__);

+ 0 - 14
asoc/codecs/lpass-cdc/lpass-cdc-wsa2-macro.c

@@ -962,20 +962,6 @@ static int lpass_cdc_wsa2_macro_event_handler(struct snd_soc_component *componen
 		}
 		break;
 	case LPASS_CDC_MACRO_EVT_PRE_SSR_UP:
-		/* enable&disable WSA_CORE_CLK to reset GFMUX reg */
-		lpass_cdc_wsa2_macro_core_vote(wsa2_priv, true);
-		ret = lpass_cdc_clk_rsc_request_clock(wsa2_priv->dev,
-						wsa2_priv->default_clk_id,
-						WSA_CORE_CLK, true);
-		if (ret < 0)
-			dev_err_ratelimited(wsa2_priv->dev,
-				"%s, failed to enable clk, ret:%d\n",
-				__func__, ret);
-		else
-			lpass_cdc_clk_rsc_request_clock(wsa2_priv->dev,
-						wsa2_priv->default_clk_id,
-						WSA_CORE_CLK, false);
-		lpass_cdc_wsa2_macro_core_vote(wsa2_priv, true);
 		break;
 	case LPASS_CDC_MACRO_EVT_SSR_UP:
 		trace_printk("%s, enter SSR up\n", __func__);