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>
diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c
index 7bf2f9a..d594a99 100644
--- a/soc/swr-mstr-ctrl.c
+++ b/soc/swr-mstr-ctrl.c
@@ -3093,7 +3093,7 @@
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
@@ -3123,6 +3123,10 @@
__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;
@@ -3477,6 +3481,18 @@
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);