asoc: lpass-cdc: update logic to vote during ssr

After ADSP is up during SSR, core_hw_vote may fail and audio_hw_vote
may successed in lpass_cdc_runtime_resume which is caused some timing.
When getting slave device_id, as core_hw_vote is 0, it will skip reading
swr registers and return 0 which causes fail to read correct device_id.
Make this change to avoid calling lpass_cdc_runtime_resume when adsp_up
notification doesn't reach lpass_cdc.

Change-Id: I90a97e5c47bb95180a96ba1c60b462f1fa0124b7
Signed-off-by: Meng Wang <quic_mengw@quicinc.com>
Signed-off-by: Kunlei Zhang <quic_kunleiz@quicinc.com>
This commit is contained in:
Meng Wang
2021-12-13 17:21:29 +08:00
committed by Kunlei Zhang
parent f3752c324e
commit 14b172d92c
5 changed files with 52 additions and 3 deletions

View File

@@ -315,6 +315,7 @@ struct lpass_cdc_wsa2_macro_priv {
u32 wsa2_rload[LPASS_CDC_WSA2_MACRO_RX1 + 1];
u8 idle_detect_en;
int noise_gate_mode;
bool pre_dev_up;
};
static struct snd_soc_dai_driver lpass_cdc_wsa2_macro_dai[];
@@ -1030,6 +1031,7 @@ static int lpass_cdc_wsa2_macro_event_handler(struct snd_soc_component *componen
switch (event) {
case LPASS_CDC_MACRO_EVT_SSR_DOWN:
wsa2_priv->pre_dev_up = false;
trace_printk("%s, enter SSR down\n", __func__);
if (wsa2_priv->swr_ctrl_data) {
swrm_wcd_notify(
@@ -1050,6 +1052,7 @@ static int lpass_cdc_wsa2_macro_event_handler(struct snd_soc_component *componen
break;
case LPASS_CDC_MACRO_EVT_SSR_UP:
trace_printk("%s, enter SSR up\n", __func__);
wsa2_priv->pre_dev_up = true;
/* reset swr after ssr/pdr */
wsa2_priv->reset_swr = true;
if (wsa2_priv->swr_ctrl_data)
@@ -3295,6 +3298,12 @@ static int lpass_cdc_wsa2_macro_core_vote(void *handle, bool enable)
pr_err_ratelimited("%s: wsa2 priv data is NULL\n", __func__);
return -EINVAL;
}
if (!wsa2_priv->pre_dev_up && enable) {
pr_debug("%s: adsp is not up\n", __func__);
return -EINVAL;
}
if (enable) {
pm_runtime_get_sync(wsa2_priv->dev);
if (lpass_cdc_check_core_votes(wsa2_priv->dev))
@@ -3751,6 +3760,7 @@ static int lpass_cdc_wsa2_macro_probe(struct platform_device *pdev)
if (!wsa2_priv)
return -ENOMEM;
wsa2_priv->pre_dev_up = true;
wsa2_priv->dev = &pdev->dev;
ret = of_property_read_u32(pdev->dev.of_node, "reg",
&wsa2_base_addr);