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.

Change-Id: I853f42d125eb5a60e3f1f065a60516877e3a463c
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
This commit is contained in:
Laxminath Kasam 2020-10-22 09:29:59 +05:30
parent 63a7be894a
commit 32134e17dd
2 changed files with 18 additions and 1 deletions

View file

@ -3090,7 +3090,7 @@ static int swrm_runtime_resume(struct device *dev)
swrm_request_hw_vote(swrm, LPASS_AUDIO_CORE, false);
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
@ -3120,6 +3120,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->reslock);
mutex_lock(&swrm->force_down_lock);
current_state = swrm->state;
@ -3474,6 +3478,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

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