1 // SPDX-License-Identifier: GPL-2.0-only
2 //
3 // aw88395_reg.h --  AW88395 chip register file
4 //
5 // Copyright (c) 2022-2023 AWINIC Technology CO., LTD
6 //
7 // Author: Bruce zhao <zhaolei@awinic.com>
8 //
9 
10 #ifndef __AW88395_REG_H__
11 #define __AW88395_REG_H__
12 
13 #define AW88395_ID_REG			(0x00)
14 #define AW88395_SYSST_REG		(0x01)
15 #define AW88395_SYSINT_REG		(0x02)
16 #define AW88395_SYSINTM_REG		(0x03)
17 #define AW88395_SYSCTRL_REG		(0x04)
18 #define AW88395_SYSCTRL2_REG		(0x05)
19 #define AW88395_I2SCTRL_REG		(0x06)
20 #define AW88395_I2SCFG1_REG		(0x07)
21 #define AW88395_I2SCFG2_REG		(0x08)
22 #define AW88395_HAGCCFG1_REG		(0x09)
23 #define AW88395_HAGCCFG2_REG		(0x0A)
24 #define AW88395_HAGCCFG3_REG		(0x0B)
25 #define AW88395_HAGCCFG4_REG		(0x0C)
26 #define AW88395_HAGCCFG5_REG		(0x0D)
27 #define AW88395_HAGCCFG6_REG		(0x0E)
28 #define AW88395_HAGCCFG7_REG		(0x0F)
29 #define AW88395_MPDCFG_REG		(0x10)
30 #define AW88395_PWMCTRL_REG		(0x11)
31 #define AW88395_I2SCFG3_REG		(0x12)
32 #define AW88395_DBGCTRL_REG		(0x13)
33 #define AW88395_HAGCST_REG		(0x20)
34 #define AW88395_VBAT_REG		(0x21)
35 #define AW88395_TEMP_REG		(0x22)
36 #define AW88395_PVDD_REG		(0x23)
37 #define AW88395_ISNDAT_REG		(0x24)
38 #define AW88395_VSNDAT_REG		(0x25)
39 #define AW88395_I2SINT_REG		(0x26)
40 #define AW88395_I2SCAPCNT_REG		(0x27)
41 #define AW88395_ANASTA1_REG		(0x28)
42 #define AW88395_ANASTA2_REG		(0x29)
43 #define AW88395_ANASTA3_REG		(0x2A)
44 #define AW88395_ANASTA4_REG		(0x2B)
45 #define AW88395_TESTDET_REG		(0x2C)
46 #define AW88395_TESTIN_REG		(0x38)
47 #define AW88395_TESTOUT_REG		(0x39)
48 #define AW88395_DSPMADD_REG		(0x40)
49 #define AW88395_DSPMDAT_REG		(0x41)
50 #define AW88395_WDT_REG		(0x42)
51 #define AW88395_ACR1_REG		(0x43)
52 #define AW88395_ACR2_REG		(0x44)
53 #define AW88395_ASR1_REG		(0x45)
54 #define AW88395_ASR2_REG		(0x46)
55 #define AW88395_DSPCFG_REG		(0x47)
56 #define AW88395_ASR3_REG		(0x48)
57 #define AW88395_ASR4_REG		(0x49)
58 #define AW88395_VSNCTRL1_REG		(0x50)
59 #define AW88395_ISNCTRL1_REG		(0x51)
60 #define AW88395_PLLCTRL1_REG		(0x52)
61 #define AW88395_PLLCTRL2_REG		(0x53)
62 #define AW88395_PLLCTRL3_REG		(0x54)
63 #define AW88395_CDACTRL1_REG		(0x55)
64 #define AW88395_CDACTRL2_REG		(0x56)
65 #define AW88395_SADCCTRL1_REG		(0x57)
66 #define AW88395_SADCCTRL2_REG		(0x58)
67 #define AW88395_CPCTRL1_REG		(0x59)
68 #define AW88395_BSTCTRL1_REG		(0x60)
69 #define AW88395_BSTCTRL2_REG		(0x61)
70 #define AW88395_BSTCTRL3_REG		(0x62)
71 #define AW88395_BSTCTRL4_REG		(0x63)
72 #define AW88395_BSTCTRL5_REG		(0x64)
73 #define AW88395_BSTCTRL6_REG		(0x65)
74 #define AW88395_BSTCTRL7_REG		(0x66)
75 #define AW88395_DSMCFG1_REG		(0x67)
76 #define AW88395_DSMCFG2_REG		(0x68)
77 #define AW88395_DSMCFG3_REG		(0x69)
78 #define AW88395_DSMCFG4_REG		(0x6A)
79 #define AW88395_DSMCFG5_REG		(0x6B)
80 #define AW88395_DSMCFG6_REG		(0x6C)
81 #define AW88395_DSMCFG7_REG		(0x6D)
82 #define AW88395_DSMCFG8_REG		(0x6E)
83 #define AW88395_TESTCTRL1_REG		(0x70)
84 #define AW88395_TESTCTRL2_REG		(0x71)
85 #define AW88395_EFCTRL1_REG		(0x72)
86 #define AW88395_EFCTRL2_REG		(0x73)
87 #define AW88395_EFWH_REG		(0x74)
88 #define AW88395_EFWM2_REG		(0x75)
89 #define AW88395_EFWM1_REG		(0x76)
90 #define AW88395_EFWL_REG		(0x77)
91 #define AW88395_EFRH_REG		(0x78)
92 #define AW88395_EFRM2_REG		(0x79)
93 #define AW88395_EFRM1_REG		(0x7A)
94 #define AW88395_EFRL_REG		(0x7B)
95 #define AW88395_TM_REG			(0x7C)
96 
97 enum aw88395_id {
98 	AW88395_CHIP_ID = 0x2049,
99 	AW88261_CHIP_ID = 0x2113,
100 };
101 
102 #define AW88395_REG_MAX		(0x7D)
103 
104 #define AW88395_VOLUME_STEP_DB		(6 * 8)
105 
106 #define AW88395_UVLS_START_BIT		(14)
107 #define AW88395_UVLS_NORMAL		(0)
108 #define AW88395_UVLS_NORMAL_VALUE	\
109 	(AW88395_UVLS_NORMAL << AW88395_UVLS_START_BIT)
110 
111 #define AW88395_DSPS_START_BIT		(12)
112 #define AW88395_DSPS_BITS_LEN		(1)
113 #define AW88395_DSPS_MASK		\
114 	(~(((1<<AW88395_DSPS_BITS_LEN)-1) << AW88395_DSPS_START_BIT))
115 
116 #define AW88395_DSPS_NORMAL		(0)
117 #define AW88395_DSPS_NORMAL_VALUE	\
118 	(AW88395_DSPS_NORMAL << AW88395_DSPS_START_BIT)
119 
120 #define AW88395_BSTOCS_START_BIT	(11)
121 #define AW88395_BSTOCS_OVER_CURRENT	(1)
122 #define AW88395_BSTOCS_OVER_CURRENT_VALUE	\
123 	(AW88395_BSTOCS_OVER_CURRENT << AW88395_BSTOCS_START_BIT)
124 
125 #define AW88395_BSTS_START_BIT		(9)
126 #define AW88395_BSTS_FINISHED		(1)
127 #define AW88395_BSTS_FINISHED_VALUE	\
128 	(AW88395_BSTS_FINISHED << AW88395_BSTS_START_BIT)
129 
130 #define AW88395_SWS_START_BIT		(8)
131 #define AW88395_SWS_SWITCHING		(1)
132 #define AW88395_SWS_SWITCHING_VALUE	\
133 	(AW88395_SWS_SWITCHING << AW88395_SWS_START_BIT)
134 
135 #define AW88395_NOCLKS_START_BIT	(5)
136 #define AW88395_NOCLKS_NO_CLOCK	(1)
137 #define AW88395_NOCLKS_NO_CLOCK_VALUE	\
138 	(AW88395_NOCLKS_NO_CLOCK << AW88395_NOCLKS_START_BIT)
139 
140 #define AW88395_CLKS_START_BIT		(4)
141 #define AW88395_CLKS_STABLE		(1)
142 #define AW88395_CLKS_STABLE_VALUE	\
143 	(AW88395_CLKS_STABLE << AW88395_CLKS_START_BIT)
144 
145 #define AW88395_OCDS_START_BIT		(3)
146 #define AW88395_OCDS_OC		(1)
147 #define AW88395_OCDS_OC_VALUE		\
148 	(AW88395_OCDS_OC << AW88395_OCDS_START_BIT)
149 
150 #define AW88395_OTHS_START_BIT		(1)
151 #define AW88395_OTHS_OT		(1)
152 #define AW88395_OTHS_OT_VALUE		\
153 	(AW88395_OTHS_OT << AW88395_OTHS_START_BIT)
154 
155 #define AW88395_PLLS_START_BIT		(0)
156 #define AW88395_PLLS_LOCKED		(1)
157 #define AW88395_PLLS_LOCKED_VALUE	\
158 	(AW88395_PLLS_LOCKED << AW88395_PLLS_START_BIT)
159 
160 #define AW88395_BIT_PLL_CHECK \
161 		(AW88395_CLKS_STABLE_VALUE | \
162 		AW88395_PLLS_LOCKED_VALUE)
163 
164 #define AW88395_BIT_SYSST_CHECK_MASK \
165 		(~(AW88395_UVLS_NORMAL_VALUE | \
166 		AW88395_BSTOCS_OVER_CURRENT_VALUE | \
167 		AW88395_BSTS_FINISHED_VALUE | \
168 		AW88395_SWS_SWITCHING_VALUE | \
169 		AW88395_NOCLKS_NO_CLOCK_VALUE | \
170 		AW88395_CLKS_STABLE_VALUE | \
171 		AW88395_OCDS_OC_VALUE | \
172 		AW88395_OTHS_OT_VALUE | \
173 		AW88395_PLLS_LOCKED_VALUE))
174 
175 #define AW88395_BIT_SYSST_CHECK \
176 		(AW88395_BSTS_FINISHED_VALUE | \
177 		AW88395_SWS_SWITCHING_VALUE | \
178 		AW88395_CLKS_STABLE_VALUE | \
179 		AW88395_PLLS_LOCKED_VALUE)
180 
181 #define AW88395_WDI_START_BIT		(6)
182 #define AW88395_WDI_INT_VALUE		(1)
183 #define AW88395_WDI_INTERRUPT		\
184 	(AW88395_WDI_INT_VALUE << AW88395_WDI_START_BIT)
185 
186 #define AW88395_NOCLKI_START_BIT	(5)
187 #define AW88395_NOCLKI_INT_VALUE	(1)
188 #define AW88395_NOCLKI_INTERRUPT	\
189 	(AW88395_NOCLKI_INT_VALUE << AW88395_NOCLKI_START_BIT)
190 
191 #define AW88395_CLKI_START_BIT		(4)
192 #define AW88395_CLKI_INT_VALUE		(1)
193 #define AW88395_CLKI_INTERRUPT		\
194 	(AW88395_CLKI_INT_VALUE << AW88395_CLKI_START_BIT)
195 
196 #define AW88395_PLLI_START_BIT		(0)
197 #define AW88395_PLLI_INT_VALUE		(1)
198 #define AW88395_PLLI_INTERRUPT		\
199 	(AW88395_PLLI_INT_VALUE << AW88395_PLLI_START_BIT)
200 
201 #define AW88395_BIT_SYSINT_CHECK \
202 		(AW88395_WDI_INTERRUPT | \
203 		AW88395_CLKI_INTERRUPT | \
204 		AW88395_NOCLKI_INTERRUPT | \
205 		AW88395_PLLI_INTERRUPT)
206 
207 #define AW88395_HMUTE_START_BIT	(8)
208 #define AW88395_HMUTE_BITS_LEN		(1)
209 #define AW88395_HMUTE_MASK		\
210 	(~(((1<<AW88395_HMUTE_BITS_LEN)-1) << AW88395_HMUTE_START_BIT))
211 
212 #define AW88395_HMUTE_DISABLE		(0)
213 #define AW88395_HMUTE_DISABLE_VALUE	\
214 	(AW88395_HMUTE_DISABLE << AW88395_HMUTE_START_BIT)
215 
216 #define AW88395_HMUTE_ENABLE		(1)
217 #define AW88395_HMUTE_ENABLE_VALUE	\
218 	(AW88395_HMUTE_ENABLE << AW88395_HMUTE_START_BIT)
219 
220 #define AW88395_RCV_MODE_START_BIT	(7)
221 #define AW88395_RCV_MODE_BITS_LEN	(1)
222 #define AW88395_RCV_MODE_MASK		\
223 	(~(((1<<AW88395_RCV_MODE_BITS_LEN)-1) << AW88395_RCV_MODE_START_BIT))
224 
225 #define AW88395_RCV_MODE_RECEIVER	(1)
226 #define AW88395_RCV_MODE_RECEIVER_VALUE	\
227 	(AW88395_RCV_MODE_RECEIVER << AW88395_RCV_MODE_START_BIT)
228 
229 #define AW88395_DSPBY_START_BIT	(2)
230 #define AW88395_DSPBY_BITS_LEN		(1)
231 #define AW88395_DSPBY_MASK		\
232 	(~(((1<<AW88395_DSPBY_BITS_LEN)-1) << AW88395_DSPBY_START_BIT))
233 
234 #define AW88395_DSPBY_WORKING		(0)
235 #define AW88395_DSPBY_WORKING_VALUE	\
236 	(AW88395_DSPBY_WORKING << AW88395_DSPBY_START_BIT)
237 
238 #define AW88395_DSPBY_BYPASS		(1)
239 #define AW88395_DSPBY_BYPASS_VALUE	\
240 	(AW88395_DSPBY_BYPASS << AW88395_DSPBY_START_BIT)
241 
242 #define AW88395_AMPPD_START_BIT	(1)
243 #define AW88395_AMPPD_BITS_LEN		(1)
244 #define AW88395_AMPPD_MASK		\
245 	(~(((1<<AW88395_AMPPD_BITS_LEN)-1) << AW88395_AMPPD_START_BIT))
246 
247 #define AW88395_AMPPD_WORKING		(0)
248 #define AW88395_AMPPD_WORKING_VALUE	\
249 	(AW88395_AMPPD_WORKING << AW88395_AMPPD_START_BIT)
250 
251 #define AW88395_AMPPD_POWER_DOWN	(1)
252 #define AW88395_AMPPD_POWER_DOWN_VALUE	\
253 	(AW88395_AMPPD_POWER_DOWN << AW88395_AMPPD_START_BIT)
254 
255 #define AW88395_PWDN_START_BIT		(0)
256 #define AW88395_PWDN_BITS_LEN		(1)
257 #define AW88395_PWDN_MASK		\
258 	(~(((1<<AW88395_PWDN_BITS_LEN)-1) << AW88395_PWDN_START_BIT))
259 
260 #define AW88395_PWDN_WORKING		(0)
261 #define AW88395_PWDN_WORKING_VALUE	\
262 	(AW88395_PWDN_WORKING << AW88395_PWDN_START_BIT)
263 
264 #define AW88395_PWDN_POWER_DOWN	(1)
265 #define AW88395_PWDN_POWER_DOWN_VALUE	\
266 	(AW88395_PWDN_POWER_DOWN << AW88395_PWDN_START_BIT)
267 
268 #define AW88395_MUTE_VOL		(90 * 8)
269 #define AW88395_VOLUME_STEP_DB		(6 * 8)
270 
271 #define AW88395_VOL_6DB_START		(6)
272 #define AW88395_VOL_START_BIT		(6)
273 #define AW88395_VOL_BITS_LEN		(10)
274 #define AW88395_VOL_MASK		\
275 	(~(((1<<AW88395_VOL_BITS_LEN)-1) << AW88395_VOL_START_BIT))
276 
277 #define AW88395_VOL_DEFAULT_VALUE	(0)
278 
279 #define AW88395_I2STXEN_START_BIT	(0)
280 #define AW88395_I2STXEN_BITS_LEN	(1)
281 #define AW88395_I2STXEN_MASK		\
282 	(~(((1<<AW88395_I2STXEN_BITS_LEN)-1) << AW88395_I2STXEN_START_BIT))
283 
284 #define AW88395_I2STXEN_DISABLE	(0)
285 #define AW88395_I2STXEN_DISABLE_VALUE	\
286 	(AW88395_I2STXEN_DISABLE << AW88395_I2STXEN_START_BIT)
287 
288 #define AW88395_I2STXEN_ENABLE		(1)
289 #define AW88395_I2STXEN_ENABLE_VALUE	\
290 	(AW88395_I2STXEN_ENABLE << AW88395_I2STXEN_START_BIT)
291 
292 #define AW88395_AGC_DSP_CTL_START_BIT	(15)
293 #define AW88395_AGC_DSP_CTL_BITS_LEN	(1)
294 #define AW88395_AGC_DSP_CTL_MASK	\
295 	(~(((1<<AW88395_AGC_DSP_CTL_BITS_LEN)-1) << AW88395_AGC_DSP_CTL_START_BIT))
296 
297 #define AW88395_AGC_DSP_CTL_DISABLE	(0)
298 #define AW88395_AGC_DSP_CTL_DISABLE_VALUE	\
299 	(AW88395_AGC_DSP_CTL_DISABLE << AW88395_AGC_DSP_CTL_START_BIT)
300 
301 #define AW88395_AGC_DSP_CTL_ENABLE	(1)
302 #define AW88395_AGC_DSP_CTL_ENABLE_VALUE	\
303 	(AW88395_AGC_DSP_CTL_ENABLE << AW88395_AGC_DSP_CTL_START_BIT)
304 
305 #define AW88395_VDSEL_START_BIT	(0)
306 #define AW88395_VDSEL_BITS_LEN		(1)
307 #define AW88395_VDSEL_MASK		\
308 	(~(((1<<AW88395_VDSEL_BITS_LEN)-1) << AW88395_VDSEL_START_BIT))
309 
310 #define AW88395_MEM_CLKSEL_START_BIT	(3)
311 #define AW88395_MEM_CLKSEL_BITS_LEN	(1)
312 #define AW88395_MEM_CLKSEL_MASK		\
313 	(~(((1<<AW88395_MEM_CLKSEL_BITS_LEN)-1) << AW88395_MEM_CLKSEL_START_BIT))
314 
315 #define AW88395_MEM_CLKSEL_OSC_CLK	(0)
316 #define AW88395_MEM_CLKSEL_OSC_CLK_VALUE	\
317 	(AW88395_MEM_CLKSEL_OSC_CLK << AW88395_MEM_CLKSEL_START_BIT)
318 
319 #define AW88395_MEM_CLKSEL_DAP_HCLK	(1)
320 #define AW88395_MEM_CLKSEL_DAP_HCLK_VALUE	\
321 	(AW88395_MEM_CLKSEL_DAP_HCLK << AW88395_MEM_CLKSEL_START_BIT)
322 
323 #define AW88395_CCO_MUX_START_BIT	(14)
324 #define AW88395_CCO_MUX_BITS_LEN	(1)
325 #define AW88395_CCO_MUX_MASK		\
326 	(~(((1<<AW88395_CCO_MUX_BITS_LEN)-1) << AW88395_CCO_MUX_START_BIT))
327 
328 #define AW88395_CCO_MUX_DIVIDED	(0)
329 #define AW88395_CCO_MUX_DIVIDED_VALUE	\
330 	(AW88395_CCO_MUX_DIVIDED << AW88395_CCO_MUX_START_BIT)
331 
332 #define AW88395_CCO_MUX_BYPASS		(1)
333 #define AW88395_CCO_MUX_BYPASS_VALUE	\
334 	(AW88395_CCO_MUX_BYPASS << AW88395_CCO_MUX_START_BIT)
335 
336 #define AW88395_EF_VSN_GESLP_START_BIT	(0)
337 #define AW88395_EF_VSN_GESLP_BITS_LEN	(10)
338 #define AW88395_EF_VSN_GESLP_MASK	\
339 	(~(((1<<AW88395_EF_VSN_GESLP_BITS_LEN)-1) << AW88395_EF_VSN_GESLP_START_BIT))
340 
341 #define AW88395_EF_VSN_GESLP_SIGN_MASK	(~(1 << 9))
342 #define AW88395_EF_VSN_GESLP_SIGN_NEG	(0xfe00)
343 
344 #define AW88395_EF_ISN_GESLP_START_BIT	(0)
345 #define AW88395_EF_ISN_GESLP_BITS_LEN	(10)
346 #define AW88395_EF_ISN_GESLP_MASK	\
347 	(~(((1<<AW88395_EF_ISN_GESLP_BITS_LEN)-1) << AW88395_EF_ISN_GESLP_START_BIT))
348 
349 #define AW88395_EF_ISN_GESLP_SIGN_MASK	(~(1 << 9))
350 #define AW88395_EF_ISN_GESLP_SIGN_NEG	(0xfe00)
351 
352 #define AW88395_CABL_BASE_VALUE	(1000)
353 #define AW88395_ICABLK_FACTOR		(1)
354 #define AW88395_VCABLK_FACTOR		(1)
355 #define AW88395_VCAL_FACTOR		(1 << 12)
356 #define AW88395_VSCAL_FACTOR		(16500)
357 #define AW88395_ISCAL_FACTOR		(3667)
358 #define AW88395_EF_VSENSE_GAIN_SHIFT	(0)
359 
360 #define AW88395_VCABLK_FACTOR_DAC	(2)
361 #define AW88395_VSCAL_FACTOR_DAC	(11790)
362 #define AW88395_EF_DAC_GESLP_SHIFT	(10)
363 #define AW88395_EF_DAC_GESLP_SIGN_MASK	(1 << 5)
364 #define AW88395_EF_DAC_GESLP_SIGN_NEG	(0xffc0)
365 
366 #define AW88395_VCALB_ADJ_FACTOR	(12)
367 
368 #define AW88395_WDT_CNT_START_BIT	(0)
369 #define AW88395_WDT_CNT_BITS_LEN	(8)
370 #define AW88395_WDT_CNT_MASK		\
371 	(~(((1<<AW88395_WDT_CNT_BITS_LEN)-1) << AW88395_WDT_CNT_START_BIT))
372 
373 #define AW88395_DSP_CFG_ADDR		(0x9C80)
374 #define AW88395_DSP_FW_ADDR		(0x8C00)
375 #define AW88395_DSP_REG_VMAX		(0x9C94)
376 #define AW88395_DSP_REG_CFG_ADPZ_RE	(0x9D00)
377 #define AW88395_DSP_REG_VCALB		(0x9CF7)
378 #define AW88395_DSP_RE_SHIFT		(12)
379 
380 #define AW88395_DSP_REG_CFG_ADPZ_RA	(0x9D02)
381 #define AW88395_DSP_REG_CRC_ADDR	(0x9F42)
382 #define AW88395_DSP_CALI_F0_DELAY	(0x9CFD)
383 
384 #endif
385