xref: /linux/sound/soc/codecs/nau8325.h (revision 33e02dc69afbd8f1b85a51d74d72f139ba4ca623)
1*c0a3873bSSeven Lee /* SPDX-License-Identifier: GPL-2.0 */
2*c0a3873bSSeven Lee /*
3*c0a3873bSSeven Lee  * nau8325.h -- Nuvoton NAU8325 audio codec driver
4*c0a3873bSSeven Lee  *
5*c0a3873bSSeven Lee  * Copyright 2023 Nuvoton Technology Crop.
6*c0a3873bSSeven Lee  * Author: Seven Lee <WTLI@nuvoton.com>
7*c0a3873bSSeven Lee  *	   David Lin <CTLIN0@nuvoton.com>
8*c0a3873bSSeven Lee  */
9*c0a3873bSSeven Lee 
10*c0a3873bSSeven Lee #ifndef __NAU8325_H__
11*c0a3873bSSeven Lee #define __NAU8325_H__
12*c0a3873bSSeven Lee 
13*c0a3873bSSeven Lee #define NAU8325_R00_HARDWARE_RST		0x00
14*c0a3873bSSeven Lee #define NAU8325_R01_SOFTWARE_RST		0x01
15*c0a3873bSSeven Lee #define NAU8325_R02_DEVICE_ID			0x02
16*c0a3873bSSeven Lee #define NAU8325_R03_CLK_CTRL			0x03
17*c0a3873bSSeven Lee #define NAU8325_R04_ENA_CTRL			0x04
18*c0a3873bSSeven Lee #define NAU8325_R05_INTERRUPT_CTRL		0x05
19*c0a3873bSSeven Lee #define NAU8325_R06_INT_CLR_STATUS		0x06
20*c0a3873bSSeven Lee #define NAU8325_R09_IRQOUT			0x09
21*c0a3873bSSeven Lee #define NAU8325_R0A_IO_CTRL			0x0a
22*c0a3873bSSeven Lee #define NAU8325_R0B_PDM_CTRL			0x0b
23*c0a3873bSSeven Lee #define NAU8325_R0C_TDM_CTRL			0x0c
24*c0a3873bSSeven Lee #define NAU8325_R0D_I2S_PCM_CTRL1		0x0d
25*c0a3873bSSeven Lee #define NAU8325_R0E_I2S_PCM_CTRL2		0x0e
26*c0a3873bSSeven Lee #define NAU8325_R0F_L_TIME_SLOT			0x0f
27*c0a3873bSSeven Lee #define NAU8325_R10_R_TIME_SLOT			0x10
28*c0a3873bSSeven Lee #define NAU8325_R11_HPF_CTRL			0x11
29*c0a3873bSSeven Lee #define NAU8325_R12_MUTE_CTRL			0x12
30*c0a3873bSSeven Lee #define NAU8325_R13_DAC_VOLUME			0x13
31*c0a3873bSSeven Lee #define NAU8325_R1D_DEBUG_READ1			0x1d
32*c0a3873bSSeven Lee #define NAU8325_R1F_DEBUG_READ2			0x1f
33*c0a3873bSSeven Lee #define NAU8325_R22_DEBUG_READ3			0x22
34*c0a3873bSSeven Lee #define NAU8325_R29_DAC_CTRL1			0x29
35*c0a3873bSSeven Lee #define NAU8325_R2A_DAC_CTRL2			0x2a
36*c0a3873bSSeven Lee #define NAU8325_R2C_ALC_CTRL1			0x2c
37*c0a3873bSSeven Lee #define NAU8325_R2D_ALC_CTRL2			0x2d
38*c0a3873bSSeven Lee #define NAU8325_R2E_ALC_CTRL3			0x2e
39*c0a3873bSSeven Lee #define NAU8325_R2F_ALC_CTRL4			0x2f
40*c0a3873bSSeven Lee #define NAU8325_R40_CLK_DET_CTRL		0x40
41*c0a3873bSSeven Lee #define NAU8325_R49_TEST_STATUS			0x49
42*c0a3873bSSeven Lee #define NAU8325_R4A_ANALOG_READ			0x4a
43*c0a3873bSSeven Lee #define NAU8325_R50_MIXER_CTRL			0x50
44*c0a3873bSSeven Lee #define NAU8325_R55_MISC_CTRL			0x55
45*c0a3873bSSeven Lee #define NAU8325_R60_BIAS_ADJ			0x60
46*c0a3873bSSeven Lee #define NAU8325_R61_ANALOG_CONTROL_1		0x61
47*c0a3873bSSeven Lee #define NAU8325_R62_ANALOG_CONTROL_2		0x62
48*c0a3873bSSeven Lee #define NAU8325_R63_ANALOG_CONTROL_3		0x63
49*c0a3873bSSeven Lee #define NAU8325_R64_ANALOG_CONTROL_4		0x64
50*c0a3873bSSeven Lee #define NAU8325_R65_ANALOG_CONTROL_5		0x65
51*c0a3873bSSeven Lee #define NAU8325_R66_ANALOG_CONTROL_6		0x66
52*c0a3873bSSeven Lee #define NAU8325_R69_CLIP_CTRL			0x69
53*c0a3873bSSeven Lee #define NAU8325_R73_RDAC			0x73
54*c0a3873bSSeven Lee #define NAU8325_REG_MAX				NAU8325_R73_RDAC
55*c0a3873bSSeven Lee 
56*c0a3873bSSeven Lee /* 16-bit control register address, and 16-bits control register data */
57*c0a3873bSSeven Lee #define NAU8325_REG_ADDR_LEN		16
58*c0a3873bSSeven Lee #define NAU8325_REG_DATA_LEN		16
59*c0a3873bSSeven Lee 
60*c0a3873bSSeven Lee /* CLK_CTRL (0x03) */
61*c0a3873bSSeven Lee #define NAU8325_CLK_DAC_SRC_SFT		12
62*c0a3873bSSeven Lee #define NAU8325_CLK_DAC_SRC_MASK	(0x3 << NAU8325_CLK_DAC_SRC_SFT)
63*c0a3873bSSeven Lee #define NAU8325_CLK_MUL_SRC_SFT		6
64*c0a3873bSSeven Lee #define NAU8325_CLK_MUL_SRC_MASK	(0x3 << NAU8325_CLK_MUL_SRC_SFT)
65*c0a3873bSSeven Lee #define NAU8325_MCLK_SEL_SFT		3
66*c0a3873bSSeven Lee #define NAU8325_MCLK_SEL_MASK		(0x7 << NAU8325_MCLK_SEL_SFT)
67*c0a3873bSSeven Lee #define NAU8325_MCLK_SRC_MASK		0x7
68*c0a3873bSSeven Lee 
69*c0a3873bSSeven Lee /* ENA_CTRL (0x04) */
70*c0a3873bSSeven Lee #define NAU8325_DAC_LEFT_CH_EN_SFT	3
71*c0a3873bSSeven Lee #define NAU8325_DAC_LEFT_CH_EN		(0x1 << NAU8325_DAC_LEFT_CH_EN_SFT)
72*c0a3873bSSeven Lee #define NAU8325_DAC_RIGHT_CH_EN_SFT	2
73*c0a3873bSSeven Lee #define NAU8325_DAC_RIGHT_CH_EN		(0x1 << NAU8325_DAC_RIGHT_CH_EN_SFT)
74*c0a3873bSSeven Lee 
75*c0a3873bSSeven Lee /* INTERRUPT_CTRL (0x05) */
76*c0a3873bSSeven Lee #define NAU8325_ARP_DWN_INT_SFT		12
77*c0a3873bSSeven Lee #define NAU8325_ARP_DWN_INT_MASK	(0x1 << NAU8325_ARP_DWN_INT_SFT)
78*c0a3873bSSeven Lee #define NAU8325_CLIP_INT_SFT		11
79*c0a3873bSSeven Lee #define NAU8325_CLIP_INT_MASK		(0x1 << NAU8325_CLIP_INT_SFT)
80*c0a3873bSSeven Lee #define NAU8325_LVD_INT_SFT		10
81*c0a3873bSSeven Lee #define NAU8325_LVD_INT_MASK		(0x1 << NAU8325_LVD_INT_SFT)
82*c0a3873bSSeven Lee #define NAU8325_PWR_INT_DIS_SFT		8
83*c0a3873bSSeven Lee #define NAU8325_PWR_INT_DIS		(0x1 << NAU8325_PWR_INT_DIS_SFT)
84*c0a3873bSSeven Lee #define NAU8325_OCP_OTP_SHTDWN_INT_SFT	4
85*c0a3873bSSeven Lee #define NAU8325_OCP_OTP_SHTDWN_INT_MASK (0x1 << NAU8325_OCP_OTP_SHTDWN_INT_SFT)
86*c0a3873bSSeven Lee #define NAU8325_CLIP_INT_DIS_SFT	3
87*c0a3873bSSeven Lee #define NAU8325_CLIP_INT_DIS		(0x1 << NAU8325_CLIP_INT_DIS_SFT)
88*c0a3873bSSeven Lee #define NAU8325_LVD_INT_DIS_SFT		2
89*c0a3873bSSeven Lee #define NAU8325_LVD_INT_DIS		(0x1 << NAU8325_LVD_INT_DIS_SFT)
90*c0a3873bSSeven Lee #define NAU8325_PWR_INT_MASK		0x1
91*c0a3873bSSeven Lee 
92*c0a3873bSSeven Lee /* INT_CLR_STATUS (0x06) */
93*c0a3873bSSeven Lee #define NAU8325_INT_STATUS_MASK		0x7f
94*c0a3873bSSeven Lee 
95*c0a3873bSSeven Lee /* IRQOUT (0x9) */
96*c0a3873bSSeven Lee #define NAU8325_IRQOUT_SEL_SEF		12
97*c0a3873bSSeven Lee #define NAU8325_IRQOUT_SEL_MASK		(0xf << NAU8325_IRQOUT_SEL_SEF)
98*c0a3873bSSeven Lee #define NAU8325_DEM_DITH_SFT		7
99*c0a3873bSSeven Lee #define NAU8325_DEM_DITH_EN		(0x1 << NAU8325_DEM_DITH_SFT)
100*c0a3873bSSeven Lee #define NAU8325_GAINZI3_SFT		5
101*c0a3873bSSeven Lee #define NAU8325_GAINZI3_MASK		(0x1 << NAU8325_GAINZI3_SFT)
102*c0a3873bSSeven Lee #define NAU8325_GAINZI2_MASK		0x1f
103*c0a3873bSSeven Lee 
104*c0a3873bSSeven Lee /* IO_CTRL (0x0a) */
105*c0a3873bSSeven Lee #define NAU8325_IRQ_PL_SFT		15
106*c0a3873bSSeven Lee #define NAU8325_IRQ_PL_ACT_HIGH		(0x1 << NAU8325_IRQ_PL_SFT)
107*c0a3873bSSeven Lee #define NAU8325_IRQ_PS_SFT		14
108*c0a3873bSSeven Lee #define NAU8325_IRQ_PS_UP		(0x1 << NAU8325_IRQ_PS_SFT)
109*c0a3873bSSeven Lee #define NAU8325_IRQ_PE_SFT		13
110*c0a3873bSSeven Lee #define NAU8325_IRQ_PE_EN		(0x1 << NAU8325_IRQ_PE_SFT)
111*c0a3873bSSeven Lee #define NAU8325_IRQ_DS_SFT		12
112*c0a3873bSSeven Lee #define NAU8325_IRQ_DS_HIGH		(0x1 << NAU8325_IRQ_DS_SFT)
113*c0a3873bSSeven Lee #define NAU8325_IRQ_OUTPUT_SFT		11
114*c0a3873bSSeven Lee #define NAU8325_IRQ_OUTPUT_EN		(0x1 << NAU8325_IRQ_OUTPUT_SFT)
115*c0a3873bSSeven Lee #define NAU8325_IRQ_PIN_DEBUG_SFT	10
116*c0a3873bSSeven Lee #define NAU8325_IRQ_PIN_DEBUG_EN	(0x1 << NAU8325_IRQ_PIN_DEBUG_SFT)
117*c0a3873bSSeven Lee 
118*c0a3873bSSeven Lee /* PDM_CTRL (0x0b) */
119*c0a3873bSSeven Lee #define NAU8325_PDM_LCH_EDGE_SFT	1
120*c0a3873bSSeven Lee #define NAU8325_PDM_LCH_EDGE__MASK	(0x1 << NAU8325_PDM_LCH_EDGE_SFT)
121*c0a3873bSSeven Lee #define NAU8325_PDM_MODE_EN		0x1
122*c0a3873bSSeven Lee 
123*c0a3873bSSeven Lee /* TDM_CTRL (0x0c) */
124*c0a3873bSSeven Lee #define NAU8325_TDM_SFT			15
125*c0a3873bSSeven Lee #define NAU8325_TDM_EN			(0x1 << NAU8325_TDM_SFT)
126*c0a3873bSSeven Lee #define NAU8325_PCM_OFFSET_CTRL_SFT	14
127*c0a3873bSSeven Lee #define NAU8325_PCM_OFFSET_CTRL_EN	(0x1 << NAU8325_PCM_OFFSET_CTRL_SFT)
128*c0a3873bSSeven Lee #define NAU8325_DAC_LEFT_SFT		6
129*c0a3873bSSeven Lee #define NAU8325_NAU8325_DAC_LEFT_MASK	(0x7 << NAU8325_DAC_LEFT_SFT)
130*c0a3873bSSeven Lee #define NAU8325_DAC_RIGHT_SFT		3
131*c0a3873bSSeven Lee #define NAU8325_DAC_RIGHT_MASK		(0x7 << NAU8325_DAC_RIGHT_SFT)
132*c0a3873bSSeven Lee 
133*c0a3873bSSeven Lee /* I2S_PCM_CTRL1 (0x0d) */
134*c0a3873bSSeven Lee #define NAU8325_DACCM_CTL_SFT		14
135*c0a3873bSSeven Lee #define NAU8325_DACCM_CTL_MASK		(0x3 << NAU8325_DACCM_CTL_SFT)
136*c0a3873bSSeven Lee #define NAU8325_CMB8_0_SFT		10
137*c0a3873bSSeven Lee #define NAU8325_CMB8_0_MASK		(0x1 << NAU8325_CMB8_0_SFT)
138*c0a3873bSSeven Lee #define NAU8325_UA_OFFSET_SFT		9
139*c0a3873bSSeven Lee #define NAU8325_UA_OFFSET_MASK		(0x1 << NAU8325_UA_OFFSET_SFT)
140*c0a3873bSSeven Lee #define NAU8325_I2S_BP_SFT		7
141*c0a3873bSSeven Lee #define NAU8325_I2S_BP_MASK		(0x1 << NAU8325_I2S_BP_SFT)
142*c0a3873bSSeven Lee #define NAU8325_I2S_BP_INV		(0x1 << NAU8325_I2S_BP_SFT)
143*c0a3873bSSeven Lee #define NAU8325_I2S_PCMB_SFT		6
144*c0a3873bSSeven Lee #define NAU8325_I2S_PCMB_EN		(0x1 << NAU8325_I2S_PCMB_SFT)
145*c0a3873bSSeven Lee #define NAU8325_I2S_DACPSHS0_SFT	5
146*c0a3873bSSeven Lee #define NAU8325_I2S_DACPSHS0_MASK	(0x1 << NAU8325_I2S_DACPSHS0_SFT)
147*c0a3873bSSeven Lee #define NAU8325_I2S_DL_SFT		2
148*c0a3873bSSeven Lee #define NAU8325_I2S_DL_MASK		(0x3 << NAU8325_I2S_DL_SFT)
149*c0a3873bSSeven Lee #define NAU8325_I2S_DL_32		(0x3 << NAU8325_I2S_DL_SFT)
150*c0a3873bSSeven Lee #define NAU8325_I2S_DL_24		(0x2 << NAU8325_I2S_DL_SFT)
151*c0a3873bSSeven Lee #define NAU8325_I2S_DL_20		(0x1 << NAU8325_I2S_DL_SFT)
152*c0a3873bSSeven Lee #define NAU8325_I2S_DL_16		(0x0 << NAU8325_I2S_DL_SFT)
153*c0a3873bSSeven Lee #define NAU8325_I2S_DF_MASK		0x3
154*c0a3873bSSeven Lee #define NAU8325_I2S_DF_RIGTH		0x0
155*c0a3873bSSeven Lee #define NAU8325_I2S_DF_LEFT		0x1
156*c0a3873bSSeven Lee #define NAU8325_I2S_DF_I2S		0x2
157*c0a3873bSSeven Lee #define NAU8325_I2S_DF_PCM_AB		0x3
158*c0a3873bSSeven Lee 
159*c0a3873bSSeven Lee /* I2S_PCM_CTRL2 (0x0e) */
160*c0a3873bSSeven Lee #define NAU8325_PCM_TS_SFT		10
161*c0a3873bSSeven Lee #define NAU8325_PCM_TS_EN		(0x1 << NAU8325_PCM_TS_SFT)
162*c0a3873bSSeven Lee #define NAU8325_PCM8BIT0_SFT		8
163*c0a3873bSSeven Lee #define NAU8325_PCM8BIT0_MASK		(0x1 << NAU8325_PCM8BIT0_SFT)
164*c0a3873bSSeven Lee 
165*c0a3873bSSeven Lee /* L_TIME_SLOT (0x0f)*/
166*c0a3873bSSeven Lee #define NAU8325_SHORT_FS_DET_SFT	13
167*c0a3873bSSeven Lee #define NAU8325_SHORT_FS_DET_DIS	(0x1 << NAU8325_SHORT_FS_DET_SFT)
168*c0a3873bSSeven Lee #define NAU8325_TSLOT_L0_MASK		0x3ff
169*c0a3873bSSeven Lee 
170*c0a3873bSSeven Lee /* R_TIME_SLOT (0x10)*/
171*c0a3873bSSeven Lee #define NAU8325_TSLOT_R0_MASK		0x3ff
172*c0a3873bSSeven Lee 
173*c0a3873bSSeven Lee /* HPF_CTRL (0x11)*/
174*c0a3873bSSeven Lee #define NAU8325_DAC_HPF_SFT		15
175*c0a3873bSSeven Lee #define NAU8325_DAC_HPF_EN		(0x1 << NAU8325_DAC_HPF_SFT)
176*c0a3873bSSeven Lee #define NAU8325_DAC_HPF_APP_SFT		14
177*c0a3873bSSeven Lee #define NAU8325_DAC_HPF_APP_MASK	(0x1 << NAU8325_DAC_HPF_APP_SFT)
178*c0a3873bSSeven Lee #define NAU8325_DAC_HPF_FCUT_SFT	11
179*c0a3873bSSeven Lee #define NAU8325_DAC_HPF_FCUT_MASK	(0x7 << NAU8325_DAC_HPF_FCUT_SFT)
180*c0a3873bSSeven Lee 
181*c0a3873bSSeven Lee /* MUTE_CTRL (0x12)*/
182*c0a3873bSSeven Lee #define NAU8325_SOFT_MUTE_SFT		15
183*c0a3873bSSeven Lee #define NAU8325_SOFT_MUTE		(0x1 << NAU8325_SOFT_MUTE_SFT)
184*c0a3873bSSeven Lee #define NAU8325_DAC_ZC_SFT		8
185*c0a3873bSSeven Lee #define NAU8325_DAC_ZC_EN		(0x1 << NAU8325_DAC_ZC_SFT)
186*c0a3873bSSeven Lee #define NAU8325_UNMUTE_CTL_SFT		6
187*c0a3873bSSeven Lee #define NAU8325_UNMUTE_CTL_MASK		(0x3 << NAU8325_UNMUTE_CTL_SFT)
188*c0a3873bSSeven Lee #define NAU8325_ANA_MUTE_SFT		4
189*c0a3873bSSeven Lee #define NAU8325_ANA_MUTE_MASK		(0x3 << NAU8325_ANA_MUTE_SFT)
190*c0a3873bSSeven Lee #define NAU8325_AUTO_MUTE_SFT		3
191*c0a3873bSSeven Lee #define NAU8325_AUTO_MUTE_DIS		(0x1 << NAU8325_AUTO_MUTE_SFT)
192*c0a3873bSSeven Lee 
193*c0a3873bSSeven Lee /* DAC_VOLUME (0x13) */
194*c0a3873bSSeven Lee #define NAU8325_DAC_VOLUME_L_SFT	8
195*c0a3873bSSeven Lee #define NAU8325_DAC_VOLUME_L_EN		(0xff << NAU8325_DAC_VOLUME_L_SFT)
196*c0a3873bSSeven Lee #define NAU8325_DAC_VOLUME_R_SFT	0
197*c0a3873bSSeven Lee #define NAU8325_DAC_VOLUME_R_EN		(0xff << NAU8325_DAC_VOLUME_R_SFT)
198*c0a3873bSSeven Lee #define NAU8325_DAC_VOL_MAX		0xff
199*c0a3873bSSeven Lee 
200*c0a3873bSSeven Lee /* DEBUG_READ1 (0x1d)*/
201*c0a3873bSSeven Lee #define NAU8325_OSR100_MASK		(0x1 << 6)
202*c0a3873bSSeven Lee #define NAU8325_MIPS500_MASK		(0x1 << 5)
203*c0a3873bSSeven Lee #define NAU8325_SHUTDWNDRVR_R_MASK	(0x1 << 4)
204*c0a3873bSSeven Lee #define NAU8325_SHUTDWNDRVR_L_MASK	(0x1 << 3)
205*c0a3873bSSeven Lee #define NAU8325_MUTEB_MASK		(0x1 << 2)
206*c0a3873bSSeven Lee #define NAU8325_PDOSCB_MASK		(0x1 << 1)
207*c0a3873bSSeven Lee #define NAU8325_POWERDOWN1B_D_MASK	0x1
208*c0a3873bSSeven Lee 
209*c0a3873bSSeven Lee /* DEBUG_READ2 (0x1f)*/
210*c0a3873bSSeven Lee #define NAU8325_R_CHANNEL_Vol_SFT	8
211*c0a3873bSSeven Lee #define NAU8325_R_CHANNEL_Vol_MASK	(0xff << NAU8325_R_CHANNEL_Vol_SFT)
212*c0a3873bSSeven Lee #define NAU8325_L_CHANNEL_Vol_MASK	0xff
213*c0a3873bSSeven Lee 
214*c0a3873bSSeven Lee /* DEBUG_READ3(0x22)*/
215*c0a3873bSSeven Lee #define NAU8325_PGAL_GAIN_MASK		(0x3f << 7)
216*c0a3873bSSeven Lee #define NAU8325_CLIP_MASK		(0x1 << 6)
217*c0a3873bSSeven Lee #define NAU8325_SCAN_MODE_MASK		(0x1 << 5)
218*c0a3873bSSeven Lee #define NAU8325_SDB_MASK		(0x1 << 4)
219*c0a3873bSSeven Lee #define NAU8325_TALARM_MASK		(0x1 << 3)
220*c0a3873bSSeven Lee #define NAU8325_SHORTR_MASK		(0x1 << 2)
221*c0a3873bSSeven Lee #define NAU8325_SHORTL_MASK		(0x1 << 1)
222*c0a3873bSSeven Lee #define NAU8325_TMDET_MASK		0x1
223*c0a3873bSSeven Lee 
224*c0a3873bSSeven Lee /* DAC_CTRL1 (0x29) */
225*c0a3873bSSeven Lee #define NAU8325_DAC_OVERSAMPLE_SFT	0
226*c0a3873bSSeven Lee #define NAU8325_DAC_OVERSAMPLE_MASK	0x7
227*c0a3873bSSeven Lee #define NAU8325_DAC_OVERSAMPLE_256	1
228*c0a3873bSSeven Lee #define NAU8325_DAC_OVERSAMPLE_128	2
229*c0a3873bSSeven Lee #define NAU8325_DAC_OVERSAMPLE_64	0
230*c0a3873bSSeven Lee #define NAU8325_DAC_OVERSAMPLE_32	4
231*c0a3873bSSeven Lee 
232*c0a3873bSSeven Lee /* ALC_CTRL1 (0x2c) */
233*c0a3873bSSeven Lee #define NAU8325_ALC_MAXGAIN_SFT		5
234*c0a3873bSSeven Lee #define NAU8325_ALC_MAXGAIN_MAX		0x7
235*c0a3873bSSeven Lee #define NAU8325_ALC_MAXGAIN_MASK	(0x7 << NAU8325_ALC_MAXGAIN_SFT)
236*c0a3873bSSeven Lee #define NAU8325_ALC_MINGAIN_MAX		4
237*c0a3873bSSeven Lee #define NAU8325_ALC_MINGAIN_SFT		1
238*c0a3873bSSeven Lee #define NAU8325_ALC_MINGAIN_MASK	(0x7 << NAU8325_ALC_MINGAIN_SFT)
239*c0a3873bSSeven Lee 
240*c0a3873bSSeven Lee /* ALC_CTRL2 (0x2d) */
241*c0a3873bSSeven Lee #define NAU8325_ALC_DCY_SFT		12
242*c0a3873bSSeven Lee #define NAU8325_ALC_DCY_MAX		0xb
243*c0a3873bSSeven Lee #define NAU8325_ALC_DCY_MASK		(0xf << NAU8325_ALC_DCY_SFT)
244*c0a3873bSSeven Lee #define NAU8325_ALC_ATK_SFT		8
245*c0a3873bSSeven Lee #define NAU8325_ALC_ATK_MAX		0xb
246*c0a3873bSSeven Lee #define NAU8325_ALC_ATK_MASK		(0xf << NAU8325_ALC_ATK_SFT)
247*c0a3873bSSeven Lee #define NAU8325_ALC_HLD_SFT		4
248*c0a3873bSSeven Lee #define NAU8325_ALC_HLD_MAX		0xa
249*c0a3873bSSeven Lee #define NAU8325_ALC_HLD_MASK		(0xf << NAU8325_ALC_HLD_SFT)
250*c0a3873bSSeven Lee #define NAU8325_ALC_LVL_SFT		0
251*c0a3873bSSeven Lee #define NAU8325_ALC_LVL_MAX		0xf
252*c0a3873bSSeven Lee #define NAU8325_ALC_LVL_MASK		0xf
253*c0a3873bSSeven Lee 
254*c0a3873bSSeven Lee /* ALC_CTRL3 (0x2e) */
255*c0a3873bSSeven Lee #define NAU8325_ALC_EN_SFT		15
256*c0a3873bSSeven Lee #define NAU8325_ALC_EN			(0x1 << NAU8325_ALC_EN_SFT)
257*c0a3873bSSeven Lee 
258*c0a3873bSSeven Lee /* TEMP_COMP_CTRL (0x30) */
259*c0a3873bSSeven Lee #define NAU8325_TEMP_COMP_ACT2_MASK	0xff
260*c0a3873bSSeven Lee 
261*c0a3873bSSeven Lee /* LPF_CTRL (0x33) */
262*c0a3873bSSeven Lee #define NAU8325_LPF_IN1_EN_SFT		15
263*c0a3873bSSeven Lee #define NAU8325_LPF_IN1_EN		(0x1 << NAU8325_LPF_IN1_EN_SFT)
264*c0a3873bSSeven Lee #define NAU8325_LPF_IN1_TC_SFT		11
265*c0a3873bSSeven Lee #define NAU8325_LPF_IN1_TC_MASK		(0xf << NAU8325_LPF_IN1_TC_SFT)
266*c0a3873bSSeven Lee #define NAU8325_LPF_IN2_EN_SFT		10
267*c0a3873bSSeven Lee #define NAU8325_LPF_IN2_EN		(0x1 << NAU8325_LPF_IN2_EN_SFT)
268*c0a3873bSSeven Lee #define NAU8325_LPF_IN2_TC_SFT		6
269*c0a3873bSSeven Lee #define NAU8325_LPF_IN2_TC_MASK		(0xf << NAU8325_LPF_IN2_TC_SFT)
270*c0a3873bSSeven Lee 
271*c0a3873bSSeven Lee /* CLK_DET_CTRL (0x40) */
272*c0a3873bSSeven Lee #define NAU8325_APWRUP_SFT		15
273*c0a3873bSSeven Lee #define NAU8325_APWRUP_EN		(0x1 << NAU8325_APWRUP_SFT)
274*c0a3873bSSeven Lee #define NAU8325_CLKPWRUP_SFT		14
275*c0a3873bSSeven Lee #define NAU8325_CLKPWRUP_DIS		(0x1 << NAU8325_CLKPWRUP_SFT)
276*c0a3873bSSeven Lee #define NAU8325_PWRUP_DFT_SFT		13
277*c0a3873bSSeven Lee #define NAU8325_PWRUP_DFT		(0x1 << NAU8325_PWRUP_DFT_SFT)
278*c0a3873bSSeven Lee #define NAU8325_REG_SRATE_SFT		10
279*c0a3873bSSeven Lee #define NAU8325_REG_SRATE_MASK		(0x7 << NAU8325_REG_SRATE_SFT)
280*c0a3873bSSeven Lee #define NAU8325_REG_ALT_SRATE_SFT	9
281*c0a3873bSSeven Lee #define NAU8325_REG_ALT_SRATE_EN	(0x1 << NAU8325_REG_ALT_SRATE_SFT)
282*c0a3873bSSeven Lee #define NAU8325_REG_DIV_MAX		0x1
283*c0a3873bSSeven Lee 
284*c0a3873bSSeven Lee /* BIAS_ADJ (0x60) */
285*c0a3873bSSeven Lee #define NAU8325_BIAS_VMID_SEL_SFT	4
286*c0a3873bSSeven Lee #define NAU8325_BIAS_VMID_SEL_MASK	(0x3 << NAU8325_BIAS_VMID_SEL_SFT)
287*c0a3873bSSeven Lee 
288*c0a3873bSSeven Lee /* ANALOG_CONTROL_1 (0x61) */
289*c0a3873bSSeven Lee #define NAU8325_VMDFSTENB_SFT		14
290*c0a3873bSSeven Lee #define NAU8325_VMDFSTENB_MASK		(0x3 << NAU8325_VMDFSTENB_SFT)
291*c0a3873bSSeven Lee #define NAU8325_CLASSDEN_SFT		12
292*c0a3873bSSeven Lee #define NAU8325_CLASSDEN_MASK		(0x3 << NAU8325_CLASSDEN_SFT)
293*c0a3873bSSeven Lee #define NAU8325_DACCLKEN_R_SFT		10
294*c0a3873bSSeven Lee #define NAU8325_DACCLKEN_R_MASK		(0x3 << NAU8325_DACCLKEN_R_SFT)
295*c0a3873bSSeven Lee #define NAU8325_DACEN_R_SFT		8
296*c0a3873bSSeven Lee #define NAU8325_DACEN_R_MASK		(0x3 << NAU8325_DACEN_R_SFT)
297*c0a3873bSSeven Lee #define NAU8325_DACCLKEN_SFT		6
298*c0a3873bSSeven Lee #define NAU8325_DACCLKEN_MASK		(0x3 << NAU8325_DACCLKEN_SFT)
299*c0a3873bSSeven Lee #define NAU8325_DACEN_SFT		4
300*c0a3873bSSeven Lee #define NAU8325_DACEN_MASK		(0x3 << NAU8325_DACEN_SFT)
301*c0a3873bSSeven Lee #define NAU8325_BIASEN_SFT		2
302*c0a3873bSSeven Lee #define NAU8325_BIASEN_MASK		(0x3 << NAU8325_BIASEN_SFT)
303*c0a3873bSSeven Lee #define NAU8325_VMIDEN_MASK		0x3
304*c0a3873bSSeven Lee 
305*c0a3873bSSeven Lee /* ANALOG_CONTROL_2 (0x62) */
306*c0a3873bSSeven Lee #define NAU8325_PWMMOD_SFT		14
307*c0a3873bSSeven Lee #define NAU8325_PWMMOD_MASK		(0x1 << NAU8325_PWMMOD_SFT)
308*c0a3873bSSeven Lee #define NAU8325_DACTEST_SFT		6
309*c0a3873bSSeven Lee #define NAU8325_DACTEST_MASK		(0x3 << NAU8325_DACTEST_SFT)
310*c0a3873bSSeven Lee #define NAU8325_DACREFCAP_SFT		4
311*c0a3873bSSeven Lee #define NAU8325_DACREFCAP_MASK		(0x3 << NAU8325_DACREFCAP_SFT)
312*c0a3873bSSeven Lee 
313*c0a3873bSSeven Lee /* ANALOG_CONTROL_3 (0x63) */
314*c0a3873bSSeven Lee #define NAU8325_POWER_DOWN_L_SFT	12
315*c0a3873bSSeven Lee #define NAU8325_POWER_DOWN_L_MASK	(0x3 << NAU8325_POWER_DOWN_L_SFT)
316*c0a3873bSSeven Lee #define NAU8325_POWER_DOWN_R_SFT	11
317*c0a3873bSSeven Lee #define NAU8325_POWER_DOWN_R_MASK	(0x3 << NAU8325_DACREFCAP_SFT)
318*c0a3873bSSeven Lee #define NAU8325_CLASSD_FINE_SFT		5
319*c0a3873bSSeven Lee #define NAU8325_CLASSD_FINE_MASK	(0x3 << NAU8325_CLASSD_FINE_SFT)
320*c0a3873bSSeven Lee #define NAU8325_CLASSD_COARSE_GAIN_MASK	0xf
321*c0a3873bSSeven Lee 
322*c0a3873bSSeven Lee /* ANALOG_CONTROL_4 (0x64) */
323*c0a3873bSSeven Lee #define NAU8325_CLASSD_OCPN_SFT		12
324*c0a3873bSSeven Lee #define NAU8325_CLASSD_OCPN_MASK	(0xf << NAU8325_CLASSD_OCPN_SFT)
325*c0a3873bSSeven Lee #define NAU8325_CLASSD_OCPP_SFT		8
326*c0a3873bSSeven Lee #define NAU8325_CLASSD_OCPP_MASK	(0xf << NAU8325_CLASSD_OCPP_SFT)
327*c0a3873bSSeven Lee #define NAU8325_CLASSD_SLEWN_MASK	0xff
328*c0a3873bSSeven Lee 
329*c0a3873bSSeven Lee /* ANALOG_CONTROL_5 (0x65) */
330*c0a3873bSSeven Lee #define NAU8325_MCLK_RANGE_SFT		2
331*c0a3873bSSeven Lee #define NAU8325_MCLK_RANGE_EN		(0x1 << NAU8325_MCLK_RANGE_SFT)
332*c0a3873bSSeven Lee #define NAU8325_MCLK8XEN_SFT		1
333*c0a3873bSSeven Lee #define NAU8325_MCLK8XEN_EN		(0x1 << NAU8325_MCLK8XEN_SFT)
334*c0a3873bSSeven Lee #define NAU8325_MCLK4XEN_EN		0x1
335*c0a3873bSSeven Lee 
336*c0a3873bSSeven Lee /* ANALOG_CONTROL_6 (0x66) */
337*c0a3873bSSeven Lee #define NAU8325_VBATLOW_SFT		4
338*c0a3873bSSeven Lee #define NAU8325_VBATLOW_MASK		(0x1 << NAU8325_VBATLOW_SFT)
339*c0a3873bSSeven Lee #define NAU8325_VDDSPK_LIM_SFT		3
340*c0a3873bSSeven Lee #define NAU8325_VDDSPK_LIM_EN		(0x1 << NAU8325_VDDSPK_LIM_SFT)
341*c0a3873bSSeven Lee #define NAU8325_VDDSPK_LIM_MASK		0x7
342*c0a3873bSSeven Lee 
343*c0a3873bSSeven Lee /* CLIP_CTRL (0x69)*/
344*c0a3873bSSeven Lee #define NAU8325_ANTI_CLIP_SFT		4
345*c0a3873bSSeven Lee #define NAU8325_ANTI_CLIP_EN		(0x1 << NAU8325_ANTI_CLIP_SFT)
346*c0a3873bSSeven Lee 
347*c0a3873bSSeven Lee /* RDAC (0x73) */
348*c0a3873bSSeven Lee #define NAU8325_CLK_DAC_DELAY_SFT	4
349*c0a3873bSSeven Lee #define NAU8325_CLK_DAC_DELAY_EN	(0x7 << NAU8325_CLK_DAC_DELAY_SFT)
350*c0a3873bSSeven Lee #define NAU8325_DACVREFSEL_SFT		2
351*c0a3873bSSeven Lee #define NAU8325_DACVREFSEL_MASK		(0x3 << NAU8325_DACVREFSEL_SFT)
352*c0a3873bSSeven Lee 
353*c0a3873bSSeven Lee #define NAU8325_CODEC_DAI "nau8325-hifi"
354*c0a3873bSSeven Lee 
355*c0a3873bSSeven Lee struct nau8325 {
356*c0a3873bSSeven Lee 	struct device *dev;
357*c0a3873bSSeven Lee 	struct regmap *regmap;
358*c0a3873bSSeven Lee 	int mclk;
359*c0a3873bSSeven Lee 	int fs;
360*c0a3873bSSeven Lee 	int vref_impedance_ohms;
361*c0a3873bSSeven Lee 	int dac_vref_microvolt;
362*c0a3873bSSeven Lee 	int clock_detection;
363*c0a3873bSSeven Lee 	int clock_det_data;
364*c0a3873bSSeven Lee 	int alc_enable;
365*c0a3873bSSeven Lee };
366*c0a3873bSSeven Lee 
367*c0a3873bSSeven Lee struct nau8325_src_attr {
368*c0a3873bSSeven Lee 	int param;
369*c0a3873bSSeven Lee 	unsigned int val;
370*c0a3873bSSeven Lee };
371*c0a3873bSSeven Lee 
372*c0a3873bSSeven Lee enum {
373*c0a3873bSSeven Lee 	NAU8325_MCLK_FS_RATIO_256,
374*c0a3873bSSeven Lee 	NAU8325_MCLK_FS_RATIO_400,
375*c0a3873bSSeven Lee 	NAU8325_MCLK_FS_RATIO_500,
376*c0a3873bSSeven Lee 	NAU8325_MCLK_FS_RATIO_NUM,
377*c0a3873bSSeven Lee };
378*c0a3873bSSeven Lee 
379*c0a3873bSSeven Lee struct nau8325_srate_attr {
380*c0a3873bSSeven Lee 	int fs;
381*c0a3873bSSeven Lee 	int range;
382*c0a3873bSSeven Lee 	bool max;
383*c0a3873bSSeven Lee 	unsigned int mclk_src[NAU8325_MCLK_FS_RATIO_NUM];
384*c0a3873bSSeven Lee };
385*c0a3873bSSeven Lee 
386*c0a3873bSSeven Lee struct nau8325_osr_attr {
387*c0a3873bSSeven Lee 	unsigned int osr;
388*c0a3873bSSeven Lee 	unsigned int clk_src;
389*c0a3873bSSeven Lee };
390*c0a3873bSSeven Lee 
391*c0a3873bSSeven Lee #endif /* __NAU8325_H__ */
392