blob: 5a78dba1dcb58bcdccdc7693a3eec43beaba44b6 [file] [log] [blame]
Adam Thomsonef5c2eb2013-02-14 12:02:51 +00001/*
2 * da7213.h - DA7213 ASoC Codec Driver
3 *
4 * Copyright (c) 2013 Dialog Semiconductor
5 *
6 * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _DA7213_H
14#define _DA7213_H
15
Adam Thomson6e7c4442015-10-07 14:27:11 +010016#include <linux/clk.h>
Adam Thomsonef5c2eb2013-02-14 12:02:51 +000017#include <linux/regmap.h>
18#include <sound/da7213.h>
19
20/*
21 * Registers
22 */
23
24/* Status Registers */
25#define DA7213_STATUS1 0x02
26#define DA7213_PLL_STATUS 0x03
27#define DA7213_AUX_L_GAIN_STATUS 0x04
28#define DA7213_AUX_R_GAIN_STATUS 0x05
29#define DA7213_MIC_1_GAIN_STATUS 0x06
30#define DA7213_MIC_2_GAIN_STATUS 0x07
31#define DA7213_MIXIN_L_GAIN_STATUS 0x08
32#define DA7213_MIXIN_R_GAIN_STATUS 0x09
33#define DA7213_ADC_L_GAIN_STATUS 0x0A
34#define DA7213_ADC_R_GAIN_STATUS 0x0B
35#define DA7213_DAC_L_GAIN_STATUS 0x0C
36#define DA7213_DAC_R_GAIN_STATUS 0x0D
37#define DA7213_HP_L_GAIN_STATUS 0x0E
38#define DA7213_HP_R_GAIN_STATUS 0x0F
39#define DA7213_LINE_GAIN_STATUS 0x10
40
41/* System Initialisation Registers */
42#define DA7213_DIG_ROUTING_DAI 0x21
43#define DA7213_SR 0x22
44#define DA7213_REFERENCES 0x23
45#define DA7213_PLL_FRAC_TOP 0x24
46#define DA7213_PLL_FRAC_BOT 0x25
47#define DA7213_PLL_INTEGER 0x26
48#define DA7213_PLL_CTRL 0x27
49#define DA7213_DAI_CLK_MODE 0x28
50#define DA7213_DAI_CTRL 0x29
51#define DA7213_DIG_ROUTING_DAC 0x2A
52#define DA7213_ALC_CTRL1 0x2B
53
54/* Input - Gain, Select and Filter Registers */
55#define DA7213_AUX_L_GAIN 0x30
56#define DA7213_AUX_R_GAIN 0x31
57#define DA7213_MIXIN_L_SELECT 0x32
58#define DA7213_MIXIN_R_SELECT 0x33
59#define DA7213_MIXIN_L_GAIN 0x34
60#define DA7213_MIXIN_R_GAIN 0x35
61#define DA7213_ADC_L_GAIN 0x36
62#define DA7213_ADC_R_GAIN 0x37
63#define DA7213_ADC_FILTERS1 0x38
64#define DA7213_MIC_1_GAIN 0x39
65#define DA7213_MIC_2_GAIN 0x3A
66
67/* Output - Gain, Select and Filter Registers */
68#define DA7213_DAC_FILTERS5 0x40
69#define DA7213_DAC_FILTERS2 0x41
70#define DA7213_DAC_FILTERS3 0x42
71#define DA7213_DAC_FILTERS4 0x43
72#define DA7213_DAC_FILTERS1 0x44
73#define DA7213_DAC_L_GAIN 0x45
74#define DA7213_DAC_R_GAIN 0x46
75#define DA7213_CP_CTRL 0x47
76#define DA7213_HP_L_GAIN 0x48
77#define DA7213_HP_R_GAIN 0x49
78#define DA7213_LINE_GAIN 0x4A
79#define DA7213_MIXOUT_L_SELECT 0x4B
80#define DA7213_MIXOUT_R_SELECT 0x4C
81
82/* System Controller Registers */
83#define DA7213_SYSTEM_MODES_INPUT 0x50
84#define DA7213_SYSTEM_MODES_OUTPUT 0x51
85
86/* Control Registers */
87#define DA7213_AUX_L_CTRL 0x60
88#define DA7213_AUX_R_CTRL 0x61
89#define DA7213_MICBIAS_CTRL 0x62
90#define DA7213_MIC_1_CTRL 0x63
91#define DA7213_MIC_2_CTRL 0x64
92#define DA7213_MIXIN_L_CTRL 0x65
93#define DA7213_MIXIN_R_CTRL 0x66
94#define DA7213_ADC_L_CTRL 0x67
95#define DA7213_ADC_R_CTRL 0x68
96#define DA7213_DAC_L_CTRL 0x69
97#define DA7213_DAC_R_CTRL 0x6A
98#define DA7213_HP_L_CTRL 0x6B
99#define DA7213_HP_R_CTRL 0x6C
100#define DA7213_LINE_CTRL 0x6D
101#define DA7213_MIXOUT_L_CTRL 0x6E
102#define DA7213_MIXOUT_R_CTRL 0x6F
103
104/* Configuration Registers */
105#define DA7213_LDO_CTRL 0x90
106#define DA7213_IO_CTRL 0x91
107#define DA7213_GAIN_RAMP_CTRL 0x92
108#define DA7213_MIC_CONFIG 0x93
109#define DA7213_PC_COUNT 0x94
110#define DA7213_CP_VOL_THRESHOLD1 0x95
111#define DA7213_CP_DELAY 0x96
112#define DA7213_CP_DETECTOR 0x97
113#define DA7213_DAI_OFFSET 0x98
114#define DA7213_DIG_CTRL 0x99
115#define DA7213_ALC_CTRL2 0x9A
116#define DA7213_ALC_CTRL3 0x9B
117#define DA7213_ALC_NOISE 0x9C
118#define DA7213_ALC_TARGET_MIN 0x9D
119#define DA7213_ALC_TARGET_MAX 0x9E
120#define DA7213_ALC_GAIN_LIMITS 0x9F
121#define DA7213_ALC_ANA_GAIN_LIMITS 0xA0
122#define DA7213_ALC_ANTICLIP_CTRL 0xA1
123#define DA7213_ALC_ANTICLIP_LEVEL 0xA2
124
125#define DA7213_ALC_OFFSET_AUTO_M_L 0xA3
126#define DA7213_ALC_OFFSET_AUTO_U_L 0xA4
127#define DA7213_ALC_OFFSET_MAN_M_L 0xA6
128#define DA7213_ALC_OFFSET_MAN_U_L 0xA7
129#define DA7213_ALC_OFFSET_AUTO_M_R 0xA8
130#define DA7213_ALC_OFFSET_AUTO_U_R 0xA9
131#define DA7213_ALC_OFFSET_MAN_M_R 0xAB
132#define DA7213_ALC_OFFSET_MAN_U_R 0xAC
133#define DA7213_ALC_CIC_OP_LVL_CTRL 0xAD
134#define DA7213_ALC_CIC_OP_LVL_DATA 0xAE
135#define DA7213_DAC_NG_SETUP_TIME 0xAF
136#define DA7213_DAC_NG_OFF_THRESHOLD 0xB0
137#define DA7213_DAC_NG_ON_THRESHOLD 0xB1
138#define DA7213_DAC_NG_CTRL 0xB2
139
140
141/*
142 * Bit fields
143 */
144
Adam Thomsond575b0b2016-05-10 16:11:05 +0100145/* DA7213_PLL_STATUS = 0x03 */
146#define DA7219_PLL_SRM_LOCK (0x1 << 1)
147
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000148/* DA7213_SR = 0x22 */
149#define DA7213_SR_8000 (0x1 << 0)
150#define DA7213_SR_11025 (0x2 << 0)
151#define DA7213_SR_12000 (0x3 << 0)
152#define DA7213_SR_16000 (0x5 << 0)
153#define DA7213_SR_22050 (0x6 << 0)
154#define DA7213_SR_24000 (0x7 << 0)
155#define DA7213_SR_32000 (0x9 << 0)
156#define DA7213_SR_44100 (0xA << 0)
157#define DA7213_SR_48000 (0xB << 0)
158#define DA7213_SR_88200 (0xE << 0)
159#define DA7213_SR_96000 (0xF << 0)
160
161/* DA7213_REFERENCES = 0x23 */
162#define DA7213_BIAS_EN (0x1 << 3)
163#define DA7213_VMID_EN (0x1 << 7)
164
165/* DA7213_PLL_CTRL = 0x27 */
Adam Thomson1e62c522016-05-10 16:11:07 +0100166#define DA7213_PLL_INDIV_5_TO_9_MHZ (0x0 << 2)
167#define DA7213_PLL_INDIV_9_TO_18_MHZ (0x1 << 2)
168#define DA7213_PLL_INDIV_18_TO_36_MHZ (0x2 << 2)
169#define DA7213_PLL_INDIV_36_TO_54_MHZ (0x3 << 2)
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000170#define DA7213_PLL_INDIV_MASK (0x3 << 2)
171#define DA7213_PLL_MCLK_SQR_EN (0x1 << 4)
172#define DA7213_PLL_32K_MODE (0x1 << 5)
173#define DA7213_PLL_SRM_EN (0x1 << 6)
174#define DA7213_PLL_EN (0x1 << 7)
Adam Thomson4c752252016-08-04 15:35:40 +0100175#define DA7213_PLL_MODE_MASK (0x7 << 5)
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000176
177/* DA7213_DAI_CLK_MODE = 0x28 */
178#define DA7213_DAI_BCLKS_PER_WCLK_32 (0x0 << 0)
179#define DA7213_DAI_BCLKS_PER_WCLK_64 (0x1 << 0)
180#define DA7213_DAI_BCLKS_PER_WCLK_128 (0x2 << 0)
181#define DA7213_DAI_BCLKS_PER_WCLK_256 (0x3 << 0)
182#define DA7213_DAI_BCLKS_PER_WCLK_MASK (0x3 << 0)
183#define DA7213_DAI_CLK_POL_INV (0x1 << 2)
184#define DA7213_DAI_WCLK_POL_INV (0x1 << 3)
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000185#define DA7213_DAI_CLK_EN_MASK (0x1 << 7)
186
187/* DA7213_DAI_CTRL = 0x29 */
188#define DA7213_DAI_FORMAT_I2S_MODE (0x0 << 0)
189#define DA7213_DAI_FORMAT_LEFT_J (0x1 << 0)
190#define DA7213_DAI_FORMAT_RIGHT_J (0x2 << 0)
Pierre-Louis Bossarte0d746c2017-11-08 16:42:31 -0600191#define DA7213_DAI_FORMAT_DSP (0x3 << 0)
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000192#define DA7213_DAI_FORMAT_MASK (0x3 << 0)
193#define DA7213_DAI_WORD_LENGTH_S16_LE (0x0 << 2)
194#define DA7213_DAI_WORD_LENGTH_S20_LE (0x1 << 2)
195#define DA7213_DAI_WORD_LENGTH_S24_LE (0x2 << 2)
196#define DA7213_DAI_WORD_LENGTH_S32_LE (0x3 << 2)
197#define DA7213_DAI_WORD_LENGTH_MASK (0x3 << 2)
198#define DA7213_DAI_EN_SHIFT 7
199
200/* DA7213_DIG_ROUTING_DAI = 0x21 */
201#define DA7213_DAI_L_SRC_SHIFT 0
202#define DA7213_DAI_R_SRC_SHIFT 4
203#define DA7213_DAI_SRC_MAX 4
204
205/* DA7213_DIG_ROUTING_DAC = 0x2A */
206#define DA7213_DAC_L_SRC_SHIFT 0
207#define DA7213_DAC_L_MONO_SHIFT 3
208#define DA7213_DAC_R_SRC_SHIFT 4
209#define DA7213_DAC_R_MONO_SHIFT 7
210#define DA7213_DAC_SRC_MAX 4
211#define DA7213_DAC_MONO_MAX 0x1
212
213/* DA7213_ALC_CTRL1 = 0x2B */
214#define DA7213_ALC_OFFSET_EN_SHIFT 0
215#define DA7213_ALC_OFFSET_EN_MAX 0x1
216#define DA7213_ALC_OFFSET_EN (0x1 << 0)
217#define DA7213_ALC_SYNC_MODE (0x1 << 1)
218#define DA7213_ALC_CALIB_MODE_MAN (0x1 << 2)
219#define DA7213_ALC_L_EN_SHIFT 3
220#define DA7213_ALC_AUTO_CALIB_EN (0x1 << 4)
221#define DA7213_ALC_CALIB_OVERFLOW (0x1 << 5)
222#define DA7213_ALC_R_EN_SHIFT 7
223#define DA7213_ALC_EN_MAX 0x1
224
225/* DA7213_AUX_L/R_GAIN = 0x30/0x31 */
226#define DA7213_AUX_AMP_GAIN_SHIFT 0
227#define DA7213_AUX_AMP_GAIN_MAX 0x3F
228
229/* DA7213_MIXIN_L/R_SELECT = 0x32/0x33 */
230#define DA7213_DMIC_EN_SHIFT 7
231#define DA7213_DMIC_EN_MAX 0x1
232
233/* DA7213_MIXIN_L_SELECT = 0x32 */
234#define DA7213_MIXIN_L_MIX_SELECT_AUX_L_SHIFT 0
235#define DA7213_MIXIN_L_MIX_SELECT_MIC_1_SHIFT 1
236#define DA7213_MIXIN_L_MIX_SELECT_MIC_1 (0x1 << 1)
237#define DA7213_MIXIN_L_MIX_SELECT_MIC_2_SHIFT 2
238#define DA7213_MIXIN_L_MIX_SELECT_MIC_2 (0x1 << 2)
239#define DA7213_MIXIN_L_MIX_SELECT_MIXIN_R_SHIFT 3
240#define DA7213_MIXIN_L_MIX_SELECT_MAX 0x1
241
242/* DA7213_MIXIN_R_SELECT = 0x33 */
243#define DA7213_MIXIN_R_MIX_SELECT_AUX_R_SHIFT 0
244#define DA7213_MIXIN_R_MIX_SELECT_MIC_2_SHIFT 1
245#define DA7213_MIXIN_R_MIX_SELECT_MIC_2 (0x1 << 1)
246#define DA7213_MIXIN_R_MIX_SELECT_MIC_1_SHIFT 2
247#define DA7213_MIXIN_R_MIX_SELECT_MIC_1 (0x1 << 2)
248#define DA7213_MIXIN_R_MIX_SELECT_MIXIN_L_SHIFT 3
249#define DA7213_MIXIN_R_MIX_SELECT_MAX 0x1
250#define DA7213_MIC_BIAS_OUTPUT_SELECT_2 (0x1 << 6)
251
252/* DA7213_MIXIN_L/R_GAIN = 0x34/0x35 */
253#define DA7213_MIXIN_AMP_GAIN_SHIFT 0
254#define DA7213_MIXIN_AMP_GAIN_MAX 0xF
255
256/* DA7213_ADC_L/R_GAIN = 0x36/0x37 */
257#define DA7213_ADC_AMP_GAIN_SHIFT 0
258#define DA7213_ADC_AMP_GAIN_MAX 0x7F
259
260/* DA7213_ADC/DAC_FILTERS1 = 0x38/0x44 */
261#define DA7213_VOICE_HPF_CORNER_SHIFT 0
262#define DA7213_VOICE_HPF_CORNER_MAX 8
263#define DA7213_VOICE_EN_SHIFT 3
264#define DA7213_VOICE_EN_MAX 0x1
265#define DA7213_AUDIO_HPF_CORNER_SHIFT 4
266#define DA7213_AUDIO_HPF_CORNER_MAX 4
267#define DA7213_HPF_EN_SHIFT 7
268#define DA7213_HPF_EN_MAX 0x1
269
270/* DA7213_MIC_1/2_GAIN = 0x39/0x3A */
271#define DA7213_MIC_AMP_GAIN_SHIFT 0
272#define DA7213_MIC_AMP_GAIN_MAX 0x7
273
274/* DA7213_DAC_FILTERS5 = 0x40 */
275#define DA7213_DAC_SOFTMUTE_EN_SHIFT 7
276#define DA7213_DAC_SOFTMUTE_EN_MAX 0x1
277#define DA7213_DAC_SOFTMUTE_RATE_SHIFT 4
278#define DA7213_DAC_SOFTMUTE_RATE_MAX 7
279
280/* DA7213_DAC_FILTERS2/3/4 = 0x41/0x42/0x43 */
281#define DA7213_DAC_EQ_BAND_MAX 0xF
282
283/* DA7213_DAC_FILTERS2 = 0x41 */
284#define DA7213_DAC_EQ_BAND1_SHIFT 0
285#define DA7213_DAC_EQ_BAND2_SHIFT 4
286
287/* DA7213_DAC_FILTERS2 = 0x42 */
288#define DA7213_DAC_EQ_BAND3_SHIFT 0
289#define DA7213_DAC_EQ_BAND4_SHIFT 4
290
291/* DA7213_DAC_FILTERS4 = 0x43 */
292#define DA7213_DAC_EQ_BAND5_SHIFT 0
293#define DA7213_DAC_EQ_EN_SHIFT 7
294#define DA7213_DAC_EQ_EN_MAX 0x1
295
296/* DA7213_DAC_L/R_GAIN = 0x45/0x46 */
297#define DA7213_DAC_AMP_GAIN_SHIFT 0
298#define DA7213_DAC_AMP_GAIN_MAX 0x7F
299
300/* DA7213_HP_L/R_GAIN = 0x45/0x46 */
301#define DA7213_HP_AMP_GAIN_SHIFT 0
302#define DA7213_HP_AMP_GAIN_MAX 0x3F
303
304/* DA7213_CP_CTRL = 0x47 */
305#define DA7213_CP_EN_SHIFT 7
306
307/* DA7213_LINE_GAIN = 0x4A */
308#define DA7213_LINE_AMP_GAIN_SHIFT 0
309#define DA7213_LINE_AMP_GAIN_MAX 0x3F
310
311/* DA7213_MIXOUT_L_SELECT = 0x4B */
312#define DA7213_MIXOUT_L_MIX_SELECT_AUX_L_SHIFT 0
313#define DA7213_MIXOUT_L_MIX_SELECT_MIXIN_L_SHIFT 1
314#define DA7213_MIXOUT_L_MIX_SELECT_MIXIN_R_SHIFT 2
315#define DA7213_MIXOUT_L_MIX_SELECT_DAC_L_SHIFT 3
316#define DA7213_MIXOUT_L_MIX_SELECT_AUX_L_INVERTED_SHIFT 4
317#define DA7213_MIXOUT_L_MIX_SELECT_MIXIN_L_INVERTED_SHIFT 5
318#define DA7213_MIXOUT_L_MIX_SELECT_MIXIN_R_INVERTED_SHIFT 6
319#define DA7213_MIXOUT_L_MIX_SELECT_MAX 0x1
320
321/* DA7213_MIXOUT_R_SELECT = 0x4C */
322#define DA7213_MIXOUT_R_MIX_SELECT_AUX_R_SHIFT 0
323#define DA7213_MIXOUT_R_MIX_SELECT_MIXIN_R_SHIFT 1
324#define DA7213_MIXOUT_R_MIX_SELECT_MIXIN_L_SHIFT 2
325#define DA7213_MIXOUT_R_MIX_SELECT_DAC_R_SHIFT 3
326#define DA7213_MIXOUT_R_MIX_SELECT_AUX_R_INVERTED_SHIFT 4
327#define DA7213_MIXOUT_R_MIX_SELECT_MIXIN_R_INVERTED_SHIFT 5
328#define DA7213_MIXOUT_R_MIX_SELECT_MIXIN_L_INVERTED_SHIFT 6
329#define DA7213_MIXOUT_R_MIX_SELECT_MAX 0x1
330
331/*
332 * DA7213_AUX_L/R_CTRL = 0x60/0x61,
333 * DA7213_MIC_1/2_CTRL = 0x63/0x64,
334 * DA7213_MIXIN_L/R_CTRL = 0x65/0x66,
335 * DA7213_ADC_L/R_CTRL = 0x65/0x66,
336 * DA7213_DAC_L/R_CTRL = 0x69/0x6A,
337 * DA7213_HP_L/R_CTRL = 0x6B/0x6C,
338 * DA7213_LINE_CTRL = 0x6D
339 */
340#define DA7213_MUTE_EN_SHIFT 6
341#define DA7213_MUTE_EN_MAX 0x1
342#define DA7213_MUTE_EN (0x1 << 6)
343
344/*
345 * DA7213_AUX_L/R_CTRL = 0x60/0x61,
346 * DA7213_MIXIN_L/R_CTRL = 0x65/0x66,
347 * DA7213_ADC_L/R_CTRL = 0x65/0x66,
348 * DA7213_DAC_L/R_CTRL = 0x69/0x6A,
349 * DA7213_HP_L/R_CTRL = 0x6B/0x6C,
350 * DA7213_LINE_CTRL = 0x6D
351 */
352#define DA7213_GAIN_RAMP_EN_SHIFT 5
353#define DA7213_GAIN_RAMP_EN_MAX 0x1
354#define DA7213_GAIN_RAMP_EN (0x1 << 5)
355
356/*
357 * DA7213_AUX_L/R_CTRL = 0x60/0x61,
358 * DA7213_MIXIN_L/R_CTRL = 0x65/0x66,
359 * DA7213_HP_L/R_CTRL = 0x6B/0x6C,
360 * DA7213_LINE_CTRL = 0x6D
361 */
362#define DA7213_ZC_EN_SHIFT 4
363#define DA7213_ZC_EN_MAX 0x1
364
365/*
366 * DA7213_AUX_L/R_CTRL = 0x60/0x61,
367 * DA7213_MIC_1/2_CTRL = 0x63/0x64,
368 * DA7213_MIXIN_L/R_CTRL = 0x65/0x66,
369 * DA7213_HP_L/R_CTRL = 0x6B/0x6C,
370 * DA7213_MIXOUT_L/R_CTRL = 0x6E/0x6F,
371 * DA7213_LINE_CTRL = 0x6D
372 */
373#define DA7213_AMP_EN_SHIFT 7
374
375/* DA7213_MIC_1/2_CTRL = 0x63/0x64 */
376#define DA7213_MIC_AMP_IN_SEL_SHIFT 2
377#define DA7213_MIC_AMP_IN_SEL_MAX 3
378
379/* DA7213_MICBIAS_CTRL = 0x62 */
380#define DA7213_MICBIAS1_LEVEL_SHIFT 0
381#define DA7213_MICBIAS1_LEVEL_MASK (0x3 << 0)
382#define DA7213_MICBIAS1_EN_SHIFT 3
383#define DA7213_MICBIAS2_LEVEL_SHIFT 4
384#define DA7213_MICBIAS2_LEVEL_MASK (0x3 << 4)
385#define DA7213_MICBIAS2_EN_SHIFT 7
386
387/* DA7213_MIXIN_L/R_CTRL = 0x65/0x66 */
388#define DA7213_MIXIN_MIX_EN (0x1 << 3)
389
390/* DA7213_ADC_L/R_CTRL = 0x67/0x68 */
391#define DA7213_ADC_EN_SHIFT 7
392#define DA7213_ADC_EN (0x1 << 7)
393
394/* DA7213_DAC_L/R_CTRL = 0x69/0x6A*/
395#define DA7213_DAC_EN_SHIFT 7
396
397/* DA7213_HP_L/R_CTRL = 0x6B/0x6C */
398#define DA7213_HP_AMP_OE (0x1 << 3)
399
400/* DA7213_LINE_CTRL = 0x6D */
401#define DA7213_LINE_AMP_OE (0x1 << 3)
402
403/* DA7213_MIXOUT_L/R_CTRL = 0x6E/0x6F */
404#define DA7213_MIXOUT_MIX_EN (0x1 << 3)
405
406/* DA7213_GAIN_RAMP_CTRL = 0x92 */
407#define DA7213_GAIN_RAMP_RATE_SHIFT 0
408#define DA7213_GAIN_RAMP_RATE_MAX 4
409
410/* DA7213_MIC_CONFIG = 0x93 */
411#define DA7213_DMIC_DATA_SEL_SHIFT 0
412#define DA7213_DMIC_DATA_SEL_MASK (0x1 << 0)
413#define DA7213_DMIC_SAMPLEPHASE_SHIFT 1
414#define DA7213_DMIC_SAMPLEPHASE_MASK (0x1 << 1)
415#define DA7213_DMIC_CLK_RATE_SHIFT 2
416#define DA7213_DMIC_CLK_RATE_MASK (0x1 << 2)
417
Adam Thomson7e28fd42016-05-10 16:11:06 +0100418/* DA7213_PC_COUNT = 0x94 */
419#define DA7213_PC_FREERUN_MASK (0x1 << 0)
420
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000421/* DA7213_DIG_CTRL = 0x99 */
422#define DA7213_DAC_L_INV_SHIFT 3
423#define DA7213_DAC_R_INV_SHIFT 7
424#define DA7213_DAC_INV_MAX 0x1
425
426/* DA7213_ALC_CTRL2 = 0x9A */
427#define DA7213_ALC_ATTACK_SHIFT 0
428#define DA7213_ALC_ATTACK_MAX 13
429#define DA7213_ALC_RELEASE_SHIFT 4
430#define DA7213_ALC_RELEASE_MAX 11
431
432/* DA7213_ALC_CTRL3 = 0x9B */
433#define DA7213_ALC_HOLD_SHIFT 0
434#define DA7213_ALC_HOLD_MAX 16
435#define DA7213_ALC_INTEG_ATTACK_SHIFT 4
436#define DA7213_ALC_INTEG_RELEASE_SHIFT 6
437#define DA7213_ALC_INTEG_MAX 4
438
439/*
440 * DA7213_ALC_NOISE = 0x9C,
441 * DA7213_ALC_TARGET_MIN/MAX = 0x9D/0x9E
442 */
443#define DA7213_ALC_THRESHOLD_SHIFT 0
444#define DA7213_ALC_THRESHOLD_MAX 0x3F
445
446/* DA7213_ALC_GAIN_LIMITS = 0x9F */
447#define DA7213_ALC_ATTEN_MAX_SHIFT 0
448#define DA7213_ALC_GAIN_MAX_SHIFT 4
449#define DA7213_ALC_ATTEN_GAIN_MAX_MAX 0xF
450
451/* DA7213_ALC_ANA_GAIN_LIMITS = 0xA0 */
452#define DA7213_ALC_ANA_GAIN_MIN_SHIFT 0
453#define DA7213_ALC_ANA_GAIN_MAX_SHIFT 4
454#define DA7213_ALC_ANA_GAIN_MAX 0x7
455
456/* DA7213_ALC_ANTICLIP_CTRL = 0xA1 */
457#define DA7213_ALC_ANTICLIP_EN_SHIFT 7
458#define DA7213_ALC_ANTICLIP_EN_MAX 0x1
459
460/* DA7213_ALC_ANTICLIP_LEVEL = 0xA2 */
461#define DA7213_ALC_ANTICLIP_LEVEL_SHIFT 0
462#define DA7213_ALC_ANTICLIP_LEVEL_MAX 0x7F
463
464/* DA7213_ALC_CIC_OP_LVL_CTRL = 0xAD */
465#define DA7213_ALC_DATA_MIDDLE (0x2 << 0)
466#define DA7213_ALC_DATA_TOP (0x3 << 0)
467#define DA7213_ALC_CIC_OP_CHANNEL_LEFT (0x0 << 7)
468#define DA7213_ALC_CIC_OP_CHANNEL_RIGHT (0x1 << 7)
469
470/* DA7213_DAC_NG_SETUP_TIME = 0xAF */
471#define DA7213_DAC_NG_SETUP_TIME_SHIFT 0
472#define DA7213_DAC_NG_SETUP_TIME_MAX 4
473#define DA7213_DAC_NG_RAMPUP_RATE_SHIFT 2
474#define DA7213_DAC_NG_RAMPDN_RATE_SHIFT 3
475#define DA7213_DAC_NG_RAMP_RATE_MAX 2
476
477/* DA7213_DAC_NG_OFF/ON_THRESH = 0xB0/0xB1 */
478#define DA7213_DAC_NG_THRESHOLD_SHIFT 0
479#define DA7213_DAC_NG_THRESHOLD_MAX 0x7
480
481/* DA7213_DAC_NG_CTRL = 0xB2 */
482#define DA7213_DAC_NG_EN_SHIFT 7
483#define DA7213_DAC_NG_EN_MAX 0x1
484
485
486/*
487 * General defines
488 */
489
490/* Register inversion */
491#define DA7213_NO_INVERT 0
492#define DA7213_INVERT 1
493
494/* Byte related defines */
495#define DA7213_BYTE_SHIFT 8
496#define DA7213_BYTE_MASK 0xFF
497
498/* ALC related */
499#define DA7213_ALC_OFFSET_15_8 0x00FF00
500#define DA7213_ALC_OFFSET_19_16 0x0F0000
501#define DA7213_ALC_AVG_ITERATIONS 5
502
503/* PLL related */
Adam Thomson1e62c522016-05-10 16:11:07 +0100504#define DA7213_PLL_FREQ_OUT_90316800 90316800
505#define DA7213_PLL_FREQ_OUT_98304000 98304000
506#define DA7213_PLL_FREQ_OUT_94310400 94310400
507#define DA7213_PLL_INDIV_5_TO_9_MHZ_VAL 2
508#define DA7213_PLL_INDIV_9_TO_18_MHZ_VAL 4
509#define DA7213_PLL_INDIV_18_TO_36_MHZ_VAL 8
510#define DA7213_PLL_INDIV_36_TO_54_MHZ_VAL 16
511#define DA7213_SRM_CHECK_RETRIES 8
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000512
Adam Thomson6e7c4442015-10-07 14:27:11 +0100513enum da7213_clk_src {
514 DA7213_CLKSRC_MCLK = 0,
515 DA7213_CLKSRC_MCLK_SQR,
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000516};
517
Adam Thomson4c752252016-08-04 15:35:40 +0100518enum da7213_sys_clk {
519 DA7213_SYSCLK_MCLK = 0,
520 DA7213_SYSCLK_PLL,
521 DA7213_SYSCLK_PLL_SRM,
522 DA7213_SYSCLK_PLL_32KHZ
523};
524
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000525/* Codec private data */
526struct da7213_priv {
527 struct regmap *regmap;
Adam Thomson6e7c4442015-10-07 14:27:11 +0100528 struct clk *mclk;
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000529 unsigned int mclk_rate;
Adam Thomson6e7c4442015-10-07 14:27:11 +0100530 int clk_src;
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000531 bool master;
Adam Thomsonef5c2eb2013-02-14 12:02:51 +0000532 bool alc_calib_auto;
533 bool alc_en;
534 struct da7213_platform_data *pdata;
535};
536
537#endif /* _DA7213_H */