xref: /linux/sound/soc/codecs/da7213.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2ef5c2ebaSAdam Thomson /*
3ef5c2ebaSAdam Thomson  * da7213.h - DA7213 ASoC Codec Driver
4ef5c2ebaSAdam Thomson  *
5ef5c2ebaSAdam Thomson  * Copyright (c) 2013 Dialog Semiconductor
6ef5c2ebaSAdam Thomson  *
7ef5c2ebaSAdam Thomson  * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
8*64c3259bSDavid Rau  * Author: David Rau <David.Rau.opensource@dm.renesas.com>
9ef5c2ebaSAdam Thomson  */
10ef5c2ebaSAdam Thomson 
11ef5c2ebaSAdam Thomson #ifndef _DA7213_H
12ef5c2ebaSAdam Thomson #define _DA7213_H
13ef5c2ebaSAdam Thomson 
146e7c4443SAdam Thomson #include <linux/clk.h>
15ef5c2ebaSAdam Thomson #include <linux/regmap.h>
16b2a37881SSebastian Reichel #include <linux/regulator/consumer.h>
17ef5c2ebaSAdam Thomson #include <sound/da7213.h>
18ef5c2ebaSAdam Thomson 
19ef5c2ebaSAdam Thomson /*
20ef5c2ebaSAdam Thomson  * Registers
21ef5c2ebaSAdam Thomson  */
22ef5c2ebaSAdam Thomson 
23ef5c2ebaSAdam Thomson /* Status Registers */
24ef5c2ebaSAdam Thomson #define DA7213_STATUS1			0x02
25ef5c2ebaSAdam Thomson #define DA7213_PLL_STATUS		0x03
26ef5c2ebaSAdam Thomson #define DA7213_AUX_L_GAIN_STATUS	0x04
27ef5c2ebaSAdam Thomson #define DA7213_AUX_R_GAIN_STATUS	0x05
28ef5c2ebaSAdam Thomson #define DA7213_MIC_1_GAIN_STATUS	0x06
29ef5c2ebaSAdam Thomson #define DA7213_MIC_2_GAIN_STATUS	0x07
30ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_GAIN_STATUS	0x08
31ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_GAIN_STATUS	0x09
32ef5c2ebaSAdam Thomson #define DA7213_ADC_L_GAIN_STATUS	0x0A
33ef5c2ebaSAdam Thomson #define DA7213_ADC_R_GAIN_STATUS	0x0B
34ef5c2ebaSAdam Thomson #define DA7213_DAC_L_GAIN_STATUS	0x0C
35ef5c2ebaSAdam Thomson #define DA7213_DAC_R_GAIN_STATUS	0x0D
36ef5c2ebaSAdam Thomson #define DA7213_HP_L_GAIN_STATUS		0x0E
37ef5c2ebaSAdam Thomson #define DA7213_HP_R_GAIN_STATUS		0x0F
38ef5c2ebaSAdam Thomson #define DA7213_LINE_GAIN_STATUS		0x10
39ef5c2ebaSAdam Thomson 
40ef5c2ebaSAdam Thomson /* System Initialisation Registers */
41ef5c2ebaSAdam Thomson #define DA7213_DIG_ROUTING_DAI		0x21
42ef5c2ebaSAdam Thomson #define DA7213_SR			0x22
43ef5c2ebaSAdam Thomson #define DA7213_REFERENCES		0x23
44ef5c2ebaSAdam Thomson #define DA7213_PLL_FRAC_TOP		0x24
45ef5c2ebaSAdam Thomson #define DA7213_PLL_FRAC_BOT		0x25
46ef5c2ebaSAdam Thomson #define DA7213_PLL_INTEGER		0x26
47ef5c2ebaSAdam Thomson #define DA7213_PLL_CTRL			0x27
48ef5c2ebaSAdam Thomson #define DA7213_DAI_CLK_MODE		0x28
49ef5c2ebaSAdam Thomson #define DA7213_DAI_CTRL			0x29
50ef5c2ebaSAdam Thomson #define DA7213_DIG_ROUTING_DAC		0x2A
51ef5c2ebaSAdam Thomson #define DA7213_ALC_CTRL1		0x2B
52ef5c2ebaSAdam Thomson 
53ef5c2ebaSAdam Thomson /* Input - Gain, Select and Filter Registers */
54ef5c2ebaSAdam Thomson #define DA7213_AUX_L_GAIN		0x30
55ef5c2ebaSAdam Thomson #define DA7213_AUX_R_GAIN		0x31
56ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_SELECT		0x32
57ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_SELECT		0x33
58ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_GAIN		0x34
59ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_GAIN		0x35
60ef5c2ebaSAdam Thomson #define DA7213_ADC_L_GAIN		0x36
61ef5c2ebaSAdam Thomson #define DA7213_ADC_R_GAIN		0x37
62ef5c2ebaSAdam Thomson #define DA7213_ADC_FILTERS1		0x38
63ef5c2ebaSAdam Thomson #define DA7213_MIC_1_GAIN		0x39
64ef5c2ebaSAdam Thomson #define DA7213_MIC_2_GAIN		0x3A
65ef5c2ebaSAdam Thomson 
66ef5c2ebaSAdam Thomson /* Output - Gain, Select and Filter Registers */
67ef5c2ebaSAdam Thomson #define DA7213_DAC_FILTERS5		0x40
68ef5c2ebaSAdam Thomson #define DA7213_DAC_FILTERS2		0x41
69ef5c2ebaSAdam Thomson #define DA7213_DAC_FILTERS3		0x42
70ef5c2ebaSAdam Thomson #define DA7213_DAC_FILTERS4		0x43
71ef5c2ebaSAdam Thomson #define DA7213_DAC_FILTERS1		0x44
72ef5c2ebaSAdam Thomson #define DA7213_DAC_L_GAIN		0x45
73ef5c2ebaSAdam Thomson #define DA7213_DAC_R_GAIN		0x46
74ef5c2ebaSAdam Thomson #define DA7213_CP_CTRL			0x47
75ef5c2ebaSAdam Thomson #define DA7213_HP_L_GAIN		0x48
76ef5c2ebaSAdam Thomson #define DA7213_HP_R_GAIN		0x49
77ef5c2ebaSAdam Thomson #define DA7213_LINE_GAIN		0x4A
78ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_SELECT		0x4B
79ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_SELECT		0x4C
80ef5c2ebaSAdam Thomson 
81ef5c2ebaSAdam Thomson /* System Controller Registers */
82ef5c2ebaSAdam Thomson #define DA7213_SYSTEM_MODES_INPUT	0x50
83ef5c2ebaSAdam Thomson #define DA7213_SYSTEM_MODES_OUTPUT	0x51
84ef5c2ebaSAdam Thomson 
85ef5c2ebaSAdam Thomson /* Control Registers */
86ef5c2ebaSAdam Thomson #define DA7213_AUX_L_CTRL		0x60
87ef5c2ebaSAdam Thomson #define DA7213_AUX_R_CTRL		0x61
88ef5c2ebaSAdam Thomson #define DA7213_MICBIAS_CTRL		0x62
89ef5c2ebaSAdam Thomson #define DA7213_MIC_1_CTRL		0x63
90ef5c2ebaSAdam Thomson #define DA7213_MIC_2_CTRL		0x64
91ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_CTRL		0x65
92ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_CTRL		0x66
93ef5c2ebaSAdam Thomson #define DA7213_ADC_L_CTRL		0x67
94ef5c2ebaSAdam Thomson #define DA7213_ADC_R_CTRL		0x68
95ef5c2ebaSAdam Thomson #define DA7213_DAC_L_CTRL		0x69
96ef5c2ebaSAdam Thomson #define DA7213_DAC_R_CTRL		0x6A
97ef5c2ebaSAdam Thomson #define DA7213_HP_L_CTRL		0x6B
98ef5c2ebaSAdam Thomson #define DA7213_HP_R_CTRL		0x6C
99ef5c2ebaSAdam Thomson #define DA7213_LINE_CTRL		0x6D
100ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_CTRL		0x6E
101ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_CTRL		0x6F
102ef5c2ebaSAdam Thomson 
103ef5c2ebaSAdam Thomson /* Configuration Registers */
104ef5c2ebaSAdam Thomson #define DA7213_LDO_CTRL			0x90
105ef5c2ebaSAdam Thomson #define DA7213_IO_CTRL			0x91
106ef5c2ebaSAdam Thomson #define DA7213_GAIN_RAMP_CTRL		0x92
107ef5c2ebaSAdam Thomson #define DA7213_MIC_CONFIG		0x93
108ef5c2ebaSAdam Thomson #define DA7213_PC_COUNT			0x94
109ef5c2ebaSAdam Thomson #define DA7213_CP_VOL_THRESHOLD1	0x95
110ef5c2ebaSAdam Thomson #define DA7213_CP_DELAY			0x96
111ef5c2ebaSAdam Thomson #define DA7213_CP_DETECTOR		0x97
112ef5c2ebaSAdam Thomson #define DA7213_DAI_OFFSET		0x98
113ef5c2ebaSAdam Thomson #define DA7213_DIG_CTRL			0x99
114ef5c2ebaSAdam Thomson #define DA7213_ALC_CTRL2		0x9A
115ef5c2ebaSAdam Thomson #define DA7213_ALC_CTRL3		0x9B
116ef5c2ebaSAdam Thomson #define DA7213_ALC_NOISE		0x9C
117ef5c2ebaSAdam Thomson #define DA7213_ALC_TARGET_MIN		0x9D
118ef5c2ebaSAdam Thomson #define DA7213_ALC_TARGET_MAX		0x9E
119ef5c2ebaSAdam Thomson #define DA7213_ALC_GAIN_LIMITS		0x9F
120ef5c2ebaSAdam Thomson #define DA7213_ALC_ANA_GAIN_LIMITS	0xA0
121ef5c2ebaSAdam Thomson #define DA7213_ALC_ANTICLIP_CTRL	0xA1
122ef5c2ebaSAdam Thomson #define DA7213_ALC_ANTICLIP_LEVEL	0xA2
123ef5c2ebaSAdam Thomson 
124ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_AUTO_M_L	0xA3
125ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_AUTO_U_L	0xA4
126ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_MAN_M_L	0xA6
127ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_MAN_U_L	0xA7
128ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_AUTO_M_R	0xA8
129ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_AUTO_U_R	0xA9
130ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_MAN_M_R	0xAB
131ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_MAN_U_R	0xAC
132ef5c2ebaSAdam Thomson #define DA7213_ALC_CIC_OP_LVL_CTRL	0xAD
133ef5c2ebaSAdam Thomson #define DA7213_ALC_CIC_OP_LVL_DATA	0xAE
134ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_SETUP_TIME	0xAF
135ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_OFF_THRESHOLD	0xB0
136ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_ON_THRESHOLD	0xB1
137ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_CTRL		0xB2
138ef5c2ebaSAdam Thomson 
139*64c3259bSDavid Rau #define DA7213_TONE_GEN_CFG1		0xB4
140*64c3259bSDavid Rau #define DA7213_TONE_GEN_CFG2		0xB5
141*64c3259bSDavid Rau #define DA7213_TONE_GEN_CYCLES		0xB6
142*64c3259bSDavid Rau #define DA7213_TONE_GEN_FREQ1_L		0xB7
143*64c3259bSDavid Rau #define DA7213_TONE_GEN_FREQ1_U		0xB8
144*64c3259bSDavid Rau #define DA7213_TONE_GEN_FREQ2_L		0xB9
145*64c3259bSDavid Rau #define DA7213_TONE_GEN_FREQ2_U		0xBA
146*64c3259bSDavid Rau #define DA7213_TONE_GEN_ON_PER		0xBB
147*64c3259bSDavid Rau #define DA7213_TONE_GEN_OFF_PER		0xBC
148ef5c2ebaSAdam Thomson 
149ef5c2ebaSAdam Thomson /*
150ef5c2ebaSAdam Thomson  * Bit fields
151ef5c2ebaSAdam Thomson  */
152ef5c2ebaSAdam Thomson 
153*64c3259bSDavid Rau #define DA7213_SWITCH_EN_MAX		0x1
154*64c3259bSDavid Rau 
155d575b0b0SAdam Thomson /* DA7213_PLL_STATUS = 0x03 */
156*64c3259bSDavid Rau #define DA7213_PLL_SRM_LOCK					(0x1 << 1)
157d575b0b0SAdam Thomson 
158ef5c2ebaSAdam Thomson /* DA7213_SR = 0x22 */
159ef5c2ebaSAdam Thomson #define DA7213_SR_8000						(0x1 << 0)
160ef5c2ebaSAdam Thomson #define DA7213_SR_11025						(0x2 << 0)
161ef5c2ebaSAdam Thomson #define DA7213_SR_12000						(0x3 << 0)
162ef5c2ebaSAdam Thomson #define DA7213_SR_16000						(0x5 << 0)
163ef5c2ebaSAdam Thomson #define DA7213_SR_22050						(0x6 << 0)
164ef5c2ebaSAdam Thomson #define DA7213_SR_24000						(0x7 << 0)
165ef5c2ebaSAdam Thomson #define DA7213_SR_32000						(0x9 << 0)
166ef5c2ebaSAdam Thomson #define DA7213_SR_44100						(0xA << 0)
167ef5c2ebaSAdam Thomson #define DA7213_SR_48000						(0xB << 0)
168ef5c2ebaSAdam Thomson #define DA7213_SR_88200						(0xE << 0)
169ef5c2ebaSAdam Thomson #define DA7213_SR_96000						(0xF << 0)
170ef5c2ebaSAdam Thomson 
171ef5c2ebaSAdam Thomson /* DA7213_REFERENCES = 0x23 */
172ef5c2ebaSAdam Thomson #define DA7213_BIAS_EN						(0x1 << 3)
173ef5c2ebaSAdam Thomson #define DA7213_VMID_EN						(0x1 << 7)
174ef5c2ebaSAdam Thomson 
175ef5c2ebaSAdam Thomson /* DA7213_PLL_CTRL = 0x27 */
1761e62c52dSAdam Thomson #define DA7213_PLL_INDIV_5_TO_9_MHZ				(0x0 << 2)
1771e62c52dSAdam Thomson #define DA7213_PLL_INDIV_9_TO_18_MHZ				(0x1 << 2)
1781e62c52dSAdam Thomson #define DA7213_PLL_INDIV_18_TO_36_MHZ				(0x2 << 2)
1791e62c52dSAdam Thomson #define DA7213_PLL_INDIV_36_TO_54_MHZ				(0x3 << 2)
180ef5c2ebaSAdam Thomson #define DA7213_PLL_INDIV_MASK					(0x3 << 2)
181ef5c2ebaSAdam Thomson #define DA7213_PLL_MCLK_SQR_EN					(0x1 << 4)
182ef5c2ebaSAdam Thomson #define DA7213_PLL_32K_MODE					(0x1 << 5)
183ef5c2ebaSAdam Thomson #define DA7213_PLL_SRM_EN					(0x1 << 6)
184ef5c2ebaSAdam Thomson #define DA7213_PLL_EN						(0x1 << 7)
1854c75225aSAdam Thomson #define DA7213_PLL_MODE_MASK					(0x7 << 5)
186ef5c2ebaSAdam Thomson 
187ef5c2ebaSAdam Thomson /* DA7213_DAI_CLK_MODE = 0x28 */
188ef5c2ebaSAdam Thomson #define DA7213_DAI_BCLKS_PER_WCLK_32				(0x0 << 0)
189ef5c2ebaSAdam Thomson #define DA7213_DAI_BCLKS_PER_WCLK_64				(0x1 << 0)
190ef5c2ebaSAdam Thomson #define DA7213_DAI_BCLKS_PER_WCLK_128				(0x2 << 0)
191ef5c2ebaSAdam Thomson #define DA7213_DAI_BCLKS_PER_WCLK_256				(0x3 << 0)
192ef5c2ebaSAdam Thomson #define DA7213_DAI_BCLKS_PER_WCLK_MASK				(0x3 << 0)
193ef5c2ebaSAdam Thomson #define DA7213_DAI_CLK_POL_INV					(0x1 << 2)
194414a7321SLogesh #define DA7213_DAI_CLK_POL_MASK					(0x1 << 2)
195ef5c2ebaSAdam Thomson #define DA7213_DAI_WCLK_POL_INV					(0x1 << 3)
196414a7321SLogesh #define DA7213_DAI_WCLK_POL_MASK				(0x1 << 3)
197ef5c2ebaSAdam Thomson #define DA7213_DAI_CLK_EN_MASK					(0x1 << 7)
198ef5c2ebaSAdam Thomson 
199ef5c2ebaSAdam Thomson /* DA7213_DAI_CTRL = 0x29 */
200ef5c2ebaSAdam Thomson #define DA7213_DAI_FORMAT_I2S_MODE				(0x0 << 0)
201ef5c2ebaSAdam Thomson #define DA7213_DAI_FORMAT_LEFT_J				(0x1 << 0)
202ef5c2ebaSAdam Thomson #define DA7213_DAI_FORMAT_RIGHT_J				(0x2 << 0)
203e0d746ccSPierre-Louis Bossart #define DA7213_DAI_FORMAT_DSP					(0x3 << 0)
204ef5c2ebaSAdam Thomson #define DA7213_DAI_FORMAT_MASK					(0x3 << 0)
205ef5c2ebaSAdam Thomson #define DA7213_DAI_WORD_LENGTH_S16_LE				(0x0 << 2)
206ef5c2ebaSAdam Thomson #define DA7213_DAI_WORD_LENGTH_S20_LE				(0x1 << 2)
207ef5c2ebaSAdam Thomson #define DA7213_DAI_WORD_LENGTH_S24_LE				(0x2 << 2)
208ef5c2ebaSAdam Thomson #define DA7213_DAI_WORD_LENGTH_S32_LE				(0x3 << 2)
209ef5c2ebaSAdam Thomson #define DA7213_DAI_WORD_LENGTH_MASK				(0x3 << 2)
210c89e652eSDavid Rau #define DA7213_DAI_MONO_MODE_EN					(0x1 << 4)
211c89e652eSDavid Rau #define DA7213_DAI_MONO_MODE_MASK				(0x1 << 4)
212ef5c2ebaSAdam Thomson #define DA7213_DAI_EN_SHIFT					7
213ef5c2ebaSAdam Thomson 
214ef5c2ebaSAdam Thomson /* DA7213_DIG_ROUTING_DAI = 0x21 */
215ef5c2ebaSAdam Thomson #define DA7213_DAI_L_SRC_SHIFT					0
216ef5c2ebaSAdam Thomson #define DA7213_DAI_R_SRC_SHIFT					4
217ef5c2ebaSAdam Thomson #define DA7213_DAI_SRC_MAX					4
218ef5c2ebaSAdam Thomson 
219ef5c2ebaSAdam Thomson /* DA7213_DIG_ROUTING_DAC = 0x2A */
220ef5c2ebaSAdam Thomson #define DA7213_DAC_L_SRC_SHIFT					0
221ef5c2ebaSAdam Thomson #define DA7213_DAC_L_MONO_SHIFT					3
222ef5c2ebaSAdam Thomson #define DA7213_DAC_R_SRC_SHIFT					4
223ef5c2ebaSAdam Thomson #define DA7213_DAC_R_MONO_SHIFT					7
224ef5c2ebaSAdam Thomson #define DA7213_DAC_SRC_MAX					4
225ef5c2ebaSAdam Thomson #define DA7213_DAC_MONO_MAX					0x1
226ef5c2ebaSAdam Thomson 
227ef5c2ebaSAdam Thomson /* DA7213_ALC_CTRL1 = 0x2B */
228ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_EN_SHIFT				0
229ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_EN_MAX				0x1
230ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_EN					(0x1 << 0)
231ef5c2ebaSAdam Thomson #define DA7213_ALC_SYNC_MODE					(0x1 << 1)
232ef5c2ebaSAdam Thomson #define DA7213_ALC_CALIB_MODE_MAN				(0x1 << 2)
233ef5c2ebaSAdam Thomson #define DA7213_ALC_L_EN_SHIFT					3
234ef5c2ebaSAdam Thomson #define DA7213_ALC_AUTO_CALIB_EN				(0x1 << 4)
235ef5c2ebaSAdam Thomson #define DA7213_ALC_CALIB_OVERFLOW				(0x1 << 5)
236ef5c2ebaSAdam Thomson #define DA7213_ALC_R_EN_SHIFT					7
237ef5c2ebaSAdam Thomson #define DA7213_ALC_EN_MAX					0x1
238ef5c2ebaSAdam Thomson 
239ef5c2ebaSAdam Thomson /* DA7213_AUX_L/R_GAIN = 0x30/0x31 */
240ef5c2ebaSAdam Thomson #define DA7213_AUX_AMP_GAIN_SHIFT				0
241ef5c2ebaSAdam Thomson #define DA7213_AUX_AMP_GAIN_MAX					0x3F
242ef5c2ebaSAdam Thomson 
243ef5c2ebaSAdam Thomson /* DA7213_MIXIN_L/R_SELECT = 0x32/0x33 */
244ef5c2ebaSAdam Thomson #define DA7213_DMIC_EN_SHIFT					7
245ef5c2ebaSAdam Thomson #define DA7213_DMIC_EN_MAX					0x1
246ef5c2ebaSAdam Thomson 
247ef5c2ebaSAdam Thomson /* DA7213_MIXIN_L_SELECT = 0x32 */
248ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_MIX_SELECT_AUX_L_SHIFT			0
249ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_MIX_SELECT_MIC_1_SHIFT			1
250ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_MIX_SELECT_MIC_1				(0x1 << 1)
251ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_MIX_SELECT_MIC_2_SHIFT			2
252ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_MIX_SELECT_MIC_2				(0x1 << 2)
253ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_MIX_SELECT_MIXIN_R_SHIFT			3
254ef5c2ebaSAdam Thomson #define DA7213_MIXIN_L_MIX_SELECT_MAX				0x1
255ef5c2ebaSAdam Thomson 
256ef5c2ebaSAdam Thomson /* DA7213_MIXIN_R_SELECT =  0x33 */
257ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_MIX_SELECT_AUX_R_SHIFT			0
258ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_MIX_SELECT_MIC_2_SHIFT			1
259ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_MIX_SELECT_MIC_2				(0x1 << 1)
260ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_MIX_SELECT_MIC_1_SHIFT			2
261ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_MIX_SELECT_MIC_1				(0x1 << 2)
262ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_MIX_SELECT_MIXIN_L_SHIFT			3
263ef5c2ebaSAdam Thomson #define DA7213_MIXIN_R_MIX_SELECT_MAX				0x1
264ef5c2ebaSAdam Thomson #define DA7213_MIC_BIAS_OUTPUT_SELECT_2				(0x1 << 6)
265ef5c2ebaSAdam Thomson 
266ef5c2ebaSAdam Thomson /* DA7213_MIXIN_L/R_GAIN = 0x34/0x35 */
267ef5c2ebaSAdam Thomson #define DA7213_MIXIN_AMP_GAIN_SHIFT				0
268ef5c2ebaSAdam Thomson #define DA7213_MIXIN_AMP_GAIN_MAX				0xF
269ef5c2ebaSAdam Thomson 
270ef5c2ebaSAdam Thomson /* DA7213_ADC_L/R_GAIN = 0x36/0x37 */
271ef5c2ebaSAdam Thomson #define DA7213_ADC_AMP_GAIN_SHIFT				0
272ef5c2ebaSAdam Thomson #define DA7213_ADC_AMP_GAIN_MAX					0x7F
273ef5c2ebaSAdam Thomson 
274ef5c2ebaSAdam Thomson /* DA7213_ADC/DAC_FILTERS1 = 0x38/0x44 */
275ef5c2ebaSAdam Thomson #define DA7213_VOICE_HPF_CORNER_SHIFT				0
276ef5c2ebaSAdam Thomson #define DA7213_VOICE_HPF_CORNER_MAX				8
277ef5c2ebaSAdam Thomson #define DA7213_VOICE_EN_SHIFT					3
278ef5c2ebaSAdam Thomson #define DA7213_VOICE_EN_MAX					0x1
279ef5c2ebaSAdam Thomson #define DA7213_AUDIO_HPF_CORNER_SHIFT				4
280ef5c2ebaSAdam Thomson #define DA7213_AUDIO_HPF_CORNER_MAX				4
281ef5c2ebaSAdam Thomson #define DA7213_HPF_EN_SHIFT					7
282ef5c2ebaSAdam Thomson #define DA7213_HPF_EN_MAX					0x1
283ef5c2ebaSAdam Thomson 
284ef5c2ebaSAdam Thomson /* DA7213_MIC_1/2_GAIN = 0x39/0x3A */
285ef5c2ebaSAdam Thomson #define DA7213_MIC_AMP_GAIN_SHIFT				0
286ef5c2ebaSAdam Thomson #define DA7213_MIC_AMP_GAIN_MAX					0x7
287ef5c2ebaSAdam Thomson 
288ef5c2ebaSAdam Thomson /* DA7213_DAC_FILTERS5 = 0x40 */
289ef5c2ebaSAdam Thomson #define DA7213_DAC_SOFTMUTE_EN_SHIFT				7
290ef5c2ebaSAdam Thomson #define DA7213_DAC_SOFTMUTE_EN_MAX				0x1
291ef5c2ebaSAdam Thomson #define DA7213_DAC_SOFTMUTE_RATE_SHIFT				4
292ef5c2ebaSAdam Thomson #define DA7213_DAC_SOFTMUTE_RATE_MAX				7
293ef5c2ebaSAdam Thomson 
294ef5c2ebaSAdam Thomson /* DA7213_DAC_FILTERS2/3/4 = 0x41/0x42/0x43 */
295ef5c2ebaSAdam Thomson #define DA7213_DAC_EQ_BAND_MAX					0xF
296ef5c2ebaSAdam Thomson 
297ef5c2ebaSAdam Thomson /* DA7213_DAC_FILTERS2 = 0x41 */
298ef5c2ebaSAdam Thomson #define DA7213_DAC_EQ_BAND1_SHIFT				0
299ef5c2ebaSAdam Thomson #define DA7213_DAC_EQ_BAND2_SHIFT				4
300ef5c2ebaSAdam Thomson 
301ef5c2ebaSAdam Thomson /* DA7213_DAC_FILTERS2 = 0x42 */
302ef5c2ebaSAdam Thomson #define DA7213_DAC_EQ_BAND3_SHIFT				0
303ef5c2ebaSAdam Thomson #define DA7213_DAC_EQ_BAND4_SHIFT				4
304ef5c2ebaSAdam Thomson 
305ef5c2ebaSAdam Thomson /* DA7213_DAC_FILTERS4 = 0x43 */
306ef5c2ebaSAdam Thomson #define DA7213_DAC_EQ_BAND5_SHIFT				0
307ef5c2ebaSAdam Thomson #define DA7213_DAC_EQ_EN_SHIFT					7
308ef5c2ebaSAdam Thomson #define DA7213_DAC_EQ_EN_MAX					0x1
309ef5c2ebaSAdam Thomson 
310ef5c2ebaSAdam Thomson /* DA7213_DAC_L/R_GAIN = 0x45/0x46 */
311ef5c2ebaSAdam Thomson #define DA7213_DAC_AMP_GAIN_SHIFT				0
312ef5c2ebaSAdam Thomson #define DA7213_DAC_AMP_GAIN_MAX					0x7F
313ef5c2ebaSAdam Thomson 
314ef5c2ebaSAdam Thomson /* DA7213_HP_L/R_GAIN = 0x45/0x46 */
315ef5c2ebaSAdam Thomson #define DA7213_HP_AMP_GAIN_SHIFT				0
316ef5c2ebaSAdam Thomson #define DA7213_HP_AMP_GAIN_MAX					0x3F
317ef5c2ebaSAdam Thomson 
318ef5c2ebaSAdam Thomson /* DA7213_CP_CTRL = 0x47 */
319ef5c2ebaSAdam Thomson #define DA7213_CP_EN_SHIFT					7
320ef5c2ebaSAdam Thomson 
321ef5c2ebaSAdam Thomson /* DA7213_LINE_GAIN = 0x4A */
322ef5c2ebaSAdam Thomson #define DA7213_LINE_AMP_GAIN_SHIFT				0
323ef5c2ebaSAdam Thomson #define DA7213_LINE_AMP_GAIN_MAX				0x3F
324ef5c2ebaSAdam Thomson 
325ef5c2ebaSAdam Thomson /* DA7213_MIXOUT_L_SELECT = 0x4B */
326ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_MIX_SELECT_AUX_L_SHIFT			0
327ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_MIX_SELECT_MIXIN_L_SHIFT		1
328ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_MIX_SELECT_MIXIN_R_SHIFT		2
329ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_MIX_SELECT_DAC_L_SHIFT			3
330ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_MIX_SELECT_AUX_L_INVERTED_SHIFT		4
331ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_MIX_SELECT_MIXIN_L_INVERTED_SHIFT	5
332ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_MIX_SELECT_MIXIN_R_INVERTED_SHIFT	6
333ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_L_MIX_SELECT_MAX				0x1
334ef5c2ebaSAdam Thomson 
335ef5c2ebaSAdam Thomson /* DA7213_MIXOUT_R_SELECT = 0x4C */
336ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_MIX_SELECT_AUX_R_SHIFT			0
337ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_MIX_SELECT_MIXIN_R_SHIFT		1
338ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_MIX_SELECT_MIXIN_L_SHIFT		2
339ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_MIX_SELECT_DAC_R_SHIFT			3
340ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_MIX_SELECT_AUX_R_INVERTED_SHIFT		4
341ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_MIX_SELECT_MIXIN_R_INVERTED_SHIFT	5
342ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_MIX_SELECT_MIXIN_L_INVERTED_SHIFT	6
343ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_R_MIX_SELECT_MAX				0x1
344ef5c2ebaSAdam Thomson 
345ef5c2ebaSAdam Thomson /*
346ef5c2ebaSAdam Thomson  * DA7213_AUX_L/R_CTRL = 0x60/0x61,
347ef5c2ebaSAdam Thomson  * DA7213_MIC_1/2_CTRL = 0x63/0x64,
348ef5c2ebaSAdam Thomson  * DA7213_MIXIN_L/R_CTRL = 0x65/0x66,
349ef5c2ebaSAdam Thomson  * DA7213_ADC_L/R_CTRL = 0x65/0x66,
350ef5c2ebaSAdam Thomson  * DA7213_DAC_L/R_CTRL = 0x69/0x6A,
351ef5c2ebaSAdam Thomson  * DA7213_HP_L/R_CTRL = 0x6B/0x6C,
352ef5c2ebaSAdam Thomson  * DA7213_LINE_CTRL = 0x6D
353ef5c2ebaSAdam Thomson  */
354ef5c2ebaSAdam Thomson #define DA7213_MUTE_EN_SHIFT					6
355ef5c2ebaSAdam Thomson #define DA7213_MUTE_EN_MAX					0x1
356ef5c2ebaSAdam Thomson #define DA7213_MUTE_EN						(0x1 << 6)
357ef5c2ebaSAdam Thomson 
358ef5c2ebaSAdam Thomson /*
359ef5c2ebaSAdam Thomson  * DA7213_AUX_L/R_CTRL = 0x60/0x61,
360ef5c2ebaSAdam Thomson  * DA7213_MIXIN_L/R_CTRL = 0x65/0x66,
361ef5c2ebaSAdam Thomson  * DA7213_ADC_L/R_CTRL = 0x65/0x66,
362ef5c2ebaSAdam Thomson  * DA7213_DAC_L/R_CTRL = 0x69/0x6A,
363ef5c2ebaSAdam Thomson  * DA7213_HP_L/R_CTRL = 0x6B/0x6C,
364ef5c2ebaSAdam Thomson  * DA7213_LINE_CTRL = 0x6D
365ef5c2ebaSAdam Thomson  */
366ef5c2ebaSAdam Thomson #define DA7213_GAIN_RAMP_EN_SHIFT				5
367ef5c2ebaSAdam Thomson #define DA7213_GAIN_RAMP_EN_MAX					0x1
368ef5c2ebaSAdam Thomson #define DA7213_GAIN_RAMP_EN					(0x1 << 5)
369ef5c2ebaSAdam Thomson 
370ef5c2ebaSAdam Thomson /*
371ef5c2ebaSAdam Thomson  * DA7213_AUX_L/R_CTRL = 0x60/0x61,
372ef5c2ebaSAdam Thomson  * DA7213_MIXIN_L/R_CTRL = 0x65/0x66,
373ef5c2ebaSAdam Thomson  * DA7213_HP_L/R_CTRL = 0x6B/0x6C,
374ef5c2ebaSAdam Thomson  * DA7213_LINE_CTRL = 0x6D
375ef5c2ebaSAdam Thomson  */
376ef5c2ebaSAdam Thomson #define DA7213_ZC_EN_SHIFT					4
377ef5c2ebaSAdam Thomson #define DA7213_ZC_EN_MAX					0x1
378ef5c2ebaSAdam Thomson 
379ef5c2ebaSAdam Thomson /*
380ef5c2ebaSAdam Thomson  * DA7213_AUX_L/R_CTRL = 0x60/0x61,
381ef5c2ebaSAdam Thomson  * DA7213_MIC_1/2_CTRL = 0x63/0x64,
382ef5c2ebaSAdam Thomson  * DA7213_MIXIN_L/R_CTRL = 0x65/0x66,
383ef5c2ebaSAdam Thomson  * DA7213_HP_L/R_CTRL = 0x6B/0x6C,
384ef5c2ebaSAdam Thomson  * DA7213_MIXOUT_L/R_CTRL = 0x6E/0x6F,
385ef5c2ebaSAdam Thomson  * DA7213_LINE_CTRL = 0x6D
386ef5c2ebaSAdam Thomson  */
387ef5c2ebaSAdam Thomson #define DA7213_AMP_EN_SHIFT					7
388ef5c2ebaSAdam Thomson 
389ef5c2ebaSAdam Thomson /* DA7213_MIC_1/2_CTRL = 0x63/0x64 */
390ef5c2ebaSAdam Thomson #define DA7213_MIC_AMP_IN_SEL_SHIFT				2
391ef5c2ebaSAdam Thomson #define DA7213_MIC_AMP_IN_SEL_MAX				3
392ef5c2ebaSAdam Thomson 
393ef5c2ebaSAdam Thomson /* DA7213_MICBIAS_CTRL = 0x62 */
394ef5c2ebaSAdam Thomson #define DA7213_MICBIAS1_LEVEL_SHIFT				0
395ef5c2ebaSAdam Thomson #define DA7213_MICBIAS1_LEVEL_MASK				(0x3 << 0)
396ef5c2ebaSAdam Thomson #define DA7213_MICBIAS1_EN_SHIFT				3
397ef5c2ebaSAdam Thomson #define DA7213_MICBIAS2_LEVEL_SHIFT				4
398ef5c2ebaSAdam Thomson #define DA7213_MICBIAS2_LEVEL_MASK				(0x3 << 4)
399ef5c2ebaSAdam Thomson #define DA7213_MICBIAS2_EN_SHIFT				7
400ef5c2ebaSAdam Thomson 
401ef5c2ebaSAdam Thomson /* DA7213_MIXIN_L/R_CTRL = 0x65/0x66 */
402ef5c2ebaSAdam Thomson #define DA7213_MIXIN_MIX_EN					(0x1 << 3)
403ef5c2ebaSAdam Thomson 
404ef5c2ebaSAdam Thomson /* DA7213_ADC_L/R_CTRL = 0x67/0x68 */
405ef5c2ebaSAdam Thomson #define DA7213_ADC_EN_SHIFT					7
406ef5c2ebaSAdam Thomson #define DA7213_ADC_EN						(0x1 << 7)
407ef5c2ebaSAdam Thomson 
408ef5c2ebaSAdam Thomson /* DA7213_DAC_L/R_CTRL =  0x69/0x6A*/
409ef5c2ebaSAdam Thomson #define DA7213_DAC_EN_SHIFT					7
410ef5c2ebaSAdam Thomson 
411ef5c2ebaSAdam Thomson /* DA7213_HP_L/R_CTRL = 0x6B/0x6C */
412ef5c2ebaSAdam Thomson #define DA7213_HP_AMP_OE					(0x1 << 3)
413ef5c2ebaSAdam Thomson 
414ef5c2ebaSAdam Thomson /* DA7213_LINE_CTRL = 0x6D */
415ef5c2ebaSAdam Thomson #define DA7213_LINE_AMP_OE					(0x1 << 3)
416ef5c2ebaSAdam Thomson 
417ef5c2ebaSAdam Thomson /* DA7213_MIXOUT_L/R_CTRL = 0x6E/0x6F */
418ef5c2ebaSAdam Thomson #define DA7213_MIXOUT_MIX_EN					(0x1 << 3)
419ef5c2ebaSAdam Thomson 
420ef5c2ebaSAdam Thomson /* DA7213_GAIN_RAMP_CTRL = 0x92 */
421ef5c2ebaSAdam Thomson #define DA7213_GAIN_RAMP_RATE_SHIFT				0
422ef5c2ebaSAdam Thomson #define DA7213_GAIN_RAMP_RATE_MAX				4
423ef5c2ebaSAdam Thomson 
424ef5c2ebaSAdam Thomson /* DA7213_MIC_CONFIG = 0x93 */
425ef5c2ebaSAdam Thomson #define DA7213_DMIC_DATA_SEL_SHIFT				0
426ef5c2ebaSAdam Thomson #define DA7213_DMIC_DATA_SEL_MASK				(0x1 << 0)
427ef5c2ebaSAdam Thomson #define DA7213_DMIC_SAMPLEPHASE_SHIFT				1
428ef5c2ebaSAdam Thomson #define DA7213_DMIC_SAMPLEPHASE_MASK				(0x1 << 1)
429ef5c2ebaSAdam Thomson #define DA7213_DMIC_CLK_RATE_SHIFT				2
430ef5c2ebaSAdam Thomson #define DA7213_DMIC_CLK_RATE_MASK				(0x1 << 2)
431ef5c2ebaSAdam Thomson 
4327e28fd46SAdam Thomson /* DA7213_PC_COUNT = 0x94 */
4337e28fd46SAdam Thomson #define DA7213_PC_FREERUN_MASK					(0x1 << 0)
4347e28fd46SAdam Thomson 
435ef5c2ebaSAdam Thomson /* DA7213_DIG_CTRL = 0x99 */
436ef5c2ebaSAdam Thomson #define DA7213_DAC_L_INV_SHIFT					3
437ef5c2ebaSAdam Thomson #define DA7213_DAC_R_INV_SHIFT					7
438ef5c2ebaSAdam Thomson #define DA7213_DAC_INV_MAX					0x1
439ef5c2ebaSAdam Thomson 
440ef5c2ebaSAdam Thomson /* DA7213_ALC_CTRL2 = 0x9A */
441ef5c2ebaSAdam Thomson #define DA7213_ALC_ATTACK_SHIFT					0
442ef5c2ebaSAdam Thomson #define DA7213_ALC_ATTACK_MAX					13
443ef5c2ebaSAdam Thomson #define DA7213_ALC_RELEASE_SHIFT				4
444ef5c2ebaSAdam Thomson #define DA7213_ALC_RELEASE_MAX					11
445ef5c2ebaSAdam Thomson 
446ef5c2ebaSAdam Thomson /* DA7213_ALC_CTRL3 = 0x9B */
447ef5c2ebaSAdam Thomson #define DA7213_ALC_HOLD_SHIFT					0
448ef5c2ebaSAdam Thomson #define DA7213_ALC_HOLD_MAX					16
449ef5c2ebaSAdam Thomson #define DA7213_ALC_INTEG_ATTACK_SHIFT				4
450ef5c2ebaSAdam Thomson #define DA7213_ALC_INTEG_RELEASE_SHIFT				6
451ef5c2ebaSAdam Thomson #define DA7213_ALC_INTEG_MAX					4
452ef5c2ebaSAdam Thomson 
453ef5c2ebaSAdam Thomson /*
454ef5c2ebaSAdam Thomson  * DA7213_ALC_NOISE = 0x9C,
455ef5c2ebaSAdam Thomson  * DA7213_ALC_TARGET_MIN/MAX = 0x9D/0x9E
456ef5c2ebaSAdam Thomson  */
457ef5c2ebaSAdam Thomson #define DA7213_ALC_THRESHOLD_SHIFT				0
458ef5c2ebaSAdam Thomson #define DA7213_ALC_THRESHOLD_MAX				0x3F
459ef5c2ebaSAdam Thomson 
460ef5c2ebaSAdam Thomson /* DA7213_ALC_GAIN_LIMITS = 0x9F */
461ef5c2ebaSAdam Thomson #define DA7213_ALC_ATTEN_MAX_SHIFT				0
462ef5c2ebaSAdam Thomson #define DA7213_ALC_GAIN_MAX_SHIFT				4
463ef5c2ebaSAdam Thomson #define DA7213_ALC_ATTEN_GAIN_MAX_MAX				0xF
464ef5c2ebaSAdam Thomson 
465ef5c2ebaSAdam Thomson /* DA7213_ALC_ANA_GAIN_LIMITS = 0xA0 */
466ef5c2ebaSAdam Thomson #define DA7213_ALC_ANA_GAIN_MIN_SHIFT				0
467ef5c2ebaSAdam Thomson #define DA7213_ALC_ANA_GAIN_MAX_SHIFT				4
468ef5c2ebaSAdam Thomson #define DA7213_ALC_ANA_GAIN_MAX					0x7
469ef5c2ebaSAdam Thomson 
470ef5c2ebaSAdam Thomson /* DA7213_ALC_ANTICLIP_CTRL = 0xA1 */
471ef5c2ebaSAdam Thomson #define DA7213_ALC_ANTICLIP_EN_SHIFT				7
472ef5c2ebaSAdam Thomson #define DA7213_ALC_ANTICLIP_EN_MAX				0x1
473ef5c2ebaSAdam Thomson 
474ef5c2ebaSAdam Thomson /* DA7213_ALC_ANTICLIP_LEVEL = 0xA2 */
475ef5c2ebaSAdam Thomson #define DA7213_ALC_ANTICLIP_LEVEL_SHIFT				0
476ef5c2ebaSAdam Thomson #define DA7213_ALC_ANTICLIP_LEVEL_MAX				0x7F
477ef5c2ebaSAdam Thomson 
478ef5c2ebaSAdam Thomson /* DA7213_ALC_CIC_OP_LVL_CTRL = 0xAD */
479ef5c2ebaSAdam Thomson #define DA7213_ALC_DATA_MIDDLE					(0x2 << 0)
480ef5c2ebaSAdam Thomson #define DA7213_ALC_DATA_TOP					(0x3 << 0)
481ef5c2ebaSAdam Thomson #define DA7213_ALC_CIC_OP_CHANNEL_LEFT				(0x0 << 7)
482ef5c2ebaSAdam Thomson #define DA7213_ALC_CIC_OP_CHANNEL_RIGHT				(0x1 << 7)
483ef5c2ebaSAdam Thomson 
484ef5c2ebaSAdam Thomson /* DA7213_DAC_NG_SETUP_TIME = 0xAF */
485ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_SETUP_TIME_SHIFT				0
486ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_SETUP_TIME_MAX				4
487ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_RAMPUP_RATE_SHIFT				2
488ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_RAMPDN_RATE_SHIFT				3
489ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_RAMP_RATE_MAX				2
490ef5c2ebaSAdam Thomson 
491ef5c2ebaSAdam Thomson /* DA7213_DAC_NG_OFF/ON_THRESH = 0xB0/0xB1 */
492ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_THRESHOLD_SHIFT				0
493ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_THRESHOLD_MAX				0x7
494ef5c2ebaSAdam Thomson 
495ef5c2ebaSAdam Thomson /* DA7213_DAC_NG_CTRL = 0xB2 */
496ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_EN_SHIFT					7
497ef5c2ebaSAdam Thomson #define DA7213_DAC_NG_EN_MAX					0x1
498ef5c2ebaSAdam Thomson 
499*64c3259bSDavid Rau /* DA7213_TONE_GEN_CFG1 = 0xB4 */
500*64c3259bSDavid Rau #define DA7213_DTMF_REG_SHIFT		0
501*64c3259bSDavid Rau #define DA7213_DTMF_REG_MASK		(0xF << 0)
502*64c3259bSDavid Rau #define DA7213_DTMF_REG_MAX		16
503*64c3259bSDavid Rau #define DA7213_DTMF_EN_SHIFT		4
504*64c3259bSDavid Rau #define DA7213_DTMF_EN_MASK		(0x1 << 4)
505*64c3259bSDavid Rau #define DA7213_START_STOPN_SHIFT	7
506*64c3259bSDavid Rau #define DA7213_START_STOPN_MASK		(0x1 << 7)
507*64c3259bSDavid Rau 
508*64c3259bSDavid Rau /* DA7213_TONE_GEN_CFG2 = 0xB5 */
509*64c3259bSDavid Rau #define DA7213_SWG_SEL_SHIFT		0
510*64c3259bSDavid Rau #define DA7213_SWG_SEL_MASK		(0x3 << 0)
511*64c3259bSDavid Rau #define DA7213_SWG_SEL_MAX		4
512*64c3259bSDavid Rau #define DA7213_SWG_SEL_SRAMP		(0x3 << 0)
513*64c3259bSDavid Rau #define DA7213_TONE_GEN_GAIN_SHIFT	4
514*64c3259bSDavid Rau #define DA7213_TONE_GEN_GAIN_MASK	(0xF << 4)
515*64c3259bSDavid Rau #define DA7213_TONE_GEN_GAIN_MAX	0xF
516*64c3259bSDavid Rau #define DA7213_TONE_GEN_GAIN_MINUS_9DB	(0x3 << 4)
517*64c3259bSDavid Rau #define DA7213_TONE_GEN_GAIN_MINUS_15DB	(0x5 << 4)
518*64c3259bSDavid Rau 
519*64c3259bSDavid Rau /* DA7213_TONE_GEN_CYCLES = 0xB6 */
520*64c3259bSDavid Rau #define DA7213_BEEP_CYCLES_SHIFT	0
521*64c3259bSDavid Rau #define DA7213_BEEP_CYCLES_MASK		(0x7 << 0)
522*64c3259bSDavid Rau 
523*64c3259bSDavid Rau /* DA7213_TONE_GEN_FREQ1_L = 0xB7 */
524*64c3259bSDavid Rau #define DA7213_FREQ1_L_SHIFT	0
525*64c3259bSDavid Rau #define DA7213_FREQ1_L_MASK	(0xFF << 0)
526*64c3259bSDavid Rau #define DA7213_FREQ_MAX		0xFFFF
527*64c3259bSDavid Rau 
528*64c3259bSDavid Rau /* DA7213_TONE_GEN_FREQ1_U = 0xB8 */
529*64c3259bSDavid Rau #define DA7213_FREQ1_U_SHIFT	0
530*64c3259bSDavid Rau #define DA7213_FREQ1_U_MASK	(0xFF << 0)
531*64c3259bSDavid Rau 
532*64c3259bSDavid Rau /* DA7213_TONE_GEN_FREQ2_L = 0xB9 */
533*64c3259bSDavid Rau #define DA7213_FREQ2_L_SHIFT	0
534*64c3259bSDavid Rau #define DA7213_FREQ2_L_MASK	(0xFF << 0)
535*64c3259bSDavid Rau 
536*64c3259bSDavid Rau /* DA7213_TONE_GEN_FREQ2_U = 0xBA */
537*64c3259bSDavid Rau #define DA7213_FREQ2_U_SHIFT	0
538*64c3259bSDavid Rau #define DA7213_FREQ2_U_MASK	(0xFF << 0)
539*64c3259bSDavid Rau 
540*64c3259bSDavid Rau /* DA7213_TONE_GEN_ON_PER = 0xBB */
541*64c3259bSDavid Rau #define DA7213_BEEP_ON_PER_SHIFT	0
542*64c3259bSDavid Rau #define DA7213_BEEP_ON_PER_MASK		(0x3F << 0)
543*64c3259bSDavid Rau #define DA7213_BEEP_ON_OFF_MAX		0x3F
544*64c3259bSDavid Rau 
545*64c3259bSDavid Rau /* DA7213_TONE_GEN_OFF_PER = 0xBC */
546*64c3259bSDavid Rau #define DA7213_BEEP_OFF_PER_SHIFT	0
547*64c3259bSDavid Rau #define DA7213_BEEP_OFF_PER_MASK	(0x3F << 0)
548ef5c2ebaSAdam Thomson 
549ef5c2ebaSAdam Thomson /*
550ef5c2ebaSAdam Thomson  * General defines
551ef5c2ebaSAdam Thomson  */
552ef5c2ebaSAdam Thomson 
553ef5c2ebaSAdam Thomson /* Register inversion */
554ef5c2ebaSAdam Thomson #define DA7213_NO_INVERT		0
555ef5c2ebaSAdam Thomson #define DA7213_INVERT			1
556ef5c2ebaSAdam Thomson 
557ef5c2ebaSAdam Thomson /* Byte related defines */
558ef5c2ebaSAdam Thomson #define DA7213_BYTE_SHIFT		8
559ef5c2ebaSAdam Thomson #define DA7213_BYTE_MASK		0xFF
560ef5c2ebaSAdam Thomson 
561ef5c2ebaSAdam Thomson /* ALC related */
562ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_15_8		0x00FF00
563ef5c2ebaSAdam Thomson #define DA7213_ALC_OFFSET_19_16		0x0F0000
564ef5c2ebaSAdam Thomson #define DA7213_ALC_AVG_ITERATIONS	5
565ef5c2ebaSAdam Thomson 
566ef5c2ebaSAdam Thomson /* PLL related */
567ef5c2ebaSAdam Thomson #define DA7213_PLL_FREQ_OUT_90316800		90316800
568ef5c2ebaSAdam Thomson #define DA7213_PLL_FREQ_OUT_98304000		98304000
569ef5c2ebaSAdam Thomson #define DA7213_PLL_FREQ_OUT_94310400		94310400
5701e62c52dSAdam Thomson #define DA7213_PLL_INDIV_5_TO_9_MHZ_VAL		2
5711e62c52dSAdam Thomson #define DA7213_PLL_INDIV_9_TO_18_MHZ_VAL	4
5721e62c52dSAdam Thomson #define DA7213_PLL_INDIV_18_TO_36_MHZ_VAL	8
5731e62c52dSAdam Thomson #define DA7213_PLL_INDIV_36_TO_54_MHZ_VAL	16
574d575b0b0SAdam Thomson #define DA7213_SRM_CHECK_RETRIES		8
575ef5c2ebaSAdam Thomson 
5766e7c4443SAdam Thomson enum da7213_clk_src {
5776e7c4443SAdam Thomson 	DA7213_CLKSRC_MCLK = 0,
5786e7c4443SAdam Thomson 	DA7213_CLKSRC_MCLK_SQR,
579ef5c2ebaSAdam Thomson };
580ef5c2ebaSAdam Thomson 
5814c75225aSAdam Thomson enum da7213_sys_clk {
5824c75225aSAdam Thomson 	DA7213_SYSCLK_MCLK = 0,
5834c75225aSAdam Thomson 	DA7213_SYSCLK_PLL,
5844c75225aSAdam Thomson 	DA7213_SYSCLK_PLL_SRM,
5854c75225aSAdam Thomson 	DA7213_SYSCLK_PLL_32KHZ
5864c75225aSAdam Thomson };
5874c75225aSAdam Thomson 
588b2a37881SSebastian Reichel /* Regulators */
589b2a37881SSebastian Reichel enum da7213_supplies {
590b2a37881SSebastian Reichel 	DA7213_SUPPLY_VDDA = 0,
591b2a37881SSebastian Reichel 	DA7213_SUPPLY_VDDIO,
592b2a37881SSebastian Reichel 	DA7213_NUM_SUPPLIES,
593b2a37881SSebastian Reichel };
594b2a37881SSebastian Reichel 
595ef5c2ebaSAdam Thomson /* Codec private data */
596ef5c2ebaSAdam Thomson struct da7213_priv {
597ef5c2ebaSAdam Thomson 	struct regmap *regmap;
598*64c3259bSDavid Rau 	struct mutex ctrl_lock;
599b2a37881SSebastian Reichel 	struct regulator_bulk_data supplies[DA7213_NUM_SUPPLIES];
6006e7c4443SAdam Thomson 	struct clk *mclk;
601ef5c2ebaSAdam Thomson 	unsigned int mclk_rate;
6025146b6a9SSebastian Reichel 	unsigned int out_rate;
6036e7c4443SAdam Thomson 	int clk_src;
604ef5c2ebaSAdam Thomson 	bool master;
605ef5c2ebaSAdam Thomson 	bool alc_calib_auto;
606ef5c2ebaSAdam Thomson 	bool alc_en;
6075146b6a9SSebastian Reichel 	bool fixed_clk_auto_pll;
608ef5c2ebaSAdam Thomson 	struct da7213_platform_data *pdata;
609c89e652eSDavid Rau 	int fmt;
610ef5c2ebaSAdam Thomson };
611ef5c2ebaSAdam Thomson 
612ef5c2ebaSAdam Thomson #endif /* _DA7213_H */
613