blob: f6affba734c3c2055f87d29dc908d3815614e902 [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
12#include <linux/fs.h>
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/pm.h>
Anatol Pomozovf9f6a592014-09-17 13:14:20 -070018#include <linux/of_gpio.h>
Oder Chiou0e826e82014-05-26 20:32:33 +080019#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>
Oder Chiou44caf762014-09-16 11:37:39 +080024#include <linux/gpio.h>
Oder Chiou0e826e82014-05-26 20:32:33 +080025#include <sound/core.h>
26#include <sound/pcm.h>
27#include <sound/pcm_params.h>
28#include <sound/soc.h>
29#include <sound/soc-dapm.h>
30#include <sound/initval.h>
31#include <sound/tlv.h>
32
Axel Lin30f14b42014-06-10 08:57:36 +080033#include "rl6231.h"
Oder Chiou0e826e82014-05-26 20:32:33 +080034#include "rt5677.h"
Oder Chiouaf48f1d2014-10-06 16:30:51 +080035#include "rt5677-spi.h"
Oder Chiou0e826e82014-05-26 20:32:33 +080036
37#define RT5677_DEVICE_ID 0x6327
38
39#define RT5677_PR_RANGE_BASE (0xff + 1)
40#define RT5677_PR_SPACING 0x100
41
42#define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
43
44static const struct regmap_range_cfg rt5677_ranges[] = {
45 {
46 .name = "PR",
47 .range_min = RT5677_PR_BASE,
48 .range_max = RT5677_PR_BASE + 0xfd,
49 .selector_reg = RT5677_PRIV_INDEX,
50 .selector_mask = 0xff,
51 .selector_shift = 0x0,
52 .window_start = RT5677_PRIV_DATA,
53 .window_len = 0x1,
54 },
55};
56
57static const struct reg_default init_list[] = {
Oder Chiou2dfe2b02014-11-19 13:52:18 +080058 {RT5677_ASRC_12, 0x0018},
59 {RT5677_PR_BASE + 0x3d, 0x364d},
60 {RT5677_PR_BASE + 0x17, 0x4fc0},
61 {RT5677_PR_BASE + 0x13, 0x0312},
62 {RT5677_PR_BASE + 0x1e, 0x0000},
63 {RT5677_PR_BASE + 0x12, 0x0eaa},
64 {RT5677_PR_BASE + 0x14, 0x018a},
Oder Chiou0e826e82014-05-26 20:32:33 +080065};
66#define RT5677_INIT_REG_LEN ARRAY_SIZE(init_list)
67
68static const struct reg_default rt5677_reg[] = {
69 {RT5677_RESET , 0x0000},
70 {RT5677_LOUT1 , 0xa800},
71 {RT5677_IN1 , 0x0000},
72 {RT5677_MICBIAS , 0x0000},
73 {RT5677_SLIMBUS_PARAM , 0x0000},
74 {RT5677_SLIMBUS_RX , 0x0000},
75 {RT5677_SLIMBUS_CTRL , 0x0000},
76 {RT5677_SIDETONE_CTRL , 0x000b},
77 {RT5677_ANA_DAC1_2_3_SRC , 0x0000},
78 {RT5677_IF_DSP_DAC3_4_MIXER , 0x1111},
79 {RT5677_DAC4_DIG_VOL , 0xafaf},
80 {RT5677_DAC3_DIG_VOL , 0xafaf},
81 {RT5677_DAC1_DIG_VOL , 0xafaf},
82 {RT5677_DAC2_DIG_VOL , 0xafaf},
83 {RT5677_IF_DSP_DAC2_MIXER , 0x0011},
84 {RT5677_STO1_ADC_DIG_VOL , 0x2f2f},
85 {RT5677_MONO_ADC_DIG_VOL , 0x2f2f},
86 {RT5677_STO1_2_ADC_BST , 0x0000},
87 {RT5677_STO2_ADC_DIG_VOL , 0x2f2f},
88 {RT5677_ADC_BST_CTRL2 , 0x0000},
89 {RT5677_STO3_4_ADC_BST , 0x0000},
90 {RT5677_STO3_ADC_DIG_VOL , 0x2f2f},
91 {RT5677_STO4_ADC_DIG_VOL , 0x2f2f},
92 {RT5677_STO4_ADC_MIXER , 0xd4c0},
93 {RT5677_STO3_ADC_MIXER , 0xd4c0},
94 {RT5677_STO2_ADC_MIXER , 0xd4c0},
95 {RT5677_STO1_ADC_MIXER , 0xd4c0},
96 {RT5677_MONO_ADC_MIXER , 0xd4d1},
97 {RT5677_ADC_IF_DSP_DAC1_MIXER , 0x8080},
98 {RT5677_STO1_DAC_MIXER , 0xaaaa},
99 {RT5677_MONO_DAC_MIXER , 0xaaaa},
100 {RT5677_DD1_MIXER , 0xaaaa},
101 {RT5677_DD2_MIXER , 0xaaaa},
102 {RT5677_IF3_DATA , 0x0000},
103 {RT5677_IF4_DATA , 0x0000},
104 {RT5677_PDM_OUT_CTRL , 0x8888},
105 {RT5677_PDM_DATA_CTRL1 , 0x0000},
106 {RT5677_PDM_DATA_CTRL2 , 0x0000},
107 {RT5677_PDM1_DATA_CTRL2 , 0x0000},
108 {RT5677_PDM1_DATA_CTRL3 , 0x0000},
109 {RT5677_PDM1_DATA_CTRL4 , 0x0000},
110 {RT5677_PDM2_DATA_CTRL2 , 0x0000},
111 {RT5677_PDM2_DATA_CTRL3 , 0x0000},
112 {RT5677_PDM2_DATA_CTRL4 , 0x0000},
113 {RT5677_TDM1_CTRL1 , 0x0300},
114 {RT5677_TDM1_CTRL2 , 0x0000},
115 {RT5677_TDM1_CTRL3 , 0x4000},
116 {RT5677_TDM1_CTRL4 , 0x0123},
117 {RT5677_TDM1_CTRL5 , 0x4567},
118 {RT5677_TDM2_CTRL1 , 0x0300},
119 {RT5677_TDM2_CTRL2 , 0x0000},
120 {RT5677_TDM2_CTRL3 , 0x4000},
121 {RT5677_TDM2_CTRL4 , 0x0123},
122 {RT5677_TDM2_CTRL5 , 0x4567},
123 {RT5677_I2C_MASTER_CTRL1 , 0x0001},
124 {RT5677_I2C_MASTER_CTRL2 , 0x0000},
125 {RT5677_I2C_MASTER_CTRL3 , 0x0000},
126 {RT5677_I2C_MASTER_CTRL4 , 0x0000},
127 {RT5677_I2C_MASTER_CTRL5 , 0x0000},
128 {RT5677_I2C_MASTER_CTRL6 , 0x0000},
129 {RT5677_I2C_MASTER_CTRL7 , 0x0000},
130 {RT5677_I2C_MASTER_CTRL8 , 0x0000},
131 {RT5677_DMIC_CTRL1 , 0x1505},
132 {RT5677_DMIC_CTRL2 , 0x0055},
133 {RT5677_HAP_GENE_CTRL1 , 0x0111},
134 {RT5677_HAP_GENE_CTRL2 , 0x0064},
135 {RT5677_HAP_GENE_CTRL3 , 0xef0e},
136 {RT5677_HAP_GENE_CTRL4 , 0xf0f0},
137 {RT5677_HAP_GENE_CTRL5 , 0xef0e},
138 {RT5677_HAP_GENE_CTRL6 , 0xf0f0},
139 {RT5677_HAP_GENE_CTRL7 , 0xef0e},
140 {RT5677_HAP_GENE_CTRL8 , 0xf0f0},
141 {RT5677_HAP_GENE_CTRL9 , 0xf000},
142 {RT5677_HAP_GENE_CTRL10 , 0x0000},
143 {RT5677_PWR_DIG1 , 0x0000},
144 {RT5677_PWR_DIG2 , 0x0000},
145 {RT5677_PWR_ANLG1 , 0x0055},
146 {RT5677_PWR_ANLG2 , 0x0000},
147 {RT5677_PWR_DSP1 , 0x0001},
148 {RT5677_PWR_DSP_ST , 0x0000},
149 {RT5677_PWR_DSP2 , 0x0000},
150 {RT5677_ADC_DAC_HPF_CTRL1 , 0x0e00},
151 {RT5677_PRIV_INDEX , 0x0000},
152 {RT5677_PRIV_DATA , 0x0000},
153 {RT5677_I2S4_SDP , 0x8000},
154 {RT5677_I2S1_SDP , 0x8000},
155 {RT5677_I2S2_SDP , 0x8000},
156 {RT5677_I2S3_SDP , 0x8000},
157 {RT5677_CLK_TREE_CTRL1 , 0x1111},
158 {RT5677_CLK_TREE_CTRL2 , 0x1111},
159 {RT5677_CLK_TREE_CTRL3 , 0x0000},
160 {RT5677_PLL1_CTRL1 , 0x0000},
161 {RT5677_PLL1_CTRL2 , 0x0000},
162 {RT5677_PLL2_CTRL1 , 0x0c60},
163 {RT5677_PLL2_CTRL2 , 0x2000},
164 {RT5677_GLB_CLK1 , 0x0000},
165 {RT5677_GLB_CLK2 , 0x0000},
166 {RT5677_ASRC_1 , 0x0000},
167 {RT5677_ASRC_2 , 0x0000},
168 {RT5677_ASRC_3 , 0x0000},
169 {RT5677_ASRC_4 , 0x0000},
170 {RT5677_ASRC_5 , 0x0000},
171 {RT5677_ASRC_6 , 0x0000},
172 {RT5677_ASRC_7 , 0x0000},
173 {RT5677_ASRC_8 , 0x0000},
174 {RT5677_ASRC_9 , 0x0000},
175 {RT5677_ASRC_10 , 0x0000},
176 {RT5677_ASRC_11 , 0x0000},
Oder Chiou86ae04b2014-11-17 10:18:11 +0800177 {RT5677_ASRC_12 , 0x0018},
Oder Chiou0e826e82014-05-26 20:32:33 +0800178 {RT5677_ASRC_13 , 0x0000},
179 {RT5677_ASRC_14 , 0x0000},
180 {RT5677_ASRC_15 , 0x0000},
181 {RT5677_ASRC_16 , 0x0000},
182 {RT5677_ASRC_17 , 0x0000},
183 {RT5677_ASRC_18 , 0x0000},
184 {RT5677_ASRC_19 , 0x0000},
185 {RT5677_ASRC_20 , 0x0000},
186 {RT5677_ASRC_21 , 0x000c},
187 {RT5677_ASRC_22 , 0x0000},
188 {RT5677_ASRC_23 , 0x0000},
189 {RT5677_VAD_CTRL1 , 0x2184},
190 {RT5677_VAD_CTRL2 , 0x010a},
191 {RT5677_VAD_CTRL3 , 0x0aea},
192 {RT5677_VAD_CTRL4 , 0x000c},
193 {RT5677_VAD_CTRL5 , 0x0000},
194 {RT5677_DSP_INB_CTRL1 , 0x0000},
195 {RT5677_DSP_INB_CTRL2 , 0x0000},
196 {RT5677_DSP_IN_OUTB_CTRL , 0x0000},
197 {RT5677_DSP_OUTB0_1_DIG_VOL , 0x2f2f},
198 {RT5677_DSP_OUTB2_3_DIG_VOL , 0x2f2f},
199 {RT5677_DSP_OUTB4_5_DIG_VOL , 0x2f2f},
200 {RT5677_DSP_OUTB6_7_DIG_VOL , 0x2f2f},
201 {RT5677_ADC_EQ_CTRL1 , 0x6000},
202 {RT5677_ADC_EQ_CTRL2 , 0x0000},
203 {RT5677_EQ_CTRL1 , 0xc000},
204 {RT5677_EQ_CTRL2 , 0x0000},
205 {RT5677_EQ_CTRL3 , 0x0000},
206 {RT5677_SOFT_VOL_ZERO_CROSS1 , 0x0009},
207 {RT5677_JD_CTRL1 , 0x0000},
208 {RT5677_JD_CTRL2 , 0x0000},
209 {RT5677_JD_CTRL3 , 0x0000},
210 {RT5677_IRQ_CTRL1 , 0x0000},
211 {RT5677_IRQ_CTRL2 , 0x0000},
212 {RT5677_GPIO_ST , 0x0000},
213 {RT5677_GPIO_CTRL1 , 0x0000},
214 {RT5677_GPIO_CTRL2 , 0x0000},
215 {RT5677_GPIO_CTRL3 , 0x0000},
216 {RT5677_STO1_ADC_HI_FILTER1 , 0xb320},
217 {RT5677_STO1_ADC_HI_FILTER2 , 0x0000},
218 {RT5677_MONO_ADC_HI_FILTER1 , 0xb300},
219 {RT5677_MONO_ADC_HI_FILTER2 , 0x0000},
220 {RT5677_STO2_ADC_HI_FILTER1 , 0xb300},
221 {RT5677_STO2_ADC_HI_FILTER2 , 0x0000},
222 {RT5677_STO3_ADC_HI_FILTER1 , 0xb300},
223 {RT5677_STO3_ADC_HI_FILTER2 , 0x0000},
224 {RT5677_STO4_ADC_HI_FILTER1 , 0xb300},
225 {RT5677_STO4_ADC_HI_FILTER2 , 0x0000},
226 {RT5677_MB_DRC_CTRL1 , 0x0f20},
227 {RT5677_DRC1_CTRL1 , 0x001f},
228 {RT5677_DRC1_CTRL2 , 0x020c},
229 {RT5677_DRC1_CTRL3 , 0x1f00},
230 {RT5677_DRC1_CTRL4 , 0x0000},
231 {RT5677_DRC1_CTRL5 , 0x0000},
232 {RT5677_DRC1_CTRL6 , 0x0029},
233 {RT5677_DRC2_CTRL1 , 0x001f},
234 {RT5677_DRC2_CTRL2 , 0x020c},
235 {RT5677_DRC2_CTRL3 , 0x1f00},
236 {RT5677_DRC2_CTRL4 , 0x0000},
237 {RT5677_DRC2_CTRL5 , 0x0000},
238 {RT5677_DRC2_CTRL6 , 0x0029},
239 {RT5677_DRC1_HL_CTRL1 , 0x8000},
240 {RT5677_DRC1_HL_CTRL2 , 0x0200},
241 {RT5677_DRC2_HL_CTRL1 , 0x8000},
242 {RT5677_DRC2_HL_CTRL2 , 0x0200},
243 {RT5677_DSP_INB1_SRC_CTRL1 , 0x5800},
244 {RT5677_DSP_INB1_SRC_CTRL2 , 0x0000},
245 {RT5677_DSP_INB1_SRC_CTRL3 , 0x0000},
246 {RT5677_DSP_INB1_SRC_CTRL4 , 0x0800},
247 {RT5677_DSP_INB2_SRC_CTRL1 , 0x5800},
248 {RT5677_DSP_INB2_SRC_CTRL2 , 0x0000},
249 {RT5677_DSP_INB2_SRC_CTRL3 , 0x0000},
250 {RT5677_DSP_INB2_SRC_CTRL4 , 0x0800},
251 {RT5677_DSP_INB3_SRC_CTRL1 , 0x5800},
252 {RT5677_DSP_INB3_SRC_CTRL2 , 0x0000},
253 {RT5677_DSP_INB3_SRC_CTRL3 , 0x0000},
254 {RT5677_DSP_INB3_SRC_CTRL4 , 0x0800},
255 {RT5677_DSP_OUTB1_SRC_CTRL1 , 0x5800},
256 {RT5677_DSP_OUTB1_SRC_CTRL2 , 0x0000},
257 {RT5677_DSP_OUTB1_SRC_CTRL3 , 0x0000},
258 {RT5677_DSP_OUTB1_SRC_CTRL4 , 0x0800},
259 {RT5677_DSP_OUTB2_SRC_CTRL1 , 0x5800},
260 {RT5677_DSP_OUTB2_SRC_CTRL2 , 0x0000},
261 {RT5677_DSP_OUTB2_SRC_CTRL3 , 0x0000},
262 {RT5677_DSP_OUTB2_SRC_CTRL4 , 0x0800},
263 {RT5677_DSP_OUTB_0123_MIXER_CTRL, 0xfefe},
264 {RT5677_DSP_OUTB_45_MIXER_CTRL , 0xfefe},
265 {RT5677_DSP_OUTB_67_MIXER_CTRL , 0xfefe},
266 {RT5677_DIG_MISC , 0x0000},
267 {RT5677_GEN_CTRL1 , 0x0000},
268 {RT5677_GEN_CTRL2 , 0x0000},
269 {RT5677_VENDOR_ID , 0x0000},
270 {RT5677_VENDOR_ID1 , 0x10ec},
271 {RT5677_VENDOR_ID2 , 0x6327},
272};
273
274static bool rt5677_volatile_register(struct device *dev, unsigned int reg)
275{
276 int i;
277
278 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
279 if (reg >= rt5677_ranges[i].range_min &&
280 reg <= rt5677_ranges[i].range_max) {
281 return true;
282 }
283 }
284
285 switch (reg) {
286 case RT5677_RESET:
287 case RT5677_SLIMBUS_PARAM:
288 case RT5677_PDM_DATA_CTRL1:
289 case RT5677_PDM_DATA_CTRL2:
290 case RT5677_PDM1_DATA_CTRL4:
291 case RT5677_PDM2_DATA_CTRL4:
292 case RT5677_I2C_MASTER_CTRL1:
293 case RT5677_I2C_MASTER_CTRL7:
294 case RT5677_I2C_MASTER_CTRL8:
295 case RT5677_HAP_GENE_CTRL2:
296 case RT5677_PWR_DSP_ST:
297 case RT5677_PRIV_DATA:
298 case RT5677_PLL1_CTRL2:
299 case RT5677_PLL2_CTRL2:
300 case RT5677_ASRC_22:
301 case RT5677_ASRC_23:
302 case RT5677_VAD_CTRL5:
303 case RT5677_ADC_EQ_CTRL1:
304 case RT5677_EQ_CTRL1:
305 case RT5677_IRQ_CTRL1:
306 case RT5677_IRQ_CTRL2:
307 case RT5677_GPIO_ST:
308 case RT5677_DSP_INB1_SRC_CTRL4:
309 case RT5677_DSP_INB2_SRC_CTRL4:
310 case RT5677_DSP_INB3_SRC_CTRL4:
311 case RT5677_DSP_OUTB1_SRC_CTRL4:
312 case RT5677_DSP_OUTB2_SRC_CTRL4:
313 case RT5677_VENDOR_ID:
314 case RT5677_VENDOR_ID1:
315 case RT5677_VENDOR_ID2:
316 return true;
317 default:
318 return false;
319 }
320}
321
322static bool rt5677_readable_register(struct device *dev, unsigned int reg)
323{
324 int i;
325
326 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
327 if (reg >= rt5677_ranges[i].range_min &&
328 reg <= rt5677_ranges[i].range_max) {
329 return true;
330 }
331 }
332
333 switch (reg) {
334 case RT5677_RESET:
335 case RT5677_LOUT1:
336 case RT5677_IN1:
337 case RT5677_MICBIAS:
338 case RT5677_SLIMBUS_PARAM:
339 case RT5677_SLIMBUS_RX:
340 case RT5677_SLIMBUS_CTRL:
341 case RT5677_SIDETONE_CTRL:
342 case RT5677_ANA_DAC1_2_3_SRC:
343 case RT5677_IF_DSP_DAC3_4_MIXER:
344 case RT5677_DAC4_DIG_VOL:
345 case RT5677_DAC3_DIG_VOL:
346 case RT5677_DAC1_DIG_VOL:
347 case RT5677_DAC2_DIG_VOL:
348 case RT5677_IF_DSP_DAC2_MIXER:
349 case RT5677_STO1_ADC_DIG_VOL:
350 case RT5677_MONO_ADC_DIG_VOL:
351 case RT5677_STO1_2_ADC_BST:
352 case RT5677_STO2_ADC_DIG_VOL:
353 case RT5677_ADC_BST_CTRL2:
354 case RT5677_STO3_4_ADC_BST:
355 case RT5677_STO3_ADC_DIG_VOL:
356 case RT5677_STO4_ADC_DIG_VOL:
357 case RT5677_STO4_ADC_MIXER:
358 case RT5677_STO3_ADC_MIXER:
359 case RT5677_STO2_ADC_MIXER:
360 case RT5677_STO1_ADC_MIXER:
361 case RT5677_MONO_ADC_MIXER:
362 case RT5677_ADC_IF_DSP_DAC1_MIXER:
363 case RT5677_STO1_DAC_MIXER:
364 case RT5677_MONO_DAC_MIXER:
365 case RT5677_DD1_MIXER:
366 case RT5677_DD2_MIXER:
367 case RT5677_IF3_DATA:
368 case RT5677_IF4_DATA:
369 case RT5677_PDM_OUT_CTRL:
370 case RT5677_PDM_DATA_CTRL1:
371 case RT5677_PDM_DATA_CTRL2:
372 case RT5677_PDM1_DATA_CTRL2:
373 case RT5677_PDM1_DATA_CTRL3:
374 case RT5677_PDM1_DATA_CTRL4:
375 case RT5677_PDM2_DATA_CTRL2:
376 case RT5677_PDM2_DATA_CTRL3:
377 case RT5677_PDM2_DATA_CTRL4:
378 case RT5677_TDM1_CTRL1:
379 case RT5677_TDM1_CTRL2:
380 case RT5677_TDM1_CTRL3:
381 case RT5677_TDM1_CTRL4:
382 case RT5677_TDM1_CTRL5:
383 case RT5677_TDM2_CTRL1:
384 case RT5677_TDM2_CTRL2:
385 case RT5677_TDM2_CTRL3:
386 case RT5677_TDM2_CTRL4:
387 case RT5677_TDM2_CTRL5:
388 case RT5677_I2C_MASTER_CTRL1:
389 case RT5677_I2C_MASTER_CTRL2:
390 case RT5677_I2C_MASTER_CTRL3:
391 case RT5677_I2C_MASTER_CTRL4:
392 case RT5677_I2C_MASTER_CTRL5:
393 case RT5677_I2C_MASTER_CTRL6:
394 case RT5677_I2C_MASTER_CTRL7:
395 case RT5677_I2C_MASTER_CTRL8:
396 case RT5677_DMIC_CTRL1:
397 case RT5677_DMIC_CTRL2:
398 case RT5677_HAP_GENE_CTRL1:
399 case RT5677_HAP_GENE_CTRL2:
400 case RT5677_HAP_GENE_CTRL3:
401 case RT5677_HAP_GENE_CTRL4:
402 case RT5677_HAP_GENE_CTRL5:
403 case RT5677_HAP_GENE_CTRL6:
404 case RT5677_HAP_GENE_CTRL7:
405 case RT5677_HAP_GENE_CTRL8:
406 case RT5677_HAP_GENE_CTRL9:
407 case RT5677_HAP_GENE_CTRL10:
408 case RT5677_PWR_DIG1:
409 case RT5677_PWR_DIG2:
410 case RT5677_PWR_ANLG1:
411 case RT5677_PWR_ANLG2:
412 case RT5677_PWR_DSP1:
413 case RT5677_PWR_DSP_ST:
414 case RT5677_PWR_DSP2:
415 case RT5677_ADC_DAC_HPF_CTRL1:
416 case RT5677_PRIV_INDEX:
417 case RT5677_PRIV_DATA:
418 case RT5677_I2S4_SDP:
419 case RT5677_I2S1_SDP:
420 case RT5677_I2S2_SDP:
421 case RT5677_I2S3_SDP:
422 case RT5677_CLK_TREE_CTRL1:
423 case RT5677_CLK_TREE_CTRL2:
424 case RT5677_CLK_TREE_CTRL3:
425 case RT5677_PLL1_CTRL1:
426 case RT5677_PLL1_CTRL2:
427 case RT5677_PLL2_CTRL1:
428 case RT5677_PLL2_CTRL2:
429 case RT5677_GLB_CLK1:
430 case RT5677_GLB_CLK2:
431 case RT5677_ASRC_1:
432 case RT5677_ASRC_2:
433 case RT5677_ASRC_3:
434 case RT5677_ASRC_4:
435 case RT5677_ASRC_5:
436 case RT5677_ASRC_6:
437 case RT5677_ASRC_7:
438 case RT5677_ASRC_8:
439 case RT5677_ASRC_9:
440 case RT5677_ASRC_10:
441 case RT5677_ASRC_11:
442 case RT5677_ASRC_12:
443 case RT5677_ASRC_13:
444 case RT5677_ASRC_14:
445 case RT5677_ASRC_15:
446 case RT5677_ASRC_16:
447 case RT5677_ASRC_17:
448 case RT5677_ASRC_18:
449 case RT5677_ASRC_19:
450 case RT5677_ASRC_20:
451 case RT5677_ASRC_21:
452 case RT5677_ASRC_22:
453 case RT5677_ASRC_23:
454 case RT5677_VAD_CTRL1:
455 case RT5677_VAD_CTRL2:
456 case RT5677_VAD_CTRL3:
457 case RT5677_VAD_CTRL4:
458 case RT5677_VAD_CTRL5:
459 case RT5677_DSP_INB_CTRL1:
460 case RT5677_DSP_INB_CTRL2:
461 case RT5677_DSP_IN_OUTB_CTRL:
462 case RT5677_DSP_OUTB0_1_DIG_VOL:
463 case RT5677_DSP_OUTB2_3_DIG_VOL:
464 case RT5677_DSP_OUTB4_5_DIG_VOL:
465 case RT5677_DSP_OUTB6_7_DIG_VOL:
466 case RT5677_ADC_EQ_CTRL1:
467 case RT5677_ADC_EQ_CTRL2:
468 case RT5677_EQ_CTRL1:
469 case RT5677_EQ_CTRL2:
470 case RT5677_EQ_CTRL3:
471 case RT5677_SOFT_VOL_ZERO_CROSS1:
472 case RT5677_JD_CTRL1:
473 case RT5677_JD_CTRL2:
474 case RT5677_JD_CTRL3:
475 case RT5677_IRQ_CTRL1:
476 case RT5677_IRQ_CTRL2:
477 case RT5677_GPIO_ST:
478 case RT5677_GPIO_CTRL1:
479 case RT5677_GPIO_CTRL2:
480 case RT5677_GPIO_CTRL3:
481 case RT5677_STO1_ADC_HI_FILTER1:
482 case RT5677_STO1_ADC_HI_FILTER2:
483 case RT5677_MONO_ADC_HI_FILTER1:
484 case RT5677_MONO_ADC_HI_FILTER2:
485 case RT5677_STO2_ADC_HI_FILTER1:
486 case RT5677_STO2_ADC_HI_FILTER2:
487 case RT5677_STO3_ADC_HI_FILTER1:
488 case RT5677_STO3_ADC_HI_FILTER2:
489 case RT5677_STO4_ADC_HI_FILTER1:
490 case RT5677_STO4_ADC_HI_FILTER2:
491 case RT5677_MB_DRC_CTRL1:
492 case RT5677_DRC1_CTRL1:
493 case RT5677_DRC1_CTRL2:
494 case RT5677_DRC1_CTRL3:
495 case RT5677_DRC1_CTRL4:
496 case RT5677_DRC1_CTRL5:
497 case RT5677_DRC1_CTRL6:
498 case RT5677_DRC2_CTRL1:
499 case RT5677_DRC2_CTRL2:
500 case RT5677_DRC2_CTRL3:
501 case RT5677_DRC2_CTRL4:
502 case RT5677_DRC2_CTRL5:
503 case RT5677_DRC2_CTRL6:
504 case RT5677_DRC1_HL_CTRL1:
505 case RT5677_DRC1_HL_CTRL2:
506 case RT5677_DRC2_HL_CTRL1:
507 case RT5677_DRC2_HL_CTRL2:
508 case RT5677_DSP_INB1_SRC_CTRL1:
509 case RT5677_DSP_INB1_SRC_CTRL2:
510 case RT5677_DSP_INB1_SRC_CTRL3:
511 case RT5677_DSP_INB1_SRC_CTRL4:
512 case RT5677_DSP_INB2_SRC_CTRL1:
513 case RT5677_DSP_INB2_SRC_CTRL2:
514 case RT5677_DSP_INB2_SRC_CTRL3:
515 case RT5677_DSP_INB2_SRC_CTRL4:
516 case RT5677_DSP_INB3_SRC_CTRL1:
517 case RT5677_DSP_INB3_SRC_CTRL2:
518 case RT5677_DSP_INB3_SRC_CTRL3:
519 case RT5677_DSP_INB3_SRC_CTRL4:
520 case RT5677_DSP_OUTB1_SRC_CTRL1:
521 case RT5677_DSP_OUTB1_SRC_CTRL2:
522 case RT5677_DSP_OUTB1_SRC_CTRL3:
523 case RT5677_DSP_OUTB1_SRC_CTRL4:
524 case RT5677_DSP_OUTB2_SRC_CTRL1:
525 case RT5677_DSP_OUTB2_SRC_CTRL2:
526 case RT5677_DSP_OUTB2_SRC_CTRL3:
527 case RT5677_DSP_OUTB2_SRC_CTRL4:
528 case RT5677_DSP_OUTB_0123_MIXER_CTRL:
529 case RT5677_DSP_OUTB_45_MIXER_CTRL:
530 case RT5677_DSP_OUTB_67_MIXER_CTRL:
531 case RT5677_DIG_MISC:
532 case RT5677_GEN_CTRL1:
533 case RT5677_GEN_CTRL2:
534 case RT5677_VENDOR_ID:
535 case RT5677_VENDOR_ID1:
536 case RT5677_VENDOR_ID2:
537 return true;
538 default:
539 return false;
540 }
541}
542
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800543/**
544 * rt5677_dsp_mode_i2c_write_addr - Write value to address on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800545 * @rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800546 * @addr: Address index.
547 * @value: Address data.
548 *
549 *
550 * Returns 0 for success or negative error code.
551 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800552static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800553 unsigned int addr, unsigned int value, unsigned int opcode)
554{
Oder Chiou19ba4842014-11-05 13:42:53 +0800555 struct snd_soc_codec *codec = rt5677->codec;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800556 int ret;
557
558 mutex_lock(&rt5677->dsp_cmd_lock);
559
Oder Chiou19ba4842014-11-05 13:42:53 +0800560 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
561 addr >> 16);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800562 if (ret < 0) {
563 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
564 goto err;
565 }
566
Oder Chiou19ba4842014-11-05 13:42:53 +0800567 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800568 addr & 0xffff);
569 if (ret < 0) {
570 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
571 goto err;
572 }
573
Oder Chiou19ba4842014-11-05 13:42:53 +0800574 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800575 value >> 16);
576 if (ret < 0) {
577 dev_err(codec->dev, "Failed to set data msb value: %d\n", ret);
578 goto err;
579 }
580
Oder Chiou19ba4842014-11-05 13:42:53 +0800581 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800582 value & 0xffff);
583 if (ret < 0) {
584 dev_err(codec->dev, "Failed to set data lsb value: %d\n", ret);
585 goto err;
586 }
587
Oder Chiou19ba4842014-11-05 13:42:53 +0800588 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
589 opcode);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800590 if (ret < 0) {
591 dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
592 goto err;
593 }
594
595err:
596 mutex_unlock(&rt5677->dsp_cmd_lock);
597
598 return ret;
599}
600
601/**
602 * rt5677_dsp_mode_i2c_read_addr - Read value from address on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800603 * rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800604 * @addr: Address index.
605 * @value: Address data.
606 *
Oder Chiou19ba4842014-11-05 13:42:53 +0800607 *
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800608 * Returns 0 for success or negative error code.
609 */
610static int rt5677_dsp_mode_i2c_read_addr(
Oder Chiou19ba4842014-11-05 13:42:53 +0800611 struct rt5677_priv *rt5677, unsigned int addr, unsigned int *value)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800612{
Oder Chiou19ba4842014-11-05 13:42:53 +0800613 struct snd_soc_codec *codec = rt5677->codec;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800614 int ret;
615 unsigned int msb, lsb;
616
617 mutex_lock(&rt5677->dsp_cmd_lock);
618
Oder Chiou19ba4842014-11-05 13:42:53 +0800619 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
620 addr >> 16);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800621 if (ret < 0) {
622 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
623 goto err;
624 }
625
Oder Chiou19ba4842014-11-05 13:42:53 +0800626 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800627 addr & 0xffff);
628 if (ret < 0) {
629 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
630 goto err;
631 }
632
Oder Chiou19ba4842014-11-05 13:42:53 +0800633 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
634 0x0002);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800635 if (ret < 0) {
636 dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
637 goto err;
638 }
639
Oder Chiou19ba4842014-11-05 13:42:53 +0800640 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, &msb);
641 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, &lsb);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800642 *value = (msb << 16) | lsb;
643
644err:
645 mutex_unlock(&rt5677->dsp_cmd_lock);
646
647 return ret;
648}
649
650/**
651 * rt5677_dsp_mode_i2c_write - Write register on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800652 * rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800653 * @reg: Register index.
654 * @value: Register data.
655 *
656 *
657 * Returns 0 for success or negative error code.
658 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800659static int rt5677_dsp_mode_i2c_write(struct rt5677_priv *rt5677,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800660 unsigned int reg, unsigned int value)
661{
Oder Chiou19ba4842014-11-05 13:42:53 +0800662 return rt5677_dsp_mode_i2c_write_addr(rt5677, 0x18020000 + reg * 2,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800663 value, 0x0001);
664}
665
666/**
667 * rt5677_dsp_mode_i2c_read - Read register on DSP mode.
668 * @codec: SoC audio codec device.
669 * @reg: Register index.
Oder Chiou19ba4842014-11-05 13:42:53 +0800670 * @value: Register data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800671 *
672 *
Oder Chiou19ba4842014-11-05 13:42:53 +0800673 * Returns 0 for success or negative error code.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800674 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800675static int rt5677_dsp_mode_i2c_read(
676 struct rt5677_priv *rt5677, unsigned int reg, unsigned int *value)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800677{
Oder Chiou19ba4842014-11-05 13:42:53 +0800678 int ret = rt5677_dsp_mode_i2c_read_addr(rt5677, 0x18020000 + reg * 2,
679 value);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800680
Oder Chiou19ba4842014-11-05 13:42:53 +0800681 *value &= 0xffff;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800682
Oder Chiou19ba4842014-11-05 13:42:53 +0800683 return ret;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800684}
685
Oder Chiou19ba4842014-11-05 13:42:53 +0800686static void rt5677_set_dsp_mode(struct snd_soc_codec *codec, bool on)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800687{
Oder Chiou19ba4842014-11-05 13:42:53 +0800688 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800689
Oder Chiou19ba4842014-11-05 13:42:53 +0800690 if (on) {
691 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x2);
692 rt5677->is_dsp_mode = true;
693 } else {
694 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x0);
695 rt5677->is_dsp_mode = false;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800696 }
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800697}
698
699static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
700{
701 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
702 static bool activity;
703 int ret;
704
705 if (on && !activity) {
706 activity = true;
707
708 regcache_cache_only(rt5677->regmap, false);
709 regcache_cache_bypass(rt5677->regmap, true);
710
711 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x1);
712 regmap_update_bits(rt5677->regmap,
713 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0f00);
714 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
715 RT5677_LDO1_SEL_MASK, 0x0);
716 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
717 RT5677_PWR_LDO1, RT5677_PWR_LDO1);
Oder Chiou19ba4842014-11-05 13:42:53 +0800718 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
719 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC);
720 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
721 RT5677_PLL2_PR_SRC_MASK | RT5677_DSP_CLK_SRC_MASK,
722 RT5677_PLL2_PR_SRC_MCLK2 | RT5677_DSP_CLK_SRC_BYPASS);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800723 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff);
Oder Chiou19ba4842014-11-05 13:42:53 +0800724 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd);
725 rt5677_set_dsp_mode(codec, true);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800726
727 ret = request_firmware(&rt5677->fw1, RT5677_FIRMWARE1,
728 codec->dev);
729 if (ret == 0) {
730 rt5677_spi_burst_write(0x50000000, rt5677->fw1);
731 release_firmware(rt5677->fw1);
732 }
733
734 ret = request_firmware(&rt5677->fw2, RT5677_FIRMWARE2,
735 codec->dev);
736 if (ret == 0) {
737 rt5677_spi_burst_write(0x60000000, rt5677->fw2);
738 release_firmware(rt5677->fw2);
739 }
740
Oder Chiou19ba4842014-11-05 13:42:53 +0800741 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x0);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800742
743 regcache_cache_bypass(rt5677->regmap, false);
744 regcache_cache_only(rt5677->regmap, true);
745 } else if (!on && activity) {
746 activity = false;
747
748 regcache_cache_only(rt5677->regmap, false);
749 regcache_cache_bypass(rt5677->regmap, true);
750
Oder Chiou19ba4842014-11-05 13:42:53 +0800751 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x1);
752 rt5677_set_dsp_mode(codec, false);
753 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x0001);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800754
755 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
756
757 regcache_cache_bypass(rt5677->regmap, false);
758 regcache_mark_dirty(rt5677->regmap);
759 regcache_sync(rt5677->regmap);
760 }
761
762 return 0;
763}
764
Oder Chiou0e826e82014-05-26 20:32:33 +0800765static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
Dylan Reid40e32622014-12-04 17:00:13 -0800766static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800767static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
Dylan Reid40e32622014-12-04 17:00:13 -0800768static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800769static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
Oder Chiou90bdbb42014-09-18 14:45:59 +0800770static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800771
772/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
773static unsigned int bst_tlv[] = {
774 TLV_DB_RANGE_HEAD(7),
775 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
776 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
777 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
778 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
779 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
780 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
781 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0),
782};
783
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800784static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
785 struct snd_ctl_elem_value *ucontrol)
786{
787 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
788 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
789
790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en;
791
792 return 0;
793}
794
795static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol,
796 struct snd_ctl_elem_value *ucontrol)
797{
798 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
799 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
800
801 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0];
802
803 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
804 rt5677_set_dsp_vad(codec, rt5677->dsp_vad_en);
805
806 return 0;
807}
808
Oder Chiou0e826e82014-05-26 20:32:33 +0800809static const struct snd_kcontrol_new rt5677_snd_controls[] = {
810 /* OUTPUT Control */
811 SOC_SINGLE("OUT1 Playback Switch", RT5677_LOUT1,
812 RT5677_LOUT1_L_MUTE_SFT, 1, 1),
813 SOC_SINGLE("OUT2 Playback Switch", RT5677_LOUT1,
814 RT5677_LOUT2_L_MUTE_SFT, 1, 1),
815 SOC_SINGLE("OUT3 Playback Switch", RT5677_LOUT1,
816 RT5677_LOUT3_L_MUTE_SFT, 1, 1),
817
818 /* DAC Digital Volume */
819 SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5677_DAC1_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800820 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800821 SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5677_DAC2_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800822 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800823 SOC_DOUBLE_TLV("DAC3 Playback Volume", RT5677_DAC3_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800824 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800825 SOC_DOUBLE_TLV("DAC4 Playback Volume", RT5677_DAC4_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800826 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800827
828 /* IN1/IN2 Control */
829 SOC_SINGLE_TLV("IN1 Boost", RT5677_IN1, RT5677_BST_SFT1, 8, 0, bst_tlv),
830 SOC_SINGLE_TLV("IN2 Boost", RT5677_IN1, RT5677_BST_SFT2, 8, 0, bst_tlv),
831
832 /* ADC Digital Volume Control */
833 SOC_DOUBLE("ADC1 Capture Switch", RT5677_STO1_ADC_DIG_VOL,
834 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
835 SOC_DOUBLE("ADC2 Capture Switch", RT5677_STO2_ADC_DIG_VOL,
836 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
837 SOC_DOUBLE("ADC3 Capture Switch", RT5677_STO3_ADC_DIG_VOL,
838 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
839 SOC_DOUBLE("ADC4 Capture Switch", RT5677_STO4_ADC_DIG_VOL,
840 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
841 SOC_DOUBLE("Mono ADC Capture Switch", RT5677_MONO_ADC_DIG_VOL,
842 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
843
844 SOC_DOUBLE_TLV("ADC1 Capture Volume", RT5677_STO1_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800845 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800846 adc_vol_tlv),
847 SOC_DOUBLE_TLV("ADC2 Capture Volume", RT5677_STO2_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800848 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800849 adc_vol_tlv),
850 SOC_DOUBLE_TLV("ADC3 Capture Volume", RT5677_STO3_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800851 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800852 adc_vol_tlv),
853 SOC_DOUBLE_TLV("ADC4 Capture Volume", RT5677_STO4_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800854 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800855 adc_vol_tlv),
856 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5677_MONO_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800857 RT5677_MONO_ADC_L_VOL_SFT, RT5677_MONO_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800858 adc_vol_tlv),
859
Oder Chiou90bdbb42014-09-18 14:45:59 +0800860 /* Sidetone Control */
861 SOC_SINGLE_TLV("Sidetone Volume", RT5677_SIDETONE_CTRL,
862 RT5677_ST_VOL_SFT, 31, 0, st_vol_tlv),
863
Oder Chiou0e826e82014-05-26 20:32:33 +0800864 /* ADC Boost Volume Control */
Oder Chiou80220f22014-06-10 14:35:25 +0800865 SOC_DOUBLE_TLV("STO1 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800866 RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0,
867 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800868 SOC_DOUBLE_TLV("STO2 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800869 RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0,
870 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800871 SOC_DOUBLE_TLV("STO3 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800872 RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0,
873 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800874 SOC_DOUBLE_TLV("STO4 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800875 RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0,
876 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800877 SOC_DOUBLE_TLV("Mono ADC Boost Volume", RT5677_ADC_BST_CTRL2,
Oder Chiou0e826e82014-05-26 20:32:33 +0800878 RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0,
879 adc_bst_tlv),
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800880
881 SOC_SINGLE_EXT("DSP VAD Switch", SND_SOC_NOPM, 0, 1, 0,
882 rt5677_dsp_vad_get, rt5677_dsp_vad_put),
Oder Chiou0e826e82014-05-26 20:32:33 +0800883};
884
885/**
886 * set_dmic_clk - Set parameter of dmic.
887 *
888 * @w: DAPM widget.
889 * @kcontrol: The kcontrol of this widget.
890 * @event: Event id.
891 *
892 * Choose dmic clock between 1MHz and 3MHz.
893 * It is better for clock to approximate 3MHz.
894 */
895static int set_dmic_clk(struct snd_soc_dapm_widget *w,
896 struct snd_kcontrol *kcontrol, int event)
897{
898 struct snd_soc_codec *codec = w->codec;
899 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Axel Lin9a535812014-06-03 10:58:58 +0800900 int idx = rl6231_calc_dmic_clk(rt5677->sysclk);
Oder Chiou0e826e82014-05-26 20:32:33 +0800901
902 if (idx < 0)
903 dev_err(codec->dev, "Failed to set DMIC clock\n");
904 else
905 regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1,
906 RT5677_DMIC_CLK_MASK, idx << RT5677_DMIC_CLK_SFT);
907 return idx;
908}
909
910static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
911 struct snd_soc_dapm_widget *sink)
912{
913 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(source->codec);
914 unsigned int val;
915
916 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val);
917 val &= RT5677_SCLK_SRC_MASK;
918 if (val == RT5677_SCLK_SRC_PLL1)
919 return 1;
920 else
921 return 0;
922}
923
Oder Chiou5a8c7c22014-12-23 10:27:55 +0800924static int is_using_asrc(struct snd_soc_dapm_widget *source,
925 struct snd_soc_dapm_widget *sink)
926{
Oder Chioue4b7e6a2015-01-13 11:13:14 +0800927 struct snd_soc_codec *codec = source->codec;
928 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou5a8c7c22014-12-23 10:27:55 +0800929 unsigned int reg, shift, val;
930
931 if (source->reg == RT5677_ASRC_1) {
932 switch (source->shift) {
933 case 12:
934 reg = RT5677_ASRC_4;
935 shift = 0;
936 break;
937 case 13:
938 reg = RT5677_ASRC_4;
939 shift = 4;
940 break;
941 case 14:
942 reg = RT5677_ASRC_4;
943 shift = 8;
944 break;
945 case 15:
946 reg = RT5677_ASRC_4;
947 shift = 12;
948 break;
949 default:
950 return 0;
951 }
952 } else {
953 switch (source->shift) {
954 case 0:
955 reg = RT5677_ASRC_6;
956 shift = 8;
957 break;
958 case 1:
959 reg = RT5677_ASRC_6;
960 shift = 12;
961 break;
962 case 2:
963 reg = RT5677_ASRC_5;
964 shift = 0;
965 break;
966 case 3:
967 reg = RT5677_ASRC_5;
968 shift = 4;
969 break;
970 case 4:
971 reg = RT5677_ASRC_5;
972 shift = 8;
973 break;
974 case 5:
975 reg = RT5677_ASRC_5;
976 shift = 12;
977 break;
978 case 12:
979 reg = RT5677_ASRC_3;
980 shift = 0;
981 break;
982 case 13:
983 reg = RT5677_ASRC_3;
984 shift = 4;
985 break;
986 case 14:
987 reg = RT5677_ASRC_3;
988 shift = 12;
989 break;
990 default:
991 return 0;
992 }
993 }
994
Oder Chioue4b7e6a2015-01-13 11:13:14 +0800995 regmap_read(rt5677->regmap, reg, &val);
996 val = (val >> shift) & 0xf;
997
Oder Chiou5a8c7c22014-12-23 10:27:55 +0800998 switch (val) {
999 case 1 ... 6:
1000 return 1;
1001 default:
1002 return 0;
1003 }
1004
1005}
1006
1007static int can_use_asrc(struct snd_soc_dapm_widget *source,
1008 struct snd_soc_dapm_widget *sink)
1009{
1010 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
1011 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
1012
1013 if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384)
1014 return 1;
1015
1016 return 0;
1017}
1018
Oder Chiou0e826e82014-05-26 20:32:33 +08001019/* Digital Mixer */
1020static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = {
1021 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
1022 RT5677_M_STO1_ADC_L1_SFT, 1, 1),
1023 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
1024 RT5677_M_STO1_ADC_L2_SFT, 1, 1),
1025};
1026
1027static const struct snd_kcontrol_new rt5677_sto1_adc_r_mix[] = {
1028 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
1029 RT5677_M_STO1_ADC_R1_SFT, 1, 1),
1030 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
1031 RT5677_M_STO1_ADC_R2_SFT, 1, 1),
1032};
1033
1034static const struct snd_kcontrol_new rt5677_sto2_adc_l_mix[] = {
1035 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
1036 RT5677_M_STO2_ADC_L1_SFT, 1, 1),
1037 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
1038 RT5677_M_STO2_ADC_L2_SFT, 1, 1),
1039};
1040
1041static const struct snd_kcontrol_new rt5677_sto2_adc_r_mix[] = {
1042 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
1043 RT5677_M_STO2_ADC_R1_SFT, 1, 1),
1044 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
1045 RT5677_M_STO2_ADC_R2_SFT, 1, 1),
1046};
1047
1048static const struct snd_kcontrol_new rt5677_sto3_adc_l_mix[] = {
1049 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
1050 RT5677_M_STO3_ADC_L1_SFT, 1, 1),
1051 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
1052 RT5677_M_STO3_ADC_L2_SFT, 1, 1),
1053};
1054
1055static const struct snd_kcontrol_new rt5677_sto3_adc_r_mix[] = {
1056 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
1057 RT5677_M_STO3_ADC_R1_SFT, 1, 1),
1058 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
1059 RT5677_M_STO3_ADC_R2_SFT, 1, 1),
1060};
1061
1062static const struct snd_kcontrol_new rt5677_sto4_adc_l_mix[] = {
1063 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
1064 RT5677_M_STO4_ADC_L1_SFT, 1, 1),
1065 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
1066 RT5677_M_STO4_ADC_L2_SFT, 1, 1),
1067};
1068
1069static const struct snd_kcontrol_new rt5677_sto4_adc_r_mix[] = {
1070 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
1071 RT5677_M_STO4_ADC_R1_SFT, 1, 1),
1072 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
1073 RT5677_M_STO4_ADC_R2_SFT, 1, 1),
1074};
1075
1076static const struct snd_kcontrol_new rt5677_mono_adc_l_mix[] = {
1077 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
1078 RT5677_M_MONO_ADC_L1_SFT, 1, 1),
1079 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
1080 RT5677_M_MONO_ADC_L2_SFT, 1, 1),
1081};
1082
1083static const struct snd_kcontrol_new rt5677_mono_adc_r_mix[] = {
1084 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
1085 RT5677_M_MONO_ADC_R1_SFT, 1, 1),
1086 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
1087 RT5677_M_MONO_ADC_R2_SFT, 1, 1),
1088};
1089
1090static const struct snd_kcontrol_new rt5677_dac_l_mix[] = {
1091 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1092 RT5677_M_ADDA_MIXER1_L_SFT, 1, 1),
1093 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1094 RT5677_M_DAC1_L_SFT, 1, 1),
1095};
1096
1097static const struct snd_kcontrol_new rt5677_dac_r_mix[] = {
1098 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1099 RT5677_M_ADDA_MIXER1_R_SFT, 1, 1),
1100 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1101 RT5677_M_DAC1_R_SFT, 1, 1),
1102};
1103
1104static const struct snd_kcontrol_new rt5677_sto1_dac_l_mix[] = {
1105 SOC_DAPM_SINGLE("ST L Switch", RT5677_STO1_DAC_MIXER,
1106 RT5677_M_ST_DAC1_L_SFT, 1, 1),
1107 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
1108 RT5677_M_DAC1_L_STO_L_SFT, 1, 1),
1109 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_STO1_DAC_MIXER,
1110 RT5677_M_DAC2_L_STO_L_SFT, 1, 1),
1111 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
1112 RT5677_M_DAC1_R_STO_L_SFT, 1, 1),
1113};
1114
1115static const struct snd_kcontrol_new rt5677_sto1_dac_r_mix[] = {
1116 SOC_DAPM_SINGLE("ST R Switch", RT5677_STO1_DAC_MIXER,
1117 RT5677_M_ST_DAC1_R_SFT, 1, 1),
1118 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
1119 RT5677_M_DAC1_R_STO_R_SFT, 1, 1),
1120 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_STO1_DAC_MIXER,
1121 RT5677_M_DAC2_R_STO_R_SFT, 1, 1),
1122 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
1123 RT5677_M_DAC1_L_STO_R_SFT, 1, 1),
1124};
1125
1126static const struct snd_kcontrol_new rt5677_mono_dac_l_mix[] = {
1127 SOC_DAPM_SINGLE("ST L Switch", RT5677_MONO_DAC_MIXER,
1128 RT5677_M_ST_DAC2_L_SFT, 1, 1),
1129 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_MONO_DAC_MIXER,
1130 RT5677_M_DAC1_L_MONO_L_SFT, 1, 1),
1131 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
1132 RT5677_M_DAC2_L_MONO_L_SFT, 1, 1),
1133 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
1134 RT5677_M_DAC2_R_MONO_L_SFT, 1, 1),
1135};
1136
1137static const struct snd_kcontrol_new rt5677_mono_dac_r_mix[] = {
1138 SOC_DAPM_SINGLE("ST R Switch", RT5677_MONO_DAC_MIXER,
1139 RT5677_M_ST_DAC2_R_SFT, 1, 1),
1140 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_MONO_DAC_MIXER,
1141 RT5677_M_DAC1_R_MONO_R_SFT, 1, 1),
1142 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
1143 RT5677_M_DAC2_R_MONO_R_SFT, 1, 1),
1144 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
1145 RT5677_M_DAC2_L_MONO_R_SFT, 1, 1),
1146};
1147
1148static const struct snd_kcontrol_new rt5677_dd1_l_mix[] = {
1149 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD1_MIXER,
1150 RT5677_M_STO_L_DD1_L_SFT, 1, 1),
1151 SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD1_MIXER,
1152 RT5677_M_MONO_L_DD1_L_SFT, 1, 1),
1153 SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER,
1154 RT5677_M_DAC3_L_DD1_L_SFT, 1, 1),
1155 SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER,
1156 RT5677_M_DAC3_R_DD1_L_SFT, 1, 1),
1157};
1158
1159static const struct snd_kcontrol_new rt5677_dd1_r_mix[] = {
1160 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD1_MIXER,
1161 RT5677_M_STO_R_DD1_R_SFT, 1, 1),
1162 SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD1_MIXER,
1163 RT5677_M_MONO_R_DD1_R_SFT, 1, 1),
1164 SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER,
1165 RT5677_M_DAC3_R_DD1_R_SFT, 1, 1),
1166 SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER,
1167 RT5677_M_DAC3_L_DD1_R_SFT, 1, 1),
1168};
1169
1170static const struct snd_kcontrol_new rt5677_dd2_l_mix[] = {
1171 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD2_MIXER,
1172 RT5677_M_STO_L_DD2_L_SFT, 1, 1),
1173 SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD2_MIXER,
1174 RT5677_M_MONO_L_DD2_L_SFT, 1, 1),
1175 SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER,
1176 RT5677_M_DAC4_L_DD2_L_SFT, 1, 1),
1177 SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER,
1178 RT5677_M_DAC4_R_DD2_L_SFT, 1, 1),
1179};
1180
1181static const struct snd_kcontrol_new rt5677_dd2_r_mix[] = {
1182 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD2_MIXER,
1183 RT5677_M_STO_R_DD2_R_SFT, 1, 1),
1184 SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD2_MIXER,
1185 RT5677_M_MONO_R_DD2_R_SFT, 1, 1),
1186 SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER,
1187 RT5677_M_DAC4_R_DD2_R_SFT, 1, 1),
1188 SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER,
1189 RT5677_M_DAC4_L_DD2_R_SFT, 1, 1),
1190};
1191
1192static const struct snd_kcontrol_new rt5677_ob_01_mix[] = {
1193 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1194 RT5677_DSP_IB_01_H_SFT, 1, 1),
1195 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1196 RT5677_DSP_IB_23_H_SFT, 1, 1),
1197 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1198 RT5677_DSP_IB_45_H_SFT, 1, 1),
1199 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1200 RT5677_DSP_IB_6_H_SFT, 1, 1),
1201 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1202 RT5677_DSP_IB_7_H_SFT, 1, 1),
1203 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1204 RT5677_DSP_IB_8_H_SFT, 1, 1),
1205 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1206 RT5677_DSP_IB_9_H_SFT, 1, 1),
1207};
1208
1209static const struct snd_kcontrol_new rt5677_ob_23_mix[] = {
1210 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1211 RT5677_DSP_IB_01_L_SFT, 1, 1),
1212 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1213 RT5677_DSP_IB_23_L_SFT, 1, 1),
1214 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1215 RT5677_DSP_IB_45_L_SFT, 1, 1),
1216 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1217 RT5677_DSP_IB_6_L_SFT, 1, 1),
1218 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1219 RT5677_DSP_IB_7_L_SFT, 1, 1),
1220 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1221 RT5677_DSP_IB_8_L_SFT, 1, 1),
1222 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1223 RT5677_DSP_IB_9_L_SFT, 1, 1),
1224};
1225
1226static const struct snd_kcontrol_new rt5677_ob_4_mix[] = {
1227 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1228 RT5677_DSP_IB_01_H_SFT, 1, 1),
1229 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1230 RT5677_DSP_IB_23_H_SFT, 1, 1),
1231 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1232 RT5677_DSP_IB_45_H_SFT, 1, 1),
1233 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1234 RT5677_DSP_IB_6_H_SFT, 1, 1),
1235 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1236 RT5677_DSP_IB_7_H_SFT, 1, 1),
1237 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1238 RT5677_DSP_IB_8_H_SFT, 1, 1),
1239 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1240 RT5677_DSP_IB_9_H_SFT, 1, 1),
1241};
1242
1243static const struct snd_kcontrol_new rt5677_ob_5_mix[] = {
1244 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1245 RT5677_DSP_IB_01_L_SFT, 1, 1),
1246 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1247 RT5677_DSP_IB_23_L_SFT, 1, 1),
1248 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1249 RT5677_DSP_IB_45_L_SFT, 1, 1),
1250 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1251 RT5677_DSP_IB_6_L_SFT, 1, 1),
1252 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1253 RT5677_DSP_IB_7_L_SFT, 1, 1),
1254 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1255 RT5677_DSP_IB_8_L_SFT, 1, 1),
1256 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1257 RT5677_DSP_IB_9_L_SFT, 1, 1),
1258};
1259
1260static const struct snd_kcontrol_new rt5677_ob_6_mix[] = {
1261 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1262 RT5677_DSP_IB_01_H_SFT, 1, 1),
1263 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1264 RT5677_DSP_IB_23_H_SFT, 1, 1),
1265 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1266 RT5677_DSP_IB_45_H_SFT, 1, 1),
1267 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1268 RT5677_DSP_IB_6_H_SFT, 1, 1),
1269 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1270 RT5677_DSP_IB_7_H_SFT, 1, 1),
1271 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1272 RT5677_DSP_IB_8_H_SFT, 1, 1),
1273 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1274 RT5677_DSP_IB_9_H_SFT, 1, 1),
1275};
1276
1277static const struct snd_kcontrol_new rt5677_ob_7_mix[] = {
1278 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1279 RT5677_DSP_IB_01_L_SFT, 1, 1),
1280 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1281 RT5677_DSP_IB_23_L_SFT, 1, 1),
1282 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1283 RT5677_DSP_IB_45_L_SFT, 1, 1),
1284 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1285 RT5677_DSP_IB_6_L_SFT, 1, 1),
1286 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1287 RT5677_DSP_IB_7_L_SFT, 1, 1),
1288 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1289 RT5677_DSP_IB_8_L_SFT, 1, 1),
1290 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1291 RT5677_DSP_IB_9_L_SFT, 1, 1),
1292};
1293
1294
1295/* Mux */
Oder Chiou1b7fd762014-06-10 14:35:24 +08001296/* DAC1 L/R Source */ /* MX-29 [10:8] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001297static const char * const rt5677_dac1_src[] = {
1298 "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01",
1299 "OB 01"
1300};
1301
1302static SOC_ENUM_SINGLE_DECL(
1303 rt5677_dac1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
1304 RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src);
1305
1306static const struct snd_kcontrol_new rt5677_dac1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001307 SOC_DAPM_ENUM("DAC1 Source", rt5677_dac1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001308
Oder Chiou1b7fd762014-06-10 14:35:24 +08001309/* ADDA1 L/R Source */ /* MX-29 [1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001310static const char * const rt5677_adda1_src[] = {
1311 "STO1 ADC MIX", "STO2 ADC MIX", "OB 67",
1312};
1313
1314static SOC_ENUM_SINGLE_DECL(
1315 rt5677_adda1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
1316 RT5677_ADDA1_SEL_SFT, rt5677_adda1_src);
1317
1318static const struct snd_kcontrol_new rt5677_adda1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001319 SOC_DAPM_ENUM("ADDA1 Source", rt5677_adda1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001320
1321
Oder Chiou1b7fd762014-06-10 14:35:24 +08001322/*DAC2 L/R Source*/ /* MX-1B [6:4] [2:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001323static const char * const rt5677_dac2l_src[] = {
1324 "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2",
1325 "OB 2",
1326};
1327
1328static SOC_ENUM_SINGLE_DECL(
1329 rt5677_dac2l_enum, RT5677_IF_DSP_DAC2_MIXER,
1330 RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src);
1331
1332static const struct snd_kcontrol_new rt5677_dac2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001333 SOC_DAPM_ENUM("DAC2 L Source", rt5677_dac2l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001334
1335static const char * const rt5677_dac2r_src[] = {
1336 "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3",
1337 "OB 3", "Haptic Generator", "VAD ADC"
1338};
1339
1340static SOC_ENUM_SINGLE_DECL(
1341 rt5677_dac2r_enum, RT5677_IF_DSP_DAC2_MIXER,
1342 RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src);
1343
1344static const struct snd_kcontrol_new rt5677_dac2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001345 SOC_DAPM_ENUM("DAC2 R Source", rt5677_dac2r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001346
Oder Chiou1b7fd762014-06-10 14:35:24 +08001347/*DAC3 L/R Source*/ /* MX-16 [6:4] [2:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001348static const char * const rt5677_dac3l_src[] = {
1349 "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L",
1350 "SLB DAC 4", "OB 4"
1351};
1352
1353static SOC_ENUM_SINGLE_DECL(
1354 rt5677_dac3l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1355 RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src);
1356
1357static const struct snd_kcontrol_new rt5677_dac3_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001358 SOC_DAPM_ENUM("DAC3 L Source", rt5677_dac3l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001359
1360static const char * const rt5677_dac3r_src[] = {
1361 "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R",
1362 "SLB DAC 5", "OB 5"
1363};
1364
1365static SOC_ENUM_SINGLE_DECL(
1366 rt5677_dac3r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1367 RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src);
1368
1369static const struct snd_kcontrol_new rt5677_dac3_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001370 SOC_DAPM_ENUM("DAC3 R Source", rt5677_dac3r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001371
Oder Chiou1b7fd762014-06-10 14:35:24 +08001372/*DAC4 L/R Source*/ /* MX-16 [14:12] [10:8] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001373static const char * const rt5677_dac4l_src[] = {
1374 "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L",
1375 "SLB DAC 6", "OB 6"
1376};
1377
1378static SOC_ENUM_SINGLE_DECL(
1379 rt5677_dac4l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1380 RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src);
1381
1382static const struct snd_kcontrol_new rt5677_dac4_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001383 SOC_DAPM_ENUM("DAC4 L Source", rt5677_dac4l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001384
1385static const char * const rt5677_dac4r_src[] = {
1386 "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R",
1387 "SLB DAC 7", "OB 7"
1388};
1389
1390static SOC_ENUM_SINGLE_DECL(
1391 rt5677_dac4r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1392 RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src);
1393
1394static const struct snd_kcontrol_new rt5677_dac4_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001395 SOC_DAPM_ENUM("DAC4 R Source", rt5677_dac4r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001396
1397/* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */
1398static const char * const rt5677_iob_bypass_src[] = {
1399 "Bypass", "Pass SRC"
1400};
1401
1402static SOC_ENUM_SINGLE_DECL(
1403 rt5677_ob01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1404 RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src);
1405
1406static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001407 SOC_DAPM_ENUM("OB01 Bypass Source", rt5677_ob01_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001408
1409static SOC_ENUM_SINGLE_DECL(
1410 rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1411 RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src);
1412
1413static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001414 SOC_DAPM_ENUM("OB23 Bypass Source", rt5677_ob23_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001415
1416static SOC_ENUM_SINGLE_DECL(
1417 rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1418 RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src);
1419
1420static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001421 SOC_DAPM_ENUM("IB01 Bypass Source", rt5677_ib01_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001422
1423static SOC_ENUM_SINGLE_DECL(
1424 rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1425 RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src);
1426
1427static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001428 SOC_DAPM_ENUM("IB23 Bypass Source", rt5677_ib23_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001429
1430static SOC_ENUM_SINGLE_DECL(
1431 rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1432 RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src);
1433
1434static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001435 SOC_DAPM_ENUM("IB45 Bypass Source", rt5677_ib45_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001436
Oder Chioud65fd3a2014-11-05 13:42:52 +08001437/* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001438static const char * const rt5677_stereo_adc2_src[] = {
1439 "DD MIX1", "DMIC", "Stereo DAC MIX"
1440};
1441
1442static SOC_ENUM_SINGLE_DECL(
1443 rt5677_stereo1_adc2_enum, RT5677_STO1_ADC_MIXER,
1444 RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src);
1445
1446static const struct snd_kcontrol_new rt5677_sto1_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001447 SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5677_stereo1_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001448
1449static SOC_ENUM_SINGLE_DECL(
1450 rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER,
1451 RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src);
1452
1453static const struct snd_kcontrol_new rt5677_sto2_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001454 SOC_DAPM_ENUM("Stereo2 ADC2 Source", rt5677_stereo2_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001455
1456static SOC_ENUM_SINGLE_DECL(
1457 rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER,
1458 RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src);
1459
1460static const struct snd_kcontrol_new rt5677_sto3_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001461 SOC_DAPM_ENUM("Stereo3 ADC2 Source", rt5677_stereo3_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001462
1463/* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */
1464static const char * const rt5677_dmic_src[] = {
1465 "DMIC1", "DMIC2", "DMIC3", "DMIC4"
1466};
1467
1468static SOC_ENUM_SINGLE_DECL(
1469 rt5677_mono_dmic_l_enum, RT5677_MONO_ADC_MIXER,
1470 RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src);
1471
1472static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001473 SOC_DAPM_ENUM("Mono DMIC L Source", rt5677_mono_dmic_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001474
1475static SOC_ENUM_SINGLE_DECL(
1476 rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER,
1477 RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src);
1478
1479static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001480 SOC_DAPM_ENUM("Mono DMIC R Source", rt5677_mono_dmic_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001481
1482static SOC_ENUM_SINGLE_DECL(
1483 rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER,
1484 RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src);
1485
1486static const struct snd_kcontrol_new rt5677_sto1_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001487 SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5677_stereo1_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001488
1489static SOC_ENUM_SINGLE_DECL(
1490 rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER,
1491 RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src);
1492
1493static const struct snd_kcontrol_new rt5677_sto2_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001494 SOC_DAPM_ENUM("Stereo2 DMIC Source", rt5677_stereo2_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001495
1496static SOC_ENUM_SINGLE_DECL(
1497 rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER,
1498 RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src);
1499
1500static const struct snd_kcontrol_new rt5677_sto3_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001501 SOC_DAPM_ENUM("Stereo3 DMIC Source", rt5677_stereo3_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001502
1503static SOC_ENUM_SINGLE_DECL(
1504 rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER,
1505 RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src);
1506
1507static const struct snd_kcontrol_new rt5677_sto4_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001508 SOC_DAPM_ENUM("Stereo4 DMIC Source", rt5677_stereo4_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001509
Oder Chiou1b7fd762014-06-10 14:35:24 +08001510/* Stereo2 ADC Source */ /* MX-26 [0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001511static const char * const rt5677_stereo2_adc_lr_src[] = {
1512 "L", "LR"
1513};
1514
1515static SOC_ENUM_SINGLE_DECL(
1516 rt5677_stereo2_adc_lr_enum, RT5677_STO2_ADC_MIXER,
1517 RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src);
1518
1519static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001520 SOC_DAPM_ENUM("Stereo2 ADC LR Source", rt5677_stereo2_adc_lr_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001521
Oder Chioud65fd3a2014-11-05 13:42:52 +08001522/* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001523static const char * const rt5677_stereo_adc1_src[] = {
1524 "DD MIX1", "ADC1/2", "Stereo DAC MIX"
1525};
1526
1527static SOC_ENUM_SINGLE_DECL(
1528 rt5677_stereo1_adc1_enum, RT5677_STO1_ADC_MIXER,
1529 RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src);
1530
1531static const struct snd_kcontrol_new rt5677_sto1_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001532 SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5677_stereo1_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001533
1534static SOC_ENUM_SINGLE_DECL(
1535 rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER,
1536 RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src);
1537
1538static const struct snd_kcontrol_new rt5677_sto2_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001539 SOC_DAPM_ENUM("Stereo2 ADC1 Source", rt5677_stereo2_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001540
1541static SOC_ENUM_SINGLE_DECL(
1542 rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER,
1543 RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src);
1544
1545static const struct snd_kcontrol_new rt5677_sto3_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001546 SOC_DAPM_ENUM("Stereo3 ADC1 Source", rt5677_stereo3_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001547
Oder Chiou1b7fd762014-06-10 14:35:24 +08001548/* Mono ADC Left Source 2 */ /* MX-28 [11:10] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001549static const char * const rt5677_mono_adc2_l_src[] = {
1550 "DD MIX1L", "DMIC", "MONO DAC MIXL"
1551};
1552
1553static SOC_ENUM_SINGLE_DECL(
1554 rt5677_mono_adc2_l_enum, RT5677_MONO_ADC_MIXER,
1555 RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src);
1556
1557static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001558 SOC_DAPM_ENUM("Mono ADC2 L Source", rt5677_mono_adc2_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001559
Oder Chiou1b7fd762014-06-10 14:35:24 +08001560/* Mono ADC Left Source 1 */ /* MX-28 [13:12] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001561static const char * const rt5677_mono_adc1_l_src[] = {
1562 "DD MIX1L", "ADC1", "MONO DAC MIXL"
1563};
1564
1565static SOC_ENUM_SINGLE_DECL(
1566 rt5677_mono_adc1_l_enum, RT5677_MONO_ADC_MIXER,
1567 RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src);
1568
1569static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001570 SOC_DAPM_ENUM("Mono ADC1 L Source", rt5677_mono_adc1_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001571
Oder Chiou1b7fd762014-06-10 14:35:24 +08001572/* Mono ADC Right Source 2 */ /* MX-28 [3:2] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001573static const char * const rt5677_mono_adc2_r_src[] = {
1574 "DD MIX1R", "DMIC", "MONO DAC MIXR"
1575};
1576
1577static SOC_ENUM_SINGLE_DECL(
1578 rt5677_mono_adc2_r_enum, RT5677_MONO_ADC_MIXER,
1579 RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src);
1580
1581static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001582 SOC_DAPM_ENUM("Mono ADC2 R Source", rt5677_mono_adc2_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001583
Oder Chiou1b7fd762014-06-10 14:35:24 +08001584/* Mono ADC Right Source 1 */ /* MX-28 [5:4] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001585static const char * const rt5677_mono_adc1_r_src[] = {
1586 "DD MIX1R", "ADC2", "MONO DAC MIXR"
1587};
1588
1589static SOC_ENUM_SINGLE_DECL(
1590 rt5677_mono_adc1_r_enum, RT5677_MONO_ADC_MIXER,
1591 RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src);
1592
1593static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001594 SOC_DAPM_ENUM("Mono ADC1 R Source", rt5677_mono_adc1_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001595
1596/* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */
1597static const char * const rt5677_stereo4_adc2_src[] = {
1598 "DD MIX1", "DMIC", "DD MIX2"
1599};
1600
1601static SOC_ENUM_SINGLE_DECL(
1602 rt5677_stereo4_adc2_enum, RT5677_STO4_ADC_MIXER,
1603 RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src);
1604
1605static const struct snd_kcontrol_new rt5677_sto4_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001606 SOC_DAPM_ENUM("Stereo4 ADC2 Source", rt5677_stereo4_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001607
1608
1609/* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */
1610static const char * const rt5677_stereo4_adc1_src[] = {
1611 "DD MIX1", "ADC1/2", "DD MIX2"
1612};
1613
1614static SOC_ENUM_SINGLE_DECL(
1615 rt5677_stereo4_adc1_enum, RT5677_STO4_ADC_MIXER,
1616 RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src);
1617
1618static const struct snd_kcontrol_new rt5677_sto4_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001619 SOC_DAPM_ENUM("Stereo4 ADC1 Source", rt5677_stereo4_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001620
1621/* InBound0/1 Source */ /* MX-A3 [14:12] */
1622static const char * const rt5677_inbound01_src[] = {
1623 "IF1 DAC 01", "IF2 DAC 01", "SLB DAC 01", "STO1 ADC MIX",
1624 "VAD ADC/DAC1 FS"
1625};
1626
1627static SOC_ENUM_SINGLE_DECL(
1628 rt5677_inbound01_enum, RT5677_DSP_INB_CTRL1,
1629 RT5677_IB01_SRC_SFT, rt5677_inbound01_src);
1630
1631static const struct snd_kcontrol_new rt5677_ib01_src_mux =
1632 SOC_DAPM_ENUM("InBound0/1 Source", rt5677_inbound01_enum);
1633
1634/* InBound2/3 Source */ /* MX-A3 [10:8] */
1635static const char * const rt5677_inbound23_src[] = {
1636 "IF1 DAC 23", "IF2 DAC 23", "SLB DAC 23", "STO2 ADC MIX",
1637 "DAC1 FS", "IF4 DAC"
1638};
1639
1640static SOC_ENUM_SINGLE_DECL(
1641 rt5677_inbound23_enum, RT5677_DSP_INB_CTRL1,
1642 RT5677_IB23_SRC_SFT, rt5677_inbound23_src);
1643
1644static const struct snd_kcontrol_new rt5677_ib23_src_mux =
1645 SOC_DAPM_ENUM("InBound2/3 Source", rt5677_inbound23_enum);
1646
1647/* InBound4/5 Source */ /* MX-A3 [6:4] */
1648static const char * const rt5677_inbound45_src[] = {
1649 "IF1 DAC 45", "IF2 DAC 45", "SLB DAC 45", "STO3 ADC MIX",
1650 "IF3 DAC"
1651};
1652
1653static SOC_ENUM_SINGLE_DECL(
1654 rt5677_inbound45_enum, RT5677_DSP_INB_CTRL1,
1655 RT5677_IB45_SRC_SFT, rt5677_inbound45_src);
1656
1657static const struct snd_kcontrol_new rt5677_ib45_src_mux =
1658 SOC_DAPM_ENUM("InBound4/5 Source", rt5677_inbound45_enum);
1659
1660/* InBound6 Source */ /* MX-A3 [2:0] */
1661static const char * const rt5677_inbound6_src[] = {
1662 "IF1 DAC 6", "IF2 DAC 6", "SLB DAC 6", "STO4 ADC MIX L",
1663 "IF4 DAC L", "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L"
1664};
1665
1666static SOC_ENUM_SINGLE_DECL(
1667 rt5677_inbound6_enum, RT5677_DSP_INB_CTRL1,
1668 RT5677_IB6_SRC_SFT, rt5677_inbound6_src);
1669
1670static const struct snd_kcontrol_new rt5677_ib6_src_mux =
1671 SOC_DAPM_ENUM("InBound6 Source", rt5677_inbound6_enum);
1672
1673/* InBound7 Source */ /* MX-A4 [14:12] */
1674static const char * const rt5677_inbound7_src[] = {
1675 "IF1 DAC 7", "IF2 DAC 7", "SLB DAC 7", "STO4 ADC MIX R",
1676 "IF4 DAC R", "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R"
1677};
1678
1679static SOC_ENUM_SINGLE_DECL(
1680 rt5677_inbound7_enum, RT5677_DSP_INB_CTRL2,
1681 RT5677_IB7_SRC_SFT, rt5677_inbound7_src);
1682
1683static const struct snd_kcontrol_new rt5677_ib7_src_mux =
1684 SOC_DAPM_ENUM("InBound7 Source", rt5677_inbound7_enum);
1685
1686/* InBound8 Source */ /* MX-A4 [10:8] */
1687static const char * const rt5677_inbound8_src[] = {
1688 "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L", "STO4 ADC MIX L",
1689 "MONO ADC MIX L", "DACL1 FS"
1690};
1691
1692static SOC_ENUM_SINGLE_DECL(
1693 rt5677_inbound8_enum, RT5677_DSP_INB_CTRL2,
1694 RT5677_IB8_SRC_SFT, rt5677_inbound8_src);
1695
1696static const struct snd_kcontrol_new rt5677_ib8_src_mux =
1697 SOC_DAPM_ENUM("InBound8 Source", rt5677_inbound8_enum);
1698
1699/* InBound9 Source */ /* MX-A4 [6:4] */
1700static const char * const rt5677_inbound9_src[] = {
1701 "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R", "STO4 ADC MIX R",
1702 "MONO ADC MIX R", "DACR1 FS", "DAC1 FS"
1703};
1704
1705static SOC_ENUM_SINGLE_DECL(
1706 rt5677_inbound9_enum, RT5677_DSP_INB_CTRL2,
1707 RT5677_IB9_SRC_SFT, rt5677_inbound9_src);
1708
1709static const struct snd_kcontrol_new rt5677_ib9_src_mux =
1710 SOC_DAPM_ENUM("InBound9 Source", rt5677_inbound9_enum);
1711
1712/* VAD Source */ /* MX-9F [6:4] */
1713static const char * const rt5677_vad_src[] = {
1714 "STO1 ADC MIX L", "MONO ADC MIX L", "MONO ADC MIX R", "STO2 ADC MIX L",
1715 "STO3 ADC MIX L"
1716};
1717
1718static SOC_ENUM_SINGLE_DECL(
1719 rt5677_vad_enum, RT5677_VAD_CTRL4,
1720 RT5677_VAD_SRC_SFT, rt5677_vad_src);
1721
1722static const struct snd_kcontrol_new rt5677_vad_src_mux =
1723 SOC_DAPM_ENUM("VAD Source", rt5677_vad_enum);
1724
1725/* Sidetone Source */ /* MX-13 [11:9] */
1726static const char * const rt5677_sidetone_src[] = {
1727 "DMIC1 L", "DMIC2 L", "DMIC3 L", "DMIC4 L", "ADC1", "ADC2"
1728};
1729
1730static SOC_ENUM_SINGLE_DECL(
1731 rt5677_sidetone_enum, RT5677_SIDETONE_CTRL,
1732 RT5677_ST_SEL_SFT, rt5677_sidetone_src);
1733
1734static const struct snd_kcontrol_new rt5677_sidetone_mux =
1735 SOC_DAPM_ENUM("Sidetone Source", rt5677_sidetone_enum);
1736
1737/* DAC1/2 Source */ /* MX-15 [1:0] */
1738static const char * const rt5677_dac12_src[] = {
1739 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
1740};
1741
1742static SOC_ENUM_SINGLE_DECL(
1743 rt5677_dac12_enum, RT5677_ANA_DAC1_2_3_SRC,
1744 RT5677_ANA_DAC1_2_SRC_SEL_SFT, rt5677_dac12_src);
1745
1746static const struct snd_kcontrol_new rt5677_dac12_mux =
1747 SOC_DAPM_ENUM("Analog DAC1/2 Source", rt5677_dac12_enum);
1748
1749/* DAC3 Source */ /* MX-15 [5:4] */
1750static const char * const rt5677_dac3_src[] = {
1751 "MONO DAC MIXL", "MONO DAC MIXR", "DD MIX1L", "DD MIX2L"
1752};
1753
1754static SOC_ENUM_SINGLE_DECL(
1755 rt5677_dac3_enum, RT5677_ANA_DAC1_2_3_SRC,
1756 RT5677_ANA_DAC3_SRC_SEL_SFT, rt5677_dac3_src);
1757
1758static const struct snd_kcontrol_new rt5677_dac3_mux =
1759 SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum);
1760
Oder Chiou1b7fd762014-06-10 14:35:24 +08001761/* PDM channel Source */ /* MX-31 [13:12][9:8][5:4][1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001762static const char * const rt5677_pdm_src[] = {
1763 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
1764};
1765
1766static SOC_ENUM_SINGLE_DECL(
1767 rt5677_pdm1_l_enum, RT5677_PDM_OUT_CTRL,
1768 RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src);
1769
1770static const struct snd_kcontrol_new rt5677_pdm1_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001771 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001772
1773static SOC_ENUM_SINGLE_DECL(
1774 rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL,
1775 RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src);
1776
1777static const struct snd_kcontrol_new rt5677_pdm2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001778 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001779
1780static SOC_ENUM_SINGLE_DECL(
1781 rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL,
1782 RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src);
1783
1784static const struct snd_kcontrol_new rt5677_pdm1_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001785 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001786
1787static SOC_ENUM_SINGLE_DECL(
1788 rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL,
1789 RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src);
1790
1791static const struct snd_kcontrol_new rt5677_pdm2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001792 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001793
Oder Chioud65fd3a2014-11-05 13:42:52 +08001794/* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001795static const char * const rt5677_if12_adc1_src[] = {
1796 "STO1 ADC MIX", "OB01", "VAD ADC"
1797};
1798
1799static SOC_ENUM_SINGLE_DECL(
1800 rt5677_if1_adc1_enum, RT5677_TDM1_CTRL2,
1801 RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src);
1802
1803static const struct snd_kcontrol_new rt5677_if1_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001804 SOC_DAPM_ENUM("IF1 ADC1 Source", rt5677_if1_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001805
1806static SOC_ENUM_SINGLE_DECL(
1807 rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2,
1808 RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src);
1809
1810static const struct snd_kcontrol_new rt5677_if2_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001811 SOC_DAPM_ENUM("IF2 ADC1 Source", rt5677_if2_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001812
1813static SOC_ENUM_SINGLE_DECL(
1814 rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX,
1815 RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src);
1816
1817static const struct snd_kcontrol_new rt5677_slb_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001818 SOC_DAPM_ENUM("SLB ADC1 Source", rt5677_slb_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001819
1820/* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */
1821static const char * const rt5677_if12_adc2_src[] = {
1822 "STO2 ADC MIX", "OB23"
1823};
1824
1825static SOC_ENUM_SINGLE_DECL(
1826 rt5677_if1_adc2_enum, RT5677_TDM1_CTRL2,
1827 RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src);
1828
1829static const struct snd_kcontrol_new rt5677_if1_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001830 SOC_DAPM_ENUM("IF1 ADC2 Source", rt5677_if1_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001831
1832static SOC_ENUM_SINGLE_DECL(
1833 rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2,
1834 RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src);
1835
1836static const struct snd_kcontrol_new rt5677_if2_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001837 SOC_DAPM_ENUM("IF2 ADC2 Source", rt5677_if2_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001838
1839static SOC_ENUM_SINGLE_DECL(
1840 rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX,
1841 RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src);
1842
1843static const struct snd_kcontrol_new rt5677_slb_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001844 SOC_DAPM_ENUM("SLB ADC2 Source", rt5677_slb_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001845
1846/* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */
1847static const char * const rt5677_if12_adc3_src[] = {
1848 "STO3 ADC MIX", "MONO ADC MIX", "OB45"
1849};
1850
1851static SOC_ENUM_SINGLE_DECL(
1852 rt5677_if1_adc3_enum, RT5677_TDM1_CTRL2,
1853 RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src);
1854
1855static const struct snd_kcontrol_new rt5677_if1_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001856 SOC_DAPM_ENUM("IF1 ADC3 Source", rt5677_if1_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001857
1858static SOC_ENUM_SINGLE_DECL(
1859 rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2,
1860 RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src);
1861
1862static const struct snd_kcontrol_new rt5677_if2_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001863 SOC_DAPM_ENUM("IF2 ADC3 Source", rt5677_if2_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001864
1865static SOC_ENUM_SINGLE_DECL(
1866 rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX,
1867 RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src);
1868
1869static const struct snd_kcontrol_new rt5677_slb_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001870 SOC_DAPM_ENUM("SLB ADC3 Source", rt5677_slb_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001871
Oder Chioud65fd3a2014-11-05 13:42:52 +08001872/* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001873static const char * const rt5677_if12_adc4_src[] = {
1874 "STO4 ADC MIX", "OB67", "OB01"
1875};
1876
1877static SOC_ENUM_SINGLE_DECL(
1878 rt5677_if1_adc4_enum, RT5677_TDM1_CTRL2,
1879 RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src);
1880
1881static const struct snd_kcontrol_new rt5677_if1_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001882 SOC_DAPM_ENUM("IF1 ADC4 Source", rt5677_if1_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001883
1884static SOC_ENUM_SINGLE_DECL(
1885 rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2,
1886 RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src);
1887
1888static const struct snd_kcontrol_new rt5677_if2_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001889 SOC_DAPM_ENUM("IF2 ADC4 Source", rt5677_if2_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001890
1891static SOC_ENUM_SINGLE_DECL(
1892 rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX,
1893 RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src);
1894
1895static const struct snd_kcontrol_new rt5677_slb_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001896 SOC_DAPM_ENUM("SLB ADC4 Source", rt5677_slb_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001897
Oder Chioud65fd3a2014-11-05 13:42:52 +08001898/* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001899static const char * const rt5677_if34_adc_src[] = {
1900 "STO1 ADC MIX", "STO2 ADC MIX", "STO3 ADC MIX", "STO4 ADC MIX",
1901 "MONO ADC MIX", "OB01", "OB23", "VAD ADC"
1902};
1903
1904static SOC_ENUM_SINGLE_DECL(
1905 rt5677_if3_adc_enum, RT5677_IF3_DATA,
1906 RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src);
1907
1908static const struct snd_kcontrol_new rt5677_if3_adc_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001909 SOC_DAPM_ENUM("IF3 ADC Source", rt5677_if3_adc_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001910
1911static SOC_ENUM_SINGLE_DECL(
1912 rt5677_if4_adc_enum, RT5677_IF4_DATA,
1913 RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src);
1914
1915static const struct snd_kcontrol_new rt5677_if4_adc_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001916 SOC_DAPM_ENUM("IF4 ADC Source", rt5677_if4_adc_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001917
Oder Chioue6f6ebc2014-10-22 16:11:39 +08001918/* TDM IF1/2 ADC Data Selection */ /* MX-3B MX-40 [7:6][5:4][3:2][1:0] */
1919static const char * const rt5677_if12_adc_swap_src[] = {
1920 "L/R", "R/L", "L/L", "R/R"
1921};
1922
1923static SOC_ENUM_SINGLE_DECL(
1924 rt5677_if1_adc1_swap_enum, RT5677_TDM1_CTRL1,
1925 RT5677_IF1_ADC1_SWAP_SFT, rt5677_if12_adc_swap_src);
1926
1927static const struct snd_kcontrol_new rt5677_if1_adc1_swap_mux =
1928 SOC_DAPM_ENUM("IF1 ADC1 Swap Source", rt5677_if1_adc1_swap_enum);
1929
1930static SOC_ENUM_SINGLE_DECL(
1931 rt5677_if1_adc2_swap_enum, RT5677_TDM1_CTRL1,
1932 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1933
1934static const struct snd_kcontrol_new rt5677_if1_adc2_swap_mux =
1935 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if1_adc2_swap_enum);
1936
1937static SOC_ENUM_SINGLE_DECL(
1938 rt5677_if1_adc3_swap_enum, RT5677_TDM1_CTRL1,
1939 RT5677_IF1_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
1940
1941static const struct snd_kcontrol_new rt5677_if1_adc3_swap_mux =
1942 SOC_DAPM_ENUM("IF1 ADC3 Swap Source", rt5677_if1_adc3_swap_enum);
1943
1944static SOC_ENUM_SINGLE_DECL(
1945 rt5677_if1_adc4_swap_enum, RT5677_TDM1_CTRL1,
1946 RT5677_IF1_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
1947
1948static const struct snd_kcontrol_new rt5677_if1_adc4_swap_mux =
1949 SOC_DAPM_ENUM("IF1 ADC4 Swap Source", rt5677_if1_adc4_swap_enum);
1950
1951static SOC_ENUM_SINGLE_DECL(
1952 rt5677_if2_adc1_swap_enum, RT5677_TDM2_CTRL1,
1953 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1954
1955static const struct snd_kcontrol_new rt5677_if2_adc1_swap_mux =
1956 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if2_adc1_swap_enum);
1957
1958static SOC_ENUM_SINGLE_DECL(
1959 rt5677_if2_adc2_swap_enum, RT5677_TDM2_CTRL1,
1960 RT5677_IF2_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1961
1962static const struct snd_kcontrol_new rt5677_if2_adc2_swap_mux =
1963 SOC_DAPM_ENUM("IF2 ADC2 Swap Source", rt5677_if2_adc2_swap_enum);
1964
1965static SOC_ENUM_SINGLE_DECL(
1966 rt5677_if2_adc3_swap_enum, RT5677_TDM2_CTRL1,
1967 RT5677_IF2_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
1968
1969static const struct snd_kcontrol_new rt5677_if2_adc3_swap_mux =
1970 SOC_DAPM_ENUM("IF2 ADC3 Swap Source", rt5677_if2_adc3_swap_enum);
1971
1972static SOC_ENUM_SINGLE_DECL(
1973 rt5677_if2_adc4_swap_enum, RT5677_TDM2_CTRL1,
1974 RT5677_IF2_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
1975
1976static const struct snd_kcontrol_new rt5677_if2_adc4_swap_mux =
1977 SOC_DAPM_ENUM("IF2 ADC4 Swap Source", rt5677_if2_adc4_swap_enum);
1978
Oder Chioud65fd3a2014-11-05 13:42:52 +08001979/* TDM IF1 ADC Data Selection */ /* MX-3C [2:0] */
Oder Chioue6f6ebc2014-10-22 16:11:39 +08001980static const char * const rt5677_if1_adc_tdm_swap_src[] = {
1981 "1/2/3/4", "2/1/3/4", "2/3/1/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
1982 "3/1/2/4", "3/4/1/2"
1983};
1984
1985static SOC_ENUM_SINGLE_DECL(
1986 rt5677_if1_adc_tdm_swap_enum, RT5677_TDM1_CTRL2,
1987 RT5677_IF1_ADC_CTRL_SFT, rt5677_if1_adc_tdm_swap_src);
1988
1989static const struct snd_kcontrol_new rt5677_if1_adc_tdm_swap_mux =
1990 SOC_DAPM_ENUM("IF1 ADC TDM Swap Source", rt5677_if1_adc_tdm_swap_enum);
1991
1992/* TDM IF2 ADC Data Selection */ /* MX-41[2:0] */
1993static const char * const rt5677_if2_adc_tdm_swap_src[] = {
1994 "1/2/3/4", "2/1/3/4", "3/1/2/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
1995 "2/3/1/4", "3/4/1/2"
1996};
1997
1998static SOC_ENUM_SINGLE_DECL(
1999 rt5677_if2_adc_tdm_swap_enum, RT5677_TDM2_CTRL2,
2000 RT5677_IF2_ADC_CTRL_SFT, rt5677_if2_adc_tdm_swap_src);
2001
2002static const struct snd_kcontrol_new rt5677_if2_adc_tdm_swap_mux =
2003 SOC_DAPM_ENUM("IF2 ADC TDM Swap Source", rt5677_if2_adc_tdm_swap_enum);
2004
Oder Chiou91159ec2014-11-11 15:31:19 +08002005/* TDM IF1/2 DAC Data Selection */ /* MX-3E[14:12][10:8][6:4][2:0]
2006 MX-3F[14:12][10:8][6:4][2:0]
2007 MX-43[14:12][10:8][6:4][2:0]
2008 MX-44[14:12][10:8][6:4][2:0] */
2009static const char * const rt5677_if12_dac_tdm_sel_src[] = {
2010 "Slot0", "Slot1", "Slot2", "Slot3", "Slot4", "Slot5", "Slot6", "Slot7"
2011};
2012
2013static SOC_ENUM_SINGLE_DECL(
2014 rt5677_if1_dac0_tdm_sel_enum, RT5677_TDM1_CTRL4,
2015 RT5677_IF1_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
2016
2017static const struct snd_kcontrol_new rt5677_if1_dac0_tdm_sel_mux =
2018 SOC_DAPM_ENUM("IF1 DAC0 TDM Source", rt5677_if1_dac0_tdm_sel_enum);
2019
2020static SOC_ENUM_SINGLE_DECL(
2021 rt5677_if1_dac1_tdm_sel_enum, RT5677_TDM1_CTRL4,
2022 RT5677_IF1_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
2023
2024static const struct snd_kcontrol_new rt5677_if1_dac1_tdm_sel_mux =
2025 SOC_DAPM_ENUM("IF1 DAC1 TDM Source", rt5677_if1_dac1_tdm_sel_enum);
2026
2027static SOC_ENUM_SINGLE_DECL(
2028 rt5677_if1_dac2_tdm_sel_enum, RT5677_TDM1_CTRL4,
2029 RT5677_IF1_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
2030
2031static const struct snd_kcontrol_new rt5677_if1_dac2_tdm_sel_mux =
2032 SOC_DAPM_ENUM("IF1 DAC2 TDM Source", rt5677_if1_dac2_tdm_sel_enum);
2033
2034static SOC_ENUM_SINGLE_DECL(
2035 rt5677_if1_dac3_tdm_sel_enum, RT5677_TDM1_CTRL4,
2036 RT5677_IF1_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
2037
2038static const struct snd_kcontrol_new rt5677_if1_dac3_tdm_sel_mux =
2039 SOC_DAPM_ENUM("IF1 DAC3 TDM Source", rt5677_if1_dac3_tdm_sel_enum);
2040
2041static SOC_ENUM_SINGLE_DECL(
2042 rt5677_if1_dac4_tdm_sel_enum, RT5677_TDM1_CTRL5,
2043 RT5677_IF1_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
2044
2045static const struct snd_kcontrol_new rt5677_if1_dac4_tdm_sel_mux =
2046 SOC_DAPM_ENUM("IF1 DAC4 TDM Source", rt5677_if1_dac4_tdm_sel_enum);
2047
2048static SOC_ENUM_SINGLE_DECL(
2049 rt5677_if1_dac5_tdm_sel_enum, RT5677_TDM1_CTRL5,
2050 RT5677_IF1_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
2051
2052static const struct snd_kcontrol_new rt5677_if1_dac5_tdm_sel_mux =
2053 SOC_DAPM_ENUM("IF1 DAC5 TDM Source", rt5677_if1_dac5_tdm_sel_enum);
2054
2055static SOC_ENUM_SINGLE_DECL(
2056 rt5677_if1_dac6_tdm_sel_enum, RT5677_TDM1_CTRL5,
2057 RT5677_IF1_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
2058
2059static const struct snd_kcontrol_new rt5677_if1_dac6_tdm_sel_mux =
2060 SOC_DAPM_ENUM("IF1 DAC6 TDM Source", rt5677_if1_dac6_tdm_sel_enum);
2061
2062static SOC_ENUM_SINGLE_DECL(
2063 rt5677_if1_dac7_tdm_sel_enum, RT5677_TDM1_CTRL5,
2064 RT5677_IF1_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
2065
2066static const struct snd_kcontrol_new rt5677_if1_dac7_tdm_sel_mux =
2067 SOC_DAPM_ENUM("IF1 DAC7 TDM Source", rt5677_if1_dac7_tdm_sel_enum);
2068
2069static SOC_ENUM_SINGLE_DECL(
2070 rt5677_if2_dac0_tdm_sel_enum, RT5677_TDM2_CTRL4,
2071 RT5677_IF2_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
2072
2073static const struct snd_kcontrol_new rt5677_if2_dac0_tdm_sel_mux =
2074 SOC_DAPM_ENUM("IF2 DAC0 TDM Source", rt5677_if2_dac0_tdm_sel_enum);
2075
2076static SOC_ENUM_SINGLE_DECL(
2077 rt5677_if2_dac1_tdm_sel_enum, RT5677_TDM2_CTRL4,
2078 RT5677_IF2_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
2079
2080static const struct snd_kcontrol_new rt5677_if2_dac1_tdm_sel_mux =
2081 SOC_DAPM_ENUM("IF2 DAC1 TDM Source", rt5677_if2_dac1_tdm_sel_enum);
2082
2083static SOC_ENUM_SINGLE_DECL(
2084 rt5677_if2_dac2_tdm_sel_enum, RT5677_TDM2_CTRL4,
2085 RT5677_IF2_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
2086
2087static const struct snd_kcontrol_new rt5677_if2_dac2_tdm_sel_mux =
2088 SOC_DAPM_ENUM("IF2 DAC2 TDM Source", rt5677_if2_dac2_tdm_sel_enum);
2089
2090static SOC_ENUM_SINGLE_DECL(
2091 rt5677_if2_dac3_tdm_sel_enum, RT5677_TDM2_CTRL4,
2092 RT5677_IF2_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
2093
2094static const struct snd_kcontrol_new rt5677_if2_dac3_tdm_sel_mux =
2095 SOC_DAPM_ENUM("IF2 DAC3 TDM Source", rt5677_if2_dac3_tdm_sel_enum);
2096
2097static SOC_ENUM_SINGLE_DECL(
2098 rt5677_if2_dac4_tdm_sel_enum, RT5677_TDM2_CTRL5,
2099 RT5677_IF2_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
2100
2101static const struct snd_kcontrol_new rt5677_if2_dac4_tdm_sel_mux =
2102 SOC_DAPM_ENUM("IF2 DAC4 TDM Source", rt5677_if2_dac4_tdm_sel_enum);
2103
2104static SOC_ENUM_SINGLE_DECL(
2105 rt5677_if2_dac5_tdm_sel_enum, RT5677_TDM2_CTRL5,
2106 RT5677_IF2_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
2107
2108static const struct snd_kcontrol_new rt5677_if2_dac5_tdm_sel_mux =
2109 SOC_DAPM_ENUM("IF2 DAC5 TDM Source", rt5677_if2_dac5_tdm_sel_enum);
2110
2111static SOC_ENUM_SINGLE_DECL(
2112 rt5677_if2_dac6_tdm_sel_enum, RT5677_TDM2_CTRL5,
2113 RT5677_IF2_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
2114
2115static const struct snd_kcontrol_new rt5677_if2_dac6_tdm_sel_mux =
2116 SOC_DAPM_ENUM("IF2 DAC6 TDM Source", rt5677_if2_dac6_tdm_sel_enum);
2117
2118static SOC_ENUM_SINGLE_DECL(
2119 rt5677_if2_dac7_tdm_sel_enum, RT5677_TDM2_CTRL5,
2120 RT5677_IF2_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
2121
2122static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux =
2123 SOC_DAPM_ENUM("IF2 DAC7 TDM Source", rt5677_if2_dac7_tdm_sel_enum);
2124
Oder Chiou0e826e82014-05-26 20:32:33 +08002125static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
2126 struct snd_kcontrol *kcontrol, int event)
2127{
2128 struct snd_soc_codec *codec = w->codec;
2129 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2130
2131 switch (event) {
2132 case SND_SOC_DAPM_POST_PMU:
2133 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2134 RT5677_PWR_BST1_P, RT5677_PWR_BST1_P);
2135 break;
2136
2137 case SND_SOC_DAPM_PRE_PMD:
2138 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2139 RT5677_PWR_BST1_P, 0);
2140 break;
2141
2142 default:
2143 return 0;
2144 }
2145
2146 return 0;
2147}
2148
2149static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
2150 struct snd_kcontrol *kcontrol, int event)
2151{
2152 struct snd_soc_codec *codec = w->codec;
2153 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2154
2155 switch (event) {
2156 case SND_SOC_DAPM_POST_PMU:
2157 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2158 RT5677_PWR_BST2_P, RT5677_PWR_BST2_P);
2159 break;
2160
2161 case SND_SOC_DAPM_PRE_PMD:
2162 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2163 RT5677_PWR_BST2_P, 0);
2164 break;
2165
2166 default:
2167 return 0;
2168 }
2169
2170 return 0;
2171}
2172
2173static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
2174 struct snd_kcontrol *kcontrol, int event)
2175{
2176 struct snd_soc_codec *codec = w->codec;
2177 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2178
2179 switch (event) {
2180 case SND_SOC_DAPM_POST_PMU:
2181 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2);
2182 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0);
2183 break;
2184 default:
2185 return 0;
2186 }
2187
2188 return 0;
2189}
2190
2191static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
2192 struct snd_kcontrol *kcontrol, int event)
2193{
2194 struct snd_soc_codec *codec = w->codec;
2195 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2196
2197 switch (event) {
2198 case SND_SOC_DAPM_POST_PMU:
2199 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2);
2200 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0);
2201 break;
2202 default:
2203 return 0;
2204 }
2205
2206 return 0;
2207}
2208
2209static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
2210 struct snd_kcontrol *kcontrol, int event)
2211{
2212 struct snd_soc_codec *codec = w->codec;
2213 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2214
2215 switch (event) {
2216 case SND_SOC_DAPM_POST_PMU:
2217 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2218 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
2219 RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 |
2220 RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB);
2221 break;
Oder Chiouf58c3b92014-06-10 14:35:26 +08002222
2223 case SND_SOC_DAPM_PRE_PMD:
2224 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2225 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
2226 RT5677_PWR_CLK_MB, 0);
2227 break;
2228
Oder Chiou0e826e82014-05-26 20:32:33 +08002229 default:
2230 return 0;
2231 }
2232
2233 return 0;
2234}
2235
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002236static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
2237 struct snd_kcontrol *kcontrol, int event)
2238{
2239 struct snd_soc_codec *codec = w->codec;
2240 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2241 unsigned int value;
2242
2243 switch (event) {
2244 case SND_SOC_DAPM_PRE_PMU:
2245 regmap_read(rt5677->regmap, RT5677_TDM1_CTRL2, &value);
2246 if (value & RT5677_IF1_ADC_CTRL_MASK)
2247 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1,
2248 RT5677_IF1_ADC_MODE_MASK,
2249 RT5677_IF1_ADC_MODE_TDM);
2250 break;
2251
2252 default:
2253 return 0;
2254 }
2255
2256 return 0;
2257}
2258
2259static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
2260 struct snd_kcontrol *kcontrol, int event)
2261{
2262 struct snd_soc_codec *codec = w->codec;
2263 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2264 unsigned int value;
2265
2266 switch (event) {
2267 case SND_SOC_DAPM_PRE_PMU:
2268 regmap_read(rt5677->regmap, RT5677_TDM2_CTRL2, &value);
2269 if (value & RT5677_IF2_ADC_CTRL_MASK)
2270 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1,
2271 RT5677_IF2_ADC_MODE_MASK,
2272 RT5677_IF2_ADC_MODE_TDM);
2273 break;
2274
2275 default:
2276 return 0;
2277 }
2278
2279 return 0;
2280}
2281
Oder Chiou683996c2014-11-19 13:52:20 +08002282static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
2283 struct snd_kcontrol *kcontrol, int event)
2284{
2285 struct snd_soc_codec *codec = w->codec;
2286 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2287
2288 switch (event) {
2289 case SND_SOC_DAPM_POST_PMU:
2290 if (codec->dapm.bias_level != SND_SOC_BIAS_ON &&
2291 !rt5677->is_vref_slow) {
2292 mdelay(20);
2293 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
2294 RT5677_PWR_FV1 | RT5677_PWR_FV2,
2295 RT5677_PWR_FV1 | RT5677_PWR_FV2);
2296 rt5677->is_vref_slow = true;
2297 }
2298 break;
2299
2300 default:
2301 return 0;
2302 }
2303
2304 return 0;
2305}
2306
Oder Chiou0e826e82014-05-26 20:32:33 +08002307static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2308 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT,
2309 0, rt5677_set_pll1_event, SND_SOC_DAPM_POST_PMU),
2310 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT,
2311 0, rt5677_set_pll2_event, SND_SOC_DAPM_POST_PMU),
2312
Oder Chiou5a8c7c22014-12-23 10:27:55 +08002313 /* ASRC */
2314 SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5677_ASRC_1, 0, 0, NULL, 0),
2315 SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5677_ASRC_1, 1, 0, NULL, 0),
2316 SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5677_ASRC_1, 2, 0, NULL, 0),
2317 SND_SOC_DAPM_SUPPLY_S("I2S4 ASRC", 1, RT5677_ASRC_1, 3, 0, NULL, 0),
2318 SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5677_ASRC_2, 14, 0, NULL, 0),
2319 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 L ASRC", 1, RT5677_ASRC_2, 13, 0, NULL,
2320 0),
2321 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 R ASRC", 1, RT5677_ASRC_2, 12, 0, NULL,
2322 0),
2323 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 L ASRC", 1, RT5677_ASRC_1, 15, 0, NULL,
2324 0),
2325 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 R ASRC", 1, RT5677_ASRC_1, 14, 0, NULL,
2326 0),
2327 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 L ASRC", 1, RT5677_ASRC_1, 13, 0, NULL,
2328 0),
2329 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 R ASRC", 1, RT5677_ASRC_1, 12, 0, NULL,
2330 0),
2331 SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5677_ASRC_2, 11, 0, NULL,
2332 0),
2333 SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5677_ASRC_2, 10, 0, NULL,
2334 0),
2335 SND_SOC_DAPM_SUPPLY_S("DMIC STO3 ASRC", 1, RT5677_ASRC_2, 9, 0, NULL,
2336 0),
2337 SND_SOC_DAPM_SUPPLY_S("DMIC STO4 ASRC", 1, RT5677_ASRC_2, 8, 0, NULL,
2338 0),
2339 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5677_ASRC_2, 7, 0, NULL,
2340 0),
2341 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5677_ASRC_2, 6, 0, NULL,
2342 0),
2343 SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5677_ASRC_2, 5, 0, NULL, 0),
2344 SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5677_ASRC_2, 4, 0, NULL, 0),
2345 SND_SOC_DAPM_SUPPLY_S("ADC STO3 ASRC", 1, RT5677_ASRC_2, 3, 0, NULL, 0),
2346 SND_SOC_DAPM_SUPPLY_S("ADC STO4 ASRC", 1, RT5677_ASRC_2, 2, 0, NULL, 0),
2347 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5677_ASRC_2, 1, 0, NULL,
2348 0),
2349 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5677_ASRC_2, 0, 0, NULL,
2350 0),
2351
Oder Chiou0e826e82014-05-26 20:32:33 +08002352 /* Input Side */
2353 /* micbias */
Oder Chiou3d0c03d2014-06-10 14:35:23 +08002354 SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT,
Oder Chiouf58c3b92014-06-10 14:35:26 +08002355 0, rt5677_set_micbias1_event, SND_SOC_DAPM_PRE_PMD |
2356 SND_SOC_DAPM_POST_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002357
2358 /* Input Lines */
2359 SND_SOC_DAPM_INPUT("DMIC L1"),
2360 SND_SOC_DAPM_INPUT("DMIC R1"),
2361 SND_SOC_DAPM_INPUT("DMIC L2"),
2362 SND_SOC_DAPM_INPUT("DMIC R2"),
2363 SND_SOC_DAPM_INPUT("DMIC L3"),
2364 SND_SOC_DAPM_INPUT("DMIC R3"),
2365 SND_SOC_DAPM_INPUT("DMIC L4"),
2366 SND_SOC_DAPM_INPUT("DMIC R4"),
2367
2368 SND_SOC_DAPM_INPUT("IN1P"),
2369 SND_SOC_DAPM_INPUT("IN1N"),
2370 SND_SOC_DAPM_INPUT("IN2P"),
2371 SND_SOC_DAPM_INPUT("IN2N"),
2372
2373 SND_SOC_DAPM_INPUT("Haptic Generator"),
2374
Bard Liao2d15d972014-08-27 19:50:34 +08002375 SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2376 SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2377 SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2378 SND_SOC_DAPM_PGA("DMIC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2379
2380 SND_SOC_DAPM_SUPPLY("DMIC1 power", RT5677_DMIC_CTRL1,
2381 RT5677_DMIC_1_EN_SFT, 0, NULL, 0),
2382 SND_SOC_DAPM_SUPPLY("DMIC2 power", RT5677_DMIC_CTRL1,
2383 RT5677_DMIC_2_EN_SFT, 0, NULL, 0),
2384 SND_SOC_DAPM_SUPPLY("DMIC3 power", RT5677_DMIC_CTRL1,
2385 RT5677_DMIC_3_EN_SFT, 0, NULL, 0),
2386 SND_SOC_DAPM_SUPPLY("DMIC4 power", RT5677_DMIC_CTRL2,
2387 RT5677_DMIC_4_EN_SFT, 0, NULL, 0),
Oder Chiou0e826e82014-05-26 20:32:33 +08002388
2389 SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0,
2390 set_dmic_clk, SND_SOC_DAPM_PRE_PMU),
2391
2392 /* Boost */
2393 SND_SOC_DAPM_PGA_E("BST1", RT5677_PWR_ANLG2,
2394 RT5677_PWR_BST1_BIT, 0, NULL, 0, rt5677_bst1_event,
2395 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2396 SND_SOC_DAPM_PGA_E("BST2", RT5677_PWR_ANLG2,
2397 RT5677_PWR_BST2_BIT, 0, NULL, 0, rt5677_bst2_event,
2398 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2399
2400 /* ADCs */
2401 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM,
2402 0, 0),
2403 SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM,
2404 0, 0),
2405 SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0),
2406
2407 SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5677_PWR_DIG1,
2408 RT5677_PWR_ADC_L_BIT, 0, NULL, 0),
2409 SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5677_PWR_DIG1,
2410 RT5677_PWR_ADC_R_BIT, 0, NULL, 0),
2411 SND_SOC_DAPM_SUPPLY("ADC1 clock", RT5677_PWR_DIG1,
2412 RT5677_PWR_ADCFED1_BIT, 0, NULL, 0),
2413 SND_SOC_DAPM_SUPPLY("ADC2 clock", RT5677_PWR_DIG1,
2414 RT5677_PWR_ADCFED2_BIT, 0, NULL, 0),
2415
2416 /* ADC Mux */
2417 SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0,
2418 &rt5677_sto1_dmic_mux),
2419 SND_SOC_DAPM_MUX("Stereo1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2420 &rt5677_sto1_adc1_mux),
2421 SND_SOC_DAPM_MUX("Stereo1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2422 &rt5677_sto1_adc2_mux),
2423 SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0,
2424 &rt5677_sto2_dmic_mux),
2425 SND_SOC_DAPM_MUX("Stereo2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2426 &rt5677_sto2_adc1_mux),
2427 SND_SOC_DAPM_MUX("Stereo2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2428 &rt5677_sto2_adc2_mux),
2429 SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0,
2430 &rt5677_sto2_adc_lr_mux),
2431 SND_SOC_DAPM_MUX("Stereo3 DMIC Mux", SND_SOC_NOPM, 0, 0,
2432 &rt5677_sto3_dmic_mux),
2433 SND_SOC_DAPM_MUX("Stereo3 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2434 &rt5677_sto3_adc1_mux),
2435 SND_SOC_DAPM_MUX("Stereo3 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2436 &rt5677_sto3_adc2_mux),
2437 SND_SOC_DAPM_MUX("Stereo4 DMIC Mux", SND_SOC_NOPM, 0, 0,
2438 &rt5677_sto4_dmic_mux),
2439 SND_SOC_DAPM_MUX("Stereo4 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2440 &rt5677_sto4_adc1_mux),
2441 SND_SOC_DAPM_MUX("Stereo4 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2442 &rt5677_sto4_adc2_mux),
2443 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
2444 &rt5677_mono_dmic_l_mux),
2445 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
2446 &rt5677_mono_dmic_r_mux),
2447 SND_SOC_DAPM_MUX("Mono ADC2 L Mux", SND_SOC_NOPM, 0, 0,
2448 &rt5677_mono_adc2_l_mux),
2449 SND_SOC_DAPM_MUX("Mono ADC1 L Mux", SND_SOC_NOPM, 0, 0,
2450 &rt5677_mono_adc1_l_mux),
2451 SND_SOC_DAPM_MUX("Mono ADC1 R Mux", SND_SOC_NOPM, 0, 0,
2452 &rt5677_mono_adc1_r_mux),
2453 SND_SOC_DAPM_MUX("Mono ADC2 R Mux", SND_SOC_NOPM, 0, 0,
2454 &rt5677_mono_adc2_r_mux),
2455
2456 /* ADC Mixer */
2457 SND_SOC_DAPM_SUPPLY("adc stereo1 filter", RT5677_PWR_DIG2,
2458 RT5677_PWR_ADC_S1F_BIT, 0, NULL, 0),
2459 SND_SOC_DAPM_SUPPLY("adc stereo2 filter", RT5677_PWR_DIG2,
2460 RT5677_PWR_ADC_S2F_BIT, 0, NULL, 0),
2461 SND_SOC_DAPM_SUPPLY("adc stereo3 filter", RT5677_PWR_DIG2,
2462 RT5677_PWR_ADC_S3F_BIT, 0, NULL, 0),
2463 SND_SOC_DAPM_SUPPLY("adc stereo4 filter", RT5677_PWR_DIG2,
2464 RT5677_PWR_ADC_S4F_BIT, 0, NULL, 0),
2465 SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0,
2466 rt5677_sto1_adc_l_mix, ARRAY_SIZE(rt5677_sto1_adc_l_mix)),
2467 SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0,
2468 rt5677_sto1_adc_r_mix, ARRAY_SIZE(rt5677_sto1_adc_r_mix)),
2469 SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0,
2470 rt5677_sto2_adc_l_mix, ARRAY_SIZE(rt5677_sto2_adc_l_mix)),
2471 SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0,
2472 rt5677_sto2_adc_r_mix, ARRAY_SIZE(rt5677_sto2_adc_r_mix)),
2473 SND_SOC_DAPM_MIXER("Sto3 ADC MIXL", SND_SOC_NOPM, 0, 0,
2474 rt5677_sto3_adc_l_mix, ARRAY_SIZE(rt5677_sto3_adc_l_mix)),
2475 SND_SOC_DAPM_MIXER("Sto3 ADC MIXR", SND_SOC_NOPM, 0, 0,
2476 rt5677_sto3_adc_r_mix, ARRAY_SIZE(rt5677_sto3_adc_r_mix)),
2477 SND_SOC_DAPM_MIXER("Sto4 ADC MIXL", SND_SOC_NOPM, 0, 0,
2478 rt5677_sto4_adc_l_mix, ARRAY_SIZE(rt5677_sto4_adc_l_mix)),
2479 SND_SOC_DAPM_MIXER("Sto4 ADC MIXR", SND_SOC_NOPM, 0, 0,
2480 rt5677_sto4_adc_r_mix, ARRAY_SIZE(rt5677_sto4_adc_r_mix)),
2481 SND_SOC_DAPM_SUPPLY("adc mono left filter", RT5677_PWR_DIG2,
2482 RT5677_PWR_ADC_MF_L_BIT, 0, NULL, 0),
2483 SND_SOC_DAPM_MIXER("Mono ADC MIXL", SND_SOC_NOPM, 0, 0,
2484 rt5677_mono_adc_l_mix, ARRAY_SIZE(rt5677_mono_adc_l_mix)),
2485 SND_SOC_DAPM_SUPPLY("adc mono right filter", RT5677_PWR_DIG2,
2486 RT5677_PWR_ADC_MF_R_BIT, 0, NULL, 0),
2487 SND_SOC_DAPM_MIXER("Mono ADC MIXR", SND_SOC_NOPM, 0, 0,
2488 rt5677_mono_adc_r_mix, ARRAY_SIZE(rt5677_mono_adc_r_mix)),
2489
2490 /* ADC PGA */
2491 SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2492 SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2493 SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2494 SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2495 SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2496 SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2497 SND_SOC_DAPM_PGA("Stereo3 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2498 SND_SOC_DAPM_PGA("Stereo3 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2499 SND_SOC_DAPM_PGA("Stereo3 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2500 SND_SOC_DAPM_PGA("Stereo4 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2501 SND_SOC_DAPM_PGA("Stereo4 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2502 SND_SOC_DAPM_PGA("Stereo4 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2503 SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2504 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002505 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2506 SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
Oder Chiou0e826e82014-05-26 20:32:33 +08002507
2508 /* DSP */
2509 SND_SOC_DAPM_MUX("IB9 Mux", SND_SOC_NOPM, 0, 0,
2510 &rt5677_ib9_src_mux),
2511 SND_SOC_DAPM_MUX("IB8 Mux", SND_SOC_NOPM, 0, 0,
2512 &rt5677_ib8_src_mux),
2513 SND_SOC_DAPM_MUX("IB7 Mux", SND_SOC_NOPM, 0, 0,
2514 &rt5677_ib7_src_mux),
2515 SND_SOC_DAPM_MUX("IB6 Mux", SND_SOC_NOPM, 0, 0,
2516 &rt5677_ib6_src_mux),
2517 SND_SOC_DAPM_MUX("IB45 Mux", SND_SOC_NOPM, 0, 0,
2518 &rt5677_ib45_src_mux),
2519 SND_SOC_DAPM_MUX("IB23 Mux", SND_SOC_NOPM, 0, 0,
2520 &rt5677_ib23_src_mux),
2521 SND_SOC_DAPM_MUX("IB01 Mux", SND_SOC_NOPM, 0, 0,
2522 &rt5677_ib01_src_mux),
2523 SND_SOC_DAPM_MUX("IB45 Bypass Mux", SND_SOC_NOPM, 0, 0,
2524 &rt5677_ib45_bypass_src_mux),
2525 SND_SOC_DAPM_MUX("IB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
2526 &rt5677_ib23_bypass_src_mux),
2527 SND_SOC_DAPM_MUX("IB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
2528 &rt5677_ib01_bypass_src_mux),
2529 SND_SOC_DAPM_MUX("OB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
2530 &rt5677_ob23_bypass_src_mux),
2531 SND_SOC_DAPM_MUX("OB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
2532 &rt5677_ob01_bypass_src_mux),
2533
2534 SND_SOC_DAPM_PGA("OB45", SND_SOC_NOPM, 0, 0, NULL, 0),
2535 SND_SOC_DAPM_PGA("OB67", SND_SOC_NOPM, 0, 0, NULL, 0),
2536
2537 SND_SOC_DAPM_PGA("OutBound2", SND_SOC_NOPM, 0, 0, NULL, 0),
2538 SND_SOC_DAPM_PGA("OutBound3", SND_SOC_NOPM, 0, 0, NULL, 0),
2539 SND_SOC_DAPM_PGA("OutBound4", SND_SOC_NOPM, 0, 0, NULL, 0),
2540 SND_SOC_DAPM_PGA("OutBound5", SND_SOC_NOPM, 0, 0, NULL, 0),
2541 SND_SOC_DAPM_PGA("OutBound6", SND_SOC_NOPM, 0, 0, NULL, 0),
2542 SND_SOC_DAPM_PGA("OutBound7", SND_SOC_NOPM, 0, 0, NULL, 0),
2543
2544 /* Digital Interface */
2545 SND_SOC_DAPM_SUPPLY("I2S1", RT5677_PWR_DIG1,
2546 RT5677_PWR_I2S1_BIT, 0, NULL, 0),
2547 SND_SOC_DAPM_PGA("IF1 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2548 SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2549 SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2550 SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2551 SND_SOC_DAPM_PGA("IF1 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2552 SND_SOC_DAPM_PGA("IF1 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2553 SND_SOC_DAPM_PGA("IF1 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2554 SND_SOC_DAPM_PGA("IF1 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2555 SND_SOC_DAPM_PGA("IF1 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2556 SND_SOC_DAPM_PGA("IF1 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2557 SND_SOC_DAPM_PGA("IF1 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2558 SND_SOC_DAPM_PGA("IF1 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2559 SND_SOC_DAPM_PGA("IF1 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2560 SND_SOC_DAPM_PGA("IF1 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2561 SND_SOC_DAPM_PGA("IF1 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2562 SND_SOC_DAPM_PGA("IF1 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2563
2564 SND_SOC_DAPM_SUPPLY("I2S2", RT5677_PWR_DIG1,
2565 RT5677_PWR_I2S2_BIT, 0, NULL, 0),
2566 SND_SOC_DAPM_PGA("IF2 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2567 SND_SOC_DAPM_PGA("IF2 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2568 SND_SOC_DAPM_PGA("IF2 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2569 SND_SOC_DAPM_PGA("IF2 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2570 SND_SOC_DAPM_PGA("IF2 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2571 SND_SOC_DAPM_PGA("IF2 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2572 SND_SOC_DAPM_PGA("IF2 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2573 SND_SOC_DAPM_PGA("IF2 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2574 SND_SOC_DAPM_PGA("IF2 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2575 SND_SOC_DAPM_PGA("IF2 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2576 SND_SOC_DAPM_PGA("IF2 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2577 SND_SOC_DAPM_PGA("IF2 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2578 SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2579 SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2580 SND_SOC_DAPM_PGA("IF2 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2581 SND_SOC_DAPM_PGA("IF2 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2582
2583 SND_SOC_DAPM_SUPPLY("I2S3", RT5677_PWR_DIG1,
2584 RT5677_PWR_I2S3_BIT, 0, NULL, 0),
2585 SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2586 SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2587 SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2588 SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2589 SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2590 SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2591
2592 SND_SOC_DAPM_SUPPLY("I2S4", RT5677_PWR_DIG1,
2593 RT5677_PWR_I2S4_BIT, 0, NULL, 0),
2594 SND_SOC_DAPM_PGA("IF4 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2595 SND_SOC_DAPM_PGA("IF4 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2596 SND_SOC_DAPM_PGA("IF4 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2597 SND_SOC_DAPM_PGA("IF4 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2598 SND_SOC_DAPM_PGA("IF4 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2599 SND_SOC_DAPM_PGA("IF4 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2600
2601 SND_SOC_DAPM_SUPPLY("SLB", RT5677_PWR_DIG1,
2602 RT5677_PWR_SLB_BIT, 0, NULL, 0),
2603 SND_SOC_DAPM_PGA("SLB DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2604 SND_SOC_DAPM_PGA("SLB DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2605 SND_SOC_DAPM_PGA("SLB DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2606 SND_SOC_DAPM_PGA("SLB DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2607 SND_SOC_DAPM_PGA("SLB DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2608 SND_SOC_DAPM_PGA("SLB DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2609 SND_SOC_DAPM_PGA("SLB DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2610 SND_SOC_DAPM_PGA("SLB DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2611 SND_SOC_DAPM_PGA("SLB DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2612 SND_SOC_DAPM_PGA("SLB DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2613 SND_SOC_DAPM_PGA("SLB DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2614 SND_SOC_DAPM_PGA("SLB DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2615 SND_SOC_DAPM_PGA("SLB ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2616 SND_SOC_DAPM_PGA("SLB ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2617 SND_SOC_DAPM_PGA("SLB ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2618 SND_SOC_DAPM_PGA("SLB ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2619
2620 /* Digital Interface Select */
2621 SND_SOC_DAPM_MUX("IF1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2622 &rt5677_if1_adc1_mux),
2623 SND_SOC_DAPM_MUX("IF1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2624 &rt5677_if1_adc2_mux),
2625 SND_SOC_DAPM_MUX("IF1 ADC3 Mux", SND_SOC_NOPM, 0, 0,
2626 &rt5677_if1_adc3_mux),
2627 SND_SOC_DAPM_MUX("IF1 ADC4 Mux", SND_SOC_NOPM, 0, 0,
2628 &rt5677_if1_adc4_mux),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002629 SND_SOC_DAPM_MUX("IF1 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
2630 &rt5677_if1_adc1_swap_mux),
2631 SND_SOC_DAPM_MUX("IF1 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
2632 &rt5677_if1_adc2_swap_mux),
2633 SND_SOC_DAPM_MUX("IF1 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
2634 &rt5677_if1_adc3_swap_mux),
2635 SND_SOC_DAPM_MUX("IF1 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
2636 &rt5677_if1_adc4_swap_mux),
2637 SND_SOC_DAPM_MUX_E("IF1 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
2638 &rt5677_if1_adc_tdm_swap_mux, rt5677_if1_adc_tdm_event,
2639 SND_SOC_DAPM_PRE_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002640 SND_SOC_DAPM_MUX("IF2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2641 &rt5677_if2_adc1_mux),
2642 SND_SOC_DAPM_MUX("IF2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2643 &rt5677_if2_adc2_mux),
2644 SND_SOC_DAPM_MUX("IF2 ADC3 Mux", SND_SOC_NOPM, 0, 0,
2645 &rt5677_if2_adc3_mux),
2646 SND_SOC_DAPM_MUX("IF2 ADC4 Mux", SND_SOC_NOPM, 0, 0,
2647 &rt5677_if2_adc4_mux),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002648 SND_SOC_DAPM_MUX("IF2 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
2649 &rt5677_if2_adc1_swap_mux),
2650 SND_SOC_DAPM_MUX("IF2 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
2651 &rt5677_if2_adc2_swap_mux),
2652 SND_SOC_DAPM_MUX("IF2 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
2653 &rt5677_if2_adc3_swap_mux),
2654 SND_SOC_DAPM_MUX("IF2 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
2655 &rt5677_if2_adc4_swap_mux),
2656 SND_SOC_DAPM_MUX_E("IF2 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
2657 &rt5677_if2_adc_tdm_swap_mux, rt5677_if2_adc_tdm_event,
2658 SND_SOC_DAPM_PRE_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002659 SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0,
2660 &rt5677_if3_adc_mux),
2661 SND_SOC_DAPM_MUX("IF4 ADC Mux", SND_SOC_NOPM, 0, 0,
2662 &rt5677_if4_adc_mux),
2663 SND_SOC_DAPM_MUX("SLB ADC1 Mux", SND_SOC_NOPM, 0, 0,
2664 &rt5677_slb_adc1_mux),
2665 SND_SOC_DAPM_MUX("SLB ADC2 Mux", SND_SOC_NOPM, 0, 0,
2666 &rt5677_slb_adc2_mux),
2667 SND_SOC_DAPM_MUX("SLB ADC3 Mux", SND_SOC_NOPM, 0, 0,
2668 &rt5677_slb_adc3_mux),
2669 SND_SOC_DAPM_MUX("SLB ADC4 Mux", SND_SOC_NOPM, 0, 0,
2670 &rt5677_slb_adc4_mux),
2671
Oder Chiou91159ec2014-11-11 15:31:19 +08002672 SND_SOC_DAPM_MUX("IF1 DAC0 Mux", SND_SOC_NOPM, 0, 0,
2673 &rt5677_if1_dac0_tdm_sel_mux),
2674 SND_SOC_DAPM_MUX("IF1 DAC1 Mux", SND_SOC_NOPM, 0, 0,
2675 &rt5677_if1_dac1_tdm_sel_mux),
2676 SND_SOC_DAPM_MUX("IF1 DAC2 Mux", SND_SOC_NOPM, 0, 0,
2677 &rt5677_if1_dac2_tdm_sel_mux),
2678 SND_SOC_DAPM_MUX("IF1 DAC3 Mux", SND_SOC_NOPM, 0, 0,
2679 &rt5677_if1_dac3_tdm_sel_mux),
2680 SND_SOC_DAPM_MUX("IF1 DAC4 Mux", SND_SOC_NOPM, 0, 0,
2681 &rt5677_if1_dac4_tdm_sel_mux),
2682 SND_SOC_DAPM_MUX("IF1 DAC5 Mux", SND_SOC_NOPM, 0, 0,
2683 &rt5677_if1_dac5_tdm_sel_mux),
2684 SND_SOC_DAPM_MUX("IF1 DAC6 Mux", SND_SOC_NOPM, 0, 0,
2685 &rt5677_if1_dac6_tdm_sel_mux),
2686 SND_SOC_DAPM_MUX("IF1 DAC7 Mux", SND_SOC_NOPM, 0, 0,
2687 &rt5677_if1_dac7_tdm_sel_mux),
2688
2689 SND_SOC_DAPM_MUX("IF2 DAC0 Mux", SND_SOC_NOPM, 0, 0,
2690 &rt5677_if2_dac0_tdm_sel_mux),
2691 SND_SOC_DAPM_MUX("IF2 DAC1 Mux", SND_SOC_NOPM, 0, 0,
2692 &rt5677_if2_dac1_tdm_sel_mux),
2693 SND_SOC_DAPM_MUX("IF2 DAC2 Mux", SND_SOC_NOPM, 0, 0,
2694 &rt5677_if2_dac2_tdm_sel_mux),
2695 SND_SOC_DAPM_MUX("IF2 DAC3 Mux", SND_SOC_NOPM, 0, 0,
2696 &rt5677_if2_dac3_tdm_sel_mux),
2697 SND_SOC_DAPM_MUX("IF2 DAC4 Mux", SND_SOC_NOPM, 0, 0,
2698 &rt5677_if2_dac4_tdm_sel_mux),
2699 SND_SOC_DAPM_MUX("IF2 DAC5 Mux", SND_SOC_NOPM, 0, 0,
2700 &rt5677_if2_dac5_tdm_sel_mux),
2701 SND_SOC_DAPM_MUX("IF2 DAC6 Mux", SND_SOC_NOPM, 0, 0,
2702 &rt5677_if2_dac6_tdm_sel_mux),
2703 SND_SOC_DAPM_MUX("IF2 DAC7 Mux", SND_SOC_NOPM, 0, 0,
2704 &rt5677_if2_dac7_tdm_sel_mux),
2705
Oder Chiou0e826e82014-05-26 20:32:33 +08002706 /* Audio Interface */
2707 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
2708 SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
2709 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
2710 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
2711 SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
2712 SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
2713 SND_SOC_DAPM_AIF_IN("AIF4RX", "AIF4 Playback", 0, SND_SOC_NOPM, 0, 0),
2714 SND_SOC_DAPM_AIF_OUT("AIF4TX", "AIF4 Capture", 0, SND_SOC_NOPM, 0, 0),
2715 SND_SOC_DAPM_AIF_IN("SLBRX", "SLIMBus Playback", 0, SND_SOC_NOPM, 0, 0),
2716 SND_SOC_DAPM_AIF_OUT("SLBTX", "SLIMBus Capture", 0, SND_SOC_NOPM, 0, 0),
2717
2718 /* Sidetone Mux */
2719 SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0,
2720 &rt5677_sidetone_mux),
Oder Chiou90bdbb42014-09-18 14:45:59 +08002721 SND_SOC_DAPM_SUPPLY("Sidetone Power", RT5677_SIDETONE_CTRL,
2722 RT5677_ST_EN_SFT, 0, NULL, 0),
2723
Oder Chiou0e826e82014-05-26 20:32:33 +08002724 /* VAD Mux*/
2725 SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0,
2726 &rt5677_vad_src_mux),
2727
2728 /* Tensilica DSP */
2729 SND_SOC_DAPM_PGA("Tensilica DSP", SND_SOC_NOPM, 0, 0, NULL, 0),
2730 SND_SOC_DAPM_MIXER("OB01 MIX", SND_SOC_NOPM, 0, 0,
2731 rt5677_ob_01_mix, ARRAY_SIZE(rt5677_ob_01_mix)),
2732 SND_SOC_DAPM_MIXER("OB23 MIX", SND_SOC_NOPM, 0, 0,
2733 rt5677_ob_23_mix, ARRAY_SIZE(rt5677_ob_23_mix)),
2734 SND_SOC_DAPM_MIXER("OB4 MIX", SND_SOC_NOPM, 0, 0,
2735 rt5677_ob_4_mix, ARRAY_SIZE(rt5677_ob_4_mix)),
2736 SND_SOC_DAPM_MIXER("OB5 MIX", SND_SOC_NOPM, 0, 0,
2737 rt5677_ob_5_mix, ARRAY_SIZE(rt5677_ob_5_mix)),
2738 SND_SOC_DAPM_MIXER("OB6 MIX", SND_SOC_NOPM, 0, 0,
2739 rt5677_ob_6_mix, ARRAY_SIZE(rt5677_ob_6_mix)),
2740 SND_SOC_DAPM_MIXER("OB7 MIX", SND_SOC_NOPM, 0, 0,
2741 rt5677_ob_7_mix, ARRAY_SIZE(rt5677_ob_7_mix)),
2742
2743 /* Output Side */
Oder Chioud65fd3a2014-11-05 13:42:52 +08002744 /* DAC mixer before sound effect */
Oder Chiou0e826e82014-05-26 20:32:33 +08002745 SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0,
2746 rt5677_dac_l_mix, ARRAY_SIZE(rt5677_dac_l_mix)),
2747 SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0,
2748 rt5677_dac_r_mix, ARRAY_SIZE(rt5677_dac_r_mix)),
2749 SND_SOC_DAPM_PGA("DAC1 FS", SND_SOC_NOPM, 0, 0, NULL, 0),
2750
2751 /* DAC Mux */
2752 SND_SOC_DAPM_MUX("DAC1 Mux", SND_SOC_NOPM, 0, 0,
2753 &rt5677_dac1_mux),
2754 SND_SOC_DAPM_MUX("ADDA1 Mux", SND_SOC_NOPM, 0, 0,
2755 &rt5677_adda1_mux),
2756 SND_SOC_DAPM_MUX("DAC12 SRC Mux", SND_SOC_NOPM, 0, 0,
2757 &rt5677_dac12_mux),
2758 SND_SOC_DAPM_MUX("DAC3 SRC Mux", SND_SOC_NOPM, 0, 0,
2759 &rt5677_dac3_mux),
2760
2761 /* DAC2 channel Mux */
2762 SND_SOC_DAPM_MUX("DAC2 L Mux", SND_SOC_NOPM, 0, 0,
2763 &rt5677_dac2_l_mux),
2764 SND_SOC_DAPM_MUX("DAC2 R Mux", SND_SOC_NOPM, 0, 0,
2765 &rt5677_dac2_r_mux),
2766
2767 /* DAC3 channel Mux */
2768 SND_SOC_DAPM_MUX("DAC3 L Mux", SND_SOC_NOPM, 0, 0,
2769 &rt5677_dac3_l_mux),
2770 SND_SOC_DAPM_MUX("DAC3 R Mux", SND_SOC_NOPM, 0, 0,
2771 &rt5677_dac3_r_mux),
2772
2773 /* DAC4 channel Mux */
2774 SND_SOC_DAPM_MUX("DAC4 L Mux", SND_SOC_NOPM, 0, 0,
2775 &rt5677_dac4_l_mux),
2776 SND_SOC_DAPM_MUX("DAC4 R Mux", SND_SOC_NOPM, 0, 0,
2777 &rt5677_dac4_r_mux),
2778
2779 /* DAC Mixer */
2780 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2,
2781 RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0),
Oder Chiou6800b5b2014-12-23 10:27:54 +08002782 SND_SOC_DAPM_SUPPLY("dac mono2 left filter", RT5677_PWR_DIG2,
Oder Chiou0e826e82014-05-26 20:32:33 +08002783 RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0),
Oder Chiou6800b5b2014-12-23 10:27:54 +08002784 SND_SOC_DAPM_SUPPLY("dac mono2 right filter", RT5677_PWR_DIG2,
Oder Chiou0e826e82014-05-26 20:32:33 +08002785 RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0),
Oder Chiou6800b5b2014-12-23 10:27:54 +08002786 SND_SOC_DAPM_SUPPLY("dac mono3 left filter", RT5677_PWR_DIG2,
2787 RT5677_PWR_DAC_M3F_L_BIT, 0, NULL, 0),
2788 SND_SOC_DAPM_SUPPLY("dac mono3 right filter", RT5677_PWR_DIG2,
2789 RT5677_PWR_DAC_M3F_R_BIT, 0, NULL, 0),
2790 SND_SOC_DAPM_SUPPLY("dac mono4 left filter", RT5677_PWR_DIG2,
2791 RT5677_PWR_DAC_M4F_L_BIT, 0, NULL, 0),
2792 SND_SOC_DAPM_SUPPLY("dac mono4 right filter", RT5677_PWR_DIG2,
2793 RT5677_PWR_DAC_M4F_R_BIT, 0, NULL, 0),
Oder Chiou0e826e82014-05-26 20:32:33 +08002794
2795 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
2796 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)),
2797 SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0,
2798 rt5677_sto1_dac_r_mix, ARRAY_SIZE(rt5677_sto1_dac_r_mix)),
2799 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
2800 rt5677_mono_dac_l_mix, ARRAY_SIZE(rt5677_mono_dac_l_mix)),
2801 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
2802 rt5677_mono_dac_r_mix, ARRAY_SIZE(rt5677_mono_dac_r_mix)),
2803 SND_SOC_DAPM_MIXER("DD1 MIXL", SND_SOC_NOPM, 0, 0,
2804 rt5677_dd1_l_mix, ARRAY_SIZE(rt5677_dd1_l_mix)),
2805 SND_SOC_DAPM_MIXER("DD1 MIXR", SND_SOC_NOPM, 0, 0,
2806 rt5677_dd1_r_mix, ARRAY_SIZE(rt5677_dd1_r_mix)),
2807 SND_SOC_DAPM_MIXER("DD2 MIXL", SND_SOC_NOPM, 0, 0,
2808 rt5677_dd2_l_mix, ARRAY_SIZE(rt5677_dd2_l_mix)),
2809 SND_SOC_DAPM_MIXER("DD2 MIXR", SND_SOC_NOPM, 0, 0,
2810 rt5677_dd2_r_mix, ARRAY_SIZE(rt5677_dd2_r_mix)),
2811 SND_SOC_DAPM_PGA("Stereo DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2812 SND_SOC_DAPM_PGA("Mono DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2813 SND_SOC_DAPM_PGA("DD1 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2814 SND_SOC_DAPM_PGA("DD2 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2815
2816 /* DACs */
2817 SND_SOC_DAPM_DAC("DAC 1", NULL, RT5677_PWR_DIG1,
2818 RT5677_PWR_DAC1_BIT, 0),
2819 SND_SOC_DAPM_DAC("DAC 2", NULL, RT5677_PWR_DIG1,
2820 RT5677_PWR_DAC2_BIT, 0),
2821 SND_SOC_DAPM_DAC("DAC 3", NULL, RT5677_PWR_DIG1,
2822 RT5677_PWR_DAC3_BIT, 0),
2823
2824 /* PDM */
2825 SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5677_PWR_DIG2,
2826 RT5677_PWR_PDM1_BIT, 0, NULL, 0),
2827 SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5677_PWR_DIG2,
2828 RT5677_PWR_PDM2_BIT, 0, NULL, 0),
2829
2830 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_L_SFT,
2831 1, &rt5677_pdm1_l_mux),
2832 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_R_SFT,
2833 1, &rt5677_pdm1_r_mux),
2834 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_L_SFT,
2835 1, &rt5677_pdm2_l_mux),
2836 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_R_SFT,
2837 1, &rt5677_pdm2_r_mux),
2838
Oder Chiou683996c2014-11-19 13:52:20 +08002839 SND_SOC_DAPM_PGA_S("LOUT1 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO1_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08002840 0, NULL, 0),
Oder Chiou683996c2014-11-19 13:52:20 +08002841 SND_SOC_DAPM_PGA_S("LOUT2 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO2_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08002842 0, NULL, 0),
Oder Chiou683996c2014-11-19 13:52:20 +08002843 SND_SOC_DAPM_PGA_S("LOUT3 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO3_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08002844 0, NULL, 0),
2845
Oder Chiou683996c2014-11-19 13:52:20 +08002846 SND_SOC_DAPM_PGA_S("LOUT1 vref", 1, SND_SOC_NOPM, 0, 0,
2847 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2848 SND_SOC_DAPM_PGA_S("LOUT2 vref", 1, SND_SOC_NOPM, 0, 0,
2849 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2850 SND_SOC_DAPM_PGA_S("LOUT3 vref", 1, SND_SOC_NOPM, 0, 0,
2851 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2852
Oder Chiou0e826e82014-05-26 20:32:33 +08002853 /* Output Lines */
2854 SND_SOC_DAPM_OUTPUT("LOUT1"),
2855 SND_SOC_DAPM_OUTPUT("LOUT2"),
2856 SND_SOC_DAPM_OUTPUT("LOUT3"),
2857 SND_SOC_DAPM_OUTPUT("PDM1L"),
2858 SND_SOC_DAPM_OUTPUT("PDM1R"),
2859 SND_SOC_DAPM_OUTPUT("PDM2L"),
2860 SND_SOC_DAPM_OUTPUT("PDM2R"),
Oder Chiou683996c2014-11-19 13:52:20 +08002861
2862 SND_SOC_DAPM_POST("vref", rt5677_vref_event),
Oder Chiou0e826e82014-05-26 20:32:33 +08002863};
2864
2865static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
Oder Chiou5a8c7c22014-12-23 10:27:55 +08002866 { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", can_use_asrc },
2867 { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", can_use_asrc },
2868 { "Stereo3 DMIC Mux", NULL, "DMIC STO3 ASRC", can_use_asrc },
2869 { "Stereo4 DMIC Mux", NULL, "DMIC STO4 ASRC", can_use_asrc },
2870 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc },
2871 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc },
2872 { "I2S1", NULL, "I2S1 ASRC", can_use_asrc},
2873 { "I2S2", NULL, "I2S2 ASRC", can_use_asrc},
2874 { "I2S3", NULL, "I2S3 ASRC", can_use_asrc},
2875 { "I2S4", NULL, "I2S4 ASRC", can_use_asrc},
2876
2877 { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc },
2878 { "dac mono2 left filter", NULL, "DAC MONO2 L ASRC", is_using_asrc },
2879 { "dac mono2 right filter", NULL, "DAC MONO2 R ASRC", is_using_asrc },
2880 { "dac mono3 left filter", NULL, "DAC MONO3 L ASRC", is_using_asrc },
2881 { "dac mono3 right filter", NULL, "DAC MONO3 R ASRC", is_using_asrc },
2882 { "dac mono4 left filter", NULL, "DAC MONO4 L ASRC", is_using_asrc },
2883 { "dac mono4 right filter", NULL, "DAC MONO4 R ASRC", is_using_asrc },
2884 { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc },
2885 { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc },
2886 { "adc stereo3 filter", NULL, "ADC STO3 ASRC", is_using_asrc },
2887 { "adc stereo4 filter", NULL, "ADC STO4 ASRC", is_using_asrc },
2888 { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc },
2889 { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc },
2890
Oder Chiou0e826e82014-05-26 20:32:33 +08002891 { "DMIC1", NULL, "DMIC L1" },
2892 { "DMIC1", NULL, "DMIC R1" },
2893 { "DMIC2", NULL, "DMIC L2" },
2894 { "DMIC2", NULL, "DMIC R2" },
2895 { "DMIC3", NULL, "DMIC L3" },
2896 { "DMIC3", NULL, "DMIC R3" },
2897 { "DMIC4", NULL, "DMIC L4" },
2898 { "DMIC4", NULL, "DMIC R4" },
2899
2900 { "DMIC L1", NULL, "DMIC CLK" },
2901 { "DMIC R1", NULL, "DMIC CLK" },
2902 { "DMIC L2", NULL, "DMIC CLK" },
2903 { "DMIC R2", NULL, "DMIC CLK" },
2904 { "DMIC L3", NULL, "DMIC CLK" },
2905 { "DMIC R3", NULL, "DMIC CLK" },
2906 { "DMIC L4", NULL, "DMIC CLK" },
2907 { "DMIC R4", NULL, "DMIC CLK" },
2908
Bard Liao2d15d972014-08-27 19:50:34 +08002909 { "DMIC L1", NULL, "DMIC1 power" },
2910 { "DMIC R1", NULL, "DMIC1 power" },
2911 { "DMIC L3", NULL, "DMIC3 power" },
2912 { "DMIC R3", NULL, "DMIC3 power" },
2913 { "DMIC L4", NULL, "DMIC4 power" },
2914 { "DMIC R4", NULL, "DMIC4 power" },
2915
Oder Chiou0e826e82014-05-26 20:32:33 +08002916 { "BST1", NULL, "IN1P" },
2917 { "BST1", NULL, "IN1N" },
2918 { "BST2", NULL, "IN2P" },
2919 { "BST2", NULL, "IN2N" },
2920
Bard Liao22e51342014-08-27 19:50:33 +08002921 { "IN1P", NULL, "MICBIAS1" },
2922 { "IN1N", NULL, "MICBIAS1" },
2923 { "IN2P", NULL, "MICBIAS1" },
2924 { "IN2N", NULL, "MICBIAS1" },
Oder Chiou0e826e82014-05-26 20:32:33 +08002925
2926 { "ADC 1", NULL, "BST1" },
2927 { "ADC 1", NULL, "ADC 1 power" },
2928 { "ADC 1", NULL, "ADC1 clock" },
2929 { "ADC 2", NULL, "BST2" },
2930 { "ADC 2", NULL, "ADC 2 power" },
2931 { "ADC 2", NULL, "ADC2 clock" },
2932
2933 { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" },
2934 { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" },
2935 { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" },
2936 { "Stereo1 DMIC Mux", "DMIC4", "DMIC4" },
2937
2938 { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" },
2939 { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" },
2940 { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" },
2941 { "Stereo2 DMIC Mux", "DMIC4", "DMIC4" },
2942
2943 { "Stereo3 DMIC Mux", "DMIC1", "DMIC1" },
2944 { "Stereo3 DMIC Mux", "DMIC2", "DMIC2" },
2945 { "Stereo3 DMIC Mux", "DMIC3", "DMIC3" },
2946 { "Stereo3 DMIC Mux", "DMIC4", "DMIC4" },
2947
2948 { "Stereo4 DMIC Mux", "DMIC1", "DMIC1" },
2949 { "Stereo4 DMIC Mux", "DMIC2", "DMIC2" },
2950 { "Stereo4 DMIC Mux", "DMIC3", "DMIC3" },
2951 { "Stereo4 DMIC Mux", "DMIC4", "DMIC4" },
2952
2953 { "Mono DMIC L Mux", "DMIC1", "DMIC1" },
2954 { "Mono DMIC L Mux", "DMIC2", "DMIC2" },
2955 { "Mono DMIC L Mux", "DMIC3", "DMIC3" },
2956 { "Mono DMIC L Mux", "DMIC4", "DMIC4" },
2957
2958 { "Mono DMIC R Mux", "DMIC1", "DMIC1" },
2959 { "Mono DMIC R Mux", "DMIC2", "DMIC2" },
2960 { "Mono DMIC R Mux", "DMIC3", "DMIC3" },
2961 { "Mono DMIC R Mux", "DMIC4", "DMIC4" },
2962
2963 { "ADC 1_2", NULL, "ADC 1" },
2964 { "ADC 1_2", NULL, "ADC 2" },
2965
2966 { "Stereo1 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2967 { "Stereo1 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2968 { "Stereo1 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2969
2970 { "Stereo1 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2971 { "Stereo1 ADC2 Mux", "DMIC", "Stereo1 DMIC Mux" },
2972 { "Stereo1 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2973
2974 { "Stereo2 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2975 { "Stereo2 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2976 { "Stereo2 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2977
2978 { "Stereo2 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2979 { "Stereo2 ADC2 Mux", "DMIC", "Stereo2 DMIC Mux" },
2980 { "Stereo2 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2981
2982 { "Stereo3 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2983 { "Stereo3 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2984 { "Stereo3 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2985
2986 { "Stereo3 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2987 { "Stereo3 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
2988 { "Stereo3 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2989
2990 { "Stereo4 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2991 { "Stereo4 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2992 { "Stereo4 ADC1 Mux", "DD MIX2", "DD2 MIX" },
2993
2994 { "Stereo4 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2995 { "Stereo4 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
2996 { "Stereo4 ADC2 Mux", "DD MIX2", "DD2 MIX" },
2997
2998 { "Mono ADC2 L Mux", "DD MIX1L", "DD1 MIXL" },
2999 { "Mono ADC2 L Mux", "DMIC", "Mono DMIC L Mux" },
3000 { "Mono ADC2 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3001
3002 { "Mono ADC1 L Mux", "DD MIX1L", "DD1 MIXL" },
3003 { "Mono ADC1 L Mux", "ADC1", "ADC 1" },
3004 { "Mono ADC1 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3005
3006 { "Mono ADC1 R Mux", "DD MIX1R", "DD1 MIXR" },
3007 { "Mono ADC1 R Mux", "ADC2", "ADC 2" },
3008 { "Mono ADC1 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3009
3010 { "Mono ADC2 R Mux", "DD MIX1R", "DD1 MIXR" },
3011 { "Mono ADC2 R Mux", "DMIC", "Mono DMIC R Mux" },
3012 { "Mono ADC2 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3013
3014 { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC1 Mux" },
3015 { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC2 Mux" },
3016 { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC1 Mux" },
3017 { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC2 Mux" },
3018
3019 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" },
3020 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003021 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" },
3022 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" },
3023 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
3024
3025 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" },
3026 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" },
3027
3028 { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC1 Mux" },
3029 { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC2 Mux" },
3030 { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC1 Mux" },
3031 { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC2 Mux" },
3032
3033 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" },
3034 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" },
3035
3036 { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" },
3037 { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" },
3038
3039 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" },
3040 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003041 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" },
3042 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" },
3043 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
3044
3045 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXL" },
3046 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR" },
3047
3048 { "Sto3 ADC MIXL", "ADC1 Switch", "Stereo3 ADC1 Mux" },
3049 { "Sto3 ADC MIXL", "ADC2 Switch", "Stereo3 ADC2 Mux" },
3050 { "Sto3 ADC MIXR", "ADC1 Switch", "Stereo3 ADC1 Mux" },
3051 { "Sto3 ADC MIXR", "ADC2 Switch", "Stereo3 ADC2 Mux" },
3052
3053 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" },
3054 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003055 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" },
3056 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" },
3057 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
3058
3059 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXL" },
3060 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXR" },
3061
3062 { "Sto4 ADC MIXL", "ADC1 Switch", "Stereo4 ADC1 Mux" },
3063 { "Sto4 ADC MIXL", "ADC2 Switch", "Stereo4 ADC2 Mux" },
3064 { "Sto4 ADC MIXR", "ADC1 Switch", "Stereo4 ADC1 Mux" },
3065 { "Sto4 ADC MIXR", "ADC2 Switch", "Stereo4 ADC2 Mux" },
3066
3067 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" },
3068 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003069 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" },
3070 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" },
3071 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
3072
3073 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXL" },
3074 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXR" },
3075
3076 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC1 L Mux" },
3077 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC2 L Mux" },
3078 { "Mono ADC MIXL", NULL, "adc mono left filter" },
3079 { "adc mono left filter", NULL, "PLL1", is_sys_clk_from_pll },
3080
3081 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC1 R Mux" },
3082 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC2 R Mux" },
3083 { "Mono ADC MIXR", NULL, "adc mono right filter" },
3084 { "adc mono right filter", NULL, "PLL1", is_sys_clk_from_pll },
3085
3086 { "Mono ADC MIX", NULL, "Mono ADC MIXL" },
3087 { "Mono ADC MIX", NULL, "Mono ADC MIXR" },
3088
3089 { "VAD ADC Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3090 { "VAD ADC Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
3091 { "VAD ADC Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
3092 { "VAD ADC Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3093 { "VAD ADC Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3094
3095 { "IF1 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3096 { "IF1 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3097 { "IF1 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3098
3099 { "IF1 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3100 { "IF1 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3101
3102 { "IF1 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3103 { "IF1 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3104 { "IF1 ADC3 Mux", "OB45", "OB45" },
3105
3106 { "IF1 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3107 { "IF1 ADC4 Mux", "OB67", "OB67" },
3108 { "IF1 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3109
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003110 { "IF1 ADC1 Swap Mux", "L/R", "IF1 ADC1 Mux" },
3111 { "IF1 ADC1 Swap Mux", "R/L", "IF1 ADC1 Mux" },
3112 { "IF1 ADC1 Swap Mux", "L/L", "IF1 ADC1 Mux" },
3113 { "IF1 ADC1 Swap Mux", "R/R", "IF1 ADC1 Mux" },
3114
3115 { "IF1 ADC2 Swap Mux", "L/R", "IF1 ADC2 Mux" },
3116 { "IF1 ADC2 Swap Mux", "R/L", "IF1 ADC2 Mux" },
3117 { "IF1 ADC2 Swap Mux", "L/L", "IF1 ADC2 Mux" },
3118 { "IF1 ADC2 Swap Mux", "R/R", "IF1 ADC2 Mux" },
3119
3120 { "IF1 ADC3 Swap Mux", "L/R", "IF1 ADC3 Mux" },
3121 { "IF1 ADC3 Swap Mux", "R/L", "IF1 ADC3 Mux" },
3122 { "IF1 ADC3 Swap Mux", "L/L", "IF1 ADC3 Mux" },
3123 { "IF1 ADC3 Swap Mux", "R/R", "IF1 ADC3 Mux" },
3124
3125 { "IF1 ADC4 Swap Mux", "L/R", "IF1 ADC4 Mux" },
3126 { "IF1 ADC4 Swap Mux", "R/L", "IF1 ADC4 Mux" },
3127 { "IF1 ADC4 Swap Mux", "L/L", "IF1 ADC4 Mux" },
3128 { "IF1 ADC4 Swap Mux", "R/R", "IF1 ADC4 Mux" },
3129
3130 { "IF1 ADC", NULL, "IF1 ADC1 Swap Mux" },
3131 { "IF1 ADC", NULL, "IF1 ADC2 Swap Mux" },
3132 { "IF1 ADC", NULL, "IF1 ADC3 Swap Mux" },
3133 { "IF1 ADC", NULL, "IF1 ADC4 Swap Mux" },
3134
3135 { "IF1 ADC TDM Swap Mux", "1/2/3/4", "IF1 ADC" },
3136 { "IF1 ADC TDM Swap Mux", "2/1/3/4", "IF1 ADC" },
3137 { "IF1 ADC TDM Swap Mux", "2/3/1/4", "IF1 ADC" },
3138 { "IF1 ADC TDM Swap Mux", "4/1/2/3", "IF1 ADC" },
3139 { "IF1 ADC TDM Swap Mux", "1/3/2/4", "IF1 ADC" },
3140 { "IF1 ADC TDM Swap Mux", "1/4/2/3", "IF1 ADC" },
3141 { "IF1 ADC TDM Swap Mux", "3/1/2/4", "IF1 ADC" },
3142 { "IF1 ADC TDM Swap Mux", "3/4/1/2", "IF1 ADC" },
3143
Oder Chiou0e826e82014-05-26 20:32:33 +08003144 { "AIF1TX", NULL, "I2S1" },
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003145 { "AIF1TX", NULL, "IF1 ADC TDM Swap Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003146
3147 { "IF2 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3148 { "IF2 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3149 { "IF2 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3150
3151 { "IF2 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3152 { "IF2 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3153
3154 { "IF2 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3155 { "IF2 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3156 { "IF2 ADC3 Mux", "OB45", "OB45" },
3157
3158 { "IF2 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3159 { "IF2 ADC4 Mux", "OB67", "OB67" },
3160 { "IF2 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3161
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003162 { "IF2 ADC1 Swap Mux", "L/R", "IF2 ADC1 Mux" },
3163 { "IF2 ADC1 Swap Mux", "R/L", "IF2 ADC1 Mux" },
3164 { "IF2 ADC1 Swap Mux", "L/L", "IF2 ADC1 Mux" },
3165 { "IF2 ADC1 Swap Mux", "R/R", "IF2 ADC1 Mux" },
3166
3167 { "IF2 ADC2 Swap Mux", "L/R", "IF2 ADC2 Mux" },
3168 { "IF2 ADC2 Swap Mux", "R/L", "IF2 ADC2 Mux" },
3169 { "IF2 ADC2 Swap Mux", "L/L", "IF2 ADC2 Mux" },
3170 { "IF2 ADC2 Swap Mux", "R/R", "IF2 ADC2 Mux" },
3171
3172 { "IF2 ADC3 Swap Mux", "L/R", "IF2 ADC3 Mux" },
3173 { "IF2 ADC3 Swap Mux", "R/L", "IF2 ADC3 Mux" },
3174 { "IF2 ADC3 Swap Mux", "L/L", "IF2 ADC3 Mux" },
3175 { "IF2 ADC3 Swap Mux", "R/R", "IF2 ADC3 Mux" },
3176
3177 { "IF2 ADC4 Swap Mux", "L/R", "IF2 ADC4 Mux" },
3178 { "IF2 ADC4 Swap Mux", "R/L", "IF2 ADC4 Mux" },
3179 { "IF2 ADC4 Swap Mux", "L/L", "IF2 ADC4 Mux" },
3180 { "IF2 ADC4 Swap Mux", "R/R", "IF2 ADC4 Mux" },
3181
3182 { "IF2 ADC", NULL, "IF2 ADC1 Swap Mux" },
3183 { "IF2 ADC", NULL, "IF2 ADC2 Swap Mux" },
3184 { "IF2 ADC", NULL, "IF2 ADC3 Swap Mux" },
3185 { "IF2 ADC", NULL, "IF2 ADC4 Swap Mux" },
3186
3187 { "IF2 ADC TDM Swap Mux", "1/2/3/4", "IF2 ADC" },
3188 { "IF2 ADC TDM Swap Mux", "2/1/3/4", "IF2 ADC" },
3189 { "IF2 ADC TDM Swap Mux", "3/1/2/4", "IF2 ADC" },
3190 { "IF2 ADC TDM Swap Mux", "4/1/2/3", "IF2 ADC" },
3191 { "IF2 ADC TDM Swap Mux", "1/3/2/4", "IF2 ADC" },
3192 { "IF2 ADC TDM Swap Mux", "1/4/2/3", "IF2 ADC" },
3193 { "IF2 ADC TDM Swap Mux", "2/3/1/4", "IF2 ADC" },
3194 { "IF2 ADC TDM Swap Mux", "3/4/1/2", "IF2 ADC" },
3195
Oder Chiou0e826e82014-05-26 20:32:33 +08003196 { "AIF2TX", NULL, "I2S2" },
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003197 { "AIF2TX", NULL, "IF2 ADC TDM Swap Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003198
3199 { "IF3 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3200 { "IF3 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3201 { "IF3 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3202 { "IF3 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3203 { "IF3 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
3204 { "IF3 ADC Mux", "OB01", "OB01 Bypass Mux" },
3205 { "IF3 ADC Mux", "OB23", "OB23 Bypass Mux" },
3206 { "IF3 ADC Mux", "VAD ADC", "VAD ADC Mux" },
3207
3208 { "AIF3TX", NULL, "I2S3" },
3209 { "AIF3TX", NULL, "IF3 ADC Mux" },
3210
3211 { "IF4 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3212 { "IF4 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3213 { "IF4 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3214 { "IF4 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3215 { "IF4 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
3216 { "IF4 ADC Mux", "OB01", "OB01 Bypass Mux" },
3217 { "IF4 ADC Mux", "OB23", "OB23 Bypass Mux" },
3218 { "IF4 ADC Mux", "VAD ADC", "VAD ADC Mux" },
3219
3220 { "AIF4TX", NULL, "I2S4" },
3221 { "AIF4TX", NULL, "IF4 ADC Mux" },
3222
3223 { "SLB ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3224 { "SLB ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3225 { "SLB ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3226
3227 { "SLB ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3228 { "SLB ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3229
3230 { "SLB ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3231 { "SLB ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3232 { "SLB ADC3 Mux", "OB45", "OB45" },
3233
3234 { "SLB ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3235 { "SLB ADC4 Mux", "OB67", "OB67" },
3236 { "SLB ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3237
3238 { "SLBTX", NULL, "SLB" },
3239 { "SLBTX", NULL, "SLB ADC1 Mux" },
3240 { "SLBTX", NULL, "SLB ADC2 Mux" },
3241 { "SLBTX", NULL, "SLB ADC3 Mux" },
3242 { "SLBTX", NULL, "SLB ADC4 Mux" },
3243
3244 { "IB01 Mux", "IF1 DAC 01", "IF1 DAC01" },
3245 { "IB01 Mux", "IF2 DAC 01", "IF2 DAC01" },
3246 { "IB01 Mux", "SLB DAC 01", "SLB DAC01" },
3247 { "IB01 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3248 { "IB01 Mux", "VAD ADC/DAC1 FS", "DAC1 FS" },
3249
3250 { "IB01 Bypass Mux", "Bypass", "IB01 Mux" },
3251 { "IB01 Bypass Mux", "Pass SRC", "IB01 Mux" },
3252
3253 { "IB23 Mux", "IF1 DAC 23", "IF1 DAC23" },
3254 { "IB23 Mux", "IF2 DAC 23", "IF2 DAC23" },
3255 { "IB23 Mux", "SLB DAC 23", "SLB DAC23" },
3256 { "IB23 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3257 { "IB23 Mux", "DAC1 FS", "DAC1 FS" },
3258 { "IB23 Mux", "IF4 DAC", "IF4 DAC" },
3259
3260 { "IB23 Bypass Mux", "Bypass", "IB23 Mux" },
3261 { "IB23 Bypass Mux", "Pass SRC", "IB23 Mux" },
3262
3263 { "IB45 Mux", "IF1 DAC 45", "IF1 DAC45" },
3264 { "IB45 Mux", "IF2 DAC 45", "IF2 DAC45" },
3265 { "IB45 Mux", "SLB DAC 45", "SLB DAC45" },
3266 { "IB45 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3267 { "IB45 Mux", "IF3 DAC", "IF3 DAC" },
3268
3269 { "IB45 Bypass Mux", "Bypass", "IB45 Mux" },
3270 { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" },
3271
3272 { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6" },
3273 { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6" },
3274 { "IB6 Mux", "SLB DAC 6", "SLB DAC6" },
3275 { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3276 { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" },
3277 { "IB6 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3278 { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3279 { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3280
3281 { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7" },
3282 { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7" },
3283 { "IB7 Mux", "SLB DAC 7", "SLB DAC7" },
3284 { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3285 { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" },
3286 { "IB7 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
3287 { "IB7 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
3288 { "IB7 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
3289
3290 { "IB8 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3291 { "IB8 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3292 { "IB8 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3293 { "IB8 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3294 { "IB8 Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
3295 { "IB8 Mux", "DACL1 FS", "DAC1 MIXL" },
3296
3297 { "IB9 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
3298 { "IB9 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
3299 { "IB9 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
3300 { "IB9 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3301 { "IB9 Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
3302 { "IB9 Mux", "DACR1 FS", "DAC1 MIXR" },
3303 { "IB9 Mux", "DAC1 FS", "DAC1 FS" },
3304
3305 { "OB01 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3306 { "OB01 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3307 { "OB01 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3308 { "OB01 MIX", "IB6 Switch", "IB6 Mux" },
3309 { "OB01 MIX", "IB7 Switch", "IB7 Mux" },
3310 { "OB01 MIX", "IB8 Switch", "IB8 Mux" },
3311 { "OB01 MIX", "IB9 Switch", "IB9 Mux" },
3312
3313 { "OB23 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3314 { "OB23 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3315 { "OB23 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3316 { "OB23 MIX", "IB6 Switch", "IB6 Mux" },
3317 { "OB23 MIX", "IB7 Switch", "IB7 Mux" },
3318 { "OB23 MIX", "IB8 Switch", "IB8 Mux" },
3319 { "OB23 MIX", "IB9 Switch", "IB9 Mux" },
3320
3321 { "OB4 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3322 { "OB4 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3323 { "OB4 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3324 { "OB4 MIX", "IB6 Switch", "IB6 Mux" },
3325 { "OB4 MIX", "IB7 Switch", "IB7 Mux" },
3326 { "OB4 MIX", "IB8 Switch", "IB8 Mux" },
3327 { "OB4 MIX", "IB9 Switch", "IB9 Mux" },
3328
3329 { "OB5 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3330 { "OB5 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3331 { "OB5 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3332 { "OB5 MIX", "IB6 Switch", "IB6 Mux" },
3333 { "OB5 MIX", "IB7 Switch", "IB7 Mux" },
3334 { "OB5 MIX", "IB8 Switch", "IB8 Mux" },
3335 { "OB5 MIX", "IB9 Switch", "IB9 Mux" },
3336
3337 { "OB6 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3338 { "OB6 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3339 { "OB6 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3340 { "OB6 MIX", "IB6 Switch", "IB6 Mux" },
3341 { "OB6 MIX", "IB7 Switch", "IB7 Mux" },
3342 { "OB6 MIX", "IB8 Switch", "IB8 Mux" },
3343 { "OB6 MIX", "IB9 Switch", "IB9 Mux" },
3344
3345 { "OB7 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3346 { "OB7 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3347 { "OB7 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3348 { "OB7 MIX", "IB6 Switch", "IB6 Mux" },
3349 { "OB7 MIX", "IB7 Switch", "IB7 Mux" },
3350 { "OB7 MIX", "IB8 Switch", "IB8 Mux" },
3351 { "OB7 MIX", "IB9 Switch", "IB9 Mux" },
3352
3353 { "OB01 Bypass Mux", "Bypass", "OB01 MIX" },
3354 { "OB01 Bypass Mux", "Pass SRC", "OB01 MIX" },
3355 { "OB23 Bypass Mux", "Bypass", "OB23 MIX" },
3356 { "OB23 Bypass Mux", "Pass SRC", "OB23 MIX" },
3357
3358 { "OutBound2", NULL, "OB23 Bypass Mux" },
3359 { "OutBound3", NULL, "OB23 Bypass Mux" },
3360 { "OutBound4", NULL, "OB4 MIX" },
3361 { "OutBound5", NULL, "OB5 MIX" },
3362 { "OutBound6", NULL, "OB6 MIX" },
3363 { "OutBound7", NULL, "OB7 MIX" },
3364
3365 { "OB45", NULL, "OutBound4" },
3366 { "OB45", NULL, "OutBound5" },
3367 { "OB67", NULL, "OutBound6" },
3368 { "OB67", NULL, "OutBound7" },
3369
3370 { "IF1 DAC0", NULL, "AIF1RX" },
3371 { "IF1 DAC1", NULL, "AIF1RX" },
3372 { "IF1 DAC2", NULL, "AIF1RX" },
3373 { "IF1 DAC3", NULL, "AIF1RX" },
3374 { "IF1 DAC4", NULL, "AIF1RX" },
3375 { "IF1 DAC5", NULL, "AIF1RX" },
3376 { "IF1 DAC6", NULL, "AIF1RX" },
3377 { "IF1 DAC7", NULL, "AIF1RX" },
3378 { "IF1 DAC0", NULL, "I2S1" },
3379 { "IF1 DAC1", NULL, "I2S1" },
3380 { "IF1 DAC2", NULL, "I2S1" },
3381 { "IF1 DAC3", NULL, "I2S1" },
3382 { "IF1 DAC4", NULL, "I2S1" },
3383 { "IF1 DAC5", NULL, "I2S1" },
3384 { "IF1 DAC6", NULL, "I2S1" },
3385 { "IF1 DAC7", NULL, "I2S1" },
3386
Oder Chiou91159ec2014-11-11 15:31:19 +08003387 { "IF1 DAC0 Mux", "Slot0", "IF1 DAC0" },
3388 { "IF1 DAC0 Mux", "Slot1", "IF1 DAC1" },
3389 { "IF1 DAC0 Mux", "Slot2", "IF1 DAC2" },
3390 { "IF1 DAC0 Mux", "Slot3", "IF1 DAC3" },
3391 { "IF1 DAC0 Mux", "Slot4", "IF1 DAC4" },
3392 { "IF1 DAC0 Mux", "Slot5", "IF1 DAC5" },
3393 { "IF1 DAC0 Mux", "Slot6", "IF1 DAC6" },
3394 { "IF1 DAC0 Mux", "Slot7", "IF1 DAC7" },
3395
3396 { "IF1 DAC1 Mux", "Slot0", "IF1 DAC0" },
3397 { "IF1 DAC1 Mux", "Slot1", "IF1 DAC1" },
3398 { "IF1 DAC1 Mux", "Slot2", "IF1 DAC2" },
3399 { "IF1 DAC1 Mux", "Slot3", "IF1 DAC3" },
3400 { "IF1 DAC1 Mux", "Slot4", "IF1 DAC4" },
3401 { "IF1 DAC1 Mux", "Slot5", "IF1 DAC5" },
3402 { "IF1 DAC1 Mux", "Slot6", "IF1 DAC6" },
3403 { "IF1 DAC1 Mux", "Slot7", "IF1 DAC7" },
3404
3405 { "IF1 DAC2 Mux", "Slot0", "IF1 DAC0" },
3406 { "IF1 DAC2 Mux", "Slot1", "IF1 DAC1" },
3407 { "IF1 DAC2 Mux", "Slot2", "IF1 DAC2" },
3408 { "IF1 DAC2 Mux", "Slot3", "IF1 DAC3" },
3409 { "IF1 DAC2 Mux", "Slot4", "IF1 DAC4" },
3410 { "IF1 DAC2 Mux", "Slot5", "IF1 DAC5" },
3411 { "IF1 DAC2 Mux", "Slot6", "IF1 DAC6" },
3412 { "IF1 DAC2 Mux", "Slot7", "IF1 DAC7" },
3413
3414 { "IF1 DAC3 Mux", "Slot0", "IF1 DAC0" },
3415 { "IF1 DAC3 Mux", "Slot1", "IF1 DAC1" },
3416 { "IF1 DAC3 Mux", "Slot2", "IF1 DAC2" },
3417 { "IF1 DAC3 Mux", "Slot3", "IF1 DAC3" },
3418 { "IF1 DAC3 Mux", "Slot4", "IF1 DAC4" },
3419 { "IF1 DAC3 Mux", "Slot5", "IF1 DAC5" },
3420 { "IF1 DAC3 Mux", "Slot6", "IF1 DAC6" },
3421 { "IF1 DAC3 Mux", "Slot7", "IF1 DAC7" },
3422
3423 { "IF1 DAC4 Mux", "Slot0", "IF1 DAC0" },
3424 { "IF1 DAC4 Mux", "Slot1", "IF1 DAC1" },
3425 { "IF1 DAC4 Mux", "Slot2", "IF1 DAC2" },
3426 { "IF1 DAC4 Mux", "Slot3", "IF1 DAC3" },
3427 { "IF1 DAC4 Mux", "Slot4", "IF1 DAC4" },
3428 { "IF1 DAC4 Mux", "Slot5", "IF1 DAC5" },
3429 { "IF1 DAC4 Mux", "Slot6", "IF1 DAC6" },
3430 { "IF1 DAC4 Mux", "Slot7", "IF1 DAC7" },
3431
3432 { "IF1 DAC5 Mux", "Slot0", "IF1 DAC0" },
3433 { "IF1 DAC5 Mux", "Slot1", "IF1 DAC1" },
3434 { "IF1 DAC5 Mux", "Slot2", "IF1 DAC2" },
3435 { "IF1 DAC5 Mux", "Slot3", "IF1 DAC3" },
3436 { "IF1 DAC5 Mux", "Slot4", "IF1 DAC4" },
3437 { "IF1 DAC5 Mux", "Slot5", "IF1 DAC5" },
3438 { "IF1 DAC5 Mux", "Slot6", "IF1 DAC6" },
3439 { "IF1 DAC5 Mux", "Slot7", "IF1 DAC7" },
3440
3441 { "IF1 DAC6 Mux", "Slot0", "IF1 DAC0" },
3442 { "IF1 DAC6 Mux", "Slot1", "IF1 DAC1" },
3443 { "IF1 DAC6 Mux", "Slot2", "IF1 DAC2" },
3444 { "IF1 DAC6 Mux", "Slot3", "IF1 DAC3" },
3445 { "IF1 DAC6 Mux", "Slot4", "IF1 DAC4" },
3446 { "IF1 DAC6 Mux", "Slot5", "IF1 DAC5" },
3447 { "IF1 DAC6 Mux", "Slot6", "IF1 DAC6" },
3448 { "IF1 DAC6 Mux", "Slot7", "IF1 DAC7" },
3449
3450 { "IF1 DAC7 Mux", "Slot0", "IF1 DAC0" },
3451 { "IF1 DAC7 Mux", "Slot1", "IF1 DAC1" },
3452 { "IF1 DAC7 Mux", "Slot2", "IF1 DAC2" },
3453 { "IF1 DAC7 Mux", "Slot3", "IF1 DAC3" },
3454 { "IF1 DAC7 Mux", "Slot4", "IF1 DAC4" },
3455 { "IF1 DAC7 Mux", "Slot5", "IF1 DAC5" },
3456 { "IF1 DAC7 Mux", "Slot6", "IF1 DAC6" },
3457 { "IF1 DAC7 Mux", "Slot7", "IF1 DAC7" },
3458
3459 { "IF1 DAC01", NULL, "IF1 DAC0 Mux" },
3460 { "IF1 DAC01", NULL, "IF1 DAC1 Mux" },
3461 { "IF1 DAC23", NULL, "IF1 DAC2 Mux" },
3462 { "IF1 DAC23", NULL, "IF1 DAC3 Mux" },
3463 { "IF1 DAC45", NULL, "IF1 DAC4 Mux" },
3464 { "IF1 DAC45", NULL, "IF1 DAC5 Mux" },
3465 { "IF1 DAC67", NULL, "IF1 DAC6 Mux" },
3466 { "IF1 DAC67", NULL, "IF1 DAC7 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003467
3468 { "IF2 DAC0", NULL, "AIF2RX" },
3469 { "IF2 DAC1", NULL, "AIF2RX" },
3470 { "IF2 DAC2", NULL, "AIF2RX" },
3471 { "IF2 DAC3", NULL, "AIF2RX" },
3472 { "IF2 DAC4", NULL, "AIF2RX" },
3473 { "IF2 DAC5", NULL, "AIF2RX" },
3474 { "IF2 DAC6", NULL, "AIF2RX" },
3475 { "IF2 DAC7", NULL, "AIF2RX" },
3476 { "IF2 DAC0", NULL, "I2S2" },
3477 { "IF2 DAC1", NULL, "I2S2" },
3478 { "IF2 DAC2", NULL, "I2S2" },
3479 { "IF2 DAC3", NULL, "I2S2" },
3480 { "IF2 DAC4", NULL, "I2S2" },
3481 { "IF2 DAC5", NULL, "I2S2" },
3482 { "IF2 DAC6", NULL, "I2S2" },
3483 { "IF2 DAC7", NULL, "I2S2" },
3484
Oder Chiou91159ec2014-11-11 15:31:19 +08003485 { "IF2 DAC0 Mux", "Slot0", "IF2 DAC0" },
3486 { "IF2 DAC0 Mux", "Slot1", "IF2 DAC1" },
3487 { "IF2 DAC0 Mux", "Slot2", "IF2 DAC2" },
3488 { "IF2 DAC0 Mux", "Slot3", "IF2 DAC3" },
3489 { "IF2 DAC0 Mux", "Slot4", "IF2 DAC4" },
3490 { "IF2 DAC0 Mux", "Slot5", "IF2 DAC5" },
3491 { "IF2 DAC0 Mux", "Slot6", "IF2 DAC6" },
3492 { "IF2 DAC0 Mux", "Slot7", "IF2 DAC7" },
3493
3494 { "IF2 DAC1 Mux", "Slot0", "IF2 DAC0" },
3495 { "IF2 DAC1 Mux", "Slot1", "IF2 DAC1" },
3496 { "IF2 DAC1 Mux", "Slot2", "IF2 DAC2" },
3497 { "IF2 DAC1 Mux", "Slot3", "IF2 DAC3" },
3498 { "IF2 DAC1 Mux", "Slot4", "IF2 DAC4" },
3499 { "IF2 DAC1 Mux", "Slot5", "IF2 DAC5" },
3500 { "IF2 DAC1 Mux", "Slot6", "IF2 DAC6" },
3501 { "IF2 DAC1 Mux", "Slot7", "IF2 DAC7" },
3502
3503 { "IF2 DAC2 Mux", "Slot0", "IF2 DAC0" },
3504 { "IF2 DAC2 Mux", "Slot1", "IF2 DAC1" },
3505 { "IF2 DAC2 Mux", "Slot2", "IF2 DAC2" },
3506 { "IF2 DAC2 Mux", "Slot3", "IF2 DAC3" },
3507 { "IF2 DAC2 Mux", "Slot4", "IF2 DAC4" },
3508 { "IF2 DAC2 Mux", "Slot5", "IF2 DAC5" },
3509 { "IF2 DAC2 Mux", "Slot6", "IF2 DAC6" },
3510 { "IF2 DAC2 Mux", "Slot7", "IF2 DAC7" },
3511
3512 { "IF2 DAC3 Mux", "Slot0", "IF2 DAC0" },
3513 { "IF2 DAC3 Mux", "Slot1", "IF2 DAC1" },
3514 { "IF2 DAC3 Mux", "Slot2", "IF2 DAC2" },
3515 { "IF2 DAC3 Mux", "Slot3", "IF2 DAC3" },
3516 { "IF2 DAC3 Mux", "Slot4", "IF2 DAC4" },
3517 { "IF2 DAC3 Mux", "Slot5", "IF2 DAC5" },
3518 { "IF2 DAC3 Mux", "Slot6", "IF2 DAC6" },
3519 { "IF2 DAC3 Mux", "Slot7", "IF2 DAC7" },
3520
3521 { "IF2 DAC4 Mux", "Slot0", "IF2 DAC0" },
3522 { "IF2 DAC4 Mux", "Slot1", "IF2 DAC1" },
3523 { "IF2 DAC4 Mux", "Slot2", "IF2 DAC2" },
3524 { "IF2 DAC4 Mux", "Slot3", "IF2 DAC3" },
3525 { "IF2 DAC4 Mux", "Slot4", "IF2 DAC4" },
3526 { "IF2 DAC4 Mux", "Slot5", "IF2 DAC5" },
3527 { "IF2 DAC4 Mux", "Slot6", "IF2 DAC6" },
3528 { "IF2 DAC4 Mux", "Slot7", "IF2 DAC7" },
3529
3530 { "IF2 DAC5 Mux", "Slot0", "IF2 DAC0" },
3531 { "IF2 DAC5 Mux", "Slot1", "IF2 DAC1" },
3532 { "IF2 DAC5 Mux", "Slot2", "IF2 DAC2" },
3533 { "IF2 DAC5 Mux", "Slot3", "IF2 DAC3" },
3534 { "IF2 DAC5 Mux", "Slot4", "IF2 DAC4" },
3535 { "IF2 DAC5 Mux", "Slot5", "IF2 DAC5" },
3536 { "IF2 DAC5 Mux", "Slot6", "IF2 DAC6" },
3537 { "IF2 DAC5 Mux", "Slot7", "IF2 DAC7" },
3538
3539 { "IF2 DAC6 Mux", "Slot0", "IF2 DAC0" },
3540 { "IF2 DAC6 Mux", "Slot1", "IF2 DAC1" },
3541 { "IF2 DAC6 Mux", "Slot2", "IF2 DAC2" },
3542 { "IF2 DAC6 Mux", "Slot3", "IF2 DAC3" },
3543 { "IF2 DAC6 Mux", "Slot4", "IF2 DAC4" },
3544 { "IF2 DAC6 Mux", "Slot5", "IF2 DAC5" },
3545 { "IF2 DAC6 Mux", "Slot6", "IF2 DAC6" },
3546 { "IF2 DAC6 Mux", "Slot7", "IF2 DAC7" },
3547
3548 { "IF2 DAC7 Mux", "Slot0", "IF2 DAC0" },
3549 { "IF2 DAC7 Mux", "Slot1", "IF2 DAC1" },
3550 { "IF2 DAC7 Mux", "Slot2", "IF2 DAC2" },
3551 { "IF2 DAC7 Mux", "Slot3", "IF2 DAC3" },
3552 { "IF2 DAC7 Mux", "Slot4", "IF2 DAC4" },
3553 { "IF2 DAC7 Mux", "Slot5", "IF2 DAC5" },
3554 { "IF2 DAC7 Mux", "Slot6", "IF2 DAC6" },
3555 { "IF2 DAC7 Mux", "Slot7", "IF2 DAC7" },
3556
3557 { "IF2 DAC01", NULL, "IF2 DAC0 Mux" },
3558 { "IF2 DAC01", NULL, "IF2 DAC1 Mux" },
3559 { "IF2 DAC23", NULL, "IF2 DAC2 Mux" },
3560 { "IF2 DAC23", NULL, "IF2 DAC3 Mux" },
3561 { "IF2 DAC45", NULL, "IF2 DAC4 Mux" },
3562 { "IF2 DAC45", NULL, "IF2 DAC5 Mux" },
3563 { "IF2 DAC67", NULL, "IF2 DAC6 Mux" },
3564 { "IF2 DAC67", NULL, "IF2 DAC7 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003565
3566 { "IF3 DAC", NULL, "AIF3RX" },
3567 { "IF3 DAC", NULL, "I2S3" },
3568
3569 { "IF4 DAC", NULL, "AIF4RX" },
3570 { "IF4 DAC", NULL, "I2S4" },
3571
3572 { "IF3 DAC L", NULL, "IF3 DAC" },
3573 { "IF3 DAC R", NULL, "IF3 DAC" },
3574
3575 { "IF4 DAC L", NULL, "IF4 DAC" },
3576 { "IF4 DAC R", NULL, "IF4 DAC" },
3577
3578 { "SLB DAC0", NULL, "SLBRX" },
3579 { "SLB DAC1", NULL, "SLBRX" },
3580 { "SLB DAC2", NULL, "SLBRX" },
3581 { "SLB DAC3", NULL, "SLBRX" },
3582 { "SLB DAC4", NULL, "SLBRX" },
3583 { "SLB DAC5", NULL, "SLBRX" },
3584 { "SLB DAC6", NULL, "SLBRX" },
3585 { "SLB DAC7", NULL, "SLBRX" },
3586 { "SLB DAC0", NULL, "SLB" },
3587 { "SLB DAC1", NULL, "SLB" },
3588 { "SLB DAC2", NULL, "SLB" },
3589 { "SLB DAC3", NULL, "SLB" },
3590 { "SLB DAC4", NULL, "SLB" },
3591 { "SLB DAC5", NULL, "SLB" },
3592 { "SLB DAC6", NULL, "SLB" },
3593 { "SLB DAC7", NULL, "SLB" },
3594
3595 { "SLB DAC01", NULL, "SLB DAC0" },
3596 { "SLB DAC01", NULL, "SLB DAC1" },
3597 { "SLB DAC23", NULL, "SLB DAC2" },
3598 { "SLB DAC23", NULL, "SLB DAC3" },
3599 { "SLB DAC45", NULL, "SLB DAC4" },
3600 { "SLB DAC45", NULL, "SLB DAC5" },
3601 { "SLB DAC67", NULL, "SLB DAC6" },
3602 { "SLB DAC67", NULL, "SLB DAC7" },
3603
3604 { "ADDA1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3605 { "ADDA1 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3606 { "ADDA1 Mux", "OB 67", "OB67" },
3607
3608 { "DAC1 Mux", "IF1 DAC 01", "IF1 DAC01" },
3609 { "DAC1 Mux", "IF2 DAC 01", "IF2 DAC01" },
3610 { "DAC1 Mux", "IF3 DAC LR", "IF3 DAC" },
3611 { "DAC1 Mux", "IF4 DAC LR", "IF4 DAC" },
3612 { "DAC1 Mux", "SLB DAC 01", "SLB DAC01" },
3613 { "DAC1 Mux", "OB 01", "OB01 Bypass Mux" },
3614
3615 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" },
3616 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003617 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" },
3618 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003619
3620 { "DAC1 FS", NULL, "DAC1 MIXL" },
3621 { "DAC1 FS", NULL, "DAC1 MIXR" },
3622
3623 { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2" },
3624 { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2" },
3625 { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" },
3626 { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" },
3627 { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" },
3628 { "DAC2 L Mux", "OB 2", "OutBound2" },
3629
3630 { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3" },
3631 { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3" },
3632 { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" },
3633 { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" },
3634 { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" },
3635 { "DAC2 R Mux", "OB 3", "OutBound3" },
3636 { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" },
3637 { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" },
3638
3639 { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4" },
3640 { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4" },
3641 { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" },
3642 { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" },
3643 { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" },
3644 { "DAC3 L Mux", "OB 4", "OutBound4" },
3645
3646 { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC4" },
3647 { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC4" },
3648 { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" },
3649 { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" },
3650 { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" },
3651 { "DAC3 R Mux", "OB 5", "OutBound5" },
3652
3653 { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6" },
3654 { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6" },
3655 { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" },
3656 { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" },
3657 { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" },
3658 { "DAC4 L Mux", "OB 6", "OutBound6" },
3659
3660 { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7" },
3661 { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7" },
3662 { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" },
3663 { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" },
3664 { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" },
3665 { "DAC4 R Mux", "OB 7", "OutBound7" },
3666
3667 { "Sidetone Mux", "DMIC1 L", "DMIC L1" },
3668 { "Sidetone Mux", "DMIC2 L", "DMIC L2" },
3669 { "Sidetone Mux", "DMIC3 L", "DMIC L3" },
3670 { "Sidetone Mux", "DMIC4 L", "DMIC L4" },
3671 { "Sidetone Mux", "ADC1", "ADC 1" },
3672 { "Sidetone Mux", "ADC2", "ADC 2" },
Oder Chiou90bdbb42014-09-18 14:45:59 +08003673 { "Sidetone Mux", NULL, "Sidetone Power" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003674
3675 { "Stereo DAC MIXL", "ST L Switch", "Sidetone Mux" },
3676 { "Stereo DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3677 { "Stereo DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3678 { "Stereo DAC MIXL", "DAC1 R Switch", "DAC1 MIXR" },
3679 { "Stereo DAC MIXL", NULL, "dac stereo1 filter" },
3680 { "Stereo DAC MIXR", "ST R Switch", "Sidetone Mux" },
3681 { "Stereo DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3682 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3683 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" },
3684 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003685 { "dac stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003686
3687 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" },
3688 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3689 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3690 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003691 { "Mono DAC MIXL", NULL, "dac mono2 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003692 { "dac mono2 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003693 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" },
3694 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3695 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3696 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003697 { "Mono DAC MIXR", NULL, "dac mono2 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003698 { "dac mono2 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003699
3700 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3701 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3702 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" },
3703 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003704 { "DD1 MIXL", NULL, "dac mono3 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003705 { "dac mono3 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003706 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3707 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3708 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" },
3709 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003710 { "DD1 MIXR", NULL, "dac mono3 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003711 { "dac mono3 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003712
3713 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3714 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3715 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" },
3716 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003717 { "DD2 MIXL", NULL, "dac mono4 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003718 { "dac mono4 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003719 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3720 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3721 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" },
3722 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003723 { "DD2 MIXR", NULL, "dac mono4 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003724 { "dac mono4 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003725
3726 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" },
3727 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" },
3728 { "Mono DAC MIX", NULL, "Mono DAC MIXL" },
3729 { "Mono DAC MIX", NULL, "Mono DAC MIXR" },
3730 { "DD1 MIX", NULL, "DD1 MIXL" },
3731 { "DD1 MIX", NULL, "DD1 MIXR" },
3732 { "DD2 MIX", NULL, "DD2 MIXL" },
3733 { "DD2 MIX", NULL, "DD2 MIXR" },
3734
3735 { "DAC12 SRC Mux", "STO1 DAC MIX", "Stereo DAC MIX" },
3736 { "DAC12 SRC Mux", "MONO DAC MIX", "Mono DAC MIX" },
3737 { "DAC12 SRC Mux", "DD MIX1", "DD1 MIX" },
3738 { "DAC12 SRC Mux", "DD MIX2", "DD2 MIX" },
3739
3740 { "DAC3 SRC Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3741 { "DAC3 SRC Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3742 { "DAC3 SRC Mux", "DD MIX1L", "DD1 MIXL" },
3743 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" },
3744
3745 { "DAC 1", NULL, "DAC12 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003746 { "DAC 2", NULL, "DAC12 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003747 { "DAC 3", NULL, "DAC3 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003748
3749 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
3750 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
3751 { "PDM1 L Mux", "DD MIX1", "DD1 MIXL" },
3752 { "PDM1 L Mux", "DD MIX2", "DD2 MIXL" },
3753 { "PDM1 L Mux", NULL, "PDM1 Power" },
3754 { "PDM1 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
3755 { "PDM1 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
3756 { "PDM1 R Mux", "DD MIX1", "DD1 MIXR" },
3757 { "PDM1 R Mux", "DD MIX2", "DD2 MIXR" },
3758 { "PDM1 R Mux", NULL, "PDM1 Power" },
3759 { "PDM2 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
3760 { "PDM2 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
3761 { "PDM2 L Mux", "DD MIX1", "DD1 MIXL" },
3762 { "PDM2 L Mux", "DD MIX2", "DD2 MIXL" },
3763 { "PDM2 L Mux", NULL, "PDM2 Power" },
3764 { "PDM2 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
3765 { "PDM2 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
3766 { "PDM2 R Mux", "DD MIX1", "DD1 MIXR" },
3767 { "PDM2 R Mux", "DD MIX1", "DD2 MIXR" },
3768 { "PDM2 R Mux", NULL, "PDM2 Power" },
3769
3770 { "LOUT1 amp", NULL, "DAC 1" },
3771 { "LOUT2 amp", NULL, "DAC 2" },
3772 { "LOUT3 amp", NULL, "DAC 3" },
3773
Oder Chiou683996c2014-11-19 13:52:20 +08003774 { "LOUT1 vref", NULL, "LOUT1 amp" },
3775 { "LOUT2 vref", NULL, "LOUT2 amp" },
3776 { "LOUT3 vref", NULL, "LOUT3 amp" },
3777
3778 { "LOUT1", NULL, "LOUT1 vref" },
3779 { "LOUT2", NULL, "LOUT2 vref" },
3780 { "LOUT3", NULL, "LOUT3 vref" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003781
3782 { "PDM1L", NULL, "PDM1 L Mux" },
3783 { "PDM1R", NULL, "PDM1 R Mux" },
3784 { "PDM2L", NULL, "PDM2 L Mux" },
3785 { "PDM2R", NULL, "PDM2 R Mux" },
3786};
3787
Bard Liao2d15d972014-08-27 19:50:34 +08003788static const struct snd_soc_dapm_route rt5677_dmic2_clk_1[] = {
3789 { "DMIC L2", NULL, "DMIC1 power" },
3790 { "DMIC R2", NULL, "DMIC1 power" },
3791};
3792
3793static const struct snd_soc_dapm_route rt5677_dmic2_clk_2[] = {
3794 { "DMIC L2", NULL, "DMIC2 power" },
3795 { "DMIC R2", NULL, "DMIC2 power" },
3796};
3797
Oder Chiou0e826e82014-05-26 20:32:33 +08003798static int rt5677_hw_params(struct snd_pcm_substream *substream,
3799 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
3800{
3801 struct snd_soc_codec *codec = dai->codec;
3802 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3803 unsigned int val_len = 0, val_clk, mask_clk;
3804 int pre_div, bclk_ms, frame_size;
3805
3806 rt5677->lrck[dai->id] = params_rate(params);
Axel Lin30f14b42014-06-10 08:57:36 +08003807 pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]);
Oder Chiou0e826e82014-05-26 20:32:33 +08003808 if (pre_div < 0) {
Anatol Pomozov8a4bd602014-10-15 13:55:32 -07003809 dev_err(codec->dev, "Unsupported clock setting: sysclk=%dHz lrck=%dHz\n",
3810 rt5677->sysclk, rt5677->lrck[dai->id]);
Oder Chiou0e826e82014-05-26 20:32:33 +08003811 return -EINVAL;
3812 }
3813 frame_size = snd_soc_params_to_frame_size(params);
3814 if (frame_size < 0) {
3815 dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
3816 return -EINVAL;
3817 }
3818 bclk_ms = frame_size > 32;
3819 rt5677->bclk[dai->id] = rt5677->lrck[dai->id] * (32 << bclk_ms);
3820
3821 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n",
3822 rt5677->bclk[dai->id], rt5677->lrck[dai->id]);
3823 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n",
3824 bclk_ms, pre_div, dai->id);
3825
3826 switch (params_width(params)) {
3827 case 16:
3828 break;
3829 case 20:
3830 val_len |= RT5677_I2S_DL_20;
3831 break;
3832 case 24:
3833 val_len |= RT5677_I2S_DL_24;
3834 break;
3835 case 8:
3836 val_len |= RT5677_I2S_DL_8;
3837 break;
3838 default:
3839 return -EINVAL;
3840 }
3841
3842 switch (dai->id) {
3843 case RT5677_AIF1:
3844 mask_clk = RT5677_I2S_PD1_MASK;
3845 val_clk = pre_div << RT5677_I2S_PD1_SFT;
3846 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
3847 RT5677_I2S_DL_MASK, val_len);
3848 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3849 mask_clk, val_clk);
3850 break;
3851 case RT5677_AIF2:
3852 mask_clk = RT5677_I2S_PD2_MASK;
3853 val_clk = pre_div << RT5677_I2S_PD2_SFT;
3854 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
3855 RT5677_I2S_DL_MASK, val_len);
3856 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3857 mask_clk, val_clk);
3858 break;
3859 case RT5677_AIF3:
3860 mask_clk = RT5677_I2S_BCLK_MS3_MASK | RT5677_I2S_PD3_MASK;
3861 val_clk = bclk_ms << RT5677_I2S_BCLK_MS3_SFT |
3862 pre_div << RT5677_I2S_PD3_SFT;
3863 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
3864 RT5677_I2S_DL_MASK, val_len);
3865 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3866 mask_clk, val_clk);
3867 break;
3868 case RT5677_AIF4:
3869 mask_clk = RT5677_I2S_BCLK_MS4_MASK | RT5677_I2S_PD4_MASK;
3870 val_clk = bclk_ms << RT5677_I2S_BCLK_MS4_SFT |
3871 pre_div << RT5677_I2S_PD4_SFT;
3872 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
3873 RT5677_I2S_DL_MASK, val_len);
3874 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3875 mask_clk, val_clk);
3876 break;
3877 default:
3878 break;
3879 }
3880
3881 return 0;
3882}
3883
3884static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
3885{
3886 struct snd_soc_codec *codec = dai->codec;
3887 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3888 unsigned int reg_val = 0;
3889
3890 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
3891 case SND_SOC_DAIFMT_CBM_CFM:
3892 rt5677->master[dai->id] = 1;
3893 break;
3894 case SND_SOC_DAIFMT_CBS_CFS:
3895 reg_val |= RT5677_I2S_MS_S;
3896 rt5677->master[dai->id] = 0;
3897 break;
3898 default:
3899 return -EINVAL;
3900 }
3901
3902 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
3903 case SND_SOC_DAIFMT_NB_NF:
3904 break;
3905 case SND_SOC_DAIFMT_IB_NF:
3906 reg_val |= RT5677_I2S_BP_INV;
3907 break;
3908 default:
3909 return -EINVAL;
3910 }
3911
3912 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
3913 case SND_SOC_DAIFMT_I2S:
3914 break;
3915 case SND_SOC_DAIFMT_LEFT_J:
3916 reg_val |= RT5677_I2S_DF_LEFT;
3917 break;
3918 case SND_SOC_DAIFMT_DSP_A:
3919 reg_val |= RT5677_I2S_DF_PCM_A;
3920 break;
3921 case SND_SOC_DAIFMT_DSP_B:
3922 reg_val |= RT5677_I2S_DF_PCM_B;
3923 break;
3924 default:
3925 return -EINVAL;
3926 }
3927
3928 switch (dai->id) {
3929 case RT5677_AIF1:
3930 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
3931 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3932 RT5677_I2S_DF_MASK, reg_val);
3933 break;
3934 case RT5677_AIF2:
3935 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
3936 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3937 RT5677_I2S_DF_MASK, reg_val);
3938 break;
3939 case RT5677_AIF3:
3940 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
3941 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3942 RT5677_I2S_DF_MASK, reg_val);
3943 break;
3944 case RT5677_AIF4:
3945 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
3946 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3947 RT5677_I2S_DF_MASK, reg_val);
3948 break;
3949 default:
3950 break;
3951 }
3952
3953
3954 return 0;
3955}
3956
3957static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai,
3958 int clk_id, unsigned int freq, int dir)
3959{
3960 struct snd_soc_codec *codec = dai->codec;
3961 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3962 unsigned int reg_val = 0;
3963
3964 if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src)
3965 return 0;
3966
3967 switch (clk_id) {
3968 case RT5677_SCLK_S_MCLK:
3969 reg_val |= RT5677_SCLK_SRC_MCLK;
3970 break;
3971 case RT5677_SCLK_S_PLL1:
3972 reg_val |= RT5677_SCLK_SRC_PLL1;
3973 break;
3974 case RT5677_SCLK_S_RCCLK:
3975 reg_val |= RT5677_SCLK_SRC_RCCLK;
3976 break;
3977 default:
3978 dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
3979 return -EINVAL;
3980 }
3981 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
3982 RT5677_SCLK_SRC_MASK, reg_val);
3983 rt5677->sysclk = freq;
3984 rt5677->sysclk_src = clk_id;
3985
3986 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id);
3987
3988 return 0;
3989}
3990
3991/**
3992 * rt5677_pll_calc - Calcualte PLL M/N/K code.
3993 * @freq_in: external clock provided to codec.
3994 * @freq_out: target clock which codec works on.
3995 * @pll_code: Pointer to structure with M, N, K, bypass K and bypass M flag.
3996 *
3997 * Calcualte M/N/K code and bypass K/M flag to configure PLL for codec.
3998 *
3999 * Returns 0 for success or negative error code.
4000 */
4001static int rt5677_pll_calc(const unsigned int freq_in,
Axel Lin099d3342014-06-17 12:41:31 +08004002 const unsigned int freq_out, struct rl6231_pll_code *pll_code)
Oder Chiou0e826e82014-05-26 20:32:33 +08004003{
Axel Lin099d3342014-06-17 12:41:31 +08004004 if (RT5677_PLL_INP_MIN > freq_in)
Oder Chiou0e826e82014-05-26 20:32:33 +08004005 return -EINVAL;
4006
Axel Lin099d3342014-06-17 12:41:31 +08004007 return rl6231_pll_calc(freq_in, freq_out, pll_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004008}
4009
4010static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
4011 unsigned int freq_in, unsigned int freq_out)
4012{
4013 struct snd_soc_codec *codec = dai->codec;
4014 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Axel Lin099d3342014-06-17 12:41:31 +08004015 struct rl6231_pll_code pll_code;
Oder Chiou0e826e82014-05-26 20:32:33 +08004016 int ret;
4017
4018 if (source == rt5677->pll_src && freq_in == rt5677->pll_in &&
4019 freq_out == rt5677->pll_out)
4020 return 0;
4021
4022 if (!freq_in || !freq_out) {
4023 dev_dbg(codec->dev, "PLL disabled\n");
4024
4025 rt5677->pll_in = 0;
4026 rt5677->pll_out = 0;
4027 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4028 RT5677_SCLK_SRC_MASK, RT5677_SCLK_SRC_MCLK);
4029 return 0;
4030 }
4031
4032 switch (source) {
4033 case RT5677_PLL1_S_MCLK:
4034 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4035 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_MCLK);
4036 break;
4037 case RT5677_PLL1_S_BCLK1:
4038 case RT5677_PLL1_S_BCLK2:
4039 case RT5677_PLL1_S_BCLK3:
4040 case RT5677_PLL1_S_BCLK4:
4041 switch (dai->id) {
4042 case RT5677_AIF1:
4043 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4044 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK1);
4045 break;
4046 case RT5677_AIF2:
4047 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4048 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK2);
4049 break;
4050 case RT5677_AIF3:
4051 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4052 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK3);
4053 break;
4054 case RT5677_AIF4:
4055 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4056 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK4);
4057 break;
4058 default:
4059 break;
4060 }
4061 break;
4062 default:
4063 dev_err(codec->dev, "Unknown PLL source %d\n", source);
4064 return -EINVAL;
4065 }
4066
4067 ret = rt5677_pll_calc(freq_in, freq_out, &pll_code);
4068 if (ret < 0) {
4069 dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
4070 return ret;
4071 }
4072
Axel Lin099d3342014-06-17 12:41:31 +08004073 dev_dbg(codec->dev, "m_bypass=%d m=%d n=%d k=%d\n",
4074 pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
4075 pll_code.n_code, pll_code.k_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004076
4077 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1,
Axel Lin099d3342014-06-17 12:41:31 +08004078 pll_code.n_code << RT5677_PLL_N_SFT | pll_code.k_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004079 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2,
4080 (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT |
4081 pll_code.m_bp << RT5677_PLL_M_BP_SFT);
4082
4083 rt5677->pll_in = freq_in;
4084 rt5677->pll_out = freq_out;
4085 rt5677->pll_src = source;
4086
4087 return 0;
4088}
4089
Oder Chiou48561af2014-09-17 15:12:33 +08004090static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
4091 unsigned int rx_mask, int slots, int slot_width)
4092{
4093 struct snd_soc_codec *codec = dai->codec;
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004094 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou48561af2014-09-17 15:12:33 +08004095 unsigned int val = 0;
4096
4097 if (rx_mask || tx_mask)
4098 val |= (1 << 12);
4099
4100 switch (slots) {
4101 case 4:
4102 val |= (1 << 10);
4103 break;
4104 case 6:
4105 val |= (2 << 10);
4106 break;
4107 case 8:
4108 val |= (3 << 10);
4109 break;
4110 case 2:
4111 default:
4112 break;
4113 }
4114
4115 switch (slot_width) {
4116 case 20:
4117 val |= (1 << 8);
4118 break;
4119 case 24:
4120 val |= (2 << 8);
4121 break;
4122 case 32:
4123 val |= (3 << 8);
4124 break;
4125 case 16:
4126 default:
4127 break;
4128 }
4129
4130 switch (dai->id) {
4131 case RT5677_AIF1:
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004132 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00,
4133 val);
Oder Chiou48561af2014-09-17 15:12:33 +08004134 break;
4135 case RT5677_AIF2:
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004136 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00,
4137 val);
Oder Chiou48561af2014-09-17 15:12:33 +08004138 break;
4139 default:
4140 break;
4141 }
4142
4143 return 0;
4144}
4145
Oder Chiou0e826e82014-05-26 20:32:33 +08004146static int rt5677_set_bias_level(struct snd_soc_codec *codec,
4147 enum snd_soc_bias_level level)
4148{
4149 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4150
4151 switch (level) {
4152 case SND_SOC_BIAS_ON:
4153 break;
4154
4155 case SND_SOC_BIAS_PREPARE:
4156 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) {
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004157 rt5677_set_dsp_vad(codec, false);
4158
Oder Chiou0e826e82014-05-26 20:32:33 +08004159 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
4160 RT5677_LDO1_SEL_MASK | RT5677_LDO2_SEL_MASK,
4161 0x0055);
4162 regmap_update_bits(rt5677->regmap,
4163 RT5677_PR_BASE + RT5677_BIAS_CUR4,
4164 0x0f00, 0x0f00);
4165 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
Oder Chiou683996c2014-11-19 13:52:20 +08004166 RT5677_PWR_FV1 | RT5677_PWR_FV2 |
Oder Chiou0e826e82014-05-26 20:32:33 +08004167 RT5677_PWR_VREF1 | RT5677_PWR_MB |
4168 RT5677_PWR_BG | RT5677_PWR_VREF2,
4169 RT5677_PWR_VREF1 | RT5677_PWR_MB |
4170 RT5677_PWR_BG | RT5677_PWR_VREF2);
Oder Chiou683996c2014-11-19 13:52:20 +08004171 rt5677->is_vref_slow = false;
Oder Chiou0e826e82014-05-26 20:32:33 +08004172 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
4173 RT5677_PWR_CORE, RT5677_PWR_CORE);
4174 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC,
4175 0x1, 0x1);
4176 }
4177 break;
4178
4179 case SND_SOC_BIAS_STANDBY:
4180 break;
4181
4182 case SND_SOC_BIAS_OFF:
4183 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0);
4184 regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000);
4185 regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000);
Oder Chiouf18803a2014-07-07 15:37:00 +08004186 regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0022);
Oder Chiou0e826e82014-05-26 20:32:33 +08004187 regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000);
4188 regmap_update_bits(rt5677->regmap,
4189 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000);
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004190
4191 if (rt5677->dsp_vad_en)
4192 rt5677_set_dsp_vad(codec, true);
Oder Chiou0e826e82014-05-26 20:32:33 +08004193 break;
4194
4195 default:
4196 break;
4197 }
4198 codec->dapm.bias_level = level;
4199
4200 return 0;
4201}
4202
Oder Chiou44caf762014-09-16 11:37:39 +08004203#ifdef CONFIG_GPIOLIB
4204static inline struct rt5677_priv *gpio_to_rt5677(struct gpio_chip *chip)
4205{
4206 return container_of(chip, struct rt5677_priv, gpio_chip);
4207}
4208
4209static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
4210{
4211 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4212
4213 switch (offset) {
4214 case RT5677_GPIO1 ... RT5677_GPIO5:
4215 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4216 0x1 << (offset * 3 + 1), !!value << (offset * 3 + 1));
4217 break;
4218
4219 case RT5677_GPIO6:
4220 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4221 RT5677_GPIO6_OUT_MASK, !!value << RT5677_GPIO6_OUT_SFT);
4222 break;
4223
4224 default:
4225 break;
4226 }
4227}
4228
4229static int rt5677_gpio_direction_out(struct gpio_chip *chip,
4230 unsigned offset, int value)
4231{
4232 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4233
4234 switch (offset) {
4235 case RT5677_GPIO1 ... RT5677_GPIO5:
4236 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4237 0x3 << (offset * 3 + 1),
4238 (0x2 | !!value) << (offset * 3 + 1));
4239 break;
4240
4241 case RT5677_GPIO6:
4242 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4243 RT5677_GPIO6_DIR_MASK | RT5677_GPIO6_OUT_MASK,
4244 RT5677_GPIO6_DIR_OUT | !!value << RT5677_GPIO6_OUT_SFT);
4245 break;
4246
4247 default:
4248 break;
4249 }
4250
4251 return 0;
4252}
4253
4254static int rt5677_gpio_get(struct gpio_chip *chip, unsigned offset)
4255{
4256 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4257 int value, ret;
4258
4259 ret = regmap_read(rt5677->regmap, RT5677_GPIO_ST, &value);
4260 if (ret < 0)
4261 return ret;
4262
4263 return (value & (0x1 << offset)) >> offset;
4264}
4265
4266static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
4267{
4268 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4269
4270 switch (offset) {
4271 case RT5677_GPIO1 ... RT5677_GPIO5:
4272 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4273 0x1 << (offset * 3 + 2), 0x0);
4274 break;
4275
4276 case RT5677_GPIO6:
4277 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4278 RT5677_GPIO6_DIR_MASK, RT5677_GPIO6_DIR_IN);
4279 break;
4280
4281 default:
4282 break;
4283 }
4284
4285 return 0;
4286}
4287
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004288/** Configures the gpio as
4289 * 0 - floating
4290 * 1 - pull down
4291 * 2 - pull up
4292 */
4293static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
4294 int value)
4295{
4296 int shift;
4297
4298 switch (offset) {
4299 case RT5677_GPIO1 ... RT5677_GPIO2:
4300 shift = 2 * (1 - offset);
4301 regmap_update_bits(rt5677->regmap,
4302 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL2,
4303 0x3 << shift,
4304 (value & 0x3) << shift);
4305 break;
4306
4307 case RT5677_GPIO3 ... RT5677_GPIO6:
4308 shift = 2 * (9 - offset);
4309 regmap_update_bits(rt5677->regmap,
4310 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL3,
4311 0x3 << shift,
4312 (value & 0x3) << shift);
4313 break;
4314
4315 default:
4316 break;
4317 }
4318}
4319
Oder Chiou5e3363a2014-10-16 11:24:26 -07004320static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset)
4321{
4322 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4323 struct regmap_irq_chip_data *data = rt5677->irq_data;
4324 int irq;
4325
4326 if (offset >= RT5677_GPIO1 && offset <= RT5677_GPIO3) {
4327 if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) ||
4328 (rt5677->pdata.jd1_gpio == 2 &&
4329 offset == RT5677_GPIO2) ||
4330 (rt5677->pdata.jd1_gpio == 3 &&
4331 offset == RT5677_GPIO3)) {
4332 irq = RT5677_IRQ_JD1;
4333 } else {
4334 return -ENXIO;
4335 }
4336 }
4337
4338 if (offset >= RT5677_GPIO4 && offset <= RT5677_GPIO6) {
4339 if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) ||
4340 (rt5677->pdata.jd2_gpio == 2 &&
4341 offset == RT5677_GPIO5) ||
4342 (rt5677->pdata.jd2_gpio == 3 &&
4343 offset == RT5677_GPIO6)) {
4344 irq = RT5677_IRQ_JD2;
4345 } else if ((rt5677->pdata.jd3_gpio == 1 &&
4346 offset == RT5677_GPIO4) ||
4347 (rt5677->pdata.jd3_gpio == 2 &&
4348 offset == RT5677_GPIO5) ||
4349 (rt5677->pdata.jd3_gpio == 3 &&
4350 offset == RT5677_GPIO6)) {
4351 irq = RT5677_IRQ_JD3;
4352 } else {
4353 return -ENXIO;
4354 }
4355 }
4356
4357 return regmap_irq_get_virq(data, irq);
4358}
4359
Oder Chiou44caf762014-09-16 11:37:39 +08004360static struct gpio_chip rt5677_template_chip = {
4361 .label = "rt5677",
4362 .owner = THIS_MODULE,
4363 .direction_output = rt5677_gpio_direction_out,
4364 .set = rt5677_gpio_set,
4365 .direction_input = rt5677_gpio_direction_in,
4366 .get = rt5677_gpio_get,
Oder Chiou5e3363a2014-10-16 11:24:26 -07004367 .to_irq = rt5677_to_irq,
Oder Chiou44caf762014-09-16 11:37:39 +08004368 .can_sleep = 1,
4369};
4370
4371static void rt5677_init_gpio(struct i2c_client *i2c)
4372{
4373 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4374 int ret;
4375
4376 rt5677->gpio_chip = rt5677_template_chip;
4377 rt5677->gpio_chip.ngpio = RT5677_GPIO_NUM;
4378 rt5677->gpio_chip.dev = &i2c->dev;
4379 rt5677->gpio_chip.base = -1;
4380
4381 ret = gpiochip_add(&rt5677->gpio_chip);
4382 if (ret != 0)
4383 dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret);
4384}
4385
4386static void rt5677_free_gpio(struct i2c_client *i2c)
4387{
4388 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08004389
Axel Lin5d5e63a2014-09-17 20:58:02 +08004390 gpiochip_remove(&rt5677->gpio_chip);
Oder Chiou44caf762014-09-16 11:37:39 +08004391}
4392#else
Anatol Pomozov45b6e1d2014-10-16 09:40:58 -07004393static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
4394 int value)
4395{
4396}
4397
Oder Chiou44caf762014-09-16 11:37:39 +08004398static void rt5677_init_gpio(struct i2c_client *i2c)
4399{
4400}
4401
4402static void rt5677_free_gpio(struct i2c_client *i2c)
4403{
4404}
4405#endif
4406
Oder Chiou0e826e82014-05-26 20:32:33 +08004407static int rt5677_probe(struct snd_soc_codec *codec)
4408{
4409 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004410 int i;
Oder Chiou0e826e82014-05-26 20:32:33 +08004411
4412 rt5677->codec = codec;
4413
Bard Liao2d15d972014-08-27 19:50:34 +08004414 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
4415 snd_soc_dapm_add_routes(&codec->dapm,
4416 rt5677_dmic2_clk_2,
4417 ARRAY_SIZE(rt5677_dmic2_clk_2));
4418 } else { /*use dmic1 clock by default*/
4419 snd_soc_dapm_add_routes(&codec->dapm,
4420 rt5677_dmic2_clk_1,
4421 ARRAY_SIZE(rt5677_dmic2_clk_1));
4422 }
4423
Oder Chiou0e826e82014-05-26 20:32:33 +08004424 rt5677_set_bias_level(codec, SND_SOC_BIAS_OFF);
4425
4426 regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020);
4427 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00);
4428
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004429 for (i = 0; i < RT5677_GPIO_NUM; i++)
4430 rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]);
4431
Oder Chiou5e3363a2014-10-16 11:24:26 -07004432 if (rt5677->irq_data) {
4433 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, 0x8000,
4434 0x8000);
4435 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x0018,
4436 0x0008);
4437
4438 if (rt5677->pdata.jd1_gpio)
4439 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4440 RT5677_SEL_GPIO_JD1_MASK,
4441 rt5677->pdata.jd1_gpio <<
4442 RT5677_SEL_GPIO_JD1_SFT);
4443
4444 if (rt5677->pdata.jd2_gpio)
4445 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4446 RT5677_SEL_GPIO_JD2_MASK,
4447 rt5677->pdata.jd2_gpio <<
4448 RT5677_SEL_GPIO_JD2_SFT);
4449
4450 if (rt5677->pdata.jd3_gpio)
4451 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4452 RT5677_SEL_GPIO_JD3_MASK,
4453 rt5677->pdata.jd3_gpio <<
4454 RT5677_SEL_GPIO_JD3_SFT);
4455 }
4456
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004457 mutex_init(&rt5677->dsp_cmd_lock);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004458 mutex_init(&rt5677->dsp_pri_lock);
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004459
Oder Chiou0e826e82014-05-26 20:32:33 +08004460 return 0;
4461}
4462
4463static int rt5677_remove(struct snd_soc_codec *codec)
4464{
4465 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4466
4467 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004468 if (gpio_is_valid(rt5677->pow_ldo2))
4469 gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +08004470
4471 return 0;
4472}
4473
4474#ifdef CONFIG_PM
4475static int rt5677_suspend(struct snd_soc_codec *codec)
4476{
4477 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4478
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004479 if (!rt5677->dsp_vad_en) {
4480 regcache_cache_only(rt5677->regmap, true);
4481 regcache_mark_dirty(rt5677->regmap);
4482 }
4483
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004484 if (gpio_is_valid(rt5677->pow_ldo2))
4485 gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +08004486
4487 return 0;
4488}
4489
4490static int rt5677_resume(struct snd_soc_codec *codec)
4491{
4492 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4493
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004494 if (gpio_is_valid(rt5677->pow_ldo2)) {
4495 gpio_set_value_cansleep(rt5677->pow_ldo2, 1);
4496 msleep(10);
4497 }
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004498
4499 if (!rt5677->dsp_vad_en) {
4500 regcache_cache_only(rt5677->regmap, false);
4501 regcache_sync(rt5677->regmap);
4502 }
Oder Chiou0e826e82014-05-26 20:32:33 +08004503
4504 return 0;
4505}
4506#else
4507#define rt5677_suspend NULL
4508#define rt5677_resume NULL
4509#endif
4510
Oder Chiou19ba4842014-11-05 13:42:53 +08004511static int rt5677_read(void *context, unsigned int reg, unsigned int *val)
4512{
4513 struct i2c_client *client = context;
4514 struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
4515
Oder Chiou6fe17da2014-11-25 09:51:41 +08004516 if (rt5677->is_dsp_mode) {
4517 if (reg > 0xff) {
4518 mutex_lock(&rt5677->dsp_pri_lock);
4519 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
4520 reg & 0xff);
4521 rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val);
4522 mutex_unlock(&rt5677->dsp_pri_lock);
4523 } else {
4524 rt5677_dsp_mode_i2c_read(rt5677, reg, val);
4525 }
4526 } else {
Oder Chiou19ba4842014-11-05 13:42:53 +08004527 regmap_read(rt5677->regmap_physical, reg, val);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004528 }
Oder Chiou19ba4842014-11-05 13:42:53 +08004529
4530 return 0;
4531}
4532
4533static int rt5677_write(void *context, unsigned int reg, unsigned int val)
4534{
4535 struct i2c_client *client = context;
4536 struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
4537
Oder Chiou6fe17da2014-11-25 09:51:41 +08004538 if (rt5677->is_dsp_mode) {
4539 if (reg > 0xff) {
4540 mutex_lock(&rt5677->dsp_pri_lock);
4541 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
4542 reg & 0xff);
4543 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA,
4544 val);
4545 mutex_unlock(&rt5677->dsp_pri_lock);
4546 } else {
4547 rt5677_dsp_mode_i2c_write(rt5677, reg, val);
4548 }
4549 } else {
Oder Chiou19ba4842014-11-05 13:42:53 +08004550 regmap_write(rt5677->regmap_physical, reg, val);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004551 }
Oder Chiou19ba4842014-11-05 13:42:53 +08004552
4553 return 0;
4554}
4555
Oder Chiou0e826e82014-05-26 20:32:33 +08004556#define RT5677_STEREO_RATES SNDRV_PCM_RATE_8000_96000
4557#define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
4558 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
4559
4560static struct snd_soc_dai_ops rt5677_aif_dai_ops = {
4561 .hw_params = rt5677_hw_params,
4562 .set_fmt = rt5677_set_dai_fmt,
4563 .set_sysclk = rt5677_set_dai_sysclk,
4564 .set_pll = rt5677_set_dai_pll,
Oder Chiou48561af2014-09-17 15:12:33 +08004565 .set_tdm_slot = rt5677_set_tdm_slot,
Oder Chiou0e826e82014-05-26 20:32:33 +08004566};
4567
4568static struct snd_soc_dai_driver rt5677_dai[] = {
4569 {
4570 .name = "rt5677-aif1",
4571 .id = RT5677_AIF1,
4572 .playback = {
4573 .stream_name = "AIF1 Playback",
4574 .channels_min = 1,
4575 .channels_max = 2,
4576 .rates = RT5677_STEREO_RATES,
4577 .formats = RT5677_FORMATS,
4578 },
4579 .capture = {
4580 .stream_name = "AIF1 Capture",
4581 .channels_min = 1,
4582 .channels_max = 2,
4583 .rates = RT5677_STEREO_RATES,
4584 .formats = RT5677_FORMATS,
4585 },
4586 .ops = &rt5677_aif_dai_ops,
4587 },
4588 {
4589 .name = "rt5677-aif2",
4590 .id = RT5677_AIF2,
4591 .playback = {
4592 .stream_name = "AIF2 Playback",
4593 .channels_min = 1,
4594 .channels_max = 2,
4595 .rates = RT5677_STEREO_RATES,
4596 .formats = RT5677_FORMATS,
4597 },
4598 .capture = {
4599 .stream_name = "AIF2 Capture",
4600 .channels_min = 1,
4601 .channels_max = 2,
4602 .rates = RT5677_STEREO_RATES,
4603 .formats = RT5677_FORMATS,
4604 },
4605 .ops = &rt5677_aif_dai_ops,
4606 },
4607 {
4608 .name = "rt5677-aif3",
4609 .id = RT5677_AIF3,
4610 .playback = {
4611 .stream_name = "AIF3 Playback",
4612 .channels_min = 1,
4613 .channels_max = 2,
4614 .rates = RT5677_STEREO_RATES,
4615 .formats = RT5677_FORMATS,
4616 },
4617 .capture = {
4618 .stream_name = "AIF3 Capture",
4619 .channels_min = 1,
4620 .channels_max = 2,
4621 .rates = RT5677_STEREO_RATES,
4622 .formats = RT5677_FORMATS,
4623 },
4624 .ops = &rt5677_aif_dai_ops,
4625 },
4626 {
4627 .name = "rt5677-aif4",
4628 .id = RT5677_AIF4,
4629 .playback = {
4630 .stream_name = "AIF4 Playback",
4631 .channels_min = 1,
4632 .channels_max = 2,
4633 .rates = RT5677_STEREO_RATES,
4634 .formats = RT5677_FORMATS,
4635 },
4636 .capture = {
4637 .stream_name = "AIF4 Capture",
4638 .channels_min = 1,
4639 .channels_max = 2,
4640 .rates = RT5677_STEREO_RATES,
4641 .formats = RT5677_FORMATS,
4642 },
4643 .ops = &rt5677_aif_dai_ops,
4644 },
4645 {
4646 .name = "rt5677-slimbus",
4647 .id = RT5677_AIF5,
4648 .playback = {
4649 .stream_name = "SLIMBus Playback",
4650 .channels_min = 1,
4651 .channels_max = 2,
4652 .rates = RT5677_STEREO_RATES,
4653 .formats = RT5677_FORMATS,
4654 },
4655 .capture = {
4656 .stream_name = "SLIMBus Capture",
4657 .channels_min = 1,
4658 .channels_max = 2,
4659 .rates = RT5677_STEREO_RATES,
4660 .formats = RT5677_FORMATS,
4661 },
4662 .ops = &rt5677_aif_dai_ops,
4663 },
4664};
4665
4666static struct snd_soc_codec_driver soc_codec_dev_rt5677 = {
4667 .probe = rt5677_probe,
4668 .remove = rt5677_remove,
4669 .suspend = rt5677_suspend,
4670 .resume = rt5677_resume,
4671 .set_bias_level = rt5677_set_bias_level,
4672 .idle_bias_off = true,
4673 .controls = rt5677_snd_controls,
4674 .num_controls = ARRAY_SIZE(rt5677_snd_controls),
4675 .dapm_widgets = rt5677_dapm_widgets,
4676 .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets),
4677 .dapm_routes = rt5677_dapm_routes,
4678 .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes),
4679};
4680
Oder Chiou19ba4842014-11-05 13:42:53 +08004681static const struct regmap_config rt5677_regmap_physical = {
4682 .name = "physical",
4683 .reg_bits = 8,
4684 .val_bits = 16,
4685
Oder Chiou6fe17da2014-11-25 09:51:41 +08004686 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
4687 RT5677_PR_SPACING),
Oder Chiou19ba4842014-11-05 13:42:53 +08004688 .readable_reg = rt5677_readable_register,
4689
4690 .cache_type = REGCACHE_NONE,
Oder Chiou6fe17da2014-11-25 09:51:41 +08004691 .ranges = rt5677_ranges,
4692 .num_ranges = ARRAY_SIZE(rt5677_ranges),
Oder Chiou19ba4842014-11-05 13:42:53 +08004693};
4694
Oder Chiou0e826e82014-05-26 20:32:33 +08004695static const struct regmap_config rt5677_regmap = {
4696 .reg_bits = 8,
4697 .val_bits = 16,
4698
4699 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
4700 RT5677_PR_SPACING),
4701
4702 .volatile_reg = rt5677_volatile_register,
4703 .readable_reg = rt5677_readable_register,
Oder Chiou19ba4842014-11-05 13:42:53 +08004704 .reg_read = rt5677_read,
4705 .reg_write = rt5677_write,
Oder Chiou0e826e82014-05-26 20:32:33 +08004706
4707 .cache_type = REGCACHE_RBTREE,
4708 .reg_defaults = rt5677_reg,
4709 .num_reg_defaults = ARRAY_SIZE(rt5677_reg),
4710 .ranges = rt5677_ranges,
4711 .num_ranges = ARRAY_SIZE(rt5677_ranges),
4712};
4713
4714static const struct i2c_device_id rt5677_i2c_id[] = {
4715 { "rt5677", 0 },
4716 { }
4717};
4718MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
4719
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004720static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np)
4721{
Anatol Pomozov6f67c382014-09-26 09:57:27 -07004722 rt5677->pdata.in1_diff = of_property_read_bool(np,
4723 "realtek,in1-differential");
4724 rt5677->pdata.in2_diff = of_property_read_bool(np,
4725 "realtek,in2-differential");
4726 rt5677->pdata.lout1_diff = of_property_read_bool(np,
4727 "realtek,lout1-differential");
4728 rt5677->pdata.lout2_diff = of_property_read_bool(np,
4729 "realtek,lout2-differential");
4730 rt5677->pdata.lout3_diff = of_property_read_bool(np,
4731 "realtek,lout3-differential");
4732
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004733 rt5677->pow_ldo2 = of_get_named_gpio(np,
4734 "realtek,pow-ldo2-gpio", 0);
4735
4736 /*
4737 * POW_LDO2 is optional (it may be statically tied on the board).
4738 * -ENOENT means that the property doesn't exist, i.e. there is no
4739 * GPIO, so is not an error. Any other error code means the property
4740 * exists, but could not be parsed.
4741 */
4742 if (!gpio_is_valid(rt5677->pow_ldo2) &&
4743 (rt5677->pow_ldo2 != -ENOENT))
4744 return rt5677->pow_ldo2;
4745
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004746 of_property_read_u8_array(np, "realtek,gpio-config",
4747 rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
4748
Oder Chiou5e3363a2014-10-16 11:24:26 -07004749 of_property_read_u32(np, "realtek,jd1-gpio", &rt5677->pdata.jd1_gpio);
4750 of_property_read_u32(np, "realtek,jd2-gpio", &rt5677->pdata.jd2_gpio);
4751 of_property_read_u32(np, "realtek,jd3-gpio", &rt5677->pdata.jd3_gpio);
4752
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004753 return 0;
4754}
4755
Oder Chiou5e3363a2014-10-16 11:24:26 -07004756static struct regmap_irq rt5677_irqs[] = {
4757 [RT5677_IRQ_JD1] = {
4758 .reg_offset = 0,
4759 .mask = RT5677_EN_IRQ_GPIO_JD1,
4760 },
4761 [RT5677_IRQ_JD2] = {
4762 .reg_offset = 0,
4763 .mask = RT5677_EN_IRQ_GPIO_JD2,
4764 },
4765 [RT5677_IRQ_JD3] = {
4766 .reg_offset = 0,
4767 .mask = RT5677_EN_IRQ_GPIO_JD3,
4768 },
4769};
4770
4771static struct regmap_irq_chip rt5677_irq_chip = {
4772 .name = "rt5677",
4773 .irqs = rt5677_irqs,
4774 .num_irqs = ARRAY_SIZE(rt5677_irqs),
4775
4776 .num_regs = 1,
4777 .status_base = RT5677_IRQ_CTRL1,
4778 .mask_base = RT5677_IRQ_CTRL1,
4779 .mask_invert = 1,
4780};
4781
Oder Chiou35d40d12014-11-19 13:52:19 +08004782static int rt5677_init_irq(struct i2c_client *i2c)
Oder Chiou5e3363a2014-10-16 11:24:26 -07004783{
4784 int ret;
4785 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4786
4787 if (!rt5677->pdata.jd1_gpio &&
4788 !rt5677->pdata.jd2_gpio &&
4789 !rt5677->pdata.jd3_gpio)
4790 return 0;
4791
4792 if (!i2c->irq) {
4793 dev_err(&i2c->dev, "No interrupt specified\n");
4794 return -EINVAL;
4795 }
4796
4797 ret = regmap_add_irq_chip(rt5677->regmap, i2c->irq,
4798 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
4799 &rt5677_irq_chip, &rt5677->irq_data);
4800
4801 if (ret != 0) {
4802 dev_err(&i2c->dev, "Failed to register IRQ chip: %d\n", ret);
4803 return ret;
4804 }
4805
4806 return 0;
4807}
4808
Oder Chiou35d40d12014-11-19 13:52:19 +08004809static void rt5677_free_irq(struct i2c_client *i2c)
Oder Chiou5e3363a2014-10-16 11:24:26 -07004810{
4811 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4812
4813 if (rt5677->irq_data)
4814 regmap_del_irq_chip(i2c->irq, rt5677->irq_data);
4815}
4816
Oder Chiou0e826e82014-05-26 20:32:33 +08004817static int rt5677_i2c_probe(struct i2c_client *i2c,
4818 const struct i2c_device_id *id)
4819{
4820 struct rt5677_platform_data *pdata = dev_get_platdata(&i2c->dev);
4821 struct rt5677_priv *rt5677;
4822 int ret;
4823 unsigned int val;
4824
4825 rt5677 = devm_kzalloc(&i2c->dev, sizeof(struct rt5677_priv),
4826 GFP_KERNEL);
4827 if (rt5677 == NULL)
4828 return -ENOMEM;
4829
4830 i2c_set_clientdata(i2c, rt5677);
4831
4832 if (pdata)
4833 rt5677->pdata = *pdata;
4834
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004835 if (i2c->dev.of_node) {
4836 ret = rt5677_parse_dt(rt5677, i2c->dev.of_node);
4837 if (ret) {
4838 dev_err(&i2c->dev, "Failed to parse device tree: %d\n",
4839 ret);
4840 return ret;
4841 }
4842 } else {
4843 rt5677->pow_ldo2 = -EINVAL;
4844 }
4845
4846 if (gpio_is_valid(rt5677->pow_ldo2)) {
4847 ret = devm_gpio_request_one(&i2c->dev, rt5677->pow_ldo2,
4848 GPIOF_OUT_INIT_HIGH,
4849 "RT5677 POW_LDO2");
4850 if (ret < 0) {
4851 dev_err(&i2c->dev, "Failed to request POW_LDO2 %d: %d\n",
4852 rt5677->pow_ldo2, ret);
4853 return ret;
4854 }
4855 /* Wait a while until I2C bus becomes available. The datasheet
4856 * does not specify the exact we should wait but startup
4857 * sequence mentiones at least a few milliseconds.
4858 */
4859 msleep(10);
4860 }
4861
Oder Chiou19ba4842014-11-05 13:42:53 +08004862 rt5677->regmap_physical = devm_regmap_init_i2c(i2c,
4863 &rt5677_regmap_physical);
4864 if (IS_ERR(rt5677->regmap_physical)) {
4865 ret = PTR_ERR(rt5677->regmap_physical);
4866 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
4867 ret);
4868 return ret;
4869 }
4870
4871 rt5677->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5677_regmap);
Oder Chiou0e826e82014-05-26 20:32:33 +08004872 if (IS_ERR(rt5677->regmap)) {
4873 ret = PTR_ERR(rt5677->regmap);
4874 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
4875 ret);
4876 return ret;
4877 }
4878
4879 regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val);
4880 if (val != RT5677_DEVICE_ID) {
4881 dev_err(&i2c->dev,
4882 "Device with ID register %x is not rt5677\n", val);
4883 return -ENODEV;
4884 }
4885
4886 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
4887
4888 ret = regmap_register_patch(rt5677->regmap, init_list,
4889 ARRAY_SIZE(init_list));
4890 if (ret != 0)
4891 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
4892
4893 if (rt5677->pdata.in1_diff)
4894 regmap_update_bits(rt5677->regmap, RT5677_IN1,
4895 RT5677_IN_DF1, RT5677_IN_DF1);
4896
4897 if (rt5677->pdata.in2_diff)
4898 regmap_update_bits(rt5677->regmap, RT5677_IN1,
4899 RT5677_IN_DF2, RT5677_IN_DF2);
4900
Anatol Pomozov6f67c382014-09-26 09:57:27 -07004901 if (rt5677->pdata.lout1_diff)
4902 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4903 RT5677_LOUT1_L_DF, RT5677_LOUT1_L_DF);
4904
4905 if (rt5677->pdata.lout2_diff)
4906 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4907 RT5677_LOUT2_L_DF, RT5677_LOUT2_L_DF);
4908
4909 if (rt5677->pdata.lout3_diff)
4910 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4911 RT5677_LOUT3_L_DF, RT5677_LOUT3_L_DF);
4912
Bard Liao2d15d972014-08-27 19:50:34 +08004913 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
4914 regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL2,
4915 RT5677_GPIO5_FUNC_MASK,
4916 RT5677_GPIO5_FUNC_DMIC);
4917 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4918 RT5677_GPIO5_DIR_MASK,
4919 RT5677_GPIO5_DIR_OUT);
4920 }
4921
Oder Chiou277880a2015-01-08 10:31:06 +08004922 if (rt5677->pdata.micbias1_vdd_3v3)
4923 regmap_update_bits(rt5677->regmap, RT5677_MICBIAS,
4924 RT5677_MICBIAS1_CTRL_VDD_MASK,
4925 RT5677_MICBIAS1_CTRL_VDD_3_3V);
4926
Oder Chiou44caf762014-09-16 11:37:39 +08004927 rt5677_init_gpio(i2c);
Oder Chiou35d40d12014-11-19 13:52:19 +08004928 rt5677_init_irq(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08004929
Axel Lind0bdcb92014-06-10 11:37:24 +08004930 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677,
4931 rt5677_dai, ARRAY_SIZE(rt5677_dai));
Oder Chiou0e826e82014-05-26 20:32:33 +08004932}
4933
4934static int rt5677_i2c_remove(struct i2c_client *i2c)
4935{
4936 snd_soc_unregister_codec(&i2c->dev);
Oder Chiou35d40d12014-11-19 13:52:19 +08004937 rt5677_free_irq(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08004938 rt5677_free_gpio(i2c);
Oder Chiou0e826e82014-05-26 20:32:33 +08004939
4940 return 0;
4941}
4942
4943static struct i2c_driver rt5677_i2c_driver = {
4944 .driver = {
4945 .name = "rt5677",
4946 .owner = THIS_MODULE,
4947 },
4948 .probe = rt5677_i2c_probe,
4949 .remove = rt5677_i2c_remove,
4950 .id_table = rt5677_i2c_id,
4951};
Axel Linc8cfbec2014-06-03 10:56:41 +08004952module_i2c_driver(rt5677_i2c_driver);
Oder Chiou0e826e82014-05-26 20:32:33 +08004953
4954MODULE_DESCRIPTION("ASoC RT5677 driver");
4955MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>");
4956MODULE_LICENSE("GPL v2");