blob: 84d162d91ff6ee5d55c400e6a46dc2de2505eceb [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},
Bard Liao74d6ea52015-04-24 15:19:29 +080065 {RT5677_PR_BASE + 0x15, 0x0490},
66 {RT5677_PR_BASE + 0x38, 0x0f71},
67 {RT5677_PR_BASE + 0x39, 0x0f71},
Oder Chiou0e826e82014-05-26 20:32:33 +080068};
69#define RT5677_INIT_REG_LEN ARRAY_SIZE(init_list)
70
71static const struct reg_default rt5677_reg[] = {
72 {RT5677_RESET , 0x0000},
73 {RT5677_LOUT1 , 0xa800},
74 {RT5677_IN1 , 0x0000},
75 {RT5677_MICBIAS , 0x0000},
76 {RT5677_SLIMBUS_PARAM , 0x0000},
77 {RT5677_SLIMBUS_RX , 0x0000},
78 {RT5677_SLIMBUS_CTRL , 0x0000},
79 {RT5677_SIDETONE_CTRL , 0x000b},
80 {RT5677_ANA_DAC1_2_3_SRC , 0x0000},
81 {RT5677_IF_DSP_DAC3_4_MIXER , 0x1111},
82 {RT5677_DAC4_DIG_VOL , 0xafaf},
83 {RT5677_DAC3_DIG_VOL , 0xafaf},
84 {RT5677_DAC1_DIG_VOL , 0xafaf},
85 {RT5677_DAC2_DIG_VOL , 0xafaf},
86 {RT5677_IF_DSP_DAC2_MIXER , 0x0011},
87 {RT5677_STO1_ADC_DIG_VOL , 0x2f2f},
88 {RT5677_MONO_ADC_DIG_VOL , 0x2f2f},
89 {RT5677_STO1_2_ADC_BST , 0x0000},
90 {RT5677_STO2_ADC_DIG_VOL , 0x2f2f},
91 {RT5677_ADC_BST_CTRL2 , 0x0000},
92 {RT5677_STO3_4_ADC_BST , 0x0000},
93 {RT5677_STO3_ADC_DIG_VOL , 0x2f2f},
94 {RT5677_STO4_ADC_DIG_VOL , 0x2f2f},
95 {RT5677_STO4_ADC_MIXER , 0xd4c0},
96 {RT5677_STO3_ADC_MIXER , 0xd4c0},
97 {RT5677_STO2_ADC_MIXER , 0xd4c0},
98 {RT5677_STO1_ADC_MIXER , 0xd4c0},
99 {RT5677_MONO_ADC_MIXER , 0xd4d1},
100 {RT5677_ADC_IF_DSP_DAC1_MIXER , 0x8080},
101 {RT5677_STO1_DAC_MIXER , 0xaaaa},
102 {RT5677_MONO_DAC_MIXER , 0xaaaa},
103 {RT5677_DD1_MIXER , 0xaaaa},
104 {RT5677_DD2_MIXER , 0xaaaa},
105 {RT5677_IF3_DATA , 0x0000},
106 {RT5677_IF4_DATA , 0x0000},
107 {RT5677_PDM_OUT_CTRL , 0x8888},
108 {RT5677_PDM_DATA_CTRL1 , 0x0000},
109 {RT5677_PDM_DATA_CTRL2 , 0x0000},
110 {RT5677_PDM1_DATA_CTRL2 , 0x0000},
111 {RT5677_PDM1_DATA_CTRL3 , 0x0000},
112 {RT5677_PDM1_DATA_CTRL4 , 0x0000},
113 {RT5677_PDM2_DATA_CTRL2 , 0x0000},
114 {RT5677_PDM2_DATA_CTRL3 , 0x0000},
115 {RT5677_PDM2_DATA_CTRL4 , 0x0000},
116 {RT5677_TDM1_CTRL1 , 0x0300},
117 {RT5677_TDM1_CTRL2 , 0x0000},
118 {RT5677_TDM1_CTRL3 , 0x4000},
119 {RT5677_TDM1_CTRL4 , 0x0123},
120 {RT5677_TDM1_CTRL5 , 0x4567},
121 {RT5677_TDM2_CTRL1 , 0x0300},
122 {RT5677_TDM2_CTRL2 , 0x0000},
123 {RT5677_TDM2_CTRL3 , 0x4000},
124 {RT5677_TDM2_CTRL4 , 0x0123},
125 {RT5677_TDM2_CTRL5 , 0x4567},
126 {RT5677_I2C_MASTER_CTRL1 , 0x0001},
127 {RT5677_I2C_MASTER_CTRL2 , 0x0000},
128 {RT5677_I2C_MASTER_CTRL3 , 0x0000},
129 {RT5677_I2C_MASTER_CTRL4 , 0x0000},
130 {RT5677_I2C_MASTER_CTRL5 , 0x0000},
131 {RT5677_I2C_MASTER_CTRL6 , 0x0000},
132 {RT5677_I2C_MASTER_CTRL7 , 0x0000},
133 {RT5677_I2C_MASTER_CTRL8 , 0x0000},
134 {RT5677_DMIC_CTRL1 , 0x1505},
135 {RT5677_DMIC_CTRL2 , 0x0055},
136 {RT5677_HAP_GENE_CTRL1 , 0x0111},
137 {RT5677_HAP_GENE_CTRL2 , 0x0064},
138 {RT5677_HAP_GENE_CTRL3 , 0xef0e},
139 {RT5677_HAP_GENE_CTRL4 , 0xf0f0},
140 {RT5677_HAP_GENE_CTRL5 , 0xef0e},
141 {RT5677_HAP_GENE_CTRL6 , 0xf0f0},
142 {RT5677_HAP_GENE_CTRL7 , 0xef0e},
143 {RT5677_HAP_GENE_CTRL8 , 0xf0f0},
144 {RT5677_HAP_GENE_CTRL9 , 0xf000},
145 {RT5677_HAP_GENE_CTRL10 , 0x0000},
146 {RT5677_PWR_DIG1 , 0x0000},
147 {RT5677_PWR_DIG2 , 0x0000},
148 {RT5677_PWR_ANLG1 , 0x0055},
149 {RT5677_PWR_ANLG2 , 0x0000},
150 {RT5677_PWR_DSP1 , 0x0001},
151 {RT5677_PWR_DSP_ST , 0x0000},
152 {RT5677_PWR_DSP2 , 0x0000},
153 {RT5677_ADC_DAC_HPF_CTRL1 , 0x0e00},
154 {RT5677_PRIV_INDEX , 0x0000},
155 {RT5677_PRIV_DATA , 0x0000},
156 {RT5677_I2S4_SDP , 0x8000},
157 {RT5677_I2S1_SDP , 0x8000},
158 {RT5677_I2S2_SDP , 0x8000},
159 {RT5677_I2S3_SDP , 0x8000},
160 {RT5677_CLK_TREE_CTRL1 , 0x1111},
161 {RT5677_CLK_TREE_CTRL2 , 0x1111},
162 {RT5677_CLK_TREE_CTRL3 , 0x0000},
163 {RT5677_PLL1_CTRL1 , 0x0000},
164 {RT5677_PLL1_CTRL2 , 0x0000},
165 {RT5677_PLL2_CTRL1 , 0x0c60},
166 {RT5677_PLL2_CTRL2 , 0x2000},
167 {RT5677_GLB_CLK1 , 0x0000},
168 {RT5677_GLB_CLK2 , 0x0000},
169 {RT5677_ASRC_1 , 0x0000},
170 {RT5677_ASRC_2 , 0x0000},
171 {RT5677_ASRC_3 , 0x0000},
172 {RT5677_ASRC_4 , 0x0000},
173 {RT5677_ASRC_5 , 0x0000},
174 {RT5677_ASRC_6 , 0x0000},
175 {RT5677_ASRC_7 , 0x0000},
176 {RT5677_ASRC_8 , 0x0000},
177 {RT5677_ASRC_9 , 0x0000},
178 {RT5677_ASRC_10 , 0x0000},
179 {RT5677_ASRC_11 , 0x0000},
Oder Chiou86ae04b2014-11-17 10:18:11 +0800180 {RT5677_ASRC_12 , 0x0018},
Oder Chiou0e826e82014-05-26 20:32:33 +0800181 {RT5677_ASRC_13 , 0x0000},
182 {RT5677_ASRC_14 , 0x0000},
183 {RT5677_ASRC_15 , 0x0000},
184 {RT5677_ASRC_16 , 0x0000},
185 {RT5677_ASRC_17 , 0x0000},
186 {RT5677_ASRC_18 , 0x0000},
187 {RT5677_ASRC_19 , 0x0000},
188 {RT5677_ASRC_20 , 0x0000},
189 {RT5677_ASRC_21 , 0x000c},
190 {RT5677_ASRC_22 , 0x0000},
191 {RT5677_ASRC_23 , 0x0000},
192 {RT5677_VAD_CTRL1 , 0x2184},
193 {RT5677_VAD_CTRL2 , 0x010a},
194 {RT5677_VAD_CTRL3 , 0x0aea},
195 {RT5677_VAD_CTRL4 , 0x000c},
196 {RT5677_VAD_CTRL5 , 0x0000},
197 {RT5677_DSP_INB_CTRL1 , 0x0000},
198 {RT5677_DSP_INB_CTRL2 , 0x0000},
199 {RT5677_DSP_IN_OUTB_CTRL , 0x0000},
200 {RT5677_DSP_OUTB0_1_DIG_VOL , 0x2f2f},
201 {RT5677_DSP_OUTB2_3_DIG_VOL , 0x2f2f},
202 {RT5677_DSP_OUTB4_5_DIG_VOL , 0x2f2f},
203 {RT5677_DSP_OUTB6_7_DIG_VOL , 0x2f2f},
204 {RT5677_ADC_EQ_CTRL1 , 0x6000},
205 {RT5677_ADC_EQ_CTRL2 , 0x0000},
206 {RT5677_EQ_CTRL1 , 0xc000},
207 {RT5677_EQ_CTRL2 , 0x0000},
208 {RT5677_EQ_CTRL3 , 0x0000},
209 {RT5677_SOFT_VOL_ZERO_CROSS1 , 0x0009},
210 {RT5677_JD_CTRL1 , 0x0000},
211 {RT5677_JD_CTRL2 , 0x0000},
212 {RT5677_JD_CTRL3 , 0x0000},
213 {RT5677_IRQ_CTRL1 , 0x0000},
214 {RT5677_IRQ_CTRL2 , 0x0000},
215 {RT5677_GPIO_ST , 0x0000},
216 {RT5677_GPIO_CTRL1 , 0x0000},
217 {RT5677_GPIO_CTRL2 , 0x0000},
218 {RT5677_GPIO_CTRL3 , 0x0000},
219 {RT5677_STO1_ADC_HI_FILTER1 , 0xb320},
220 {RT5677_STO1_ADC_HI_FILTER2 , 0x0000},
221 {RT5677_MONO_ADC_HI_FILTER1 , 0xb300},
222 {RT5677_MONO_ADC_HI_FILTER2 , 0x0000},
223 {RT5677_STO2_ADC_HI_FILTER1 , 0xb300},
224 {RT5677_STO2_ADC_HI_FILTER2 , 0x0000},
225 {RT5677_STO3_ADC_HI_FILTER1 , 0xb300},
226 {RT5677_STO3_ADC_HI_FILTER2 , 0x0000},
227 {RT5677_STO4_ADC_HI_FILTER1 , 0xb300},
228 {RT5677_STO4_ADC_HI_FILTER2 , 0x0000},
229 {RT5677_MB_DRC_CTRL1 , 0x0f20},
230 {RT5677_DRC1_CTRL1 , 0x001f},
231 {RT5677_DRC1_CTRL2 , 0x020c},
232 {RT5677_DRC1_CTRL3 , 0x1f00},
233 {RT5677_DRC1_CTRL4 , 0x0000},
234 {RT5677_DRC1_CTRL5 , 0x0000},
235 {RT5677_DRC1_CTRL6 , 0x0029},
236 {RT5677_DRC2_CTRL1 , 0x001f},
237 {RT5677_DRC2_CTRL2 , 0x020c},
238 {RT5677_DRC2_CTRL3 , 0x1f00},
239 {RT5677_DRC2_CTRL4 , 0x0000},
240 {RT5677_DRC2_CTRL5 , 0x0000},
241 {RT5677_DRC2_CTRL6 , 0x0029},
242 {RT5677_DRC1_HL_CTRL1 , 0x8000},
243 {RT5677_DRC1_HL_CTRL2 , 0x0200},
244 {RT5677_DRC2_HL_CTRL1 , 0x8000},
245 {RT5677_DRC2_HL_CTRL2 , 0x0200},
246 {RT5677_DSP_INB1_SRC_CTRL1 , 0x5800},
247 {RT5677_DSP_INB1_SRC_CTRL2 , 0x0000},
248 {RT5677_DSP_INB1_SRC_CTRL3 , 0x0000},
249 {RT5677_DSP_INB1_SRC_CTRL4 , 0x0800},
250 {RT5677_DSP_INB2_SRC_CTRL1 , 0x5800},
251 {RT5677_DSP_INB2_SRC_CTRL2 , 0x0000},
252 {RT5677_DSP_INB2_SRC_CTRL3 , 0x0000},
253 {RT5677_DSP_INB2_SRC_CTRL4 , 0x0800},
254 {RT5677_DSP_INB3_SRC_CTRL1 , 0x5800},
255 {RT5677_DSP_INB3_SRC_CTRL2 , 0x0000},
256 {RT5677_DSP_INB3_SRC_CTRL3 , 0x0000},
257 {RT5677_DSP_INB3_SRC_CTRL4 , 0x0800},
258 {RT5677_DSP_OUTB1_SRC_CTRL1 , 0x5800},
259 {RT5677_DSP_OUTB1_SRC_CTRL2 , 0x0000},
260 {RT5677_DSP_OUTB1_SRC_CTRL3 , 0x0000},
261 {RT5677_DSP_OUTB1_SRC_CTRL4 , 0x0800},
262 {RT5677_DSP_OUTB2_SRC_CTRL1 , 0x5800},
263 {RT5677_DSP_OUTB2_SRC_CTRL2 , 0x0000},
264 {RT5677_DSP_OUTB2_SRC_CTRL3 , 0x0000},
265 {RT5677_DSP_OUTB2_SRC_CTRL4 , 0x0800},
266 {RT5677_DSP_OUTB_0123_MIXER_CTRL, 0xfefe},
267 {RT5677_DSP_OUTB_45_MIXER_CTRL , 0xfefe},
268 {RT5677_DSP_OUTB_67_MIXER_CTRL , 0xfefe},
269 {RT5677_DIG_MISC , 0x0000},
270 {RT5677_GEN_CTRL1 , 0x0000},
271 {RT5677_GEN_CTRL2 , 0x0000},
272 {RT5677_VENDOR_ID , 0x0000},
273 {RT5677_VENDOR_ID1 , 0x10ec},
274 {RT5677_VENDOR_ID2 , 0x6327},
275};
276
277static bool rt5677_volatile_register(struct device *dev, unsigned int reg)
278{
279 int i;
280
281 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
282 if (reg >= rt5677_ranges[i].range_min &&
283 reg <= rt5677_ranges[i].range_max) {
284 return true;
285 }
286 }
287
288 switch (reg) {
289 case RT5677_RESET:
290 case RT5677_SLIMBUS_PARAM:
291 case RT5677_PDM_DATA_CTRL1:
292 case RT5677_PDM_DATA_CTRL2:
293 case RT5677_PDM1_DATA_CTRL4:
294 case RT5677_PDM2_DATA_CTRL4:
295 case RT5677_I2C_MASTER_CTRL1:
296 case RT5677_I2C_MASTER_CTRL7:
297 case RT5677_I2C_MASTER_CTRL8:
298 case RT5677_HAP_GENE_CTRL2:
299 case RT5677_PWR_DSP_ST:
300 case RT5677_PRIV_DATA:
301 case RT5677_PLL1_CTRL2:
302 case RT5677_PLL2_CTRL2:
303 case RT5677_ASRC_22:
304 case RT5677_ASRC_23:
305 case RT5677_VAD_CTRL5:
306 case RT5677_ADC_EQ_CTRL1:
307 case RT5677_EQ_CTRL1:
308 case RT5677_IRQ_CTRL1:
309 case RT5677_IRQ_CTRL2:
310 case RT5677_GPIO_ST:
311 case RT5677_DSP_INB1_SRC_CTRL4:
312 case RT5677_DSP_INB2_SRC_CTRL4:
313 case RT5677_DSP_INB3_SRC_CTRL4:
314 case RT5677_DSP_OUTB1_SRC_CTRL4:
315 case RT5677_DSP_OUTB2_SRC_CTRL4:
316 case RT5677_VENDOR_ID:
317 case RT5677_VENDOR_ID1:
318 case RT5677_VENDOR_ID2:
319 return true;
320 default:
321 return false;
322 }
323}
324
325static bool rt5677_readable_register(struct device *dev, unsigned int reg)
326{
327 int i;
328
329 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
330 if (reg >= rt5677_ranges[i].range_min &&
331 reg <= rt5677_ranges[i].range_max) {
332 return true;
333 }
334 }
335
336 switch (reg) {
337 case RT5677_RESET:
338 case RT5677_LOUT1:
339 case RT5677_IN1:
340 case RT5677_MICBIAS:
341 case RT5677_SLIMBUS_PARAM:
342 case RT5677_SLIMBUS_RX:
343 case RT5677_SLIMBUS_CTRL:
344 case RT5677_SIDETONE_CTRL:
345 case RT5677_ANA_DAC1_2_3_SRC:
346 case RT5677_IF_DSP_DAC3_4_MIXER:
347 case RT5677_DAC4_DIG_VOL:
348 case RT5677_DAC3_DIG_VOL:
349 case RT5677_DAC1_DIG_VOL:
350 case RT5677_DAC2_DIG_VOL:
351 case RT5677_IF_DSP_DAC2_MIXER:
352 case RT5677_STO1_ADC_DIG_VOL:
353 case RT5677_MONO_ADC_DIG_VOL:
354 case RT5677_STO1_2_ADC_BST:
355 case RT5677_STO2_ADC_DIG_VOL:
356 case RT5677_ADC_BST_CTRL2:
357 case RT5677_STO3_4_ADC_BST:
358 case RT5677_STO3_ADC_DIG_VOL:
359 case RT5677_STO4_ADC_DIG_VOL:
360 case RT5677_STO4_ADC_MIXER:
361 case RT5677_STO3_ADC_MIXER:
362 case RT5677_STO2_ADC_MIXER:
363 case RT5677_STO1_ADC_MIXER:
364 case RT5677_MONO_ADC_MIXER:
365 case RT5677_ADC_IF_DSP_DAC1_MIXER:
366 case RT5677_STO1_DAC_MIXER:
367 case RT5677_MONO_DAC_MIXER:
368 case RT5677_DD1_MIXER:
369 case RT5677_DD2_MIXER:
370 case RT5677_IF3_DATA:
371 case RT5677_IF4_DATA:
372 case RT5677_PDM_OUT_CTRL:
373 case RT5677_PDM_DATA_CTRL1:
374 case RT5677_PDM_DATA_CTRL2:
375 case RT5677_PDM1_DATA_CTRL2:
376 case RT5677_PDM1_DATA_CTRL3:
377 case RT5677_PDM1_DATA_CTRL4:
378 case RT5677_PDM2_DATA_CTRL2:
379 case RT5677_PDM2_DATA_CTRL3:
380 case RT5677_PDM2_DATA_CTRL4:
381 case RT5677_TDM1_CTRL1:
382 case RT5677_TDM1_CTRL2:
383 case RT5677_TDM1_CTRL3:
384 case RT5677_TDM1_CTRL4:
385 case RT5677_TDM1_CTRL5:
386 case RT5677_TDM2_CTRL1:
387 case RT5677_TDM2_CTRL2:
388 case RT5677_TDM2_CTRL3:
389 case RT5677_TDM2_CTRL4:
390 case RT5677_TDM2_CTRL5:
391 case RT5677_I2C_MASTER_CTRL1:
392 case RT5677_I2C_MASTER_CTRL2:
393 case RT5677_I2C_MASTER_CTRL3:
394 case RT5677_I2C_MASTER_CTRL4:
395 case RT5677_I2C_MASTER_CTRL5:
396 case RT5677_I2C_MASTER_CTRL6:
397 case RT5677_I2C_MASTER_CTRL7:
398 case RT5677_I2C_MASTER_CTRL8:
399 case RT5677_DMIC_CTRL1:
400 case RT5677_DMIC_CTRL2:
401 case RT5677_HAP_GENE_CTRL1:
402 case RT5677_HAP_GENE_CTRL2:
403 case RT5677_HAP_GENE_CTRL3:
404 case RT5677_HAP_GENE_CTRL4:
405 case RT5677_HAP_GENE_CTRL5:
406 case RT5677_HAP_GENE_CTRL6:
407 case RT5677_HAP_GENE_CTRL7:
408 case RT5677_HAP_GENE_CTRL8:
409 case RT5677_HAP_GENE_CTRL9:
410 case RT5677_HAP_GENE_CTRL10:
411 case RT5677_PWR_DIG1:
412 case RT5677_PWR_DIG2:
413 case RT5677_PWR_ANLG1:
414 case RT5677_PWR_ANLG2:
415 case RT5677_PWR_DSP1:
416 case RT5677_PWR_DSP_ST:
417 case RT5677_PWR_DSP2:
418 case RT5677_ADC_DAC_HPF_CTRL1:
419 case RT5677_PRIV_INDEX:
420 case RT5677_PRIV_DATA:
421 case RT5677_I2S4_SDP:
422 case RT5677_I2S1_SDP:
423 case RT5677_I2S2_SDP:
424 case RT5677_I2S3_SDP:
425 case RT5677_CLK_TREE_CTRL1:
426 case RT5677_CLK_TREE_CTRL2:
427 case RT5677_CLK_TREE_CTRL3:
428 case RT5677_PLL1_CTRL1:
429 case RT5677_PLL1_CTRL2:
430 case RT5677_PLL2_CTRL1:
431 case RT5677_PLL2_CTRL2:
432 case RT5677_GLB_CLK1:
433 case RT5677_GLB_CLK2:
434 case RT5677_ASRC_1:
435 case RT5677_ASRC_2:
436 case RT5677_ASRC_3:
437 case RT5677_ASRC_4:
438 case RT5677_ASRC_5:
439 case RT5677_ASRC_6:
440 case RT5677_ASRC_7:
441 case RT5677_ASRC_8:
442 case RT5677_ASRC_9:
443 case RT5677_ASRC_10:
444 case RT5677_ASRC_11:
445 case RT5677_ASRC_12:
446 case RT5677_ASRC_13:
447 case RT5677_ASRC_14:
448 case RT5677_ASRC_15:
449 case RT5677_ASRC_16:
450 case RT5677_ASRC_17:
451 case RT5677_ASRC_18:
452 case RT5677_ASRC_19:
453 case RT5677_ASRC_20:
454 case RT5677_ASRC_21:
455 case RT5677_ASRC_22:
456 case RT5677_ASRC_23:
457 case RT5677_VAD_CTRL1:
458 case RT5677_VAD_CTRL2:
459 case RT5677_VAD_CTRL3:
460 case RT5677_VAD_CTRL4:
461 case RT5677_VAD_CTRL5:
462 case RT5677_DSP_INB_CTRL1:
463 case RT5677_DSP_INB_CTRL2:
464 case RT5677_DSP_IN_OUTB_CTRL:
465 case RT5677_DSP_OUTB0_1_DIG_VOL:
466 case RT5677_DSP_OUTB2_3_DIG_VOL:
467 case RT5677_DSP_OUTB4_5_DIG_VOL:
468 case RT5677_DSP_OUTB6_7_DIG_VOL:
469 case RT5677_ADC_EQ_CTRL1:
470 case RT5677_ADC_EQ_CTRL2:
471 case RT5677_EQ_CTRL1:
472 case RT5677_EQ_CTRL2:
473 case RT5677_EQ_CTRL3:
474 case RT5677_SOFT_VOL_ZERO_CROSS1:
475 case RT5677_JD_CTRL1:
476 case RT5677_JD_CTRL2:
477 case RT5677_JD_CTRL3:
478 case RT5677_IRQ_CTRL1:
479 case RT5677_IRQ_CTRL2:
480 case RT5677_GPIO_ST:
481 case RT5677_GPIO_CTRL1:
482 case RT5677_GPIO_CTRL2:
483 case RT5677_GPIO_CTRL3:
484 case RT5677_STO1_ADC_HI_FILTER1:
485 case RT5677_STO1_ADC_HI_FILTER2:
486 case RT5677_MONO_ADC_HI_FILTER1:
487 case RT5677_MONO_ADC_HI_FILTER2:
488 case RT5677_STO2_ADC_HI_FILTER1:
489 case RT5677_STO2_ADC_HI_FILTER2:
490 case RT5677_STO3_ADC_HI_FILTER1:
491 case RT5677_STO3_ADC_HI_FILTER2:
492 case RT5677_STO4_ADC_HI_FILTER1:
493 case RT5677_STO4_ADC_HI_FILTER2:
494 case RT5677_MB_DRC_CTRL1:
495 case RT5677_DRC1_CTRL1:
496 case RT5677_DRC1_CTRL2:
497 case RT5677_DRC1_CTRL3:
498 case RT5677_DRC1_CTRL4:
499 case RT5677_DRC1_CTRL5:
500 case RT5677_DRC1_CTRL6:
501 case RT5677_DRC2_CTRL1:
502 case RT5677_DRC2_CTRL2:
503 case RT5677_DRC2_CTRL3:
504 case RT5677_DRC2_CTRL4:
505 case RT5677_DRC2_CTRL5:
506 case RT5677_DRC2_CTRL6:
507 case RT5677_DRC1_HL_CTRL1:
508 case RT5677_DRC1_HL_CTRL2:
509 case RT5677_DRC2_HL_CTRL1:
510 case RT5677_DRC2_HL_CTRL2:
511 case RT5677_DSP_INB1_SRC_CTRL1:
512 case RT5677_DSP_INB1_SRC_CTRL2:
513 case RT5677_DSP_INB1_SRC_CTRL3:
514 case RT5677_DSP_INB1_SRC_CTRL4:
515 case RT5677_DSP_INB2_SRC_CTRL1:
516 case RT5677_DSP_INB2_SRC_CTRL2:
517 case RT5677_DSP_INB2_SRC_CTRL3:
518 case RT5677_DSP_INB2_SRC_CTRL4:
519 case RT5677_DSP_INB3_SRC_CTRL1:
520 case RT5677_DSP_INB3_SRC_CTRL2:
521 case RT5677_DSP_INB3_SRC_CTRL3:
522 case RT5677_DSP_INB3_SRC_CTRL4:
523 case RT5677_DSP_OUTB1_SRC_CTRL1:
524 case RT5677_DSP_OUTB1_SRC_CTRL2:
525 case RT5677_DSP_OUTB1_SRC_CTRL3:
526 case RT5677_DSP_OUTB1_SRC_CTRL4:
527 case RT5677_DSP_OUTB2_SRC_CTRL1:
528 case RT5677_DSP_OUTB2_SRC_CTRL2:
529 case RT5677_DSP_OUTB2_SRC_CTRL3:
530 case RT5677_DSP_OUTB2_SRC_CTRL4:
531 case RT5677_DSP_OUTB_0123_MIXER_CTRL:
532 case RT5677_DSP_OUTB_45_MIXER_CTRL:
533 case RT5677_DSP_OUTB_67_MIXER_CTRL:
534 case RT5677_DIG_MISC:
535 case RT5677_GEN_CTRL1:
536 case RT5677_GEN_CTRL2:
537 case RT5677_VENDOR_ID:
538 case RT5677_VENDOR_ID1:
539 case RT5677_VENDOR_ID2:
540 return true;
541 default:
542 return false;
543 }
544}
545
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800546/**
547 * rt5677_dsp_mode_i2c_write_addr - Write value to address on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800548 * @rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800549 * @addr: Address index.
550 * @value: Address data.
551 *
552 *
553 * Returns 0 for success or negative error code.
554 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800555static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800556 unsigned int addr, unsigned int value, unsigned int opcode)
557{
Oder Chiou19ba4842014-11-05 13:42:53 +0800558 struct snd_soc_codec *codec = rt5677->codec;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800559 int ret;
560
561 mutex_lock(&rt5677->dsp_cmd_lock);
562
Oder Chiou19ba4842014-11-05 13:42:53 +0800563 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
564 addr >> 16);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800565 if (ret < 0) {
566 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
567 goto err;
568 }
569
Oder Chiou19ba4842014-11-05 13:42:53 +0800570 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800571 addr & 0xffff);
572 if (ret < 0) {
573 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
574 goto err;
575 }
576
Oder Chiou19ba4842014-11-05 13:42:53 +0800577 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800578 value >> 16);
579 if (ret < 0) {
580 dev_err(codec->dev, "Failed to set data msb value: %d\n", ret);
581 goto err;
582 }
583
Oder Chiou19ba4842014-11-05 13:42:53 +0800584 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800585 value & 0xffff);
586 if (ret < 0) {
587 dev_err(codec->dev, "Failed to set data lsb value: %d\n", ret);
588 goto err;
589 }
590
Oder Chiou19ba4842014-11-05 13:42:53 +0800591 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
592 opcode);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800593 if (ret < 0) {
594 dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
595 goto err;
596 }
597
598err:
599 mutex_unlock(&rt5677->dsp_cmd_lock);
600
601 return ret;
602}
603
604/**
605 * rt5677_dsp_mode_i2c_read_addr - Read value from address on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800606 * rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800607 * @addr: Address index.
608 * @value: Address data.
609 *
Oder Chiou19ba4842014-11-05 13:42:53 +0800610 *
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800611 * Returns 0 for success or negative error code.
612 */
613static int rt5677_dsp_mode_i2c_read_addr(
Oder Chiou19ba4842014-11-05 13:42:53 +0800614 struct rt5677_priv *rt5677, unsigned int addr, unsigned int *value)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800615{
Oder Chiou19ba4842014-11-05 13:42:53 +0800616 struct snd_soc_codec *codec = rt5677->codec;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800617 int ret;
618 unsigned int msb, lsb;
619
620 mutex_lock(&rt5677->dsp_cmd_lock);
621
Oder Chiou19ba4842014-11-05 13:42:53 +0800622 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
623 addr >> 16);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800624 if (ret < 0) {
625 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
626 goto err;
627 }
628
Oder Chiou19ba4842014-11-05 13:42:53 +0800629 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800630 addr & 0xffff);
631 if (ret < 0) {
632 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
633 goto err;
634 }
635
Oder Chiou19ba4842014-11-05 13:42:53 +0800636 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
637 0x0002);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800638 if (ret < 0) {
639 dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
640 goto err;
641 }
642
Oder Chiou19ba4842014-11-05 13:42:53 +0800643 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, &msb);
644 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, &lsb);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800645 *value = (msb << 16) | lsb;
646
647err:
648 mutex_unlock(&rt5677->dsp_cmd_lock);
649
650 return ret;
651}
652
653/**
654 * rt5677_dsp_mode_i2c_write - Write register on DSP mode.
Oder Chiou19ba4842014-11-05 13:42:53 +0800655 * rt5677: Private Data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800656 * @reg: Register index.
657 * @value: Register data.
658 *
659 *
660 * Returns 0 for success or negative error code.
661 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800662static int rt5677_dsp_mode_i2c_write(struct rt5677_priv *rt5677,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800663 unsigned int reg, unsigned int value)
664{
Oder Chiou19ba4842014-11-05 13:42:53 +0800665 return rt5677_dsp_mode_i2c_write_addr(rt5677, 0x18020000 + reg * 2,
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800666 value, 0x0001);
667}
668
669/**
670 * rt5677_dsp_mode_i2c_read - Read register on DSP mode.
671 * @codec: SoC audio codec device.
672 * @reg: Register index.
Oder Chiou19ba4842014-11-05 13:42:53 +0800673 * @value: Register data.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800674 *
675 *
Oder Chiou19ba4842014-11-05 13:42:53 +0800676 * Returns 0 for success or negative error code.
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800677 */
Oder Chiou19ba4842014-11-05 13:42:53 +0800678static int rt5677_dsp_mode_i2c_read(
679 struct rt5677_priv *rt5677, unsigned int reg, unsigned int *value)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800680{
Oder Chiou19ba4842014-11-05 13:42:53 +0800681 int ret = rt5677_dsp_mode_i2c_read_addr(rt5677, 0x18020000 + reg * 2,
682 value);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800683
Oder Chiou19ba4842014-11-05 13:42:53 +0800684 *value &= 0xffff;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800685
Oder Chiou19ba4842014-11-05 13:42:53 +0800686 return ret;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800687}
688
Oder Chiou19ba4842014-11-05 13:42:53 +0800689static void rt5677_set_dsp_mode(struct snd_soc_codec *codec, bool on)
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800690{
Oder Chiou19ba4842014-11-05 13:42:53 +0800691 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800692
Oder Chiou19ba4842014-11-05 13:42:53 +0800693 if (on) {
694 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x2);
695 rt5677->is_dsp_mode = true;
696 } else {
697 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x0);
698 rt5677->is_dsp_mode = false;
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800699 }
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800700}
701
702static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
703{
704 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
705 static bool activity;
706 int ret;
707
Arnd Bergmann4c121122015-01-28 22:31:30 +0100708 if (!IS_ENABLED(CONFIG_SND_SOC_RT5677_SPI))
709 return -ENXIO;
710
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800711 if (on && !activity) {
712 activity = true;
713
714 regcache_cache_only(rt5677->regmap, false);
715 regcache_cache_bypass(rt5677->regmap, true);
716
717 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x1);
718 regmap_update_bits(rt5677->regmap,
719 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0f00);
720 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
721 RT5677_LDO1_SEL_MASK, 0x0);
722 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
723 RT5677_PWR_LDO1, RT5677_PWR_LDO1);
Oder Chiou19ba4842014-11-05 13:42:53 +0800724 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
725 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC);
726 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
727 RT5677_PLL2_PR_SRC_MASK | RT5677_DSP_CLK_SRC_MASK,
728 RT5677_PLL2_PR_SRC_MCLK2 | RT5677_DSP_CLK_SRC_BYPASS);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800729 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff);
Oder Chiou19ba4842014-11-05 13:42:53 +0800730 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd);
731 rt5677_set_dsp_mode(codec, true);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800732
733 ret = request_firmware(&rt5677->fw1, RT5677_FIRMWARE1,
734 codec->dev);
735 if (ret == 0) {
736 rt5677_spi_burst_write(0x50000000, rt5677->fw1);
737 release_firmware(rt5677->fw1);
738 }
739
740 ret = request_firmware(&rt5677->fw2, RT5677_FIRMWARE2,
741 codec->dev);
742 if (ret == 0) {
743 rt5677_spi_burst_write(0x60000000, rt5677->fw2);
744 release_firmware(rt5677->fw2);
745 }
746
Oder Chiou19ba4842014-11-05 13:42:53 +0800747 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x0);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800748
749 regcache_cache_bypass(rt5677->regmap, false);
750 regcache_cache_only(rt5677->regmap, true);
751 } else if (!on && activity) {
752 activity = false;
753
754 regcache_cache_only(rt5677->regmap, false);
755 regcache_cache_bypass(rt5677->regmap, true);
756
Oder Chiou19ba4842014-11-05 13:42:53 +0800757 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x1);
758 rt5677_set_dsp_mode(codec, false);
759 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x0001);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800760
761 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
762
763 regcache_cache_bypass(rt5677->regmap, false);
764 regcache_mark_dirty(rt5677->regmap);
765 regcache_sync(rt5677->regmap);
766 }
767
768 return 0;
769}
770
Oder Chiou0e826e82014-05-26 20:32:33 +0800771static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
Dylan Reid40e32622014-12-04 17:00:13 -0800772static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800773static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
Dylan Reid40e32622014-12-04 17:00:13 -0800774static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800775static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
Oder Chiou90bdbb42014-09-18 14:45:59 +0800776static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +0800777
778/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
779static unsigned int bst_tlv[] = {
780 TLV_DB_RANGE_HEAD(7),
781 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
782 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
783 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
784 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
785 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
786 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
787 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0),
788};
789
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800790static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_value *ucontrol)
792{
Fang, Yang A6087fca2014-12-23 23:49:05 -0400793 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
794 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800795
796 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en;
797
798 return 0;
799}
800
801static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
803{
Fang, Yang A6087fca2014-12-23 23:49:05 -0400804 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
805 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
806 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800807
808 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0];
809
810 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
811 rt5677_set_dsp_vad(codec, rt5677->dsp_vad_en);
812
813 return 0;
814}
815
Oder Chiou0e826e82014-05-26 20:32:33 +0800816static const struct snd_kcontrol_new rt5677_snd_controls[] = {
817 /* OUTPUT Control */
818 SOC_SINGLE("OUT1 Playback Switch", RT5677_LOUT1,
819 RT5677_LOUT1_L_MUTE_SFT, 1, 1),
820 SOC_SINGLE("OUT2 Playback Switch", RT5677_LOUT1,
821 RT5677_LOUT2_L_MUTE_SFT, 1, 1),
822 SOC_SINGLE("OUT3 Playback Switch", RT5677_LOUT1,
823 RT5677_LOUT3_L_MUTE_SFT, 1, 1),
824
825 /* DAC Digital Volume */
826 SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5677_DAC1_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800827 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800828 SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5677_DAC2_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800829 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800830 SOC_DOUBLE_TLV("DAC3 Playback Volume", RT5677_DAC3_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800831 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800832 SOC_DOUBLE_TLV("DAC4 Playback Volume", RT5677_DAC4_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800833 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
Oder Chiou0e826e82014-05-26 20:32:33 +0800834
835 /* IN1/IN2 Control */
836 SOC_SINGLE_TLV("IN1 Boost", RT5677_IN1, RT5677_BST_SFT1, 8, 0, bst_tlv),
837 SOC_SINGLE_TLV("IN2 Boost", RT5677_IN1, RT5677_BST_SFT2, 8, 0, bst_tlv),
838
839 /* ADC Digital Volume Control */
840 SOC_DOUBLE("ADC1 Capture Switch", RT5677_STO1_ADC_DIG_VOL,
841 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
842 SOC_DOUBLE("ADC2 Capture Switch", RT5677_STO2_ADC_DIG_VOL,
843 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
844 SOC_DOUBLE("ADC3 Capture Switch", RT5677_STO3_ADC_DIG_VOL,
845 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
846 SOC_DOUBLE("ADC4 Capture Switch", RT5677_STO4_ADC_DIG_VOL,
847 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
848 SOC_DOUBLE("Mono ADC Capture Switch", RT5677_MONO_ADC_DIG_VOL,
849 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
850
851 SOC_DOUBLE_TLV("ADC1 Capture Volume", RT5677_STO1_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800852 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800853 adc_vol_tlv),
854 SOC_DOUBLE_TLV("ADC2 Capture Volume", RT5677_STO2_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800855 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800856 adc_vol_tlv),
857 SOC_DOUBLE_TLV("ADC3 Capture Volume", RT5677_STO3_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800858 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800859 adc_vol_tlv),
860 SOC_DOUBLE_TLV("ADC4 Capture Volume", RT5677_STO4_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800861 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800862 adc_vol_tlv),
863 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5677_MONO_ADC_DIG_VOL,
Dylan Reid40e32622014-12-04 17:00:13 -0800864 RT5677_MONO_ADC_L_VOL_SFT, RT5677_MONO_ADC_R_VOL_SFT, 63, 0,
Oder Chiou0e826e82014-05-26 20:32:33 +0800865 adc_vol_tlv),
866
Oder Chiou90bdbb42014-09-18 14:45:59 +0800867 /* Sidetone Control */
868 SOC_SINGLE_TLV("Sidetone Volume", RT5677_SIDETONE_CTRL,
869 RT5677_ST_VOL_SFT, 31, 0, st_vol_tlv),
870
Oder Chiou0e826e82014-05-26 20:32:33 +0800871 /* ADC Boost Volume Control */
Oder Chiou80220f22014-06-10 14:35:25 +0800872 SOC_DOUBLE_TLV("STO1 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800873 RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0,
874 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800875 SOC_DOUBLE_TLV("STO2 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800876 RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0,
877 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800878 SOC_DOUBLE_TLV("STO3 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800879 RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0,
880 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800881 SOC_DOUBLE_TLV("STO4 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
Oder Chiou0e826e82014-05-26 20:32:33 +0800882 RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0,
883 adc_bst_tlv),
Oder Chiou80220f22014-06-10 14:35:25 +0800884 SOC_DOUBLE_TLV("Mono ADC Boost Volume", RT5677_ADC_BST_CTRL2,
Oder Chiou0e826e82014-05-26 20:32:33 +0800885 RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0,
886 adc_bst_tlv),
Oder Chiouaf48f1d2014-10-06 16:30:51 +0800887
888 SOC_SINGLE_EXT("DSP VAD Switch", SND_SOC_NOPM, 0, 1, 0,
889 rt5677_dsp_vad_get, rt5677_dsp_vad_put),
Oder Chiou0e826e82014-05-26 20:32:33 +0800890};
891
892/**
893 * set_dmic_clk - Set parameter of dmic.
894 *
895 * @w: DAPM widget.
896 * @kcontrol: The kcontrol of this widget.
897 * @event: Event id.
898 *
899 * Choose dmic clock between 1MHz and 3MHz.
900 * It is better for clock to approximate 3MHz.
901 */
902static int set_dmic_clk(struct snd_soc_dapm_widget *w,
903 struct snd_kcontrol *kcontrol, int event)
904{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +0100905 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +0800906 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Bard Liao60a8d622015-04-28 11:27:39 +0800907 int idx = rl6231_calc_dmic_clk(rt5677->lrck[RT5677_AIF1] << 8);
Oder Chiou0e826e82014-05-26 20:32:33 +0800908
909 if (idx < 0)
910 dev_err(codec->dev, "Failed to set DMIC clock\n");
911 else
912 regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1,
913 RT5677_DMIC_CLK_MASK, idx << RT5677_DMIC_CLK_SFT);
914 return idx;
915}
916
917static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
918 struct snd_soc_dapm_widget *sink)
919{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +0100920 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
921 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou0e826e82014-05-26 20:32:33 +0800922 unsigned int val;
923
924 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val);
925 val &= RT5677_SCLK_SRC_MASK;
926 if (val == RT5677_SCLK_SRC_PLL1)
927 return 1;
928 else
929 return 0;
930}
931
Oder Chiou5a8c7c22014-12-23 10:27:55 +0800932static int is_using_asrc(struct snd_soc_dapm_widget *source,
933 struct snd_soc_dapm_widget *sink)
934{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +0100935 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
Oder Chioue4b7e6a2015-01-13 11:13:14 +0800936 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou5a8c7c22014-12-23 10:27:55 +0800937 unsigned int reg, shift, val;
938
939 if (source->reg == RT5677_ASRC_1) {
940 switch (source->shift) {
941 case 12:
942 reg = RT5677_ASRC_4;
943 shift = 0;
944 break;
945 case 13:
946 reg = RT5677_ASRC_4;
947 shift = 4;
948 break;
949 case 14:
950 reg = RT5677_ASRC_4;
951 shift = 8;
952 break;
953 case 15:
954 reg = RT5677_ASRC_4;
955 shift = 12;
956 break;
957 default:
958 return 0;
959 }
960 } else {
961 switch (source->shift) {
962 case 0:
963 reg = RT5677_ASRC_6;
964 shift = 8;
965 break;
966 case 1:
967 reg = RT5677_ASRC_6;
968 shift = 12;
969 break;
970 case 2:
971 reg = RT5677_ASRC_5;
972 shift = 0;
973 break;
974 case 3:
975 reg = RT5677_ASRC_5;
976 shift = 4;
977 break;
978 case 4:
979 reg = RT5677_ASRC_5;
980 shift = 8;
981 break;
982 case 5:
983 reg = RT5677_ASRC_5;
984 shift = 12;
985 break;
986 case 12:
987 reg = RT5677_ASRC_3;
988 shift = 0;
989 break;
990 case 13:
991 reg = RT5677_ASRC_3;
992 shift = 4;
993 break;
994 case 14:
995 reg = RT5677_ASRC_3;
996 shift = 12;
997 break;
998 default:
999 return 0;
1000 }
1001 }
1002
Oder Chioue4b7e6a2015-01-13 11:13:14 +08001003 regmap_read(rt5677->regmap, reg, &val);
1004 val = (val >> shift) & 0xf;
1005
Oder Chiou5a8c7c22014-12-23 10:27:55 +08001006 switch (val) {
1007 case 1 ... 6:
1008 return 1;
1009 default:
1010 return 0;
1011 }
1012
1013}
1014
1015static int can_use_asrc(struct snd_soc_dapm_widget *source,
1016 struct snd_soc_dapm_widget *sink)
1017{
1018 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
1019 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
1020
1021 if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384)
1022 return 1;
1023
1024 return 0;
1025}
1026
Oder Chiou0e826e82014-05-26 20:32:33 +08001027/* Digital Mixer */
1028static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = {
1029 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
1030 RT5677_M_STO1_ADC_L1_SFT, 1, 1),
1031 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
1032 RT5677_M_STO1_ADC_L2_SFT, 1, 1),
1033};
1034
1035static const struct snd_kcontrol_new rt5677_sto1_adc_r_mix[] = {
1036 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
1037 RT5677_M_STO1_ADC_R1_SFT, 1, 1),
1038 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
1039 RT5677_M_STO1_ADC_R2_SFT, 1, 1),
1040};
1041
1042static const struct snd_kcontrol_new rt5677_sto2_adc_l_mix[] = {
1043 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
1044 RT5677_M_STO2_ADC_L1_SFT, 1, 1),
1045 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
1046 RT5677_M_STO2_ADC_L2_SFT, 1, 1),
1047};
1048
1049static const struct snd_kcontrol_new rt5677_sto2_adc_r_mix[] = {
1050 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
1051 RT5677_M_STO2_ADC_R1_SFT, 1, 1),
1052 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
1053 RT5677_M_STO2_ADC_R2_SFT, 1, 1),
1054};
1055
1056static const struct snd_kcontrol_new rt5677_sto3_adc_l_mix[] = {
1057 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
1058 RT5677_M_STO3_ADC_L1_SFT, 1, 1),
1059 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
1060 RT5677_M_STO3_ADC_L2_SFT, 1, 1),
1061};
1062
1063static const struct snd_kcontrol_new rt5677_sto3_adc_r_mix[] = {
1064 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
1065 RT5677_M_STO3_ADC_R1_SFT, 1, 1),
1066 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
1067 RT5677_M_STO3_ADC_R2_SFT, 1, 1),
1068};
1069
1070static const struct snd_kcontrol_new rt5677_sto4_adc_l_mix[] = {
1071 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
1072 RT5677_M_STO4_ADC_L1_SFT, 1, 1),
1073 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
1074 RT5677_M_STO4_ADC_L2_SFT, 1, 1),
1075};
1076
1077static const struct snd_kcontrol_new rt5677_sto4_adc_r_mix[] = {
1078 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
1079 RT5677_M_STO4_ADC_R1_SFT, 1, 1),
1080 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
1081 RT5677_M_STO4_ADC_R2_SFT, 1, 1),
1082};
1083
1084static const struct snd_kcontrol_new rt5677_mono_adc_l_mix[] = {
1085 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
1086 RT5677_M_MONO_ADC_L1_SFT, 1, 1),
1087 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
1088 RT5677_M_MONO_ADC_L2_SFT, 1, 1),
1089};
1090
1091static const struct snd_kcontrol_new rt5677_mono_adc_r_mix[] = {
1092 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
1093 RT5677_M_MONO_ADC_R1_SFT, 1, 1),
1094 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
1095 RT5677_M_MONO_ADC_R2_SFT, 1, 1),
1096};
1097
1098static const struct snd_kcontrol_new rt5677_dac_l_mix[] = {
1099 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1100 RT5677_M_ADDA_MIXER1_L_SFT, 1, 1),
1101 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1102 RT5677_M_DAC1_L_SFT, 1, 1),
1103};
1104
1105static const struct snd_kcontrol_new rt5677_dac_r_mix[] = {
1106 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1107 RT5677_M_ADDA_MIXER1_R_SFT, 1, 1),
1108 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1109 RT5677_M_DAC1_R_SFT, 1, 1),
1110};
1111
1112static const struct snd_kcontrol_new rt5677_sto1_dac_l_mix[] = {
1113 SOC_DAPM_SINGLE("ST L Switch", RT5677_STO1_DAC_MIXER,
1114 RT5677_M_ST_DAC1_L_SFT, 1, 1),
1115 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
1116 RT5677_M_DAC1_L_STO_L_SFT, 1, 1),
1117 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_STO1_DAC_MIXER,
1118 RT5677_M_DAC2_L_STO_L_SFT, 1, 1),
1119 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
1120 RT5677_M_DAC1_R_STO_L_SFT, 1, 1),
1121};
1122
1123static const struct snd_kcontrol_new rt5677_sto1_dac_r_mix[] = {
1124 SOC_DAPM_SINGLE("ST R Switch", RT5677_STO1_DAC_MIXER,
1125 RT5677_M_ST_DAC1_R_SFT, 1, 1),
1126 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
1127 RT5677_M_DAC1_R_STO_R_SFT, 1, 1),
1128 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_STO1_DAC_MIXER,
1129 RT5677_M_DAC2_R_STO_R_SFT, 1, 1),
1130 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
1131 RT5677_M_DAC1_L_STO_R_SFT, 1, 1),
1132};
1133
1134static const struct snd_kcontrol_new rt5677_mono_dac_l_mix[] = {
1135 SOC_DAPM_SINGLE("ST L Switch", RT5677_MONO_DAC_MIXER,
1136 RT5677_M_ST_DAC2_L_SFT, 1, 1),
1137 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_MONO_DAC_MIXER,
1138 RT5677_M_DAC1_L_MONO_L_SFT, 1, 1),
1139 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
1140 RT5677_M_DAC2_L_MONO_L_SFT, 1, 1),
1141 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
1142 RT5677_M_DAC2_R_MONO_L_SFT, 1, 1),
1143};
1144
1145static const struct snd_kcontrol_new rt5677_mono_dac_r_mix[] = {
1146 SOC_DAPM_SINGLE("ST R Switch", RT5677_MONO_DAC_MIXER,
1147 RT5677_M_ST_DAC2_R_SFT, 1, 1),
1148 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_MONO_DAC_MIXER,
1149 RT5677_M_DAC1_R_MONO_R_SFT, 1, 1),
1150 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
1151 RT5677_M_DAC2_R_MONO_R_SFT, 1, 1),
1152 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
1153 RT5677_M_DAC2_L_MONO_R_SFT, 1, 1),
1154};
1155
1156static const struct snd_kcontrol_new rt5677_dd1_l_mix[] = {
1157 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD1_MIXER,
1158 RT5677_M_STO_L_DD1_L_SFT, 1, 1),
1159 SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD1_MIXER,
1160 RT5677_M_MONO_L_DD1_L_SFT, 1, 1),
1161 SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER,
1162 RT5677_M_DAC3_L_DD1_L_SFT, 1, 1),
1163 SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER,
1164 RT5677_M_DAC3_R_DD1_L_SFT, 1, 1),
1165};
1166
1167static const struct snd_kcontrol_new rt5677_dd1_r_mix[] = {
1168 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD1_MIXER,
1169 RT5677_M_STO_R_DD1_R_SFT, 1, 1),
1170 SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD1_MIXER,
1171 RT5677_M_MONO_R_DD1_R_SFT, 1, 1),
1172 SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER,
1173 RT5677_M_DAC3_R_DD1_R_SFT, 1, 1),
1174 SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER,
1175 RT5677_M_DAC3_L_DD1_R_SFT, 1, 1),
1176};
1177
1178static const struct snd_kcontrol_new rt5677_dd2_l_mix[] = {
1179 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD2_MIXER,
1180 RT5677_M_STO_L_DD2_L_SFT, 1, 1),
1181 SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD2_MIXER,
1182 RT5677_M_MONO_L_DD2_L_SFT, 1, 1),
1183 SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER,
1184 RT5677_M_DAC4_L_DD2_L_SFT, 1, 1),
1185 SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER,
1186 RT5677_M_DAC4_R_DD2_L_SFT, 1, 1),
1187};
1188
1189static const struct snd_kcontrol_new rt5677_dd2_r_mix[] = {
1190 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD2_MIXER,
1191 RT5677_M_STO_R_DD2_R_SFT, 1, 1),
1192 SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD2_MIXER,
1193 RT5677_M_MONO_R_DD2_R_SFT, 1, 1),
1194 SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER,
1195 RT5677_M_DAC4_R_DD2_R_SFT, 1, 1),
1196 SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER,
1197 RT5677_M_DAC4_L_DD2_R_SFT, 1, 1),
1198};
1199
1200static const struct snd_kcontrol_new rt5677_ob_01_mix[] = {
1201 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1202 RT5677_DSP_IB_01_H_SFT, 1, 1),
1203 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1204 RT5677_DSP_IB_23_H_SFT, 1, 1),
1205 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1206 RT5677_DSP_IB_45_H_SFT, 1, 1),
1207 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1208 RT5677_DSP_IB_6_H_SFT, 1, 1),
1209 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1210 RT5677_DSP_IB_7_H_SFT, 1, 1),
1211 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1212 RT5677_DSP_IB_8_H_SFT, 1, 1),
1213 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1214 RT5677_DSP_IB_9_H_SFT, 1, 1),
1215};
1216
1217static const struct snd_kcontrol_new rt5677_ob_23_mix[] = {
1218 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1219 RT5677_DSP_IB_01_L_SFT, 1, 1),
1220 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1221 RT5677_DSP_IB_23_L_SFT, 1, 1),
1222 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1223 RT5677_DSP_IB_45_L_SFT, 1, 1),
1224 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1225 RT5677_DSP_IB_6_L_SFT, 1, 1),
1226 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1227 RT5677_DSP_IB_7_L_SFT, 1, 1),
1228 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1229 RT5677_DSP_IB_8_L_SFT, 1, 1),
1230 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1231 RT5677_DSP_IB_9_L_SFT, 1, 1),
1232};
1233
1234static const struct snd_kcontrol_new rt5677_ob_4_mix[] = {
1235 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1236 RT5677_DSP_IB_01_H_SFT, 1, 1),
1237 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1238 RT5677_DSP_IB_23_H_SFT, 1, 1),
1239 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1240 RT5677_DSP_IB_45_H_SFT, 1, 1),
1241 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1242 RT5677_DSP_IB_6_H_SFT, 1, 1),
1243 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1244 RT5677_DSP_IB_7_H_SFT, 1, 1),
1245 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1246 RT5677_DSP_IB_8_H_SFT, 1, 1),
1247 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1248 RT5677_DSP_IB_9_H_SFT, 1, 1),
1249};
1250
1251static const struct snd_kcontrol_new rt5677_ob_5_mix[] = {
1252 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1253 RT5677_DSP_IB_01_L_SFT, 1, 1),
1254 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1255 RT5677_DSP_IB_23_L_SFT, 1, 1),
1256 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1257 RT5677_DSP_IB_45_L_SFT, 1, 1),
1258 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1259 RT5677_DSP_IB_6_L_SFT, 1, 1),
1260 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1261 RT5677_DSP_IB_7_L_SFT, 1, 1),
1262 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1263 RT5677_DSP_IB_8_L_SFT, 1, 1),
1264 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1265 RT5677_DSP_IB_9_L_SFT, 1, 1),
1266};
1267
1268static const struct snd_kcontrol_new rt5677_ob_6_mix[] = {
1269 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1270 RT5677_DSP_IB_01_H_SFT, 1, 1),
1271 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1272 RT5677_DSP_IB_23_H_SFT, 1, 1),
1273 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1274 RT5677_DSP_IB_45_H_SFT, 1, 1),
1275 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1276 RT5677_DSP_IB_6_H_SFT, 1, 1),
1277 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1278 RT5677_DSP_IB_7_H_SFT, 1, 1),
1279 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1280 RT5677_DSP_IB_8_H_SFT, 1, 1),
1281 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1282 RT5677_DSP_IB_9_H_SFT, 1, 1),
1283};
1284
1285static const struct snd_kcontrol_new rt5677_ob_7_mix[] = {
1286 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1287 RT5677_DSP_IB_01_L_SFT, 1, 1),
1288 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1289 RT5677_DSP_IB_23_L_SFT, 1, 1),
1290 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1291 RT5677_DSP_IB_45_L_SFT, 1, 1),
1292 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1293 RT5677_DSP_IB_6_L_SFT, 1, 1),
1294 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1295 RT5677_DSP_IB_7_L_SFT, 1, 1),
1296 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1297 RT5677_DSP_IB_8_L_SFT, 1, 1),
1298 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1299 RT5677_DSP_IB_9_L_SFT, 1, 1),
1300};
1301
1302
1303/* Mux */
Oder Chiou1b7fd762014-06-10 14:35:24 +08001304/* DAC1 L/R Source */ /* MX-29 [10:8] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001305static const char * const rt5677_dac1_src[] = {
1306 "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01",
1307 "OB 01"
1308};
1309
1310static SOC_ENUM_SINGLE_DECL(
1311 rt5677_dac1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
1312 RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src);
1313
1314static const struct snd_kcontrol_new rt5677_dac1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001315 SOC_DAPM_ENUM("DAC1 Source", rt5677_dac1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001316
Oder Chiou1b7fd762014-06-10 14:35:24 +08001317/* ADDA1 L/R Source */ /* MX-29 [1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001318static const char * const rt5677_adda1_src[] = {
1319 "STO1 ADC MIX", "STO2 ADC MIX", "OB 67",
1320};
1321
1322static SOC_ENUM_SINGLE_DECL(
1323 rt5677_adda1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
1324 RT5677_ADDA1_SEL_SFT, rt5677_adda1_src);
1325
1326static const struct snd_kcontrol_new rt5677_adda1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001327 SOC_DAPM_ENUM("ADDA1 Source", rt5677_adda1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001328
1329
Oder Chiou1b7fd762014-06-10 14:35:24 +08001330/*DAC2 L/R Source*/ /* MX-1B [6:4] [2:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001331static const char * const rt5677_dac2l_src[] = {
1332 "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2",
1333 "OB 2",
1334};
1335
1336static SOC_ENUM_SINGLE_DECL(
1337 rt5677_dac2l_enum, RT5677_IF_DSP_DAC2_MIXER,
1338 RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src);
1339
1340static const struct snd_kcontrol_new rt5677_dac2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001341 SOC_DAPM_ENUM("DAC2 L Source", rt5677_dac2l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001342
1343static const char * const rt5677_dac2r_src[] = {
1344 "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3",
1345 "OB 3", "Haptic Generator", "VAD ADC"
1346};
1347
1348static SOC_ENUM_SINGLE_DECL(
1349 rt5677_dac2r_enum, RT5677_IF_DSP_DAC2_MIXER,
1350 RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src);
1351
1352static const struct snd_kcontrol_new rt5677_dac2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001353 SOC_DAPM_ENUM("DAC2 R Source", rt5677_dac2r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001354
Oder Chiou1b7fd762014-06-10 14:35:24 +08001355/*DAC3 L/R Source*/ /* MX-16 [6:4] [2:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001356static const char * const rt5677_dac3l_src[] = {
1357 "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L",
1358 "SLB DAC 4", "OB 4"
1359};
1360
1361static SOC_ENUM_SINGLE_DECL(
1362 rt5677_dac3l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1363 RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src);
1364
1365static const struct snd_kcontrol_new rt5677_dac3_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001366 SOC_DAPM_ENUM("DAC3 L Source", rt5677_dac3l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001367
1368static const char * const rt5677_dac3r_src[] = {
1369 "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R",
1370 "SLB DAC 5", "OB 5"
1371};
1372
1373static SOC_ENUM_SINGLE_DECL(
1374 rt5677_dac3r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1375 RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src);
1376
1377static const struct snd_kcontrol_new rt5677_dac3_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001378 SOC_DAPM_ENUM("DAC3 R Source", rt5677_dac3r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001379
Oder Chiou1b7fd762014-06-10 14:35:24 +08001380/*DAC4 L/R Source*/ /* MX-16 [14:12] [10:8] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001381static const char * const rt5677_dac4l_src[] = {
1382 "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L",
1383 "SLB DAC 6", "OB 6"
1384};
1385
1386static SOC_ENUM_SINGLE_DECL(
1387 rt5677_dac4l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1388 RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src);
1389
1390static const struct snd_kcontrol_new rt5677_dac4_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001391 SOC_DAPM_ENUM("DAC4 L Source", rt5677_dac4l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001392
1393static const char * const rt5677_dac4r_src[] = {
1394 "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R",
1395 "SLB DAC 7", "OB 7"
1396};
1397
1398static SOC_ENUM_SINGLE_DECL(
1399 rt5677_dac4r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1400 RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src);
1401
1402static const struct snd_kcontrol_new rt5677_dac4_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001403 SOC_DAPM_ENUM("DAC4 R Source", rt5677_dac4r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001404
1405/* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */
1406static const char * const rt5677_iob_bypass_src[] = {
1407 "Bypass", "Pass SRC"
1408};
1409
1410static SOC_ENUM_SINGLE_DECL(
1411 rt5677_ob01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1412 RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src);
1413
1414static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001415 SOC_DAPM_ENUM("OB01 Bypass Source", rt5677_ob01_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001416
1417static SOC_ENUM_SINGLE_DECL(
1418 rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1419 RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src);
1420
1421static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001422 SOC_DAPM_ENUM("OB23 Bypass Source", rt5677_ob23_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001423
1424static SOC_ENUM_SINGLE_DECL(
1425 rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1426 RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src);
1427
1428static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001429 SOC_DAPM_ENUM("IB01 Bypass Source", rt5677_ib01_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001430
1431static SOC_ENUM_SINGLE_DECL(
1432 rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1433 RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src);
1434
1435static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001436 SOC_DAPM_ENUM("IB23 Bypass Source", rt5677_ib23_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001437
1438static SOC_ENUM_SINGLE_DECL(
1439 rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1440 RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src);
1441
1442static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001443 SOC_DAPM_ENUM("IB45 Bypass Source", rt5677_ib45_bypass_src_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001444
Oder Chioud65fd3a2014-11-05 13:42:52 +08001445/* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001446static const char * const rt5677_stereo_adc2_src[] = {
1447 "DD MIX1", "DMIC", "Stereo DAC MIX"
1448};
1449
1450static SOC_ENUM_SINGLE_DECL(
1451 rt5677_stereo1_adc2_enum, RT5677_STO1_ADC_MIXER,
1452 RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src);
1453
1454static const struct snd_kcontrol_new rt5677_sto1_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001455 SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5677_stereo1_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001456
1457static SOC_ENUM_SINGLE_DECL(
1458 rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER,
1459 RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src);
1460
1461static const struct snd_kcontrol_new rt5677_sto2_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001462 SOC_DAPM_ENUM("Stereo2 ADC2 Source", rt5677_stereo2_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001463
1464static SOC_ENUM_SINGLE_DECL(
1465 rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER,
1466 RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src);
1467
1468static const struct snd_kcontrol_new rt5677_sto3_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001469 SOC_DAPM_ENUM("Stereo3 ADC2 Source", rt5677_stereo3_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001470
1471/* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */
1472static const char * const rt5677_dmic_src[] = {
1473 "DMIC1", "DMIC2", "DMIC3", "DMIC4"
1474};
1475
1476static SOC_ENUM_SINGLE_DECL(
1477 rt5677_mono_dmic_l_enum, RT5677_MONO_ADC_MIXER,
1478 RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src);
1479
1480static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001481 SOC_DAPM_ENUM("Mono DMIC L Source", rt5677_mono_dmic_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001482
1483static SOC_ENUM_SINGLE_DECL(
1484 rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER,
1485 RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src);
1486
1487static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001488 SOC_DAPM_ENUM("Mono DMIC R Source", rt5677_mono_dmic_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001489
1490static SOC_ENUM_SINGLE_DECL(
1491 rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER,
1492 RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src);
1493
1494static const struct snd_kcontrol_new rt5677_sto1_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001495 SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5677_stereo1_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001496
1497static SOC_ENUM_SINGLE_DECL(
1498 rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER,
1499 RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src);
1500
1501static const struct snd_kcontrol_new rt5677_sto2_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001502 SOC_DAPM_ENUM("Stereo2 DMIC Source", rt5677_stereo2_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001503
1504static SOC_ENUM_SINGLE_DECL(
1505 rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER,
1506 RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src);
1507
1508static const struct snd_kcontrol_new rt5677_sto3_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001509 SOC_DAPM_ENUM("Stereo3 DMIC Source", rt5677_stereo3_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001510
1511static SOC_ENUM_SINGLE_DECL(
1512 rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER,
1513 RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src);
1514
1515static const struct snd_kcontrol_new rt5677_sto4_dmic_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001516 SOC_DAPM_ENUM("Stereo4 DMIC Source", rt5677_stereo4_dmic_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001517
Oder Chiou1b7fd762014-06-10 14:35:24 +08001518/* Stereo2 ADC Source */ /* MX-26 [0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001519static const char * const rt5677_stereo2_adc_lr_src[] = {
1520 "L", "LR"
1521};
1522
1523static SOC_ENUM_SINGLE_DECL(
1524 rt5677_stereo2_adc_lr_enum, RT5677_STO2_ADC_MIXER,
1525 RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src);
1526
1527static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001528 SOC_DAPM_ENUM("Stereo2 ADC LR Source", rt5677_stereo2_adc_lr_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001529
Oder Chioud65fd3a2014-11-05 13:42:52 +08001530/* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001531static const char * const rt5677_stereo_adc1_src[] = {
1532 "DD MIX1", "ADC1/2", "Stereo DAC MIX"
1533};
1534
1535static SOC_ENUM_SINGLE_DECL(
1536 rt5677_stereo1_adc1_enum, RT5677_STO1_ADC_MIXER,
1537 RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src);
1538
1539static const struct snd_kcontrol_new rt5677_sto1_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001540 SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5677_stereo1_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001541
1542static SOC_ENUM_SINGLE_DECL(
1543 rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER,
1544 RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src);
1545
1546static const struct snd_kcontrol_new rt5677_sto2_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001547 SOC_DAPM_ENUM("Stereo2 ADC1 Source", rt5677_stereo2_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001548
1549static SOC_ENUM_SINGLE_DECL(
1550 rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER,
1551 RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src);
1552
1553static const struct snd_kcontrol_new rt5677_sto3_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001554 SOC_DAPM_ENUM("Stereo3 ADC1 Source", rt5677_stereo3_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001555
Oder Chiou1b7fd762014-06-10 14:35:24 +08001556/* Mono ADC Left Source 2 */ /* MX-28 [11:10] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001557static const char * const rt5677_mono_adc2_l_src[] = {
1558 "DD MIX1L", "DMIC", "MONO DAC MIXL"
1559};
1560
1561static SOC_ENUM_SINGLE_DECL(
1562 rt5677_mono_adc2_l_enum, RT5677_MONO_ADC_MIXER,
1563 RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src);
1564
1565static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001566 SOC_DAPM_ENUM("Mono ADC2 L Source", rt5677_mono_adc2_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001567
Oder Chiou1b7fd762014-06-10 14:35:24 +08001568/* Mono ADC Left Source 1 */ /* MX-28 [13:12] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001569static const char * const rt5677_mono_adc1_l_src[] = {
1570 "DD MIX1L", "ADC1", "MONO DAC MIXL"
1571};
1572
1573static SOC_ENUM_SINGLE_DECL(
1574 rt5677_mono_adc1_l_enum, RT5677_MONO_ADC_MIXER,
1575 RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src);
1576
1577static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001578 SOC_DAPM_ENUM("Mono ADC1 L Source", rt5677_mono_adc1_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001579
Oder Chiou1b7fd762014-06-10 14:35:24 +08001580/* Mono ADC Right Source 2 */ /* MX-28 [3:2] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001581static const char * const rt5677_mono_adc2_r_src[] = {
1582 "DD MIX1R", "DMIC", "MONO DAC MIXR"
1583};
1584
1585static SOC_ENUM_SINGLE_DECL(
1586 rt5677_mono_adc2_r_enum, RT5677_MONO_ADC_MIXER,
1587 RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src);
1588
1589static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001590 SOC_DAPM_ENUM("Mono ADC2 R Source", rt5677_mono_adc2_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001591
Oder Chiou1b7fd762014-06-10 14:35:24 +08001592/* Mono ADC Right Source 1 */ /* MX-28 [5:4] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001593static const char * const rt5677_mono_adc1_r_src[] = {
1594 "DD MIX1R", "ADC2", "MONO DAC MIXR"
1595};
1596
1597static SOC_ENUM_SINGLE_DECL(
1598 rt5677_mono_adc1_r_enum, RT5677_MONO_ADC_MIXER,
1599 RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src);
1600
1601static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001602 SOC_DAPM_ENUM("Mono ADC1 R Source", rt5677_mono_adc1_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001603
1604/* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */
1605static const char * const rt5677_stereo4_adc2_src[] = {
1606 "DD MIX1", "DMIC", "DD MIX2"
1607};
1608
1609static SOC_ENUM_SINGLE_DECL(
1610 rt5677_stereo4_adc2_enum, RT5677_STO4_ADC_MIXER,
1611 RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src);
1612
1613static const struct snd_kcontrol_new rt5677_sto4_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001614 SOC_DAPM_ENUM("Stereo4 ADC2 Source", rt5677_stereo4_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001615
1616
1617/* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */
1618static const char * const rt5677_stereo4_adc1_src[] = {
1619 "DD MIX1", "ADC1/2", "DD MIX2"
1620};
1621
1622static SOC_ENUM_SINGLE_DECL(
1623 rt5677_stereo4_adc1_enum, RT5677_STO4_ADC_MIXER,
1624 RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src);
1625
1626static const struct snd_kcontrol_new rt5677_sto4_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001627 SOC_DAPM_ENUM("Stereo4 ADC1 Source", rt5677_stereo4_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001628
1629/* InBound0/1 Source */ /* MX-A3 [14:12] */
1630static const char * const rt5677_inbound01_src[] = {
1631 "IF1 DAC 01", "IF2 DAC 01", "SLB DAC 01", "STO1 ADC MIX",
1632 "VAD ADC/DAC1 FS"
1633};
1634
1635static SOC_ENUM_SINGLE_DECL(
1636 rt5677_inbound01_enum, RT5677_DSP_INB_CTRL1,
1637 RT5677_IB01_SRC_SFT, rt5677_inbound01_src);
1638
1639static const struct snd_kcontrol_new rt5677_ib01_src_mux =
1640 SOC_DAPM_ENUM("InBound0/1 Source", rt5677_inbound01_enum);
1641
1642/* InBound2/3 Source */ /* MX-A3 [10:8] */
1643static const char * const rt5677_inbound23_src[] = {
1644 "IF1 DAC 23", "IF2 DAC 23", "SLB DAC 23", "STO2 ADC MIX",
1645 "DAC1 FS", "IF4 DAC"
1646};
1647
1648static SOC_ENUM_SINGLE_DECL(
1649 rt5677_inbound23_enum, RT5677_DSP_INB_CTRL1,
1650 RT5677_IB23_SRC_SFT, rt5677_inbound23_src);
1651
1652static const struct snd_kcontrol_new rt5677_ib23_src_mux =
1653 SOC_DAPM_ENUM("InBound2/3 Source", rt5677_inbound23_enum);
1654
1655/* InBound4/5 Source */ /* MX-A3 [6:4] */
1656static const char * const rt5677_inbound45_src[] = {
1657 "IF1 DAC 45", "IF2 DAC 45", "SLB DAC 45", "STO3 ADC MIX",
1658 "IF3 DAC"
1659};
1660
1661static SOC_ENUM_SINGLE_DECL(
1662 rt5677_inbound45_enum, RT5677_DSP_INB_CTRL1,
1663 RT5677_IB45_SRC_SFT, rt5677_inbound45_src);
1664
1665static const struct snd_kcontrol_new rt5677_ib45_src_mux =
1666 SOC_DAPM_ENUM("InBound4/5 Source", rt5677_inbound45_enum);
1667
1668/* InBound6 Source */ /* MX-A3 [2:0] */
1669static const char * const rt5677_inbound6_src[] = {
1670 "IF1 DAC 6", "IF2 DAC 6", "SLB DAC 6", "STO4 ADC MIX L",
1671 "IF4 DAC L", "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L"
1672};
1673
1674static SOC_ENUM_SINGLE_DECL(
1675 rt5677_inbound6_enum, RT5677_DSP_INB_CTRL1,
1676 RT5677_IB6_SRC_SFT, rt5677_inbound6_src);
1677
1678static const struct snd_kcontrol_new rt5677_ib6_src_mux =
1679 SOC_DAPM_ENUM("InBound6 Source", rt5677_inbound6_enum);
1680
1681/* InBound7 Source */ /* MX-A4 [14:12] */
1682static const char * const rt5677_inbound7_src[] = {
1683 "IF1 DAC 7", "IF2 DAC 7", "SLB DAC 7", "STO4 ADC MIX R",
1684 "IF4 DAC R", "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R"
1685};
1686
1687static SOC_ENUM_SINGLE_DECL(
1688 rt5677_inbound7_enum, RT5677_DSP_INB_CTRL2,
1689 RT5677_IB7_SRC_SFT, rt5677_inbound7_src);
1690
1691static const struct snd_kcontrol_new rt5677_ib7_src_mux =
1692 SOC_DAPM_ENUM("InBound7 Source", rt5677_inbound7_enum);
1693
1694/* InBound8 Source */ /* MX-A4 [10:8] */
1695static const char * const rt5677_inbound8_src[] = {
1696 "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L", "STO4 ADC MIX L",
1697 "MONO ADC MIX L", "DACL1 FS"
1698};
1699
1700static SOC_ENUM_SINGLE_DECL(
1701 rt5677_inbound8_enum, RT5677_DSP_INB_CTRL2,
1702 RT5677_IB8_SRC_SFT, rt5677_inbound8_src);
1703
1704static const struct snd_kcontrol_new rt5677_ib8_src_mux =
1705 SOC_DAPM_ENUM("InBound8 Source", rt5677_inbound8_enum);
1706
1707/* InBound9 Source */ /* MX-A4 [6:4] */
1708static const char * const rt5677_inbound9_src[] = {
1709 "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R", "STO4 ADC MIX R",
1710 "MONO ADC MIX R", "DACR1 FS", "DAC1 FS"
1711};
1712
1713static SOC_ENUM_SINGLE_DECL(
1714 rt5677_inbound9_enum, RT5677_DSP_INB_CTRL2,
1715 RT5677_IB9_SRC_SFT, rt5677_inbound9_src);
1716
1717static const struct snd_kcontrol_new rt5677_ib9_src_mux =
1718 SOC_DAPM_ENUM("InBound9 Source", rt5677_inbound9_enum);
1719
1720/* VAD Source */ /* MX-9F [6:4] */
1721static const char * const rt5677_vad_src[] = {
1722 "STO1 ADC MIX L", "MONO ADC MIX L", "MONO ADC MIX R", "STO2 ADC MIX L",
1723 "STO3 ADC MIX L"
1724};
1725
1726static SOC_ENUM_SINGLE_DECL(
1727 rt5677_vad_enum, RT5677_VAD_CTRL4,
1728 RT5677_VAD_SRC_SFT, rt5677_vad_src);
1729
1730static const struct snd_kcontrol_new rt5677_vad_src_mux =
1731 SOC_DAPM_ENUM("VAD Source", rt5677_vad_enum);
1732
1733/* Sidetone Source */ /* MX-13 [11:9] */
1734static const char * const rt5677_sidetone_src[] = {
1735 "DMIC1 L", "DMIC2 L", "DMIC3 L", "DMIC4 L", "ADC1", "ADC2"
1736};
1737
1738static SOC_ENUM_SINGLE_DECL(
1739 rt5677_sidetone_enum, RT5677_SIDETONE_CTRL,
1740 RT5677_ST_SEL_SFT, rt5677_sidetone_src);
1741
1742static const struct snd_kcontrol_new rt5677_sidetone_mux =
1743 SOC_DAPM_ENUM("Sidetone Source", rt5677_sidetone_enum);
1744
1745/* DAC1/2 Source */ /* MX-15 [1:0] */
1746static const char * const rt5677_dac12_src[] = {
1747 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
1748};
1749
1750static SOC_ENUM_SINGLE_DECL(
1751 rt5677_dac12_enum, RT5677_ANA_DAC1_2_3_SRC,
1752 RT5677_ANA_DAC1_2_SRC_SEL_SFT, rt5677_dac12_src);
1753
1754static const struct snd_kcontrol_new rt5677_dac12_mux =
1755 SOC_DAPM_ENUM("Analog DAC1/2 Source", rt5677_dac12_enum);
1756
1757/* DAC3 Source */ /* MX-15 [5:4] */
1758static const char * const rt5677_dac3_src[] = {
1759 "MONO DAC MIXL", "MONO DAC MIXR", "DD MIX1L", "DD MIX2L"
1760};
1761
1762static SOC_ENUM_SINGLE_DECL(
1763 rt5677_dac3_enum, RT5677_ANA_DAC1_2_3_SRC,
1764 RT5677_ANA_DAC3_SRC_SEL_SFT, rt5677_dac3_src);
1765
1766static const struct snd_kcontrol_new rt5677_dac3_mux =
1767 SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum);
1768
Oder Chiou1b7fd762014-06-10 14:35:24 +08001769/* PDM channel Source */ /* MX-31 [13:12][9:8][5:4][1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001770static const char * const rt5677_pdm_src[] = {
1771 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
1772};
1773
1774static SOC_ENUM_SINGLE_DECL(
1775 rt5677_pdm1_l_enum, RT5677_PDM_OUT_CTRL,
1776 RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src);
1777
1778static const struct snd_kcontrol_new rt5677_pdm1_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001779 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001780
1781static SOC_ENUM_SINGLE_DECL(
1782 rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL,
1783 RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src);
1784
1785static const struct snd_kcontrol_new rt5677_pdm2_l_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001786 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_l_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001787
1788static SOC_ENUM_SINGLE_DECL(
1789 rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL,
1790 RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src);
1791
1792static const struct snd_kcontrol_new rt5677_pdm1_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001793 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001794
1795static SOC_ENUM_SINGLE_DECL(
1796 rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL,
1797 RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src);
1798
1799static const struct snd_kcontrol_new rt5677_pdm2_r_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001800 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_r_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001801
Oder Chioud65fd3a2014-11-05 13:42:52 +08001802/* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001803static const char * const rt5677_if12_adc1_src[] = {
1804 "STO1 ADC MIX", "OB01", "VAD ADC"
1805};
1806
1807static SOC_ENUM_SINGLE_DECL(
1808 rt5677_if1_adc1_enum, RT5677_TDM1_CTRL2,
1809 RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src);
1810
1811static const struct snd_kcontrol_new rt5677_if1_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001812 SOC_DAPM_ENUM("IF1 ADC1 Source", rt5677_if1_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001813
1814static SOC_ENUM_SINGLE_DECL(
1815 rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2,
1816 RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src);
1817
1818static const struct snd_kcontrol_new rt5677_if2_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001819 SOC_DAPM_ENUM("IF2 ADC1 Source", rt5677_if2_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001820
1821static SOC_ENUM_SINGLE_DECL(
1822 rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX,
1823 RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src);
1824
1825static const struct snd_kcontrol_new rt5677_slb_adc1_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001826 SOC_DAPM_ENUM("SLB ADC1 Source", rt5677_slb_adc1_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001827
1828/* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */
1829static const char * const rt5677_if12_adc2_src[] = {
1830 "STO2 ADC MIX", "OB23"
1831};
1832
1833static SOC_ENUM_SINGLE_DECL(
1834 rt5677_if1_adc2_enum, RT5677_TDM1_CTRL2,
1835 RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src);
1836
1837static const struct snd_kcontrol_new rt5677_if1_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001838 SOC_DAPM_ENUM("IF1 ADC2 Source", rt5677_if1_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001839
1840static SOC_ENUM_SINGLE_DECL(
1841 rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2,
1842 RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src);
1843
1844static const struct snd_kcontrol_new rt5677_if2_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001845 SOC_DAPM_ENUM("IF2 ADC2 Source", rt5677_if2_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001846
1847static SOC_ENUM_SINGLE_DECL(
1848 rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX,
1849 RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src);
1850
1851static const struct snd_kcontrol_new rt5677_slb_adc2_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001852 SOC_DAPM_ENUM("SLB ADC2 Source", rt5677_slb_adc2_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001853
1854/* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */
1855static const char * const rt5677_if12_adc3_src[] = {
1856 "STO3 ADC MIX", "MONO ADC MIX", "OB45"
1857};
1858
1859static SOC_ENUM_SINGLE_DECL(
1860 rt5677_if1_adc3_enum, RT5677_TDM1_CTRL2,
1861 RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src);
1862
1863static const struct snd_kcontrol_new rt5677_if1_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001864 SOC_DAPM_ENUM("IF1 ADC3 Source", rt5677_if1_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001865
1866static SOC_ENUM_SINGLE_DECL(
1867 rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2,
1868 RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src);
1869
1870static const struct snd_kcontrol_new rt5677_if2_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001871 SOC_DAPM_ENUM("IF2 ADC3 Source", rt5677_if2_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001872
1873static SOC_ENUM_SINGLE_DECL(
1874 rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX,
1875 RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src);
1876
1877static const struct snd_kcontrol_new rt5677_slb_adc3_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001878 SOC_DAPM_ENUM("SLB ADC3 Source", rt5677_slb_adc3_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001879
Oder Chioud65fd3a2014-11-05 13:42:52 +08001880/* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001881static const char * const rt5677_if12_adc4_src[] = {
1882 "STO4 ADC MIX", "OB67", "OB01"
1883};
1884
1885static SOC_ENUM_SINGLE_DECL(
1886 rt5677_if1_adc4_enum, RT5677_TDM1_CTRL2,
1887 RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src);
1888
1889static const struct snd_kcontrol_new rt5677_if1_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001890 SOC_DAPM_ENUM("IF1 ADC4 Source", rt5677_if1_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001891
1892static SOC_ENUM_SINGLE_DECL(
1893 rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2,
1894 RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src);
1895
1896static const struct snd_kcontrol_new rt5677_if2_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001897 SOC_DAPM_ENUM("IF2 ADC4 Source", rt5677_if2_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001898
1899static SOC_ENUM_SINGLE_DECL(
1900 rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX,
1901 RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src);
1902
1903static const struct snd_kcontrol_new rt5677_slb_adc4_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001904 SOC_DAPM_ENUM("SLB ADC4 Source", rt5677_slb_adc4_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001905
Oder Chioud65fd3a2014-11-05 13:42:52 +08001906/* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4] */
Oder Chiou0e826e82014-05-26 20:32:33 +08001907static const char * const rt5677_if34_adc_src[] = {
1908 "STO1 ADC MIX", "STO2 ADC MIX", "STO3 ADC MIX", "STO4 ADC MIX",
1909 "MONO ADC MIX", "OB01", "OB23", "VAD ADC"
1910};
1911
1912static SOC_ENUM_SINGLE_DECL(
1913 rt5677_if3_adc_enum, RT5677_IF3_DATA,
1914 RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src);
1915
1916static const struct snd_kcontrol_new rt5677_if3_adc_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001917 SOC_DAPM_ENUM("IF3 ADC Source", rt5677_if3_adc_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001918
1919static SOC_ENUM_SINGLE_DECL(
1920 rt5677_if4_adc_enum, RT5677_IF4_DATA,
1921 RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src);
1922
1923static const struct snd_kcontrol_new rt5677_if4_adc_mux =
Oder Chiou1b7fd762014-06-10 14:35:24 +08001924 SOC_DAPM_ENUM("IF4 ADC Source", rt5677_if4_adc_enum);
Oder Chiou0e826e82014-05-26 20:32:33 +08001925
Oder Chioue6f6ebc2014-10-22 16:11:39 +08001926/* TDM IF1/2 ADC Data Selection */ /* MX-3B MX-40 [7:6][5:4][3:2][1:0] */
1927static const char * const rt5677_if12_adc_swap_src[] = {
1928 "L/R", "R/L", "L/L", "R/R"
1929};
1930
1931static SOC_ENUM_SINGLE_DECL(
1932 rt5677_if1_adc1_swap_enum, RT5677_TDM1_CTRL1,
1933 RT5677_IF1_ADC1_SWAP_SFT, rt5677_if12_adc_swap_src);
1934
1935static const struct snd_kcontrol_new rt5677_if1_adc1_swap_mux =
1936 SOC_DAPM_ENUM("IF1 ADC1 Swap Source", rt5677_if1_adc1_swap_enum);
1937
1938static SOC_ENUM_SINGLE_DECL(
1939 rt5677_if1_adc2_swap_enum, RT5677_TDM1_CTRL1,
1940 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1941
1942static const struct snd_kcontrol_new rt5677_if1_adc2_swap_mux =
1943 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if1_adc2_swap_enum);
1944
1945static SOC_ENUM_SINGLE_DECL(
1946 rt5677_if1_adc3_swap_enum, RT5677_TDM1_CTRL1,
1947 RT5677_IF1_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
1948
1949static const struct snd_kcontrol_new rt5677_if1_adc3_swap_mux =
1950 SOC_DAPM_ENUM("IF1 ADC3 Swap Source", rt5677_if1_adc3_swap_enum);
1951
1952static SOC_ENUM_SINGLE_DECL(
1953 rt5677_if1_adc4_swap_enum, RT5677_TDM1_CTRL1,
1954 RT5677_IF1_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
1955
1956static const struct snd_kcontrol_new rt5677_if1_adc4_swap_mux =
1957 SOC_DAPM_ENUM("IF1 ADC4 Swap Source", rt5677_if1_adc4_swap_enum);
1958
1959static SOC_ENUM_SINGLE_DECL(
1960 rt5677_if2_adc1_swap_enum, RT5677_TDM2_CTRL1,
1961 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1962
1963static const struct snd_kcontrol_new rt5677_if2_adc1_swap_mux =
1964 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if2_adc1_swap_enum);
1965
1966static SOC_ENUM_SINGLE_DECL(
1967 rt5677_if2_adc2_swap_enum, RT5677_TDM2_CTRL1,
1968 RT5677_IF2_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1969
1970static const struct snd_kcontrol_new rt5677_if2_adc2_swap_mux =
1971 SOC_DAPM_ENUM("IF2 ADC2 Swap Source", rt5677_if2_adc2_swap_enum);
1972
1973static SOC_ENUM_SINGLE_DECL(
1974 rt5677_if2_adc3_swap_enum, RT5677_TDM2_CTRL1,
1975 RT5677_IF2_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
1976
1977static const struct snd_kcontrol_new rt5677_if2_adc3_swap_mux =
1978 SOC_DAPM_ENUM("IF2 ADC3 Swap Source", rt5677_if2_adc3_swap_enum);
1979
1980static SOC_ENUM_SINGLE_DECL(
1981 rt5677_if2_adc4_swap_enum, RT5677_TDM2_CTRL1,
1982 RT5677_IF2_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
1983
1984static const struct snd_kcontrol_new rt5677_if2_adc4_swap_mux =
1985 SOC_DAPM_ENUM("IF2 ADC4 Swap Source", rt5677_if2_adc4_swap_enum);
1986
Oder Chioud65fd3a2014-11-05 13:42:52 +08001987/* TDM IF1 ADC Data Selection */ /* MX-3C [2:0] */
Oder Chioue6f6ebc2014-10-22 16:11:39 +08001988static const char * const rt5677_if1_adc_tdm_swap_src[] = {
1989 "1/2/3/4", "2/1/3/4", "2/3/1/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
1990 "3/1/2/4", "3/4/1/2"
1991};
1992
1993static SOC_ENUM_SINGLE_DECL(
1994 rt5677_if1_adc_tdm_swap_enum, RT5677_TDM1_CTRL2,
1995 RT5677_IF1_ADC_CTRL_SFT, rt5677_if1_adc_tdm_swap_src);
1996
1997static const struct snd_kcontrol_new rt5677_if1_adc_tdm_swap_mux =
1998 SOC_DAPM_ENUM("IF1 ADC TDM Swap Source", rt5677_if1_adc_tdm_swap_enum);
1999
2000/* TDM IF2 ADC Data Selection */ /* MX-41[2:0] */
2001static const char * const rt5677_if2_adc_tdm_swap_src[] = {
2002 "1/2/3/4", "2/1/3/4", "3/1/2/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
2003 "2/3/1/4", "3/4/1/2"
2004};
2005
2006static SOC_ENUM_SINGLE_DECL(
2007 rt5677_if2_adc_tdm_swap_enum, RT5677_TDM2_CTRL2,
2008 RT5677_IF2_ADC_CTRL_SFT, rt5677_if2_adc_tdm_swap_src);
2009
2010static const struct snd_kcontrol_new rt5677_if2_adc_tdm_swap_mux =
2011 SOC_DAPM_ENUM("IF2 ADC TDM Swap Source", rt5677_if2_adc_tdm_swap_enum);
2012
Oder Chiou91159ec2014-11-11 15:31:19 +08002013/* TDM IF1/2 DAC Data Selection */ /* MX-3E[14:12][10:8][6:4][2:0]
2014 MX-3F[14:12][10:8][6:4][2:0]
2015 MX-43[14:12][10:8][6:4][2:0]
2016 MX-44[14:12][10:8][6:4][2:0] */
2017static const char * const rt5677_if12_dac_tdm_sel_src[] = {
2018 "Slot0", "Slot1", "Slot2", "Slot3", "Slot4", "Slot5", "Slot6", "Slot7"
2019};
2020
2021static SOC_ENUM_SINGLE_DECL(
2022 rt5677_if1_dac0_tdm_sel_enum, RT5677_TDM1_CTRL4,
2023 RT5677_IF1_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
2024
2025static const struct snd_kcontrol_new rt5677_if1_dac0_tdm_sel_mux =
2026 SOC_DAPM_ENUM("IF1 DAC0 TDM Source", rt5677_if1_dac0_tdm_sel_enum);
2027
2028static SOC_ENUM_SINGLE_DECL(
2029 rt5677_if1_dac1_tdm_sel_enum, RT5677_TDM1_CTRL4,
2030 RT5677_IF1_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
2031
2032static const struct snd_kcontrol_new rt5677_if1_dac1_tdm_sel_mux =
2033 SOC_DAPM_ENUM("IF1 DAC1 TDM Source", rt5677_if1_dac1_tdm_sel_enum);
2034
2035static SOC_ENUM_SINGLE_DECL(
2036 rt5677_if1_dac2_tdm_sel_enum, RT5677_TDM1_CTRL4,
2037 RT5677_IF1_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
2038
2039static const struct snd_kcontrol_new rt5677_if1_dac2_tdm_sel_mux =
2040 SOC_DAPM_ENUM("IF1 DAC2 TDM Source", rt5677_if1_dac2_tdm_sel_enum);
2041
2042static SOC_ENUM_SINGLE_DECL(
2043 rt5677_if1_dac3_tdm_sel_enum, RT5677_TDM1_CTRL4,
2044 RT5677_IF1_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
2045
2046static const struct snd_kcontrol_new rt5677_if1_dac3_tdm_sel_mux =
2047 SOC_DAPM_ENUM("IF1 DAC3 TDM Source", rt5677_if1_dac3_tdm_sel_enum);
2048
2049static SOC_ENUM_SINGLE_DECL(
2050 rt5677_if1_dac4_tdm_sel_enum, RT5677_TDM1_CTRL5,
2051 RT5677_IF1_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
2052
2053static const struct snd_kcontrol_new rt5677_if1_dac4_tdm_sel_mux =
2054 SOC_DAPM_ENUM("IF1 DAC4 TDM Source", rt5677_if1_dac4_tdm_sel_enum);
2055
2056static SOC_ENUM_SINGLE_DECL(
2057 rt5677_if1_dac5_tdm_sel_enum, RT5677_TDM1_CTRL5,
2058 RT5677_IF1_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
2059
2060static const struct snd_kcontrol_new rt5677_if1_dac5_tdm_sel_mux =
2061 SOC_DAPM_ENUM("IF1 DAC5 TDM Source", rt5677_if1_dac5_tdm_sel_enum);
2062
2063static SOC_ENUM_SINGLE_DECL(
2064 rt5677_if1_dac6_tdm_sel_enum, RT5677_TDM1_CTRL5,
2065 RT5677_IF1_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
2066
2067static const struct snd_kcontrol_new rt5677_if1_dac6_tdm_sel_mux =
2068 SOC_DAPM_ENUM("IF1 DAC6 TDM Source", rt5677_if1_dac6_tdm_sel_enum);
2069
2070static SOC_ENUM_SINGLE_DECL(
2071 rt5677_if1_dac7_tdm_sel_enum, RT5677_TDM1_CTRL5,
2072 RT5677_IF1_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
2073
2074static const struct snd_kcontrol_new rt5677_if1_dac7_tdm_sel_mux =
2075 SOC_DAPM_ENUM("IF1 DAC7 TDM Source", rt5677_if1_dac7_tdm_sel_enum);
2076
2077static SOC_ENUM_SINGLE_DECL(
2078 rt5677_if2_dac0_tdm_sel_enum, RT5677_TDM2_CTRL4,
2079 RT5677_IF2_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
2080
2081static const struct snd_kcontrol_new rt5677_if2_dac0_tdm_sel_mux =
2082 SOC_DAPM_ENUM("IF2 DAC0 TDM Source", rt5677_if2_dac0_tdm_sel_enum);
2083
2084static SOC_ENUM_SINGLE_DECL(
2085 rt5677_if2_dac1_tdm_sel_enum, RT5677_TDM2_CTRL4,
2086 RT5677_IF2_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
2087
2088static const struct snd_kcontrol_new rt5677_if2_dac1_tdm_sel_mux =
2089 SOC_DAPM_ENUM("IF2 DAC1 TDM Source", rt5677_if2_dac1_tdm_sel_enum);
2090
2091static SOC_ENUM_SINGLE_DECL(
2092 rt5677_if2_dac2_tdm_sel_enum, RT5677_TDM2_CTRL4,
2093 RT5677_IF2_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
2094
2095static const struct snd_kcontrol_new rt5677_if2_dac2_tdm_sel_mux =
2096 SOC_DAPM_ENUM("IF2 DAC2 TDM Source", rt5677_if2_dac2_tdm_sel_enum);
2097
2098static SOC_ENUM_SINGLE_DECL(
2099 rt5677_if2_dac3_tdm_sel_enum, RT5677_TDM2_CTRL4,
2100 RT5677_IF2_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
2101
2102static const struct snd_kcontrol_new rt5677_if2_dac3_tdm_sel_mux =
2103 SOC_DAPM_ENUM("IF2 DAC3 TDM Source", rt5677_if2_dac3_tdm_sel_enum);
2104
2105static SOC_ENUM_SINGLE_DECL(
2106 rt5677_if2_dac4_tdm_sel_enum, RT5677_TDM2_CTRL5,
2107 RT5677_IF2_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
2108
2109static const struct snd_kcontrol_new rt5677_if2_dac4_tdm_sel_mux =
2110 SOC_DAPM_ENUM("IF2 DAC4 TDM Source", rt5677_if2_dac4_tdm_sel_enum);
2111
2112static SOC_ENUM_SINGLE_DECL(
2113 rt5677_if2_dac5_tdm_sel_enum, RT5677_TDM2_CTRL5,
2114 RT5677_IF2_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
2115
2116static const struct snd_kcontrol_new rt5677_if2_dac5_tdm_sel_mux =
2117 SOC_DAPM_ENUM("IF2 DAC5 TDM Source", rt5677_if2_dac5_tdm_sel_enum);
2118
2119static SOC_ENUM_SINGLE_DECL(
2120 rt5677_if2_dac6_tdm_sel_enum, RT5677_TDM2_CTRL5,
2121 RT5677_IF2_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
2122
2123static const struct snd_kcontrol_new rt5677_if2_dac6_tdm_sel_mux =
2124 SOC_DAPM_ENUM("IF2 DAC6 TDM Source", rt5677_if2_dac6_tdm_sel_enum);
2125
2126static SOC_ENUM_SINGLE_DECL(
2127 rt5677_if2_dac7_tdm_sel_enum, RT5677_TDM2_CTRL5,
2128 RT5677_IF2_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
2129
2130static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux =
2131 SOC_DAPM_ENUM("IF2 DAC7 TDM Source", rt5677_if2_dac7_tdm_sel_enum);
2132
Oder Chiou0e826e82014-05-26 20:32:33 +08002133static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
2134 struct snd_kcontrol *kcontrol, int event)
2135{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002136 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002137 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2138
2139 switch (event) {
2140 case SND_SOC_DAPM_POST_PMU:
2141 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2142 RT5677_PWR_BST1_P, RT5677_PWR_BST1_P);
2143 break;
2144
2145 case SND_SOC_DAPM_PRE_PMD:
2146 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2147 RT5677_PWR_BST1_P, 0);
2148 break;
2149
2150 default:
2151 return 0;
2152 }
2153
2154 return 0;
2155}
2156
2157static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
2158 struct snd_kcontrol *kcontrol, int event)
2159{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002160 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002161 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2162
2163 switch (event) {
2164 case SND_SOC_DAPM_POST_PMU:
2165 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2166 RT5677_PWR_BST2_P, RT5677_PWR_BST2_P);
2167 break;
2168
2169 case SND_SOC_DAPM_PRE_PMD:
2170 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2171 RT5677_PWR_BST2_P, 0);
2172 break;
2173
2174 default:
2175 return 0;
2176 }
2177
2178 return 0;
2179}
2180
2181static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
2182 struct snd_kcontrol *kcontrol, int event)
2183{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002184 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002185 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2186
2187 switch (event) {
Oder Chioubdfbf252015-01-08 10:31:05 +08002188 case SND_SOC_DAPM_PRE_PMU:
Oder Chiou0e826e82014-05-26 20:32:33 +08002189 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2);
Oder Chioubdfbf252015-01-08 10:31:05 +08002190 break;
2191
2192 case SND_SOC_DAPM_POST_PMU:
Oder Chiou0e826e82014-05-26 20:32:33 +08002193 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0);
2194 break;
Oder Chioubdfbf252015-01-08 10:31:05 +08002195
Oder Chiou0e826e82014-05-26 20:32:33 +08002196 default:
2197 return 0;
2198 }
2199
2200 return 0;
2201}
2202
2203static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
2204 struct snd_kcontrol *kcontrol, int event)
2205{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002206 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002207 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2208
2209 switch (event) {
Oder Chioubdfbf252015-01-08 10:31:05 +08002210 case SND_SOC_DAPM_PRE_PMU:
Oder Chiou0e826e82014-05-26 20:32:33 +08002211 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2);
Oder Chioubdfbf252015-01-08 10:31:05 +08002212 break;
2213
2214 case SND_SOC_DAPM_POST_PMU:
Oder Chiou0e826e82014-05-26 20:32:33 +08002215 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0);
2216 break;
Oder Chioubdfbf252015-01-08 10:31:05 +08002217
Oder Chiou0e826e82014-05-26 20:32:33 +08002218 default:
2219 return 0;
2220 }
2221
2222 return 0;
2223}
2224
2225static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
2226 struct snd_kcontrol *kcontrol, int event)
2227{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002228 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou0e826e82014-05-26 20:32:33 +08002229 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2230
2231 switch (event) {
2232 case SND_SOC_DAPM_POST_PMU:
2233 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2234 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
2235 RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 |
2236 RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB);
2237 break;
Oder Chiouf58c3b92014-06-10 14:35:26 +08002238
2239 case SND_SOC_DAPM_PRE_PMD:
2240 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2241 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
2242 RT5677_PWR_CLK_MB, 0);
2243 break;
2244
Oder Chiou0e826e82014-05-26 20:32:33 +08002245 default:
2246 return 0;
2247 }
2248
2249 return 0;
2250}
2251
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002252static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
2253 struct snd_kcontrol *kcontrol, int event)
2254{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002255 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002256 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2257 unsigned int value;
2258
2259 switch (event) {
2260 case SND_SOC_DAPM_PRE_PMU:
2261 regmap_read(rt5677->regmap, RT5677_TDM1_CTRL2, &value);
2262 if (value & RT5677_IF1_ADC_CTRL_MASK)
2263 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1,
2264 RT5677_IF1_ADC_MODE_MASK,
2265 RT5677_IF1_ADC_MODE_TDM);
2266 break;
2267
2268 default:
2269 return 0;
2270 }
2271
2272 return 0;
2273}
2274
2275static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
2276 struct snd_kcontrol *kcontrol, int event)
2277{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002278 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002279 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2280 unsigned int value;
2281
2282 switch (event) {
2283 case SND_SOC_DAPM_PRE_PMU:
2284 regmap_read(rt5677->regmap, RT5677_TDM2_CTRL2, &value);
2285 if (value & RT5677_IF2_ADC_CTRL_MASK)
2286 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1,
2287 RT5677_IF2_ADC_MODE_MASK,
2288 RT5677_IF2_ADC_MODE_TDM);
2289 break;
2290
2291 default:
2292 return 0;
2293 }
2294
2295 return 0;
2296}
2297
Oder Chiou683996c2014-11-19 13:52:20 +08002298static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
2299 struct snd_kcontrol *kcontrol, int event)
2300{
Lars-Peter Clausen46f20872015-01-15 12:52:16 +01002301 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
Oder Chiou683996c2014-11-19 13:52:20 +08002302 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2303
2304 switch (event) {
2305 case SND_SOC_DAPM_POST_PMU:
2306 if (codec->dapm.bias_level != SND_SOC_BIAS_ON &&
2307 !rt5677->is_vref_slow) {
2308 mdelay(20);
2309 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
2310 RT5677_PWR_FV1 | RT5677_PWR_FV2,
2311 RT5677_PWR_FV1 | RT5677_PWR_FV2);
2312 rt5677->is_vref_slow = true;
2313 }
2314 break;
2315
2316 default:
2317 return 0;
2318 }
2319
2320 return 0;
2321}
2322
Oder Chiou0e826e82014-05-26 20:32:33 +08002323static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2324 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT,
Oder Chioubdfbf252015-01-08 10:31:05 +08002325 0, rt5677_set_pll1_event, SND_SOC_DAPM_PRE_PMU |
2326 SND_SOC_DAPM_POST_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002327 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT,
Oder Chioubdfbf252015-01-08 10:31:05 +08002328 0, rt5677_set_pll2_event, SND_SOC_DAPM_PRE_PMU |
2329 SND_SOC_DAPM_POST_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002330
Oder Chiou5a8c7c22014-12-23 10:27:55 +08002331 /* ASRC */
2332 SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5677_ASRC_1, 0, 0, NULL, 0),
2333 SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5677_ASRC_1, 1, 0, NULL, 0),
2334 SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5677_ASRC_1, 2, 0, NULL, 0),
2335 SND_SOC_DAPM_SUPPLY_S("I2S4 ASRC", 1, RT5677_ASRC_1, 3, 0, NULL, 0),
2336 SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5677_ASRC_2, 14, 0, NULL, 0),
2337 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 L ASRC", 1, RT5677_ASRC_2, 13, 0, NULL,
2338 0),
2339 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 R ASRC", 1, RT5677_ASRC_2, 12, 0, NULL,
2340 0),
2341 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 L ASRC", 1, RT5677_ASRC_1, 15, 0, NULL,
2342 0),
2343 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 R ASRC", 1, RT5677_ASRC_1, 14, 0, NULL,
2344 0),
2345 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 L ASRC", 1, RT5677_ASRC_1, 13, 0, NULL,
2346 0),
2347 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 R ASRC", 1, RT5677_ASRC_1, 12, 0, NULL,
2348 0),
2349 SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5677_ASRC_2, 11, 0, NULL,
2350 0),
2351 SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5677_ASRC_2, 10, 0, NULL,
2352 0),
2353 SND_SOC_DAPM_SUPPLY_S("DMIC STO3 ASRC", 1, RT5677_ASRC_2, 9, 0, NULL,
2354 0),
2355 SND_SOC_DAPM_SUPPLY_S("DMIC STO4 ASRC", 1, RT5677_ASRC_2, 8, 0, NULL,
2356 0),
2357 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5677_ASRC_2, 7, 0, NULL,
2358 0),
2359 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5677_ASRC_2, 6, 0, NULL,
2360 0),
2361 SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5677_ASRC_2, 5, 0, NULL, 0),
2362 SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5677_ASRC_2, 4, 0, NULL, 0),
2363 SND_SOC_DAPM_SUPPLY_S("ADC STO3 ASRC", 1, RT5677_ASRC_2, 3, 0, NULL, 0),
2364 SND_SOC_DAPM_SUPPLY_S("ADC STO4 ASRC", 1, RT5677_ASRC_2, 2, 0, NULL, 0),
2365 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5677_ASRC_2, 1, 0, NULL,
2366 0),
2367 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5677_ASRC_2, 0, 0, NULL,
2368 0),
2369
Oder Chiou0e826e82014-05-26 20:32:33 +08002370 /* Input Side */
2371 /* micbias */
Oder Chiou3d0c03d2014-06-10 14:35:23 +08002372 SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT,
Oder Chiouf58c3b92014-06-10 14:35:26 +08002373 0, rt5677_set_micbias1_event, SND_SOC_DAPM_PRE_PMD |
2374 SND_SOC_DAPM_POST_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002375
2376 /* Input Lines */
2377 SND_SOC_DAPM_INPUT("DMIC L1"),
2378 SND_SOC_DAPM_INPUT("DMIC R1"),
2379 SND_SOC_DAPM_INPUT("DMIC L2"),
2380 SND_SOC_DAPM_INPUT("DMIC R2"),
2381 SND_SOC_DAPM_INPUT("DMIC L3"),
2382 SND_SOC_DAPM_INPUT("DMIC R3"),
2383 SND_SOC_DAPM_INPUT("DMIC L4"),
2384 SND_SOC_DAPM_INPUT("DMIC R4"),
2385
2386 SND_SOC_DAPM_INPUT("IN1P"),
2387 SND_SOC_DAPM_INPUT("IN1N"),
2388 SND_SOC_DAPM_INPUT("IN2P"),
2389 SND_SOC_DAPM_INPUT("IN2N"),
2390
2391 SND_SOC_DAPM_INPUT("Haptic Generator"),
2392
Bard Liao2d15d972014-08-27 19:50:34 +08002393 SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2394 SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2395 SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2396 SND_SOC_DAPM_PGA("DMIC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2397
2398 SND_SOC_DAPM_SUPPLY("DMIC1 power", RT5677_DMIC_CTRL1,
2399 RT5677_DMIC_1_EN_SFT, 0, NULL, 0),
2400 SND_SOC_DAPM_SUPPLY("DMIC2 power", RT5677_DMIC_CTRL1,
2401 RT5677_DMIC_2_EN_SFT, 0, NULL, 0),
2402 SND_SOC_DAPM_SUPPLY("DMIC3 power", RT5677_DMIC_CTRL1,
2403 RT5677_DMIC_3_EN_SFT, 0, NULL, 0),
2404 SND_SOC_DAPM_SUPPLY("DMIC4 power", RT5677_DMIC_CTRL2,
2405 RT5677_DMIC_4_EN_SFT, 0, NULL, 0),
Oder Chiou0e826e82014-05-26 20:32:33 +08002406
2407 SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0,
2408 set_dmic_clk, SND_SOC_DAPM_PRE_PMU),
2409
2410 /* Boost */
2411 SND_SOC_DAPM_PGA_E("BST1", RT5677_PWR_ANLG2,
2412 RT5677_PWR_BST1_BIT, 0, NULL, 0, rt5677_bst1_event,
2413 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2414 SND_SOC_DAPM_PGA_E("BST2", RT5677_PWR_ANLG2,
2415 RT5677_PWR_BST2_BIT, 0, NULL, 0, rt5677_bst2_event,
2416 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2417
2418 /* ADCs */
2419 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM,
2420 0, 0),
2421 SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM,
2422 0, 0),
2423 SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0),
2424
2425 SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5677_PWR_DIG1,
2426 RT5677_PWR_ADC_L_BIT, 0, NULL, 0),
2427 SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5677_PWR_DIG1,
2428 RT5677_PWR_ADC_R_BIT, 0, NULL, 0),
2429 SND_SOC_DAPM_SUPPLY("ADC1 clock", RT5677_PWR_DIG1,
2430 RT5677_PWR_ADCFED1_BIT, 0, NULL, 0),
2431 SND_SOC_DAPM_SUPPLY("ADC2 clock", RT5677_PWR_DIG1,
2432 RT5677_PWR_ADCFED2_BIT, 0, NULL, 0),
2433
2434 /* ADC Mux */
2435 SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0,
2436 &rt5677_sto1_dmic_mux),
2437 SND_SOC_DAPM_MUX("Stereo1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2438 &rt5677_sto1_adc1_mux),
2439 SND_SOC_DAPM_MUX("Stereo1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2440 &rt5677_sto1_adc2_mux),
2441 SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0,
2442 &rt5677_sto2_dmic_mux),
2443 SND_SOC_DAPM_MUX("Stereo2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2444 &rt5677_sto2_adc1_mux),
2445 SND_SOC_DAPM_MUX("Stereo2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2446 &rt5677_sto2_adc2_mux),
2447 SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0,
2448 &rt5677_sto2_adc_lr_mux),
2449 SND_SOC_DAPM_MUX("Stereo3 DMIC Mux", SND_SOC_NOPM, 0, 0,
2450 &rt5677_sto3_dmic_mux),
2451 SND_SOC_DAPM_MUX("Stereo3 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2452 &rt5677_sto3_adc1_mux),
2453 SND_SOC_DAPM_MUX("Stereo3 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2454 &rt5677_sto3_adc2_mux),
2455 SND_SOC_DAPM_MUX("Stereo4 DMIC Mux", SND_SOC_NOPM, 0, 0,
2456 &rt5677_sto4_dmic_mux),
2457 SND_SOC_DAPM_MUX("Stereo4 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2458 &rt5677_sto4_adc1_mux),
2459 SND_SOC_DAPM_MUX("Stereo4 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2460 &rt5677_sto4_adc2_mux),
2461 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
2462 &rt5677_mono_dmic_l_mux),
2463 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
2464 &rt5677_mono_dmic_r_mux),
2465 SND_SOC_DAPM_MUX("Mono ADC2 L Mux", SND_SOC_NOPM, 0, 0,
2466 &rt5677_mono_adc2_l_mux),
2467 SND_SOC_DAPM_MUX("Mono ADC1 L Mux", SND_SOC_NOPM, 0, 0,
2468 &rt5677_mono_adc1_l_mux),
2469 SND_SOC_DAPM_MUX("Mono ADC1 R Mux", SND_SOC_NOPM, 0, 0,
2470 &rt5677_mono_adc1_r_mux),
2471 SND_SOC_DAPM_MUX("Mono ADC2 R Mux", SND_SOC_NOPM, 0, 0,
2472 &rt5677_mono_adc2_r_mux),
2473
2474 /* ADC Mixer */
2475 SND_SOC_DAPM_SUPPLY("adc stereo1 filter", RT5677_PWR_DIG2,
2476 RT5677_PWR_ADC_S1F_BIT, 0, NULL, 0),
2477 SND_SOC_DAPM_SUPPLY("adc stereo2 filter", RT5677_PWR_DIG2,
2478 RT5677_PWR_ADC_S2F_BIT, 0, NULL, 0),
2479 SND_SOC_DAPM_SUPPLY("adc stereo3 filter", RT5677_PWR_DIG2,
2480 RT5677_PWR_ADC_S3F_BIT, 0, NULL, 0),
2481 SND_SOC_DAPM_SUPPLY("adc stereo4 filter", RT5677_PWR_DIG2,
2482 RT5677_PWR_ADC_S4F_BIT, 0, NULL, 0),
2483 SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0,
2484 rt5677_sto1_adc_l_mix, ARRAY_SIZE(rt5677_sto1_adc_l_mix)),
2485 SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0,
2486 rt5677_sto1_adc_r_mix, ARRAY_SIZE(rt5677_sto1_adc_r_mix)),
2487 SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0,
2488 rt5677_sto2_adc_l_mix, ARRAY_SIZE(rt5677_sto2_adc_l_mix)),
2489 SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0,
2490 rt5677_sto2_adc_r_mix, ARRAY_SIZE(rt5677_sto2_adc_r_mix)),
2491 SND_SOC_DAPM_MIXER("Sto3 ADC MIXL", SND_SOC_NOPM, 0, 0,
2492 rt5677_sto3_adc_l_mix, ARRAY_SIZE(rt5677_sto3_adc_l_mix)),
2493 SND_SOC_DAPM_MIXER("Sto3 ADC MIXR", SND_SOC_NOPM, 0, 0,
2494 rt5677_sto3_adc_r_mix, ARRAY_SIZE(rt5677_sto3_adc_r_mix)),
2495 SND_SOC_DAPM_MIXER("Sto4 ADC MIXL", SND_SOC_NOPM, 0, 0,
2496 rt5677_sto4_adc_l_mix, ARRAY_SIZE(rt5677_sto4_adc_l_mix)),
2497 SND_SOC_DAPM_MIXER("Sto4 ADC MIXR", SND_SOC_NOPM, 0, 0,
2498 rt5677_sto4_adc_r_mix, ARRAY_SIZE(rt5677_sto4_adc_r_mix)),
2499 SND_SOC_DAPM_SUPPLY("adc mono left filter", RT5677_PWR_DIG2,
2500 RT5677_PWR_ADC_MF_L_BIT, 0, NULL, 0),
2501 SND_SOC_DAPM_MIXER("Mono ADC MIXL", SND_SOC_NOPM, 0, 0,
2502 rt5677_mono_adc_l_mix, ARRAY_SIZE(rt5677_mono_adc_l_mix)),
2503 SND_SOC_DAPM_SUPPLY("adc mono right filter", RT5677_PWR_DIG2,
2504 RT5677_PWR_ADC_MF_R_BIT, 0, NULL, 0),
2505 SND_SOC_DAPM_MIXER("Mono ADC MIXR", SND_SOC_NOPM, 0, 0,
2506 rt5677_mono_adc_r_mix, ARRAY_SIZE(rt5677_mono_adc_r_mix)),
2507
2508 /* ADC PGA */
2509 SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2510 SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2511 SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2512 SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2513 SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2514 SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2515 SND_SOC_DAPM_PGA("Stereo3 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2516 SND_SOC_DAPM_PGA("Stereo3 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2517 SND_SOC_DAPM_PGA("Stereo3 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2518 SND_SOC_DAPM_PGA("Stereo4 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2519 SND_SOC_DAPM_PGA("Stereo4 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2520 SND_SOC_DAPM_PGA("Stereo4 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2521 SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2522 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002523 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2524 SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
Oder Chiou0e826e82014-05-26 20:32:33 +08002525
2526 /* DSP */
2527 SND_SOC_DAPM_MUX("IB9 Mux", SND_SOC_NOPM, 0, 0,
2528 &rt5677_ib9_src_mux),
2529 SND_SOC_DAPM_MUX("IB8 Mux", SND_SOC_NOPM, 0, 0,
2530 &rt5677_ib8_src_mux),
2531 SND_SOC_DAPM_MUX("IB7 Mux", SND_SOC_NOPM, 0, 0,
2532 &rt5677_ib7_src_mux),
2533 SND_SOC_DAPM_MUX("IB6 Mux", SND_SOC_NOPM, 0, 0,
2534 &rt5677_ib6_src_mux),
2535 SND_SOC_DAPM_MUX("IB45 Mux", SND_SOC_NOPM, 0, 0,
2536 &rt5677_ib45_src_mux),
2537 SND_SOC_DAPM_MUX("IB23 Mux", SND_SOC_NOPM, 0, 0,
2538 &rt5677_ib23_src_mux),
2539 SND_SOC_DAPM_MUX("IB01 Mux", SND_SOC_NOPM, 0, 0,
2540 &rt5677_ib01_src_mux),
2541 SND_SOC_DAPM_MUX("IB45 Bypass Mux", SND_SOC_NOPM, 0, 0,
2542 &rt5677_ib45_bypass_src_mux),
2543 SND_SOC_DAPM_MUX("IB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
2544 &rt5677_ib23_bypass_src_mux),
2545 SND_SOC_DAPM_MUX("IB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
2546 &rt5677_ib01_bypass_src_mux),
2547 SND_SOC_DAPM_MUX("OB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
2548 &rt5677_ob23_bypass_src_mux),
2549 SND_SOC_DAPM_MUX("OB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
2550 &rt5677_ob01_bypass_src_mux),
2551
2552 SND_SOC_DAPM_PGA("OB45", SND_SOC_NOPM, 0, 0, NULL, 0),
2553 SND_SOC_DAPM_PGA("OB67", SND_SOC_NOPM, 0, 0, NULL, 0),
2554
2555 SND_SOC_DAPM_PGA("OutBound2", SND_SOC_NOPM, 0, 0, NULL, 0),
2556 SND_SOC_DAPM_PGA("OutBound3", SND_SOC_NOPM, 0, 0, NULL, 0),
2557 SND_SOC_DAPM_PGA("OutBound4", SND_SOC_NOPM, 0, 0, NULL, 0),
2558 SND_SOC_DAPM_PGA("OutBound5", SND_SOC_NOPM, 0, 0, NULL, 0),
2559 SND_SOC_DAPM_PGA("OutBound6", SND_SOC_NOPM, 0, 0, NULL, 0),
2560 SND_SOC_DAPM_PGA("OutBound7", SND_SOC_NOPM, 0, 0, NULL, 0),
2561
2562 /* Digital Interface */
2563 SND_SOC_DAPM_SUPPLY("I2S1", RT5677_PWR_DIG1,
2564 RT5677_PWR_I2S1_BIT, 0, NULL, 0),
2565 SND_SOC_DAPM_PGA("IF1 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2566 SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2567 SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2568 SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2569 SND_SOC_DAPM_PGA("IF1 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2570 SND_SOC_DAPM_PGA("IF1 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2571 SND_SOC_DAPM_PGA("IF1 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2572 SND_SOC_DAPM_PGA("IF1 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2573 SND_SOC_DAPM_PGA("IF1 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2574 SND_SOC_DAPM_PGA("IF1 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2575 SND_SOC_DAPM_PGA("IF1 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2576 SND_SOC_DAPM_PGA("IF1 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2577 SND_SOC_DAPM_PGA("IF1 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2578 SND_SOC_DAPM_PGA("IF1 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2579 SND_SOC_DAPM_PGA("IF1 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2580 SND_SOC_DAPM_PGA("IF1 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2581
2582 SND_SOC_DAPM_SUPPLY("I2S2", RT5677_PWR_DIG1,
2583 RT5677_PWR_I2S2_BIT, 0, NULL, 0),
2584 SND_SOC_DAPM_PGA("IF2 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2585 SND_SOC_DAPM_PGA("IF2 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2586 SND_SOC_DAPM_PGA("IF2 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2587 SND_SOC_DAPM_PGA("IF2 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2588 SND_SOC_DAPM_PGA("IF2 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2589 SND_SOC_DAPM_PGA("IF2 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2590 SND_SOC_DAPM_PGA("IF2 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2591 SND_SOC_DAPM_PGA("IF2 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2592 SND_SOC_DAPM_PGA("IF2 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2593 SND_SOC_DAPM_PGA("IF2 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2594 SND_SOC_DAPM_PGA("IF2 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2595 SND_SOC_DAPM_PGA("IF2 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2596 SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2597 SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2598 SND_SOC_DAPM_PGA("IF2 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2599 SND_SOC_DAPM_PGA("IF2 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2600
2601 SND_SOC_DAPM_SUPPLY("I2S3", RT5677_PWR_DIG1,
2602 RT5677_PWR_I2S3_BIT, 0, NULL, 0),
2603 SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2604 SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2605 SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2606 SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2607 SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2608 SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2609
2610 SND_SOC_DAPM_SUPPLY("I2S4", RT5677_PWR_DIG1,
2611 RT5677_PWR_I2S4_BIT, 0, NULL, 0),
2612 SND_SOC_DAPM_PGA("IF4 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2613 SND_SOC_DAPM_PGA("IF4 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2614 SND_SOC_DAPM_PGA("IF4 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2615 SND_SOC_DAPM_PGA("IF4 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2616 SND_SOC_DAPM_PGA("IF4 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2617 SND_SOC_DAPM_PGA("IF4 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2618
2619 SND_SOC_DAPM_SUPPLY("SLB", RT5677_PWR_DIG1,
2620 RT5677_PWR_SLB_BIT, 0, NULL, 0),
2621 SND_SOC_DAPM_PGA("SLB DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2622 SND_SOC_DAPM_PGA("SLB DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2623 SND_SOC_DAPM_PGA("SLB DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2624 SND_SOC_DAPM_PGA("SLB DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2625 SND_SOC_DAPM_PGA("SLB DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2626 SND_SOC_DAPM_PGA("SLB DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2627 SND_SOC_DAPM_PGA("SLB DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2628 SND_SOC_DAPM_PGA("SLB DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2629 SND_SOC_DAPM_PGA("SLB DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2630 SND_SOC_DAPM_PGA("SLB DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2631 SND_SOC_DAPM_PGA("SLB DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2632 SND_SOC_DAPM_PGA("SLB DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2633 SND_SOC_DAPM_PGA("SLB ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2634 SND_SOC_DAPM_PGA("SLB ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2635 SND_SOC_DAPM_PGA("SLB ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2636 SND_SOC_DAPM_PGA("SLB ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2637
2638 /* Digital Interface Select */
2639 SND_SOC_DAPM_MUX("IF1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2640 &rt5677_if1_adc1_mux),
2641 SND_SOC_DAPM_MUX("IF1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2642 &rt5677_if1_adc2_mux),
2643 SND_SOC_DAPM_MUX("IF1 ADC3 Mux", SND_SOC_NOPM, 0, 0,
2644 &rt5677_if1_adc3_mux),
2645 SND_SOC_DAPM_MUX("IF1 ADC4 Mux", SND_SOC_NOPM, 0, 0,
2646 &rt5677_if1_adc4_mux),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002647 SND_SOC_DAPM_MUX("IF1 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
2648 &rt5677_if1_adc1_swap_mux),
2649 SND_SOC_DAPM_MUX("IF1 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
2650 &rt5677_if1_adc2_swap_mux),
2651 SND_SOC_DAPM_MUX("IF1 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
2652 &rt5677_if1_adc3_swap_mux),
2653 SND_SOC_DAPM_MUX("IF1 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
2654 &rt5677_if1_adc4_swap_mux),
2655 SND_SOC_DAPM_MUX_E("IF1 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
2656 &rt5677_if1_adc_tdm_swap_mux, rt5677_if1_adc_tdm_event,
2657 SND_SOC_DAPM_PRE_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002658 SND_SOC_DAPM_MUX("IF2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2659 &rt5677_if2_adc1_mux),
2660 SND_SOC_DAPM_MUX("IF2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2661 &rt5677_if2_adc2_mux),
2662 SND_SOC_DAPM_MUX("IF2 ADC3 Mux", SND_SOC_NOPM, 0, 0,
2663 &rt5677_if2_adc3_mux),
2664 SND_SOC_DAPM_MUX("IF2 ADC4 Mux", SND_SOC_NOPM, 0, 0,
2665 &rt5677_if2_adc4_mux),
Oder Chioue6f6ebc2014-10-22 16:11:39 +08002666 SND_SOC_DAPM_MUX("IF2 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
2667 &rt5677_if2_adc1_swap_mux),
2668 SND_SOC_DAPM_MUX("IF2 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
2669 &rt5677_if2_adc2_swap_mux),
2670 SND_SOC_DAPM_MUX("IF2 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
2671 &rt5677_if2_adc3_swap_mux),
2672 SND_SOC_DAPM_MUX("IF2 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
2673 &rt5677_if2_adc4_swap_mux),
2674 SND_SOC_DAPM_MUX_E("IF2 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
2675 &rt5677_if2_adc_tdm_swap_mux, rt5677_if2_adc_tdm_event,
2676 SND_SOC_DAPM_PRE_PMU),
Oder Chiou0e826e82014-05-26 20:32:33 +08002677 SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0,
2678 &rt5677_if3_adc_mux),
2679 SND_SOC_DAPM_MUX("IF4 ADC Mux", SND_SOC_NOPM, 0, 0,
2680 &rt5677_if4_adc_mux),
2681 SND_SOC_DAPM_MUX("SLB ADC1 Mux", SND_SOC_NOPM, 0, 0,
2682 &rt5677_slb_adc1_mux),
2683 SND_SOC_DAPM_MUX("SLB ADC2 Mux", SND_SOC_NOPM, 0, 0,
2684 &rt5677_slb_adc2_mux),
2685 SND_SOC_DAPM_MUX("SLB ADC3 Mux", SND_SOC_NOPM, 0, 0,
2686 &rt5677_slb_adc3_mux),
2687 SND_SOC_DAPM_MUX("SLB ADC4 Mux", SND_SOC_NOPM, 0, 0,
2688 &rt5677_slb_adc4_mux),
2689
Oder Chiou91159ec2014-11-11 15:31:19 +08002690 SND_SOC_DAPM_MUX("IF1 DAC0 Mux", SND_SOC_NOPM, 0, 0,
2691 &rt5677_if1_dac0_tdm_sel_mux),
2692 SND_SOC_DAPM_MUX("IF1 DAC1 Mux", SND_SOC_NOPM, 0, 0,
2693 &rt5677_if1_dac1_tdm_sel_mux),
2694 SND_SOC_DAPM_MUX("IF1 DAC2 Mux", SND_SOC_NOPM, 0, 0,
2695 &rt5677_if1_dac2_tdm_sel_mux),
2696 SND_SOC_DAPM_MUX("IF1 DAC3 Mux", SND_SOC_NOPM, 0, 0,
2697 &rt5677_if1_dac3_tdm_sel_mux),
2698 SND_SOC_DAPM_MUX("IF1 DAC4 Mux", SND_SOC_NOPM, 0, 0,
2699 &rt5677_if1_dac4_tdm_sel_mux),
2700 SND_SOC_DAPM_MUX("IF1 DAC5 Mux", SND_SOC_NOPM, 0, 0,
2701 &rt5677_if1_dac5_tdm_sel_mux),
2702 SND_SOC_DAPM_MUX("IF1 DAC6 Mux", SND_SOC_NOPM, 0, 0,
2703 &rt5677_if1_dac6_tdm_sel_mux),
2704 SND_SOC_DAPM_MUX("IF1 DAC7 Mux", SND_SOC_NOPM, 0, 0,
2705 &rt5677_if1_dac7_tdm_sel_mux),
2706
2707 SND_SOC_DAPM_MUX("IF2 DAC0 Mux", SND_SOC_NOPM, 0, 0,
2708 &rt5677_if2_dac0_tdm_sel_mux),
2709 SND_SOC_DAPM_MUX("IF2 DAC1 Mux", SND_SOC_NOPM, 0, 0,
2710 &rt5677_if2_dac1_tdm_sel_mux),
2711 SND_SOC_DAPM_MUX("IF2 DAC2 Mux", SND_SOC_NOPM, 0, 0,
2712 &rt5677_if2_dac2_tdm_sel_mux),
2713 SND_SOC_DAPM_MUX("IF2 DAC3 Mux", SND_SOC_NOPM, 0, 0,
2714 &rt5677_if2_dac3_tdm_sel_mux),
2715 SND_SOC_DAPM_MUX("IF2 DAC4 Mux", SND_SOC_NOPM, 0, 0,
2716 &rt5677_if2_dac4_tdm_sel_mux),
2717 SND_SOC_DAPM_MUX("IF2 DAC5 Mux", SND_SOC_NOPM, 0, 0,
2718 &rt5677_if2_dac5_tdm_sel_mux),
2719 SND_SOC_DAPM_MUX("IF2 DAC6 Mux", SND_SOC_NOPM, 0, 0,
2720 &rt5677_if2_dac6_tdm_sel_mux),
2721 SND_SOC_DAPM_MUX("IF2 DAC7 Mux", SND_SOC_NOPM, 0, 0,
2722 &rt5677_if2_dac7_tdm_sel_mux),
2723
Oder Chiou0e826e82014-05-26 20:32:33 +08002724 /* Audio Interface */
2725 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
2726 SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
2727 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
2728 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
2729 SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
2730 SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
2731 SND_SOC_DAPM_AIF_IN("AIF4RX", "AIF4 Playback", 0, SND_SOC_NOPM, 0, 0),
2732 SND_SOC_DAPM_AIF_OUT("AIF4TX", "AIF4 Capture", 0, SND_SOC_NOPM, 0, 0),
2733 SND_SOC_DAPM_AIF_IN("SLBRX", "SLIMBus Playback", 0, SND_SOC_NOPM, 0, 0),
2734 SND_SOC_DAPM_AIF_OUT("SLBTX", "SLIMBus Capture", 0, SND_SOC_NOPM, 0, 0),
2735
2736 /* Sidetone Mux */
2737 SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0,
2738 &rt5677_sidetone_mux),
Oder Chiou90bdbb42014-09-18 14:45:59 +08002739 SND_SOC_DAPM_SUPPLY("Sidetone Power", RT5677_SIDETONE_CTRL,
2740 RT5677_ST_EN_SFT, 0, NULL, 0),
2741
Oder Chiou0e826e82014-05-26 20:32:33 +08002742 /* VAD Mux*/
2743 SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0,
2744 &rt5677_vad_src_mux),
2745
2746 /* Tensilica DSP */
2747 SND_SOC_DAPM_PGA("Tensilica DSP", SND_SOC_NOPM, 0, 0, NULL, 0),
2748 SND_SOC_DAPM_MIXER("OB01 MIX", SND_SOC_NOPM, 0, 0,
2749 rt5677_ob_01_mix, ARRAY_SIZE(rt5677_ob_01_mix)),
2750 SND_SOC_DAPM_MIXER("OB23 MIX", SND_SOC_NOPM, 0, 0,
2751 rt5677_ob_23_mix, ARRAY_SIZE(rt5677_ob_23_mix)),
2752 SND_SOC_DAPM_MIXER("OB4 MIX", SND_SOC_NOPM, 0, 0,
2753 rt5677_ob_4_mix, ARRAY_SIZE(rt5677_ob_4_mix)),
2754 SND_SOC_DAPM_MIXER("OB5 MIX", SND_SOC_NOPM, 0, 0,
2755 rt5677_ob_5_mix, ARRAY_SIZE(rt5677_ob_5_mix)),
2756 SND_SOC_DAPM_MIXER("OB6 MIX", SND_SOC_NOPM, 0, 0,
2757 rt5677_ob_6_mix, ARRAY_SIZE(rt5677_ob_6_mix)),
2758 SND_SOC_DAPM_MIXER("OB7 MIX", SND_SOC_NOPM, 0, 0,
2759 rt5677_ob_7_mix, ARRAY_SIZE(rt5677_ob_7_mix)),
2760
2761 /* Output Side */
Oder Chioud65fd3a2014-11-05 13:42:52 +08002762 /* DAC mixer before sound effect */
Oder Chiou0e826e82014-05-26 20:32:33 +08002763 SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0,
2764 rt5677_dac_l_mix, ARRAY_SIZE(rt5677_dac_l_mix)),
2765 SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0,
2766 rt5677_dac_r_mix, ARRAY_SIZE(rt5677_dac_r_mix)),
2767 SND_SOC_DAPM_PGA("DAC1 FS", SND_SOC_NOPM, 0, 0, NULL, 0),
2768
2769 /* DAC Mux */
2770 SND_SOC_DAPM_MUX("DAC1 Mux", SND_SOC_NOPM, 0, 0,
2771 &rt5677_dac1_mux),
2772 SND_SOC_DAPM_MUX("ADDA1 Mux", SND_SOC_NOPM, 0, 0,
2773 &rt5677_adda1_mux),
2774 SND_SOC_DAPM_MUX("DAC12 SRC Mux", SND_SOC_NOPM, 0, 0,
2775 &rt5677_dac12_mux),
2776 SND_SOC_DAPM_MUX("DAC3 SRC Mux", SND_SOC_NOPM, 0, 0,
2777 &rt5677_dac3_mux),
2778
2779 /* DAC2 channel Mux */
2780 SND_SOC_DAPM_MUX("DAC2 L Mux", SND_SOC_NOPM, 0, 0,
2781 &rt5677_dac2_l_mux),
2782 SND_SOC_DAPM_MUX("DAC2 R Mux", SND_SOC_NOPM, 0, 0,
2783 &rt5677_dac2_r_mux),
2784
2785 /* DAC3 channel Mux */
2786 SND_SOC_DAPM_MUX("DAC3 L Mux", SND_SOC_NOPM, 0, 0,
2787 &rt5677_dac3_l_mux),
2788 SND_SOC_DAPM_MUX("DAC3 R Mux", SND_SOC_NOPM, 0, 0,
2789 &rt5677_dac3_r_mux),
2790
2791 /* DAC4 channel Mux */
2792 SND_SOC_DAPM_MUX("DAC4 L Mux", SND_SOC_NOPM, 0, 0,
2793 &rt5677_dac4_l_mux),
2794 SND_SOC_DAPM_MUX("DAC4 R Mux", SND_SOC_NOPM, 0, 0,
2795 &rt5677_dac4_r_mux),
2796
2797 /* DAC Mixer */
2798 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2,
2799 RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0),
Oder Chiou6800b5b2014-12-23 10:27:54 +08002800 SND_SOC_DAPM_SUPPLY("dac mono2 left filter", RT5677_PWR_DIG2,
Oder Chiou0e826e82014-05-26 20:32:33 +08002801 RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0),
Oder Chiou6800b5b2014-12-23 10:27:54 +08002802 SND_SOC_DAPM_SUPPLY("dac mono2 right filter", RT5677_PWR_DIG2,
Oder Chiou0e826e82014-05-26 20:32:33 +08002803 RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0),
Oder Chiou6800b5b2014-12-23 10:27:54 +08002804 SND_SOC_DAPM_SUPPLY("dac mono3 left filter", RT5677_PWR_DIG2,
2805 RT5677_PWR_DAC_M3F_L_BIT, 0, NULL, 0),
2806 SND_SOC_DAPM_SUPPLY("dac mono3 right filter", RT5677_PWR_DIG2,
2807 RT5677_PWR_DAC_M3F_R_BIT, 0, NULL, 0),
2808 SND_SOC_DAPM_SUPPLY("dac mono4 left filter", RT5677_PWR_DIG2,
2809 RT5677_PWR_DAC_M4F_L_BIT, 0, NULL, 0),
2810 SND_SOC_DAPM_SUPPLY("dac mono4 right filter", RT5677_PWR_DIG2,
2811 RT5677_PWR_DAC_M4F_R_BIT, 0, NULL, 0),
Oder Chiou0e826e82014-05-26 20:32:33 +08002812
2813 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
2814 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)),
2815 SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0,
2816 rt5677_sto1_dac_r_mix, ARRAY_SIZE(rt5677_sto1_dac_r_mix)),
2817 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
2818 rt5677_mono_dac_l_mix, ARRAY_SIZE(rt5677_mono_dac_l_mix)),
2819 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
2820 rt5677_mono_dac_r_mix, ARRAY_SIZE(rt5677_mono_dac_r_mix)),
2821 SND_SOC_DAPM_MIXER("DD1 MIXL", SND_SOC_NOPM, 0, 0,
2822 rt5677_dd1_l_mix, ARRAY_SIZE(rt5677_dd1_l_mix)),
2823 SND_SOC_DAPM_MIXER("DD1 MIXR", SND_SOC_NOPM, 0, 0,
2824 rt5677_dd1_r_mix, ARRAY_SIZE(rt5677_dd1_r_mix)),
2825 SND_SOC_DAPM_MIXER("DD2 MIXL", SND_SOC_NOPM, 0, 0,
2826 rt5677_dd2_l_mix, ARRAY_SIZE(rt5677_dd2_l_mix)),
2827 SND_SOC_DAPM_MIXER("DD2 MIXR", SND_SOC_NOPM, 0, 0,
2828 rt5677_dd2_r_mix, ARRAY_SIZE(rt5677_dd2_r_mix)),
2829 SND_SOC_DAPM_PGA("Stereo DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2830 SND_SOC_DAPM_PGA("Mono DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2831 SND_SOC_DAPM_PGA("DD1 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2832 SND_SOC_DAPM_PGA("DD2 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2833
2834 /* DACs */
2835 SND_SOC_DAPM_DAC("DAC 1", NULL, RT5677_PWR_DIG1,
2836 RT5677_PWR_DAC1_BIT, 0),
2837 SND_SOC_DAPM_DAC("DAC 2", NULL, RT5677_PWR_DIG1,
2838 RT5677_PWR_DAC2_BIT, 0),
2839 SND_SOC_DAPM_DAC("DAC 3", NULL, RT5677_PWR_DIG1,
2840 RT5677_PWR_DAC3_BIT, 0),
2841
2842 /* PDM */
2843 SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5677_PWR_DIG2,
2844 RT5677_PWR_PDM1_BIT, 0, NULL, 0),
2845 SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5677_PWR_DIG2,
2846 RT5677_PWR_PDM2_BIT, 0, NULL, 0),
2847
2848 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_L_SFT,
2849 1, &rt5677_pdm1_l_mux),
2850 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_R_SFT,
2851 1, &rt5677_pdm1_r_mux),
2852 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_L_SFT,
2853 1, &rt5677_pdm2_l_mux),
2854 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_R_SFT,
2855 1, &rt5677_pdm2_r_mux),
2856
Oder Chiou683996c2014-11-19 13:52:20 +08002857 SND_SOC_DAPM_PGA_S("LOUT1 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO1_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08002858 0, NULL, 0),
Oder Chiou683996c2014-11-19 13:52:20 +08002859 SND_SOC_DAPM_PGA_S("LOUT2 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO2_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08002860 0, NULL, 0),
Oder Chiou683996c2014-11-19 13:52:20 +08002861 SND_SOC_DAPM_PGA_S("LOUT3 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO3_BIT,
Oder Chiou0e826e82014-05-26 20:32:33 +08002862 0, NULL, 0),
2863
Oder Chiou683996c2014-11-19 13:52:20 +08002864 SND_SOC_DAPM_PGA_S("LOUT1 vref", 1, SND_SOC_NOPM, 0, 0,
2865 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2866 SND_SOC_DAPM_PGA_S("LOUT2 vref", 1, SND_SOC_NOPM, 0, 0,
2867 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2868 SND_SOC_DAPM_PGA_S("LOUT3 vref", 1, SND_SOC_NOPM, 0, 0,
2869 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2870
Oder Chiou0e826e82014-05-26 20:32:33 +08002871 /* Output Lines */
2872 SND_SOC_DAPM_OUTPUT("LOUT1"),
2873 SND_SOC_DAPM_OUTPUT("LOUT2"),
2874 SND_SOC_DAPM_OUTPUT("LOUT3"),
2875 SND_SOC_DAPM_OUTPUT("PDM1L"),
2876 SND_SOC_DAPM_OUTPUT("PDM1R"),
2877 SND_SOC_DAPM_OUTPUT("PDM2L"),
2878 SND_SOC_DAPM_OUTPUT("PDM2R"),
Oder Chiou683996c2014-11-19 13:52:20 +08002879
2880 SND_SOC_DAPM_POST("vref", rt5677_vref_event),
Oder Chiou0e826e82014-05-26 20:32:33 +08002881};
2882
2883static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
Oder Chiou5a8c7c22014-12-23 10:27:55 +08002884 { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", can_use_asrc },
2885 { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", can_use_asrc },
2886 { "Stereo3 DMIC Mux", NULL, "DMIC STO3 ASRC", can_use_asrc },
2887 { "Stereo4 DMIC Mux", NULL, "DMIC STO4 ASRC", can_use_asrc },
2888 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc },
2889 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc },
2890 { "I2S1", NULL, "I2S1 ASRC", can_use_asrc},
2891 { "I2S2", NULL, "I2S2 ASRC", can_use_asrc},
2892 { "I2S3", NULL, "I2S3 ASRC", can_use_asrc},
2893 { "I2S4", NULL, "I2S4 ASRC", can_use_asrc},
2894
2895 { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc },
2896 { "dac mono2 left filter", NULL, "DAC MONO2 L ASRC", is_using_asrc },
2897 { "dac mono2 right filter", NULL, "DAC MONO2 R ASRC", is_using_asrc },
2898 { "dac mono3 left filter", NULL, "DAC MONO3 L ASRC", is_using_asrc },
2899 { "dac mono3 right filter", NULL, "DAC MONO3 R ASRC", is_using_asrc },
2900 { "dac mono4 left filter", NULL, "DAC MONO4 L ASRC", is_using_asrc },
2901 { "dac mono4 right filter", NULL, "DAC MONO4 R ASRC", is_using_asrc },
2902 { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc },
2903 { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc },
2904 { "adc stereo3 filter", NULL, "ADC STO3 ASRC", is_using_asrc },
2905 { "adc stereo4 filter", NULL, "ADC STO4 ASRC", is_using_asrc },
2906 { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc },
2907 { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc },
2908
Oder Chiou0e826e82014-05-26 20:32:33 +08002909 { "DMIC1", NULL, "DMIC L1" },
2910 { "DMIC1", NULL, "DMIC R1" },
2911 { "DMIC2", NULL, "DMIC L2" },
2912 { "DMIC2", NULL, "DMIC R2" },
2913 { "DMIC3", NULL, "DMIC L3" },
2914 { "DMIC3", NULL, "DMIC R3" },
2915 { "DMIC4", NULL, "DMIC L4" },
2916 { "DMIC4", NULL, "DMIC R4" },
2917
2918 { "DMIC L1", NULL, "DMIC CLK" },
2919 { "DMIC R1", NULL, "DMIC CLK" },
2920 { "DMIC L2", NULL, "DMIC CLK" },
2921 { "DMIC R2", NULL, "DMIC CLK" },
2922 { "DMIC L3", NULL, "DMIC CLK" },
2923 { "DMIC R3", NULL, "DMIC CLK" },
2924 { "DMIC L4", NULL, "DMIC CLK" },
2925 { "DMIC R4", NULL, "DMIC CLK" },
2926
Bard Liao2d15d972014-08-27 19:50:34 +08002927 { "DMIC L1", NULL, "DMIC1 power" },
2928 { "DMIC R1", NULL, "DMIC1 power" },
2929 { "DMIC L3", NULL, "DMIC3 power" },
2930 { "DMIC R3", NULL, "DMIC3 power" },
2931 { "DMIC L4", NULL, "DMIC4 power" },
2932 { "DMIC R4", NULL, "DMIC4 power" },
2933
Oder Chiou0e826e82014-05-26 20:32:33 +08002934 { "BST1", NULL, "IN1P" },
2935 { "BST1", NULL, "IN1N" },
2936 { "BST2", NULL, "IN2P" },
2937 { "BST2", NULL, "IN2N" },
2938
Bard Liao22e51342014-08-27 19:50:33 +08002939 { "IN1P", NULL, "MICBIAS1" },
2940 { "IN1N", NULL, "MICBIAS1" },
2941 { "IN2P", NULL, "MICBIAS1" },
2942 { "IN2N", NULL, "MICBIAS1" },
Oder Chiou0e826e82014-05-26 20:32:33 +08002943
2944 { "ADC 1", NULL, "BST1" },
2945 { "ADC 1", NULL, "ADC 1 power" },
2946 { "ADC 1", NULL, "ADC1 clock" },
2947 { "ADC 2", NULL, "BST2" },
2948 { "ADC 2", NULL, "ADC 2 power" },
2949 { "ADC 2", NULL, "ADC2 clock" },
2950
2951 { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" },
2952 { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" },
2953 { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" },
2954 { "Stereo1 DMIC Mux", "DMIC4", "DMIC4" },
2955
2956 { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" },
2957 { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" },
2958 { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" },
2959 { "Stereo2 DMIC Mux", "DMIC4", "DMIC4" },
2960
2961 { "Stereo3 DMIC Mux", "DMIC1", "DMIC1" },
2962 { "Stereo3 DMIC Mux", "DMIC2", "DMIC2" },
2963 { "Stereo3 DMIC Mux", "DMIC3", "DMIC3" },
2964 { "Stereo3 DMIC Mux", "DMIC4", "DMIC4" },
2965
2966 { "Stereo4 DMIC Mux", "DMIC1", "DMIC1" },
2967 { "Stereo4 DMIC Mux", "DMIC2", "DMIC2" },
2968 { "Stereo4 DMIC Mux", "DMIC3", "DMIC3" },
2969 { "Stereo4 DMIC Mux", "DMIC4", "DMIC4" },
2970
2971 { "Mono DMIC L Mux", "DMIC1", "DMIC1" },
2972 { "Mono DMIC L Mux", "DMIC2", "DMIC2" },
2973 { "Mono DMIC L Mux", "DMIC3", "DMIC3" },
2974 { "Mono DMIC L Mux", "DMIC4", "DMIC4" },
2975
2976 { "Mono DMIC R Mux", "DMIC1", "DMIC1" },
2977 { "Mono DMIC R Mux", "DMIC2", "DMIC2" },
2978 { "Mono DMIC R Mux", "DMIC3", "DMIC3" },
2979 { "Mono DMIC R Mux", "DMIC4", "DMIC4" },
2980
2981 { "ADC 1_2", NULL, "ADC 1" },
2982 { "ADC 1_2", NULL, "ADC 2" },
2983
2984 { "Stereo1 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2985 { "Stereo1 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2986 { "Stereo1 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2987
2988 { "Stereo1 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2989 { "Stereo1 ADC2 Mux", "DMIC", "Stereo1 DMIC Mux" },
2990 { "Stereo1 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2991
2992 { "Stereo2 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2993 { "Stereo2 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2994 { "Stereo2 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2995
2996 { "Stereo2 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2997 { "Stereo2 ADC2 Mux", "DMIC", "Stereo2 DMIC Mux" },
2998 { "Stereo2 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2999
3000 { "Stereo3 ADC1 Mux", "DD MIX1", "DD1 MIX" },
3001 { "Stereo3 ADC1 Mux", "ADC1/2", "ADC 1_2" },
3002 { "Stereo3 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
3003
3004 { "Stereo3 ADC2 Mux", "DD MIX1", "DD1 MIX" },
3005 { "Stereo3 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
3006 { "Stereo3 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
3007
3008 { "Stereo4 ADC1 Mux", "DD MIX1", "DD1 MIX" },
3009 { "Stereo4 ADC1 Mux", "ADC1/2", "ADC 1_2" },
3010 { "Stereo4 ADC1 Mux", "DD MIX2", "DD2 MIX" },
3011
3012 { "Stereo4 ADC2 Mux", "DD MIX1", "DD1 MIX" },
3013 { "Stereo4 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
3014 { "Stereo4 ADC2 Mux", "DD MIX2", "DD2 MIX" },
3015
3016 { "Mono ADC2 L Mux", "DD MIX1L", "DD1 MIXL" },
3017 { "Mono ADC2 L Mux", "DMIC", "Mono DMIC L Mux" },
3018 { "Mono ADC2 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3019
3020 { "Mono ADC1 L Mux", "DD MIX1L", "DD1 MIXL" },
3021 { "Mono ADC1 L Mux", "ADC1", "ADC 1" },
3022 { "Mono ADC1 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3023
3024 { "Mono ADC1 R Mux", "DD MIX1R", "DD1 MIXR" },
3025 { "Mono ADC1 R Mux", "ADC2", "ADC 2" },
3026 { "Mono ADC1 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3027
3028 { "Mono ADC2 R Mux", "DD MIX1R", "DD1 MIXR" },
3029 { "Mono ADC2 R Mux", "DMIC", "Mono DMIC R Mux" },
3030 { "Mono ADC2 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3031
3032 { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC1 Mux" },
3033 { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC2 Mux" },
3034 { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC1 Mux" },
3035 { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC2 Mux" },
3036
3037 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" },
3038 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003039 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" },
3040 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" },
3041 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
3042
3043 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" },
3044 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" },
3045
3046 { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC1 Mux" },
3047 { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC2 Mux" },
3048 { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC1 Mux" },
3049 { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC2 Mux" },
3050
3051 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" },
3052 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" },
3053
3054 { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" },
3055 { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" },
3056
3057 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" },
3058 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003059 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" },
3060 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" },
3061 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
3062
3063 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXL" },
3064 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR" },
3065
3066 { "Sto3 ADC MIXL", "ADC1 Switch", "Stereo3 ADC1 Mux" },
3067 { "Sto3 ADC MIXL", "ADC2 Switch", "Stereo3 ADC2 Mux" },
3068 { "Sto3 ADC MIXR", "ADC1 Switch", "Stereo3 ADC1 Mux" },
3069 { "Sto3 ADC MIXR", "ADC2 Switch", "Stereo3 ADC2 Mux" },
3070
3071 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" },
3072 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003073 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" },
3074 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" },
3075 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
3076
3077 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXL" },
3078 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXR" },
3079
3080 { "Sto4 ADC MIXL", "ADC1 Switch", "Stereo4 ADC1 Mux" },
3081 { "Sto4 ADC MIXL", "ADC2 Switch", "Stereo4 ADC2 Mux" },
3082 { "Sto4 ADC MIXR", "ADC1 Switch", "Stereo4 ADC1 Mux" },
3083 { "Sto4 ADC MIXR", "ADC2 Switch", "Stereo4 ADC2 Mux" },
3084
3085 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" },
3086 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003087 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" },
3088 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" },
3089 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
3090
3091 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXL" },
3092 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXR" },
3093
3094 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC1 L Mux" },
3095 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC2 L Mux" },
3096 { "Mono ADC MIXL", NULL, "adc mono left filter" },
3097 { "adc mono left filter", NULL, "PLL1", is_sys_clk_from_pll },
3098
3099 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC1 R Mux" },
3100 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC2 R Mux" },
3101 { "Mono ADC MIXR", NULL, "adc mono right filter" },
3102 { "adc mono right filter", NULL, "PLL1", is_sys_clk_from_pll },
3103
3104 { "Mono ADC MIX", NULL, "Mono ADC MIXL" },
3105 { "Mono ADC MIX", NULL, "Mono ADC MIXR" },
3106
3107 { "VAD ADC Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3108 { "VAD ADC Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
3109 { "VAD ADC Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
3110 { "VAD ADC Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3111 { "VAD ADC Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3112
3113 { "IF1 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3114 { "IF1 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3115 { "IF1 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3116
3117 { "IF1 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3118 { "IF1 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3119
3120 { "IF1 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3121 { "IF1 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3122 { "IF1 ADC3 Mux", "OB45", "OB45" },
3123
3124 { "IF1 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3125 { "IF1 ADC4 Mux", "OB67", "OB67" },
3126 { "IF1 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3127
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003128 { "IF1 ADC1 Swap Mux", "L/R", "IF1 ADC1 Mux" },
3129 { "IF1 ADC1 Swap Mux", "R/L", "IF1 ADC1 Mux" },
3130 { "IF1 ADC1 Swap Mux", "L/L", "IF1 ADC1 Mux" },
3131 { "IF1 ADC1 Swap Mux", "R/R", "IF1 ADC1 Mux" },
3132
3133 { "IF1 ADC2 Swap Mux", "L/R", "IF1 ADC2 Mux" },
3134 { "IF1 ADC2 Swap Mux", "R/L", "IF1 ADC2 Mux" },
3135 { "IF1 ADC2 Swap Mux", "L/L", "IF1 ADC2 Mux" },
3136 { "IF1 ADC2 Swap Mux", "R/R", "IF1 ADC2 Mux" },
3137
3138 { "IF1 ADC3 Swap Mux", "L/R", "IF1 ADC3 Mux" },
3139 { "IF1 ADC3 Swap Mux", "R/L", "IF1 ADC3 Mux" },
3140 { "IF1 ADC3 Swap Mux", "L/L", "IF1 ADC3 Mux" },
3141 { "IF1 ADC3 Swap Mux", "R/R", "IF1 ADC3 Mux" },
3142
3143 { "IF1 ADC4 Swap Mux", "L/R", "IF1 ADC4 Mux" },
3144 { "IF1 ADC4 Swap Mux", "R/L", "IF1 ADC4 Mux" },
3145 { "IF1 ADC4 Swap Mux", "L/L", "IF1 ADC4 Mux" },
3146 { "IF1 ADC4 Swap Mux", "R/R", "IF1 ADC4 Mux" },
3147
3148 { "IF1 ADC", NULL, "IF1 ADC1 Swap Mux" },
3149 { "IF1 ADC", NULL, "IF1 ADC2 Swap Mux" },
3150 { "IF1 ADC", NULL, "IF1 ADC3 Swap Mux" },
3151 { "IF1 ADC", NULL, "IF1 ADC4 Swap Mux" },
3152
3153 { "IF1 ADC TDM Swap Mux", "1/2/3/4", "IF1 ADC" },
3154 { "IF1 ADC TDM Swap Mux", "2/1/3/4", "IF1 ADC" },
3155 { "IF1 ADC TDM Swap Mux", "2/3/1/4", "IF1 ADC" },
3156 { "IF1 ADC TDM Swap Mux", "4/1/2/3", "IF1 ADC" },
3157 { "IF1 ADC TDM Swap Mux", "1/3/2/4", "IF1 ADC" },
3158 { "IF1 ADC TDM Swap Mux", "1/4/2/3", "IF1 ADC" },
3159 { "IF1 ADC TDM Swap Mux", "3/1/2/4", "IF1 ADC" },
3160 { "IF1 ADC TDM Swap Mux", "3/4/1/2", "IF1 ADC" },
3161
Oder Chiou0e826e82014-05-26 20:32:33 +08003162 { "AIF1TX", NULL, "I2S1" },
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003163 { "AIF1TX", NULL, "IF1 ADC TDM Swap Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003164
3165 { "IF2 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3166 { "IF2 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3167 { "IF2 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3168
3169 { "IF2 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3170 { "IF2 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3171
3172 { "IF2 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3173 { "IF2 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3174 { "IF2 ADC3 Mux", "OB45", "OB45" },
3175
3176 { "IF2 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3177 { "IF2 ADC4 Mux", "OB67", "OB67" },
3178 { "IF2 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3179
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003180 { "IF2 ADC1 Swap Mux", "L/R", "IF2 ADC1 Mux" },
3181 { "IF2 ADC1 Swap Mux", "R/L", "IF2 ADC1 Mux" },
3182 { "IF2 ADC1 Swap Mux", "L/L", "IF2 ADC1 Mux" },
3183 { "IF2 ADC1 Swap Mux", "R/R", "IF2 ADC1 Mux" },
3184
3185 { "IF2 ADC2 Swap Mux", "L/R", "IF2 ADC2 Mux" },
3186 { "IF2 ADC2 Swap Mux", "R/L", "IF2 ADC2 Mux" },
3187 { "IF2 ADC2 Swap Mux", "L/L", "IF2 ADC2 Mux" },
3188 { "IF2 ADC2 Swap Mux", "R/R", "IF2 ADC2 Mux" },
3189
3190 { "IF2 ADC3 Swap Mux", "L/R", "IF2 ADC3 Mux" },
3191 { "IF2 ADC3 Swap Mux", "R/L", "IF2 ADC3 Mux" },
3192 { "IF2 ADC3 Swap Mux", "L/L", "IF2 ADC3 Mux" },
3193 { "IF2 ADC3 Swap Mux", "R/R", "IF2 ADC3 Mux" },
3194
3195 { "IF2 ADC4 Swap Mux", "L/R", "IF2 ADC4 Mux" },
3196 { "IF2 ADC4 Swap Mux", "R/L", "IF2 ADC4 Mux" },
3197 { "IF2 ADC4 Swap Mux", "L/L", "IF2 ADC4 Mux" },
3198 { "IF2 ADC4 Swap Mux", "R/R", "IF2 ADC4 Mux" },
3199
3200 { "IF2 ADC", NULL, "IF2 ADC1 Swap Mux" },
3201 { "IF2 ADC", NULL, "IF2 ADC2 Swap Mux" },
3202 { "IF2 ADC", NULL, "IF2 ADC3 Swap Mux" },
3203 { "IF2 ADC", NULL, "IF2 ADC4 Swap Mux" },
3204
3205 { "IF2 ADC TDM Swap Mux", "1/2/3/4", "IF2 ADC" },
3206 { "IF2 ADC TDM Swap Mux", "2/1/3/4", "IF2 ADC" },
3207 { "IF2 ADC TDM Swap Mux", "3/1/2/4", "IF2 ADC" },
3208 { "IF2 ADC TDM Swap Mux", "4/1/2/3", "IF2 ADC" },
3209 { "IF2 ADC TDM Swap Mux", "1/3/2/4", "IF2 ADC" },
3210 { "IF2 ADC TDM Swap Mux", "1/4/2/3", "IF2 ADC" },
3211 { "IF2 ADC TDM Swap Mux", "2/3/1/4", "IF2 ADC" },
3212 { "IF2 ADC TDM Swap Mux", "3/4/1/2", "IF2 ADC" },
3213
Oder Chiou0e826e82014-05-26 20:32:33 +08003214 { "AIF2TX", NULL, "I2S2" },
Oder Chioue6f6ebc2014-10-22 16:11:39 +08003215 { "AIF2TX", NULL, "IF2 ADC TDM Swap Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003216
3217 { "IF3 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3218 { "IF3 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3219 { "IF3 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3220 { "IF3 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3221 { "IF3 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
3222 { "IF3 ADC Mux", "OB01", "OB01 Bypass Mux" },
3223 { "IF3 ADC Mux", "OB23", "OB23 Bypass Mux" },
3224 { "IF3 ADC Mux", "VAD ADC", "VAD ADC Mux" },
3225
3226 { "AIF3TX", NULL, "I2S3" },
3227 { "AIF3TX", NULL, "IF3 ADC Mux" },
3228
3229 { "IF4 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3230 { "IF4 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3231 { "IF4 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3232 { "IF4 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3233 { "IF4 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
3234 { "IF4 ADC Mux", "OB01", "OB01 Bypass Mux" },
3235 { "IF4 ADC Mux", "OB23", "OB23 Bypass Mux" },
3236 { "IF4 ADC Mux", "VAD ADC", "VAD ADC Mux" },
3237
3238 { "AIF4TX", NULL, "I2S4" },
3239 { "AIF4TX", NULL, "IF4 ADC Mux" },
3240
3241 { "SLB ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3242 { "SLB ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3243 { "SLB ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3244
3245 { "SLB ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3246 { "SLB ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3247
3248 { "SLB ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3249 { "SLB ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3250 { "SLB ADC3 Mux", "OB45", "OB45" },
3251
3252 { "SLB ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3253 { "SLB ADC4 Mux", "OB67", "OB67" },
3254 { "SLB ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3255
3256 { "SLBTX", NULL, "SLB" },
3257 { "SLBTX", NULL, "SLB ADC1 Mux" },
3258 { "SLBTX", NULL, "SLB ADC2 Mux" },
3259 { "SLBTX", NULL, "SLB ADC3 Mux" },
3260 { "SLBTX", NULL, "SLB ADC4 Mux" },
3261
3262 { "IB01 Mux", "IF1 DAC 01", "IF1 DAC01" },
3263 { "IB01 Mux", "IF2 DAC 01", "IF2 DAC01" },
3264 { "IB01 Mux", "SLB DAC 01", "SLB DAC01" },
3265 { "IB01 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3266 { "IB01 Mux", "VAD ADC/DAC1 FS", "DAC1 FS" },
3267
3268 { "IB01 Bypass Mux", "Bypass", "IB01 Mux" },
3269 { "IB01 Bypass Mux", "Pass SRC", "IB01 Mux" },
3270
3271 { "IB23 Mux", "IF1 DAC 23", "IF1 DAC23" },
3272 { "IB23 Mux", "IF2 DAC 23", "IF2 DAC23" },
3273 { "IB23 Mux", "SLB DAC 23", "SLB DAC23" },
3274 { "IB23 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3275 { "IB23 Mux", "DAC1 FS", "DAC1 FS" },
3276 { "IB23 Mux", "IF4 DAC", "IF4 DAC" },
3277
3278 { "IB23 Bypass Mux", "Bypass", "IB23 Mux" },
3279 { "IB23 Bypass Mux", "Pass SRC", "IB23 Mux" },
3280
3281 { "IB45 Mux", "IF1 DAC 45", "IF1 DAC45" },
3282 { "IB45 Mux", "IF2 DAC 45", "IF2 DAC45" },
3283 { "IB45 Mux", "SLB DAC 45", "SLB DAC45" },
3284 { "IB45 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3285 { "IB45 Mux", "IF3 DAC", "IF3 DAC" },
3286
3287 { "IB45 Bypass Mux", "Bypass", "IB45 Mux" },
3288 { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" },
3289
3290 { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6" },
3291 { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6" },
3292 { "IB6 Mux", "SLB DAC 6", "SLB DAC6" },
3293 { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3294 { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" },
3295 { "IB6 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3296 { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3297 { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3298
3299 { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7" },
3300 { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7" },
3301 { "IB7 Mux", "SLB DAC 7", "SLB DAC7" },
3302 { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3303 { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" },
3304 { "IB7 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
3305 { "IB7 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
3306 { "IB7 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
3307
3308 { "IB8 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3309 { "IB8 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3310 { "IB8 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3311 { "IB8 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3312 { "IB8 Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
3313 { "IB8 Mux", "DACL1 FS", "DAC1 MIXL" },
3314
3315 { "IB9 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
3316 { "IB9 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
3317 { "IB9 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
3318 { "IB9 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3319 { "IB9 Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
3320 { "IB9 Mux", "DACR1 FS", "DAC1 MIXR" },
3321 { "IB9 Mux", "DAC1 FS", "DAC1 FS" },
3322
3323 { "OB01 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3324 { "OB01 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3325 { "OB01 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3326 { "OB01 MIX", "IB6 Switch", "IB6 Mux" },
3327 { "OB01 MIX", "IB7 Switch", "IB7 Mux" },
3328 { "OB01 MIX", "IB8 Switch", "IB8 Mux" },
3329 { "OB01 MIX", "IB9 Switch", "IB9 Mux" },
3330
3331 { "OB23 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3332 { "OB23 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3333 { "OB23 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3334 { "OB23 MIX", "IB6 Switch", "IB6 Mux" },
3335 { "OB23 MIX", "IB7 Switch", "IB7 Mux" },
3336 { "OB23 MIX", "IB8 Switch", "IB8 Mux" },
3337 { "OB23 MIX", "IB9 Switch", "IB9 Mux" },
3338
3339 { "OB4 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3340 { "OB4 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3341 { "OB4 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3342 { "OB4 MIX", "IB6 Switch", "IB6 Mux" },
3343 { "OB4 MIX", "IB7 Switch", "IB7 Mux" },
3344 { "OB4 MIX", "IB8 Switch", "IB8 Mux" },
3345 { "OB4 MIX", "IB9 Switch", "IB9 Mux" },
3346
3347 { "OB5 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3348 { "OB5 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3349 { "OB5 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3350 { "OB5 MIX", "IB6 Switch", "IB6 Mux" },
3351 { "OB5 MIX", "IB7 Switch", "IB7 Mux" },
3352 { "OB5 MIX", "IB8 Switch", "IB8 Mux" },
3353 { "OB5 MIX", "IB9 Switch", "IB9 Mux" },
3354
3355 { "OB6 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3356 { "OB6 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3357 { "OB6 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3358 { "OB6 MIX", "IB6 Switch", "IB6 Mux" },
3359 { "OB6 MIX", "IB7 Switch", "IB7 Mux" },
3360 { "OB6 MIX", "IB8 Switch", "IB8 Mux" },
3361 { "OB6 MIX", "IB9 Switch", "IB9 Mux" },
3362
3363 { "OB7 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3364 { "OB7 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3365 { "OB7 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3366 { "OB7 MIX", "IB6 Switch", "IB6 Mux" },
3367 { "OB7 MIX", "IB7 Switch", "IB7 Mux" },
3368 { "OB7 MIX", "IB8 Switch", "IB8 Mux" },
3369 { "OB7 MIX", "IB9 Switch", "IB9 Mux" },
3370
3371 { "OB01 Bypass Mux", "Bypass", "OB01 MIX" },
3372 { "OB01 Bypass Mux", "Pass SRC", "OB01 MIX" },
3373 { "OB23 Bypass Mux", "Bypass", "OB23 MIX" },
3374 { "OB23 Bypass Mux", "Pass SRC", "OB23 MIX" },
3375
3376 { "OutBound2", NULL, "OB23 Bypass Mux" },
3377 { "OutBound3", NULL, "OB23 Bypass Mux" },
3378 { "OutBound4", NULL, "OB4 MIX" },
3379 { "OutBound5", NULL, "OB5 MIX" },
3380 { "OutBound6", NULL, "OB6 MIX" },
3381 { "OutBound7", NULL, "OB7 MIX" },
3382
3383 { "OB45", NULL, "OutBound4" },
3384 { "OB45", NULL, "OutBound5" },
3385 { "OB67", NULL, "OutBound6" },
3386 { "OB67", NULL, "OutBound7" },
3387
3388 { "IF1 DAC0", NULL, "AIF1RX" },
3389 { "IF1 DAC1", NULL, "AIF1RX" },
3390 { "IF1 DAC2", NULL, "AIF1RX" },
3391 { "IF1 DAC3", NULL, "AIF1RX" },
3392 { "IF1 DAC4", NULL, "AIF1RX" },
3393 { "IF1 DAC5", NULL, "AIF1RX" },
3394 { "IF1 DAC6", NULL, "AIF1RX" },
3395 { "IF1 DAC7", NULL, "AIF1RX" },
3396 { "IF1 DAC0", NULL, "I2S1" },
3397 { "IF1 DAC1", NULL, "I2S1" },
3398 { "IF1 DAC2", NULL, "I2S1" },
3399 { "IF1 DAC3", NULL, "I2S1" },
3400 { "IF1 DAC4", NULL, "I2S1" },
3401 { "IF1 DAC5", NULL, "I2S1" },
3402 { "IF1 DAC6", NULL, "I2S1" },
3403 { "IF1 DAC7", NULL, "I2S1" },
3404
Oder Chiou91159ec2014-11-11 15:31:19 +08003405 { "IF1 DAC0 Mux", "Slot0", "IF1 DAC0" },
3406 { "IF1 DAC0 Mux", "Slot1", "IF1 DAC1" },
3407 { "IF1 DAC0 Mux", "Slot2", "IF1 DAC2" },
3408 { "IF1 DAC0 Mux", "Slot3", "IF1 DAC3" },
3409 { "IF1 DAC0 Mux", "Slot4", "IF1 DAC4" },
3410 { "IF1 DAC0 Mux", "Slot5", "IF1 DAC5" },
3411 { "IF1 DAC0 Mux", "Slot6", "IF1 DAC6" },
3412 { "IF1 DAC0 Mux", "Slot7", "IF1 DAC7" },
3413
3414 { "IF1 DAC1 Mux", "Slot0", "IF1 DAC0" },
3415 { "IF1 DAC1 Mux", "Slot1", "IF1 DAC1" },
3416 { "IF1 DAC1 Mux", "Slot2", "IF1 DAC2" },
3417 { "IF1 DAC1 Mux", "Slot3", "IF1 DAC3" },
3418 { "IF1 DAC1 Mux", "Slot4", "IF1 DAC4" },
3419 { "IF1 DAC1 Mux", "Slot5", "IF1 DAC5" },
3420 { "IF1 DAC1 Mux", "Slot6", "IF1 DAC6" },
3421 { "IF1 DAC1 Mux", "Slot7", "IF1 DAC7" },
3422
3423 { "IF1 DAC2 Mux", "Slot0", "IF1 DAC0" },
3424 { "IF1 DAC2 Mux", "Slot1", "IF1 DAC1" },
3425 { "IF1 DAC2 Mux", "Slot2", "IF1 DAC2" },
3426 { "IF1 DAC2 Mux", "Slot3", "IF1 DAC3" },
3427 { "IF1 DAC2 Mux", "Slot4", "IF1 DAC4" },
3428 { "IF1 DAC2 Mux", "Slot5", "IF1 DAC5" },
3429 { "IF1 DAC2 Mux", "Slot6", "IF1 DAC6" },
3430 { "IF1 DAC2 Mux", "Slot7", "IF1 DAC7" },
3431
3432 { "IF1 DAC3 Mux", "Slot0", "IF1 DAC0" },
3433 { "IF1 DAC3 Mux", "Slot1", "IF1 DAC1" },
3434 { "IF1 DAC3 Mux", "Slot2", "IF1 DAC2" },
3435 { "IF1 DAC3 Mux", "Slot3", "IF1 DAC3" },
3436 { "IF1 DAC3 Mux", "Slot4", "IF1 DAC4" },
3437 { "IF1 DAC3 Mux", "Slot5", "IF1 DAC5" },
3438 { "IF1 DAC3 Mux", "Slot6", "IF1 DAC6" },
3439 { "IF1 DAC3 Mux", "Slot7", "IF1 DAC7" },
3440
3441 { "IF1 DAC4 Mux", "Slot0", "IF1 DAC0" },
3442 { "IF1 DAC4 Mux", "Slot1", "IF1 DAC1" },
3443 { "IF1 DAC4 Mux", "Slot2", "IF1 DAC2" },
3444 { "IF1 DAC4 Mux", "Slot3", "IF1 DAC3" },
3445 { "IF1 DAC4 Mux", "Slot4", "IF1 DAC4" },
3446 { "IF1 DAC4 Mux", "Slot5", "IF1 DAC5" },
3447 { "IF1 DAC4 Mux", "Slot6", "IF1 DAC6" },
3448 { "IF1 DAC4 Mux", "Slot7", "IF1 DAC7" },
3449
3450 { "IF1 DAC5 Mux", "Slot0", "IF1 DAC0" },
3451 { "IF1 DAC5 Mux", "Slot1", "IF1 DAC1" },
3452 { "IF1 DAC5 Mux", "Slot2", "IF1 DAC2" },
3453 { "IF1 DAC5 Mux", "Slot3", "IF1 DAC3" },
3454 { "IF1 DAC5 Mux", "Slot4", "IF1 DAC4" },
3455 { "IF1 DAC5 Mux", "Slot5", "IF1 DAC5" },
3456 { "IF1 DAC5 Mux", "Slot6", "IF1 DAC6" },
3457 { "IF1 DAC5 Mux", "Slot7", "IF1 DAC7" },
3458
3459 { "IF1 DAC6 Mux", "Slot0", "IF1 DAC0" },
3460 { "IF1 DAC6 Mux", "Slot1", "IF1 DAC1" },
3461 { "IF1 DAC6 Mux", "Slot2", "IF1 DAC2" },
3462 { "IF1 DAC6 Mux", "Slot3", "IF1 DAC3" },
3463 { "IF1 DAC6 Mux", "Slot4", "IF1 DAC4" },
3464 { "IF1 DAC6 Mux", "Slot5", "IF1 DAC5" },
3465 { "IF1 DAC6 Mux", "Slot6", "IF1 DAC6" },
3466 { "IF1 DAC6 Mux", "Slot7", "IF1 DAC7" },
3467
3468 { "IF1 DAC7 Mux", "Slot0", "IF1 DAC0" },
3469 { "IF1 DAC7 Mux", "Slot1", "IF1 DAC1" },
3470 { "IF1 DAC7 Mux", "Slot2", "IF1 DAC2" },
3471 { "IF1 DAC7 Mux", "Slot3", "IF1 DAC3" },
3472 { "IF1 DAC7 Mux", "Slot4", "IF1 DAC4" },
3473 { "IF1 DAC7 Mux", "Slot5", "IF1 DAC5" },
3474 { "IF1 DAC7 Mux", "Slot6", "IF1 DAC6" },
3475 { "IF1 DAC7 Mux", "Slot7", "IF1 DAC7" },
3476
3477 { "IF1 DAC01", NULL, "IF1 DAC0 Mux" },
3478 { "IF1 DAC01", NULL, "IF1 DAC1 Mux" },
3479 { "IF1 DAC23", NULL, "IF1 DAC2 Mux" },
3480 { "IF1 DAC23", NULL, "IF1 DAC3 Mux" },
3481 { "IF1 DAC45", NULL, "IF1 DAC4 Mux" },
3482 { "IF1 DAC45", NULL, "IF1 DAC5 Mux" },
3483 { "IF1 DAC67", NULL, "IF1 DAC6 Mux" },
3484 { "IF1 DAC67", NULL, "IF1 DAC7 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003485
3486 { "IF2 DAC0", NULL, "AIF2RX" },
3487 { "IF2 DAC1", NULL, "AIF2RX" },
3488 { "IF2 DAC2", NULL, "AIF2RX" },
3489 { "IF2 DAC3", NULL, "AIF2RX" },
3490 { "IF2 DAC4", NULL, "AIF2RX" },
3491 { "IF2 DAC5", NULL, "AIF2RX" },
3492 { "IF2 DAC6", NULL, "AIF2RX" },
3493 { "IF2 DAC7", NULL, "AIF2RX" },
3494 { "IF2 DAC0", NULL, "I2S2" },
3495 { "IF2 DAC1", NULL, "I2S2" },
3496 { "IF2 DAC2", NULL, "I2S2" },
3497 { "IF2 DAC3", NULL, "I2S2" },
3498 { "IF2 DAC4", NULL, "I2S2" },
3499 { "IF2 DAC5", NULL, "I2S2" },
3500 { "IF2 DAC6", NULL, "I2S2" },
3501 { "IF2 DAC7", NULL, "I2S2" },
3502
Oder Chiou91159ec2014-11-11 15:31:19 +08003503 { "IF2 DAC0 Mux", "Slot0", "IF2 DAC0" },
3504 { "IF2 DAC0 Mux", "Slot1", "IF2 DAC1" },
3505 { "IF2 DAC0 Mux", "Slot2", "IF2 DAC2" },
3506 { "IF2 DAC0 Mux", "Slot3", "IF2 DAC3" },
3507 { "IF2 DAC0 Mux", "Slot4", "IF2 DAC4" },
3508 { "IF2 DAC0 Mux", "Slot5", "IF2 DAC5" },
3509 { "IF2 DAC0 Mux", "Slot6", "IF2 DAC6" },
3510 { "IF2 DAC0 Mux", "Slot7", "IF2 DAC7" },
3511
3512 { "IF2 DAC1 Mux", "Slot0", "IF2 DAC0" },
3513 { "IF2 DAC1 Mux", "Slot1", "IF2 DAC1" },
3514 { "IF2 DAC1 Mux", "Slot2", "IF2 DAC2" },
3515 { "IF2 DAC1 Mux", "Slot3", "IF2 DAC3" },
3516 { "IF2 DAC1 Mux", "Slot4", "IF2 DAC4" },
3517 { "IF2 DAC1 Mux", "Slot5", "IF2 DAC5" },
3518 { "IF2 DAC1 Mux", "Slot6", "IF2 DAC6" },
3519 { "IF2 DAC1 Mux", "Slot7", "IF2 DAC7" },
3520
3521 { "IF2 DAC2 Mux", "Slot0", "IF2 DAC0" },
3522 { "IF2 DAC2 Mux", "Slot1", "IF2 DAC1" },
3523 { "IF2 DAC2 Mux", "Slot2", "IF2 DAC2" },
3524 { "IF2 DAC2 Mux", "Slot3", "IF2 DAC3" },
3525 { "IF2 DAC2 Mux", "Slot4", "IF2 DAC4" },
3526 { "IF2 DAC2 Mux", "Slot5", "IF2 DAC5" },
3527 { "IF2 DAC2 Mux", "Slot6", "IF2 DAC6" },
3528 { "IF2 DAC2 Mux", "Slot7", "IF2 DAC7" },
3529
3530 { "IF2 DAC3 Mux", "Slot0", "IF2 DAC0" },
3531 { "IF2 DAC3 Mux", "Slot1", "IF2 DAC1" },
3532 { "IF2 DAC3 Mux", "Slot2", "IF2 DAC2" },
3533 { "IF2 DAC3 Mux", "Slot3", "IF2 DAC3" },
3534 { "IF2 DAC3 Mux", "Slot4", "IF2 DAC4" },
3535 { "IF2 DAC3 Mux", "Slot5", "IF2 DAC5" },
3536 { "IF2 DAC3 Mux", "Slot6", "IF2 DAC6" },
3537 { "IF2 DAC3 Mux", "Slot7", "IF2 DAC7" },
3538
3539 { "IF2 DAC4 Mux", "Slot0", "IF2 DAC0" },
3540 { "IF2 DAC4 Mux", "Slot1", "IF2 DAC1" },
3541 { "IF2 DAC4 Mux", "Slot2", "IF2 DAC2" },
3542 { "IF2 DAC4 Mux", "Slot3", "IF2 DAC3" },
3543 { "IF2 DAC4 Mux", "Slot4", "IF2 DAC4" },
3544 { "IF2 DAC4 Mux", "Slot5", "IF2 DAC5" },
3545 { "IF2 DAC4 Mux", "Slot6", "IF2 DAC6" },
3546 { "IF2 DAC4 Mux", "Slot7", "IF2 DAC7" },
3547
3548 { "IF2 DAC5 Mux", "Slot0", "IF2 DAC0" },
3549 { "IF2 DAC5 Mux", "Slot1", "IF2 DAC1" },
3550 { "IF2 DAC5 Mux", "Slot2", "IF2 DAC2" },
3551 { "IF2 DAC5 Mux", "Slot3", "IF2 DAC3" },
3552 { "IF2 DAC5 Mux", "Slot4", "IF2 DAC4" },
3553 { "IF2 DAC5 Mux", "Slot5", "IF2 DAC5" },
3554 { "IF2 DAC5 Mux", "Slot6", "IF2 DAC6" },
3555 { "IF2 DAC5 Mux", "Slot7", "IF2 DAC7" },
3556
3557 { "IF2 DAC6 Mux", "Slot0", "IF2 DAC0" },
3558 { "IF2 DAC6 Mux", "Slot1", "IF2 DAC1" },
3559 { "IF2 DAC6 Mux", "Slot2", "IF2 DAC2" },
3560 { "IF2 DAC6 Mux", "Slot3", "IF2 DAC3" },
3561 { "IF2 DAC6 Mux", "Slot4", "IF2 DAC4" },
3562 { "IF2 DAC6 Mux", "Slot5", "IF2 DAC5" },
3563 { "IF2 DAC6 Mux", "Slot6", "IF2 DAC6" },
3564 { "IF2 DAC6 Mux", "Slot7", "IF2 DAC7" },
3565
3566 { "IF2 DAC7 Mux", "Slot0", "IF2 DAC0" },
3567 { "IF2 DAC7 Mux", "Slot1", "IF2 DAC1" },
3568 { "IF2 DAC7 Mux", "Slot2", "IF2 DAC2" },
3569 { "IF2 DAC7 Mux", "Slot3", "IF2 DAC3" },
3570 { "IF2 DAC7 Mux", "Slot4", "IF2 DAC4" },
3571 { "IF2 DAC7 Mux", "Slot5", "IF2 DAC5" },
3572 { "IF2 DAC7 Mux", "Slot6", "IF2 DAC6" },
3573 { "IF2 DAC7 Mux", "Slot7", "IF2 DAC7" },
3574
3575 { "IF2 DAC01", NULL, "IF2 DAC0 Mux" },
3576 { "IF2 DAC01", NULL, "IF2 DAC1 Mux" },
3577 { "IF2 DAC23", NULL, "IF2 DAC2 Mux" },
3578 { "IF2 DAC23", NULL, "IF2 DAC3 Mux" },
3579 { "IF2 DAC45", NULL, "IF2 DAC4 Mux" },
3580 { "IF2 DAC45", NULL, "IF2 DAC5 Mux" },
3581 { "IF2 DAC67", NULL, "IF2 DAC6 Mux" },
3582 { "IF2 DAC67", NULL, "IF2 DAC7 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003583
3584 { "IF3 DAC", NULL, "AIF3RX" },
3585 { "IF3 DAC", NULL, "I2S3" },
3586
3587 { "IF4 DAC", NULL, "AIF4RX" },
3588 { "IF4 DAC", NULL, "I2S4" },
3589
3590 { "IF3 DAC L", NULL, "IF3 DAC" },
3591 { "IF3 DAC R", NULL, "IF3 DAC" },
3592
3593 { "IF4 DAC L", NULL, "IF4 DAC" },
3594 { "IF4 DAC R", NULL, "IF4 DAC" },
3595
3596 { "SLB DAC0", NULL, "SLBRX" },
3597 { "SLB DAC1", NULL, "SLBRX" },
3598 { "SLB DAC2", NULL, "SLBRX" },
3599 { "SLB DAC3", NULL, "SLBRX" },
3600 { "SLB DAC4", NULL, "SLBRX" },
3601 { "SLB DAC5", NULL, "SLBRX" },
3602 { "SLB DAC6", NULL, "SLBRX" },
3603 { "SLB DAC7", NULL, "SLBRX" },
3604 { "SLB DAC0", NULL, "SLB" },
3605 { "SLB DAC1", NULL, "SLB" },
3606 { "SLB DAC2", NULL, "SLB" },
3607 { "SLB DAC3", NULL, "SLB" },
3608 { "SLB DAC4", NULL, "SLB" },
3609 { "SLB DAC5", NULL, "SLB" },
3610 { "SLB DAC6", NULL, "SLB" },
3611 { "SLB DAC7", NULL, "SLB" },
3612
3613 { "SLB DAC01", NULL, "SLB DAC0" },
3614 { "SLB DAC01", NULL, "SLB DAC1" },
3615 { "SLB DAC23", NULL, "SLB DAC2" },
3616 { "SLB DAC23", NULL, "SLB DAC3" },
3617 { "SLB DAC45", NULL, "SLB DAC4" },
3618 { "SLB DAC45", NULL, "SLB DAC5" },
3619 { "SLB DAC67", NULL, "SLB DAC6" },
3620 { "SLB DAC67", NULL, "SLB DAC7" },
3621
3622 { "ADDA1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3623 { "ADDA1 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3624 { "ADDA1 Mux", "OB 67", "OB67" },
3625
3626 { "DAC1 Mux", "IF1 DAC 01", "IF1 DAC01" },
3627 { "DAC1 Mux", "IF2 DAC 01", "IF2 DAC01" },
3628 { "DAC1 Mux", "IF3 DAC LR", "IF3 DAC" },
3629 { "DAC1 Mux", "IF4 DAC LR", "IF4 DAC" },
3630 { "DAC1 Mux", "SLB DAC 01", "SLB DAC01" },
3631 { "DAC1 Mux", "OB 01", "OB01 Bypass Mux" },
3632
3633 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" },
3634 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003635 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" },
3636 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003637
3638 { "DAC1 FS", NULL, "DAC1 MIXL" },
3639 { "DAC1 FS", NULL, "DAC1 MIXR" },
3640
3641 { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2" },
3642 { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2" },
3643 { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" },
3644 { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" },
3645 { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" },
3646 { "DAC2 L Mux", "OB 2", "OutBound2" },
3647
3648 { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3" },
3649 { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3" },
3650 { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" },
3651 { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" },
3652 { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" },
3653 { "DAC2 R Mux", "OB 3", "OutBound3" },
3654 { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" },
3655 { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" },
3656
3657 { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4" },
3658 { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4" },
3659 { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" },
3660 { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" },
3661 { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" },
3662 { "DAC3 L Mux", "OB 4", "OutBound4" },
3663
3664 { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC4" },
3665 { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC4" },
3666 { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" },
3667 { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" },
3668 { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" },
3669 { "DAC3 R Mux", "OB 5", "OutBound5" },
3670
3671 { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6" },
3672 { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6" },
3673 { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" },
3674 { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" },
3675 { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" },
3676 { "DAC4 L Mux", "OB 6", "OutBound6" },
3677
3678 { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7" },
3679 { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7" },
3680 { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" },
3681 { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" },
3682 { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" },
3683 { "DAC4 R Mux", "OB 7", "OutBound7" },
3684
3685 { "Sidetone Mux", "DMIC1 L", "DMIC L1" },
3686 { "Sidetone Mux", "DMIC2 L", "DMIC L2" },
3687 { "Sidetone Mux", "DMIC3 L", "DMIC L3" },
3688 { "Sidetone Mux", "DMIC4 L", "DMIC L4" },
3689 { "Sidetone Mux", "ADC1", "ADC 1" },
3690 { "Sidetone Mux", "ADC2", "ADC 2" },
Oder Chiou90bdbb42014-09-18 14:45:59 +08003691 { "Sidetone Mux", NULL, "Sidetone Power" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003692
3693 { "Stereo DAC MIXL", "ST L Switch", "Sidetone Mux" },
3694 { "Stereo DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3695 { "Stereo DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3696 { "Stereo DAC MIXL", "DAC1 R Switch", "DAC1 MIXR" },
3697 { "Stereo DAC MIXL", NULL, "dac stereo1 filter" },
3698 { "Stereo DAC MIXR", "ST R Switch", "Sidetone Mux" },
3699 { "Stereo DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3700 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3701 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" },
3702 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003703 { "dac stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003704
3705 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" },
3706 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3707 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3708 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003709 { "Mono DAC MIXL", NULL, "dac mono2 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003710 { "dac mono2 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003711 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" },
3712 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3713 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3714 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003715 { "Mono DAC MIXR", NULL, "dac mono2 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003716 { "dac mono2 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003717
3718 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3719 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3720 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" },
3721 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003722 { "DD1 MIXL", NULL, "dac mono3 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003723 { "dac mono3 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003724 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3725 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3726 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" },
3727 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003728 { "DD1 MIXR", NULL, "dac mono3 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003729 { "dac mono3 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003730
3731 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3732 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3733 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" },
3734 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003735 { "DD2 MIXL", NULL, "dac mono4 left filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003736 { "dac mono4 left filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003737 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3738 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3739 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" },
3740 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" },
Oder Chiou6800b5b2014-12-23 10:27:54 +08003741 { "DD2 MIXR", NULL, "dac mono4 right filter" },
Oder Chiou38d595e2014-12-23 10:27:56 +08003742 { "dac mono4 right filter", NULL, "PLL1", is_sys_clk_from_pll },
Oder Chiou0e826e82014-05-26 20:32:33 +08003743
3744 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" },
3745 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" },
3746 { "Mono DAC MIX", NULL, "Mono DAC MIXL" },
3747 { "Mono DAC MIX", NULL, "Mono DAC MIXR" },
3748 { "DD1 MIX", NULL, "DD1 MIXL" },
3749 { "DD1 MIX", NULL, "DD1 MIXR" },
3750 { "DD2 MIX", NULL, "DD2 MIXL" },
3751 { "DD2 MIX", NULL, "DD2 MIXR" },
3752
3753 { "DAC12 SRC Mux", "STO1 DAC MIX", "Stereo DAC MIX" },
3754 { "DAC12 SRC Mux", "MONO DAC MIX", "Mono DAC MIX" },
3755 { "DAC12 SRC Mux", "DD MIX1", "DD1 MIX" },
3756 { "DAC12 SRC Mux", "DD MIX2", "DD2 MIX" },
3757
3758 { "DAC3 SRC Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3759 { "DAC3 SRC Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3760 { "DAC3 SRC Mux", "DD MIX1L", "DD1 MIXL" },
3761 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" },
3762
3763 { "DAC 1", NULL, "DAC12 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003764 { "DAC 2", NULL, "DAC12 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003765 { "DAC 3", NULL, "DAC3 SRC Mux" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003766
3767 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
3768 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
3769 { "PDM1 L Mux", "DD MIX1", "DD1 MIXL" },
3770 { "PDM1 L Mux", "DD MIX2", "DD2 MIXL" },
3771 { "PDM1 L Mux", NULL, "PDM1 Power" },
3772 { "PDM1 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
3773 { "PDM1 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
3774 { "PDM1 R Mux", "DD MIX1", "DD1 MIXR" },
3775 { "PDM1 R Mux", "DD MIX2", "DD2 MIXR" },
3776 { "PDM1 R Mux", NULL, "PDM1 Power" },
3777 { "PDM2 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
3778 { "PDM2 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
3779 { "PDM2 L Mux", "DD MIX1", "DD1 MIXL" },
3780 { "PDM2 L Mux", "DD MIX2", "DD2 MIXL" },
3781 { "PDM2 L Mux", NULL, "PDM2 Power" },
3782 { "PDM2 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
3783 { "PDM2 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
3784 { "PDM2 R Mux", "DD MIX1", "DD1 MIXR" },
3785 { "PDM2 R Mux", "DD MIX1", "DD2 MIXR" },
3786 { "PDM2 R Mux", NULL, "PDM2 Power" },
3787
3788 { "LOUT1 amp", NULL, "DAC 1" },
3789 { "LOUT2 amp", NULL, "DAC 2" },
3790 { "LOUT3 amp", NULL, "DAC 3" },
3791
Oder Chiou683996c2014-11-19 13:52:20 +08003792 { "LOUT1 vref", NULL, "LOUT1 amp" },
3793 { "LOUT2 vref", NULL, "LOUT2 amp" },
3794 { "LOUT3 vref", NULL, "LOUT3 amp" },
3795
3796 { "LOUT1", NULL, "LOUT1 vref" },
3797 { "LOUT2", NULL, "LOUT2 vref" },
3798 { "LOUT3", NULL, "LOUT3 vref" },
Oder Chiou0e826e82014-05-26 20:32:33 +08003799
3800 { "PDM1L", NULL, "PDM1 L Mux" },
3801 { "PDM1R", NULL, "PDM1 R Mux" },
3802 { "PDM2L", NULL, "PDM2 L Mux" },
3803 { "PDM2R", NULL, "PDM2 R Mux" },
3804};
3805
Bard Liao2d15d972014-08-27 19:50:34 +08003806static const struct snd_soc_dapm_route rt5677_dmic2_clk_1[] = {
3807 { "DMIC L2", NULL, "DMIC1 power" },
3808 { "DMIC R2", NULL, "DMIC1 power" },
3809};
3810
3811static const struct snd_soc_dapm_route rt5677_dmic2_clk_2[] = {
3812 { "DMIC L2", NULL, "DMIC2 power" },
3813 { "DMIC R2", NULL, "DMIC2 power" },
3814};
3815
Oder Chiou0e826e82014-05-26 20:32:33 +08003816static int rt5677_hw_params(struct snd_pcm_substream *substream,
3817 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
3818{
3819 struct snd_soc_codec *codec = dai->codec;
3820 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3821 unsigned int val_len = 0, val_clk, mask_clk;
3822 int pre_div, bclk_ms, frame_size;
3823
3824 rt5677->lrck[dai->id] = params_rate(params);
Axel Lin30f14b42014-06-10 08:57:36 +08003825 pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]);
Oder Chiou0e826e82014-05-26 20:32:33 +08003826 if (pre_div < 0) {
Anatol Pomozov8a4bd602014-10-15 13:55:32 -07003827 dev_err(codec->dev, "Unsupported clock setting: sysclk=%dHz lrck=%dHz\n",
3828 rt5677->sysclk, rt5677->lrck[dai->id]);
Oder Chiou0e826e82014-05-26 20:32:33 +08003829 return -EINVAL;
3830 }
3831 frame_size = snd_soc_params_to_frame_size(params);
3832 if (frame_size < 0) {
3833 dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
3834 return -EINVAL;
3835 }
3836 bclk_ms = frame_size > 32;
3837 rt5677->bclk[dai->id] = rt5677->lrck[dai->id] * (32 << bclk_ms);
3838
3839 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n",
3840 rt5677->bclk[dai->id], rt5677->lrck[dai->id]);
3841 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n",
3842 bclk_ms, pre_div, dai->id);
3843
3844 switch (params_width(params)) {
3845 case 16:
3846 break;
3847 case 20:
3848 val_len |= RT5677_I2S_DL_20;
3849 break;
3850 case 24:
3851 val_len |= RT5677_I2S_DL_24;
3852 break;
3853 case 8:
3854 val_len |= RT5677_I2S_DL_8;
3855 break;
3856 default:
3857 return -EINVAL;
3858 }
3859
3860 switch (dai->id) {
3861 case RT5677_AIF1:
3862 mask_clk = RT5677_I2S_PD1_MASK;
3863 val_clk = pre_div << RT5677_I2S_PD1_SFT;
3864 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
3865 RT5677_I2S_DL_MASK, val_len);
3866 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3867 mask_clk, val_clk);
3868 break;
3869 case RT5677_AIF2:
3870 mask_clk = RT5677_I2S_PD2_MASK;
3871 val_clk = pre_div << RT5677_I2S_PD2_SFT;
3872 regmap_update_bits(rt5677->regmap, RT5677_I2S2_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 case RT5677_AIF3:
3878 mask_clk = RT5677_I2S_BCLK_MS3_MASK | RT5677_I2S_PD3_MASK;
3879 val_clk = bclk_ms << RT5677_I2S_BCLK_MS3_SFT |
3880 pre_div << RT5677_I2S_PD3_SFT;
3881 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
3882 RT5677_I2S_DL_MASK, val_len);
3883 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3884 mask_clk, val_clk);
3885 break;
3886 case RT5677_AIF4:
3887 mask_clk = RT5677_I2S_BCLK_MS4_MASK | RT5677_I2S_PD4_MASK;
3888 val_clk = bclk_ms << RT5677_I2S_BCLK_MS4_SFT |
3889 pre_div << RT5677_I2S_PD4_SFT;
3890 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
3891 RT5677_I2S_DL_MASK, val_len);
3892 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3893 mask_clk, val_clk);
3894 break;
3895 default:
3896 break;
3897 }
3898
3899 return 0;
3900}
3901
3902static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
3903{
3904 struct snd_soc_codec *codec = dai->codec;
3905 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3906 unsigned int reg_val = 0;
3907
3908 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
3909 case SND_SOC_DAIFMT_CBM_CFM:
3910 rt5677->master[dai->id] = 1;
3911 break;
3912 case SND_SOC_DAIFMT_CBS_CFS:
3913 reg_val |= RT5677_I2S_MS_S;
3914 rt5677->master[dai->id] = 0;
3915 break;
3916 default:
3917 return -EINVAL;
3918 }
3919
3920 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
3921 case SND_SOC_DAIFMT_NB_NF:
3922 break;
3923 case SND_SOC_DAIFMT_IB_NF:
3924 reg_val |= RT5677_I2S_BP_INV;
3925 break;
3926 default:
3927 return -EINVAL;
3928 }
3929
3930 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
3931 case SND_SOC_DAIFMT_I2S:
3932 break;
3933 case SND_SOC_DAIFMT_LEFT_J:
3934 reg_val |= RT5677_I2S_DF_LEFT;
3935 break;
3936 case SND_SOC_DAIFMT_DSP_A:
3937 reg_val |= RT5677_I2S_DF_PCM_A;
3938 break;
3939 case SND_SOC_DAIFMT_DSP_B:
3940 reg_val |= RT5677_I2S_DF_PCM_B;
3941 break;
3942 default:
3943 return -EINVAL;
3944 }
3945
3946 switch (dai->id) {
3947 case RT5677_AIF1:
3948 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
3949 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3950 RT5677_I2S_DF_MASK, reg_val);
3951 break;
3952 case RT5677_AIF2:
3953 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
3954 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3955 RT5677_I2S_DF_MASK, reg_val);
3956 break;
3957 case RT5677_AIF3:
3958 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
3959 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3960 RT5677_I2S_DF_MASK, reg_val);
3961 break;
3962 case RT5677_AIF4:
3963 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
3964 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3965 RT5677_I2S_DF_MASK, reg_val);
3966 break;
3967 default:
3968 break;
3969 }
3970
3971
3972 return 0;
3973}
3974
3975static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai,
3976 int clk_id, unsigned int freq, int dir)
3977{
3978 struct snd_soc_codec *codec = dai->codec;
3979 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3980 unsigned int reg_val = 0;
3981
3982 if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src)
3983 return 0;
3984
3985 switch (clk_id) {
3986 case RT5677_SCLK_S_MCLK:
3987 reg_val |= RT5677_SCLK_SRC_MCLK;
3988 break;
3989 case RT5677_SCLK_S_PLL1:
3990 reg_val |= RT5677_SCLK_SRC_PLL1;
3991 break;
3992 case RT5677_SCLK_S_RCCLK:
3993 reg_val |= RT5677_SCLK_SRC_RCCLK;
3994 break;
3995 default:
3996 dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
3997 return -EINVAL;
3998 }
3999 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4000 RT5677_SCLK_SRC_MASK, reg_val);
4001 rt5677->sysclk = freq;
4002 rt5677->sysclk_src = clk_id;
4003
4004 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id);
4005
4006 return 0;
4007}
4008
4009/**
4010 * rt5677_pll_calc - Calcualte PLL M/N/K code.
4011 * @freq_in: external clock provided to codec.
4012 * @freq_out: target clock which codec works on.
4013 * @pll_code: Pointer to structure with M, N, K, bypass K and bypass M flag.
4014 *
4015 * Calcualte M/N/K code and bypass K/M flag to configure PLL for codec.
4016 *
4017 * Returns 0 for success or negative error code.
4018 */
4019static int rt5677_pll_calc(const unsigned int freq_in,
Axel Lin099d3342014-06-17 12:41:31 +08004020 const unsigned int freq_out, struct rl6231_pll_code *pll_code)
Oder Chiou0e826e82014-05-26 20:32:33 +08004021{
Axel Lin099d3342014-06-17 12:41:31 +08004022 if (RT5677_PLL_INP_MIN > freq_in)
Oder Chiou0e826e82014-05-26 20:32:33 +08004023 return -EINVAL;
4024
Axel Lin099d3342014-06-17 12:41:31 +08004025 return rl6231_pll_calc(freq_in, freq_out, pll_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004026}
4027
4028static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
4029 unsigned int freq_in, unsigned int freq_out)
4030{
4031 struct snd_soc_codec *codec = dai->codec;
4032 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Axel Lin099d3342014-06-17 12:41:31 +08004033 struct rl6231_pll_code pll_code;
Oder Chiou0e826e82014-05-26 20:32:33 +08004034 int ret;
4035
4036 if (source == rt5677->pll_src && freq_in == rt5677->pll_in &&
4037 freq_out == rt5677->pll_out)
4038 return 0;
4039
4040 if (!freq_in || !freq_out) {
4041 dev_dbg(codec->dev, "PLL disabled\n");
4042
4043 rt5677->pll_in = 0;
4044 rt5677->pll_out = 0;
4045 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4046 RT5677_SCLK_SRC_MASK, RT5677_SCLK_SRC_MCLK);
4047 return 0;
4048 }
4049
4050 switch (source) {
4051 case RT5677_PLL1_S_MCLK:
4052 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4053 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_MCLK);
4054 break;
4055 case RT5677_PLL1_S_BCLK1:
4056 case RT5677_PLL1_S_BCLK2:
4057 case RT5677_PLL1_S_BCLK3:
4058 case RT5677_PLL1_S_BCLK4:
4059 switch (dai->id) {
4060 case RT5677_AIF1:
4061 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4062 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK1);
4063 break;
4064 case RT5677_AIF2:
4065 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4066 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK2);
4067 break;
4068 case RT5677_AIF3:
4069 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4070 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK3);
4071 break;
4072 case RT5677_AIF4:
4073 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
4074 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK4);
4075 break;
4076 default:
4077 break;
4078 }
4079 break;
4080 default:
4081 dev_err(codec->dev, "Unknown PLL source %d\n", source);
4082 return -EINVAL;
4083 }
4084
4085 ret = rt5677_pll_calc(freq_in, freq_out, &pll_code);
4086 if (ret < 0) {
4087 dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
4088 return ret;
4089 }
4090
Axel Lin099d3342014-06-17 12:41:31 +08004091 dev_dbg(codec->dev, "m_bypass=%d m=%d n=%d k=%d\n",
4092 pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
4093 pll_code.n_code, pll_code.k_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004094
4095 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1,
Axel Lin099d3342014-06-17 12:41:31 +08004096 pll_code.n_code << RT5677_PLL_N_SFT | pll_code.k_code);
Oder Chiou0e826e82014-05-26 20:32:33 +08004097 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2,
4098 (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT |
4099 pll_code.m_bp << RT5677_PLL_M_BP_SFT);
4100
4101 rt5677->pll_in = freq_in;
4102 rt5677->pll_out = freq_out;
4103 rt5677->pll_src = source;
4104
4105 return 0;
4106}
4107
Oder Chiou48561af2014-09-17 15:12:33 +08004108static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
4109 unsigned int rx_mask, int slots, int slot_width)
4110{
4111 struct snd_soc_codec *codec = dai->codec;
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004112 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Oder Chiou9913b9f2015-01-13 11:13:15 +08004113 unsigned int val = 0, slot_width_25 = 0;
Oder Chiou48561af2014-09-17 15:12:33 +08004114
4115 if (rx_mask || tx_mask)
4116 val |= (1 << 12);
4117
4118 switch (slots) {
4119 case 4:
4120 val |= (1 << 10);
4121 break;
4122 case 6:
4123 val |= (2 << 10);
4124 break;
4125 case 8:
4126 val |= (3 << 10);
4127 break;
4128 case 2:
4129 default:
4130 break;
4131 }
4132
4133 switch (slot_width) {
4134 case 20:
4135 val |= (1 << 8);
4136 break;
Oder Chiou9913b9f2015-01-13 11:13:15 +08004137 case 25:
4138 slot_width_25 = 0x8080;
Oder Chiou48561af2014-09-17 15:12:33 +08004139 case 24:
4140 val |= (2 << 8);
4141 break;
4142 case 32:
4143 val |= (3 << 8);
4144 break;
4145 case 16:
4146 default:
4147 break;
4148 }
4149
4150 switch (dai->id) {
4151 case RT5677_AIF1:
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004152 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00,
4153 val);
Oder Chiou9913b9f2015-01-13 11:13:15 +08004154 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x8000,
4155 slot_width_25);
Oder Chiou48561af2014-09-17 15:12:33 +08004156 break;
4157 case RT5677_AIF2:
Oder Chioue4b7e6a2015-01-13 11:13:14 +08004158 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00,
4159 val);
Oder Chiou9913b9f2015-01-13 11:13:15 +08004160 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x80,
4161 slot_width_25);
Oder Chiou48561af2014-09-17 15:12:33 +08004162 break;
4163 default:
4164 break;
4165 }
4166
4167 return 0;
4168}
4169
Oder Chiou0e826e82014-05-26 20:32:33 +08004170static int rt5677_set_bias_level(struct snd_soc_codec *codec,
4171 enum snd_soc_bias_level level)
4172{
4173 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4174
4175 switch (level) {
4176 case SND_SOC_BIAS_ON:
4177 break;
4178
4179 case SND_SOC_BIAS_PREPARE:
4180 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) {
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004181 rt5677_set_dsp_vad(codec, false);
4182
Oder Chiou0e826e82014-05-26 20:32:33 +08004183 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
4184 RT5677_LDO1_SEL_MASK | RT5677_LDO2_SEL_MASK,
4185 0x0055);
4186 regmap_update_bits(rt5677->regmap,
4187 RT5677_PR_BASE + RT5677_BIAS_CUR4,
4188 0x0f00, 0x0f00);
4189 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
Oder Chiou683996c2014-11-19 13:52:20 +08004190 RT5677_PWR_FV1 | RT5677_PWR_FV2 |
Oder Chiou0e826e82014-05-26 20:32:33 +08004191 RT5677_PWR_VREF1 | RT5677_PWR_MB |
4192 RT5677_PWR_BG | RT5677_PWR_VREF2,
4193 RT5677_PWR_VREF1 | RT5677_PWR_MB |
4194 RT5677_PWR_BG | RT5677_PWR_VREF2);
Oder Chiou683996c2014-11-19 13:52:20 +08004195 rt5677->is_vref_slow = false;
Oder Chiou0e826e82014-05-26 20:32:33 +08004196 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
4197 RT5677_PWR_CORE, RT5677_PWR_CORE);
4198 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC,
4199 0x1, 0x1);
4200 }
4201 break;
4202
4203 case SND_SOC_BIAS_STANDBY:
4204 break;
4205
4206 case SND_SOC_BIAS_OFF:
4207 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0);
4208 regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000);
4209 regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000);
Oder Chiouf18803a2014-07-07 15:37:00 +08004210 regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0022);
Oder Chiou0e826e82014-05-26 20:32:33 +08004211 regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000);
4212 regmap_update_bits(rt5677->regmap,
4213 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000);
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004214
4215 if (rt5677->dsp_vad_en)
4216 rt5677_set_dsp_vad(codec, true);
Oder Chiou0e826e82014-05-26 20:32:33 +08004217 break;
4218
4219 default:
4220 break;
4221 }
4222 codec->dapm.bias_level = level;
4223
4224 return 0;
4225}
4226
Oder Chiou44caf762014-09-16 11:37:39 +08004227#ifdef CONFIG_GPIOLIB
4228static inline struct rt5677_priv *gpio_to_rt5677(struct gpio_chip *chip)
4229{
4230 return container_of(chip, struct rt5677_priv, gpio_chip);
4231}
4232
4233static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
4234{
4235 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4236
4237 switch (offset) {
4238 case RT5677_GPIO1 ... RT5677_GPIO5:
4239 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4240 0x1 << (offset * 3 + 1), !!value << (offset * 3 + 1));
4241 break;
4242
4243 case RT5677_GPIO6:
4244 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4245 RT5677_GPIO6_OUT_MASK, !!value << RT5677_GPIO6_OUT_SFT);
4246 break;
4247
4248 default:
4249 break;
4250 }
4251}
4252
4253static int rt5677_gpio_direction_out(struct gpio_chip *chip,
4254 unsigned offset, int value)
4255{
4256 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4257
4258 switch (offset) {
4259 case RT5677_GPIO1 ... RT5677_GPIO5:
4260 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4261 0x3 << (offset * 3 + 1),
4262 (0x2 | !!value) << (offset * 3 + 1));
4263 break;
4264
4265 case RT5677_GPIO6:
4266 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4267 RT5677_GPIO6_DIR_MASK | RT5677_GPIO6_OUT_MASK,
4268 RT5677_GPIO6_DIR_OUT | !!value << RT5677_GPIO6_OUT_SFT);
4269 break;
4270
4271 default:
4272 break;
4273 }
4274
4275 return 0;
4276}
4277
4278static int rt5677_gpio_get(struct gpio_chip *chip, unsigned offset)
4279{
4280 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4281 int value, ret;
4282
4283 ret = regmap_read(rt5677->regmap, RT5677_GPIO_ST, &value);
4284 if (ret < 0)
4285 return ret;
4286
4287 return (value & (0x1 << offset)) >> offset;
4288}
4289
4290static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
4291{
4292 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4293
4294 switch (offset) {
4295 case RT5677_GPIO1 ... RT5677_GPIO5:
4296 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4297 0x1 << (offset * 3 + 2), 0x0);
4298 break;
4299
4300 case RT5677_GPIO6:
4301 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4302 RT5677_GPIO6_DIR_MASK, RT5677_GPIO6_DIR_IN);
4303 break;
4304
4305 default:
4306 break;
4307 }
4308
4309 return 0;
4310}
4311
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004312/** Configures the gpio as
4313 * 0 - floating
4314 * 1 - pull down
4315 * 2 - pull up
4316 */
4317static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
4318 int value)
4319{
4320 int shift;
4321
4322 switch (offset) {
4323 case RT5677_GPIO1 ... RT5677_GPIO2:
4324 shift = 2 * (1 - offset);
4325 regmap_update_bits(rt5677->regmap,
4326 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL2,
4327 0x3 << shift,
4328 (value & 0x3) << shift);
4329 break;
4330
4331 case RT5677_GPIO3 ... RT5677_GPIO6:
4332 shift = 2 * (9 - offset);
4333 regmap_update_bits(rt5677->regmap,
4334 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL3,
4335 0x3 << shift,
4336 (value & 0x3) << shift);
4337 break;
4338
4339 default:
4340 break;
4341 }
4342}
4343
Oder Chiou5e3363a2014-10-16 11:24:26 -07004344static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset)
4345{
4346 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4347 struct regmap_irq_chip_data *data = rt5677->irq_data;
4348 int irq;
4349
4350 if (offset >= RT5677_GPIO1 && offset <= RT5677_GPIO3) {
4351 if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) ||
4352 (rt5677->pdata.jd1_gpio == 2 &&
4353 offset == RT5677_GPIO2) ||
4354 (rt5677->pdata.jd1_gpio == 3 &&
4355 offset == RT5677_GPIO3)) {
4356 irq = RT5677_IRQ_JD1;
4357 } else {
4358 return -ENXIO;
4359 }
4360 }
4361
4362 if (offset >= RT5677_GPIO4 && offset <= RT5677_GPIO6) {
4363 if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) ||
4364 (rt5677->pdata.jd2_gpio == 2 &&
4365 offset == RT5677_GPIO5) ||
4366 (rt5677->pdata.jd2_gpio == 3 &&
4367 offset == RT5677_GPIO6)) {
4368 irq = RT5677_IRQ_JD2;
4369 } else if ((rt5677->pdata.jd3_gpio == 1 &&
4370 offset == RT5677_GPIO4) ||
4371 (rt5677->pdata.jd3_gpio == 2 &&
4372 offset == RT5677_GPIO5) ||
4373 (rt5677->pdata.jd3_gpio == 3 &&
4374 offset == RT5677_GPIO6)) {
4375 irq = RT5677_IRQ_JD3;
4376 } else {
4377 return -ENXIO;
4378 }
4379 }
4380
4381 return regmap_irq_get_virq(data, irq);
4382}
4383
Oder Chiou44caf762014-09-16 11:37:39 +08004384static struct gpio_chip rt5677_template_chip = {
4385 .label = "rt5677",
4386 .owner = THIS_MODULE,
4387 .direction_output = rt5677_gpio_direction_out,
4388 .set = rt5677_gpio_set,
4389 .direction_input = rt5677_gpio_direction_in,
4390 .get = rt5677_gpio_get,
Oder Chiou5e3363a2014-10-16 11:24:26 -07004391 .to_irq = rt5677_to_irq,
Oder Chiou44caf762014-09-16 11:37:39 +08004392 .can_sleep = 1,
4393};
4394
4395static void rt5677_init_gpio(struct i2c_client *i2c)
4396{
4397 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4398 int ret;
4399
4400 rt5677->gpio_chip = rt5677_template_chip;
4401 rt5677->gpio_chip.ngpio = RT5677_GPIO_NUM;
4402 rt5677->gpio_chip.dev = &i2c->dev;
4403 rt5677->gpio_chip.base = -1;
4404
4405 ret = gpiochip_add(&rt5677->gpio_chip);
4406 if (ret != 0)
4407 dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret);
4408}
4409
4410static void rt5677_free_gpio(struct i2c_client *i2c)
4411{
4412 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08004413
Axel Lin5d5e63a2014-09-17 20:58:02 +08004414 gpiochip_remove(&rt5677->gpio_chip);
Oder Chiou44caf762014-09-16 11:37:39 +08004415}
4416#else
Anatol Pomozov45b6e1d2014-10-16 09:40:58 -07004417static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
4418 int value)
4419{
4420}
4421
Oder Chiou44caf762014-09-16 11:37:39 +08004422static void rt5677_init_gpio(struct i2c_client *i2c)
4423{
4424}
4425
4426static void rt5677_free_gpio(struct i2c_client *i2c)
4427{
4428}
4429#endif
4430
Oder Chiou0e826e82014-05-26 20:32:33 +08004431static int rt5677_probe(struct snd_soc_codec *codec)
4432{
4433 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004434 int i;
Oder Chiou0e826e82014-05-26 20:32:33 +08004435
4436 rt5677->codec = codec;
4437
Bard Liao2d15d972014-08-27 19:50:34 +08004438 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
4439 snd_soc_dapm_add_routes(&codec->dapm,
4440 rt5677_dmic2_clk_2,
4441 ARRAY_SIZE(rt5677_dmic2_clk_2));
4442 } else { /*use dmic1 clock by default*/
4443 snd_soc_dapm_add_routes(&codec->dapm,
4444 rt5677_dmic2_clk_1,
4445 ARRAY_SIZE(rt5677_dmic2_clk_1));
4446 }
4447
Oder Chiou0e826e82014-05-26 20:32:33 +08004448 rt5677_set_bias_level(codec, SND_SOC_BIAS_OFF);
4449
4450 regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020);
4451 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00);
4452
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004453 for (i = 0; i < RT5677_GPIO_NUM; i++)
4454 rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]);
4455
Oder Chiou5e3363a2014-10-16 11:24:26 -07004456 if (rt5677->irq_data) {
4457 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, 0x8000,
4458 0x8000);
4459 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x0018,
4460 0x0008);
4461
4462 if (rt5677->pdata.jd1_gpio)
4463 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4464 RT5677_SEL_GPIO_JD1_MASK,
4465 rt5677->pdata.jd1_gpio <<
4466 RT5677_SEL_GPIO_JD1_SFT);
4467
4468 if (rt5677->pdata.jd2_gpio)
4469 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4470 RT5677_SEL_GPIO_JD2_MASK,
4471 rt5677->pdata.jd2_gpio <<
4472 RT5677_SEL_GPIO_JD2_SFT);
4473
4474 if (rt5677->pdata.jd3_gpio)
4475 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4476 RT5677_SEL_GPIO_JD3_MASK,
4477 rt5677->pdata.jd3_gpio <<
4478 RT5677_SEL_GPIO_JD3_SFT);
4479 }
4480
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004481 mutex_init(&rt5677->dsp_cmd_lock);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004482 mutex_init(&rt5677->dsp_pri_lock);
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004483
Oder Chiou0e826e82014-05-26 20:32:33 +08004484 return 0;
4485}
4486
4487static int rt5677_remove(struct snd_soc_codec *codec)
4488{
4489 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4490
4491 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004492 if (gpio_is_valid(rt5677->pow_ldo2))
4493 gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +08004494
4495 return 0;
4496}
4497
4498#ifdef CONFIG_PM
4499static int rt5677_suspend(struct snd_soc_codec *codec)
4500{
4501 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4502
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004503 if (!rt5677->dsp_vad_en) {
4504 regcache_cache_only(rt5677->regmap, true);
4505 regcache_mark_dirty(rt5677->regmap);
4506 }
4507
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004508 if (gpio_is_valid(rt5677->pow_ldo2))
4509 gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
Oder Chiou0e826e82014-05-26 20:32:33 +08004510
4511 return 0;
4512}
4513
4514static int rt5677_resume(struct snd_soc_codec *codec)
4515{
4516 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4517
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004518 if (gpio_is_valid(rt5677->pow_ldo2)) {
4519 gpio_set_value_cansleep(rt5677->pow_ldo2, 1);
4520 msleep(10);
4521 }
Oder Chiouaf48f1d2014-10-06 16:30:51 +08004522
4523 if (!rt5677->dsp_vad_en) {
4524 regcache_cache_only(rt5677->regmap, false);
4525 regcache_sync(rt5677->regmap);
4526 }
Oder Chiou0e826e82014-05-26 20:32:33 +08004527
4528 return 0;
4529}
4530#else
4531#define rt5677_suspend NULL
4532#define rt5677_resume NULL
4533#endif
4534
Oder Chiou19ba4842014-11-05 13:42:53 +08004535static int rt5677_read(void *context, unsigned int reg, unsigned int *val)
4536{
4537 struct i2c_client *client = context;
4538 struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
4539
Oder Chiou6fe17da2014-11-25 09:51:41 +08004540 if (rt5677->is_dsp_mode) {
4541 if (reg > 0xff) {
4542 mutex_lock(&rt5677->dsp_pri_lock);
4543 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
4544 reg & 0xff);
4545 rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val);
4546 mutex_unlock(&rt5677->dsp_pri_lock);
4547 } else {
4548 rt5677_dsp_mode_i2c_read(rt5677, reg, val);
4549 }
4550 } else {
Oder Chiou19ba4842014-11-05 13:42:53 +08004551 regmap_read(rt5677->regmap_physical, reg, val);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004552 }
Oder Chiou19ba4842014-11-05 13:42:53 +08004553
4554 return 0;
4555}
4556
4557static int rt5677_write(void *context, unsigned int reg, unsigned int val)
4558{
4559 struct i2c_client *client = context;
4560 struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
4561
Oder Chiou6fe17da2014-11-25 09:51:41 +08004562 if (rt5677->is_dsp_mode) {
4563 if (reg > 0xff) {
4564 mutex_lock(&rt5677->dsp_pri_lock);
4565 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
4566 reg & 0xff);
4567 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA,
4568 val);
4569 mutex_unlock(&rt5677->dsp_pri_lock);
4570 } else {
4571 rt5677_dsp_mode_i2c_write(rt5677, reg, val);
4572 }
4573 } else {
Oder Chiou19ba4842014-11-05 13:42:53 +08004574 regmap_write(rt5677->regmap_physical, reg, val);
Oder Chiou6fe17da2014-11-25 09:51:41 +08004575 }
Oder Chiou19ba4842014-11-05 13:42:53 +08004576
4577 return 0;
4578}
4579
Oder Chiou0e826e82014-05-26 20:32:33 +08004580#define RT5677_STEREO_RATES SNDRV_PCM_RATE_8000_96000
4581#define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
4582 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
4583
4584static struct snd_soc_dai_ops rt5677_aif_dai_ops = {
4585 .hw_params = rt5677_hw_params,
4586 .set_fmt = rt5677_set_dai_fmt,
4587 .set_sysclk = rt5677_set_dai_sysclk,
4588 .set_pll = rt5677_set_dai_pll,
Oder Chiou48561af2014-09-17 15:12:33 +08004589 .set_tdm_slot = rt5677_set_tdm_slot,
Oder Chiou0e826e82014-05-26 20:32:33 +08004590};
4591
4592static struct snd_soc_dai_driver rt5677_dai[] = {
4593 {
4594 .name = "rt5677-aif1",
4595 .id = RT5677_AIF1,
4596 .playback = {
4597 .stream_name = "AIF1 Playback",
4598 .channels_min = 1,
4599 .channels_max = 2,
4600 .rates = RT5677_STEREO_RATES,
4601 .formats = RT5677_FORMATS,
4602 },
4603 .capture = {
4604 .stream_name = "AIF1 Capture",
4605 .channels_min = 1,
4606 .channels_max = 2,
4607 .rates = RT5677_STEREO_RATES,
4608 .formats = RT5677_FORMATS,
4609 },
4610 .ops = &rt5677_aif_dai_ops,
4611 },
4612 {
4613 .name = "rt5677-aif2",
4614 .id = RT5677_AIF2,
4615 .playback = {
4616 .stream_name = "AIF2 Playback",
4617 .channels_min = 1,
4618 .channels_max = 2,
4619 .rates = RT5677_STEREO_RATES,
4620 .formats = RT5677_FORMATS,
4621 },
4622 .capture = {
4623 .stream_name = "AIF2 Capture",
4624 .channels_min = 1,
4625 .channels_max = 2,
4626 .rates = RT5677_STEREO_RATES,
4627 .formats = RT5677_FORMATS,
4628 },
4629 .ops = &rt5677_aif_dai_ops,
4630 },
4631 {
4632 .name = "rt5677-aif3",
4633 .id = RT5677_AIF3,
4634 .playback = {
4635 .stream_name = "AIF3 Playback",
4636 .channels_min = 1,
4637 .channels_max = 2,
4638 .rates = RT5677_STEREO_RATES,
4639 .formats = RT5677_FORMATS,
4640 },
4641 .capture = {
4642 .stream_name = "AIF3 Capture",
4643 .channels_min = 1,
4644 .channels_max = 2,
4645 .rates = RT5677_STEREO_RATES,
4646 .formats = RT5677_FORMATS,
4647 },
4648 .ops = &rt5677_aif_dai_ops,
4649 },
4650 {
4651 .name = "rt5677-aif4",
4652 .id = RT5677_AIF4,
4653 .playback = {
4654 .stream_name = "AIF4 Playback",
4655 .channels_min = 1,
4656 .channels_max = 2,
4657 .rates = RT5677_STEREO_RATES,
4658 .formats = RT5677_FORMATS,
4659 },
4660 .capture = {
4661 .stream_name = "AIF4 Capture",
4662 .channels_min = 1,
4663 .channels_max = 2,
4664 .rates = RT5677_STEREO_RATES,
4665 .formats = RT5677_FORMATS,
4666 },
4667 .ops = &rt5677_aif_dai_ops,
4668 },
4669 {
4670 .name = "rt5677-slimbus",
4671 .id = RT5677_AIF5,
4672 .playback = {
4673 .stream_name = "SLIMBus Playback",
4674 .channels_min = 1,
4675 .channels_max = 2,
4676 .rates = RT5677_STEREO_RATES,
4677 .formats = RT5677_FORMATS,
4678 },
4679 .capture = {
4680 .stream_name = "SLIMBus Capture",
4681 .channels_min = 1,
4682 .channels_max = 2,
4683 .rates = RT5677_STEREO_RATES,
4684 .formats = RT5677_FORMATS,
4685 },
4686 .ops = &rt5677_aif_dai_ops,
4687 },
4688};
4689
4690static struct snd_soc_codec_driver soc_codec_dev_rt5677 = {
4691 .probe = rt5677_probe,
4692 .remove = rt5677_remove,
4693 .suspend = rt5677_suspend,
4694 .resume = rt5677_resume,
4695 .set_bias_level = rt5677_set_bias_level,
4696 .idle_bias_off = true,
4697 .controls = rt5677_snd_controls,
4698 .num_controls = ARRAY_SIZE(rt5677_snd_controls),
4699 .dapm_widgets = rt5677_dapm_widgets,
4700 .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets),
4701 .dapm_routes = rt5677_dapm_routes,
4702 .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes),
4703};
4704
Oder Chiou19ba4842014-11-05 13:42:53 +08004705static const struct regmap_config rt5677_regmap_physical = {
4706 .name = "physical",
4707 .reg_bits = 8,
4708 .val_bits = 16,
4709
Oder Chiou6fe17da2014-11-25 09:51:41 +08004710 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
4711 RT5677_PR_SPACING),
Oder Chiou19ba4842014-11-05 13:42:53 +08004712 .readable_reg = rt5677_readable_register,
4713
4714 .cache_type = REGCACHE_NONE,
Oder Chiou6fe17da2014-11-25 09:51:41 +08004715 .ranges = rt5677_ranges,
4716 .num_ranges = ARRAY_SIZE(rt5677_ranges),
Oder Chiou19ba4842014-11-05 13:42:53 +08004717};
4718
Oder Chiou0e826e82014-05-26 20:32:33 +08004719static const struct regmap_config rt5677_regmap = {
4720 .reg_bits = 8,
4721 .val_bits = 16,
4722
4723 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
4724 RT5677_PR_SPACING),
4725
4726 .volatile_reg = rt5677_volatile_register,
4727 .readable_reg = rt5677_readable_register,
Oder Chiou19ba4842014-11-05 13:42:53 +08004728 .reg_read = rt5677_read,
4729 .reg_write = rt5677_write,
Oder Chiou0e826e82014-05-26 20:32:33 +08004730
4731 .cache_type = REGCACHE_RBTREE,
4732 .reg_defaults = rt5677_reg,
4733 .num_reg_defaults = ARRAY_SIZE(rt5677_reg),
4734 .ranges = rt5677_ranges,
4735 .num_ranges = ARRAY_SIZE(rt5677_ranges),
4736};
4737
4738static const struct i2c_device_id rt5677_i2c_id[] = {
4739 { "rt5677", 0 },
4740 { }
4741};
4742MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
4743
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004744static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np)
4745{
Anatol Pomozov6f67c382014-09-26 09:57:27 -07004746 rt5677->pdata.in1_diff = of_property_read_bool(np,
4747 "realtek,in1-differential");
4748 rt5677->pdata.in2_diff = of_property_read_bool(np,
4749 "realtek,in2-differential");
4750 rt5677->pdata.lout1_diff = of_property_read_bool(np,
4751 "realtek,lout1-differential");
4752 rt5677->pdata.lout2_diff = of_property_read_bool(np,
4753 "realtek,lout2-differential");
4754 rt5677->pdata.lout3_diff = of_property_read_bool(np,
4755 "realtek,lout3-differential");
4756
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004757 rt5677->pow_ldo2 = of_get_named_gpio(np,
4758 "realtek,pow-ldo2-gpio", 0);
4759
4760 /*
4761 * POW_LDO2 is optional (it may be statically tied on the board).
4762 * -ENOENT means that the property doesn't exist, i.e. there is no
4763 * GPIO, so is not an error. Any other error code means the property
4764 * exists, but could not be parsed.
4765 */
4766 if (!gpio_is_valid(rt5677->pow_ldo2) &&
4767 (rt5677->pow_ldo2 != -ENOENT))
4768 return rt5677->pow_ldo2;
4769
Anatol Pomozov40eb90a2014-10-10 20:46:36 -07004770 of_property_read_u8_array(np, "realtek,gpio-config",
4771 rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
4772
Oder Chiou5e3363a2014-10-16 11:24:26 -07004773 of_property_read_u32(np, "realtek,jd1-gpio", &rt5677->pdata.jd1_gpio);
4774 of_property_read_u32(np, "realtek,jd2-gpio", &rt5677->pdata.jd2_gpio);
4775 of_property_read_u32(np, "realtek,jd3-gpio", &rt5677->pdata.jd3_gpio);
4776
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004777 return 0;
4778}
4779
Oder Chiou5e3363a2014-10-16 11:24:26 -07004780static struct regmap_irq rt5677_irqs[] = {
4781 [RT5677_IRQ_JD1] = {
4782 .reg_offset = 0,
4783 .mask = RT5677_EN_IRQ_GPIO_JD1,
4784 },
4785 [RT5677_IRQ_JD2] = {
4786 .reg_offset = 0,
4787 .mask = RT5677_EN_IRQ_GPIO_JD2,
4788 },
4789 [RT5677_IRQ_JD3] = {
4790 .reg_offset = 0,
4791 .mask = RT5677_EN_IRQ_GPIO_JD3,
4792 },
4793};
4794
4795static struct regmap_irq_chip rt5677_irq_chip = {
4796 .name = "rt5677",
4797 .irqs = rt5677_irqs,
4798 .num_irqs = ARRAY_SIZE(rt5677_irqs),
4799
4800 .num_regs = 1,
4801 .status_base = RT5677_IRQ_CTRL1,
4802 .mask_base = RT5677_IRQ_CTRL1,
4803 .mask_invert = 1,
4804};
4805
Oder Chiou35d40d12014-11-19 13:52:19 +08004806static int rt5677_init_irq(struct i2c_client *i2c)
Oder Chiou5e3363a2014-10-16 11:24:26 -07004807{
4808 int ret;
4809 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4810
4811 if (!rt5677->pdata.jd1_gpio &&
4812 !rt5677->pdata.jd2_gpio &&
4813 !rt5677->pdata.jd3_gpio)
4814 return 0;
4815
4816 if (!i2c->irq) {
4817 dev_err(&i2c->dev, "No interrupt specified\n");
4818 return -EINVAL;
4819 }
4820
4821 ret = regmap_add_irq_chip(rt5677->regmap, i2c->irq,
4822 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
4823 &rt5677_irq_chip, &rt5677->irq_data);
4824
4825 if (ret != 0) {
4826 dev_err(&i2c->dev, "Failed to register IRQ chip: %d\n", ret);
4827 return ret;
4828 }
4829
4830 return 0;
4831}
4832
Oder Chiou35d40d12014-11-19 13:52:19 +08004833static void rt5677_free_irq(struct i2c_client *i2c)
Oder Chiou5e3363a2014-10-16 11:24:26 -07004834{
4835 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4836
4837 if (rt5677->irq_data)
4838 regmap_del_irq_chip(i2c->irq, rt5677->irq_data);
4839}
4840
Oder Chiou0e826e82014-05-26 20:32:33 +08004841static int rt5677_i2c_probe(struct i2c_client *i2c,
4842 const struct i2c_device_id *id)
4843{
4844 struct rt5677_platform_data *pdata = dev_get_platdata(&i2c->dev);
4845 struct rt5677_priv *rt5677;
4846 int ret;
4847 unsigned int val;
4848
4849 rt5677 = devm_kzalloc(&i2c->dev, sizeof(struct rt5677_priv),
4850 GFP_KERNEL);
4851 if (rt5677 == NULL)
4852 return -ENOMEM;
4853
4854 i2c_set_clientdata(i2c, rt5677);
4855
4856 if (pdata)
4857 rt5677->pdata = *pdata;
4858
Anatol Pomozovf9f6a592014-09-17 13:14:20 -07004859 if (i2c->dev.of_node) {
4860 ret = rt5677_parse_dt(rt5677, i2c->dev.of_node);
4861 if (ret) {
4862 dev_err(&i2c->dev, "Failed to parse device tree: %d\n",
4863 ret);
4864 return ret;
4865 }
4866 } else {
4867 rt5677->pow_ldo2 = -EINVAL;
4868 }
4869
4870 if (gpio_is_valid(rt5677->pow_ldo2)) {
4871 ret = devm_gpio_request_one(&i2c->dev, rt5677->pow_ldo2,
4872 GPIOF_OUT_INIT_HIGH,
4873 "RT5677 POW_LDO2");
4874 if (ret < 0) {
4875 dev_err(&i2c->dev, "Failed to request POW_LDO2 %d: %d\n",
4876 rt5677->pow_ldo2, ret);
4877 return ret;
4878 }
4879 /* Wait a while until I2C bus becomes available. The datasheet
4880 * does not specify the exact we should wait but startup
4881 * sequence mentiones at least a few milliseconds.
4882 */
4883 msleep(10);
4884 }
4885
Oder Chiou19ba4842014-11-05 13:42:53 +08004886 rt5677->regmap_physical = devm_regmap_init_i2c(i2c,
4887 &rt5677_regmap_physical);
4888 if (IS_ERR(rt5677->regmap_physical)) {
4889 ret = PTR_ERR(rt5677->regmap_physical);
4890 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
4891 ret);
4892 return ret;
4893 }
4894
4895 rt5677->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5677_regmap);
Oder Chiou0e826e82014-05-26 20:32:33 +08004896 if (IS_ERR(rt5677->regmap)) {
4897 ret = PTR_ERR(rt5677->regmap);
4898 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
4899 ret);
4900 return ret;
4901 }
4902
4903 regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val);
4904 if (val != RT5677_DEVICE_ID) {
4905 dev_err(&i2c->dev,
4906 "Device with ID register %x is not rt5677\n", val);
4907 return -ENODEV;
4908 }
4909
4910 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
4911
4912 ret = regmap_register_patch(rt5677->regmap, init_list,
4913 ARRAY_SIZE(init_list));
4914 if (ret != 0)
4915 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
4916
4917 if (rt5677->pdata.in1_diff)
4918 regmap_update_bits(rt5677->regmap, RT5677_IN1,
4919 RT5677_IN_DF1, RT5677_IN_DF1);
4920
4921 if (rt5677->pdata.in2_diff)
4922 regmap_update_bits(rt5677->regmap, RT5677_IN1,
4923 RT5677_IN_DF2, RT5677_IN_DF2);
4924
Anatol Pomozov6f67c382014-09-26 09:57:27 -07004925 if (rt5677->pdata.lout1_diff)
4926 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4927 RT5677_LOUT1_L_DF, RT5677_LOUT1_L_DF);
4928
4929 if (rt5677->pdata.lout2_diff)
4930 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4931 RT5677_LOUT2_L_DF, RT5677_LOUT2_L_DF);
4932
4933 if (rt5677->pdata.lout3_diff)
4934 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4935 RT5677_LOUT3_L_DF, RT5677_LOUT3_L_DF);
4936
Bard Liao2d15d972014-08-27 19:50:34 +08004937 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
4938 regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL2,
4939 RT5677_GPIO5_FUNC_MASK,
4940 RT5677_GPIO5_FUNC_DMIC);
4941 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4942 RT5677_GPIO5_DIR_MASK,
4943 RT5677_GPIO5_DIR_OUT);
4944 }
4945
Oder Chiou277880a2015-01-08 10:31:06 +08004946 if (rt5677->pdata.micbias1_vdd_3v3)
4947 regmap_update_bits(rt5677->regmap, RT5677_MICBIAS,
4948 RT5677_MICBIAS1_CTRL_VDD_MASK,
4949 RT5677_MICBIAS1_CTRL_VDD_3_3V);
4950
Oder Chiou44caf762014-09-16 11:37:39 +08004951 rt5677_init_gpio(i2c);
Oder Chiou35d40d12014-11-19 13:52:19 +08004952 rt5677_init_irq(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08004953
Axel Lind0bdcb92014-06-10 11:37:24 +08004954 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677,
4955 rt5677_dai, ARRAY_SIZE(rt5677_dai));
Oder Chiou0e826e82014-05-26 20:32:33 +08004956}
4957
4958static int rt5677_i2c_remove(struct i2c_client *i2c)
4959{
4960 snd_soc_unregister_codec(&i2c->dev);
Oder Chiou35d40d12014-11-19 13:52:19 +08004961 rt5677_free_irq(i2c);
Oder Chiou44caf762014-09-16 11:37:39 +08004962 rt5677_free_gpio(i2c);
Oder Chiou0e826e82014-05-26 20:32:33 +08004963
4964 return 0;
4965}
4966
4967static struct i2c_driver rt5677_i2c_driver = {
4968 .driver = {
4969 .name = "rt5677",
4970 .owner = THIS_MODULE,
4971 },
4972 .probe = rt5677_i2c_probe,
4973 .remove = rt5677_i2c_remove,
4974 .id_table = rt5677_i2c_id,
4975};
Axel Linc8cfbec2014-06-03 10:56:41 +08004976module_i2c_driver(rt5677_i2c_driver);
Oder Chiou0e826e82014-05-26 20:32:33 +08004977
4978MODULE_DESCRIPTION("ASoC RT5677 driver");
4979MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>");
4980MODULE_LICENSE("GPL v2");