SoC: swr-mstr: Add support for device wakeup
Add support for soundwire device wakeup through bus driver.
These APIs will be used by slave driver through bus driver
to vote and unvote for master wakeup, when it requires
master for register access operations. Master will be
aware of the slave usage with the vote for device wakeup.
Change-Id: I24f0ec0344f05926dc866edb04294cb31348e1ce
Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
Signed-off-by: Ramprasad Katkam <katkam@codeaurora.org>
diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c
index b6a459e..8f1ad08 100644
--- a/soc/swr-mstr-ctrl.c
+++ b/soc/swr-mstr-ctrl.c
@@ -1535,6 +1535,32 @@
pm_runtime_put_autosuspend(swrm->dev);
return ret;
}
+
+static void swrm_device_wakeup_vote(struct swr_master *mstr)
+{
+ struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(mstr);
+
+ if (!swrm) {
+ pr_err("%s: Invalid handle to swr controller\n",
+ __func__);
+ return;
+ }
+ pm_runtime_get_sync(swrm->dev);
+}
+
+static void swrm_device_wakeup_unvote(struct swr_master *mstr)
+{
+ struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(mstr);
+
+ if (!swrm) {
+ pr_err("%s: Invalid handle to swr controller\n",
+ __func__);
+ return;
+ }
+ pm_runtime_mark_last_busy(swrm->dev);
+ pm_runtime_put_autosuspend(swrm->dev);
+}
+
static int swrm_master_init(struct swr_mstr_ctrl *swrm)
{
int ret = 0;
@@ -1777,6 +1803,8 @@
swrm->master.disconnect_port = swrm_disconnect_port;
swrm->master.slvdev_datapath_control = swrm_slvdev_datapath_control;
swrm->master.remove_from_group = swrm_remove_from_group;
+ swrm->master.device_wakeup_vote = swrm_device_wakeup_vote;
+ swrm->master.device_wakeup_unvote = swrm_device_wakeup_unvote;
swrm->master.dev.parent = &pdev->dev;
swrm->master.dev.of_node = pdev->dev.of_node;
swrm->master.num_port = 0;