xref: /openbmc/linux/sound/soc/codecs/cs35l45.h (revision 724ba675)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * cs35l45.h - CS35L45 ALSA SoC audio driver
4  *
5  * Copyright 2019-2022 Cirrus Logic, Inc.
6  *
7  * Author: James Schulman <james.schulman@cirrus.com>
8  *
9  */
10 
11 #ifndef CS35L45_H
12 #define CS35L45_H
13 
14 #include <linux/pm_runtime.h>
15 #include <linux/regmap.h>
16 #include <linux/regulator/consumer.h>
17 #include <dt-bindings/sound/cs35l45.h>
18 #include "wm_adsp.h"
19 
20 #define CS35L45_DEVID				0x00000000
21 #define CS35L45_REVID				0x00000004
22 #define CS35L45_RELID				0x0000000C
23 #define CS35L45_OTPID				0x00000010
24 #define CS35L45_SFT_RESET			0x00000020
25 #define CS35L45_GLOBAL_ENABLES			0x00002014
26 #define CS35L45_BLOCK_ENABLES			0x00002018
27 #define CS35L45_BLOCK_ENABLES2			0x0000201C
28 #define CS35L45_ERROR_RELEASE			0x00002034
29 #define CS35L45_SYNC_GPIO1			0x00002430
30 #define CS35L45_INTB_GPIO2_MCLK_REF		0x00002434
31 #define CS35L45_GPIO3				0x00002438
32 #define CS35L45_PWRMGT_CTL			0x00002900
33 #define CS35L45_WAKESRC_CTL			0x00002904
34 #define CS35L45_WKI2C_CTL			0x00002908
35 #define CS35L45_PWRMGT_STS			0x0000290C
36 #define CS35L45_REFCLK_INPUT			0x00002C04
37 #define CS35L45_GLOBAL_SAMPLE_RATE		0x00002C0C
38 #define CS35L45_BOOST_CCM_CFG			0x00003808
39 #define CS35L45_BOOST_DCM_CFG			0x0000380C
40 #define CS35L45_BOOST_OV_CFG			0x0000382C
41 #define CS35L45_ASP_ENABLES1			0x00004800
42 #define CS35L45_ASP_CONTROL1			0x00004804
43 #define CS35L45_ASP_CONTROL2			0x00004808
44 #define CS35L45_ASP_CONTROL3			0x0000480C
45 #define CS35L45_ASP_FRAME_CONTROL1		0x00004810
46 #define CS35L45_ASP_FRAME_CONTROL2		0x00004814
47 #define CS35L45_ASP_FRAME_CONTROL5		0x00004820
48 #define CS35L45_ASP_DATA_CONTROL1		0x00004830
49 #define CS35L45_ASP_DATA_CONTROL5		0x00004840
50 #define CS35L45_DACPCM1_INPUT			0x00004C00
51 #define CS35L45_ASPTX1_INPUT			0x00004C20
52 #define CS35L45_ASPTX2_INPUT			0x00004C24
53 #define CS35L45_ASPTX3_INPUT			0x00004C28
54 #define CS35L45_ASPTX4_INPUT			0x00004C2C
55 #define CS35L45_ASPTX5_INPUT			0x00004C30
56 #define CS35L45_DSP1RX1_INPUT			0x00004C40
57 #define CS35L45_DSP1RX2_INPUT			0x00004C44
58 #define CS35L45_DSP1RX3_INPUT			0x00004C48
59 #define CS35L45_DSP1RX4_INPUT			0x00004C4C
60 #define CS35L45_DSP1RX5_INPUT			0x00004C50
61 #define CS35L45_DSP1RX6_INPUT			0x00004C54
62 #define CS35L45_DSP1RX7_INPUT			0x00004C58
63 #define CS35L45_DSP1RX8_INPUT			0x00004C5C
64 #define CS35L45_LDPM_CONFIG			0x00006404
65 #define CS35L45_AMP_PCM_CONTROL			0x00007000
66 #define CS35L45_AMP_PCM_HPF_TST			0x00007004
67 #define CS35L45_IRQ1_CFG			0x0000E000
68 #define CS35L45_IRQ1_STATUS			0x0000E004
69 #define CS35L45_IRQ1_EINT_1			0x0000E010
70 #define CS35L45_IRQ1_EINT_2			0x0000E014
71 #define CS35L45_IRQ1_EINT_3			0x0000E018
72 #define CS35L45_IRQ1_EINT_4			0x0000E01C
73 #define CS35L45_IRQ1_EINT_5			0x0000E020
74 #define CS35L45_IRQ1_EINT_7			0x0000E028
75 #define CS35L45_IRQ1_EINT_8			0x0000E02C
76 #define CS35L45_IRQ1_EINT_18			0x0000E054
77 #define CS35L45_IRQ1_STS_1			0x0000E090
78 #define CS35L45_IRQ1_STS_2			0x0000E094
79 #define CS35L45_IRQ1_STS_3			0x0000E098
80 #define CS35L45_IRQ1_STS_4			0x0000E09C
81 #define CS35L45_IRQ1_STS_5			0x0000E0A0
82 #define CS35L45_IRQ1_STS_7			0x0000E0A8
83 #define CS35L45_IRQ1_STS_8			0x0000E0AC
84 #define CS35L45_IRQ1_STS_18			0x0000E0D4
85 #define CS35L45_IRQ1_MASK_1			0x0000E110
86 #define CS35L45_IRQ1_MASK_2			0x0000E114
87 #define CS35L45_IRQ1_MASK_3			0x0000E118
88 #define CS35L45_IRQ1_MASK_4			0x0000E11C
89 #define CS35L45_IRQ1_MASK_5			0x0000E120
90 #define CS35L45_IRQ1_MASK_6			0x0000E124
91 #define CS35L45_IRQ1_MASK_7			0x0000E128
92 #define CS35L45_IRQ1_MASK_8			0x0000E12C
93 #define CS35L45_IRQ1_MASK_9			0x0000E130
94 #define CS35L45_IRQ1_MASK_10			0x0000E134
95 #define CS35L45_IRQ1_MASK_11			0x0000E138
96 #define CS35L45_IRQ1_MASK_12			0x0000E13C
97 #define CS35L45_IRQ1_MASK_13			0x0000E140
98 #define CS35L45_IRQ1_MASK_14			0x0000E144
99 #define CS35L45_IRQ1_MASK_15			0x0000E148
100 #define CS35L45_IRQ1_MASK_16			0x0000E14C
101 #define CS35L45_IRQ1_MASK_17			0x0000E150
102 #define CS35L45_IRQ1_MASK_18			0x0000E154
103 #define CS35L45_GPIO_STATUS1			0x0000F000
104 #define CS35L45_GPIO1_CTRL1			0x0000F008
105 #define CS35L45_GPIO2_CTRL1			0x0000F00C
106 #define CS35L45_GPIO3_CTRL1			0x0000F010
107 #define CS35L45_DSP_MBOX_1			0x00011000
108 #define CS35L45_DSP_MBOX_2			0x00011004
109 #define CS35L45_DSP_VIRT1_MBOX_1		0x00011020
110 #define CS35L45_DSP_VIRT1_MBOX_2		0x00011024
111 #define CS35L45_DSP_VIRT1_MBOX_3		0x00011028
112 #define CS35L45_DSP_VIRT1_MBOX_4		0x0001102C
113 #define CS35L45_DSP_VIRT2_MBOX_1		0x00011040
114 #define CS35L45_DSP_VIRT2_MBOX_2		0x00011044
115 #define CS35L45_DSP_VIRT2_MBOX_3		0x00011048
116 #define CS35L45_DSP_VIRT2_MBOX_4		0x0001104C
117 #define CS35L45_DSP1_XMEM_PACK_0		0x02000000
118 #define CS35L45_DSP1_XMEM_PACK_4607		0x020047FC
119 #define CS35L45_DSP1_XMEM_UNPACK32_0		0x02400000
120 #define CS35L45_DSP1_XMEM_UNPACK32_3071	0x02402FFC
121 #define CS35L45_DSP1_SYS_ID			0x025E0000
122 #define CS35L45_DSP1_XMEM_UNPACK24_0		0x02800000
123 #define CS35L45_DSP1_XMEM_UNPACK24_6143	0x02805FFC
124 #define CS35L45_DSP1_CLOCK_FREQ		0x02B80000
125 #define CS35L45_DSP1_RX1_RATE			0x02B80080
126 #define CS35L45_DSP1_RX2_RATE			0x02B80088
127 #define CS35L45_DSP1_RX3_RATE			0x02B80090
128 #define CS35L45_DSP1_RX4_RATE			0x02B80098
129 #define CS35L45_DSP1_RX5_RATE			0x02B800A0
130 #define CS35L45_DSP1_RX6_RATE			0x02B800A8
131 #define CS35L45_DSP1_RX7_RATE			0x02B800B0
132 #define CS35L45_DSP1_RX8_RATE			0x02B800B8
133 #define CS35L45_DSP1_TX1_RATE			0x02B80280
134 #define CS35L45_DSP1_TX2_RATE			0x02B80288
135 #define CS35L45_DSP1_TX3_RATE			0x02B80290
136 #define CS35L45_DSP1_TX4_RATE			0x02B80298
137 #define CS35L45_DSP1_TX5_RATE			0x02B802A0
138 #define CS35L45_DSP1_TX6_RATE			0x02B802A8
139 #define CS35L45_DSP1_TX7_RATE			0x02B802B0
140 #define CS35L45_DSP1_TX8_RATE			0x02B802B8
141 #define CS35L45_DSP1_SCRATCH1			0x02B805C0
142 #define CS35L45_DSP1_SCRATCH2			0x02B805C8
143 #define CS35L45_DSP1_SCRATCH3			0x02B805D0
144 #define CS35L45_DSP1_SCRATCH4			0x02B805D8
145 #define CS35L45_DSP1_CCM_CORE_CONTROL		0x02BC1000
146 #define CS35L45_DSP1_YMEM_PACK_0		0x02C00000
147 #define CS35L45_DSP1_YMEM_PACK_1532		0x02C017F0
148 #define CS35L45_DSP1_YMEM_UNPACK32_0		0x03000000
149 #define CS35L45_DSP1_YMEM_UNPACK32_1022	0x03000FF8
150 #define CS35L45_DSP1_YMEM_UNPACK24_0		0x03400000
151 #define CS35L45_DSP1_YMEM_UNPACK24_2043	0x03401FEC
152 #define CS35L45_DSP1_PMEM_0			0x03800000
153 #define CS35L45_DSP1_PMEM_3834			0x03803BE8
154 #define CS35L45_LASTREG			0x03C6EFE8
155 
156 /* SFT_RESET */
157 #define CS35L45_SOFT_RESET_TRIGGER		0x5A000000
158 
159 /* GLOBAL_ENABLES */
160 #define CS35L45_GLOBAL_EN_SHIFT			0
161 #define CS35L45_GLOBAL_EN_MASK			BIT(0)
162 
163 /* BLOCK_ENABLES */
164 #define CS35L45_IMON_EN_SHIFT			13
165 #define CS35L45_VMON_EN_SHIFT			12
166 #define CS35L45_VDD_BSTMON_EN_SHIFT		9
167 #define CS35L45_VDD_BATTMON_EN_SHIFT		8
168 #define CS35L45_BST_EN_SHIFT			4
169 #define CS35L45_BST_EN_MASK			GENMASK(5, 4)
170 
171 #define CS35L45_BST_DISABLE_FET_ON              0x01
172 
173 /* BLOCK_ENABLES2 */
174 #define CS35L45_ASP_EN_SHIFT			27
175 
176 #define CS35L45_MEM_RDY_SHIFT			1
177 #define CS35L45_MEM_RDY_MASK			BIT(1)
178 
179 /* ERROR_RELEASE */
180 #define CS35L45_GLOBAL_ERR_RLS_MASK		BIT(11)
181 
182 /* CCM_CORE */
183 #define CS35L45_CCM_CORE_RESET_SHIFT		9
184 #define CS35L45_CCM_CORE_RESET_MASK		BIT(9)
185 #define CS35L45_CCM_PM_REMAP_SHIFT		7
186 #define CS35L45_CCM_PM_REMAP_MASK		BIT(7)
187 #define CS35L45_CCM_CORE_EN_SHIFT		0
188 #define CS35L45_CCM_CORE_EN_MASK		BIT(0)
189 
190 /* REFCLK_INPUT */
191 #define CS35L45_PLL_FORCE_EN_SHIFT		16
192 #define CS35L45_PLL_FORCE_EN_MASK		BIT(16)
193 #define CS35L45_PLL_OPEN_LOOP_SHIFT		11
194 #define CS35L45_PLL_OPEN_LOOP_MASK		BIT(11)
195 #define CS35L45_PLL_REFCLK_FREQ_SHIFT		5
196 #define CS35L45_PLL_REFCLK_FREQ_MASK		GENMASK(10, 5)
197 #define CS35L45_PLL_REFCLK_EN_SHIFT		4
198 #define CS35L45_PLL_REFCLK_EN_MASK		BIT(4)
199 #define CS35L45_PLL_REFCLK_SEL_SHIFT		0
200 #define CS35L45_PLL_REFCLK_SEL_MASK		GENMASK(2, 0)
201 
202 #define CS35L45_PLL_REFCLK_SEL_BCLK		0x0
203 
204 /* GLOBAL_SAMPLE_RATE */
205 #define CS35L45_GLOBAL_FS_SHIFT			0
206 #define CS35L45_GLOBAL_FS_MASK			GENMASK(4, 0)
207 
208 #define CS35L45_48P0_KHZ			0x03
209 #define CS35L45_96P0_KHZ			0x04
210 #define CS35L45_44P100_KHZ			0x0B
211 #define CS35L45_88P200_KHZ			0x0C
212 
213 /* ASP_ENABLES_1 */
214 #define CS35L45_ASP_RX2_EN_SHIFT		17
215 #define CS35L45_ASP_RX1_EN_SHIFT		16
216 #define CS35L45_ASP_TX5_EN_SHIFT		4
217 #define CS35L45_ASP_TX4_EN_SHIFT		3
218 #define CS35L45_ASP_TX3_EN_SHIFT		2
219 #define CS35L45_ASP_TX2_EN_SHIFT		1
220 #define CS35L45_ASP_TX1_EN_SHIFT		0
221 
222 /* ASP_CONTROL2 */
223 #define CS35L45_ASP_WIDTH_RX_SHIFT		24
224 #define CS35L45_ASP_WIDTH_RX_MASK		GENMASK(31, 24)
225 #define CS35L45_ASP_WIDTH_TX_SHIFT		16
226 #define CS35L45_ASP_WIDTH_TX_MASK		GENMASK(23, 16)
227 #define CS35L45_ASP_FMT_SHIFT			8
228 #define CS35L45_ASP_FMT_MASK			GENMASK(10, 8)
229 #define CS35L45_ASP_BCLK_INV_SHIFT		6
230 #define CS35L45_ASP_BCLK_INV_MASK		BIT(6)
231 #define CS35L45_ASP_FSYNC_INV_SHIFT		2
232 #define CS35L45_ASP_FSYNC_INV_MASK		BIT(2)
233 
234 #define CS35l45_ASP_FMT_DSP_A			0
235 #define CS35L45_ASP_FMT_I2S			2
236 
237 /* ASP_CONTROL3 */
238 #define CS35L45_ASP_DOUT_HIZ_CTRL_SHIFT		0
239 #define CS35L45_ASP_DOUT_HIZ_CTRL_MASK		GENMASK(1, 0)
240 
241 /* ASP_FRAME_CONTROL1 */
242 #define CS35L45_ASP_TX4_SLOT_SHIFT		24
243 #define CS35L45_ASP_TX4_SLOT_MASK		GENMASK(29, 24)
244 #define CS35L45_ASP_TX3_SLOT_SHIFT		16
245 #define CS35L45_ASP_TX3_SLOT_MASK		GENMASK(21, 16)
246 #define CS35L45_ASP_TX2_SLOT_SHIFT		8
247 #define CS35L45_ASP_TX2_SLOT_MASK		GENMASK(13, 8)
248 #define CS35L45_ASP_TX1_SLOT_SHIFT		0
249 #define CS35L45_ASP_TX1_SLOT_MASK		GENMASK(5, 0)
250 
251 #define CS35L45_ASP_TX_ALL_SLOTS		(CS35L45_ASP_TX4_SLOT_MASK | \
252 						CS35L45_ASP_TX3_SLOT_MASK  | \
253 						CS35L45_ASP_TX2_SLOT_MASK  | \
254 						CS35L45_ASP_TX1_SLOT_MASK)
255 /* ASP_FRAME_CONTROL5 */
256 #define CS35L45_ASP_RX2_SLOT_SHIFT		8
257 #define CS35L45_ASP_RX2_SLOT_MASK		GENMASK(13, 8)
258 #define CS35L45_ASP_RX1_SLOT_SHIFT		0
259 #define CS35L45_ASP_RX1_SLOT_MASK		GENMASK(5, 0)
260 
261 #define CS35L45_ASP_RX_ALL_SLOTS		(CS35L45_ASP_RX2_SLOT_MASK | \
262 						CS35L45_ASP_RX1_SLOT_MASK)
263 
264 /* ASP_DATA_CONTROL1 */
265 /* ASP_DATA_CONTROL5 */
266 #define CS35L45_ASP_WL_SHIFT			0
267 #define CS35L45_ASP_WL_MASK			GENMASK(5, 0)
268 
269 /* AMP_PCM_CONTROL */
270 #define CS35L45_AMP_VOL_PCM_SHIFT		0
271 #define CS35L45_AMP_VOL_PCM_WIDTH		11
272 
273 /* AMP_PCM_HPF_TST */
274 #define CS35l45_HPF_DEFAULT			0x00000000
275 #define CS35L45_HPF_44P1			0x000108BD
276 #define CS35L45_HPF_88P2			0x0001045F
277 
278 /* IRQ1_EINT_4 */
279 #define CS35L45_OTP_BOOT_DONE_STS_MASK		BIT(1)
280 #define CS35L45_OTP_BUSY_MASK			BIT(0)
281 
282 /* GPIOX_CTRL1 */
283 #define CS35L45_GPIO_DIR_SHIFT			31
284 #define CS35L45_GPIO_DIR_MASK			BIT(31)
285 #define CS35L45_GPIO_LVL_SHIFT			15
286 #define CS35L45_GPIO_LVL_MASK			BIT(15)
287 #define CS35L45_GPIO_OP_CFG_SHIFT		14
288 #define CS35L45_GPIO_OP_CFG_MASK		BIT(14)
289 #define CS35L45_GPIO_POL_SHIFT			12
290 #define CS35L45_GPIO_POL_MASK			BIT(12)
291 
292 /* SYNC_GPIO1, INTB_GPIO2_MCLK_REF, GPIO3 */
293 #define CS35L45_GPIO_CTRL_SHIFT		20
294 #define CS35L45_GPIO_CTRL_MASK			GENMASK(22, 20)
295 #define CS35L45_GPIO_INVERT_SHIFT		19
296 #define CS35L45_GPIO_INVERT_MASK		BIT(19)
297 
298 /* CS35L45_IRQ1_EINT_1 */
299 #define CS35L45_BST_UVP_ERR_SHIFT		7
300 #define CS35L45_BST_UVP_ERR_MASK		BIT(7)
301 #define CS35L45_BST_SHORT_ERR_SHIFT		8
302 #define CS35L45_BST_SHORT_ERR_MASK		BIT(8)
303 #define CS35L45_TEMP_ERR_SHIFT			17
304 #define CS35L45_TEMP_ERR_MASK			BIT(17)
305 #define CS35L45_MSM_GLOBAL_EN_ASSERT_SHIFT	22
306 #define CS35L45_MSM_GLOBAL_EN_ASSERT_MASK	BIT(22)
307 #define CS35L45_UVLO_VDDBATT_ERR_SHIFT	29
308 #define CS35L45_UVLO_VDDBATT_ERR_MASK		BIT(29)
309 #define CS35L45_AMP_SHORT_ERR_SHIFT		31
310 #define CS35L45_AMP_SHORT_ERR_MASK		BIT(31)
311 
312 /* CS35L45_IRQ1_EINT_2 */
313 #define CS35L45_DSP_WDT_EXPIRE_SHIFT		4
314 #define CS35L45_DSP_WDT_EXPIRE_MASK		BIT(4)
315 #define CS35L45_DSP_VIRT2_MBOX_SHIFT		21
316 #define CS35L45_DSP_VIRT2_MBOX_MASK		BIT(21)
317 
318 /* CS35L45_IRQ1_EINT_3 */
319 #define CS35L45_PLL_LOCK_FLAG_SHIFT		1
320 #define CS35L45_PLL_LOCK_FLAG_MASK		BIT(1)
321 #define CS35L45_PLL_UNLOCK_FLAG_RISE_SHIFT	4
322 #define CS35L45_PLL_UNLOCK_FLAG_RISE_MASK	BIT(4)
323 #define CS35L45_AMP_CAL_ERR_SHIFT		25
324 #define CS35L45_AMP_CAL_ERR_MASK		BIT(25)
325 
326 /* CS35L45_IRQ1_EINT_18 */
327 #define CS35L45_GLOBAL_ERROR_SHIFT		15
328 #define CS35L45_GLOBAL_ERROR_MASK		BIT(15)
329 #define CS35L45_UVLO_VDDLV_ERR_SHIFT		16
330 #define CS35L45_UVLO_VDDLV_ERR_MASK		BIT(16)
331 
332 /* Mixer sources */
333 #define CS35L45_PCM_SRC_MASK			0x7F
334 #define CS35L45_PCM_SRC_ZERO			0x00
335 #define CS35L45_PCM_SRC_ASP_RX1			0x08
336 #define CS35L45_PCM_SRC_ASP_RX2			0x09
337 #define CS35L45_PCM_SRC_VMON			0x18
338 #define CS35L45_PCM_SRC_IMON			0x19
339 #define CS35L45_PCM_SRC_ERR_VOL			0x20
340 #define CS35L45_PCM_SRC_CLASSH_TGT		0x21
341 #define CS35L45_PCM_SRC_VDD_BATTMON		0x28
342 #define CS35L45_PCM_SRC_VDD_BSTMON		0x29
343 #define CS35L45_PCM_SRC_DSP_TX1			0x32
344 #define CS35L45_PCM_SRC_DSP_TX2			0x33
345 #define CS35L45_PCM_SRC_TEMPMON			0x3A
346 #define CS35L45_PCM_SRC_INTERPOLATOR		0x40
347 #define CS35L45_PCM_SRC_IL_TARGET		0x48
348 
349 #define CS35L45_RESET_HOLD_US			2000
350 #define CS35L45_RESET_US			2000
351 #define CS35L45_POST_GLOBAL_EN_US		5000
352 #define CS35L45_PRE_GLOBAL_DIS_US		3000
353 
354 /* WAKESRC_CTL */
355 #define CS35L45_WKSRC_SYNC_GPIO1		BIT(0)
356 #define CS35L45_WKSRC_INT_GPIO2			BIT(1)
357 #define CS35L45_WKSRC_GPIO3			BIT(2)
358 #define CS35L45_WKSRC_SPI			BIT(3)
359 #define CS35L45_WKSRC_I2C			BIT(4)
360 #define CS35L45_UPDT_WKCTL_SHIFT		15
361 #define CS35L45_UPDT_WKCTL_MASK			BIT(15)
362 #define CS35L45_WKSRC_EN_SHIFT			8
363 #define CS35L45_WKSRC_EN_MASK			GENMASK(12, 8)
364 #define CS35L45_WKSRC_POL_SHIFT			0
365 #define CS35L45_WKSRC_POL_MASK			GENMASK(3, 0)
366 
367 /* WAKEI2C_CTL */
368 #define CS35L45_UPDT_WKI2C_SHIFT		15
369 #define CS35L45_UPDT_WKI2C_MASK			BIT(15)
370 #define CS35L45_WKI2C_ADDR_SHIFT		0
371 #define CS35L45_WKI2C_ADDR_MASK			GENMASK(6, 0)
372 
373 #define CS35L45_SPI_MAX_FREQ			4000000
374 
375 enum cs35l45_cspl_mboxstate {
376 	CSPL_MBOX_STS_RUNNING = 0,
377 	CSPL_MBOX_STS_PAUSED = 1,
378 	CSPL_MBOX_STS_RDY_FOR_REINIT = 2,
379 	CSPL_MBOX_STS_HIBERNATE = 3,
380 };
381 
382 enum cs35l45_cspl_mboxcmd {
383 	CSPL_MBOX_CMD_NONE = 0,
384 	CSPL_MBOX_CMD_PAUSE = 1,
385 	CSPL_MBOX_CMD_RESUME = 2,
386 	CSPL_MBOX_CMD_REINIT = 3,
387 	CSPL_MBOX_CMD_STOP_PRE_REINIT = 4,
388 	CSPL_MBOX_CMD_HIBERNATE = 5,
389 	CSPL_MBOX_CMD_OUT_OF_HIBERNATE = 6,
390 	CSPL_MBOX_CMD_UNKNOWN_CMD = -1,
391 	CSPL_MBOX_CMD_INVALID_SEQUENCE = -2,
392 };
393 
394 enum control_bus_type {
395 	CONTROL_BUS_I2C = 0,
396 	CONTROL_BUS_SPI = 1,
397 };
398 
399 #define CS35L45_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
400 			 SNDRV_PCM_FMTBIT_S24_3LE| \
401 			 SNDRV_PCM_FMTBIT_S24_LE)
402 
403 #define CS35L45_RATES (SNDRV_PCM_RATE_44100 | \
404 		       SNDRV_PCM_RATE_48000 | \
405 		       SNDRV_PCM_RATE_88200 | \
406 		       SNDRV_PCM_RATE_96000)
407 
408 /*
409  * IRQs
410  */
411 #define CS35L45_IRQ(_irq, _name, _hand)		\
412 	{					\
413 		.irq = CS35L45_ ## _irq ## _IRQ,\
414 		.name = _name,			\
415 		.handler = _hand,		\
416 	}
417 
418 struct cs35l45_irq {
419 	int irq;
420 	const char *name;
421 	irqreturn_t (*handler)(int irq, void *data);
422 };
423 
424 #define CS35L45_REG_IRQ(_reg, _irq)					\
425 	[CS35L45_ ## _irq ## _IRQ] = {					\
426 		.reg_offset = (CS35L45_ ## _reg) - CS35L45_IRQ1_EINT_1,	\
427 		.mask = CS35L45_ ## _irq ## _MASK			\
428 	}
429 
430 enum cs35l45_irq_list {
431 	CS35L45_AMP_SHORT_ERR_IRQ,
432 	CS35L45_UVLO_VDDBATT_ERR_IRQ,
433 	CS35L45_BST_SHORT_ERR_IRQ,
434 	CS35L45_BST_UVP_ERR_IRQ,
435 	CS35L45_TEMP_ERR_IRQ,
436 	CS35L45_AMP_CAL_ERR_IRQ,
437 	CS35L45_UVLO_VDDLV_ERR_IRQ,
438 	CS35L45_GLOBAL_ERROR_IRQ,
439 	CS35L45_DSP_WDT_EXPIRE_IRQ,
440 	CS35L45_PLL_UNLOCK_FLAG_RISE_IRQ,
441 	CS35L45_PLL_LOCK_FLAG_IRQ,
442 	CS35L45_DSP_VIRT2_MBOX_IRQ,
443 	CS35L45_NUM_IRQ
444 };
445 
446 #define CS35L45_MBOX3_CMD_MASK		0xFF
447 #define CS35L45_MBOX3_CMD_SHIFT		0
448 #define CS35L45_MBOX3_DATA_MASK		0xFFFFFF00
449 #define CS35L45_MBOX3_DATA_SHIFT	8
450 
451 enum mbox3_events {
452 	EVENT_SPEAKER_STATUS = 0x66,
453 	EVENT_BOOT_DONE = 0x67,
454 };
455 
456 struct cs35l45_private {
457 	struct wm_adsp dsp; /* needs to be first member */
458 	struct device *dev;
459 	struct regmap *regmap;
460 	struct gpio_desc *reset_gpio;
461 	struct regulator *vdd_batt;
462 	struct regulator *vdd_a;
463 	bool initialized;
464 	bool sysclk_set;
465 	u8 slot_width;
466 	u8 slot_count;
467 	int irq_invert;
468 	int irq;
469 	unsigned int i2c_addr;
470 	enum control_bus_type bus_type;
471 	struct regmap_irq_chip_data *irq_data;
472 };
473 
474 extern const struct dev_pm_ops cs35l45_pm_ops;
475 extern const struct regmap_config cs35l45_i2c_regmap;
476 extern const struct regmap_config cs35l45_spi_regmap;
477 int cs35l45_apply_patch(struct cs35l45_private *cs35l45);
478 unsigned int cs35l45_get_clk_freq_id(unsigned int freq);
479 int cs35l45_probe(struct cs35l45_private *cs35l45);
480 void cs35l45_remove(struct cs35l45_private *cs35l45);
481 
482 #endif /* CS35L45_H */
483