xref: /linux/sound/soc/codecs/mt6357.h (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1*5e240449SNicolas Belin /* SPDX-License-Identifier: GPL-2.0 */
2*5e240449SNicolas Belin /*
3*5e240449SNicolas Belin  * mt6357.h  --  mt6357 ALSA SoC audio codec driver
4*5e240449SNicolas Belin  *
5*5e240449SNicolas Belin  * Copyright (c) 2024 Baylibre
6*5e240449SNicolas Belin  * Author: Nicolas Belin <nbelin@baylibre.com>
7*5e240449SNicolas Belin  */
8*5e240449SNicolas Belin 
9*5e240449SNicolas Belin #ifndef __MT6357_H__
10*5e240449SNicolas Belin #define __MT6357_H__
11*5e240449SNicolas Belin 
12*5e240449SNicolas Belin #include <linux/types.h>
13*5e240449SNicolas Belin 
14*5e240449SNicolas Belin /* Reg bit defines */
15*5e240449SNicolas Belin /* MT6357_GPIO_DIR0 */
16*5e240449SNicolas Belin #define MT6357_GPIO8_DIR_MASK			BIT(8)
17*5e240449SNicolas Belin #define MT6357_GPIO8_DIR_INPUT			0
18*5e240449SNicolas Belin #define MT6357_GPIO8_DIR_OUTPUT			BIT(8)
19*5e240449SNicolas Belin #define MT6357_GPIO9_DIR_MASK			BIT(9)
20*5e240449SNicolas Belin #define MT6357_GPIO9_DIR_INPUT			0
21*5e240449SNicolas Belin #define MT6357_GPIO9_DIR_OUTPUT			BIT(9)
22*5e240449SNicolas Belin #define MT6357_GPIO10_DIR_MASK			BIT(10)
23*5e240449SNicolas Belin #define MT6357_GPIO10_DIR_INPUT			0
24*5e240449SNicolas Belin #define MT6357_GPIO10_DIR_OUTPUT		BIT(10)
25*5e240449SNicolas Belin #define MT6357_GPIO11_DIR_MASK			BIT(11)
26*5e240449SNicolas Belin #define MT6357_GPIO11_DIR_INPUT			0
27*5e240449SNicolas Belin #define MT6357_GPIO11_DIR_OUTPUT		BIT(11)
28*5e240449SNicolas Belin #define MT6357_GPIO12_DIR_MASK			BIT(12)
29*5e240449SNicolas Belin #define MT6357_GPIO12_DIR_INPUT			0
30*5e240449SNicolas Belin #define MT6357_GPIO12_DIR_OUTPUT		BIT(12)
31*5e240449SNicolas Belin #define MT6357_GPIO13_DIR_MASK			BIT(13)
32*5e240449SNicolas Belin #define MT6357_GPIO13_DIR_INPUT			0
33*5e240449SNicolas Belin #define MT6357_GPIO13_DIR_OUTPUT		BIT(13)
34*5e240449SNicolas Belin #define MT6357_GPIO14_DIR_MASK			BIT(14)
35*5e240449SNicolas Belin #define MT6357_GPIO14_DIR_INPUT			0
36*5e240449SNicolas Belin #define MT6357_GPIO14_DIR_OUTPUT		BIT(14)
37*5e240449SNicolas Belin #define MT6357_GPIO15_DIR_MASK			BIT(15)
38*5e240449SNicolas Belin #define MT6357_GPIO15_DIR_INPUT			0
39*5e240449SNicolas Belin #define MT6357_GPIO15_DIR_OUTPUT		BIT(15)
40*5e240449SNicolas Belin 
41*5e240449SNicolas Belin /* MT6357_GPIO_MODE2 */
42*5e240449SNicolas Belin #define MT6357_GPIO8_MODE_MASK			GENMASK(2, 0)
43*5e240449SNicolas Belin #define MT6357_GPIO8_MODE_AUD_CLK_MOSI		BIT(0)
44*5e240449SNicolas Belin #define MT6357_GPIO8_MODE_GPIO			0
45*5e240449SNicolas Belin #define MT6357_GPIO9_MODE_MASK			GENMASK(5, 3)
46*5e240449SNicolas Belin #define MT6357_GPIO9_MODE_AUD_DAT_MOSI0		BIT(3)
47*5e240449SNicolas Belin #define MT6357_GPIO9_MODE_GPIO			0
48*5e240449SNicolas Belin #define MT6357_GPIO10_MODE_MASK			GENMASK(8, 6)
49*5e240449SNicolas Belin #define MT6357_GPIO10_MODE_AUD_DAT_MOSI1	BIT(6)
50*5e240449SNicolas Belin #define MT6357_GPIO10_MODE_GPIO			0
51*5e240449SNicolas Belin #define MT6357_GPIO11_MODE_MASK			GENMASK(11, 9)
52*5e240449SNicolas Belin #define MT6357_GPIO11_MODE_AUD_SYNC_MOSI	BIT(9)
53*5e240449SNicolas Belin #define MT6357_GPIO11_MODE_GPIO			0
54*5e240449SNicolas Belin 
55*5e240449SNicolas Belin /* MT6357_GPIO_MODE2_SET */
56*5e240449SNicolas Belin #define MT6357_GPIO8_MODE_SET_MASK		GENMASK(2, 0)
57*5e240449SNicolas Belin #define MT6357_GPIO8_MODE_SET_AUD_CLK_MOSI	BIT(0)
58*5e240449SNicolas Belin #define MT6357_GPIO9_MODE_SET_MASK		GENMASK(5, 3)
59*5e240449SNicolas Belin #define MT6357_GPIO9_MODE_SET_AUD_DAT_MOSI0	BIT(3)
60*5e240449SNicolas Belin #define MT6357_GPIO10_MODE_SET_MASK		GENMASK(8, 6)
61*5e240449SNicolas Belin #define MT6357_GPIO10_MODE_SET_AUD_DAT_MOSI1	BIT(6)
62*5e240449SNicolas Belin #define MT6357_GPIO11_MODE_SET_MASK		GENMASK(11, 9)
63*5e240449SNicolas Belin #define MT6357_GPIO11_MODE_SET_AUD_SYNC_MOSI	BIT(9)
64*5e240449SNicolas Belin 
65*5e240449SNicolas Belin /* MT6357_GPIO_MODE2_CLR */
66*5e240449SNicolas Belin #define MT6357_GPIO_MODE2_CLEAR_ALL		GENMASK(15, 0)
67*5e240449SNicolas Belin 
68*5e240449SNicolas Belin /* MT6357_GPIO_MODE3 */
69*5e240449SNicolas Belin #define MT6357_GPIO12_MODE_MASK			GENMASK(2, 0)
70*5e240449SNicolas Belin #define MT6357_GPIO12_MODE_AUD_CLK_MISO		BIT(0)
71*5e240449SNicolas Belin #define MT6357_GPIO12_MODE_GPIO			0
72*5e240449SNicolas Belin #define MT6357_GPIO13_MODE_MASK			GENMASK(5, 3)
73*5e240449SNicolas Belin #define MT6357_GPIO13_MODE_AUD_DAT_MISO0	BIT(3)
74*5e240449SNicolas Belin #define MT6357_GPIO13_MODE_GPIO			0
75*5e240449SNicolas Belin #define MT6357_GPIO14_MODE_MASK			GENMASK(8, 6)
76*5e240449SNicolas Belin #define MT6357_GPIO14_MODE_AUD_DAT_MISO1	BIT(6)
77*5e240449SNicolas Belin #define MT6357_GPIO14_MODE_GPIO			0
78*5e240449SNicolas Belin #define MT6357_GPIO15_MODE_MASK			GENMASK(11, 9)
79*5e240449SNicolas Belin #define MT6357_GPIO15_MODE_AUD_SYNC_MISO	BIT(9)
80*5e240449SNicolas Belin #define MT6357_GPIO15_MODE_GPIO			0
81*5e240449SNicolas Belin 
82*5e240449SNicolas Belin /* MT6357_GPIO_MODE3_SET */
83*5e240449SNicolas Belin #define MT6357_GPIO12_MODE_SET_MASK		GENMASK(2, 0)
84*5e240449SNicolas Belin #define MT6357_GPIO12_MODE_SET_AUD_CLK_MISO	BIT(0)
85*5e240449SNicolas Belin #define MT6357_GPIO13_MODE_SET_MASK		GENMASK(5, 3)
86*5e240449SNicolas Belin #define MT6357_GPIO13_MODE_SET_AUD_DAT_MISO0	BIT(3)
87*5e240449SNicolas Belin #define MT6357_GPIO14_MODE_SET_MASK		GENMASK(8, 6)
88*5e240449SNicolas Belin #define MT6357_GPIO14_MODE_SET_AUD_DAT_MISO1	BIT(6)
89*5e240449SNicolas Belin #define MT6357_GPIO15_MODE_SET_MASK		GENMASK(11, 9)
90*5e240449SNicolas Belin #define MT6357_GPIO15_MODE_SET_AUD_SYNC_MISO	BIT(9)
91*5e240449SNicolas Belin 
92*5e240449SNicolas Belin /* MT6357_GPIO_MODE3_CLR */
93*5e240449SNicolas Belin #define MT6357_GPIO_MODE3_CLEAR_ALL		GENMASK(15, 0)
94*5e240449SNicolas Belin 
95*5e240449SNicolas Belin /* MT6357_DCXO_CW14 */
96*5e240449SNicolas Belin #define MT6357_XO_AUDIO_EN_M_SFT		13
97*5e240449SNicolas Belin #define MT6357_XO_AUDIO_EN_M_MASK		BIT(13)
98*5e240449SNicolas Belin #define MT6357_XO_AUDIO_EN_M_ENABLE		BIT(13)
99*5e240449SNicolas Belin #define MT6357_XO_AUDIO_EN_M_DISABLE		0
100*5e240449SNicolas Belin 
101*5e240449SNicolas Belin /* MT6357_AUD_TOP_CKPDN_CON0 */
102*5e240449SNicolas Belin #define MT6357_AUDNCP_CK_PDN_SFT		6
103*5e240449SNicolas Belin #define MT6357_ZCD13M_CK_PDN_SFT		5
104*5e240449SNicolas Belin #define MT6357_AUDIF_CK_PDN_SFT			2
105*5e240449SNicolas Belin #define MT6357_AUD_CK_PDN_SFT			1
106*5e240449SNicolas Belin 
107*5e240449SNicolas Belin /* MT6357_AUDNCP_CLKDIV_CON0 */
108*5e240449SNicolas Belin #define MT6357_DIVCKS_CHG			BIT(0)
109*5e240449SNicolas Belin 
110*5e240449SNicolas Belin /* MT6357_AUDNCP_CLKDIV_CON1 */
111*5e240449SNicolas Belin #define MT6357_DIVCKS_ON			BIT(0)
112*5e240449SNicolas Belin 
113*5e240449SNicolas Belin /* MT6357_AUDNCP_CLKDIV_CON3 */
114*5e240449SNicolas Belin #define MT6357_DIVCKS_PWD_NCP_MASK		BIT(0)
115*5e240449SNicolas Belin #define MT6357_DIVCKS_PWD_NCP_DISABLE		BIT(0)
116*5e240449SNicolas Belin #define MT6357_DIVCKS_PWD_NCP_ENABLE		0
117*5e240449SNicolas Belin 
118*5e240449SNicolas Belin /* MT6357_AUDNCP_CLKDIV_CON4 */
119*5e240449SNicolas Belin #define MT6357_DIVCKS_PWD_NCP_ST_SEL_MASK	GENMASK(1, 0)
120*5e240449SNicolas Belin #define MT6357_DIVCKS_PWD_NCP_ST_50US		0
121*5e240449SNicolas Belin #define MT6357_DIVCKS_PWD_NCP_ST_100US		1
122*5e240449SNicolas Belin #define MT6357_DIVCKS_PWD_NCP_ST_150US		2
123*5e240449SNicolas Belin #define MT6357_DIVCKS_PWD_NCP_ST_200US		3
124*5e240449SNicolas Belin 
125*5e240449SNicolas Belin /* MT6357_AFE_UL_DL_CON0 */
126*5e240449SNicolas Belin #define MT6357_AFE_UL_LR_SWAP_SFT		15
127*5e240449SNicolas Belin #define MT6357_AFE_ON_SFT			0
128*5e240449SNicolas Belin 
129*5e240449SNicolas Belin /* MT6357_AFE_DL_SRC2_CON0_L */
130*5e240449SNicolas Belin #define MT6357_DL_2_SRC_ON_TMP_CTL_PRE_SFT	0
131*5e240449SNicolas Belin 
132*5e240449SNicolas Belin /* MT6357_AFE_UL_SRC_CON0_H */
133*5e240449SNicolas Belin #define MT6357_C_TWO_DIGITAL_MIC_CTL_MASK	BIT(7)
134*5e240449SNicolas Belin #define MT6357_C_TWO_DIGITAL_MIC_ENABLE		BIT(7)
135*5e240449SNicolas Belin #define MT6357_C_TWO_DIGITAL_MIC_DISABLE	0
136*5e240449SNicolas Belin 
137*5e240449SNicolas Belin /* MT6357_AFE_UL_SRC_CON0_L */
138*5e240449SNicolas Belin #define MT6357_UL_SDM_3_LEVEL_CTL_MASK		BIT(1)
139*5e240449SNicolas Belin #define MT6357_UL_SDM_3_LEVEL_SELECT		BIT(1)
140*5e240449SNicolas Belin #define MT6357_UL_SDM_3_LEVEL_DESELECT		0
141*5e240449SNicolas Belin #define MT6357_UL_SRC_ON_TMP_CTL_MASK		BIT(0)
142*5e240449SNicolas Belin #define MT6357_UL_SRC_ENABLE			BIT(0)
143*5e240449SNicolas Belin #define MT6357_UL_SRC_DISABLE			0
144*5e240449SNicolas Belin 
145*5e240449SNicolas Belin /* MT6357_AFE_TOP_CON0 */
146*5e240449SNicolas Belin #define MT6357_UL_SINE_ON_SFT			1
147*5e240449SNicolas Belin #define MT6357_UL_SINE_ON_MASK			BIT(1)
148*5e240449SNicolas Belin #define MT6357_DL_SINE_ON_SFT			0
149*5e240449SNicolas Belin #define MT6357_DL_SINE_ON_MASK			BIT(0)
150*5e240449SNicolas Belin 
151*5e240449SNicolas Belin /* MT6357_AUDIO_TOP_CON0 */
152*5e240449SNicolas Belin #define MT6357_PDN_LPBK_CTL_SFT			15
153*5e240449SNicolas Belin #define MT6357_PDN_AFE_CTL_SFT			7
154*5e240449SNicolas Belin #define MT6357_PDN_DAC_CTL_SFT			6
155*5e240449SNicolas Belin #define MT6357_PDN_ADC_CTL_SFT			5
156*5e240449SNicolas Belin #define MT6357_PDN_I2S_DL_CTL_SFT		3
157*5e240449SNicolas Belin #define MT6357_PWR_CLK_DIS_CTL_SFT		2
158*5e240449SNicolas Belin #define MT6357_PDN_AFE_TESTMODEL_CTL_SFT	1
159*5e240449SNicolas Belin #define MT6357_PDN_RESERVED_SFT			0
160*5e240449SNicolas Belin 
161*5e240449SNicolas Belin /* MT6357_AFUNC_AUD_CON0 */
162*5e240449SNicolas Belin #define MT6357_CCI_AUD_ANACK_INVERT			BIT(15)
163*5e240449SNicolas Belin #define MT6357_CCI_AUD_ANACK_NORMAL			0
164*5e240449SNicolas Belin #define MT6357_CCI_AUDIO_FIFO_WPTR_SFT			12
165*5e240449SNicolas Belin #define MT6357_CCI_SCRAMBLER_CG_ENABLE			BIT(11)
166*5e240449SNicolas Belin #define MT6357_CCI_SCRAMBLER_CG_DISABLE			0
167*5e240449SNicolas Belin #define MT6357_CCI_LCK_INV_OUT_OF_PHASE			BIT(10)
168*5e240449SNicolas Belin #define MT6357_CCI_LCK_INV_IN_PHASE			0
169*5e240449SNicolas Belin #define MT6357_CCI_RAND_ENABLE				BIT(9)
170*5e240449SNicolas Belin #define MT6357_CCI_RAND_DISABLE				0
171*5e240449SNicolas Belin #define MT6357_CCI_SPLT_SCRMB_CLK_ON			BIT(8)
172*5e240449SNicolas Belin #define MT6357_CCI_SPLT_SCRMB_CLK_OFF			0
173*5e240449SNicolas Belin #define MT6357_CCI_SPLT_SCRMB_ON			BIT(7)
174*5e240449SNicolas Belin #define MT6357_CCI_SPLT_SCRMB_OFF			0
175*5e240449SNicolas Belin #define MT6357_CCI_AUD_IDAC_TEST_EN_FROM_TEST_IN	BIT(6)
176*5e240449SNicolas Belin #define MT6357_CCI_AUD_IDAC_TEST_EN_NORMAL_PATH		0
177*5e240449SNicolas Belin #define MT6357_CCI_ZERO_PADDING_DISABLE			BIT(5)
178*5e240449SNicolas Belin #define MT6357_CCI_ZERO_PADDING_ENABLE			0
179*5e240449SNicolas Belin #define MT6357_CCI_AUD_SPLIT_TEST_EN_FROM_TEST_IN	BIT(4)
180*5e240449SNicolas Belin #define MT6357_CCI_AUD_SPLIT_TEST_EN_NORMAL_PATH	0
181*5e240449SNicolas Belin #define MT6357_CCI_AUD_SDM_MUTE_L_REG_CTL		BIT(3)
182*5e240449SNicolas Belin #define MT6357_CCI_AUD_SDM_MUTE_L_NO_CTL		0
183*5e240449SNicolas Belin #define MT6357_CCI_AUD_SDM_MUTE_R_REG_CTL		BIT(2)
184*5e240449SNicolas Belin #define MT6357_CCI_AUD_SDM_MUTE_R_NO_CTL		0
185*5e240449SNicolas Belin #define MT6357_CCI_AUD_SDM_7BIT_FROM_SPLITTER3		BIT(1)
186*5e240449SNicolas Belin #define MT6357_CCI_AUD_SDM_7BIT_FROM_SPLITTER1		0
187*5e240449SNicolas Belin #define MT6357_CCI_SCRAMBLER_ENABLE			BIT(0)
188*5e240449SNicolas Belin #define MT6357_CCI_SCRAMBLER_DISABLE			0
189*5e240449SNicolas Belin 
190*5e240449SNicolas Belin /* MT6357_AFUNC_AUD_CON2 */
191*5e240449SNicolas Belin #define MT6357_CCI_AUDIO_FIFO_ENABLE		BIT(3)
192*5e240449SNicolas Belin #define MT6357_CCI_AUDIO_FIFO_DISABLE		0
193*5e240449SNicolas Belin #define MT6357_CCI_ACD_MODE_NORMAL_PATH		BIT(2)
194*5e240449SNicolas Belin #define MT6357_CCI_ACD_MODE_TEST_PATH		0
195*5e240449SNicolas Belin #define MT6357_CCI_AFIFO_CLK_PWDB_ON		BIT(1)
196*5e240449SNicolas Belin #define MT6357_CCI_AFIFO_CLK_PWDB_DOWN		0
197*5e240449SNicolas Belin #define MT6357_CCI_ACD_FUNC_RSTB_RELEASE	BIT(0)
198*5e240449SNicolas Belin #define MT6357_CCI_ACD_FUNC_RSTB_RESET		0
199*5e240449SNicolas Belin 
200*5e240449SNicolas Belin /* MT6357_AFE_ADDA_MTKAIF_CFG0 */
201*5e240449SNicolas Belin #define MT6357_ADDA_MTKAIF_LPBK_CTL_MASK	BIT(1)
202*5e240449SNicolas Belin #define MT6357_ADDA_MTKAIF_LPBK_ENABLE		BIT(1)
203*5e240449SNicolas Belin #define MT6357_ADDA_MTKAIF_LPBK_DISABLE		0
204*5e240449SNicolas Belin 
205*5e240449SNicolas Belin /* MT6357_AFE_SGEN_CFG0 */
206*5e240449SNicolas Belin #define MT6357_SGEN_DAC_EN_CTL_SFT		7
207*5e240449SNicolas Belin #define MT6357_SGEN_DAC_ENABLE			BIT(7)
208*5e240449SNicolas Belin #define MT6357_SGEN_MUTE_SW_CTL_SFT		6
209*5e240449SNicolas Belin #define MT6357_SGEN_MUTE_SW_DISABLE		0
210*5e240449SNicolas Belin 
211*5e240449SNicolas Belin /* MT6357_AFE_DCCLK_CFG0 */
212*5e240449SNicolas Belin #define MT6357_DCCLK_DIV_MASK			GENMASK(15, 5)
213*5e240449SNicolas Belin #define MT6357_DCCLK_DIV_SFT			5
214*5e240449SNicolas Belin #define MT6357_DCCLK_DIV_RUN_VALUE		(32 << MT6357_DCCLK_DIV_SFT)
215*5e240449SNicolas Belin #define MT6357_DCCLK_DIV_STOP_VALUE		(259 << MT6357_DCCLK_DIV_SFT)
216*5e240449SNicolas Belin #define MT6357_DCCLK_PDN_MASK			BIT(1)
217*5e240449SNicolas Belin #define MT6357_DCCLK_PDN			BIT(1)
218*5e240449SNicolas Belin #define MT6357_DCCLK_OUTPUT			0
219*5e240449SNicolas Belin #define MT6357_DCCLK_GEN_ON_MASK		BIT(0)
220*5e240449SNicolas Belin #define MT6357_DCCLK_GEN_ON			BIT(0)
221*5e240449SNicolas Belin #define MT6357_DCCLK_GEN_OFF			0
222*5e240449SNicolas Belin 
223*5e240449SNicolas Belin /* MT6357_AFE_DCCLK_CFG1 */
224*5e240449SNicolas Belin #define MT6357_DCCLK_RESYNC_BYPASS_MASK		BIT(8)
225*5e240449SNicolas Belin #define MT6357_DCCLK_RESYNC_BYPASS		BIT(8)
226*5e240449SNicolas Belin 
227*5e240449SNicolas Belin /* MT6357_AFE_AUD_PAD_TOP */
228*5e240449SNicolas Belin #define MT6357_AUD_PAD_TX_FIFO_NORMAL_PATH_MASK		GENMASK(15, 8)
229*5e240449SNicolas Belin #define MT6357_AUD_PAD_TX_FIFO_NORMAL_PATH_ENABLE	(BIT(13) | BIT(12) | BIT(8))
230*5e240449SNicolas Belin #define MT6357_AUD_PAD_TX_FIFO_NORMAL_PATH_DISABLE	(BIT(13) | BIT(12))
231*5e240449SNicolas Belin #define MT6357_AUD_PAD_TX_FIFO_LPBK_MASK		GENMASK(7, 0)
232*5e240449SNicolas Belin #define MT6357_AUD_PAD_TX_FIFO_LPBK_ENABLE		(BIT(5) | BIT(4) | BIT(0))
233*5e240449SNicolas Belin #define MT6357_AUD_PAD_TX_FIFO_LPBK_DISABLE		0
234*5e240449SNicolas Belin 
235*5e240449SNicolas Belin /* MT6357_AUDENC_ANA_CON0 */
236*5e240449SNicolas Belin #define MT6357_AUDADCLINPUTSEL_MASK		GENMASK(14, 13)
237*5e240449SNicolas Belin #define MT6357_AUDADCLINPUTSEL_PREAMPLIFIER	BIT(14)
238*5e240449SNicolas Belin #define MT6357_AUDADCLINPUTSEL_IDLE		0
239*5e240449SNicolas Belin #define MT6357_AUDADCLPWRUP_SFT			12
240*5e240449SNicolas Belin #define MT6357_AUDADCLPWRUP_MASK		BIT(12)
241*5e240449SNicolas Belin #define MT6357_AUDADCLPWRUP			BIT(12)
242*5e240449SNicolas Belin #define MT6357_AUDADCLPWRDOWN			0
243*5e240449SNicolas Belin #define MT6357_AUDPREAMPLGAIN_SFT		8
244*5e240449SNicolas Belin #define MT6357_AUDPREAMPLGAIN_MASK		GENMASK(10, 8)
245*5e240449SNicolas Belin #define MT6357_AUDPREAMPLGAIN_MAX		4
246*5e240449SNicolas Belin #define MT6357_AUDPREAMPLINPUTSEL_SFT		6
247*5e240449SNicolas Belin #define MT6357_AUDPREAMPLINPUTSEL_MASK_NOSFT	GENMASK(1, 0)
248*5e240449SNicolas Belin #define MT6357_AUDPREAMPLDCPRECHARGE_MASK	BIT(2)
249*5e240449SNicolas Belin #define MT6357_AUDPREAMPLDCPRECHARGE_ENABLE	BIT(2)
250*5e240449SNicolas Belin #define MT6357_AUDPREAMPLDCPRECHARGE_DISABLE	0
251*5e240449SNicolas Belin #define MT6357_AUDPREAMPLDCCEN_MASK		BIT(1)
252*5e240449SNicolas Belin #define MT6357_AUDPREAMPLDCCEN_DC		BIT(1)
253*5e240449SNicolas Belin #define MT6357_AUDPREAMPLDCCEN_AC		0
254*5e240449SNicolas Belin #define MT6357_AUDPREAMPLON_MASK		BIT(0)
255*5e240449SNicolas Belin #define MT6357_AUDPREAMPLON_ENABLE		BIT(0)
256*5e240449SNicolas Belin #define MT6357_AUDPREAMPLON_DISABLE		0
257*5e240449SNicolas Belin 
258*5e240449SNicolas Belin /* MT6357_AUDENC_ANA_CON1 */
259*5e240449SNicolas Belin #define MT6357_AUDADCRINPUTSEL_MASK		GENMASK(14, 13)
260*5e240449SNicolas Belin #define MT6357_AUDADCRINPUTSEL_PREAMPLIFIER	BIT(14)
261*5e240449SNicolas Belin #define MT6357_AUDADCRINPUTSEL_IDLE		0
262*5e240449SNicolas Belin #define MT6357_AUDADCRPWRUP_SFT			12
263*5e240449SNicolas Belin #define MT6357_AUDADCRPWRUP_MASK		BIT(12)
264*5e240449SNicolas Belin #define MT6357_AUDADCRPWRUP			BIT(12)
265*5e240449SNicolas Belin #define MT6357_AUDADCRPWRDOWN			0
266*5e240449SNicolas Belin #define MT6357_AUDPREAMPRGAIN_SFT		8
267*5e240449SNicolas Belin #define MT6357_AUDPREAMPRGAIN_MASK		GENMASK(10, 8)
268*5e240449SNicolas Belin #define MT6357_AUDPREAMPRGAIN_MAX		4
269*5e240449SNicolas Belin #define MT6357_AUDPREAMPRINPUTSEL_SFT		6
270*5e240449SNicolas Belin #define MT6357_AUDPREAMPRINPUTSEL_MASK_NOSFT	GENMASK(1, 0)
271*5e240449SNicolas Belin #define MT6357_AUDPREAMPRDCPRECHARGE_MASK	BIT(2)
272*5e240449SNicolas Belin #define MT6357_AUDPREAMPRDCPRECHARGE_ENABLE	BIT(2)
273*5e240449SNicolas Belin #define MT6357_AUDPREAMPRDCPRECHARGE_DISABLE	0
274*5e240449SNicolas Belin #define MT6357_AUDPREAMPRDCCEN_MASK		BIT(1)
275*5e240449SNicolas Belin #define MT6357_AUDPREAMPRDCCEN_DC		BIT(1)
276*5e240449SNicolas Belin #define MT6357_AUDPREAMPRDCCEN_AC		0
277*5e240449SNicolas Belin #define MT6357_AUDPREAMPRON_MASK		BIT(0)
278*5e240449SNicolas Belin #define MT6357_AUDPREAMPRON_ENABLE		BIT(0)
279*5e240449SNicolas Belin #define MT6357_AUDPREAMPRON_DISABLE		0
280*5e240449SNicolas Belin 
281*5e240449SNicolas Belin /* MT6357_AUDENC_ANA_CON6 */
282*5e240449SNicolas Belin #define MT6357_CLKSQ_EN_SFT			0
283*5e240449SNicolas Belin 
284*5e240449SNicolas Belin /* MT6357_AUDENC_ANA_CON7 */
285*5e240449SNicolas Belin #define MT6357_AUDDIGMICBIAS_MASK		GENMASK(2, 1)
286*5e240449SNicolas Belin #define MT6357_AUDDIGMICBIAS_DEFAULT_VALUE	BIT(2)
287*5e240449SNicolas Belin #define MT6357_AUDDIGMICBIAS_OFF		0
288*5e240449SNicolas Belin #define MT6357_AUDDIGMICEN_MASK			BIT(0)
289*5e240449SNicolas Belin #define MT6357_AUDDIGMICEN_ENABLE		BIT(0)
290*5e240449SNicolas Belin #define MT6357_AUDDIGMICEN_DISABLE		0
291*5e240449SNicolas Belin 
292*5e240449SNicolas Belin /* MT6357_AUDENC_ANA_CON8 */
293*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2N_EN_MASK	BIT(14)
294*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2N_ENABLE	BIT(14)
295*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2N_DISABLE	0
296*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2P2_EN_MASK	BIT(13)
297*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2P2_ENABLE	BIT(13)
298*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2P2_DISABLE	0
299*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2P1_EN_MASK	BIT(12)
300*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2P1_ENABLE	BIT(12)
301*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW2P1_DISABLE	0
302*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW0N_EN_MASK	BIT(10)
303*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW0N_ENABLE	BIT(10)
304*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSWN_DISABLE	0
305*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW0P2_EN_MASK	BIT(9)
306*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW0P2_ENABLE	BIT(9)
307*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW0P2_DISABLE	0
308*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW0P1_EN_MASK	BIT(8)
309*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW0P1_ENABLE	BIT(8)
310*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DCSW0P1_DISABLE	0
311*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_VREF_MASK		GENMASK(6, 4)
312*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_VREF_SFT		4
313*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_PWD_SFT		0
314*5e240449SNicolas Belin 
315*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DC_MASK		(MT6357_AUD_MICBIAS0_DCSW2N_EN_MASK | \
316*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW2P2_EN_MASK | \
317*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW2P1_EN_MASK | \
318*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW0N_EN_MASK | \
319*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW0P2_EN_MASK | \
320*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW0P1_EN_MASK)
321*5e240449SNicolas Belin 
322*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DC_ENABLE_ALL	(MT6357_AUD_MICBIAS0_DCSW2N_ENABLE | \
323*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW2P2_ENABLE | \
324*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW2P1_ENABLE | \
325*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW0N_ENABLE | \
326*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW0P2_ENABLE | \
327*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW0P1_ENABLE)
328*5e240449SNicolas Belin 
329*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DC_ENABLE_P1	(MT6357_AUD_MICBIAS0_DCSW2P1_ENABLE | \
330*5e240449SNicolas Belin 						 MT6357_AUD_MICBIAS0_DCSW0P1_ENABLE)
331*5e240449SNicolas Belin 
332*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS0_DC_DISABLE_ALL	0
333*5e240449SNicolas Belin 
334*5e240449SNicolas Belin /* MT6357_AUDENC_ANA_CON9 */
335*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS1_DCSW1P_EN_MASK	BIT(8)
336*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS1_DCSW1P_ENABLE	BIT(8)
337*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS1_DCSW1P_DISABLE	0
338*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS1_VREF_MASK		GENMASK(6, 4)
339*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS1_VREF_SFT		4
340*5e240449SNicolas Belin #define MT6357_AUD_MICBIAS1_PWD_SFT		0
341*5e240449SNicolas Belin 
342*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON0 */
343*5e240449SNicolas Belin #define MT6357_AUD_HPR_SC_VAUDP15_MASK			BIT(13)
344*5e240449SNicolas Belin #define MT6357_AUD_HPR_SC_VAUDP15_DISABLE		BIT(13)
345*5e240449SNicolas Belin #define MT6357_AUD_HPR_SC_VAUDP15_ENABLE		0
346*5e240449SNicolas Belin #define MT6357_AUD_HPL_SC_VAUDP15_MASK			BIT(12)
347*5e240449SNicolas Belin #define MT6357_AUD_HPL_SC_VAUDP15_DISABLE		BIT(12)
348*5e240449SNicolas Belin #define MT6357_AUD_HPL_SC_VAUDP15_ENABLE		0
349*5e240449SNicolas Belin #define MT6357_AUD_HPR_MUX_INPUT_VAUDP15_MASK_NOSFT	GENMASK(1, 0)
350*5e240449SNicolas Belin #define MT6357_AUD_HPR_MUX_INPUT_VAUDP15_SFT		10
351*5e240449SNicolas Belin #define MT6357_AUD_HPL_MUX_INPUT_VAUDP15_MASK_NOSFT	GENMASK(1, 0)
352*5e240449SNicolas Belin #define MT6357_AUD_HPL_MUX_INPUT_VAUDP15_SFT		8
353*5e240449SNicolas Belin #define MT6357_AUD_HPR_BIAS_VAUDP15_MASK		BIT(7)
354*5e240449SNicolas Belin #define MT6357_AUD_HPR_BIAS_VAUDP15_ENABLE		BIT(7)
355*5e240449SNicolas Belin #define MT6357_AUD_HPR_BIAS_VAUDP15_DISABLE		0
356*5e240449SNicolas Belin #define MT6357_AUD_HPL_BIAS_VAUDP15_MASK		BIT(6)
357*5e240449SNicolas Belin #define MT6357_AUD_HPL_BIAS_VAUDP15_ENABLE		BIT(6)
358*5e240449SNicolas Belin #define MT6357_AUD_HPL_BIAS_VAUDP15_DISABLE		0
359*5e240449SNicolas Belin #define MT6357_AUD_HPR_PWRUP_VAUDP15_MASK		BIT(5)
360*5e240449SNicolas Belin #define MT6357_AUD_HPR_PWRUP_VAUDP15_ENABLE		BIT(5)
361*5e240449SNicolas Belin #define MT6357_AUD_HPR_PWRUP_VAUDP15_DISABLE		0
362*5e240449SNicolas Belin #define MT6357_AUD_HPL_PWRUP_VAUDP15_MASK		BIT(4)
363*5e240449SNicolas Belin #define MT6357_AUD_HPL_PWRUP_VAUDP15_ENABLE		BIT(4)
364*5e240449SNicolas Belin #define MT6357_AUD_HPL_PWRUP_VAUDP15_DISABLE		0
365*5e240449SNicolas Belin #define MT6357_AUD_DACL_PWRUP_VA28_MASK			BIT(3)
366*5e240449SNicolas Belin #define MT6357_AUD_DACL_PWRUP_VA28_ENABLE		BIT(3)
367*5e240449SNicolas Belin #define MT6357_AUD_DACL_PWRUP_VA28_DISABLE		0
368*5e240449SNicolas Belin #define MT6357_AUD_DACR_PWRUP_VA28_MASK			BIT(2)
369*5e240449SNicolas Belin #define MT6357_AUD_DACR_PWRUP_VA28_ENABLE		BIT(2)
370*5e240449SNicolas Belin #define MT6357_AUD_DACR_PWRUP_VA28_DISABLE		0
371*5e240449SNicolas Belin #define MT6357_AUD_DACR_PWRUP_VAUDP15_MASK		BIT(1)
372*5e240449SNicolas Belin #define MT6357_AUD_DACR_PWRUP_VAUDP15_ENABLE		BIT(1)
373*5e240449SNicolas Belin #define MT6357_AUD_DACR_PWRUP_VAUDP15_DISABLE		0
374*5e240449SNicolas Belin #define MT6357_AUD_DACL_PWRUP_VAUDP15_MASK		BIT(0)
375*5e240449SNicolas Belin #define MT6357_AUD_DACL_PWRUP_VAUDP15_ENABLE		BIT(0)
376*5e240449SNicolas Belin #define MT6357_AUD_DACL_PWRUP_VAUDP15_DISABLE		0
377*5e240449SNicolas Belin 
378*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON1 */
379*5e240449SNicolas Belin #define MT6357_HPROUT_STG_CTRL_VAUDP15_MASK		GENMASK(14, 12)
380*5e240449SNicolas Belin #define MT6357_HPROUT_STG_CTRL_VAUDP15_SFT		12
381*5e240449SNicolas Belin #define MT6357_HPLOUT_STG_CTRL_VAUDP15_MASK		GENMASK(10, 8)
382*5e240449SNicolas Belin #define MT6357_HPLOUT_STG_CTRL_VAUDP15_SFT		8
383*5e240449SNicolas Belin #define MT6357_HPLOUT_STG_CTRL_VAUDP15_MAX		7
384*5e240449SNicolas Belin #define MT6357_HPR_SHORT2HPR_AUX_VAUDP15_MASK		BIT(7)
385*5e240449SNicolas Belin #define MT6357_HPR_SHORT2HPR_AUX_VAUDP15_ENABLE		BIT(7)
386*5e240449SNicolas Belin #define MT6357_HPR_SHORT2HPR_AUX_VAUDP15_DISABLE	0
387*5e240449SNicolas Belin #define MT6357_HPL_SHORT2HPR_AUX_VAUDP15_MASK		BIT(6)
388*5e240449SNicolas Belin #define MT6357_HPL_SHORT2HPR_AUX_VAUDP15_ENABLE		BIT(6)
389*5e240449SNicolas Belin #define MT6357_HPL_SHORT2HPR_AUX_VAUDP15_DISABLE	0
390*5e240449SNicolas Belin #define MT6357_HPR_AUX_FBRSW_VAUDP15_MASK		BIT(5)
391*5e240449SNicolas Belin #define MT6357_HPR_AUX_FBRSW_VAUDP15_ENABLE		BIT(5)
392*5e240449SNicolas Belin #define MT6357_HPR_AUX_FBRSW_VAUDP15_DISABLE		0
393*5e240449SNicolas Belin #define MT6357_HPL_AUX_FBRSW_VAUDP15_MASK		BIT(4)
394*5e240449SNicolas Belin #define MT6357_HPL_AUX_FBRSW_VAUDP15_ENABLE		BIT(4)
395*5e240449SNicolas Belin #define MT6357_HPL_AUX_FBRSW_VAUDP15_DISABLE		0
396*5e240449SNicolas Belin #define MT6357_HPROUT_AUX_PWRUP_VAUDP15_MASK		BIT(3)
397*5e240449SNicolas Belin #define MT6357_HPROUT_AUX_PWRUP_VAUDP15_ENABLE		BIT(3)
398*5e240449SNicolas Belin #define MT6357_HPROUT_AUX_PWRUP_VAUDP15_DISABLE	0
399*5e240449SNicolas Belin #define MT6357_HPLOUT_AUX_PWRUP_VAUDP15_MASK		BIT(2)
400*5e240449SNicolas Belin #define MT6357_HPLOUT_AUX_PWRUP_VAUDP15_ENABLE		BIT(2)
401*5e240449SNicolas Belin #define MT6357_HPLOUT_AUX_PWRUP_VAUDP15_DISABLE	0
402*5e240449SNicolas Belin #define MT6357_HPROUT_PWRUP_VAUDP15_MASK		BIT(1)
403*5e240449SNicolas Belin #define MT6357_HPROUT_PWRUP_VAUDP15_ENABLE		BIT(1)
404*5e240449SNicolas Belin #define MT6357_HPROUT_PWRUP_VAUDP15_DISABLE		0
405*5e240449SNicolas Belin #define MT6357_HPLOUT_PWRUP_VAUDP15_MASK		BIT(0)
406*5e240449SNicolas Belin #define MT6357_HPLOUT_PWRUP_VAUDP15_ENABLE		BIT(0)
407*5e240449SNicolas Belin #define MT6357_HPLOUT_PWRUP_VAUDP15_DISABLE		0
408*5e240449SNicolas Belin 
409*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON2 */
410*5e240449SNicolas Belin #define MT6357_HPP_SHORT_2VCM_VAUDP15_MASK		BIT(10)
411*5e240449SNicolas Belin #define MT6357_HPP_SHORT_2VCM_VAUDP15_ENABLE		BIT(10)
412*5e240449SNicolas Belin #define MT6357_HPP_SHORT_2VCM_VAUDP15_DISABLE		0
413*5e240449SNicolas Belin #define MT6357_AUD_REFN_DERES_VAUDP15_MASK		BIT(9)
414*5e240449SNicolas Belin #define MT6357_AUD_REFN_DERES_VAUDP15_ENABLE		BIT(9)
415*5e240449SNicolas Belin #define MT6357_AUD_REFN_DERES_VAUDP15_DISABLE		0
416*5e240449SNicolas Belin #define MT6357_HPROUT_STB_ENH_VAUDP15_MASK		GENMASK(6, 4)
417*5e240449SNicolas Belin #define MT6357_HPROUT_STB_ENH_VAUDP15_OPEN		0
418*5e240449SNicolas Belin #define MT6357_HPROUT_STB_ENH_VAUDP15_NOPEN_P250	BIT(4)
419*5e240449SNicolas Belin #define MT6357_HPROUT_STB_ENH_VAUDP15_N470_POPEN	BIT(5)
420*5e240449SNicolas Belin #define MT6357_HPROUT_STB_ENH_VAUDP15_N470_P250		(BIT(4) | BIT(5))
421*5e240449SNicolas Belin #define MT6357_HPROUT_STB_ENH_VAUDP15_NOPEN_P470	(BIT(4) | BIT(6))
422*5e240449SNicolas Belin #define MT6357_HPROUT_STB_ENH_VAUDP15_N470_P470		(BIT(4) | BIT(5) | BIT(6))
423*5e240449SNicolas Belin #define MT6357_HPLOUT_STB_ENH_VAUDP15_MASK		GENMASK(2, 0)
424*5e240449SNicolas Belin #define MT6357_HPLOUT_STB_ENH_VAUDP15_OPEN		0
425*5e240449SNicolas Belin #define MT6357_HPLOUT_STB_ENH_VAUDP15_NOPEN_P250	BIT(0)
426*5e240449SNicolas Belin #define MT6357_HPLOUT_STB_ENH_VAUDP15_N470_POPEN	BIT(1)
427*5e240449SNicolas Belin #define MT6357_HPLOUT_STB_ENH_VAUDP15_N470_P250		(BIT(0) | BIT(1))
428*5e240449SNicolas Belin #define MT6357_HPLOUT_STB_ENH_VAUDP15_NOPEN_P470	(BIT(0) | BIT(2))
429*5e240449SNicolas Belin #define MT6357_HPLOUT_STB_ENH_VAUDP15_N470_P470		(BIT(0) | BIT(1) | BIT(2))
430*5e240449SNicolas Belin 
431*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON3 */
432*5e240449SNicolas Belin #define MT6357_AUD_HSOUT_STB_ENH_VAUDP15_MASK		BIT(7)
433*5e240449SNicolas Belin #define MT6357_AUD_HSOUT_STB_ENH_VAUDP15_ENABLE		BIT(7)
434*5e240449SNicolas Belin #define MT6357_AUD_HSOUT_STB_ENH_VAUDP15_DISABLE	0
435*5e240449SNicolas Belin #define MT6357_AUD_HS_SC_VAUDP15_MASK			BIT(4)
436*5e240449SNicolas Belin #define MT6357_AUD_HS_SC_VAUDP15_DISABLE		BIT(4)
437*5e240449SNicolas Belin #define MT6357_AUD_HS_SC_VAUDP15_ENABLE			0
438*5e240449SNicolas Belin #define MT6357_AUD_HS_MUX_INPUT_VAUDP15_MASK_NOSFT	GENMASK(1, 0)
439*5e240449SNicolas Belin #define MT6357_AUD_HS_MUX_INPUT_VAUDP15_SFT		2
440*5e240449SNicolas Belin #define MT6357_AUD_HS_PWRUP_BIAS_VAUDP15_MASK		BIT(1)
441*5e240449SNicolas Belin #define MT6357_AUD_HS_PWRUP_BIAS_VAUDP15_ENABLE		BIT(1)
442*5e240449SNicolas Belin #define MT6357_AUD_HS_PWRUP_BIAS_VAUDP15_DISABLE	0
443*5e240449SNicolas Belin #define MT6357_AUD_HS_PWRUP_VAUDP15_MASK		BIT(0)
444*5e240449SNicolas Belin #define MT6357_AUD_HS_PWRUP_VAUDP15_ENABLE		BIT(0)
445*5e240449SNicolas Belin #define MT6357_AUD_HS_PWRUP_VAUDP15_DISABLE		0
446*5e240449SNicolas Belin 
447*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON4 */
448*5e240449SNicolas Belin #define MT6357_AUD_LOLOUT_STB_ENH_VAUDP15_MASK		BIT(8)
449*5e240449SNicolas Belin #define MT6357_AUD_LOLOUT_STB_ENH_VAUDP15_ENABLE	BIT(8)
450*5e240449SNicolas Belin #define MT6357_AUD_LOLOUT_STB_ENH_VAUDP15_DISABLE	0
451*5e240449SNicolas Belin #define MT6357_AUD_LOL_SC_VAUDP15_MASK			BIT(4)
452*5e240449SNicolas Belin #define MT6357_AUD_LOL_SC_VAUDP15_DISABLE		BIT(4)
453*5e240449SNicolas Belin #define MT6357_AUD_LOL_SC_VAUDP15_ENABLE		0
454*5e240449SNicolas Belin #define MT6357_AUD_LOL_MUX_INPUT_VAUDP15_MASK_NOSFT	GENMASK(1, 0)
455*5e240449SNicolas Belin #define MT6357_AUD_LOL_MUX_INPUT_VAUDP15_SFT		2
456*5e240449SNicolas Belin #define MT6357_AUD_LOL_PWRUP_BIAS_VAUDP15_MASK		BIT(1)
457*5e240449SNicolas Belin #define MT6357_AUD_LOL_PWRUP_BIAS_VAUDP15_ENABLE	BIT(1)
458*5e240449SNicolas Belin #define MT6357_AUD_LOL_PWRUP_BIAS_VAUDP15_DISABLE	0
459*5e240449SNicolas Belin #define MT6357_AUD_LOL_PWRUP_VAUDP15_MASK		BIT(0)
460*5e240449SNicolas Belin #define MT6357_AUD_LOL_PWRUP_VAUDP15_ENABLE		BIT(0)
461*5e240449SNicolas Belin #define MT6357_AUD_LOL_PWRUP_VAUDP15_DISABLE		0
462*5e240449SNicolas Belin 
463*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON6 */
464*5e240449SNicolas Belin #define MT6357_HP_AUX_LOOP_GAIN_MASK		GENMASK(15, 12)
465*5e240449SNicolas Belin #define MT6357_HP_AUX_LOOP_GAIN_SFT		12
466*5e240449SNicolas Belin #define MT6357_HP_AUX_LOOP_GAIN_MAX		0x0f
467*5e240449SNicolas Belin #define MT6357_HPR_AUX_CMFB_LOOP_MASK		BIT(11)
468*5e240449SNicolas Belin #define MT6357_HPR_AUX_CMFB_LOOP_ENABLE		BIT(11)
469*5e240449SNicolas Belin #define MT6357_HPR_AUX_CMFB_LOOP_DISABLE	0
470*5e240449SNicolas Belin #define MT6357_HPL_AUX_CMFB_LOOP_MASK		BIT(10)
471*5e240449SNicolas Belin #define MT6357_HPL_AUX_CMFB_LOOP_ENABLE		BIT(10)
472*5e240449SNicolas Belin #define MT6357_HPL_AUX_CMFB_LOOP_DISABLE	0
473*5e240449SNicolas Belin #define MT6357_HPRL_MAIN_CMFB_LOOP_MASK		BIT(9)
474*5e240449SNicolas Belin #define MT6357_HPRL_MAIN_CMFB_LOOP_ENABLE	BIT(9)
475*5e240449SNicolas Belin #define MT6357_HPRL_MAIN_CMFB_LOOP_DISABLE	0
476*5e240449SNicolas Belin #define MT6357_HP_CMFB_RST_MASK			BIT(7)
477*5e240449SNicolas Belin #define MT6357_HP_CMFB_RST_NORMAL		BIT(7)
478*5e240449SNicolas Belin #define MT6357_HP_CMFB_RST_RESET		0
479*5e240449SNicolas Belin #define MT6357_DAC_LOW_NOISE_MODE_MASK		BIT(0)
480*5e240449SNicolas Belin #define MT6357_DAC_LOW_NOISE_MODE_ENABLE	BIT(0)
481*5e240449SNicolas Belin #define MT6357_DAC_LOW_NOISE_MODE_DISABLE	0
482*5e240449SNicolas Belin 
483*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON7 */
484*5e240449SNicolas Belin #define MT6357_HP_IVBUF_DEGAIN_SFT		2
485*5e240449SNicolas Belin #define MT6357_HP_IVBUF_DEGAIN_MAX		1
486*5e240449SNicolas Belin 
487*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON10 */
488*5e240449SNicolas Belin #define MT6357_AUD_IBIAS_PWRDN_VAUDP15_MASK	BIT(8)
489*5e240449SNicolas Belin #define MT6357_AUD_IBIAS_PWRDN_VAUDP15_DISABLE	BIT(8)
490*5e240449SNicolas Belin #define MT6357_AUD_IBIAS_PWRDN_VAUDP15_ENABLE	0
491*5e240449SNicolas Belin 
492*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON11 */
493*5e240449SNicolas Belin #define MT6357_RSTB_ENCODER_VA28_MASK		BIT(5)
494*5e240449SNicolas Belin #define MT6357_RSTB_ENCODER_VA28_ENABLE		BIT(5)
495*5e240449SNicolas Belin #define MT6357_RSTB_ENCODER_VA28_DISABLE	0
496*5e240449SNicolas Belin #define MT6357_AUDGLB_PWRDN_VA28_SFT		4
497*5e240449SNicolas Belin #define MT6357_RSTB_DECODER_VA28_MASK		BIT(0)
498*5e240449SNicolas Belin #define MT6357_RSTB_DECODER_VA28_ENABLE		BIT(0)
499*5e240449SNicolas Belin #define MT6357_RSTB_DECODER_VA28_DISABLE	0
500*5e240449SNicolas Belin 
501*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON12 */
502*5e240449SNicolas Belin #define MT6357_VA28REFGEN_EN_VA28_MASK			BIT(13)
503*5e240449SNicolas Belin #define MT6357_VA28REFGEN_EN_VA28_ENABLE		BIT(13)
504*5e240449SNicolas Belin #define MT6357_VA28REFGEN_EN_VA28_DISABLE		0
505*5e240449SNicolas Belin #define MT6357_VA33REFGEN_EN_VA18_MASK			BIT(12)
506*5e240449SNicolas Belin #define MT6357_VA33REFGEN_EN_VA18_ENABLE		BIT(12)
507*5e240449SNicolas Belin #define MT6357_VA33REFGEN_EN_VA18_DISABLE		0
508*5e240449SNicolas Belin #define MT6357_LCLDO_ENC_REMOTE_SENSE_VA28_MASK		BIT(10)
509*5e240449SNicolas Belin #define MT6357_LCLDO_ENC_REMOTE_SENSE_VA28_ENABLE	BIT(10)
510*5e240449SNicolas Belin #define MT6357_LCLDO_ENC_REMOTE_SENSE_VA28_DISABLE	0
511*5e240449SNicolas Belin #define MT6357_LCLDO_ENC_EN_VA28_MASK			BIT(8)
512*5e240449SNicolas Belin #define MT6357_LCLDO_ENC_EN_VA28_ENABLE			BIT(8)
513*5e240449SNicolas Belin #define MT6357_LCLDO_ENC_EN_VA28_DISABLE		0
514*5e240449SNicolas Belin #define MT6357_LCLDO_REMOTE_SENSE_VA18_MASK		BIT(6)
515*5e240449SNicolas Belin #define MT6357_LCLDO_REMOTE_SENSE_VA18_ENABLE		BIT(6)
516*5e240449SNicolas Belin #define MT6357_LCLDO_REMOTE_SENSE_VA18_DISABLE		0
517*5e240449SNicolas Belin #define MT6357_LCLDO_EN_VA18_MASK			BIT(4)
518*5e240449SNicolas Belin #define MT6357_LCLDO_EN_VA18_ENABLE			BIT(4)
519*5e240449SNicolas Belin #define MT6357_LCLDO_EN_VA18_DISABLE			0
520*5e240449SNicolas Belin #define MT6357_HCLDO_REMOTE_SENSE_VA18_MASK		BIT(2)
521*5e240449SNicolas Belin #define MT6357_HCLDO_REMOTE_SENSE_VA18_ENABLE		BIT(2)
522*5e240449SNicolas Belin #define MT6357_HCLDO_REMOTE_SENSE_VA18_DISABLE		0
523*5e240449SNicolas Belin #define MT6357_HCLDO_EN_VA18_MASK			BIT(0)
524*5e240449SNicolas Belin #define MT6357_HCLDO_EN_VA18_ENABLE			BIT(0)
525*5e240449SNicolas Belin #define MT6357_HCLDO_EN_VA18_DISABLE			0
526*5e240449SNicolas Belin 
527*5e240449SNicolas Belin /* MT6357_AUDDEC_ANA_CON13 */
528*5e240449SNicolas Belin #define MT6357_NVREG_EN_VAUDP15_MASK		BIT(0)
529*5e240449SNicolas Belin #define MT6357_NVREG_EN_VAUDP15_ENABLE		BIT(0)
530*5e240449SNicolas Belin #define MT6357_NVREG_EN_VAUDP15_DISABLE		0
531*5e240449SNicolas Belin 
532*5e240449SNicolas Belin /* MT6357_AUDDEC_ELR_0 */
533*5e240449SNicolas Belin #define MT6357_AUD_HP_TRIM_EN_VAUDP15_MASK	BIT(12)
534*5e240449SNicolas Belin #define MT6357_AUD_HP_TRIM_EN_VAUDP15_ENABLE	BIT(12)
535*5e240449SNicolas Belin #define MT6357_AUD_HP_TRIM_EN_VAUDP15_DISABLE	0
536*5e240449SNicolas Belin 
537*5e240449SNicolas Belin /* MT6357_ZCD_CON1 */
538*5e240449SNicolas Belin #define MT6357_AUD_LOL_GAIN_MASK		GENMASK(4, 0)
539*5e240449SNicolas Belin #define MT6357_AUD_LOL_GAIN_SFT			0
540*5e240449SNicolas Belin #define MT6357_AUD_LOR_GAIN_MASK		GENMASK(11, 7)
541*5e240449SNicolas Belin #define MT6357_AUD_LOR_GAIN_SFT			7
542*5e240449SNicolas Belin #define MT6357_AUD_LO_GAIN_MAX			0x12
543*5e240449SNicolas Belin 
544*5e240449SNicolas Belin /* MT6357_ZCD_CON2 */
545*5e240449SNicolas Belin #define MT6357_AUD_HPL_GAIN_MASK		GENMASK(4, 0)
546*5e240449SNicolas Belin #define MT6357_AUD_HPL_GAIN_SFT			0
547*5e240449SNicolas Belin #define MT6357_AUD_HPR_GAIN_MASK		GENMASK(11, 7)
548*5e240449SNicolas Belin #define MT6357_AUD_HPR_GAIN_SFT			7
549*5e240449SNicolas Belin #define MT6357_AUD_HP_GAIN_MAX			0x12
550*5e240449SNicolas Belin 
551*5e240449SNicolas Belin /* MT6357_ZCD_CON3 */
552*5e240449SNicolas Belin #define MT6357_AUD_HS_GAIN_MASK			GENMASK(4, 0)
553*5e240449SNicolas Belin #define MT6357_AUD_HS_GAIN_SFT			0
554*5e240449SNicolas Belin #define MT6357_AUD_HS_GAIN_MAX			0x12
555*5e240449SNicolas Belin 
556*5e240449SNicolas Belin /* Registers list */
557*5e240449SNicolas Belin /* gpio direction */
558*5e240449SNicolas Belin #define MT6357_GPIO_DIR0			0x0088
559*5e240449SNicolas Belin /* mosi */
560*5e240449SNicolas Belin #define MT6357_GPIO_MODE2			0x00B6
561*5e240449SNicolas Belin #define MT6357_GPIO_MODE2_SET			0x00B8
562*5e240449SNicolas Belin #define MT6357_GPIO_MODE2_CLR			0x00BA
563*5e240449SNicolas Belin /* miso */
564*5e240449SNicolas Belin #define MT6357_GPIO_MODE3			0x00BC
565*5e240449SNicolas Belin #define MT6357_GPIO_MODE3_SET			0x00BE
566*5e240449SNicolas Belin #define MT6357_GPIO_MODE3_CLR			0x00C0
567*5e240449SNicolas Belin 
568*5e240449SNicolas Belin #define MT6357_DCXO_CW14			0x07AC
569*5e240449SNicolas Belin 
570*5e240449SNicolas Belin #define MT6357_AUD_TOP_CKPDN_CON0		0x208C
571*5e240449SNicolas Belin #define MT6357_AUDNCP_CLKDIV_CON0		0x20B4
572*5e240449SNicolas Belin #define MT6357_AUDNCP_CLKDIV_CON1		0x20B6
573*5e240449SNicolas Belin #define MT6357_AUDNCP_CLKDIV_CON2		0x20B8
574*5e240449SNicolas Belin #define MT6357_AUDNCP_CLKDIV_CON3		0x20BA
575*5e240449SNicolas Belin #define MT6357_AUDNCP_CLKDIV_CON4		0x20BC
576*5e240449SNicolas Belin #define MT6357_AFE_UL_DL_CON0			0x2108
577*5e240449SNicolas Belin #define MT6357_AFE_DL_SRC2_CON0_L		0x210A
578*5e240449SNicolas Belin #define MT6357_AFE_UL_SRC_CON0_H		0x210C
579*5e240449SNicolas Belin #define MT6357_AFE_UL_SRC_CON0_L		0x210E
580*5e240449SNicolas Belin #define MT6357_AFE_TOP_CON0			0x2110
581*5e240449SNicolas Belin #define MT6357_AUDIO_TOP_CON0			0x2112
582*5e240449SNicolas Belin #define MT6357_AFUNC_AUD_CON0			0x2116
583*5e240449SNicolas Belin #define MT6357_AFUNC_AUD_CON2			0x211A
584*5e240449SNicolas Belin #define MT6357_AFE_ADDA_MTKAIF_CFG0		0x2134
585*5e240449SNicolas Belin #define MT6357_AFE_SGEN_CFG0			0x2140
586*5e240449SNicolas Belin #define MT6357_AFE_DCCLK_CFG0			0x2146
587*5e240449SNicolas Belin #define MT6357_AFE_DCCLK_CFG1			0x2148
588*5e240449SNicolas Belin #define MT6357_AFE_AUD_PAD_TOP			0x214C
589*5e240449SNicolas Belin #define MT6357_AUDENC_ANA_CON0			0x2188
590*5e240449SNicolas Belin #define MT6357_AUDENC_ANA_CON1			0x218A
591*5e240449SNicolas Belin #define MT6357_AUDENC_ANA_CON6			0x2194
592*5e240449SNicolas Belin #define MT6357_AUDENC_ANA_CON7			0x2196
593*5e240449SNicolas Belin #define MT6357_AUDENC_ANA_CON8			0x2198
594*5e240449SNicolas Belin #define MT6357_AUDENC_ANA_CON9			0x219A
595*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON0			0x2208
596*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON1			0x220A
597*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON2			0x220C
598*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON3			0x220E
599*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON4			0x2210
600*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON6			0x2214
601*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON7			0x2216
602*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON10			0x221C
603*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON11			0x221E
604*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON12			0x2220
605*5e240449SNicolas Belin #define MT6357_AUDDEC_ANA_CON13			0x2222
606*5e240449SNicolas Belin #define MT6357_AUDDEC_ELR_0			0x2226
607*5e240449SNicolas Belin #define MT6357_ZCD_CON1				0x228A
608*5e240449SNicolas Belin #define MT6357_ZCD_CON2				0x228C
609*5e240449SNicolas Belin #define MT6357_ZCD_CON3				0x228E
610*5e240449SNicolas Belin 
611*5e240449SNicolas Belin enum {
612*5e240449SNicolas Belin 	DL_GAIN_8DB = 0,
613*5e240449SNicolas Belin 	DL_GAIN_0DB = 8,
614*5e240449SNicolas Belin 	DL_GAIN_N_1DB = 9,
615*5e240449SNicolas Belin 	DL_GAIN_N_10DB = 18,
616*5e240449SNicolas Belin 	DL_GAIN_N_12DB = 20,
617*5e240449SNicolas Belin 	DL_GAIN_N_40DB = 0x1f,
618*5e240449SNicolas Belin };
619*5e240449SNicolas Belin 
620*5e240449SNicolas Belin enum {
621*5e240449SNicolas Belin 	UL_GAIN_0DB = 0,
622*5e240449SNicolas Belin 	UL_GAIN_6DB,
623*5e240449SNicolas Belin 	UL_GAIN_12DB,
624*5e240449SNicolas Belin 	UL_GAIN_18DB,
625*5e240449SNicolas Belin 	UL_GAIN_24DB,
626*5e240449SNicolas Belin };
627*5e240449SNicolas Belin 
628*5e240449SNicolas Belin #define MT6357_DL_GAIN_N_40DB_REG		(DL_GAIN_N_40DB << 7 | DL_GAIN_N_40DB)
629*5e240449SNicolas Belin #define MT6357_DL_GAIN_REG_LEFT_MASK		0x001f
630*5e240449SNicolas Belin #define MT6357_DL_GAIN_REG_LEFT_SHIFT		0
631*5e240449SNicolas Belin #define MT6357_DL_GAIN_REG_RIGHT_MASK		0x0f80
632*5e240449SNicolas Belin #define MT6357_DL_GAIN_REG_RIGHT_SHIFT		7
633*5e240449SNicolas Belin #define MT6357_DL_GAIN_REG_MASK			0x0f9f
634*5e240449SNicolas Belin 
635*5e240449SNicolas Belin #define MT6357_SND_SOC_ADV_MT_FMTS (\
636*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_S16_LE |\
637*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_S16_BE |\
638*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_U16_LE |\
639*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_U16_BE |\
640*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_S24_LE |\
641*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_S24_BE |\
642*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_U24_LE |\
643*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_U24_BE |\
644*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_S32_LE |\
645*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_S32_BE |\
646*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_U32_LE |\
647*5e240449SNicolas Belin 				SNDRV_PCM_FMTBIT_U32_BE)
648*5e240449SNicolas Belin 
649*5e240449SNicolas Belin #define MT6357_SOC_HIGH_USE_RATE (\
650*5e240449SNicolas Belin 				SNDRV_PCM_RATE_CONTINUOUS |\
651*5e240449SNicolas Belin 				SNDRV_PCM_RATE_8000_192000)
652*5e240449SNicolas Belin 
653*5e240449SNicolas Belin /* codec private structure */
654*5e240449SNicolas Belin struct mt6357_priv {
655*5e240449SNicolas Belin 	struct device *dev;
656*5e240449SNicolas Belin 	struct regmap *regmap;
657*5e240449SNicolas Belin 	bool pull_down_needed;
658*5e240449SNicolas Belin 	int hp_channel_number;
659*5e240449SNicolas Belin };
660*5e240449SNicolas Belin #endif
661