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 
33 struct wmfw_header {
34 	char magic[4];
35 	__le32 len;
36 	__le16 rev;
37 	u8 core;
38 	u8 ver;
39 } __packed;
40 
41 struct wmfw_footer {
42 	__le64 timestamp;
43 	__le32 checksum;
44 } __packed;
45 
46 struct wmfw_adsp1_sizes {
47 	__le32 dm;
48 	__le32 pm;
49 	__le32 zm;
50 } __packed;
51 
52 struct wmfw_adsp2_sizes {
53 	__le32 xm;
54 	__le32 ym;
55 	__le32 pm;
56 	__le32 zm;
57 } __packed;
58 
59 struct wmfw_region {
60 	union {
61 		__be32 type;
62 		__le32 offset;
63 	};
64 	__le32 len;
65 	u8 data[];
66 } __packed;
67 
68 struct wmfw_id_hdr {
69 	__be32 core_id;
70 	__be32 core_rev;
71 	__be32 id;
72 	__be32 ver;
73 } __packed;
74 
75 struct wmfw_v3_id_hdr {
76 	__be32 core_id;
77 	__be32 block_rev;
78 	__be32 vendor_id;
79 	__be32 id;
80 	__be32 ver;
81 } __packed;
82 
83 struct wmfw_adsp1_id_hdr {
84 	struct wmfw_id_hdr fw;
85 	__be32 zm;
86 	__be32 dm;
87 	__be32 n_algs;
88 } __packed;
89 
90 struct wmfw_adsp2_id_hdr {
91 	struct wmfw_id_hdr fw;
92 	__be32 zm;
93 	__be32 xm;
94 	__be32 ym;
95 	__be32 n_algs;
96 } __packed;
97 
98 struct wmfw_halo_id_hdr {
99 	struct wmfw_v3_id_hdr fw;
100 	__be32 xm_base;
101 	__be32 xm_size;
102 	__be32 ym_base;
103 	__be32 ym_size;
104 	__be32 n_algs;
105 } __packed;
106 
107 struct wmfw_alg_hdr {
108 	__be32 id;
109 	__be32 ver;
110 } __packed;
111 
112 struct wmfw_adsp1_alg_hdr {
113 	struct wmfw_alg_hdr alg;
114 	__be32 zm;
115 	__be32 dm;
116 } __packed;
117 
118 struct wmfw_adsp2_alg_hdr {
119 	struct wmfw_alg_hdr alg;
120 	__be32 zm;
121 	__be32 xm;
122 	__be32 ym;
123 } __packed;
124 
125 struct wmfw_halo_alg_hdr {
126 	struct wmfw_alg_hdr alg;
127 	__be32 xm_base;
128 	__be32 xm_size;
129 	__be32 ym_base;
130 	__be32 ym_size;
131 } __packed;
132 
133 struct wmfw_adsp_alg_data {
134 	__le32 id;
135 	u8 name[WMFW_MAX_ALG_NAME];
136 	u8 descr[WMFW_MAX_ALG_DESCR_NAME];
137 	__le32 ncoeff;
138 	u8 data[];
139 } __packed;
140 
141 struct wmfw_adsp_coeff_data {
142 	struct {
143 		__le16 offset;
144 		__le16 type;
145 		__le32 size;
146 	} hdr;
147 	u8 name[WMFW_MAX_COEFF_NAME];
148 	u8 descr[WMFW_MAX_COEFF_DESCR_NAME];
149 	__le16 ctl_type;
150 	__le16 flags;
151 	__le32 len;
152 	u8 data[];
153 } __packed;
154 
155 struct wmfw_coeff_hdr {
156 	u8 magic[4];
157 	__le32 len;
158 	union {
159 		__be32 rev;
160 		__le32 ver;
161 	};
162 	union {
163 		__be32 core;
164 		__le32 core_ver;
165 	};
166 	u8 data[];
167 } __packed;
168 
169 struct wmfw_coeff_item {
170 	__le16 offset;
171 	__le16 type;
172 	__le32 id;
173 	__le32 ver;
174 	__le32 sr;
175 	__le32 len;
176 	u8 data[];
177 } __packed;
178 
179 #define WMFW_ADSP1 1
180 #define WMFW_ADSP2 2
181 #define WMFW_HALO 4
182 
183 #define WMFW_ABSOLUTE         0xf0
184 #define WMFW_ALGORITHM_DATA   0xf2
185 #define WMFW_METADATA         0xfc
186 #define WMFW_NAME_TEXT        0xfe
187 #define WMFW_INFO_TEXT        0xff
188 
189 #define WMFW_ADSP1_PM 2
190 #define WMFW_ADSP1_DM 3
191 #define WMFW_ADSP1_ZM 4
192 
193 #define WMFW_ADSP2_PM 2
194 #define WMFW_ADSP2_ZM 4
195 #define WMFW_ADSP2_XM 5
196 #define WMFW_ADSP2_YM 6
197 
198 #define WMFW_HALO_PM_PACKED 0x10
199 #define WMFW_HALO_XM_PACKED 0x11
200 #define WMFW_HALO_YM_PACKED 0x12
201 
202 #endif
203