xref: /linux/sound/soc/codecs/aw88261.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1028a2ae2SWeidong Wang // SPDX-License-Identifier: GPL-2.0-only
2028a2ae2SWeidong Wang //
3028a2ae2SWeidong Wang // aw88261.h  --  AW88261 ALSA SoC Audio driver
4028a2ae2SWeidong Wang //
5028a2ae2SWeidong Wang // Copyright (c) 2023 awinic Technology CO., LTD
6028a2ae2SWeidong Wang //
7028a2ae2SWeidong Wang // Author: Jimmy Zhang <zhangjianming@awinic.com>
8028a2ae2SWeidong Wang // Author: Weidong Wang <wangweidong.a@awinic.com>
9028a2ae2SWeidong Wang //
10028a2ae2SWeidong Wang 
11028a2ae2SWeidong Wang #ifndef __AW88261_H__
12028a2ae2SWeidong Wang #define __AW88261_H__
13028a2ae2SWeidong Wang 
14028a2ae2SWeidong Wang #define AW88261_ID_REG			(0x00)
15028a2ae2SWeidong Wang #define AW88261_SYSST_REG		(0x01)
16028a2ae2SWeidong Wang #define AW88261_SYSINT_REG		(0x02)
17028a2ae2SWeidong Wang #define AW88261_SYSINTM_REG		(0x03)
18028a2ae2SWeidong Wang #define AW88261_SYSCTRL_REG		(0x04)
19028a2ae2SWeidong Wang #define AW88261_SYSCTRL2_REG		(0x05)
20028a2ae2SWeidong Wang #define AW88261_I2SCTRL1_REG		(0x06)
21028a2ae2SWeidong Wang #define AW88261_I2SCTRL2_REG		(0x07)
22028a2ae2SWeidong Wang #define AW88261_I2SCTRL3_REG		(0x08)
23028a2ae2SWeidong Wang #define AW88261_DACCFG1_REG		(0x09)
24028a2ae2SWeidong Wang #define AW88261_DACCFG2_REG		(0x0A)
25028a2ae2SWeidong Wang #define AW88261_DACCFG3_REG		(0x0B)
26028a2ae2SWeidong Wang #define AW88261_DACCFG4_REG		(0x0C)
27028a2ae2SWeidong Wang #define AW88261_DACCFG5_REG		(0x0D)
28028a2ae2SWeidong Wang #define AW88261_DACCFG6_REG		(0x0E)
29028a2ae2SWeidong Wang #define AW88261_DACCFG7_REG		(0x0F)
30028a2ae2SWeidong Wang #define AW88261_DACCFG8_REG		(0x10)
31028a2ae2SWeidong Wang #define AW88261_PWMCTRL1_REG		(0x11)
32028a2ae2SWeidong Wang #define AW88261_PWMCTRL2_REG		(0x12)
33028a2ae2SWeidong Wang #define AW88261_I2SCFG1_REG		(0x13)
34028a2ae2SWeidong Wang #define AW88261_DBGCTRL_REG		(0x14)
35028a2ae2SWeidong Wang #define AW88261_DACCFG9_REG		(0x15)
36028a2ae2SWeidong Wang #define AW88261_DACCFG10_REG		(0x16)
37028a2ae2SWeidong Wang #define AW88261_DACST_REG		(0x20)
38028a2ae2SWeidong Wang #define AW88261_VBAT_REG		(0x21)
39028a2ae2SWeidong Wang #define AW88261_TEMP_REG		(0x22)
40028a2ae2SWeidong Wang #define AW88261_PVDD_REG		(0x23)
41028a2ae2SWeidong Wang #define AW88261_ISNDAT_REG		(0x24)
42028a2ae2SWeidong Wang #define AW88261_VSNDAT_REG		(0x25)
43028a2ae2SWeidong Wang #define AW88261_I2SINT_REG		(0x26)
44028a2ae2SWeidong Wang #define AW88261_I2SCAPCNT_REG		(0x27)
45028a2ae2SWeidong Wang #define AW88261_ANASTA1_REG		(0x28)
46028a2ae2SWeidong Wang #define AW88261_ANASTA2_REG		(0x29)
47028a2ae2SWeidong Wang #define AW88261_ANASTA3_REG		(0x2A)
48028a2ae2SWeidong Wang #define AW88261_TESTDET_REG		(0x2B)
49028a2ae2SWeidong Wang #define AW88261_DSMCFG1_REG		(0x30)
50028a2ae2SWeidong Wang #define AW88261_DSMCFG2_REG		(0x31)
51028a2ae2SWeidong Wang #define AW88261_DSMCFG3_REG		(0x32)
52028a2ae2SWeidong Wang #define AW88261_DSMCFG4_REG		(0x33)
53028a2ae2SWeidong Wang #define AW88261_DSMCFG5_REG		(0x34)
54028a2ae2SWeidong Wang #define AW88261_DSMCFG6_REG		(0x35)
55028a2ae2SWeidong Wang #define AW88261_DSMCFG7_REG		(0x36)
56028a2ae2SWeidong Wang #define AW88261_DSMCFG8_REG		(0x37)
57028a2ae2SWeidong Wang #define AW88261_TESTIN_REG		(0x38)
58028a2ae2SWeidong Wang #define AW88261_TESTOUT_REG		(0x39)
59028a2ae2SWeidong Wang #define AW88261_SADCCTRL1_REG		(0x3A)
60028a2ae2SWeidong Wang #define AW88261_SADCCTRL2_REG		(0x3B)
61028a2ae2SWeidong Wang #define AW88261_SADCCTRL3_REG		(0x3C)
62028a2ae2SWeidong Wang #define AW88261_SADCCTRL4_REG		(0x3D)
63028a2ae2SWeidong Wang #define AW88261_SADCCTRL5_REG		(0x3E)
64028a2ae2SWeidong Wang #define AW88261_SADCCTRL6_REG		(0x3F)
65028a2ae2SWeidong Wang #define AW88261_SADCCTRL7_REG		(0x40)
66028a2ae2SWeidong Wang #define AW88261_VSNTM1_REG		(0x50)
67028a2ae2SWeidong Wang #define AW88261_VSNTM2_REG		(0x51)
68028a2ae2SWeidong Wang #define AW88261_ISNCTRL1_REG		(0x52)
69028a2ae2SWeidong Wang #define AW88261_ISNCTRL2_REG		(0x53)
70028a2ae2SWeidong Wang #define AW88261_PLLCTRL1_REG		(0x54)
71028a2ae2SWeidong Wang #define AW88261_PLLCTRL2_REG		(0x55)
72028a2ae2SWeidong Wang #define AW88261_PLLCTRL3_REG		(0x56)
73028a2ae2SWeidong Wang #define AW88261_CDACTRL1_REG		(0x57)
74028a2ae2SWeidong Wang #define AW88261_CDACTRL2_REG		(0x58)
75028a2ae2SWeidong Wang #define AW88261_DITHERCFG1_REG		(0x59)
76028a2ae2SWeidong Wang #define AW88261_DITHERCFG2_REG		(0x5A)
77028a2ae2SWeidong Wang #define AW88261_DITHERCFG3_REG		(0x5B)
78028a2ae2SWeidong Wang #define AW88261_CPCTRL_REG		(0x5C)
79028a2ae2SWeidong Wang #define AW88261_BSTCTRL1_REG		(0x60)
80028a2ae2SWeidong Wang #define AW88261_BSTCTRL2_REG		(0x61)
81028a2ae2SWeidong Wang #define AW88261_BSTCTRL3_REG		(0x62)
82028a2ae2SWeidong Wang #define AW88261_BSTCTRL4_REG		(0x63)
83028a2ae2SWeidong Wang #define AW88261_BSTCTRL5_REG		(0x64)
84028a2ae2SWeidong Wang #define AW88261_BSTCTRL6_REG		(0x65)
85028a2ae2SWeidong Wang #define AW88261_BSTCTRL7_REG		(0x66)
86028a2ae2SWeidong Wang #define AW88261_BSTCTRL8_REG		(0x67)
87028a2ae2SWeidong Wang #define AW88261_BSTCTRL9_REG		(0x68)
88028a2ae2SWeidong Wang #define AW88261_TM_REG			(0x6F)
89028a2ae2SWeidong Wang #define AW88261_TESTCTRL1_REG		(0x70)
90028a2ae2SWeidong Wang #define AW88261_TESTCTRL2_REG		(0x71)
91028a2ae2SWeidong Wang #define AW88261_EFCTRL1_REG		(0x72)
92028a2ae2SWeidong Wang #define AW88261_EFCTRL2_REG		(0x73)
93028a2ae2SWeidong Wang #define AW88261_EFWH_REG		(0x74)
94028a2ae2SWeidong Wang #define AW88261_EFWM2_REG		(0x75)
95028a2ae2SWeidong Wang #define AW88261_EFWM1_REG		(0x76)
96028a2ae2SWeidong Wang #define AW88261_EFWL_REG		(0x77)
97028a2ae2SWeidong Wang #define AW88261_EFRH4_REG		(0x78)
98028a2ae2SWeidong Wang #define AW88261_EFRH3_REG		(0x79)
99028a2ae2SWeidong Wang #define AW88261_EFRH2_REG		(0x7A)
100028a2ae2SWeidong Wang #define AW88261_EFRH1_REG		(0x7B)
101028a2ae2SWeidong Wang #define AW88261_EFRL4_REG		(0x7C)
102028a2ae2SWeidong Wang #define AW88261_EFRL3_REG		(0x7D)
103028a2ae2SWeidong Wang #define AW88261_EFRL2_REG		(0x7E)
104028a2ae2SWeidong Wang #define AW88261_EFRL1_REG		(0x7F)
105028a2ae2SWeidong Wang 
106028a2ae2SWeidong Wang #define AW88261_REG_MAX		(0x80)
107028a2ae2SWeidong Wang #define AW88261_EF_DBMD_MASK		(0xfff7)
108028a2ae2SWeidong Wang #define AW88261_OR_VALUE		(0x0008)
109028a2ae2SWeidong Wang 
110028a2ae2SWeidong Wang #define AW88261_TEMH_MASK		(0x83ff)
111028a2ae2SWeidong Wang #define AW88261_TEML_MASK		(0x83ff)
112028a2ae2SWeidong Wang #define AW88261_DEFAULT_CFG		(0x0000)
113028a2ae2SWeidong Wang 
114028a2ae2SWeidong Wang #define AW88261_ICALK_SHIFT		(0)
115028a2ae2SWeidong Wang #define AW88261_ICALKL_SHIFT		(0)
116028a2ae2SWeidong Wang #define AW88261_VCALK_SHIFT		(0)
117028a2ae2SWeidong Wang #define AW88261_VCALKL_SHIFT		(0)
118028a2ae2SWeidong Wang 
119028a2ae2SWeidong Wang #define AW88261_AMPPD_START_BIT	(1)
120028a2ae2SWeidong Wang #define AW88261_AMPPD_BITS_LEN		(1)
121028a2ae2SWeidong Wang #define AW88261_AMPPD_MASK		\
122028a2ae2SWeidong Wang 	(~(((1<<AW88261_AMPPD_BITS_LEN)-1) << AW88261_AMPPD_START_BIT))
123028a2ae2SWeidong Wang 
124028a2ae2SWeidong Wang #define AW88261_UVLS_START_BIT		(14)
125028a2ae2SWeidong Wang #define AW88261_UVLS_NORMAL		(0)
126028a2ae2SWeidong Wang #define AW88261_UVLS_NORMAL_VALUE	\
127028a2ae2SWeidong Wang 	(AW88261_UVLS_NORMAL << AW88261_UVLS_START_BIT)
128028a2ae2SWeidong Wang 
129028a2ae2SWeidong Wang #define AW88261_BSTOCS_START_BIT	(11)
130028a2ae2SWeidong Wang #define AW88261_BSTOCS_OVER_CURRENT	(1)
131028a2ae2SWeidong Wang #define AW88261_BSTOCS_OVER_CURRENT_VALUE	\
132028a2ae2SWeidong Wang 	(AW88261_BSTOCS_OVER_CURRENT << AW88261_BSTOCS_START_BIT)
133028a2ae2SWeidong Wang 
134028a2ae2SWeidong Wang #define AW88261_BSTS_START_BIT		(9)
135028a2ae2SWeidong Wang #define AW88261_BSTS_FINISHED		(1)
136028a2ae2SWeidong Wang #define AW88261_BSTS_FINISHED_VALUE	\
137028a2ae2SWeidong Wang 	(AW88261_BSTS_FINISHED << AW88261_BSTS_START_BIT)
138028a2ae2SWeidong Wang 
139028a2ae2SWeidong Wang #define AW88261_SWS_START_BIT		(8)
140028a2ae2SWeidong Wang #define AW88261_SWS_SWITCHING		(1)
141028a2ae2SWeidong Wang #define AW88261_SWS_SWITCHING_VALUE	\
142028a2ae2SWeidong Wang 	(AW88261_SWS_SWITCHING << AW88261_SWS_START_BIT)
143028a2ae2SWeidong Wang 
144028a2ae2SWeidong Wang #define AW88261_NOCLKS_START_BIT	(5)
145028a2ae2SWeidong Wang #define AW88261_NOCLKS_NO_CLOCK	(1)
146028a2ae2SWeidong Wang #define AW88261_NOCLKS_NO_CLOCK_VALUE	\
147028a2ae2SWeidong Wang 	(AW88261_NOCLKS_NO_CLOCK << AW88261_NOCLKS_START_BIT)
148028a2ae2SWeidong Wang 
149028a2ae2SWeidong Wang #define AW88261_CLKS_START_BIT		(4)
150028a2ae2SWeidong Wang #define AW88261_CLKS_STABLE		(1)
151028a2ae2SWeidong Wang #define AW88261_CLKS_STABLE_VALUE	\
152028a2ae2SWeidong Wang 	(AW88261_CLKS_STABLE << AW88261_CLKS_START_BIT)
153028a2ae2SWeidong Wang 
154028a2ae2SWeidong Wang #define AW88261_OCDS_START_BIT		(3)
155028a2ae2SWeidong Wang #define AW88261_OCDS_OC		(1)
156028a2ae2SWeidong Wang #define AW88261_OCDS_OC_VALUE		\
157028a2ae2SWeidong Wang 	(AW88261_OCDS_OC << AW88261_OCDS_START_BIT)
158028a2ae2SWeidong Wang 
159028a2ae2SWeidong Wang #define AW88261_OTHS_START_BIT		(1)
160028a2ae2SWeidong Wang #define AW88261_OTHS_OT		(1)
161028a2ae2SWeidong Wang #define AW88261_OTHS_OT_VALUE		\
162028a2ae2SWeidong Wang 	(AW88261_OTHS_OT << AW88261_OTHS_START_BIT)
163028a2ae2SWeidong Wang 
164028a2ae2SWeidong Wang #define AW88261_PLLS_START_BIT		(0)
165028a2ae2SWeidong Wang #define AW88261_PLLS_LOCKED		(1)
166028a2ae2SWeidong Wang #define AW88261_PLLS_LOCKED_VALUE	\
167028a2ae2SWeidong Wang 	(AW88261_PLLS_LOCKED << AW88261_PLLS_START_BIT)
168028a2ae2SWeidong Wang 
169028a2ae2SWeidong Wang #define AW88261_BIT_PLL_CHECK \
170028a2ae2SWeidong Wang 		(AW88261_CLKS_STABLE_VALUE | \
171028a2ae2SWeidong Wang 		AW88261_PLLS_LOCKED_VALUE)
172028a2ae2SWeidong Wang 
173028a2ae2SWeidong Wang #define AW88261_BIT_SYSST_CHECK_MASK \
174028a2ae2SWeidong Wang 		(~(AW88261_UVLS_NORMAL_VALUE | \
175028a2ae2SWeidong Wang 		AW88261_BSTOCS_OVER_CURRENT_VALUE | \
176028a2ae2SWeidong Wang 		AW88261_BSTS_FINISHED_VALUE | \
177028a2ae2SWeidong Wang 		AW88261_SWS_SWITCHING_VALUE | \
178028a2ae2SWeidong Wang 		AW88261_NOCLKS_NO_CLOCK_VALUE | \
179028a2ae2SWeidong Wang 		AW88261_CLKS_STABLE_VALUE | \
180028a2ae2SWeidong Wang 		AW88261_OCDS_OC_VALUE | \
181028a2ae2SWeidong Wang 		AW88261_OTHS_OT_VALUE | \
182028a2ae2SWeidong Wang 		AW88261_PLLS_LOCKED_VALUE))
183028a2ae2SWeidong Wang 
184028a2ae2SWeidong Wang #define AW88261_BIT_SYSST_CHECK \
185028a2ae2SWeidong Wang 		(AW88261_BSTS_FINISHED_VALUE | \
186028a2ae2SWeidong Wang 		AW88261_SWS_SWITCHING_VALUE | \
187028a2ae2SWeidong Wang 		AW88261_CLKS_STABLE_VALUE | \
188028a2ae2SWeidong Wang 		AW88261_PLLS_LOCKED_VALUE)
189028a2ae2SWeidong Wang 
190028a2ae2SWeidong Wang #define AW88261_ULS_HMUTE_START_BIT	(14)
191028a2ae2SWeidong Wang #define AW88261_ULS_HMUTE_BITS_LEN	(1)
192028a2ae2SWeidong Wang #define AW88261_ULS_HMUTE_MASK		\
193028a2ae2SWeidong Wang 	(~(((1<<AW88261_ULS_HMUTE_BITS_LEN)-1) << AW88261_ULS_HMUTE_START_BIT))
194028a2ae2SWeidong Wang 
195028a2ae2SWeidong Wang #define AW88261_ULS_HMUTE_DISABLE	(0)
196028a2ae2SWeidong Wang #define AW88261_ULS_HMUTE_DISABLE_VALUE	\
197028a2ae2SWeidong Wang 	(AW88261_ULS_HMUTE_DISABLE << AW88261_ULS_HMUTE_START_BIT)
198028a2ae2SWeidong Wang 
199028a2ae2SWeidong Wang #define AW88261_ULS_HMUTE_ENABLE	(1)
200028a2ae2SWeidong Wang #define AW88261_ULS_HMUTE_ENABLE_VALUE	\
201028a2ae2SWeidong Wang 	(AW88261_ULS_HMUTE_ENABLE << AW88261_ULS_HMUTE_START_BIT)
202028a2ae2SWeidong Wang 
203028a2ae2SWeidong Wang #define AW88261_HMUTE_START_BIT	(8)
204028a2ae2SWeidong Wang #define AW88261_HMUTE_BITS_LEN		(1)
205028a2ae2SWeidong Wang #define AW88261_HMUTE_MASK		\
206028a2ae2SWeidong Wang 	(~(((1<<AW88261_HMUTE_BITS_LEN)-1) << AW88261_HMUTE_START_BIT))
207028a2ae2SWeidong Wang 
208028a2ae2SWeidong Wang #define AW88261_HMUTE_DISABLE		(0)
209028a2ae2SWeidong Wang #define AW88261_HMUTE_DISABLE_VALUE	\
210028a2ae2SWeidong Wang 	(AW88261_HMUTE_DISABLE << AW88261_HMUTE_START_BIT)
211028a2ae2SWeidong Wang 
212028a2ae2SWeidong Wang #define AW88261_HMUTE_ENABLE		(1)
213028a2ae2SWeidong Wang #define AW88261_HMUTE_ENABLE_VALUE	\
214028a2ae2SWeidong Wang 	(AW88261_HMUTE_ENABLE << AW88261_HMUTE_START_BIT)
215028a2ae2SWeidong Wang 
216028a2ae2SWeidong Wang #define AW88261_AMPPD_START_BIT	(1)
217028a2ae2SWeidong Wang #define AW88261_AMPPD_BITS_LEN		(1)
218028a2ae2SWeidong Wang #define AW88261_AMPPD_MASK		\
219028a2ae2SWeidong Wang 	(~(((1<<AW88261_AMPPD_BITS_LEN)-1) << AW88261_AMPPD_START_BIT))
220028a2ae2SWeidong Wang 
221028a2ae2SWeidong Wang #define AW88261_AMPPD_WORKING		(0)
222028a2ae2SWeidong Wang #define AW88261_AMPPD_WORKING_VALUE	\
223028a2ae2SWeidong Wang 	(AW88261_AMPPD_WORKING << AW88261_AMPPD_START_BIT)
224028a2ae2SWeidong Wang 
225028a2ae2SWeidong Wang #define AW88261_AMPPD_POWER_DOWN	(1)
226028a2ae2SWeidong Wang #define AW88261_AMPPD_POWER_DOWN_VALUE	\
227028a2ae2SWeidong Wang 	(AW88261_AMPPD_POWER_DOWN << AW88261_AMPPD_START_BIT)
228028a2ae2SWeidong Wang 
229028a2ae2SWeidong Wang #define AW88261_PWDN_START_BIT		(0)
230028a2ae2SWeidong Wang #define AW88261_PWDN_BITS_LEN		(1)
231028a2ae2SWeidong Wang #define AW88261_PWDN_MASK		\
232028a2ae2SWeidong Wang 	(~(((1<<AW88261_PWDN_BITS_LEN)-1) << AW88261_PWDN_START_BIT))
233028a2ae2SWeidong Wang 
234028a2ae2SWeidong Wang #define AW88261_PWDN_WORKING		(0)
235028a2ae2SWeidong Wang #define AW88261_PWDN_WORKING_VALUE	\
236028a2ae2SWeidong Wang 	(AW88261_PWDN_WORKING << AW88261_PWDN_START_BIT)
237028a2ae2SWeidong Wang 
238028a2ae2SWeidong Wang #define AW88261_PWDN_POWER_DOWN	(1)
239028a2ae2SWeidong Wang #define AW88261_PWDN_POWER_DOWN_VALUE	\
240028a2ae2SWeidong Wang 	(AW88261_PWDN_POWER_DOWN << AW88261_PWDN_START_BIT)
241028a2ae2SWeidong Wang 
242028a2ae2SWeidong Wang #define AW88261_MUTE_VOL		(90 * 8)
243028a2ae2SWeidong Wang #define AW88261_VOLUME_STEP_DB		(6 * 8)
244028a2ae2SWeidong Wang 
245028a2ae2SWeidong Wang #define AW88261_VOL_6DB_START		(6)
246028a2ae2SWeidong Wang 
247028a2ae2SWeidong Wang #define AW88261_VOL_START_BIT		(0)
248028a2ae2SWeidong Wang #define AW88261_VOL_BITS_LEN		(10)
249028a2ae2SWeidong Wang #define AW88261_VOL_MASK		\
250028a2ae2SWeidong Wang 	(~(((1<<AW88261_VOL_BITS_LEN)-1) << AW88261_VOL_START_BIT))
251028a2ae2SWeidong Wang 
252028a2ae2SWeidong Wang #define AW88261_VOL_DEFAULT_VALUE	(0)
253028a2ae2SWeidong Wang 
254028a2ae2SWeidong Wang #define AW88261_I2STXEN_START_BIT	(6)
255028a2ae2SWeidong Wang #define AW88261_I2STXEN_BITS_LEN	(1)
256028a2ae2SWeidong Wang #define AW88261_I2STXEN_MASK		\
257028a2ae2SWeidong Wang 	(~(((1<<AW88261_I2STXEN_BITS_LEN)-1) << AW88261_I2STXEN_START_BIT))
258028a2ae2SWeidong Wang 
259028a2ae2SWeidong Wang #define AW88261_I2STXEN_DISABLE	(0)
260028a2ae2SWeidong Wang #define AW88261_I2STXEN_DISABLE_VALUE	\
261028a2ae2SWeidong Wang 	(AW88261_I2STXEN_DISABLE << AW88261_I2STXEN_START_BIT)
262028a2ae2SWeidong Wang 
263028a2ae2SWeidong Wang #define AW88261_I2STXEN_ENABLE		(1)
264028a2ae2SWeidong Wang #define AW88261_I2STXEN_ENABLE_VALUE	\
265028a2ae2SWeidong Wang 	(AW88261_I2STXEN_ENABLE << AW88261_I2STXEN_START_BIT)
266028a2ae2SWeidong Wang 
267028a2ae2SWeidong Wang #define AW88261_CCO_MUX_START_BIT	(14)
268028a2ae2SWeidong Wang #define AW88261_CCO_MUX_BITS_LEN	(1)
269028a2ae2SWeidong Wang #define AW88261_CCO_MUX_MASK		\
270028a2ae2SWeidong Wang 	(~(((1<<AW88261_CCO_MUX_BITS_LEN)-1) << AW88261_CCO_MUX_START_BIT))
271028a2ae2SWeidong Wang 
272028a2ae2SWeidong Wang #define AW88261_CCO_MUX_DIVIDED	(0)
273028a2ae2SWeidong Wang #define AW88261_CCO_MUX_DIVIDED_VALUE	\
274028a2ae2SWeidong Wang 	(AW88261_CCO_MUX_DIVIDED << AW88261_CCO_MUX_START_BIT)
275028a2ae2SWeidong Wang 
276028a2ae2SWeidong Wang #define AW88261_CCO_MUX_BYPASS		(1)
277028a2ae2SWeidong Wang #define AW88261_CCO_MUX_BYPASS_VALUE	\
278028a2ae2SWeidong Wang 	(AW88261_CCO_MUX_BYPASS << AW88261_CCO_MUX_START_BIT)
279028a2ae2SWeidong Wang 
280028a2ae2SWeidong Wang #define AW88261_EF_VSN_GESLP_H_START_BIT	(0)
281028a2ae2SWeidong Wang #define AW88261_EF_VSN_GESLP_H_BITS_LEN	(10)
282028a2ae2SWeidong Wang #define AW88261_EF_VSN_GESLP_H_MASK		\
283028a2ae2SWeidong Wang 	(~(((1<<AW88261_EF_VSN_GESLP_H_BITS_LEN)-1) << AW88261_EF_VSN_GESLP_H_START_BIT))
284028a2ae2SWeidong Wang 
285028a2ae2SWeidong Wang #define AW88261_EF_VSN_GESLP_L_START_BIT	(0)
286028a2ae2SWeidong Wang #define AW88261_EF_VSN_GESLP_L_BITS_LEN	(10)
287028a2ae2SWeidong Wang #define AW88261_EF_VSN_GESLP_L_MASK		\
288028a2ae2SWeidong Wang 	(~(((1<<AW88261_EF_VSN_GESLP_L_BITS_LEN)-1) << AW88261_EF_VSN_GESLP_L_START_BIT))
289028a2ae2SWeidong Wang 
290028a2ae2SWeidong Wang #define AW88261_FORCE_PWM_START_BIT		(12)
291028a2ae2SWeidong Wang #define AW88261_FORCE_PWM_BITS_LEN		(1)
292028a2ae2SWeidong Wang #define AW88261_FORCE_PWM_MASK			\
293028a2ae2SWeidong Wang 	(~(((1<<AW88261_FORCE_PWM_BITS_LEN)-1) << AW88261_FORCE_PWM_START_BIT))
294028a2ae2SWeidong Wang 
295028a2ae2SWeidong Wang #define AW88261_FORCE_PWM_FORCEMINUS_PWM	(1)
296028a2ae2SWeidong Wang #define AW88261_FORCE_PWM_FORCEMINUS_PWM_VALUE	\
297028a2ae2SWeidong Wang 	(AW88261_FORCE_PWM_FORCEMINUS_PWM << AW88261_FORCE_PWM_START_BIT)
298028a2ae2SWeidong Wang 
299028a2ae2SWeidong Wang #define AW88261_BST_OS_WIDTH_START_BIT		(0)
300028a2ae2SWeidong Wang #define AW88261_BST_OS_WIDTH_BITS_LEN		(3)
301028a2ae2SWeidong Wang #define AW88261_BST_OS_WIDTH_MASK		\
302028a2ae2SWeidong Wang 	(~(((1<<AW88261_BST_OS_WIDTH_BITS_LEN)-1) << AW88261_BST_OS_WIDTH_START_BIT))
303028a2ae2SWeidong Wang 
304028a2ae2SWeidong Wang #define AW88261_BST_OS_WIDTH_50NS		(4)
305028a2ae2SWeidong Wang #define AW88261_BST_OS_WIDTH_50NS_VALUE	\
306028a2ae2SWeidong Wang 	(AW88261_BST_OS_WIDTH_50NS << AW88261_BST_OS_WIDTH_START_BIT)
307028a2ae2SWeidong Wang 
308028a2ae2SWeidong Wang /* BST_LOOPR bit 1:0 (BSTCTRL6 0x65) */
309028a2ae2SWeidong Wang #define AW88261_BST_LOOPR_START_BIT	(0)
310028a2ae2SWeidong Wang #define AW88261_BST_LOOPR_BITS_LEN	(2)
311028a2ae2SWeidong Wang #define AW88261_BST_LOOPR_MASK		\
312028a2ae2SWeidong Wang 	(~(((1<<AW88261_BST_LOOPR_BITS_LEN)-1) << AW88261_BST_LOOPR_START_BIT))
313028a2ae2SWeidong Wang 
314028a2ae2SWeidong Wang #define AW88261_BST_LOOPR_340K		(2)
315028a2ae2SWeidong Wang #define AW88261_BST_LOOPR_340K_VALUE	\
316028a2ae2SWeidong Wang 	(AW88261_BST_LOOPR_340K << AW88261_BST_LOOPR_START_BIT)
317028a2ae2SWeidong Wang 
318028a2ae2SWeidong Wang /* RSQN_DLY bit 15:14 (BSTCTRL7 0x66) */
319028a2ae2SWeidong Wang #define AW88261_RSQN_DLY_START_BIT	(14)
320028a2ae2SWeidong Wang #define AW88261_RSQN_DLY_BITS_LEN	(2)
321028a2ae2SWeidong Wang #define AW88261_RSQN_DLY_MASK		\
322028a2ae2SWeidong Wang 	(~(((1<<AW88261_RSQN_DLY_BITS_LEN)-1) << AW88261_RSQN_DLY_START_BIT))
323028a2ae2SWeidong Wang 
324028a2ae2SWeidong Wang #define AW88261_RSQN_DLY_35NS		(2)
325028a2ae2SWeidong Wang #define AW88261_RSQN_DLY_35NS_VALUE	\
326028a2ae2SWeidong Wang 	(AW88261_RSQN_DLY_35NS << AW88261_RSQN_DLY_START_BIT)
327028a2ae2SWeidong Wang 
328028a2ae2SWeidong Wang /* BURST_SSMODE bit 3 (BSTCTRL8 0x67) */
329028a2ae2SWeidong Wang #define AW88261_BURST_SSMODE_START_BIT	(3)
330028a2ae2SWeidong Wang #define AW88261_BURST_SSMODE_BITS_LEN	(1)
331028a2ae2SWeidong Wang #define AW88261_BURST_SSMODE_MASK	\
332028a2ae2SWeidong Wang 	(~(((1<<AW88261_BURST_SSMODE_BITS_LEN)-1) << AW88261_BURST_SSMODE_START_BIT))
333028a2ae2SWeidong Wang 
334028a2ae2SWeidong Wang #define AW88261_BURST_SSMODE_FAST	(0)
335028a2ae2SWeidong Wang #define AW88261_BURST_SSMODE_FAST_VALUE	\
336028a2ae2SWeidong Wang 	(AW88261_BURST_SSMODE_FAST << AW88261_BURST_SSMODE_START_BIT)
337028a2ae2SWeidong Wang 
338028a2ae2SWeidong Wang /* BST_BURST bit 9:7 (BSTCTRL9 0x68) */
339028a2ae2SWeidong Wang #define AW88261_BST_BURST_START_BIT	(7)
340028a2ae2SWeidong Wang #define AW88261_BST_BURST_BITS_LEN	(3)
341028a2ae2SWeidong Wang #define AW88261_BST_BURST_MASK		\
342028a2ae2SWeidong Wang 	(~(((1<<AW88261_BST_BURST_BITS_LEN)-1) << AW88261_BST_BURST_START_BIT))
343028a2ae2SWeidong Wang 
344028a2ae2SWeidong Wang #define AW88261_BST_BURST_30MA		(2)
345028a2ae2SWeidong Wang #define AW88261_BST_BURST_30MA_VALUE	\
346028a2ae2SWeidong Wang 	(AW88261_BST_BURST_30MA << AW88261_BST_BURST_START_BIT)
347028a2ae2SWeidong Wang 
348028a2ae2SWeidong Wang #define AW88261_EF_VSN_GESLP_SIGN_MASK		(~0x0200)
349028a2ae2SWeidong Wang #define AW88261_EF_VSN_GESLP_NEG		(~0xfc00)
350028a2ae2SWeidong Wang 
351028a2ae2SWeidong Wang #define AW88261_EF_ISN_GESLP_SIGN_MASK		(~0x0200)
352028a2ae2SWeidong Wang #define AW88261_EF_ISN_GESLP_NEG		(~0xfc00)
353028a2ae2SWeidong Wang 
354028a2ae2SWeidong Wang #define AW88261_EF_ISN_GESLP_H_START_BIT	(0)
355028a2ae2SWeidong Wang #define AW88261_EF_ISN_GESLP_H_BITS_LEN	(10)
356028a2ae2SWeidong Wang #define AW88261_EF_ISN_GESLP_H_MASK		\
357028a2ae2SWeidong Wang 	(~(((1<<AW88261_EF_ISN_GESLP_H_BITS_LEN)-1) << AW88261_EF_ISN_GESLP_H_START_BIT))
358028a2ae2SWeidong Wang 
359028a2ae2SWeidong Wang #define AW88261_EF_ISN_GESLP_L_START_BIT	(0)
360028a2ae2SWeidong Wang #define AW88261_EF_ISN_GESLP_L_BITS_LEN	(10)
361028a2ae2SWeidong Wang #define AW88261_EF_ISN_GESLP_L_MASK		\
362028a2ae2SWeidong Wang 	(~(((1<<AW88261_EF_ISN_GESLP_L_BITS_LEN)-1) << AW88261_EF_ISN_GESLP_L_START_BIT))
363028a2ae2SWeidong Wang 
364028a2ae2SWeidong Wang #define AW88261_CABL_BASE_VALUE		(1000)
365028a2ae2SWeidong Wang #define AW88261_ICABLK_FACTOR		(1)
366028a2ae2SWeidong Wang #define AW88261_VCABLK_FACTOR		(1)
367028a2ae2SWeidong Wang 
368028a2ae2SWeidong Wang #define AW88261_VCAL_FACTOR		(1<<13)
369028a2ae2SWeidong Wang 
370028a2ae2SWeidong Wang #define AW88261_START_RETRIES		(5)
371028a2ae2SWeidong Wang #define AW88261_START_WORK_DELAY_MS	(0)
372028a2ae2SWeidong Wang 
3736a4c3ce3SWeidong Wang #define AW88261_I2C_NAME		"aw88261"
374028a2ae2SWeidong Wang 
375028a2ae2SWeidong Wang #define AW88261_RATES (SNDRV_PCM_RATE_8000_48000 | \
376028a2ae2SWeidong Wang 			SNDRV_PCM_RATE_96000)
377028a2ae2SWeidong Wang #define AW88261_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
378028a2ae2SWeidong Wang 			SNDRV_PCM_FMTBIT_S24_LE | \
379028a2ae2SWeidong Wang 			SNDRV_PCM_FMTBIT_S32_LE)
380028a2ae2SWeidong Wang 
381028a2ae2SWeidong Wang #define FADE_TIME_MAX			100000
382028a2ae2SWeidong Wang #define FADE_TIME_MIN			0
383028a2ae2SWeidong Wang 
384028a2ae2SWeidong Wang #define AW88261_DEV_DEFAULT_CH		(0)
385028a2ae2SWeidong Wang #define AW88261_ACF_FILE		"aw88261_acf.bin"
386028a2ae2SWeidong Wang #define AW88261_DEV_SYSST_CHECK_MAX	(10)
387028a2ae2SWeidong Wang #define AW88261_SOFT_RESET_VALUE	(0x55aa)
388028a2ae2SWeidong Wang #define AW88261_REG_TO_DB		(0x3f)
389028a2ae2SWeidong Wang #define AW88261_VOL_START_MASK		(0xfc00)
390028a2ae2SWeidong Wang #define AW88261_INIT_PROFILE		(0)
391028a2ae2SWeidong Wang 
392028a2ae2SWeidong Wang #define REG_VAL_TO_DB(value)		((((value) >> AW88261_VOL_6DB_START) * \
393028a2ae2SWeidong Wang 					AW88261_VOLUME_STEP_DB) + \
394028a2ae2SWeidong Wang 					((value) & AW88261_REG_TO_DB))
395028a2ae2SWeidong Wang #define DB_TO_REG_VAL(value)		((((value) / AW88261_VOLUME_STEP_DB) << \
396028a2ae2SWeidong Wang 					AW88261_VOL_6DB_START) + \
397028a2ae2SWeidong Wang 					((value) % AW88261_VOLUME_STEP_DB))
398028a2ae2SWeidong Wang 
399028a2ae2SWeidong Wang #define AW88261_PROFILE_EXT(xname, profile_info, profile_get, profile_set) \
400028a2ae2SWeidong Wang { \
401028a2ae2SWeidong Wang 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
402028a2ae2SWeidong Wang 	.name = xname, \
403028a2ae2SWeidong Wang 	.info = profile_info, \
404028a2ae2SWeidong Wang 	.get = profile_get, \
405028a2ae2SWeidong Wang 	.put = profile_set, \
406028a2ae2SWeidong Wang }
407028a2ae2SWeidong Wang 
408028a2ae2SWeidong Wang enum {
409028a2ae2SWeidong Wang 	AW88261_SYNC_START = 0,
410028a2ae2SWeidong Wang 	AW88261_ASYNC_START,
411028a2ae2SWeidong Wang };
412028a2ae2SWeidong Wang 
413028a2ae2SWeidong Wang enum aw88261_id {
414028a2ae2SWeidong Wang 	AW88261_CHIP_ID = 0x2113,
415028a2ae2SWeidong Wang };
416028a2ae2SWeidong Wang 
417028a2ae2SWeidong Wang enum {
418028a2ae2SWeidong Wang 	AW88261_500_US = 500,
419028a2ae2SWeidong Wang 	AW88261_1000_US = 1000,
420028a2ae2SWeidong Wang 	AW88261_2000_US = 2000,
421028a2ae2SWeidong Wang };
422028a2ae2SWeidong Wang 
423028a2ae2SWeidong Wang enum {
424028a2ae2SWeidong Wang 	AW88261_DEV_PW_OFF = 0,
425028a2ae2SWeidong Wang 	AW88261_DEV_PW_ON,
426028a2ae2SWeidong Wang };
427028a2ae2SWeidong Wang 
428028a2ae2SWeidong Wang enum {
429028a2ae2SWeidong Wang 	AW88261_DEV_FW_FAILED = 0,
430028a2ae2SWeidong Wang 	AW88261_DEV_FW_OK,
431028a2ae2SWeidong Wang };
432028a2ae2SWeidong Wang 
433028a2ae2SWeidong Wang enum {
434028a2ae2SWeidong Wang 	AW88261_EF_AND_CHECK = 0,
435028a2ae2SWeidong Wang 	AW88261_EF_OR_CHECK,
436028a2ae2SWeidong Wang };
437028a2ae2SWeidong Wang 
438028a2ae2SWeidong Wang enum {
439028a2ae2SWeidong Wang 	AW88261_FRCSET_DISABLE = 0,
440028a2ae2SWeidong Wang 	AW88261_FRCSET_ENABLE,
441028a2ae2SWeidong Wang };
442028a2ae2SWeidong Wang 
443028a2ae2SWeidong Wang struct aw88261 {
444028a2ae2SWeidong Wang 	struct aw_device *aw_pa;
445028a2ae2SWeidong Wang 	struct mutex lock;
446028a2ae2SWeidong Wang 	struct gpio_desc *reset_gpio;
447028a2ae2SWeidong Wang 	struct delayed_work start_work;
448028a2ae2SWeidong Wang 	struct regmap *regmap;
449028a2ae2SWeidong Wang 	struct aw_container *aw_cfg;
450028a2ae2SWeidong Wang 
451028a2ae2SWeidong Wang 	int efuse_check;
452028a2ae2SWeidong Wang 	int frcset_en;
453028a2ae2SWeidong Wang 	unsigned int mute_st;
454028a2ae2SWeidong Wang 	unsigned int amppd_st;
455028a2ae2SWeidong Wang 
456*c786770eSWeidong Wang 	bool phase_sync;
457028a2ae2SWeidong Wang };
458028a2ae2SWeidong Wang 
459028a2ae2SWeidong Wang #endif
460