xref: /openbmc/linux/include/sound/sof/header.h (revision cc6c6912)
1 /* SPDX-License-Identifier: (GPL-2.0 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) 2018 Intel Corporation. All rights reserved.
7  */
8 
9 #ifndef __INCLUDE_SOUND_SOF_HEADER_H__
10 #define __INCLUDE_SOUND_SOF_HEADER_H__
11 
12 #include <linux/types.h>
13 #include <uapi/sound/sof/abi.h>
14 
15 /** \addtogroup sof_uapi uAPI
16  *  SOF uAPI specification.
17  *  @{
18  */
19 
20 /*
21  * IPC messages have a prefixed 32 bit identifier made up as follows :-
22  *
23  * 0xGCCCNNNN where
24  * G is global cmd type (4 bits)
25  * C is command type (12 bits)
26  * I is the ID number (16 bits) - monotonic and overflows
27  *
28  * This is sent at the start of the IPM message in the mailbox. Messages should
29  * not be sent in the doorbell (special exceptions for firmware .
30  */
31 
32 /* Global Message - Generic */
33 #define SOF_GLB_TYPE_SHIFT			28
34 #define SOF_GLB_TYPE_MASK			(0xf << SOF_GLB_TYPE_SHIFT)
35 #define SOF_GLB_TYPE(x)				((x) << SOF_GLB_TYPE_SHIFT)
36 
37 /* Command Message - Generic */
38 #define SOF_CMD_TYPE_SHIFT			16
39 #define SOF_CMD_TYPE_MASK			(0xfff << SOF_CMD_TYPE_SHIFT)
40 #define SOF_CMD_TYPE(x)				((x) << SOF_CMD_TYPE_SHIFT)
41 
42 /* Global Message Types */
43 #define SOF_IPC_GLB_REPLY			SOF_GLB_TYPE(0x1U)
44 #define SOF_IPC_GLB_COMPOUND			SOF_GLB_TYPE(0x2U)
45 #define SOF_IPC_GLB_TPLG_MSG			SOF_GLB_TYPE(0x3U)
46 #define SOF_IPC_GLB_PM_MSG			SOF_GLB_TYPE(0x4U)
47 #define SOF_IPC_GLB_COMP_MSG			SOF_GLB_TYPE(0x5U)
48 #define SOF_IPC_GLB_STREAM_MSG			SOF_GLB_TYPE(0x6U)
49 #define SOF_IPC_FW_READY			SOF_GLB_TYPE(0x7U)
50 #define SOF_IPC_GLB_DAI_MSG			SOF_GLB_TYPE(0x8U)
51 #define SOF_IPC_GLB_TRACE_MSG			SOF_GLB_TYPE(0x9U)
52 #define SOF_IPC_GLB_GDB_DEBUG                   SOF_GLB_TYPE(0xAU)
53 #define SOF_IPC_GLB_TEST_MSG			SOF_GLB_TYPE(0xBU)
54 
55 /*
56  * DSP Command Message Types
57  */
58 
59 /* topology */
60 #define SOF_IPC_TPLG_COMP_NEW			SOF_CMD_TYPE(0x001)
61 #define SOF_IPC_TPLG_COMP_FREE			SOF_CMD_TYPE(0x002)
62 #define SOF_IPC_TPLG_COMP_CONNECT		SOF_CMD_TYPE(0x003)
63 #define SOF_IPC_TPLG_PIPE_NEW			SOF_CMD_TYPE(0x010)
64 #define SOF_IPC_TPLG_PIPE_FREE			SOF_CMD_TYPE(0x011)
65 #define SOF_IPC_TPLG_PIPE_CONNECT		SOF_CMD_TYPE(0x012)
66 #define SOF_IPC_TPLG_PIPE_COMPLETE		SOF_CMD_TYPE(0x013)
67 #define SOF_IPC_TPLG_BUFFER_NEW			SOF_CMD_TYPE(0x020)
68 #define SOF_IPC_TPLG_BUFFER_FREE		SOF_CMD_TYPE(0x021)
69 
70 /* PM */
71 #define SOF_IPC_PM_CTX_SAVE			SOF_CMD_TYPE(0x001)
72 #define SOF_IPC_PM_CTX_RESTORE			SOF_CMD_TYPE(0x002)
73 #define SOF_IPC_PM_CTX_SIZE			SOF_CMD_TYPE(0x003)
74 #define SOF_IPC_PM_CLK_SET			SOF_CMD_TYPE(0x004)
75 #define SOF_IPC_PM_CLK_GET			SOF_CMD_TYPE(0x005)
76 #define SOF_IPC_PM_CLK_REQ			SOF_CMD_TYPE(0x006)
77 #define SOF_IPC_PM_CORE_ENABLE			SOF_CMD_TYPE(0x007)
78 #define SOF_IPC_PM_GATE				SOF_CMD_TYPE(0x008)
79 
80 /* component runtime config - multiple different types */
81 #define SOF_IPC_COMP_SET_VALUE			SOF_CMD_TYPE(0x001)
82 #define SOF_IPC_COMP_GET_VALUE			SOF_CMD_TYPE(0x002)
83 #define SOF_IPC_COMP_SET_DATA			SOF_CMD_TYPE(0x003)
84 #define SOF_IPC_COMP_GET_DATA			SOF_CMD_TYPE(0x004)
85 #define SOF_IPC_COMP_NOTIFICATION		SOF_CMD_TYPE(0x005)
86 
87 /* DAI messages */
88 #define SOF_IPC_DAI_CONFIG			SOF_CMD_TYPE(0x001)
89 #define SOF_IPC_DAI_LOOPBACK			SOF_CMD_TYPE(0x002)
90 
91 /* stream */
92 #define SOF_IPC_STREAM_PCM_PARAMS		SOF_CMD_TYPE(0x001)
93 #define SOF_IPC_STREAM_PCM_PARAMS_REPLY		SOF_CMD_TYPE(0x002)
94 #define SOF_IPC_STREAM_PCM_FREE			SOF_CMD_TYPE(0x003)
95 #define SOF_IPC_STREAM_TRIG_START		SOF_CMD_TYPE(0x004)
96 #define SOF_IPC_STREAM_TRIG_STOP		SOF_CMD_TYPE(0x005)
97 #define SOF_IPC_STREAM_TRIG_PAUSE		SOF_CMD_TYPE(0x006)
98 #define SOF_IPC_STREAM_TRIG_RELEASE		SOF_CMD_TYPE(0x007)
99 #define SOF_IPC_STREAM_TRIG_DRAIN		SOF_CMD_TYPE(0x008)
100 #define SOF_IPC_STREAM_TRIG_XRUN		SOF_CMD_TYPE(0x009)
101 #define SOF_IPC_STREAM_POSITION			SOF_CMD_TYPE(0x00a)
102 #define SOF_IPC_STREAM_VORBIS_PARAMS		SOF_CMD_TYPE(0x010)
103 #define SOF_IPC_STREAM_VORBIS_FREE		SOF_CMD_TYPE(0x011)
104 
105 /* trace */
106 #define SOF_IPC_TRACE_DMA_PARAMS		SOF_CMD_TYPE(0x001)
107 #define SOF_IPC_TRACE_DMA_POSITION		SOF_CMD_TYPE(0x002)
108 #define SOF_IPC_TRACE_DMA_PARAMS_EXT		SOF_CMD_TYPE(0x003)
109 
110 /* debug */
111 #define SOF_IPC_TEST_IPC_FLOOD                  SOF_CMD_TYPE(0x001)
112 
113 /* Get message component id */
114 #define SOF_IPC_MESSAGE_ID(x)			((x) & 0xffff)
115 
116 /* maximum message size for mailbox Tx/Rx */
117 #define SOF_IPC_MSG_MAX_SIZE			384
118 
119 /*
120  * Structure Header - Header for all IPC structures except command structs.
121  * The size can be greater than the structure size and that means there is
122  * extended bespoke data beyond the end of the structure including variable
123  * arrays.
124  */
125 
126 struct sof_ipc_hdr {
127 	uint32_t size;			/**< size of structure */
128 } __packed;
129 
130 /*
131  * Command Header - Header for all IPC commands. Identifies IPC message.
132  * The size can be greater than the structure size and that means there is
133  * extended bespoke data beyond the end of the structure including variable
134  * arrays.
135  */
136 
137 struct sof_ipc_cmd_hdr {
138 	uint32_t size;			/**< size of structure */
139 	uint32_t cmd;			/**< SOF_IPC_GLB_ + cmd */
140 } __packed;
141 
142 /*
143  * Generic reply message. Some commands override this with their own reply
144  * types that must include this at start.
145  */
146 struct sof_ipc_reply {
147 	struct sof_ipc_cmd_hdr hdr;
148 	int32_t error;			/**< negative error numbers */
149 }  __packed;
150 
151 /*
152  * Compound commands - SOF_IPC_GLB_COMPOUND.
153  *
154  * Compound commands are sent to the DSP as a single IPC operation. The
155  * commands are split into blocks and each block has a header. This header
156  * identifies the command type and the number of commands before the next
157  * header.
158  */
159 
160 struct sof_ipc_compound_hdr {
161 	struct sof_ipc_cmd_hdr hdr;
162 	uint32_t count;		/**< count of 0 means end of compound sequence */
163 }  __packed;
164 
165 /**
166  * OOPS header architecture specific data.
167  */
168 struct sof_ipc_dsp_oops_arch_hdr {
169 	uint32_t arch;		/* Identifier of architecture */
170 	uint32_t totalsize;	/* Total size of oops message */
171 }  __packed;
172 
173 /**
174  * OOPS header platform specific data.
175  */
176 struct sof_ipc_dsp_oops_plat_hdr {
177 	uint32_t configidhi;	/* ConfigID hi 32bits */
178 	uint32_t configidlo;	/* ConfigID lo 32bits */
179 	uint32_t numaregs;	/* Special regs num */
180 	uint32_t stackoffset;	/* Offset to stack pointer from beginning of
181 				 * oops message
182 				 */
183 	uint32_t stackptr;	/* Stack ptr */
184 }  __packed;
185 
186 /** @}*/
187 
188 #endif
189