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