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