summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/aic3xxx_cfw.h
blob: 12bc855751954d45b8bdf1c02106adef2cf483b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/**
 * \file Codec Firmware Declarations
 */

#ifndef CFW_FIRMWARE_H_
#define CFW_FIRMWARE_H_
/** \defgroup bt Basic Types */
/* @{ */
#ifndef AIC3XXX_CFW_HOST_BLD
#include <asm-generic/int-ll64.h>
#else
typedef unsigned char u8;
typedef unsigned short int u16;
typedef unsigned long  int u32;
#endif

#define CFW_FW_MAGIC 0xC0D1F1ED

/** defgroup pd Arbitrary Limitations */

#ifndef CFW_MAX_ID
#define CFW_MAX_ID	  (64)    /* Max length of string identifies */
#endif

#ifndef CFW_MAX_DESC
#define  CFW_MAX_DESC	(512)   /* Max length of description */
#endif
/* <Max number of overlays per PFW */
#ifndef CFW_MAX_NOVLY
#define CFW_MAX_NOVLY		(4)
#endif

#ifndef CFW_MAX_NCFG
#define CFW_MAX_NCFG	(16)    /* Max number of configurations per PFW */
#endif

#ifndef CFW_MAX_TRANSITIONS
#define CFW_MAX_TRANSITIONS (32)    /* max number of pre-defined transition */
#endif

#ifndef CFW_MAX_NPFW
#define CFW_MAX_NPFW	(16)    /* Max number fo process flows */
#endif

#ifndef CFW_MAX_MODES
#define CFW_MAX_MODES       (32)    /* Max number of modes */
#endif

#ifndef CFW_MAX_ASI
#define CFW_MAX_ASI	 (4)     /* Max number ASIs in a single device */
#endif


#ifndef CFW_MAX_CTRL
#define CFW_MAX_CTRL	(16)    /* Max number of control per pfw */
#endif

/** defgroup st Enums, Flags, Macros and Supporting Types */

/**
 * Sample rate bitmask
 *
 */
enum cfw_fs {
	CFW_FS_8KHZ     = 0x0001u,
	CFW_FS_11KHZ    = 0x0002u,
	CFW_FS_16KHZ    = 0x0004u,
	CFW_FS_22KHZ    = 0x0008u,
	CFW_FS_24KHZ    = 0x0010u,
	CFW_FS_32KHZ    = 0x0020u,
	CFW_FS_44KHZ    = 0x0040u,
	CFW_FS_48KHZ    = 0x0080u,
	CFW_FS_88KHZ    = 0x0100u,
	CFW_FS_96KHZ    = 0x0200u,
	CFW_FS_176KHZ   = 0x0400u,
	CFW_FS_192KHZ   = 0x0800u,
	CFW_FS_ANY      = 0x8000u,
	CFW_FS_ALL      = 0x0FFFu,
};

/**
 * Sample rate index
 *
 */
enum cfw_fsi {
	CFW_FSI_8KHZ,
	CFW_FSI_11KHZ,
	CFW_FSI_16KHZ,
	CFW_FSI_22KHZ,
	CFW_FSI_24KHZ,
	CFW_FSI_32KHZ,
	CFW_FSI_44KHZ,
	CFW_FSI_48KHZ,
	CFW_FSI_88KHZ,
	CFW_FSI_96KHZ,
	CFW_FSI_176KHZ,
	CFW_FSI_192KHZ,
	CFW_FSI_ANY = 15,
};

/**
 * Device Family Identifier
 *
 */
enum __attribute__ ((__packed__)) cfw_dfamily {
	CFW_DFM_TYPE_A,
	CFW_DFM_TYPE_B,
	CFW_DFM_TYPE_C
};

/**
 * Device Identifier
 *
 */
enum __attribute__ ((__packed__)) cfw_device {
	CFW_DEV_DAC3120,
	CFW_DEV_DAC3100,

	CFW_DEV_AIC3120,
	CFW_DEV_AIC3100,
	CFW_DEV_AIC3110,
	CFW_DEV_AIC3111,

	CFW_DEV_AIC36,

	CFW_DEV_AIC3206,
	CFW_DEV_AIC3204,
	CFW_DEV_AIC3254,
	CFW_DEV_AIC3256,
	CFW_DEV_AIC3253,

	CFW_DEV_AIC3212,
	CFW_DEV_AIC3262,
	CFW_DEV_AIC3017,
	CFW_DEV_AIC3008,

};

/**
 * Transition Sequence Identifier
 *
 */
enum cfw_transition_t {
	CFW_TRN_INIT,
	CFW_TRN_RESUME,
	CFW_TRN_NEUTRAL,
	CFW_TRN_A_MUTE,
	CFW_TRN_D_MUTE,
	CFW_TRN_AD_MUTE,
	CFW_TRN_A_UNMUTE,
	CFW_TRN_D_UNMUTE,
	CFW_TRN_AD_UNMUTE,
	CFW_TRN_SUSPEND,
	CFW_TRN_EXIT,
	CFW_TRN_N
};

static const char * const cfw_transition_id[] = {
	[CFW_TRN_INIT] "INIT",
	[CFW_TRN_RESUME] "RESUME",
	[CFW_TRN_NEUTRAL] "NEUTRAL",
	[CFW_TRN_A_MUTE] "A_MUTE",
	[CFW_TRN_D_MUTE] "D_MUTE",
	[CFW_TRN_AD_MUTE] "AD_MUTE",
	[CFW_TRN_A_UNMUTE] "A_UNMUTE",
	[CFW_TRN_D_UNMUTE] "D_UNMUTE",
	[CFW_TRN_AD_UNMUTE] "AD_UNMUTE",
	[CFW_TRN_SUSPEND] "SUSPEND",
	[CFW_TRN_EXIT] "EXIT",
};

/** defgroup ds Data Structures */

/**
* CFW Meta Command
* These commands do not appear in the register
* set of the device.
* Mainly delay, wait and set_bits.
*/
enum __attribute__ ((__packed__)) cfw_meta_cmd {
	CFW_META_DELAY = 0x80,
	CFW_META_UPDTBITS,
	CFW_META_WAITBITS,
	CFW_META_LOCK,
};

/**
* CFW Delay
* Used for the meta command delay
* Has one parameter of delay time in ms
*/
struct cfw_meta_delay {
	u16 delay;
	enum cfw_meta_cmd mcmd;
	u8	unused1;
};

/**
* CFW set_bits or wait
* Both these meta commands have same arguments
* mcmd will be used to specify which command it is
* has parameters of book, page, offset and mask
*/
struct cfw_meta_bitop {
	u16 unused1;
	enum cfw_meta_cmd mcmd;
	u8   mask;
};

/**
* CFW meta register
* Contains the data structures for the meta commands
*/
union cfw_meta_register {
	struct {
		u16 unused1;
		enum cfw_meta_cmd mcmd;
		u8 unused2;
	};
	struct cfw_meta_delay delay;
	struct cfw_meta_bitop bitop;
};

/**
 * CFW Register
 *
 * A single reg write
 *
 */
union cfw_register {
	struct {
		u8 book;
		u8 page;
		u8 offset;
		u8 data;
	};
	u32 bpod;
	union cfw_meta_register meta;
};

/**
 * CFW Burst
 *
 * A single I2C/SPI burst write sequence
 *
 */
struct cfw_burst {
	u32 length;
	union {
		union cfw_register reg;
		struct {
			u8 bpo[3];
			u8 data[1];
		};
	};
};

/**
 * CFW Command
 *
 * Can be a either a
 *      -# single register write,
 *      -# a burst write, or
 *      -# meta-command
 *
 */
union cfw_cmd {
	union cfw_register reg;
	struct cfw_burst    *burst;
};

/**
 * CFW Block Type
 *
 * Block identifier
 *
 */
enum __attribute__ ((__packed__)) cfw_block_t {
	CFW_BLOCK_SYSTEM_PRE,
	CFW_BLOCK_A_INST,
	CFW_BLOCK_A_A_COEF,
	CFW_BLOCK_A_B_COEF,
	CFW_BLOCK_A_F_COEF,
	CFW_BLOCK_D_INST,
	CFW_BLOCK_D_A1_COEF,
	CFW_BLOCK_D_B1_COEF,
	CFW_BLOCK_D_A2_COEF,
	CFW_BLOCK_D_B2_COEF,
	CFW_BLOCK_D_F_COEF,
	CFW_BLOCK_SYSTEM_POST,
	CFW_BLOCK_N,
	CFW_BLOCK_INVALID,
	CFW_BLOCK_BURSTS = 0x80
};
#define CFW_BLOCK_BURSTS(x) ((x)&CFW_BLOCK_BURSTS)
#define CFW_BLOCK_TYPE(x) ((x)&(~CFW_BLOCK_BURSTS))
#define CFW_BLOCK_D_A_COEF CFW_BLOCK_D_A1_COEF
#define CFW_BLOCK_D_B_COEF CFW_BLOCK_D_B1_COEF

/**
 * CFW Block
 *
 * A block of logically grouped sequences/commands/meta-commands
 *
 */
struct cfw_block {
	enum cfw_block_t type;
	int ncmds;
	union cfw_cmd cmd[];
};

/**
 * CFW Image
 *
 * A downloadable image
 */
struct cfw_image {
	char name[CFW_MAX_ID];	/* Name of the pfw/overlay/configuration */
	char desc[CFW_MAX_DESC];	/* User string */
	int  mute_flags;
	struct cfw_block *block[CFW_BLOCK_N];
};

struct cfw_control {
	char name[CFW_MAX_ID];  /* Control identifier */
	char desc[CFW_MAX_DESC];/* User string */
	int  mute_flags;

	int  min;	       /* Min value of control (*100) */
	int  max;	       /* Max  value of control (*100) */
	int  step;	      /* Control step size (*100) */

	int  imax;	      /* Max index into controls array */
	int  ireset;	    /* Reset control to defaults */
	int  icur;	      /* Last value set */
	struct cfw_block **output;     /* Array of sequences to send */
};

/**
 * Process flow
 *
 * Complete description of a process flow
 */
struct cfw_pfw {
	char name[CFW_MAX_ID];  /* Name of the process flow */
	char desc[CFW_MAX_DESC];    /* User string */
	u32 version;
	u8  prb_a;
	u8  prb_d;
	int novly;	      /* Number of overlays (1 or more) */
	int ncfg;	       /* Number of configurations (0 or more) */
	int nctrl;	      /* Number of run-time controls */
	struct cfw_block *pll;
	struct cfw_image *base;	/* Base sequence */
	/* Overlay and cfg */
	struct cfw_image *ovly_cfg[CFW_MAX_NOVLY][CFW_MAX_NCFG];
	/* Array of run-time controls */
	struct cfw_control *ctrl[CFW_MAX_CTRL];
};

/**
 * Process transition
 *
 * Sequence for specific state transisitions within the driver
 *
 */
struct cfw_transition {
	char name[CFW_MAX_ID];		/* Name of the transition */
	char desc[CFW_MAX_DESC];	/* User string */
	struct cfw_block *block;
};

/**
 * Device audio mode
 *
 * Structure linking various operating modes to process flows,
 * configurations and sequences
 *
 */
struct cfw_mode {
	char name[CFW_MAX_ID];
	char desc[CFW_MAX_DESC];    /* User string */
	u32 flags;
	u8  pfw;
	u8  ovly;
	u8  cfg;
	struct cfw_block *entry;
	struct cfw_block *exit;
};

struct cfw_asoc_toc_entry {
	char etext[CFW_MAX_ID];
	int mode;
	int cfg;
};

struct cfw_asoc_toc {
	int nentries;
	struct cfw_asoc_toc_entry entry[];
};

/**
 * CFW Project
 *
 * Top level structure describing the CFW project
 */
struct cfw_project {
	u32 magic;
	u32 bmagic;
	u32 size;
	u32 cksum;
	u32 version;
	u32 tstamp;
	char name[CFW_MAX_ID];      /* Project name */
	char desc[CFW_MAX_DESC];    /* User string */
	enum cfw_dfamily dfamily;
	enum cfw_device  device;
	u32  flags;
	struct cfw_transition *transition[CFW_MAX_TRANSITIONS];
	u16  npfw;		   /* Number of process flows */
	u16  nmode;		  /* Number of operating modes */
	struct cfw_pfw *pfw[CFW_MAX_NPFW]; /* Indices to PFW locations */
	struct cfw_mode *mode[CFW_MAX_MODES];
	struct cfw_asoc_toc *asoc_toc;
};

#endif /* CFW_FIRMWARE_H_ */