Browse Source

asoc: bolero: update logic for va clk switch on bolero 2.1

On bolero 2.1, SVA switch is not retain at VA_CLK
when switch between handset and headset mic sva.
Update the clock release logic during swr power event.

Change-Id: I62b492dcbff4b4f3249d1a6b3b792690b5b5c27c
Signed-off-by: Meng Wang <[email protected]>
Meng Wang 4 years ago
parent
commit
dfa3df69ae
1 changed files with 23 additions and 23 deletions
  1. 23 23
      asoc/codecs/bolero/va-macro.c

+ 23 - 23
asoc/codecs/bolero/va-macro.c

@@ -170,9 +170,11 @@ struct va_macro_priv {
 	int va_swr_clk_cnt;
 	int va_clk_status;
 	int tx_clk_status;
+	int dapm_tx_clk_status;
 	bool lpi_enable;
 	bool register_event_listener;
 	int dec_mode[VA_MACRO_NUM_DECIMATORS];
+	u16 current_clk_id;
 };
 
 static bool va_macro_get_data(struct snd_soc_component *component,
@@ -392,7 +394,14 @@ static int va_macro_swr_pwr_event_v2(struct snd_soc_dapm_widget *w,
 
 	switch (event) {
 	case SND_SOC_DAPM_PRE_PMU:
-		if (va_priv->default_clk_id != VA_CORE_CLK) {
+		dev_dbg(component->dev,
+			"%s: va_swr_clk_cnt %d, tx_swr_clk_cnt %d, tx_clk_status %d\n",
+			__func__, va_priv->va_swr_clk_cnt,
+			va_priv->tx_swr_clk_cnt, va_priv->tx_clk_status);
+		if (va_priv->current_clk_id == VA_CORE_CLK) {
+			return 0;
+		} else if ( va_priv->va_swr_clk_cnt != 0 &&
+				va_priv->tx_clk_status) {
 			ret = bolero_clk_rsc_request_clock(va_priv->dev,
 					va_priv->default_clk_id,
 					VA_CORE_CLK,
@@ -417,6 +426,7 @@ static int va_macro_swr_pwr_event_v2(struct snd_soc_dapm_widget *w,
 					false);
 				break;
 			}
+			va_priv->current_clk_id = VA_CORE_CLK;
 		}
 		msm_cdc_pinctrl_set_wakeup_capable(
 				va_priv->va_swr_gpio_p, false);
@@ -424,7 +434,9 @@ static int va_macro_swr_pwr_event_v2(struct snd_soc_dapm_widget *w,
 	case SND_SOC_DAPM_POST_PMD:
 		msm_cdc_pinctrl_set_wakeup_capable(
 				va_priv->va_swr_gpio_p, true);
-		if (va_priv->default_clk_id == TX_CORE_CLK) {
+		if (va_priv->current_clk_id == VA_CORE_CLK &&
+			va_priv->va_swr_clk_cnt != 0 &&
+			va_priv->tx_clk_status) {
 			ret = bolero_clk_rsc_request_clock(va_priv->dev,
 					va_priv->default_clk_id,
 					TX_CORE_CLK,
@@ -449,6 +461,7 @@ static int va_macro_swr_pwr_event_v2(struct snd_soc_dapm_widget *w,
 					false);
 				break;
 			}
+			va_priv->current_clk_id = TX_CORE_CLK;
 		}
 		break;
 	default:
@@ -555,7 +568,7 @@ static int va_macro_mclk_event(struct snd_soc_dapm_widget *w,
 						   TX_CORE_CLK,
 						   true);
 		if (!ret)
-			va_priv->tx_clk_status++;
+			va_priv->dapm_tx_clk_status++;
 
 		if (va_priv->lpi_enable)
 			ret = va_macro_mclk_enable(va_priv, 1, true);
@@ -569,12 +582,12 @@ static int va_macro_mclk_event(struct snd_soc_dapm_widget *w,
 			bolero_tx_mclk_enable(component, 0);
 		}
 
-		if (va_priv->tx_clk_status > 0) {
+		if (va_priv->dapm_tx_clk_status > 0) {
 			bolero_clk_rsc_request_clock(va_priv->dev,
 					   va_priv->default_clk_id,
 					   TX_CORE_CLK,
 					   false);
-			va_priv->tx_clk_status--;
+			va_priv->dapm_tx_clk_status--;
 		}
 		break;
 	default:
@@ -1313,12 +1326,12 @@ static int va_macro_enable_tx(struct snd_soc_dapm_widget *w,
 
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
-		if (va_priv->tx_clk_status > 0) {
+		if (va_priv->dapm_tx_clk_status > 0) {
 			ret = bolero_clk_rsc_request_clock(va_priv->dev,
 						   va_priv->default_clk_id,
 						   TX_CORE_CLK,
 						   false);
-			va_priv->tx_clk_status--;
+			va_priv->dapm_tx_clk_status--;
 		}
 		break;
 	case SND_SOC_DAPM_PRE_PMD:
@@ -1327,7 +1340,7 @@ static int va_macro_enable_tx(struct snd_soc_dapm_widget *w,
 						   TX_CORE_CLK,
 						   true);
 		if (!ret)
-			va_priv->tx_clk_status++;
+			va_priv->dapm_tx_clk_status++;
 		break;
 	default:
 		dev_err(va_priv->dev,
@@ -2225,18 +2238,6 @@ static const struct snd_soc_dapm_route va_audio_map_common[] = {
 	{"VA SMIC MUX1", "SWR_MIC11", "VA SWR_INPUT"},
 
 	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
-
 };
 
 static const struct snd_soc_dapm_route va_audio_map_v3[] = {
@@ -2299,9 +2300,7 @@ static const struct snd_soc_dapm_route va_audio_map_v3[] = {
 };
 
 static const struct snd_soc_dapm_route va_audio_map_v2[] = {
-	{"VA_AIF1 CAP", NULL, "VA_SWR_CLK"},
-	{"VA_AIF2 CAP", NULL, "VA_SWR_CLK"},
-	{"VA_AIF3 CAP", NULL, "VA_SWR_CLK"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_CLK"},
 };
 
 static const struct snd_soc_dapm_route va_audio_map[] = {
@@ -3170,6 +3169,7 @@ static int va_macro_probe(struct platform_device *pdev)
 	}
 	va_priv->clk_id = VA_CORE_CLK;
 	va_priv->default_clk_id = default_clk_id;
+	va_priv->current_clk_id = TX_CORE_CLK;
 
 	if (is_used_va_swr_gpio) {
 		va_priv->reset_swr = true;