1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * wmfw.h - Wolfson firmware format information 4 * 5 * Copyright 2012 Wolfson Microelectronics plc 6 * 7 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 8 */ 9 10 #ifndef __WMFW_H 11 #define __WMFW_H 12 13 #include <linux/types.h> 14 15 #define WMFW_MAX_ALG_NAME 256 16 #define WMFW_MAX_ALG_DESCR_NAME 256 17 18 #define WMFW_MAX_COEFF_NAME 256 19 #define WMFW_MAX_COEFF_DESCR_NAME 256 20 21 #define WMFW_CTL_FLAG_SYS 0x8000 22 #define WMFW_CTL_FLAG_VOLATILE 0x0004 23 #define WMFW_CTL_FLAG_WRITEABLE 0x0002 24 #define WMFW_CTL_FLAG_READABLE 0x0001 25 26 #define WMFW_CTL_TYPE_BYTES 0x0004 /* byte control */ 27 28 /* Non-ALSA coefficient types start at 0x1000 */ 29 #define WMFW_CTL_TYPE_ACKED 0x1000 /* acked control */ 30 #define WMFW_CTL_TYPE_HOSTEVENT 0x1001 /* event control */ 31 #define WMFW_CTL_TYPE_HOST_BUFFER 0x1002 /* host buffer pointer */ 32 #define WMFW_CTL_TYPE_FWEVENT 0x1004 /* firmware event control */ 33 34 struct wmfw_header { 35 char magic[4]; 36 __le32 len; 37 __le16 rev; 38 u8 core; 39 u8 ver; 40 } __packed; 41 42 struct wmfw_footer { 43 __le64 timestamp; 44 __le32 checksum; 45 } __packed; 46 47 struct wmfw_adsp1_sizes { 48 __le32 dm; 49 __le32 pm; 50 __le32 zm; 51 } __packed; 52 53 struct wmfw_adsp2_sizes { 54 __le32 xm; 55 __le32 ym; 56 __le32 pm; 57 __le32 zm; 58 } __packed; 59 60 struct wmfw_region { 61 union { 62 __be32 type; 63 __le32 offset; 64 }; 65 __le32 len; 66 u8 data[]; 67 } __packed; 68 69 struct wmfw_id_hdr { 70 __be32 core_id; 71 __be32 core_rev; 72 __be32 id; 73 __be32 ver; 74 } __packed; 75 76 struct wmfw_v3_id_hdr { 77 __be32 core_id; 78 __be32 block_rev; 79 __be32 vendor_id; 80 __be32 id; 81 __be32 ver; 82 } __packed; 83 84 struct wmfw_adsp1_id_hdr { 85 struct wmfw_id_hdr fw; 86 __be32 zm; 87 __be32 dm; 88 __be32 n_algs; 89 } __packed; 90 91 struct wmfw_adsp2_id_hdr { 92 struct wmfw_id_hdr fw; 93 __be32 zm; 94 __be32 xm; 95 __be32 ym; 96 __be32 n_algs; 97 } __packed; 98 99 struct wmfw_halo_id_hdr { 100 struct wmfw_v3_id_hdr fw; 101 __be32 xm_base; 102 __be32 xm_size; 103 __be32 ym_base; 104 __be32 ym_size; 105 __be32 n_algs; 106 } __packed; 107 108 struct wmfw_alg_hdr { 109 __be32 id; 110 __be32 ver; 111 } __packed; 112 113 struct wmfw_adsp1_alg_hdr { 114 struct wmfw_alg_hdr alg; 115 __be32 zm; 116 __be32 dm; 117 } __packed; 118 119 struct wmfw_adsp2_alg_hdr { 120 struct wmfw_alg_hdr alg; 121 __be32 zm; 122 __be32 xm; 123 __be32 ym; 124 } __packed; 125 126 struct wmfw_halo_alg_hdr { 127 struct wmfw_alg_hdr alg; 128 __be32 xm_base; 129 __be32 xm_size; 130 __be32 ym_base; 131 __be32 ym_size; 132 } __packed; 133 134 struct wmfw_adsp_alg_data { 135 __le32 id; 136 u8 name[WMFW_MAX_ALG_NAME]; 137 u8 descr[WMFW_MAX_ALG_DESCR_NAME]; 138 __le32 ncoeff; 139 u8 data[]; 140 } __packed; 141 142 struct wmfw_adsp_coeff_data { 143 struct { 144 __le16 offset; 145 __le16 type; 146 __le32 size; 147 } hdr; 148 u8 name[WMFW_MAX_COEFF_NAME]; 149 u8 descr[WMFW_MAX_COEFF_DESCR_NAME]; 150 __le16 ctl_type; 151 __le16 flags; 152 __le32 len; 153 u8 data[]; 154 } __packed; 155 156 struct wmfw_coeff_hdr { 157 u8 magic[4]; 158 __le32 len; 159 union { 160 __be32 rev; 161 __le32 ver; 162 }; 163 union { 164 __be32 core; 165 __le32 core_ver; 166 }; 167 u8 data[]; 168 } __packed; 169 170 struct wmfw_coeff_item { 171 __le16 offset; 172 __le16 type; 173 __le32 id; 174 __le32 ver; 175 __le32 sr; 176 __le32 len; 177 u8 data[]; 178 } __packed; 179 180 #define WMFW_ADSP1 1 181 #define WMFW_ADSP2 2 182 #define WMFW_HALO 4 183 184 #define WMFW_ABSOLUTE 0xf0 185 #define WMFW_ALGORITHM_DATA 0xf2 186 #define WMFW_METADATA 0xfc 187 #define WMFW_NAME_TEXT 0xfe 188 #define WMFW_INFO_TEXT 0xff 189 190 #define WMFW_ADSP1_PM 2 191 #define WMFW_ADSP1_DM 3 192 #define WMFW_ADSP1_ZM 4 193 194 #define WMFW_ADSP2_PM 2 195 #define WMFW_ADSP2_ZM 4 196 #define WMFW_ADSP2_XM 5 197 #define WMFW_ADSP2_YM 6 198 199 #define WMFW_HALO_PM_PACKED 0x10 200 #define WMFW_HALO_XM_PACKED 0x11 201 #define WMFW_HALO_YM_PACKED 0x12 202 203 #endif 204