Prechádzať zdrojové kódy

va-macro: Use DT property for selecting the clock ID

Use device tree property "qcom,use-clk-id" for selecting
the clock ID for VA Macro operation.

Change-Id: I759c690ab7f6dc7ca023d5954e9b445a7b91b1b6
Phani Kumar Uppalapati 3 rokov pred
rodič
commit
2b5f3e4778
1 zmenil súbory, kde vykonal 29 pridanie a 5 odobranie
  1. 29 5
      asoc/codecs/lpass-cdc/lpass-cdc-va-macro.c

+ 29 - 5
asoc/codecs/lpass-cdc/lpass-cdc-va-macro.c

@@ -566,10 +566,24 @@ static int lpass_cdc_va_macro_mclk_event(struct snd_soc_dapm_widget *w,
 		if (!ret)
 			va_priv->dapm_tx_clk_status++;
 
-		ret = lpass_cdc_va_macro_mclk_enable(va_priv, 1, true);
+		if (va_priv->clk_id == TX_CORE_CLK) {
+			ret = lpass_cdc_va_macro_mclk_enable(va_priv, 1, true);
+		} else {
+			if (va_priv->lpi_enable)
+				ret = lpass_cdc_va_macro_mclk_enable(va_priv, 1, true);
+			else
+				ret = lpass_cdc_tx_mclk_enable(component, 1);
+		}
 		break;
 	case SND_SOC_DAPM_POST_PMD:
-		lpass_cdc_va_macro_mclk_enable(va_priv, 0, true);
+		if (va_priv->clk_id == TX_CORE_CLK) {
+			lpass_cdc_va_macro_mclk_enable(va_priv, 0, true);
+		} else {
+			if (va_priv->lpi_enable)
+				lpass_cdc_va_macro_mclk_enable(va_priv, 0, true);
+			else
+				lpass_cdc_tx_mclk_enable(component, 0);
+		}
 
 		if (va_priv->dapm_tx_clk_status > 0) {
 			lpass_cdc_clk_rsc_request_clock(va_priv->dev,
@@ -2368,7 +2382,7 @@ static int lpass_cdc_va_macro_probe(struct platform_device *pdev)
 	const char *micb_current_str = "qcom,va-vdd-micb-current";
 	int ret = 0;
 	const char *dmic_sample_rate = "qcom,va-dmic-sample-rate";
-	u32 default_clk_id = 0;
+	u32 default_clk_id = 0, use_clk_id = 0;
 	struct clk *lpass_audio_hw_vote = NULL;
 	u32 is_used_va_swr_gpio = 0;
 	const char *is_used_va_swr_gpio_dt = "qcom,is-used-swr-gpio";
@@ -2475,14 +2489,24 @@ static int lpass_cdc_va_macro_probe(struct platform_device *pdev)
 			return ret;
 		}
 	}
+	use_clk_id = VA_CORE_CLK; /* default to using VA CORE CLK */
+	if (of_find_property(pdev->dev.of_node, "qcom,use-clk-id", NULL)) {
+		ret = of_property_read_u32(pdev->dev.of_node, "qcom,use-clk-id",
+				&use_clk_id);
+		if (ret) {
+			dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
+					__func__, "qcom,use-clk-id");
+			use_clk_id = VA_CORE_CLK;
+		}
+	}
+	va_priv->clk_id = use_clk_id;
 	ret = of_property_read_u32(pdev->dev.of_node, "qcom,default-clk-id",
 				   &default_clk_id);
 	if (ret) {
 		dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
 			__func__, "qcom,default-clk-id");
-		default_clk_id = TX_CORE_CLK;
+		default_clk_id = use_clk_id;
 	}
-	va_priv->clk_id = TX_CORE_CLK;
 	va_priv->default_clk_id = default_clk_id;
 	va_priv->current_clk_id = TX_CORE_CLK;