blob: 0f9642c2198ae8cfdaf0409cdae41372ed9dc37c [file] [log] [blame]
Oder Chiou0e826e82014-05-26 20:32:33 +08001/*
2 * rt5677.c -- RT5677 ALSA SoC audio codec driver
3 *
4 * Copyright 2013 Realtek Semiconductor Corp.
5 * Author: Oder Chiou <oder_chiou@realtek.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
John Keeping89128532016-08-24 22:06:35 +010012#include <linux/acpi.h>
Oder Chiou0e826e82014-05-26 20:32:33 +080013#include <linux/fs.h>
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/pm.h>
19#include <linux/regmap.h>
20#include <linux/i2c.h>
21#include <linux/platform_device.h>
22#include <linux/spi/spi.h>
Oder Chiouaf48f1d2014-10-06 16:30:51 +080023#include <linux/firmware.h>
Andy Shevchenkoddc9e692017-07-18 20:34:17 +030024#include <linux/of_device.h>
Ben Zhang9bfde722015-06-22 11:13:00 -070025#include <linux/property.h>
Oder Chiou0e826e82014-05-26 20:32:33 +080026#include <sound/core.h>
27#include <sound/pcm.h>
28#include <sound/pcm_params.h>
29#include <sound/soc.h>
30#include <sound/soc-dapm.h>
31#include <sound/initval.h>
32#include <sound/tlv.h>
33
Axel Lin30f14b42014-06-10 08:57:36 +080034#include "rl6231.h"
Oder Chiou0e826e82014-05-26 20:32:33 +080035#include "rt5677.h"
Oder Chiouaf48f1d2014-10-06 16:30:51 +080036#include "rt5677-spi.h"
Oder Chiou0e826e82014-05-26 20:32:33 +080037
38#define RT5677_DEVICE_ID 0x6327
39
40#define RT5677_PR_RANGE_BASE (0xff + 1)
41#define RT5677_PR_SPACING 0x100
42
43#define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
44
45static const struct regmap_range_cfg rt5677_ranges[] = {
46 {
47 .name = "PR",
48 .range_min = RT5677_PR_BASE,
49 .range_max = RT5677_PR_BASE + 0xfd,
50 .selector_reg = RT5677_PRIV_INDEX,
51 .selector_mask = 0xff,
52 .selector_shift = 0x0,
53 .window_start = RT5677_PRIV_DATA,
54 .window_len = 0x1,
55 },
56};
57
Nariman Poushin8019ff62015-07-16 16:36:21 +010058static const struct reg_sequence init_list[] = {
Oder Chiou2dfe2b02014-11-19 13:52:18 +080059 {RT5677_ASRC_12, 0x0018},
60 {RT5677_PR_BASE + 0x3d, 0x364d},
61 {RT5677_PR_BASE + 0x17, 0x4fc0},
62 {RT5677_PR_BASE + 0x13, 0x0312},
63 {RT5677_PR_BASE + 0x1e, 0x0000},
64 {RT5677_PR_BASE + 0x12, 0x0eaa},
65 {RT5677_PR_BASE + 0x14, 0x018a},
Bard Liao74d6ea52015-04-24 15:19:29 +080066 {RT5677_PR_BASE + 0x15, 0x0490},
67 {RT5677_PR_BASE + 0x38, 0x0f71},
68 {RT5677_PR_BASE + 0x39, 0x0f71},
Oder Chiou0e826e82014-05-26 20:32:33 +080069};
70#define RT5677_INIT_REG_LEN ARRAY_SIZE(init_list)
71
72static const struct reg_default rt5677_reg[] = {
73 {RT5677_RESET , 0x0000},
74 {RT5677_LOUT1 , 0xa800},
75 {RT5677_IN1 , 0x0000},
76 {RT5677_MICBIAS , 0x0000},
77 {RT5677_SLIMBUS_PARAM , 0x0000},
78 {RT5677_SLIMBUS_RX , 0x0000},
79 {RT5677_SLIMBUS_CTRL , 0x0000},
80 {RT5677_SIDETONE_CTRL , 0x000b},
81 {RT5677_ANA_DAC1_2_3_SRC , 0x0000},
82 {RT5677_IF_DSP_DAC3_4_MIXER , 0x1111},
83 {RT5677_DAC4_DIG_VOL , 0xafaf},
84 {RT5677_DAC3_DIG_VOL , 0xafaf},
85 {RT5677_DAC1_DIG_VOL , 0xafaf},
86 {RT5677_DAC2_DIG_VOL , 0xafaf},
87 {RT5677_IF_DSP_DAC2_MIXER , 0x0011},
88 {RT5677_STO1_ADC_DIG_VOL , 0x2f2f},
89 {RT5677_MONO_ADC_DIG_VOL , 0x2f2f},
90 {RT5677_STO1_2_ADC_BST , 0x0000},
91 {RT5677_STO2_ADC_DIG_VOL , 0x2f2f},
92 {RT5677_ADC_BST_CTRL2 , 0x0000},
93 {RT5677_STO3_4_ADC_BST , 0x0000},
94 {RT5677_STO3_ADC_DIG_VOL , 0x2f2f},
95 {RT5677_STO4_ADC_DIG_VOL , 0x2f2f},
96 {RT5677_STO4_ADC_MIXER , 0xd4c0},
97 {RT5677_STO3_ADC_MIXER , 0xd4c0},
98 {RT5677_STO2_ADC_MIXER , 0xd4c0},
99 {RT5677_STO1_ADC_MIXER , 0xd4c0},
100 {RT5677_MONO_ADC_MIXER , 0xd4d1},
101 {RT5677_ADC_IF_DSP_DAC1_MIXER , 0x8080},
102 {RT5677_STO1_DAC_MIXER , 0xaaaa},
103 {RT5677_MONO_DAC_MIXER , 0xaaaa},
104 {RT5677_DD1_MIXER , 0xaaaa},
105 {RT5677_DD2_MIXER , 0xaaaa},
106 {RT5677_IF3_DATA , 0x0000},
107 {RT5677_IF4_DATA , 0x0000},
108 {RT5677_PDM_OUT_CTRL , 0x8888},
109 {RT5677_PDM_DATA_CTRL1 , 0x0000},
110 {RT5677_PDM_DATA_CTRL2 , 0x0000},
111 {RT5677_PDM1_DATA_CTRL2 , 0x0000},
112 {RT5677_PDM1_DATA_CTRL3 , 0x0000},
113 {RT5677_PDM1_DATA_CTRL4 , 0x0000},
114 {RT5677_PDM2_DATA_CTRL2 , 0x0000},
115 {RT5677_PDM2_DATA_CTRL3 , 0x0000},
116 {RT5677_PDM2_DATA_CTRL4 , 0x0000},
117 {RT5677_TDM1_CTRL1 , 0x0300},
118 {RT5677_TDM1_CTRL2 , 0x0000},
119 {RT5677_TDM1_CTRL3 , 0x4000},
120 {RT5677_TDM1_CTRL4 , 0x0123},
121 {RT5677_TDM1_CTRL5 , 0x4567},
122 {RT5677_TDM2_CTRL1 , 0x0300},
123 {RT5677_TDM2_CTRL2 , 0x0000},
124 {RT5677_TDM2_CTRL3 , 0x4000},
125 {RT5677_TDM2_CTRL4 , 0x0123},
126 {RT5677_TDM2_CTRL5 , 0x4567},
127 {RT5677_I2C_MASTER_CTRL1 , 0x0001},
128 {RT5677_I2C_MASTER_CTRL2 , 0x0000},
129 {RT5677_I2C_MASTER_CTRL3 , 0x0000},
130 {RT5677_I2C_MASTER_CTRL4 , 0x0000},
131 {RT5677_I2C_MASTER_CTRL5 , 0x0000},
132 {RT5677_I2C_MASTER_CTRL6 , 0x0000},
133 {RT5677_I2C_MASTER_CTRL7 , 0x0000},
134 {RT5677_I2C_MASTER_CTRL8 , 0x0000},
135 {RT5677_DMIC_CTRL1 , 0x1505},
136 {RT5677_DMIC_CTRL2 , 0x0055},
137 {RT5677_HAP_GENE_CTRL1 , 0x0111},
138 {RT5677_HAP_GENE_CTRL2 , 0x0064},
139 {RT5677_HAP_GENE_CTRL3 , 0xef0e},
140 {RT5677_HAP_GENE_CTRL4 , 0xf0f0},
141 {RT5677_HAP_GENE_CTRL5 , 0xef0e},
142 {RT5677_HAP_GENE_CTRL6 , 0xf0f0},
143 {RT5677_HAP_GENE_CTRL7 , 0xef0e},
144 {RT5677_HAP_GENE_CTRL8 , 0xf0f0},
145 {RT5677_HAP_GENE_CTRL9 , 0xf000},
146 {RT5677_HAP_GENE_CTRL10 , 0x0000},
147 {RT5677_PWR_DIG1 , 0x0000},
148 {RT5677_PWR_DIG2 , 0x0000},
149 {RT5677_PWR_ANLG1 , 0x0055},
150 {RT5677_PWR_ANLG2 , 0x0000},
151 {RT5677_PWR_DSP1 , 0x0001},
152 {RT5677_PWR_DSP_ST , 0x0000},
153 {RT5677_PWR_DSP2 , 0x0000},
154 {RT5677_ADC_DAC_HPF_CTRL1 , 0x0e00},
155 {RT5677_PRIV_INDEX , 0x0000},
156 {RT5677_PRIV_DATA , 0x0000},
157 {RT5677_I2S4_SDP , 0x8000},
158 {RT5677_I2S1_SDP , 0x8000},
159 {RT5677_I2S2_SDP , 0x8000},
160 {RT5677_I2S3_SDP , 0x8000},
161 {RT5677_CLK_TREE_CTRL1 , 0x1111},
162 {RT5677_CLK_TREE_CTRL2 , 0x1111},
163 {RT5677_CLK_TREE_CTRL3 , 0x0000},
164 {RT5677_PLL1_CTRL1 , 0x0000},
165 {RT5677_PLL1_CTRL2 , 0x0000},
166 {RT5677_PLL2_CTRL1 , 0x0c60},
167 {RT5677_PLL2_CTRL2 , 0x2000},
168 {RT5677_GLB_CLK1 , 0x0000},
169 {RT5677_GLB_CLK2 , 0x0000},
170 {RT5677_ASRC_1 , 0x0000},
171 {RT5677_ASRC_2 , 0x0000},
172 {RT5677_ASRC_3 , 0x0000},
173 {RT5677_ASRC_4 , 0x0000},
174 {RT5677_ASRC_5 , 0x0000},
175 {RT5677_ASRC_6 , 0x0000},
176 {RT5677_ASRC_7 , 0x0000},
177 {RT5677_ASRC_8 , 0x0000},
178 {RT5677_ASRC_9 , 0x0000},
179 {RT5677_ASRC_10 , 0x0000},
180 {RT5677_ASRC_11 , 0x0000},
Oder Chiou86ae04b2014-11-17 10:18:11 +0800181 {RT5677_ASRC_12 , 0x0018},
Oder Chiou0e826e82014-05-26 20:32:33 +0800182 {RT5677_ASRC_13 , 0x0000},
183 {RT5677_ASRC_14 , 0x0000},
184 {RT5677_ASRC_15 , 0x0000},
185 {RT5677_ASRC_16 , 0x0000},
186 {RT5677_ASRC_17 , 0x0000},
187 {RT5677_ASRC_18 , 0x0000},
188 {RT5677_ASRC_19 , 0x0000},
189 {RT5677_ASRC_20 , 0x0000},
190 {RT5677_ASRC_21 , 0x000c},
191 {RT5677_ASRC_22 , 0x0000},
192 {RT5677_ASRC_23 , 0x0000},
193 {RT5677_VAD_CTRL1 , 0x2184},
194 {RT5677_VAD_CTRL2 , 0x010a},
195 {RT5677_VAD_CTRL3 , 0x0aea},
196 {RT5677_VAD_CTRL4 , 0x000c},
197 {RT5677_VAD_CTRL5 , 0x0000},
198 {RT5677_DSP_INB_CTRL1 , 0x0000},
199 {RT5677_DSP_INB_CTRL2 , 0x0000},
200 {RT5677_DSP_IN_OUTB_CTRL , 0x0000},
201 {RT5677_DSP_OUTB0_1_DIG_VOL , 0x2f2f},
202 {RT5677_DSP_OUTB2_3_DIG_VOL , 0x2f2f},
203 {RT5677_DSP_OUTB4_5_DIG_VOL , 0x2f2f},
204 {RT5677_DSP_OUTB6_7_DIG_VOL , 0x2f2f},
205 {RT5677_ADC_EQ_CTRL1 , 0x6000},
206 {RT5677_ADC_EQ_CTRL2 , 0x0000},
207 {RT5677_EQ_CTRL1 , 0xc000},
208 {RT5677_EQ_CTRL2 , 0x0000},
209 {RT5677_EQ_CTRL3 , 0x0000},
210 {RT5677_SOFT_VOL_ZERO_CROSS1 , 0x0009},
211 {RT5677_JD_CTRL1 , 0x0000},
212 {RT5677_JD_CTRL2 , 0x0000},
213 {RT5677_JD_CTRL3 , 0x0000},
214 {RT5677_IRQ_CTRL1 , 0x0000},
215 {RT5677_IRQ_CTRL2 , 0x0000},
216 {RT5677_GPIO_ST , 0x0000},
217 {RT5677_GPIO_CTRL1 , 0x0000},
218 {RT5677_GPIO_CTRL2 , 0x0000},
219 {RT5677_GPIO_CTRL3 , 0x0000},
220 {RT5677_STO1_ADC_HI_FILTER1 , 0xb320},
221 {RT5677_STO1_ADC_HI_FILTER2 , 0x0000},
222 {RT5677_MONO_ADC_HI_FILTER1 , 0xb300},
223 {RT5677_MONO_ADC_HI_FILTER2 , 0x0000},
224 {RT5677_STO2_ADC_HI_FILTER1 , 0xb300},
225 {RT5677_STO2_ADC_HI_FILTER2 , 0x0000},
226 {RT5677_STO3_ADC_HI_FILTER1 , 0xb300},
227 {RT5677_STO3_ADC_HI_FILTER2 , 0x0000},
228 {RT5677_STO4_ADC_HI_FILTER1 , 0xb300},
229 {RT5677_STO4_ADC_HI_FILTER2 , 0x0000},
230 {RT5677_MB_DRC_CTRL1 , 0x0f20},
231 {RT5677_DRC1_CTRL1 , 0x001f},
232 {RT5677_DRC1_CTRL2 , 0x020c},
233 {RT5677_DRC1_CTRL3 , 0x1f00},
234 {RT5677_DRC1_CTRL4 , 0x0000},
235 {RT5677_DRC1_CTRL5 , 0x0000},
236 {RT5677_DRC1_CTRL6 , 0x0029},
237 {RT5677_DRC2_CTRL1 , 0x001f},
238 {RT5677_DRC2_CTRL2 , 0x020c},
239 {RT5677_DRC2_CTRL3 , 0x1f00},
240 {RT5677_DRC2_CTRL4 , 0x0000},
241 {RT5677_DRC2_CTRL5 , 0x0000},
242 {RT5677_DRC2_CTRL6 , 0x0029},
243 {RT5677_DRC1_HL_CTRL1 , 0x8000},
244 {RT5677_DRC1_HL_CTRL2 , 0x0200},
245 {RT5677_DRC2_HL_CTRL1 , 0x8000},
246 {RT5677_DRC2_HL_CTRL2 , 0x0200},
247 {RT5677_DSP_INB1_SRC_CTRL1 , 0x5800},
248 {RT5677_DSP_INB1_SRC_CTRL2 , 0x0000},
249 {RT5677_DSP_INB1_SRC_CTRL3 , 0x0000},
250 {RT5677_DSP_INB1_SRC_CTRL4 , 0x0800},
251 {RT5677_DSP_INB2_SRC_CTRL1 , 0x5800},
252 {RT5677_DSP_INB2_SRC_CTRL2 , 0x0000},
253 {RT5677_DSP_INB2_SRC_CTRL3 , 0x0000},
254 {RT5677_DSP_INB2_SRC_CTRL4 , 0x0800},
255 {RT5677_DSP_INB3_SRC_CTRL1 , 0x5800},
256 {RT5677_DSP_INB3_SRC_CTRL2 , 0x0000},
257 {RT5677_DSP_INB3_SRC_CTRL3 , 0x0000},
258 {RT5677_DSP_INB3_SRC_CTRL4 , 0x0800},
259 {RT5677_DSP_OUTB1_SRC_CTRL1 , 0x5800},
260 {RT5677_DSP_OUTB1_SRC_CTRL2 , 0x0000},
261 {RT5677_DSP_OUTB1_SRC_CTRL3 , 0x0000},
262 {RT5677_DSP_OUTB1_SRC_CTRL4 , 0x0800},
263 {RT5677_DSP_OUTB2_SRC_CTRL1 , 0x5800},
264 {RT5677_DSP_OUTB2_SRC_CTRL2 , 0x0000},
265 {RT5677_DSP_OUTB2_SRC_CTRL3 , 0x0000},
266 {RT5677_DSP_OUTB2_SRC_CTRL4 , 0x0800},
267 {RT5677_DSP_OUTB_0123_MIXER_CTRL, 0xfefe},
268 {RT5677_DSP_OUTB_45_MIXER_CTRL , 0xfefe},
269 {RT5677_DSP_OUTB_67_MIXER_CTRL , 0xfefe},
270 {RT5677_DIG_MISC , 0x0000},
271 {RT5677_GEN_CTRL1 , 0x0000},
272 {RT5677_GEN_CTRL2 , 0x0000},
273 {RT5677_VENDOR_ID , 0x0000},
274 {RT5677_VENDOR_ID1 , 0x10ec},
275 {RT5677_VENDOR_ID2 , 0x6327},
276};
277
278static bool rt5677_volatile_register(struct device *dev, unsigned int reg)
279{
280 int i;
281
282 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
283 if (reg >= rt5677_ranges[i].range_min &&
284 reg <= rt5677_ranges[i].range_max) {
285 return true;
286 }
287 }
288
289 switch (reg) {
290 case RT5677_RESET:
291 case RT5677_SLIMBUS_PARAM:
292 case RT5677_PDM_DATA_CTRL1:
293 case RT5677_PDM_DATA_CTRL2:
294 case RT5677_PDM1_DATA_CTRL4:
295 case RT5677_PDM2_DATA_CTRL4:
296 case RT5677_I2C_MASTER_CTRL1:
297 case RT5677_I2C_MASTER_CTRL7:
298 case RT5677_I2C_MASTER_CTRL8:
299 case RT5677_HAP_GENE_CTRL2:
300 case RT5677_PWR_DSP_ST:
301 case RT5677_PRIV_DATA:
Oder Chiou0e826e82014-05-26 20:32:33 +0800302 case RT5677_ASRC_22:
303 case RT5677_ASRC_23:
304 case RT5677_VAD_CTRL5:
305 case RT5677_ADC_EQ_CTRL1:
306 case RT5677_EQ_CTRL1:
307 case RT5677_IRQ_CTRL1:
308 case RT5677_IRQ_CTRL2:
309 case RT5677_GPIO_ST:
310 case RT5677_DSP_INB1_SRC_CTRL4:
311 case RT5677_DSP_INB2_SRC_CTRL4:
312 case RT5677_DSP_INB3_SRC_CTRL4:
313 case RT5677_DSP_OUTB1_SRC_CTRL4:
314 case RT5677_DSP_OUTB2_SRC_CTRL4:
315 case RT5677_VENDOR_ID:
316 case RT5677_VENDOR_ID1:
317 case RT5677_VENDOR_ID2:
318 return true;
319 default:
320 return false;
321 }
322}
323
324static bool rt5677_readable_register(struct device *dev, unsigned int reg)
325{
326 int i;
327
328 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
329 if (reg >= rt5677_ranges[i].range_min &&
330 reg <= rt5677_ranges[i].range_max) {
331 return true;
332 }
333 }
334
335 switch (reg) {
336 case RT5677_RESET:
337 case RT5677_LOUT1:
338 case RT5677_IN1:
339 case RT5677_MICBIAS:
340 case RT5677_SLIMBUS_PARAM:
341 case RT5677_SLIMBUS_RX:
342 case RT5677_SLIMBUS_CTRL:
343 case RT5677_SIDETONE_CTRL:
344 case RT5677_ANA_DAC1_2_3_SRC:
345 case RT5677_IF_DSP_DAC3_4_MIXER:
346 case RT5677_DAC4_DIG_VOL:
347 case RT5677_DAC3_DIG_VOL:
348 case RT5677_DAC1_DIG_VOL:
349 case RT5677_DAC2_DIG_VOL:
350 case RT5677_IF_DSP_DAC2_MIXER:
351 case RT5677_STO1_ADC_DIG_VOL:
352 case RT5677_MONO_ADC_DIG_VOL:
353 case RT5677_STO1_2_ADC_BST:
354 case RT5677_STO2_ADC_DIG_VOL:
355 case RT5677_ADC_BST_CTRL2:
356 case RT5677_STO3_4_ADC_BST:
357 case RT5677_STO3_ADC_DIG_VOL:
358 case RT5677_STO4_ADC_DIG_VOL:
359 case RT5677_STO4_ADC_MIXER:
360 case RT5677_STO3_ADC_MIXER:
361 case RT5677_STO2_ADC_MIXER:
362 case RT5677_STO1_ADC_MIXER:
363 case RT5677_MONO_ADC_MIXER:
364 case RT5677_ADC_IF_DSP_DAC1_MIXER:
365 case RT5677_STO1_DAC_MIXER:
366 case RT5677_MONO_DAC_MIXER:
367 case RT5677_DD1_MIXER:
368 case RT5677_DD2_MIXER:
369 case RT5677_IF3_DATA:
370 case RT5677_IF4_DATA:
371 case RT5677_PDM_OUT_CTRL:
372 case RT5677_PDM_DATA_CTRL1:
373 case RT5677_PDM_DATA_CTRL2:
374 case RT5677_PDM1_DATA_CTRL2:
375 case RT5677_PDM1_DATA_CTRL3:
376 case RT5677_PDM1_DATA_CTRL4:
377 case RT5677_PDM2_DATA_CTRL2:
378 case RT5677_PDM2_DATA_CTRL3:
379 case RT5677_PDM2_DATA_CTRL4:
380 case RT5677_TDM1_CTRL1:
381 case RT5677_TDM1_CTRL2:
382 case RT5677_TDM1_CTRL3:
383 case RT5677_TDM1_CTRL4:
384 case RT5677_TDM1_CTRL5:
385 case RT5677_TDM2_CTRL1:
386 case RT5677_TDM2_CTRL2:
387 case RT5677_TDM2_CTRL3:
388 case RT5677_TDM2_CTRL4:
389 case RT5677_TDM2_CTRL5:
390 case RT5677_I2C_MASTER_CTRL1:
391 case RT5677_I2C_MASTER_CTRL2:
392 case RT5677_I2C_MASTER_CTRL3:
393 case RT5677_I2C_MASTER_CTRL4:
394 case RT5677_I2C_MASTER_CTRL5:
395 case RT5677_I2C_MASTER_CTRL6:
396 case RT5677_I2C_MASTER_CTRL7:
397 case RT5677_I2C_MASTER_CTRL8:
398 case RT5677_DMIC_CTRL1:
399 case RT5677_DMIC_CTRL2:
400 case RT5677_HAP_GENE_CTRL1:
401 case RT5677_HAP_GENE_CTRL2:
402 case RT5677_HAP_GENE_CTRL3:
403 case RT5677_HAP_GENE_CTRL4:
404 case RT5677_HAP_GENE_CTRL5:
405 case RT5677_HAP_GENE_CTRL6:
406 case RT5677_HAP_GENE_CTRL7:
407 case RT5677_HAP_GENE_CTRL8:
408 case RT5677_HAP_GENE_CTRL9:
409 case RT5677_HAP_GENE_CTRL10:
410 case RT5677_PWR_DIG1:
411 case RT5677_PWR_DIG2:
412 case RT5677_PWR_ANLG1:
413 case RT5677_PWR_ANLG2:
414 case RT5677_PWR_DSP1:
415 case RT5677_PWR_DSP_ST:
416 case RT5677_PWR_DSP2:
417 case RT5677_ADC_DAC_HPF_CTRL1:
418 case RT5677_PRIV_INDEX:
419 case RT5677_PRIV_DATA:
420 case RT5677_I2S4_SDP:
421 case RT5677_I2S1_SDP:
422 case RT5677_I2S2_SDP:
423 case RT5677_I2S3_SDP:
424 case RT5677_CLK_TREE_CTRL1:
425 case RT5677_CLK_TREE_CTRL2:
426 case RT5677_CLK_TREE_CTRL3:
427 case RT5677_PLL1_CTRL1:
428 case RT5677_PLL1_CTRL2:
429 case RT5677_PLL2_CTRL1:
430 case RT5677_PLL2_CTRL2:
431 case RT5677_GLB_CLK1:
432 case RT5677_GLB_CLK2:
433 case RT5677_ASRC_1:
434 case RT5677_ASRC_2:
435 case RT5677_ASRC_3:
436 case RT5677_ASRC_4:
437 case RT5677_ASRC_5:
438 case RT5677_ASRC_6:
439 case RT5677_ASRC_7:
440 case RT5677_ASRC_8:
441 case RT5677_ASRC_9:
442 case RT5677_ASRC_10:
443 case RT5677_ASRC_11:
444 case RT5677_ASRC_12:
445 case RT5677_ASRC_13:
446 case RT5677_ASRC_14:
447 case RT5677_ASRC_15:
448 case RT5677_ASRC_16:
449 case RT5677_ASRC_17:
450 case RT5677_ASRC_18:
451 case RT5677_ASRC_19:
452 case RT5677_ASRC_20:
453 case RT5677_ASRC_21:
454 case RT5677_ASRC_22:
455 case RT5677_ASRC_23:
456 case RT5677_VAD_CTRL1:
457 case RT5677_VAD_CTRL2:
458 case RT5677_VAD_CTRL3:
459 case RT5677_VAD_CTRL4:
460 case RT5677_VAD_CTRL5:
461 case RT5677_DSP_INB_CTRL1:
462 case RT5677_DSP_INB_CTRL2:
463 case RT5677_DSP_IN_OUTB_CTRL:
464 case RT5677_DSP_OUTB0_1_DIG_VOL:
465 case RT5677_DSP_OUTB2_3_DIG_VOL:
466 case RT5677_DSP_OUTB4_5_DIG_VOL:
467 case RT5677_DSP_OUTB6_7_DIG_VOL:
468 case RT5677_ADC_EQ_CTRL1:
469 case RT5677_ADC_EQ_CTRL2:
470 case RT5677_EQ_CTRL1:
471 case RT5677_EQ_CTRL2:
472 case RT5677_EQ_CTRL3:
473 case RT5677_SOFT_VOL_ZERO_CROSS1:
474 case RT5677_JD_CTRL1:
475 case RT5677_JD_CTRL2:
476 case RT5677_JD_CTRL3:
477 case RT5677_IRQ_CTRL1:
478 case RT5677_IRQ_CTRL2:
479 case RT5677_GPIO_ST:
480 case RT5677_GPIO_CTRL1:
481 case RT5677_GPIO_CTRL2:
482 case RT5677_GPIO_CTRL3:
483 case RT5677_STO1_ADC_HI_FILTER1:
484 case RT5677_STO1_ADC_HI_FILTER2:
485 case RT5677_MONO_ADC_HI_FILTER1:
486 case RT5677_MONO_ADC_HI_FILTER2:
487 case RT5677_STO2_ADC_HI_FILTER1:
488 case RT5677_STO2_ADC_HI_FILTER2:
489 case RT5677_STO3_ADC_HI_FILTER1:
490 case RT5677_STO3_ADC_HI_FILTER2:
491 case RT5677_STO4_ADC_HI_FILTER1:
492 case RT5677_STO4_ADC_HI_FILTER2:
493 case RT5677_MB_DRC_CTRL1:
494 case RT5677_DRC1_CTRL1:
495 case RT5677_DRC1_CTRL2:
496 case RT5677_DRC1_CTRL3:
497 case RT5677_DRC1_CTRL4:
498 case RT5677_DRC1_CTRL5:
499 case RT5677_DRC1_CTRL6:
500 case RT5677_DRC2_CTRL1:
501 case RT5677_DRC2_CTRL2:
502 case RT5677_DRC2_CTRL3:
503 case RT5677_DRC2_CTRL4:
504 case RT5677_DRC2_CTRL5:
505 case RT5677_DRC2_CTRL6:
506 case RT5677_DRC1_HL_CTRL1:
507 case RT5677_DRC1_HL_CTRL2:
508 case RT5677_DRC2_HL_CTRL1:
509 case RT5677_DRC2_HL_CTRL2:
510 case RT5677_DSP_INB1_SRC_CTRL1:
511 case RT5677_DSP_INB1_SRC_CTRL2:
512 case RT5677_DSP_INB1_SRC_CTRL3:
513 case RT5677_DSP_INB1_SRC_CTRL4:
514 case RT5677_DSP_INB2_SRC_CTRL1:
515 case RT5677_DSP_INB2_SRC_CTRL2:
516 case RT5677_DSP_INB2_SRC_CTRL3:
517 case RT5677_DSP_INB2_SRC_CTRL4:
518 case RT5677_DSP_INB3_SRC_CTRL1:
519 case RT5677_DSP_INB3_SRC_CTRL2:
520 case RT5677_DSP_INB3_SRC_CTRL3:
521 case RT5677_DSP_INB3_SRC_CTRL4:
522 case RT5677_DSP_OUTB1_SRC_CTRL1:
523 case RT5677_DSP_OUTB1_SRC_CTRL2:
524 case RT5677_DSP_OUTB1_SRC_CTRL3:
525 case RT5677_DSP_OUTB1_SRC_CTRL4:
526 case RT5677_DSP_OUTB2_SRC_CTRL1:
527 case RT5677_DSP_OUTB2_SRC_CTRL2:
528 case RT5677_DSP_OUTB2_SRC_CTRL3:
529 case RT5677_DSP_OUTB2_SRC_CTRL4:
530 case RT5677_DSP_OUTB_0123_MIXER_CTRL:
531 case RT5677_DSP_OUTB_45_MIXER_CTRL:
532 case RT5677_DSP_OUTB_67_MIXER_CTRL:
533 case RT5677_DIG_MISC:
534 case RT5677_GEN_CTRL1:
535 case RT5677_GEN_CTRL2:
536 case RT5677_VENDOR_ID:
537 case RT5677_VENDOR_ID1:
538 case RT5677_VENDOR_ID2:
539 return true;
540 default:
541 return false;
542 }
543}
544
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800545/**
546 * rt5677_dsp_mode_i2c_write_addr - Write value to address on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800547 * @rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800548 * @addr: Address index.
549 * @value: Address data.
550 *
551 *
552 * Returns 0 for success or negative error code.
553 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800554static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800555 unsigned int addr, unsigned int value, unsigned int opcode)
556{
Oder Chiou19ba4842014-11-05 13:42:53 +0800557 struct snd_soc_codec *codec = rt5677->codec;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800558 int ret;
559
560 mutex_lock(&rt5677->dsp_cmd_lock);
561
Oder Chiou19ba4842014-11-05 13:42:53 +0800562 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
563 addr >> 16);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800564 if (ret < 0) {
565 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
566 goto err;
567 }
568
Oder Chiou19ba4842014-11-05 13:42:53 +0800569 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800570 addr & 0xffff);
571 if (ret < 0) {
572 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
573 goto err;
574 }
575
Oder Chiou19ba4842014-11-05 13:42:53 +0800576 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800577 value >> 16);
578 if (ret < 0) {
579 dev_err(codec->dev, "Failed to set data msb value: %d\n", ret);
580 goto err;
581 }
582
Oder Chiou19ba4842014-11-05 13:42:53 +0800583 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800584 value & 0xffff);
585 if (ret < 0) {
586 dev_err(codec->dev, "Failed to set data lsb value: %d\n", ret);
587 goto err;
588 }
589
Oder Chiou19ba4842014-11-05 13:42:53 +0800590 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
591 opcode);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800592 if (ret < 0) {
593 dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
594 goto err;
595 }
596
597err:
598 mutex_unlock(&rt5677->dsp_cmd_lock);
599
600 return ret;
601}
602
603/**
604 * rt5677_dsp_mode_i2c_read_addr - Read value from address on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800605 * rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800606 * @addr: Address index.
607 * @value: Address data.
608 *
Oder Chiou19ba4842014-11-05 13:42:53 +0800609 *
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800610 * Returns 0 for success or negative error code.
611 */
612static int rt5677_dsp_mode_i2c_read_addr(
Oder Chiou19ba4842014-11-05 13:42:53 +0800613 struct rt5677_priv *rt5677, unsigned int addr, unsigned int *value)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800614{
Oder Chiou19ba4842014-11-05 13:42:53 +0800615 struct snd_soc_codec *codec = rt5677->codec;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800616 int ret;
617 unsigned int msb, lsb;
618
619 mutex_lock(&rt5677->dsp_cmd_lock);
620
Oder Chiou19ba4842014-11-05 13:42:53 +0800621 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
622 addr >> 16);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800623 if (ret < 0) {
624 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
625 goto err;
626 }
627
Oder Chiou19ba4842014-11-05 13:42:53 +0800628 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800629 addr & 0xffff);
630 if (ret < 0) {
631 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
632 goto err;
633 }
634
Oder Chiou19ba4842014-11-05 13:42:53 +0800635 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
636 0x0002);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800637 if (ret < 0) {
638 dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
639 goto err;
640 }
641
Oder Chiou19ba4842014-11-05 13:42:53 +0800642 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, &msb);
643 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, &lsb);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800644 *value = (msb << 16) | lsb;
645
646err:
647 mutex_unlock(&rt5677->dsp_cmd_lock);
648
649 return ret;
650}
651
652/**
653 * rt5677_dsp_mode_i2c_write - Write register on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800654 * rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800655 * @reg: Register index.
656 * @value: Register data.
657 *
658 *
659 * Returns 0 for success or negative error code.
660 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800661static int rt5677_dsp_mode_i2c_write(struct rt5677_priv *rt5677,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800662 unsigned int reg, unsigned int value)
663{
Oder Chiou19ba4842014-11-05 13:42:53 +0800664 return rt5677_dsp_mode_i2c_write_addr(rt5677, 0x18020000 + reg * 2,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800665 value, 0x0001);
666}
667
668/**
669 * rt5677_dsp_mode_i2c_read - Read register on DSP mode.
670 * @codec: SoC audio codec device.
671 * @reg: Register index.
Oder Chiou19ba4842014-11-05 13:42:53 +0800672 * @value: Register data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800673 *
674 *
Oder Chiou19ba4842014-11-05 13:42:53 +0800675 * Returns 0 for success or negative error code.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800676 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800677static int rt5677_dsp_mode_i2c_read(
678 struct rt5677_priv *rt5677, unsigned int reg, unsigned int *value)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800679{
Oder Chiou19ba4842014-11-05 13:42:53 +0800680 int ret = rt5677_dsp_mode_i2c_read_addr(rt5677, 0x18020000 + reg * 2,
681 value);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800682
Oder Chiou19ba4842014-11-05 13:42:53 +0800683 *value &= 0xffff;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800684
Oder Chiou19ba4842014-11-05 13:42:53 +0800685 return ret;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800686}
687
Oder Chiou19ba4842014-11-05 13:42:53 +0800688static void rt5677_set_dsp_mode(struct snd_soc_codec *codec, bool on)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800689{
Oder Chiou19ba4842014-11-05 13:42:53 +0800690 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800691
Oder Chiou19ba4842014-11-05 13:42:53 +0800692 if (on) {
693 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x2);
694 rt5677->is_dsp_mode = true;
695 } else {
696 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x0);
697 rt5677->is_dsp_mode = false;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800698 }
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800699}
700
701static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
702{
703 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
704 static bool activity;
705 int ret;
706
Arnd Bergmann4c121122015-01-28 22:31:30 +0100707 if (!IS_ENABLED(CONFIG_SND_SOC_RT5677_SPI))
708 return -ENXIO;
709
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800710 if (on && !activity) {
711 activity = true;
712
713 regcache_cache_only(rt5677->regmap, false);
714 regcache_cache_bypass(rt5677->regmap, true);
715
716 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x1);
717 regmap_update_bits(rt5677->regmap,
718 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0f00);
719 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
720 RT5677_LDO1_SEL_MASK, 0x0);
721 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
722 RT5677_PWR_LDO1, RT5677_PWR_LDO1);
Oder Chiouab1f7092015-02-11 19:18:51 +0800723 switch (rt5677->type) {
724 case RT5677:
725 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
726 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC);
727 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
728 RT5677_PLL2_PR_SRC_MASK |
729 RT5677_DSP_CLK_SRC_MASK,
730 RT5677_PLL2_PR_SRC_MCLK2 |
731 RT5677_DSP_CLK_SRC_BYPASS);
732 break;
733 case RT5676:
734 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
735 RT5677_DSP_CLK_SRC_MASK,
736 RT5677_DSP_CLK_SRC_BYPASS);
737 break;
738 default:
739 break;
740 }
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800741 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff);
Oder Chiou19ba4842014-11-05 13:42:53 +0800742 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd);
743 rt5677_set_dsp_mode(codec, true);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800744
745 ret = request_firmware(&rt5677->fw1, RT5677_FIRMWARE1,
746 codec->dev);
747 if (ret == 0) {
Ben Zhang7d4d4432015-08-21 21:17:00 -0700748 rt5677_spi_write_firmware(0x50000000, rt5677->fw1);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800749 release_firmware(rt5677->fw1);
750 }
751
752 ret = request_firmware(&rt5677->fw2, RT5677_FIRMWARE2,
753 codec->dev);
754 if (ret == 0) {
Ben Zhang7d4d4432015-08-21 21:17:00 -0700755 rt5677_spi_write_firmware(0x60000000, rt5677->fw2);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800756 release_firmware(rt5677->fw2);
757 }
758
Oder Chiou19ba4842014-11-05 13:42:53 +0800759 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x0);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800760
761 regcache_cache_bypass(rt5677->regmap, false);
762 regcache_cache_only(rt5677->regmap, true);
763 } else if (!on && activity) {
764 activity = false;
765
766 regcache_cache_only(rt5677->regmap, false);
767 regcache_cache_bypass(rt5677->regmap, true);
768
Oder Chiou19ba4842014-11-05 13:42:53 +0800769 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x1);
770 rt5677_set_dsp_mode(codec, false);
771 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x0001);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800772
773 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
774
775 regcache_cache_bypass(rt5677->regmap, false);
776 regcache_mark_dirty(rt5677->regmap);
777 regcache_sync(rt5677->regmap);
778 }
779
780 return 0;
781}
782
Oder Chiou0e826e82014-05-26 20:32:33 +0800783static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
Dylan Reid40e32622014-12-04 17:00:13 -0800784static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800785static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
Dylan Reid40e32622014-12-04 17:00:13 -0800786static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800787static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
Oder Chiou90bdbb42014-09-18 14:45:59 +0800788static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800789
790/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
Lars-Peter Clausen53f28602015-08-02 17:19:52 +0200791static const DECLARE_TLV_DB_RANGE(bst_tlv,
Oder Chiou0e826e82014-05-26 20:32:33 +0800792 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
793 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
794 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
795 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
796 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
797 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
Lars-Peter Clausen53f28602015-08-02 17:19:52 +0200798 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
799);
Oder Chiou0e826e82014-05-26 20:32:33 +0800800
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800801static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
803{
Fang, Yang A6087fca2014-12-23 23:49:05 -0400804 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
805 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800806
807 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en;
808
809 return 0;
810}
811
812static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol,
813 struct snd_ctl_elem_value *ucontrol)
814{
Fang, Yang A6087fca2014-12-23 23:49:05 -0400815 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
816 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
817 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800818
819 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0];
820
Lars-Peter Clausen6b43c2e2015-05-19 21:49:11 +0200821 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800822 rt5677_set_dsp_vad(codec, rt5677->dsp_vad_en);
823
824 return 0;
825}
826
Oder Chiou0e826e82014-05-26 20:32:33 +0800827static const struct snd_kcontrol_new rt5677_snd_controls[] = {
828 /* OUTPUT Control */
829 SOC_SINGLE("OUT1 Playback Switch", RT5677_LOUT1,
830 RT5677_LOUT1_L_MUTE_SFT, 1, 1),
831 SOC_SINGLE("OUT2 Playback Switch", RT5677_LOUT1,
832 RT5677_LOUT2_L_MUTE_SFT, 1, 1),
833 SOC_SINGLE("OUT3 Playback Switch", RT5677_LOUT1,
834 RT5677_LOUT3_L_MUTE_SFT, 1, 1),
835
836 /* DAC Digital Volume */
837 SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5677_DAC1_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800838 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800839 SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5677_DAC2_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800840 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800841 SOC_DOUBLE_TLV("DAC3 Playback Volume", RT5677_DAC3_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800842 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800843 SOC_DOUBLE_TLV("DAC4 Playback Volume", RT5677_DAC4_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800844 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800845
846 /* IN1/IN2 Control */
847 SOC_SINGLE_TLV("IN1 Boost", RT5677_IN1, RT5677_BST_SFT1, 8, 0, bst_tlv),
848 SOC_SINGLE_TLV("IN2 Boost", RT5677_IN1, RT5677_BST_SFT2, 8, 0, bst_tlv),
849
850 /* ADC Digital Volume Control */
851 SOC_DOUBLE("ADC1 Capture Switch", RT5677_STO1_ADC_DIG_VOL,
852 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
853 SOC_DOUBLE("ADC2 Capture Switch", RT5677_STO2_ADC_DIG_VOL,
854 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
855 SOC_DOUBLE("ADC3 Capture Switch", RT5677_STO3_ADC_DIG_VOL,
856 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
857 SOC_DOUBLE("ADC4 Capture Switch", RT5677_STO4_ADC_DIG_VOL,
858 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
859 SOC_DOUBLE("Mono ADC Capture Switch", RT5677_MONO_ADC_DIG_VOL,
860 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
861
862 SOC_DOUBLE_TLV("ADC1 Capture Volume", RT5677_STO1_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800863 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800864 adc_vol_tlv),
865 SOC_DOUBLE_TLV("ADC2 Capture Volume", RT5677_STO2_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800866 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800867 adc_vol_tlv),
868 SOC_DOUBLE_TLV("ADC3 Capture Volume", RT5677_STO3_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800869 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800870 adc_vol_tlv),
871 SOC_DOUBLE_TLV("ADC4 Capture Volume", RT5677_STO4_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800872 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800873 adc_vol_tlv),
874 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5677_MONO_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800875 RT5677_MONO_ADC_L_VOL_SFT, RT5677_MONO_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800876 adc_vol_tlv),
877
Oder Chiou90bdbb42014-09-18 14:45:59 +0800878 /* Sidetone Control */
879 SOC_SINGLE_TLV("Sidetone Volume", RT5677_SIDETONE_CTRL,
880 RT5677_ST_VOL_SFT, 31, 0, st_vol_tlv),
881
Oder Chiou0e826e82014-05-26 20:32:33 +0800882 /* ADC Boost Volume Control */
Oder Chiou80220f22014-06-10 14:35:25 +0800883 SOC_DOUBLE_TLV("STO1 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800884 RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0,
885 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800886 SOC_DOUBLE_TLV("STO2 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800887 RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0,
888 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800889 SOC_DOUBLE_TLV("STO3 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800890 RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0,
891 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800892 SOC_DOUBLE_TLV("STO4 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800893 RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0,
894 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800895 SOC_DOUBLE_TLV("Mono ADC Boost Volume", RT5677_ADC_BST_CTRL2,
Oder Chiou0e826e82014-05-26 20:32:33 +0800896 RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0,
897 adc_bst_tlv),
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800898
899 SOC_SINGLE_EXT("DSP VAD Switch", SND_SOC_NOPM, 0, 1, 0,
900 rt5677_dsp_vad_get, rt5677_dsp_vad_put),
Oder Chiou0e826e82014-05-26 20:32:33 +0800901};
902
903/**
904 * set_dmic_clk - Set parameter of dmic.
905 *
906 * @w: DAPM widget.
907 * @kcontrol: The kcontrol of this widget.
908 * @event: Event id.
909 *
910 * Choose dmic clock between 1MHz and 3MHz.
911 * It is better for clock to approximate 3MHz.
912 */
913static int set_dmic_clk(struct snd_soc_dapm_widget *w,
914 struct snd_kcontrol *kcontrol, int event)
915{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +0100916 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +0800917 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou00a6d6e52015-08-05 10:03:18 +0800918 int idx, rate;
Oder Chiou0e826e82014-05-26 20:32:33 +0800919
Oder Chiou00a6d6e52015-08-05 10:03:18 +0800920 rate = rt5677->sysclk / rl6231_get_pre_div(rt5677->regmap,
921 RT5677_CLK_TREE_CTRL1, RT5677_I2S_PD1_SFT);
922 idx = rl6231_calc_dmic_clk(rate);
Oder Chiou0e826e82014-05-26 20:32:33 +0800923 if (idx < 0)
924 dev_err(codec->dev, "Failed to set DMIC clock\n");
925 else
926 regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1,
927 RT5677_DMIC_CLK_MASK, idx << RT5677_DMIC_CLK_SFT);
928 return idx;
929}
930
931static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
932 struct snd_soc_dapm_widget *sink)
933{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +0100934 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
935 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou0e826e82014-05-26 20:32:33 +0800936 unsigned int val;
937
938 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val);
939 val &= RT5677_SCLK_SRC_MASK;
940 if (val == RT5677_SCLK_SRC_PLL1)
941 return 1;
942 else
943 return 0;
944}
945
Oder Chiou5a8c7c22014-12-23 10:27:55 +0800946static int is_using_asrc(struct snd_soc_dapm_widget *source,
947 struct snd_soc_dapm_widget *sink)
948{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +0100949 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
Oder Chioue4b7e6a2015-01-13 11:13:14 +0800950 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou5a8c7c22014-12-23 10:27:55 +0800951 unsigned int reg, shift, val;
952
953 if (source->reg == RT5677_ASRC_1) {
954 switch (source->shift) {
955 case 12:
956 reg = RT5677_ASRC_4;
957 shift = 0;
958 break;
959 case 13:
960 reg = RT5677_ASRC_4;
961 shift = 4;
962 break;
963 case 14:
964 reg = RT5677_ASRC_4;
965 shift = 8;
966 break;
967 case 15:
968 reg = RT5677_ASRC_4;
969 shift = 12;
970 break;
971 default:
972 return 0;
973 }
974 } else {
975 switch (source->shift) {
976 case 0:
977 reg = RT5677_ASRC_6;
978 shift = 8;
979 break;
980 case 1:
981 reg = RT5677_ASRC_6;
982 shift = 12;
983 break;
984 case 2:
985 reg = RT5677_ASRC_5;
986 shift = 0;
987 break;
988 case 3:
989 reg = RT5677_ASRC_5;
990 shift = 4;
991 break;
992 case 4:
993 reg = RT5677_ASRC_5;
994 shift = 8;
995 break;
996 case 5:
997 reg = RT5677_ASRC_5;
998 shift = 12;
999 break;
1000 case 12:
1001 reg = RT5677_ASRC_3;
1002 shift = 0;
1003 break;
1004 case 13:
1005 reg = RT5677_ASRC_3;
1006 shift = 4;
1007 break;
1008 case 14:
1009 reg = RT5677_ASRC_3;
1010 shift = 12;
1011 break;
1012 default:
1013 return 0;
1014 }
1015 }
1016
Oder Chioue4b7e6a2015-01-13 11:13:14 +08001017 regmap_read(rt5677->regmap, reg, &val);
1018 val = (val >> shift) & 0xf;
1019
Oder Chiou5a8c7c22014-12-23 10:27:55 +08001020 switch (val) {
1021 case 1 ... 6:
1022 return 1;
1023 default:
1024 return 0;
1025 }
1026
1027}
1028
1029static int can_use_asrc(struct snd_soc_dapm_widget *source,
1030 struct snd_soc_dapm_widget *sink)
1031{
1032 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
1033 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
1034
1035 if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384)
1036 return 1;
1037
1038 return 0;
1039}
1040
Oder Chiouc36aa0a2015-03-16 14:39:57 +08001041/**
1042 * rt5677_sel_asrc_clk_src - select ASRC clock source for a set of filters
1043 * @codec: SoC audio codec device.
1044 * @filter_mask: mask of filters.
1045 * @clk_src: clock source
1046 *
1047 * The ASRC function is for asynchronous MCLK and LRCK. Also, since RT5677 can
1048 * only support standard 32fs or 64fs i2s format, ASRC should be enabled to
1049 * support special i2s clock format such as Intel's 100fs(100 * sampling rate).
1050 * ASRC function will track i2s clock and generate a corresponding system clock
1051 * for codec. This function provides an API to select the clock source for a
1052 * set of filters specified by the mask. And the codec driver will turn on ASRC
1053 * for these filters if ASRC is selected as their clock source.
1054 */
1055int rt5677_sel_asrc_clk_src(struct snd_soc_codec *codec,
1056 unsigned int filter_mask, unsigned int clk_src)
1057{
1058 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
1059 unsigned int asrc3_mask = 0, asrc3_value = 0;
1060 unsigned int asrc4_mask = 0, asrc4_value = 0;
1061 unsigned int asrc5_mask = 0, asrc5_value = 0;
1062 unsigned int asrc6_mask = 0, asrc6_value = 0;
1063 unsigned int asrc7_mask = 0, asrc7_value = 0;
Bard Liao16ab6e12015-04-28 11:27:40 +08001064 unsigned int asrc8_mask = 0, asrc8_value = 0;
Oder Chiouc36aa0a2015-03-16 14:39:57 +08001065
1066 switch (clk_src) {
1067 case RT5677_CLK_SEL_SYS:
1068 case RT5677_CLK_SEL_I2S1_ASRC:
1069 case RT5677_CLK_SEL_I2S2_ASRC:
1070 case RT5677_CLK_SEL_I2S3_ASRC:
1071 case RT5677_CLK_SEL_I2S4_ASRC:
1072 case RT5677_CLK_SEL_I2S5_ASRC:
1073 case RT5677_CLK_SEL_I2S6_ASRC:
1074 case RT5677_CLK_SEL_SYS2:
1075 case RT5677_CLK_SEL_SYS3:
1076 case RT5677_CLK_SEL_SYS4:
1077 case RT5677_CLK_SEL_SYS5:
1078 case RT5677_CLK_SEL_SYS6:
1079 case RT5677_CLK_SEL_SYS7:
1080 break;
1081
1082 default:
1083 return -EINVAL;
1084 }
1085
1086 /* ASRC 3 */
1087 if (filter_mask & RT5677_DA_STEREO_FILTER) {
1088 asrc3_mask |= RT5677_DA_STO_CLK_SEL_MASK;
1089 asrc3_value = (asrc3_value & ~RT5677_DA_STO_CLK_SEL_MASK)
1090 | (clk_src << RT5677_DA_STO_CLK_SEL_SFT);
1091 }
1092
1093 if (filter_mask & RT5677_DA_MONO2_L_FILTER) {
1094 asrc3_mask |= RT5677_DA_MONO2L_CLK_SEL_MASK;
1095 asrc3_value = (asrc3_value & ~RT5677_DA_MONO2L_CLK_SEL_MASK)
1096 | (clk_src << RT5677_DA_MONO2L_CLK_SEL_SFT);
1097 }
1098
1099 if (filter_mask & RT5677_DA_MONO2_R_FILTER) {
1100 asrc3_mask |= RT5677_DA_MONO2R_CLK_SEL_MASK;
1101 asrc3_value = (asrc3_value & ~RT5677_DA_MONO2R_CLK_SEL_MASK)
1102 | (clk_src << RT5677_DA_MONO2R_CLK_SEL_SFT);
1103 }
1104
1105 if (asrc3_mask)
1106 regmap_update_bits(rt5677->regmap, RT5677_ASRC_3, asrc3_mask,
1107 asrc3_value);
1108
1109 /* ASRC 4 */
1110 if (filter_mask & RT5677_DA_MONO3_L_FILTER) {
1111 asrc4_mask |= RT5677_DA_MONO3L_CLK_SEL_MASK;
1112 asrc4_value = (asrc4_value & ~RT5677_DA_MONO3L_CLK_SEL_MASK)
1113 | (clk_src << RT5677_DA_MONO3L_CLK_SEL_SFT);
1114 }
1115
1116 if (filter_mask & RT5677_DA_MONO3_R_FILTER) {
1117 asrc4_mask |= RT5677_DA_MONO3R_CLK_SEL_MASK;
1118 asrc4_value = (asrc4_value & ~RT5677_DA_MONO3R_CLK_SEL_MASK)
1119 | (clk_src << RT5677_DA_MONO3R_CLK_SEL_SFT);
1120 }
1121
1122 if (filter_mask & RT5677_DA_MONO4_L_FILTER) {
1123 asrc4_mask |= RT5677_DA_MONO4L_CLK_SEL_MASK;
1124 asrc4_value = (asrc4_value & ~RT5677_DA_MONO4L_CLK_SEL_MASK)
1125 | (clk_src << RT5677_DA_MONO4L_CLK_SEL_SFT);
1126 }
1127
1128 if (filter_mask & RT5677_DA_MONO4_R_FILTER) {
1129 asrc4_mask |= RT5677_DA_MONO4R_CLK_SEL_MASK;
1130 asrc4_value = (asrc4_value & ~RT5677_DA_MONO4R_CLK_SEL_MASK)
1131 | (clk_src << RT5677_DA_MONO4R_CLK_SEL_SFT);
1132 }
1133
1134 if (asrc4_mask)
1135 regmap_update_bits(rt5677->regmap, RT5677_ASRC_4, asrc4_mask,
1136 asrc4_value);
1137
1138 /* ASRC 5 */
1139 if (filter_mask & RT5677_AD_STEREO1_FILTER) {
1140 asrc5_mask |= RT5677_AD_STO1_CLK_SEL_MASK;
1141 asrc5_value = (asrc5_value & ~RT5677_AD_STO1_CLK_SEL_MASK)
1142 | (clk_src << RT5677_AD_STO1_CLK_SEL_SFT);
1143 }
1144
1145 if (filter_mask & RT5677_AD_STEREO2_FILTER) {
1146 asrc5_mask |= RT5677_AD_STO2_CLK_SEL_MASK;
1147 asrc5_value = (asrc5_value & ~RT5677_AD_STO2_CLK_SEL_MASK)
1148 | (clk_src << RT5677_AD_STO2_CLK_SEL_SFT);
1149 }
1150
1151 if (filter_mask & RT5677_AD_STEREO3_FILTER) {
1152 asrc5_mask |= RT5677_AD_STO3_CLK_SEL_MASK;
1153 asrc5_value = (asrc5_value & ~RT5677_AD_STO3_CLK_SEL_MASK)
1154 | (clk_src << RT5677_AD_STO3_CLK_SEL_SFT);
1155 }
1156
1157 if (filter_mask & RT5677_AD_STEREO4_FILTER) {
1158 asrc5_mask |= RT5677_AD_STO4_CLK_SEL_MASK;
1159 asrc5_value = (asrc5_value & ~RT5677_AD_STO4_CLK_SEL_MASK)
1160 | (clk_src << RT5677_AD_STO4_CLK_SEL_SFT);
1161 }
1162
1163 if (asrc5_mask)
1164 regmap_update_bits(rt5677->regmap, RT5677_ASRC_5, asrc5_mask,
1165 asrc5_value);
1166
1167 /* ASRC 6 */
1168 if (filter_mask & RT5677_AD_MONO_L_FILTER) {
1169 asrc6_mask |= RT5677_AD_MONOL_CLK_SEL_MASK;
1170 asrc6_value = (asrc6_value & ~RT5677_AD_MONOL_CLK_SEL_MASK)
1171 | (clk_src << RT5677_AD_MONOL_CLK_SEL_SFT);
1172 }
1173
1174 if (filter_mask & RT5677_AD_MONO_R_FILTER) {
1175 asrc6_mask |= RT5677_AD_MONOR_CLK_SEL_MASK;
1176 asrc6_value = (asrc6_value & ~RT5677_AD_MONOR_CLK_SEL_MASK)
1177 | (clk_src << RT5677_AD_MONOR_CLK_SEL_SFT);
1178 }
1179
1180 if (asrc6_mask)
1181 regmap_update_bits(rt5677->regmap, RT5677_ASRC_6, asrc6_mask,
1182 asrc6_value);
1183
1184 /* ASRC 7 */
1185 if (filter_mask & RT5677_DSP_OB_0_3_FILTER) {
1186 asrc7_mask |= RT5677_DSP_OB_0_3_CLK_SEL_MASK;
1187 asrc7_value = (asrc7_value & ~RT5677_DSP_OB_0_3_CLK_SEL_MASK)
1188 | (clk_src << RT5677_DSP_OB_0_3_CLK_SEL_SFT);
1189 }
1190
1191 if (filter_mask & RT5677_DSP_OB_4_7_FILTER) {
1192 asrc7_mask |= RT5677_DSP_OB_4_7_CLK_SEL_MASK;
1193 asrc7_value = (asrc7_value & ~RT5677_DSP_OB_4_7_CLK_SEL_MASK)
1194 | (clk_src << RT5677_DSP_OB_4_7_CLK_SEL_SFT);
1195 }
1196
1197 if (asrc7_mask)
1198 regmap_update_bits(rt5677->regmap, RT5677_ASRC_7, asrc7_mask,
1199 asrc7_value);
1200
Bard Liao16ab6e12015-04-28 11:27:40 +08001201 /* ASRC 8 */
1202 if (filter_mask & RT5677_I2S1_SOURCE) {
1203 asrc8_mask |= RT5677_I2S1_CLK_SEL_MASK;
1204 asrc8_value = (asrc8_value & ~RT5677_I2S1_CLK_SEL_MASK)
1205 | ((clk_src - 1) << RT5677_I2S1_CLK_SEL_SFT);
1206 }
1207
1208 if (filter_mask & RT5677_I2S2_SOURCE) {
1209 asrc8_mask |= RT5677_I2S2_CLK_SEL_MASK;
1210 asrc8_value = (asrc8_value & ~RT5677_I2S2_CLK_SEL_MASK)
1211 | ((clk_src - 1) << RT5677_I2S2_CLK_SEL_SFT);
1212 }
1213
1214 if (filter_mask & RT5677_I2S3_SOURCE) {
1215 asrc8_mask |= RT5677_I2S3_CLK_SEL_MASK;
1216 asrc8_value = (asrc8_value & ~RT5677_I2S3_CLK_SEL_MASK)
1217 | ((clk_src - 1) << RT5677_I2S3_CLK_SEL_SFT);
1218 }
1219
1220 if (filter_mask & RT5677_I2S4_SOURCE) {
1221 asrc8_mask |= RT5677_I2S4_CLK_SEL_MASK;
1222 asrc8_value = (asrc8_value & ~RT5677_I2S4_CLK_SEL_MASK)
1223 | ((clk_src - 1) << RT5677_I2S4_CLK_SEL_SFT);
1224 }
1225
1226 if (asrc8_mask)
1227 regmap_update_bits(rt5677->regmap, RT5677_ASRC_8, asrc8_mask,
1228 asrc8_value);
1229
Oder Chiouc36aa0a2015-03-16 14:39:57 +08001230 return 0;
1231}
1232EXPORT_SYMBOL_GPL(rt5677_sel_asrc_clk_src);
1233
Oder Chiou5220f7f2015-05-08 13:24:02 +08001234static int rt5677_dmic_use_asrc(struct snd_soc_dapm_widget *source,
1235 struct snd_soc_dapm_widget *sink)
1236{
1237 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
1238 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
1239 unsigned int asrc_setting;
1240
1241 switch (source->shift) {
1242 case 11:
1243 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
1244 asrc_setting = (asrc_setting & RT5677_AD_STO1_CLK_SEL_MASK) >>
1245 RT5677_AD_STO1_CLK_SEL_SFT;
Oder Chiou5220f7f2015-05-08 13:24:02 +08001246 break;
1247
1248 case 10:
1249 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
1250 asrc_setting = (asrc_setting & RT5677_AD_STO2_CLK_SEL_MASK) >>
1251 RT5677_AD_STO2_CLK_SEL_SFT;
Oder Chiou5220f7f2015-05-08 13:24:02 +08001252 break;
1253
1254 case 9:
1255 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
1256 asrc_setting = (asrc_setting & RT5677_AD_STO3_CLK_SEL_MASK) >>
1257 RT5677_AD_STO3_CLK_SEL_SFT;
Oder Chiou5220f7f2015-05-08 13:24:02 +08001258 break;
1259
1260 case 8:
1261 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
1262 asrc_setting = (asrc_setting & RT5677_AD_STO4_CLK_SEL_MASK) >>
1263 RT5677_AD_STO4_CLK_SEL_SFT;
Oder Chiou5220f7f2015-05-08 13:24:02 +08001264 break;
1265
1266 case 7:
1267 regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting);
1268 asrc_setting = (asrc_setting & RT5677_AD_MONOL_CLK_SEL_MASK) >>
1269 RT5677_AD_MONOL_CLK_SEL_SFT;
Oder Chiou5220f7f2015-05-08 13:24:02 +08001270 break;
1271
1272 case 6:
1273 regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting);
1274 asrc_setting = (asrc_setting & RT5677_AD_MONOR_CLK_SEL_MASK) >>
1275 RT5677_AD_MONOR_CLK_SEL_SFT;
Oder Chiou5220f7f2015-05-08 13:24:02 +08001276 break;
1277
1278 default:
Axel Lin2dfadff2016-03-30 18:25:07 +08001279 return 0;
Oder Chiou5220f7f2015-05-08 13:24:02 +08001280 }
1281
Axel Lin2dfadff2016-03-30 18:25:07 +08001282 if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
1283 asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
1284 return 1;
1285
Oder Chiou5220f7f2015-05-08 13:24:02 +08001286 return 0;
1287}
1288
Oder Chiou0e826e82014-05-26 20:32:33 +08001289/* Digital Mixer */
1290static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = {
1291 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
1292 RT5677_M_STO1_ADC_L1_SFT, 1, 1),
1293 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
1294 RT5677_M_STO1_ADC_L2_SFT, 1, 1),
1295};
1296
1297static const struct snd_kcontrol_new rt5677_sto1_adc_r_mix[] = {
1298 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
1299 RT5677_M_STO1_ADC_R1_SFT, 1, 1),
1300 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
1301 RT5677_M_STO1_ADC_R2_SFT, 1, 1),
1302};
1303
1304static const struct snd_kcontrol_new rt5677_sto2_adc_l_mix[] = {
1305 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
1306 RT5677_M_STO2_ADC_L1_SFT, 1, 1),
1307 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
1308 RT5677_M_STO2_ADC_L2_SFT, 1, 1),
1309};
1310
1311static const struct snd_kcontrol_new rt5677_sto2_adc_r_mix[] = {
1312 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
1313 RT5677_M_STO2_ADC_R1_SFT, 1, 1),
1314 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
1315 RT5677_M_STO2_ADC_R2_SFT, 1, 1),
1316};
1317
1318static const struct snd_kcontrol_new rt5677_sto3_adc_l_mix[] = {
1319 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
1320 RT5677_M_STO3_ADC_L1_SFT, 1, 1),
1321 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
1322 RT5677_M_STO3_ADC_L2_SFT, 1, 1),
1323};
1324
1325static const struct snd_kcontrol_new rt5677_sto3_adc_r_mix[] = {
1326 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
1327 RT5677_M_STO3_ADC_R1_SFT, 1, 1),
1328 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
1329 RT5677_M_STO3_ADC_R2_SFT, 1, 1),
1330};
1331
1332static const struct snd_kcontrol_new rt5677_sto4_adc_l_mix[] = {
1333 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
1334 RT5677_M_STO4_ADC_L1_SFT, 1, 1),
1335 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
1336 RT5677_M_STO4_ADC_L2_SFT, 1, 1),
1337};
1338
1339static const struct snd_kcontrol_new rt5677_sto4_adc_r_mix[] = {
1340 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
1341 RT5677_M_STO4_ADC_R1_SFT, 1, 1),
1342 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
1343 RT5677_M_STO4_ADC_R2_SFT, 1, 1),
1344};
1345
1346static const struct snd_kcontrol_new rt5677_mono_adc_l_mix[] = {
1347 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
1348 RT5677_M_MONO_ADC_L1_SFT, 1, 1),
1349 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
1350 RT5677_M_MONO_ADC_L2_SFT, 1, 1),
1351};
1352
1353static const struct snd_kcontrol_new rt5677_mono_adc_r_mix[] = {
1354 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
1355 RT5677_M_MONO_ADC_R1_SFT, 1, 1),
1356 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
1357 RT5677_M_MONO_ADC_R2_SFT, 1, 1),
1358};
1359
1360static const struct snd_kcontrol_new rt5677_dac_l_mix[] = {
1361 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1362 RT5677_M_ADDA_MIXER1_L_SFT, 1, 1),
1363 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1364 RT5677_M_DAC1_L_SFT, 1, 1),
1365};
1366
1367static const struct snd_kcontrol_new rt5677_dac_r_mix[] = {
1368 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1369 RT5677_M_ADDA_MIXER1_R_SFT, 1, 1),
1370 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1371 RT5677_M_DAC1_R_SFT, 1, 1),
1372};
1373
1374static const struct snd_kcontrol_new rt5677_sto1_dac_l_mix[] = {
Oder Chiouc22d7662015-11-09 18:01:04 +08001375 SOC_DAPM_SINGLE_AUTODISABLE("ST L Switch", RT5677_STO1_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001376 RT5677_M_ST_DAC1_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001377 SOC_DAPM_SINGLE_AUTODISABLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001378 RT5677_M_DAC1_L_STO_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001379 SOC_DAPM_SINGLE_AUTODISABLE("DAC2 L Switch", RT5677_STO1_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001380 RT5677_M_DAC2_L_STO_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001381 SOC_DAPM_SINGLE_AUTODISABLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001382 RT5677_M_DAC1_R_STO_L_SFT, 1, 1),
1383};
1384
1385static const struct snd_kcontrol_new rt5677_sto1_dac_r_mix[] = {
Oder Chiouc22d7662015-11-09 18:01:04 +08001386 SOC_DAPM_SINGLE_AUTODISABLE("ST R Switch", RT5677_STO1_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001387 RT5677_M_ST_DAC1_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001388 SOC_DAPM_SINGLE_AUTODISABLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001389 RT5677_M_DAC1_R_STO_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001390 SOC_DAPM_SINGLE_AUTODISABLE("DAC2 R Switch", RT5677_STO1_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001391 RT5677_M_DAC2_R_STO_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001392 SOC_DAPM_SINGLE_AUTODISABLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001393 RT5677_M_DAC1_L_STO_R_SFT, 1, 1),
1394};
1395
1396static const struct snd_kcontrol_new rt5677_mono_dac_l_mix[] = {
Oder Chiouc22d7662015-11-09 18:01:04 +08001397 SOC_DAPM_SINGLE_AUTODISABLE("ST L Switch", RT5677_MONO_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001398 RT5677_M_ST_DAC2_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001399 SOC_DAPM_SINGLE_AUTODISABLE("DAC1 L Switch", RT5677_MONO_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001400 RT5677_M_DAC1_L_MONO_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001401 SOC_DAPM_SINGLE_AUTODISABLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001402 RT5677_M_DAC2_L_MONO_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001403 SOC_DAPM_SINGLE_AUTODISABLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001404 RT5677_M_DAC2_R_MONO_L_SFT, 1, 1),
1405};
1406
1407static const struct snd_kcontrol_new rt5677_mono_dac_r_mix[] = {
Oder Chiouc22d7662015-11-09 18:01:04 +08001408 SOC_DAPM_SINGLE_AUTODISABLE("ST R Switch", RT5677_MONO_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001409 RT5677_M_ST_DAC2_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001410 SOC_DAPM_SINGLE_AUTODISABLE("DAC1 R Switch", RT5677_MONO_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001411 RT5677_M_DAC1_R_MONO_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001412 SOC_DAPM_SINGLE_AUTODISABLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001413 RT5677_M_DAC2_R_MONO_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001414 SOC_DAPM_SINGLE_AUTODISABLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001415 RT5677_M_DAC2_L_MONO_R_SFT, 1, 1),
1416};
1417
1418static const struct snd_kcontrol_new rt5677_dd1_l_mix[] = {
Oder Chiouc22d7662015-11-09 18:01:04 +08001419 SOC_DAPM_SINGLE_AUTODISABLE("Sto DAC Mix L Switch", RT5677_DD1_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001420 RT5677_M_STO_L_DD1_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001421 SOC_DAPM_SINGLE_AUTODISABLE("Mono DAC Mix L Switch", RT5677_DD1_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001422 RT5677_M_MONO_L_DD1_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001423 SOC_DAPM_SINGLE_AUTODISABLE("DAC3 L Switch", RT5677_DD1_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001424 RT5677_M_DAC3_L_DD1_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001425 SOC_DAPM_SINGLE_AUTODISABLE("DAC3 R Switch", RT5677_DD1_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001426 RT5677_M_DAC3_R_DD1_L_SFT, 1, 1),
1427};
1428
1429static const struct snd_kcontrol_new rt5677_dd1_r_mix[] = {
Oder Chiouc22d7662015-11-09 18:01:04 +08001430 SOC_DAPM_SINGLE_AUTODISABLE("Sto DAC Mix R Switch", RT5677_DD1_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001431 RT5677_M_STO_R_DD1_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001432 SOC_DAPM_SINGLE_AUTODISABLE("Mono DAC Mix R Switch", RT5677_DD1_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001433 RT5677_M_MONO_R_DD1_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001434 SOC_DAPM_SINGLE_AUTODISABLE("DAC3 R Switch", RT5677_DD1_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001435 RT5677_M_DAC3_R_DD1_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001436 SOC_DAPM_SINGLE_AUTODISABLE("DAC3 L Switch", RT5677_DD1_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001437 RT5677_M_DAC3_L_DD1_R_SFT, 1, 1),
1438};
1439
1440static const struct snd_kcontrol_new rt5677_dd2_l_mix[] = {
Oder Chiouc22d7662015-11-09 18:01:04 +08001441 SOC_DAPM_SINGLE_AUTODISABLE("Sto DAC Mix L Switch", RT5677_DD2_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001442 RT5677_M_STO_L_DD2_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001443 SOC_DAPM_SINGLE_AUTODISABLE("Mono DAC Mix L Switch", RT5677_DD2_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001444 RT5677_M_MONO_L_DD2_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001445 SOC_DAPM_SINGLE_AUTODISABLE("DAC4 L Switch", RT5677_DD2_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001446 RT5677_M_DAC4_L_DD2_L_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001447 SOC_DAPM_SINGLE_AUTODISABLE("DAC4 R Switch", RT5677_DD2_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001448 RT5677_M_DAC4_R_DD2_L_SFT, 1, 1),
1449};
1450
1451static const struct snd_kcontrol_new rt5677_dd2_r_mix[] = {
Oder Chiouc22d7662015-11-09 18:01:04 +08001452 SOC_DAPM_SINGLE_AUTODISABLE("Sto DAC Mix R Switch", RT5677_DD2_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001453 RT5677_M_STO_R_DD2_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001454 SOC_DAPM_SINGLE_AUTODISABLE("Mono DAC Mix R Switch", RT5677_DD2_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001455 RT5677_M_MONO_R_DD2_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001456 SOC_DAPM_SINGLE_AUTODISABLE("DAC4 R Switch", RT5677_DD2_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001457 RT5677_M_DAC4_R_DD2_R_SFT, 1, 1),
Oder Chiouc22d7662015-11-09 18:01:04 +08001458 SOC_DAPM_SINGLE_AUTODISABLE("DAC4 L Switch", RT5677_DD2_MIXER,
Oder Chiou0e826e82014-05-26 20:32:33 +08001459 RT5677_M_DAC4_L_DD2_R_SFT, 1, 1),
1460};
1461
1462static const struct snd_kcontrol_new rt5677_ob_01_mix[] = {
1463 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1464 RT5677_DSP_IB_01_H_SFT, 1, 1),
1465 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1466 RT5677_DSP_IB_23_H_SFT, 1, 1),
1467 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1468 RT5677_DSP_IB_45_H_SFT, 1, 1),
1469 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1470 RT5677_DSP_IB_6_H_SFT, 1, 1),
1471 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1472 RT5677_DSP_IB_7_H_SFT, 1, 1),
1473 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1474 RT5677_DSP_IB_8_H_SFT, 1, 1),
1475 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1476 RT5677_DSP_IB_9_H_SFT, 1, 1),
1477};
1478
1479static const struct snd_kcontrol_new rt5677_ob_23_mix[] = {
1480 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1481 RT5677_DSP_IB_01_L_SFT, 1, 1),
1482 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1483 RT5677_DSP_IB_23_L_SFT, 1, 1),
1484 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1485 RT5677_DSP_IB_45_L_SFT, 1, 1),
1486 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1487 RT5677_DSP_IB_6_L_SFT, 1, 1),
1488 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1489 RT5677_DSP_IB_7_L_SFT, 1, 1),
1490 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1491 RT5677_DSP_IB_8_L_SFT, 1, 1),
1492 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1493 RT5677_DSP_IB_9_L_SFT, 1, 1),
1494};
1495
1496static const struct snd_kcontrol_new rt5677_ob_4_mix[] = {
1497 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1498 RT5677_DSP_IB_01_H_SFT, 1, 1),
1499 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1500 RT5677_DSP_IB_23_H_SFT, 1, 1),
1501 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1502 RT5677_DSP_IB_45_H_SFT, 1, 1),
1503 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1504 RT5677_DSP_IB_6_H_SFT, 1, 1),
1505 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1506 RT5677_DSP_IB_7_H_SFT, 1, 1),
1507 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1508 RT5677_DSP_IB_8_H_SFT, 1, 1),
1509 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1510 RT5677_DSP_IB_9_H_SFT, 1, 1),
1511};
1512
1513static const struct snd_kcontrol_new rt5677_ob_5_mix[] = {
1514 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1515 RT5677_DSP_IB_01_L_SFT, 1, 1),
1516 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1517 RT5677_DSP_IB_23_L_SFT, 1, 1),
1518 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1519 RT5677_DSP_IB_45_L_SFT, 1, 1),
1520 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1521 RT5677_DSP_IB_6_L_SFT, 1, 1),
1522 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1523 RT5677_DSP_IB_7_L_SFT, 1, 1),
1524 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1525 RT5677_DSP_IB_8_L_SFT, 1, 1),
1526 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1527 RT5677_DSP_IB_9_L_SFT, 1, 1),
1528};
1529
1530static const struct snd_kcontrol_new rt5677_ob_6_mix[] = {
1531 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1532 RT5677_DSP_IB_01_H_SFT, 1, 1),
1533 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1534 RT5677_DSP_IB_23_H_SFT, 1, 1),
1535 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1536 RT5677_DSP_IB_45_H_SFT, 1, 1),
1537 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1538 RT5677_DSP_IB_6_H_SFT, 1, 1),
1539 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1540 RT5677_DSP_IB_7_H_SFT, 1, 1),
1541 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1542 RT5677_DSP_IB_8_H_SFT, 1, 1),
1543 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1544 RT5677_DSP_IB_9_H_SFT, 1, 1),
1545};
1546
1547static const struct snd_kcontrol_new rt5677_ob_7_mix[] = {
1548 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1549 RT5677_DSP_IB_01_L_SFT, 1, 1),
1550 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1551 RT5677_DSP_IB_23_L_SFT, 1, 1),
1552 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1553 RT5677_DSP_IB_45_L_SFT, 1, 1),
1554 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1555 RT5677_DSP_IB_6_L_SFT, 1, 1),
1556 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1557 RT5677_DSP_IB_7_L_SFT, 1, 1),
1558 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1559 RT5677_DSP_IB_8_L_SFT, 1, 1),
1560 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1561 RT5677_DSP_IB_9_L_SFT, 1, 1),
1562};
1563
1564
1565/* Mux */
Oder Chiou1b7fd762014-06-10 14:35:24 +08001566/* DAC1 L/R Source */ /* MX-29 [10:8] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001567static const char * const rt5677_dac1_src[] = {
1568 "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01",
1569 "OB 01"
1570};
1571
1572static SOC_ENUM_SINGLE_DECL(
1573 rt5677_dac1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
1574 RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src);
1575
1576static const struct snd_kcontrol_new rt5677_dac1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001577 SOC_DAPM_ENUM("DAC1 Source", rt5677_dac1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001578
Oder Chiou1b7fd762014-06-10 14:35:24 +08001579/* ADDA1 L/R Source */ /* MX-29 [1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001580static const char * const rt5677_adda1_src[] = {
1581 "STO1 ADC MIX", "STO2 ADC MIX", "OB 67",
1582};
1583
1584static SOC_ENUM_SINGLE_DECL(
1585 rt5677_adda1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
1586 RT5677_ADDA1_SEL_SFT, rt5677_adda1_src);
1587
1588static const struct snd_kcontrol_new rt5677_adda1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001589 SOC_DAPM_ENUM("ADDA1 Source", rt5677_adda1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001590
1591
Oder Chiou1b7fd762014-06-10 14:35:24 +08001592/*DAC2 L/R Source*/ /* MX-1B [6:4] [2:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001593static const char * const rt5677_dac2l_src[] = {
1594 "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2",
1595 "OB 2",
1596};
1597
1598static SOC_ENUM_SINGLE_DECL(
1599 rt5677_dac2l_enum, RT5677_IF_DSP_DAC2_MIXER,
1600 RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src);
1601
1602static const struct snd_kcontrol_new rt5677_dac2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001603 SOC_DAPM_ENUM("DAC2 L Source", rt5677_dac2l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001604
1605static const char * const rt5677_dac2r_src[] = {
1606 "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3",
1607 "OB 3", "Haptic Generator", "VAD ADC"
1608};
1609
1610static SOC_ENUM_SINGLE_DECL(
1611 rt5677_dac2r_enum, RT5677_IF_DSP_DAC2_MIXER,
1612 RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src);
1613
1614static const struct snd_kcontrol_new rt5677_dac2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001615 SOC_DAPM_ENUM("DAC2 R Source", rt5677_dac2r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001616
Oder Chiou1b7fd762014-06-10 14:35:24 +08001617/*DAC3 L/R Source*/ /* MX-16 [6:4] [2:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001618static const char * const rt5677_dac3l_src[] = {
1619 "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L",
1620 "SLB DAC 4", "OB 4"
1621};
1622
1623static SOC_ENUM_SINGLE_DECL(
1624 rt5677_dac3l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1625 RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src);
1626
1627static const struct snd_kcontrol_new rt5677_dac3_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001628 SOC_DAPM_ENUM("DAC3 L Source", rt5677_dac3l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001629
1630static const char * const rt5677_dac3r_src[] = {
1631 "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R",
1632 "SLB DAC 5", "OB 5"
1633};
1634
1635static SOC_ENUM_SINGLE_DECL(
1636 rt5677_dac3r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1637 RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src);
1638
1639static const struct snd_kcontrol_new rt5677_dac3_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001640 SOC_DAPM_ENUM("DAC3 R Source", rt5677_dac3r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001641
Oder Chiou1b7fd762014-06-10 14:35:24 +08001642/*DAC4 L/R Source*/ /* MX-16 [14:12] [10:8] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001643static const char * const rt5677_dac4l_src[] = {
1644 "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L",
1645 "SLB DAC 6", "OB 6"
1646};
1647
1648static SOC_ENUM_SINGLE_DECL(
1649 rt5677_dac4l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1650 RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src);
1651
1652static const struct snd_kcontrol_new rt5677_dac4_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001653 SOC_DAPM_ENUM("DAC4 L Source", rt5677_dac4l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001654
1655static const char * const rt5677_dac4r_src[] = {
1656 "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R",
1657 "SLB DAC 7", "OB 7"
1658};
1659
1660static SOC_ENUM_SINGLE_DECL(
1661 rt5677_dac4r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1662 RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src);
1663
1664static const struct snd_kcontrol_new rt5677_dac4_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001665 SOC_DAPM_ENUM("DAC4 R Source", rt5677_dac4r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001666
1667/* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */
1668static const char * const rt5677_iob_bypass_src[] = {
1669 "Bypass", "Pass SRC"
1670};
1671
1672static SOC_ENUM_SINGLE_DECL(
1673 rt5677_ob01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1674 RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src);
1675
1676static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001677 SOC_DAPM_ENUM("OB01 Bypass Source", rt5677_ob01_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001678
1679static SOC_ENUM_SINGLE_DECL(
1680 rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1681 RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src);
1682
1683static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001684 SOC_DAPM_ENUM("OB23 Bypass Source", rt5677_ob23_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001685
1686static SOC_ENUM_SINGLE_DECL(
1687 rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1688 RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src);
1689
1690static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001691 SOC_DAPM_ENUM("IB01 Bypass Source", rt5677_ib01_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001692
1693static SOC_ENUM_SINGLE_DECL(
1694 rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1695 RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src);
1696
1697static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001698 SOC_DAPM_ENUM("IB23 Bypass Source", rt5677_ib23_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001699
1700static SOC_ENUM_SINGLE_DECL(
1701 rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1702 RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src);
1703
1704static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001705 SOC_DAPM_ENUM("IB45 Bypass Source", rt5677_ib45_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001706
Oder Chioud65fd3a2014-11-05 13:42:52 +08001707/* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001708static const char * const rt5677_stereo_adc2_src[] = {
1709 "DD MIX1", "DMIC", "Stereo DAC MIX"
1710};
1711
1712static SOC_ENUM_SINGLE_DECL(
1713 rt5677_stereo1_adc2_enum, RT5677_STO1_ADC_MIXER,
1714 RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src);
1715
1716static const struct snd_kcontrol_new rt5677_sto1_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001717 SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5677_stereo1_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001718
1719static SOC_ENUM_SINGLE_DECL(
1720 rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER,
1721 RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src);
1722
1723static const struct snd_kcontrol_new rt5677_sto2_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001724 SOC_DAPM_ENUM("Stereo2 ADC2 Source", rt5677_stereo2_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001725
1726static SOC_ENUM_SINGLE_DECL(
1727 rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER,
1728 RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src);
1729
1730static const struct snd_kcontrol_new rt5677_sto3_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001731 SOC_DAPM_ENUM("Stereo3 ADC2 Source", rt5677_stereo3_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001732
1733/* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */
1734static const char * const rt5677_dmic_src[] = {
1735 "DMIC1", "DMIC2", "DMIC3", "DMIC4"
1736};
1737
1738static SOC_ENUM_SINGLE_DECL(
1739 rt5677_mono_dmic_l_enum, RT5677_MONO_ADC_MIXER,
1740 RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src);
1741
1742static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001743 SOC_DAPM_ENUM("Mono DMIC L Source", rt5677_mono_dmic_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001744
1745static SOC_ENUM_SINGLE_DECL(
1746 rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER,
1747 RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src);
1748
1749static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001750 SOC_DAPM_ENUM("Mono DMIC R Source", rt5677_mono_dmic_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001751
1752static SOC_ENUM_SINGLE_DECL(
1753 rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER,
1754 RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src);
1755
1756static const struct snd_kcontrol_new rt5677_sto1_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001757 SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5677_stereo1_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001758
1759static SOC_ENUM_SINGLE_DECL(
1760 rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER,
1761 RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src);
1762
1763static const struct snd_kcontrol_new rt5677_sto2_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001764 SOC_DAPM_ENUM("Stereo2 DMIC Source", rt5677_stereo2_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001765
1766static SOC_ENUM_SINGLE_DECL(
1767 rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER,
1768 RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src);
1769
1770static const struct snd_kcontrol_new rt5677_sto3_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001771 SOC_DAPM_ENUM("Stereo3 DMIC Source", rt5677_stereo3_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001772
1773static SOC_ENUM_SINGLE_DECL(
1774 rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER,
1775 RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src);
1776
1777static const struct snd_kcontrol_new rt5677_sto4_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001778 SOC_DAPM_ENUM("Stereo4 DMIC Source", rt5677_stereo4_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001779
Oder Chiou1b7fd762014-06-10 14:35:24 +08001780/* Stereo2 ADC Source */ /* MX-26 [0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001781static const char * const rt5677_stereo2_adc_lr_src[] = {
1782 "L", "LR"
1783};
1784
1785static SOC_ENUM_SINGLE_DECL(
1786 rt5677_stereo2_adc_lr_enum, RT5677_STO2_ADC_MIXER,
1787 RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src);
1788
1789static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001790 SOC_DAPM_ENUM("Stereo2 ADC LR Source", rt5677_stereo2_adc_lr_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001791
Oder Chioud65fd3a2014-11-05 13:42:52 +08001792/* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001793static const char * const rt5677_stereo_adc1_src[] = {
1794 "DD MIX1", "ADC1/2", "Stereo DAC MIX"
1795};
1796
1797static SOC_ENUM_SINGLE_DECL(
1798 rt5677_stereo1_adc1_enum, RT5677_STO1_ADC_MIXER,
1799 RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src);
1800
1801static const struct snd_kcontrol_new rt5677_sto1_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001802 SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5677_stereo1_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001803
1804static SOC_ENUM_SINGLE_DECL(
1805 rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER,
1806 RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src);
1807
1808static const struct snd_kcontrol_new rt5677_sto2_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001809 SOC_DAPM_ENUM("Stereo2 ADC1 Source", rt5677_stereo2_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001810
1811static SOC_ENUM_SINGLE_DECL(
1812 rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER,
1813 RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src);
1814
1815static const struct snd_kcontrol_new rt5677_sto3_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001816 SOC_DAPM_ENUM("Stereo3 ADC1 Source", rt5677_stereo3_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001817
Oder Chiou1b7fd762014-06-10 14:35:24 +08001818/* Mono ADC Left Source 2 */ /* MX-28 [11:10] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001819static const char * const rt5677_mono_adc2_l_src[] = {
1820 "DD MIX1L", "DMIC", "MONO DAC MIXL"
1821};
1822
1823static SOC_ENUM_SINGLE_DECL(
1824 rt5677_mono_adc2_l_enum, RT5677_MONO_ADC_MIXER,
1825 RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src);
1826
1827static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001828 SOC_DAPM_ENUM("Mono ADC2 L Source", rt5677_mono_adc2_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001829
Oder Chiou1b7fd762014-06-10 14:35:24 +08001830/* Mono ADC Left Source 1 */ /* MX-28 [13:12] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001831static const char * const rt5677_mono_adc1_l_src[] = {
1832 "DD MIX1L", "ADC1", "MONO DAC MIXL"
1833};
1834
1835static SOC_ENUM_SINGLE_DECL(
1836 rt5677_mono_adc1_l_enum, RT5677_MONO_ADC_MIXER,
1837 RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src);
1838
1839static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001840 SOC_DAPM_ENUM("Mono ADC1 L Source", rt5677_mono_adc1_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001841
Oder Chiou1b7fd762014-06-10 14:35:24 +08001842/* Mono ADC Right Source 2 */ /* MX-28 [3:2] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001843static const char * const rt5677_mono_adc2_r_src[] = {
1844 "DD MIX1R", "DMIC", "MONO DAC MIXR"
1845};
1846
1847static SOC_ENUM_SINGLE_DECL(
1848 rt5677_mono_adc2_r_enum, RT5677_MONO_ADC_MIXER,
1849 RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src);
1850
1851static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001852 SOC_DAPM_ENUM("Mono ADC2 R Source", rt5677_mono_adc2_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001853
Oder Chiou1b7fd762014-06-10 14:35:24 +08001854/* Mono ADC Right Source 1 */ /* MX-28 [5:4] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001855static const char * const rt5677_mono_adc1_r_src[] = {
1856 "DD MIX1R", "ADC2", "MONO DAC MIXR"
1857};
1858
1859static SOC_ENUM_SINGLE_DECL(
1860 rt5677_mono_adc1_r_enum, RT5677_MONO_ADC_MIXER,
1861 RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src);
1862
1863static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001864 SOC_DAPM_ENUM("Mono ADC1 R Source", rt5677_mono_adc1_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001865
1866/* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */
1867static const char * const rt5677_stereo4_adc2_src[] = {
1868 "DD MIX1", "DMIC", "DD MIX2"
1869};
1870
1871static SOC_ENUM_SINGLE_DECL(
1872 rt5677_stereo4_adc2_enum, RT5677_STO4_ADC_MIXER,
1873 RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src);
1874
1875static const struct snd_kcontrol_new rt5677_sto4_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001876 SOC_DAPM_ENUM("Stereo4 ADC2 Source", rt5677_stereo4_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001877
1878
1879/* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */
1880static const char * const rt5677_stereo4_adc1_src[] = {
1881 "DD MIX1", "ADC1/2", "DD MIX2"
1882};
1883
1884static SOC_ENUM_SINGLE_DECL(
1885 rt5677_stereo4_adc1_enum, RT5677_STO4_ADC_MIXER,
1886 RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src);
1887
1888static const struct snd_kcontrol_new rt5677_sto4_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001889 SOC_DAPM_ENUM("Stereo4 ADC1 Source", rt5677_stereo4_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001890
1891/* InBound0/1 Source */ /* MX-A3 [14:12] */
1892static const char * const rt5677_inbound01_src[] = {
1893 "IF1 DAC 01", "IF2 DAC 01", "SLB DAC 01", "STO1 ADC MIX",
1894 "VAD ADC/DAC1 FS"
1895};
1896
1897static SOC_ENUM_SINGLE_DECL(
1898 rt5677_inbound01_enum, RT5677_DSP_INB_CTRL1,
1899 RT5677_IB01_SRC_SFT, rt5677_inbound01_src);
1900
1901static const struct snd_kcontrol_new rt5677_ib01_src_mux =
1902 SOC_DAPM_ENUM("InBound0/1 Source", rt5677_inbound01_enum);
1903
1904/* InBound2/3 Source */ /* MX-A3 [10:8] */
1905static const char * const rt5677_inbound23_src[] = {
1906 "IF1 DAC 23", "IF2 DAC 23", "SLB DAC 23", "STO2 ADC MIX",
1907 "DAC1 FS", "IF4 DAC"
1908};
1909
1910static SOC_ENUM_SINGLE_DECL(
1911 rt5677_inbound23_enum, RT5677_DSP_INB_CTRL1,
1912 RT5677_IB23_SRC_SFT, rt5677_inbound23_src);
1913
1914static const struct snd_kcontrol_new rt5677_ib23_src_mux =
1915 SOC_DAPM_ENUM("InBound2/3 Source", rt5677_inbound23_enum);
1916
1917/* InBound4/5 Source */ /* MX-A3 [6:4] */
1918static const char * const rt5677_inbound45_src[] = {
1919 "IF1 DAC 45", "IF2 DAC 45", "SLB DAC 45", "STO3 ADC MIX",
1920 "IF3 DAC"
1921};
1922
1923static SOC_ENUM_SINGLE_DECL(
1924 rt5677_inbound45_enum, RT5677_DSP_INB_CTRL1,
1925 RT5677_IB45_SRC_SFT, rt5677_inbound45_src);
1926
1927static const struct snd_kcontrol_new rt5677_ib45_src_mux =
1928 SOC_DAPM_ENUM("InBound4/5 Source", rt5677_inbound45_enum);
1929
1930/* InBound6 Source */ /* MX-A3 [2:0] */
1931static const char * const rt5677_inbound6_src[] = {
1932 "IF1 DAC 6", "IF2 DAC 6", "SLB DAC 6", "STO4 ADC MIX L",
1933 "IF4 DAC L", "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L"
1934};
1935
1936static SOC_ENUM_SINGLE_DECL(
1937 rt5677_inbound6_enum, RT5677_DSP_INB_CTRL1,
1938 RT5677_IB6_SRC_SFT, rt5677_inbound6_src);
1939
1940static const struct snd_kcontrol_new rt5677_ib6_src_mux =
1941 SOC_DAPM_ENUM("InBound6 Source", rt5677_inbound6_enum);
1942
1943/* InBound7 Source */ /* MX-A4 [14:12] */
1944static const char * const rt5677_inbound7_src[] = {
1945 "IF1 DAC 7", "IF2 DAC 7", "SLB DAC 7", "STO4 ADC MIX R",
1946 "IF4 DAC R", "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R"
1947};
1948
1949static SOC_ENUM_SINGLE_DECL(
1950 rt5677_inbound7_enum, RT5677_DSP_INB_CTRL2,
1951 RT5677_IB7_SRC_SFT, rt5677_inbound7_src);
1952
1953static const struct snd_kcontrol_new rt5677_ib7_src_mux =
1954 SOC_DAPM_ENUM("InBound7 Source", rt5677_inbound7_enum);
1955
1956/* InBound8 Source */ /* MX-A4 [10:8] */
1957static const char * const rt5677_inbound8_src[] = {
1958 "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L", "STO4 ADC MIX L",
1959 "MONO ADC MIX L", "DACL1 FS"
1960};
1961
1962static SOC_ENUM_SINGLE_DECL(
1963 rt5677_inbound8_enum, RT5677_DSP_INB_CTRL2,
1964 RT5677_IB8_SRC_SFT, rt5677_inbound8_src);
1965
1966static const struct snd_kcontrol_new rt5677_ib8_src_mux =
1967 SOC_DAPM_ENUM("InBound8 Source", rt5677_inbound8_enum);
1968
1969/* InBound9 Source */ /* MX-A4 [6:4] */
1970static const char * const rt5677_inbound9_src[] = {
1971 "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R", "STO4 ADC MIX R",
1972 "MONO ADC MIX R", "DACR1 FS", "DAC1 FS"
1973};
1974
1975static SOC_ENUM_SINGLE_DECL(
1976 rt5677_inbound9_enum, RT5677_DSP_INB_CTRL2,
1977 RT5677_IB9_SRC_SFT, rt5677_inbound9_src);
1978
1979static const struct snd_kcontrol_new rt5677_ib9_src_mux =
1980 SOC_DAPM_ENUM("InBound9 Source", rt5677_inbound9_enum);
1981
1982/* VAD Source */ /* MX-9F [6:4] */
1983static const char * const rt5677_vad_src[] = {
1984 "STO1 ADC MIX L", "MONO ADC MIX L", "MONO ADC MIX R", "STO2 ADC MIX L",
1985 "STO3 ADC MIX L"
1986};
1987
1988static SOC_ENUM_SINGLE_DECL(
1989 rt5677_vad_enum, RT5677_VAD_CTRL4,
1990 RT5677_VAD_SRC_SFT, rt5677_vad_src);
1991
1992static const struct snd_kcontrol_new rt5677_vad_src_mux =
1993 SOC_DAPM_ENUM("VAD Source", rt5677_vad_enum);
1994
1995/* Sidetone Source */ /* MX-13 [11:9] */
1996static const char * const rt5677_sidetone_src[] = {
1997 "DMIC1 L", "DMIC2 L", "DMIC3 L", "DMIC4 L", "ADC1", "ADC2"
1998};
1999
2000static SOC_ENUM_SINGLE_DECL(
2001 rt5677_sidetone_enum, RT5677_SIDETONE_CTRL,
2002 RT5677_ST_SEL_SFT, rt5677_sidetone_src);
2003
2004static const struct snd_kcontrol_new rt5677_sidetone_mux =
2005 SOC_DAPM_ENUM("Sidetone Source", rt5677_sidetone_enum);
2006
2007/* DAC1/2 Source */ /* MX-15 [1:0] */
2008static const char * const rt5677_dac12_src[] = {
2009 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
2010};
2011
2012static SOC_ENUM_SINGLE_DECL(
2013 rt5677_dac12_enum, RT5677_ANA_DAC1_2_3_SRC,
2014 RT5677_ANA_DAC1_2_SRC_SEL_SFT, rt5677_dac12_src);
2015
2016static const struct snd_kcontrol_new rt5677_dac12_mux =
2017 SOC_DAPM_ENUM("Analog DAC1/2 Source", rt5677_dac12_enum);
2018
2019/* DAC3 Source */ /* MX-15 [5:4] */
2020static const char * const rt5677_dac3_src[] = {
2021 "MONO DAC MIXL", "MONO DAC MIXR", "DD MIX1L", "DD MIX2L"
2022};
2023
2024static SOC_ENUM_SINGLE_DECL(
2025 rt5677_dac3_enum, RT5677_ANA_DAC1_2_3_SRC,
2026 RT5677_ANA_DAC3_SRC_SEL_SFT, rt5677_dac3_src);
2027
2028static const struct snd_kcontrol_new rt5677_dac3_mux =
2029 SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum);
2030
Oder Chiou1b7fd762014-06-10 14:35:24 +08002031/* PDM channel Source */ /* MX-31 [13:12][9:8][5:4][1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08002032static const char * const rt5677_pdm_src[] = {
2033 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
2034};
2035
2036static SOC_ENUM_SINGLE_DECL(
2037 rt5677_pdm1_l_enum, RT5677_PDM_OUT_CTRL,
2038 RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src);
2039
2040static const struct snd_kcontrol_new rt5677_pdm1_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002041 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002042
2043static SOC_ENUM_SINGLE_DECL(
2044 rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL,
2045 RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src);
2046
2047static const struct snd_kcontrol_new rt5677_pdm2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002048 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002049
2050static SOC_ENUM_SINGLE_DECL(
2051 rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL,
2052 RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src);
2053
2054static const struct snd_kcontrol_new rt5677_pdm1_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002055 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002056
2057static SOC_ENUM_SINGLE_DECL(
2058 rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL,
2059 RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src);
2060
2061static const struct snd_kcontrol_new rt5677_pdm2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002062 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002063
Oder Chioud65fd3a2014-11-05 13:42:52 +08002064/* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08002065static const char * const rt5677_if12_adc1_src[] = {
2066 "STO1 ADC MIX", "OB01", "VAD ADC"
2067};
2068
2069static SOC_ENUM_SINGLE_DECL(
2070 rt5677_if1_adc1_enum, RT5677_TDM1_CTRL2,
2071 RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src);
2072
2073static const struct snd_kcontrol_new rt5677_if1_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002074 SOC_DAPM_ENUM("IF1 ADC1 Source", rt5677_if1_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002075
2076static SOC_ENUM_SINGLE_DECL(
2077 rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2,
2078 RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src);
2079
2080static const struct snd_kcontrol_new rt5677_if2_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002081 SOC_DAPM_ENUM("IF2 ADC1 Source", rt5677_if2_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002082
2083static SOC_ENUM_SINGLE_DECL(
2084 rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX,
2085 RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src);
2086
2087static const struct snd_kcontrol_new rt5677_slb_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002088 SOC_DAPM_ENUM("SLB ADC1 Source", rt5677_slb_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002089
2090/* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */
2091static const char * const rt5677_if12_adc2_src[] = {
2092 "STO2 ADC MIX", "OB23"
2093};
2094
2095static SOC_ENUM_SINGLE_DECL(
2096 rt5677_if1_adc2_enum, RT5677_TDM1_CTRL2,
2097 RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src);
2098
2099static const struct snd_kcontrol_new rt5677_if1_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002100 SOC_DAPM_ENUM("IF1 ADC2 Source", rt5677_if1_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002101
2102static SOC_ENUM_SINGLE_DECL(
2103 rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2,
2104 RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src);
2105
2106static const struct snd_kcontrol_new rt5677_if2_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002107 SOC_DAPM_ENUM("IF2 ADC2 Source", rt5677_if2_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002108
2109static SOC_ENUM_SINGLE_DECL(
2110 rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX,
2111 RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src);
2112
2113static const struct snd_kcontrol_new rt5677_slb_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002114 SOC_DAPM_ENUM("SLB ADC2 Source", rt5677_slb_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002115
2116/* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */
2117static const char * const rt5677_if12_adc3_src[] = {
2118 "STO3 ADC MIX", "MONO ADC MIX", "OB45"
2119};
2120
2121static SOC_ENUM_SINGLE_DECL(
2122 rt5677_if1_adc3_enum, RT5677_TDM1_CTRL2,
2123 RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src);
2124
2125static const struct snd_kcontrol_new rt5677_if1_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002126 SOC_DAPM_ENUM("IF1 ADC3 Source", rt5677_if1_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002127
2128static SOC_ENUM_SINGLE_DECL(
2129 rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2,
2130 RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src);
2131
2132static const struct snd_kcontrol_new rt5677_if2_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002133 SOC_DAPM_ENUM("IF2 ADC3 Source", rt5677_if2_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002134
2135static SOC_ENUM_SINGLE_DECL(
2136 rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX,
2137 RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src);
2138
2139static const struct snd_kcontrol_new rt5677_slb_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002140 SOC_DAPM_ENUM("SLB ADC3 Source", rt5677_slb_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002141
Oder Chioud65fd3a2014-11-05 13:42:52 +08002142/* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */
Oder Chiou0e826e82014-05-26 20:32:33 +08002143static const char * const rt5677_if12_adc4_src[] = {
2144 "STO4 ADC MIX", "OB67", "OB01"
2145};
2146
2147static SOC_ENUM_SINGLE_DECL(
2148 rt5677_if1_adc4_enum, RT5677_TDM1_CTRL2,
2149 RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src);
2150
2151static const struct snd_kcontrol_new rt5677_if1_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002152 SOC_DAPM_ENUM("IF1 ADC4 Source", rt5677_if1_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002153
2154static SOC_ENUM_SINGLE_DECL(
2155 rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2,
2156 RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src);
2157
2158static const struct snd_kcontrol_new rt5677_if2_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002159 SOC_DAPM_ENUM("IF2 ADC4 Source", rt5677_if2_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002160
2161static SOC_ENUM_SINGLE_DECL(
2162 rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX,
2163 RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src);
2164
2165static const struct snd_kcontrol_new rt5677_slb_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002166 SOC_DAPM_ENUM("SLB ADC4 Source", rt5677_slb_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002167
Oder Chioud65fd3a2014-11-05 13:42:52 +08002168/* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4] */
Oder Chiou0e826e82014-05-26 20:32:33 +08002169static const char * const rt5677_if34_adc_src[] = {
2170 "STO1 ADC MIX", "STO2 ADC MIX", "STO3 ADC MIX", "STO4 ADC MIX",
2171 "MONO ADC MIX", "OB01", "OB23", "VAD ADC"
2172};
2173
2174static SOC_ENUM_SINGLE_DECL(
2175 rt5677_if3_adc_enum, RT5677_IF3_DATA,
2176 RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src);
2177
2178static const struct snd_kcontrol_new rt5677_if3_adc_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002179 SOC_DAPM_ENUM("IF3 ADC Source", rt5677_if3_adc_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002180
2181static SOC_ENUM_SINGLE_DECL(
2182 rt5677_if4_adc_enum, RT5677_IF4_DATA,
2183 RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src);
2184
2185static const struct snd_kcontrol_new rt5677_if4_adc_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08002186 SOC_DAPM_ENUM("IF4 ADC Source", rt5677_if4_adc_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08002187
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002188/* TDM IF1/2 ADC Data Selection */ /* MX-3B MX-40 [7:6][5:4][3:2][1:0] */
2189static const char * const rt5677_if12_adc_swap_src[] = {
2190 "L/R", "R/L", "L/L", "R/R"
2191};
2192
2193static SOC_ENUM_SINGLE_DECL(
2194 rt5677_if1_adc1_swap_enum, RT5677_TDM1_CTRL1,
2195 RT5677_IF1_ADC1_SWAP_SFT, rt5677_if12_adc_swap_src);
2196
2197static const struct snd_kcontrol_new rt5677_if1_adc1_swap_mux =
2198 SOC_DAPM_ENUM("IF1 ADC1 Swap Source", rt5677_if1_adc1_swap_enum);
2199
2200static SOC_ENUM_SINGLE_DECL(
2201 rt5677_if1_adc2_swap_enum, RT5677_TDM1_CTRL1,
2202 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
2203
2204static const struct snd_kcontrol_new rt5677_if1_adc2_swap_mux =
2205 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if1_adc2_swap_enum);
2206
2207static SOC_ENUM_SINGLE_DECL(
2208 rt5677_if1_adc3_swap_enum, RT5677_TDM1_CTRL1,
2209 RT5677_IF1_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
2210
2211static const struct snd_kcontrol_new rt5677_if1_adc3_swap_mux =
2212 SOC_DAPM_ENUM("IF1 ADC3 Swap Source", rt5677_if1_adc3_swap_enum);
2213
2214static SOC_ENUM_SINGLE_DECL(
2215 rt5677_if1_adc4_swap_enum, RT5677_TDM1_CTRL1,
2216 RT5677_IF1_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
2217
2218static const struct snd_kcontrol_new rt5677_if1_adc4_swap_mux =
2219 SOC_DAPM_ENUM("IF1 ADC4 Swap Source", rt5677_if1_adc4_swap_enum);
2220
2221static SOC_ENUM_SINGLE_DECL(
2222 rt5677_if2_adc1_swap_enum, RT5677_TDM2_CTRL1,
2223 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
2224
2225static const struct snd_kcontrol_new rt5677_if2_adc1_swap_mux =
2226 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if2_adc1_swap_enum);
2227
2228static SOC_ENUM_SINGLE_DECL(
2229 rt5677_if2_adc2_swap_enum, RT5677_TDM2_CTRL1,
2230 RT5677_IF2_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
2231
2232static const struct snd_kcontrol_new rt5677_if2_adc2_swap_mux =
2233 SOC_DAPM_ENUM("IF2 ADC2 Swap Source", rt5677_if2_adc2_swap_enum);
2234
2235static SOC_ENUM_SINGLE_DECL(
2236 rt5677_if2_adc3_swap_enum, RT5677_TDM2_CTRL1,
2237 RT5677_IF2_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
2238
2239static const struct snd_kcontrol_new rt5677_if2_adc3_swap_mux =
2240 SOC_DAPM_ENUM("IF2 ADC3 Swap Source", rt5677_if2_adc3_swap_enum);
2241
2242static SOC_ENUM_SINGLE_DECL(
2243 rt5677_if2_adc4_swap_enum, RT5677_TDM2_CTRL1,
2244 RT5677_IF2_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
2245
2246static const struct snd_kcontrol_new rt5677_if2_adc4_swap_mux =
2247 SOC_DAPM_ENUM("IF2 ADC4 Swap Source", rt5677_if2_adc4_swap_enum);
2248
Oder Chioud65fd3a2014-11-05 13:42:52 +08002249/* TDM IF1 ADC Data Selection */ /* MX-3C [2:0] */
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002250static const char * const rt5677_if1_adc_tdm_swap_src[] = {
2251 "1/2/3/4", "2/1/3/4", "2/3/1/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
2252 "3/1/2/4", "3/4/1/2"
2253};
2254
2255static SOC_ENUM_SINGLE_DECL(
2256 rt5677_if1_adc_tdm_swap_enum, RT5677_TDM1_CTRL2,
2257 RT5677_IF1_ADC_CTRL_SFT, rt5677_if1_adc_tdm_swap_src);
2258
2259static const struct snd_kcontrol_new rt5677_if1_adc_tdm_swap_mux =
2260 SOC_DAPM_ENUM("IF1 ADC TDM Swap Source", rt5677_if1_adc_tdm_swap_enum);
2261
2262/* TDM IF2 ADC Data Selection */ /* MX-41[2:0] */
2263static const char * const rt5677_if2_adc_tdm_swap_src[] = {
2264 "1/2/3/4", "2/1/3/4", "3/1/2/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
2265 "2/3/1/4", "3/4/1/2"
2266};
2267
2268static SOC_ENUM_SINGLE_DECL(
2269 rt5677_if2_adc_tdm_swap_enum, RT5677_TDM2_CTRL2,
2270 RT5677_IF2_ADC_CTRL_SFT, rt5677_if2_adc_tdm_swap_src);
2271
2272static const struct snd_kcontrol_new rt5677_if2_adc_tdm_swap_mux =
2273 SOC_DAPM_ENUM("IF2 ADC TDM Swap Source", rt5677_if2_adc_tdm_swap_enum);
2274
Oder Chiou91159ec2014-11-11 15:31:19 +08002275/* TDM IF1/2 DAC Data Selection */ /* MX-3E[14:12][10:8][6:4][2:0]
2276 MX-3F[14:12][10:8][6:4][2:0]
2277 MX-43[14:12][10:8][6:4][2:0]
2278 MX-44[14:12][10:8][6:4][2:0] */
2279static const char * const rt5677_if12_dac_tdm_sel_src[] = {
2280 "Slot0", "Slot1", "Slot2", "Slot3", "Slot4", "Slot5", "Slot6", "Slot7"
2281};
2282
2283static SOC_ENUM_SINGLE_DECL(
2284 rt5677_if1_dac0_tdm_sel_enum, RT5677_TDM1_CTRL4,
2285 RT5677_IF1_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
2286
2287static const struct snd_kcontrol_new rt5677_if1_dac0_tdm_sel_mux =
2288 SOC_DAPM_ENUM("IF1 DAC0 TDM Source", rt5677_if1_dac0_tdm_sel_enum);
2289
2290static SOC_ENUM_SINGLE_DECL(
2291 rt5677_if1_dac1_tdm_sel_enum, RT5677_TDM1_CTRL4,
2292 RT5677_IF1_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
2293
2294static const struct snd_kcontrol_new rt5677_if1_dac1_tdm_sel_mux =
2295 SOC_DAPM_ENUM("IF1 DAC1 TDM Source", rt5677_if1_dac1_tdm_sel_enum);
2296
2297static SOC_ENUM_SINGLE_DECL(
2298 rt5677_if1_dac2_tdm_sel_enum, RT5677_TDM1_CTRL4,
2299 RT5677_IF1_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
2300
2301static const struct snd_kcontrol_new rt5677_if1_dac2_tdm_sel_mux =
2302 SOC_DAPM_ENUM("IF1 DAC2 TDM Source", rt5677_if1_dac2_tdm_sel_enum);
2303
2304static SOC_ENUM_SINGLE_DECL(
2305 rt5677_if1_dac3_tdm_sel_enum, RT5677_TDM1_CTRL4,
2306 RT5677_IF1_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
2307
2308static const struct snd_kcontrol_new rt5677_if1_dac3_tdm_sel_mux =
2309 SOC_DAPM_ENUM("IF1 DAC3 TDM Source", rt5677_if1_dac3_tdm_sel_enum);
2310
2311static SOC_ENUM_SINGLE_DECL(
2312 rt5677_if1_dac4_tdm_sel_enum, RT5677_TDM1_CTRL5,
2313 RT5677_IF1_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
2314
2315static const struct snd_kcontrol_new rt5677_if1_dac4_tdm_sel_mux =
2316 SOC_DAPM_ENUM("IF1 DAC4 TDM Source", rt5677_if1_dac4_tdm_sel_enum);
2317
2318static SOC_ENUM_SINGLE_DECL(
2319 rt5677_if1_dac5_tdm_sel_enum, RT5677_TDM1_CTRL5,
2320 RT5677_IF1_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
2321
2322static const struct snd_kcontrol_new rt5677_if1_dac5_tdm_sel_mux =
2323 SOC_DAPM_ENUM("IF1 DAC5 TDM Source", rt5677_if1_dac5_tdm_sel_enum);
2324
2325static SOC_ENUM_SINGLE_DECL(
2326 rt5677_if1_dac6_tdm_sel_enum, RT5677_TDM1_CTRL5,
2327 RT5677_IF1_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
2328
2329static const struct snd_kcontrol_new rt5677_if1_dac6_tdm_sel_mux =
2330 SOC_DAPM_ENUM("IF1 DAC6 TDM Source", rt5677_if1_dac6_tdm_sel_enum);
2331
2332static SOC_ENUM_SINGLE_DECL(
2333 rt5677_if1_dac7_tdm_sel_enum, RT5677_TDM1_CTRL5,
2334 RT5677_IF1_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
2335
2336static const struct snd_kcontrol_new rt5677_if1_dac7_tdm_sel_mux =
2337 SOC_DAPM_ENUM("IF1 DAC7 TDM Source", rt5677_if1_dac7_tdm_sel_enum);
2338
2339static SOC_ENUM_SINGLE_DECL(
2340 rt5677_if2_dac0_tdm_sel_enum, RT5677_TDM2_CTRL4,
2341 RT5677_IF2_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
2342
2343static const struct snd_kcontrol_new rt5677_if2_dac0_tdm_sel_mux =
2344 SOC_DAPM_ENUM("IF2 DAC0 TDM Source", rt5677_if2_dac0_tdm_sel_enum);
2345
2346static SOC_ENUM_SINGLE_DECL(
2347 rt5677_if2_dac1_tdm_sel_enum, RT5677_TDM2_CTRL4,
2348 RT5677_IF2_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
2349
2350static const struct snd_kcontrol_new rt5677_if2_dac1_tdm_sel_mux =
2351 SOC_DAPM_ENUM("IF2 DAC1 TDM Source", rt5677_if2_dac1_tdm_sel_enum);
2352
2353static SOC_ENUM_SINGLE_DECL(
2354 rt5677_if2_dac2_tdm_sel_enum, RT5677_TDM2_CTRL4,
2355 RT5677_IF2_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
2356
2357static const struct snd_kcontrol_new rt5677_if2_dac2_tdm_sel_mux =
2358 SOC_DAPM_ENUM("IF2 DAC2 TDM Source", rt5677_if2_dac2_tdm_sel_enum);
2359
2360static SOC_ENUM_SINGLE_DECL(
2361 rt5677_if2_dac3_tdm_sel_enum, RT5677_TDM2_CTRL4,
2362 RT5677_IF2_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
2363
2364static const struct snd_kcontrol_new rt5677_if2_dac3_tdm_sel_mux =
2365 SOC_DAPM_ENUM("IF2 DAC3 TDM Source", rt5677_if2_dac3_tdm_sel_enum);
2366
2367static SOC_ENUM_SINGLE_DECL(
2368 rt5677_if2_dac4_tdm_sel_enum, RT5677_TDM2_CTRL5,
2369 RT5677_IF2_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
2370
2371static const struct snd_kcontrol_new rt5677_if2_dac4_tdm_sel_mux =
2372 SOC_DAPM_ENUM("IF2 DAC4 TDM Source", rt5677_if2_dac4_tdm_sel_enum);
2373
2374static SOC_ENUM_SINGLE_DECL(
2375 rt5677_if2_dac5_tdm_sel_enum, RT5677_TDM2_CTRL5,
2376 RT5677_IF2_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
2377
2378static const struct snd_kcontrol_new rt5677_if2_dac5_tdm_sel_mux =
2379 SOC_DAPM_ENUM("IF2 DAC5 TDM Source", rt5677_if2_dac5_tdm_sel_enum);
2380
2381static SOC_ENUM_SINGLE_DECL(
2382 rt5677_if2_dac6_tdm_sel_enum, RT5677_TDM2_CTRL5,
2383 RT5677_IF2_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
2384
2385static const struct snd_kcontrol_new rt5677_if2_dac6_tdm_sel_mux =
2386 SOC_DAPM_ENUM("IF2 DAC6 TDM Source", rt5677_if2_dac6_tdm_sel_enum);
2387
2388static SOC_ENUM_SINGLE_DECL(
2389 rt5677_if2_dac7_tdm_sel_enum, RT5677_TDM2_CTRL5,
2390 RT5677_IF2_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
2391
2392static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux =
2393 SOC_DAPM_ENUM("IF2 DAC7 TDM Source", rt5677_if2_dac7_tdm_sel_enum);
2394
Oder Chiou0e826e82014-05-26 20:32:33 +08002395static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
2396 struct snd_kcontrol *kcontrol, int event)
2397{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002398 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002399 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2400
2401 switch (event) {
2402 case SND_SOC_DAPM_POST_PMU:
2403 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2404 RT5677_PWR_BST1_P, RT5677_PWR_BST1_P);
2405 break;
2406
2407 case SND_SOC_DAPM_PRE_PMD:
2408 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2409 RT5677_PWR_BST1_P, 0);
2410 break;
2411
2412 default:
2413 return 0;
2414 }
2415
2416 return 0;
2417}
2418
2419static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
2420 struct snd_kcontrol *kcontrol, int event)
2421{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002422 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002423 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2424
2425 switch (event) {
2426 case SND_SOC_DAPM_POST_PMU:
2427 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2428 RT5677_PWR_BST2_P, RT5677_PWR_BST2_P);
2429 break;
2430
2431 case SND_SOC_DAPM_PRE_PMD:
2432 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2433 RT5677_PWR_BST2_P, 0);
2434 break;
2435
2436 default:
2437 return 0;
2438 }
2439
2440 return 0;
2441}
2442
2443static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
2444 struct snd_kcontrol *kcontrol, int event)
2445{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002446 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002447 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2448
2449 switch (event) {
Oder Chioubdfbf252015-01-08 10:31:05 +08002450 case SND_SOC_DAPM_PRE_PMU:
Oder Chiou0e826e82014-05-26 20:32:33 +08002451 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2);
Oder Chioubdfbf252015-01-08 10:31:05 +08002452 break;
2453
2454 case SND_SOC_DAPM_POST_PMU:
Oder Chiou0e826e82014-05-26 20:32:33 +08002455 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0);
2456 break;
Oder Chioubdfbf252015-01-08 10:31:05 +08002457
Oder Chiou0e826e82014-05-26 20:32:33 +08002458 default:
2459 return 0;
2460 }
2461
2462 return 0;
2463}
2464
2465static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
2466 struct snd_kcontrol *kcontrol, int event)
2467{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002468 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002469 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2470
2471 switch (event) {
Oder Chioubdfbf252015-01-08 10:31:05 +08002472 case SND_SOC_DAPM_PRE_PMU:
Oder Chiou0e826e82014-05-26 20:32:33 +08002473 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2);
Oder Chioubdfbf252015-01-08 10:31:05 +08002474 break;
2475
2476 case SND_SOC_DAPM_POST_PMU:
Oder Chiou0e826e82014-05-26 20:32:33 +08002477 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0);
2478 break;
Oder Chioubdfbf252015-01-08 10:31:05 +08002479
Oder Chiou0e826e82014-05-26 20:32:33 +08002480 default:
2481 return 0;
2482 }
2483
2484 return 0;
2485}
2486
2487static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
2488 struct snd_kcontrol *kcontrol, int event)
2489{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002490 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002491 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2492
2493 switch (event) {
2494 case SND_SOC_DAPM_POST_PMU:
2495 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2496 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
2497 RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 |
2498 RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB);
2499 break;
Oder Chiouf58c3b92014-06-10 14:35:26 +08002500
2501 case SND_SOC_DAPM_PRE_PMD:
2502 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2503 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
2504 RT5677_PWR_CLK_MB, 0);
2505 break;
2506
Oder Chiou0e826e82014-05-26 20:32:33 +08002507 default:
2508 return 0;
2509 }
2510
2511 return 0;
2512}
2513
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002514static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
2515 struct snd_kcontrol *kcontrol, int event)
2516{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002517 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002518 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2519 unsigned int value;
2520
2521 switch (event) {
2522 case SND_SOC_DAPM_PRE_PMU:
2523 regmap_read(rt5677->regmap, RT5677_TDM1_CTRL2, &value);
2524 if (value & RT5677_IF1_ADC_CTRL_MASK)
2525 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1,
2526 RT5677_IF1_ADC_MODE_MASK,
2527 RT5677_IF1_ADC_MODE_TDM);
2528 break;
2529
2530 default:
2531 return 0;
2532 }
2533
2534 return 0;
2535}
2536
2537static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
2538 struct snd_kcontrol *kcontrol, int event)
2539{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002540 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002541 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2542 unsigned int value;
2543
2544 switch (event) {
2545 case SND_SOC_DAPM_PRE_PMU:
2546 regmap_read(rt5677->regmap, RT5677_TDM2_CTRL2, &value);
2547 if (value & RT5677_IF2_ADC_CTRL_MASK)
2548 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1,
2549 RT5677_IF2_ADC_MODE_MASK,
2550 RT5677_IF2_ADC_MODE_TDM);
2551 break;
2552
2553 default:
2554 return 0;
2555 }
2556
2557 return 0;
2558}
2559
Oder Chiou683996c2014-11-19 13:52:20 +08002560static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
2561 struct snd_kcontrol *kcontrol, int event)
2562{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002563 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou683996c2014-11-19 13:52:20 +08002564 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2565
2566 switch (event) {
2567 case SND_SOC_DAPM_POST_PMU:
Lars-Peter Clausen6b43c2e2015-05-19 21:49:11 +02002568 if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON &&
Oder Chiou683996c2014-11-19 13:52:20 +08002569 !rt5677->is_vref_slow) {
2570 mdelay(20);
2571 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
2572 RT5677_PWR_FV1 | RT5677_PWR_FV2,
2573 RT5677_PWR_FV1 | RT5677_PWR_FV2);
2574 rt5677->is_vref_slow = true;
2575 }
2576 break;
2577
2578 default:
2579 return 0;
2580 }
2581
2582 return 0;
2583}
2584
Oder Chiouc22d7662015-11-09 18:01:04 +08002585static int rt5677_filter_power_event(struct snd_soc_dapm_widget *w,
2586 struct snd_kcontrol *kcontrol, int event)
2587{
2588 switch (event) {
2589 case SND_SOC_DAPM_POST_PMU:
2590 msleep(50);
2591 break;
2592
2593 default:
2594 return 0;
2595 }
2596
2597 return 0;
2598}
2599
Oder Chiou0e826e82014-05-26 20:32:33 +08002600static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2601 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT,
Oder Chioubdfbf252015-01-08 10:31:05 +08002602 0, rt5677_set_pll1_event, SND_SOC_DAPM_PRE_PMU |
2603 SND_SOC_DAPM_POST_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002604 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT,
Oder Chioubdfbf252015-01-08 10:31:05 +08002605 0, rt5677_set_pll2_event, SND_SOC_DAPM_PRE_PMU |
2606 SND_SOC_DAPM_POST_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002607
Oder Chiou5a8c7c22014-12-23 10:27:55 +08002608 /* ASRC */
2609 SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5677_ASRC_1, 0, 0, NULL, 0),
2610 SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5677_ASRC_1, 1, 0, NULL, 0),
2611 SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5677_ASRC_1, 2, 0, NULL, 0),
2612 SND_SOC_DAPM_SUPPLY_S("I2S4 ASRC", 1, RT5677_ASRC_1, 3, 0, NULL, 0),
2613 SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5677_ASRC_2, 14, 0, NULL, 0),
2614 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 L ASRC", 1, RT5677_ASRC_2, 13, 0, NULL,
2615 0),
2616 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 R ASRC", 1, RT5677_ASRC_2, 12, 0, NULL,
2617 0),
2618 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 L ASRC", 1, RT5677_ASRC_1, 15, 0, NULL,
2619 0),
2620 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 R ASRC", 1, RT5677_ASRC_1, 14, 0, NULL,
2621 0),
2622 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 L ASRC", 1, RT5677_ASRC_1, 13, 0, NULL,
2623 0),
2624 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 R ASRC", 1, RT5677_ASRC_1, 12, 0, NULL,
2625 0),
2626 SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5677_ASRC_2, 11, 0, NULL,
2627 0),
2628 SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5677_ASRC_2, 10, 0, NULL,
2629 0),
2630 SND_SOC_DAPM_SUPPLY_S("DMIC STO3 ASRC", 1, RT5677_ASRC_2, 9, 0, NULL,
2631 0),
2632 SND_SOC_DAPM_SUPPLY_S("DMIC STO4 ASRC", 1, RT5677_ASRC_2, 8, 0, NULL,
2633 0),
2634 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5677_ASRC_2, 7, 0, NULL,
2635 0),
2636 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5677_ASRC_2, 6, 0, NULL,
2637 0),
2638 SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5677_ASRC_2, 5, 0, NULL, 0),
2639 SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5677_ASRC_2, 4, 0, NULL, 0),
2640 SND_SOC_DAPM_SUPPLY_S("ADC STO3 ASRC", 1, RT5677_ASRC_2, 3, 0, NULL, 0),
2641 SND_SOC_DAPM_SUPPLY_S("ADC STO4 ASRC", 1, RT5677_ASRC_2, 2, 0, NULL, 0),
2642 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5677_ASRC_2, 1, 0, NULL,
2643 0),
2644 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5677_ASRC_2, 0, 0, NULL,
2645 0),
2646
Oder Chiou0e826e82014-05-26 20:32:33 +08002647 /* Input Side */
2648 /* micbias */
Oder Chiou3d0c03d2014-06-10 14:35:23 +08002649 SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT,
Oder Chiouf58c3b92014-06-10 14:35:26 +08002650 0, rt5677_set_micbias1_event, SND_SOC_DAPM_PRE_PMD |
2651 SND_SOC_DAPM_POST_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002652
2653 /* Input Lines */
2654 SND_SOC_DAPM_INPUT("DMIC L1"),
2655 SND_SOC_DAPM_INPUT("DMIC R1"),
2656 SND_SOC_DAPM_INPUT("DMIC L2"),
2657 SND_SOC_DAPM_INPUT("DMIC R2"),
2658 SND_SOC_DAPM_INPUT("DMIC L3"),
2659 SND_SOC_DAPM_INPUT("DMIC R3"),
2660 SND_SOC_DAPM_INPUT("DMIC L4"),
2661 SND_SOC_DAPM_INPUT("DMIC R4"),
2662
2663 SND_SOC_DAPM_INPUT("IN1P"),
2664 SND_SOC_DAPM_INPUT("IN1N"),
2665 SND_SOC_DAPM_INPUT("IN2P"),
2666 SND_SOC_DAPM_INPUT("IN2N"),
2667
2668 SND_SOC_DAPM_INPUT("Haptic Generator"),
2669
Bard Liao2d15d972014-08-27 19:50:34 +08002670 SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2671 SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2672 SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2673 SND_SOC_DAPM_PGA("DMIC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2674
2675 SND_SOC_DAPM_SUPPLY("DMIC1 power", RT5677_DMIC_CTRL1,
2676 RT5677_DMIC_1_EN_SFT, 0, NULL, 0),
2677 SND_SOC_DAPM_SUPPLY("DMIC2 power", RT5677_DMIC_CTRL1,
2678 RT5677_DMIC_2_EN_SFT, 0, NULL, 0),
2679 SND_SOC_DAPM_SUPPLY("DMIC3 power", RT5677_DMIC_CTRL1,
2680 RT5677_DMIC_3_EN_SFT, 0, NULL, 0),
2681 SND_SOC_DAPM_SUPPLY("DMIC4 power", RT5677_DMIC_CTRL2,
2682 RT5677_DMIC_4_EN_SFT, 0, NULL, 0),
Oder Chiou0e826e82014-05-26 20:32:33 +08002683
2684 SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0,
2685 set_dmic_clk, SND_SOC_DAPM_PRE_PMU),
2686
2687 /* Boost */
2688 SND_SOC_DAPM_PGA_E("BST1", RT5677_PWR_ANLG2,
2689 RT5677_PWR_BST1_BIT, 0, NULL, 0, rt5677_bst1_event,
2690 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2691 SND_SOC_DAPM_PGA_E("BST2", RT5677_PWR_ANLG2,
2692 RT5677_PWR_BST2_BIT, 0, NULL, 0, rt5677_bst2_event,
2693 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2694
2695 /* ADCs */
2696 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM,
2697 0, 0),
2698 SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM,
2699 0, 0),
2700 SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0),
2701
2702 SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5677_PWR_DIG1,
2703 RT5677_PWR_ADC_L_BIT, 0, NULL, 0),
2704 SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5677_PWR_DIG1,
2705 RT5677_PWR_ADC_R_BIT, 0, NULL, 0),
2706 SND_SOC_DAPM_SUPPLY("ADC1 clock", RT5677_PWR_DIG1,
2707 RT5677_PWR_ADCFED1_BIT, 0, NULL, 0),
2708 SND_SOC_DAPM_SUPPLY("ADC2 clock", RT5677_PWR_DIG1,
2709 RT5677_PWR_ADCFED2_BIT, 0, NULL, 0),
2710
2711 /* ADC Mux */
2712 SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0,
2713 &rt5677_sto1_dmic_mux),
2714 SND_SOC_DAPM_MUX("Stereo1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2715 &rt5677_sto1_adc1_mux),
2716 SND_SOC_DAPM_MUX("Stereo1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2717 &rt5677_sto1_adc2_mux),
2718 SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0,
2719 &rt5677_sto2_dmic_mux),
2720 SND_SOC_DAPM_MUX("Stereo2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2721 &rt5677_sto2_adc1_mux),
2722 SND_SOC_DAPM_MUX("Stereo2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2723 &rt5677_sto2_adc2_mux),
2724 SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0,
2725 &rt5677_sto2_adc_lr_mux),
2726 SND_SOC_DAPM_MUX("Stereo3 DMIC Mux", SND_SOC_NOPM, 0, 0,
2727 &rt5677_sto3_dmic_mux),
2728 SND_SOC_DAPM_MUX("Stereo3 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2729 &rt5677_sto3_adc1_mux),
2730 SND_SOC_DAPM_MUX("Stereo3 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2731 &rt5677_sto3_adc2_mux),
2732 SND_SOC_DAPM_MUX("Stereo4 DMIC Mux", SND_SOC_NOPM, 0, 0,
2733 &rt5677_sto4_dmic_mux),
2734 SND_SOC_DAPM_MUX("Stereo4 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2735 &rt5677_sto4_adc1_mux),
2736 SND_SOC_DAPM_MUX("Stereo4 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2737 &rt5677_sto4_adc2_mux),
2738 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
2739 &rt5677_mono_dmic_l_mux),
2740 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
2741 &rt5677_mono_dmic_r_mux),
2742 SND_SOC_DAPM_MUX("Mono ADC2 L Mux", SND_SOC_NOPM, 0, 0,
2743 &rt5677_mono_adc2_l_mux),
2744 SND_SOC_DAPM_MUX("Mono ADC1 L Mux", SND_SOC_NOPM, 0, 0,
2745 &rt5677_mono_adc1_l_mux),
2746 SND_SOC_DAPM_MUX("Mono ADC1 R Mux", SND_SOC_NOPM, 0, 0,
2747 &rt5677_mono_adc1_r_mux),
2748 SND_SOC_DAPM_MUX("Mono ADC2 R Mux", SND_SOC_NOPM, 0, 0,
2749 &rt5677_mono_adc2_r_mux),
2750
2751 /* ADC Mixer */
2752 SND_SOC_DAPM_SUPPLY("adc stereo1 filter", RT5677_PWR_DIG2,
2753 RT5677_PWR_ADC_S1F_BIT, 0, NULL, 0),
2754 SND_SOC_DAPM_SUPPLY("adc stereo2 filter", RT5677_PWR_DIG2,
2755 RT5677_PWR_ADC_S2F_BIT, 0, NULL, 0),
2756 SND_SOC_DAPM_SUPPLY("adc stereo3 filter", RT5677_PWR_DIG2,
2757 RT5677_PWR_ADC_S3F_BIT, 0, NULL, 0),
2758 SND_SOC_DAPM_SUPPLY("adc stereo4 filter", RT5677_PWR_DIG2,
2759 RT5677_PWR_ADC_S4F_BIT, 0, NULL, 0),
2760 SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0,
2761 rt5677_sto1_adc_l_mix, ARRAY_SIZE(rt5677_sto1_adc_l_mix)),
2762 SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0,
2763 rt5677_sto1_adc_r_mix, ARRAY_SIZE(rt5677_sto1_adc_r_mix)),
2764 SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0,
2765 rt5677_sto2_adc_l_mix, ARRAY_SIZE(rt5677_sto2_adc_l_mix)),
2766 SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0,
2767 rt5677_sto2_adc_r_mix, ARRAY_SIZE(rt5677_sto2_adc_r_mix)),
2768 SND_SOC_DAPM_MIXER("Sto3 ADC MIXL", SND_SOC_NOPM, 0, 0,
2769 rt5677_sto3_adc_l_mix, ARRAY_SIZE(rt5677_sto3_adc_l_mix)),
2770 SND_SOC_DAPM_MIXER("Sto3 ADC MIXR", SND_SOC_NOPM, 0, 0,
2771 rt5677_sto3_adc_r_mix, ARRAY_SIZE(rt5677_sto3_adc_r_mix)),
2772 SND_SOC_DAPM_MIXER("Sto4 ADC MIXL", SND_SOC_NOPM, 0, 0,
2773 rt5677_sto4_adc_l_mix, ARRAY_SIZE(rt5677_sto4_adc_l_mix)),
2774 SND_SOC_DAPM_MIXER("Sto4 ADC MIXR", SND_SOC_NOPM, 0, 0,
2775 rt5677_sto4_adc_r_mix, ARRAY_SIZE(rt5677_sto4_adc_r_mix)),
2776 SND_SOC_DAPM_SUPPLY("adc mono left filter", RT5677_PWR_DIG2,
2777 RT5677_PWR_ADC_MF_L_BIT, 0, NULL, 0),
2778 SND_SOC_DAPM_MIXER("Mono ADC MIXL", SND_SOC_NOPM, 0, 0,
2779 rt5677_mono_adc_l_mix, ARRAY_SIZE(rt5677_mono_adc_l_mix)),
2780 SND_SOC_DAPM_SUPPLY("adc mono right filter", RT5677_PWR_DIG2,
2781 RT5677_PWR_ADC_MF_R_BIT, 0, NULL, 0),
2782 SND_SOC_DAPM_MIXER("Mono ADC MIXR", SND_SOC_NOPM, 0, 0,
2783 rt5677_mono_adc_r_mix, ARRAY_SIZE(rt5677_mono_adc_r_mix)),
2784
2785 /* ADC PGA */
2786 SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2787 SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2788 SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2789 SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2790 SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2791 SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2792 SND_SOC_DAPM_PGA("Stereo3 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2793 SND_SOC_DAPM_PGA("Stereo3 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2794 SND_SOC_DAPM_PGA("Stereo3 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2795 SND_SOC_DAPM_PGA("Stereo4 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2796 SND_SOC_DAPM_PGA("Stereo4 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2797 SND_SOC_DAPM_PGA("Stereo4 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2798 SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2799 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002800 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2801 SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
Oder Chiou0e826e82014-05-26 20:32:33 +08002802
2803 /* DSP */
2804 SND_SOC_DAPM_MUX("IB9 Mux", SND_SOC_NOPM, 0, 0,
2805 &rt5677_ib9_src_mux),
2806 SND_SOC_DAPM_MUX("IB8 Mux", SND_SOC_NOPM, 0, 0,
2807 &rt5677_ib8_src_mux),
2808 SND_SOC_DAPM_MUX("IB7 Mux", SND_SOC_NOPM, 0, 0,
2809 &rt5677_ib7_src_mux),
2810 SND_SOC_DAPM_MUX("IB6 Mux", SND_SOC_NOPM, 0, 0,
2811 &rt5677_ib6_src_mux),
2812 SND_SOC_DAPM_MUX("IB45 Mux", SND_SOC_NOPM, 0, 0,
2813 &rt5677_ib45_src_mux),
2814 SND_SOC_DAPM_MUX("IB23 Mux", SND_SOC_NOPM, 0, 0,
2815 &rt5677_ib23_src_mux),
2816 SND_SOC_DAPM_MUX("IB01 Mux", SND_SOC_NOPM, 0, 0,
2817 &rt5677_ib01_src_mux),
2818 SND_SOC_DAPM_MUX("IB45 Bypass Mux", SND_SOC_NOPM, 0, 0,
2819 &rt5677_ib45_bypass_src_mux),
2820 SND_SOC_DAPM_MUX("IB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
2821 &rt5677_ib23_bypass_src_mux),
2822 SND_SOC_DAPM_MUX("IB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
2823 &rt5677_ib01_bypass_src_mux),
2824 SND_SOC_DAPM_MUX("OB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
2825 &rt5677_ob23_bypass_src_mux),
2826 SND_SOC_DAPM_MUX("OB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
2827 &rt5677_ob01_bypass_src_mux),
2828
2829 SND_SOC_DAPM_PGA("OB45", SND_SOC_NOPM, 0, 0, NULL, 0),
2830 SND_SOC_DAPM_PGA("OB67", SND_SOC_NOPM, 0, 0, NULL, 0),
2831
2832 SND_SOC_DAPM_PGA("OutBound2", SND_SOC_NOPM, 0, 0, NULL, 0),
2833 SND_SOC_DAPM_PGA("OutBound3", SND_SOC_NOPM, 0, 0, NULL, 0),
2834 SND_SOC_DAPM_PGA("OutBound4", SND_SOC_NOPM, 0, 0, NULL, 0),
2835 SND_SOC_DAPM_PGA("OutBound5", SND_SOC_NOPM, 0, 0, NULL, 0),
2836 SND_SOC_DAPM_PGA("OutBound6", SND_SOC_NOPM, 0, 0, NULL, 0),
2837 SND_SOC_DAPM_PGA("OutBound7", SND_SOC_NOPM, 0, 0, NULL, 0),
2838
2839 /* Digital Interface */
2840 SND_SOC_DAPM_SUPPLY("I2S1", RT5677_PWR_DIG1,
2841 RT5677_PWR_I2S1_BIT, 0, NULL, 0),
2842 SND_SOC_DAPM_PGA("IF1 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2843 SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2844 SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2845 SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2846 SND_SOC_DAPM_PGA("IF1 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2847 SND_SOC_DAPM_PGA("IF1 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2848 SND_SOC_DAPM_PGA("IF1 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2849 SND_SOC_DAPM_PGA("IF1 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2850 SND_SOC_DAPM_PGA("IF1 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2851 SND_SOC_DAPM_PGA("IF1 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2852 SND_SOC_DAPM_PGA("IF1 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2853 SND_SOC_DAPM_PGA("IF1 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2854 SND_SOC_DAPM_PGA("IF1 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2855 SND_SOC_DAPM_PGA("IF1 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2856 SND_SOC_DAPM_PGA("IF1 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2857 SND_SOC_DAPM_PGA("IF1 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2858
2859 SND_SOC_DAPM_SUPPLY("I2S2", RT5677_PWR_DIG1,
2860 RT5677_PWR_I2S2_BIT, 0, NULL, 0),
2861 SND_SOC_DAPM_PGA("IF2 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2862 SND_SOC_DAPM_PGA("IF2 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2863 SND_SOC_DAPM_PGA("IF2 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2864 SND_SOC_DAPM_PGA("IF2 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2865 SND_SOC_DAPM_PGA("IF2 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2866 SND_SOC_DAPM_PGA("IF2 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2867 SND_SOC_DAPM_PGA("IF2 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2868 SND_SOC_DAPM_PGA("IF2 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2869 SND_SOC_DAPM_PGA("IF2 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2870 SND_SOC_DAPM_PGA("IF2 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2871 SND_SOC_DAPM_PGA("IF2 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2872 SND_SOC_DAPM_PGA("IF2 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2873 SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2874 SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2875 SND_SOC_DAPM_PGA("IF2 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2876 SND_SOC_DAPM_PGA("IF2 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2877
2878 SND_SOC_DAPM_SUPPLY("I2S3", RT5677_PWR_DIG1,
2879 RT5677_PWR_I2S3_BIT, 0, NULL, 0),
2880 SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2881 SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2882 SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2883 SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2884 SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2885 SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2886
2887 SND_SOC_DAPM_SUPPLY("I2S4", RT5677_PWR_DIG1,
2888 RT5677_PWR_I2S4_BIT, 0, NULL, 0),
2889 SND_SOC_DAPM_PGA("IF4 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2890 SND_SOC_DAPM_PGA("IF4 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2891 SND_SOC_DAPM_PGA("IF4 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2892 SND_SOC_DAPM_PGA("IF4 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2893 SND_SOC_DAPM_PGA("IF4 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2894 SND_SOC_DAPM_PGA("IF4 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2895
2896 SND_SOC_DAPM_SUPPLY("SLB", RT5677_PWR_DIG1,
2897 RT5677_PWR_SLB_BIT, 0, NULL, 0),
2898 SND_SOC_DAPM_PGA("SLB DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2899 SND_SOC_DAPM_PGA("SLB DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2900 SND_SOC_DAPM_PGA("SLB DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2901 SND_SOC_DAPM_PGA("SLB DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2902 SND_SOC_DAPM_PGA("SLB DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2903 SND_SOC_DAPM_PGA("SLB DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2904 SND_SOC_DAPM_PGA("SLB DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2905 SND_SOC_DAPM_PGA("SLB DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2906 SND_SOC_DAPM_PGA("SLB DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2907 SND_SOC_DAPM_PGA("SLB DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2908 SND_SOC_DAPM_PGA("SLB DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2909 SND_SOC_DAPM_PGA("SLB DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2910 SND_SOC_DAPM_PGA("SLB ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2911 SND_SOC_DAPM_PGA("SLB ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2912 SND_SOC_DAPM_PGA("SLB ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2913 SND_SOC_DAPM_PGA("SLB ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2914
2915 /* Digital Interface Select */
2916 SND_SOC_DAPM_MUX("IF1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2917 &rt5677_if1_adc1_mux),
2918 SND_SOC_DAPM_MUX("IF1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2919 &rt5677_if1_adc2_mux),
2920 SND_SOC_DAPM_MUX("IF1 ADC3 Mux", SND_SOC_NOPM, 0, 0,
2921 &rt5677_if1_adc3_mux),
2922 SND_SOC_DAPM_MUX("IF1 ADC4 Mux", SND_SOC_NOPM, 0, 0,
2923 &rt5677_if1_adc4_mux),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002924 SND_SOC_DAPM_MUX("IF1 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
2925 &rt5677_if1_adc1_swap_mux),
2926 SND_SOC_DAPM_MUX("IF1 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
2927 &rt5677_if1_adc2_swap_mux),
2928 SND_SOC_DAPM_MUX("IF1 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
2929 &rt5677_if1_adc3_swap_mux),
2930 SND_SOC_DAPM_MUX("IF1 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
2931 &rt5677_if1_adc4_swap_mux),
2932 SND_SOC_DAPM_MUX_E("IF1 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
2933 &rt5677_if1_adc_tdm_swap_mux, rt5677_if1_adc_tdm_event,
2934 SND_SOC_DAPM_PRE_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002935 SND_SOC_DAPM_MUX("IF2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2936 &rt5677_if2_adc1_mux),
2937 SND_SOC_DAPM_MUX("IF2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2938 &rt5677_if2_adc2_mux),
2939 SND_SOC_DAPM_MUX("IF2 ADC3 Mux", SND_SOC_NOPM, 0, 0,
2940 &rt5677_if2_adc3_mux),
2941 SND_SOC_DAPM_MUX("IF2 ADC4 Mux", SND_SOC_NOPM, 0, 0,
2942 &rt5677_if2_adc4_mux),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002943 SND_SOC_DAPM_MUX("IF2 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
2944 &rt5677_if2_adc1_swap_mux),
2945 SND_SOC_DAPM_MUX("IF2 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
2946 &rt5677_if2_adc2_swap_mux),
2947 SND_SOC_DAPM_MUX("IF2 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
2948 &rt5677_if2_adc3_swap_mux),
2949 SND_SOC_DAPM_MUX("IF2 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
2950 &rt5677_if2_adc4_swap_mux),
2951 SND_SOC_DAPM_MUX_E("IF2 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
2952 &rt5677_if2_adc_tdm_swap_mux, rt5677_if2_adc_tdm_event,
2953 SND_SOC_DAPM_PRE_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002954 SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0,
2955 &rt5677_if3_adc_mux),
2956 SND_SOC_DAPM_MUX("IF4 ADC Mux", SND_SOC_NOPM, 0, 0,
2957 &rt5677_if4_adc_mux),
2958 SND_SOC_DAPM_MUX("SLB ADC1 Mux", SND_SOC_NOPM, 0, 0,
2959 &rt5677_slb_adc1_mux),
2960 SND_SOC_DAPM_MUX("SLB ADC2 Mux", SND_SOC_NOPM, 0, 0,
2961 &rt5677_slb_adc2_mux),
2962 SND_SOC_DAPM_MUX("SLB ADC3 Mux", SND_SOC_NOPM, 0, 0,
2963 &rt5677_slb_adc3_mux),
2964 SND_SOC_DAPM_MUX("SLB ADC4 Mux", SND_SOC_NOPM, 0, 0,
2965 &rt5677_slb_adc4_mux),
2966
Oder Chiou91159ec2014-11-11 15:31:19 +08002967 SND_SOC_DAPM_MUX("IF1 DAC0 Mux", SND_SOC_NOPM, 0, 0,
2968 &rt5677_if1_dac0_tdm_sel_mux),
2969 SND_SOC_DAPM_MUX("IF1 DAC1 Mux", SND_SOC_NOPM, 0, 0,
2970 &rt5677_if1_dac1_tdm_sel_mux),
2971 SND_SOC_DAPM_MUX("IF1 DAC2 Mux", SND_SOC_NOPM, 0, 0,
2972 &rt5677_if1_dac2_tdm_sel_mux),
2973 SND_SOC_DAPM_MUX("IF1 DAC3 Mux", SND_SOC_NOPM, 0, 0,
2974 &rt5677_if1_dac3_tdm_sel_mux),
2975 SND_SOC_DAPM_MUX("IF1 DAC4 Mux", SND_SOC_NOPM, 0, 0,
2976 &rt5677_if1_dac4_tdm_sel_mux),
2977 SND_SOC_DAPM_MUX("IF1 DAC5 Mux", SND_SOC_NOPM, 0, 0,
2978 &rt5677_if1_dac5_tdm_sel_mux),
2979 SND_SOC_DAPM_MUX("IF1 DAC6 Mux", SND_SOC_NOPM, 0, 0,
2980 &rt5677_if1_dac6_tdm_sel_mux),
2981 SND_SOC_DAPM_MUX("IF1 DAC7 Mux", SND_SOC_NOPM, 0, 0,
2982 &rt5677_if1_dac7_tdm_sel_mux),
2983
2984 SND_SOC_DAPM_MUX("IF2 DAC0 Mux", SND_SOC_NOPM, 0, 0,
2985 &rt5677_if2_dac0_tdm_sel_mux),
2986 SND_SOC_DAPM_MUX("IF2 DAC1 Mux", SND_SOC_NOPM, 0, 0,
2987 &rt5677_if2_dac1_tdm_sel_mux),
2988 SND_SOC_DAPM_MUX("IF2 DAC2 Mux", SND_SOC_NOPM, 0, 0,
2989 &rt5677_if2_dac2_tdm_sel_mux),
2990 SND_SOC_DAPM_MUX("IF2 DAC3 Mux", SND_SOC_NOPM, 0, 0,
2991 &rt5677_if2_dac3_tdm_sel_mux),
2992 SND_SOC_DAPM_MUX("IF2 DAC4 Mux", SND_SOC_NOPM, 0, 0,
2993 &rt5677_if2_dac4_tdm_sel_mux),
2994 SND_SOC_DAPM_MUX("IF2 DAC5 Mux", SND_SOC_NOPM, 0, 0,
2995 &rt5677_if2_dac5_tdm_sel_mux),
2996 SND_SOC_DAPM_MUX("IF2 DAC6 Mux", SND_SOC_NOPM, 0, 0,
2997 &rt5677_if2_dac6_tdm_sel_mux),
2998 SND_SOC_DAPM_MUX("IF2 DAC7 Mux", SND_SOC_NOPM, 0, 0,
2999 &rt5677_if2_dac7_tdm_sel_mux),
3000
Oder Chiou0e826e82014-05-26 20:32:33 +08003001 /* Audio Interface */
3002 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
3003 SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
3004 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
3005 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
3006 SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
3007 SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
3008 SND_SOC_DAPM_AIF_IN("AIF4RX", "AIF4 Playback", 0, SND_SOC_NOPM, 0, 0),
3009 SND_SOC_DAPM_AIF_OUT("AIF4TX", "AIF4 Capture", 0, SND_SOC_NOPM, 0, 0),
3010 SND_SOC_DAPM_AIF_IN("SLBRX", "SLIMBus Playback", 0, SND_SOC_NOPM, 0, 0),
3011 SND_SOC_DAPM_AIF_OUT("SLBTX", "SLIMBus Capture", 0, SND_SOC_NOPM, 0, 0),
3012
3013 /* Sidetone Mux */
3014 SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0,
3015 &rt5677_sidetone_mux),
Oder Chiou90bdbb42014-09-18 14:45:59 +08003016 SND_SOC_DAPM_SUPPLY("Sidetone Power", RT5677_SIDETONE_CTRL,
3017 RT5677_ST_EN_SFT, 0, NULL, 0),
3018
Oder Chiou0e826e82014-05-26 20:32:33 +08003019 /* VAD Mux*/
3020 SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0,
3021 &rt5677_vad_src_mux),
3022
3023 /* Tensilica DSP */
3024 SND_SOC_DAPM_PGA("Tensilica DSP", SND_SOC_NOPM, 0, 0, NULL, 0),
3025 SND_SOC_DAPM_MIXER("OB01 MIX", SND_SOC_NOPM, 0, 0,
3026 rt5677_ob_01_mix, ARRAY_SIZE(rt5677_ob_01_mix)),
3027 SND_SOC_DAPM_MIXER("OB23 MIX", SND_SOC_NOPM, 0, 0,
3028 rt5677_ob_23_mix, ARRAY_SIZE(rt5677_ob_23_mix)),
3029 SND_SOC_DAPM_MIXER("OB4 MIX", SND_SOC_NOPM, 0, 0,
3030 rt5677_ob_4_mix, ARRAY_SIZE(rt5677_ob_4_mix)),
3031 SND_SOC_DAPM_MIXER("OB5 MIX", SND_SOC_NOPM, 0, 0,
3032 rt5677_ob_5_mix, ARRAY_SIZE(rt5677_ob_5_mix)),
3033 SND_SOC_DAPM_MIXER("OB6 MIX", SND_SOC_NOPM, 0, 0,
3034 rt5677_ob_6_mix, ARRAY_SIZE(rt5677_ob_6_mix)),
3035 SND_SOC_DAPM_MIXER("OB7 MIX", SND_SOC_NOPM, 0, 0,
3036 rt5677_ob_7_mix, ARRAY_SIZE(rt5677_ob_7_mix)),
3037
3038 /* Output Side */
Oder Chioud65fd3a2014-11-05 13:42:52 +08003039 /* DAC mixer before sound effect */
Oder Chiou0e826e82014-05-26 20:32:33 +08003040 SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0,
3041 rt5677_dac_l_mix, ARRAY_SIZE(rt5677_dac_l_mix)),
3042 SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0,
3043 rt5677_dac_r_mix, ARRAY_SIZE(rt5677_dac_r_mix)),
3044 SND_SOC_DAPM_PGA("DAC1 FS", SND_SOC_NOPM, 0, 0, NULL, 0),
3045
3046 /* DAC Mux */
3047 SND_SOC_DAPM_MUX("DAC1 Mux", SND_SOC_NOPM, 0, 0,
3048 &rt5677_dac1_mux),
3049 SND_SOC_DAPM_MUX("ADDA1 Mux", SND_SOC_NOPM, 0, 0,
3050 &rt5677_adda1_mux),
3051 SND_SOC_DAPM_MUX("DAC12 SRC Mux", SND_SOC_NOPM, 0, 0,
3052 &rt5677_dac12_mux),
3053 SND_SOC_DAPM_MUX("DAC3 SRC Mux", SND_SOC_NOPM, 0, 0,
3054 &rt5677_dac3_mux),
3055
3056 /* DAC2 channel Mux */
3057 SND_SOC_DAPM_MUX("DAC2 L Mux", SND_SOC_NOPM, 0, 0,
3058 &rt5677_dac2_l_mux),
3059 SND_SOC_DAPM_MUX("DAC2 R Mux", SND_SOC_NOPM, 0, 0,
3060 &rt5677_dac2_r_mux),
3061
3062 /* DAC3 channel Mux */
3063 SND_SOC_DAPM_MUX("DAC3 L Mux", SND_SOC_NOPM, 0, 0,
3064 &rt5677_dac3_l_mux),
3065 SND_SOC_DAPM_MUX("DAC3 R Mux", SND_SOC_NOPM, 0, 0,
3066 &rt5677_dac3_r_mux),
3067
3068 /* DAC4 channel Mux */
3069 SND_SOC_DAPM_MUX("DAC4 L Mux", SND_SOC_NOPM, 0, 0,
3070 &rt5677_dac4_l_mux),
3071 SND_SOC_DAPM_MUX("DAC4 R Mux", SND_SOC_NOPM, 0, 0,
3072 &rt5677_dac4_r_mux),
3073
3074 /* DAC Mixer */
3075 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2,
Oder Chiouc22d7662015-11-09 18:01:04 +08003076 RT5677_PWR_DAC_S1F_BIT, 0, rt5677_filter_power_event,
3077 SND_SOC_DAPM_POST_PMU),
Oder Chiou6800b5b2014-12-23 10:27:54 +08003078 SND_SOC_DAPM_SUPPLY("dac mono2 left filter", RT5677_PWR_DIG2,
Oder Chiouc22d7662015-11-09 18:01:04 +08003079 RT5677_PWR_DAC_M2F_L_BIT, 0, rt5677_filter_power_event,
3080 SND_SOC_DAPM_POST_PMU),
Oder Chiou6800b5b2014-12-23 10:27:54 +08003081 SND_SOC_DAPM_SUPPLY("dac mono2 right filter", RT5677_PWR_DIG2,
Oder Chiouc22d7662015-11-09 18:01:04 +08003082 RT5677_PWR_DAC_M2F_R_BIT, 0, rt5677_filter_power_event,
3083 SND_SOC_DAPM_POST_PMU),
Oder Chiou6800b5b2014-12-23 10:27:54 +08003084 SND_SOC_DAPM_SUPPLY("dac mono3 left filter", RT5677_PWR_DIG2,
Oder Chiouc22d7662015-11-09 18:01:04 +08003085 RT5677_PWR_DAC_M3F_L_BIT, 0, rt5677_filter_power_event,
3086 SND_SOC_DAPM_POST_PMU),
Oder Chiou6800b5b2014-12-23 10:27:54 +08003087 SND_SOC_DAPM_SUPPLY("dac mono3 right filter", RT5677_PWR_DIG2,
Oder Chiouc22d7662015-11-09 18:01:04 +08003088 RT5677_PWR_DAC_M3F_R_BIT, 0, rt5677_filter_power_event,
3089 SND_SOC_DAPM_POST_PMU),
Oder Chiou6800b5b2014-12-23 10:27:54 +08003090 SND_SOC_DAPM_SUPPLY("dac mono4 left filter", RT5677_PWR_DIG2,
Oder Chiouc22d7662015-11-09 18:01:04 +08003091 RT5677_PWR_DAC_M4F_L_BIT, 0, rt5677_filter_power_event,
3092 SND_SOC_DAPM_POST_PMU),
Oder Chiou6800b5b2014-12-23 10:27:54 +08003093 SND_SOC_DAPM_SUPPLY("dac mono4 right filter", RT5677_PWR_DIG2,
Oder Chiouc22d7662015-11-09 18:01:04 +08003094 RT5677_PWR_DAC_M4F_R_BIT, 0, rt5677_filter_power_event,
3095 SND_SOC_DAPM_POST_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08003096
3097 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
3098 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)),
3099 SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0,
3100 rt5677_sto1_dac_r_mix, ARRAY_SIZE(rt5677_sto1_dac_r_mix)),
3101 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
3102 rt5677_mono_dac_l_mix, ARRAY_SIZE(rt5677_mono_dac_l_mix)),
3103 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
3104 rt5677_mono_dac_r_mix, ARRAY_SIZE(rt5677_mono_dac_r_mix)),
3105 SND_SOC_DAPM_MIXER("DD1 MIXL", SND_SOC_NOPM, 0, 0,
3106 rt5677_dd1_l_mix, ARRAY_SIZE(rt5677_dd1_l_mix)),
3107 SND_SOC_DAPM_MIXER("DD1 MIXR", SND_SOC_NOPM, 0, 0,
3108 rt5677_dd1_r_mix, ARRAY_SIZE(rt5677_dd1_r_mix)),
3109 SND_SOC_DAPM_MIXER("DD2 MIXL", SND_SOC_NOPM, 0, 0,
3110 rt5677_dd2_l_mix, ARRAY_SIZE(rt5677_dd2_l_mix)),
3111 SND_SOC_DAPM_MIXER("DD2 MIXR", SND_SOC_NOPM, 0, 0,
3112 rt5677_dd2_r_mix, ARRAY_SIZE(rt5677_dd2_r_mix)),
3113 SND_SOC_DAPM_PGA("Stereo DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
3114 SND_SOC_DAPM_PGA("Mono DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
3115 SND_SOC_DAPM_PGA("DD1 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
3116 SND_SOC_DAPM_PGA("DD2 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
3117
3118 /* DACs */
3119 SND_SOC_DAPM_DAC("DAC 1", NULL, RT5677_PWR_DIG1,
3120 RT5677_PWR_DAC1_BIT, 0),
3121 SND_SOC_DAPM_DAC("DAC 2", NULL, RT5677_PWR_DIG1,
3122 RT5677_PWR_DAC2_BIT, 0),
3123 SND_SOC_DAPM_DAC("DAC 3", NULL, RT5677_PWR_DIG1,
3124 RT5677_PWR_DAC3_BIT, 0),
3125
3126 /* PDM */
3127 SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5677_PWR_DIG2,
3128 RT5677_PWR_PDM1_BIT, 0, NULL, 0),
3129 SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5677_PWR_DIG2,
3130 RT5677_PWR_PDM2_BIT, 0, NULL, 0),
3131
3132 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_L_SFT,
3133 1, &rt5677_pdm1_l_mux),
3134 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_R_SFT,
3135 1, &rt5677_pdm1_r_mux),
3136 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_L_SFT,
3137 1, &rt5677_pdm2_l_mux),
3138 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_R_SFT,
3139 1, &rt5677_pdm2_r_mux),
3140
Oder Chiou683996c2014-11-19 13:52:20 +08003141 SND_SOC_DAPM_PGA_S("LOUT1 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO1_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08003142 0, NULL, 0),
Oder Chiou683996c2014-11-19 13:52:20 +08003143 SND_SOC_DAPM_PGA_S("LOUT2 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO2_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08003144 0, NULL, 0),
Oder Chiou683996c2014-11-19 13:52:20 +08003145 SND_SOC_DAPM_PGA_S("LOUT3 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO3_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08003146 0, NULL, 0),
3147
Oder Chiou683996c2014-11-19 13:52:20 +08003148 SND_SOC_DAPM_PGA_S("LOUT1 vref", 1, SND_SOC_NOPM, 0, 0,
3149 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
3150 SND_SOC_DAPM_PGA_S("LOUT2 vref", 1, SND_SOC_NOPM, 0, 0,
3151 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
3152 SND_SOC_DAPM_PGA_S("LOUT3 vref", 1, SND_SOC_NOPM, 0, 0,
3153 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
3154
Oder Chiou0e826e82014-05-26 20:32:33 +08003155 /* Output Lines */
3156 SND_SOC_DAPM_OUTPUT("LOUT1"),
3157 SND_SOC_DAPM_OUTPUT("LOUT2"),
3158 SND_SOC_DAPM_OUTPUT("LOUT3"),
3159 SND_SOC_DAPM_OUTPUT("PDM1L"),
3160 SND_SOC_DAPM_OUTPUT("PDM1R"),
3161 SND_SOC_DAPM_OUTPUT("PDM2L"),
3162 SND_SOC_DAPM_OUTPUT("PDM2R"),
Oder Chiou683996c2014-11-19 13:52:20 +08003163
3164 SND_SOC_DAPM_POST("vref", rt5677_vref_event),
Oder Chiou0e826e82014-05-26 20:32:33 +08003165};
3166
3167static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
Oder Chiou5220f7f2015-05-08 13:24:02 +08003168 { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", rt5677_dmic_use_asrc },
3169 { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", rt5677_dmic_use_asrc },
3170 { "Stereo3 DMIC Mux", NULL, "DMIC STO3 ASRC", rt5677_dmic_use_asrc },
3171 { "Stereo4 DMIC Mux", NULL, "DMIC STO4 ASRC", rt5677_dmic_use_asrc },
3172 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", rt5677_dmic_use_asrc },
3173 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", rt5677_dmic_use_asrc },
Oder Chiou5a8c7c22014-12-23 10:27:55 +08003174 { "I2S1", NULL, "I2S1 ASRC", can_use_asrc},
3175 { "I2S2", NULL, "I2S2 ASRC", can_use_asrc},
3176 { "I2S3", NULL, "I2S3 ASRC", can_use_asrc},
3177 { "I2S4", NULL, "I2S4 ASRC", can_use_asrc},
3178
3179 { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc },
3180 { "dac mono2 left filter", NULL, "DAC MONO2 L ASRC", is_using_asrc },
3181 { "dac mono2 right filter", NULL, "DAC MONO2 R ASRC", is_using_asrc },
3182 { "dac mono3 left filter", NULL, "DAC MONO3 L ASRC", is_using_asrc },
3183 { "dac mono3 right filter", NULL, "DAC MONO3 R ASRC", is_using_asrc },
3184 { "dac mono4 left filter", NULL, "DAC MONO4 L ASRC", is_using_asrc },
3185 { "dac mono4 right filter", NULL, "DAC MONO4 R ASRC", is_using_asrc },
3186 { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc },
3187 { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc },
3188 { "adc stereo3 filter", NULL, "ADC STO3 ASRC", is_using_asrc },
3189 { "adc stereo4 filter", NULL, "ADC STO4 ASRC", is_using_asrc },
3190 { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc },
3191 { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc },
3192
Oder Chiou0e826e82014-05-26 20:32:33 +08003193 { "DMIC1", NULL, "DMIC L1" },
3194 { "DMIC1", NULL, "DMIC R1" },
3195 { "DMIC2", NULL, "DMIC L2" },
3196 { "DMIC2", NULL, "DMIC R2" },
3197 { "DMIC3", NULL, "DMIC L3" },
3198 { "DMIC3", NULL, "DMIC R3" },
3199 { "DMIC4", NULL, "DMIC L4" },
3200 { "DMIC4", NULL, "DMIC R4" },
3201
3202 { "DMIC L1", NULL, "DMIC CLK" },
3203 { "DMIC R1", NULL, "DMIC CLK" },
3204 { "DMIC L2", NULL, "DMIC CLK" },
3205 { "DMIC R2", NULL, "DMIC CLK" },
3206 { "DMIC L3", NULL, "DMIC CLK" },
3207 { "DMIC R3", NULL, "DMIC CLK" },
3208 { "DMIC L4", NULL, "DMIC CLK" },
3209 { "DMIC R4", NULL, "DMIC CLK" },
3210
Bard Liao2d15d972014-08-27 19:50:34 +08003211 { "DMIC L1", NULL, "DMIC1 power" },
3212 { "DMIC R1", NULL, "DMIC1 power" },
3213 { "DMIC L3", NULL, "DMIC3 power" },
3214 { "DMIC R3", NULL, "DMIC3 power" },
3215 { "DMIC L4", NULL, "DMIC4 power" },
3216 { "DMIC R4", NULL, "DMIC4 power" },
3217
Oder Chiou0e826e82014-05-26 20:32:33 +08003218 { "BST1", NULL, "IN1P" },
3219 { "BST1", NULL, "IN1N" },
3220 { "BST2", NULL, "IN2P" },
3221 { "BST2", NULL, "IN2N" },
3222
Bard Liao22e51342014-08-27 19:50:33 +08003223 { "IN1P", NULL, "MICBIAS1" },
3224 { "IN1N", NULL, "MICBIAS1" },
3225 { "IN2P", NULL, "MICBIAS1" },
3226 { "IN2N", NULL, "MICBIAS1" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003227
3228 { "ADC 1", NULL, "BST1" },
3229 { "ADC 1", NULL, "ADC 1 power" },
3230 { "ADC 1", NULL, "ADC1 clock" },
3231 { "ADC 2", NULL, "BST2" },
3232 { "ADC 2", NULL, "ADC 2 power" },
3233 { "ADC 2", NULL, "ADC2 clock" },
3234
3235 { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" },
3236 { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" },
3237 { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" },
3238 { "Stereo1 DMIC Mux", "DMIC4", "DMIC4" },
3239
3240 { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" },
3241 { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" },
3242 { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" },
3243 { "Stereo2 DMIC Mux", "DMIC4", "DMIC4" },
3244
3245 { "Stereo3 DMIC Mux", "DMIC1", "DMIC1" },
3246 { "Stereo3 DMIC Mux", "DMIC2", "DMIC2" },
3247 { "Stereo3 DMIC Mux", "DMIC3", "DMIC3" },
3248 { "Stereo3 DMIC Mux", "DMIC4", "DMIC4" },
3249
3250 { "Stereo4 DMIC Mux", "DMIC1", "DMIC1" },
3251 { "Stereo4 DMIC Mux", "DMIC2", "DMIC2" },
3252 { "Stereo4 DMIC Mux", "DMIC3", "DMIC3" },
3253 { "Stereo4 DMIC Mux", "DMIC4", "DMIC4" },
3254
3255 { "Mono DMIC L Mux", "DMIC1", "DMIC1" },
3256 { "Mono DMIC L Mux", "DMIC2", "DMIC2" },
3257 { "Mono DMIC L Mux", "DMIC3", "DMIC3" },
3258 { "Mono DMIC L Mux", "DMIC4", "DMIC4" },
3259
3260 { "Mono DMIC R Mux", "DMIC1", "DMIC1" },
3261 { "Mono DMIC R Mux", "DMIC2", "DMIC2" },
3262 { "Mono DMIC R Mux", "DMIC3", "DMIC3" },
3263 { "Mono DMIC R Mux", "DMIC4", "DMIC4" },
3264
3265 { "ADC 1_2", NULL, "ADC 1" },
3266 { "ADC 1_2", NULL, "ADC 2" },
3267
3268 { "Stereo1 ADC1 Mux", "DD MIX1", "DD1 MIX" },
3269 { "Stereo1 ADC1 Mux", "ADC1/2", "ADC 1_2" },
3270 { "Stereo1 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
3271
3272 { "Stereo1 ADC2 Mux", "DD MIX1", "DD1 MIX" },
3273 { "Stereo1 ADC2 Mux", "DMIC", "Stereo1 DMIC Mux" },
3274 { "Stereo1 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
3275
3276 { "Stereo2 ADC1 Mux", "DD MIX1", "DD1 MIX" },
3277 { "Stereo2 ADC1 Mux", "ADC1/2", "ADC 1_2" },
3278 { "Stereo2 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
3279
3280 { "Stereo2 ADC2 Mux", "DD MIX1", "DD1 MIX" },
3281 { "Stereo2 ADC2 Mux", "DMIC", "Stereo2 DMIC Mux" },
3282 { "Stereo2 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
3283
3284 { "Stereo3 ADC1 Mux", "DD MIX1", "DD1 MIX" },
3285 { "Stereo3 ADC1 Mux", "ADC1/2", "ADC 1_2" },
3286 { "Stereo3 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
3287
3288 { "Stereo3 ADC2 Mux", "DD MIX1", "DD1 MIX" },
3289 { "Stereo3 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
3290 { "Stereo3 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
3291
3292 { "Stereo4 ADC1 Mux", "DD MIX1", "DD1 MIX" },
3293 { "Stereo4 ADC1 Mux", "ADC1/2", "ADC 1_2" },
3294 { "Stereo4 ADC1 Mux", "DD MIX2", "DD2 MIX" },
3295
3296 { "Stereo4 ADC2 Mux", "DD MIX1", "DD1 MIX" },
3297 { "Stereo4 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
3298 { "Stereo4 ADC2 Mux", "DD MIX2", "DD2 MIX" },
3299
3300 { "Mono ADC2 L Mux", "DD MIX1L", "DD1 MIXL" },
3301 { "Mono ADC2 L Mux", "DMIC", "Mono DMIC L Mux" },
3302 { "Mono ADC2 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3303
3304 { "Mono ADC1 L Mux", "DD MIX1L", "DD1 MIXL" },
3305 { "Mono ADC1 L Mux", "ADC1", "ADC 1" },
3306 { "Mono ADC1 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3307
3308 { "Mono ADC1 R Mux", "DD MIX1R", "DD1 MIXR" },
3309 { "Mono ADC1 R Mux", "ADC2", "ADC 2" },
3310 { "Mono ADC1 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3311
3312 { "Mono ADC2 R Mux", "DD MIX1R", "DD1 MIXR" },
3313 { "Mono ADC2 R Mux", "DMIC", "Mono DMIC R Mux" },
3314 { "Mono ADC2 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3315
3316 { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC1 Mux" },
3317 { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC2 Mux" },
3318 { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC1 Mux" },
3319 { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC2 Mux" },
3320
3321 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" },
3322 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003323 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" },
3324 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" },
3325 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
3326
3327 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" },
3328 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" },
3329
3330 { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC1 Mux" },
3331 { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC2 Mux" },
3332 { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC1 Mux" },
3333 { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC2 Mux" },
3334
3335 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" },
3336 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" },
3337
3338 { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" },
3339 { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" },
3340
3341 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" },
3342 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003343 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" },
3344 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" },
3345 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
3346
3347 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXL" },
3348 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR" },
3349
3350 { "Sto3 ADC MIXL", "ADC1 Switch", "Stereo3 ADC1 Mux" },
3351 { "Sto3 ADC MIXL", "ADC2 Switch", "Stereo3 ADC2 Mux" },
3352 { "Sto3 ADC MIXR", "ADC1 Switch", "Stereo3 ADC1 Mux" },
3353 { "Sto3 ADC MIXR", "ADC2 Switch", "Stereo3 ADC2 Mux" },
3354
3355 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" },
3356 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003357 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" },
3358 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" },
3359 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
3360
3361 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXL" },
3362 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXR" },
3363
3364 { "Sto4 ADC MIXL", "ADC1 Switch", "Stereo4 ADC1 Mux" },
3365 { "Sto4 ADC MIXL", "ADC2 Switch", "Stereo4 ADC2 Mux" },
3366 { "Sto4 ADC MIXR", "ADC1 Switch", "Stereo4 ADC1 Mux" },
3367 { "Sto4 ADC MIXR", "ADC2 Switch", "Stereo4 ADC2 Mux" },
3368
3369 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" },
3370 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003371 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" },
3372 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" },
3373 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
3374
3375 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXL" },
3376 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXR" },
3377
3378 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC1 L Mux" },
3379 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC2 L Mux" },
3380 { "Mono ADC MIXL", NULL, "adc mono left filter" },
3381 { "adc mono left filter", NULL, "PLL1", is_sys_clk_from_pll },
3382
3383 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC1 R Mux" },
3384 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC2 R Mux" },
3385 { "Mono ADC MIXR", NULL, "adc mono right filter" },
3386 { "adc mono right filter", NULL, "PLL1", is_sys_clk_from_pll },
3387
3388 { "Mono ADC MIX", NULL, "Mono ADC MIXL" },
3389 { "Mono ADC MIX", NULL, "Mono ADC MIXR" },
3390
3391 { "VAD ADC Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3392 { "VAD ADC Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
3393 { "VAD ADC Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
3394 { "VAD ADC Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3395 { "VAD ADC Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3396
3397 { "IF1 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3398 { "IF1 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3399 { "IF1 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3400
3401 { "IF1 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3402 { "IF1 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3403
3404 { "IF1 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3405 { "IF1 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3406 { "IF1 ADC3 Mux", "OB45", "OB45" },
3407
3408 { "IF1 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3409 { "IF1 ADC4 Mux", "OB67", "OB67" },
3410 { "IF1 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3411
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003412 { "IF1 ADC1 Swap Mux", "L/R", "IF1 ADC1 Mux" },
3413 { "IF1 ADC1 Swap Mux", "R/L", "IF1 ADC1 Mux" },
3414 { "IF1 ADC1 Swap Mux", "L/L", "IF1 ADC1 Mux" },
3415 { "IF1 ADC1 Swap Mux", "R/R", "IF1 ADC1 Mux" },
3416
3417 { "IF1 ADC2 Swap Mux", "L/R", "IF1 ADC2 Mux" },
3418 { "IF1 ADC2 Swap Mux", "R/L", "IF1 ADC2 Mux" },
3419 { "IF1 ADC2 Swap Mux", "L/L", "IF1 ADC2 Mux" },
3420 { "IF1 ADC2 Swap Mux", "R/R", "IF1 ADC2 Mux" },
3421
3422 { "IF1 ADC3 Swap Mux", "L/R", "IF1 ADC3 Mux" },
3423 { "IF1 ADC3 Swap Mux", "R/L", "IF1 ADC3 Mux" },
3424 { "IF1 ADC3 Swap Mux", "L/L", "IF1 ADC3 Mux" },
3425 { "IF1 ADC3 Swap Mux", "R/R", "IF1 ADC3 Mux" },
3426
3427 { "IF1 ADC4 Swap Mux", "L/R", "IF1 ADC4 Mux" },
3428 { "IF1 ADC4 Swap Mux", "R/L", "IF1 ADC4 Mux" },
3429 { "IF1 ADC4 Swap Mux", "L/L", "IF1 ADC4 Mux" },
3430 { "IF1 ADC4 Swap Mux", "R/R", "IF1 ADC4 Mux" },
3431
3432 { "IF1 ADC", NULL, "IF1 ADC1 Swap Mux" },
3433 { "IF1 ADC", NULL, "IF1 ADC2 Swap Mux" },
3434 { "IF1 ADC", NULL, "IF1 ADC3 Swap Mux" },
3435 { "IF1 ADC", NULL, "IF1 ADC4 Swap Mux" },
3436
3437 { "IF1 ADC TDM Swap Mux", "1/2/3/4", "IF1 ADC" },
3438 { "IF1 ADC TDM Swap Mux", "2/1/3/4", "IF1 ADC" },
3439 { "IF1 ADC TDM Swap Mux", "2/3/1/4", "IF1 ADC" },
3440 { "IF1 ADC TDM Swap Mux", "4/1/2/3", "IF1 ADC" },
3441 { "IF1 ADC TDM Swap Mux", "1/3/2/4", "IF1 ADC" },
3442 { "IF1 ADC TDM Swap Mux", "1/4/2/3", "IF1 ADC" },
3443 { "IF1 ADC TDM Swap Mux", "3/1/2/4", "IF1 ADC" },
3444 { "IF1 ADC TDM Swap Mux", "3/4/1/2", "IF1 ADC" },
3445
Oder Chiou0e826e82014-05-26 20:32:33 +08003446 { "AIF1TX", NULL, "I2S1" },
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003447 { "AIF1TX", NULL, "IF1 ADC TDM Swap Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003448
3449 { "IF2 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3450 { "IF2 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3451 { "IF2 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3452
3453 { "IF2 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3454 { "IF2 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3455
3456 { "IF2 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3457 { "IF2 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3458 { "IF2 ADC3 Mux", "OB45", "OB45" },
3459
3460 { "IF2 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3461 { "IF2 ADC4 Mux", "OB67", "OB67" },
3462 { "IF2 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3463
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003464 { "IF2 ADC1 Swap Mux", "L/R", "IF2 ADC1 Mux" },
3465 { "IF2 ADC1 Swap Mux", "R/L", "IF2 ADC1 Mux" },
3466 { "IF2 ADC1 Swap Mux", "L/L", "IF2 ADC1 Mux" },
3467 { "IF2 ADC1 Swap Mux", "R/R", "IF2 ADC1 Mux" },
3468
3469 { "IF2 ADC2 Swap Mux", "L/R", "IF2 ADC2 Mux" },
3470 { "IF2 ADC2 Swap Mux", "R/L", "IF2 ADC2 Mux" },
3471 { "IF2 ADC2 Swap Mux", "L/L", "IF2 ADC2 Mux" },
3472 { "IF2 ADC2 Swap Mux", "R/R", "IF2 ADC2 Mux" },
3473
3474 { "IF2 ADC3 Swap Mux", "L/R", "IF2 ADC3 Mux" },
3475 { "IF2 ADC3 Swap Mux", "R/L", "IF2 ADC3 Mux" },
3476 { "IF2 ADC3 Swap Mux", "L/L", "IF2 ADC3 Mux" },
3477 { "IF2 ADC3 Swap Mux", "R/R", "IF2 ADC3 Mux" },
3478
3479 { "IF2 ADC4 Swap Mux", "L/R", "IF2 ADC4 Mux" },
3480 { "IF2 ADC4 Swap Mux", "R/L", "IF2 ADC4 Mux" },
3481 { "IF2 ADC4 Swap Mux", "L/L", "IF2 ADC4 Mux" },
3482 { "IF2 ADC4 Swap Mux", "R/R", "IF2 ADC4 Mux" },
3483
3484 { "IF2 ADC", NULL, "IF2 ADC1 Swap Mux" },
3485 { "IF2 ADC", NULL, "IF2 ADC2 Swap Mux" },
3486 { "IF2 ADC", NULL, "IF2 ADC3 Swap Mux" },
3487 { "IF2 ADC", NULL, "IF2 ADC4 Swap Mux" },
3488
3489 { "IF2 ADC TDM Swap Mux", "1/2/3/4", "IF2 ADC" },
3490 { "IF2 ADC TDM Swap Mux", "2/1/3/4", "IF2 ADC" },
3491 { "IF2 ADC TDM Swap Mux", "3/1/2/4", "IF2 ADC" },
3492 { "IF2 ADC TDM Swap Mux", "4/1/2/3", "IF2 ADC" },
3493 { "IF2 ADC TDM Swap Mux", "1/3/2/4", "IF2 ADC" },
3494 { "IF2 ADC TDM Swap Mux", "1/4/2/3", "IF2 ADC" },
3495 { "IF2 ADC TDM Swap Mux", "2/3/1/4", "IF2 ADC" },
3496 { "IF2 ADC TDM Swap Mux", "3/4/1/2", "IF2 ADC" },
3497
Oder Chiou0e826e82014-05-26 20:32:33 +08003498 { "AIF2TX", NULL, "I2S2" },
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003499 { "AIF2TX", NULL, "IF2 ADC TDM Swap Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003500
3501 { "IF3 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3502 { "IF3 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3503 { "IF3 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3504 { "IF3 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3505 { "IF3 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
3506 { "IF3 ADC Mux", "OB01", "OB01 Bypass Mux" },
3507 { "IF3 ADC Mux", "OB23", "OB23 Bypass Mux" },
3508 { "IF3 ADC Mux", "VAD ADC", "VAD ADC Mux" },
3509
3510 { "AIF3TX", NULL, "I2S3" },
3511 { "AIF3TX", NULL, "IF3 ADC Mux" },
3512
3513 { "IF4 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3514 { "IF4 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3515 { "IF4 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3516 { "IF4 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3517 { "IF4 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
3518 { "IF4 ADC Mux", "OB01", "OB01 Bypass Mux" },
3519 { "IF4 ADC Mux", "OB23", "OB23 Bypass Mux" },
3520 { "IF4 ADC Mux", "VAD ADC", "VAD ADC Mux" },
3521
3522 { "AIF4TX", NULL, "I2S4" },
3523 { "AIF4TX", NULL, "IF4 ADC Mux" },
3524
3525 { "SLB ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3526 { "SLB ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3527 { "SLB ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3528
3529 { "SLB ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3530 { "SLB ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3531
3532 { "SLB ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3533 { "SLB ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3534 { "SLB ADC3 Mux", "OB45", "OB45" },
3535
3536 { "SLB ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3537 { "SLB ADC4 Mux", "OB67", "OB67" },
3538 { "SLB ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3539
3540 { "SLBTX", NULL, "SLB" },
3541 { "SLBTX", NULL, "SLB ADC1 Mux" },
3542 { "SLBTX", NULL, "SLB ADC2 Mux" },
3543 { "SLBTX", NULL, "SLB ADC3 Mux" },
3544 { "SLBTX", NULL, "SLB ADC4 Mux" },
3545
3546 { "IB01 Mux", "IF1 DAC 01", "IF1 DAC01" },
3547 { "IB01 Mux", "IF2 DAC 01", "IF2 DAC01" },
3548 { "IB01 Mux", "SLB DAC 01", "SLB DAC01" },
3549 { "IB01 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3550 { "IB01 Mux", "VAD ADC/DAC1 FS", "DAC1 FS" },
3551
3552 { "IB01 Bypass Mux", "Bypass", "IB01 Mux" },
3553 { "IB01 Bypass Mux", "Pass SRC", "IB01 Mux" },
3554
3555 { "IB23 Mux", "IF1 DAC 23", "IF1 DAC23" },
3556 { "IB23 Mux", "IF2 DAC 23", "IF2 DAC23" },
3557 { "IB23 Mux", "SLB DAC 23", "SLB DAC23" },
3558 { "IB23 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3559 { "IB23 Mux", "DAC1 FS", "DAC1 FS" },
3560 { "IB23 Mux", "IF4 DAC", "IF4 DAC" },
3561
3562 { "IB23 Bypass Mux", "Bypass", "IB23 Mux" },
3563 { "IB23 Bypass Mux", "Pass SRC", "IB23 Mux" },
3564
3565 { "IB45 Mux", "IF1 DAC 45", "IF1 DAC45" },
3566 { "IB45 Mux", "IF2 DAC 45", "IF2 DAC45" },
3567 { "IB45 Mux", "SLB DAC 45", "SLB DAC45" },
3568 { "IB45 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3569 { "IB45 Mux", "IF3 DAC", "IF3 DAC" },
3570
3571 { "IB45 Bypass Mux", "Bypass", "IB45 Mux" },
3572 { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" },
3573
Oder Chiou70068772015-02-25 17:36:13 +08003574 { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6 Mux" },
3575 { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003576 { "IB6 Mux", "SLB DAC 6", "SLB DAC6" },
3577 { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3578 { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" },
3579 { "IB6 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3580 { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3581 { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3582
Oder Chiou70068772015-02-25 17:36:13 +08003583 { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7 Mux" },
3584 { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003585 { "IB7 Mux", "SLB DAC 7", "SLB DAC7" },
3586 { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3587 { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" },
3588 { "IB7 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
3589 { "IB7 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
3590 { "IB7 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
3591
3592 { "IB8 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3593 { "IB8 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3594 { "IB8 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3595 { "IB8 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3596 { "IB8 Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
3597 { "IB8 Mux", "DACL1 FS", "DAC1 MIXL" },
3598
3599 { "IB9 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
3600 { "IB9 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
3601 { "IB9 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
3602 { "IB9 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3603 { "IB9 Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
3604 { "IB9 Mux", "DACR1 FS", "DAC1 MIXR" },
3605 { "IB9 Mux", "DAC1 FS", "DAC1 FS" },
3606
3607 { "OB01 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3608 { "OB01 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3609 { "OB01 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3610 { "OB01 MIX", "IB6 Switch", "IB6 Mux" },
3611 { "OB01 MIX", "IB7 Switch", "IB7 Mux" },
3612 { "OB01 MIX", "IB8 Switch", "IB8 Mux" },
3613 { "OB01 MIX", "IB9 Switch", "IB9 Mux" },
3614
3615 { "OB23 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3616 { "OB23 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3617 { "OB23 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3618 { "OB23 MIX", "IB6 Switch", "IB6 Mux" },
3619 { "OB23 MIX", "IB7 Switch", "IB7 Mux" },
3620 { "OB23 MIX", "IB8 Switch", "IB8 Mux" },
3621 { "OB23 MIX", "IB9 Switch", "IB9 Mux" },
3622
3623 { "OB4 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3624 { "OB4 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3625 { "OB4 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3626 { "OB4 MIX", "IB6 Switch", "IB6 Mux" },
3627 { "OB4 MIX", "IB7 Switch", "IB7 Mux" },
3628 { "OB4 MIX", "IB8 Switch", "IB8 Mux" },
3629 { "OB4 MIX", "IB9 Switch", "IB9 Mux" },
3630
3631 { "OB5 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3632 { "OB5 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3633 { "OB5 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3634 { "OB5 MIX", "IB6 Switch", "IB6 Mux" },
3635 { "OB5 MIX", "IB7 Switch", "IB7 Mux" },
3636 { "OB5 MIX", "IB8 Switch", "IB8 Mux" },
3637 { "OB5 MIX", "IB9 Switch", "IB9 Mux" },
3638
3639 { "OB6 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3640 { "OB6 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3641 { "OB6 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3642 { "OB6 MIX", "IB6 Switch", "IB6 Mux" },
3643 { "OB6 MIX", "IB7 Switch", "IB7 Mux" },
3644 { "OB6 MIX", "IB8 Switch", "IB8 Mux" },
3645 { "OB6 MIX", "IB9 Switch", "IB9 Mux" },
3646
3647 { "OB7 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3648 { "OB7 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3649 { "OB7 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3650 { "OB7 MIX", "IB6 Switch", "IB6 Mux" },
3651 { "OB7 MIX", "IB7 Switch", "IB7 Mux" },
3652 { "OB7 MIX", "IB8 Switch", "IB8 Mux" },
3653 { "OB7 MIX", "IB9 Switch", "IB9 Mux" },
3654
3655 { "OB01 Bypass Mux", "Bypass", "OB01 MIX" },
3656 { "OB01 Bypass Mux", "Pass SRC", "OB01 MIX" },
3657 { "OB23 Bypass Mux", "Bypass", "OB23 MIX" },
3658 { "OB23 Bypass Mux", "Pass SRC", "OB23 MIX" },
3659
3660 { "OutBound2", NULL, "OB23 Bypass Mux" },
3661 { "OutBound3", NULL, "OB23 Bypass Mux" },
3662 { "OutBound4", NULL, "OB4 MIX" },
3663 { "OutBound5", NULL, "OB5 MIX" },
3664 { "OutBound6", NULL, "OB6 MIX" },
3665 { "OutBound7", NULL, "OB7 MIX" },
3666
3667 { "OB45", NULL, "OutBound4" },
3668 { "OB45", NULL, "OutBound5" },
3669 { "OB67", NULL, "OutBound6" },
3670 { "OB67", NULL, "OutBound7" },
3671
3672 { "IF1 DAC0", NULL, "AIF1RX" },
3673 { "IF1 DAC1", NULL, "AIF1RX" },
3674 { "IF1 DAC2", NULL, "AIF1RX" },
3675 { "IF1 DAC3", NULL, "AIF1RX" },
3676 { "IF1 DAC4", NULL, "AIF1RX" },
3677 { "IF1 DAC5", NULL, "AIF1RX" },
3678 { "IF1 DAC6", NULL, "AIF1RX" },
3679 { "IF1 DAC7", NULL, "AIF1RX" },
3680 { "IF1 DAC0", NULL, "I2S1" },
3681 { "IF1 DAC1", NULL, "I2S1" },
3682 { "IF1 DAC2", NULL, "I2S1" },
3683 { "IF1 DAC3", NULL, "I2S1" },
3684 { "IF1 DAC4", NULL, "I2S1" },
3685 { "IF1 DAC5", NULL, "I2S1" },
3686 { "IF1 DAC6", NULL, "I2S1" },
3687 { "IF1 DAC7", NULL, "I2S1" },
3688
Oder Chiou91159ec2014-11-11 15:31:19 +08003689 { "IF1 DAC0 Mux", "Slot0", "IF1 DAC0" },
3690 { "IF1 DAC0 Mux", "Slot1", "IF1 DAC1" },
3691 { "IF1 DAC0 Mux", "Slot2", "IF1 DAC2" },
3692 { "IF1 DAC0 Mux", "Slot3", "IF1 DAC3" },
3693 { "IF1 DAC0 Mux", "Slot4", "IF1 DAC4" },
3694 { "IF1 DAC0 Mux", "Slot5", "IF1 DAC5" },
3695 { "IF1 DAC0 Mux", "Slot6", "IF1 DAC6" },
3696 { "IF1 DAC0 Mux", "Slot7", "IF1 DAC7" },
3697
3698 { "IF1 DAC1 Mux", "Slot0", "IF1 DAC0" },
3699 { "IF1 DAC1 Mux", "Slot1", "IF1 DAC1" },
3700 { "IF1 DAC1 Mux", "Slot2", "IF1 DAC2" },
3701 { "IF1 DAC1 Mux", "Slot3", "IF1 DAC3" },
3702 { "IF1 DAC1 Mux", "Slot4", "IF1 DAC4" },
3703 { "IF1 DAC1 Mux", "Slot5", "IF1 DAC5" },
3704 { "IF1 DAC1 Mux", "Slot6", "IF1 DAC6" },
3705 { "IF1 DAC1 Mux", "Slot7", "IF1 DAC7" },
3706
3707 { "IF1 DAC2 Mux", "Slot0", "IF1 DAC0" },
3708 { "IF1 DAC2 Mux", "Slot1", "IF1 DAC1" },
3709 { "IF1 DAC2 Mux", "Slot2", "IF1 DAC2" },
3710 { "IF1 DAC2 Mux", "Slot3", "IF1 DAC3" },
3711 { "IF1 DAC2 Mux", "Slot4", "IF1 DAC4" },
3712 { "IF1 DAC2 Mux", "Slot5", "IF1 DAC5" },
3713 { "IF1 DAC2 Mux", "Slot6", "IF1 DAC6" },
3714 { "IF1 DAC2 Mux", "Slot7", "IF1 DAC7" },
3715
3716 { "IF1 DAC3 Mux", "Slot0", "IF1 DAC0" },
3717 { "IF1 DAC3 Mux", "Slot1", "IF1 DAC1" },
3718 { "IF1 DAC3 Mux", "Slot2", "IF1 DAC2" },
3719 { "IF1 DAC3 Mux", "Slot3", "IF1 DAC3" },
3720 { "IF1 DAC3 Mux", "Slot4", "IF1 DAC4" },
3721 { "IF1 DAC3 Mux", "Slot5", "IF1 DAC5" },
3722 { "IF1 DAC3 Mux", "Slot6", "IF1 DAC6" },
3723 { "IF1 DAC3 Mux", "Slot7", "IF1 DAC7" },
3724
3725 { "IF1 DAC4 Mux", "Slot0", "IF1 DAC0" },
3726 { "IF1 DAC4 Mux", "Slot1", "IF1 DAC1" },
3727 { "IF1 DAC4 Mux", "Slot2", "IF1 DAC2" },
3728 { "IF1 DAC4 Mux", "Slot3", "IF1 DAC3" },
3729 { "IF1 DAC4 Mux", "Slot4", "IF1 DAC4" },
3730 { "IF1 DAC4 Mux", "Slot5", "IF1 DAC5" },
3731 { "IF1 DAC4 Mux", "Slot6", "IF1 DAC6" },
3732 { "IF1 DAC4 Mux", "Slot7", "IF1 DAC7" },
3733
3734 { "IF1 DAC5 Mux", "Slot0", "IF1 DAC0" },
3735 { "IF1 DAC5 Mux", "Slot1", "IF1 DAC1" },
3736 { "IF1 DAC5 Mux", "Slot2", "IF1 DAC2" },
3737 { "IF1 DAC5 Mux", "Slot3", "IF1 DAC3" },
3738 { "IF1 DAC5 Mux", "Slot4", "IF1 DAC4" },
3739 { "IF1 DAC5 Mux", "Slot5", "IF1 DAC5" },
3740 { "IF1 DAC5 Mux", "Slot6", "IF1 DAC6" },
3741 { "IF1 DAC5 Mux", "Slot7", "IF1 DAC7" },
3742
3743 { "IF1 DAC6 Mux", "Slot0", "IF1 DAC0" },
3744 { "IF1 DAC6 Mux", "Slot1", "IF1 DAC1" },
3745 { "IF1 DAC6 Mux", "Slot2", "IF1 DAC2" },
3746 { "IF1 DAC6 Mux", "Slot3", "IF1 DAC3" },
3747 { "IF1 DAC6 Mux", "Slot4", "IF1 DAC4" },
3748 { "IF1 DAC6 Mux", "Slot5", "IF1 DAC5" },
3749 { "IF1 DAC6 Mux", "Slot6", "IF1 DAC6" },
3750 { "IF1 DAC6 Mux", "Slot7", "IF1 DAC7" },
3751
3752 { "IF1 DAC7 Mux", "Slot0", "IF1 DAC0" },
3753 { "IF1 DAC7 Mux", "Slot1", "IF1 DAC1" },
3754 { "IF1 DAC7 Mux", "Slot2", "IF1 DAC2" },
3755 { "IF1 DAC7 Mux", "Slot3", "IF1 DAC3" },
3756 { "IF1 DAC7 Mux", "Slot4", "IF1 DAC4" },
3757 { "IF1 DAC7 Mux", "Slot5", "IF1 DAC5" },
3758 { "IF1 DAC7 Mux", "Slot6", "IF1 DAC6" },
3759 { "IF1 DAC7 Mux", "Slot7", "IF1 DAC7" },
3760
3761 { "IF1 DAC01", NULL, "IF1 DAC0 Mux" },
3762 { "IF1 DAC01", NULL, "IF1 DAC1 Mux" },
3763 { "IF1 DAC23", NULL, "IF1 DAC2 Mux" },
3764 { "IF1 DAC23", NULL, "IF1 DAC3 Mux" },
3765 { "IF1 DAC45", NULL, "IF1 DAC4 Mux" },
3766 { "IF1 DAC45", NULL, "IF1 DAC5 Mux" },
3767 { "IF1 DAC67", NULL, "IF1 DAC6 Mux" },
3768 { "IF1 DAC67", NULL, "IF1 DAC7 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003769
3770 { "IF2 DAC0", NULL, "AIF2RX" },
3771 { "IF2 DAC1", NULL, "AIF2RX" },
3772 { "IF2 DAC2", NULL, "AIF2RX" },
3773 { "IF2 DAC3", NULL, "AIF2RX" },
3774 { "IF2 DAC4", NULL, "AIF2RX" },
3775 { "IF2 DAC5", NULL, "AIF2RX" },
3776 { "IF2 DAC6", NULL, "AIF2RX" },
3777 { "IF2 DAC7", NULL, "AIF2RX" },
3778 { "IF2 DAC0", NULL, "I2S2" },
3779 { "IF2 DAC1", NULL, "I2S2" },
3780 { "IF2 DAC2", NULL, "I2S2" },
3781 { "IF2 DAC3", NULL, "I2S2" },
3782 { "IF2 DAC4", NULL, "I2S2" },
3783 { "IF2 DAC5", NULL, "I2S2" },
3784 { "IF2 DAC6", NULL, "I2S2" },
3785 { "IF2 DAC7", NULL, "I2S2" },
3786
Oder Chiou91159ec2014-11-11 15:31:19 +08003787 { "IF2 DAC0 Mux", "Slot0", "IF2 DAC0" },
3788 { "IF2 DAC0 Mux", "Slot1", "IF2 DAC1" },
3789 { "IF2 DAC0 Mux", "Slot2", "IF2 DAC2" },
3790 { "IF2 DAC0 Mux", "Slot3", "IF2 DAC3" },
3791 { "IF2 DAC0 Mux", "Slot4", "IF2 DAC4" },
3792 { "IF2 DAC0 Mux", "Slot5", "IF2 DAC5" },
3793 { "IF2 DAC0 Mux", "Slot6", "IF2 DAC6" },
3794 { "IF2 DAC0 Mux", "Slot7", "IF2 DAC7" },
3795
3796 { "IF2 DAC1 Mux", "Slot0", "IF2 DAC0" },
3797 { "IF2 DAC1 Mux", "Slot1", "IF2 DAC1" },
3798 { "IF2 DAC1 Mux", "Slot2", "IF2 DAC2" },
3799 { "IF2 DAC1 Mux", "Slot3", "IF2 DAC3" },
3800 { "IF2 DAC1 Mux", "Slot4", "IF2 DAC4" },
3801 { "IF2 DAC1 Mux", "Slot5", "IF2 DAC5" },
3802 { "IF2 DAC1 Mux", "Slot6", "IF2 DAC6" },
3803 { "IF2 DAC1 Mux", "Slot7", "IF2 DAC7" },
3804
3805 { "IF2 DAC2 Mux", "Slot0", "IF2 DAC0" },
3806 { "IF2 DAC2 Mux", "Slot1", "IF2 DAC1" },
3807 { "IF2 DAC2 Mux", "Slot2", "IF2 DAC2" },
3808 { "IF2 DAC2 Mux", "Slot3", "IF2 DAC3" },
3809 { "IF2 DAC2 Mux", "Slot4", "IF2 DAC4" },
3810 { "IF2 DAC2 Mux", "Slot5", "IF2 DAC5" },
3811 { "IF2 DAC2 Mux", "Slot6", "IF2 DAC6" },
3812 { "IF2 DAC2 Mux", "Slot7", "IF2 DAC7" },
3813
3814 { "IF2 DAC3 Mux", "Slot0", "IF2 DAC0" },
3815 { "IF2 DAC3 Mux", "Slot1", "IF2 DAC1" },
3816 { "IF2 DAC3 Mux", "Slot2", "IF2 DAC2" },
3817 { "IF2 DAC3 Mux", "Slot3", "IF2 DAC3" },
3818 { "IF2 DAC3 Mux", "Slot4", "IF2 DAC4" },
3819 { "IF2 DAC3 Mux", "Slot5", "IF2 DAC5" },
3820 { "IF2 DAC3 Mux", "Slot6", "IF2 DAC6" },
3821 { "IF2 DAC3 Mux", "Slot7", "IF2 DAC7" },
3822
3823 { "IF2 DAC4 Mux", "Slot0", "IF2 DAC0" },
3824 { "IF2 DAC4 Mux", "Slot1", "IF2 DAC1" },
3825 { "IF2 DAC4 Mux", "Slot2", "IF2 DAC2" },
3826 { "IF2 DAC4 Mux", "Slot3", "IF2 DAC3" },
3827 { "IF2 DAC4 Mux", "Slot4", "IF2 DAC4" },
3828 { "IF2 DAC4 Mux", "Slot5", "IF2 DAC5" },
3829 { "IF2 DAC4 Mux", "Slot6", "IF2 DAC6" },
3830 { "IF2 DAC4 Mux", "Slot7", "IF2 DAC7" },
3831
3832 { "IF2 DAC5 Mux", "Slot0", "IF2 DAC0" },
3833 { "IF2 DAC5 Mux", "Slot1", "IF2 DAC1" },
3834 { "IF2 DAC5 Mux", "Slot2", "IF2 DAC2" },
3835 { "IF2 DAC5 Mux", "Slot3", "IF2 DAC3" },
3836 { "IF2 DAC5 Mux", "Slot4", "IF2 DAC4" },
3837 { "IF2 DAC5 Mux", "Slot5", "IF2 DAC5" },
3838 { "IF2 DAC5 Mux", "Slot6", "IF2 DAC6" },
3839 { "IF2 DAC5 Mux", "Slot7", "IF2 DAC7" },
3840
3841 { "IF2 DAC6 Mux", "Slot0", "IF2 DAC0" },
3842 { "IF2 DAC6 Mux", "Slot1", "IF2 DAC1" },
3843 { "IF2 DAC6 Mux", "Slot2", "IF2 DAC2" },
3844 { "IF2 DAC6 Mux", "Slot3", "IF2 DAC3" },
3845 { "IF2 DAC6 Mux", "Slot4", "IF2 DAC4" },
3846 { "IF2 DAC6 Mux", "Slot5", "IF2 DAC5" },
3847 { "IF2 DAC6 Mux", "Slot6", "IF2 DAC6" },
3848 { "IF2 DAC6 Mux", "Slot7", "IF2 DAC7" },
3849
3850 { "IF2 DAC7 Mux", "Slot0", "IF2 DAC0" },
3851 { "IF2 DAC7 Mux", "Slot1", "IF2 DAC1" },
3852 { "IF2 DAC7 Mux", "Slot2", "IF2 DAC2" },
3853 { "IF2 DAC7 Mux", "Slot3", "IF2 DAC3" },
3854 { "IF2 DAC7 Mux", "Slot4", "IF2 DAC4" },
3855 { "IF2 DAC7 Mux", "Slot5", "IF2 DAC5" },
3856 { "IF2 DAC7 Mux", "Slot6", "IF2 DAC6" },
3857 { "IF2 DAC7 Mux", "Slot7", "IF2 DAC7" },
3858
3859 { "IF2 DAC01", NULL, "IF2 DAC0 Mux" },
3860 { "IF2 DAC01", NULL, "IF2 DAC1 Mux" },
3861 { "IF2 DAC23", NULL, "IF2 DAC2 Mux" },
3862 { "IF2 DAC23", NULL, "IF2 DAC3 Mux" },
3863 { "IF2 DAC45", NULL, "IF2 DAC4 Mux" },
3864 { "IF2 DAC45", NULL, "IF2 DAC5 Mux" },
3865 { "IF2 DAC67", NULL, "IF2 DAC6 Mux" },
3866 { "IF2 DAC67", NULL, "IF2 DAC7 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003867
3868 { "IF3 DAC", NULL, "AIF3RX" },
3869 { "IF3 DAC", NULL, "I2S3" },
3870
3871 { "IF4 DAC", NULL, "AIF4RX" },
3872 { "IF4 DAC", NULL, "I2S4" },
3873
3874 { "IF3 DAC L", NULL, "IF3 DAC" },
3875 { "IF3 DAC R", NULL, "IF3 DAC" },
3876
3877 { "IF4 DAC L", NULL, "IF4 DAC" },
3878 { "IF4 DAC R", NULL, "IF4 DAC" },
3879
3880 { "SLB DAC0", NULL, "SLBRX" },
3881 { "SLB DAC1", NULL, "SLBRX" },
3882 { "SLB DAC2", NULL, "SLBRX" },
3883 { "SLB DAC3", NULL, "SLBRX" },
3884 { "SLB DAC4", NULL, "SLBRX" },
3885 { "SLB DAC5", NULL, "SLBRX" },
3886 { "SLB DAC6", NULL, "SLBRX" },
3887 { "SLB DAC7", NULL, "SLBRX" },
3888 { "SLB DAC0", NULL, "SLB" },
3889 { "SLB DAC1", NULL, "SLB" },
3890 { "SLB DAC2", NULL, "SLB" },
3891 { "SLB DAC3", NULL, "SLB" },
3892 { "SLB DAC4", NULL, "SLB" },
3893 { "SLB DAC5", NULL, "SLB" },
3894 { "SLB DAC6", NULL, "SLB" },
3895 { "SLB DAC7", NULL, "SLB" },
3896
3897 { "SLB DAC01", NULL, "SLB DAC0" },
3898 { "SLB DAC01", NULL, "SLB DAC1" },
3899 { "SLB DAC23", NULL, "SLB DAC2" },
3900 { "SLB DAC23", NULL, "SLB DAC3" },
3901 { "SLB DAC45", NULL, "SLB DAC4" },
3902 { "SLB DAC45", NULL, "SLB DAC5" },
3903 { "SLB DAC67", NULL, "SLB DAC6" },
3904 { "SLB DAC67", NULL, "SLB DAC7" },
3905
3906 { "ADDA1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3907 { "ADDA1 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3908 { "ADDA1 Mux", "OB 67", "OB67" },
3909
3910 { "DAC1 Mux", "IF1 DAC 01", "IF1 DAC01" },
3911 { "DAC1 Mux", "IF2 DAC 01", "IF2 DAC01" },
3912 { "DAC1 Mux", "IF3 DAC LR", "IF3 DAC" },
3913 { "DAC1 Mux", "IF4 DAC LR", "IF4 DAC" },
3914 { "DAC1 Mux", "SLB DAC 01", "SLB DAC01" },
3915 { "DAC1 Mux", "OB 01", "OB01 Bypass Mux" },
3916
3917 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" },
3918 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003919 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" },
3920 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003921
3922 { "DAC1 FS", NULL, "DAC1 MIXL" },
3923 { "DAC1 FS", NULL, "DAC1 MIXR" },
3924
Oder Chiou70068772015-02-25 17:36:13 +08003925 { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2 Mux" },
3926 { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003927 { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" },
3928 { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" },
3929 { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" },
3930 { "DAC2 L Mux", "OB 2", "OutBound2" },
3931
Oder Chiou70068772015-02-25 17:36:13 +08003932 { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3 Mux" },
3933 { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003934 { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" },
3935 { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" },
3936 { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" },
3937 { "DAC2 R Mux", "OB 3", "OutBound3" },
3938 { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" },
3939 { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" },
3940
Oder Chiou70068772015-02-25 17:36:13 +08003941 { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4 Mux" },
3942 { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003943 { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" },
3944 { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" },
3945 { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" },
3946 { "DAC3 L Mux", "OB 4", "OutBound4" },
3947
Oder Chiou70068772015-02-25 17:36:13 +08003948 { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC5 Mux" },
3949 { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC5 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003950 { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" },
3951 { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" },
3952 { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" },
3953 { "DAC3 R Mux", "OB 5", "OutBound5" },
3954
Oder Chiou70068772015-02-25 17:36:13 +08003955 { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6 Mux" },
3956 { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003957 { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" },
3958 { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" },
3959 { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" },
3960 { "DAC4 L Mux", "OB 6", "OutBound6" },
3961
Oder Chiou70068772015-02-25 17:36:13 +08003962 { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7 Mux" },
3963 { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003964 { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" },
3965 { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" },
3966 { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" },
3967 { "DAC4 R Mux", "OB 7", "OutBound7" },
3968
3969 { "Sidetone Mux", "DMIC1 L", "DMIC L1" },
3970 { "Sidetone Mux", "DMIC2 L", "DMIC L2" },
3971 { "Sidetone Mux", "DMIC3 L", "DMIC L3" },
3972 { "Sidetone Mux", "DMIC4 L", "DMIC L4" },
3973 { "Sidetone Mux", "ADC1", "ADC 1" },
3974 { "Sidetone Mux", "ADC2", "ADC 2" },
Oder Chiou90bdbb42014-09-18 14:45:59 +08003975 { "Sidetone Mux", NULL, "Sidetone Power" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003976
3977 { "Stereo DAC MIXL", "ST L Switch", "Sidetone Mux" },
3978 { "Stereo DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3979 { "Stereo DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3980 { "Stereo DAC MIXL", "DAC1 R Switch", "DAC1 MIXR" },
3981 { "Stereo DAC MIXL", NULL, "dac stereo1 filter" },
3982 { "Stereo DAC MIXR", "ST R Switch", "Sidetone Mux" },
3983 { "Stereo DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3984 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3985 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" },
3986 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003987 { "dac stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003988
3989 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" },
3990 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3991 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3992 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003993 { "Mono DAC MIXL", NULL, "dac mono2 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003994 { "dac mono2 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003995 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" },
3996 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3997 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3998 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003999 { "Mono DAC MIXR", NULL, "dac mono2 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08004000 { "dac mono2 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08004001
4002 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
4003 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
4004 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" },
4005 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08004006 { "DD1 MIXL", NULL, "dac mono3 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08004007 { "dac mono3 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08004008 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
4009 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
4010 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" },
4011 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08004012 { "DD1 MIXR", NULL, "dac mono3 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08004013 { "dac mono3 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08004014
4015 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
4016 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
4017 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" },
4018 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08004019 { "DD2 MIXL", NULL, "dac mono4 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08004020 { "dac mono4 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08004021 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
4022 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
4023 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" },
4024 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08004025 { "DD2 MIXR", NULL, "dac mono4 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08004026 { "dac mono4 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08004027
4028 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" },
4029 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" },
4030 { "Mono DAC MIX", NULL, "Mono DAC MIXL" },
4031 { "Mono DAC MIX", NULL, "Mono DAC MIXR" },
4032 { "DD1 MIX", NULL, "DD1 MIXL" },
4033 { "DD1 MIX", NULL, "DD1 MIXR" },
4034 { "DD2 MIX", NULL, "DD2 MIXL" },
4035 { "DD2 MIX", NULL, "DD2 MIXR" },
4036
4037 { "DAC12 SRC Mux", "STO1 DAC MIX", "Stereo DAC MIX" },
4038 { "DAC12 SRC Mux", "MONO DAC MIX", "Mono DAC MIX" },
4039 { "DAC12 SRC Mux", "DD MIX1", "DD1 MIX" },
4040 { "DAC12 SRC Mux", "DD MIX2", "DD2 MIX" },
4041
4042 { "DAC3 SRC Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
4043 { "DAC3 SRC Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
4044 { "DAC3 SRC Mux", "DD MIX1L", "DD1 MIXL" },
4045 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" },
4046
4047 { "DAC 1", NULL, "DAC12 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08004048 { "DAC 2", NULL, "DAC12 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08004049 { "DAC 3", NULL, "DAC3 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08004050
4051 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
4052 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
4053 { "PDM1 L Mux", "DD MIX1", "DD1 MIXL" },
4054 { "PDM1 L Mux", "DD MIX2", "DD2 MIXL" },
4055 { "PDM1 L Mux", NULL, "PDM1 Power" },
4056 { "PDM1 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
4057 { "PDM1 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
4058 { "PDM1 R Mux", "DD MIX1", "DD1 MIXR" },
4059 { "PDM1 R Mux", "DD MIX2", "DD2 MIXR" },
4060 { "PDM1 R Mux", NULL, "PDM1 Power" },
4061 { "PDM2 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
4062 { "PDM2 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
4063 { "PDM2 L Mux", "DD MIX1", "DD1 MIXL" },
4064 { "PDM2 L Mux", "DD MIX2", "DD2 MIXL" },
4065 { "PDM2 L Mux", NULL, "PDM2 Power" },
4066 { "PDM2 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
4067 { "PDM2 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
4068 { "PDM2 R Mux", "DD MIX1", "DD1 MIXR" },
4069 { "PDM2 R Mux", "DD MIX1", "DD2 MIXR" },
4070 { "PDM2 R Mux", NULL, "PDM2 Power" },
4071
4072 { "LOUT1 amp", NULL, "DAC 1" },
4073 { "LOUT2 amp", NULL, "DAC 2" },
4074 { "LOUT3 amp", NULL, "DAC 3" },
4075
Oder Chiou683996c2014-11-19 13:52:20 +08004076 { "LOUT1 vref", NULL, "LOUT1 amp" },
4077 { "LOUT2 vref", NULL, "LOUT2 amp" },
4078 { "LOUT3 vref", NULL, "LOUT3 amp" },
4079
4080 { "LOUT1", NULL, "LOUT1 vref" },
4081 { "LOUT2", NULL, "LOUT2 vref" },
4082 { "LOUT3", NULL, "LOUT3 vref" },
Oder Chiou0e826e82014-05-26 20:32:33 +08004083
4084 { "PDM1L", NULL, "PDM1 L Mux" },
4085 { "PDM1R", NULL, "PDM1 R Mux" },
4086 { "PDM2L", NULL, "PDM2 L Mux" },
4087 { "PDM2R", NULL, "PDM2 R Mux" },
4088};
4089
Bard Liao2d15d972014-08-27 19:50:34 +08004090static const struct snd_soc_dapm_route rt5677_dmic2_clk_1[] = {
4091 { "DMIC L2", NULL, "DMIC1 power" },
4092 { "DMIC R2", NULL, "DMIC1 power" },
4093};
4094
4095static const struct snd_soc_dapm_route rt5677_dmic2_clk_2[] = {
4096 { "DMIC L2", NULL, "DMIC2 power" },
4097 { "DMIC R2", NULL, "DMIC2 power" },
4098};
4099
Oder Chiou0e826e82014-05-26 20:32:33 +08004100static int rt5677_hw_params(struct snd_pcm_substream *substream,
4101 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
4102{
4103 struct snd_soc_codec *codec = dai->codec;
4104 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4105 unsigned int val_len = 0, val_clk, mask_clk;
4106 int pre_div, bclk_ms, frame_size;
4107
4108 rt5677->lrck[dai->id] = params_rate(params);
Axel Lin30f14b42014-06-10 08:57:36 +08004109 pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]);
Oder Chiou0e826e82014-05-26 20:32:33 +08004110 if (pre_div < 0) {
Anatol Pomozov8a4bd602014-10-15 13:55:32 -07004111 dev_err(codec->dev, "Unsupported clock setting: sysclk=%dHz lrck=%dHz\n",
4112 rt5677->sysclk, rt5677->lrck[dai->id]);
Oder Chiou0e826e82014-05-26 20:32:33 +08004113 return -EINVAL;
4114 }
4115 frame_size = snd_soc_params_to_frame_size(params);
4116 if (frame_size < 0) {
4117 dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
4118 return -EINVAL;
4119 }
4120 bclk_ms = frame_size > 32;
4121 rt5677->bclk[dai->id] = rt5677->lrck[dai->id] * (32 << bclk_ms);
4122
4123 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n",
4124 rt5677->bclk[dai->id], rt5677->lrck[dai->id]);
4125 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n",
4126 bclk_ms, pre_div, dai->id);
4127
4128 switch (params_width(params)) {
4129 case 16:
4130 break;
4131 case 20:
4132 val_len |= RT5677_I2S_DL_20;
4133 break;
4134 case 24:
4135 val_len |= RT5677_I2S_DL_24;
4136 break;
4137 case 8:
4138 val_len |= RT5677_I2S_DL_8;
4139 break;
4140 default:
4141 return -EINVAL;
4142 }
4143
4144 switch (dai->id) {
4145 case RT5677_AIF1:
4146 mask_clk = RT5677_I2S_PD1_MASK;
4147 val_clk = pre_div << RT5677_I2S_PD1_SFT;
4148 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
4149 RT5677_I2S_DL_MASK, val_len);
4150 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
4151 mask_clk, val_clk);
4152 break;
4153 case RT5677_AIF2:
4154 mask_clk = RT5677_I2S_PD2_MASK;
4155 val_clk = pre_div << RT5677_I2S_PD2_SFT;
4156 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
4157 RT5677_I2S_DL_MASK, val_len);
4158 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
4159 mask_clk, val_clk);
4160 break;
4161 case RT5677_AIF3:
4162 mask_clk = RT5677_I2S_BCLK_MS3_MASK | RT5677_I2S_PD3_MASK;
4163 val_clk = bclk_ms << RT5677_I2S_BCLK_MS3_SFT |
4164 pre_div << RT5677_I2S_PD3_SFT;
4165 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
4166 RT5677_I2S_DL_MASK, val_len);
4167 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
4168 mask_clk, val_clk);
4169 break;
4170 case RT5677_AIF4:
4171 mask_clk = RT5677_I2S_BCLK_MS4_MASK | RT5677_I2S_PD4_MASK;
4172 val_clk = bclk_ms << RT5677_I2S_BCLK_MS4_SFT |
4173 pre_div << RT5677_I2S_PD4_SFT;
4174 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
4175 RT5677_I2S_DL_MASK, val_len);
4176 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
4177 mask_clk, val_clk);
4178 break;
4179 default:
4180 break;
4181 }
4182
4183 return 0;
4184}
4185
4186static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
4187{
4188 struct snd_soc_codec *codec = dai->codec;
4189 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4190 unsigned int reg_val = 0;
4191
4192 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
4193 case SND_SOC_DAIFMT_CBM_CFM:
4194 rt5677->master[dai->id] = 1;
4195 break;
4196 case SND_SOC_DAIFMT_CBS_CFS:
4197 reg_val |= RT5677_I2S_MS_S;
4198 rt5677->master[dai->id] = 0;
4199 break;
4200 default:
4201 return -EINVAL;
4202 }
4203
4204 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
4205 case SND_SOC_DAIFMT_NB_NF:
4206 break;
4207 case SND_SOC_DAIFMT_IB_NF:
4208 reg_val |= RT5677_I2S_BP_INV;
4209 break;
4210 default:
4211 return -EINVAL;
4212 }
4213
4214 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
4215 case SND_SOC_DAIFMT_I2S:
4216 break;
4217 case SND_SOC_DAIFMT_LEFT_J:
4218 reg_val |= RT5677_I2S_DF_LEFT;
4219 break;
4220 case SND_SOC_DAIFMT_DSP_A:
4221 reg_val |= RT5677_I2S_DF_PCM_A;
4222 break;
4223 case SND_SOC_DAIFMT_DSP_B:
4224 reg_val |= RT5677_I2S_DF_PCM_B;
4225 break;
4226 default:
4227 return -EINVAL;
4228 }
4229
4230 switch (dai->id) {
4231 case RT5677_AIF1:
4232 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
4233 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
4234 RT5677_I2S_DF_MASK, reg_val);
4235 break;
4236 case RT5677_AIF2:
4237 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
4238 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
4239 RT5677_I2S_DF_MASK, reg_val);
4240 break;
4241 case RT5677_AIF3:
4242 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
4243 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
4244 RT5677_I2S_DF_MASK, reg_val);
4245 break;
4246 case RT5677_AIF4:
4247 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
4248 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
4249 RT5677_I2S_DF_MASK, reg_val);
4250 break;
4251 default:
4252 break;
4253 }
4254
4255
4256 return 0;
4257}
4258
4259static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai,
4260 int clk_id, unsigned int freq, int dir)
4261{
4262 struct snd_soc_codec *codec = dai->codec;
4263 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4264 unsigned int reg_val = 0;
4265
4266 if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src)
4267 return 0;
4268
4269 switch (clk_id) {
4270 case RT5677_SCLK_S_MCLK:
4271 reg_val |= RT5677_SCLK_SRC_MCLK;
4272 break;
4273 case RT5677_SCLK_S_PLL1:
4274 reg_val |= RT5677_SCLK_SRC_PLL1;
4275 break;
4276 case RT5677_SCLK_S_RCCLK:
4277 reg_val |= RT5677_SCLK_SRC_RCCLK;
4278 break;
4279 default:
4280 dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
4281 return -EINVAL;
4282 }
4283 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4284 RT5677_SCLK_SRC_MASK, reg_val);
4285 rt5677->sysclk = freq;
4286 rt5677->sysclk_src = clk_id;
4287
4288 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id);
4289
4290 return 0;
4291}
4292
4293/**
4294 * rt5677_pll_calc - Calcualte PLL M/N/K code.
4295 * @freq_in: external clock provided to codec.
4296 * @freq_out: target clock which codec works on.
4297 * @pll_code: Pointer to structure with M, N, K, bypass K and bypass M flag.
4298 *
4299 * Calcualte M/N/K code and bypass K/M flag to configure PLL for codec.
4300 *
4301 * Returns 0 for success or negative error code.
4302 */
4303static int rt5677_pll_calc(const unsigned int freq_in,
Axel Lin099d3342014-06-17 12:41:31 +08004304 const unsigned int freq_out, struct rl6231_pll_code *pll_code)
Oder Chiou0e826e82014-05-26 20:32:33 +08004305{
Axel Lin099d3342014-06-17 12:41:31 +08004306 if (RT5677_PLL_INP_MIN > freq_in)
Oder Chiou0e826e82014-05-26 20:32:33 +08004307 return -EINVAL;
4308
Axel Lin099d3342014-06-17 12:41:31 +08004309 return rl6231_pll_calc(freq_in, freq_out, pll_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004310}
4311
4312static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
4313 unsigned int freq_in, unsigned int freq_out)
4314{
4315 struct snd_soc_codec *codec = dai->codec;
4316 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Axel Lin099d3342014-06-17 12:41:31 +08004317 struct rl6231_pll_code pll_code;
Oder Chiou0e826e82014-05-26 20:32:33 +08004318 int ret;
4319
4320 if (source == rt5677->pll_src && freq_in == rt5677->pll_in &&
4321 freq_out == rt5677->pll_out)
4322 return 0;
4323
4324 if (!freq_in || !freq_out) {
4325 dev_dbg(codec->dev, "PLL disabled\n");
4326
4327 rt5677->pll_in = 0;
4328 rt5677->pll_out = 0;
4329 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4330 RT5677_SCLK_SRC_MASK, RT5677_SCLK_SRC_MCLK);
4331 return 0;
4332 }
4333
4334 switch (source) {
4335 case RT5677_PLL1_S_MCLK:
4336 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4337 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_MCLK);
4338 break;
4339 case RT5677_PLL1_S_BCLK1:
4340 case RT5677_PLL1_S_BCLK2:
4341 case RT5677_PLL1_S_BCLK3:
4342 case RT5677_PLL1_S_BCLK4:
4343 switch (dai->id) {
4344 case RT5677_AIF1:
4345 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4346 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK1);
4347 break;
4348 case RT5677_AIF2:
4349 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4350 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK2);
4351 break;
4352 case RT5677_AIF3:
4353 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4354 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK3);
4355 break;
4356 case RT5677_AIF4:
4357 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4358 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK4);
4359 break;
4360 default:
4361 break;
4362 }
4363 break;
4364 default:
4365 dev_err(codec->dev, "Unknown PLL source %d\n", source);
4366 return -EINVAL;
4367 }
4368
4369 ret = rt5677_pll_calc(freq_in, freq_out, &pll_code);
4370 if (ret < 0) {
4371 dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
4372 return ret;
4373 }
4374
Axel Lin099d3342014-06-17 12:41:31 +08004375 dev_dbg(codec->dev, "m_bypass=%d m=%d n=%d k=%d\n",
4376 pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
4377 pll_code.n_code, pll_code.k_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004378
4379 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1,
Axel Lin099d3342014-06-17 12:41:31 +08004380 pll_code.n_code << RT5677_PLL_N_SFT | pll_code.k_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004381 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2,
4382 (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT |
4383 pll_code.m_bp << RT5677_PLL_M_BP_SFT);
4384
4385 rt5677->pll_in = freq_in;
4386 rt5677->pll_out = freq_out;
4387 rt5677->pll_src = source;
4388
4389 return 0;
4390}
4391
Oder Chiou48561af2014-09-17 15:12:33 +08004392static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
4393 unsigned int rx_mask, int slots, int slot_width)
4394{
4395 struct snd_soc_codec *codec = dai->codec;
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004396 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou9913b9f2015-01-13 11:13:15 +08004397 unsigned int val = 0, slot_width_25 = 0;
Oder Chiou48561af2014-09-17 15:12:33 +08004398
4399 if (rx_mask || tx_mask)
4400 val |= (1 << 12);
4401
4402 switch (slots) {
4403 case 4:
4404 val |= (1 << 10);
4405 break;
4406 case 6:
4407 val |= (2 << 10);
4408 break;
4409 case 8:
4410 val |= (3 << 10);
4411 break;
4412 case 2:
4413 default:
4414 break;
4415 }
4416
4417 switch (slot_width) {
4418 case 20:
4419 val |= (1 << 8);
4420 break;
Oder Chiou9913b9f2015-01-13 11:13:15 +08004421 case 25:
4422 slot_width_25 = 0x8080;
Oder Chiou48561af2014-09-17 15:12:33 +08004423 case 24:
4424 val |= (2 << 8);
4425 break;
4426 case 32:
4427 val |= (3 << 8);
4428 break;
4429 case 16:
4430 default:
4431 break;
4432 }
4433
4434 switch (dai->id) {
4435 case RT5677_AIF1:
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004436 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00,
4437 val);
Oder Chiou9913b9f2015-01-13 11:13:15 +08004438 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x8000,
4439 slot_width_25);
Oder Chiou48561af2014-09-17 15:12:33 +08004440 break;
4441 case RT5677_AIF2:
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004442 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00,
4443 val);
Oder Chiou9913b9f2015-01-13 11:13:15 +08004444 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x80,
4445 slot_width_25);
Oder Chiou48561af2014-09-17 15:12:33 +08004446 break;
4447 default:
4448 break;
4449 }
4450
4451 return 0;
4452}
4453
Oder Chiou0e826e82014-05-26 20:32:33 +08004454static int rt5677_set_bias_level(struct snd_soc_codec *codec,
4455 enum snd_soc_bias_level level)
4456{
4457 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4458
4459 switch (level) {
4460 case SND_SOC_BIAS_ON:
4461 break;
4462
4463 case SND_SOC_BIAS_PREPARE:
Lars-Peter Clausen6b43c2e2015-05-19 21:49:11 +02004464 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) {
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004465 rt5677_set_dsp_vad(codec, false);
4466
Oder Chiou0e826e82014-05-26 20:32:33 +08004467 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
4468 RT5677_LDO1_SEL_MASK | RT5677_LDO2_SEL_MASK,
4469 0x0055);
4470 regmap_update_bits(rt5677->regmap,
4471 RT5677_PR_BASE + RT5677_BIAS_CUR4,
4472 0x0f00, 0x0f00);
4473 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
Oder Chiou683996c2014-11-19 13:52:20 +08004474 RT5677_PWR_FV1 | RT5677_PWR_FV2 |
Oder Chiou0e826e82014-05-26 20:32:33 +08004475 RT5677_PWR_VREF1 | RT5677_PWR_MB |
4476 RT5677_PWR_BG | RT5677_PWR_VREF2,
4477 RT5677_PWR_VREF1 | RT5677_PWR_MB |
4478 RT5677_PWR_BG | RT5677_PWR_VREF2);
Oder Chiou683996c2014-11-19 13:52:20 +08004479 rt5677->is_vref_slow = false;
Oder Chiou0e826e82014-05-26 20:32:33 +08004480 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
4481 RT5677_PWR_CORE, RT5677_PWR_CORE);
4482 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC,
4483 0x1, 0x1);
4484 }
4485 break;
4486
4487 case SND_SOC_BIAS_STANDBY:
4488 break;
4489
4490 case SND_SOC_BIAS_OFF:
4491 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0);
4492 regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000);
4493 regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000);
Oder Chiouf18803a2014-07-07 15:37:00 +08004494 regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0022);
Oder Chiou0e826e82014-05-26 20:32:33 +08004495 regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000);
4496 regmap_update_bits(rt5677->regmap,
4497 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000);
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004498
4499 if (rt5677->dsp_vad_en)
4500 rt5677_set_dsp_vad(codec, true);
Oder Chiou0e826e82014-05-26 20:32:33 +08004501 break;
4502
4503 default:
4504 break;
4505 }
Oder Chiou0e826e82014-05-26 20:32:33 +08004506
4507 return 0;
4508}
4509
Oder Chiou44caf762014-09-16 11:37:39 +08004510#ifdef CONFIG_GPIOLIB
Oder Chiou44caf762014-09-16 11:37:39 +08004511static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
4512{
Linus Walleij14900362015-12-08 23:27:09 +01004513 struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
Oder Chiou44caf762014-09-16 11:37:39 +08004514
4515 switch (offset) {
4516 case RT5677_GPIO1 ... RT5677_GPIO5:
4517 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4518 0x1 << (offset * 3 + 1), !!value << (offset * 3 + 1));
4519 break;
4520
4521 case RT5677_GPIO6:
4522 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4523 RT5677_GPIO6_OUT_MASK, !!value << RT5677_GPIO6_OUT_SFT);
4524 break;
4525
4526 default:
4527 break;
4528 }
4529}
4530
4531static int rt5677_gpio_direction_out(struct gpio_chip *chip,
4532 unsigned offset, int value)
4533{
Linus Walleij14900362015-12-08 23:27:09 +01004534 struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
Oder Chiou44caf762014-09-16 11:37:39 +08004535
4536 switch (offset) {
4537 case RT5677_GPIO1 ... RT5677_GPIO5:
4538 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4539 0x3 << (offset * 3 + 1),
4540 (0x2 | !!value) << (offset * 3 + 1));
4541 break;
4542
4543 case RT5677_GPIO6:
4544 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4545 RT5677_GPIO6_DIR_MASK | RT5677_GPIO6_OUT_MASK,
4546 RT5677_GPIO6_DIR_OUT | !!value << RT5677_GPIO6_OUT_SFT);
4547 break;
4548
4549 default:
4550 break;
4551 }
4552
4553 return 0;
4554}
4555
4556static int rt5677_gpio_get(struct gpio_chip *chip, unsigned offset)
4557{
Linus Walleij14900362015-12-08 23:27:09 +01004558 struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
Oder Chiou44caf762014-09-16 11:37:39 +08004559 int value, ret;
4560
4561 ret = regmap_read(rt5677->regmap, RT5677_GPIO_ST, &value);
4562 if (ret < 0)
4563 return ret;
4564
4565 return (value & (0x1 << offset)) >> offset;
4566}
4567
4568static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
4569{
Linus Walleij14900362015-12-08 23:27:09 +01004570 struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
Oder Chiou44caf762014-09-16 11:37:39 +08004571
4572 switch (offset) {
4573 case RT5677_GPIO1 ... RT5677_GPIO5:
4574 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4575 0x1 << (offset * 3 + 2), 0x0);
4576 break;
4577
4578 case RT5677_GPIO6:
4579 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4580 RT5677_GPIO6_DIR_MASK, RT5677_GPIO6_DIR_IN);
4581 break;
4582
4583 default:
4584 break;
4585 }
4586
4587 return 0;
4588}
4589
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004590/** Configures the gpio as
4591 * 0 - floating
4592 * 1 - pull down
4593 * 2 - pull up
4594 */
4595static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
4596 int value)
4597{
4598 int shift;
4599
4600 switch (offset) {
4601 case RT5677_GPIO1 ... RT5677_GPIO2:
4602 shift = 2 * (1 - offset);
4603 regmap_update_bits(rt5677->regmap,
4604 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL2,
4605 0x3 << shift,
4606 (value & 0x3) << shift);
4607 break;
4608
4609 case RT5677_GPIO3 ... RT5677_GPIO6:
4610 shift = 2 * (9 - offset);
4611 regmap_update_bits(rt5677->regmap,
4612 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL3,
4613 0x3 << shift,
4614 (value & 0x3) << shift);
4615 break;
4616
4617 default:
4618 break;
4619 }
4620}
4621
Oder Chiou5e3363a2014-10-16 11:24:26 -07004622static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset)
4623{
Linus Walleij14900362015-12-08 23:27:09 +01004624 struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
Oder Chiou5e3363a2014-10-16 11:24:26 -07004625 struct regmap_irq_chip_data *data = rt5677->irq_data;
4626 int irq;
4627
4628 if (offset >= RT5677_GPIO1 && offset <= RT5677_GPIO3) {
4629 if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) ||
4630 (rt5677->pdata.jd1_gpio == 2 &&
4631 offset == RT5677_GPIO2) ||
4632 (rt5677->pdata.jd1_gpio == 3 &&
4633 offset == RT5677_GPIO3)) {
4634 irq = RT5677_IRQ_JD1;
4635 } else {
4636 return -ENXIO;
4637 }
4638 }
4639
4640 if (offset >= RT5677_GPIO4 && offset <= RT5677_GPIO6) {
4641 if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) ||
4642 (rt5677->pdata.jd2_gpio == 2 &&
4643 offset == RT5677_GPIO5) ||
4644 (rt5677->pdata.jd2_gpio == 3 &&
4645 offset == RT5677_GPIO6)) {
4646 irq = RT5677_IRQ_JD2;
4647 } else if ((rt5677->pdata.jd3_gpio == 1 &&
4648 offset == RT5677_GPIO4) ||
4649 (rt5677->pdata.jd3_gpio == 2 &&
4650 offset == RT5677_GPIO5) ||
4651 (rt5677->pdata.jd3_gpio == 3 &&
4652 offset == RT5677_GPIO6)) {
4653 irq = RT5677_IRQ_JD3;
4654 } else {
4655 return -ENXIO;
4656 }
4657 }
4658
4659 return regmap_irq_get_virq(data, irq);
4660}
4661
Julia Lawallc59b24f2016-09-11 14:14:42 +02004662static const struct gpio_chip rt5677_template_chip = {
Oder Chiou44caf762014-09-16 11:37:39 +08004663 .label = "rt5677",
4664 .owner = THIS_MODULE,
4665 .direction_output = rt5677_gpio_direction_out,
4666 .set = rt5677_gpio_set,
4667 .direction_input = rt5677_gpio_direction_in,
4668 .get = rt5677_gpio_get,
Oder Chiou5e3363a2014-10-16 11:24:26 -07004669 .to_irq = rt5677_to_irq,
Oder Chiou44caf762014-09-16 11:37:39 +08004670 .can_sleep = 1,
4671};
4672
4673static void rt5677_init_gpio(struct i2c_client *i2c)
4674{
4675 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4676 int ret;
4677
4678 rt5677->gpio_chip = rt5677_template_chip;
4679 rt5677->gpio_chip.ngpio = RT5677_GPIO_NUM;
Linus Walleij58383c782015-11-04 09:56:26 +01004680 rt5677->gpio_chip.parent = &i2c->dev;
Oder Chiou44caf762014-09-16 11:37:39 +08004681 rt5677->gpio_chip.base = -1;
4682
Linus Walleij14900362015-12-08 23:27:09 +01004683 ret = gpiochip_add_data(&rt5677->gpio_chip, rt5677);
Oder Chiou44caf762014-09-16 11:37:39 +08004684 if (ret != 0)
4685 dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret);
4686}
4687
4688static void rt5677_free_gpio(struct i2c_client *i2c)
4689{
4690 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08004691
Axel Lin5d5e63a2014-09-17 20:58:02 +08004692 gpiochip_remove(&rt5677->gpio_chip);
Oder Chiou44caf762014-09-16 11:37:39 +08004693}
4694#else
Anatol Pomozov45b6e1d2014-10-16 09:40:58 -07004695static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
4696 int value)
4697{
4698}
4699
Oder Chiou44caf762014-09-16 11:37:39 +08004700static void rt5677_init_gpio(struct i2c_client *i2c)
4701{
4702}
4703
4704static void rt5677_free_gpio(struct i2c_client *i2c)
4705{
4706}
4707#endif
4708
Oder Chiou0e826e82014-05-26 20:32:33 +08004709static int rt5677_probe(struct snd_soc_codec *codec)
4710{
Lars-Peter Clausen6b43c2e2015-05-19 21:49:11 +02004711 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
Oder Chiou0e826e82014-05-26 20:32:33 +08004712 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004713 int i;
Oder Chiou0e826e82014-05-26 20:32:33 +08004714
4715 rt5677->codec = codec;
4716
Bard Liao2d15d972014-08-27 19:50:34 +08004717 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
Lars-Peter Clausen6b43c2e2015-05-19 21:49:11 +02004718 snd_soc_dapm_add_routes(dapm,
Bard Liao2d15d972014-08-27 19:50:34 +08004719 rt5677_dmic2_clk_2,
4720 ARRAY_SIZE(rt5677_dmic2_clk_2));
4721 } else { /*use dmic1 clock by default*/
Lars-Peter Clausen6b43c2e2015-05-19 21:49:11 +02004722 snd_soc_dapm_add_routes(dapm,
Bard Liao2d15d972014-08-27 19:50:34 +08004723 rt5677_dmic2_clk_1,
4724 ARRAY_SIZE(rt5677_dmic2_clk_1));
4725 }
4726
Lars-Peter Clausenbd1204c2015-04-27 22:13:24 +02004727 snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF);
Oder Chiou0e826e82014-05-26 20:32:33 +08004728
4729 regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020);
4730 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00);
4731
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004732 for (i = 0; i < RT5677_GPIO_NUM; i++)
4733 rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]);
4734
Oder Chiou5e3363a2014-10-16 11:24:26 -07004735 if (rt5677->irq_data) {
4736 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, 0x8000,
4737 0x8000);
4738 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x0018,
4739 0x0008);
4740
4741 if (rt5677->pdata.jd1_gpio)
4742 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4743 RT5677_SEL_GPIO_JD1_MASK,
4744 rt5677->pdata.jd1_gpio <<
4745 RT5677_SEL_GPIO_JD1_SFT);
4746
4747 if (rt5677->pdata.jd2_gpio)
4748 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4749 RT5677_SEL_GPIO_JD2_MASK,
4750 rt5677->pdata.jd2_gpio <<
4751 RT5677_SEL_GPIO_JD2_SFT);
4752
4753 if (rt5677->pdata.jd3_gpio)
4754 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4755 RT5677_SEL_GPIO_JD3_MASK,
4756 rt5677->pdata.jd3_gpio <<
4757 RT5677_SEL_GPIO_JD3_SFT);
4758 }
4759
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004760 mutex_init(&rt5677->dsp_cmd_lock);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004761 mutex_init(&rt5677->dsp_pri_lock);
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004762
Oder Chiou0e826e82014-05-26 20:32:33 +08004763 return 0;
4764}
4765
4766static int rt5677_remove(struct snd_soc_codec *codec)
4767{
4768 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4769
4770 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
Axel Linf285f162015-07-23 23:32:04 +08004771 gpiod_set_value_cansleep(rt5677->pow_ldo2, 0);
Anatol Pomozovcdab0d42015-10-29 15:31:59 -07004772 gpiod_set_value_cansleep(rt5677->reset_pin, 1);
Oder Chiou0e826e82014-05-26 20:32:33 +08004773
4774 return 0;
4775}
4776
4777#ifdef CONFIG_PM
4778static int rt5677_suspend(struct snd_soc_codec *codec)
4779{
4780 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4781
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004782 if (!rt5677->dsp_vad_en) {
4783 regcache_cache_only(rt5677->regmap, true);
4784 regcache_mark_dirty(rt5677->regmap);
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004785
Axel Linf285f162015-07-23 23:32:04 +08004786 gpiod_set_value_cansleep(rt5677->pow_ldo2, 0);
Anatol Pomozovcdab0d42015-10-29 15:31:59 -07004787 gpiod_set_value_cansleep(rt5677->reset_pin, 1);
Oder Chioucbca4072015-02-25 17:36:14 +08004788 }
Oder Chiou0e826e82014-05-26 20:32:33 +08004789
4790 return 0;
4791}
4792
4793static int rt5677_resume(struct snd_soc_codec *codec)
4794{
4795 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4796
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004797 if (!rt5677->dsp_vad_en) {
Ben Zhang1aa844c2015-12-15 13:51:25 -08004798 rt5677->pll_src = 0;
4799 rt5677->pll_in = 0;
4800 rt5677->pll_out = 0;
Axel Linf285f162015-07-23 23:32:04 +08004801 gpiod_set_value_cansleep(rt5677->pow_ldo2, 1);
Anatol Pomozovcdab0d42015-10-29 15:31:59 -07004802 gpiod_set_value_cansleep(rt5677->reset_pin, 0);
Ben Zhangefd901e2015-06-22 11:12:59 -07004803 if (rt5677->pow_ldo2 || rt5677->reset_pin)
Oder Chioucbca4072015-02-25 17:36:14 +08004804 msleep(10);
Oder Chioucbca4072015-02-25 17:36:14 +08004805
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004806 regcache_cache_only(rt5677->regmap, false);
4807 regcache_sync(rt5677->regmap);
4808 }
Oder Chiou0e826e82014-05-26 20:32:33 +08004809
4810 return 0;
4811}
4812#else
4813#define rt5677_suspend NULL
4814#define rt5677_resume NULL
4815#endif
4816
Oder Chiou19ba4842014-11-05 13:42:53 +08004817static int rt5677_read(void *context, unsigned int reg, unsigned int *val)
4818{
4819 struct i2c_client *client = context;
4820 struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
4821
Oder Chiou6fe17da2014-11-25 09:51:41 +08004822 if (rt5677->is_dsp_mode) {
4823 if (reg > 0xff) {
4824 mutex_lock(&rt5677->dsp_pri_lock);
4825 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
4826 reg & 0xff);
4827 rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val);
4828 mutex_unlock(&rt5677->dsp_pri_lock);
4829 } else {
4830 rt5677_dsp_mode_i2c_read(rt5677, reg, val);
4831 }
4832 } else {
Oder Chiou19ba4842014-11-05 13:42:53 +08004833 regmap_read(rt5677->regmap_physical, reg, val);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004834 }
Oder Chiou19ba4842014-11-05 13:42:53 +08004835
4836 return 0;
4837}
4838
4839static int rt5677_write(void *context, unsigned int reg, unsigned int val)
4840{
4841 struct i2c_client *client = context;
4842 struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
4843
Oder Chiou6fe17da2014-11-25 09:51:41 +08004844 if (rt5677->is_dsp_mode) {
4845 if (reg > 0xff) {
4846 mutex_lock(&rt5677->dsp_pri_lock);
4847 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
4848 reg & 0xff);
4849 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA,
4850 val);
4851 mutex_unlock(&rt5677->dsp_pri_lock);
4852 } else {
4853 rt5677_dsp_mode_i2c_write(rt5677, reg, val);
4854 }
4855 } else {
Oder Chiou19ba4842014-11-05 13:42:53 +08004856 regmap_write(rt5677->regmap_physical, reg, val);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004857 }
Oder Chiou19ba4842014-11-05 13:42:53 +08004858
4859 return 0;
4860}
4861
Oder Chiou0e826e82014-05-26 20:32:33 +08004862#define RT5677_STEREO_RATES SNDRV_PCM_RATE_8000_96000
4863#define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
4864 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
4865
Axel Lin64793042015-07-15 15:38:14 +08004866static const struct snd_soc_dai_ops rt5677_aif_dai_ops = {
Oder Chiou0e826e82014-05-26 20:32:33 +08004867 .hw_params = rt5677_hw_params,
4868 .set_fmt = rt5677_set_dai_fmt,
4869 .set_sysclk = rt5677_set_dai_sysclk,
4870 .set_pll = rt5677_set_dai_pll,
Oder Chiou48561af2014-09-17 15:12:33 +08004871 .set_tdm_slot = rt5677_set_tdm_slot,
Oder Chiou0e826e82014-05-26 20:32:33 +08004872};
4873
4874static struct snd_soc_dai_driver rt5677_dai[] = {
4875 {
4876 .name = "rt5677-aif1",
4877 .id = RT5677_AIF1,
4878 .playback = {
4879 .stream_name = "AIF1 Playback",
4880 .channels_min = 1,
4881 .channels_max = 2,
4882 .rates = RT5677_STEREO_RATES,
4883 .formats = RT5677_FORMATS,
4884 },
4885 .capture = {
4886 .stream_name = "AIF1 Capture",
4887 .channels_min = 1,
4888 .channels_max = 2,
4889 .rates = RT5677_STEREO_RATES,
4890 .formats = RT5677_FORMATS,
4891 },
4892 .ops = &rt5677_aif_dai_ops,
4893 },
4894 {
4895 .name = "rt5677-aif2",
4896 .id = RT5677_AIF2,
4897 .playback = {
4898 .stream_name = "AIF2 Playback",
4899 .channels_min = 1,
4900 .channels_max = 2,
4901 .rates = RT5677_STEREO_RATES,
4902 .formats = RT5677_FORMATS,
4903 },
4904 .capture = {
4905 .stream_name = "AIF2 Capture",
4906 .channels_min = 1,
4907 .channels_max = 2,
4908 .rates = RT5677_STEREO_RATES,
4909 .formats = RT5677_FORMATS,
4910 },
4911 .ops = &rt5677_aif_dai_ops,
4912 },
4913 {
4914 .name = "rt5677-aif3",
4915 .id = RT5677_AIF3,
4916 .playback = {
4917 .stream_name = "AIF3 Playback",
4918 .channels_min = 1,
4919 .channels_max = 2,
4920 .rates = RT5677_STEREO_RATES,
4921 .formats = RT5677_FORMATS,
4922 },
4923 .capture = {
4924 .stream_name = "AIF3 Capture",
4925 .channels_min = 1,
4926 .channels_max = 2,
4927 .rates = RT5677_STEREO_RATES,
4928 .formats = RT5677_FORMATS,
4929 },
4930 .ops = &rt5677_aif_dai_ops,
4931 },
4932 {
4933 .name = "rt5677-aif4",
4934 .id = RT5677_AIF4,
4935 .playback = {
4936 .stream_name = "AIF4 Playback",
4937 .channels_min = 1,
4938 .channels_max = 2,
4939 .rates = RT5677_STEREO_RATES,
4940 .formats = RT5677_FORMATS,
4941 },
4942 .capture = {
4943 .stream_name = "AIF4 Capture",
4944 .channels_min = 1,
4945 .channels_max = 2,
4946 .rates = RT5677_STEREO_RATES,
4947 .formats = RT5677_FORMATS,
4948 },
4949 .ops = &rt5677_aif_dai_ops,
4950 },
4951 {
4952 .name = "rt5677-slimbus",
4953 .id = RT5677_AIF5,
4954 .playback = {
4955 .stream_name = "SLIMBus Playback",
4956 .channels_min = 1,
4957 .channels_max = 2,
4958 .rates = RT5677_STEREO_RATES,
4959 .formats = RT5677_FORMATS,
4960 },
4961 .capture = {
4962 .stream_name = "SLIMBus Capture",
4963 .channels_min = 1,
4964 .channels_max = 2,
4965 .rates = RT5677_STEREO_RATES,
4966 .formats = RT5677_FORMATS,
4967 },
4968 .ops = &rt5677_aif_dai_ops,
4969 },
4970};
4971
4972static struct snd_soc_codec_driver soc_codec_dev_rt5677 = {
4973 .probe = rt5677_probe,
4974 .remove = rt5677_remove,
4975 .suspend = rt5677_suspend,
4976 .resume = rt5677_resume,
4977 .set_bias_level = rt5677_set_bias_level,
4978 .idle_bias_off = true,
Kuninori Morimoto1ec95a52016-08-08 09:23:46 +00004979 .component_driver = {
4980 .controls = rt5677_snd_controls,
4981 .num_controls = ARRAY_SIZE(rt5677_snd_controls),
4982 .dapm_widgets = rt5677_dapm_widgets,
4983 .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets),
4984 .dapm_routes = rt5677_dapm_routes,
4985 .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes),
4986 },
Oder Chiou0e826e82014-05-26 20:32:33 +08004987};
4988
Oder Chiou19ba4842014-11-05 13:42:53 +08004989static const struct regmap_config rt5677_regmap_physical = {
4990 .name = "physical",
4991 .reg_bits = 8,
4992 .val_bits = 16,
4993
Oder Chiou6fe17da2014-11-25 09:51:41 +08004994 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
4995 RT5677_PR_SPACING),
Oder Chiou19ba4842014-11-05 13:42:53 +08004996 .readable_reg = rt5677_readable_register,
4997
4998 .cache_type = REGCACHE_NONE,
Oder Chiou6fe17da2014-11-25 09:51:41 +08004999 .ranges = rt5677_ranges,
5000 .num_ranges = ARRAY_SIZE(rt5677_ranges),
Oder Chiou19ba4842014-11-05 13:42:53 +08005001};
5002
Oder Chiou0e826e82014-05-26 20:32:33 +08005003static const struct regmap_config rt5677_regmap = {
5004 .reg_bits = 8,
5005 .val_bits = 16,
5006
5007 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
5008 RT5677_PR_SPACING),
5009
5010 .volatile_reg = rt5677_volatile_register,
5011 .readable_reg = rt5677_readable_register,
Oder Chiou19ba4842014-11-05 13:42:53 +08005012 .reg_read = rt5677_read,
5013 .reg_write = rt5677_write,
Oder Chiou0e826e82014-05-26 20:32:33 +08005014
5015 .cache_type = REGCACHE_RBTREE,
5016 .reg_defaults = rt5677_reg,
5017 .num_reg_defaults = ARRAY_SIZE(rt5677_reg),
5018 .ranges = rt5677_ranges,
5019 .num_ranges = ARRAY_SIZE(rt5677_ranges),
5020};
5021
5022static const struct i2c_device_id rt5677_i2c_id[] = {
Oder Chiou0e826e82014-05-26 20:32:33 +08005023 { }
5024};
5025MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
5026
Javier Martinez Canillas7b874632017-04-04 15:26:30 -04005027static const struct of_device_id rt5677_of_match[] = {
Andy Shevchenkoddc9e692017-07-18 20:34:17 +03005028 { .compatible = "realtek,rt5677", RT5677 },
Javier Martinez Canillas7b874632017-04-04 15:26:30 -04005029 { }
5030};
5031MODULE_DEVICE_TABLE(of, rt5677_of_match);
5032
Andy Shevchenkoa36afb02017-06-15 15:46:36 +03005033static const struct acpi_device_id rt5677_acpi_match[] = {
5034 { "RT5677CE", RT5677 },
5035 { }
5036};
5037MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match);
Andy Shevchenkoa36afb02017-06-15 15:46:36 +03005038
John Keeping89128532016-08-24 22:06:35 +01005039static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677,
5040 struct device *dev)
5041{
John Keeping89128532016-08-24 22:06:35 +01005042 u32 val;
5043
John Keeping89128532016-08-24 22:06:35 +01005044 if (!device_property_read_u32(dev, "DCLK", &val))
5045 rt5677->pdata.dmic2_clk_pin = val;
5046
5047 rt5677->pdata.in1_diff = device_property_read_bool(dev, "IN1");
5048 rt5677->pdata.in2_diff = device_property_read_bool(dev, "IN2");
5049 rt5677->pdata.lout1_diff = device_property_read_bool(dev, "OUT1");
5050 rt5677->pdata.lout2_diff = device_property_read_bool(dev, "OUT2");
5051 rt5677->pdata.lout3_diff = device_property_read_bool(dev, "OUT3");
5052
5053 device_property_read_u32(dev, "JD1", &rt5677->pdata.jd1_gpio);
5054 device_property_read_u32(dev, "JD2", &rt5677->pdata.jd2_gpio);
5055 device_property_read_u32(dev, "JD3", &rt5677->pdata.jd3_gpio);
5056}
5057
Ben Zhang9bfde722015-06-22 11:13:00 -07005058static void rt5677_read_device_properties(struct rt5677_priv *rt5677,
5059 struct device *dev)
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07005060{
Ben Zhang9bfde722015-06-22 11:13:00 -07005061 rt5677->pdata.in1_diff = device_property_read_bool(dev,
5062 "realtek,in1-differential");
5063 rt5677->pdata.in2_diff = device_property_read_bool(dev,
5064 "realtek,in2-differential");
5065 rt5677->pdata.lout1_diff = device_property_read_bool(dev,
5066 "realtek,lout1-differential");
5067 rt5677->pdata.lout2_diff = device_property_read_bool(dev,
5068 "realtek,lout2-differential");
5069 rt5677->pdata.lout3_diff = device_property_read_bool(dev,
5070 "realtek,lout3-differential");
Anatol Pomozov6f67c382014-09-26 09:57:27 -07005071
Ben Zhang9bfde722015-06-22 11:13:00 -07005072 device_property_read_u8_array(dev, "realtek,gpio-config",
5073 rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07005074
Ben Zhang9bfde722015-06-22 11:13:00 -07005075 device_property_read_u32(dev, "realtek,jd1-gpio",
5076 &rt5677->pdata.jd1_gpio);
5077 device_property_read_u32(dev, "realtek,jd2-gpio",
5078 &rt5677->pdata.jd2_gpio);
5079 device_property_read_u32(dev, "realtek,jd3-gpio",
5080 &rt5677->pdata.jd3_gpio);
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07005081}
5082
Oder Chiou5e3363a2014-10-16 11:24:26 -07005083static struct regmap_irq rt5677_irqs[] = {
5084 [RT5677_IRQ_JD1] = {
5085 .reg_offset = 0,
5086 .mask = RT5677_EN_IRQ_GPIO_JD1,
5087 },
5088 [RT5677_IRQ_JD2] = {
5089 .reg_offset = 0,
5090 .mask = RT5677_EN_IRQ_GPIO_JD2,
5091 },
5092 [RT5677_IRQ_JD3] = {
5093 .reg_offset = 0,
5094 .mask = RT5677_EN_IRQ_GPIO_JD3,
5095 },
5096};
5097
5098static struct regmap_irq_chip rt5677_irq_chip = {
5099 .name = "rt5677",
5100 .irqs = rt5677_irqs,
5101 .num_irqs = ARRAY_SIZE(rt5677_irqs),
5102
5103 .num_regs = 1,
5104 .status_base = RT5677_IRQ_CTRL1,
5105 .mask_base = RT5677_IRQ_CTRL1,
5106 .mask_invert = 1,
5107};
5108
Oder Chiou35d40d12014-11-19 13:52:19 +08005109static int rt5677_init_irq(struct i2c_client *i2c)
Oder Chiou5e3363a2014-10-16 11:24:26 -07005110{
5111 int ret;
5112 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
5113
5114 if (!rt5677->pdata.jd1_gpio &&
5115 !rt5677->pdata.jd2_gpio &&
5116 !rt5677->pdata.jd3_gpio)
5117 return 0;
5118
5119 if (!i2c->irq) {
5120 dev_err(&i2c->dev, "No interrupt specified\n");
5121 return -EINVAL;
5122 }
5123
5124 ret = regmap_add_irq_chip(rt5677->regmap, i2c->irq,
5125 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
5126 &rt5677_irq_chip, &rt5677->irq_data);
5127
5128 if (ret != 0) {
5129 dev_err(&i2c->dev, "Failed to register IRQ chip: %d\n", ret);
5130 return ret;
5131 }
5132
5133 return 0;
5134}
5135
Oder Chiou35d40d12014-11-19 13:52:19 +08005136static void rt5677_free_irq(struct i2c_client *i2c)
Oder Chiou5e3363a2014-10-16 11:24:26 -07005137{
5138 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
5139
5140 if (rt5677->irq_data)
5141 regmap_del_irq_chip(i2c->irq, rt5677->irq_data);
5142}
5143
Oder Chiou0e826e82014-05-26 20:32:33 +08005144static int rt5677_i2c_probe(struct i2c_client *i2c,
5145 const struct i2c_device_id *id)
5146{
Oder Chiou0e826e82014-05-26 20:32:33 +08005147 struct rt5677_priv *rt5677;
5148 int ret;
5149 unsigned int val;
5150
5151 rt5677 = devm_kzalloc(&i2c->dev, sizeof(struct rt5677_priv),
5152 GFP_KERNEL);
5153 if (rt5677 == NULL)
5154 return -ENOMEM;
5155
5156 i2c_set_clientdata(i2c, rt5677);
5157
Andy Shevchenkoddc9e692017-07-18 20:34:17 +03005158 if (i2c->dev.of_node) {
5159 const struct of_device_id *match_id;
Oder Chiouab1f7092015-02-11 19:18:51 +08005160
Andy Shevchenkoddc9e692017-07-18 20:34:17 +03005161 match_id = of_match_device(rt5677_of_match, &i2c->dev);
5162 if (match_id)
5163 rt5677->type = (enum rt5677_type)match_id->data;
5164
Ben Zhang9bfde722015-06-22 11:13:00 -07005165 rt5677_read_device_properties(rt5677, &i2c->dev);
Andy Shevchenkoddc9e692017-07-18 20:34:17 +03005166 } else if (ACPI_HANDLE(&i2c->dev)) {
5167 const struct acpi_device_id *acpi_id;
5168
5169 acpi_id = acpi_match_device(rt5677_acpi_match, &i2c->dev);
5170 if (acpi_id)
5171 rt5677->type = (enum rt5677_type)acpi_id->driver_data;
5172
John Keeping89128532016-08-24 22:06:35 +01005173 rt5677_read_acpi_properties(rt5677, &i2c->dev);
Andy Shevchenkoddc9e692017-07-18 20:34:17 +03005174 } else {
John Keeping89128532016-08-24 22:06:35 +01005175 return -EINVAL;
Andy Shevchenkoddc9e692017-07-18 20:34:17 +03005176 }
Oder Chiou0e826e82014-05-26 20:32:33 +08005177
Ben Zhangefd901e2015-06-22 11:12:59 -07005178 /* pow-ldo2 and reset are optional. The codec pins may be statically
5179 * connected on the board without gpios. If the gpio device property
5180 * isn't specified, devm_gpiod_get_optional returns NULL.
5181 */
5182 rt5677->pow_ldo2 = devm_gpiod_get_optional(&i2c->dev,
5183 "realtek,pow-ldo2", GPIOD_OUT_HIGH);
5184 if (IS_ERR(rt5677->pow_ldo2)) {
5185 ret = PTR_ERR(rt5677->pow_ldo2);
5186 dev_err(&i2c->dev, "Failed to request POW_LDO2: %d\n", ret);
Axel Linf8163c82015-07-25 10:23:40 +08005187 return ret;
Ben Zhangefd901e2015-06-22 11:12:59 -07005188 }
5189 rt5677->reset_pin = devm_gpiod_get_optional(&i2c->dev,
Anatol Pomozovcdab0d42015-10-29 15:31:59 -07005190 "realtek,reset", GPIOD_OUT_LOW);
Ben Zhangefd901e2015-06-22 11:12:59 -07005191 if (IS_ERR(rt5677->reset_pin)) {
5192 ret = PTR_ERR(rt5677->reset_pin);
5193 dev_err(&i2c->dev, "Failed to request RESET: %d\n", ret);
Axel Linf8163c82015-07-25 10:23:40 +08005194 return ret;
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07005195 }
5196
Ben Zhangefd901e2015-06-22 11:12:59 -07005197 if (rt5677->pow_ldo2 || rt5677->reset_pin) {
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07005198 /* Wait a while until I2C bus becomes available. The datasheet
5199 * does not specify the exact we should wait but startup
5200 * sequence mentiones at least a few milliseconds.
5201 */
5202 msleep(10);
5203 }
5204
Oder Chiou19ba4842014-11-05 13:42:53 +08005205 rt5677->regmap_physical = devm_regmap_init_i2c(i2c,
5206 &rt5677_regmap_physical);
5207 if (IS_ERR(rt5677->regmap_physical)) {
5208 ret = PTR_ERR(rt5677->regmap_physical);
5209 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
5210 ret);
5211 return ret;
5212 }
5213
5214 rt5677->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5677_regmap);
Oder Chiou0e826e82014-05-26 20:32:33 +08005215 if (IS_ERR(rt5677->regmap)) {
5216 ret = PTR_ERR(rt5677->regmap);
5217 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
5218 ret);
5219 return ret;
5220 }
5221
5222 regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val);
5223 if (val != RT5677_DEVICE_ID) {
5224 dev_err(&i2c->dev,
Jarkko Nikulaaa0bcc52015-06-25 13:59:01 +03005225 "Device with ID register %#x is not rt5677\n", val);
Oder Chiou0e826e82014-05-26 20:32:33 +08005226 return -ENODEV;
5227 }
5228
5229 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
5230
5231 ret = regmap_register_patch(rt5677->regmap, init_list,
5232 ARRAY_SIZE(init_list));
5233 if (ret != 0)
5234 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
5235
5236 if (rt5677->pdata.in1_diff)
5237 regmap_update_bits(rt5677->regmap, RT5677_IN1,
5238 RT5677_IN_DF1, RT5677_IN_DF1);
5239
5240 if (rt5677->pdata.in2_diff)
5241 regmap_update_bits(rt5677->regmap, RT5677_IN1,
5242 RT5677_IN_DF2, RT5677_IN_DF2);
5243
Anatol Pomozov6f67c382014-09-26 09:57:27 -07005244 if (rt5677->pdata.lout1_diff)
5245 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
5246 RT5677_LOUT1_L_DF, RT5677_LOUT1_L_DF);
5247
5248 if (rt5677->pdata.lout2_diff)
5249 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
5250 RT5677_LOUT2_L_DF, RT5677_LOUT2_L_DF);
5251
5252 if (rt5677->pdata.lout3_diff)
5253 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
5254 RT5677_LOUT3_L_DF, RT5677_LOUT3_L_DF);
5255
Bard Liao2d15d972014-08-27 19:50:34 +08005256 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
5257 regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL2,
5258 RT5677_GPIO5_FUNC_MASK,
5259 RT5677_GPIO5_FUNC_DMIC);
5260 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
5261 RT5677_GPIO5_DIR_MASK,
5262 RT5677_GPIO5_DIR_OUT);
5263 }
5264
Oder Chiou277880a2015-01-08 10:31:06 +08005265 if (rt5677->pdata.micbias1_vdd_3v3)
5266 regmap_update_bits(rt5677->regmap, RT5677_MICBIAS,
5267 RT5677_MICBIAS1_CTRL_VDD_MASK,
5268 RT5677_MICBIAS1_CTRL_VDD_3_3V);
5269
Oder Chiou44caf762014-09-16 11:37:39 +08005270 rt5677_init_gpio(i2c);
Oder Chiou35d40d12014-11-19 13:52:19 +08005271 rt5677_init_irq(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08005272
Axel Lind0bdcb92014-06-10 11:37:24 +08005273 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677,
5274 rt5677_dai, ARRAY_SIZE(rt5677_dai));
Oder Chiou0e826e82014-05-26 20:32:33 +08005275}
5276
5277static int rt5677_i2c_remove(struct i2c_client *i2c)
5278{
5279 snd_soc_unregister_codec(&i2c->dev);
Oder Chiou35d40d12014-11-19 13:52:19 +08005280 rt5677_free_irq(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08005281 rt5677_free_gpio(i2c);
Oder Chiou0e826e82014-05-26 20:32:33 +08005282
5283 return 0;
5284}
5285
5286static struct i2c_driver rt5677_i2c_driver = {
5287 .driver = {
5288 .name = "rt5677",
Javier Martinez Canillas7b874632017-04-04 15:26:30 -04005289 .of_match_table = rt5677_of_match,
Andy Shevchenkoa36afb02017-06-15 15:46:36 +03005290 .acpi_match_table = ACPI_PTR(rt5677_acpi_match),
Oder Chiou0e826e82014-05-26 20:32:33 +08005291 },
5292 .probe = rt5677_i2c_probe,
5293 .remove = rt5677_i2c_remove,
5294 .id_table = rt5677_i2c_id,
5295};
Axel Linc8cfbec2014-06-03 10:56:41 +08005296module_i2c_driver(rt5677_i2c_driver);
Oder Chiou0e826e82014-05-26 20:32:33 +08005297
5298MODULE_DESCRIPTION("ASoC RT5677 driver");
5299MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>");
5300MODULE_LICENSE("GPL v2");