xref: /linux/sound/soc/codecs/rt5659.c (revision c62db3d5abf89ca5502c7fe1f869c2862e48336d)
1d3cb2de2SBard Liao /*
2d3cb2de2SBard Liao  * rt5659.c  --  RT5659/RT5658 ALSA SoC audio codec driver
3d3cb2de2SBard Liao  *
4d3cb2de2SBard Liao  * Copyright 2015 Realtek Semiconductor Corp.
5d3cb2de2SBard Liao  * Author: Bard Liao <bardliao@realtek.com>
6d3cb2de2SBard Liao  *
7d3cb2de2SBard Liao  * This program is free software; you can redistribute it and/or modify
8d3cb2de2SBard Liao  * it under the terms of the GNU General Public License version 2 as
9d3cb2de2SBard Liao  * published by the Free Software Foundation.
10d3cb2de2SBard Liao  */
11d3cb2de2SBard Liao 
12d3cb2de2SBard Liao #include <linux/module.h>
13d3cb2de2SBard Liao #include <linux/moduleparam.h>
14d3cb2de2SBard Liao #include <linux/init.h>
15d3cb2de2SBard Liao #include <linux/delay.h>
16d3cb2de2SBard Liao #include <linux/pm.h>
17d3cb2de2SBard Liao #include <linux/i2c.h>
18d3cb2de2SBard Liao #include <linux/platform_device.h>
19d3cb2de2SBard Liao #include <linux/spi/spi.h>
20d3cb2de2SBard Liao #include <linux/acpi.h>
21d3cb2de2SBard Liao #include <linux/gpio.h>
22d3cb2de2SBard Liao #include <linux/gpio/consumer.h>
23d3cb2de2SBard Liao #include <sound/core.h>
24d3cb2de2SBard Liao #include <sound/pcm.h>
25d3cb2de2SBard Liao #include <sound/pcm_params.h>
26d3cb2de2SBard Liao #include <sound/jack.h>
27d3cb2de2SBard Liao #include <sound/soc.h>
28d3cb2de2SBard Liao #include <sound/soc-dapm.h>
29d3cb2de2SBard Liao #include <sound/initval.h>
30d3cb2de2SBard Liao #include <sound/tlv.h>
31d3cb2de2SBard Liao #include <sound/rt5659.h>
32d3cb2de2SBard Liao 
33d3cb2de2SBard Liao #include "rl6231.h"
34d3cb2de2SBard Liao #include "rt5659.h"
35d3cb2de2SBard Liao 
36d3cb2de2SBard Liao static const struct reg_default rt5659_reg[] = {
37d3cb2de2SBard Liao 	{ 0x0000, 0x0000 },
38d3cb2de2SBard Liao 	{ 0x0001, 0x4848 },
39d3cb2de2SBard Liao 	{ 0x0002, 0x8080 },
40d3cb2de2SBard Liao 	{ 0x0003, 0xc8c8 },
41d3cb2de2SBard Liao 	{ 0x0004, 0xc80a },
42d3cb2de2SBard Liao 	{ 0x0005, 0x0000 },
43d3cb2de2SBard Liao 	{ 0x0006, 0x0000 },
44d3cb2de2SBard Liao 	{ 0x0007, 0x0103 },
45d3cb2de2SBard Liao 	{ 0x0008, 0x0080 },
46d3cb2de2SBard Liao 	{ 0x0009, 0x0000 },
47d3cb2de2SBard Liao 	{ 0x000a, 0x0000 },
48d3cb2de2SBard Liao 	{ 0x000c, 0x0000 },
49d3cb2de2SBard Liao 	{ 0x000d, 0x0000 },
50d3cb2de2SBard Liao 	{ 0x000f, 0x0808 },
51d3cb2de2SBard Liao 	{ 0x0010, 0x3080 },
52d3cb2de2SBard Liao 	{ 0x0011, 0x4a00 },
53d3cb2de2SBard Liao 	{ 0x0012, 0x4e00 },
54d3cb2de2SBard Liao 	{ 0x0015, 0x42c1 },
55d3cb2de2SBard Liao 	{ 0x0016, 0x0000 },
56d3cb2de2SBard Liao 	{ 0x0018, 0x000b },
57d3cb2de2SBard Liao 	{ 0x0019, 0xafaf },
58d3cb2de2SBard Liao 	{ 0x001a, 0xafaf },
59d3cb2de2SBard Liao 	{ 0x001b, 0x0011 },
60d3cb2de2SBard Liao 	{ 0x001c, 0x2f2f },
61d3cb2de2SBard Liao 	{ 0x001d, 0x2f2f },
62d3cb2de2SBard Liao 	{ 0x001e, 0x2f2f },
63d3cb2de2SBard Liao 	{ 0x001f, 0x0000 },
64d3cb2de2SBard Liao 	{ 0x0020, 0x0000 },
65d3cb2de2SBard Liao 	{ 0x0021, 0x0000 },
66d3cb2de2SBard Liao 	{ 0x0022, 0x5757 },
67d3cb2de2SBard Liao 	{ 0x0023, 0x0039 },
68d3cb2de2SBard Liao 	{ 0x0026, 0xc060 },
69d3cb2de2SBard Liao 	{ 0x0027, 0xd8d8 },
70d3cb2de2SBard Liao 	{ 0x0029, 0x8080 },
71d3cb2de2SBard Liao 	{ 0x002a, 0xaaaa },
72d3cb2de2SBard Liao 	{ 0x002b, 0xaaaa },
73d3cb2de2SBard Liao 	{ 0x002c, 0x00af },
74d3cb2de2SBard Liao 	{ 0x002d, 0x0000 },
75d3cb2de2SBard Liao 	{ 0x002f, 0x1002 },
76d3cb2de2SBard Liao 	{ 0x0031, 0x5000 },
77d3cb2de2SBard Liao 	{ 0x0032, 0x0000 },
78d3cb2de2SBard Liao 	{ 0x0033, 0x0000 },
79d3cb2de2SBard Liao 	{ 0x0034, 0x0000 },
80d3cb2de2SBard Liao 	{ 0x0035, 0x0000 },
81d3cb2de2SBard Liao 	{ 0x0036, 0x0000 },
82d3cb2de2SBard Liao 	{ 0x003a, 0x0000 },
83d3cb2de2SBard Liao 	{ 0x003b, 0x0000 },
84d3cb2de2SBard Liao 	{ 0x003c, 0x007f },
85d3cb2de2SBard Liao 	{ 0x003d, 0x0000 },
86d3cb2de2SBard Liao 	{ 0x003e, 0x007f },
87d3cb2de2SBard Liao 	{ 0x0040, 0x0808 },
88d3cb2de2SBard Liao 	{ 0x0046, 0x001f },
89d3cb2de2SBard Liao 	{ 0x0047, 0x001f },
90d3cb2de2SBard Liao 	{ 0x0048, 0x0003 },
91d3cb2de2SBard Liao 	{ 0x0049, 0xe061 },
92d3cb2de2SBard Liao 	{ 0x004a, 0x0000 },
93d3cb2de2SBard Liao 	{ 0x004b, 0x031f },
94d3cb2de2SBard Liao 	{ 0x004d, 0x0000 },
95d3cb2de2SBard Liao 	{ 0x004e, 0x001f },
96d3cb2de2SBard Liao 	{ 0x004f, 0x0000 },
97d3cb2de2SBard Liao 	{ 0x0050, 0x001f },
98d3cb2de2SBard Liao 	{ 0x0052, 0xf000 },
99d3cb2de2SBard Liao 	{ 0x0053, 0x0111 },
100d3cb2de2SBard Liao 	{ 0x0054, 0x0064 },
101d3cb2de2SBard Liao 	{ 0x0055, 0x0080 },
102d3cb2de2SBard Liao 	{ 0x0056, 0xef0e },
103d3cb2de2SBard Liao 	{ 0x0057, 0xf0f0 },
104d3cb2de2SBard Liao 	{ 0x0058, 0xef0e },
105d3cb2de2SBard Liao 	{ 0x0059, 0xf0f0 },
106d3cb2de2SBard Liao 	{ 0x005a, 0xef0e },
107d3cb2de2SBard Liao 	{ 0x005b, 0xf0f0 },
108d3cb2de2SBard Liao 	{ 0x005c, 0xf000 },
109d3cb2de2SBard Liao 	{ 0x005d, 0x0000 },
110d3cb2de2SBard Liao 	{ 0x005e, 0x1f2c },
111d3cb2de2SBard Liao 	{ 0x005f, 0x1f2c },
112d3cb2de2SBard Liao 	{ 0x0060, 0x2717 },
113d3cb2de2SBard Liao 	{ 0x0061, 0x0000 },
114d3cb2de2SBard Liao 	{ 0x0062, 0x0000 },
115d3cb2de2SBard Liao 	{ 0x0063, 0x003e },
116d3cb2de2SBard Liao 	{ 0x0064, 0x0000 },
117d3cb2de2SBard Liao 	{ 0x0065, 0x0000 },
118d3cb2de2SBard Liao 	{ 0x0066, 0x0000 },
119d3cb2de2SBard Liao 	{ 0x0067, 0x0000 },
120d3cb2de2SBard Liao 	{ 0x006a, 0x0000 },
121d3cb2de2SBard Liao 	{ 0x006b, 0x0000 },
122d3cb2de2SBard Liao 	{ 0x006c, 0x0000 },
123d3cb2de2SBard Liao 	{ 0x006e, 0x0000 },
124d3cb2de2SBard Liao 	{ 0x006f, 0x0000 },
125d3cb2de2SBard Liao 	{ 0x0070, 0x8000 },
126d3cb2de2SBard Liao 	{ 0x0071, 0x8000 },
127d3cb2de2SBard Liao 	{ 0x0072, 0x8000 },
128d3cb2de2SBard Liao 	{ 0x0073, 0x1110 },
129d3cb2de2SBard Liao 	{ 0x0074, 0xfe00 },
130d3cb2de2SBard Liao 	{ 0x0075, 0x2409 },
131d3cb2de2SBard Liao 	{ 0x0076, 0x000a },
132d3cb2de2SBard Liao 	{ 0x0077, 0x00f0 },
133d3cb2de2SBard Liao 	{ 0x0078, 0x0000 },
134d3cb2de2SBard Liao 	{ 0x0079, 0x0000 },
135d3cb2de2SBard Liao 	{ 0x007a, 0x0123 },
136d3cb2de2SBard Liao 	{ 0x007b, 0x8003 },
137d3cb2de2SBard Liao 	{ 0x0080, 0x0000 },
138d3cb2de2SBard Liao 	{ 0x0081, 0x0000 },
139d3cb2de2SBard Liao 	{ 0x0082, 0x0000 },
140d3cb2de2SBard Liao 	{ 0x0083, 0x0000 },
141d3cb2de2SBard Liao 	{ 0x0084, 0x0000 },
142d3cb2de2SBard Liao 	{ 0x0085, 0x0000 },
143d3cb2de2SBard Liao 	{ 0x0086, 0x0008 },
144d3cb2de2SBard Liao 	{ 0x0087, 0x0000 },
145d3cb2de2SBard Liao 	{ 0x0088, 0x0000 },
146d3cb2de2SBard Liao 	{ 0x0089, 0x0000 },
147d3cb2de2SBard Liao 	{ 0x008a, 0x0000 },
148d3cb2de2SBard Liao 	{ 0x008b, 0x0000 },
149d3cb2de2SBard Liao 	{ 0x008c, 0x0003 },
150d3cb2de2SBard Liao 	{ 0x008e, 0x0000 },
151d3cb2de2SBard Liao 	{ 0x008f, 0x1000 },
152d3cb2de2SBard Liao 	{ 0x0090, 0x0646 },
153d3cb2de2SBard Liao 	{ 0x0091, 0x0c16 },
154d3cb2de2SBard Liao 	{ 0x0092, 0x0073 },
155d3cb2de2SBard Liao 	{ 0x0093, 0x0000 },
156d3cb2de2SBard Liao 	{ 0x0094, 0x0080 },
157d3cb2de2SBard Liao 	{ 0x0097, 0x0000 },
158d3cb2de2SBard Liao 	{ 0x0098, 0x0000 },
159d3cb2de2SBard Liao 	{ 0x0099, 0x0000 },
160d3cb2de2SBard Liao 	{ 0x009a, 0x0000 },
161d3cb2de2SBard Liao 	{ 0x009b, 0x0000 },
162d3cb2de2SBard Liao 	{ 0x009c, 0x007f },
163d3cb2de2SBard Liao 	{ 0x009d, 0x0000 },
164d3cb2de2SBard Liao 	{ 0x009e, 0x007f },
165d3cb2de2SBard Liao 	{ 0x009f, 0x0000 },
166d3cb2de2SBard Liao 	{ 0x00a0, 0x0060 },
167d3cb2de2SBard Liao 	{ 0x00a1, 0x90a1 },
168d3cb2de2SBard Liao 	{ 0x00ae, 0x2000 },
169d3cb2de2SBard Liao 	{ 0x00af, 0x0000 },
170d3cb2de2SBard Liao 	{ 0x00b0, 0x2000 },
171d3cb2de2SBard Liao 	{ 0x00b1, 0x0000 },
172d3cb2de2SBard Liao 	{ 0x00b2, 0x0000 },
173d3cb2de2SBard Liao 	{ 0x00b6, 0x0000 },
174d3cb2de2SBard Liao 	{ 0x00b7, 0x0000 },
175d3cb2de2SBard Liao 	{ 0x00b8, 0x0000 },
176d3cb2de2SBard Liao 	{ 0x00b9, 0x0000 },
177d3cb2de2SBard Liao 	{ 0x00ba, 0x0000 },
178d3cb2de2SBard Liao 	{ 0x00bb, 0x0000 },
179d3cb2de2SBard Liao 	{ 0x00be, 0x0000 },
180d3cb2de2SBard Liao 	{ 0x00bf, 0x0000 },
181d3cb2de2SBard Liao 	{ 0x00c0, 0x0000 },
182d3cb2de2SBard Liao 	{ 0x00c1, 0x0000 },
183d3cb2de2SBard Liao 	{ 0x00c2, 0x0000 },
184d3cb2de2SBard Liao 	{ 0x00c3, 0x0000 },
185d3cb2de2SBard Liao 	{ 0x00c4, 0x0003 },
186d3cb2de2SBard Liao 	{ 0x00c5, 0x0000 },
187d3cb2de2SBard Liao 	{ 0x00cb, 0xa02f },
188d3cb2de2SBard Liao 	{ 0x00cc, 0x0000 },
189d3cb2de2SBard Liao 	{ 0x00cd, 0x0e02 },
190d3cb2de2SBard Liao 	{ 0x00d6, 0x0000 },
191d3cb2de2SBard Liao 	{ 0x00d7, 0x2244 },
192d3cb2de2SBard Liao 	{ 0x00d9, 0x0809 },
193d3cb2de2SBard Liao 	{ 0x00da, 0x0000 },
194d3cb2de2SBard Liao 	{ 0x00db, 0x0008 },
195d3cb2de2SBard Liao 	{ 0x00dc, 0x00c0 },
196d3cb2de2SBard Liao 	{ 0x00dd, 0x6724 },
197d3cb2de2SBard Liao 	{ 0x00de, 0x3131 },
198d3cb2de2SBard Liao 	{ 0x00df, 0x0008 },
199d3cb2de2SBard Liao 	{ 0x00e0, 0x4000 },
200d3cb2de2SBard Liao 	{ 0x00e1, 0x3131 },
201d3cb2de2SBard Liao 	{ 0x00e4, 0x400c },
202d3cb2de2SBard Liao 	{ 0x00e5, 0x8031 },
203d3cb2de2SBard Liao 	{ 0x00ea, 0xb320 },
204d3cb2de2SBard Liao 	{ 0x00eb, 0x0000 },
205d3cb2de2SBard Liao 	{ 0x00ec, 0xb300 },
206d3cb2de2SBard Liao 	{ 0x00ed, 0x0000 },
207d3cb2de2SBard Liao 	{ 0x00f0, 0x0000 },
208d3cb2de2SBard Liao 	{ 0x00f1, 0x0202 },
209d3cb2de2SBard Liao 	{ 0x00f2, 0x0ddd },
210d3cb2de2SBard Liao 	{ 0x00f3, 0x0ddd },
211d3cb2de2SBard Liao 	{ 0x00f4, 0x0ddd },
212d3cb2de2SBard Liao 	{ 0x00f6, 0x0000 },
213d3cb2de2SBard Liao 	{ 0x00f7, 0x0000 },
214d3cb2de2SBard Liao 	{ 0x00f8, 0x0000 },
215d3cb2de2SBard Liao 	{ 0x00f9, 0x0000 },
216d3cb2de2SBard Liao 	{ 0x00fa, 0x8000 },
217d3cb2de2SBard Liao 	{ 0x00fb, 0x0000 },
218d3cb2de2SBard Liao 	{ 0x00fc, 0x0000 },
219d3cb2de2SBard Liao 	{ 0x00fd, 0x0001 },
220d3cb2de2SBard Liao 	{ 0x00fe, 0x10ec },
221d3cb2de2SBard Liao 	{ 0x00ff, 0x6311 },
222d3cb2de2SBard Liao 	{ 0x0100, 0xaaaa },
223d3cb2de2SBard Liao 	{ 0x010a, 0xaaaa },
224d3cb2de2SBard Liao 	{ 0x010b, 0x00a0 },
225d3cb2de2SBard Liao 	{ 0x010c, 0xaeae },
226d3cb2de2SBard Liao 	{ 0x010d, 0xaaaa },
227d3cb2de2SBard Liao 	{ 0x010e, 0xaaa8 },
228d3cb2de2SBard Liao 	{ 0x010f, 0xa0aa },
229d3cb2de2SBard Liao 	{ 0x0110, 0xe02a },
230d3cb2de2SBard Liao 	{ 0x0111, 0xa702 },
231d3cb2de2SBard Liao 	{ 0x0112, 0xaaaa },
232d3cb2de2SBard Liao 	{ 0x0113, 0x2800 },
233d3cb2de2SBard Liao 	{ 0x0116, 0x0000 },
234d3cb2de2SBard Liao 	{ 0x0117, 0x0f00 },
235d3cb2de2SBard Liao 	{ 0x011a, 0x0020 },
236d3cb2de2SBard Liao 	{ 0x011b, 0x0011 },
237d3cb2de2SBard Liao 	{ 0x011c, 0x0150 },
238d3cb2de2SBard Liao 	{ 0x011d, 0x0000 },
239d3cb2de2SBard Liao 	{ 0x011e, 0x0000 },
240d3cb2de2SBard Liao 	{ 0x011f, 0x0000 },
241d3cb2de2SBard Liao 	{ 0x0120, 0x0000 },
242d3cb2de2SBard Liao 	{ 0x0121, 0x009b },
243d3cb2de2SBard Liao 	{ 0x0122, 0x5014 },
244d3cb2de2SBard Liao 	{ 0x0123, 0x0421 },
245d3cb2de2SBard Liao 	{ 0x0124, 0x7cea },
246d3cb2de2SBard Liao 	{ 0x0125, 0x0420 },
247d3cb2de2SBard Liao 	{ 0x0126, 0x5550 },
248d3cb2de2SBard Liao 	{ 0x0132, 0x0000 },
249d3cb2de2SBard Liao 	{ 0x0133, 0x0000 },
250d3cb2de2SBard Liao 	{ 0x0137, 0x5055 },
251d3cb2de2SBard Liao 	{ 0x0138, 0x3700 },
252d3cb2de2SBard Liao 	{ 0x0139, 0x79a1 },
253d3cb2de2SBard Liao 	{ 0x013a, 0x2020 },
254d3cb2de2SBard Liao 	{ 0x013b, 0x2020 },
255d3cb2de2SBard Liao 	{ 0x013c, 0x2005 },
256d3cb2de2SBard Liao 	{ 0x013e, 0x1f00 },
257d3cb2de2SBard Liao 	{ 0x013f, 0x0000 },
258d3cb2de2SBard Liao 	{ 0x0145, 0x0002 },
259d3cb2de2SBard Liao 	{ 0x0146, 0x0000 },
260d3cb2de2SBard Liao 	{ 0x0147, 0x0000 },
261d3cb2de2SBard Liao 	{ 0x0148, 0x0000 },
262d3cb2de2SBard Liao 	{ 0x0150, 0x1813 },
263d3cb2de2SBard Liao 	{ 0x0151, 0x0690 },
264d3cb2de2SBard Liao 	{ 0x0152, 0x1c17 },
265d3cb2de2SBard Liao 	{ 0x0153, 0x6883 },
266d3cb2de2SBard Liao 	{ 0x0154, 0xd3ce },
267d3cb2de2SBard Liao 	{ 0x0155, 0x352d },
268d3cb2de2SBard Liao 	{ 0x0156, 0x00eb },
269d3cb2de2SBard Liao 	{ 0x0157, 0x3717 },
270d3cb2de2SBard Liao 	{ 0x0158, 0x4c6a },
271d3cb2de2SBard Liao 	{ 0x0159, 0xe41b },
272d3cb2de2SBard Liao 	{ 0x015a, 0x2a13 },
273d3cb2de2SBard Liao 	{ 0x015b, 0xb600 },
274d3cb2de2SBard Liao 	{ 0x015c, 0xc730 },
275d3cb2de2SBard Liao 	{ 0x015d, 0x35d4 },
276d3cb2de2SBard Liao 	{ 0x015e, 0x00bf },
277d3cb2de2SBard Liao 	{ 0x0160, 0x0ec0 },
278d3cb2de2SBard Liao 	{ 0x0161, 0x0020 },
279d3cb2de2SBard Liao 	{ 0x0162, 0x0080 },
280d3cb2de2SBard Liao 	{ 0x0163, 0x0800 },
281d3cb2de2SBard Liao 	{ 0x0164, 0x0000 },
282d3cb2de2SBard Liao 	{ 0x0165, 0x0000 },
283d3cb2de2SBard Liao 	{ 0x0166, 0x0000 },
284d3cb2de2SBard Liao 	{ 0x0167, 0x001f },
285d3cb2de2SBard Liao 	{ 0x0170, 0x4e80 },
286d3cb2de2SBard Liao 	{ 0x0171, 0x0020 },
287d3cb2de2SBard Liao 	{ 0x0172, 0x0080 },
288d3cb2de2SBard Liao 	{ 0x0173, 0x0800 },
289d3cb2de2SBard Liao 	{ 0x0174, 0x000c },
290d3cb2de2SBard Liao 	{ 0x0175, 0x0000 },
291d3cb2de2SBard Liao 	{ 0x0190, 0x3300 },
292d3cb2de2SBard Liao 	{ 0x0191, 0x2200 },
293d3cb2de2SBard Liao 	{ 0x0192, 0x0000 },
294d3cb2de2SBard Liao 	{ 0x01b0, 0x4b38 },
295d3cb2de2SBard Liao 	{ 0x01b1, 0x0000 },
296d3cb2de2SBard Liao 	{ 0x01b2, 0x0000 },
297d3cb2de2SBard Liao 	{ 0x01b3, 0x0000 },
298d3cb2de2SBard Liao 	{ 0x01c0, 0x0045 },
299d3cb2de2SBard Liao 	{ 0x01c1, 0x0540 },
300d3cb2de2SBard Liao 	{ 0x01c2, 0x0000 },
301d3cb2de2SBard Liao 	{ 0x01c3, 0x0030 },
302d3cb2de2SBard Liao 	{ 0x01c7, 0x0000 },
303d3cb2de2SBard Liao 	{ 0x01c8, 0x5757 },
304d3cb2de2SBard Liao 	{ 0x01c9, 0x5757 },
305d3cb2de2SBard Liao 	{ 0x01ca, 0x5757 },
306d3cb2de2SBard Liao 	{ 0x01cb, 0x5757 },
307d3cb2de2SBard Liao 	{ 0x01cc, 0x5757 },
308d3cb2de2SBard Liao 	{ 0x01cd, 0x5757 },
309d3cb2de2SBard Liao 	{ 0x01ce, 0x006f },
310d3cb2de2SBard Liao 	{ 0x01da, 0x0000 },
311d3cb2de2SBard Liao 	{ 0x01db, 0x0000 },
312d3cb2de2SBard Liao 	{ 0x01de, 0x7d00 },
313d3cb2de2SBard Liao 	{ 0x01df, 0x10c0 },
314d3cb2de2SBard Liao 	{ 0x01e0, 0x06a1 },
315d3cb2de2SBard Liao 	{ 0x01e1, 0x0000 },
316d3cb2de2SBard Liao 	{ 0x01e2, 0x0000 },
317d3cb2de2SBard Liao 	{ 0x01e3, 0x0000 },
318d3cb2de2SBard Liao 	{ 0x01e4, 0x0001 },
319d3cb2de2SBard Liao 	{ 0x01e6, 0x0000 },
320d3cb2de2SBard Liao 	{ 0x01e7, 0x0000 },
321d3cb2de2SBard Liao 	{ 0x01e8, 0x0000 },
322d3cb2de2SBard Liao 	{ 0x01ea, 0x0000 },
323d3cb2de2SBard Liao 	{ 0x01eb, 0x0000 },
324d3cb2de2SBard Liao 	{ 0x01ec, 0x0000 },
325d3cb2de2SBard Liao 	{ 0x01ed, 0x0000 },
326d3cb2de2SBard Liao 	{ 0x01ee, 0x0000 },
327d3cb2de2SBard Liao 	{ 0x01ef, 0x0000 },
328d3cb2de2SBard Liao 	{ 0x01f0, 0x0000 },
329d3cb2de2SBard Liao 	{ 0x01f1, 0x0000 },
330d3cb2de2SBard Liao 	{ 0x01f2, 0x0000 },
331d3cb2de2SBard Liao 	{ 0x01f6, 0x1e04 },
332d3cb2de2SBard Liao 	{ 0x01f7, 0x01a1 },
333d3cb2de2SBard Liao 	{ 0x01f8, 0x0000 },
334d3cb2de2SBard Liao 	{ 0x01f9, 0x0000 },
335d3cb2de2SBard Liao 	{ 0x01fa, 0x0002 },
336d3cb2de2SBard Liao 	{ 0x01fb, 0x0000 },
337d3cb2de2SBard Liao 	{ 0x01fc, 0x0000 },
338d3cb2de2SBard Liao 	{ 0x01fd, 0x0000 },
339d3cb2de2SBard Liao 	{ 0x01fe, 0x0000 },
340d3cb2de2SBard Liao 	{ 0x0200, 0x066c },
341d3cb2de2SBard Liao 	{ 0x0201, 0x7fff },
342d3cb2de2SBard Liao 	{ 0x0202, 0x7fff },
343d3cb2de2SBard Liao 	{ 0x0203, 0x0000 },
344d3cb2de2SBard Liao 	{ 0x0204, 0x0000 },
345d3cb2de2SBard Liao 	{ 0x0205, 0x0000 },
346d3cb2de2SBard Liao 	{ 0x0206, 0x0000 },
347d3cb2de2SBard Liao 	{ 0x0207, 0x0000 },
348d3cb2de2SBard Liao 	{ 0x0208, 0x0000 },
349d3cb2de2SBard Liao 	{ 0x0256, 0x0000 },
350d3cb2de2SBard Liao 	{ 0x0257, 0x0000 },
351d3cb2de2SBard Liao 	{ 0x0258, 0x0000 },
352d3cb2de2SBard Liao 	{ 0x0259, 0x0000 },
353d3cb2de2SBard Liao 	{ 0x025a, 0x0000 },
354d3cb2de2SBard Liao 	{ 0x025b, 0x3333 },
355d3cb2de2SBard Liao 	{ 0x025c, 0x3333 },
356d3cb2de2SBard Liao 	{ 0x025d, 0x3333 },
357d3cb2de2SBard Liao 	{ 0x025e, 0x0000 },
358d3cb2de2SBard Liao 	{ 0x025f, 0x0000 },
359d3cb2de2SBard Liao 	{ 0x0260, 0x0000 },
360d3cb2de2SBard Liao 	{ 0x0261, 0x0022 },
361d3cb2de2SBard Liao 	{ 0x0262, 0x0300 },
362d3cb2de2SBard Liao 	{ 0x0265, 0x1e80 },
363d3cb2de2SBard Liao 	{ 0x0266, 0x0131 },
364d3cb2de2SBard Liao 	{ 0x0267, 0x0003 },
365d3cb2de2SBard Liao 	{ 0x0268, 0x0000 },
366d3cb2de2SBard Liao 	{ 0x0269, 0x0000 },
367d3cb2de2SBard Liao 	{ 0x026a, 0x0000 },
368d3cb2de2SBard Liao 	{ 0x026b, 0x0000 },
369d3cb2de2SBard Liao 	{ 0x026c, 0x0000 },
370d3cb2de2SBard Liao 	{ 0x026d, 0x0000 },
371d3cb2de2SBard Liao 	{ 0x026e, 0x0000 },
372d3cb2de2SBard Liao 	{ 0x026f, 0x0000 },
373d3cb2de2SBard Liao 	{ 0x0270, 0x0000 },
374d3cb2de2SBard Liao 	{ 0x0271, 0x0000 },
375d3cb2de2SBard Liao 	{ 0x0272, 0x0000 },
376d3cb2de2SBard Liao 	{ 0x0273, 0x0000 },
377d3cb2de2SBard Liao 	{ 0x0280, 0x0000 },
378d3cb2de2SBard Liao 	{ 0x0281, 0x0000 },
379d3cb2de2SBard Liao 	{ 0x0282, 0x0418 },
380d3cb2de2SBard Liao 	{ 0x0283, 0x7fff },
381d3cb2de2SBard Liao 	{ 0x0284, 0x7000 },
382d3cb2de2SBard Liao 	{ 0x0290, 0x01d0 },
383d3cb2de2SBard Liao 	{ 0x0291, 0x0100 },
384d3cb2de2SBard Liao 	{ 0x02fa, 0x0000 },
385d3cb2de2SBard Liao 	{ 0x02fb, 0x0000 },
386d3cb2de2SBard Liao 	{ 0x02fc, 0x0000 },
387d3cb2de2SBard Liao 	{ 0x0300, 0x001f },
388d3cb2de2SBard Liao 	{ 0x0301, 0x032c },
389d3cb2de2SBard Liao 	{ 0x0302, 0x5f21 },
390d3cb2de2SBard Liao 	{ 0x0303, 0x4000 },
391d3cb2de2SBard Liao 	{ 0x0304, 0x4000 },
392d3cb2de2SBard Liao 	{ 0x0305, 0x0600 },
393d3cb2de2SBard Liao 	{ 0x0306, 0x8000 },
394d3cb2de2SBard Liao 	{ 0x0307, 0x0700 },
395d3cb2de2SBard Liao 	{ 0x0308, 0x001f },
396d3cb2de2SBard Liao 	{ 0x0309, 0x032c },
397d3cb2de2SBard Liao 	{ 0x030a, 0x5f21 },
398d3cb2de2SBard Liao 	{ 0x030b, 0x4000 },
399d3cb2de2SBard Liao 	{ 0x030c, 0x4000 },
400d3cb2de2SBard Liao 	{ 0x030d, 0x0600 },
401d3cb2de2SBard Liao 	{ 0x030e, 0x8000 },
402d3cb2de2SBard Liao 	{ 0x030f, 0x0700 },
403d3cb2de2SBard Liao 	{ 0x0310, 0x4560 },
404d3cb2de2SBard Liao 	{ 0x0311, 0xa4a8 },
405d3cb2de2SBard Liao 	{ 0x0312, 0x7418 },
406d3cb2de2SBard Liao 	{ 0x0313, 0x0000 },
407d3cb2de2SBard Liao 	{ 0x0314, 0x0006 },
408d3cb2de2SBard Liao 	{ 0x0315, 0x00ff },
409d3cb2de2SBard Liao 	{ 0x0316, 0xc400 },
410d3cb2de2SBard Liao 	{ 0x0317, 0x4560 },
411d3cb2de2SBard Liao 	{ 0x0318, 0xa4a8 },
412d3cb2de2SBard Liao 	{ 0x0319, 0x7418 },
413d3cb2de2SBard Liao 	{ 0x031a, 0x0000 },
414d3cb2de2SBard Liao 	{ 0x031b, 0x0006 },
415d3cb2de2SBard Liao 	{ 0x031c, 0x00ff },
416d3cb2de2SBard Liao 	{ 0x031d, 0xc400 },
417d3cb2de2SBard Liao 	{ 0x0320, 0x0f20 },
418d3cb2de2SBard Liao 	{ 0x0321, 0x8700 },
419d3cb2de2SBard Liao 	{ 0x0322, 0x7dc2 },
420d3cb2de2SBard Liao 	{ 0x0323, 0xa178 },
421d3cb2de2SBard Liao 	{ 0x0324, 0x5383 },
422d3cb2de2SBard Liao 	{ 0x0325, 0x7dc2 },
423d3cb2de2SBard Liao 	{ 0x0326, 0xa178 },
424d3cb2de2SBard Liao 	{ 0x0327, 0x5383 },
425d3cb2de2SBard Liao 	{ 0x0328, 0x003e },
426d3cb2de2SBard Liao 	{ 0x0329, 0x02c1 },
427d3cb2de2SBard Liao 	{ 0x032a, 0xd37d },
428d3cb2de2SBard Liao 	{ 0x0330, 0x00a6 },
429d3cb2de2SBard Liao 	{ 0x0331, 0x04c3 },
430d3cb2de2SBard Liao 	{ 0x0332, 0x27c8 },
431d3cb2de2SBard Liao 	{ 0x0333, 0xbf50 },
432d3cb2de2SBard Liao 	{ 0x0334, 0x0045 },
433d3cb2de2SBard Liao 	{ 0x0335, 0x2007 },
434d3cb2de2SBard Liao 	{ 0x0336, 0x7418 },
435d3cb2de2SBard Liao 	{ 0x0337, 0x0501 },
436d3cb2de2SBard Liao 	{ 0x0338, 0x0000 },
437d3cb2de2SBard Liao 	{ 0x0339, 0x0010 },
438d3cb2de2SBard Liao 	{ 0x033a, 0x1010 },
439d3cb2de2SBard Liao 	{ 0x0340, 0x0800 },
440d3cb2de2SBard Liao 	{ 0x0341, 0x0800 },
441d3cb2de2SBard Liao 	{ 0x0342, 0x0800 },
442d3cb2de2SBard Liao 	{ 0x0343, 0x0800 },
443d3cb2de2SBard Liao 	{ 0x0344, 0x0000 },
444d3cb2de2SBard Liao 	{ 0x0345, 0x0000 },
445d3cb2de2SBard Liao 	{ 0x0346, 0x0000 },
446d3cb2de2SBard Liao 	{ 0x0347, 0x0000 },
447d3cb2de2SBard Liao 	{ 0x0348, 0x0000 },
448d3cb2de2SBard Liao 	{ 0x0349, 0x0000 },
449d3cb2de2SBard Liao 	{ 0x034a, 0x0000 },
450d3cb2de2SBard Liao 	{ 0x034b, 0x0000 },
451d3cb2de2SBard Liao 	{ 0x034c, 0x0000 },
452d3cb2de2SBard Liao 	{ 0x034d, 0x0000 },
453d3cb2de2SBard Liao 	{ 0x034e, 0x0000 },
454d3cb2de2SBard Liao 	{ 0x034f, 0x0000 },
455d3cb2de2SBard Liao 	{ 0x0350, 0x0000 },
456d3cb2de2SBard Liao 	{ 0x0351, 0x0000 },
457d3cb2de2SBard Liao 	{ 0x0352, 0x0000 },
458d3cb2de2SBard Liao 	{ 0x0353, 0x0000 },
459d3cb2de2SBard Liao 	{ 0x0354, 0x0000 },
460d3cb2de2SBard Liao 	{ 0x0355, 0x0000 },
461d3cb2de2SBard Liao 	{ 0x0356, 0x0000 },
462d3cb2de2SBard Liao 	{ 0x0357, 0x0000 },
463d3cb2de2SBard Liao 	{ 0x0358, 0x0000 },
464d3cb2de2SBard Liao 	{ 0x0359, 0x0000 },
465d3cb2de2SBard Liao 	{ 0x035a, 0x0000 },
466d3cb2de2SBard Liao 	{ 0x035b, 0x0000 },
467d3cb2de2SBard Liao 	{ 0x035c, 0x0000 },
468d3cb2de2SBard Liao 	{ 0x035d, 0x0000 },
469d3cb2de2SBard Liao 	{ 0x035e, 0x2000 },
470d3cb2de2SBard Liao 	{ 0x035f, 0x0000 },
471d3cb2de2SBard Liao 	{ 0x0360, 0x2000 },
472d3cb2de2SBard Liao 	{ 0x0361, 0x2000 },
473d3cb2de2SBard Liao 	{ 0x0362, 0x0000 },
474d3cb2de2SBard Liao 	{ 0x0363, 0x2000 },
475d3cb2de2SBard Liao 	{ 0x0364, 0x0200 },
476d3cb2de2SBard Liao 	{ 0x0365, 0x0000 },
477d3cb2de2SBard Liao 	{ 0x0366, 0x0000 },
478d3cb2de2SBard Liao 	{ 0x0367, 0x0000 },
479d3cb2de2SBard Liao 	{ 0x0368, 0x0000 },
480d3cb2de2SBard Liao 	{ 0x0369, 0x0000 },
481d3cb2de2SBard Liao 	{ 0x036a, 0x0000 },
482d3cb2de2SBard Liao 	{ 0x036b, 0x0000 },
483d3cb2de2SBard Liao 	{ 0x036c, 0x0000 },
484d3cb2de2SBard Liao 	{ 0x036d, 0x0000 },
485d3cb2de2SBard Liao 	{ 0x036e, 0x0200 },
486d3cb2de2SBard Liao 	{ 0x036f, 0x0000 },
487d3cb2de2SBard Liao 	{ 0x0370, 0x0000 },
488d3cb2de2SBard Liao 	{ 0x0371, 0x0000 },
489d3cb2de2SBard Liao 	{ 0x0372, 0x0000 },
490d3cb2de2SBard Liao 	{ 0x0373, 0x0000 },
491d3cb2de2SBard Liao 	{ 0x0374, 0x0000 },
492d3cb2de2SBard Liao 	{ 0x0375, 0x0000 },
493d3cb2de2SBard Liao 	{ 0x0376, 0x0000 },
494d3cb2de2SBard Liao 	{ 0x0377, 0x0000 },
495d3cb2de2SBard Liao 	{ 0x03d0, 0x0000 },
496d3cb2de2SBard Liao 	{ 0x03d1, 0x0000 },
497d3cb2de2SBard Liao 	{ 0x03d2, 0x0000 },
498d3cb2de2SBard Liao 	{ 0x03d3, 0x0000 },
499d3cb2de2SBard Liao 	{ 0x03d4, 0x2000 },
500d3cb2de2SBard Liao 	{ 0x03d5, 0x2000 },
501d3cb2de2SBard Liao 	{ 0x03d6, 0x0000 },
502d3cb2de2SBard Liao 	{ 0x03d7, 0x0000 },
503d3cb2de2SBard Liao 	{ 0x03d8, 0x2000 },
504d3cb2de2SBard Liao 	{ 0x03d9, 0x2000 },
505d3cb2de2SBard Liao 	{ 0x03da, 0x2000 },
506d3cb2de2SBard Liao 	{ 0x03db, 0x2000 },
507d3cb2de2SBard Liao 	{ 0x03dc, 0x0000 },
508d3cb2de2SBard Liao 	{ 0x03dd, 0x0000 },
509d3cb2de2SBard Liao 	{ 0x03de, 0x0000 },
510d3cb2de2SBard Liao 	{ 0x03df, 0x2000 },
511d3cb2de2SBard Liao 	{ 0x03e0, 0x0000 },
512d3cb2de2SBard Liao 	{ 0x03e1, 0x0000 },
513d3cb2de2SBard Liao 	{ 0x03e2, 0x0000 },
514d3cb2de2SBard Liao 	{ 0x03e3, 0x0000 },
515d3cb2de2SBard Liao 	{ 0x03e4, 0x0000 },
516d3cb2de2SBard Liao 	{ 0x03e5, 0x0000 },
517d3cb2de2SBard Liao 	{ 0x03e6, 0x0000 },
518d3cb2de2SBard Liao 	{ 0x03e7, 0x0000 },
519d3cb2de2SBard Liao 	{ 0x03e8, 0x0000 },
520d3cb2de2SBard Liao 	{ 0x03e9, 0x0000 },
521d3cb2de2SBard Liao 	{ 0x03ea, 0x0000 },
522d3cb2de2SBard Liao 	{ 0x03eb, 0x0000 },
523d3cb2de2SBard Liao 	{ 0x03ec, 0x0000 },
524d3cb2de2SBard Liao 	{ 0x03ed, 0x0000 },
525d3cb2de2SBard Liao 	{ 0x03ee, 0x0000 },
526d3cb2de2SBard Liao 	{ 0x03ef, 0x0000 },
527d3cb2de2SBard Liao 	{ 0x03f0, 0x0800 },
528d3cb2de2SBard Liao 	{ 0x03f1, 0x0800 },
529d3cb2de2SBard Liao 	{ 0x03f2, 0x0800 },
530d3cb2de2SBard Liao 	{ 0x03f3, 0x0800 },
531d3cb2de2SBard Liao };
532d3cb2de2SBard Liao 
533d3cb2de2SBard Liao static bool rt5659_volatile_register(struct device *dev, unsigned int reg)
534d3cb2de2SBard Liao {
535d3cb2de2SBard Liao 	switch (reg) {
536d3cb2de2SBard Liao 	case RT5659_RESET:
537d3cb2de2SBard Liao 	case RT5659_EJD_CTRL_2:
538d3cb2de2SBard Liao 	case RT5659_SILENCE_CTRL:
539d3cb2de2SBard Liao 	case RT5659_DAC2_DIG_VOL:
540d3cb2de2SBard Liao 	case RT5659_HP_IMP_GAIN_2:
541d3cb2de2SBard Liao 	case RT5659_PDM_OUT_CTRL:
542d3cb2de2SBard Liao 	case RT5659_PDM_DATA_CTRL_1:
543d3cb2de2SBard Liao 	case RT5659_PDM_DATA_CTRL_4:
544d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_1:
545d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_3:
546d3cb2de2SBard Liao 	case RT5659_HAPTIC_LPF_CTRL_3:
547d3cb2de2SBard Liao 	case RT5659_CLK_DET:
548d3cb2de2SBard Liao 	case RT5659_MICBIAS_1:
549d3cb2de2SBard Liao 	case RT5659_ASRC_11:
550d3cb2de2SBard Liao 	case RT5659_ADC_EQ_CTRL_1:
551d3cb2de2SBard Liao 	case RT5659_DAC_EQ_CTRL_1:
552d3cb2de2SBard Liao 	case RT5659_INT_ST_1:
553d3cb2de2SBard Liao 	case RT5659_INT_ST_2:
554d3cb2de2SBard Liao 	case RT5659_GPIO_STA:
555d3cb2de2SBard Liao 	case RT5659_SINE_GEN_CTRL_1:
556d3cb2de2SBard Liao 	case RT5659_IL_CMD_1:
557d3cb2de2SBard Liao 	case RT5659_4BTN_IL_CMD_1:
558d3cb2de2SBard Liao 	case RT5659_PSV_IL_CMD_1:
559d3cb2de2SBard Liao 	case RT5659_AJD1_CTRL:
560d3cb2de2SBard Liao 	case RT5659_AJD2_AJD3_CTRL:
561d3cb2de2SBard Liao 	case RT5659_JD_CTRL_3:
562d3cb2de2SBard Liao 	case RT5659_VENDOR_ID:
563d3cb2de2SBard Liao 	case RT5659_VENDOR_ID_1:
564d3cb2de2SBard Liao 	case RT5659_DEVICE_ID:
565d3cb2de2SBard Liao 	case RT5659_MEMORY_TEST:
566d3cb2de2SBard Liao 	case RT5659_SOFT_RAMP_DEPOP_DAC_CLK_CTRL:
567d3cb2de2SBard Liao 	case RT5659_VOL_TEST:
568d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_1:
569d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_5:
570d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_6:
571d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_7:
572d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_1:
573d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_5:
574d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_6:
575d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_CTRL_1:
576d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_CTRL_3:
577d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_CTRL_4:
578d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_1:
579d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_9:
580d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_1:
581d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_2:
582d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_3:
583d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_4:
584d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_5:
585d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_6:
586d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_7:
587d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_8:
588d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_9:
589d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_CTRL_1:
590d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_CTRL_3:
591d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_STA_1:
592d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_STA_2:
593d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_STA_3:
594d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_STA_4:
595d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_1:
596d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_2:
597d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_3:
598d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_4:
599d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_5:
600d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_6:
601d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_CTRL_1:
602d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_1:
603d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_2:
604d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_3:
605d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_4:
606d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_5:
607d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_6:
608d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_7:
609d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_8:
610d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_9:
611d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_10:
612d3cb2de2SBard Liao 	case RT5659_SPK_VDD_STA_1:
613d3cb2de2SBard Liao 	case RT5659_SPK_VDD_STA_2:
614d3cb2de2SBard Liao 	case RT5659_SPK_DC_DET_CTRL_1:
615d3cb2de2SBard Liao 	case RT5659_PURE_DC_DET_CTRL_1:
616d3cb2de2SBard Liao 	case RT5659_PURE_DC_DET_CTRL_2:
617d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_1:
618d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_4:
619d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_5:
620d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_6:
621d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_7:
622d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_1:
623d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_4:
624d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_5:
625d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_6:
626d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_7:
627d3cb2de2SBard Liao 	case RT5659_ALC_PGA_STA_1:
628d3cb2de2SBard Liao 	case RT5659_ALC_PGA_STA_2:
629d3cb2de2SBard Liao 	case RT5659_ALC_PGA_STA_3:
630d3cb2de2SBard Liao 		return true;
631d3cb2de2SBard Liao 	default:
632d3cb2de2SBard Liao 		return false;
633d3cb2de2SBard Liao 	}
634d3cb2de2SBard Liao }
635d3cb2de2SBard Liao 
636d3cb2de2SBard Liao static bool rt5659_readable_register(struct device *dev, unsigned int reg)
637d3cb2de2SBard Liao {
638d3cb2de2SBard Liao 	switch (reg) {
639d3cb2de2SBard Liao 	case RT5659_RESET:
640d3cb2de2SBard Liao 	case RT5659_SPO_VOL:
641d3cb2de2SBard Liao 	case RT5659_HP_VOL:
642d3cb2de2SBard Liao 	case RT5659_LOUT:
643d3cb2de2SBard Liao 	case RT5659_MONO_OUT:
644d3cb2de2SBard Liao 	case RT5659_HPL_GAIN:
645d3cb2de2SBard Liao 	case RT5659_HPR_GAIN:
646d3cb2de2SBard Liao 	case RT5659_MONO_GAIN:
647d3cb2de2SBard Liao 	case RT5659_SPDIF_CTRL_1:
648d3cb2de2SBard Liao 	case RT5659_SPDIF_CTRL_2:
649d3cb2de2SBard Liao 	case RT5659_CAL_BST_CTRL:
650d3cb2de2SBard Liao 	case RT5659_IN1_IN2:
651d3cb2de2SBard Liao 	case RT5659_IN3_IN4:
652d3cb2de2SBard Liao 	case RT5659_INL1_INR1_VOL:
653d3cb2de2SBard Liao 	case RT5659_EJD_CTRL_1:
654d3cb2de2SBard Liao 	case RT5659_EJD_CTRL_2:
655d3cb2de2SBard Liao 	case RT5659_EJD_CTRL_3:
656d3cb2de2SBard Liao 	case RT5659_SILENCE_CTRL:
657d3cb2de2SBard Liao 	case RT5659_PSV_CTRL:
658d3cb2de2SBard Liao 	case RT5659_SIDETONE_CTRL:
659d3cb2de2SBard Liao 	case RT5659_DAC1_DIG_VOL:
660d3cb2de2SBard Liao 	case RT5659_DAC2_DIG_VOL:
661d3cb2de2SBard Liao 	case RT5659_DAC_CTRL:
662d3cb2de2SBard Liao 	case RT5659_STO1_ADC_DIG_VOL:
663d3cb2de2SBard Liao 	case RT5659_MONO_ADC_DIG_VOL:
664d3cb2de2SBard Liao 	case RT5659_STO2_ADC_DIG_VOL:
665d3cb2de2SBard Liao 	case RT5659_STO1_BOOST:
666d3cb2de2SBard Liao 	case RT5659_MONO_BOOST:
667d3cb2de2SBard Liao 	case RT5659_STO2_BOOST:
668d3cb2de2SBard Liao 	case RT5659_HP_IMP_GAIN_1:
669d3cb2de2SBard Liao 	case RT5659_HP_IMP_GAIN_2:
670d3cb2de2SBard Liao 	case RT5659_STO1_ADC_MIXER:
671d3cb2de2SBard Liao 	case RT5659_MONO_ADC_MIXER:
672d3cb2de2SBard Liao 	case RT5659_AD_DA_MIXER:
673d3cb2de2SBard Liao 	case RT5659_STO_DAC_MIXER:
674d3cb2de2SBard Liao 	case RT5659_MONO_DAC_MIXER:
675d3cb2de2SBard Liao 	case RT5659_DIG_MIXER:
676d3cb2de2SBard Liao 	case RT5659_A_DAC_MUX:
677d3cb2de2SBard Liao 	case RT5659_DIG_INF23_DATA:
678d3cb2de2SBard Liao 	case RT5659_PDM_OUT_CTRL:
679d3cb2de2SBard Liao 	case RT5659_PDM_DATA_CTRL_1:
680d3cb2de2SBard Liao 	case RT5659_PDM_DATA_CTRL_2:
681d3cb2de2SBard Liao 	case RT5659_PDM_DATA_CTRL_3:
682d3cb2de2SBard Liao 	case RT5659_PDM_DATA_CTRL_4:
683d3cb2de2SBard Liao 	case RT5659_SPDIF_CTRL:
684d3cb2de2SBard Liao 	case RT5659_REC1_GAIN:
685d3cb2de2SBard Liao 	case RT5659_REC1_L1_MIXER:
686d3cb2de2SBard Liao 	case RT5659_REC1_L2_MIXER:
687d3cb2de2SBard Liao 	case RT5659_REC1_R1_MIXER:
688d3cb2de2SBard Liao 	case RT5659_REC1_R2_MIXER:
689d3cb2de2SBard Liao 	case RT5659_CAL_REC:
690d3cb2de2SBard Liao 	case RT5659_REC2_L1_MIXER:
691d3cb2de2SBard Liao 	case RT5659_REC2_L2_MIXER:
692d3cb2de2SBard Liao 	case RT5659_REC2_R1_MIXER:
693d3cb2de2SBard Liao 	case RT5659_REC2_R2_MIXER:
694d3cb2de2SBard Liao 	case RT5659_SPK_L_MIXER:
695d3cb2de2SBard Liao 	case RT5659_SPK_R_MIXER:
696d3cb2de2SBard Liao 	case RT5659_SPO_AMP_GAIN:
697d3cb2de2SBard Liao 	case RT5659_ALC_BACK_GAIN:
698d3cb2de2SBard Liao 	case RT5659_MONOMIX_GAIN:
699d3cb2de2SBard Liao 	case RT5659_MONOMIX_IN_GAIN:
700d3cb2de2SBard Liao 	case RT5659_OUT_L_GAIN:
701d3cb2de2SBard Liao 	case RT5659_OUT_L_MIXER:
702d3cb2de2SBard Liao 	case RT5659_OUT_R_GAIN:
703d3cb2de2SBard Liao 	case RT5659_OUT_R_MIXER:
704d3cb2de2SBard Liao 	case RT5659_LOUT_MIXER:
705d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_1:
706d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_2:
707d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_3:
708d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_4:
709d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_5:
710d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_6:
711d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_7:
712d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_8:
713d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_9:
714d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_10:
715d3cb2de2SBard Liao 	case RT5659_HAPTIC_GEN_CTRL_11:
716d3cb2de2SBard Liao 	case RT5659_HAPTIC_LPF_CTRL_1:
717d3cb2de2SBard Liao 	case RT5659_HAPTIC_LPF_CTRL_2:
718d3cb2de2SBard Liao 	case RT5659_HAPTIC_LPF_CTRL_3:
719d3cb2de2SBard Liao 	case RT5659_PWR_DIG_1:
720d3cb2de2SBard Liao 	case RT5659_PWR_DIG_2:
721d3cb2de2SBard Liao 	case RT5659_PWR_ANLG_1:
722d3cb2de2SBard Liao 	case RT5659_PWR_ANLG_2:
723d3cb2de2SBard Liao 	case RT5659_PWR_ANLG_3:
724d3cb2de2SBard Liao 	case RT5659_PWR_MIXER:
725d3cb2de2SBard Liao 	case RT5659_PWR_VOL:
726d3cb2de2SBard Liao 	case RT5659_PRIV_INDEX:
727d3cb2de2SBard Liao 	case RT5659_CLK_DET:
728d3cb2de2SBard Liao 	case RT5659_PRIV_DATA:
729d3cb2de2SBard Liao 	case RT5659_PRE_DIV_1:
730d3cb2de2SBard Liao 	case RT5659_PRE_DIV_2:
731d3cb2de2SBard Liao 	case RT5659_I2S1_SDP:
732d3cb2de2SBard Liao 	case RT5659_I2S2_SDP:
733d3cb2de2SBard Liao 	case RT5659_I2S3_SDP:
734d3cb2de2SBard Liao 	case RT5659_ADDA_CLK_1:
735d3cb2de2SBard Liao 	case RT5659_ADDA_CLK_2:
736d3cb2de2SBard Liao 	case RT5659_DMIC_CTRL_1:
737d3cb2de2SBard Liao 	case RT5659_DMIC_CTRL_2:
738d3cb2de2SBard Liao 	case RT5659_TDM_CTRL_1:
739d3cb2de2SBard Liao 	case RT5659_TDM_CTRL_2:
740d3cb2de2SBard Liao 	case RT5659_TDM_CTRL_3:
741d3cb2de2SBard Liao 	case RT5659_TDM_CTRL_4:
742d3cb2de2SBard Liao 	case RT5659_TDM_CTRL_5:
743d3cb2de2SBard Liao 	case RT5659_GLB_CLK:
744d3cb2de2SBard Liao 	case RT5659_PLL_CTRL_1:
745d3cb2de2SBard Liao 	case RT5659_PLL_CTRL_2:
746d3cb2de2SBard Liao 	case RT5659_ASRC_1:
747d3cb2de2SBard Liao 	case RT5659_ASRC_2:
748d3cb2de2SBard Liao 	case RT5659_ASRC_3:
749d3cb2de2SBard Liao 	case RT5659_ASRC_4:
750d3cb2de2SBard Liao 	case RT5659_ASRC_5:
751d3cb2de2SBard Liao 	case RT5659_ASRC_6:
752d3cb2de2SBard Liao 	case RT5659_ASRC_7:
753d3cb2de2SBard Liao 	case RT5659_ASRC_8:
754d3cb2de2SBard Liao 	case RT5659_ASRC_9:
755d3cb2de2SBard Liao 	case RT5659_ASRC_10:
756d3cb2de2SBard Liao 	case RT5659_DEPOP_1:
757d3cb2de2SBard Liao 	case RT5659_DEPOP_2:
758d3cb2de2SBard Liao 	case RT5659_DEPOP_3:
759d3cb2de2SBard Liao 	case RT5659_HP_CHARGE_PUMP_1:
760d3cb2de2SBard Liao 	case RT5659_HP_CHARGE_PUMP_2:
761d3cb2de2SBard Liao 	case RT5659_MICBIAS_1:
762d3cb2de2SBard Liao 	case RT5659_MICBIAS_2:
763d3cb2de2SBard Liao 	case RT5659_ASRC_11:
764d3cb2de2SBard Liao 	case RT5659_ASRC_12:
765d3cb2de2SBard Liao 	case RT5659_ASRC_13:
766d3cb2de2SBard Liao 	case RT5659_REC_M1_M2_GAIN_CTRL:
767d3cb2de2SBard Liao 	case RT5659_RC_CLK_CTRL:
768d3cb2de2SBard Liao 	case RT5659_CLASSD_CTRL_1:
769d3cb2de2SBard Liao 	case RT5659_CLASSD_CTRL_2:
770d3cb2de2SBard Liao 	case RT5659_ADC_EQ_CTRL_1:
771d3cb2de2SBard Liao 	case RT5659_ADC_EQ_CTRL_2:
772d3cb2de2SBard Liao 	case RT5659_DAC_EQ_CTRL_1:
773d3cb2de2SBard Liao 	case RT5659_DAC_EQ_CTRL_2:
774d3cb2de2SBard Liao 	case RT5659_DAC_EQ_CTRL_3:
775d3cb2de2SBard Liao 	case RT5659_IRQ_CTRL_1:
776d3cb2de2SBard Liao 	case RT5659_IRQ_CTRL_2:
777d3cb2de2SBard Liao 	case RT5659_IRQ_CTRL_3:
778d3cb2de2SBard Liao 	case RT5659_IRQ_CTRL_4:
779d3cb2de2SBard Liao 	case RT5659_IRQ_CTRL_5:
780d3cb2de2SBard Liao 	case RT5659_IRQ_CTRL_6:
781d3cb2de2SBard Liao 	case RT5659_INT_ST_1:
782d3cb2de2SBard Liao 	case RT5659_INT_ST_2:
783d3cb2de2SBard Liao 	case RT5659_GPIO_CTRL_1:
784d3cb2de2SBard Liao 	case RT5659_GPIO_CTRL_2:
785d3cb2de2SBard Liao 	case RT5659_GPIO_CTRL_3:
786d3cb2de2SBard Liao 	case RT5659_GPIO_CTRL_4:
787d3cb2de2SBard Liao 	case RT5659_GPIO_CTRL_5:
788d3cb2de2SBard Liao 	case RT5659_GPIO_STA:
789d3cb2de2SBard Liao 	case RT5659_SINE_GEN_CTRL_1:
790d3cb2de2SBard Liao 	case RT5659_SINE_GEN_CTRL_2:
791d3cb2de2SBard Liao 	case RT5659_SINE_GEN_CTRL_3:
792d3cb2de2SBard Liao 	case RT5659_HP_AMP_DET_CTRL_1:
793d3cb2de2SBard Liao 	case RT5659_HP_AMP_DET_CTRL_2:
794d3cb2de2SBard Liao 	case RT5659_SV_ZCD_1:
795d3cb2de2SBard Liao 	case RT5659_SV_ZCD_2:
796d3cb2de2SBard Liao 	case RT5659_IL_CMD_1:
797d3cb2de2SBard Liao 	case RT5659_IL_CMD_2:
798d3cb2de2SBard Liao 	case RT5659_IL_CMD_3:
799d3cb2de2SBard Liao 	case RT5659_IL_CMD_4:
800d3cb2de2SBard Liao 	case RT5659_4BTN_IL_CMD_1:
801d3cb2de2SBard Liao 	case RT5659_4BTN_IL_CMD_2:
802d3cb2de2SBard Liao 	case RT5659_4BTN_IL_CMD_3:
803d3cb2de2SBard Liao 	case RT5659_PSV_IL_CMD_1:
804d3cb2de2SBard Liao 	case RT5659_PSV_IL_CMD_2:
805d3cb2de2SBard Liao 	case RT5659_ADC_STO1_HP_CTRL_1:
806d3cb2de2SBard Liao 	case RT5659_ADC_STO1_HP_CTRL_2:
807d3cb2de2SBard Liao 	case RT5659_ADC_MONO_HP_CTRL_1:
808d3cb2de2SBard Liao 	case RT5659_ADC_MONO_HP_CTRL_2:
809d3cb2de2SBard Liao 	case RT5659_AJD1_CTRL:
810d3cb2de2SBard Liao 	case RT5659_AJD2_AJD3_CTRL:
811d3cb2de2SBard Liao 	case RT5659_JD1_THD:
812d3cb2de2SBard Liao 	case RT5659_JD2_THD:
813d3cb2de2SBard Liao 	case RT5659_JD3_THD:
814d3cb2de2SBard Liao 	case RT5659_JD_CTRL_1:
815d3cb2de2SBard Liao 	case RT5659_JD_CTRL_2:
816d3cb2de2SBard Liao 	case RT5659_JD_CTRL_3:
817d3cb2de2SBard Liao 	case RT5659_JD_CTRL_4:
818d3cb2de2SBard Liao 	case RT5659_DIG_MISC:
819d3cb2de2SBard Liao 	case RT5659_DUMMY_2:
820d3cb2de2SBard Liao 	case RT5659_DUMMY_3:
821d3cb2de2SBard Liao 	case RT5659_VENDOR_ID:
822d3cb2de2SBard Liao 	case RT5659_VENDOR_ID_1:
823d3cb2de2SBard Liao 	case RT5659_DEVICE_ID:
824d3cb2de2SBard Liao 	case RT5659_DAC_ADC_DIG_VOL:
825d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_1:
826d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_2:
827d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_3:
828d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_4:
829d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_5:
830d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_6:
831d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_7:
832d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_8:
833d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_9:
834d3cb2de2SBard Liao 	case RT5659_BIAS_CUR_CTRL_10:
835d3cb2de2SBard Liao 	case RT5659_MEMORY_TEST:
836d3cb2de2SBard Liao 	case RT5659_VREF_REC_OP_FB_CAP_CTRL:
837d3cb2de2SBard Liao 	case RT5659_CLASSD_0:
838d3cb2de2SBard Liao 	case RT5659_CLASSD_1:
839d3cb2de2SBard Liao 	case RT5659_CLASSD_2:
840d3cb2de2SBard Liao 	case RT5659_CLASSD_3:
841d3cb2de2SBard Liao 	case RT5659_CLASSD_4:
842d3cb2de2SBard Liao 	case RT5659_CLASSD_5:
843d3cb2de2SBard Liao 	case RT5659_CLASSD_6:
844d3cb2de2SBard Liao 	case RT5659_CLASSD_7:
845d3cb2de2SBard Liao 	case RT5659_CLASSD_8:
846d3cb2de2SBard Liao 	case RT5659_CLASSD_9:
847d3cb2de2SBard Liao 	case RT5659_CLASSD_10:
848d3cb2de2SBard Liao 	case RT5659_CHARGE_PUMP_1:
849d3cb2de2SBard Liao 	case RT5659_CHARGE_PUMP_2:
850d3cb2de2SBard Liao 	case RT5659_DIG_IN_CTRL_1:
851d3cb2de2SBard Liao 	case RT5659_DIG_IN_CTRL_2:
852d3cb2de2SBard Liao 	case RT5659_PAD_DRIVING_CTRL:
853d3cb2de2SBard Liao 	case RT5659_SOFT_RAMP_DEPOP:
854d3cb2de2SBard Liao 	case RT5659_PLL:
855d3cb2de2SBard Liao 	case RT5659_CHOP_DAC:
856d3cb2de2SBard Liao 	case RT5659_CHOP_ADC:
857d3cb2de2SBard Liao 	case RT5659_CALIB_ADC_CTRL:
858d3cb2de2SBard Liao 	case RT5659_SOFT_RAMP_DEPOP_DAC_CLK_CTRL:
859d3cb2de2SBard Liao 	case RT5659_VOL_TEST:
860d3cb2de2SBard Liao 	case RT5659_TEST_MODE_CTRL_1:
861d3cb2de2SBard Liao 	case RT5659_TEST_MODE_CTRL_2:
862d3cb2de2SBard Liao 	case RT5659_TEST_MODE_CTRL_3:
863d3cb2de2SBard Liao 	case RT5659_TEST_MODE_CTRL_4:
864d3cb2de2SBard Liao 	case RT5659_BASSBACK_CTRL:
865d3cb2de2SBard Liao 	case RT5659_MP3_PLUS_CTRL_1:
866d3cb2de2SBard Liao 	case RT5659_MP3_PLUS_CTRL_2:
867d3cb2de2SBard Liao 	case RT5659_MP3_HPF_A1:
868d3cb2de2SBard Liao 	case RT5659_MP3_HPF_A2:
869d3cb2de2SBard Liao 	case RT5659_MP3_HPF_H0:
870d3cb2de2SBard Liao 	case RT5659_MP3_LPF_H0:
871d3cb2de2SBard Liao 	case RT5659_3D_SPK_CTRL:
872d3cb2de2SBard Liao 	case RT5659_3D_SPK_COEF_1:
873d3cb2de2SBard Liao 	case RT5659_3D_SPK_COEF_2:
874d3cb2de2SBard Liao 	case RT5659_3D_SPK_COEF_3:
875d3cb2de2SBard Liao 	case RT5659_3D_SPK_COEF_4:
876d3cb2de2SBard Liao 	case RT5659_3D_SPK_COEF_5:
877d3cb2de2SBard Liao 	case RT5659_3D_SPK_COEF_6:
878d3cb2de2SBard Liao 	case RT5659_3D_SPK_COEF_7:
879d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_1:
880d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_2:
881d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_3:
882d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_4:
883d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_5:
884d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_6:
885d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_7:
886d3cb2de2SBard Liao 	case RT5659_STO_NG2_CTRL_8:
887d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_1:
888d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_2:
889d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_3:
890d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_4:
891d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_5:
892d3cb2de2SBard Liao 	case RT5659_MONO_NG2_CTRL_6:
893d3cb2de2SBard Liao 	case RT5659_MID_HP_AMP_DET:
894d3cb2de2SBard Liao 	case RT5659_LOW_HP_AMP_DET:
895d3cb2de2SBard Liao 	case RT5659_LDO_CTRL:
896d3cb2de2SBard Liao 	case RT5659_HP_DECROSS_CTRL_1:
897d3cb2de2SBard Liao 	case RT5659_HP_DECROSS_CTRL_2:
898d3cb2de2SBard Liao 	case RT5659_HP_DECROSS_CTRL_3:
899d3cb2de2SBard Liao 	case RT5659_HP_DECROSS_CTRL_4:
900d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_CTRL_1:
901d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_CTRL_2:
902d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_CTRL_3:
903d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_CTRL_4:
904d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_MAP_1:
905d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_MAP_2:
906d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_MAP_3:
907d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_MAP_4:
908d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_MAP_5:
909d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_MAP_6:
910d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_MAP_7:
911d3cb2de2SBard Liao 	case RT5659_HP_IMP_SENS_MAP_8:
912d3cb2de2SBard Liao 	case RT5659_HP_LOGIC_CTRL_1:
913d3cb2de2SBard Liao 	case RT5659_HP_LOGIC_CTRL_2:
914d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_1:
915d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_2:
916d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_3:
917d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_4:
918d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_5:
919d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_6:
920d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_7:
921d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_9:
922d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_10:
923d3cb2de2SBard Liao 	case RT5659_HP_CALIB_CTRL_11:
924d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_1:
925d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_2:
926d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_3:
927d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_4:
928d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_5:
929d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_6:
930d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_7:
931d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_8:
932d3cb2de2SBard Liao 	case RT5659_HP_CALIB_STA_9:
933d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_CTRL_1:
934d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_CTRL_2:
935d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_CTRL_3:
936d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_CTRL_4:
937d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_CTRL_5:
938d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_STA_1:
939d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_STA_2:
940d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_STA_3:
941d3cb2de2SBard Liao 	case RT5659_MONO_AMP_CALIB_STA_4:
942d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_CTRL_1:
943d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_CTRL_2:
944d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_CTRL_3:
945d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_1:
946d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_2:
947d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_3:
948d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_4:
949d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_5:
950d3cb2de2SBard Liao 	case RT5659_SPK_PWR_LMT_STA_6:
951d3cb2de2SBard Liao 	case RT5659_FLEX_SPK_BST_CTRL_1:
952d3cb2de2SBard Liao 	case RT5659_FLEX_SPK_BST_CTRL_2:
953d3cb2de2SBard Liao 	case RT5659_FLEX_SPK_BST_CTRL_3:
954d3cb2de2SBard Liao 	case RT5659_FLEX_SPK_BST_CTRL_4:
955d3cb2de2SBard Liao 	case RT5659_SPK_EX_LMT_CTRL_1:
956d3cb2de2SBard Liao 	case RT5659_SPK_EX_LMT_CTRL_2:
957d3cb2de2SBard Liao 	case RT5659_SPK_EX_LMT_CTRL_3:
958d3cb2de2SBard Liao 	case RT5659_SPK_EX_LMT_CTRL_4:
959d3cb2de2SBard Liao 	case RT5659_SPK_EX_LMT_CTRL_5:
960d3cb2de2SBard Liao 	case RT5659_SPK_EX_LMT_CTRL_6:
961d3cb2de2SBard Liao 	case RT5659_SPK_EX_LMT_CTRL_7:
962d3cb2de2SBard Liao 	case RT5659_ADJ_HPF_CTRL_1:
963d3cb2de2SBard Liao 	case RT5659_ADJ_HPF_CTRL_2:
964d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_CTRL_1:
965d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_CTRL_2:
966d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_CTRL_3:
967d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_CTRL_4:
968d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_CTRL_5:
969d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_1:
970d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_2:
971d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_3:
972d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_4:
973d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_5:
974d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_6:
975d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_7:
976d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_8:
977d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_9:
978d3cb2de2SBard Liao 	case RT5659_SPK_DC_CAILB_STA_10:
979d3cb2de2SBard Liao 	case RT5659_SPK_VDD_STA_1:
980d3cb2de2SBard Liao 	case RT5659_SPK_VDD_STA_2:
981d3cb2de2SBard Liao 	case RT5659_SPK_DC_DET_CTRL_1:
982d3cb2de2SBard Liao 	case RT5659_SPK_DC_DET_CTRL_2:
983d3cb2de2SBard Liao 	case RT5659_SPK_DC_DET_CTRL_3:
984d3cb2de2SBard Liao 	case RT5659_PURE_DC_DET_CTRL_1:
985d3cb2de2SBard Liao 	case RT5659_PURE_DC_DET_CTRL_2:
986d3cb2de2SBard Liao 	case RT5659_DUMMY_4:
987d3cb2de2SBard Liao 	case RT5659_DUMMY_5:
988d3cb2de2SBard Liao 	case RT5659_DUMMY_6:
989d3cb2de2SBard Liao 	case RT5659_DRC1_CTRL_1:
990d3cb2de2SBard Liao 	case RT5659_DRC1_CTRL_2:
991d3cb2de2SBard Liao 	case RT5659_DRC1_CTRL_3:
992d3cb2de2SBard Liao 	case RT5659_DRC1_CTRL_4:
993d3cb2de2SBard Liao 	case RT5659_DRC1_CTRL_5:
994d3cb2de2SBard Liao 	case RT5659_DRC1_CTRL_6:
995d3cb2de2SBard Liao 	case RT5659_DRC1_HARD_LMT_CTRL_1:
996d3cb2de2SBard Liao 	case RT5659_DRC1_HARD_LMT_CTRL_2:
997d3cb2de2SBard Liao 	case RT5659_DRC2_CTRL_1:
998d3cb2de2SBard Liao 	case RT5659_DRC2_CTRL_2:
999d3cb2de2SBard Liao 	case RT5659_DRC2_CTRL_3:
1000d3cb2de2SBard Liao 	case RT5659_DRC2_CTRL_4:
1001d3cb2de2SBard Liao 	case RT5659_DRC2_CTRL_5:
1002d3cb2de2SBard Liao 	case RT5659_DRC2_CTRL_6:
1003d3cb2de2SBard Liao 	case RT5659_DRC2_HARD_LMT_CTRL_1:
1004d3cb2de2SBard Liao 	case RT5659_DRC2_HARD_LMT_CTRL_2:
1005d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_1:
1006d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_2:
1007d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_3:
1008d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_4:
1009d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_5:
1010d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_6:
1011d3cb2de2SBard Liao 	case RT5659_DRC1_PRIV_7:
1012d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_1:
1013d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_2:
1014d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_3:
1015d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_4:
1016d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_5:
1017d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_6:
1018d3cb2de2SBard Liao 	case RT5659_DRC2_PRIV_7:
1019d3cb2de2SBard Liao 	case RT5659_MULTI_DRC_CTRL:
1020d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_1:
1021d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_2:
1022d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_3:
1023d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_4:
1024d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_5:
1025d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_6:
1026d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_7:
1027d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_8:
1028d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_9:
1029d3cb2de2SBard Liao 	case RT5659_CROSS_OVER_10:
1030d3cb2de2SBard Liao 	case RT5659_ALC_PGA_CTRL_1:
1031d3cb2de2SBard Liao 	case RT5659_ALC_PGA_CTRL_2:
1032d3cb2de2SBard Liao 	case RT5659_ALC_PGA_CTRL_3:
1033d3cb2de2SBard Liao 	case RT5659_ALC_PGA_CTRL_4:
1034d3cb2de2SBard Liao 	case RT5659_ALC_PGA_CTRL_5:
1035d3cb2de2SBard Liao 	case RT5659_ALC_PGA_CTRL_6:
1036d3cb2de2SBard Liao 	case RT5659_ALC_PGA_CTRL_7:
1037d3cb2de2SBard Liao 	case RT5659_ALC_PGA_CTRL_8:
1038d3cb2de2SBard Liao 	case RT5659_ALC_PGA_STA_1:
1039d3cb2de2SBard Liao 	case RT5659_ALC_PGA_STA_2:
1040d3cb2de2SBard Liao 	case RT5659_ALC_PGA_STA_3:
1041d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_PRE_VOL:
1042d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_PRE_VOL:
1043d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_POST_VOL:
1044d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_POST_VOL:
1045d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_LPF1_A1:
1046d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_LPF1_H0:
1047d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_LPF1_A1:
1048d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_LPF1_H0:
1049d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF2_A1:
1050d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF2_A2:
1051d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF2_H0:
1052d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF2_A1:
1053d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF2_A2:
1054d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF2_H0:
1055d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF3_A1:
1056d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF3_A2:
1057d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF3_H0:
1058d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF3_A1:
1059d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF3_A2:
1060d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF3_H0:
1061d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF4_A1:
1062d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF4_A2:
1063d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_BPF4_H0:
1064d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF4_A1:
1065d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF4_A2:
1066d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_BPF4_H0:
1067d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_HPF1_A1:
1068d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_HPF1_H0:
1069d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_HPF1_A1:
1070d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_HPF1_H0:
1071d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_HPF2_A1:
1072d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_HPF2_A2:
1073d3cb2de2SBard Liao 	case RT5659_DAC_L_EQ_HPF2_H0:
1074d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_HPF2_A1:
1075d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_HPF2_A2:
1076d3cb2de2SBard Liao 	case RT5659_DAC_R_EQ_HPF2_H0:
1077d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_H0_1:
1078d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_H0_2:
1079d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_B1_1:
1080d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_B1_2:
1081d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_B2_1:
1082d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_B2_2:
1083d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_A1_1:
1084d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_A1_2:
1085d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_A2_1:
1086d3cb2de2SBard Liao 	case RT5659_DAC_L_BI_EQ_BPF1_A2_2:
1087d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_H0_1:
1088d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_H0_2:
1089d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_B1_1:
1090d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_B1_2:
1091d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_B2_1:
1092d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_B2_2:
1093d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_A1_1:
1094d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_A1_2:
1095d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_A2_1:
1096d3cb2de2SBard Liao 	case RT5659_DAC_R_BI_EQ_BPF1_A2_2:
1097d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_LPF1_A1:
1098d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_LPF1_A1:
1099d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_LPF1_H0:
1100d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_LPF1_H0:
1101d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF1_A1:
1102d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF1_A1:
1103d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF1_A2:
1104d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF1_A2:
1105d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF1_H0:
1106d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF1_H0:
1107d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF2_A1:
1108d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF2_A1:
1109d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF2_A2:
1110d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF2_A2:
1111d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF2_H0:
1112d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF2_H0:
1113d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF3_A1:
1114d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF3_A1:
1115d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF3_A2:
1116d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF3_A2:
1117d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF3_H0:
1118d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF3_H0:
1119d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF4_A1:
1120d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF4_A1:
1121d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF4_A2:
1122d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF4_A2:
1123d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_BPF4_H0:
1124d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_BPF4_H0:
1125d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_HPF1_A1:
1126d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_HPF1_A1:
1127d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_HPF1_H0:
1128d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_HPF1_H0:
1129d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_PRE_VOL:
1130d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_PRE_VOL:
1131d3cb2de2SBard Liao 	case RT5659_ADC_L_EQ_POST_VOL:
1132d3cb2de2SBard Liao 	case RT5659_ADC_R_EQ_POST_VOL:
1133d3cb2de2SBard Liao 		return true;
1134d3cb2de2SBard Liao 	default:
1135d3cb2de2SBard Liao 		return false;
1136d3cb2de2SBard Liao 	}
1137d3cb2de2SBard Liao }
1138d3cb2de2SBard Liao 
1139d3cb2de2SBard Liao static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -2325, 75, 0);
1140d3cb2de2SBard Liao static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
1141d3cb2de2SBard Liao static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
1142d3cb2de2SBard Liao static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
1143d3cb2de2SBard Liao static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
1144d3cb2de2SBard Liao static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
1145d3cb2de2SBard Liao static const DECLARE_TLV_DB_SCALE(in_bst_tlv, -1200, 75, 0);
1146d3cb2de2SBard Liao 
1147d3cb2de2SBard Liao /* Interface data select */
1148d3cb2de2SBard Liao static const char * const rt5659_data_select[] = {
1149d3cb2de2SBard Liao 	"L/R", "R/L", "L/L", "R/R"
1150d3cb2de2SBard Liao };
1151d3cb2de2SBard Liao 
1152d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(rt5659_if1_01_adc_enum,
1153d3cb2de2SBard Liao 	RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT01_SFT, rt5659_data_select);
1154d3cb2de2SBard Liao 
1155d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(rt5659_if1_23_adc_enum,
1156d3cb2de2SBard Liao 	RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT23_SFT, rt5659_data_select);
1157d3cb2de2SBard Liao 
1158d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(rt5659_if1_45_adc_enum,
1159d3cb2de2SBard Liao 	RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT45_SFT, rt5659_data_select);
1160d3cb2de2SBard Liao 
1161d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(rt5659_if1_67_adc_enum,
1162d3cb2de2SBard Liao 	RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT67_SFT, rt5659_data_select);
1163d3cb2de2SBard Liao 
1164d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(rt5659_if2_dac_enum,
1165d3cb2de2SBard Liao 	RT5659_DIG_INF23_DATA, RT5659_IF2_DAC_SEL_SFT, rt5659_data_select);
1166d3cb2de2SBard Liao 
1167d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(rt5659_if2_adc_enum,
1168d3cb2de2SBard Liao 	RT5659_DIG_INF23_DATA, RT5659_IF2_ADC_SEL_SFT, rt5659_data_select);
1169d3cb2de2SBard Liao 
1170d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(rt5659_if3_dac_enum,
1171d3cb2de2SBard Liao 	RT5659_DIG_INF23_DATA, RT5659_IF3_DAC_SEL_SFT, rt5659_data_select);
1172d3cb2de2SBard Liao 
1173d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(rt5659_if3_adc_enum,
1174d3cb2de2SBard Liao 	RT5659_DIG_INF23_DATA, RT5659_IF3_ADC_SEL_SFT, rt5659_data_select);
1175d3cb2de2SBard Liao 
1176d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if1_01_adc_swap_mux =
1177d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF1 01 ADC Swap Source", rt5659_if1_01_adc_enum);
1178d3cb2de2SBard Liao 
1179d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if1_23_adc_swap_mux =
1180d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF1 23 ADC1 Swap Source", rt5659_if1_23_adc_enum);
1181d3cb2de2SBard Liao 
1182d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if1_45_adc_swap_mux =
1183d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF1 45 ADC1 Swap Source", rt5659_if1_45_adc_enum);
1184d3cb2de2SBard Liao 
1185d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if1_67_adc_swap_mux =
1186d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF1 67 ADC1 Swap Source", rt5659_if1_67_adc_enum);
1187d3cb2de2SBard Liao 
1188d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if2_dac_swap_mux =
1189d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF2 DAC Swap Source", rt5659_if2_dac_enum);
1190d3cb2de2SBard Liao 
1191d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if2_adc_swap_mux =
1192d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF2 ADC Swap Source", rt5659_if2_adc_enum);
1193d3cb2de2SBard Liao 
1194d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if3_dac_swap_mux =
1195d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF3 DAC Swap Source", rt5659_if3_dac_enum);
1196d3cb2de2SBard Liao 
1197d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if3_adc_swap_mux =
1198d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF3 ADC Swap Source", rt5659_if3_adc_enum);
1199d3cb2de2SBard Liao 
1200d3cb2de2SBard Liao static const char * const rt5659_asrc_clk_src[] = {
1201d3cb2de2SBard Liao 	"clk_sysy_div_out", "clk_i2s1_track", "clk_i2s2_track",
1202d3cb2de2SBard Liao 	"clk_i2s3_track", "clk_sys2", "clk_sys3"
1203d3cb2de2SBard Liao };
1204d3cb2de2SBard Liao 
1205d3cb2de2SBard Liao static unsigned int rt5659_asrc_clk_map_values[] = {
1206d3cb2de2SBard Liao 	0, 1, 2, 3, 5, 6,
1207d3cb2de2SBard Liao };
1208d3cb2de2SBard Liao 
1209d3cb2de2SBard Liao static const SOC_VALUE_ENUM_SINGLE_DECL(
1210d3cb2de2SBard Liao 	rt5659_da_sto_asrc_enum, RT5659_ASRC_2, RT5659_DA_STO_T_SFT, 0x7,
1211d3cb2de2SBard Liao 	rt5659_asrc_clk_src, rt5659_asrc_clk_map_values);
1212d3cb2de2SBard Liao 
1213d3cb2de2SBard Liao static const SOC_VALUE_ENUM_SINGLE_DECL(
1214d3cb2de2SBard Liao 	rt5659_da_monol_asrc_enum, RT5659_ASRC_2, RT5659_DA_MONO_L_T_SFT, 0x7,
1215d3cb2de2SBard Liao 	rt5659_asrc_clk_src, rt5659_asrc_clk_map_values);
1216d3cb2de2SBard Liao 
1217d3cb2de2SBard Liao static const SOC_VALUE_ENUM_SINGLE_DECL(
1218d3cb2de2SBard Liao 	rt5659_da_monor_asrc_enum, RT5659_ASRC_2, RT5659_DA_MONO_R_T_SFT, 0x7,
1219d3cb2de2SBard Liao 	rt5659_asrc_clk_src, rt5659_asrc_clk_map_values);
1220d3cb2de2SBard Liao 
1221d3cb2de2SBard Liao static const SOC_VALUE_ENUM_SINGLE_DECL(
1222d3cb2de2SBard Liao 	rt5659_ad_sto1_asrc_enum, RT5659_ASRC_2, RT5659_AD_STO1_T_SFT, 0x7,
1223d3cb2de2SBard Liao 	rt5659_asrc_clk_src, rt5659_asrc_clk_map_values);
1224d3cb2de2SBard Liao 
1225d3cb2de2SBard Liao static const SOC_VALUE_ENUM_SINGLE_DECL(
1226d3cb2de2SBard Liao 	rt5659_ad_sto2_asrc_enum, RT5659_ASRC_3, RT5659_AD_STO2_T_SFT, 0x7,
1227d3cb2de2SBard Liao 	rt5659_asrc_clk_src, rt5659_asrc_clk_map_values);
1228d3cb2de2SBard Liao 
1229d3cb2de2SBard Liao static const SOC_VALUE_ENUM_SINGLE_DECL(
1230d3cb2de2SBard Liao 	rt5659_ad_monol_asrc_enum, RT5659_ASRC_3, RT5659_AD_MONO_L_T_SFT, 0x7,
1231d3cb2de2SBard Liao 	rt5659_asrc_clk_src, rt5659_asrc_clk_map_values);
1232d3cb2de2SBard Liao 
1233d3cb2de2SBard Liao static const SOC_VALUE_ENUM_SINGLE_DECL(
1234d3cb2de2SBard Liao 	rt5659_ad_monor_asrc_enum, RT5659_ASRC_3, RT5659_AD_MONO_R_T_SFT, 0x7,
1235d3cb2de2SBard Liao 	rt5659_asrc_clk_src, rt5659_asrc_clk_map_values);
1236d3cb2de2SBard Liao 
1237d3cb2de2SBard Liao static int rt5659_hp_vol_put(struct snd_kcontrol *kcontrol,
1238d3cb2de2SBard Liao 		struct snd_ctl_elem_value *ucontrol)
1239d3cb2de2SBard Liao {
1240d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
1241d3cb2de2SBard Liao 	int ret = snd_soc_put_volsw(kcontrol, ucontrol);
1242d3cb2de2SBard Liao 
1243d3cb2de2SBard Liao 	if (snd_soc_read(codec, RT5659_STO_NG2_CTRL_1) & RT5659_NG2_EN) {
1244d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_STO_NG2_CTRL_1,
1245d3cb2de2SBard Liao 			RT5659_NG2_EN_MASK, RT5659_NG2_DIS);
1246d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_STO_NG2_CTRL_1,
1247d3cb2de2SBard Liao 			RT5659_NG2_EN_MASK, RT5659_NG2_EN);
1248d3cb2de2SBard Liao 	}
1249d3cb2de2SBard Liao 
1250d3cb2de2SBard Liao 	return ret;
1251d3cb2de2SBard Liao }
1252d3cb2de2SBard Liao 
1253d3cb2de2SBard Liao static void rt5659_enable_push_button_irq(struct snd_soc_codec *codec,
1254d3cb2de2SBard Liao 	bool enable)
1255d3cb2de2SBard Liao {
1256d3cb2de2SBard Liao 	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
1257d3cb2de2SBard Liao 
1258d3cb2de2SBard Liao 	if (enable) {
1259d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_4BTN_IL_CMD_1, 0x000b);
1260d3cb2de2SBard Liao 
1261d3cb2de2SBard Liao 		/* MICBIAS1 and Mic Det Power for button detect*/
1262d3cb2de2SBard Liao 		snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
1263d3cb2de2SBard Liao 		snd_soc_dapm_force_enable_pin(dapm,
1264d3cb2de2SBard Liao 			"Mic Det Power");
1265d3cb2de2SBard Liao 		snd_soc_dapm_sync(dapm);
1266d3cb2de2SBard Liao 
1267d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_PWR_ANLG_2,
1268d3cb2de2SBard Liao 			RT5659_PWR_MB1, RT5659_PWR_MB1);
1269d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_PWR_VOL,
1270d3cb2de2SBard Liao 			RT5659_PWR_MIC_DET, RT5659_PWR_MIC_DET);
1271d3cb2de2SBard Liao 
1272d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_IRQ_CTRL_2,
1273d3cb2de2SBard Liao 				RT5659_IL_IRQ_MASK, RT5659_IL_IRQ_EN);
1274d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_4BTN_IL_CMD_2,
1275d3cb2de2SBard Liao 				RT5659_4BTN_IL_MASK, RT5659_4BTN_IL_EN);
1276d3cb2de2SBard Liao 	} else {
1277d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_4BTN_IL_CMD_2,
1278d3cb2de2SBard Liao 				RT5659_4BTN_IL_MASK, RT5659_4BTN_IL_DIS);
1279d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_IRQ_CTRL_2,
1280d3cb2de2SBard Liao 				RT5659_IL_IRQ_MASK, RT5659_IL_IRQ_DIS);
1281d3cb2de2SBard Liao 		/* MICBIAS1 and Mic Det Power for button detect*/
1282d3cb2de2SBard Liao 		snd_soc_dapm_disable_pin(dapm, "MICBIAS1");
1283d3cb2de2SBard Liao 		snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
1284d3cb2de2SBard Liao 		snd_soc_dapm_sync(dapm);
1285d3cb2de2SBard Liao 	}
1286d3cb2de2SBard Liao }
1287d3cb2de2SBard Liao 
1288d3cb2de2SBard Liao /**
1289d3cb2de2SBard Liao  * rt5659_headset_detect - Detect headset.
1290d3cb2de2SBard Liao  * @codec: SoC audio codec device.
1291d3cb2de2SBard Liao  * @jack_insert: Jack insert or not.
1292d3cb2de2SBard Liao  *
1293d3cb2de2SBard Liao  * Detect whether is headset or not when jack inserted.
1294d3cb2de2SBard Liao  *
1295d3cb2de2SBard Liao  * Returns detect status.
1296d3cb2de2SBard Liao  */
1297d3cb2de2SBard Liao 
1298d3cb2de2SBard Liao static int rt5659_headset_detect(struct snd_soc_codec *codec, int jack_insert)
1299d3cb2de2SBard Liao {
1300d3cb2de2SBard Liao 	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
1301d3cb2de2SBard Liao 	int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30};
1302d3cb2de2SBard Liao 	int reg_63;
1303d3cb2de2SBard Liao 
1304d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
1305d3cb2de2SBard Liao 
1306d3cb2de2SBard Liao 	if (jack_insert) {
1307d3cb2de2SBard Liao 		snd_soc_dapm_force_enable_pin(dapm,
1308d3cb2de2SBard Liao 			"Mic Det Power");
1309d3cb2de2SBard Liao 		snd_soc_dapm_sync(dapm);
1310d3cb2de2SBard Liao 		reg_63 = snd_soc_read(codec, RT5659_PWR_ANLG_1);
1311d3cb2de2SBard Liao 
1312d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_PWR_ANLG_1,
1313d3cb2de2SBard Liao 			RT5659_PWR_VREF2 | RT5659_PWR_MB,
1314d3cb2de2SBard Liao 			RT5659_PWR_VREF2 | RT5659_PWR_MB);
1315d3cb2de2SBard Liao 		msleep(20);
1316d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_PWR_ANLG_1,
1317d3cb2de2SBard Liao 			RT5659_PWR_FV2, RT5659_PWR_FV2);
1318d3cb2de2SBard Liao 
1319d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_EJD_CTRL_2, 0x4160);
1320d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_EJD_CTRL_1,
1321d3cb2de2SBard Liao 			0x20, 0x0);
1322d3cb2de2SBard Liao 		msleep(20);
1323d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_EJD_CTRL_1,
1324d3cb2de2SBard Liao 			0x20, 0x20);
1325d3cb2de2SBard Liao 
1326d3cb2de2SBard Liao 		while (i < 5) {
1327d3cb2de2SBard Liao 			msleep(sleep_time[i]);
1328d3cb2de2SBard Liao 			val = snd_soc_read(codec, RT5659_EJD_CTRL_2) & 0x0003;
1329d3cb2de2SBard Liao 			i++;
1330d3cb2de2SBard Liao 			if (val == 0x1 || val == 0x2 || val == 0x3)
1331d3cb2de2SBard Liao 				break;
1332d3cb2de2SBard Liao 		}
1333d3cb2de2SBard Liao 
1334d3cb2de2SBard Liao 		switch (val) {
1335d3cb2de2SBard Liao 		case 1:
1336d3cb2de2SBard Liao 			rt5659->jack_type = SND_JACK_HEADSET;
1337d3cb2de2SBard Liao 			rt5659_enable_push_button_irq(codec, true);
1338d3cb2de2SBard Liao 			break;
1339d3cb2de2SBard Liao 		default:
1340d3cb2de2SBard Liao 			snd_soc_write(codec, RT5659_PWR_ANLG_1, reg_63);
1341d3cb2de2SBard Liao 			rt5659->jack_type = SND_JACK_HEADPHONE;
1342d3cb2de2SBard Liao 			snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
1343d3cb2de2SBard Liao 			snd_soc_dapm_sync(dapm);
1344d3cb2de2SBard Liao 			break;
1345d3cb2de2SBard Liao 		}
1346d3cb2de2SBard Liao 	} else {
1347d3cb2de2SBard Liao 		snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
1348d3cb2de2SBard Liao 		snd_soc_dapm_sync(dapm);
1349d3cb2de2SBard Liao 		if (rt5659->jack_type == SND_JACK_HEADSET)
1350d3cb2de2SBard Liao 			rt5659_enable_push_button_irq(codec, false);
1351d3cb2de2SBard Liao 		rt5659->jack_type = 0;
1352d3cb2de2SBard Liao 	}
1353d3cb2de2SBard Liao 
1354d3cb2de2SBard Liao 	dev_dbg(codec->dev, "jack_type = %d\n", rt5659->jack_type);
1355d3cb2de2SBard Liao 	return rt5659->jack_type;
1356d3cb2de2SBard Liao }
1357d3cb2de2SBard Liao 
1358d3cb2de2SBard Liao static int rt5659_button_detect(struct snd_soc_codec *codec)
1359d3cb2de2SBard Liao {
1360d3cb2de2SBard Liao 	int btn_type, val;
1361d3cb2de2SBard Liao 
1362d3cb2de2SBard Liao 	val = snd_soc_read(codec, RT5659_4BTN_IL_CMD_1);
1363d3cb2de2SBard Liao 	btn_type = val & 0xfff0;
1364d3cb2de2SBard Liao 	snd_soc_write(codec, RT5659_4BTN_IL_CMD_1, val);
1365d3cb2de2SBard Liao 
1366d3cb2de2SBard Liao 	return btn_type;
1367d3cb2de2SBard Liao }
1368d3cb2de2SBard Liao 
1369d3cb2de2SBard Liao static irqreturn_t rt5659_irq(int irq, void *data)
1370d3cb2de2SBard Liao {
1371d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = data;
1372d3cb2de2SBard Liao 
1373d3cb2de2SBard Liao 	queue_delayed_work(system_power_efficient_wq,
1374d3cb2de2SBard Liao 			   &rt5659->jack_detect_work, msecs_to_jiffies(250));
1375d3cb2de2SBard Liao 
1376d3cb2de2SBard Liao 	return IRQ_HANDLED;
1377d3cb2de2SBard Liao }
1378d3cb2de2SBard Liao 
1379d3cb2de2SBard Liao int rt5659_set_jack_detect(struct snd_soc_codec *codec,
1380d3cb2de2SBard Liao 	struct snd_soc_jack *hs_jack)
1381d3cb2de2SBard Liao {
1382d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
1383d3cb2de2SBard Liao 
1384d3cb2de2SBard Liao 	rt5659->hs_jack = hs_jack;
1385d3cb2de2SBard Liao 
1386d3cb2de2SBard Liao 	rt5659_irq(0, rt5659);
1387d3cb2de2SBard Liao 
1388d3cb2de2SBard Liao 	return 0;
1389d3cb2de2SBard Liao }
1390d3cb2de2SBard Liao EXPORT_SYMBOL_GPL(rt5659_set_jack_detect);
1391d3cb2de2SBard Liao 
1392d3cb2de2SBard Liao static void rt5659_jack_detect_work(struct work_struct *work)
1393d3cb2de2SBard Liao {
1394d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 =
1395d3cb2de2SBard Liao 		container_of(work, struct rt5659_priv, jack_detect_work.work);
1396d3cb2de2SBard Liao 	int val, btn_type, report = 0;
1397d3cb2de2SBard Liao 
1398d3cb2de2SBard Liao 	if (!rt5659->codec)
1399d3cb2de2SBard Liao 		return;
1400d3cb2de2SBard Liao 
1401d3cb2de2SBard Liao 	val = snd_soc_read(rt5659->codec, RT5659_INT_ST_1) & 0x0080;
1402d3cb2de2SBard Liao 	if (!val) {
1403d3cb2de2SBard Liao 		/* jack in */
1404d3cb2de2SBard Liao 		if (rt5659->jack_type == 0) {
1405d3cb2de2SBard Liao 			/* jack was out, report jack type */
1406d3cb2de2SBard Liao 			report = rt5659_headset_detect(rt5659->codec, 1);
1407d3cb2de2SBard Liao 		} else {
1408d3cb2de2SBard Liao 			/* jack is already in, report button event */
1409d3cb2de2SBard Liao 			report = SND_JACK_HEADSET;
1410d3cb2de2SBard Liao 			btn_type = rt5659_button_detect(rt5659->codec);
1411d3cb2de2SBard Liao 			/**
1412d3cb2de2SBard Liao 			 * rt5659 can report three kinds of button behavior,
1413d3cb2de2SBard Liao 			 * one click, double click and hold. However,
1414d3cb2de2SBard Liao 			 * currently we will report button pressed/released
1415d3cb2de2SBard Liao 			 * event. So all the three button behaviors are
1416d3cb2de2SBard Liao 			 * treated as button pressed.
1417d3cb2de2SBard Liao 			 */
1418d3cb2de2SBard Liao 			switch (btn_type) {
1419d3cb2de2SBard Liao 			case 0x8000:
1420d3cb2de2SBard Liao 			case 0x4000:
1421d3cb2de2SBard Liao 			case 0x2000:
1422d3cb2de2SBard Liao 				report |= SND_JACK_BTN_0;
1423d3cb2de2SBard Liao 				break;
1424d3cb2de2SBard Liao 			case 0x1000:
1425d3cb2de2SBard Liao 			case 0x0800:
1426d3cb2de2SBard Liao 			case 0x0400:
1427d3cb2de2SBard Liao 				report |= SND_JACK_BTN_1;
1428d3cb2de2SBard Liao 				break;
1429d3cb2de2SBard Liao 			case 0x0200:
1430d3cb2de2SBard Liao 			case 0x0100:
1431d3cb2de2SBard Liao 			case 0x0080:
1432d3cb2de2SBard Liao 				report |= SND_JACK_BTN_2;
1433d3cb2de2SBard Liao 				break;
1434d3cb2de2SBard Liao 			case 0x0040:
1435d3cb2de2SBard Liao 			case 0x0020:
1436d3cb2de2SBard Liao 			case 0x0010:
1437d3cb2de2SBard Liao 				report |= SND_JACK_BTN_3;
1438d3cb2de2SBard Liao 				break;
1439d3cb2de2SBard Liao 			case 0x0000: /* unpressed */
1440d3cb2de2SBard Liao 				break;
1441d3cb2de2SBard Liao 			default:
1442d3cb2de2SBard Liao 				btn_type = 0;
1443d3cb2de2SBard Liao 				dev_err(rt5659->codec->dev,
1444d3cb2de2SBard Liao 					"Unexpected button code 0x%04x\n",
1445d3cb2de2SBard Liao 					btn_type);
1446d3cb2de2SBard Liao 				break;
1447d3cb2de2SBard Liao 			}
1448d3cb2de2SBard Liao 
1449d3cb2de2SBard Liao 			/* button release or spurious interrput*/
1450d3cb2de2SBard Liao 			if (btn_type == 0)
1451d3cb2de2SBard Liao 				report =  rt5659->jack_type;
1452d3cb2de2SBard Liao 		}
1453d3cb2de2SBard Liao 	} else {
1454d3cb2de2SBard Liao 		/* jack out */
1455d3cb2de2SBard Liao 		report = rt5659_headset_detect(rt5659->codec, 0);
1456d3cb2de2SBard Liao 	}
1457d3cb2de2SBard Liao 
1458d3cb2de2SBard Liao 	snd_soc_jack_report(rt5659->hs_jack, report, SND_JACK_HEADSET |
1459d3cb2de2SBard Liao 			    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
1460d3cb2de2SBard Liao 			    SND_JACK_BTN_2 | SND_JACK_BTN_3);
1461d3cb2de2SBard Liao }
1462d3cb2de2SBard Liao 
1463d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_snd_controls[] = {
1464d3cb2de2SBard Liao 	/* Speaker Output Volume */
1465d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("Speaker Playback Volume", RT5659_SPO_VOL,
1466d3cb2de2SBard Liao 		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 39, 1, out_vol_tlv),
1467d3cb2de2SBard Liao 
1468d3cb2de2SBard Liao 	/* Headphone Output Volume */
1469d3cb2de2SBard Liao 	SOC_DOUBLE_R_EXT_TLV("Headphone Playback Volume", RT5659_HPL_GAIN,
1470d3cb2de2SBard Liao 		RT5659_HPR_GAIN, RT5659_G_HP_SFT, 31, 1, snd_soc_get_volsw,
1471d3cb2de2SBard Liao 		rt5659_hp_vol_put, hp_vol_tlv),
1472d3cb2de2SBard Liao 
1473d3cb2de2SBard Liao 	/* Mono Output Volume */
1474d3cb2de2SBard Liao 	SOC_SINGLE_TLV("Mono Playback Volume", RT5659_MONO_OUT,
1475d3cb2de2SBard Liao 		RT5659_L_VOL_SFT, 39, 1, out_vol_tlv),
1476d3cb2de2SBard Liao 
1477d3cb2de2SBard Liao 	/* Output Volume */
1478d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("OUT Playback Volume", RT5659_LOUT,
1479d3cb2de2SBard Liao 		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 39, 1, out_vol_tlv),
1480d3cb2de2SBard Liao 
1481d3cb2de2SBard Liao 	/* DAC Digital Volume */
1482d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5659_DAC1_DIG_VOL,
1483d3cb2de2SBard Liao 		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 175, 0, dac_vol_tlv),
1484d3cb2de2SBard Liao 	SOC_DOUBLE("DAC1 Playback Switch", RT5659_AD_DA_MIXER,
1485d3cb2de2SBard Liao 		RT5659_M_DAC1_L_SFT, RT5659_M_DAC1_R_SFT, 1, 1),
1486d3cb2de2SBard Liao 
1487d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5659_DAC2_DIG_VOL,
1488d3cb2de2SBard Liao 		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 175, 0, dac_vol_tlv),
1489d3cb2de2SBard Liao 	SOC_DOUBLE("DAC2 Playback Switch", RT5659_DAC_CTRL,
1490d3cb2de2SBard Liao 		RT5659_M_DAC2_L_VOL_SFT, RT5659_M_DAC2_R_VOL_SFT, 1, 1),
1491d3cb2de2SBard Liao 
1492d3cb2de2SBard Liao 	/* IN1/IN2/IN3/IN4 Volume */
1493d3cb2de2SBard Liao 	SOC_SINGLE_TLV("IN1 Boost Volume", RT5659_IN1_IN2,
1494d3cb2de2SBard Liao 		RT5659_BST1_SFT, 69, 0, in_bst_tlv),
1495d3cb2de2SBard Liao 	SOC_SINGLE_TLV("IN2 Boost Volume", RT5659_IN1_IN2,
1496d3cb2de2SBard Liao 		RT5659_BST2_SFT, 69, 0, in_bst_tlv),
1497d3cb2de2SBard Liao 	SOC_SINGLE_TLV("IN3 Boost Volume", RT5659_IN3_IN4,
1498d3cb2de2SBard Liao 		RT5659_BST3_SFT, 69, 0, in_bst_tlv),
1499d3cb2de2SBard Liao 	SOC_SINGLE_TLV("IN4 Boost Volume", RT5659_IN3_IN4,
1500d3cb2de2SBard Liao 		RT5659_BST4_SFT, 69, 0, in_bst_tlv),
1501d3cb2de2SBard Liao 
1502d3cb2de2SBard Liao 	/* INL/INR Volume Control */
1503d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("IN Capture Volume", RT5659_INL1_INR1_VOL,
1504d3cb2de2SBard Liao 		RT5659_INL_VOL_SFT, RT5659_INR_VOL_SFT, 31, 1, in_vol_tlv),
1505d3cb2de2SBard Liao 
1506d3cb2de2SBard Liao 	/* ADC Digital Volume Control */
1507d3cb2de2SBard Liao 	SOC_DOUBLE("STO1 ADC Capture Switch", RT5659_STO1_ADC_DIG_VOL,
1508d3cb2de2SBard Liao 		RT5659_L_MUTE_SFT, RT5659_R_MUTE_SFT, 1, 1),
1509d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("STO1 ADC Capture Volume", RT5659_STO1_ADC_DIG_VOL,
1510d3cb2de2SBard Liao 		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 127, 0, adc_vol_tlv),
1511d3cb2de2SBard Liao 	SOC_DOUBLE("Mono ADC Capture Switch", RT5659_MONO_ADC_DIG_VOL,
1512d3cb2de2SBard Liao 		RT5659_L_MUTE_SFT, RT5659_R_MUTE_SFT, 1, 1),
1513d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5659_MONO_ADC_DIG_VOL,
1514d3cb2de2SBard Liao 		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 127, 0, adc_vol_tlv),
1515d3cb2de2SBard Liao 	SOC_DOUBLE("STO2 ADC Capture Switch", RT5659_STO2_ADC_DIG_VOL,
1516d3cb2de2SBard Liao 		RT5659_L_MUTE_SFT, RT5659_R_MUTE_SFT, 1, 1),
1517d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("STO2 ADC Capture Volume", RT5659_STO2_ADC_DIG_VOL,
1518d3cb2de2SBard Liao 		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 127, 0, adc_vol_tlv),
1519d3cb2de2SBard Liao 
1520d3cb2de2SBard Liao 	/* ADC Boost Volume Control */
1521d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("STO1 ADC Boost Gain Volume", RT5659_STO1_BOOST,
1522d3cb2de2SBard Liao 		RT5659_STO1_ADC_L_BST_SFT, RT5659_STO1_ADC_R_BST_SFT,
1523d3cb2de2SBard Liao 		3, 0, adc_bst_tlv),
1524d3cb2de2SBard Liao 
1525d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("Mono ADC Boost Gain Volume", RT5659_MONO_BOOST,
1526d3cb2de2SBard Liao 		RT5659_MONO_ADC_L_BST_SFT, RT5659_MONO_ADC_R_BST_SFT,
1527d3cb2de2SBard Liao 		3, 0, adc_bst_tlv),
1528d3cb2de2SBard Liao 
1529d3cb2de2SBard Liao 	SOC_DOUBLE_TLV("STO2 ADC Boost Gain Volume", RT5659_STO2_BOOST,
1530d3cb2de2SBard Liao 		RT5659_STO2_ADC_L_BST_SFT, RT5659_STO2_ADC_R_BST_SFT,
1531d3cb2de2SBard Liao 		3, 0, adc_bst_tlv),
1532d3cb2de2SBard Liao 
1533d3cb2de2SBard Liao 	SOC_SINGLE("DAC IF1 DAC1 L Data Switch", RT5659_TDM_CTRL_4, 12, 7, 0),
1534d3cb2de2SBard Liao 	SOC_SINGLE("DAC IF1 DAC1 R Data Switch", RT5659_TDM_CTRL_4, 8, 7, 0),
1535d3cb2de2SBard Liao 	SOC_SINGLE("DAC IF1 DAC2 L Data Switch", RT5659_TDM_CTRL_4, 4, 7, 0),
1536d3cb2de2SBard Liao 	SOC_SINGLE("DAC IF1 DAC2 R Data Switch", RT5659_TDM_CTRL_4, 0, 7, 0),
1537d3cb2de2SBard Liao };
1538d3cb2de2SBard Liao 
1539d3cb2de2SBard Liao /**
1540d3cb2de2SBard Liao  * set_dmic_clk - Set parameter of dmic.
1541d3cb2de2SBard Liao  *
1542d3cb2de2SBard Liao  * @w: DAPM widget.
1543d3cb2de2SBard Liao  * @kcontrol: The kcontrol of this widget.
1544d3cb2de2SBard Liao  * @event: Event id.
1545d3cb2de2SBard Liao  *
1546d3cb2de2SBard Liao  * Choose dmic clock between 1MHz and 3MHz.
1547d3cb2de2SBard Liao  * It is better for clock to approximate 3MHz.
1548d3cb2de2SBard Liao  */
1549d3cb2de2SBard Liao static int set_dmic_clk(struct snd_soc_dapm_widget *w,
1550d3cb2de2SBard Liao 	struct snd_kcontrol *kcontrol, int event)
1551d3cb2de2SBard Liao {
1552d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1553d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
1554d3cb2de2SBard Liao 	int pd, idx = -EINVAL;
1555d3cb2de2SBard Liao 
1556d3cb2de2SBard Liao 	pd = rl6231_get_pre_div(rt5659->regmap,
1557d3cb2de2SBard Liao 		RT5659_ADDA_CLK_1, RT5659_I2S_PD1_SFT);
1558d3cb2de2SBard Liao 	idx = rl6231_calc_dmic_clk(rt5659->sysclk / pd);
1559d3cb2de2SBard Liao 
1560d3cb2de2SBard Liao 	if (idx < 0)
1561d3cb2de2SBard Liao 		dev_err(codec->dev, "Failed to set DMIC clock\n");
1562d3cb2de2SBard Liao 	else {
1563d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_DMIC_CTRL_1,
1564d3cb2de2SBard Liao 			RT5659_DMIC_CLK_MASK, idx << RT5659_DMIC_CLK_SFT);
1565d3cb2de2SBard Liao 	}
1566d3cb2de2SBard Liao 	return idx;
1567d3cb2de2SBard Liao }
1568d3cb2de2SBard Liao 
1569d3cb2de2SBard Liao static int set_adc_clk(struct snd_soc_dapm_widget *w,
1570d3cb2de2SBard Liao 	struct snd_kcontrol *kcontrol, int event)
1571d3cb2de2SBard Liao {
1572d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1573d3cb2de2SBard Liao 
1574d3cb2de2SBard Liao 	switch (event) {
1575d3cb2de2SBard Liao 	case SND_SOC_DAPM_POST_PMU:
1576d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_CHOP_ADC,
1577d3cb2de2SBard Liao 			RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK,
1578d3cb2de2SBard Liao 			RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK);
1579d3cb2de2SBard Liao 		break;
1580d3cb2de2SBard Liao 
1581d3cb2de2SBard Liao 	case SND_SOC_DAPM_PRE_PMD:
1582d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_CHOP_ADC,
1583d3cb2de2SBard Liao 			RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK, 0);
1584d3cb2de2SBard Liao 		break;
1585d3cb2de2SBard Liao 
1586d3cb2de2SBard Liao 	default:
1587d3cb2de2SBard Liao 		return 0;
1588d3cb2de2SBard Liao 	}
1589d3cb2de2SBard Liao 
1590d3cb2de2SBard Liao 	return 0;
1591d3cb2de2SBard Liao 
1592d3cb2de2SBard Liao }
1593d3cb2de2SBard Liao 
1594d3cb2de2SBard Liao static int rt5659_charge_pump_event(struct snd_soc_dapm_widget *w,
1595d3cb2de2SBard Liao 	struct snd_kcontrol *kcontrol, int event)
1596d3cb2de2SBard Liao {
1597d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1598d3cb2de2SBard Liao 
1599d3cb2de2SBard Liao 	switch (event) {
1600d3cb2de2SBard Liao 	case SND_SOC_DAPM_PRE_PMU:
1601d3cb2de2SBard Liao 		/* Depop */
1602d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_DEPOP_1, 0x0009);
1603d3cb2de2SBard Liao 		break;
1604d3cb2de2SBard Liao 	case SND_SOC_DAPM_POST_PMD:
1605d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_HP_CHARGE_PUMP_1, 0x0c16);
1606d3cb2de2SBard Liao 		break;
1607d3cb2de2SBard Liao 	default:
1608d3cb2de2SBard Liao 		return 0;
1609d3cb2de2SBard Liao 	}
1610d3cb2de2SBard Liao 
1611d3cb2de2SBard Liao 	return 0;
1612d3cb2de2SBard Liao }
1613d3cb2de2SBard Liao 
1614d3cb2de2SBard Liao static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *w,
1615d3cb2de2SBard Liao 			 struct snd_soc_dapm_widget *sink)
1616d3cb2de2SBard Liao {
1617d3cb2de2SBard Liao 	unsigned int val;
1618d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1619d3cb2de2SBard Liao 
1620d3cb2de2SBard Liao 	val = snd_soc_read(codec, RT5659_GLB_CLK);
1621d3cb2de2SBard Liao 	val &= RT5659_SCLK_SRC_MASK;
1622d3cb2de2SBard Liao 	if (val == RT5659_SCLK_SRC_PLL1)
1623d3cb2de2SBard Liao 		return 1;
1624d3cb2de2SBard Liao 	else
1625d3cb2de2SBard Liao 		return 0;
1626d3cb2de2SBard Liao }
1627d3cb2de2SBard Liao 
1628d3cb2de2SBard Liao static int is_using_asrc(struct snd_soc_dapm_widget *w,
1629d3cb2de2SBard Liao 			 struct snd_soc_dapm_widget *sink)
1630d3cb2de2SBard Liao {
1631d3cb2de2SBard Liao 	unsigned int reg, shift, val;
1632d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1633d3cb2de2SBard Liao 
1634d3cb2de2SBard Liao 	switch (w->shift) {
1635d3cb2de2SBard Liao 	case RT5659_ADC_MONO_R_ASRC_SFT:
1636d3cb2de2SBard Liao 		reg = RT5659_ASRC_3;
1637d3cb2de2SBard Liao 		shift = RT5659_AD_MONO_R_T_SFT;
1638d3cb2de2SBard Liao 		break;
1639d3cb2de2SBard Liao 	case RT5659_ADC_MONO_L_ASRC_SFT:
1640d3cb2de2SBard Liao 		reg = RT5659_ASRC_3;
1641d3cb2de2SBard Liao 		shift = RT5659_AD_MONO_L_T_SFT;
1642d3cb2de2SBard Liao 		break;
1643d3cb2de2SBard Liao 	case RT5659_ADC_STO1_ASRC_SFT:
1644d3cb2de2SBard Liao 		reg = RT5659_ASRC_2;
1645d3cb2de2SBard Liao 		shift = RT5659_AD_STO1_T_SFT;
1646d3cb2de2SBard Liao 		break;
1647d3cb2de2SBard Liao 	case RT5659_DAC_MONO_R_ASRC_SFT:
1648d3cb2de2SBard Liao 		reg = RT5659_ASRC_2;
1649d3cb2de2SBard Liao 		shift = RT5659_DA_MONO_R_T_SFT;
1650d3cb2de2SBard Liao 		break;
1651d3cb2de2SBard Liao 	case RT5659_DAC_MONO_L_ASRC_SFT:
1652d3cb2de2SBard Liao 		reg = RT5659_ASRC_2;
1653d3cb2de2SBard Liao 		shift = RT5659_DA_MONO_L_T_SFT;
1654d3cb2de2SBard Liao 		break;
1655d3cb2de2SBard Liao 	case RT5659_DAC_STO_ASRC_SFT:
1656d3cb2de2SBard Liao 		reg = RT5659_ASRC_2;
1657d3cb2de2SBard Liao 		shift = RT5659_DA_STO_T_SFT;
1658d3cb2de2SBard Liao 		break;
1659d3cb2de2SBard Liao 	default:
1660d3cb2de2SBard Liao 		return 0;
1661d3cb2de2SBard Liao 	}
1662d3cb2de2SBard Liao 
1663d3cb2de2SBard Liao 	val = (snd_soc_read(codec, reg) >> shift) & 0xf;
1664d3cb2de2SBard Liao 	switch (val) {
1665d3cb2de2SBard Liao 	case 1:
1666d3cb2de2SBard Liao 	case 2:
1667d3cb2de2SBard Liao 	case 3:
1668d3cb2de2SBard Liao 		/* I2S_Pre_Div1 should be 1 in asrc mode */
1669d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_ADDA_CLK_1,
1670d3cb2de2SBard Liao 			RT5659_I2S_PD1_MASK, RT5659_I2S_PD1_2);
1671d3cb2de2SBard Liao 		return 1;
1672d3cb2de2SBard Liao 	default:
1673d3cb2de2SBard Liao 		return 0;
1674d3cb2de2SBard Liao 	}
1675d3cb2de2SBard Liao 
1676d3cb2de2SBard Liao }
1677d3cb2de2SBard Liao 
1678d3cb2de2SBard Liao /* Digital Mixer */
1679d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_sto1_adc_l_mix[] = {
1680d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("ADC1 Switch", RT5659_STO1_ADC_MIXER,
1681d3cb2de2SBard Liao 			RT5659_M_STO1_ADC_L1_SFT, 1, 1),
1682d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("ADC2 Switch", RT5659_STO1_ADC_MIXER,
1683d3cb2de2SBard Liao 			RT5659_M_STO1_ADC_L2_SFT, 1, 1),
1684d3cb2de2SBard Liao };
1685d3cb2de2SBard Liao 
1686d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_sto1_adc_r_mix[] = {
1687d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("ADC1 Switch", RT5659_STO1_ADC_MIXER,
1688d3cb2de2SBard Liao 			RT5659_M_STO1_ADC_R1_SFT, 1, 1),
1689d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("ADC2 Switch", RT5659_STO1_ADC_MIXER,
1690d3cb2de2SBard Liao 			RT5659_M_STO1_ADC_R2_SFT, 1, 1),
1691d3cb2de2SBard Liao };
1692d3cb2de2SBard Liao 
1693d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_adc_l_mix[] = {
1694d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("ADC1 Switch", RT5659_MONO_ADC_MIXER,
1695d3cb2de2SBard Liao 			RT5659_M_MONO_ADC_L1_SFT, 1, 1),
1696d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("ADC2 Switch", RT5659_MONO_ADC_MIXER,
1697d3cb2de2SBard Liao 			RT5659_M_MONO_ADC_L2_SFT, 1, 1),
1698d3cb2de2SBard Liao };
1699d3cb2de2SBard Liao 
1700d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_adc_r_mix[] = {
1701d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("ADC1 Switch", RT5659_MONO_ADC_MIXER,
1702d3cb2de2SBard Liao 			RT5659_M_MONO_ADC_R1_SFT, 1, 1),
1703d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("ADC2 Switch", RT5659_MONO_ADC_MIXER,
1704d3cb2de2SBard Liao 			RT5659_M_MONO_ADC_R2_SFT, 1, 1),
1705d3cb2de2SBard Liao };
1706d3cb2de2SBard Liao 
1707d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_dac_l_mix[] = {
1708d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Stereo ADC Switch", RT5659_AD_DA_MIXER,
1709d3cb2de2SBard Liao 			RT5659_M_ADCMIX_L_SFT, 1, 1),
1710d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC1 Switch", RT5659_AD_DA_MIXER,
1711d3cb2de2SBard Liao 			RT5659_M_DAC1_L_SFT, 1, 1),
1712d3cb2de2SBard Liao };
1713d3cb2de2SBard Liao 
1714d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_dac_r_mix[] = {
1715d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Stereo ADC Switch", RT5659_AD_DA_MIXER,
1716d3cb2de2SBard Liao 			RT5659_M_ADCMIX_R_SFT, 1, 1),
1717d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC1 Switch", RT5659_AD_DA_MIXER,
1718d3cb2de2SBard Liao 			RT5659_M_DAC1_R_SFT, 1, 1),
1719d3cb2de2SBard Liao };
1720d3cb2de2SBard Liao 
1721d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_sto_dac_l_mix[] = {
1722d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L1 Switch", RT5659_STO_DAC_MIXER,
1723d3cb2de2SBard Liao 			RT5659_M_DAC_L1_STO_L_SFT, 1, 1),
1724d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R1 Switch", RT5659_STO_DAC_MIXER,
1725d3cb2de2SBard Liao 			RT5659_M_DAC_R1_STO_L_SFT, 1, 1),
1726d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_STO_DAC_MIXER,
1727d3cb2de2SBard Liao 			RT5659_M_DAC_L2_STO_L_SFT, 1, 1),
1728d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_STO_DAC_MIXER,
1729d3cb2de2SBard Liao 			RT5659_M_DAC_R2_STO_L_SFT, 1, 1),
1730d3cb2de2SBard Liao };
1731d3cb2de2SBard Liao 
1732d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_sto_dac_r_mix[] = {
1733d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L1 Switch", RT5659_STO_DAC_MIXER,
1734d3cb2de2SBard Liao 			RT5659_M_DAC_L1_STO_R_SFT, 1, 1),
1735d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R1 Switch", RT5659_STO_DAC_MIXER,
1736d3cb2de2SBard Liao 			RT5659_M_DAC_R1_STO_R_SFT, 1, 1),
1737d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_STO_DAC_MIXER,
1738d3cb2de2SBard Liao 			RT5659_M_DAC_L2_STO_R_SFT, 1, 1),
1739d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_STO_DAC_MIXER,
1740d3cb2de2SBard Liao 			RT5659_M_DAC_R2_STO_R_SFT, 1, 1),
1741d3cb2de2SBard Liao };
1742d3cb2de2SBard Liao 
1743d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_dac_l_mix[] = {
1744d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L1 Switch", RT5659_MONO_DAC_MIXER,
1745d3cb2de2SBard Liao 			RT5659_M_DAC_L1_MONO_L_SFT, 1, 1),
1746d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R1 Switch", RT5659_MONO_DAC_MIXER,
1747d3cb2de2SBard Liao 			RT5659_M_DAC_R1_MONO_L_SFT, 1, 1),
1748d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_MONO_DAC_MIXER,
1749d3cb2de2SBard Liao 			RT5659_M_DAC_L2_MONO_L_SFT, 1, 1),
1750d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_MONO_DAC_MIXER,
1751d3cb2de2SBard Liao 			RT5659_M_DAC_R2_MONO_L_SFT, 1, 1),
1752d3cb2de2SBard Liao };
1753d3cb2de2SBard Liao 
1754d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_dac_r_mix[] = {
1755d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L1 Switch", RT5659_MONO_DAC_MIXER,
1756d3cb2de2SBard Liao 			RT5659_M_DAC_L1_MONO_R_SFT, 1, 1),
1757d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R1 Switch", RT5659_MONO_DAC_MIXER,
1758d3cb2de2SBard Liao 			RT5659_M_DAC_R1_MONO_R_SFT, 1, 1),
1759d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_MONO_DAC_MIXER,
1760d3cb2de2SBard Liao 			RT5659_M_DAC_L2_MONO_R_SFT, 1, 1),
1761d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_MONO_DAC_MIXER,
1762d3cb2de2SBard Liao 			RT5659_M_DAC_R2_MONO_R_SFT, 1, 1),
1763d3cb2de2SBard Liao };
1764d3cb2de2SBard Liao 
1765d3cb2de2SBard Liao /* Analog Input Mixer */
1766d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_rec1_l_mix[] = {
1767d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("SPKVOLL Switch", RT5659_REC1_L2_MIXER,
1768d3cb2de2SBard Liao 			RT5659_M_SPKVOLL_RM1_L_SFT, 1, 1),
1769d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("INL Switch", RT5659_REC1_L2_MIXER,
1770d3cb2de2SBard Liao 			RT5659_M_INL_RM1_L_SFT, 1, 1),
1771d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST4 Switch", RT5659_REC1_L2_MIXER,
1772d3cb2de2SBard Liao 			RT5659_M_BST4_RM1_L_SFT, 1, 1),
1773d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_REC1_L2_MIXER,
1774d3cb2de2SBard Liao 			RT5659_M_BST3_RM1_L_SFT, 1, 1),
1775d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST2 Switch", RT5659_REC1_L2_MIXER,
1776d3cb2de2SBard Liao 			RT5659_M_BST2_RM1_L_SFT, 1, 1),
1777d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST1 Switch", RT5659_REC1_L2_MIXER,
1778d3cb2de2SBard Liao 			RT5659_M_BST1_RM1_L_SFT, 1, 1),
1779d3cb2de2SBard Liao };
1780d3cb2de2SBard Liao 
1781d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_rec1_r_mix[] = {
1782d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("HPOVOLR Switch", RT5659_REC1_L2_MIXER,
1783d3cb2de2SBard Liao 			RT5659_M_HPOVOLR_RM1_R_SFT, 1, 1),
1784d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("INR Switch", RT5659_REC1_R2_MIXER,
1785d3cb2de2SBard Liao 			RT5659_M_INR_RM1_R_SFT, 1, 1),
1786d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST4 Switch", RT5659_REC1_R2_MIXER,
1787d3cb2de2SBard Liao 			RT5659_M_BST4_RM1_R_SFT, 1, 1),
1788d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_REC1_R2_MIXER,
1789d3cb2de2SBard Liao 			RT5659_M_BST3_RM1_R_SFT, 1, 1),
1790d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST2 Switch", RT5659_REC1_R2_MIXER,
1791d3cb2de2SBard Liao 			RT5659_M_BST2_RM1_R_SFT, 1, 1),
1792d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST1 Switch", RT5659_REC1_R2_MIXER,
1793d3cb2de2SBard Liao 			RT5659_M_BST1_RM1_R_SFT, 1, 1),
1794d3cb2de2SBard Liao };
1795d3cb2de2SBard Liao 
1796d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_rec2_l_mix[] = {
1797d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("SPKVOLL Switch", RT5659_REC2_L2_MIXER,
1798d3cb2de2SBard Liao 			RT5659_M_SPKVOL_RM2_L_SFT, 1, 1),
1799d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("OUTVOLL Switch", RT5659_REC2_L2_MIXER,
1800d3cb2de2SBard Liao 			RT5659_M_OUTVOLL_RM2_L_SFT, 1, 1),
1801d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST4 Switch", RT5659_REC2_L2_MIXER,
1802d3cb2de2SBard Liao 			RT5659_M_BST4_RM2_L_SFT, 1, 1),
1803d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_REC2_L2_MIXER,
1804d3cb2de2SBard Liao 			RT5659_M_BST3_RM2_L_SFT, 1, 1),
1805d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST2 Switch", RT5659_REC2_L2_MIXER,
1806d3cb2de2SBard Liao 			RT5659_M_BST2_RM2_L_SFT, 1, 1),
1807d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST1 Switch", RT5659_REC2_L2_MIXER,
1808d3cb2de2SBard Liao 			RT5659_M_BST1_RM2_L_SFT, 1, 1),
1809d3cb2de2SBard Liao };
1810d3cb2de2SBard Liao 
1811d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_rec2_r_mix[] = {
1812d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("MONOVOL Switch", RT5659_REC2_R2_MIXER,
1813d3cb2de2SBard Liao 			RT5659_M_MONOVOL_RM2_R_SFT, 1, 1),
1814d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("OUTVOLR Switch", RT5659_REC2_R2_MIXER,
1815d3cb2de2SBard Liao 			RT5659_M_OUTVOLR_RM2_R_SFT, 1, 1),
1816d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST4 Switch", RT5659_REC2_R2_MIXER,
1817d3cb2de2SBard Liao 			RT5659_M_BST4_RM2_R_SFT, 1, 1),
1818d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_REC2_R2_MIXER,
1819d3cb2de2SBard Liao 			RT5659_M_BST3_RM2_R_SFT, 1, 1),
1820d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST2 Switch", RT5659_REC2_R2_MIXER,
1821d3cb2de2SBard Liao 			RT5659_M_BST2_RM2_R_SFT, 1, 1),
1822d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST1 Switch", RT5659_REC2_R2_MIXER,
1823d3cb2de2SBard Liao 			RT5659_M_BST1_RM2_R_SFT, 1, 1),
1824d3cb2de2SBard Liao };
1825d3cb2de2SBard Liao 
1826d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_spk_l_mix[] = {
1827d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_SPK_L_MIXER,
1828d3cb2de2SBard Liao 			RT5659_M_DAC_L2_SM_L_SFT, 1, 1),
1829d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST1 Switch", RT5659_SPK_L_MIXER,
1830d3cb2de2SBard Liao 			RT5659_M_BST1_SM_L_SFT, 1, 1),
1831d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("INL Switch", RT5659_SPK_L_MIXER,
1832d3cb2de2SBard Liao 			RT5659_M_IN_L_SM_L_SFT, 1, 1),
1833d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("INR Switch", RT5659_SPK_L_MIXER,
1834d3cb2de2SBard Liao 			RT5659_M_IN_R_SM_L_SFT, 1, 1),
1835d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_SPK_L_MIXER,
1836d3cb2de2SBard Liao 			RT5659_M_BST3_SM_L_SFT, 1, 1),
1837d3cb2de2SBard Liao };
1838d3cb2de2SBard Liao 
1839d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_spk_r_mix[] = {
1840d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_SPK_R_MIXER,
1841d3cb2de2SBard Liao 			RT5659_M_DAC_R2_SM_R_SFT, 1, 1),
1842d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST4 Switch", RT5659_SPK_R_MIXER,
1843d3cb2de2SBard Liao 			RT5659_M_BST4_SM_R_SFT, 1, 1),
1844d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("INL Switch", RT5659_SPK_R_MIXER,
1845d3cb2de2SBard Liao 			RT5659_M_IN_L_SM_R_SFT, 1, 1),
1846d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("INR Switch", RT5659_SPK_R_MIXER,
1847d3cb2de2SBard Liao 			RT5659_M_IN_R_SM_R_SFT, 1, 1),
1848d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_SPK_R_MIXER,
1849d3cb2de2SBard Liao 			RT5659_M_BST3_SM_R_SFT, 1, 1),
1850d3cb2de2SBard Liao };
1851d3cb2de2SBard Liao 
1852d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_monovol_mix[] = {
1853d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_MONOMIX_IN_GAIN,
1854d3cb2de2SBard Liao 			RT5659_M_DAC_L2_MM_SFT, 1, 1),
1855d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_MONOMIX_IN_GAIN,
1856d3cb2de2SBard Liao 			RT5659_M_DAC_R2_MM_SFT, 1, 1),
1857d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST1 Switch", RT5659_MONOMIX_IN_GAIN,
1858d3cb2de2SBard Liao 			RT5659_M_BST1_MM_SFT, 1, 1),
1859d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST2 Switch", RT5659_MONOMIX_IN_GAIN,
1860d3cb2de2SBard Liao 			RT5659_M_BST2_MM_SFT, 1, 1),
1861d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_MONOMIX_IN_GAIN,
1862d3cb2de2SBard Liao 			RT5659_M_BST3_MM_SFT, 1, 1),
1863d3cb2de2SBard Liao };
1864d3cb2de2SBard Liao 
1865d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_out_l_mix[] = {
1866d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_OUT_L_MIXER,
1867d3cb2de2SBard Liao 			RT5659_M_DAC_L2_OM_L_SFT, 1, 1),
1868d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("INL Switch", RT5659_OUT_L_MIXER,
1869d3cb2de2SBard Liao 			RT5659_M_IN_L_OM_L_SFT, 1, 1),
1870d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST1 Switch", RT5659_OUT_L_MIXER,
1871d3cb2de2SBard Liao 			RT5659_M_BST1_OM_L_SFT, 1, 1),
1872d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST2 Switch", RT5659_OUT_L_MIXER,
1873d3cb2de2SBard Liao 			RT5659_M_BST2_OM_L_SFT, 1, 1),
1874d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_OUT_L_MIXER,
1875d3cb2de2SBard Liao 			RT5659_M_BST3_OM_L_SFT, 1, 1),
1876d3cb2de2SBard Liao };
1877d3cb2de2SBard Liao 
1878d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_out_r_mix[] = {
1879d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_OUT_R_MIXER,
1880d3cb2de2SBard Liao 			RT5659_M_DAC_R2_OM_R_SFT, 1, 1),
1881d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("INR Switch", RT5659_OUT_R_MIXER,
1882d3cb2de2SBard Liao 			RT5659_M_IN_R_OM_R_SFT, 1, 1),
1883d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST2 Switch", RT5659_OUT_R_MIXER,
1884d3cb2de2SBard Liao 			RT5659_M_BST2_OM_R_SFT, 1, 1),
1885d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST3 Switch", RT5659_OUT_R_MIXER,
1886d3cb2de2SBard Liao 			RT5659_M_BST3_OM_R_SFT, 1, 1),
1887d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("BST4 Switch", RT5659_OUT_R_MIXER,
1888d3cb2de2SBard Liao 			RT5659_M_BST4_OM_R_SFT, 1, 1),
1889d3cb2de2SBard Liao };
1890d3cb2de2SBard Liao 
1891d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_spo_l_mix[] = {
1892d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_SPO_AMP_GAIN,
1893d3cb2de2SBard Liao 			RT5659_M_DAC_L2_SPKOMIX_SFT, 1, 0),
1894d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("SPKVOL L Switch", RT5659_SPO_AMP_GAIN,
1895d3cb2de2SBard Liao 			RT5659_M_SPKVOLL_SPKOMIX_SFT, 1, 0),
1896d3cb2de2SBard Liao };
1897d3cb2de2SBard Liao 
1898d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_spo_r_mix[] = {
1899d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_SPO_AMP_GAIN,
1900d3cb2de2SBard Liao 			RT5659_M_DAC_R2_SPKOMIX_SFT, 1, 0),
1901d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("SPKVOL R Switch", RT5659_SPO_AMP_GAIN,
1902d3cb2de2SBard Liao 			RT5659_M_SPKVOLR_SPKOMIX_SFT, 1, 0),
1903d3cb2de2SBard Liao };
1904d3cb2de2SBard Liao 
1905d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_mix[] = {
1906d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_MONOMIX_IN_GAIN,
1907d3cb2de2SBard Liao 			RT5659_M_DAC_L2_MA_SFT, 1, 1),
1908d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("MONOVOL Switch", RT5659_MONOMIX_IN_GAIN,
1909d3cb2de2SBard Liao 			RT5659_M_MONOVOL_MA_SFT, 1, 1),
1910d3cb2de2SBard Liao };
1911d3cb2de2SBard Liao 
1912d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_lout_l_mix[] = {
1913d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_LOUT_MIXER,
1914d3cb2de2SBard Liao 			RT5659_M_DAC_L2_LM_SFT, 1, 1),
1915d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("OUTVOL L Switch", RT5659_LOUT_MIXER,
1916d3cb2de2SBard Liao 			RT5659_M_OV_L_LM_SFT, 1, 1),
1917d3cb2de2SBard Liao };
1918d3cb2de2SBard Liao 
1919d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_lout_r_mix[] = {
1920d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_LOUT_MIXER,
1921d3cb2de2SBard Liao 			RT5659_M_DAC_R2_LM_SFT, 1, 1),
1922d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("OUTVOL R Switch", RT5659_LOUT_MIXER,
1923d3cb2de2SBard Liao 			RT5659_M_OV_R_LM_SFT, 1, 1),
1924d3cb2de2SBard Liao };
1925d3cb2de2SBard Liao 
1926d3cb2de2SBard Liao /*DAC L2, DAC R2*/
1927d3cb2de2SBard Liao /*MX-1B [6:4], MX-1B [2:0]*/
1928d3cb2de2SBard Liao static const char * const rt5659_dac2_src[] = {
1929d3cb2de2SBard Liao 	"IF1 DAC2", "IF2 DAC", "IF3 DAC", "Mono ADC MIX"
1930d3cb2de2SBard Liao };
1931d3cb2de2SBard Liao 
1932d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
1933d3cb2de2SBard Liao 	rt5659_dac_l2_enum, RT5659_DAC_CTRL,
1934d3cb2de2SBard Liao 	RT5659_DAC_L2_SEL_SFT, rt5659_dac2_src);
1935d3cb2de2SBard Liao 
1936d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_dac_l2_mux =
1937d3cb2de2SBard Liao 	SOC_DAPM_ENUM("DAC L2 Source", rt5659_dac_l2_enum);
1938d3cb2de2SBard Liao 
1939d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
1940d3cb2de2SBard Liao 	rt5659_dac_r2_enum, RT5659_DAC_CTRL,
1941d3cb2de2SBard Liao 	RT5659_DAC_R2_SEL_SFT, rt5659_dac2_src);
1942d3cb2de2SBard Liao 
1943d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_dac_r2_mux =
1944d3cb2de2SBard Liao 	SOC_DAPM_ENUM("DAC R2 Source", rt5659_dac_r2_enum);
1945d3cb2de2SBard Liao 
1946d3cb2de2SBard Liao 
1947d3cb2de2SBard Liao /* STO1 ADC1 Source */
1948d3cb2de2SBard Liao /* MX-26 [13] */
1949d3cb2de2SBard Liao static const char * const rt5659_sto1_adc1_src[] = {
1950d3cb2de2SBard Liao 	"DAC MIX", "ADC"
1951d3cb2de2SBard Liao };
1952d3cb2de2SBard Liao 
1953d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
1954d3cb2de2SBard Liao 	rt5659_sto1_adc1_enum, RT5659_STO1_ADC_MIXER,
1955d3cb2de2SBard Liao 	RT5659_STO1_ADC1_SRC_SFT, rt5659_sto1_adc1_src);
1956d3cb2de2SBard Liao 
1957d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_sto1_adc1_mux =
1958d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5659_sto1_adc1_enum);
1959d3cb2de2SBard Liao 
1960d3cb2de2SBard Liao /* STO1 ADC Source */
1961d3cb2de2SBard Liao /* MX-26 [12] */
1962d3cb2de2SBard Liao static const char * const rt5659_sto1_adc_src[] = {
1963d3cb2de2SBard Liao 	"ADC1", "ADC2"
1964d3cb2de2SBard Liao };
1965d3cb2de2SBard Liao 
1966d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
1967d3cb2de2SBard Liao 	rt5659_sto1_adc_enum, RT5659_STO1_ADC_MIXER,
1968d3cb2de2SBard Liao 	RT5659_STO1_ADC_SRC_SFT, rt5659_sto1_adc_src);
1969d3cb2de2SBard Liao 
1970d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_sto1_adc_mux =
1971d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Stereo1 ADC Source", rt5659_sto1_adc_enum);
1972d3cb2de2SBard Liao 
1973d3cb2de2SBard Liao /* STO1 ADC2 Source */
1974d3cb2de2SBard Liao /* MX-26 [11] */
1975d3cb2de2SBard Liao static const char * const rt5659_sto1_adc2_src[] = {
1976d3cb2de2SBard Liao 	"DAC MIX", "DMIC"
1977d3cb2de2SBard Liao };
1978d3cb2de2SBard Liao 
1979d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
1980d3cb2de2SBard Liao 	rt5659_sto1_adc2_enum, RT5659_STO1_ADC_MIXER,
1981d3cb2de2SBard Liao 	RT5659_STO1_ADC2_SRC_SFT, rt5659_sto1_adc2_src);
1982d3cb2de2SBard Liao 
1983d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_sto1_adc2_mux =
1984d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5659_sto1_adc2_enum);
1985d3cb2de2SBard Liao 
1986d3cb2de2SBard Liao /* STO1 DMIC Source */
1987d3cb2de2SBard Liao /* MX-26 [8] */
1988d3cb2de2SBard Liao static const char * const rt5659_sto1_dmic_src[] = {
1989d3cb2de2SBard Liao 	"DMIC1", "DMIC2"
1990d3cb2de2SBard Liao };
1991d3cb2de2SBard Liao 
1992d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
1993d3cb2de2SBard Liao 	rt5659_sto1_dmic_enum, RT5659_STO1_ADC_MIXER,
1994d3cb2de2SBard Liao 	RT5659_STO1_DMIC_SRC_SFT, rt5659_sto1_dmic_src);
1995d3cb2de2SBard Liao 
1996d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_sto1_dmic_mux =
1997d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5659_sto1_dmic_enum);
1998d3cb2de2SBard Liao 
1999d3cb2de2SBard Liao 
2000d3cb2de2SBard Liao /* MONO ADC L2 Source */
2001d3cb2de2SBard Liao /* MX-27 [12] */
2002d3cb2de2SBard Liao static const char * const rt5659_mono_adc_l2_src[] = {
2003d3cb2de2SBard Liao 	"Mono DAC MIXL", "DMIC"
2004d3cb2de2SBard Liao };
2005d3cb2de2SBard Liao 
2006d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2007d3cb2de2SBard Liao 	rt5659_mono_adc_l2_enum, RT5659_MONO_ADC_MIXER,
2008d3cb2de2SBard Liao 	RT5659_MONO_ADC_L2_SRC_SFT, rt5659_mono_adc_l2_src);
2009d3cb2de2SBard Liao 
2010d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_adc_l2_mux =
2011d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Mono ADC L2 Source", rt5659_mono_adc_l2_enum);
2012d3cb2de2SBard Liao 
2013d3cb2de2SBard Liao 
2014d3cb2de2SBard Liao /* MONO ADC L1 Source */
2015d3cb2de2SBard Liao /* MX-27 [11] */
2016d3cb2de2SBard Liao static const char * const rt5659_mono_adc_l1_src[] = {
2017d3cb2de2SBard Liao 	"Mono DAC MIXL", "ADC"
2018d3cb2de2SBard Liao };
2019d3cb2de2SBard Liao 
2020d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2021d3cb2de2SBard Liao 	rt5659_mono_adc_l1_enum, RT5659_MONO_ADC_MIXER,
2022d3cb2de2SBard Liao 	RT5659_MONO_ADC_L1_SRC_SFT, rt5659_mono_adc_l1_src);
2023d3cb2de2SBard Liao 
2024d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_adc_l1_mux =
2025d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Mono ADC L1 Source", rt5659_mono_adc_l1_enum);
2026d3cb2de2SBard Liao 
2027d3cb2de2SBard Liao /* MONO ADC L Source, MONO ADC R Source*/
2028d3cb2de2SBard Liao /* MX-27 [10:9], MX-27 [2:1] */
2029d3cb2de2SBard Liao static const char * const rt5659_mono_adc_src[] = {
2030d3cb2de2SBard Liao 	"ADC1 L", "ADC1 R", "ADC2 L", "ADC2 R"
2031d3cb2de2SBard Liao };
2032d3cb2de2SBard Liao 
2033d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2034d3cb2de2SBard Liao 	rt5659_mono_adc_l_enum, RT5659_MONO_ADC_MIXER,
2035d3cb2de2SBard Liao 	RT5659_MONO_ADC_L_SRC_SFT, rt5659_mono_adc_src);
2036d3cb2de2SBard Liao 
2037d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_adc_l_mux =
2038d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Mono ADC L Source", rt5659_mono_adc_l_enum);
2039d3cb2de2SBard Liao 
2040d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2041d3cb2de2SBard Liao 	rt5659_mono_adcr_enum, RT5659_MONO_ADC_MIXER,
2042d3cb2de2SBard Liao 	RT5659_MONO_ADC_R_SRC_SFT, rt5659_mono_adc_src);
2043d3cb2de2SBard Liao 
2044d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_adc_r_mux =
2045d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Mono ADC R Source", rt5659_mono_adcr_enum);
2046d3cb2de2SBard Liao 
2047d3cb2de2SBard Liao /* MONO DMIC L Source */
2048d3cb2de2SBard Liao /* MX-27 [8] */
2049d3cb2de2SBard Liao static const char * const rt5659_mono_dmic_l_src[] = {
2050d3cb2de2SBard Liao 	"DMIC1 L", "DMIC2 L"
2051d3cb2de2SBard Liao };
2052d3cb2de2SBard Liao 
2053d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2054d3cb2de2SBard Liao 	rt5659_mono_dmic_l_enum, RT5659_MONO_ADC_MIXER,
2055d3cb2de2SBard Liao 	RT5659_MONO_DMIC_L_SRC_SFT, rt5659_mono_dmic_l_src);
2056d3cb2de2SBard Liao 
2057d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_dmic_l_mux =
2058d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Mono DMIC L Source", rt5659_mono_dmic_l_enum);
2059d3cb2de2SBard Liao 
2060d3cb2de2SBard Liao /* MONO ADC R2 Source */
2061d3cb2de2SBard Liao /* MX-27 [4] */
2062d3cb2de2SBard Liao static const char * const rt5659_mono_adc_r2_src[] = {
2063d3cb2de2SBard Liao 	"Mono DAC MIXR", "DMIC"
2064d3cb2de2SBard Liao };
2065d3cb2de2SBard Liao 
2066d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2067d3cb2de2SBard Liao 	rt5659_mono_adc_r2_enum, RT5659_MONO_ADC_MIXER,
2068d3cb2de2SBard Liao 	RT5659_MONO_ADC_R2_SRC_SFT, rt5659_mono_adc_r2_src);
2069d3cb2de2SBard Liao 
2070d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_adc_r2_mux =
2071d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Mono ADC R2 Source", rt5659_mono_adc_r2_enum);
2072d3cb2de2SBard Liao 
2073d3cb2de2SBard Liao /* MONO ADC R1 Source */
2074d3cb2de2SBard Liao /* MX-27 [3] */
2075d3cb2de2SBard Liao static const char * const rt5659_mono_adc_r1_src[] = {
2076d3cb2de2SBard Liao 	"Mono DAC MIXR", "ADC"
2077d3cb2de2SBard Liao };
2078d3cb2de2SBard Liao 
2079d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2080d3cb2de2SBard Liao 	rt5659_mono_adc_r1_enum, RT5659_MONO_ADC_MIXER,
2081d3cb2de2SBard Liao 	RT5659_MONO_ADC_R1_SRC_SFT, rt5659_mono_adc_r1_src);
2082d3cb2de2SBard Liao 
2083d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_adc_r1_mux =
2084d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Mono ADC R1 Source", rt5659_mono_adc_r1_enum);
2085d3cb2de2SBard Liao 
2086d3cb2de2SBard Liao /* MONO DMIC R Source */
2087d3cb2de2SBard Liao /* MX-27 [0] */
2088d3cb2de2SBard Liao static const char * const rt5659_mono_dmic_r_src[] = {
2089d3cb2de2SBard Liao 	"DMIC1 R", "DMIC2 R"
2090d3cb2de2SBard Liao };
2091d3cb2de2SBard Liao 
2092d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2093d3cb2de2SBard Liao 	rt5659_mono_dmic_r_enum, RT5659_MONO_ADC_MIXER,
2094d3cb2de2SBard Liao 	RT5659_MONO_DMIC_R_SRC_SFT, rt5659_mono_dmic_r_src);
2095d3cb2de2SBard Liao 
2096d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_mono_dmic_r_mux =
2097d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Mono DMIC R Source", rt5659_mono_dmic_r_enum);
2098d3cb2de2SBard Liao 
2099d3cb2de2SBard Liao 
2100d3cb2de2SBard Liao /* DAC R1 Source, DAC L1 Source*/
2101d3cb2de2SBard Liao /* MX-29 [11:10], MX-29 [9:8]*/
2102d3cb2de2SBard Liao static const char * const rt5659_dac1_src[] = {
2103d3cb2de2SBard Liao 	"IF1 DAC1", "IF2 DAC", "IF3 DAC"
2104d3cb2de2SBard Liao };
2105d3cb2de2SBard Liao 
2106d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2107d3cb2de2SBard Liao 	rt5659_dac_r1_enum, RT5659_AD_DA_MIXER,
2108d3cb2de2SBard Liao 	RT5659_DAC1_R_SEL_SFT, rt5659_dac1_src);
2109d3cb2de2SBard Liao 
2110d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_dac_r1_mux =
2111d3cb2de2SBard Liao 	SOC_DAPM_ENUM("DAC R1 Source", rt5659_dac_r1_enum);
2112d3cb2de2SBard Liao 
2113d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2114d3cb2de2SBard Liao 	rt5659_dac_l1_enum, RT5659_AD_DA_MIXER,
2115d3cb2de2SBard Liao 	RT5659_DAC1_L_SEL_SFT, rt5659_dac1_src);
2116d3cb2de2SBard Liao 
2117d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_dac_l1_mux =
2118d3cb2de2SBard Liao 	SOC_DAPM_ENUM("DAC L1 Source", rt5659_dac_l1_enum);
2119d3cb2de2SBard Liao 
2120d3cb2de2SBard Liao /* DAC Digital Mixer L Source, DAC Digital Mixer R Source*/
2121d3cb2de2SBard Liao /* MX-2C [6], MX-2C [4]*/
2122d3cb2de2SBard Liao static const char * const rt5659_dig_dac_mix_src[] = {
2123d3cb2de2SBard Liao 	"Stereo DAC Mixer", "Mono DAC Mixer"
2124d3cb2de2SBard Liao };
2125d3cb2de2SBard Liao 
2126d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2127d3cb2de2SBard Liao 	rt5659_dig_dac_mixl_enum, RT5659_DIG_MIXER,
2128d3cb2de2SBard Liao 	RT5659_DAC_MIX_L_SFT, rt5659_dig_dac_mix_src);
2129d3cb2de2SBard Liao 
2130d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_dig_dac_mixl_mux =
2131d3cb2de2SBard Liao 	SOC_DAPM_ENUM("DAC Digital Mixer L Source", rt5659_dig_dac_mixl_enum);
2132d3cb2de2SBard Liao 
2133d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2134d3cb2de2SBard Liao 	rt5659_dig_dac_mixr_enum, RT5659_DIG_MIXER,
2135d3cb2de2SBard Liao 	RT5659_DAC_MIX_R_SFT, rt5659_dig_dac_mix_src);
2136d3cb2de2SBard Liao 
2137d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_dig_dac_mixr_mux =
2138d3cb2de2SBard Liao 	SOC_DAPM_ENUM("DAC Digital Mixer R Source", rt5659_dig_dac_mixr_enum);
2139d3cb2de2SBard Liao 
2140d3cb2de2SBard Liao /* Analog DAC L1 Source, Analog DAC R1 Source*/
2141d3cb2de2SBard Liao /* MX-2D [3], MX-2D [2]*/
2142d3cb2de2SBard Liao static const char * const rt5659_alg_dac1_src[] = {
2143d3cb2de2SBard Liao 	"DAC", "Stereo DAC Mixer"
2144d3cb2de2SBard Liao };
2145d3cb2de2SBard Liao 
2146d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2147d3cb2de2SBard Liao 	rt5659_alg_dac_l1_enum, RT5659_A_DAC_MUX,
2148d3cb2de2SBard Liao 	RT5659_A_DACL1_SFT, rt5659_alg_dac1_src);
2149d3cb2de2SBard Liao 
2150d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_alg_dac_l1_mux =
2151d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Analog DACL1 Source", rt5659_alg_dac_l1_enum);
2152d3cb2de2SBard Liao 
2153d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2154d3cb2de2SBard Liao 	rt5659_alg_dac_r1_enum, RT5659_A_DAC_MUX,
2155d3cb2de2SBard Liao 	RT5659_A_DACR1_SFT, rt5659_alg_dac1_src);
2156d3cb2de2SBard Liao 
2157d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_alg_dac_r1_mux =
2158d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Analog DACR1 Source", rt5659_alg_dac_r1_enum);
2159d3cb2de2SBard Liao 
2160d3cb2de2SBard Liao /* Analog DAC LR Source, Analog DAC R2 Source*/
2161d3cb2de2SBard Liao /* MX-2D [1], MX-2D [0]*/
2162d3cb2de2SBard Liao static const char * const rt5659_alg_dac2_src[] = {
2163d3cb2de2SBard Liao 	"Stereo DAC Mixer", "Mono DAC Mixer"
2164d3cb2de2SBard Liao };
2165d3cb2de2SBard Liao 
2166d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2167d3cb2de2SBard Liao 	rt5659_alg_dac_l2_enum, RT5659_A_DAC_MUX,
2168d3cb2de2SBard Liao 	RT5659_A_DACL2_SFT, rt5659_alg_dac2_src);
2169d3cb2de2SBard Liao 
2170d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_alg_dac_l2_mux =
2171d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Analog DAC L2 Source", rt5659_alg_dac_l2_enum);
2172d3cb2de2SBard Liao 
2173d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2174d3cb2de2SBard Liao 	rt5659_alg_dac_r2_enum, RT5659_A_DAC_MUX,
2175d3cb2de2SBard Liao 	RT5659_A_DACR2_SFT, rt5659_alg_dac2_src);
2176d3cb2de2SBard Liao 
2177d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_alg_dac_r2_mux =
2178d3cb2de2SBard Liao 	SOC_DAPM_ENUM("Analog DAC R2 Source", rt5659_alg_dac_r2_enum);
2179d3cb2de2SBard Liao 
2180d3cb2de2SBard Liao /* Interface2 ADC Data Input*/
2181d3cb2de2SBard Liao /* MX-2F [13:12] */
2182d3cb2de2SBard Liao static const char * const rt5659_if2_adc_in_src[] = {
2183d3cb2de2SBard Liao 	"IF_ADC1", "IF_ADC2", "DAC_REF", "IF_ADC3"
2184d3cb2de2SBard Liao };
2185d3cb2de2SBard Liao 
2186d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2187d3cb2de2SBard Liao 	rt5659_if2_adc_in_enum, RT5659_DIG_INF23_DATA,
2188d3cb2de2SBard Liao 	RT5659_IF2_ADC_IN_SFT, rt5659_if2_adc_in_src);
2189d3cb2de2SBard Liao 
2190d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if2_adc_in_mux =
2191d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF2 ADC IN Source", rt5659_if2_adc_in_enum);
2192d3cb2de2SBard Liao 
2193d3cb2de2SBard Liao /* Interface3 ADC Data Input*/
2194d3cb2de2SBard Liao /* MX-2F [1:0] */
2195d3cb2de2SBard Liao static const char * const rt5659_if3_adc_in_src[] = {
2196d3cb2de2SBard Liao 	"IF_ADC1", "IF_ADC2", "DAC_REF", "Stereo2_ADC_L/R"
2197d3cb2de2SBard Liao };
2198d3cb2de2SBard Liao 
2199d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2200d3cb2de2SBard Liao 	rt5659_if3_adc_in_enum, RT5659_DIG_INF23_DATA,
2201d3cb2de2SBard Liao 	RT5659_IF3_ADC_IN_SFT, rt5659_if3_adc_in_src);
2202d3cb2de2SBard Liao 
2203d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_if3_adc_in_mux =
2204d3cb2de2SBard Liao 	SOC_DAPM_ENUM("IF3 ADC IN Source", rt5659_if3_adc_in_enum);
2205d3cb2de2SBard Liao 
2206d3cb2de2SBard Liao /* PDM 1 L/R*/
2207d3cb2de2SBard Liao /* MX-31 [15] [13] */
2208d3cb2de2SBard Liao static const char * const rt5659_pdm_src[] = {
2209d3cb2de2SBard Liao 	"Mono DAC", "Stereo DAC"
2210d3cb2de2SBard Liao };
2211d3cb2de2SBard Liao 
2212d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2213d3cb2de2SBard Liao 	rt5659_pdm_l_enum, RT5659_PDM_OUT_CTRL,
2214d3cb2de2SBard Liao 	RT5659_PDM1_L_SFT, rt5659_pdm_src);
2215d3cb2de2SBard Liao 
2216d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_pdm_l_mux =
2217d3cb2de2SBard Liao 	SOC_DAPM_ENUM("PDM L Source", rt5659_pdm_l_enum);
2218d3cb2de2SBard Liao 
2219d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2220d3cb2de2SBard Liao 	rt5659_pdm_r_enum, RT5659_PDM_OUT_CTRL,
2221d3cb2de2SBard Liao 	RT5659_PDM1_R_SFT, rt5659_pdm_src);
2222d3cb2de2SBard Liao 
2223d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_pdm_r_mux =
2224d3cb2de2SBard Liao 	SOC_DAPM_ENUM("PDM R Source", rt5659_pdm_r_enum);
2225d3cb2de2SBard Liao 
2226d3cb2de2SBard Liao /* SPDIF Output source*/
2227d3cb2de2SBard Liao /* MX-36 [1:0] */
2228d3cb2de2SBard Liao static const char * const rt5659_spdif_src[] = {
2229d3cb2de2SBard Liao 	"IF1_DAC1", "IF1_DAC2", "IF2_DAC", "IF3_DAC"
2230d3cb2de2SBard Liao };
2231d3cb2de2SBard Liao 
2232d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2233d3cb2de2SBard Liao 	rt5659_spdif_enum, RT5659_SPDIF_CTRL,
2234d3cb2de2SBard Liao 	RT5659_SPDIF_SEL_SFT, rt5659_spdif_src);
2235d3cb2de2SBard Liao 
2236d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_spdif_mux =
2237d3cb2de2SBard Liao 	SOC_DAPM_ENUM("SPDIF Source", rt5659_spdif_enum);
2238d3cb2de2SBard Liao 
2239d3cb2de2SBard Liao /* I2S1 TDM ADCDAT Source */
2240d3cb2de2SBard Liao /* MX-78[4:0] */
2241d3cb2de2SBard Liao static const char * const rt5659_rx_adc_data_src[] = {
2242d3cb2de2SBard Liao 	"AD1:AD2:DAC:NUL", "AD1:AD2:NUL:DAC", "AD1:DAC:AD2:NUL",
2243d3cb2de2SBard Liao 	"AD1:DAC:NUL:AD2", "AD1:NUL:DAC:AD2", "AD1:NUL:AD2:DAC",
2244d3cb2de2SBard Liao 	"AD2:AD1:DAC:NUL", "AD2:AD1:NUL:DAC", "AD2:DAC:AD1:NUL",
2245d3cb2de2SBard Liao 	"AD2:DAC:NUL:AD1", "AD2:NUL:DAC:AD1", "AD1:NUL:AD1:DAC",
2246d3cb2de2SBard Liao 	"DAC:AD1:AD2:NUL", "DAC:AD1:NUL:AD2", "DAC:AD2:AD1:NUL",
2247d3cb2de2SBard Liao 	"DAC:AD2:NUL:AD1", "DAC:NUL:DAC:AD2", "DAC:NUL:AD2:DAC",
2248d3cb2de2SBard Liao 	"NUL:AD1:AD2:DAC", "NUL:AD1:DAC:AD2", "NUL:AD2:AD1:DAC",
2249d3cb2de2SBard Liao 	"NUL:AD2:DAC:AD1", "NUL:DAC:DAC:AD2", "NUL:DAC:AD2:DAC"
2250d3cb2de2SBard Liao };
2251d3cb2de2SBard Liao 
2252d3cb2de2SBard Liao static const SOC_ENUM_SINGLE_DECL(
2253d3cb2de2SBard Liao 	rt5659_rx_adc_data_enum, RT5659_TDM_CTRL_2,
2254d3cb2de2SBard Liao 	RT5659_ADCDAT_SRC_SFT, rt5659_rx_adc_data_src);
2255d3cb2de2SBard Liao 
2256d3cb2de2SBard Liao static const struct snd_kcontrol_new rt5659_rx_adc_dac_mux =
2257d3cb2de2SBard Liao 	SOC_DAPM_ENUM("TDM ADCDAT Source", rt5659_rx_adc_data_enum);
2258d3cb2de2SBard Liao 
2259d3cb2de2SBard Liao /* Out Volume Switch */
2260d3cb2de2SBard Liao static const struct snd_kcontrol_new spkvol_l_switch =
2261d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_SPO_VOL, RT5659_VOL_L_SFT, 1, 1);
2262d3cb2de2SBard Liao 
2263d3cb2de2SBard Liao static const struct snd_kcontrol_new spkvol_r_switch =
2264d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_SPO_VOL, RT5659_VOL_R_SFT, 1, 1);
2265d3cb2de2SBard Liao 
2266d3cb2de2SBard Liao static const struct snd_kcontrol_new monovol_switch =
2267d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_MONO_OUT, RT5659_VOL_L_SFT, 1, 1);
2268d3cb2de2SBard Liao 
2269d3cb2de2SBard Liao static const struct snd_kcontrol_new outvol_l_switch =
2270d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_LOUT, RT5659_VOL_L_SFT, 1, 1);
2271d3cb2de2SBard Liao 
2272d3cb2de2SBard Liao static const struct snd_kcontrol_new outvol_r_switch =
2273d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_LOUT, RT5659_VOL_R_SFT, 1, 1);
2274d3cb2de2SBard Liao 
2275d3cb2de2SBard Liao /* Out Switch */
2276d3cb2de2SBard Liao static const struct snd_kcontrol_new spo_switch =
2277d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_CLASSD_2, RT5659_M_RF_DIG_SFT, 1, 1);
2278d3cb2de2SBard Liao 
2279d3cb2de2SBard Liao static const struct snd_kcontrol_new mono_switch =
2280d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_MONO_OUT, RT5659_L_MUTE_SFT, 1, 1);
2281d3cb2de2SBard Liao 
2282d3cb2de2SBard Liao static const struct snd_kcontrol_new hpo_l_switch =
2283d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_HP_VOL, RT5659_L_MUTE_SFT, 1, 1);
2284d3cb2de2SBard Liao 
2285d3cb2de2SBard Liao static const struct snd_kcontrol_new hpo_r_switch =
2286d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_HP_VOL, RT5659_R_MUTE_SFT, 1, 1);
2287d3cb2de2SBard Liao 
2288d3cb2de2SBard Liao static const struct snd_kcontrol_new lout_l_switch =
2289d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_LOUT, RT5659_L_MUTE_SFT, 1, 1);
2290d3cb2de2SBard Liao 
2291d3cb2de2SBard Liao static const struct snd_kcontrol_new lout_r_switch =
2292d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_LOUT, RT5659_R_MUTE_SFT, 1, 1);
2293d3cb2de2SBard Liao 
2294d3cb2de2SBard Liao static const struct snd_kcontrol_new pdm_l_switch =
2295d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_PDM_OUT_CTRL, RT5659_M_PDM1_L_SFT, 1,
2296d3cb2de2SBard Liao 		1);
2297d3cb2de2SBard Liao 
2298d3cb2de2SBard Liao static const struct snd_kcontrol_new pdm_r_switch =
2299d3cb2de2SBard Liao 	SOC_DAPM_SINGLE("Switch", RT5659_PDM_OUT_CTRL, RT5659_M_PDM1_R_SFT, 1,
2300d3cb2de2SBard Liao 		1);
2301d3cb2de2SBard Liao 
2302d3cb2de2SBard Liao static int rt5659_spk_event(struct snd_soc_dapm_widget *w,
2303d3cb2de2SBard Liao 	struct snd_kcontrol *kcontrol, int event)
2304d3cb2de2SBard Liao {
2305d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2306d3cb2de2SBard Liao 
2307d3cb2de2SBard Liao 	switch (event) {
2308d3cb2de2SBard Liao 	case SND_SOC_DAPM_PRE_PMU:
2309d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_CLASSD_CTRL_1,
2310d3cb2de2SBard Liao 			RT5659_POW_CLSD_DB_MASK, RT5659_POW_CLSD_DB_EN);
2311d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_CLASSD_2,
2312d3cb2de2SBard Liao 			RT5659_M_RI_DIG, RT5659_M_RI_DIG);
2313d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_CLASSD_1, 0x0803);
2314d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_SPK_DC_CAILB_CTRL_3, 0x0000);
2315d3cb2de2SBard Liao 		break;
2316d3cb2de2SBard Liao 
2317d3cb2de2SBard Liao 	case SND_SOC_DAPM_POST_PMD:
2318d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_CLASSD_1, 0x0011);
2319d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_CLASSD_2,
2320d3cb2de2SBard Liao 			RT5659_M_RI_DIG, 0x0);
2321d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_SPK_DC_CAILB_CTRL_3, 0x0003);
2322d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_CLASSD_CTRL_1,
2323d3cb2de2SBard Liao 			RT5659_POW_CLSD_DB_MASK, RT5659_POW_CLSD_DB_DIS);
2324d3cb2de2SBard Liao 		break;
2325d3cb2de2SBard Liao 
2326d3cb2de2SBard Liao 	default:
2327d3cb2de2SBard Liao 		return 0;
2328d3cb2de2SBard Liao 	}
2329d3cb2de2SBard Liao 
2330d3cb2de2SBard Liao 	return 0;
2331d3cb2de2SBard Liao 
2332d3cb2de2SBard Liao }
2333d3cb2de2SBard Liao 
2334d3cb2de2SBard Liao static int rt5659_mono_event(struct snd_soc_dapm_widget *w,
2335d3cb2de2SBard Liao 	struct snd_kcontrol *kcontrol, int event)
2336d3cb2de2SBard Liao {
2337d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2338d3cb2de2SBard Liao 
2339d3cb2de2SBard Liao 	switch (event) {
2340d3cb2de2SBard Liao 	case SND_SOC_DAPM_PRE_PMU:
2341d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e00);
2342d3cb2de2SBard Liao 		break;
2343d3cb2de2SBard Liao 
2344d3cb2de2SBard Liao 	case SND_SOC_DAPM_POST_PMD:
2345d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e04);
2346d3cb2de2SBard Liao 		break;
2347d3cb2de2SBard Liao 
2348d3cb2de2SBard Liao 	default:
2349d3cb2de2SBard Liao 		return 0;
2350d3cb2de2SBard Liao 	}
2351d3cb2de2SBard Liao 
2352d3cb2de2SBard Liao 	return 0;
2353d3cb2de2SBard Liao 
2354d3cb2de2SBard Liao }
2355d3cb2de2SBard Liao 
2356d3cb2de2SBard Liao static int rt5659_hp_event(struct snd_soc_dapm_widget *w,
2357d3cb2de2SBard Liao 	struct snd_kcontrol *kcontrol, int event)
2358d3cb2de2SBard Liao {
2359d3cb2de2SBard Liao 	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2360d3cb2de2SBard Liao 
2361d3cb2de2SBard Liao 	switch (event) {
2362d3cb2de2SBard Liao 	case SND_SOC_DAPM_POST_PMU:
2363d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_HP_CHARGE_PUMP_1, 0x0e1e);
2364d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_DEPOP_1, 0x0010, 0x0010);
2365d3cb2de2SBard Liao 		break;
2366d3cb2de2SBard Liao 
2367d3cb2de2SBard Liao 	case SND_SOC_DAPM_PRE_PMD:
2368d3cb2de2SBard Liao 		snd_soc_write(codec, RT5659_DEPOP_1, 0x0000);
2369d3cb2de2SBard Liao 		break;
2370d3cb2de2SBard Liao 
2371d3cb2de2SBard Liao 	default:
2372d3cb2de2SBard Liao 		return 0;
2373d3cb2de2SBard Liao 	}
2374d3cb2de2SBard Liao 
2375d3cb2de2SBard Liao 	return 0;
2376d3cb2de2SBard Liao }
2377d3cb2de2SBard Liao 
2378d3cb2de2SBard Liao static int set_dmic_power(struct snd_soc_dapm_widget *w,
2379d3cb2de2SBard Liao 	struct snd_kcontrol *kcontrol, int event)
2380d3cb2de2SBard Liao {
2381d3cb2de2SBard Liao 	switch (event) {
2382d3cb2de2SBard Liao 	case SND_SOC_DAPM_POST_PMU:
2383d3cb2de2SBard Liao 		/*Add delay to avoid pop noise*/
2384d3cb2de2SBard Liao 		msleep(450);
2385d3cb2de2SBard Liao 		break;
2386d3cb2de2SBard Liao 
2387d3cb2de2SBard Liao 	default:
2388d3cb2de2SBard Liao 		return 0;
2389d3cb2de2SBard Liao 	}
2390d3cb2de2SBard Liao 
2391d3cb2de2SBard Liao 	return 0;
2392d3cb2de2SBard Liao }
2393d3cb2de2SBard Liao 
2394d3cb2de2SBard Liao static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = {
2395d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("LDO2", RT5659_PWR_ANLG_3, RT5659_PWR_LDO2_BIT, 0,
2396d3cb2de2SBard Liao 		NULL, 0),
2397d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0,
2398d3cb2de2SBard Liao 		NULL, 0),
2399d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5659_PWR_VOL,
2400d3cb2de2SBard Liao 		RT5659_PWR_MIC_DET_BIT, 0, NULL, 0),
2401d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("Mono Vref", RT5659_PWR_ANLG_1,
2402d3cb2de2SBard Liao 		RT5659_PWR_VREF3_BIT, 0, NULL, 0),
2403d3cb2de2SBard Liao 
2404d3cb2de2SBard Liao 	/* ASRC */
2405d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5659_ASRC_1,
2406d3cb2de2SBard Liao 		RT5659_I2S1_ASRC_SFT, 0, NULL, 0),
2407d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5659_ASRC_1,
2408d3cb2de2SBard Liao 		RT5659_I2S2_ASRC_SFT, 0, NULL, 0),
2409d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5659_ASRC_1,
2410d3cb2de2SBard Liao 		RT5659_I2S3_ASRC_SFT, 0, NULL, 0),
2411d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5659_ASRC_1,
2412d3cb2de2SBard Liao 		RT5659_DAC_STO_ASRC_SFT, 0, NULL, 0),
2413d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("DAC Mono L ASRC", 1, RT5659_ASRC_1,
2414d3cb2de2SBard Liao 		RT5659_DAC_MONO_L_ASRC_SFT, 0, NULL, 0),
2415d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("DAC Mono R ASRC", 1, RT5659_ASRC_1,
2416d3cb2de2SBard Liao 		RT5659_DAC_MONO_R_ASRC_SFT, 0, NULL, 0),
2417d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5659_ASRC_1,
2418d3cb2de2SBard Liao 		RT5659_ADC_STO1_ASRC_SFT, 0, NULL, 0),
2419d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("ADC Mono L ASRC", 1, RT5659_ASRC_1,
2420d3cb2de2SBard Liao 		RT5659_ADC_MONO_L_ASRC_SFT, 0, NULL, 0),
2421d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("ADC Mono R ASRC", 1, RT5659_ASRC_1,
2422d3cb2de2SBard Liao 		RT5659_ADC_MONO_R_ASRC_SFT, 0, NULL, 0),
2423d3cb2de2SBard Liao 
2424d3cb2de2SBard Liao 	/* Input Side */
2425d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT,
2426d3cb2de2SBard Liao 		0, NULL, 0),
2427d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("MICBIAS2", RT5659_PWR_ANLG_2, RT5659_PWR_MB2_BIT,
2428d3cb2de2SBard Liao 		0, NULL, 0),
2429d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("MICBIAS3", RT5659_PWR_ANLG_2, RT5659_PWR_MB3_BIT,
2430d3cb2de2SBard Liao 		0, NULL, 0),
2431d3cb2de2SBard Liao 
2432d3cb2de2SBard Liao 	/* Input Lines */
2433d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("DMIC L1"),
2434d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("DMIC R1"),
2435d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("DMIC L2"),
2436d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("DMIC R2"),
2437d3cb2de2SBard Liao 
2438d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("IN1P"),
2439d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("IN1N"),
2440d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("IN2P"),
2441d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("IN2N"),
2442d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("IN3P"),
2443d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("IN3N"),
2444d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("IN4P"),
2445d3cb2de2SBard Liao 	SND_SOC_DAPM_INPUT("IN4N"),
2446d3cb2de2SBard Liao 
2447d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2448d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2449d3cb2de2SBard Liao 
2450d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0,
2451d3cb2de2SBard Liao 		set_dmic_clk, SND_SOC_DAPM_PRE_PMU),
2452d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("DMIC1 Power", RT5659_DMIC_CTRL_1,
2453d3cb2de2SBard Liao 		RT5659_DMIC_1_EN_SFT, 0, set_dmic_power, SND_SOC_DAPM_POST_PMU),
2454d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("DMIC2 Power", RT5659_DMIC_CTRL_1,
2455d3cb2de2SBard Liao 		RT5659_DMIC_2_EN_SFT, 0, set_dmic_power, SND_SOC_DAPM_POST_PMU),
2456d3cb2de2SBard Liao 
2457d3cb2de2SBard Liao 	/* Boost */
2458d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("BST1", RT5659_PWR_ANLG_2,
2459d3cb2de2SBard Liao 		RT5659_PWR_BST1_P_BIT, 0, NULL, 0),
2460d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("BST2", RT5659_PWR_ANLG_2,
2461d3cb2de2SBard Liao 		RT5659_PWR_BST2_P_BIT, 0, NULL, 0),
2462d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("BST3", RT5659_PWR_ANLG_2,
2463d3cb2de2SBard Liao 		RT5659_PWR_BST3_P_BIT, 0, NULL, 0),
2464d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("BST4", RT5659_PWR_ANLG_2,
2465d3cb2de2SBard Liao 		RT5659_PWR_BST4_P_BIT, 0, NULL, 0),
2466d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("BST1 Power", RT5659_PWR_ANLG_2,
2467d3cb2de2SBard Liao 		RT5659_PWR_BST1_BIT, 0, NULL, 0),
2468d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("BST2 Power", RT5659_PWR_ANLG_2,
2469d3cb2de2SBard Liao 		RT5659_PWR_BST2_BIT, 0, NULL, 0),
2470d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("BST3 Power", RT5659_PWR_ANLG_2,
2471d3cb2de2SBard Liao 		RT5659_PWR_BST3_BIT, 0, NULL, 0),
2472d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("BST4 Power", RT5659_PWR_ANLG_2,
2473d3cb2de2SBard Liao 		RT5659_PWR_BST4_BIT, 0, NULL, 0),
2474d3cb2de2SBard Liao 
2475d3cb2de2SBard Liao 
2476d3cb2de2SBard Liao 	/* Input Volume */
2477d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("INL VOL", RT5659_PWR_VOL, RT5659_PWR_IN_L_BIT,
2478d3cb2de2SBard Liao 		0, NULL, 0),
2479d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("INR VOL", RT5659_PWR_VOL, RT5659_PWR_IN_R_BIT,
2480d3cb2de2SBard Liao 		0, NULL, 0),
2481d3cb2de2SBard Liao 
2482d3cb2de2SBard Liao 	/* REC Mixer */
2483d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("RECMIX1L", RT5659_PWR_MIXER, RT5659_PWR_RM1_L_BIT,
2484d3cb2de2SBard Liao 		0, rt5659_rec1_l_mix, ARRAY_SIZE(rt5659_rec1_l_mix)),
2485d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("RECMIX1R", RT5659_PWR_MIXER, RT5659_PWR_RM1_R_BIT,
2486d3cb2de2SBard Liao 		0, rt5659_rec1_r_mix, ARRAY_SIZE(rt5659_rec1_r_mix)),
2487d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("RECMIX2L", RT5659_PWR_MIXER, RT5659_PWR_RM2_L_BIT,
2488d3cb2de2SBard Liao 		0, rt5659_rec2_l_mix, ARRAY_SIZE(rt5659_rec2_l_mix)),
2489d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("RECMIX2R", RT5659_PWR_MIXER, RT5659_PWR_RM2_R_BIT,
2490d3cb2de2SBard Liao 		0, rt5659_rec2_r_mix, ARRAY_SIZE(rt5659_rec2_r_mix)),
2491d3cb2de2SBard Liao 
2492d3cb2de2SBard Liao 	/* ADCs */
2493d3cb2de2SBard Liao 	SND_SOC_DAPM_ADC("ADC1 L", NULL, SND_SOC_NOPM, 0, 0),
2494d3cb2de2SBard Liao 	SND_SOC_DAPM_ADC("ADC1 R", NULL, SND_SOC_NOPM, 0, 0),
2495d3cb2de2SBard Liao 	SND_SOC_DAPM_ADC("ADC2 L", NULL, SND_SOC_NOPM, 0, 0),
2496d3cb2de2SBard Liao 	SND_SOC_DAPM_ADC("ADC2 R", NULL, SND_SOC_NOPM, 0, 0),
2497d3cb2de2SBard Liao 
2498d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC1 L Power", RT5659_PWR_DIG_1,
2499d3cb2de2SBard Liao 		RT5659_PWR_ADC_L1_BIT, 0, NULL, 0),
2500d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC1 R Power", RT5659_PWR_DIG_1,
2501d3cb2de2SBard Liao 		RT5659_PWR_ADC_R1_BIT, 0, NULL, 0),
2502d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC2 L Power", RT5659_PWR_DIG_2,
2503d3cb2de2SBard Liao 		RT5659_PWR_ADC_L2_BIT, 0, NULL, 0),
2504d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC2 R Power", RT5659_PWR_DIG_2,
2505d3cb2de2SBard Liao 		RT5659_PWR_ADC_R2_BIT, 0, NULL, 0),
2506d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC1 clock", SND_SOC_NOPM, 0, 0, set_adc_clk,
2507d3cb2de2SBard Liao 		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
2508d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC2 clock", SND_SOC_NOPM, 0, 0, set_adc_clk,
2509d3cb2de2SBard Liao 		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
2510d3cb2de2SBard Liao 
2511d3cb2de2SBard Liao 	/* ADC Mux */
2512d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Stereo1 DMIC L Mux", SND_SOC_NOPM, 0, 0,
2513d3cb2de2SBard Liao 		&rt5659_sto1_dmic_mux),
2514d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Stereo1 DMIC R Mux", SND_SOC_NOPM, 0, 0,
2515d3cb2de2SBard Liao 		&rt5659_sto1_dmic_mux),
2516d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM, 0, 0,
2517d3cb2de2SBard Liao 		&rt5659_sto1_adc1_mux),
2518d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM, 0, 0,
2519d3cb2de2SBard Liao 		&rt5659_sto1_adc1_mux),
2520d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM, 0, 0,
2521d3cb2de2SBard Liao 		&rt5659_sto1_adc2_mux),
2522d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM, 0, 0,
2523d3cb2de2SBard Liao 		&rt5659_sto1_adc2_mux),
2524d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Stereo1 ADC L Mux", SND_SOC_NOPM, 0, 0,
2525d3cb2de2SBard Liao 		&rt5659_sto1_adc_mux),
2526d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Stereo1 ADC R Mux", SND_SOC_NOPM, 0, 0,
2527d3cb2de2SBard Liao 		&rt5659_sto1_adc_mux),
2528d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0,
2529d3cb2de2SBard Liao 		&rt5659_mono_adc_l2_mux),
2530d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0,
2531d3cb2de2SBard Liao 		&rt5659_mono_adc_r2_mux),
2532d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0,
2533d3cb2de2SBard Liao 		&rt5659_mono_adc_l1_mux),
2534d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0,
2535d3cb2de2SBard Liao 		&rt5659_mono_adc_r1_mux),
2536d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
2537d3cb2de2SBard Liao 		&rt5659_mono_dmic_l_mux),
2538d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
2539d3cb2de2SBard Liao 		&rt5659_mono_dmic_r_mux),
2540d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Mono ADC L Mux", SND_SOC_NOPM, 0, 0,
2541d3cb2de2SBard Liao 		&rt5659_mono_adc_l_mux),
2542d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("Mono ADC R Mux", SND_SOC_NOPM, 0, 0,
2543d3cb2de2SBard Liao 		&rt5659_mono_adc_r_mux),
2544d3cb2de2SBard Liao 	/* ADC Mixer */
2545d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC Stereo1 Filter", RT5659_PWR_DIG_2,
2546d3cb2de2SBard Liao 		RT5659_PWR_ADC_S1F_BIT, 0, NULL, 0),
2547d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC Stereo2 Filter", RT5659_PWR_DIG_2,
2548d3cb2de2SBard Liao 		RT5659_PWR_ADC_S2F_BIT, 0, NULL, 0),
2549d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Stereo1 ADC MIXL", SND_SOC_NOPM,
2550d3cb2de2SBard Liao 		0, 0, rt5659_sto1_adc_l_mix,
2551d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_sto1_adc_l_mix)),
2552d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Stereo1 ADC MIXR", SND_SOC_NOPM,
2553d3cb2de2SBard Liao 		0, 0, rt5659_sto1_adc_r_mix,
2554d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_sto1_adc_r_mix)),
2555d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5659_PWR_DIG_2,
2556d3cb2de2SBard Liao 		RT5659_PWR_ADC_MF_L_BIT, 0, NULL, 0),
2557d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5659_MONO_ADC_DIG_VOL,
2558d3cb2de2SBard Liao 		RT5659_L_MUTE_SFT, 1, rt5659_mono_adc_l_mix,
2559d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_mono_adc_l_mix)),
2560d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5659_PWR_DIG_2,
2561d3cb2de2SBard Liao 		RT5659_PWR_ADC_MF_R_BIT, 0, NULL, 0),
2562d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5659_MONO_ADC_DIG_VOL,
2563d3cb2de2SBard Liao 		RT5659_R_MUTE_SFT, 1, rt5659_mono_adc_r_mix,
2564d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_mono_adc_r_mix)),
2565d3cb2de2SBard Liao 
2566d3cb2de2SBard Liao 	/* ADC PGA */
2567d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2568d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2569d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2570d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2571d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2572d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2573d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1_ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2574d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("Stereo2 ADC LR", SND_SOC_NOPM, 0, 0, NULL, 0),
2575d3cb2de2SBard Liao 
2576d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("Stereo1 ADC Volume L", RT5659_STO1_ADC_DIG_VOL,
2577d3cb2de2SBard Liao 		RT5659_L_MUTE_SFT, 1, NULL, 0),
2578d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("Stereo1 ADC Volume R", RT5659_STO1_ADC_DIG_VOL,
2579d3cb2de2SBard Liao 		RT5659_R_MUTE_SFT, 1, NULL, 0),
2580d3cb2de2SBard Liao 
2581d3cb2de2SBard Liao 	/* Digital Interface */
2582d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("I2S1", RT5659_PWR_DIG_1, RT5659_PWR_I2S1_BIT,
2583d3cb2de2SBard Liao 		0, NULL, 0),
2584d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2585d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2586d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 DAC1 L", SND_SOC_NOPM, 0, 0, NULL, 0),
2587d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 DAC1 R", SND_SOC_NOPM, 0, 0, NULL, 0),
2588d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 DAC2 L", SND_SOC_NOPM, 0, 0, NULL, 0),
2589d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 DAC2 R", SND_SOC_NOPM, 0, 0, NULL, 0),
2590d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2591d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2592d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF1 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2593d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("I2S2", RT5659_PWR_DIG_1, RT5659_PWR_I2S2_BIT, 0,
2594d3cb2de2SBard Liao 		NULL, 0),
2595d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF2 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2596d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF2 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2597d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF2 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2598d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2599d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2600d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2601d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("I2S3", RT5659_PWR_DIG_1, RT5659_PWR_I2S3_BIT, 0,
2602d3cb2de2SBard Liao 		NULL, 0),
2603d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2604d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2605d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2606d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2607d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2608d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2609d3cb2de2SBard Liao 
2610d3cb2de2SBard Liao 	/* Digital Interface Select */
2611d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("TDM AD1:AD2:DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2612d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("TDM AD2:DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2613d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("TDM Data Mux", SND_SOC_NOPM, 0, 0,
2614d3cb2de2SBard Liao 		&rt5659_rx_adc_dac_mux),
2615d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF2 ADC Mux", SND_SOC_NOPM, 0, 0,
2616d3cb2de2SBard Liao 		&rt5659_if2_adc_in_mux),
2617d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0,
2618d3cb2de2SBard Liao 		&rt5659_if3_adc_in_mux),
2619d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF1 01 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
2620d3cb2de2SBard Liao 			&rt5659_if1_01_adc_swap_mux),
2621d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF1 23 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
2622d3cb2de2SBard Liao 			&rt5659_if1_23_adc_swap_mux),
2623d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF1 45 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
2624d3cb2de2SBard Liao 			&rt5659_if1_45_adc_swap_mux),
2625d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF1 67 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
2626d3cb2de2SBard Liao 			&rt5659_if1_67_adc_swap_mux),
2627d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF2 DAC Swap Mux", SND_SOC_NOPM, 0, 0,
2628d3cb2de2SBard Liao 			&rt5659_if2_dac_swap_mux),
2629d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF2 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
2630d3cb2de2SBard Liao 			&rt5659_if2_adc_swap_mux),
2631d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF3 DAC Swap Mux", SND_SOC_NOPM, 0, 0,
2632d3cb2de2SBard Liao 			&rt5659_if3_dac_swap_mux),
2633d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("IF3 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
2634d3cb2de2SBard Liao 			&rt5659_if3_adc_swap_mux),
2635d3cb2de2SBard Liao 
2636d3cb2de2SBard Liao 	/* Audio Interface */
2637d3cb2de2SBard Liao 	SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
2638d3cb2de2SBard Liao 	SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
2639d3cb2de2SBard Liao 	SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
2640d3cb2de2SBard Liao 	SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
2641d3cb2de2SBard Liao 	SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
2642d3cb2de2SBard Liao 	SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
2643d3cb2de2SBard Liao 
2644d3cb2de2SBard Liao 	/* Output Side */
2645d3cb2de2SBard Liao 	/* DAC mixer before sound effect  */
2646d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0,
2647d3cb2de2SBard Liao 		rt5659_dac_l_mix, ARRAY_SIZE(rt5659_dac_l_mix)),
2648d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0,
2649d3cb2de2SBard Liao 		rt5659_dac_r_mix, ARRAY_SIZE(rt5659_dac_r_mix)),
2650d3cb2de2SBard Liao 
2651d3cb2de2SBard Liao 	/* DAC channel Mux */
2652d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC L1 Mux", SND_SOC_NOPM, 0, 0, &rt5659_dac_l1_mux),
2653d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC R1 Mux", SND_SOC_NOPM, 0, 0, &rt5659_dac_r1_mux),
2654d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM, 0, 0, &rt5659_dac_l2_mux),
2655d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM, 0, 0, &rt5659_dac_r2_mux),
2656d3cb2de2SBard Liao 
2657d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC L1 Source", SND_SOC_NOPM, 0, 0,
2658d3cb2de2SBard Liao 		&rt5659_alg_dac_l1_mux),
2659d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC R1 Source", SND_SOC_NOPM, 0, 0,
2660d3cb2de2SBard Liao 		&rt5659_alg_dac_r1_mux),
2661d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC L2 Source", SND_SOC_NOPM, 0, 0,
2662d3cb2de2SBard Liao 		&rt5659_alg_dac_l2_mux),
2663d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC R2 Source", SND_SOC_NOPM, 0, 0,
2664d3cb2de2SBard Liao 		&rt5659_alg_dac_r2_mux),
2665d3cb2de2SBard Liao 
2666d3cb2de2SBard Liao 	/* DAC Mixer */
2667d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("DAC Stereo1 Filter", RT5659_PWR_DIG_2,
2668d3cb2de2SBard Liao 		RT5659_PWR_DAC_S1F_BIT, 0, NULL, 0),
2669d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("DAC Mono Left Filter", RT5659_PWR_DIG_2,
2670d3cb2de2SBard Liao 		RT5659_PWR_DAC_MF_L_BIT, 0, NULL, 0),
2671d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("DAC Mono Right Filter", RT5659_PWR_DIG_2,
2672d3cb2de2SBard Liao 		RT5659_PWR_DAC_MF_R_BIT, 0, NULL, 0),
2673d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
2674d3cb2de2SBard Liao 		rt5659_sto_dac_l_mix, ARRAY_SIZE(rt5659_sto_dac_l_mix)),
2675d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0,
2676d3cb2de2SBard Liao 		rt5659_sto_dac_r_mix, ARRAY_SIZE(rt5659_sto_dac_r_mix)),
2677d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
2678d3cb2de2SBard Liao 		rt5659_mono_dac_l_mix, ARRAY_SIZE(rt5659_mono_dac_l_mix)),
2679d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
2680d3cb2de2SBard Liao 		rt5659_mono_dac_r_mix, ARRAY_SIZE(rt5659_mono_dac_r_mix)),
2681d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC MIXL", SND_SOC_NOPM, 0, 0,
2682d3cb2de2SBard Liao 		&rt5659_dig_dac_mixl_mux),
2683d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("DAC MIXR", SND_SOC_NOPM, 0, 0,
2684d3cb2de2SBard Liao 		&rt5659_dig_dac_mixr_mux),
2685d3cb2de2SBard Liao 
2686d3cb2de2SBard Liao 	/* DACs */
2687d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("DAC L1 Power", 1, RT5659_PWR_DIG_1,
2688d3cb2de2SBard Liao 		RT5659_PWR_DAC_L1_BIT, 0, NULL, 0),
2689d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY_S("DAC R1 Power", 1, RT5659_PWR_DIG_1,
2690d3cb2de2SBard Liao 		RT5659_PWR_DAC_R1_BIT, 0, NULL, 0),
2691d3cb2de2SBard Liao 	SND_SOC_DAPM_DAC("DAC L1", NULL, SND_SOC_NOPM, 0, 0),
2692d3cb2de2SBard Liao 	SND_SOC_DAPM_DAC("DAC R1", NULL, SND_SOC_NOPM, 0, 0),
2693d3cb2de2SBard Liao 
2694d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("DAC L2 Power", RT5659_PWR_DIG_1,
2695d3cb2de2SBard Liao 		RT5659_PWR_DAC_L2_BIT, 0, NULL, 0),
2696d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("DAC R2 Power", RT5659_PWR_DIG_1,
2697d3cb2de2SBard Liao 		RT5659_PWR_DAC_R2_BIT, 0, NULL, 0),
2698d3cb2de2SBard Liao 	SND_SOC_DAPM_DAC("DAC L2", NULL, SND_SOC_NOPM, 0, 0),
2699d3cb2de2SBard Liao 	SND_SOC_DAPM_DAC("DAC R2", NULL, SND_SOC_NOPM, 0, 0),
2700d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("DAC_REF", SND_SOC_NOPM, 0, 0, NULL, 0),
2701d3cb2de2SBard Liao 
2702d3cb2de2SBard Liao 	/* OUT Mixer */
2703d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("SPK MIXL", RT5659_PWR_MIXER, RT5659_PWR_SM_L_BIT,
2704d3cb2de2SBard Liao 		0, rt5659_spk_l_mix, ARRAY_SIZE(rt5659_spk_l_mix)),
2705d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("SPK MIXR", RT5659_PWR_MIXER, RT5659_PWR_SM_R_BIT,
2706d3cb2de2SBard Liao 		0, rt5659_spk_r_mix, ARRAY_SIZE(rt5659_spk_r_mix)),
2707d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("MONOVOL MIX", RT5659_PWR_MIXER, RT5659_PWR_MM_BIT,
2708d3cb2de2SBard Liao 		0, rt5659_monovol_mix, ARRAY_SIZE(rt5659_monovol_mix)),
2709d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("OUT MIXL", RT5659_PWR_MIXER, RT5659_PWR_OM_L_BIT,
2710d3cb2de2SBard Liao 		0, rt5659_out_l_mix, ARRAY_SIZE(rt5659_out_l_mix)),
2711d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("OUT MIXR", RT5659_PWR_MIXER, RT5659_PWR_OM_R_BIT,
2712d3cb2de2SBard Liao 		0, rt5659_out_r_mix, ARRAY_SIZE(rt5659_out_r_mix)),
2713d3cb2de2SBard Liao 
2714d3cb2de2SBard Liao 	/* Output Volume */
2715d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("SPKVOL L", RT5659_PWR_VOL, RT5659_PWR_SV_L_BIT, 0,
2716d3cb2de2SBard Liao 		&spkvol_l_switch),
2717d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("SPKVOL R", RT5659_PWR_VOL, RT5659_PWR_SV_R_BIT, 0,
2718d3cb2de2SBard Liao 		&spkvol_r_switch),
2719d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("MONOVOL", RT5659_PWR_VOL, RT5659_PWR_MV_BIT, 0,
2720d3cb2de2SBard Liao 		&monovol_switch),
2721d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("OUTVOL L", RT5659_PWR_VOL, RT5659_PWR_OV_L_BIT, 0,
2722d3cb2de2SBard Liao 		&outvol_l_switch),
2723d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("OUTVOL R", RT5659_PWR_VOL, RT5659_PWR_OV_R_BIT, 0,
2724d3cb2de2SBard Liao 		&outvol_r_switch),
2725d3cb2de2SBard Liao 
2726d3cb2de2SBard Liao 	/* SPO/MONO/HPO/LOUT */
2727d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("SPO L MIX", SND_SOC_NOPM, 0, 0, rt5659_spo_l_mix,
2728d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_spo_l_mix)),
2729d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("SPO R MIX", SND_SOC_NOPM, 0, 0, rt5659_spo_r_mix,
2730d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_spo_r_mix)),
2731d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("Mono MIX", SND_SOC_NOPM, 0,	0, rt5659_mono_mix,
2732d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_mono_mix)),
2733d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("LOUT L MIX", SND_SOC_NOPM, 0, 0, rt5659_lout_l_mix,
2734d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_lout_l_mix)),
2735d3cb2de2SBard Liao 	SND_SOC_DAPM_MIXER("LOUT R MIX", SND_SOC_NOPM, 0, 0, rt5659_lout_r_mix,
2736d3cb2de2SBard Liao 		ARRAY_SIZE(rt5659_lout_r_mix)),
2737d3cb2de2SBard Liao 
2738d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA_S("SPK Amp", 1, RT5659_PWR_DIG_1, RT5659_PWR_CLS_D_BIT,
2739d3cb2de2SBard Liao 		0, rt5659_spk_event, SND_SOC_DAPM_POST_PMD |
2740d3cb2de2SBard Liao 		SND_SOC_DAPM_PRE_PMU),
2741d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA_S("Mono Amp", 1, RT5659_PWR_ANLG_1, RT5659_PWR_MA_BIT,
2742d3cb2de2SBard Liao 		0, rt5659_mono_event, SND_SOC_DAPM_POST_PMD |
2743d3cb2de2SBard Liao 		SND_SOC_DAPM_PRE_PMU),
2744d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, rt5659_hp_event,
2745d3cb2de2SBard Liao 		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2746d3cb2de2SBard Liao 	SND_SOC_DAPM_PGA("LOUT Amp", SND_SOC_NOPM, 0, 0, NULL, 0),
2747d3cb2de2SBard Liao 
2748d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("Charge Pump", SND_SOC_NOPM, 0, 0,
2749d3cb2de2SBard Liao 		rt5659_charge_pump_event, SND_SOC_DAPM_PRE_PMU |
2750d3cb2de2SBard Liao 		SND_SOC_DAPM_POST_PMD),
2751d3cb2de2SBard Liao 
2752d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("SPO Playback", SND_SOC_NOPM, 0, 0, &spo_switch),
2753d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("Mono Playback", SND_SOC_NOPM, 0, 0,
2754d3cb2de2SBard Liao 		&mono_switch),
2755d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("HPO L Playback", SND_SOC_NOPM, 0, 0,
2756d3cb2de2SBard Liao 		&hpo_l_switch),
2757d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("HPO R Playback", SND_SOC_NOPM, 0, 0,
2758d3cb2de2SBard Liao 		&hpo_r_switch),
2759d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("LOUT L Playback", SND_SOC_NOPM, 0, 0,
2760d3cb2de2SBard Liao 		&lout_l_switch),
2761d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("LOUT R Playback", SND_SOC_NOPM, 0, 0,
2762d3cb2de2SBard Liao 		&lout_r_switch),
2763d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("PDM L Playback", SND_SOC_NOPM, 0, 0,
2764d3cb2de2SBard Liao 		&pdm_l_switch),
2765d3cb2de2SBard Liao 	SND_SOC_DAPM_SWITCH("PDM R Playback", SND_SOC_NOPM, 0, 0,
2766d3cb2de2SBard Liao 		&pdm_r_switch),
2767d3cb2de2SBard Liao 
2768d3cb2de2SBard Liao 	/* PDM */
2769d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("PDM Power", RT5659_PWR_DIG_2,
2770d3cb2de2SBard Liao 		RT5659_PWR_PDM1_BIT, 0, NULL, 0),
2771d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("PDM L Mux", RT5659_PDM_OUT_CTRL,
2772d3cb2de2SBard Liao 		RT5659_M_PDM1_L_SFT, 1, &rt5659_pdm_l_mux),
2773d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("PDM R Mux", RT5659_PDM_OUT_CTRL,
2774d3cb2de2SBard Liao 		RT5659_M_PDM1_R_SFT, 1, &rt5659_pdm_r_mux),
2775d3cb2de2SBard Liao 
2776d3cb2de2SBard Liao 	/* SPDIF */
2777d3cb2de2SBard Liao 	SND_SOC_DAPM_MUX("SPDIF Mux", SND_SOC_NOPM, 0, 0, &rt5659_spdif_mux),
2778d3cb2de2SBard Liao 
2779d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("SYS CLK DET", RT5659_CLK_DET, 3, 0, NULL, 0),
2780d3cb2de2SBard Liao 	SND_SOC_DAPM_SUPPLY("CLKDET", RT5659_CLK_DET, 0, 0, NULL, 0),
2781d3cb2de2SBard Liao 
2782d3cb2de2SBard Liao 	/* Output Lines */
2783d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("HPOL"),
2784d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("HPOR"),
2785d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("SPOL"),
2786d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("SPOR"),
2787d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("LOUTL"),
2788d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("LOUTR"),
2789d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("MONOOUT"),
2790d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("PDML"),
2791d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("PDMR"),
2792d3cb2de2SBard Liao 	SND_SOC_DAPM_OUTPUT("SPDIF"),
2793d3cb2de2SBard Liao };
2794d3cb2de2SBard Liao 
2795d3cb2de2SBard Liao static const struct snd_soc_dapm_route rt5659_dapm_routes[] = {
2796d3cb2de2SBard Liao 	/*PLL*/
2797d3cb2de2SBard Liao 	{ "ADC Stereo1 Filter", NULL, "PLL", is_sys_clk_from_pll },
2798d3cb2de2SBard Liao 	{ "ADC Stereo2 Filter", NULL, "PLL", is_sys_clk_from_pll },
2799d3cb2de2SBard Liao 	{ "ADC Mono Left Filter", NULL, "PLL", is_sys_clk_from_pll },
2800d3cb2de2SBard Liao 	{ "ADC Mono Right Filter", NULL, "PLL", is_sys_clk_from_pll },
2801d3cb2de2SBard Liao 	{ "DAC Stereo1 Filter", NULL, "PLL", is_sys_clk_from_pll },
2802d3cb2de2SBard Liao 	{ "DAC Mono Left Filter", NULL, "PLL", is_sys_clk_from_pll },
2803d3cb2de2SBard Liao 	{ "DAC Mono Right Filter", NULL, "PLL", is_sys_clk_from_pll },
2804d3cb2de2SBard Liao 
2805d3cb2de2SBard Liao 	/*ASRC*/
2806d3cb2de2SBard Liao 	{ "ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc },
2807d3cb2de2SBard Liao 	{ "ADC Mono Left Filter", NULL, "ADC Mono L ASRC", is_using_asrc },
2808d3cb2de2SBard Liao 	{ "ADC Mono Right Filter", NULL, "ADC Mono R ASRC", is_using_asrc },
2809d3cb2de2SBard Liao 	{ "DAC Mono Left Filter", NULL, "DAC Mono L ASRC", is_using_asrc },
2810d3cb2de2SBard Liao 	{ "DAC Mono Right Filter", NULL, "DAC Mono R ASRC", is_using_asrc },
2811d3cb2de2SBard Liao 	{ "DAC Stereo1 Filter", NULL, "DAC STO ASRC", is_using_asrc },
2812d3cb2de2SBard Liao 
2813d3cb2de2SBard Liao 	{ "SYS CLK DET", NULL, "CLKDET" },
2814d3cb2de2SBard Liao 
2815d3cb2de2SBard Liao 	{ "I2S1", NULL, "I2S1 ASRC" },
2816d3cb2de2SBard Liao 	{ "I2S2", NULL, "I2S2 ASRC" },
2817d3cb2de2SBard Liao 	{ "I2S3", NULL, "I2S3 ASRC" },
2818d3cb2de2SBard Liao 
2819d3cb2de2SBard Liao 	{ "IN1P", NULL, "LDO2" },
2820d3cb2de2SBard Liao 	{ "IN2P", NULL, "LDO2" },
2821d3cb2de2SBard Liao 	{ "IN3P", NULL, "LDO2" },
2822d3cb2de2SBard Liao 	{ "IN4P", NULL, "LDO2" },
2823d3cb2de2SBard Liao 
2824d3cb2de2SBard Liao 	{ "DMIC1", NULL, "DMIC L1" },
2825d3cb2de2SBard Liao 	{ "DMIC1", NULL, "DMIC R1" },
2826d3cb2de2SBard Liao 	{ "DMIC2", NULL, "DMIC L2" },
2827d3cb2de2SBard Liao 	{ "DMIC2", NULL, "DMIC R2" },
2828d3cb2de2SBard Liao 
2829d3cb2de2SBard Liao 	{ "BST1", NULL, "IN1P" },
2830d3cb2de2SBard Liao 	{ "BST1", NULL, "IN1N" },
2831d3cb2de2SBard Liao 	{ "BST1", NULL, "BST1 Power" },
2832d3cb2de2SBard Liao 	{ "BST2", NULL, "IN2P" },
2833d3cb2de2SBard Liao 	{ "BST2", NULL, "IN2N" },
2834d3cb2de2SBard Liao 	{ "BST2", NULL, "BST2 Power" },
2835d3cb2de2SBard Liao 	{ "BST3", NULL, "IN3P" },
2836d3cb2de2SBard Liao 	{ "BST3", NULL, "IN3N" },
2837d3cb2de2SBard Liao 	{ "BST3", NULL, "BST3 Power" },
2838d3cb2de2SBard Liao 	{ "BST4", NULL, "IN4P" },
2839d3cb2de2SBard Liao 	{ "BST4", NULL, "IN4N" },
2840d3cb2de2SBard Liao 	{ "BST4", NULL, "BST4 Power" },
2841d3cb2de2SBard Liao 
2842d3cb2de2SBard Liao 	{ "INL VOL", NULL, "IN2P" },
2843d3cb2de2SBard Liao 	{ "INR VOL", NULL, "IN2N" },
2844d3cb2de2SBard Liao 
2845d3cb2de2SBard Liao 	{ "RECMIX1L", "SPKVOLL Switch", "SPKVOL L" },
2846d3cb2de2SBard Liao 	{ "RECMIX1L", "INL Switch", "INL VOL" },
2847d3cb2de2SBard Liao 	{ "RECMIX1L", "BST4 Switch", "BST4" },
2848d3cb2de2SBard Liao 	{ "RECMIX1L", "BST3 Switch", "BST3" },
2849d3cb2de2SBard Liao 	{ "RECMIX1L", "BST2 Switch", "BST2" },
2850d3cb2de2SBard Liao 	{ "RECMIX1L", "BST1 Switch", "BST1" },
2851d3cb2de2SBard Liao 
2852d3cb2de2SBard Liao 	{ "RECMIX1R", "HPOVOLR Switch", "HPO R Playback" },
2853d3cb2de2SBard Liao 	{ "RECMIX1R", "INR Switch", "INR VOL" },
2854d3cb2de2SBard Liao 	{ "RECMIX1R", "BST4 Switch", "BST4" },
2855d3cb2de2SBard Liao 	{ "RECMIX1R", "BST3 Switch", "BST3" },
2856d3cb2de2SBard Liao 	{ "RECMIX1R", "BST2 Switch", "BST2" },
2857d3cb2de2SBard Liao 	{ "RECMIX1R", "BST1 Switch", "BST1" },
2858d3cb2de2SBard Liao 
2859d3cb2de2SBard Liao 	{ "RECMIX2L", "SPKVOLL Switch", "SPKVOL L" },
2860d3cb2de2SBard Liao 	{ "RECMIX2L", "OUTVOLL Switch", "OUTVOL L" },
2861d3cb2de2SBard Liao 	{ "RECMIX2L", "BST4 Switch", "BST4" },
2862d3cb2de2SBard Liao 	{ "RECMIX2L", "BST3 Switch", "BST3" },
2863d3cb2de2SBard Liao 	{ "RECMIX2L", "BST2 Switch", "BST2" },
2864d3cb2de2SBard Liao 	{ "RECMIX2L", "BST1 Switch", "BST1" },
2865d3cb2de2SBard Liao 
2866d3cb2de2SBard Liao 	{ "RECMIX2R", "MONOVOL Switch", "MONOVOL" },
2867d3cb2de2SBard Liao 	{ "RECMIX2R", "OUTVOLR Switch", "OUTVOL R" },
2868d3cb2de2SBard Liao 	{ "RECMIX2R", "BST4 Switch", "BST4" },
2869d3cb2de2SBard Liao 	{ "RECMIX2R", "BST3 Switch", "BST3" },
2870d3cb2de2SBard Liao 	{ "RECMIX2R", "BST2 Switch", "BST2" },
2871d3cb2de2SBard Liao 	{ "RECMIX2R", "BST1 Switch", "BST1" },
2872d3cb2de2SBard Liao 
2873d3cb2de2SBard Liao 	{ "ADC1 L", NULL, "RECMIX1L" },
2874d3cb2de2SBard Liao 	{ "ADC1 L", NULL, "ADC1 L Power" },
2875d3cb2de2SBard Liao 	{ "ADC1 L", NULL, "ADC1 clock" },
2876d3cb2de2SBard Liao 	{ "ADC1 R", NULL, "RECMIX1R" },
2877d3cb2de2SBard Liao 	{ "ADC1 R", NULL, "ADC1 R Power" },
2878d3cb2de2SBard Liao 	{ "ADC1 R", NULL, "ADC1 clock" },
2879d3cb2de2SBard Liao 
2880d3cb2de2SBard Liao 	{ "ADC2 L", NULL, "RECMIX2L" },
2881d3cb2de2SBard Liao 	{ "ADC2 L", NULL, "ADC2 L Power" },
2882d3cb2de2SBard Liao 	{ "ADC2 L", NULL, "ADC2 clock" },
2883d3cb2de2SBard Liao 	{ "ADC2 R", NULL, "RECMIX2R" },
2884d3cb2de2SBard Liao 	{ "ADC2 R", NULL, "ADC2 R Power" },
2885d3cb2de2SBard Liao 	{ "ADC2 R", NULL, "ADC2 clock" },
2886d3cb2de2SBard Liao 
2887d3cb2de2SBard Liao 	{ "DMIC L1", NULL, "DMIC CLK" },
2888d3cb2de2SBard Liao 	{ "DMIC L1", NULL, "DMIC1 Power" },
2889d3cb2de2SBard Liao 	{ "DMIC R1", NULL, "DMIC CLK" },
2890d3cb2de2SBard Liao 	{ "DMIC R1", NULL, "DMIC1 Power" },
2891d3cb2de2SBard Liao 	{ "DMIC L2", NULL, "DMIC CLK" },
2892d3cb2de2SBard Liao 	{ "DMIC L2", NULL, "DMIC2 Power" },
2893d3cb2de2SBard Liao 	{ "DMIC R2", NULL, "DMIC CLK" },
2894d3cb2de2SBard Liao 	{ "DMIC R2", NULL, "DMIC2 Power" },
2895d3cb2de2SBard Liao 
2896d3cb2de2SBard Liao 	{ "Stereo1 DMIC L Mux", "DMIC1", "DMIC L1" },
2897d3cb2de2SBard Liao 	{ "Stereo1 DMIC L Mux", "DMIC2", "DMIC L2" },
2898d3cb2de2SBard Liao 
2899d3cb2de2SBard Liao 	{ "Stereo1 DMIC R Mux", "DMIC1", "DMIC R1" },
2900d3cb2de2SBard Liao 	{ "Stereo1 DMIC R Mux", "DMIC2", "DMIC R2" },
2901d3cb2de2SBard Liao 
2902d3cb2de2SBard Liao 	{ "Mono DMIC L Mux", "DMIC1 L", "DMIC L1" },
2903d3cb2de2SBard Liao 	{ "Mono DMIC L Mux", "DMIC2 L", "DMIC L2" },
2904d3cb2de2SBard Liao 
2905d3cb2de2SBard Liao 	{ "Mono DMIC R Mux", "DMIC1 R", "DMIC R1" },
2906d3cb2de2SBard Liao 	{ "Mono DMIC R Mux", "DMIC2 R", "DMIC R2" },
2907d3cb2de2SBard Liao 
2908d3cb2de2SBard Liao 	{ "Stereo1 ADC L Mux", "ADC1", "ADC1 L" },
2909d3cb2de2SBard Liao 	{ "Stereo1 ADC L Mux", "ADC2", "ADC2 L" },
2910d3cb2de2SBard Liao 	{ "Stereo1 ADC R Mux", "ADC1", "ADC1 R" },
2911d3cb2de2SBard Liao 	{ "Stereo1 ADC R Mux", "ADC2", "ADC2 R" },
2912d3cb2de2SBard Liao 
2913d3cb2de2SBard Liao 	{ "Stereo1 ADC L1 Mux", "ADC", "Stereo1 ADC L Mux" },
2914d3cb2de2SBard Liao 	{ "Stereo1 ADC L1 Mux", "DAC MIX", "DAC MIXL" },
2915d3cb2de2SBard Liao 	{ "Stereo1 ADC L2 Mux", "DMIC", "Stereo1 DMIC L Mux" },
2916d3cb2de2SBard Liao 	{ "Stereo1 ADC L2 Mux", "DAC MIX", "DAC MIXL" },
2917d3cb2de2SBard Liao 
2918d3cb2de2SBard Liao 	{ "Stereo1 ADC R1 Mux", "ADC", "Stereo1 ADC R Mux" },
2919d3cb2de2SBard Liao 	{ "Stereo1 ADC R1 Mux", "DAC MIX", "DAC MIXR" },
2920d3cb2de2SBard Liao 	{ "Stereo1 ADC R2 Mux", "DMIC", "Stereo1 DMIC R Mux" },
2921d3cb2de2SBard Liao 	{ "Stereo1 ADC R2 Mux", "DAC MIX", "DAC MIXR" },
2922d3cb2de2SBard Liao 
2923d3cb2de2SBard Liao 	{ "Mono ADC L Mux", "ADC1 L", "ADC1 L" },
2924d3cb2de2SBard Liao 	{ "Mono ADC L Mux", "ADC1 R", "ADC1 R" },
2925d3cb2de2SBard Liao 	{ "Mono ADC L Mux", "ADC2 L", "ADC2 L" },
2926d3cb2de2SBard Liao 	{ "Mono ADC L Mux", "ADC2 R", "ADC2 R" },
2927d3cb2de2SBard Liao 
2928d3cb2de2SBard Liao 	{ "Mono ADC R Mux", "ADC1 L", "ADC1 L" },
2929d3cb2de2SBard Liao 	{ "Mono ADC R Mux", "ADC1 R", "ADC1 R" },
2930d3cb2de2SBard Liao 	{ "Mono ADC R Mux", "ADC2 L", "ADC2 L" },
2931d3cb2de2SBard Liao 	{ "Mono ADC R Mux", "ADC2 R", "ADC2 R" },
2932d3cb2de2SBard Liao 
2933d3cb2de2SBard Liao 	{ "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" },
2934d3cb2de2SBard Liao 	{ "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2935d3cb2de2SBard Liao 	{ "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2936d3cb2de2SBard Liao 	{ "Mono ADC L1 Mux", "ADC",  "Mono ADC L Mux" },
2937d3cb2de2SBard Liao 
2938d3cb2de2SBard Liao 	{ "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2939d3cb2de2SBard Liao 	{ "Mono ADC R1 Mux", "ADC", "Mono ADC R Mux" },
2940d3cb2de2SBard Liao 	{ "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" },
2941d3cb2de2SBard Liao 	{ "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2942d3cb2de2SBard Liao 
2943d3cb2de2SBard Liao 	{ "Stereo1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux" },
2944d3cb2de2SBard Liao 	{ "Stereo1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux" },
2945d3cb2de2SBard Liao 	{ "Stereo1 ADC MIXL", NULL, "ADC Stereo1 Filter" },
2946d3cb2de2SBard Liao 
2947d3cb2de2SBard Liao 	{ "Stereo1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux" },
2948d3cb2de2SBard Liao 	{ "Stereo1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC R2 Mux" },
2949d3cb2de2SBard Liao 	{ "Stereo1 ADC MIXR", NULL, "ADC Stereo1 Filter" },
2950d3cb2de2SBard Liao 
2951d3cb2de2SBard Liao 	{ "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" },
2952d3cb2de2SBard Liao 	{ "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" },
2953d3cb2de2SBard Liao 	{ "Mono ADC MIXL", NULL, "ADC Mono Left Filter" },
2954d3cb2de2SBard Liao 
2955d3cb2de2SBard Liao 	{ "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" },
2956d3cb2de2SBard Liao 	{ "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" },
2957d3cb2de2SBard Liao 	{ "Mono ADC MIXR", NULL, "ADC Mono Right Filter" },
2958d3cb2de2SBard Liao 
2959d3cb2de2SBard Liao 	{ "Stereo1 ADC Volume L", NULL, "Stereo1 ADC MIXL" },
2960d3cb2de2SBard Liao 	{ "Stereo1 ADC Volume R", NULL, "Stereo1 ADC MIXR" },
2961d3cb2de2SBard Liao 
2962d3cb2de2SBard Liao 	{ "IF_ADC1", NULL, "Stereo1 ADC Volume L" },
2963d3cb2de2SBard Liao 	{ "IF_ADC1", NULL, "Stereo1 ADC Volume R" },
2964d3cb2de2SBard Liao 	{ "IF_ADC2", NULL, "Mono ADC MIXL" },
2965d3cb2de2SBard Liao 	{ "IF_ADC2", NULL, "Mono ADC MIXR" },
2966d3cb2de2SBard Liao 
2967d3cb2de2SBard Liao 	{ "TDM AD1:AD2:DAC", NULL, "IF_ADC1" },
2968d3cb2de2SBard Liao 	{ "TDM AD1:AD2:DAC", NULL, "IF_ADC2" },
2969d3cb2de2SBard Liao 	{ "TDM AD1:AD2:DAC", NULL, "DAC_REF" },
2970d3cb2de2SBard Liao 	{ "TDM AD2:DAC", NULL, "IF_ADC2" },
2971d3cb2de2SBard Liao 	{ "TDM AD2:DAC", NULL, "DAC_REF" },
2972d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD1:AD2:DAC:NUL", "TDM AD1:AD2:DAC" },
2973d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD1:AD2:NUL:DAC", "TDM AD1:AD2:DAC" },
2974d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD1:DAC:AD2:NUL", "TDM AD1:AD2:DAC" },
2975d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD1:DAC:NUL:AD2", "TDM AD1:AD2:DAC" },
2976d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD1:NUL:DAC:AD2", "TDM AD1:AD2:DAC" },
2977d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD1:NUL:AD2:DAC", "TDM AD1:AD2:DAC" },
2978d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD2:AD1:DAC:NUL", "TDM AD1:AD2:DAC" },
2979d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD2:AD1:NUL:DAC", "TDM AD1:AD2:DAC" },
2980d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD2:DAC:AD1:NUL", "TDM AD1:AD2:DAC" },
2981d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD2:DAC:NUL:AD1", "TDM AD1:AD2:DAC" },
2982d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD2:NUL:DAC:AD1", "TDM AD1:AD2:DAC" },
2983d3cb2de2SBard Liao 	{ "TDM Data Mux", "AD1:NUL:AD1:DAC", "TDM AD1:AD2:DAC" },
2984d3cb2de2SBard Liao 	{ "TDM Data Mux", "DAC:AD1:AD2:NUL", "TDM AD1:AD2:DAC" },
2985d3cb2de2SBard Liao 	{ "TDM Data Mux", "DAC:AD1:NUL:AD2", "TDM AD1:AD2:DAC" },
2986d3cb2de2SBard Liao 	{ "TDM Data Mux", "DAC:AD2:AD1:NUL", "TDM AD1:AD2:DAC" },
2987d3cb2de2SBard Liao 	{ "TDM Data Mux", "DAC:AD2:NUL:AD1", "TDM AD1:AD2:DAC" },
2988d3cb2de2SBard Liao 	{ "TDM Data Mux", "DAC:NUL:DAC:AD2", "TDM AD2:DAC" },
2989d3cb2de2SBard Liao 	{ "TDM Data Mux", "DAC:NUL:AD2:DAC", "TDM AD2:DAC" },
2990d3cb2de2SBard Liao 	{ "TDM Data Mux", "NUL:AD1:AD2:DAC", "TDM AD1:AD2:DAC" },
2991d3cb2de2SBard Liao 	{ "TDM Data Mux", "NUL:AD1:DAC:AD2", "TDM AD1:AD2:DAC" },
2992d3cb2de2SBard Liao 	{ "TDM Data Mux", "NUL:AD2:AD1:DAC", "TDM AD1:AD2:DAC" },
2993d3cb2de2SBard Liao 	{ "TDM Data Mux", "NUL:AD2:DAC:AD1", "TDM AD1:AD2:DAC" },
2994d3cb2de2SBard Liao 	{ "TDM Data Mux", "NUL:DAC:DAC:AD2", "TDM AD2:DAC" },
2995d3cb2de2SBard Liao 	{ "TDM Data Mux", "NUL:DAC:AD2:DAC", "TDM AD2:DAC" },
2996d3cb2de2SBard Liao 	{ "IF1 01 ADC Swap Mux", "L/R", "TDM Data Mux" },
2997d3cb2de2SBard Liao 	{ "IF1 01 ADC Swap Mux", "R/L", "TDM Data Mux" },
2998d3cb2de2SBard Liao 	{ "IF1 01 ADC Swap Mux", "L/L", "TDM Data Mux" },
2999d3cb2de2SBard Liao 	{ "IF1 01 ADC Swap Mux", "R/R", "TDM Data Mux" },
3000d3cb2de2SBard Liao 	{ "IF1 23 ADC Swap Mux", "L/R", "TDM Data Mux" },
3001d3cb2de2SBard Liao 	{ "IF1 23 ADC Swap Mux", "R/L", "TDM Data Mux" },
3002d3cb2de2SBard Liao 	{ "IF1 23 ADC Swap Mux", "L/L", "TDM Data Mux" },
3003d3cb2de2SBard Liao 	{ "IF1 23 ADC Swap Mux", "R/R", "TDM Data Mux" },
3004d3cb2de2SBard Liao 	{ "IF1 45 ADC Swap Mux", "L/R", "TDM Data Mux" },
3005d3cb2de2SBard Liao 	{ "IF1 45 ADC Swap Mux", "R/L", "TDM Data Mux" },
3006d3cb2de2SBard Liao 	{ "IF1 45 ADC Swap Mux", "L/L", "TDM Data Mux" },
3007d3cb2de2SBard Liao 	{ "IF1 45 ADC Swap Mux", "R/R", "TDM Data Mux" },
3008d3cb2de2SBard Liao 	{ "IF1 67 ADC Swap Mux", "L/R", "TDM Data Mux" },
3009d3cb2de2SBard Liao 	{ "IF1 67 ADC Swap Mux", "R/L", "TDM Data Mux" },
3010d3cb2de2SBard Liao 	{ "IF1 67 ADC Swap Mux", "L/L", "TDM Data Mux" },
3011d3cb2de2SBard Liao 	{ "IF1 67 ADC Swap Mux", "R/R", "TDM Data Mux" },
3012d3cb2de2SBard Liao 	{ "IF1 ADC", NULL, "IF1 01 ADC Swap Mux" },
3013d3cb2de2SBard Liao 	{ "IF1 ADC", NULL, "IF1 23 ADC Swap Mux" },
3014d3cb2de2SBard Liao 	{ "IF1 ADC", NULL, "IF1 45 ADC Swap Mux" },
3015d3cb2de2SBard Liao 	{ "IF1 ADC", NULL, "IF1 67 ADC Swap Mux" },
3016d3cb2de2SBard Liao 	{ "IF1 ADC", NULL, "I2S1" },
3017d3cb2de2SBard Liao 
3018d3cb2de2SBard Liao 	{ "IF2 ADC Mux", "IF_ADC1", "IF_ADC1" },
3019d3cb2de2SBard Liao 	{ "IF2 ADC Mux", "IF_ADC2", "IF_ADC2" },
3020d3cb2de2SBard Liao 	{ "IF2 ADC Mux", "IF_ADC3", "IF_ADC3" },
3021d3cb2de2SBard Liao 	{ "IF2 ADC Mux", "DAC_REF", "DAC_REF" },
3022d3cb2de2SBard Liao 	{ "IF2 ADC", NULL, "IF2 ADC Mux"},
3023d3cb2de2SBard Liao 	{ "IF2 ADC", NULL, "I2S2" },
3024d3cb2de2SBard Liao 
3025d3cb2de2SBard Liao 	{ "IF3 ADC Mux", "IF_ADC1", "IF_ADC1" },
3026d3cb2de2SBard Liao 	{ "IF3 ADC Mux", "IF_ADC2", "IF_ADC2" },
3027d3cb2de2SBard Liao 	{ "IF3 ADC Mux", "Stereo2_ADC_L/R", "Stereo2 ADC LR" },
3028d3cb2de2SBard Liao 	{ "IF3 ADC Mux", "DAC_REF", "DAC_REF" },
3029d3cb2de2SBard Liao 	{ "IF3 ADC", NULL, "IF3 ADC Mux"},
3030d3cb2de2SBard Liao 	{ "IF3 ADC", NULL, "I2S3" },
3031d3cb2de2SBard Liao 
3032d3cb2de2SBard Liao 	{ "AIF1TX", NULL, "IF1 ADC" },
3033d3cb2de2SBard Liao 	{ "IF2 ADC Swap Mux", "L/R", "IF2 ADC" },
3034d3cb2de2SBard Liao 	{ "IF2 ADC Swap Mux", "R/L", "IF2 ADC" },
3035d3cb2de2SBard Liao 	{ "IF2 ADC Swap Mux", "L/L", "IF2 ADC" },
3036d3cb2de2SBard Liao 	{ "IF2 ADC Swap Mux", "R/R", "IF2 ADC" },
3037d3cb2de2SBard Liao 	{ "AIF2TX", NULL, "IF2 ADC Swap Mux" },
3038d3cb2de2SBard Liao 	{ "IF3 ADC Swap Mux", "L/R", "IF3 ADC" },
3039d3cb2de2SBard Liao 	{ "IF3 ADC Swap Mux", "R/L", "IF3 ADC" },
3040d3cb2de2SBard Liao 	{ "IF3 ADC Swap Mux", "L/L", "IF3 ADC" },
3041d3cb2de2SBard Liao 	{ "IF3 ADC Swap Mux", "R/R", "IF3 ADC" },
3042d3cb2de2SBard Liao 	{ "AIF3TX", NULL, "IF3 ADC Swap Mux" },
3043d3cb2de2SBard Liao 
3044d3cb2de2SBard Liao 	{ "IF1 DAC1", NULL, "AIF1RX" },
3045d3cb2de2SBard Liao 	{ "IF1 DAC2", NULL, "AIF1RX" },
3046d3cb2de2SBard Liao 	{ "IF2 DAC Swap Mux", "L/R", "AIF2RX" },
3047d3cb2de2SBard Liao 	{ "IF2 DAC Swap Mux", "R/L", "AIF2RX" },
3048d3cb2de2SBard Liao 	{ "IF2 DAC Swap Mux", "L/L", "AIF2RX" },
3049d3cb2de2SBard Liao 	{ "IF2 DAC Swap Mux", "R/R", "AIF2RX" },
3050d3cb2de2SBard Liao 	{ "IF2 DAC", NULL, "IF2 DAC Swap Mux" },
3051d3cb2de2SBard Liao 	{ "IF3 DAC Swap Mux", "L/R", "AIF3RX" },
3052d3cb2de2SBard Liao 	{ "IF3 DAC Swap Mux", "R/L", "AIF3RX" },
3053d3cb2de2SBard Liao 	{ "IF3 DAC Swap Mux", "L/L", "AIF3RX" },
3054d3cb2de2SBard Liao 	{ "IF3 DAC Swap Mux", "R/R", "AIF3RX" },
3055d3cb2de2SBard Liao 	{ "IF3 DAC", NULL, "IF3 DAC Swap Mux" },
3056d3cb2de2SBard Liao 
3057d3cb2de2SBard Liao 	{ "IF1 DAC1", NULL, "I2S1" },
3058d3cb2de2SBard Liao 	{ "IF1 DAC2", NULL, "I2S1" },
3059d3cb2de2SBard Liao 	{ "IF2 DAC", NULL, "I2S2" },
3060d3cb2de2SBard Liao 	{ "IF3 DAC", NULL, "I2S3" },
3061d3cb2de2SBard Liao 
3062d3cb2de2SBard Liao 	{ "IF1 DAC2 L", NULL, "IF1 DAC2" },
3063d3cb2de2SBard Liao 	{ "IF1 DAC2 R", NULL, "IF1 DAC2" },
3064d3cb2de2SBard Liao 	{ "IF1 DAC1 L", NULL, "IF1 DAC1" },
3065d3cb2de2SBard Liao 	{ "IF1 DAC1 R", NULL, "IF1 DAC1" },
3066d3cb2de2SBard Liao 	{ "IF2 DAC L", NULL, "IF2 DAC" },
3067d3cb2de2SBard Liao 	{ "IF2 DAC R", NULL, "IF2 DAC" },
3068d3cb2de2SBard Liao 	{ "IF3 DAC L", NULL, "IF3 DAC" },
3069d3cb2de2SBard Liao 	{ "IF3 DAC R", NULL, "IF3 DAC" },
3070d3cb2de2SBard Liao 
3071d3cb2de2SBard Liao 	{ "DAC L1 Mux", "IF1 DAC1", "IF1 DAC1 L" },
3072d3cb2de2SBard Liao 	{ "DAC L1 Mux", "IF2 DAC", "IF2 DAC L" },
3073d3cb2de2SBard Liao 	{ "DAC L1 Mux", "IF3 DAC", "IF3 DAC L" },
3074d3cb2de2SBard Liao 	{ "DAC L1 Mux", NULL, "DAC Stereo1 Filter" },
3075d3cb2de2SBard Liao 
3076d3cb2de2SBard Liao 	{ "DAC R1 Mux", "IF1 DAC1", "IF1 DAC1 R" },
3077d3cb2de2SBard Liao 	{ "DAC R1 Mux", "IF2 DAC", "IF2 DAC R" },
3078d3cb2de2SBard Liao 	{ "DAC R1 Mux", "IF3 DAC", "IF3 DAC R" },
3079d3cb2de2SBard Liao 	{ "DAC R1 Mux", NULL, "DAC Stereo1 Filter" },
3080d3cb2de2SBard Liao 
3081d3cb2de2SBard Liao 	{ "DAC1 MIXL", "Stereo ADC Switch", "Stereo1 ADC Volume L" },
3082d3cb2de2SBard Liao 	{ "DAC1 MIXL", "DAC1 Switch", "DAC L1 Mux" },
3083d3cb2de2SBard Liao 	{ "DAC1 MIXR", "Stereo ADC Switch", "Stereo1 ADC Volume R" },
3084d3cb2de2SBard Liao 	{ "DAC1 MIXR", "DAC1 Switch", "DAC R1 Mux" },
3085d3cb2de2SBard Liao 
3086d3cb2de2SBard Liao 	{ "DAC_REF", NULL, "DAC1 MIXL" },
3087d3cb2de2SBard Liao 	{ "DAC_REF", NULL, "DAC1 MIXR" },
3088d3cb2de2SBard Liao 
3089d3cb2de2SBard Liao 	{ "DAC L2 Mux", "IF1 DAC2", "IF1 DAC2 L" },
3090d3cb2de2SBard Liao 	{ "DAC L2 Mux", "IF2 DAC", "IF2 DAC L" },
3091d3cb2de2SBard Liao 	{ "DAC L2 Mux", "IF3 DAC", "IF3 DAC L" },
3092d3cb2de2SBard Liao 	{ "DAC L2 Mux", "Mono ADC MIX", "Mono ADC MIXL" },
3093d3cb2de2SBard Liao 	{ "DAC L2 Mux", NULL, "DAC Mono Left Filter" },
3094d3cb2de2SBard Liao 
3095d3cb2de2SBard Liao 	{ "DAC R2 Mux", "IF1 DAC2", "IF1 DAC2 R" },
3096d3cb2de2SBard Liao 	{ "DAC R2 Mux", "IF2 DAC", "IF2 DAC R" },
3097d3cb2de2SBard Liao 	{ "DAC R2 Mux", "IF3 DAC", "IF3 DAC R" },
3098d3cb2de2SBard Liao 	{ "DAC R2 Mux", "Mono ADC MIX", "Mono ADC MIXR" },
3099d3cb2de2SBard Liao 	{ "DAC R2 Mux", NULL, "DAC Mono Right Filter" },
3100d3cb2de2SBard Liao 
3101d3cb2de2SBard Liao 	{ "Stereo DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
3102d3cb2de2SBard Liao 	{ "Stereo DAC MIXL", "DAC R1 Switch", "DAC1 MIXR" },
3103d3cb2de2SBard Liao 	{ "Stereo DAC MIXL", "DAC L2 Switch", "DAC L2 Mux" },
3104d3cb2de2SBard Liao 	{ "Stereo DAC MIXL", "DAC R2 Switch", "DAC R2 Mux" },
3105d3cb2de2SBard Liao 
3106d3cb2de2SBard Liao 	{ "Stereo DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
3107d3cb2de2SBard Liao 	{ "Stereo DAC MIXR", "DAC L1 Switch", "DAC1 MIXL" },
3108d3cb2de2SBard Liao 	{ "Stereo DAC MIXR", "DAC L2 Switch", "DAC L2 Mux" },
3109d3cb2de2SBard Liao 	{ "Stereo DAC MIXR", "DAC R2 Switch", "DAC R2 Mux" },
3110d3cb2de2SBard Liao 
3111d3cb2de2SBard Liao 	{ "Mono DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
3112d3cb2de2SBard Liao 	{ "Mono DAC MIXL", "DAC R1 Switch", "DAC1 MIXR" },
3113d3cb2de2SBard Liao 	{ "Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Mux" },
3114d3cb2de2SBard Liao 	{ "Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Mux" },
3115d3cb2de2SBard Liao 	{ "Mono DAC MIXR", "DAC L1 Switch", "DAC1 MIXL" },
3116d3cb2de2SBard Liao 	{ "Mono DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
3117d3cb2de2SBard Liao 	{ "Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Mux" },
3118d3cb2de2SBard Liao 	{ "Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Mux" },
3119d3cb2de2SBard Liao 
3120d3cb2de2SBard Liao 	{ "DAC MIXL", "Stereo DAC Mixer", "Stereo DAC MIXL" },
3121d3cb2de2SBard Liao 	{ "DAC MIXL", "Mono DAC Mixer", "Mono DAC MIXL" },
3122d3cb2de2SBard Liao 	{ "DAC MIXR", "Stereo DAC Mixer", "Stereo DAC MIXR" },
3123d3cb2de2SBard Liao 	{ "DAC MIXR", "Mono DAC Mixer", "Mono DAC MIXR" },
3124d3cb2de2SBard Liao 
3125d3cb2de2SBard Liao 	{ "DAC L1 Source", NULL, "DAC L1 Power" },
3126d3cb2de2SBard Liao 	{ "DAC L1 Source", "DAC", "DAC1 MIXL" },
3127d3cb2de2SBard Liao 	{ "DAC L1 Source", "Stereo DAC Mixer", "Stereo DAC MIXL" },
3128d3cb2de2SBard Liao 	{ "DAC R1 Source", NULL, "DAC R1 Power" },
3129d3cb2de2SBard Liao 	{ "DAC R1 Source", "DAC", "DAC1 MIXR" },
3130d3cb2de2SBard Liao 	{ "DAC R1 Source", "Stereo DAC Mixer", "Stereo DAC MIXR" },
3131d3cb2de2SBard Liao 	{ "DAC L2 Source", "Stereo DAC Mixer", "Stereo DAC MIXL" },
3132d3cb2de2SBard Liao 	{ "DAC L2 Source", "Mono DAC Mixer", "Mono DAC MIXL" },
3133d3cb2de2SBard Liao 	{ "DAC L2 Source", NULL, "DAC L2 Power" },
3134d3cb2de2SBard Liao 	{ "DAC R2 Source", "Stereo DAC Mixer", "Stereo DAC MIXR" },
3135d3cb2de2SBard Liao 	{ "DAC R2 Source", "Mono DAC Mixer", "Mono DAC MIXR" },
3136d3cb2de2SBard Liao 	{ "DAC R2 Source", NULL, "DAC R2 Power" },
3137d3cb2de2SBard Liao 
3138d3cb2de2SBard Liao 	{ "DAC L1", NULL, "DAC L1 Source" },
3139d3cb2de2SBard Liao 	{ "DAC R1", NULL, "DAC R1 Source" },
3140d3cb2de2SBard Liao 	{ "DAC L2", NULL, "DAC L2 Source" },
3141d3cb2de2SBard Liao 	{ "DAC R2", NULL, "DAC R2 Source" },
3142d3cb2de2SBard Liao 
3143d3cb2de2SBard Liao 	{ "SPK MIXL", "DAC L2 Switch", "DAC L2" },
3144d3cb2de2SBard Liao 	{ "SPK MIXL", "BST1 Switch", "BST1" },
3145d3cb2de2SBard Liao 	{ "SPK MIXL", "INL Switch", "INL VOL" },
3146d3cb2de2SBard Liao 	{ "SPK MIXL", "INR Switch", "INR VOL" },
3147d3cb2de2SBard Liao 	{ "SPK MIXL", "BST3 Switch", "BST3" },
3148d3cb2de2SBard Liao 	{ "SPK MIXR", "DAC R2 Switch", "DAC R2" },
3149d3cb2de2SBard Liao 	{ "SPK MIXR", "BST4 Switch", "BST4" },
3150d3cb2de2SBard Liao 	{ "SPK MIXR", "INL Switch", "INL VOL" },
3151d3cb2de2SBard Liao 	{ "SPK MIXR", "INR Switch", "INR VOL" },
3152d3cb2de2SBard Liao 	{ "SPK MIXR", "BST3 Switch", "BST3" },
3153d3cb2de2SBard Liao 
3154d3cb2de2SBard Liao 	{ "MONOVOL MIX", "DAC L2 Switch", "DAC L2" },
3155d3cb2de2SBard Liao 	{ "MONOVOL MIX", "DAC R2 Switch", "DAC R2" },
3156d3cb2de2SBard Liao 	{ "MONOVOL MIX", "BST1 Switch", "BST1" },
3157d3cb2de2SBard Liao 	{ "MONOVOL MIX", "BST2 Switch", "BST2" },
3158d3cb2de2SBard Liao 	{ "MONOVOL MIX", "BST3 Switch", "BST3" },
3159d3cb2de2SBard Liao 
3160d3cb2de2SBard Liao 	{ "OUT MIXL", "DAC L2 Switch", "DAC L2" },
3161d3cb2de2SBard Liao 	{ "OUT MIXL", "INL Switch", "INL VOL" },
3162d3cb2de2SBard Liao 	{ "OUT MIXL", "BST1 Switch", "BST1" },
3163d3cb2de2SBard Liao 	{ "OUT MIXL", "BST2 Switch", "BST2" },
3164d3cb2de2SBard Liao 	{ "OUT MIXL", "BST3 Switch", "BST3" },
3165d3cb2de2SBard Liao 	{ "OUT MIXR", "DAC R2 Switch", "DAC R2" },
3166d3cb2de2SBard Liao 	{ "OUT MIXR", "INR Switch", "INR VOL" },
3167d3cb2de2SBard Liao 	{ "OUT MIXR", "BST2 Switch", "BST2" },
3168d3cb2de2SBard Liao 	{ "OUT MIXR", "BST3 Switch", "BST3" },
3169d3cb2de2SBard Liao 	{ "OUT MIXR", "BST4 Switch", "BST4" },
3170d3cb2de2SBard Liao 
3171d3cb2de2SBard Liao 	{ "SPKVOL L", "Switch", "SPK MIXL" },
3172d3cb2de2SBard Liao 	{ "SPKVOL R", "Switch", "SPK MIXR" },
3173d3cb2de2SBard Liao 	{ "SPO L MIX", "DAC L2 Switch", "DAC L2" },
3174d3cb2de2SBard Liao 	{ "SPO L MIX", "SPKVOL L Switch", "SPKVOL L" },
3175d3cb2de2SBard Liao 	{ "SPO R MIX", "DAC R2 Switch", "DAC R2" },
3176d3cb2de2SBard Liao 	{ "SPO R MIX", "SPKVOL R Switch", "SPKVOL R" },
3177d3cb2de2SBard Liao 	{ "SPK Amp", NULL, "SPO L MIX" },
3178d3cb2de2SBard Liao 	{ "SPK Amp", NULL, "SPO R MIX" },
3179d3cb2de2SBard Liao 	{ "SPK Amp", NULL, "SYS CLK DET" },
3180d3cb2de2SBard Liao 	{ "SPO Playback", "Switch", "SPK Amp" },
3181d3cb2de2SBard Liao 	{ "SPOL", NULL, "SPO Playback" },
3182d3cb2de2SBard Liao 	{ "SPOR", NULL, "SPO Playback" },
3183d3cb2de2SBard Liao 
3184d3cb2de2SBard Liao 	{ "MONOVOL", "Switch", "MONOVOL MIX" },
3185d3cb2de2SBard Liao 	{ "Mono MIX", "DAC L2 Switch", "DAC L2" },
3186d3cb2de2SBard Liao 	{ "Mono MIX", "MONOVOL Switch", "MONOVOL" },
3187d3cb2de2SBard Liao 	{ "Mono Amp", NULL, "Mono MIX" },
3188d3cb2de2SBard Liao 	{ "Mono Amp", NULL, "Mono Vref" },
3189d3cb2de2SBard Liao 	{ "Mono Amp", NULL, "SYS CLK DET" },
3190d3cb2de2SBard Liao 	{ "Mono Playback", "Switch", "Mono Amp" },
3191d3cb2de2SBard Liao 	{ "MONOOUT", NULL, "Mono Playback" },
3192d3cb2de2SBard Liao 
3193d3cb2de2SBard Liao 	{ "HP Amp", NULL, "DAC L1" },
3194d3cb2de2SBard Liao 	{ "HP Amp", NULL, "DAC R1" },
3195d3cb2de2SBard Liao 	{ "HP Amp", NULL, "Charge Pump" },
3196d3cb2de2SBard Liao 	{ "HP Amp", NULL, "SYS CLK DET" },
3197d3cb2de2SBard Liao 	{ "HPO L Playback", "Switch", "HP Amp"},
3198d3cb2de2SBard Liao 	{ "HPO R Playback", "Switch", "HP Amp"},
3199d3cb2de2SBard Liao 	{ "HPOL", NULL, "HPO L Playback" },
3200d3cb2de2SBard Liao 	{ "HPOR", NULL, "HPO R Playback" },
3201d3cb2de2SBard Liao 
3202d3cb2de2SBard Liao 	{ "OUTVOL L", "Switch", "OUT MIXL" },
3203d3cb2de2SBard Liao 	{ "OUTVOL R", "Switch", "OUT MIXR" },
3204d3cb2de2SBard Liao 	{ "LOUT L MIX", "DAC L2 Switch", "DAC L2" },
3205d3cb2de2SBard Liao 	{ "LOUT L MIX", "OUTVOL L Switch", "OUTVOL L" },
3206d3cb2de2SBard Liao 	{ "LOUT R MIX", "DAC R2 Switch", "DAC R2" },
3207d3cb2de2SBard Liao 	{ "LOUT R MIX", "OUTVOL R Switch", "OUTVOL R" },
3208d3cb2de2SBard Liao 	{ "LOUT Amp", NULL, "LOUT L MIX" },
3209d3cb2de2SBard Liao 	{ "LOUT Amp", NULL, "LOUT R MIX" },
3210d3cb2de2SBard Liao 	{ "LOUT Amp", NULL, "SYS CLK DET" },
3211d3cb2de2SBard Liao 	{ "LOUT L Playback", "Switch", "LOUT Amp" },
3212d3cb2de2SBard Liao 	{ "LOUT R Playback", "Switch", "LOUT Amp" },
3213d3cb2de2SBard Liao 	{ "LOUTL", NULL, "LOUT L Playback" },
3214d3cb2de2SBard Liao 	{ "LOUTR", NULL, "LOUT R Playback" },
3215d3cb2de2SBard Liao 
3216d3cb2de2SBard Liao 	{ "PDM L Mux", "Mono DAC", "Mono DAC MIXL" },
3217d3cb2de2SBard Liao 	{ "PDM L Mux", "Stereo DAC", "Stereo DAC MIXL" },
3218d3cb2de2SBard Liao 	{ "PDM L Mux", NULL, "PDM Power" },
3219d3cb2de2SBard Liao 	{ "PDM R Mux", "Mono DAC", "Mono DAC MIXR" },
3220d3cb2de2SBard Liao 	{ "PDM R Mux", "Stereo DAC", "Stereo DAC MIXR" },
3221d3cb2de2SBard Liao 	{ "PDM R Mux", NULL, "PDM Power" },
3222d3cb2de2SBard Liao 	{ "PDM L Playback", "Switch", "PDM L Mux" },
3223d3cb2de2SBard Liao 	{ "PDM R Playback", "Switch", "PDM R Mux" },
3224d3cb2de2SBard Liao 	{ "PDML", NULL, "PDM L Playback" },
3225d3cb2de2SBard Liao 	{ "PDMR", NULL, "PDM R Playback" },
3226d3cb2de2SBard Liao 
3227d3cb2de2SBard Liao 	{ "SPDIF Mux", "IF3_DAC", "IF3 DAC" },
3228d3cb2de2SBard Liao 	{ "SPDIF Mux", "IF2_DAC", "IF2 DAC" },
3229d3cb2de2SBard Liao 	{ "SPDIF Mux", "IF1_DAC2", "IF1 DAC2" },
3230d3cb2de2SBard Liao 	{ "SPDIF Mux", "IF1_DAC1", "IF1 DAC1" },
3231d3cb2de2SBard Liao 	{ "SPDIF", NULL, "SPDIF Mux" },
3232d3cb2de2SBard Liao };
3233d3cb2de2SBard Liao 
3234d3cb2de2SBard Liao static int rt5659_hw_params(struct snd_pcm_substream *substream,
3235d3cb2de2SBard Liao 	struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
3236d3cb2de2SBard Liao {
3237d3cb2de2SBard Liao 	struct snd_soc_codec *codec = dai->codec;
3238d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3239d3cb2de2SBard Liao 	unsigned int val_len = 0, val_clk, mask_clk;
3240d3cb2de2SBard Liao 	int pre_div, frame_size;
3241d3cb2de2SBard Liao 
3242d3cb2de2SBard Liao 	rt5659->lrck[dai->id] = params_rate(params);
3243d3cb2de2SBard Liao 	pre_div = rl6231_get_clk_info(rt5659->sysclk, rt5659->lrck[dai->id]);
3244d3cb2de2SBard Liao 	if (pre_div < 0) {
3245d3cb2de2SBard Liao 		dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n",
3246d3cb2de2SBard Liao 			rt5659->lrck[dai->id], dai->id);
3247d3cb2de2SBard Liao 		return -EINVAL;
3248d3cb2de2SBard Liao 	}
3249d3cb2de2SBard Liao 	frame_size = snd_soc_params_to_frame_size(params);
3250d3cb2de2SBard Liao 	if (frame_size < 0) {
3251d3cb2de2SBard Liao 		dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
3252d3cb2de2SBard Liao 		return -EINVAL;
3253d3cb2de2SBard Liao 	}
3254d3cb2de2SBard Liao 
3255d3cb2de2SBard Liao 	dev_dbg(dai->dev, "lrck is %dHz and pre_div is %d for iis %d\n",
3256d3cb2de2SBard Liao 				rt5659->lrck[dai->id], pre_div, dai->id);
3257d3cb2de2SBard Liao 
3258d3cb2de2SBard Liao 	switch (params_width(params)) {
3259d3cb2de2SBard Liao 	case 16:
3260d3cb2de2SBard Liao 		break;
3261d3cb2de2SBard Liao 	case 20:
3262d3cb2de2SBard Liao 		val_len |= RT5659_I2S_DL_20;
3263d3cb2de2SBard Liao 		break;
3264d3cb2de2SBard Liao 	case 24:
3265d3cb2de2SBard Liao 		val_len |= RT5659_I2S_DL_24;
3266d3cb2de2SBard Liao 		break;
3267d3cb2de2SBard Liao 	case 8:
3268d3cb2de2SBard Liao 		val_len |= RT5659_I2S_DL_8;
3269d3cb2de2SBard Liao 		break;
3270d3cb2de2SBard Liao 	default:
3271d3cb2de2SBard Liao 		return -EINVAL;
3272d3cb2de2SBard Liao 	}
3273d3cb2de2SBard Liao 
3274d3cb2de2SBard Liao 	switch (dai->id) {
3275d3cb2de2SBard Liao 	case RT5659_AIF1:
3276d3cb2de2SBard Liao 		mask_clk = RT5659_I2S_PD1_MASK;
3277d3cb2de2SBard Liao 		val_clk = pre_div << RT5659_I2S_PD1_SFT;
3278d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_I2S1_SDP,
3279d3cb2de2SBard Liao 			RT5659_I2S_DL_MASK, val_len);
3280d3cb2de2SBard Liao 		break;
3281d3cb2de2SBard Liao 	case RT5659_AIF2:
3282d3cb2de2SBard Liao 		mask_clk = RT5659_I2S_PD2_MASK;
3283d3cb2de2SBard Liao 		val_clk = pre_div << RT5659_I2S_PD2_SFT;
3284d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_I2S2_SDP,
3285d3cb2de2SBard Liao 			RT5659_I2S_DL_MASK, val_len);
3286d3cb2de2SBard Liao 		break;
3287d3cb2de2SBard Liao 	case RT5659_AIF3:
3288d3cb2de2SBard Liao 		mask_clk = RT5659_I2S_PD3_MASK;
3289d3cb2de2SBard Liao 		val_clk = pre_div << RT5659_I2S_PD3_SFT;
3290d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_I2S3_SDP,
3291d3cb2de2SBard Liao 			RT5659_I2S_DL_MASK, val_len);
3292d3cb2de2SBard Liao 		break;
3293d3cb2de2SBard Liao 	default:
3294d3cb2de2SBard Liao 		dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id);
3295d3cb2de2SBard Liao 		return -EINVAL;
3296d3cb2de2SBard Liao 	}
3297d3cb2de2SBard Liao 
3298d3cb2de2SBard Liao 	snd_soc_update_bits(codec, RT5659_ADDA_CLK_1, mask_clk, val_clk);
3299d3cb2de2SBard Liao 
3300d3cb2de2SBard Liao 	switch (rt5659->lrck[dai->id]) {
3301d3cb2de2SBard Liao 	case 192000:
3302d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_ADDA_CLK_1,
3303d3cb2de2SBard Liao 			RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_32);
3304d3cb2de2SBard Liao 		break;
3305d3cb2de2SBard Liao 	case 96000:
3306d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_ADDA_CLK_1,
3307d3cb2de2SBard Liao 			RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_64);
3308d3cb2de2SBard Liao 		break;
3309d3cb2de2SBard Liao 	default:
3310d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_ADDA_CLK_1,
3311d3cb2de2SBard Liao 			RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_128);
3312d3cb2de2SBard Liao 		break;
3313d3cb2de2SBard Liao 	}
3314d3cb2de2SBard Liao 
3315d3cb2de2SBard Liao 	return 0;
3316d3cb2de2SBard Liao }
3317d3cb2de2SBard Liao 
3318d3cb2de2SBard Liao static int rt5659_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
3319d3cb2de2SBard Liao {
3320d3cb2de2SBard Liao 	struct snd_soc_codec *codec = dai->codec;
3321d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3322d3cb2de2SBard Liao 	unsigned int reg_val = 0;
3323d3cb2de2SBard Liao 
3324d3cb2de2SBard Liao 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
3325d3cb2de2SBard Liao 	case SND_SOC_DAIFMT_CBM_CFM:
3326d3cb2de2SBard Liao 		rt5659->master[dai->id] = 1;
3327d3cb2de2SBard Liao 		break;
3328d3cb2de2SBard Liao 	case SND_SOC_DAIFMT_CBS_CFS:
3329d3cb2de2SBard Liao 		reg_val |= RT5659_I2S_MS_S;
3330d3cb2de2SBard Liao 		rt5659->master[dai->id] = 0;
3331d3cb2de2SBard Liao 		break;
3332d3cb2de2SBard Liao 	default:
3333d3cb2de2SBard Liao 		return -EINVAL;
3334d3cb2de2SBard Liao 	}
3335d3cb2de2SBard Liao 
3336d3cb2de2SBard Liao 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
3337d3cb2de2SBard Liao 	case SND_SOC_DAIFMT_NB_NF:
3338d3cb2de2SBard Liao 		break;
3339d3cb2de2SBard Liao 	case SND_SOC_DAIFMT_IB_NF:
3340d3cb2de2SBard Liao 		reg_val |= RT5659_I2S_BP_INV;
3341d3cb2de2SBard Liao 		break;
3342d3cb2de2SBard Liao 	default:
3343d3cb2de2SBard Liao 		return -EINVAL;
3344d3cb2de2SBard Liao 	}
3345d3cb2de2SBard Liao 
3346d3cb2de2SBard Liao 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
3347d3cb2de2SBard Liao 	case SND_SOC_DAIFMT_I2S:
3348d3cb2de2SBard Liao 		break;
3349d3cb2de2SBard Liao 	case SND_SOC_DAIFMT_LEFT_J:
3350d3cb2de2SBard Liao 		reg_val |= RT5659_I2S_DF_LEFT;
3351d3cb2de2SBard Liao 		break;
3352d3cb2de2SBard Liao 	case SND_SOC_DAIFMT_DSP_A:
3353d3cb2de2SBard Liao 		reg_val |= RT5659_I2S_DF_PCM_A;
3354d3cb2de2SBard Liao 		break;
3355d3cb2de2SBard Liao 	case SND_SOC_DAIFMT_DSP_B:
3356d3cb2de2SBard Liao 		reg_val |= RT5659_I2S_DF_PCM_B;
3357d3cb2de2SBard Liao 		break;
3358d3cb2de2SBard Liao 	default:
3359d3cb2de2SBard Liao 		return -EINVAL;
3360d3cb2de2SBard Liao 	}
3361d3cb2de2SBard Liao 
3362d3cb2de2SBard Liao 	switch (dai->id) {
3363d3cb2de2SBard Liao 	case RT5659_AIF1:
3364d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_I2S1_SDP,
3365d3cb2de2SBard Liao 			RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK |
3366d3cb2de2SBard Liao 			RT5659_I2S_DF_MASK, reg_val);
3367d3cb2de2SBard Liao 		break;
3368d3cb2de2SBard Liao 	case RT5659_AIF2:
3369d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_I2S2_SDP,
3370d3cb2de2SBard Liao 			RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK |
3371d3cb2de2SBard Liao 			RT5659_I2S_DF_MASK, reg_val);
3372d3cb2de2SBard Liao 		break;
3373d3cb2de2SBard Liao 	case RT5659_AIF3:
3374d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_I2S3_SDP,
3375d3cb2de2SBard Liao 			RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK |
3376d3cb2de2SBard Liao 			RT5659_I2S_DF_MASK, reg_val);
3377d3cb2de2SBard Liao 		break;
3378d3cb2de2SBard Liao 	default:
3379d3cb2de2SBard Liao 		dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id);
3380d3cb2de2SBard Liao 		return -EINVAL;
3381d3cb2de2SBard Liao 	}
3382d3cb2de2SBard Liao 	return 0;
3383d3cb2de2SBard Liao }
3384d3cb2de2SBard Liao 
3385d3cb2de2SBard Liao static int rt5659_set_dai_sysclk(struct snd_soc_dai *dai,
3386d3cb2de2SBard Liao 		int clk_id, unsigned int freq, int dir)
3387d3cb2de2SBard Liao {
3388d3cb2de2SBard Liao 	struct snd_soc_codec *codec = dai->codec;
3389d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3390d3cb2de2SBard Liao 	unsigned int reg_val = 0;
3391d3cb2de2SBard Liao 
3392d3cb2de2SBard Liao 	if (freq == rt5659->sysclk && clk_id == rt5659->sysclk_src)
3393d3cb2de2SBard Liao 		return 0;
3394d3cb2de2SBard Liao 
3395d3cb2de2SBard Liao 	switch (clk_id) {
3396d3cb2de2SBard Liao 	case RT5659_SCLK_S_MCLK:
3397d3cb2de2SBard Liao 		reg_val |= RT5659_SCLK_SRC_MCLK;
3398d3cb2de2SBard Liao 		break;
3399d3cb2de2SBard Liao 	case RT5659_SCLK_S_PLL1:
3400d3cb2de2SBard Liao 		reg_val |= RT5659_SCLK_SRC_PLL1;
3401d3cb2de2SBard Liao 		break;
3402d3cb2de2SBard Liao 	case RT5659_SCLK_S_RCCLK:
3403d3cb2de2SBard Liao 		reg_val |= RT5659_SCLK_SRC_RCCLK;
3404d3cb2de2SBard Liao 		break;
3405d3cb2de2SBard Liao 	default:
3406d3cb2de2SBard Liao 		dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
3407d3cb2de2SBard Liao 		return -EINVAL;
3408d3cb2de2SBard Liao 	}
3409d3cb2de2SBard Liao 	snd_soc_update_bits(codec, RT5659_GLB_CLK,
3410d3cb2de2SBard Liao 		RT5659_SCLK_SRC_MASK, reg_val);
3411d3cb2de2SBard Liao 	rt5659->sysclk = freq;
3412d3cb2de2SBard Liao 	rt5659->sysclk_src = clk_id;
3413d3cb2de2SBard Liao 
3414d3cb2de2SBard Liao 	dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id);
3415d3cb2de2SBard Liao 
3416d3cb2de2SBard Liao 	return 0;
3417d3cb2de2SBard Liao }
3418d3cb2de2SBard Liao 
3419d3cb2de2SBard Liao static int rt5659_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int Source,
3420d3cb2de2SBard Liao 			unsigned int freq_in, unsigned int freq_out)
3421d3cb2de2SBard Liao {
3422d3cb2de2SBard Liao 	struct snd_soc_codec *codec = dai->codec;
3423d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3424d3cb2de2SBard Liao 	struct rl6231_pll_code pll_code;
3425d3cb2de2SBard Liao 	int ret;
3426d3cb2de2SBard Liao 
3427d3cb2de2SBard Liao 	if (Source == rt5659->pll_src && freq_in == rt5659->pll_in &&
3428d3cb2de2SBard Liao 	    freq_out == rt5659->pll_out)
3429d3cb2de2SBard Liao 		return 0;
3430d3cb2de2SBard Liao 
3431d3cb2de2SBard Liao 	if (!freq_in || !freq_out) {
3432d3cb2de2SBard Liao 		dev_dbg(codec->dev, "PLL disabled\n");
3433d3cb2de2SBard Liao 
3434d3cb2de2SBard Liao 		rt5659->pll_in = 0;
3435d3cb2de2SBard Liao 		rt5659->pll_out = 0;
3436d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_GLB_CLK,
3437d3cb2de2SBard Liao 			RT5659_SCLK_SRC_MASK, RT5659_SCLK_SRC_MCLK);
3438d3cb2de2SBard Liao 		return 0;
3439d3cb2de2SBard Liao 	}
3440d3cb2de2SBard Liao 
3441d3cb2de2SBard Liao 	switch (Source) {
3442d3cb2de2SBard Liao 	case RT5659_PLL1_S_MCLK:
3443d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_GLB_CLK,
3444d3cb2de2SBard Liao 			RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_MCLK);
3445d3cb2de2SBard Liao 		break;
3446d3cb2de2SBard Liao 	case RT5659_PLL1_S_BCLK1:
3447d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_GLB_CLK,
3448d3cb2de2SBard Liao 				RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK1);
3449d3cb2de2SBard Liao 		break;
3450d3cb2de2SBard Liao 	case RT5659_PLL1_S_BCLK2:
3451d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_GLB_CLK,
3452d3cb2de2SBard Liao 				RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK2);
3453d3cb2de2SBard Liao 		break;
3454d3cb2de2SBard Liao 	case RT5659_PLL1_S_BCLK3:
3455d3cb2de2SBard Liao 		snd_soc_update_bits(codec, RT5659_GLB_CLK,
3456d3cb2de2SBard Liao 				RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK3);
3457d3cb2de2SBard Liao 		break;
3458d3cb2de2SBard Liao 	default:
3459d3cb2de2SBard Liao 		dev_err(codec->dev, "Unknown PLL Source %d\n", Source);
3460d3cb2de2SBard Liao 		return -EINVAL;
3461d3cb2de2SBard Liao 	}
3462d3cb2de2SBard Liao 
3463d3cb2de2SBard Liao 	ret = rl6231_pll_calc(freq_in, freq_out, &pll_code);
3464d3cb2de2SBard Liao 	if (ret < 0) {
3465d3cb2de2SBard Liao 		dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
3466d3cb2de2SBard Liao 		return ret;
3467d3cb2de2SBard Liao 	}
3468d3cb2de2SBard Liao 
3469d3cb2de2SBard Liao 	dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n",
3470d3cb2de2SBard Liao 		pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
3471d3cb2de2SBard Liao 		pll_code.n_code, pll_code.k_code);
3472d3cb2de2SBard Liao 
3473d3cb2de2SBard Liao 	snd_soc_write(codec, RT5659_PLL_CTRL_1,
3474d3cb2de2SBard Liao 		pll_code.n_code << RT5659_PLL_N_SFT | pll_code.k_code);
3475d3cb2de2SBard Liao 	snd_soc_write(codec, RT5659_PLL_CTRL_2,
3476d3cb2de2SBard Liao 		(pll_code.m_bp ? 0 : pll_code.m_code) << RT5659_PLL_M_SFT |
3477d3cb2de2SBard Liao 		pll_code.m_bp << RT5659_PLL_M_BP_SFT);
3478d3cb2de2SBard Liao 
3479d3cb2de2SBard Liao 	rt5659->pll_in = freq_in;
3480d3cb2de2SBard Liao 	rt5659->pll_out = freq_out;
3481d3cb2de2SBard Liao 	rt5659->pll_src = Source;
3482d3cb2de2SBard Liao 
3483d3cb2de2SBard Liao 	return 0;
3484d3cb2de2SBard Liao }
3485d3cb2de2SBard Liao 
3486d3cb2de2SBard Liao static int rt5659_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3487d3cb2de2SBard Liao 			unsigned int rx_mask, int slots, int slot_width)
3488d3cb2de2SBard Liao {
3489d3cb2de2SBard Liao 	struct snd_soc_codec *codec = dai->codec;
3490d3cb2de2SBard Liao 	unsigned int val = 0;
3491d3cb2de2SBard Liao 
3492d3cb2de2SBard Liao 	if (rx_mask || tx_mask)
3493d3cb2de2SBard Liao 		val |= (1 << 15);
3494d3cb2de2SBard Liao 
3495d3cb2de2SBard Liao 	switch (slots) {
3496d3cb2de2SBard Liao 	case 4:
3497d3cb2de2SBard Liao 		val |= (1 << 10);
3498d3cb2de2SBard Liao 		val |= (1 << 8);
3499d3cb2de2SBard Liao 		break;
3500d3cb2de2SBard Liao 	case 6:
3501d3cb2de2SBard Liao 		val |= (2 << 10);
3502d3cb2de2SBard Liao 		val |= (2 << 8);
3503d3cb2de2SBard Liao 		break;
3504d3cb2de2SBard Liao 	case 8:
3505d3cb2de2SBard Liao 		val |= (3 << 10);
3506d3cb2de2SBard Liao 		val |= (3 << 8);
3507d3cb2de2SBard Liao 		break;
3508d3cb2de2SBard Liao 	case 2:
3509d3cb2de2SBard Liao 		break;
3510d3cb2de2SBard Liao 	default:
3511d3cb2de2SBard Liao 		return -EINVAL;
3512d3cb2de2SBard Liao 	}
3513d3cb2de2SBard Liao 
3514d3cb2de2SBard Liao 	switch (slot_width) {
3515d3cb2de2SBard Liao 	case 20:
3516d3cb2de2SBard Liao 		val |= (1 << 6);
3517d3cb2de2SBard Liao 		val |= (1 << 4);
3518d3cb2de2SBard Liao 		break;
3519d3cb2de2SBard Liao 	case 24:
3520d3cb2de2SBard Liao 		val |= (2 << 6);
3521d3cb2de2SBard Liao 		val |= (2 << 4);
3522d3cb2de2SBard Liao 		break;
3523d3cb2de2SBard Liao 	case 32:
3524d3cb2de2SBard Liao 		val |= (3 << 6);
3525d3cb2de2SBard Liao 		val |= (3 << 4);
3526d3cb2de2SBard Liao 		break;
3527d3cb2de2SBard Liao 	case 16:
3528d3cb2de2SBard Liao 		break;
3529d3cb2de2SBard Liao 	default:
3530d3cb2de2SBard Liao 		return -EINVAL;
3531d3cb2de2SBard Liao 	}
3532d3cb2de2SBard Liao 
3533d3cb2de2SBard Liao 	snd_soc_update_bits(codec, RT5659_TDM_CTRL_1, 0x8ff0, val);
3534d3cb2de2SBard Liao 
3535d3cb2de2SBard Liao 	return 0;
3536d3cb2de2SBard Liao }
3537d3cb2de2SBard Liao 
3538d3cb2de2SBard Liao static int rt5659_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
3539d3cb2de2SBard Liao {
3540d3cb2de2SBard Liao 	struct snd_soc_codec *codec = dai->codec;
3541d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3542d3cb2de2SBard Liao 
3543d3cb2de2SBard Liao 	dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio);
3544d3cb2de2SBard Liao 
3545d3cb2de2SBard Liao 	rt5659->bclk[dai->id] = ratio;
3546d3cb2de2SBard Liao 
3547d3cb2de2SBard Liao 	if (ratio == 64) {
3548d3cb2de2SBard Liao 		switch (dai->id) {
3549d3cb2de2SBard Liao 		case RT5659_AIF2:
3550d3cb2de2SBard Liao 			snd_soc_update_bits(codec, RT5659_ADDA_CLK_1,
3551d3cb2de2SBard Liao 				RT5659_I2S_BCLK_MS2_MASK,
3552d3cb2de2SBard Liao 				RT5659_I2S_BCLK_MS2_64);
3553d3cb2de2SBard Liao 			break;
3554d3cb2de2SBard Liao 		case RT5659_AIF3:
3555d3cb2de2SBard Liao 			snd_soc_update_bits(codec, RT5659_ADDA_CLK_1,
3556d3cb2de2SBard Liao 				RT5659_I2S_BCLK_MS3_MASK,
3557d3cb2de2SBard Liao 				RT5659_I2S_BCLK_MS3_64);
3558d3cb2de2SBard Liao 			break;
3559d3cb2de2SBard Liao 		}
3560d3cb2de2SBard Liao 	}
3561d3cb2de2SBard Liao 
3562d3cb2de2SBard Liao 	return 0;
3563d3cb2de2SBard Liao }
3564d3cb2de2SBard Liao 
3565d3cb2de2SBard Liao static int rt5659_set_bias_level(struct snd_soc_codec *codec,
3566d3cb2de2SBard Liao 			enum snd_soc_bias_level level)
3567d3cb2de2SBard Liao {
3568d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3569d3cb2de2SBard Liao 
3570d3cb2de2SBard Liao 	switch (level) {
3571d3cb2de2SBard Liao 	case SND_SOC_BIAS_PREPARE:
3572d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_DIG_MISC,
3573d3cb2de2SBard Liao 			RT5659_DIG_GATE_CTRL, RT5659_DIG_GATE_CTRL);
3574d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_PWR_DIG_1,
3575d3cb2de2SBard Liao 			RT5659_PWR_LDO,	RT5659_PWR_LDO);
3576d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
3577d3cb2de2SBard Liao 			RT5659_PWR_MB | RT5659_PWR_VREF1 | RT5659_PWR_VREF2,
3578d3cb2de2SBard Liao 			RT5659_PWR_MB | RT5659_PWR_VREF1 | RT5659_PWR_VREF2);
3579d3cb2de2SBard Liao 		msleep(20);
3580d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
3581d3cb2de2SBard Liao 			RT5659_PWR_FV1 | RT5659_PWR_FV2,
3582d3cb2de2SBard Liao 			RT5659_PWR_FV1 | RT5659_PWR_FV2);
3583d3cb2de2SBard Liao 		break;
3584d3cb2de2SBard Liao 
3585d3cb2de2SBard Liao 	case SND_SOC_BIAS_OFF:
3586d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_PWR_DIG_1,
3587d3cb2de2SBard Liao 			RT5659_PWR_LDO, 0);
3588d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
3589d3cb2de2SBard Liao 			RT5659_PWR_MB | RT5659_PWR_VREF1 | RT5659_PWR_VREF2
3590d3cb2de2SBard Liao 			| RT5659_PWR_FV1 | RT5659_PWR_FV2,
3591d3cb2de2SBard Liao 			RT5659_PWR_MB | RT5659_PWR_VREF2);
3592d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_DIG_MISC,
3593d3cb2de2SBard Liao 			RT5659_DIG_GATE_CTRL, 0);
3594d3cb2de2SBard Liao 		break;
3595d3cb2de2SBard Liao 
3596d3cb2de2SBard Liao 	default:
3597d3cb2de2SBard Liao 		break;
3598d3cb2de2SBard Liao 	}
3599d3cb2de2SBard Liao 
3600d3cb2de2SBard Liao 	return 0;
3601d3cb2de2SBard Liao }
3602d3cb2de2SBard Liao 
3603d3cb2de2SBard Liao static int rt5659_probe(struct snd_soc_codec *codec)
3604d3cb2de2SBard Liao {
3605d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3606d3cb2de2SBard Liao 
3607d3cb2de2SBard Liao 	rt5659->codec = codec;
3608d3cb2de2SBard Liao 
3609d3cb2de2SBard Liao 	return 0;
3610d3cb2de2SBard Liao }
3611d3cb2de2SBard Liao 
3612d3cb2de2SBard Liao static int rt5659_remove(struct snd_soc_codec *codec)
3613d3cb2de2SBard Liao {
3614d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3615d3cb2de2SBard Liao 
3616d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_RESET, 0);
3617d3cb2de2SBard Liao 
3618d3cb2de2SBard Liao 	return 0;
3619d3cb2de2SBard Liao }
3620d3cb2de2SBard Liao 
3621d3cb2de2SBard Liao #ifdef CONFIG_PM
3622d3cb2de2SBard Liao static int rt5659_suspend(struct snd_soc_codec *codec)
3623d3cb2de2SBard Liao {
3624d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3625d3cb2de2SBard Liao 
3626d3cb2de2SBard Liao 	regcache_cache_only(rt5659->regmap, true);
3627d3cb2de2SBard Liao 	regcache_mark_dirty(rt5659->regmap);
3628d3cb2de2SBard Liao 	return 0;
3629d3cb2de2SBard Liao }
3630d3cb2de2SBard Liao 
3631d3cb2de2SBard Liao static int rt5659_resume(struct snd_soc_codec *codec)
3632d3cb2de2SBard Liao {
3633d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
3634d3cb2de2SBard Liao 
3635d3cb2de2SBard Liao 	regcache_cache_only(rt5659->regmap, false);
3636d3cb2de2SBard Liao 	regcache_sync(rt5659->regmap);
3637d3cb2de2SBard Liao 
3638d3cb2de2SBard Liao 	return 0;
3639d3cb2de2SBard Liao }
3640d3cb2de2SBard Liao #else
3641d3cb2de2SBard Liao #define rt5659_suspend NULL
3642d3cb2de2SBard Liao #define rt5659_resume NULL
3643d3cb2de2SBard Liao #endif
3644d3cb2de2SBard Liao 
3645d3cb2de2SBard Liao #define RT5659_STEREO_RATES SNDRV_PCM_RATE_8000_192000
3646d3cb2de2SBard Liao #define RT5659_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
3647d3cb2de2SBard Liao 		SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
3648d3cb2de2SBard Liao 
3649d3cb2de2SBard Liao static const struct snd_soc_dai_ops rt5659_aif_dai_ops = {
3650d3cb2de2SBard Liao 	.hw_params = rt5659_hw_params,
3651d3cb2de2SBard Liao 	.set_fmt = rt5659_set_dai_fmt,
3652d3cb2de2SBard Liao 	.set_sysclk = rt5659_set_dai_sysclk,
3653d3cb2de2SBard Liao 	.set_tdm_slot = rt5659_set_tdm_slot,
3654d3cb2de2SBard Liao 	.set_pll = rt5659_set_dai_pll,
3655d3cb2de2SBard Liao 	.set_bclk_ratio = rt5659_set_bclk_ratio,
3656d3cb2de2SBard Liao };
3657d3cb2de2SBard Liao 
3658d3cb2de2SBard Liao static struct snd_soc_dai_driver rt5659_dai[] = {
3659d3cb2de2SBard Liao 	{
3660d3cb2de2SBard Liao 		.name = "rt5659-aif1",
3661d3cb2de2SBard Liao 		.id = RT5659_AIF1,
3662d3cb2de2SBard Liao 		.playback = {
3663d3cb2de2SBard Liao 			.stream_name = "AIF1 Playback",
3664d3cb2de2SBard Liao 			.channels_min = 1,
3665d3cb2de2SBard Liao 			.channels_max = 2,
3666d3cb2de2SBard Liao 			.rates = RT5659_STEREO_RATES,
3667d3cb2de2SBard Liao 			.formats = RT5659_FORMATS,
3668d3cb2de2SBard Liao 		},
3669d3cb2de2SBard Liao 		.capture = {
3670d3cb2de2SBard Liao 			.stream_name = "AIF1 Capture",
3671d3cb2de2SBard Liao 			.channels_min = 1,
3672d3cb2de2SBard Liao 			.channels_max = 2,
3673d3cb2de2SBard Liao 			.rates = RT5659_STEREO_RATES,
3674d3cb2de2SBard Liao 			.formats = RT5659_FORMATS,
3675d3cb2de2SBard Liao 		},
3676d3cb2de2SBard Liao 		.ops = &rt5659_aif_dai_ops,
3677d3cb2de2SBard Liao 	},
3678d3cb2de2SBard Liao 	{
3679d3cb2de2SBard Liao 		.name = "rt5659-aif2",
3680d3cb2de2SBard Liao 		.id = RT5659_AIF2,
3681d3cb2de2SBard Liao 		.playback = {
3682d3cb2de2SBard Liao 			.stream_name = "AIF2 Playback",
3683d3cb2de2SBard Liao 			.channels_min = 1,
3684d3cb2de2SBard Liao 			.channels_max = 2,
3685d3cb2de2SBard Liao 			.rates = RT5659_STEREO_RATES,
3686d3cb2de2SBard Liao 			.formats = RT5659_FORMATS,
3687d3cb2de2SBard Liao 		},
3688d3cb2de2SBard Liao 		.capture = {
3689d3cb2de2SBard Liao 			.stream_name = "AIF2 Capture",
3690d3cb2de2SBard Liao 			.channels_min = 1,
3691d3cb2de2SBard Liao 			.channels_max = 2,
3692d3cb2de2SBard Liao 			.rates = RT5659_STEREO_RATES,
3693d3cb2de2SBard Liao 			.formats = RT5659_FORMATS,
3694d3cb2de2SBard Liao 		},
3695d3cb2de2SBard Liao 		.ops = &rt5659_aif_dai_ops,
3696d3cb2de2SBard Liao 	},
3697d3cb2de2SBard Liao 	{
3698d3cb2de2SBard Liao 		.name = "rt5659-aif3",
3699d3cb2de2SBard Liao 		.id = RT5659_AIF3,
3700d3cb2de2SBard Liao 		.playback = {
3701d3cb2de2SBard Liao 			.stream_name = "AIF3 Playback",
3702d3cb2de2SBard Liao 			.channels_min = 1,
3703d3cb2de2SBard Liao 			.channels_max = 2,
3704d3cb2de2SBard Liao 			.rates = RT5659_STEREO_RATES,
3705d3cb2de2SBard Liao 			.formats = RT5659_FORMATS,
3706d3cb2de2SBard Liao 		},
3707d3cb2de2SBard Liao 		.capture = {
3708d3cb2de2SBard Liao 			.stream_name = "AIF3 Capture",
3709d3cb2de2SBard Liao 			.channels_min = 1,
3710d3cb2de2SBard Liao 			.channels_max = 2,
3711d3cb2de2SBard Liao 			.rates = RT5659_STEREO_RATES,
3712d3cb2de2SBard Liao 			.formats = RT5659_FORMATS,
3713d3cb2de2SBard Liao 		},
3714d3cb2de2SBard Liao 		.ops = &rt5659_aif_dai_ops,
3715d3cb2de2SBard Liao 	},
3716d3cb2de2SBard Liao };
3717d3cb2de2SBard Liao 
3718d3cb2de2SBard Liao static struct snd_soc_codec_driver soc_codec_dev_rt5659 = {
3719d3cb2de2SBard Liao 	.probe = rt5659_probe,
3720d3cb2de2SBard Liao 	.remove = rt5659_remove,
3721d3cb2de2SBard Liao 	.suspend = rt5659_suspend,
3722d3cb2de2SBard Liao 	.resume = rt5659_resume,
3723d3cb2de2SBard Liao 	.set_bias_level = rt5659_set_bias_level,
3724d3cb2de2SBard Liao 	.idle_bias_off = true,
3725d3cb2de2SBard Liao 	.controls = rt5659_snd_controls,
3726d3cb2de2SBard Liao 	.num_controls = ARRAY_SIZE(rt5659_snd_controls),
3727d3cb2de2SBard Liao 	.dapm_widgets = rt5659_dapm_widgets,
3728d3cb2de2SBard Liao 	.num_dapm_widgets = ARRAY_SIZE(rt5659_dapm_widgets),
3729d3cb2de2SBard Liao 	.dapm_routes = rt5659_dapm_routes,
3730d3cb2de2SBard Liao 	.num_dapm_routes = ARRAY_SIZE(rt5659_dapm_routes),
3731d3cb2de2SBard Liao };
3732d3cb2de2SBard Liao 
3733d3cb2de2SBard Liao 
3734d3cb2de2SBard Liao static const struct regmap_config rt5659_regmap = {
3735d3cb2de2SBard Liao 	.reg_bits = 16,
3736d3cb2de2SBard Liao 	.val_bits = 16,
3737d3cb2de2SBard Liao 	.max_register = 0x0400,
3738d3cb2de2SBard Liao 	.volatile_reg = rt5659_volatile_register,
3739d3cb2de2SBard Liao 	.readable_reg = rt5659_readable_register,
3740d3cb2de2SBard Liao 	.cache_type = REGCACHE_RBTREE,
3741d3cb2de2SBard Liao 	.reg_defaults = rt5659_reg,
3742d3cb2de2SBard Liao 	.num_reg_defaults = ARRAY_SIZE(rt5659_reg),
3743d3cb2de2SBard Liao };
3744d3cb2de2SBard Liao 
3745d3cb2de2SBard Liao static const struct i2c_device_id rt5659_i2c_id[] = {
3746d3cb2de2SBard Liao 	{ "rt5658", 0 },
3747d3cb2de2SBard Liao 	{ "rt5659", 0 },
3748d3cb2de2SBard Liao 	{ }
3749d3cb2de2SBard Liao };
3750d3cb2de2SBard Liao MODULE_DEVICE_TABLE(i2c, rt5659_i2c_id);
3751d3cb2de2SBard Liao 
3752d3cb2de2SBard Liao static int rt5659_parse_dt(struct rt5659_priv *rt5659, struct device *dev)
3753d3cb2de2SBard Liao {
3754d3cb2de2SBard Liao 	rt5659->pdata.in1_diff = device_property_read_bool(dev,
3755d3cb2de2SBard Liao 					"realtek,in1-differential");
3756d3cb2de2SBard Liao 	rt5659->pdata.in3_diff = device_property_read_bool(dev,
3757d3cb2de2SBard Liao 					"realtek,in3-differential");
3758d3cb2de2SBard Liao 	rt5659->pdata.in4_diff = device_property_read_bool(dev,
3759d3cb2de2SBard Liao 					"realtek,in4-differential");
3760d3cb2de2SBard Liao 
3761d3cb2de2SBard Liao 
3762d3cb2de2SBard Liao 	device_property_read_u32(dev, "realtek,dmic1-data-pin",
3763d3cb2de2SBard Liao 		&rt5659->pdata.dmic1_data_pin);
3764d3cb2de2SBard Liao 	device_property_read_u32(dev, "realtek,dmic2-data-pin",
3765d3cb2de2SBard Liao 		&rt5659->pdata.dmic2_data_pin);
3766d3cb2de2SBard Liao 	device_property_read_u32(dev, "realtek,jd-src",
3767d3cb2de2SBard Liao 		&rt5659->pdata.jd_src);
3768d3cb2de2SBard Liao 
3769d3cb2de2SBard Liao 	return 0;
3770d3cb2de2SBard Liao }
3771d3cb2de2SBard Liao 
3772d3cb2de2SBard Liao static void rt5659_calibrate(struct rt5659_priv *rt5659)
3773d3cb2de2SBard Liao {
3774d3cb2de2SBard Liao 	int value, count;
3775d3cb2de2SBard Liao 
3776d3cb2de2SBard Liao 	/* Calibrate HPO Start */
3777d3cb2de2SBard Liao 	/* Fine tune HP Performance */
3778d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_BIAS_CUR_CTRL_8, 0xa502);
3779d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CHOP_DAC, 0x3030);
3780d3cb2de2SBard Liao 
3781d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PRE_DIV_1, 0xef00);
3782d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PRE_DIV_2, 0xeffc);
3783d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MICBIAS_2, 0x0280);
3784d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_DIG_MISC, 0x0001);
3785d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_GLB_CLK, 0x8000);
3786d3cb2de2SBard Liao 
3787d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_1, 0xaa7e);
3788d3cb2de2SBard Liao 	msleep(60);
3789d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_1, 0xfe7e);
3790d3cb2de2SBard Liao 	msleep(50);
3791d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_3, 0x0004);
3792d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_DIG_2, 0x0400);
3793d3cb2de2SBard Liao 	msleep(50);
3794d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_DIG_1, 0x0080);
3795d3cb2de2SBard Liao 	usleep_range(10000, 10005);
3796d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_DEPOP_1, 0x0009);
3797d3cb2de2SBard Liao 	msleep(50);
3798d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_DIG_1, 0x0f80);
3799d3cb2de2SBard Liao 	msleep(50);
3800d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CHARGE_PUMP_1, 0x0e16);
3801d3cb2de2SBard Liao 	msleep(50);
3802d3cb2de2SBard Liao 
3803d3cb2de2SBard Liao 	/* Enalbe K ADC Power And Clock */
3804d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CAL_REC, 0x0505);
3805d3cb2de2SBard Liao 	msleep(50);
3806d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_3, 0x0184);
3807d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CALIB_ADC_CTRL, 0x3c05);
3808d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x20c1);
3809d3cb2de2SBard Liao 
3810d3cb2de2SBard Liao 	/* K Headphone */
3811d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x2cc1);
3812d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, 0x5100);
3813d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_7, 0x0014);
3814d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, 0xd100);
3815d3cb2de2SBard Liao 	msleep(60);
3816d3cb2de2SBard Liao 
3817d3cb2de2SBard Liao 	/* Manual K ADC Offset */
3818d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x2cc1);
3819d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, 0x4900);
3820d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_7, 0x0016);
3821d3cb2de2SBard Liao 	regmap_update_bits(rt5659->regmap, RT5659_HP_CALIB_CTRL_1,
3822d3cb2de2SBard Liao 		0x8000, 0x8000);
3823d3cb2de2SBard Liao 
3824d3cb2de2SBard Liao 	count = 0;
3825d3cb2de2SBard Liao 	while (true) {
3826d3cb2de2SBard Liao 		regmap_read(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, &value);
3827d3cb2de2SBard Liao 		if (value & 0x8000)
3828d3cb2de2SBard Liao 			usleep_range(10000, 10005);
3829d3cb2de2SBard Liao 		else
3830d3cb2de2SBard Liao 			break;
3831d3cb2de2SBard Liao 
3832d3cb2de2SBard Liao 		if (count > 30) {
3833d3cb2de2SBard Liao 			dev_err(rt5659->codec->dev,
3834d3cb2de2SBard Liao 				"HP Calibration 1 Failure\n");
3835d3cb2de2SBard Liao 			return;
3836d3cb2de2SBard Liao 		}
3837d3cb2de2SBard Liao 
3838d3cb2de2SBard Liao 		count++;
3839d3cb2de2SBard Liao 	}
3840d3cb2de2SBard Liao 
3841d3cb2de2SBard Liao 	/* Manual K Internal Path Offset */
3842d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x2cc1);
3843d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_VOL, 0x0000);
3844d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, 0x4500);
3845d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_7, 0x001f);
3846d3cb2de2SBard Liao 	regmap_update_bits(rt5659->regmap, RT5659_HP_CALIB_CTRL_1,
3847d3cb2de2SBard Liao 		0x8000, 0x8000);
3848d3cb2de2SBard Liao 
3849d3cb2de2SBard Liao 	count = 0;
3850d3cb2de2SBard Liao 	while (true) {
3851d3cb2de2SBard Liao 		regmap_read(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, &value);
3852d3cb2de2SBard Liao 		if (value & 0x8000)
3853d3cb2de2SBard Liao 			usleep_range(10000, 10005);
3854d3cb2de2SBard Liao 		else
3855d3cb2de2SBard Liao 			break;
3856d3cb2de2SBard Liao 
3857d3cb2de2SBard Liao 		if (count > 85) {
3858d3cb2de2SBard Liao 			dev_err(rt5659->codec->dev,
3859d3cb2de2SBard Liao 				"HP Calibration 2 Failure\n");
3860d3cb2de2SBard Liao 			return;
3861d3cb2de2SBard Liao 		}
3862d3cb2de2SBard Liao 
3863d3cb2de2SBard Liao 		count++;
3864d3cb2de2SBard Liao 	}
3865d3cb2de2SBard Liao 
3866d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_7, 0x0000);
3867d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x20c0);
3868d3cb2de2SBard Liao 	/* Calibrate HPO End */
3869d3cb2de2SBard Liao 
3870d3cb2de2SBard Liao 	/* Calibrate SPO Start */
3871d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_0, 0x2021);
3872d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_CTRL_1, 0x0260);
3873d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_MIXER, 0x3000);
3874d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_VOL, 0xc000);
3875d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_A_DAC_MUX, 0x000c);
3876d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_DIG_MISC, 0x8000);
3877d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_SPO_VOL, 0x0808);
3878d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_SPK_L_MIXER, 0x001e);
3879d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_SPK_R_MIXER, 0x001e);
3880d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_1, 0x0803);
3881d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_2, 0x0554);
3882d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_SPO_AMP_GAIN, 0x1103);
3883d3cb2de2SBard Liao 
3884d3cb2de2SBard Liao 	/* Enalbe K ADC Power And Clock */
3885d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CAL_REC, 0x0909);
3886d3cb2de2SBard Liao 	regmap_update_bits(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x0001,
3887d3cb2de2SBard Liao 		0x0001);
3888d3cb2de2SBard Liao 
3889d3cb2de2SBard Liao 	/* Start Calibration */
3890d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_3, 0x0000);
3891d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_0, 0x0021);
3892d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_1, 0x3e80);
3893d3cb2de2SBard Liao 	regmap_update_bits(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_1,
3894d3cb2de2SBard Liao 		0x8000, 0x8000);
3895d3cb2de2SBard Liao 
3896d3cb2de2SBard Liao 	count = 0;
3897d3cb2de2SBard Liao 	while (true) {
3898d3cb2de2SBard Liao 		regmap_read(rt5659->regmap,
3899d3cb2de2SBard Liao 				RT5659_SPK_DC_CAILB_CTRL_1, &value);
3900d3cb2de2SBard Liao 		if (value & 0x8000)
3901d3cb2de2SBard Liao 			usleep_range(10000, 10005);
3902d3cb2de2SBard Liao 		else
3903d3cb2de2SBard Liao 			break;
3904d3cb2de2SBard Liao 
3905d3cb2de2SBard Liao 		if (count > 10) {
3906d3cb2de2SBard Liao 			dev_err(rt5659->codec->dev,
3907d3cb2de2SBard Liao 				"SPK Calibration Failure\n");
3908d3cb2de2SBard Liao 			return;
3909d3cb2de2SBard Liao 		}
3910d3cb2de2SBard Liao 
3911d3cb2de2SBard Liao 		count++;
3912d3cb2de2SBard Liao 	}
3913d3cb2de2SBard Liao 	/* Calibrate SPO End */
3914d3cb2de2SBard Liao 
3915d3cb2de2SBard Liao 	/* Calibrate MONO Start */
3916d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_DIG_MISC, 0x0000);
3917d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MONOMIX_IN_GAIN, 0x021f);
3918d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MONO_OUT, 0x480a);
3919d3cb2de2SBard Liao 	/* MONO NG2 GAIN 5dB */
3920d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MONO_GAIN, 0x0003);
3921d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MONO_NG2_CTRL_5, 0x0009);
3922d3cb2de2SBard Liao 
3923d3cb2de2SBard Liao 	/* Start Calibration */
3924d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_3, 0x000f);
3925d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e00);
3926d3cb2de2SBard Liao 	regmap_update_bits(rt5659->regmap, RT5659_MONO_AMP_CALIB_CTRL_1,
3927d3cb2de2SBard Liao 		0x8000, 0x8000);
3928d3cb2de2SBard Liao 
3929d3cb2de2SBard Liao 	count = 0;
3930d3cb2de2SBard Liao 	while (true) {
3931d3cb2de2SBard Liao 		regmap_read(rt5659->regmap, RT5659_MONO_AMP_CALIB_CTRL_1,
3932d3cb2de2SBard Liao 			&value);
3933d3cb2de2SBard Liao 		if (value & 0x8000)
3934d3cb2de2SBard Liao 			usleep_range(10000, 10005);
3935d3cb2de2SBard Liao 		else
3936d3cb2de2SBard Liao 			break;
3937d3cb2de2SBard Liao 
3938d3cb2de2SBard Liao 		if (count > 35) {
3939d3cb2de2SBard Liao 			dev_err(rt5659->codec->dev,
3940d3cb2de2SBard Liao 				"Mono Calibration Failure\n");
3941d3cb2de2SBard Liao 			return;
3942d3cb2de2SBard Liao 		}
3943d3cb2de2SBard Liao 
3944d3cb2de2SBard Liao 		count++;
3945d3cb2de2SBard Liao 	}
3946d3cb2de2SBard Liao 
3947d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_3, 0x0003);
3948d3cb2de2SBard Liao 	/* Calibrate MONO End */
3949d3cb2de2SBard Liao 
3950d3cb2de2SBard Liao 	/* Power Off */
3951d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CAL_REC, 0x0808);
3952d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_3, 0x0000);
3953d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CALIB_ADC_CTRL, 0x2005);
3954d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x20c0);
3955d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_DEPOP_1, 0x0000);
3956d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_1, 0x0011);
3957d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_2, 0x0150);
3958d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_1, 0xfe3e);
3959d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MONO_OUT, 0xc80a);
3960d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e04);
3961d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_MIXER, 0x0000);
3962d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_VOL, 0x0000);
3963d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_DIG_1, 0x0000);
3964d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_DIG_2, 0x0000);
3965d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_1, 0x003e);
3966d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_CTRL_1, 0x0060);
3967d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_CLASSD_0, 0x2021);
3968d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_GLB_CLK, 0x0000);
3969d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_MICBIAS_2, 0x0080);
3970d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_VOL, 0x8080);
3971d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_HP_CHARGE_PUMP_1, 0x0c16);
3972d3cb2de2SBard Liao }
3973d3cb2de2SBard Liao 
3974d3cb2de2SBard Liao static int rt5659_i2c_probe(struct i2c_client *i2c,
3975d3cb2de2SBard Liao 		    const struct i2c_device_id *id)
3976d3cb2de2SBard Liao {
3977d3cb2de2SBard Liao 	struct rt5659_platform_data *pdata = dev_get_platdata(&i2c->dev);
3978d3cb2de2SBard Liao 	struct rt5659_priv *rt5659;
3979d3cb2de2SBard Liao 	int ret;
3980d3cb2de2SBard Liao 	unsigned int val;
3981d3cb2de2SBard Liao 
3982d3cb2de2SBard Liao 	rt5659 = devm_kzalloc(&i2c->dev, sizeof(struct rt5659_priv),
3983d3cb2de2SBard Liao 		GFP_KERNEL);
3984d3cb2de2SBard Liao 
3985d3cb2de2SBard Liao 	if (rt5659 == NULL)
3986d3cb2de2SBard Liao 		return -ENOMEM;
3987d3cb2de2SBard Liao 
3988d3cb2de2SBard Liao 	rt5659->i2c = i2c;
3989d3cb2de2SBard Liao 	i2c_set_clientdata(i2c, rt5659);
3990d3cb2de2SBard Liao 
3991d3cb2de2SBard Liao 	if (pdata)
3992d3cb2de2SBard Liao 		rt5659->pdata = *pdata;
3993d3cb2de2SBard Liao 	else
3994d3cb2de2SBard Liao 		rt5659_parse_dt(rt5659, &i2c->dev);
3995d3cb2de2SBard Liao 
3996d3cb2de2SBard Liao 	rt5659->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev, "ldo1-en",
3997d3cb2de2SBard Liao 							GPIOD_OUT_HIGH);
3998d3cb2de2SBard Liao 	if (IS_ERR(rt5659->gpiod_ldo1_en))
3999d3cb2de2SBard Liao 		dev_warn(&i2c->dev, "Request ldo1-en GPIO failed\n");
4000d3cb2de2SBard Liao 
4001d3cb2de2SBard Liao 	rt5659->gpiod_reset = devm_gpiod_get_optional(&i2c->dev, "reset",
4002d3cb2de2SBard Liao 							GPIOD_OUT_HIGH);
4003d3cb2de2SBard Liao 
4004d3cb2de2SBard Liao 	/* Sleep for 300 ms miniumum */
4005d3cb2de2SBard Liao 	usleep_range(300000, 350000);
4006d3cb2de2SBard Liao 
4007d3cb2de2SBard Liao 	rt5659->regmap = devm_regmap_init_i2c(i2c, &rt5659_regmap);
4008d3cb2de2SBard Liao 	if (IS_ERR(rt5659->regmap)) {
4009d3cb2de2SBard Liao 		ret = PTR_ERR(rt5659->regmap);
4010d3cb2de2SBard Liao 		dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
4011d3cb2de2SBard Liao 			ret);
4012d3cb2de2SBard Liao 		return ret;
4013d3cb2de2SBard Liao 	}
4014d3cb2de2SBard Liao 
4015d3cb2de2SBard Liao 	regmap_read(rt5659->regmap, RT5659_DEVICE_ID, &val);
4016d3cb2de2SBard Liao 	if (val != DEVICE_ID) {
4017d3cb2de2SBard Liao 		dev_err(&i2c->dev,
4018d3cb2de2SBard Liao 			"Device with ID register %x is not rt5659\n", val);
4019d3cb2de2SBard Liao 		return -ENODEV;
4020d3cb2de2SBard Liao 	}
4021d3cb2de2SBard Liao 
4022d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_RESET, 0);
4023d3cb2de2SBard Liao 
4024d3cb2de2SBard Liao 	rt5659_calibrate(rt5659);
4025d3cb2de2SBard Liao 
4026d3cb2de2SBard Liao 	/* line in diff mode*/
4027d3cb2de2SBard Liao 	if (rt5659->pdata.in1_diff)
4028d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_IN1_IN2,
4029d3cb2de2SBard Liao 			RT5659_IN1_DF_MASK, RT5659_IN1_DF_MASK);
4030d3cb2de2SBard Liao 	if (rt5659->pdata.in3_diff)
4031d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_IN3_IN4,
4032d3cb2de2SBard Liao 			RT5659_IN3_DF_MASK, RT5659_IN3_DF_MASK);
4033d3cb2de2SBard Liao 	if (rt5659->pdata.in4_diff)
4034d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_IN3_IN4,
4035d3cb2de2SBard Liao 			RT5659_IN4_DF_MASK, RT5659_IN4_DF_MASK);
4036d3cb2de2SBard Liao 
4037d3cb2de2SBard Liao 	/* DMIC pin*/
4038d3cb2de2SBard Liao 	if (rt5659->pdata.dmic1_data_pin != RT5659_DMIC1_NULL ||
4039d3cb2de2SBard Liao 		rt5659->pdata.dmic2_data_pin != RT5659_DMIC2_NULL) {
4040d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
4041d3cb2de2SBard Liao 			RT5659_GP2_PIN_MASK, RT5659_GP2_PIN_DMIC1_SCL);
4042d3cb2de2SBard Liao 
4043d3cb2de2SBard Liao 		switch (rt5659->pdata.dmic1_data_pin) {
4044d3cb2de2SBard Liao 		case RT5659_DMIC1_DATA_IN2N:
4045d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
4046d3cb2de2SBard Liao 				RT5659_DMIC_1_DP_MASK, RT5659_DMIC_1_DP_IN2N);
4047d3cb2de2SBard Liao 			break;
4048d3cb2de2SBard Liao 
4049d3cb2de2SBard Liao 		case RT5659_DMIC1_DATA_GPIO5:
4050d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap,
4051d3cb2de2SBard Liao 				RT5659_GPIO_CTRL_3,
4052d3cb2de2SBard Liao 				RT5659_I2S2_PIN_MASK,
4053d3cb2de2SBard Liao 				RT5659_I2S2_PIN_GPIO);
4054d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
4055d3cb2de2SBard Liao 				RT5659_DMIC_1_DP_MASK, RT5659_DMIC_1_DP_GPIO5);
4056d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
4057d3cb2de2SBard Liao 				RT5659_GP5_PIN_MASK, RT5659_GP5_PIN_DMIC1_SDA);
4058d3cb2de2SBard Liao 			break;
4059d3cb2de2SBard Liao 
4060d3cb2de2SBard Liao 		case RT5659_DMIC1_DATA_GPIO9:
4061d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
4062d3cb2de2SBard Liao 				RT5659_DMIC_1_DP_MASK, RT5659_DMIC_1_DP_GPIO9);
4063d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
4064d3cb2de2SBard Liao 				RT5659_GP9_PIN_MASK, RT5659_GP9_PIN_DMIC1_SDA);
4065d3cb2de2SBard Liao 			break;
4066d3cb2de2SBard Liao 
4067d3cb2de2SBard Liao 		case RT5659_DMIC1_DATA_GPIO11:
4068d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
4069d3cb2de2SBard Liao 				RT5659_DMIC_1_DP_MASK, RT5659_DMIC_1_DP_GPIO11);
4070d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
4071d3cb2de2SBard Liao 				RT5659_GP11_PIN_MASK,
4072d3cb2de2SBard Liao 				RT5659_GP11_PIN_DMIC1_SDA);
4073d3cb2de2SBard Liao 			break;
4074d3cb2de2SBard Liao 
4075d3cb2de2SBard Liao 		default:
4076d3cb2de2SBard Liao 			dev_dbg(&i2c->dev, "no DMIC1\n");
4077d3cb2de2SBard Liao 			break;
4078d3cb2de2SBard Liao 		}
4079d3cb2de2SBard Liao 
4080d3cb2de2SBard Liao 		switch (rt5659->pdata.dmic2_data_pin) {
4081d3cb2de2SBard Liao 		case RT5659_DMIC2_DATA_IN2P:
4082d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap,
4083d3cb2de2SBard Liao 				RT5659_DMIC_CTRL_1,
4084d3cb2de2SBard Liao 				RT5659_DMIC_2_DP_MASK,
4085d3cb2de2SBard Liao 				RT5659_DMIC_2_DP_IN2P);
4086d3cb2de2SBard Liao 			break;
4087d3cb2de2SBard Liao 
4088d3cb2de2SBard Liao 		case RT5659_DMIC2_DATA_GPIO6:
4089d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap,
4090d3cb2de2SBard Liao 				RT5659_DMIC_CTRL_1,
4091d3cb2de2SBard Liao 				RT5659_DMIC_2_DP_MASK,
4092d3cb2de2SBard Liao 				RT5659_DMIC_2_DP_GPIO6);
4093d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap,
4094d3cb2de2SBard Liao 				RT5659_GPIO_CTRL_1,
4095d3cb2de2SBard Liao 				RT5659_GP6_PIN_MASK,
4096d3cb2de2SBard Liao 				RT5659_GP6_PIN_DMIC2_SDA);
4097d3cb2de2SBard Liao 			break;
4098d3cb2de2SBard Liao 
4099d3cb2de2SBard Liao 		case RT5659_DMIC2_DATA_GPIO10:
4100d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap,
4101d3cb2de2SBard Liao 				RT5659_DMIC_CTRL_1,
4102d3cb2de2SBard Liao 				RT5659_DMIC_2_DP_MASK,
4103d3cb2de2SBard Liao 				RT5659_DMIC_2_DP_GPIO10);
4104d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap,
4105d3cb2de2SBard Liao 				RT5659_GPIO_CTRL_1,
4106d3cb2de2SBard Liao 				RT5659_GP10_PIN_MASK,
4107d3cb2de2SBard Liao 				RT5659_GP10_PIN_DMIC2_SDA);
4108d3cb2de2SBard Liao 			break;
4109d3cb2de2SBard Liao 
4110d3cb2de2SBard Liao 		case RT5659_DMIC2_DATA_GPIO12:
4111d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap,
4112d3cb2de2SBard Liao 				RT5659_DMIC_CTRL_1,
4113d3cb2de2SBard Liao 				RT5659_DMIC_2_DP_MASK,
4114d3cb2de2SBard Liao 				RT5659_DMIC_2_DP_GPIO12);
4115d3cb2de2SBard Liao 			regmap_update_bits(rt5659->regmap,
4116d3cb2de2SBard Liao 				RT5659_GPIO_CTRL_1,
4117d3cb2de2SBard Liao 				RT5659_GP12_PIN_MASK,
4118d3cb2de2SBard Liao 				RT5659_GP12_PIN_DMIC2_SDA);
4119d3cb2de2SBard Liao 			break;
4120d3cb2de2SBard Liao 
4121d3cb2de2SBard Liao 		default:
4122d3cb2de2SBard Liao 			dev_dbg(&i2c->dev, "no DMIC2\n");
4123d3cb2de2SBard Liao 			break;
4124d3cb2de2SBard Liao 
4125d3cb2de2SBard Liao 		}
4126d3cb2de2SBard Liao 	} else {
4127d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
4128d3cb2de2SBard Liao 			RT5659_GP2_PIN_MASK | RT5659_GP5_PIN_MASK |
4129d3cb2de2SBard Liao 			RT5659_GP9_PIN_MASK | RT5659_GP11_PIN_MASK |
4130d3cb2de2SBard Liao 			RT5659_GP6_PIN_MASK | RT5659_GP10_PIN_MASK |
4131d3cb2de2SBard Liao 			RT5659_GP12_PIN_MASK,
4132d3cb2de2SBard Liao 			RT5659_GP2_PIN_GPIO2 | RT5659_GP5_PIN_GPIO5 |
4133d3cb2de2SBard Liao 			RT5659_GP9_PIN_GPIO9 | RT5659_GP11_PIN_GPIO11 |
4134d3cb2de2SBard Liao 			RT5659_GP6_PIN_GPIO6 | RT5659_GP10_PIN_GPIO10 |
4135d3cb2de2SBard Liao 			RT5659_GP12_PIN_GPIO12);
4136d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
4137d3cb2de2SBard Liao 			RT5659_DMIC_1_DP_MASK | RT5659_DMIC_2_DP_MASK,
4138d3cb2de2SBard Liao 			RT5659_DMIC_1_DP_IN2N | RT5659_DMIC_2_DP_IN2P);
4139d3cb2de2SBard Liao 	}
4140d3cb2de2SBard Liao 
4141d3cb2de2SBard Liao 	switch (rt5659->pdata.jd_src) {
4142d3cb2de2SBard Liao 	case RT5659_JD3:
4143d3cb2de2SBard Liao 		regmap_write(rt5659->regmap, RT5659_EJD_CTRL_1, 0xa880);
4144d3cb2de2SBard Liao 		regmap_write(rt5659->regmap, RT5659_RC_CLK_CTRL, 0x9000);
4145d3cb2de2SBard Liao 		regmap_write(rt5659->regmap, RT5659_GPIO_CTRL_1, 0xc800);
4146d3cb2de2SBard Liao 		regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
4147d3cb2de2SBard Liao 				RT5659_PWR_MB, RT5659_PWR_MB);
4148d3cb2de2SBard Liao 		regmap_write(rt5659->regmap, RT5659_PWR_ANLG_2, 0x0001);
4149d3cb2de2SBard Liao 		regmap_write(rt5659->regmap, RT5659_IRQ_CTRL_2, 0x0040);
4150d3cb2de2SBard Liao 		break;
4151d3cb2de2SBard Liao 	case RT5659_JD_NULL:
4152d3cb2de2SBard Liao 		break;
4153d3cb2de2SBard Liao 	default:
4154d3cb2de2SBard Liao 		dev_warn(&i2c->dev, "Currently, support JD3 only\n");
4155d3cb2de2SBard Liao 		break;
4156d3cb2de2SBard Liao 	}
4157d3cb2de2SBard Liao 
4158d3cb2de2SBard Liao 	INIT_DELAYED_WORK(&rt5659->jack_detect_work, rt5659_jack_detect_work);
4159d3cb2de2SBard Liao 
4160d3cb2de2SBard Liao 	if (rt5659->i2c->irq) {
4161d3cb2de2SBard Liao 		ret = request_threaded_irq(rt5659->i2c->irq, NULL, rt5659_irq,
4162d3cb2de2SBard Liao 			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
4163d3cb2de2SBard Liao 			| IRQF_ONESHOT, "rt5659", rt5659);
4164d3cb2de2SBard Liao 		if (ret)
4165d3cb2de2SBard Liao 			dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret);
4166d3cb2de2SBard Liao 
4167d3cb2de2SBard Liao 	}
4168d3cb2de2SBard Liao 
4169d3cb2de2SBard Liao 	ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5659,
4170d3cb2de2SBard Liao 			rt5659_dai, ARRAY_SIZE(rt5659_dai));
4171d3cb2de2SBard Liao 
4172d3cb2de2SBard Liao 	if (ret) {
4173d3cb2de2SBard Liao 		if (rt5659->i2c->irq)
4174d3cb2de2SBard Liao 			free_irq(rt5659->i2c->irq, rt5659);
4175d3cb2de2SBard Liao 	}
4176d3cb2de2SBard Liao 
4177d3cb2de2SBard Liao 	return 0;
4178d3cb2de2SBard Liao }
4179d3cb2de2SBard Liao 
4180d3cb2de2SBard Liao static int rt5659_i2c_remove(struct i2c_client *i2c)
4181d3cb2de2SBard Liao {
4182d3cb2de2SBard Liao 	snd_soc_unregister_codec(&i2c->dev);
4183d3cb2de2SBard Liao 
4184d3cb2de2SBard Liao 	return 0;
4185d3cb2de2SBard Liao }
4186d3cb2de2SBard Liao 
4187*c62db3d5SAxel Lin static void rt5659_i2c_shutdown(struct i2c_client *client)
4188d3cb2de2SBard Liao {
4189d3cb2de2SBard Liao 	struct rt5659_priv *rt5659 = i2c_get_clientdata(client);
4190d3cb2de2SBard Liao 
4191d3cb2de2SBard Liao 	regmap_write(rt5659->regmap, RT5659_RESET, 0);
4192d3cb2de2SBard Liao }
4193d3cb2de2SBard Liao 
4194d3cb2de2SBard Liao static const struct of_device_id rt5659_of_match[] = {
4195d3cb2de2SBard Liao 	{ .compatible = "realtek,rt5658", },
4196d3cb2de2SBard Liao 	{ .compatible = "realtek,rt5659", },
4197d3cb2de2SBard Liao 	{},
4198d3cb2de2SBard Liao };
4199d3cb2de2SBard Liao 
4200d3cb2de2SBard Liao static struct acpi_device_id rt5659_acpi_match[] = {
4201d3cb2de2SBard Liao 		{ "10EC5658", 0},
4202d3cb2de2SBard Liao 		{ "10EC5659", 0},
4203d3cb2de2SBard Liao 		{ },
4204d3cb2de2SBard Liao };
4205d3cb2de2SBard Liao MODULE_DEVICE_TABLE(acpi, rt5659_acpi_match);
4206d3cb2de2SBard Liao 
4207d3cb2de2SBard Liao struct i2c_driver rt5659_i2c_driver = {
4208d3cb2de2SBard Liao 	.driver = {
4209d3cb2de2SBard Liao 		.name = "rt5659",
4210d3cb2de2SBard Liao 		.owner = THIS_MODULE,
4211d3cb2de2SBard Liao 		.of_match_table = rt5659_of_match,
4212d3cb2de2SBard Liao 		.acpi_match_table = ACPI_PTR(rt5659_acpi_match),
4213d3cb2de2SBard Liao 	},
4214d3cb2de2SBard Liao 	.probe = rt5659_i2c_probe,
4215d3cb2de2SBard Liao 	.remove = rt5659_i2c_remove,
4216d3cb2de2SBard Liao 	.shutdown = rt5659_i2c_shutdown,
4217d3cb2de2SBard Liao 	.id_table = rt5659_i2c_id,
4218d3cb2de2SBard Liao };
4219d3cb2de2SBard Liao module_i2c_driver(rt5659_i2c_driver);
4220d3cb2de2SBard Liao 
4221d3cb2de2SBard Liao MODULE_DESCRIPTION("ASoC RT5659 driver");
4222d3cb2de2SBard Liao MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>");
4223d3cb2de2SBard Liao MODULE_LICENSE("GPL v2");
4224