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

Commit 3bd80a59 authored by Karthikeyan Mani's avatar Karthikeyan Mani Committed by Gerrit - the friendly Code Review server
Browse files

asoc: codecs: add support to disable soundwire devices



Add changes to support disabling of soundwire devices
so that soundwire pins can be freed for other purposes
if needed.

Change-Id: Iae14d43c2c3d5380347be4c3b443c209b2612a97
Signed-off-by: default avatarKarthikeyan Mani <kmani@codeaurora.org>
parent c63ec8cd
Loading
Loading
Loading
Loading
+38 −19
Original line number Diff line number Diff line
@@ -764,6 +764,7 @@ static int rx_macro_set_port_map(struct snd_soc_component *component,
	port_cfg.size = size;
	port_cfg.params = data;

	if (rx_priv->swr_ctrl_data)
		ret = swrm_wcd_notify(
			rx_priv->swr_ctrl_data[0].rx_swr_pdev,
			SWR_SET_PORT_MAP, &port_cfg);
@@ -1152,6 +1153,7 @@ static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w,
			     rx_priv->is_native_on) ||
			    (rx_priv->clk_id == RX_CORE_CLK &&
			     !rx_priv->is_native_on)) {
				if (rx_priv->swr_ctrl_data)
					swrm_wcd_notify(
					rx_priv->swr_ctrl_data[0].rx_swr_pdev,
					SWR_DEVICE_DOWN, NULL);
@@ -1159,6 +1161,7 @@ static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w,
		}
		if (rx_priv->is_native_on)
			mclk_freq = MCLK_FREQ_NATIVE;
		if (rx_priv->swr_ctrl_data)
			swrm_wcd_notify(
				rx_priv->swr_ctrl_data[0].rx_swr_pdev,
				SWR_CLK_FREQ, &mclk_freq);
@@ -1213,12 +1216,14 @@ static int rx_macro_event_handler(struct snd_soc_component *component,
		break;
	case BOLERO_MACRO_EVT_SSR_DOWN:
		rx_priv->dev_up = false;
		if (rx_priv->swr_ctrl_data) {
			swrm_wcd_notify(
				rx_priv->swr_ctrl_data[0].rx_swr_pdev,
				SWR_DEVICE_DOWN, NULL);
			swrm_wcd_notify(
				rx_priv->swr_ctrl_data[0].rx_swr_pdev,
				SWR_DEVICE_SSR_DOWN, NULL);
		}
		break;
	case BOLERO_MACRO_EVT_SSR_UP:
		rx_priv->dev_up = true;
@@ -1237,6 +1242,7 @@ static int rx_macro_event_handler(struct snd_soc_component *component,
						rx_priv->default_clk_id,
						RX_CORE_CLK, false);

		if (rx_priv->swr_ctrl_data)
			swrm_wcd_notify(
				rx_priv->swr_ctrl_data[0].rx_swr_pdev,
				SWR_DEVICE_SSR_UP, NULL);
@@ -3570,6 +3576,8 @@ static int rx_macro_probe(struct platform_device *pdev)
	int ret = 0;
	u8 bcl_pmic_params[3];
	u32 default_clk_id = 0;
	u32 is_used_rx_swr_gpio = 1;
	const char *is_used_rx_swr_gpio_dt = "qcom,is-used-swr-gpio";

	rx_priv = devm_kzalloc(&pdev->dev, sizeof(struct rx_macro_priv),
			    GFP_KERNEL);
@@ -3598,9 +3606,20 @@ static int rx_macro_probe(struct platform_device *pdev)
			__func__, "qcom,default-clk-id");
		default_clk_id = RX_CORE_CLK;
	}
	if (of_find_property(pdev->dev.of_node, is_used_rx_swr_gpio_dt,
			     NULL)) {
		ret = of_property_read_u32(pdev->dev.of_node,
					   is_used_rx_swr_gpio_dt,
					   &is_used_rx_swr_gpio);
		if (ret) {
			dev_err(&pdev->dev, "%s: error reading %s in dt\n",
				__func__, is_used_rx_swr_gpio_dt);
			is_used_rx_swr_gpio = 1;
		}
	}
	rx_priv->rx_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
					"qcom,rx-swr-gpios", 0);
	if (!rx_priv->rx_swr_gpio_p) {
	if (!rx_priv->rx_swr_gpio_p && is_used_rx_swr_gpio) {
		dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
			__func__);
		return -EINVAL;
+36 −17
Original line number Diff line number Diff line
@@ -346,16 +346,19 @@ static int tx_macro_event_handler(struct snd_soc_component *component,

	switch (event) {
	case BOLERO_MACRO_EVT_SSR_DOWN:
		if (tx_priv->swr_ctrl_data) {
			swrm_wcd_notify(
				tx_priv->swr_ctrl_data[0].tx_swr_pdev,
				SWR_DEVICE_DOWN, NULL);
			swrm_wcd_notify(
				tx_priv->swr_ctrl_data[0].tx_swr_pdev,
				SWR_DEVICE_SSR_DOWN, NULL);
		}
		break;
	case BOLERO_MACRO_EVT_SSR_UP:
		/* reset swr after ssr/pdr */
		tx_priv->reset_swr = true;
		if (tx_priv->swr_ctrl_data)
			swrm_wcd_notify(
				tx_priv->swr_ctrl_data[0].tx_swr_pdev,
				SWR_DEVICE_SSR_UP, NULL);
@@ -375,6 +378,7 @@ static int tx_macro_reg_wake_irq(struct snd_soc_component *component,
	if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
		return -EINVAL;

	if (tx_priv->swr_ctrl_data)
		ret = swrm_wcd_notify(
			tx_priv->swr_ctrl_data[0].tx_swr_pdev,
			SWR_REGISTER_WAKE_IRQ, &ipc_wakeup);
@@ -1948,6 +1952,7 @@ static int tx_macro_set_port_map(struct snd_soc_component *component,
	port_cfg.size = size;
	port_cfg.params = data;

	if (tx_priv->swr_ctrl_data)
		ret = swrm_wcd_notify(
			tx_priv->swr_ctrl_data[0].tx_swr_pdev,
			SWR_SET_PORT_MAP, &port_cfg);
@@ -1977,6 +1982,8 @@ static int tx_macro_probe(struct platform_device *pdev)
	char __iomem *tx_io_base = NULL;
	int ret = 0;
	const char *dmic_sample_rate = "qcom,tx-dmic-sample-rate";
	u32 is_used_tx_swr_gpio = 1;
	const char *is_used_tx_swr_gpio_dt = "qcom,is-used-swr-gpio";

	tx_priv = devm_kzalloc(&pdev->dev, sizeof(struct tx_macro_priv),
			    GFP_KERNEL);
@@ -1993,9 +2000,20 @@ static int tx_macro_probe(struct platform_device *pdev)
		return ret;
	}
	dev_set_drvdata(&pdev->dev, tx_priv);
	if (of_find_property(pdev->dev.of_node, is_used_tx_swr_gpio_dt,
			     NULL)) {
		ret = of_property_read_u32(pdev->dev.of_node,
					   is_used_tx_swr_gpio_dt,
					   &is_used_tx_swr_gpio);
		if (ret) {
			dev_err(&pdev->dev, "%s: error reading %s in dt\n",
				__func__, is_used_tx_swr_gpio_dt);
			is_used_tx_swr_gpio = 1;
		}
	}
	tx_priv->tx_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
					"qcom,tx-swr-gpios", 0);
	if (!tx_priv->tx_swr_gpio_p) {
	if (!tx_priv->tx_swr_gpio_p && is_used_tx_swr_gpio) {
		dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
			__func__);
		return -EINVAL;
@@ -2064,6 +2082,7 @@ static int tx_macro_remove(struct platform_device *pdev)
	if (!tx_priv)
		return -EINVAL;

	if (tx_priv->swr_ctrl_data)
		kfree(tx_priv->swr_ctrl_data);
	for (count = 0; count < tx_priv->child_count &&
		count < TX_MACRO_CHILD_DEVICES_MAX; count++)
+42 −22
Original line number Diff line number Diff line
@@ -473,6 +473,7 @@ static int wsa_macro_set_port_map(struct snd_soc_component *component,
	port_cfg.size = size;
	port_cfg.params = data;

	if (wsa_priv->swr_ctrl_data)
		ret = swrm_wcd_notify(
			wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
			SWR_SET_PORT_MAP, &port_cfg);
@@ -910,16 +911,19 @@ static int wsa_macro_event_handler(struct snd_soc_component *component,

	switch (event) {
	case BOLERO_MACRO_EVT_SSR_DOWN:
		if (wsa_priv->swr_ctrl_data) {
			swrm_wcd_notify(
				wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
				SWR_DEVICE_DOWN, NULL);
			swrm_wcd_notify(
				wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
				SWR_DEVICE_SSR_DOWN, NULL);
		}
		break;
	case BOLERO_MACRO_EVT_SSR_UP:
		/* reset swr after ssr/pdr */
		wsa_priv->reset_swr = true;
		if (wsa_priv->swr_ctrl_data)
			swrm_wcd_notify(
				wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
				SWR_DEVICE_SSR_UP, NULL);
@@ -1135,12 +1139,14 @@ static int wsa_macro_enable_swr(struct snd_soc_dapm_widget *w,
			wsa_priv->rx_1_count++;
		ch_cnt = wsa_priv->rx_0_count + wsa_priv->rx_1_count;

		if (wsa_priv->swr_ctrl_data) {
			swrm_wcd_notify(
				wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
				SWR_DEVICE_UP, NULL);
			swrm_wcd_notify(
				wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
				SWR_SET_NUM_RX_CH, &ch_cnt);
		}
		break;
	case SND_SOC_DAPM_POST_PMD:
		if (!(strnstr(w->name, "RX0", sizeof("WSA_RX0"))) &&
@@ -1151,6 +1157,7 @@ static int wsa_macro_enable_swr(struct snd_soc_dapm_widget *w,
			wsa_priv->rx_1_count--;
		ch_cnt = wsa_priv->rx_0_count + wsa_priv->rx_1_count;

		if (wsa_priv->swr_ctrl_data)
			swrm_wcd_notify(
				wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
				SWR_SET_NUM_RX_CH, &ch_cnt);
@@ -2880,6 +2887,8 @@ static int wsa_macro_probe(struct platform_device *pdev)
	char __iomem *wsa_io_base;
	int ret = 0;
	u8 bcl_pmic_params[3];
	u32 is_used_wsa_swr_gpio = 1;
	const char *is_used_wsa_swr_gpio_dt = "qcom,is-used-swr-gpio";

	wsa_priv = devm_kzalloc(&pdev->dev, sizeof(struct wsa_macro_priv),
				GFP_KERNEL);
@@ -2894,9 +2903,20 @@ static int wsa_macro_probe(struct platform_device *pdev)
			__func__, "reg");
		return ret;
	}
	if (of_find_property(pdev->dev.of_node, is_used_wsa_swr_gpio_dt,
			     NULL)) {
		ret = of_property_read_u32(pdev->dev.of_node,
					   is_used_wsa_swr_gpio_dt,
					   &is_used_wsa_swr_gpio);
		if (ret) {
			dev_err(&pdev->dev, "%s: error reading %s in dt\n",
				__func__, is_used_wsa_swr_gpio_dt);
			is_used_wsa_swr_gpio = 1;
		}
	}
	wsa_priv->wsa_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
					"qcom,wsa-swr-gpios", 0);
	if (!wsa_priv->wsa_swr_gpio_p) {
	if (!wsa_priv->wsa_swr_gpio_p && is_used_wsa_swr_gpio) {
		dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
			__func__);
		return -EINVAL;