xref: /openbmc/linux/sound/soc/sof/ipc3.c (revision b4bd2aaf)
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 //
3 // This file is provided under a dual BSD/GPLv2 license.  When using or
4 // redistributing this file, you may do so under either license.
5 //
6 // Copyright(c) 2021 Intel Corporation. All rights reserved.
7 //
8 //
9 
10 #include "sof-priv.h"
11 #include "ipc3-ops.h"
12 
13 static int sof_ipc3_ctx_ipc(struct snd_sof_dev *sdev, int cmd)
14 {
15 	struct sof_ipc_pm_ctx pm_ctx = {
16 		.hdr.size = sizeof(pm_ctx),
17 		.hdr.cmd = SOF_IPC_GLB_PM_MSG | cmd,
18 	};
19 	struct sof_ipc_reply reply;
20 
21 	/* send ctx save ipc to dsp */
22 	return sof_ipc_tx_message(sdev->ipc, pm_ctx.hdr.cmd, &pm_ctx,
23 				  sizeof(pm_ctx), &reply, sizeof(reply));
24 }
25 
26 static int sof_ipc3_ctx_save(struct snd_sof_dev *sdev)
27 {
28 	return sof_ipc3_ctx_ipc(sdev, SOF_IPC_PM_CTX_SAVE);
29 }
30 
31 static int sof_ipc3_ctx_restore(struct snd_sof_dev *sdev)
32 {
33 	return sof_ipc3_ctx_ipc(sdev, SOF_IPC_PM_CTX_RESTORE);
34 }
35 
36 static const struct sof_ipc_pm_ops ipc3_pm_ops = {
37 	.ctx_save = sof_ipc3_ctx_save,
38 	.ctx_restore = sof_ipc3_ctx_restore,
39 };
40 
41 const struct sof_ipc_ops ipc3_ops = {
42 	.tplg = &ipc3_tplg_ops,
43 	.pm = &ipc3_pm_ops,
44 	.pcm = &ipc3_pcm_ops,
45 };
46