xref: /openbmc/linux/sound/soc/codecs/isabelle.c (revision d477f603)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * isabelle.c - Low power high fidelity audio codec driver
4  *
5  * Copyright (c) 2012 Texas Instruments, Inc
6  *
7  * Initially based on sound/soc/codecs/twl6040.c
8  */
9 #include <linux/module.h>
10 #include <linux/moduleparam.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/pm.h>
15 #include <linux/regmap.h>
16 #include <linux/i2c.h>
17 #include <linux/slab.h>
18 #include <sound/core.h>
19 #include <sound/pcm.h>
20 #include <sound/pcm_params.h>
21 #include <sound/soc.h>
22 #include <sound/soc-dapm.h>
23 #include <sound/tlv.h>
24 #include <sound/jack.h>
25 #include <sound/initval.h>
26 #include <asm/div64.h>
27 #include "isabelle.h"
28 
29 
30 /* Register default values for ISABELLE driver. */
31 static const struct reg_default isabelle_reg_defs[] = {
32 	{ 0, 0x00 },
33 	{ 1, 0x00 },
34 	{ 2, 0x00 },
35 	{ 3, 0x00 },
36 	{ 4, 0x00 },
37 	{ 5, 0x00 },
38 	{ 6, 0x00 },
39 	{ 7, 0x00 },
40 	{ 8, 0x00 },
41 	{ 9, 0x00 },
42 	{ 10, 0x00 },
43 	{ 11, 0x00 },
44 	{ 12, 0x00 },
45 	{ 13, 0x00 },
46 	{ 14, 0x00 },
47 	{ 15, 0x00 },
48 	{ 16, 0x00 },
49 	{ 17, 0x00 },
50 	{ 18, 0x00 },
51 	{ 19, 0x00 },
52 	{ 20, 0x00 },
53 	{ 21, 0x02 },
54 	{ 22, 0x02 },
55 	{ 23, 0x02 },
56 	{ 24, 0x02 },
57 	{ 25, 0x0F },
58 	{ 26, 0x8F },
59 	{ 27, 0x0F },
60 	{ 28, 0x8F },
61 	{ 29, 0x00 },
62 	{ 30, 0x00 },
63 	{ 31, 0x00 },
64 	{ 32, 0x00 },
65 	{ 33, 0x00 },
66 	{ 34, 0x00 },
67 	{ 35, 0x00 },
68 	{ 36, 0x00 },
69 	{ 37, 0x00 },
70 	{ 38, 0x00 },
71 	{ 39, 0x00 },
72 	{ 40, 0x00 },
73 	{ 41, 0x00 },
74 	{ 42, 0x00 },
75 	{ 43, 0x00 },
76 	{ 44, 0x00 },
77 	{ 45, 0x00 },
78 	{ 46, 0x00 },
79 	{ 47, 0x00 },
80 	{ 48, 0x00 },
81 	{ 49, 0x00 },
82 	{ 50, 0x00 },
83 	{ 51, 0x00 },
84 	{ 52, 0x00 },
85 	{ 53, 0x00 },
86 	{ 54, 0x00 },
87 	{ 55, 0x00 },
88 	{ 56, 0x00 },
89 	{ 57, 0x00 },
90 	{ 58, 0x00 },
91 	{ 59, 0x00 },
92 	{ 60, 0x00 },
93 	{ 61, 0x00 },
94 	{ 62, 0x00 },
95 	{ 63, 0x00 },
96 	{ 64, 0x00 },
97 	{ 65, 0x00 },
98 	{ 66, 0x00 },
99 	{ 67, 0x00 },
100 	{ 68, 0x00 },
101 	{ 69, 0x90 },
102 	{ 70, 0x90 },
103 	{ 71, 0x90 },
104 	{ 72, 0x00 },
105 	{ 73, 0x00 },
106 	{ 74, 0x00 },
107 	{ 75, 0x00 },
108 	{ 76, 0x00 },
109 	{ 77, 0x00 },
110 	{ 78, 0x00 },
111 	{ 79, 0x00 },
112 	{ 80, 0x00 },
113 	{ 81, 0x00 },
114 	{ 82, 0x00 },
115 	{ 83, 0x00 },
116 	{ 84, 0x00 },
117 	{ 85, 0x07 },
118 	{ 86, 0x00 },
119 	{ 87, 0x00 },
120 	{ 88, 0x00 },
121 	{ 89, 0x07 },
122 	{ 90, 0x80 },
123 	{ 91, 0x07 },
124 	{ 92, 0x07 },
125 	{ 93, 0x00 },
126 	{ 94, 0x00 },
127 	{ 95, 0x00 },
128 	{ 96, 0x00 },
129 	{ 97, 0x00 },
130 	{ 98, 0x00 },
131 	{ 99, 0x00 },
132 };
133 
134 static const char *isabelle_rx1_texts[] = {"VRX1", "ARX1"};
135 static const char *isabelle_rx2_texts[] = {"VRX2", "ARX2"};
136 
137 static const struct soc_enum isabelle_rx1_enum[] = {
138 	SOC_ENUM_SINGLE(ISABELLE_VOICE_HPF_CFG_REG, 3,
139 			ARRAY_SIZE(isabelle_rx1_texts), isabelle_rx1_texts),
140 	SOC_ENUM_SINGLE(ISABELLE_AUDIO_HPF_CFG_REG, 5,
141 			ARRAY_SIZE(isabelle_rx1_texts), isabelle_rx1_texts),
142 };
143 
144 static const struct soc_enum isabelle_rx2_enum[] = {
145 	SOC_ENUM_SINGLE(ISABELLE_VOICE_HPF_CFG_REG, 2,
146 			ARRAY_SIZE(isabelle_rx2_texts), isabelle_rx2_texts),
147 	SOC_ENUM_SINGLE(ISABELLE_AUDIO_HPF_CFG_REG, 4,
148 			ARRAY_SIZE(isabelle_rx2_texts), isabelle_rx2_texts),
149 };
150 
151 /* Headset DAC playback switches */
152 static const struct snd_kcontrol_new rx1_mux_controls =
153 	SOC_DAPM_ENUM("Route", isabelle_rx1_enum);
154 
155 static const struct snd_kcontrol_new rx2_mux_controls =
156 	SOC_DAPM_ENUM("Route", isabelle_rx2_enum);
157 
158 /* TX input selection */
159 static const char *isabelle_atx_texts[] = {"AMIC1", "DMIC"};
160 static const char *isabelle_vtx_texts[] = {"AMIC2", "DMIC"};
161 
162 static const struct soc_enum isabelle_atx_enum[] = {
163 	SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 7,
164 			ARRAY_SIZE(isabelle_atx_texts), isabelle_atx_texts),
165 	SOC_ENUM_SINGLE(ISABELLE_DMIC_CFG_REG, 0,
166 			ARRAY_SIZE(isabelle_atx_texts), isabelle_atx_texts),
167 };
168 
169 static const struct soc_enum isabelle_vtx_enum[] = {
170 	SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 6,
171 			ARRAY_SIZE(isabelle_vtx_texts), isabelle_vtx_texts),
172 	SOC_ENUM_SINGLE(ISABELLE_DMIC_CFG_REG, 0,
173 			ARRAY_SIZE(isabelle_vtx_texts), isabelle_vtx_texts),
174 };
175 
176 static const struct snd_kcontrol_new atx_mux_controls =
177 	SOC_DAPM_ENUM("Route", isabelle_atx_enum);
178 
179 static const struct snd_kcontrol_new vtx_mux_controls =
180 	SOC_DAPM_ENUM("Route", isabelle_vtx_enum);
181 
182 /* Left analog microphone selection */
183 static const char *isabelle_amic1_texts[] = {
184 	"Main Mic", "Headset Mic", "Aux/FM Left"};
185 
186 /* Left analog microphone selection */
187 static const char *isabelle_amic2_texts[] = {"Sub Mic", "Aux/FM Right"};
188 
189 static SOC_ENUM_SINGLE_DECL(isabelle_amic1_enum,
190 			    ISABELLE_AMIC_CFG_REG, 5,
191 			    isabelle_amic1_texts);
192 
193 static SOC_ENUM_SINGLE_DECL(isabelle_amic2_enum,
194 			    ISABELLE_AMIC_CFG_REG, 4,
195 			    isabelle_amic2_texts);
196 
197 static const struct snd_kcontrol_new amic1_control =
198 	SOC_DAPM_ENUM("Route", isabelle_amic1_enum);
199 
200 static const struct snd_kcontrol_new amic2_control =
201 	SOC_DAPM_ENUM("Route", isabelle_amic2_enum);
202 
203 static const char *isabelle_st_audio_texts[] = {"ATX1", "ATX2"};
204 
205 static const char *isabelle_st_voice_texts[] = {"VTX1", "VTX2"};
206 
207 static const struct soc_enum isabelle_st_audio_enum[] = {
208 	SOC_ENUM_SINGLE(ISABELLE_ATX_STPGA1_CFG_REG, 7,
209 			ARRAY_SIZE(isabelle_st_audio_texts),
210 			isabelle_st_audio_texts),
211 	SOC_ENUM_SINGLE(ISABELLE_ATX_STPGA2_CFG_REG, 7,
212 			ARRAY_SIZE(isabelle_st_audio_texts),
213 			isabelle_st_audio_texts),
214 };
215 
216 static const struct soc_enum isabelle_st_voice_enum[] = {
217 	SOC_ENUM_SINGLE(ISABELLE_VTX_STPGA1_CFG_REG, 7,
218 			ARRAY_SIZE(isabelle_st_voice_texts),
219 			isabelle_st_voice_texts),
220 	SOC_ENUM_SINGLE(ISABELLE_VTX2_STPGA2_CFG_REG, 7,
221 			ARRAY_SIZE(isabelle_st_voice_texts),
222 			isabelle_st_voice_texts),
223 };
224 
225 static const struct snd_kcontrol_new st_audio_control =
226 	SOC_DAPM_ENUM("Route", isabelle_st_audio_enum);
227 
228 static const struct snd_kcontrol_new st_voice_control =
229 	SOC_DAPM_ENUM("Route", isabelle_st_voice_enum);
230 
231 /* Mixer controls */
232 static const struct snd_kcontrol_new isabelle_hs_left_mixer_controls[] = {
233 SOC_DAPM_SINGLE("DAC1L Playback Switch", ISABELLE_HSDRV_CFG1_REG, 7, 1, 0),
234 SOC_DAPM_SINGLE("APGA1 Playback Switch", ISABELLE_HSDRV_CFG1_REG, 6, 1, 0),
235 };
236 
237 static const struct snd_kcontrol_new isabelle_hs_right_mixer_controls[] = {
238 SOC_DAPM_SINGLE("DAC1R Playback Switch", ISABELLE_HSDRV_CFG1_REG, 5, 1, 0),
239 SOC_DAPM_SINGLE("APGA2 Playback Switch", ISABELLE_HSDRV_CFG1_REG, 4, 1, 0),
240 };
241 
242 static const struct snd_kcontrol_new isabelle_hf_left_mixer_controls[] = {
243 SOC_DAPM_SINGLE("DAC2L Playback Switch", ISABELLE_HFLPGA_CFG_REG, 7, 1, 0),
244 SOC_DAPM_SINGLE("APGA1 Playback Switch", ISABELLE_HFLPGA_CFG_REG, 6, 1, 0),
245 };
246 
247 static const struct snd_kcontrol_new isabelle_hf_right_mixer_controls[] = {
248 SOC_DAPM_SINGLE("DAC2R Playback Switch", ISABELLE_HFRPGA_CFG_REG, 7, 1, 0),
249 SOC_DAPM_SINGLE("APGA2 Playback Switch", ISABELLE_HFRPGA_CFG_REG, 6, 1, 0),
250 };
251 
252 static const struct snd_kcontrol_new isabelle_ep_mixer_controls[] = {
253 SOC_DAPM_SINGLE("DAC2L Playback Switch", ISABELLE_EARDRV_CFG1_REG, 7, 1, 0),
254 SOC_DAPM_SINGLE("APGA1 Playback Switch", ISABELLE_EARDRV_CFG1_REG, 6, 1, 0),
255 };
256 
257 static const struct snd_kcontrol_new isabelle_aux_left_mixer_controls[] = {
258 SOC_DAPM_SINGLE("DAC3L Playback Switch", ISABELLE_LINEAMP_CFG_REG, 7, 1, 0),
259 SOC_DAPM_SINGLE("APGA1 Playback Switch", ISABELLE_LINEAMP_CFG_REG, 6, 1, 0),
260 };
261 
262 static const struct snd_kcontrol_new isabelle_aux_right_mixer_controls[] = {
263 SOC_DAPM_SINGLE("DAC3R Playback Switch", ISABELLE_LINEAMP_CFG_REG, 5, 1, 0),
264 SOC_DAPM_SINGLE("APGA2 Playback Switch", ISABELLE_LINEAMP_CFG_REG, 4, 1, 0),
265 };
266 
267 static const struct snd_kcontrol_new isabelle_dpga1_left_mixer_controls[] = {
268 SOC_DAPM_SINGLE("RX1 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 7, 1, 0),
269 SOC_DAPM_SINGLE("RX3 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 6, 1, 0),
270 SOC_DAPM_SINGLE("RX5 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 5, 1, 0),
271 };
272 
273 static const struct snd_kcontrol_new isabelle_dpga1_right_mixer_controls[] = {
274 SOC_DAPM_SINGLE("RX2 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 3, 1, 0),
275 SOC_DAPM_SINGLE("RX4 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 2, 1, 0),
276 SOC_DAPM_SINGLE("RX6 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 1, 1, 0),
277 };
278 
279 static const struct snd_kcontrol_new isabelle_dpga2_left_mixer_controls[] = {
280 SOC_DAPM_SINGLE("RX1 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 7, 1, 0),
281 SOC_DAPM_SINGLE("RX2 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 6, 1, 0),
282 SOC_DAPM_SINGLE("RX3 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 5, 1, 0),
283 SOC_DAPM_SINGLE("RX4 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 4, 1, 0),
284 SOC_DAPM_SINGLE("RX5 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 3, 1, 0),
285 SOC_DAPM_SINGLE("RX6 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 2, 1, 0),
286 };
287 
288 static const struct snd_kcontrol_new isabelle_dpga2_right_mixer_controls[] = {
289 SOC_DAPM_SINGLE("USNC Playback Switch", ISABELLE_DPGA2R_IN_SEL_REG, 7, 1, 0),
290 SOC_DAPM_SINGLE("RX2 Playback Switch", ISABELLE_DPGA2R_IN_SEL_REG, 3, 1, 0),
291 SOC_DAPM_SINGLE("RX4 Playback Switch", ISABELLE_DPGA2R_IN_SEL_REG, 2, 1, 0),
292 SOC_DAPM_SINGLE("RX6 Playback Switch", ISABELLE_DPGA2R_IN_SEL_REG, 1, 1, 0),
293 };
294 
295 static const struct snd_kcontrol_new isabelle_dpga3_left_mixer_controls[] = {
296 SOC_DAPM_SINGLE("RX1 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 7, 1, 0),
297 SOC_DAPM_SINGLE("RX3 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 6, 1, 0),
298 SOC_DAPM_SINGLE("RX5 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 5, 1, 0),
299 };
300 
301 static const struct snd_kcontrol_new isabelle_dpga3_right_mixer_controls[] = {
302 SOC_DAPM_SINGLE("RX2 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 3, 1, 0),
303 SOC_DAPM_SINGLE("RX4 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 2, 1, 0),
304 SOC_DAPM_SINGLE("RX6 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 1, 1, 0),
305 };
306 
307 static const struct snd_kcontrol_new isabelle_rx1_mixer_controls[] = {
308 SOC_DAPM_SINGLE("ST1 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 7, 1, 0),
309 SOC_DAPM_SINGLE("DL1 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 6, 1, 0),
310 };
311 
312 static const struct snd_kcontrol_new isabelle_rx2_mixer_controls[] = {
313 SOC_DAPM_SINGLE("ST2 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 5, 1, 0),
314 SOC_DAPM_SINGLE("DL2 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 4, 1, 0),
315 };
316 
317 static const struct snd_kcontrol_new isabelle_rx3_mixer_controls[] = {
318 SOC_DAPM_SINGLE("ST1 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 3, 1, 0),
319 SOC_DAPM_SINGLE("DL3 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 2, 1, 0),
320 };
321 
322 static const struct snd_kcontrol_new isabelle_rx4_mixer_controls[] = {
323 SOC_DAPM_SINGLE("ST2 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 1, 1, 0),
324 SOC_DAPM_SINGLE("DL4 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 0, 1, 0),
325 };
326 
327 static const struct snd_kcontrol_new isabelle_rx5_mixer_controls[] = {
328 SOC_DAPM_SINGLE("ST1 Playback Switch", ISABELLE_RX_INPUT_CFG2_REG, 7, 1, 0),
329 SOC_DAPM_SINGLE("DL5 Playback Switch", ISABELLE_RX_INPUT_CFG2_REG, 6, 1, 0),
330 };
331 
332 static const struct snd_kcontrol_new isabelle_rx6_mixer_controls[] = {
333 SOC_DAPM_SINGLE("ST2 Playback Switch", ISABELLE_RX_INPUT_CFG2_REG, 5, 1, 0),
334 SOC_DAPM_SINGLE("DL6 Playback Switch", ISABELLE_RX_INPUT_CFG2_REG, 4, 1, 0),
335 };
336 
337 static const struct snd_kcontrol_new ep_path_enable_control =
338 	SOC_DAPM_SINGLE("Switch", ISABELLE_EARDRV_CFG2_REG, 0, 1, 0);
339 
340 /* TLV Declarations */
341 static const DECLARE_TLV_DB_SCALE(mic_amp_tlv, 0, 100, 0);
342 static const DECLARE_TLV_DB_SCALE(afm_amp_tlv, -3300, 300, 0);
343 static const DECLARE_TLV_DB_SCALE(dac_tlv, -1200, 200, 0);
344 static const DECLARE_TLV_DB_SCALE(hf_tlv, -5000, 200, 0);
345 
346 /* from -63 to 0 dB in 1 dB steps */
347 static const DECLARE_TLV_DB_SCALE(dpga_tlv, -6300, 100, 1);
348 
349 /* from -63 to 9 dB in 1 dB steps */
350 static const DECLARE_TLV_DB_SCALE(rx_tlv, -6300, 100, 1);
351 
352 static const DECLARE_TLV_DB_SCALE(st_tlv, -2700, 300, 1);
353 static const DECLARE_TLV_DB_SCALE(tx_tlv, -600, 100, 0);
354 
355 static const struct snd_kcontrol_new isabelle_snd_controls[] = {
356 	SOC_DOUBLE_TLV("Headset Playback Volume", ISABELLE_HSDRV_GAIN_REG,
357 			4, 0, 0xF, 0, dac_tlv),
358 	SOC_DOUBLE_R_TLV("Handsfree Playback Volume",
359 			ISABELLE_HFLPGA_CFG_REG, ISABELLE_HFRPGA_CFG_REG,
360 			0, 0x1F, 0, hf_tlv),
361 	SOC_DOUBLE_TLV("Aux Playback Volume", ISABELLE_LINEAMP_GAIN_REG,
362 			4, 0, 0xF, 0, dac_tlv),
363 	SOC_SINGLE_TLV("Earpiece Playback Volume", ISABELLE_EARDRV_CFG1_REG,
364 			0, 0xF, 0, dac_tlv),
365 
366 	SOC_DOUBLE_TLV("Aux FM Volume", ISABELLE_APGA_GAIN_REG, 4, 0, 0xF, 0,
367 			afm_amp_tlv),
368 	SOC_SINGLE_TLV("Mic1 Capture Volume", ISABELLE_MIC1_GAIN_REG, 3, 0x1F,
369 			0, mic_amp_tlv),
370 	SOC_SINGLE_TLV("Mic2 Capture Volume", ISABELLE_MIC2_GAIN_REG, 3, 0x1F,
371 			0, mic_amp_tlv),
372 
373 	SOC_DOUBLE_R_TLV("DPGA1 Volume", ISABELLE_DPGA1L_GAIN_REG,
374 			ISABELLE_DPGA1R_GAIN_REG, 0, 0x3F, 0, dpga_tlv),
375 	SOC_DOUBLE_R_TLV("DPGA2 Volume", ISABELLE_DPGA2L_GAIN_REG,
376 			ISABELLE_DPGA2R_GAIN_REG, 0, 0x3F, 0, dpga_tlv),
377 	SOC_DOUBLE_R_TLV("DPGA3 Volume", ISABELLE_DPGA3L_GAIN_REG,
378 			ISABELLE_DPGA3R_GAIN_REG, 0, 0x3F, 0, dpga_tlv),
379 
380 	SOC_SINGLE_TLV("Sidetone Audio TX1 Volume",
381 			ISABELLE_ATX_STPGA1_CFG_REG, 0, 0xF, 0, st_tlv),
382 	SOC_SINGLE_TLV("Sidetone Audio TX2 Volume",
383 			ISABELLE_ATX_STPGA2_CFG_REG, 0, 0xF, 0, st_tlv),
384 	SOC_SINGLE_TLV("Sidetone Voice TX1 Volume",
385 			ISABELLE_VTX_STPGA1_CFG_REG, 0, 0xF, 0, st_tlv),
386 	SOC_SINGLE_TLV("Sidetone Voice TX2 Volume",
387 			ISABELLE_VTX2_STPGA2_CFG_REG, 0, 0xF, 0, st_tlv),
388 
389 	SOC_SINGLE_TLV("Audio TX1 Volume", ISABELLE_ATX1_DPGA_REG, 4, 0xF, 0,
390 			tx_tlv),
391 	SOC_SINGLE_TLV("Audio TX2 Volume", ISABELLE_ATX2_DPGA_REG, 4, 0xF, 0,
392 			tx_tlv),
393 	SOC_SINGLE_TLV("Voice TX1 Volume", ISABELLE_VTX1_DPGA_REG, 4, 0xF, 0,
394 			tx_tlv),
395 	SOC_SINGLE_TLV("Voice TX2 Volume", ISABELLE_VTX2_DPGA_REG, 4, 0xF, 0,
396 			tx_tlv),
397 
398 	SOC_SINGLE_TLV("RX1 DPGA Volume", ISABELLE_RX1_DPGA_REG, 0, 0x3F, 0,
399 			rx_tlv),
400 	SOC_SINGLE_TLV("RX2 DPGA Volume", ISABELLE_RX2_DPGA_REG, 0, 0x3F, 0,
401 			rx_tlv),
402 	SOC_SINGLE_TLV("RX3 DPGA Volume", ISABELLE_RX3_DPGA_REG, 0, 0x3F, 0,
403 			rx_tlv),
404 	SOC_SINGLE_TLV("RX4 DPGA Volume", ISABELLE_RX4_DPGA_REG, 0, 0x3F, 0,
405 			rx_tlv),
406 	SOC_SINGLE_TLV("RX5 DPGA Volume", ISABELLE_RX5_DPGA_REG, 0, 0x3F, 0,
407 			rx_tlv),
408 	SOC_SINGLE_TLV("RX6 DPGA Volume", ISABELLE_RX6_DPGA_REG, 0, 0x3F, 0,
409 			rx_tlv),
410 
411 	SOC_SINGLE("Headset Noise Gate", ISABELLE_HS_NG_CFG1_REG, 7, 1, 0),
412 	SOC_SINGLE("Handsfree Noise Gate", ISABELLE_HF_NG_CFG1_REG, 7, 1, 0),
413 
414 	SOC_SINGLE("ATX1 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
415 		7, 1, 0),
416 	SOC_SINGLE("ATX2 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
417 		6, 1, 0),
418 	SOC_SINGLE("ARX1 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
419 		5, 1, 0),
420 	SOC_SINGLE("ARX2 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
421 		4, 1, 0),
422 	SOC_SINGLE("ARX3 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
423 		3, 1, 0),
424 	SOC_SINGLE("ARX4 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
425 		2, 1, 0),
426 	SOC_SINGLE("ARX5 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
427 		1, 1, 0),
428 	SOC_SINGLE("ARX6 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
429 		0, 1, 0),
430 	SOC_SINGLE("VRX1 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
431 		3, 1, 0),
432 	SOC_SINGLE("VRX2 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
433 		2, 1, 0),
434 
435 	SOC_SINGLE("ATX1 Filter Enable Switch", ISABELLE_ALU_TX_EN_REG,
436 		7, 1, 0),
437 	SOC_SINGLE("ATX2 Filter Enable Switch", ISABELLE_ALU_TX_EN_REG,
438 		6, 1, 0),
439 	SOC_SINGLE("VTX1 Filter Enable Switch", ISABELLE_ALU_TX_EN_REG,
440 		5, 1, 0),
441 	SOC_SINGLE("VTX2 Filter Enable Switch", ISABELLE_ALU_TX_EN_REG,
442 		4, 1, 0),
443 	SOC_SINGLE("RX1 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
444 		5, 1, 0),
445 	SOC_SINGLE("RX2 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
446 		4, 1, 0),
447 	SOC_SINGLE("RX3 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
448 		3, 1, 0),
449 	SOC_SINGLE("RX4 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
450 		2, 1, 0),
451 	SOC_SINGLE("RX5 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
452 		1, 1, 0),
453 	SOC_SINGLE("RX6 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
454 		0, 1, 0),
455 
456 	SOC_SINGLE("ULATX12 Capture Switch", ISABELLE_ULATX12_INTF_CFG_REG,
457 		7, 1, 0),
458 
459 	SOC_SINGLE("DL12 Playback Switch", ISABELLE_DL12_INTF_CFG_REG,
460 		7, 1, 0),
461 	SOC_SINGLE("DL34 Playback Switch", ISABELLE_DL34_INTF_CFG_REG,
462 		7, 1, 0),
463 	SOC_SINGLE("DL56 Playback Switch", ISABELLE_DL56_INTF_CFG_REG,
464 		7, 1, 0),
465 
466 	/* DMIC Switch */
467 	SOC_SINGLE("DMIC Switch", ISABELLE_DMIC_CFG_REG, 0, 1, 0),
468 };
469 
470 static const struct snd_soc_dapm_widget isabelle_dapm_widgets[] = {
471 	/* Inputs */
472 	SND_SOC_DAPM_INPUT("MAINMIC"),
473 	SND_SOC_DAPM_INPUT("HSMIC"),
474 	SND_SOC_DAPM_INPUT("SUBMIC"),
475 	SND_SOC_DAPM_INPUT("LINEIN1"),
476 	SND_SOC_DAPM_INPUT("LINEIN2"),
477 	SND_SOC_DAPM_INPUT("DMICDAT"),
478 
479 	/* Outputs */
480 	SND_SOC_DAPM_OUTPUT("HSOL"),
481 	SND_SOC_DAPM_OUTPUT("HSOR"),
482 	SND_SOC_DAPM_OUTPUT("HFL"),
483 	SND_SOC_DAPM_OUTPUT("HFR"),
484 	SND_SOC_DAPM_OUTPUT("EP"),
485 	SND_SOC_DAPM_OUTPUT("LINEOUT1"),
486 	SND_SOC_DAPM_OUTPUT("LINEOUT2"),
487 
488 	SND_SOC_DAPM_PGA("DL1", SND_SOC_NOPM, 0, 0, NULL, 0),
489 	SND_SOC_DAPM_PGA("DL2", SND_SOC_NOPM, 0, 0, NULL, 0),
490 	SND_SOC_DAPM_PGA("DL3", SND_SOC_NOPM, 0, 0, NULL, 0),
491 	SND_SOC_DAPM_PGA("DL4", SND_SOC_NOPM, 0, 0, NULL, 0),
492 	SND_SOC_DAPM_PGA("DL5", SND_SOC_NOPM, 0, 0, NULL, 0),
493 	SND_SOC_DAPM_PGA("DL6", SND_SOC_NOPM, 0, 0, NULL, 0),
494 
495 	/* Analog input muxes for the capture amplifiers */
496 	SND_SOC_DAPM_MUX("Analog Left Capture Route",
497 			SND_SOC_NOPM, 0, 0, &amic1_control),
498 	SND_SOC_DAPM_MUX("Analog Right Capture Route",
499 			SND_SOC_NOPM, 0, 0, &amic2_control),
500 
501 	SND_SOC_DAPM_MUX("Sidetone Audio Playback", SND_SOC_NOPM, 0, 0,
502 			&st_audio_control),
503 	SND_SOC_DAPM_MUX("Sidetone Voice Playback", SND_SOC_NOPM, 0, 0,
504 			&st_voice_control),
505 
506 	/* AIF */
507 	SND_SOC_DAPM_AIF_IN("INTF1_SDI", NULL, 0, ISABELLE_INTF_EN_REG, 7, 0),
508 	SND_SOC_DAPM_AIF_IN("INTF2_SDI", NULL, 0, ISABELLE_INTF_EN_REG, 6, 0),
509 
510 	SND_SOC_DAPM_AIF_OUT("INTF1_SDO", NULL, 0, ISABELLE_INTF_EN_REG, 5, 0),
511 	SND_SOC_DAPM_AIF_OUT("INTF2_SDO", NULL, 0, ISABELLE_INTF_EN_REG, 4, 0),
512 
513 	SND_SOC_DAPM_OUT_DRV("ULATX1", SND_SOC_NOPM, 0, 0, NULL, 0),
514 	SND_SOC_DAPM_OUT_DRV("ULATX2", SND_SOC_NOPM, 0, 0, NULL, 0),
515 	SND_SOC_DAPM_OUT_DRV("ULVTX1", SND_SOC_NOPM, 0, 0, NULL, 0),
516 	SND_SOC_DAPM_OUT_DRV("ULVTX2", SND_SOC_NOPM, 0, 0, NULL, 0),
517 
518 	/* Analog Capture PGAs */
519 	SND_SOC_DAPM_PGA("MicAmp1", ISABELLE_AMIC_CFG_REG, 5, 0, NULL, 0),
520 	SND_SOC_DAPM_PGA("MicAmp2", ISABELLE_AMIC_CFG_REG, 4, 0, NULL, 0),
521 
522 	/* Auxiliary FM PGAs */
523 	SND_SOC_DAPM_PGA("APGA1", ISABELLE_APGA_CFG_REG, 7, 0, NULL, 0),
524 	SND_SOC_DAPM_PGA("APGA2", ISABELLE_APGA_CFG_REG, 6, 0, NULL, 0),
525 
526 	/* ADCs */
527 	SND_SOC_DAPM_ADC("ADC1", "Left Front Capture",
528 			ISABELLE_AMIC_CFG_REG, 7, 0),
529 	SND_SOC_DAPM_ADC("ADC2", "Right Front Capture",
530 			ISABELLE_AMIC_CFG_REG, 6, 0),
531 
532 	/* Microphone Bias */
533 	SND_SOC_DAPM_SUPPLY("Headset Mic Bias", ISABELLE_ABIAS_CFG_REG,
534 			3, 0, NULL, 0),
535 	SND_SOC_DAPM_SUPPLY("Main Mic Bias", ISABELLE_ABIAS_CFG_REG,
536 			2, 0, NULL, 0),
537 	SND_SOC_DAPM_SUPPLY("Digital Mic1 Bias",
538 			ISABELLE_DBIAS_CFG_REG, 3, 0, NULL, 0),
539 	SND_SOC_DAPM_SUPPLY("Digital Mic2 Bias",
540 			ISABELLE_DBIAS_CFG_REG, 2, 0, NULL, 0),
541 
542 	/* Mixers */
543 	SND_SOC_DAPM_MIXER("Headset Left Mixer", SND_SOC_NOPM, 0, 0,
544 			isabelle_hs_left_mixer_controls,
545 			ARRAY_SIZE(isabelle_hs_left_mixer_controls)),
546 	SND_SOC_DAPM_MIXER("Headset Right Mixer", SND_SOC_NOPM, 0, 0,
547 			isabelle_hs_right_mixer_controls,
548 			ARRAY_SIZE(isabelle_hs_right_mixer_controls)),
549 	SND_SOC_DAPM_MIXER("Handsfree Left Mixer", SND_SOC_NOPM, 0, 0,
550 			isabelle_hf_left_mixer_controls,
551 			ARRAY_SIZE(isabelle_hf_left_mixer_controls)),
552 	SND_SOC_DAPM_MIXER("Handsfree Right Mixer", SND_SOC_NOPM, 0, 0,
553 			isabelle_hf_right_mixer_controls,
554 			ARRAY_SIZE(isabelle_hf_right_mixer_controls)),
555 	SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0,
556 			isabelle_aux_left_mixer_controls,
557 			ARRAY_SIZE(isabelle_aux_left_mixer_controls)),
558 	SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0,
559 			isabelle_aux_right_mixer_controls,
560 			ARRAY_SIZE(isabelle_aux_right_mixer_controls)),
561 	SND_SOC_DAPM_MIXER("Earphone Mixer", SND_SOC_NOPM, 0, 0,
562 			isabelle_ep_mixer_controls,
563 			ARRAY_SIZE(isabelle_ep_mixer_controls)),
564 
565 	SND_SOC_DAPM_MIXER("DPGA1L Mixer", SND_SOC_NOPM, 0, 0,
566 			isabelle_dpga1_left_mixer_controls,
567 			ARRAY_SIZE(isabelle_dpga1_left_mixer_controls)),
568 	SND_SOC_DAPM_MIXER("DPGA1R Mixer", SND_SOC_NOPM, 0, 0,
569 			isabelle_dpga1_right_mixer_controls,
570 			ARRAY_SIZE(isabelle_dpga1_right_mixer_controls)),
571 	SND_SOC_DAPM_MIXER("DPGA2L Mixer", SND_SOC_NOPM, 0, 0,
572 			isabelle_dpga2_left_mixer_controls,
573 			ARRAY_SIZE(isabelle_dpga2_left_mixer_controls)),
574 	SND_SOC_DAPM_MIXER("DPGA2R Mixer", SND_SOC_NOPM, 0, 0,
575 			isabelle_dpga2_right_mixer_controls,
576 			ARRAY_SIZE(isabelle_dpga2_right_mixer_controls)),
577 	SND_SOC_DAPM_MIXER("DPGA3L Mixer", SND_SOC_NOPM, 0, 0,
578 			isabelle_dpga3_left_mixer_controls,
579 			ARRAY_SIZE(isabelle_dpga3_left_mixer_controls)),
580 	SND_SOC_DAPM_MIXER("DPGA3R Mixer", SND_SOC_NOPM, 0, 0,
581 			isabelle_dpga3_right_mixer_controls,
582 			ARRAY_SIZE(isabelle_dpga3_right_mixer_controls)),
583 
584 	SND_SOC_DAPM_MIXER("RX1 Mixer", SND_SOC_NOPM, 0, 0,
585 			isabelle_rx1_mixer_controls,
586 			ARRAY_SIZE(isabelle_rx1_mixer_controls)),
587 	SND_SOC_DAPM_MIXER("RX2 Mixer", SND_SOC_NOPM, 0, 0,
588 			isabelle_rx2_mixer_controls,
589 			ARRAY_SIZE(isabelle_rx2_mixer_controls)),
590 	SND_SOC_DAPM_MIXER("RX3 Mixer", SND_SOC_NOPM, 0, 0,
591 			isabelle_rx3_mixer_controls,
592 			ARRAY_SIZE(isabelle_rx3_mixer_controls)),
593 	SND_SOC_DAPM_MIXER("RX4 Mixer", SND_SOC_NOPM, 0, 0,
594 			isabelle_rx4_mixer_controls,
595 			ARRAY_SIZE(isabelle_rx4_mixer_controls)),
596 	SND_SOC_DAPM_MIXER("RX5 Mixer", SND_SOC_NOPM, 0, 0,
597 			isabelle_rx5_mixer_controls,
598 			ARRAY_SIZE(isabelle_rx5_mixer_controls)),
599 	SND_SOC_DAPM_MIXER("RX6 Mixer", SND_SOC_NOPM, 0, 0,
600 			isabelle_rx6_mixer_controls,
601 			ARRAY_SIZE(isabelle_rx6_mixer_controls)),
602 
603 	/* DACs */
604 	SND_SOC_DAPM_DAC("DAC1L", "Headset Playback", ISABELLE_DAC_CFG_REG,
605 			5, 0),
606 	SND_SOC_DAPM_DAC("DAC1R", "Headset Playback", ISABELLE_DAC_CFG_REG,
607 			4, 0),
608 	SND_SOC_DAPM_DAC("DAC2L", "Handsfree Playback", ISABELLE_DAC_CFG_REG,
609 			3, 0),
610 	SND_SOC_DAPM_DAC("DAC2R", "Handsfree Playback", ISABELLE_DAC_CFG_REG,
611 			2, 0),
612 	SND_SOC_DAPM_DAC("DAC3L", "Lineout Playback", ISABELLE_DAC_CFG_REG,
613 			1, 0),
614 	SND_SOC_DAPM_DAC("DAC3R", "Lineout Playback", ISABELLE_DAC_CFG_REG,
615 			0, 0),
616 
617 	/* Analog Playback PGAs */
618 	SND_SOC_DAPM_PGA("Sidetone Audio PGA", SND_SOC_NOPM, 0, 0, NULL, 0),
619 	SND_SOC_DAPM_PGA("Sidetone Voice PGA", SND_SOC_NOPM, 0, 0, NULL, 0),
620 	SND_SOC_DAPM_PGA("HF Left PGA", SND_SOC_NOPM, 0, 0, NULL, 0),
621 	SND_SOC_DAPM_PGA("HF Right PGA", SND_SOC_NOPM, 0, 0, NULL, 0),
622 	SND_SOC_DAPM_PGA("DPGA1L", SND_SOC_NOPM, 0, 0, NULL, 0),
623 	SND_SOC_DAPM_PGA("DPGA1R", SND_SOC_NOPM, 0, 0, NULL, 0),
624 	SND_SOC_DAPM_PGA("DPGA2L", SND_SOC_NOPM, 0, 0, NULL, 0),
625 	SND_SOC_DAPM_PGA("DPGA2R", SND_SOC_NOPM, 0, 0, NULL, 0),
626 	SND_SOC_DAPM_PGA("DPGA3L", SND_SOC_NOPM, 0, 0, NULL, 0),
627 	SND_SOC_DAPM_PGA("DPGA3R", SND_SOC_NOPM, 0, 0, NULL, 0),
628 
629 	/* Analog Playback Mux */
630 	SND_SOC_DAPM_MUX("RX1 Playback", ISABELLE_ALU_RX_EN_REG, 5, 0,
631 			&rx1_mux_controls),
632 	SND_SOC_DAPM_MUX("RX2 Playback", ISABELLE_ALU_RX_EN_REG, 4, 0,
633 			&rx2_mux_controls),
634 
635 	/* TX Select */
636 	SND_SOC_DAPM_MUX("ATX Select", ISABELLE_TX_INPUT_CFG_REG,
637 			7, 0, &atx_mux_controls),
638 	SND_SOC_DAPM_MUX("VTX Select", ISABELLE_TX_INPUT_CFG_REG,
639 			6, 0, &vtx_mux_controls),
640 
641 	SND_SOC_DAPM_SWITCH("Earphone Playback", SND_SOC_NOPM, 0, 0,
642 			&ep_path_enable_control),
643 
644 	/* Output Drivers */
645 	SND_SOC_DAPM_OUT_DRV("HS Left Driver", ISABELLE_HSDRV_CFG2_REG,
646 			1, 0, NULL, 0),
647 	SND_SOC_DAPM_OUT_DRV("HS Right Driver", ISABELLE_HSDRV_CFG2_REG,
648 			0, 0, NULL, 0),
649 	SND_SOC_DAPM_OUT_DRV("LINEOUT1 Left Driver", ISABELLE_LINEAMP_CFG_REG,
650 			1, 0, NULL, 0),
651 	SND_SOC_DAPM_OUT_DRV("LINEOUT2 Right Driver", ISABELLE_LINEAMP_CFG_REG,
652 			0, 0, NULL, 0),
653 	SND_SOC_DAPM_OUT_DRV("Earphone Driver", ISABELLE_EARDRV_CFG2_REG,
654 			1, 0, NULL, 0),
655 
656 	SND_SOC_DAPM_OUT_DRV("HF Left Driver", ISABELLE_HFDRV_CFG_REG,
657 			1, 0, NULL, 0),
658 	SND_SOC_DAPM_OUT_DRV("HF Right Driver", ISABELLE_HFDRV_CFG_REG,
659 			0, 0, NULL, 0),
660 };
661 
662 static const struct snd_soc_dapm_route isabelle_intercon[] = {
663 	/* Interface mapping */
664 	{ "DL1", "DL12 Playback Switch", "INTF1_SDI" },
665 	{ "DL2", "DL12 Playback Switch", "INTF1_SDI" },
666 	{ "DL3", "DL34 Playback Switch", "INTF1_SDI" },
667 	{ "DL4", "DL34 Playback Switch", "INTF1_SDI" },
668 	{ "DL5", "DL56 Playback Switch", "INTF1_SDI" },
669 	{ "DL6", "DL56 Playback Switch", "INTF1_SDI" },
670 
671 	{ "DL1", "DL12 Playback Switch", "INTF2_SDI" },
672 	{ "DL2", "DL12 Playback Switch", "INTF2_SDI" },
673 	{ "DL3", "DL34 Playback Switch", "INTF2_SDI" },
674 	{ "DL4", "DL34 Playback Switch", "INTF2_SDI" },
675 	{ "DL5", "DL56 Playback Switch", "INTF2_SDI" },
676 	{ "DL6", "DL56 Playback Switch", "INTF2_SDI" },
677 
678 	/* Input side mapping */
679 	{ "Sidetone Audio PGA", NULL, "Sidetone Audio Playback" },
680 	{ "Sidetone Voice PGA", NULL, "Sidetone Voice Playback" },
681 
682 	{ "RX1 Mixer", "ST1 Playback Switch", "Sidetone Audio PGA" },
683 
684 	{ "RX1 Mixer", "ST1 Playback Switch", "Sidetone Voice PGA" },
685 	{ "RX1 Mixer", "DL1 Playback Switch", "DL1" },
686 
687 	{ "RX2 Mixer", "ST2 Playback Switch", "Sidetone Audio PGA" },
688 
689 	{ "RX2 Mixer", "ST2 Playback Switch", "Sidetone Voice PGA" },
690 	{ "RX2 Mixer", "DL2 Playback Switch", "DL2" },
691 
692 	{ "RX3 Mixer", "ST1 Playback Switch", "Sidetone Voice PGA" },
693 	{ "RX3 Mixer", "DL3 Playback Switch", "DL3" },
694 
695 	{ "RX4 Mixer", "ST2 Playback Switch", "Sidetone Voice PGA" },
696 	{ "RX4 Mixer", "DL4 Playback Switch", "DL4" },
697 
698 	{ "RX5 Mixer", "ST1 Playback Switch", "Sidetone Voice PGA" },
699 	{ "RX5 Mixer", "DL5 Playback Switch", "DL5" },
700 
701 	{ "RX6 Mixer", "ST2 Playback Switch", "Sidetone Voice PGA" },
702 	{ "RX6 Mixer", "DL6 Playback Switch", "DL6" },
703 
704 	/* Capture path */
705 	{ "Analog Left Capture Route", "Headset Mic", "HSMIC" },
706 	{ "Analog Left Capture Route", "Main Mic", "MAINMIC" },
707 	{ "Analog Left Capture Route", "Aux/FM Left", "LINEIN1" },
708 
709 	{ "Analog Right Capture Route", "Sub Mic", "SUBMIC" },
710 	{ "Analog Right Capture Route", "Aux/FM Right", "LINEIN2" },
711 
712 	{ "MicAmp1", NULL, "Analog Left Capture Route" },
713 	{ "MicAmp2", NULL, "Analog Right Capture Route" },
714 
715 	{ "ADC1", NULL, "MicAmp1" },
716 	{ "ADC2", NULL, "MicAmp2" },
717 
718 	{ "ATX Select", "AMIC1", "ADC1" },
719 	{ "ATX Select", "DMIC", "DMICDAT" },
720 	{ "ATX Select", "AMIC2", "ADC2" },
721 
722 	{ "VTX Select", "AMIC1", "ADC1" },
723 	{ "VTX Select", "DMIC", "DMICDAT" },
724 	{ "VTX Select", "AMIC2", "ADC2" },
725 
726 	{ "ULATX1", "ATX1 Filter Enable Switch", "ATX Select" },
727 	{ "ULATX1", "ATX1 Filter Bypass Switch", "ATX Select" },
728 	{ "ULATX2", "ATX2 Filter Enable Switch", "ATX Select" },
729 	{ "ULATX2", "ATX2 Filter Bypass Switch", "ATX Select" },
730 
731 	{ "ULVTX1", "VTX1 Filter Enable Switch", "VTX Select" },
732 	{ "ULVTX1", "VTX1 Filter Bypass Switch", "VTX Select" },
733 	{ "ULVTX2", "VTX2 Filter Enable Switch", "VTX Select" },
734 	{ "ULVTX2", "VTX2 Filter Bypass Switch", "VTX Select" },
735 
736 	{ "INTF1_SDO", "ULATX12 Capture Switch", "ULATX1" },
737 	{ "INTF1_SDO", "ULATX12 Capture Switch", "ULATX2" },
738 	{ "INTF2_SDO", "ULATX12 Capture Switch", "ULATX1" },
739 	{ "INTF2_SDO", "ULATX12 Capture Switch", "ULATX2" },
740 
741 	{ "INTF1_SDO", NULL, "ULVTX1" },
742 	{ "INTF1_SDO", NULL, "ULVTX2" },
743 	{ "INTF2_SDO", NULL, "ULVTX1" },
744 	{ "INTF2_SDO", NULL, "ULVTX2" },
745 
746 	/* AFM Path */
747 	{ "APGA1", NULL, "LINEIN1" },
748 	{ "APGA2", NULL, "LINEIN2" },
749 
750 	{ "RX1 Playback", "VRX1 Filter Bypass Switch", "RX1 Mixer" },
751 	{ "RX1 Playback", "ARX1 Filter Bypass Switch", "RX1 Mixer" },
752 	{ "RX1 Playback", "RX1 Filter Enable Switch", "RX1 Mixer" },
753 
754 	{ "RX2 Playback", "VRX2 Filter Bypass Switch", "RX2 Mixer" },
755 	{ "RX2 Playback", "ARX2 Filter Bypass Switch", "RX2 Mixer" },
756 	{ "RX2 Playback", "RX2 Filter Enable Switch", "RX2 Mixer" },
757 
758 	{ "RX3 Playback", "ARX3 Filter Bypass Switch", "RX3 Mixer" },
759 	{ "RX3 Playback", "RX3 Filter Enable Switch", "RX3 Mixer" },
760 
761 	{ "RX4 Playback", "ARX4 Filter Bypass Switch", "RX4 Mixer" },
762 	{ "RX4 Playback", "RX4 Filter Enable Switch", "RX4 Mixer" },
763 
764 	{ "RX5 Playback", "ARX5 Filter Bypass Switch", "RX5 Mixer" },
765 	{ "RX5 Playback", "RX5 Filter Enable Switch", "RX5 Mixer" },
766 
767 	{ "RX6 Playback", "ARX6 Filter Bypass Switch", "RX6 Mixer" },
768 	{ "RX6 Playback", "RX6 Filter Enable Switch", "RX6 Mixer" },
769 
770 	{ "DPGA1L Mixer", "RX1 Playback Switch", "RX1 Playback" },
771 	{ "DPGA1L Mixer", "RX3 Playback Switch", "RX3 Playback" },
772 	{ "DPGA1L Mixer", "RX5 Playback Switch", "RX5 Playback" },
773 
774 	{ "DPGA1R Mixer", "RX2 Playback Switch", "RX2 Playback" },
775 	{ "DPGA1R Mixer", "RX4 Playback Switch", "RX4 Playback" },
776 	{ "DPGA1R Mixer", "RX6 Playback Switch", "RX6 Playback" },
777 
778 	{ "DPGA1L", NULL, "DPGA1L Mixer" },
779 	{ "DPGA1R", NULL, "DPGA1R Mixer" },
780 
781 	{ "DAC1L", NULL, "DPGA1L" },
782 	{ "DAC1R", NULL, "DPGA1R" },
783 
784 	{ "DPGA2L Mixer", "RX1 Playback Switch", "RX1 Playback" },
785 	{ "DPGA2L Mixer", "RX2 Playback Switch", "RX2 Playback" },
786 	{ "DPGA2L Mixer", "RX3 Playback Switch", "RX3 Playback" },
787 	{ "DPGA2L Mixer", "RX4 Playback Switch", "RX4 Playback" },
788 	{ "DPGA2L Mixer", "RX5 Playback Switch", "RX5 Playback" },
789 	{ "DPGA2L Mixer", "RX6 Playback Switch", "RX6 Playback" },
790 
791 	{ "DPGA2R Mixer", "RX2 Playback Switch", "RX2 Playback" },
792 	{ "DPGA2R Mixer", "RX4 Playback Switch", "RX4 Playback" },
793 	{ "DPGA2R Mixer", "RX6 Playback Switch", "RX6 Playback" },
794 
795 	{ "DPGA2L", NULL, "DPGA2L Mixer" },
796 	{ "DPGA2R", NULL, "DPGA2R Mixer" },
797 
798 	{ "DAC2L", NULL, "DPGA2L" },
799 	{ "DAC2R", NULL, "DPGA2R" },
800 
801 	{ "DPGA3L Mixer", "RX1 Playback Switch", "RX1 Playback" },
802 	{ "DPGA3L Mixer", "RX3 Playback Switch", "RX3 Playback" },
803 	{ "DPGA3L Mixer", "RX5 Playback Switch", "RX5 Playback" },
804 
805 	{ "DPGA3R Mixer", "RX2 Playback Switch", "RX2 Playback" },
806 	{ "DPGA3R Mixer", "RX4 Playback Switch", "RX4 Playback" },
807 	{ "DPGA3R Mixer", "RX6 Playback Switch", "RX6 Playback" },
808 
809 	{ "DPGA3L", NULL, "DPGA3L Mixer" },
810 	{ "DPGA3R", NULL, "DPGA3R Mixer" },
811 
812 	{ "DAC3L", NULL, "DPGA3L" },
813 	{ "DAC3R", NULL, "DPGA3R" },
814 
815 	{ "Headset Left Mixer", "DAC1L Playback Switch", "DAC1L" },
816 	{ "Headset Left Mixer", "APGA1 Playback Switch", "APGA1" },
817 
818 	{ "Headset Right Mixer", "DAC1R Playback Switch", "DAC1R" },
819 	{ "Headset Right Mixer", "APGA2 Playback Switch", "APGA2" },
820 
821 	{ "HS Left Driver", NULL, "Headset Left Mixer" },
822 	{ "HS Right Driver", NULL, "Headset Right Mixer" },
823 
824 	{ "HSOL", NULL, "HS Left Driver" },
825 	{ "HSOR", NULL, "HS Right Driver" },
826 
827 	/* Earphone playback path */
828 	{ "Earphone Mixer", "DAC2L Playback Switch", "DAC2L" },
829 	{ "Earphone Mixer", "APGA1 Playback Switch", "APGA1" },
830 
831 	{ "Earphone Playback", "Switch", "Earphone Mixer" },
832 	{ "Earphone Driver", NULL, "Earphone Playback" },
833 	{ "EP", NULL, "Earphone Driver" },
834 
835 	{ "Handsfree Left Mixer", "DAC2L Playback Switch", "DAC2L" },
836 	{ "Handsfree Left Mixer", "APGA1 Playback Switch", "APGA1" },
837 
838 	{ "Handsfree Right Mixer", "DAC2R Playback Switch", "DAC2R" },
839 	{ "Handsfree Right Mixer", "APGA2 Playback Switch", "APGA2" },
840 
841 	{ "HF Left PGA", NULL, "Handsfree Left Mixer" },
842 	{ "HF Right PGA", NULL, "Handsfree Right Mixer" },
843 
844 	{ "HF Left Driver", NULL, "HF Left PGA" },
845 	{ "HF Right Driver", NULL, "HF Right PGA" },
846 
847 	{ "HFL", NULL, "HF Left Driver" },
848 	{ "HFR", NULL, "HF Right Driver" },
849 
850 	{ "LINEOUT1 Mixer", "DAC3L Playback Switch", "DAC3L" },
851 	{ "LINEOUT1 Mixer", "APGA1 Playback Switch", "APGA1" },
852 
853 	{ "LINEOUT2 Mixer", "DAC3R Playback Switch", "DAC3R" },
854 	{ "LINEOUT2 Mixer", "APGA2 Playback Switch", "APGA2" },
855 
856 	{ "LINEOUT1 Driver", NULL, "LINEOUT1 Mixer" },
857 	{ "LINEOUT2 Driver", NULL, "LINEOUT2 Mixer" },
858 
859 	{ "LINEOUT1", NULL, "LINEOUT1 Driver" },
860 	{ "LINEOUT2", NULL, "LINEOUT2 Driver" },
861 };
862 
863 static int isabelle_hs_mute(struct snd_soc_dai *dai, int mute, int direction)
864 {
865 	snd_soc_component_update_bits(dai->component, ISABELLE_DAC1_SOFTRAMP_REG,
866 			BIT(4), (mute ? BIT(4) : 0));
867 
868 	return 0;
869 }
870 
871 static int isabelle_hf_mute(struct snd_soc_dai *dai, int mute, int direction)
872 {
873 	snd_soc_component_update_bits(dai->component, ISABELLE_DAC2_SOFTRAMP_REG,
874 			BIT(4), (mute ? BIT(4) : 0));
875 
876 	return 0;
877 }
878 
879 static int isabelle_line_mute(struct snd_soc_dai *dai, int mute, int direction)
880 {
881 	snd_soc_component_update_bits(dai->component, ISABELLE_DAC3_SOFTRAMP_REG,
882 			BIT(4), (mute ? BIT(4) : 0));
883 
884 	return 0;
885 }
886 
887 static int isabelle_set_bias_level(struct snd_soc_component *component,
888 				enum snd_soc_bias_level level)
889 {
890 	switch (level) {
891 	case SND_SOC_BIAS_ON:
892 		break;
893 	case SND_SOC_BIAS_PREPARE:
894 		break;
895 
896 	case SND_SOC_BIAS_STANDBY:
897 		snd_soc_component_update_bits(component, ISABELLE_PWR_EN_REG,
898 				ISABELLE_CHIP_EN, BIT(0));
899 		break;
900 
901 	case SND_SOC_BIAS_OFF:
902 		snd_soc_component_update_bits(component, ISABELLE_PWR_EN_REG,
903 				ISABELLE_CHIP_EN, 0);
904 		break;
905 	}
906 
907 	return 0;
908 }
909 
910 static int isabelle_hw_params(struct snd_pcm_substream *substream,
911 			      struct snd_pcm_hw_params *params,
912 			      struct snd_soc_dai *dai)
913 {
914 	struct snd_soc_component *component = dai->component;
915 	u16 aif = 0;
916 	unsigned int fs_val = 0;
917 
918 	switch (params_rate(params)) {
919 	case 8000:
920 		fs_val = ISABELLE_FS_RATE_8;
921 		break;
922 	case 11025:
923 		fs_val = ISABELLE_FS_RATE_11;
924 		break;
925 	case 12000:
926 		fs_val = ISABELLE_FS_RATE_12;
927 		break;
928 	case 16000:
929 		fs_val = ISABELLE_FS_RATE_16;
930 		break;
931 	case 22050:
932 		fs_val = ISABELLE_FS_RATE_22;
933 		break;
934 	case 24000:
935 		fs_val = ISABELLE_FS_RATE_24;
936 		break;
937 	case 32000:
938 		fs_val = ISABELLE_FS_RATE_32;
939 		break;
940 	case 44100:
941 		fs_val = ISABELLE_FS_RATE_44;
942 		break;
943 	case 48000:
944 		fs_val = ISABELLE_FS_RATE_48;
945 		break;
946 	default:
947 		return -EINVAL;
948 	}
949 
950 	snd_soc_component_update_bits(component, ISABELLE_FS_RATE_CFG_REG,
951 			ISABELLE_FS_RATE_MASK, fs_val);
952 
953 	/* bit size */
954 	switch (params_width(params)) {
955 	case 20:
956 		aif |= ISABELLE_AIF_LENGTH_20;
957 		break;
958 	case 32:
959 		aif |= ISABELLE_AIF_LENGTH_32;
960 		break;
961 	default:
962 		return -EINVAL;
963 	}
964 
965 	snd_soc_component_update_bits(component, ISABELLE_INTF_CFG_REG,
966 			ISABELLE_AIF_LENGTH_MASK, aif);
967 
968 	return 0;
969 }
970 
971 static int isabelle_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
972 {
973 	struct snd_soc_component *component = codec_dai->component;
974 	unsigned int aif_val = 0;
975 
976 	switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
977 	case SND_SOC_DAIFMT_CBC_CFC:
978 		aif_val &= ~ISABELLE_AIF_MS;
979 		break;
980 	case SND_SOC_DAIFMT_CBP_CFP:
981 		aif_val |= ISABELLE_AIF_MS;
982 		break;
983 	default:
984 		return -EINVAL;
985 	}
986 
987 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
988 	case SND_SOC_DAIFMT_I2S:
989 		aif_val |= ISABELLE_I2S_MODE;
990 		break;
991 	case SND_SOC_DAIFMT_LEFT_J:
992 		aif_val |= ISABELLE_LEFT_J_MODE;
993 		break;
994 	case SND_SOC_DAIFMT_PDM:
995 		aif_val |= ISABELLE_PDM_MODE;
996 		break;
997 	default:
998 		return -EINVAL;
999 	}
1000 
1001 	snd_soc_component_update_bits(component, ISABELLE_INTF_CFG_REG,
1002 			(ISABELLE_AIF_MS | ISABELLE_AIF_FMT_MASK), aif_val);
1003 
1004 	return 0;
1005 }
1006 
1007 /* Rates supported by Isabelle driver */
1008 #define ISABELLE_RATES		SNDRV_PCM_RATE_8000_48000
1009 
1010 /* Formates supported by Isabelle driver. */
1011 #define ISABELLE_FORMATS (SNDRV_PCM_FMTBIT_S20_3LE |\
1012 			SNDRV_PCM_FMTBIT_S32_LE)
1013 
1014 static const struct snd_soc_dai_ops isabelle_hs_dai_ops = {
1015 	.hw_params	= isabelle_hw_params,
1016 	.set_fmt	= isabelle_set_dai_fmt,
1017 	.mute_stream	= isabelle_hs_mute,
1018 	.no_capture_mute = 1,
1019 };
1020 
1021 static const struct snd_soc_dai_ops isabelle_hf_dai_ops = {
1022 	.hw_params	= isabelle_hw_params,
1023 	.set_fmt	= isabelle_set_dai_fmt,
1024 	.mute_stream	= isabelle_hf_mute,
1025 	.no_capture_mute = 1,
1026 };
1027 
1028 static const struct snd_soc_dai_ops isabelle_line_dai_ops = {
1029 	.hw_params	= isabelle_hw_params,
1030 	.set_fmt	= isabelle_set_dai_fmt,
1031 	.mute_stream	= isabelle_line_mute,
1032 	.no_capture_mute = 1,
1033 };
1034 
1035 static const struct snd_soc_dai_ops isabelle_ul_dai_ops = {
1036 	.hw_params	= isabelle_hw_params,
1037 	.set_fmt	= isabelle_set_dai_fmt,
1038 };
1039 
1040 /* ISABELLE dai structure */
1041 static struct snd_soc_dai_driver isabelle_dai[] = {
1042 	{
1043 		.name = "isabelle-dl1",
1044 		.playback = {
1045 			.stream_name = "Headset Playback",
1046 			.channels_min = 1,
1047 			.channels_max = 2,
1048 			.rates = ISABELLE_RATES,
1049 			.formats = ISABELLE_FORMATS,
1050 		},
1051 		.ops = &isabelle_hs_dai_ops,
1052 	},
1053 	{
1054 		.name = "isabelle-dl2",
1055 		.playback = {
1056 			.stream_name = "Handsfree Playback",
1057 			.channels_min = 1,
1058 			.channels_max = 2,
1059 			.rates = ISABELLE_RATES,
1060 			.formats = ISABELLE_FORMATS,
1061 		},
1062 		.ops = &isabelle_hf_dai_ops,
1063 	},
1064 	{
1065 		.name = "isabelle-lineout",
1066 		.playback = {
1067 			.stream_name = "Lineout Playback",
1068 			.channels_min = 1,
1069 			.channels_max = 2,
1070 			.rates = ISABELLE_RATES,
1071 			.formats = ISABELLE_FORMATS,
1072 		},
1073 		.ops = &isabelle_line_dai_ops,
1074 	},
1075 	{
1076 		.name = "isabelle-ul",
1077 		.capture = {
1078 			.stream_name = "Capture",
1079 			.channels_min = 1,
1080 			.channels_max = 2,
1081 			.rates = ISABELLE_RATES,
1082 			.formats = ISABELLE_FORMATS,
1083 		},
1084 		.ops = &isabelle_ul_dai_ops,
1085 	},
1086 };
1087 
1088 static const struct snd_soc_component_driver soc_component_dev_isabelle = {
1089 	.set_bias_level		= isabelle_set_bias_level,
1090 	.controls		= isabelle_snd_controls,
1091 	.num_controls		= ARRAY_SIZE(isabelle_snd_controls),
1092 	.dapm_widgets		= isabelle_dapm_widgets,
1093 	.num_dapm_widgets	= ARRAY_SIZE(isabelle_dapm_widgets),
1094 	.dapm_routes		= isabelle_intercon,
1095 	.num_dapm_routes	= ARRAY_SIZE(isabelle_intercon),
1096 	.use_pmdown_time	= 1,
1097 	.endianness		= 1,
1098 };
1099 
1100 static const struct regmap_config isabelle_regmap_config = {
1101 	.reg_bits = 8,
1102 	.val_bits = 8,
1103 
1104 	.max_register = ISABELLE_MAX_REGISTER,
1105 	.reg_defaults = isabelle_reg_defs,
1106 	.num_reg_defaults = ARRAY_SIZE(isabelle_reg_defs),
1107 	.cache_type = REGCACHE_RBTREE,
1108 };
1109 
1110 static int isabelle_i2c_probe(struct i2c_client *i2c)
1111 {
1112 	struct regmap *isabelle_regmap;
1113 	int ret = 0;
1114 
1115 	isabelle_regmap = devm_regmap_init_i2c(i2c, &isabelle_regmap_config);
1116 	if (IS_ERR(isabelle_regmap)) {
1117 		ret = PTR_ERR(isabelle_regmap);
1118 		dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
1119 			ret);
1120 		return ret;
1121 	}
1122 	i2c_set_clientdata(i2c, isabelle_regmap);
1123 
1124 	ret = devm_snd_soc_register_component(&i2c->dev,
1125 				&soc_component_dev_isabelle, isabelle_dai,
1126 				ARRAY_SIZE(isabelle_dai));
1127 	if (ret < 0) {
1128 		dev_err(&i2c->dev, "Failed to register component: %d\n", ret);
1129 		return ret;
1130 	}
1131 
1132 	return ret;
1133 }
1134 
1135 static const struct i2c_device_id isabelle_i2c_id[] = {
1136 	{ "isabelle", 0 },
1137 	{ }
1138 };
1139 MODULE_DEVICE_TABLE(i2c, isabelle_i2c_id);
1140 
1141 static struct i2c_driver isabelle_i2c_driver = {
1142 	.driver = {
1143 		.name = "isabelle",
1144 	},
1145 	.probe = isabelle_i2c_probe,
1146 	.id_table = isabelle_i2c_id,
1147 };
1148 
1149 module_i2c_driver(isabelle_i2c_driver);
1150 
1151 MODULE_DESCRIPTION("ASoC ISABELLE driver");
1152 MODULE_AUTHOR("Vishwas A Deshpande <vishwas.a.deshpande@ti.com>");
1153 MODULE_AUTHOR("M R Swami Reddy <MR.Swami.Reddy@ti.com>");
1154 MODULE_LICENSE("GPL v2");
1155