soc: swr-mstr: Update soundwire state to SSR during UP

During SSR up event handler, if soundwire state is
already up or auto suspend jiffies is not completed,
ensure put in suspend/SSR state.

Propagated from the 5.0 branch.

Change-Id: I2a8a995399e7844cbc1d6a5676f0d57d97577862
Signed-off-by: Junkai Cai <junkai@codeaurora.org>
This commit is contained in:
Junkai Cai
2021-08-21 16:28:18 -07:00
parent 16acb739c4
commit 319e140119
2 changed files with 18 additions and 1 deletions

View File

@@ -3261,7 +3261,7 @@ exit:
if (!hw_core_err)
swrm_request_hw_vote(swrm, LPASS_HW_CORE, false);
if (swrm_clk_req_err)
if (swrm_clk_req_err || aud_core_err || hw_core_err)
pm_runtime_set_autosuspend_delay(&pdev->dev,
ERR_AUTO_SUSPEND_TIMER_VAL);
else
@@ -3292,6 +3292,10 @@ static int swrm_runtime_suspend(struct device *dev)
__func__, swrm->state);
dev_dbg(dev, "%s: pm_runtime: suspend state: %d\n",
__func__, swrm->state);
if (swrm->state == SWR_MSTR_SSR_RESET) {
swrm->state = SWR_MSTR_SSR;
return 0;
}
mutex_lock(&swrm->runtime_lock);
mutex_lock(&swrm->reslock);
mutex_lock(&swrm->force_down_lock);
@@ -3638,6 +3642,18 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
dev_err(swrm->dev, "%s: clock voting not zero\n",
__func__);
if (swrm->state == SWR_MSTR_UP ||
pm_runtime_autosuspend_expiration(swrm->dev)) {
swrm->state = SWR_MSTR_SSR_RESET;
dev_dbg(swrm->dev,
"%s:suspend swr if active at SSR up\n",
__func__);
pm_runtime_set_autosuspend_delay(swrm->dev,
ERR_AUTO_SUSPEND_TIMER_VAL);
usleep_range(50000, 50100);
swrm->state = SWR_MSTR_SSR;
}
mutex_lock(&swrm->devlock);
swrm->dev_up = true;
mutex_unlock(&swrm->devlock);

View File

@@ -52,6 +52,7 @@ enum {
SWR_MSTR_UP,
SWR_MSTR_DOWN,
SWR_MSTR_SSR,
SWR_MSTR_SSR_RESET,
};
enum swrm_pm_state {