18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 48c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright(c) 2018 Intel Corporation. All rights reserved. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __INCLUDE_SOUND_SOF_HEADER_H__ 108c2ecf20Sopenharmony_ci#define __INCLUDE_SOUND_SOF_HEADER_H__ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/types.h> 138c2ecf20Sopenharmony_ci#include <uapi/sound/sof/abi.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/** \addtogroup sof_uapi uAPI 168c2ecf20Sopenharmony_ci * SOF uAPI specification. 178c2ecf20Sopenharmony_ci * @{ 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * IPC messages have a prefixed 32 bit identifier made up as follows :- 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * 0xGCCCNNNN where 248c2ecf20Sopenharmony_ci * G is global cmd type (4 bits) 258c2ecf20Sopenharmony_ci * C is command type (12 bits) 268c2ecf20Sopenharmony_ci * I is the ID number (16 bits) - monotonic and overflows 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * This is sent at the start of the IPM message in the mailbox. Messages should 298c2ecf20Sopenharmony_ci * not be sent in the doorbell (special exceptions for firmware . 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* Global Message - Generic */ 338c2ecf20Sopenharmony_ci#define SOF_GLB_TYPE_SHIFT 28 348c2ecf20Sopenharmony_ci#define SOF_GLB_TYPE_MASK (0xf << SOF_GLB_TYPE_SHIFT) 358c2ecf20Sopenharmony_ci#define SOF_GLB_TYPE(x) ((x) << SOF_GLB_TYPE_SHIFT) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* Command Message - Generic */ 388c2ecf20Sopenharmony_ci#define SOF_CMD_TYPE_SHIFT 16 398c2ecf20Sopenharmony_ci#define SOF_CMD_TYPE_MASK (0xfff << SOF_CMD_TYPE_SHIFT) 408c2ecf20Sopenharmony_ci#define SOF_CMD_TYPE(x) ((x) << SOF_CMD_TYPE_SHIFT) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* Global Message Types */ 438c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_REPLY SOF_GLB_TYPE(0x1U) 448c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_COMPOUND SOF_GLB_TYPE(0x2U) 458c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_TPLG_MSG SOF_GLB_TYPE(0x3U) 468c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_PM_MSG SOF_GLB_TYPE(0x4U) 478c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_COMP_MSG SOF_GLB_TYPE(0x5U) 488c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_STREAM_MSG SOF_GLB_TYPE(0x6U) 498c2ecf20Sopenharmony_ci#define SOF_IPC_FW_READY SOF_GLB_TYPE(0x7U) 508c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_DAI_MSG SOF_GLB_TYPE(0x8U) 518c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_TRACE_MSG SOF_GLB_TYPE(0x9U) 528c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_GDB_DEBUG SOF_GLB_TYPE(0xAU) 538c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_TEST_MSG SOF_GLB_TYPE(0xBU) 548c2ecf20Sopenharmony_ci#define SOF_IPC_GLB_PROBE SOF_GLB_TYPE(0xCU) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* 578c2ecf20Sopenharmony_ci * DSP Command Message Types 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* topology */ 618c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_COMP_NEW SOF_CMD_TYPE(0x001) 628c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_COMP_FREE SOF_CMD_TYPE(0x002) 638c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_COMP_CONNECT SOF_CMD_TYPE(0x003) 648c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_PIPE_NEW SOF_CMD_TYPE(0x010) 658c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_PIPE_FREE SOF_CMD_TYPE(0x011) 668c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_PIPE_CONNECT SOF_CMD_TYPE(0x012) 678c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_PIPE_COMPLETE SOF_CMD_TYPE(0x013) 688c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_BUFFER_NEW SOF_CMD_TYPE(0x020) 698c2ecf20Sopenharmony_ci#define SOF_IPC_TPLG_BUFFER_FREE SOF_CMD_TYPE(0x021) 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* PM */ 728c2ecf20Sopenharmony_ci#define SOF_IPC_PM_CTX_SAVE SOF_CMD_TYPE(0x001) 738c2ecf20Sopenharmony_ci#define SOF_IPC_PM_CTX_RESTORE SOF_CMD_TYPE(0x002) 748c2ecf20Sopenharmony_ci#define SOF_IPC_PM_CTX_SIZE SOF_CMD_TYPE(0x003) 758c2ecf20Sopenharmony_ci#define SOF_IPC_PM_CLK_SET SOF_CMD_TYPE(0x004) 768c2ecf20Sopenharmony_ci#define SOF_IPC_PM_CLK_GET SOF_CMD_TYPE(0x005) 778c2ecf20Sopenharmony_ci#define SOF_IPC_PM_CLK_REQ SOF_CMD_TYPE(0x006) 788c2ecf20Sopenharmony_ci#define SOF_IPC_PM_CORE_ENABLE SOF_CMD_TYPE(0x007) 798c2ecf20Sopenharmony_ci#define SOF_IPC_PM_GATE SOF_CMD_TYPE(0x008) 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* component runtime config - multiple different types */ 828c2ecf20Sopenharmony_ci#define SOF_IPC_COMP_SET_VALUE SOF_CMD_TYPE(0x001) 838c2ecf20Sopenharmony_ci#define SOF_IPC_COMP_GET_VALUE SOF_CMD_TYPE(0x002) 848c2ecf20Sopenharmony_ci#define SOF_IPC_COMP_SET_DATA SOF_CMD_TYPE(0x003) 858c2ecf20Sopenharmony_ci#define SOF_IPC_COMP_GET_DATA SOF_CMD_TYPE(0x004) 868c2ecf20Sopenharmony_ci#define SOF_IPC_COMP_NOTIFICATION SOF_CMD_TYPE(0x005) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* DAI messages */ 898c2ecf20Sopenharmony_ci#define SOF_IPC_DAI_CONFIG SOF_CMD_TYPE(0x001) 908c2ecf20Sopenharmony_ci#define SOF_IPC_DAI_LOOPBACK SOF_CMD_TYPE(0x002) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* stream */ 938c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_PCM_PARAMS SOF_CMD_TYPE(0x001) 948c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_PCM_PARAMS_REPLY SOF_CMD_TYPE(0x002) 958c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_PCM_FREE SOF_CMD_TYPE(0x003) 968c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_TRIG_START SOF_CMD_TYPE(0x004) 978c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_TRIG_STOP SOF_CMD_TYPE(0x005) 988c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_TRIG_PAUSE SOF_CMD_TYPE(0x006) 998c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_TRIG_RELEASE SOF_CMD_TYPE(0x007) 1008c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_TRIG_DRAIN SOF_CMD_TYPE(0x008) 1018c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_TRIG_XRUN SOF_CMD_TYPE(0x009) 1028c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_POSITION SOF_CMD_TYPE(0x00a) 1038c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_VORBIS_PARAMS SOF_CMD_TYPE(0x010) 1048c2ecf20Sopenharmony_ci#define SOF_IPC_STREAM_VORBIS_FREE SOF_CMD_TYPE(0x011) 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* probe */ 1078c2ecf20Sopenharmony_ci#define SOF_IPC_PROBE_INIT SOF_CMD_TYPE(0x001) 1088c2ecf20Sopenharmony_ci#define SOF_IPC_PROBE_DEINIT SOF_CMD_TYPE(0x002) 1098c2ecf20Sopenharmony_ci#define SOF_IPC_PROBE_DMA_ADD SOF_CMD_TYPE(0x003) 1108c2ecf20Sopenharmony_ci#define SOF_IPC_PROBE_DMA_INFO SOF_CMD_TYPE(0x004) 1118c2ecf20Sopenharmony_ci#define SOF_IPC_PROBE_DMA_REMOVE SOF_CMD_TYPE(0x005) 1128c2ecf20Sopenharmony_ci#define SOF_IPC_PROBE_POINT_ADD SOF_CMD_TYPE(0x006) 1138c2ecf20Sopenharmony_ci#define SOF_IPC_PROBE_POINT_INFO SOF_CMD_TYPE(0x007) 1148c2ecf20Sopenharmony_ci#define SOF_IPC_PROBE_POINT_REMOVE SOF_CMD_TYPE(0x008) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci/* trace */ 1178c2ecf20Sopenharmony_ci#define SOF_IPC_TRACE_DMA_PARAMS SOF_CMD_TYPE(0x001) 1188c2ecf20Sopenharmony_ci#define SOF_IPC_TRACE_DMA_POSITION SOF_CMD_TYPE(0x002) 1198c2ecf20Sopenharmony_ci#define SOF_IPC_TRACE_DMA_PARAMS_EXT SOF_CMD_TYPE(0x003) 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* debug */ 1228c2ecf20Sopenharmony_ci#define SOF_IPC_TEST_IPC_FLOOD SOF_CMD_TYPE(0x001) 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci/* Get message component id */ 1258c2ecf20Sopenharmony_ci#define SOF_IPC_MESSAGE_ID(x) ((x) & 0xffff) 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci/* maximum message size for mailbox Tx/Rx */ 1288c2ecf20Sopenharmony_ci#define SOF_IPC_MSG_MAX_SIZE 384 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci/* 1318c2ecf20Sopenharmony_ci * Structure Header - Header for all IPC structures except command structs. 1328c2ecf20Sopenharmony_ci * The size can be greater than the structure size and that means there is 1338c2ecf20Sopenharmony_ci * extended bespoke data beyond the end of the structure including variable 1348c2ecf20Sopenharmony_ci * arrays. 1358c2ecf20Sopenharmony_ci */ 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cistruct sof_ipc_hdr { 1388c2ecf20Sopenharmony_ci uint32_t size; /**< size of structure */ 1398c2ecf20Sopenharmony_ci} __packed; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* 1428c2ecf20Sopenharmony_ci * Command Header - Header for all IPC commands. Identifies IPC message. 1438c2ecf20Sopenharmony_ci * The size can be greater than the structure size and that means there is 1448c2ecf20Sopenharmony_ci * extended bespoke data beyond the end of the structure including variable 1458c2ecf20Sopenharmony_ci * arrays. 1468c2ecf20Sopenharmony_ci */ 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_cistruct sof_ipc_cmd_hdr { 1498c2ecf20Sopenharmony_ci uint32_t size; /**< size of structure */ 1508c2ecf20Sopenharmony_ci uint32_t cmd; /**< SOF_IPC_GLB_ + cmd */ 1518c2ecf20Sopenharmony_ci} __packed; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci/* 1548c2ecf20Sopenharmony_ci * Generic reply message. Some commands override this with their own reply 1558c2ecf20Sopenharmony_ci * types that must include this at start. 1568c2ecf20Sopenharmony_ci */ 1578c2ecf20Sopenharmony_cistruct sof_ipc_reply { 1588c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 1598c2ecf20Sopenharmony_ci int32_t error; /**< negative error numbers */ 1608c2ecf20Sopenharmony_ci} __packed; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci/* 1638c2ecf20Sopenharmony_ci * Compound commands - SOF_IPC_GLB_COMPOUND. 1648c2ecf20Sopenharmony_ci * 1658c2ecf20Sopenharmony_ci * Compound commands are sent to the DSP as a single IPC operation. The 1668c2ecf20Sopenharmony_ci * commands are split into blocks and each block has a header. This header 1678c2ecf20Sopenharmony_ci * identifies the command type and the number of commands before the next 1688c2ecf20Sopenharmony_ci * header. 1698c2ecf20Sopenharmony_ci */ 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_cistruct sof_ipc_compound_hdr { 1728c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 1738c2ecf20Sopenharmony_ci uint32_t count; /**< count of 0 means end of compound sequence */ 1748c2ecf20Sopenharmony_ci} __packed; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/** 1778c2ecf20Sopenharmony_ci * OOPS header architecture specific data. 1788c2ecf20Sopenharmony_ci */ 1798c2ecf20Sopenharmony_cistruct sof_ipc_dsp_oops_arch_hdr { 1808c2ecf20Sopenharmony_ci uint32_t arch; /* Identifier of architecture */ 1818c2ecf20Sopenharmony_ci uint32_t totalsize; /* Total size of oops message */ 1828c2ecf20Sopenharmony_ci} __packed; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci/** 1858c2ecf20Sopenharmony_ci * OOPS header platform specific data. 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_cistruct sof_ipc_dsp_oops_plat_hdr { 1888c2ecf20Sopenharmony_ci uint32_t configidhi; /* ConfigID hi 32bits */ 1898c2ecf20Sopenharmony_ci uint32_t configidlo; /* ConfigID lo 32bits */ 1908c2ecf20Sopenharmony_ci uint32_t numaregs; /* Special regs num */ 1918c2ecf20Sopenharmony_ci uint32_t stackoffset; /* Offset to stack pointer from beginning of 1928c2ecf20Sopenharmony_ci * oops message 1938c2ecf20Sopenharmony_ci */ 1948c2ecf20Sopenharmony_ci uint32_t stackptr; /* Stack ptr */ 1958c2ecf20Sopenharmony_ci} __packed; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/** @}*/ 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci#endif 200