1 /* SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright(c) 2021 Intel Corporation. All rights reserved. 4 */ 5 6 /* 7 * This file contains structures that are exact copies of an existing ABI used 8 * by IOT middleware. They are Intel specific and will be used by one middleware. 9 * 10 * Some of the structures may contain programming implementations that makes them 11 * unsuitable for generic use and general usage. 12 * 13 * This code is mostly copied "as-is" from existing C++ interface files hence the use of 14 * different style in places. The intention is to keep the interface as close as possible to 15 * original so it's easier to track changes with IPC host code. 16 */ 17 18 /** 19 * \file include/ipc4/header.h 20 * \brief IPC4 global definitions. 21 * NOTE: This ABI uses bit fields and is non portable. 22 */ 23 24 #ifndef __SOF_IPC4_GATEWAY_H__ 25 #define __SOF_IPC4_GATEWAY_H__ 26 27 #include <stdint.h> 28 #include <rtos/bit.h> 29 30 /**< Type of the gateway. */ 31 enum ipc4_connector_node_id_type { 32 /**< HD/A host output (-> DSP). */ 33 ipc4_hda_host_output_class = 0, 34 /**< HD/A host input (<- DSP). */ 35 ipc4_hda_host_input_class = 1, 36 /**< HD/A host input/output (rsvd for future use). */ 37 ipc4_hda_host_inout_class = 2, 38 39 /**< HD/A link output (DSP ->). */ 40 ipc4_hda_link_output_class = 8, 41 /**< HD/A link input (DSP <-). */ 42 ipc4_hda_link_input_class = 9, 43 /**< HD/A link input/output (rsvd for future use). */ 44 ipc4_hda_link_inout_class = 10, 45 46 /**< DMIC link input (DSP <-). */ 47 ipc4_dmic_link_input_class = 11, 48 49 /**< I2S link output (DSP ->). */ 50 ipc4_i2s_link_output_class = 12, 51 /**< I2S link input (DSP <-). */ 52 ipc4_i2s_link_input_class = 13, 53 54 /**< ALH link output, legacy for SNDW (DSP ->). */ 55 ipc4_alh_link_output_class = 16, 56 /**< ALH link input, legacy for SNDW (DSP <-). */ 57 ipc4_alh_link_input_class = 17, 58 59 /**< SNDW link output (DSP ->). */ 60 ipc4_alh_snd_wire_stream_link_output_class = 16, 61 /**< SNDW link input (DSP <-). */ 62 ipc4_alh_snd_wire_stream_link_input_class = 17, 63 64 /**< UAOL link output (DSP ->). */ 65 ipc4_alh_uaol_stream_link_output_class = 18, 66 /**< UAOL link input (DSP <-). */ 67 ipc4_alh_uaol_stream_link_input_class = 19, 68 69 /**< IPC output (DSP ->). */ 70 ipc4_ipc_output_class = 20, 71 /**< IPC input (DSP <-). */ 72 ipc4_ipc_input_class = 21, 73 74 /**< I2S Multi gtw output (DSP ->). */ 75 ipc4_i2s_multi_link_output_class = 22, 76 /**< I2S Multi gtw input (DSP <-). */ 77 ipc4_i2s_multi_link_input_class = 23, 78 /**< GPIO */ 79 ipc4_gpio_class = 24, 80 /**< SPI */ 81 ipc4_spi_output_class = 25, 82 ipc4_spi_input_class = 26, 83 ipc4_max_connector_node_id_type 84 }; 85 86 /**< Invalid raw node id (to indicate uninitialized node id). */ 87 #define IPC4_INVALID_NODE_ID 0xffffffff 88 89 /**< all bits of v_index and dma_type */ 90 #define IPC4_NODE_ID_MASK 0x1fff 91 92 /**< Base top-level structure of an address of a gateway. */ 93 /*! 94 * The virtual index value, presented on the top level as raw 8 bits, 95 * is expected to be encoded in a gateway specific way depending on 96 * the actual type of gateway. 97 */ 98 union ipc4_connector_node_id { 99 100 /**< Raw 32-bit value of node id. */ 101 uint32_t dw; 102 103 /**< Bit fields */ 104 struct { 105 /**< Index of the virtual DMA at the gateway. */ 106 uint32_t v_index : 8; 107 108 /**< Type of the gateway, one of ConnectorNodeId::Type values. */ 109 uint32_t dma_type : 5; 110 111 /**< Rsvd field. */ 112 uint32_t _rsvd : 19; 113 } f; /**<< Bits */ 114 } __attribute__((packed, aligned(4))); 115 116 #define IPC4_HW_HOST_OUTPUT_NODE_ID_BASE 0x00 117 #define IPC4_HW_CODE_LOADER_NODE_ID 0x0F 118 #define IPC4_HW_LINK_INPUT_NODE_ID_BASE 0x10 119 120 /*! 121 * Attributes are usually provided along with the gateway configuration 122 * BLOB when the FW is requested to instantiate that gateway. 123 * 124 * There are flags which requests FW to allocate gateway related data 125 * (buffers and other items used while transferring data, like linked list) 126 * to be allocated from a special memory area, e.g low power memory. 127 */ 128 union ipc4_gateway_attributes { 129 130 /**< Raw value */ 131 uint32_t dw; 132 133 /**< Access to the fields */ 134 struct { 135 /**< Gateway data requested in low power memory. */ 136 uint32_t lp_buffer_alloc : 1; 137 138 /**< Gateway data requested in register file memory. */ 139 uint32_t alloc_from_reg_file : 1; 140 141 /**< Reserved field */ 142 uint32_t _rsvd : 30; 143 } bits; /**<< Bits */ 144 } __attribute__((packed, aligned(4))); 145 146 /**< Gateway configuration BLOB structure. */ 147 /*! 148 * Actual config_blob content depends on the specific target gateway type. 149 */ 150 struct ipc4_gateway_config_data { 151 /**< Gateway attributes */ 152 union ipc4_gateway_attributes gtw_attributes; 153 154 /**< Configuration BLOB */ 155 uint32_t config_blob[]; 156 } __attribute__((packed, aligned(4))); 157 158 /**< Configuration for the IPC Gateway */ 159 struct ipc4_ipc_gateway_config_blob { 160 161 /**< Size of the gateway buffer, specified in bytes */ 162 uint32_t buffer_size; 163 164 /**< Flags */ 165 union flags { 166 struct bits { 167 /**< Activates high threshold notification */ 168 /*! 169 * Indicates whether notification should be sent to the host 170 * when the size of data in the buffer reaches the high threshold 171 * specified by threshold_high parameter. 172 */ 173 uint32_t notif_high : 1; 174 175 /**< Activates low threshold notification */ 176 /*! 177 * Indicates whether notification should be sent to the host 178 * when the size of data in the buffer reaches the low threshold 179 * specified by threshold_low parameter. 180 */ 181 uint32_t notif_low : 1; 182 183 /**< Reserved field */ 184 uint32_t rsvd : 30; 185 } f; /**<< Bits */ 186 /**< Raw value of flags */ 187 uint32_t flags_raw; 188 } u; /**<< Flags */ 189 190 /**< High threshold */ 191 /*! 192 * Specifies the high threshold (in bytes) for notifying the host 193 * about the buffered data level. 194 */ 195 uint32_t threshold_high; 196 197 /**< Low threshold */ 198 /*! 199 * Specifies the low threshold (in bytes) for notifying the host 200 * about the buffered data level. 201 */ 202 uint32_t threshold_low; 203 } __attribute__((packed, aligned(4))); 204 205 enum ipc4_gateway_type { 206 ipc4_gtw_none = BIT(0), 207 ipc4_gtw_host = BIT(1), 208 ipc4_gtw_dmic = BIT(2), 209 ipc4_gtw_link = BIT(3), 210 ipc4_gtw_alh = BIT(4), 211 ipc4_gtw_ssp = BIT(5), 212 ipc4_gtw_all = BIT(6) - 1 213 }; 214 215 enum ipc4_direction_type { 216 ipc4_playback = BIT(0), 217 ipc4_capture = BIT(1), 218 ipc4_bidirection = BIT(0) | BIT(1) 219 }; 220 221 #define IPC4_DIRECTION(x) BIT(x) 222 #endif 223