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