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: Karthikeyan Mani <kmani@codeaurora.org>
This commit is contained in:
Karthikeyan Mani
2019-06-04 23:40:16 -07:00
committed by Gerrit - the friendly Code Review server
parent c63ec8cd8f
commit 3bd80a59b2
3 changed files with 116 additions and 58 deletions

View File

@@ -764,9 +764,10 @@ static int rx_macro_set_port_map(struct snd_soc_component *component,
port_cfg.size = size; port_cfg.size = size;
port_cfg.params = data; port_cfg.params = data;
ret = swrm_wcd_notify( if (rx_priv->swr_ctrl_data)
rx_priv->swr_ctrl_data[0].rx_swr_pdev, ret = swrm_wcd_notify(
SWR_SET_PORT_MAP, &port_cfg); rx_priv->swr_ctrl_data[0].rx_swr_pdev,
SWR_SET_PORT_MAP, &port_cfg);
return ret; return ret;
} }
@@ -1152,16 +1153,18 @@ static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w,
rx_priv->is_native_on) || rx_priv->is_native_on) ||
(rx_priv->clk_id == RX_CORE_CLK && (rx_priv->clk_id == RX_CORE_CLK &&
!rx_priv->is_native_on)) { !rx_priv->is_native_on)) {
swrm_wcd_notify( if (rx_priv->swr_ctrl_data)
rx_priv->swr_ctrl_data[0].rx_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_DOWN, NULL); rx_priv->swr_ctrl_data[0].rx_swr_pdev,
SWR_DEVICE_DOWN, NULL);
} }
} }
if (rx_priv->is_native_on) if (rx_priv->is_native_on)
mclk_freq = MCLK_FREQ_NATIVE; mclk_freq = MCLK_FREQ_NATIVE;
swrm_wcd_notify( if (rx_priv->swr_ctrl_data)
rx_priv->swr_ctrl_data[0].rx_swr_pdev, swrm_wcd_notify(
SWR_CLK_FREQ, &mclk_freq); rx_priv->swr_ctrl_data[0].rx_swr_pdev,
SWR_CLK_FREQ, &mclk_freq);
ret = rx_macro_mclk_enable(rx_priv, 1, true); ret = rx_macro_mclk_enable(rx_priv, 1, true);
if (ret) if (ret)
rx_priv->dapm_mclk_enable = false; rx_priv->dapm_mclk_enable = false;
@@ -1213,12 +1216,14 @@ static int rx_macro_event_handler(struct snd_soc_component *component,
break; break;
case BOLERO_MACRO_EVT_SSR_DOWN: case BOLERO_MACRO_EVT_SSR_DOWN:
rx_priv->dev_up = false; rx_priv->dev_up = false;
swrm_wcd_notify( if (rx_priv->swr_ctrl_data) {
rx_priv->swr_ctrl_data[0].rx_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_DOWN, NULL); rx_priv->swr_ctrl_data[0].rx_swr_pdev,
swrm_wcd_notify( SWR_DEVICE_DOWN, NULL);
rx_priv->swr_ctrl_data[0].rx_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_SSR_DOWN, NULL); rx_priv->swr_ctrl_data[0].rx_swr_pdev,
SWR_DEVICE_SSR_DOWN, NULL);
}
break; break;
case BOLERO_MACRO_EVT_SSR_UP: case BOLERO_MACRO_EVT_SSR_UP:
rx_priv->dev_up = true; rx_priv->dev_up = true;
@@ -1237,9 +1242,10 @@ static int rx_macro_event_handler(struct snd_soc_component *component,
rx_priv->default_clk_id, rx_priv->default_clk_id,
RX_CORE_CLK, false); RX_CORE_CLK, false);
swrm_wcd_notify( if (rx_priv->swr_ctrl_data)
rx_priv->swr_ctrl_data[0].rx_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_SSR_UP, NULL); rx_priv->swr_ctrl_data[0].rx_swr_pdev,
SWR_DEVICE_SSR_UP, NULL);
break; break;
} }
return ret; return ret;
@@ -3570,6 +3576,8 @@ static int rx_macro_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
u8 bcl_pmic_params[3]; u8 bcl_pmic_params[3];
u32 default_clk_id = 0; 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), rx_priv = devm_kzalloc(&pdev->dev, sizeof(struct rx_macro_priv),
GFP_KERNEL); GFP_KERNEL);
@@ -3598,9 +3606,20 @@ static int rx_macro_probe(struct platform_device *pdev)
__func__, "qcom,default-clk-id"); __func__, "qcom,default-clk-id");
default_clk_id = RX_CORE_CLK; 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, rx_priv->rx_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
"qcom,rx-swr-gpios", 0); "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", dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
__func__); __func__);
return -EINVAL; return -EINVAL;

View File

@@ -346,19 +346,22 @@ static int tx_macro_event_handler(struct snd_soc_component *component,
switch (event) { switch (event) {
case BOLERO_MACRO_EVT_SSR_DOWN: case BOLERO_MACRO_EVT_SSR_DOWN:
swrm_wcd_notify( if (tx_priv->swr_ctrl_data) {
tx_priv->swr_ctrl_data[0].tx_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_DOWN, NULL); tx_priv->swr_ctrl_data[0].tx_swr_pdev,
swrm_wcd_notify( SWR_DEVICE_DOWN, NULL);
tx_priv->swr_ctrl_data[0].tx_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_SSR_DOWN, NULL); tx_priv->swr_ctrl_data[0].tx_swr_pdev,
SWR_DEVICE_SSR_DOWN, NULL);
}
break; break;
case BOLERO_MACRO_EVT_SSR_UP: case BOLERO_MACRO_EVT_SSR_UP:
/* reset swr after ssr/pdr */ /* reset swr after ssr/pdr */
tx_priv->reset_swr = true; tx_priv->reset_swr = true;
swrm_wcd_notify( if (tx_priv->swr_ctrl_data)
tx_priv->swr_ctrl_data[0].tx_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_SSR_UP, NULL); tx_priv->swr_ctrl_data[0].tx_swr_pdev,
SWR_DEVICE_SSR_UP, NULL);
break; break;
} }
return 0; return 0;
@@ -375,9 +378,10 @@ static int tx_macro_reg_wake_irq(struct snd_soc_component *component,
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
return -EINVAL; return -EINVAL;
ret = swrm_wcd_notify( if (tx_priv->swr_ctrl_data)
tx_priv->swr_ctrl_data[0].tx_swr_pdev, ret = swrm_wcd_notify(
SWR_REGISTER_WAKE_IRQ, &ipc_wakeup); tx_priv->swr_ctrl_data[0].tx_swr_pdev,
SWR_REGISTER_WAKE_IRQ, &ipc_wakeup);
return ret; return ret;
} }
@@ -1948,9 +1952,10 @@ static int tx_macro_set_port_map(struct snd_soc_component *component,
port_cfg.size = size; port_cfg.size = size;
port_cfg.params = data; port_cfg.params = data;
ret = swrm_wcd_notify( if (tx_priv->swr_ctrl_data)
tx_priv->swr_ctrl_data[0].tx_swr_pdev, ret = swrm_wcd_notify(
SWR_SET_PORT_MAP, &port_cfg); tx_priv->swr_ctrl_data[0].tx_swr_pdev,
SWR_SET_PORT_MAP, &port_cfg);
return ret; return ret;
} }
@@ -1977,6 +1982,8 @@ static int tx_macro_probe(struct platform_device *pdev)
char __iomem *tx_io_base = NULL; char __iomem *tx_io_base = NULL;
int ret = 0; int ret = 0;
const char *dmic_sample_rate = "qcom,tx-dmic-sample-rate"; 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), tx_priv = devm_kzalloc(&pdev->dev, sizeof(struct tx_macro_priv),
GFP_KERNEL); GFP_KERNEL);
@@ -1993,9 +2000,20 @@ static int tx_macro_probe(struct platform_device *pdev)
return ret; return ret;
} }
dev_set_drvdata(&pdev->dev, tx_priv); 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, tx_priv->tx_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
"qcom,tx-swr-gpios", 0); "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", dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
__func__); __func__);
return -EINVAL; return -EINVAL;
@@ -2064,7 +2082,8 @@ static int tx_macro_remove(struct platform_device *pdev)
if (!tx_priv) if (!tx_priv)
return -EINVAL; return -EINVAL;
kfree(tx_priv->swr_ctrl_data); if (tx_priv->swr_ctrl_data)
kfree(tx_priv->swr_ctrl_data);
for (count = 0; count < tx_priv->child_count && for (count = 0; count < tx_priv->child_count &&
count < TX_MACRO_CHILD_DEVICES_MAX; count++) count < TX_MACRO_CHILD_DEVICES_MAX; count++)
platform_device_unregister(tx_priv->pdev_child_devices[count]); platform_device_unregister(tx_priv->pdev_child_devices[count]);

View File

@@ -473,9 +473,10 @@ static int wsa_macro_set_port_map(struct snd_soc_component *component,
port_cfg.size = size; port_cfg.size = size;
port_cfg.params = data; port_cfg.params = data;
ret = swrm_wcd_notify( if (wsa_priv->swr_ctrl_data)
wsa_priv->swr_ctrl_data[0].wsa_swr_pdev, ret = swrm_wcd_notify(
SWR_SET_PORT_MAP, &port_cfg); wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
SWR_SET_PORT_MAP, &port_cfg);
return ret; return ret;
} }
@@ -910,19 +911,22 @@ static int wsa_macro_event_handler(struct snd_soc_component *component,
switch (event) { switch (event) {
case BOLERO_MACRO_EVT_SSR_DOWN: case BOLERO_MACRO_EVT_SSR_DOWN:
swrm_wcd_notify( if (wsa_priv->swr_ctrl_data) {
wsa_priv->swr_ctrl_data[0].wsa_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_DOWN, NULL); wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
swrm_wcd_notify( SWR_DEVICE_DOWN, NULL);
wsa_priv->swr_ctrl_data[0].wsa_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_SSR_DOWN, NULL); wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
SWR_DEVICE_SSR_DOWN, NULL);
}
break; break;
case BOLERO_MACRO_EVT_SSR_UP: case BOLERO_MACRO_EVT_SSR_UP:
/* reset swr after ssr/pdr */ /* reset swr after ssr/pdr */
wsa_priv->reset_swr = true; wsa_priv->reset_swr = true;
swrm_wcd_notify( if (wsa_priv->swr_ctrl_data)
wsa_priv->swr_ctrl_data[0].wsa_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_SSR_UP, NULL); wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
SWR_DEVICE_SSR_UP, NULL);
break; break;
} }
return 0; return 0;
@@ -1135,12 +1139,14 @@ static int wsa_macro_enable_swr(struct snd_soc_dapm_widget *w,
wsa_priv->rx_1_count++; wsa_priv->rx_1_count++;
ch_cnt = wsa_priv->rx_0_count + wsa_priv->rx_1_count; ch_cnt = wsa_priv->rx_0_count + wsa_priv->rx_1_count;
swrm_wcd_notify( if (wsa_priv->swr_ctrl_data) {
wsa_priv->swr_ctrl_data[0].wsa_swr_pdev, swrm_wcd_notify(
SWR_DEVICE_UP, NULL); wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
swrm_wcd_notify( SWR_DEVICE_UP, NULL);
wsa_priv->swr_ctrl_data[0].wsa_swr_pdev, swrm_wcd_notify(
SWR_SET_NUM_RX_CH, &ch_cnt); wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
SWR_SET_NUM_RX_CH, &ch_cnt);
}
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
if (!(strnstr(w->name, "RX0", sizeof("WSA_RX0"))) && if (!(strnstr(w->name, "RX0", sizeof("WSA_RX0"))) &&
@@ -1151,9 +1157,10 @@ static int wsa_macro_enable_swr(struct snd_soc_dapm_widget *w,
wsa_priv->rx_1_count--; wsa_priv->rx_1_count--;
ch_cnt = wsa_priv->rx_0_count + wsa_priv->rx_1_count; ch_cnt = wsa_priv->rx_0_count + wsa_priv->rx_1_count;
swrm_wcd_notify( if (wsa_priv->swr_ctrl_data)
wsa_priv->swr_ctrl_data[0].wsa_swr_pdev, swrm_wcd_notify(
SWR_SET_NUM_RX_CH, &ch_cnt); wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
SWR_SET_NUM_RX_CH, &ch_cnt);
break; break;
} }
dev_dbg(wsa_priv->dev, "%s: current swr ch cnt: %d\n", dev_dbg(wsa_priv->dev, "%s: current swr ch cnt: %d\n",
@@ -2880,6 +2887,8 @@ static int wsa_macro_probe(struct platform_device *pdev)
char __iomem *wsa_io_base; char __iomem *wsa_io_base;
int ret = 0; int ret = 0;
u8 bcl_pmic_params[3]; 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), wsa_priv = devm_kzalloc(&pdev->dev, sizeof(struct wsa_macro_priv),
GFP_KERNEL); GFP_KERNEL);
@@ -2894,9 +2903,20 @@ static int wsa_macro_probe(struct platform_device *pdev)
__func__, "reg"); __func__, "reg");
return ret; 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, wsa_priv->wsa_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
"qcom,wsa-swr-gpios", 0); "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", dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
__func__); __func__);
return -EINVAL; return -EINVAL;