18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * rt5659.c  --  RT5659/RT5658 ALSA SoC audio codec driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2015 Realtek Semiconductor Corp.
68c2ecf20Sopenharmony_ci * Author: Bard Liao <bardliao@realtek.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/clk.h>
108c2ecf20Sopenharmony_ci#include <linux/module.h>
118c2ecf20Sopenharmony_ci#include <linux/moduleparam.h>
128c2ecf20Sopenharmony_ci#include <linux/init.h>
138c2ecf20Sopenharmony_ci#include <linux/delay.h>
148c2ecf20Sopenharmony_ci#include <linux/pm.h>
158c2ecf20Sopenharmony_ci#include <linux/i2c.h>
168c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
178c2ecf20Sopenharmony_ci#include <linux/spi/spi.h>
188c2ecf20Sopenharmony_ci#include <linux/acpi.h>
198c2ecf20Sopenharmony_ci#include <linux/gpio.h>
208c2ecf20Sopenharmony_ci#include <linux/gpio/consumer.h>
218c2ecf20Sopenharmony_ci#include <sound/core.h>
228c2ecf20Sopenharmony_ci#include <sound/pcm.h>
238c2ecf20Sopenharmony_ci#include <sound/pcm_params.h>
248c2ecf20Sopenharmony_ci#include <sound/jack.h>
258c2ecf20Sopenharmony_ci#include <sound/soc.h>
268c2ecf20Sopenharmony_ci#include <sound/soc-dapm.h>
278c2ecf20Sopenharmony_ci#include <sound/initval.h>
288c2ecf20Sopenharmony_ci#include <sound/tlv.h>
298c2ecf20Sopenharmony_ci#include <sound/rt5659.h>
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#include "rl6231.h"
328c2ecf20Sopenharmony_ci#include "rt5659.h"
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistatic const struct reg_default rt5659_reg[] = {
358c2ecf20Sopenharmony_ci	{ 0x0000, 0x0000 },
368c2ecf20Sopenharmony_ci	{ 0x0001, 0x4848 },
378c2ecf20Sopenharmony_ci	{ 0x0002, 0x8080 },
388c2ecf20Sopenharmony_ci	{ 0x0003, 0xc8c8 },
398c2ecf20Sopenharmony_ci	{ 0x0004, 0xc80a },
408c2ecf20Sopenharmony_ci	{ 0x0005, 0x0000 },
418c2ecf20Sopenharmony_ci	{ 0x0006, 0x0000 },
428c2ecf20Sopenharmony_ci	{ 0x0007, 0x0103 },
438c2ecf20Sopenharmony_ci	{ 0x0008, 0x0080 },
448c2ecf20Sopenharmony_ci	{ 0x0009, 0x0000 },
458c2ecf20Sopenharmony_ci	{ 0x000a, 0x0000 },
468c2ecf20Sopenharmony_ci	{ 0x000c, 0x0000 },
478c2ecf20Sopenharmony_ci	{ 0x000d, 0x0000 },
488c2ecf20Sopenharmony_ci	{ 0x000f, 0x0808 },
498c2ecf20Sopenharmony_ci	{ 0x0010, 0x3080 },
508c2ecf20Sopenharmony_ci	{ 0x0011, 0x4a00 },
518c2ecf20Sopenharmony_ci	{ 0x0012, 0x4e00 },
528c2ecf20Sopenharmony_ci	{ 0x0015, 0x42c1 },
538c2ecf20Sopenharmony_ci	{ 0x0016, 0x0000 },
548c2ecf20Sopenharmony_ci	{ 0x0018, 0x000b },
558c2ecf20Sopenharmony_ci	{ 0x0019, 0xafaf },
568c2ecf20Sopenharmony_ci	{ 0x001a, 0xafaf },
578c2ecf20Sopenharmony_ci	{ 0x001b, 0x0011 },
588c2ecf20Sopenharmony_ci	{ 0x001c, 0x2f2f },
598c2ecf20Sopenharmony_ci	{ 0x001d, 0x2f2f },
608c2ecf20Sopenharmony_ci	{ 0x001e, 0x2f2f },
618c2ecf20Sopenharmony_ci	{ 0x001f, 0x0000 },
628c2ecf20Sopenharmony_ci	{ 0x0020, 0x0000 },
638c2ecf20Sopenharmony_ci	{ 0x0021, 0x0000 },
648c2ecf20Sopenharmony_ci	{ 0x0022, 0x5757 },
658c2ecf20Sopenharmony_ci	{ 0x0023, 0x0039 },
668c2ecf20Sopenharmony_ci	{ 0x0026, 0xc060 },
678c2ecf20Sopenharmony_ci	{ 0x0027, 0xd8d8 },
688c2ecf20Sopenharmony_ci	{ 0x0029, 0x8080 },
698c2ecf20Sopenharmony_ci	{ 0x002a, 0xaaaa },
708c2ecf20Sopenharmony_ci	{ 0x002b, 0xaaaa },
718c2ecf20Sopenharmony_ci	{ 0x002c, 0x00af },
728c2ecf20Sopenharmony_ci	{ 0x002d, 0x0000 },
738c2ecf20Sopenharmony_ci	{ 0x002f, 0x1002 },
748c2ecf20Sopenharmony_ci	{ 0x0031, 0x5000 },
758c2ecf20Sopenharmony_ci	{ 0x0032, 0x0000 },
768c2ecf20Sopenharmony_ci	{ 0x0033, 0x0000 },
778c2ecf20Sopenharmony_ci	{ 0x0034, 0x0000 },
788c2ecf20Sopenharmony_ci	{ 0x0035, 0x0000 },
798c2ecf20Sopenharmony_ci	{ 0x0036, 0x0000 },
808c2ecf20Sopenharmony_ci	{ 0x003a, 0x0000 },
818c2ecf20Sopenharmony_ci	{ 0x003b, 0x0000 },
828c2ecf20Sopenharmony_ci	{ 0x003c, 0x007f },
838c2ecf20Sopenharmony_ci	{ 0x003d, 0x0000 },
848c2ecf20Sopenharmony_ci	{ 0x003e, 0x007f },
858c2ecf20Sopenharmony_ci	{ 0x0040, 0x0808 },
868c2ecf20Sopenharmony_ci	{ 0x0046, 0x001f },
878c2ecf20Sopenharmony_ci	{ 0x0047, 0x001f },
888c2ecf20Sopenharmony_ci	{ 0x0048, 0x0003 },
898c2ecf20Sopenharmony_ci	{ 0x0049, 0xe061 },
908c2ecf20Sopenharmony_ci	{ 0x004a, 0x0000 },
918c2ecf20Sopenharmony_ci	{ 0x004b, 0x031f },
928c2ecf20Sopenharmony_ci	{ 0x004d, 0x0000 },
938c2ecf20Sopenharmony_ci	{ 0x004e, 0x001f },
948c2ecf20Sopenharmony_ci	{ 0x004f, 0x0000 },
958c2ecf20Sopenharmony_ci	{ 0x0050, 0x001f },
968c2ecf20Sopenharmony_ci	{ 0x0052, 0xf000 },
978c2ecf20Sopenharmony_ci	{ 0x0053, 0x0111 },
988c2ecf20Sopenharmony_ci	{ 0x0054, 0x0064 },
998c2ecf20Sopenharmony_ci	{ 0x0055, 0x0080 },
1008c2ecf20Sopenharmony_ci	{ 0x0056, 0xef0e },
1018c2ecf20Sopenharmony_ci	{ 0x0057, 0xf0f0 },
1028c2ecf20Sopenharmony_ci	{ 0x0058, 0xef0e },
1038c2ecf20Sopenharmony_ci	{ 0x0059, 0xf0f0 },
1048c2ecf20Sopenharmony_ci	{ 0x005a, 0xef0e },
1058c2ecf20Sopenharmony_ci	{ 0x005b, 0xf0f0 },
1068c2ecf20Sopenharmony_ci	{ 0x005c, 0xf000 },
1078c2ecf20Sopenharmony_ci	{ 0x005d, 0x0000 },
1088c2ecf20Sopenharmony_ci	{ 0x005e, 0x1f2c },
1098c2ecf20Sopenharmony_ci	{ 0x005f, 0x1f2c },
1108c2ecf20Sopenharmony_ci	{ 0x0060, 0x2717 },
1118c2ecf20Sopenharmony_ci	{ 0x0061, 0x0000 },
1128c2ecf20Sopenharmony_ci	{ 0x0062, 0x0000 },
1138c2ecf20Sopenharmony_ci	{ 0x0063, 0x003e },
1148c2ecf20Sopenharmony_ci	{ 0x0064, 0x0000 },
1158c2ecf20Sopenharmony_ci	{ 0x0065, 0x0000 },
1168c2ecf20Sopenharmony_ci	{ 0x0066, 0x0000 },
1178c2ecf20Sopenharmony_ci	{ 0x0067, 0x0000 },
1188c2ecf20Sopenharmony_ci	{ 0x006a, 0x0000 },
1198c2ecf20Sopenharmony_ci	{ 0x006b, 0x0000 },
1208c2ecf20Sopenharmony_ci	{ 0x006c, 0x0000 },
1218c2ecf20Sopenharmony_ci	{ 0x006e, 0x0000 },
1228c2ecf20Sopenharmony_ci	{ 0x006f, 0x0000 },
1238c2ecf20Sopenharmony_ci	{ 0x0070, 0x8000 },
1248c2ecf20Sopenharmony_ci	{ 0x0071, 0x8000 },
1258c2ecf20Sopenharmony_ci	{ 0x0072, 0x8000 },
1268c2ecf20Sopenharmony_ci	{ 0x0073, 0x1110 },
1278c2ecf20Sopenharmony_ci	{ 0x0074, 0xfe00 },
1288c2ecf20Sopenharmony_ci	{ 0x0075, 0x2409 },
1298c2ecf20Sopenharmony_ci	{ 0x0076, 0x000a },
1308c2ecf20Sopenharmony_ci	{ 0x0077, 0x00f0 },
1318c2ecf20Sopenharmony_ci	{ 0x0078, 0x0000 },
1328c2ecf20Sopenharmony_ci	{ 0x0079, 0x0000 },
1338c2ecf20Sopenharmony_ci	{ 0x007a, 0x0123 },
1348c2ecf20Sopenharmony_ci	{ 0x007b, 0x8003 },
1358c2ecf20Sopenharmony_ci	{ 0x0080, 0x0000 },
1368c2ecf20Sopenharmony_ci	{ 0x0081, 0x0000 },
1378c2ecf20Sopenharmony_ci	{ 0x0082, 0x0000 },
1388c2ecf20Sopenharmony_ci	{ 0x0083, 0x0000 },
1398c2ecf20Sopenharmony_ci	{ 0x0084, 0x0000 },
1408c2ecf20Sopenharmony_ci	{ 0x0085, 0x0000 },
1418c2ecf20Sopenharmony_ci	{ 0x0086, 0x0008 },
1428c2ecf20Sopenharmony_ci	{ 0x0087, 0x0000 },
1438c2ecf20Sopenharmony_ci	{ 0x0088, 0x0000 },
1448c2ecf20Sopenharmony_ci	{ 0x0089, 0x0000 },
1458c2ecf20Sopenharmony_ci	{ 0x008a, 0x0000 },
1468c2ecf20Sopenharmony_ci	{ 0x008b, 0x0000 },
1478c2ecf20Sopenharmony_ci	{ 0x008c, 0x0003 },
1488c2ecf20Sopenharmony_ci	{ 0x008e, 0x0000 },
1498c2ecf20Sopenharmony_ci	{ 0x008f, 0x1000 },
1508c2ecf20Sopenharmony_ci	{ 0x0090, 0x0646 },
1518c2ecf20Sopenharmony_ci	{ 0x0091, 0x0c16 },
1528c2ecf20Sopenharmony_ci	{ 0x0092, 0x0073 },
1538c2ecf20Sopenharmony_ci	{ 0x0093, 0x0000 },
1548c2ecf20Sopenharmony_ci	{ 0x0094, 0x0080 },
1558c2ecf20Sopenharmony_ci	{ 0x0097, 0x0000 },
1568c2ecf20Sopenharmony_ci	{ 0x0098, 0x0000 },
1578c2ecf20Sopenharmony_ci	{ 0x0099, 0x0000 },
1588c2ecf20Sopenharmony_ci	{ 0x009a, 0x0000 },
1598c2ecf20Sopenharmony_ci	{ 0x009b, 0x0000 },
1608c2ecf20Sopenharmony_ci	{ 0x009c, 0x007f },
1618c2ecf20Sopenharmony_ci	{ 0x009d, 0x0000 },
1628c2ecf20Sopenharmony_ci	{ 0x009e, 0x007f },
1638c2ecf20Sopenharmony_ci	{ 0x009f, 0x0000 },
1648c2ecf20Sopenharmony_ci	{ 0x00a0, 0x0060 },
1658c2ecf20Sopenharmony_ci	{ 0x00a1, 0x90a1 },
1668c2ecf20Sopenharmony_ci	{ 0x00ae, 0x2000 },
1678c2ecf20Sopenharmony_ci	{ 0x00af, 0x0000 },
1688c2ecf20Sopenharmony_ci	{ 0x00b0, 0x2000 },
1698c2ecf20Sopenharmony_ci	{ 0x00b1, 0x0000 },
1708c2ecf20Sopenharmony_ci	{ 0x00b2, 0x0000 },
1718c2ecf20Sopenharmony_ci	{ 0x00b6, 0x0000 },
1728c2ecf20Sopenharmony_ci	{ 0x00b7, 0x0000 },
1738c2ecf20Sopenharmony_ci	{ 0x00b8, 0x0000 },
1748c2ecf20Sopenharmony_ci	{ 0x00b9, 0x0000 },
1758c2ecf20Sopenharmony_ci	{ 0x00ba, 0x0000 },
1768c2ecf20Sopenharmony_ci	{ 0x00bb, 0x0000 },
1778c2ecf20Sopenharmony_ci	{ 0x00be, 0x0000 },
1788c2ecf20Sopenharmony_ci	{ 0x00bf, 0x0000 },
1798c2ecf20Sopenharmony_ci	{ 0x00c0, 0x0000 },
1808c2ecf20Sopenharmony_ci	{ 0x00c1, 0x0000 },
1818c2ecf20Sopenharmony_ci	{ 0x00c2, 0x0000 },
1828c2ecf20Sopenharmony_ci	{ 0x00c3, 0x0000 },
1838c2ecf20Sopenharmony_ci	{ 0x00c4, 0x0003 },
1848c2ecf20Sopenharmony_ci	{ 0x00c5, 0x0000 },
1858c2ecf20Sopenharmony_ci	{ 0x00cb, 0xa02f },
1868c2ecf20Sopenharmony_ci	{ 0x00cc, 0x0000 },
1878c2ecf20Sopenharmony_ci	{ 0x00cd, 0x0e02 },
1888c2ecf20Sopenharmony_ci	{ 0x00d6, 0x0000 },
1898c2ecf20Sopenharmony_ci	{ 0x00d7, 0x2244 },
1908c2ecf20Sopenharmony_ci	{ 0x00d9, 0x0809 },
1918c2ecf20Sopenharmony_ci	{ 0x00da, 0x0000 },
1928c2ecf20Sopenharmony_ci	{ 0x00db, 0x0008 },
1938c2ecf20Sopenharmony_ci	{ 0x00dc, 0x00c0 },
1948c2ecf20Sopenharmony_ci	{ 0x00dd, 0x6724 },
1958c2ecf20Sopenharmony_ci	{ 0x00de, 0x3131 },
1968c2ecf20Sopenharmony_ci	{ 0x00df, 0x0008 },
1978c2ecf20Sopenharmony_ci	{ 0x00e0, 0x4000 },
1988c2ecf20Sopenharmony_ci	{ 0x00e1, 0x3131 },
1998c2ecf20Sopenharmony_ci	{ 0x00e4, 0x400c },
2008c2ecf20Sopenharmony_ci	{ 0x00e5, 0x8031 },
2018c2ecf20Sopenharmony_ci	{ 0x00ea, 0xb320 },
2028c2ecf20Sopenharmony_ci	{ 0x00eb, 0x0000 },
2038c2ecf20Sopenharmony_ci	{ 0x00ec, 0xb300 },
2048c2ecf20Sopenharmony_ci	{ 0x00ed, 0x0000 },
2058c2ecf20Sopenharmony_ci	{ 0x00f0, 0x0000 },
2068c2ecf20Sopenharmony_ci	{ 0x00f1, 0x0202 },
2078c2ecf20Sopenharmony_ci	{ 0x00f2, 0x0ddd },
2088c2ecf20Sopenharmony_ci	{ 0x00f3, 0x0ddd },
2098c2ecf20Sopenharmony_ci	{ 0x00f4, 0x0ddd },
2108c2ecf20Sopenharmony_ci	{ 0x00f6, 0x0000 },
2118c2ecf20Sopenharmony_ci	{ 0x00f7, 0x0000 },
2128c2ecf20Sopenharmony_ci	{ 0x00f8, 0x0000 },
2138c2ecf20Sopenharmony_ci	{ 0x00f9, 0x0000 },
2148c2ecf20Sopenharmony_ci	{ 0x00fa, 0x8000 },
2158c2ecf20Sopenharmony_ci	{ 0x00fb, 0x0000 },
2168c2ecf20Sopenharmony_ci	{ 0x00fc, 0x0000 },
2178c2ecf20Sopenharmony_ci	{ 0x00fd, 0x0001 },
2188c2ecf20Sopenharmony_ci	{ 0x00fe, 0x10ec },
2198c2ecf20Sopenharmony_ci	{ 0x00ff, 0x6311 },
2208c2ecf20Sopenharmony_ci	{ 0x0100, 0xaaaa },
2218c2ecf20Sopenharmony_ci	{ 0x010a, 0xaaaa },
2228c2ecf20Sopenharmony_ci	{ 0x010b, 0x00a0 },
2238c2ecf20Sopenharmony_ci	{ 0x010c, 0xaeae },
2248c2ecf20Sopenharmony_ci	{ 0x010d, 0xaaaa },
2258c2ecf20Sopenharmony_ci	{ 0x010e, 0xaaa8 },
2268c2ecf20Sopenharmony_ci	{ 0x010f, 0xa0aa },
2278c2ecf20Sopenharmony_ci	{ 0x0110, 0xe02a },
2288c2ecf20Sopenharmony_ci	{ 0x0111, 0xa702 },
2298c2ecf20Sopenharmony_ci	{ 0x0112, 0xaaaa },
2308c2ecf20Sopenharmony_ci	{ 0x0113, 0x2800 },
2318c2ecf20Sopenharmony_ci	{ 0x0116, 0x0000 },
2328c2ecf20Sopenharmony_ci	{ 0x0117, 0x0f00 },
2338c2ecf20Sopenharmony_ci	{ 0x011a, 0x0020 },
2348c2ecf20Sopenharmony_ci	{ 0x011b, 0x0011 },
2358c2ecf20Sopenharmony_ci	{ 0x011c, 0x0150 },
2368c2ecf20Sopenharmony_ci	{ 0x011d, 0x0000 },
2378c2ecf20Sopenharmony_ci	{ 0x011e, 0x0000 },
2388c2ecf20Sopenharmony_ci	{ 0x011f, 0x0000 },
2398c2ecf20Sopenharmony_ci	{ 0x0120, 0x0000 },
2408c2ecf20Sopenharmony_ci	{ 0x0121, 0x009b },
2418c2ecf20Sopenharmony_ci	{ 0x0122, 0x5014 },
2428c2ecf20Sopenharmony_ci	{ 0x0123, 0x0421 },
2438c2ecf20Sopenharmony_ci	{ 0x0124, 0x7cea },
2448c2ecf20Sopenharmony_ci	{ 0x0125, 0x0420 },
2458c2ecf20Sopenharmony_ci	{ 0x0126, 0x5550 },
2468c2ecf20Sopenharmony_ci	{ 0x0132, 0x0000 },
2478c2ecf20Sopenharmony_ci	{ 0x0133, 0x0000 },
2488c2ecf20Sopenharmony_ci	{ 0x0137, 0x5055 },
2498c2ecf20Sopenharmony_ci	{ 0x0138, 0x3700 },
2508c2ecf20Sopenharmony_ci	{ 0x0139, 0x79a1 },
2518c2ecf20Sopenharmony_ci	{ 0x013a, 0x2020 },
2528c2ecf20Sopenharmony_ci	{ 0x013b, 0x2020 },
2538c2ecf20Sopenharmony_ci	{ 0x013c, 0x2005 },
2548c2ecf20Sopenharmony_ci	{ 0x013e, 0x1f00 },
2558c2ecf20Sopenharmony_ci	{ 0x013f, 0x0000 },
2568c2ecf20Sopenharmony_ci	{ 0x0145, 0x0002 },
2578c2ecf20Sopenharmony_ci	{ 0x0146, 0x0000 },
2588c2ecf20Sopenharmony_ci	{ 0x0147, 0x0000 },
2598c2ecf20Sopenharmony_ci	{ 0x0148, 0x0000 },
2608c2ecf20Sopenharmony_ci	{ 0x0150, 0x1813 },
2618c2ecf20Sopenharmony_ci	{ 0x0151, 0x0690 },
2628c2ecf20Sopenharmony_ci	{ 0x0152, 0x1c17 },
2638c2ecf20Sopenharmony_ci	{ 0x0153, 0x6883 },
2648c2ecf20Sopenharmony_ci	{ 0x0154, 0xd3ce },
2658c2ecf20Sopenharmony_ci	{ 0x0155, 0x352d },
2668c2ecf20Sopenharmony_ci	{ 0x0156, 0x00eb },
2678c2ecf20Sopenharmony_ci	{ 0x0157, 0x3717 },
2688c2ecf20Sopenharmony_ci	{ 0x0158, 0x4c6a },
2698c2ecf20Sopenharmony_ci	{ 0x0159, 0xe41b },
2708c2ecf20Sopenharmony_ci	{ 0x015a, 0x2a13 },
2718c2ecf20Sopenharmony_ci	{ 0x015b, 0xb600 },
2728c2ecf20Sopenharmony_ci	{ 0x015c, 0xc730 },
2738c2ecf20Sopenharmony_ci	{ 0x015d, 0x35d4 },
2748c2ecf20Sopenharmony_ci	{ 0x015e, 0x00bf },
2758c2ecf20Sopenharmony_ci	{ 0x0160, 0x0ec0 },
2768c2ecf20Sopenharmony_ci	{ 0x0161, 0x0020 },
2778c2ecf20Sopenharmony_ci	{ 0x0162, 0x0080 },
2788c2ecf20Sopenharmony_ci	{ 0x0163, 0x0800 },
2798c2ecf20Sopenharmony_ci	{ 0x0164, 0x0000 },
2808c2ecf20Sopenharmony_ci	{ 0x0165, 0x0000 },
2818c2ecf20Sopenharmony_ci	{ 0x0166, 0x0000 },
2828c2ecf20Sopenharmony_ci	{ 0x0167, 0x001f },
2838c2ecf20Sopenharmony_ci	{ 0x0170, 0x4e80 },
2848c2ecf20Sopenharmony_ci	{ 0x0171, 0x0020 },
2858c2ecf20Sopenharmony_ci	{ 0x0172, 0x0080 },
2868c2ecf20Sopenharmony_ci	{ 0x0173, 0x0800 },
2878c2ecf20Sopenharmony_ci	{ 0x0174, 0x000c },
2888c2ecf20Sopenharmony_ci	{ 0x0175, 0x0000 },
2898c2ecf20Sopenharmony_ci	{ 0x0190, 0x3300 },
2908c2ecf20Sopenharmony_ci	{ 0x0191, 0x2200 },
2918c2ecf20Sopenharmony_ci	{ 0x0192, 0x0000 },
2928c2ecf20Sopenharmony_ci	{ 0x01b0, 0x4b38 },
2938c2ecf20Sopenharmony_ci	{ 0x01b1, 0x0000 },
2948c2ecf20Sopenharmony_ci	{ 0x01b2, 0x0000 },
2958c2ecf20Sopenharmony_ci	{ 0x01b3, 0x0000 },
2968c2ecf20Sopenharmony_ci	{ 0x01c0, 0x0045 },
2978c2ecf20Sopenharmony_ci	{ 0x01c1, 0x0540 },
2988c2ecf20Sopenharmony_ci	{ 0x01c2, 0x0000 },
2998c2ecf20Sopenharmony_ci	{ 0x01c3, 0x0030 },
3008c2ecf20Sopenharmony_ci	{ 0x01c7, 0x0000 },
3018c2ecf20Sopenharmony_ci	{ 0x01c8, 0x5757 },
3028c2ecf20Sopenharmony_ci	{ 0x01c9, 0x5757 },
3038c2ecf20Sopenharmony_ci	{ 0x01ca, 0x5757 },
3048c2ecf20Sopenharmony_ci	{ 0x01cb, 0x5757 },
3058c2ecf20Sopenharmony_ci	{ 0x01cc, 0x5757 },
3068c2ecf20Sopenharmony_ci	{ 0x01cd, 0x5757 },
3078c2ecf20Sopenharmony_ci	{ 0x01ce, 0x006f },
3088c2ecf20Sopenharmony_ci	{ 0x01da, 0x0000 },
3098c2ecf20Sopenharmony_ci	{ 0x01db, 0x0000 },
3108c2ecf20Sopenharmony_ci	{ 0x01de, 0x7d00 },
3118c2ecf20Sopenharmony_ci	{ 0x01df, 0x10c0 },
3128c2ecf20Sopenharmony_ci	{ 0x01e0, 0x06a1 },
3138c2ecf20Sopenharmony_ci	{ 0x01e1, 0x0000 },
3148c2ecf20Sopenharmony_ci	{ 0x01e2, 0x0000 },
3158c2ecf20Sopenharmony_ci	{ 0x01e3, 0x0000 },
3168c2ecf20Sopenharmony_ci	{ 0x01e4, 0x0001 },
3178c2ecf20Sopenharmony_ci	{ 0x01e6, 0x0000 },
3188c2ecf20Sopenharmony_ci	{ 0x01e7, 0x0000 },
3198c2ecf20Sopenharmony_ci	{ 0x01e8, 0x0000 },
3208c2ecf20Sopenharmony_ci	{ 0x01ea, 0x0000 },
3218c2ecf20Sopenharmony_ci	{ 0x01eb, 0x0000 },
3228c2ecf20Sopenharmony_ci	{ 0x01ec, 0x0000 },
3238c2ecf20Sopenharmony_ci	{ 0x01ed, 0x0000 },
3248c2ecf20Sopenharmony_ci	{ 0x01ee, 0x0000 },
3258c2ecf20Sopenharmony_ci	{ 0x01ef, 0x0000 },
3268c2ecf20Sopenharmony_ci	{ 0x01f0, 0x0000 },
3278c2ecf20Sopenharmony_ci	{ 0x01f1, 0x0000 },
3288c2ecf20Sopenharmony_ci	{ 0x01f2, 0x0000 },
3298c2ecf20Sopenharmony_ci	{ 0x01f6, 0x1e04 },
3308c2ecf20Sopenharmony_ci	{ 0x01f7, 0x01a1 },
3318c2ecf20Sopenharmony_ci	{ 0x01f8, 0x0000 },
3328c2ecf20Sopenharmony_ci	{ 0x01f9, 0x0000 },
3338c2ecf20Sopenharmony_ci	{ 0x01fa, 0x0002 },
3348c2ecf20Sopenharmony_ci	{ 0x01fb, 0x0000 },
3358c2ecf20Sopenharmony_ci	{ 0x01fc, 0x0000 },
3368c2ecf20Sopenharmony_ci	{ 0x01fd, 0x0000 },
3378c2ecf20Sopenharmony_ci	{ 0x01fe, 0x0000 },
3388c2ecf20Sopenharmony_ci	{ 0x0200, 0x066c },
3398c2ecf20Sopenharmony_ci	{ 0x0201, 0x7fff },
3408c2ecf20Sopenharmony_ci	{ 0x0202, 0x7fff },
3418c2ecf20Sopenharmony_ci	{ 0x0203, 0x0000 },
3428c2ecf20Sopenharmony_ci	{ 0x0204, 0x0000 },
3438c2ecf20Sopenharmony_ci	{ 0x0205, 0x0000 },
3448c2ecf20Sopenharmony_ci	{ 0x0206, 0x0000 },
3458c2ecf20Sopenharmony_ci	{ 0x0207, 0x0000 },
3468c2ecf20Sopenharmony_ci	{ 0x0208, 0x0000 },
3478c2ecf20Sopenharmony_ci	{ 0x0256, 0x0000 },
3488c2ecf20Sopenharmony_ci	{ 0x0257, 0x0000 },
3498c2ecf20Sopenharmony_ci	{ 0x0258, 0x0000 },
3508c2ecf20Sopenharmony_ci	{ 0x0259, 0x0000 },
3518c2ecf20Sopenharmony_ci	{ 0x025a, 0x0000 },
3528c2ecf20Sopenharmony_ci	{ 0x025b, 0x3333 },
3538c2ecf20Sopenharmony_ci	{ 0x025c, 0x3333 },
3548c2ecf20Sopenharmony_ci	{ 0x025d, 0x3333 },
3558c2ecf20Sopenharmony_ci	{ 0x025e, 0x0000 },
3568c2ecf20Sopenharmony_ci	{ 0x025f, 0x0000 },
3578c2ecf20Sopenharmony_ci	{ 0x0260, 0x0000 },
3588c2ecf20Sopenharmony_ci	{ 0x0261, 0x0022 },
3598c2ecf20Sopenharmony_ci	{ 0x0262, 0x0300 },
3608c2ecf20Sopenharmony_ci	{ 0x0265, 0x1e80 },
3618c2ecf20Sopenharmony_ci	{ 0x0266, 0x0131 },
3628c2ecf20Sopenharmony_ci	{ 0x0267, 0x0003 },
3638c2ecf20Sopenharmony_ci	{ 0x0268, 0x0000 },
3648c2ecf20Sopenharmony_ci	{ 0x0269, 0x0000 },
3658c2ecf20Sopenharmony_ci	{ 0x026a, 0x0000 },
3668c2ecf20Sopenharmony_ci	{ 0x026b, 0x0000 },
3678c2ecf20Sopenharmony_ci	{ 0x026c, 0x0000 },
3688c2ecf20Sopenharmony_ci	{ 0x026d, 0x0000 },
3698c2ecf20Sopenharmony_ci	{ 0x026e, 0x0000 },
3708c2ecf20Sopenharmony_ci	{ 0x026f, 0x0000 },
3718c2ecf20Sopenharmony_ci	{ 0x0270, 0x0000 },
3728c2ecf20Sopenharmony_ci	{ 0x0271, 0x0000 },
3738c2ecf20Sopenharmony_ci	{ 0x0272, 0x0000 },
3748c2ecf20Sopenharmony_ci	{ 0x0273, 0x0000 },
3758c2ecf20Sopenharmony_ci	{ 0x0280, 0x0000 },
3768c2ecf20Sopenharmony_ci	{ 0x0281, 0x0000 },
3778c2ecf20Sopenharmony_ci	{ 0x0282, 0x0418 },
3788c2ecf20Sopenharmony_ci	{ 0x0283, 0x7fff },
3798c2ecf20Sopenharmony_ci	{ 0x0284, 0x7000 },
3808c2ecf20Sopenharmony_ci	{ 0x0290, 0x01d0 },
3818c2ecf20Sopenharmony_ci	{ 0x0291, 0x0100 },
3828c2ecf20Sopenharmony_ci	{ 0x02fa, 0x0000 },
3838c2ecf20Sopenharmony_ci	{ 0x02fb, 0x0000 },
3848c2ecf20Sopenharmony_ci	{ 0x02fc, 0x0000 },
3858c2ecf20Sopenharmony_ci	{ 0x0300, 0x001f },
3868c2ecf20Sopenharmony_ci	{ 0x0301, 0x032c },
3878c2ecf20Sopenharmony_ci	{ 0x0302, 0x5f21 },
3888c2ecf20Sopenharmony_ci	{ 0x0303, 0x4000 },
3898c2ecf20Sopenharmony_ci	{ 0x0304, 0x4000 },
3908c2ecf20Sopenharmony_ci	{ 0x0305, 0x0600 },
3918c2ecf20Sopenharmony_ci	{ 0x0306, 0x8000 },
3928c2ecf20Sopenharmony_ci	{ 0x0307, 0x0700 },
3938c2ecf20Sopenharmony_ci	{ 0x0308, 0x001f },
3948c2ecf20Sopenharmony_ci	{ 0x0309, 0x032c },
3958c2ecf20Sopenharmony_ci	{ 0x030a, 0x5f21 },
3968c2ecf20Sopenharmony_ci	{ 0x030b, 0x4000 },
3978c2ecf20Sopenharmony_ci	{ 0x030c, 0x4000 },
3988c2ecf20Sopenharmony_ci	{ 0x030d, 0x0600 },
3998c2ecf20Sopenharmony_ci	{ 0x030e, 0x8000 },
4008c2ecf20Sopenharmony_ci	{ 0x030f, 0x0700 },
4018c2ecf20Sopenharmony_ci	{ 0x0310, 0x4560 },
4028c2ecf20Sopenharmony_ci	{ 0x0311, 0xa4a8 },
4038c2ecf20Sopenharmony_ci	{ 0x0312, 0x7418 },
4048c2ecf20Sopenharmony_ci	{ 0x0313, 0x0000 },
4058c2ecf20Sopenharmony_ci	{ 0x0314, 0x0006 },
4068c2ecf20Sopenharmony_ci	{ 0x0315, 0x00ff },
4078c2ecf20Sopenharmony_ci	{ 0x0316, 0xc400 },
4088c2ecf20Sopenharmony_ci	{ 0x0317, 0x4560 },
4098c2ecf20Sopenharmony_ci	{ 0x0318, 0xa4a8 },
4108c2ecf20Sopenharmony_ci	{ 0x0319, 0x7418 },
4118c2ecf20Sopenharmony_ci	{ 0x031a, 0x0000 },
4128c2ecf20Sopenharmony_ci	{ 0x031b, 0x0006 },
4138c2ecf20Sopenharmony_ci	{ 0x031c, 0x00ff },
4148c2ecf20Sopenharmony_ci	{ 0x031d, 0xc400 },
4158c2ecf20Sopenharmony_ci	{ 0x0320, 0x0f20 },
4168c2ecf20Sopenharmony_ci	{ 0x0321, 0x8700 },
4178c2ecf20Sopenharmony_ci	{ 0x0322, 0x7dc2 },
4188c2ecf20Sopenharmony_ci	{ 0x0323, 0xa178 },
4198c2ecf20Sopenharmony_ci	{ 0x0324, 0x5383 },
4208c2ecf20Sopenharmony_ci	{ 0x0325, 0x7dc2 },
4218c2ecf20Sopenharmony_ci	{ 0x0326, 0xa178 },
4228c2ecf20Sopenharmony_ci	{ 0x0327, 0x5383 },
4238c2ecf20Sopenharmony_ci	{ 0x0328, 0x003e },
4248c2ecf20Sopenharmony_ci	{ 0x0329, 0x02c1 },
4258c2ecf20Sopenharmony_ci	{ 0x032a, 0xd37d },
4268c2ecf20Sopenharmony_ci	{ 0x0330, 0x00a6 },
4278c2ecf20Sopenharmony_ci	{ 0x0331, 0x04c3 },
4288c2ecf20Sopenharmony_ci	{ 0x0332, 0x27c8 },
4298c2ecf20Sopenharmony_ci	{ 0x0333, 0xbf50 },
4308c2ecf20Sopenharmony_ci	{ 0x0334, 0x0045 },
4318c2ecf20Sopenharmony_ci	{ 0x0335, 0x2007 },
4328c2ecf20Sopenharmony_ci	{ 0x0336, 0x7418 },
4338c2ecf20Sopenharmony_ci	{ 0x0337, 0x0501 },
4348c2ecf20Sopenharmony_ci	{ 0x0338, 0x0000 },
4358c2ecf20Sopenharmony_ci	{ 0x0339, 0x0010 },
4368c2ecf20Sopenharmony_ci	{ 0x033a, 0x1010 },
4378c2ecf20Sopenharmony_ci	{ 0x0340, 0x0800 },
4388c2ecf20Sopenharmony_ci	{ 0x0341, 0x0800 },
4398c2ecf20Sopenharmony_ci	{ 0x0342, 0x0800 },
4408c2ecf20Sopenharmony_ci	{ 0x0343, 0x0800 },
4418c2ecf20Sopenharmony_ci	{ 0x0344, 0x0000 },
4428c2ecf20Sopenharmony_ci	{ 0x0345, 0x0000 },
4438c2ecf20Sopenharmony_ci	{ 0x0346, 0x0000 },
4448c2ecf20Sopenharmony_ci	{ 0x0347, 0x0000 },
4458c2ecf20Sopenharmony_ci	{ 0x0348, 0x0000 },
4468c2ecf20Sopenharmony_ci	{ 0x0349, 0x0000 },
4478c2ecf20Sopenharmony_ci	{ 0x034a, 0x0000 },
4488c2ecf20Sopenharmony_ci	{ 0x034b, 0x0000 },
4498c2ecf20Sopenharmony_ci	{ 0x034c, 0x0000 },
4508c2ecf20Sopenharmony_ci	{ 0x034d, 0x0000 },
4518c2ecf20Sopenharmony_ci	{ 0x034e, 0x0000 },
4528c2ecf20Sopenharmony_ci	{ 0x034f, 0x0000 },
4538c2ecf20Sopenharmony_ci	{ 0x0350, 0x0000 },
4548c2ecf20Sopenharmony_ci	{ 0x0351, 0x0000 },
4558c2ecf20Sopenharmony_ci	{ 0x0352, 0x0000 },
4568c2ecf20Sopenharmony_ci	{ 0x0353, 0x0000 },
4578c2ecf20Sopenharmony_ci	{ 0x0354, 0x0000 },
4588c2ecf20Sopenharmony_ci	{ 0x0355, 0x0000 },
4598c2ecf20Sopenharmony_ci	{ 0x0356, 0x0000 },
4608c2ecf20Sopenharmony_ci	{ 0x0357, 0x0000 },
4618c2ecf20Sopenharmony_ci	{ 0x0358, 0x0000 },
4628c2ecf20Sopenharmony_ci	{ 0x0359, 0x0000 },
4638c2ecf20Sopenharmony_ci	{ 0x035a, 0x0000 },
4648c2ecf20Sopenharmony_ci	{ 0x035b, 0x0000 },
4658c2ecf20Sopenharmony_ci	{ 0x035c, 0x0000 },
4668c2ecf20Sopenharmony_ci	{ 0x035d, 0x0000 },
4678c2ecf20Sopenharmony_ci	{ 0x035e, 0x2000 },
4688c2ecf20Sopenharmony_ci	{ 0x035f, 0x0000 },
4698c2ecf20Sopenharmony_ci	{ 0x0360, 0x2000 },
4708c2ecf20Sopenharmony_ci	{ 0x0361, 0x2000 },
4718c2ecf20Sopenharmony_ci	{ 0x0362, 0x0000 },
4728c2ecf20Sopenharmony_ci	{ 0x0363, 0x2000 },
4738c2ecf20Sopenharmony_ci	{ 0x0364, 0x0200 },
4748c2ecf20Sopenharmony_ci	{ 0x0365, 0x0000 },
4758c2ecf20Sopenharmony_ci	{ 0x0366, 0x0000 },
4768c2ecf20Sopenharmony_ci	{ 0x0367, 0x0000 },
4778c2ecf20Sopenharmony_ci	{ 0x0368, 0x0000 },
4788c2ecf20Sopenharmony_ci	{ 0x0369, 0x0000 },
4798c2ecf20Sopenharmony_ci	{ 0x036a, 0x0000 },
4808c2ecf20Sopenharmony_ci	{ 0x036b, 0x0000 },
4818c2ecf20Sopenharmony_ci	{ 0x036c, 0x0000 },
4828c2ecf20Sopenharmony_ci	{ 0x036d, 0x0000 },
4838c2ecf20Sopenharmony_ci	{ 0x036e, 0x0200 },
4848c2ecf20Sopenharmony_ci	{ 0x036f, 0x0000 },
4858c2ecf20Sopenharmony_ci	{ 0x0370, 0x0000 },
4868c2ecf20Sopenharmony_ci	{ 0x0371, 0x0000 },
4878c2ecf20Sopenharmony_ci	{ 0x0372, 0x0000 },
4888c2ecf20Sopenharmony_ci	{ 0x0373, 0x0000 },
4898c2ecf20Sopenharmony_ci	{ 0x0374, 0x0000 },
4908c2ecf20Sopenharmony_ci	{ 0x0375, 0x0000 },
4918c2ecf20Sopenharmony_ci	{ 0x0376, 0x0000 },
4928c2ecf20Sopenharmony_ci	{ 0x0377, 0x0000 },
4938c2ecf20Sopenharmony_ci	{ 0x03d0, 0x0000 },
4948c2ecf20Sopenharmony_ci	{ 0x03d1, 0x0000 },
4958c2ecf20Sopenharmony_ci	{ 0x03d2, 0x0000 },
4968c2ecf20Sopenharmony_ci	{ 0x03d3, 0x0000 },
4978c2ecf20Sopenharmony_ci	{ 0x03d4, 0x2000 },
4988c2ecf20Sopenharmony_ci	{ 0x03d5, 0x2000 },
4998c2ecf20Sopenharmony_ci	{ 0x03d6, 0x0000 },
5008c2ecf20Sopenharmony_ci	{ 0x03d7, 0x0000 },
5018c2ecf20Sopenharmony_ci	{ 0x03d8, 0x2000 },
5028c2ecf20Sopenharmony_ci	{ 0x03d9, 0x2000 },
5038c2ecf20Sopenharmony_ci	{ 0x03da, 0x2000 },
5048c2ecf20Sopenharmony_ci	{ 0x03db, 0x2000 },
5058c2ecf20Sopenharmony_ci	{ 0x03dc, 0x0000 },
5068c2ecf20Sopenharmony_ci	{ 0x03dd, 0x0000 },
5078c2ecf20Sopenharmony_ci	{ 0x03de, 0x0000 },
5088c2ecf20Sopenharmony_ci	{ 0x03df, 0x2000 },
5098c2ecf20Sopenharmony_ci	{ 0x03e0, 0x0000 },
5108c2ecf20Sopenharmony_ci	{ 0x03e1, 0x0000 },
5118c2ecf20Sopenharmony_ci	{ 0x03e2, 0x0000 },
5128c2ecf20Sopenharmony_ci	{ 0x03e3, 0x0000 },
5138c2ecf20Sopenharmony_ci	{ 0x03e4, 0x0000 },
5148c2ecf20Sopenharmony_ci	{ 0x03e5, 0x0000 },
5158c2ecf20Sopenharmony_ci	{ 0x03e6, 0x0000 },
5168c2ecf20Sopenharmony_ci	{ 0x03e7, 0x0000 },
5178c2ecf20Sopenharmony_ci	{ 0x03e8, 0x0000 },
5188c2ecf20Sopenharmony_ci	{ 0x03e9, 0x0000 },
5198c2ecf20Sopenharmony_ci	{ 0x03ea, 0x0000 },
5208c2ecf20Sopenharmony_ci	{ 0x03eb, 0x0000 },
5218c2ecf20Sopenharmony_ci	{ 0x03ec, 0x0000 },
5228c2ecf20Sopenharmony_ci	{ 0x03ed, 0x0000 },
5238c2ecf20Sopenharmony_ci	{ 0x03ee, 0x0000 },
5248c2ecf20Sopenharmony_ci	{ 0x03ef, 0x0000 },
5258c2ecf20Sopenharmony_ci	{ 0x03f0, 0x0800 },
5268c2ecf20Sopenharmony_ci	{ 0x03f1, 0x0800 },
5278c2ecf20Sopenharmony_ci	{ 0x03f2, 0x0800 },
5288c2ecf20Sopenharmony_ci	{ 0x03f3, 0x0800 },
5298c2ecf20Sopenharmony_ci};
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_cistatic bool rt5659_volatile_register(struct device *dev, unsigned int reg)
5328c2ecf20Sopenharmony_ci{
5338c2ecf20Sopenharmony_ci	switch (reg) {
5348c2ecf20Sopenharmony_ci	case RT5659_RESET:
5358c2ecf20Sopenharmony_ci	case RT5659_EJD_CTRL_2:
5368c2ecf20Sopenharmony_ci	case RT5659_SILENCE_CTRL:
5378c2ecf20Sopenharmony_ci	case RT5659_DAC2_DIG_VOL:
5388c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_GAIN_2:
5398c2ecf20Sopenharmony_ci	case RT5659_PDM_OUT_CTRL:
5408c2ecf20Sopenharmony_ci	case RT5659_PDM_DATA_CTRL_1:
5418c2ecf20Sopenharmony_ci	case RT5659_PDM_DATA_CTRL_4:
5428c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_1:
5438c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_3:
5448c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_LPF_CTRL_3:
5458c2ecf20Sopenharmony_ci	case RT5659_CLK_DET:
5468c2ecf20Sopenharmony_ci	case RT5659_MICBIAS_1:
5478c2ecf20Sopenharmony_ci	case RT5659_ASRC_11:
5488c2ecf20Sopenharmony_ci	case RT5659_ADC_EQ_CTRL_1:
5498c2ecf20Sopenharmony_ci	case RT5659_DAC_EQ_CTRL_1:
5508c2ecf20Sopenharmony_ci	case RT5659_INT_ST_1:
5518c2ecf20Sopenharmony_ci	case RT5659_INT_ST_2:
5528c2ecf20Sopenharmony_ci	case RT5659_GPIO_STA:
5538c2ecf20Sopenharmony_ci	case RT5659_SINE_GEN_CTRL_1:
5548c2ecf20Sopenharmony_ci	case RT5659_IL_CMD_1:
5558c2ecf20Sopenharmony_ci	case RT5659_4BTN_IL_CMD_1:
5568c2ecf20Sopenharmony_ci	case RT5659_PSV_IL_CMD_1:
5578c2ecf20Sopenharmony_ci	case RT5659_AJD1_CTRL:
5588c2ecf20Sopenharmony_ci	case RT5659_AJD2_AJD3_CTRL:
5598c2ecf20Sopenharmony_ci	case RT5659_JD_CTRL_3:
5608c2ecf20Sopenharmony_ci	case RT5659_VENDOR_ID:
5618c2ecf20Sopenharmony_ci	case RT5659_VENDOR_ID_1:
5628c2ecf20Sopenharmony_ci	case RT5659_DEVICE_ID:
5638c2ecf20Sopenharmony_ci	case RT5659_MEMORY_TEST:
5648c2ecf20Sopenharmony_ci	case RT5659_SOFT_RAMP_DEPOP_DAC_CLK_CTRL:
5658c2ecf20Sopenharmony_ci	case RT5659_VOL_TEST:
5668c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_1:
5678c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_5:
5688c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_6:
5698c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_7:
5708c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_1:
5718c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_5:
5728c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_6:
5738c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_CTRL_1:
5748c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_CTRL_3:
5758c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_CTRL_4:
5768c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_1:
5778c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_9:
5788c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_1:
5798c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_2:
5808c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_3:
5818c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_4:
5828c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_5:
5838c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_6:
5848c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_7:
5858c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_8:
5868c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_9:
5878c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_CTRL_1:
5888c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_CTRL_3:
5898c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_STA_1:
5908c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_STA_2:
5918c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_STA_3:
5928c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_STA_4:
5938c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_1:
5948c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_2:
5958c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_3:
5968c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_4:
5978c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_5:
5988c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_6:
5998c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_CTRL_1:
6008c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_1:
6018c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_2:
6028c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_3:
6038c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_4:
6048c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_5:
6058c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_6:
6068c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_7:
6078c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_8:
6088c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_9:
6098c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_10:
6108c2ecf20Sopenharmony_ci	case RT5659_SPK_VDD_STA_1:
6118c2ecf20Sopenharmony_ci	case RT5659_SPK_VDD_STA_2:
6128c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_DET_CTRL_1:
6138c2ecf20Sopenharmony_ci	case RT5659_PURE_DC_DET_CTRL_1:
6148c2ecf20Sopenharmony_ci	case RT5659_PURE_DC_DET_CTRL_2:
6158c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_1:
6168c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_4:
6178c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_5:
6188c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_6:
6198c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_7:
6208c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_1:
6218c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_4:
6228c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_5:
6238c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_6:
6248c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_7:
6258c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_STA_1:
6268c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_STA_2:
6278c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_STA_3:
6288c2ecf20Sopenharmony_ci		return true;
6298c2ecf20Sopenharmony_ci	default:
6308c2ecf20Sopenharmony_ci		return false;
6318c2ecf20Sopenharmony_ci	}
6328c2ecf20Sopenharmony_ci}
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_cistatic bool rt5659_readable_register(struct device *dev, unsigned int reg)
6358c2ecf20Sopenharmony_ci{
6368c2ecf20Sopenharmony_ci	switch (reg) {
6378c2ecf20Sopenharmony_ci	case RT5659_RESET:
6388c2ecf20Sopenharmony_ci	case RT5659_SPO_VOL:
6398c2ecf20Sopenharmony_ci	case RT5659_HP_VOL:
6408c2ecf20Sopenharmony_ci	case RT5659_LOUT:
6418c2ecf20Sopenharmony_ci	case RT5659_MONO_OUT:
6428c2ecf20Sopenharmony_ci	case RT5659_HPL_GAIN:
6438c2ecf20Sopenharmony_ci	case RT5659_HPR_GAIN:
6448c2ecf20Sopenharmony_ci	case RT5659_MONO_GAIN:
6458c2ecf20Sopenharmony_ci	case RT5659_SPDIF_CTRL_1:
6468c2ecf20Sopenharmony_ci	case RT5659_SPDIF_CTRL_2:
6478c2ecf20Sopenharmony_ci	case RT5659_CAL_BST_CTRL:
6488c2ecf20Sopenharmony_ci	case RT5659_IN1_IN2:
6498c2ecf20Sopenharmony_ci	case RT5659_IN3_IN4:
6508c2ecf20Sopenharmony_ci	case RT5659_INL1_INR1_VOL:
6518c2ecf20Sopenharmony_ci	case RT5659_EJD_CTRL_1:
6528c2ecf20Sopenharmony_ci	case RT5659_EJD_CTRL_2:
6538c2ecf20Sopenharmony_ci	case RT5659_EJD_CTRL_3:
6548c2ecf20Sopenharmony_ci	case RT5659_SILENCE_CTRL:
6558c2ecf20Sopenharmony_ci	case RT5659_PSV_CTRL:
6568c2ecf20Sopenharmony_ci	case RT5659_SIDETONE_CTRL:
6578c2ecf20Sopenharmony_ci	case RT5659_DAC1_DIG_VOL:
6588c2ecf20Sopenharmony_ci	case RT5659_DAC2_DIG_VOL:
6598c2ecf20Sopenharmony_ci	case RT5659_DAC_CTRL:
6608c2ecf20Sopenharmony_ci	case RT5659_STO1_ADC_DIG_VOL:
6618c2ecf20Sopenharmony_ci	case RT5659_MONO_ADC_DIG_VOL:
6628c2ecf20Sopenharmony_ci	case RT5659_STO2_ADC_DIG_VOL:
6638c2ecf20Sopenharmony_ci	case RT5659_STO1_BOOST:
6648c2ecf20Sopenharmony_ci	case RT5659_MONO_BOOST:
6658c2ecf20Sopenharmony_ci	case RT5659_STO2_BOOST:
6668c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_GAIN_1:
6678c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_GAIN_2:
6688c2ecf20Sopenharmony_ci	case RT5659_STO1_ADC_MIXER:
6698c2ecf20Sopenharmony_ci	case RT5659_MONO_ADC_MIXER:
6708c2ecf20Sopenharmony_ci	case RT5659_AD_DA_MIXER:
6718c2ecf20Sopenharmony_ci	case RT5659_STO_DAC_MIXER:
6728c2ecf20Sopenharmony_ci	case RT5659_MONO_DAC_MIXER:
6738c2ecf20Sopenharmony_ci	case RT5659_DIG_MIXER:
6748c2ecf20Sopenharmony_ci	case RT5659_A_DAC_MUX:
6758c2ecf20Sopenharmony_ci	case RT5659_DIG_INF23_DATA:
6768c2ecf20Sopenharmony_ci	case RT5659_PDM_OUT_CTRL:
6778c2ecf20Sopenharmony_ci	case RT5659_PDM_DATA_CTRL_1:
6788c2ecf20Sopenharmony_ci	case RT5659_PDM_DATA_CTRL_2:
6798c2ecf20Sopenharmony_ci	case RT5659_PDM_DATA_CTRL_3:
6808c2ecf20Sopenharmony_ci	case RT5659_PDM_DATA_CTRL_4:
6818c2ecf20Sopenharmony_ci	case RT5659_SPDIF_CTRL:
6828c2ecf20Sopenharmony_ci	case RT5659_REC1_GAIN:
6838c2ecf20Sopenharmony_ci	case RT5659_REC1_L1_MIXER:
6848c2ecf20Sopenharmony_ci	case RT5659_REC1_L2_MIXER:
6858c2ecf20Sopenharmony_ci	case RT5659_REC1_R1_MIXER:
6868c2ecf20Sopenharmony_ci	case RT5659_REC1_R2_MIXER:
6878c2ecf20Sopenharmony_ci	case RT5659_CAL_REC:
6888c2ecf20Sopenharmony_ci	case RT5659_REC2_L1_MIXER:
6898c2ecf20Sopenharmony_ci	case RT5659_REC2_L2_MIXER:
6908c2ecf20Sopenharmony_ci	case RT5659_REC2_R1_MIXER:
6918c2ecf20Sopenharmony_ci	case RT5659_REC2_R2_MIXER:
6928c2ecf20Sopenharmony_ci	case RT5659_SPK_L_MIXER:
6938c2ecf20Sopenharmony_ci	case RT5659_SPK_R_MIXER:
6948c2ecf20Sopenharmony_ci	case RT5659_SPO_AMP_GAIN:
6958c2ecf20Sopenharmony_ci	case RT5659_ALC_BACK_GAIN:
6968c2ecf20Sopenharmony_ci	case RT5659_MONOMIX_GAIN:
6978c2ecf20Sopenharmony_ci	case RT5659_MONOMIX_IN_GAIN:
6988c2ecf20Sopenharmony_ci	case RT5659_OUT_L_GAIN:
6998c2ecf20Sopenharmony_ci	case RT5659_OUT_L_MIXER:
7008c2ecf20Sopenharmony_ci	case RT5659_OUT_R_GAIN:
7018c2ecf20Sopenharmony_ci	case RT5659_OUT_R_MIXER:
7028c2ecf20Sopenharmony_ci	case RT5659_LOUT_MIXER:
7038c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_1:
7048c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_2:
7058c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_3:
7068c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_4:
7078c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_5:
7088c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_6:
7098c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_7:
7108c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_8:
7118c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_9:
7128c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_10:
7138c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_GEN_CTRL_11:
7148c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_LPF_CTRL_1:
7158c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_LPF_CTRL_2:
7168c2ecf20Sopenharmony_ci	case RT5659_HAPTIC_LPF_CTRL_3:
7178c2ecf20Sopenharmony_ci	case RT5659_PWR_DIG_1:
7188c2ecf20Sopenharmony_ci	case RT5659_PWR_DIG_2:
7198c2ecf20Sopenharmony_ci	case RT5659_PWR_ANLG_1:
7208c2ecf20Sopenharmony_ci	case RT5659_PWR_ANLG_2:
7218c2ecf20Sopenharmony_ci	case RT5659_PWR_ANLG_3:
7228c2ecf20Sopenharmony_ci	case RT5659_PWR_MIXER:
7238c2ecf20Sopenharmony_ci	case RT5659_PWR_VOL:
7248c2ecf20Sopenharmony_ci	case RT5659_PRIV_INDEX:
7258c2ecf20Sopenharmony_ci	case RT5659_CLK_DET:
7268c2ecf20Sopenharmony_ci	case RT5659_PRIV_DATA:
7278c2ecf20Sopenharmony_ci	case RT5659_PRE_DIV_1:
7288c2ecf20Sopenharmony_ci	case RT5659_PRE_DIV_2:
7298c2ecf20Sopenharmony_ci	case RT5659_I2S1_SDP:
7308c2ecf20Sopenharmony_ci	case RT5659_I2S2_SDP:
7318c2ecf20Sopenharmony_ci	case RT5659_I2S3_SDP:
7328c2ecf20Sopenharmony_ci	case RT5659_ADDA_CLK_1:
7338c2ecf20Sopenharmony_ci	case RT5659_ADDA_CLK_2:
7348c2ecf20Sopenharmony_ci	case RT5659_DMIC_CTRL_1:
7358c2ecf20Sopenharmony_ci	case RT5659_DMIC_CTRL_2:
7368c2ecf20Sopenharmony_ci	case RT5659_TDM_CTRL_1:
7378c2ecf20Sopenharmony_ci	case RT5659_TDM_CTRL_2:
7388c2ecf20Sopenharmony_ci	case RT5659_TDM_CTRL_3:
7398c2ecf20Sopenharmony_ci	case RT5659_TDM_CTRL_4:
7408c2ecf20Sopenharmony_ci	case RT5659_TDM_CTRL_5:
7418c2ecf20Sopenharmony_ci	case RT5659_GLB_CLK:
7428c2ecf20Sopenharmony_ci	case RT5659_PLL_CTRL_1:
7438c2ecf20Sopenharmony_ci	case RT5659_PLL_CTRL_2:
7448c2ecf20Sopenharmony_ci	case RT5659_ASRC_1:
7458c2ecf20Sopenharmony_ci	case RT5659_ASRC_2:
7468c2ecf20Sopenharmony_ci	case RT5659_ASRC_3:
7478c2ecf20Sopenharmony_ci	case RT5659_ASRC_4:
7488c2ecf20Sopenharmony_ci	case RT5659_ASRC_5:
7498c2ecf20Sopenharmony_ci	case RT5659_ASRC_6:
7508c2ecf20Sopenharmony_ci	case RT5659_ASRC_7:
7518c2ecf20Sopenharmony_ci	case RT5659_ASRC_8:
7528c2ecf20Sopenharmony_ci	case RT5659_ASRC_9:
7538c2ecf20Sopenharmony_ci	case RT5659_ASRC_10:
7548c2ecf20Sopenharmony_ci	case RT5659_DEPOP_1:
7558c2ecf20Sopenharmony_ci	case RT5659_DEPOP_2:
7568c2ecf20Sopenharmony_ci	case RT5659_DEPOP_3:
7578c2ecf20Sopenharmony_ci	case RT5659_HP_CHARGE_PUMP_1:
7588c2ecf20Sopenharmony_ci	case RT5659_HP_CHARGE_PUMP_2:
7598c2ecf20Sopenharmony_ci	case RT5659_MICBIAS_1:
7608c2ecf20Sopenharmony_ci	case RT5659_MICBIAS_2:
7618c2ecf20Sopenharmony_ci	case RT5659_ASRC_11:
7628c2ecf20Sopenharmony_ci	case RT5659_ASRC_12:
7638c2ecf20Sopenharmony_ci	case RT5659_ASRC_13:
7648c2ecf20Sopenharmony_ci	case RT5659_REC_M1_M2_GAIN_CTRL:
7658c2ecf20Sopenharmony_ci	case RT5659_RC_CLK_CTRL:
7668c2ecf20Sopenharmony_ci	case RT5659_CLASSD_CTRL_1:
7678c2ecf20Sopenharmony_ci	case RT5659_CLASSD_CTRL_2:
7688c2ecf20Sopenharmony_ci	case RT5659_ADC_EQ_CTRL_1:
7698c2ecf20Sopenharmony_ci	case RT5659_ADC_EQ_CTRL_2:
7708c2ecf20Sopenharmony_ci	case RT5659_DAC_EQ_CTRL_1:
7718c2ecf20Sopenharmony_ci	case RT5659_DAC_EQ_CTRL_2:
7728c2ecf20Sopenharmony_ci	case RT5659_DAC_EQ_CTRL_3:
7738c2ecf20Sopenharmony_ci	case RT5659_IRQ_CTRL_1:
7748c2ecf20Sopenharmony_ci	case RT5659_IRQ_CTRL_2:
7758c2ecf20Sopenharmony_ci	case RT5659_IRQ_CTRL_3:
7768c2ecf20Sopenharmony_ci	case RT5659_IRQ_CTRL_4:
7778c2ecf20Sopenharmony_ci	case RT5659_IRQ_CTRL_5:
7788c2ecf20Sopenharmony_ci	case RT5659_IRQ_CTRL_6:
7798c2ecf20Sopenharmony_ci	case RT5659_INT_ST_1:
7808c2ecf20Sopenharmony_ci	case RT5659_INT_ST_2:
7818c2ecf20Sopenharmony_ci	case RT5659_GPIO_CTRL_1:
7828c2ecf20Sopenharmony_ci	case RT5659_GPIO_CTRL_2:
7838c2ecf20Sopenharmony_ci	case RT5659_GPIO_CTRL_3:
7848c2ecf20Sopenharmony_ci	case RT5659_GPIO_CTRL_4:
7858c2ecf20Sopenharmony_ci	case RT5659_GPIO_CTRL_5:
7868c2ecf20Sopenharmony_ci	case RT5659_GPIO_STA:
7878c2ecf20Sopenharmony_ci	case RT5659_SINE_GEN_CTRL_1:
7888c2ecf20Sopenharmony_ci	case RT5659_SINE_GEN_CTRL_2:
7898c2ecf20Sopenharmony_ci	case RT5659_SINE_GEN_CTRL_3:
7908c2ecf20Sopenharmony_ci	case RT5659_HP_AMP_DET_CTRL_1:
7918c2ecf20Sopenharmony_ci	case RT5659_HP_AMP_DET_CTRL_2:
7928c2ecf20Sopenharmony_ci	case RT5659_SV_ZCD_1:
7938c2ecf20Sopenharmony_ci	case RT5659_SV_ZCD_2:
7948c2ecf20Sopenharmony_ci	case RT5659_IL_CMD_1:
7958c2ecf20Sopenharmony_ci	case RT5659_IL_CMD_2:
7968c2ecf20Sopenharmony_ci	case RT5659_IL_CMD_3:
7978c2ecf20Sopenharmony_ci	case RT5659_IL_CMD_4:
7988c2ecf20Sopenharmony_ci	case RT5659_4BTN_IL_CMD_1:
7998c2ecf20Sopenharmony_ci	case RT5659_4BTN_IL_CMD_2:
8008c2ecf20Sopenharmony_ci	case RT5659_4BTN_IL_CMD_3:
8018c2ecf20Sopenharmony_ci	case RT5659_PSV_IL_CMD_1:
8028c2ecf20Sopenharmony_ci	case RT5659_PSV_IL_CMD_2:
8038c2ecf20Sopenharmony_ci	case RT5659_ADC_STO1_HP_CTRL_1:
8048c2ecf20Sopenharmony_ci	case RT5659_ADC_STO1_HP_CTRL_2:
8058c2ecf20Sopenharmony_ci	case RT5659_ADC_MONO_HP_CTRL_1:
8068c2ecf20Sopenharmony_ci	case RT5659_ADC_MONO_HP_CTRL_2:
8078c2ecf20Sopenharmony_ci	case RT5659_AJD1_CTRL:
8088c2ecf20Sopenharmony_ci	case RT5659_AJD2_AJD3_CTRL:
8098c2ecf20Sopenharmony_ci	case RT5659_JD1_THD:
8108c2ecf20Sopenharmony_ci	case RT5659_JD2_THD:
8118c2ecf20Sopenharmony_ci	case RT5659_JD3_THD:
8128c2ecf20Sopenharmony_ci	case RT5659_JD_CTRL_1:
8138c2ecf20Sopenharmony_ci	case RT5659_JD_CTRL_2:
8148c2ecf20Sopenharmony_ci	case RT5659_JD_CTRL_3:
8158c2ecf20Sopenharmony_ci	case RT5659_JD_CTRL_4:
8168c2ecf20Sopenharmony_ci	case RT5659_DIG_MISC:
8178c2ecf20Sopenharmony_ci	case RT5659_DUMMY_2:
8188c2ecf20Sopenharmony_ci	case RT5659_DUMMY_3:
8198c2ecf20Sopenharmony_ci	case RT5659_VENDOR_ID:
8208c2ecf20Sopenharmony_ci	case RT5659_VENDOR_ID_1:
8218c2ecf20Sopenharmony_ci	case RT5659_DEVICE_ID:
8228c2ecf20Sopenharmony_ci	case RT5659_DAC_ADC_DIG_VOL:
8238c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_1:
8248c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_2:
8258c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_3:
8268c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_4:
8278c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_5:
8288c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_6:
8298c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_7:
8308c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_8:
8318c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_9:
8328c2ecf20Sopenharmony_ci	case RT5659_BIAS_CUR_CTRL_10:
8338c2ecf20Sopenharmony_ci	case RT5659_MEMORY_TEST:
8348c2ecf20Sopenharmony_ci	case RT5659_VREF_REC_OP_FB_CAP_CTRL:
8358c2ecf20Sopenharmony_ci	case RT5659_CLASSD_0:
8368c2ecf20Sopenharmony_ci	case RT5659_CLASSD_1:
8378c2ecf20Sopenharmony_ci	case RT5659_CLASSD_2:
8388c2ecf20Sopenharmony_ci	case RT5659_CLASSD_3:
8398c2ecf20Sopenharmony_ci	case RT5659_CLASSD_4:
8408c2ecf20Sopenharmony_ci	case RT5659_CLASSD_5:
8418c2ecf20Sopenharmony_ci	case RT5659_CLASSD_6:
8428c2ecf20Sopenharmony_ci	case RT5659_CLASSD_7:
8438c2ecf20Sopenharmony_ci	case RT5659_CLASSD_8:
8448c2ecf20Sopenharmony_ci	case RT5659_CLASSD_9:
8458c2ecf20Sopenharmony_ci	case RT5659_CLASSD_10:
8468c2ecf20Sopenharmony_ci	case RT5659_CHARGE_PUMP_1:
8478c2ecf20Sopenharmony_ci	case RT5659_CHARGE_PUMP_2:
8488c2ecf20Sopenharmony_ci	case RT5659_DIG_IN_CTRL_1:
8498c2ecf20Sopenharmony_ci	case RT5659_DIG_IN_CTRL_2:
8508c2ecf20Sopenharmony_ci	case RT5659_PAD_DRIVING_CTRL:
8518c2ecf20Sopenharmony_ci	case RT5659_SOFT_RAMP_DEPOP:
8528c2ecf20Sopenharmony_ci	case RT5659_PLL:
8538c2ecf20Sopenharmony_ci	case RT5659_CHOP_DAC:
8548c2ecf20Sopenharmony_ci	case RT5659_CHOP_ADC:
8558c2ecf20Sopenharmony_ci	case RT5659_CALIB_ADC_CTRL:
8568c2ecf20Sopenharmony_ci	case RT5659_SOFT_RAMP_DEPOP_DAC_CLK_CTRL:
8578c2ecf20Sopenharmony_ci	case RT5659_VOL_TEST:
8588c2ecf20Sopenharmony_ci	case RT5659_TEST_MODE_CTRL_1:
8598c2ecf20Sopenharmony_ci	case RT5659_TEST_MODE_CTRL_2:
8608c2ecf20Sopenharmony_ci	case RT5659_TEST_MODE_CTRL_3:
8618c2ecf20Sopenharmony_ci	case RT5659_TEST_MODE_CTRL_4:
8628c2ecf20Sopenharmony_ci	case RT5659_BASSBACK_CTRL:
8638c2ecf20Sopenharmony_ci	case RT5659_MP3_PLUS_CTRL_1:
8648c2ecf20Sopenharmony_ci	case RT5659_MP3_PLUS_CTRL_2:
8658c2ecf20Sopenharmony_ci	case RT5659_MP3_HPF_A1:
8668c2ecf20Sopenharmony_ci	case RT5659_MP3_HPF_A2:
8678c2ecf20Sopenharmony_ci	case RT5659_MP3_HPF_H0:
8688c2ecf20Sopenharmony_ci	case RT5659_MP3_LPF_H0:
8698c2ecf20Sopenharmony_ci	case RT5659_3D_SPK_CTRL:
8708c2ecf20Sopenharmony_ci	case RT5659_3D_SPK_COEF_1:
8718c2ecf20Sopenharmony_ci	case RT5659_3D_SPK_COEF_2:
8728c2ecf20Sopenharmony_ci	case RT5659_3D_SPK_COEF_3:
8738c2ecf20Sopenharmony_ci	case RT5659_3D_SPK_COEF_4:
8748c2ecf20Sopenharmony_ci	case RT5659_3D_SPK_COEF_5:
8758c2ecf20Sopenharmony_ci	case RT5659_3D_SPK_COEF_6:
8768c2ecf20Sopenharmony_ci	case RT5659_3D_SPK_COEF_7:
8778c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_1:
8788c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_2:
8798c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_3:
8808c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_4:
8818c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_5:
8828c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_6:
8838c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_7:
8848c2ecf20Sopenharmony_ci	case RT5659_STO_NG2_CTRL_8:
8858c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_1:
8868c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_2:
8878c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_3:
8888c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_4:
8898c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_5:
8908c2ecf20Sopenharmony_ci	case RT5659_MONO_NG2_CTRL_6:
8918c2ecf20Sopenharmony_ci	case RT5659_MID_HP_AMP_DET:
8928c2ecf20Sopenharmony_ci	case RT5659_LOW_HP_AMP_DET:
8938c2ecf20Sopenharmony_ci	case RT5659_LDO_CTRL:
8948c2ecf20Sopenharmony_ci	case RT5659_HP_DECROSS_CTRL_1:
8958c2ecf20Sopenharmony_ci	case RT5659_HP_DECROSS_CTRL_2:
8968c2ecf20Sopenharmony_ci	case RT5659_HP_DECROSS_CTRL_3:
8978c2ecf20Sopenharmony_ci	case RT5659_HP_DECROSS_CTRL_4:
8988c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_CTRL_1:
8998c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_CTRL_2:
9008c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_CTRL_3:
9018c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_CTRL_4:
9028c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_MAP_1:
9038c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_MAP_2:
9048c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_MAP_3:
9058c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_MAP_4:
9068c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_MAP_5:
9078c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_MAP_6:
9088c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_MAP_7:
9098c2ecf20Sopenharmony_ci	case RT5659_HP_IMP_SENS_MAP_8:
9108c2ecf20Sopenharmony_ci	case RT5659_HP_LOGIC_CTRL_1:
9118c2ecf20Sopenharmony_ci	case RT5659_HP_LOGIC_CTRL_2:
9128c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_1:
9138c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_2:
9148c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_3:
9158c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_4:
9168c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_5:
9178c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_6:
9188c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_7:
9198c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_9:
9208c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_10:
9218c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_CTRL_11:
9228c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_1:
9238c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_2:
9248c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_3:
9258c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_4:
9268c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_5:
9278c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_6:
9288c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_7:
9298c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_8:
9308c2ecf20Sopenharmony_ci	case RT5659_HP_CALIB_STA_9:
9318c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_CTRL_1:
9328c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_CTRL_2:
9338c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_CTRL_3:
9348c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_CTRL_4:
9358c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_CTRL_5:
9368c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_STA_1:
9378c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_STA_2:
9388c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_STA_3:
9398c2ecf20Sopenharmony_ci	case RT5659_MONO_AMP_CALIB_STA_4:
9408c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_CTRL_1:
9418c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_CTRL_2:
9428c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_CTRL_3:
9438c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_1:
9448c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_2:
9458c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_3:
9468c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_4:
9478c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_5:
9488c2ecf20Sopenharmony_ci	case RT5659_SPK_PWR_LMT_STA_6:
9498c2ecf20Sopenharmony_ci	case RT5659_FLEX_SPK_BST_CTRL_1:
9508c2ecf20Sopenharmony_ci	case RT5659_FLEX_SPK_BST_CTRL_2:
9518c2ecf20Sopenharmony_ci	case RT5659_FLEX_SPK_BST_CTRL_3:
9528c2ecf20Sopenharmony_ci	case RT5659_FLEX_SPK_BST_CTRL_4:
9538c2ecf20Sopenharmony_ci	case RT5659_SPK_EX_LMT_CTRL_1:
9548c2ecf20Sopenharmony_ci	case RT5659_SPK_EX_LMT_CTRL_2:
9558c2ecf20Sopenharmony_ci	case RT5659_SPK_EX_LMT_CTRL_3:
9568c2ecf20Sopenharmony_ci	case RT5659_SPK_EX_LMT_CTRL_4:
9578c2ecf20Sopenharmony_ci	case RT5659_SPK_EX_LMT_CTRL_5:
9588c2ecf20Sopenharmony_ci	case RT5659_SPK_EX_LMT_CTRL_6:
9598c2ecf20Sopenharmony_ci	case RT5659_SPK_EX_LMT_CTRL_7:
9608c2ecf20Sopenharmony_ci	case RT5659_ADJ_HPF_CTRL_1:
9618c2ecf20Sopenharmony_ci	case RT5659_ADJ_HPF_CTRL_2:
9628c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_CTRL_1:
9638c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_CTRL_2:
9648c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_CTRL_3:
9658c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_CTRL_4:
9668c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_CTRL_5:
9678c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_1:
9688c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_2:
9698c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_3:
9708c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_4:
9718c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_5:
9728c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_6:
9738c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_7:
9748c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_8:
9758c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_9:
9768c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_CAILB_STA_10:
9778c2ecf20Sopenharmony_ci	case RT5659_SPK_VDD_STA_1:
9788c2ecf20Sopenharmony_ci	case RT5659_SPK_VDD_STA_2:
9798c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_DET_CTRL_1:
9808c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_DET_CTRL_2:
9818c2ecf20Sopenharmony_ci	case RT5659_SPK_DC_DET_CTRL_3:
9828c2ecf20Sopenharmony_ci	case RT5659_PURE_DC_DET_CTRL_1:
9838c2ecf20Sopenharmony_ci	case RT5659_PURE_DC_DET_CTRL_2:
9848c2ecf20Sopenharmony_ci	case RT5659_DUMMY_4:
9858c2ecf20Sopenharmony_ci	case RT5659_DUMMY_5:
9868c2ecf20Sopenharmony_ci	case RT5659_DUMMY_6:
9878c2ecf20Sopenharmony_ci	case RT5659_DRC1_CTRL_1:
9888c2ecf20Sopenharmony_ci	case RT5659_DRC1_CTRL_2:
9898c2ecf20Sopenharmony_ci	case RT5659_DRC1_CTRL_3:
9908c2ecf20Sopenharmony_ci	case RT5659_DRC1_CTRL_4:
9918c2ecf20Sopenharmony_ci	case RT5659_DRC1_CTRL_5:
9928c2ecf20Sopenharmony_ci	case RT5659_DRC1_CTRL_6:
9938c2ecf20Sopenharmony_ci	case RT5659_DRC1_HARD_LMT_CTRL_1:
9948c2ecf20Sopenharmony_ci	case RT5659_DRC1_HARD_LMT_CTRL_2:
9958c2ecf20Sopenharmony_ci	case RT5659_DRC2_CTRL_1:
9968c2ecf20Sopenharmony_ci	case RT5659_DRC2_CTRL_2:
9978c2ecf20Sopenharmony_ci	case RT5659_DRC2_CTRL_3:
9988c2ecf20Sopenharmony_ci	case RT5659_DRC2_CTRL_4:
9998c2ecf20Sopenharmony_ci	case RT5659_DRC2_CTRL_5:
10008c2ecf20Sopenharmony_ci	case RT5659_DRC2_CTRL_6:
10018c2ecf20Sopenharmony_ci	case RT5659_DRC2_HARD_LMT_CTRL_1:
10028c2ecf20Sopenharmony_ci	case RT5659_DRC2_HARD_LMT_CTRL_2:
10038c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_1:
10048c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_2:
10058c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_3:
10068c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_4:
10078c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_5:
10088c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_6:
10098c2ecf20Sopenharmony_ci	case RT5659_DRC1_PRIV_7:
10108c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_1:
10118c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_2:
10128c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_3:
10138c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_4:
10148c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_5:
10158c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_6:
10168c2ecf20Sopenharmony_ci	case RT5659_DRC2_PRIV_7:
10178c2ecf20Sopenharmony_ci	case RT5659_MULTI_DRC_CTRL:
10188c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_1:
10198c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_2:
10208c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_3:
10218c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_4:
10228c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_5:
10238c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_6:
10248c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_7:
10258c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_8:
10268c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_9:
10278c2ecf20Sopenharmony_ci	case RT5659_CROSS_OVER_10:
10288c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_CTRL_1:
10298c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_CTRL_2:
10308c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_CTRL_3:
10318c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_CTRL_4:
10328c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_CTRL_5:
10338c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_CTRL_6:
10348c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_CTRL_7:
10358c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_CTRL_8:
10368c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_STA_1:
10378c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_STA_2:
10388c2ecf20Sopenharmony_ci	case RT5659_ALC_PGA_STA_3:
10398c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_PRE_VOL:
10408c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_PRE_VOL:
10418c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_POST_VOL:
10428c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_POST_VOL:
10438c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_LPF1_A1:
10448c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_LPF1_H0:
10458c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_LPF1_A1:
10468c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_LPF1_H0:
10478c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF2_A1:
10488c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF2_A2:
10498c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF2_H0:
10508c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF2_A1:
10518c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF2_A2:
10528c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF2_H0:
10538c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF3_A1:
10548c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF3_A2:
10558c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF3_H0:
10568c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF3_A1:
10578c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF3_A2:
10588c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF3_H0:
10598c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF4_A1:
10608c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF4_A2:
10618c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_BPF4_H0:
10628c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF4_A1:
10638c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF4_A2:
10648c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_BPF4_H0:
10658c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_HPF1_A1:
10668c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_HPF1_H0:
10678c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_HPF1_A1:
10688c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_HPF1_H0:
10698c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_HPF2_A1:
10708c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_HPF2_A2:
10718c2ecf20Sopenharmony_ci	case RT5659_DAC_L_EQ_HPF2_H0:
10728c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_HPF2_A1:
10738c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_HPF2_A2:
10748c2ecf20Sopenharmony_ci	case RT5659_DAC_R_EQ_HPF2_H0:
10758c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_H0_1:
10768c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_H0_2:
10778c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_B1_1:
10788c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_B1_2:
10798c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_B2_1:
10808c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_B2_2:
10818c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_A1_1:
10828c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_A1_2:
10838c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_A2_1:
10848c2ecf20Sopenharmony_ci	case RT5659_DAC_L_BI_EQ_BPF1_A2_2:
10858c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_H0_1:
10868c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_H0_2:
10878c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_B1_1:
10888c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_B1_2:
10898c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_B2_1:
10908c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_B2_2:
10918c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_A1_1:
10928c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_A1_2:
10938c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_A2_1:
10948c2ecf20Sopenharmony_ci	case RT5659_DAC_R_BI_EQ_BPF1_A2_2:
10958c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_LPF1_A1:
10968c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_LPF1_A1:
10978c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_LPF1_H0:
10988c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_LPF1_H0:
10998c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF1_A1:
11008c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF1_A1:
11018c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF1_A2:
11028c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF1_A2:
11038c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF1_H0:
11048c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF1_H0:
11058c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF2_A1:
11068c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF2_A1:
11078c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF2_A2:
11088c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF2_A2:
11098c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF2_H0:
11108c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF2_H0:
11118c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF3_A1:
11128c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF3_A1:
11138c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF3_A2:
11148c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF3_A2:
11158c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF3_H0:
11168c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF3_H0:
11178c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF4_A1:
11188c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF4_A1:
11198c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF4_A2:
11208c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF4_A2:
11218c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_BPF4_H0:
11228c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_BPF4_H0:
11238c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_HPF1_A1:
11248c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_HPF1_A1:
11258c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_HPF1_H0:
11268c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_HPF1_H0:
11278c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_PRE_VOL:
11288c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_PRE_VOL:
11298c2ecf20Sopenharmony_ci	case RT5659_ADC_L_EQ_POST_VOL:
11308c2ecf20Sopenharmony_ci	case RT5659_ADC_R_EQ_POST_VOL:
11318c2ecf20Sopenharmony_ci		return true;
11328c2ecf20Sopenharmony_ci	default:
11338c2ecf20Sopenharmony_ci		return false;
11348c2ecf20Sopenharmony_ci	}
11358c2ecf20Sopenharmony_ci}
11368c2ecf20Sopenharmony_ci
11378c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -2325, 75, 0);
11388c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
11398c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
11408c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
11418c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
11428c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
11438c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(in_bst_tlv, -1200, 75, 0);
11448c2ecf20Sopenharmony_ci
11458c2ecf20Sopenharmony_ci/* Interface data select */
11468c2ecf20Sopenharmony_cistatic const char * const rt5659_data_select[] = {
11478c2ecf20Sopenharmony_ci	"L/R", "R/L", "L/L", "R/R"
11488c2ecf20Sopenharmony_ci};
11498c2ecf20Sopenharmony_ci
11508c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5659_if1_01_adc_enum,
11518c2ecf20Sopenharmony_ci	RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT01_SFT, rt5659_data_select);
11528c2ecf20Sopenharmony_ci
11538c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5659_if1_23_adc_enum,
11548c2ecf20Sopenharmony_ci	RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT23_SFT, rt5659_data_select);
11558c2ecf20Sopenharmony_ci
11568c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5659_if1_45_adc_enum,
11578c2ecf20Sopenharmony_ci	RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT45_SFT, rt5659_data_select);
11588c2ecf20Sopenharmony_ci
11598c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5659_if1_67_adc_enum,
11608c2ecf20Sopenharmony_ci	RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT67_SFT, rt5659_data_select);
11618c2ecf20Sopenharmony_ci
11628c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5659_if2_dac_enum,
11638c2ecf20Sopenharmony_ci	RT5659_DIG_INF23_DATA, RT5659_IF2_DAC_SEL_SFT, rt5659_data_select);
11648c2ecf20Sopenharmony_ci
11658c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5659_if2_adc_enum,
11668c2ecf20Sopenharmony_ci	RT5659_DIG_INF23_DATA, RT5659_IF2_ADC_SEL_SFT, rt5659_data_select);
11678c2ecf20Sopenharmony_ci
11688c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5659_if3_dac_enum,
11698c2ecf20Sopenharmony_ci	RT5659_DIG_INF23_DATA, RT5659_IF3_DAC_SEL_SFT, rt5659_data_select);
11708c2ecf20Sopenharmony_ci
11718c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5659_if3_adc_enum,
11728c2ecf20Sopenharmony_ci	RT5659_DIG_INF23_DATA, RT5659_IF3_ADC_SEL_SFT, rt5659_data_select);
11738c2ecf20Sopenharmony_ci
11748c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if1_01_adc_swap_mux =
11758c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF1 01 ADC Swap Source", rt5659_if1_01_adc_enum);
11768c2ecf20Sopenharmony_ci
11778c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if1_23_adc_swap_mux =
11788c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF1 23 ADC1 Swap Source", rt5659_if1_23_adc_enum);
11798c2ecf20Sopenharmony_ci
11808c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if1_45_adc_swap_mux =
11818c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF1 45 ADC1 Swap Source", rt5659_if1_45_adc_enum);
11828c2ecf20Sopenharmony_ci
11838c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if1_67_adc_swap_mux =
11848c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF1 67 ADC1 Swap Source", rt5659_if1_67_adc_enum);
11858c2ecf20Sopenharmony_ci
11868c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if2_dac_swap_mux =
11878c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF2 DAC Swap Source", rt5659_if2_dac_enum);
11888c2ecf20Sopenharmony_ci
11898c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if2_adc_swap_mux =
11908c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF2 ADC Swap Source", rt5659_if2_adc_enum);
11918c2ecf20Sopenharmony_ci
11928c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if3_dac_swap_mux =
11938c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF3 DAC Swap Source", rt5659_if3_dac_enum);
11948c2ecf20Sopenharmony_ci
11958c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if3_adc_swap_mux =
11968c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF3 ADC Swap Source", rt5659_if3_adc_enum);
11978c2ecf20Sopenharmony_ci
11988c2ecf20Sopenharmony_cistatic int rt5659_hp_vol_put(struct snd_kcontrol *kcontrol,
11998c2ecf20Sopenharmony_ci		struct snd_ctl_elem_value *ucontrol)
12008c2ecf20Sopenharmony_ci{
12018c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
12028c2ecf20Sopenharmony_ci	int ret = snd_soc_put_volsw(kcontrol, ucontrol);
12038c2ecf20Sopenharmony_ci
12048c2ecf20Sopenharmony_ci	if (snd_soc_component_read(component, RT5659_STO_NG2_CTRL_1) & RT5659_NG2_EN) {
12058c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_STO_NG2_CTRL_1,
12068c2ecf20Sopenharmony_ci			RT5659_NG2_EN_MASK, RT5659_NG2_DIS);
12078c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_STO_NG2_CTRL_1,
12088c2ecf20Sopenharmony_ci			RT5659_NG2_EN_MASK, RT5659_NG2_EN);
12098c2ecf20Sopenharmony_ci	}
12108c2ecf20Sopenharmony_ci
12118c2ecf20Sopenharmony_ci	return ret;
12128c2ecf20Sopenharmony_ci}
12138c2ecf20Sopenharmony_ci
12148c2ecf20Sopenharmony_cistatic void rt5659_enable_push_button_irq(struct snd_soc_component *component,
12158c2ecf20Sopenharmony_ci	bool enable)
12168c2ecf20Sopenharmony_ci{
12178c2ecf20Sopenharmony_ci	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
12188c2ecf20Sopenharmony_ci
12198c2ecf20Sopenharmony_ci	if (enable) {
12208c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_4BTN_IL_CMD_1, 0x000b);
12218c2ecf20Sopenharmony_ci
12228c2ecf20Sopenharmony_ci		/* MICBIAS1 and Mic Det Power for button detect*/
12238c2ecf20Sopenharmony_ci		snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
12248c2ecf20Sopenharmony_ci		snd_soc_dapm_force_enable_pin(dapm,
12258c2ecf20Sopenharmony_ci			"Mic Det Power");
12268c2ecf20Sopenharmony_ci		snd_soc_dapm_sync(dapm);
12278c2ecf20Sopenharmony_ci
12288c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_PWR_ANLG_2,
12298c2ecf20Sopenharmony_ci			RT5659_PWR_MB1, RT5659_PWR_MB1);
12308c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_PWR_VOL,
12318c2ecf20Sopenharmony_ci			RT5659_PWR_MIC_DET, RT5659_PWR_MIC_DET);
12328c2ecf20Sopenharmony_ci
12338c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_IRQ_CTRL_2,
12348c2ecf20Sopenharmony_ci				RT5659_IL_IRQ_MASK, RT5659_IL_IRQ_EN);
12358c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_4BTN_IL_CMD_2,
12368c2ecf20Sopenharmony_ci				RT5659_4BTN_IL_MASK, RT5659_4BTN_IL_EN);
12378c2ecf20Sopenharmony_ci	} else {
12388c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_4BTN_IL_CMD_2,
12398c2ecf20Sopenharmony_ci				RT5659_4BTN_IL_MASK, RT5659_4BTN_IL_DIS);
12408c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_IRQ_CTRL_2,
12418c2ecf20Sopenharmony_ci				RT5659_IL_IRQ_MASK, RT5659_IL_IRQ_DIS);
12428c2ecf20Sopenharmony_ci		/* MICBIAS1 and Mic Det Power for button detect*/
12438c2ecf20Sopenharmony_ci		snd_soc_dapm_disable_pin(dapm, "MICBIAS1");
12448c2ecf20Sopenharmony_ci		snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
12458c2ecf20Sopenharmony_ci		snd_soc_dapm_sync(dapm);
12468c2ecf20Sopenharmony_ci	}
12478c2ecf20Sopenharmony_ci}
12488c2ecf20Sopenharmony_ci
12498c2ecf20Sopenharmony_ci/**
12508c2ecf20Sopenharmony_ci * rt5659_headset_detect - Detect headset.
12518c2ecf20Sopenharmony_ci * @component: SoC audio component device.
12528c2ecf20Sopenharmony_ci * @jack_insert: Jack insert or not.
12538c2ecf20Sopenharmony_ci *
12548c2ecf20Sopenharmony_ci * Detect whether is headset or not when jack inserted.
12558c2ecf20Sopenharmony_ci *
12568c2ecf20Sopenharmony_ci * Returns detect status.
12578c2ecf20Sopenharmony_ci */
12588c2ecf20Sopenharmony_ci
12598c2ecf20Sopenharmony_cistatic int rt5659_headset_detect(struct snd_soc_component *component, int jack_insert)
12608c2ecf20Sopenharmony_ci{
12618c2ecf20Sopenharmony_ci	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
12628c2ecf20Sopenharmony_ci	int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30};
12638c2ecf20Sopenharmony_ci	int reg_63;
12648c2ecf20Sopenharmony_ci
12658c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
12668c2ecf20Sopenharmony_ci
12678c2ecf20Sopenharmony_ci	if (jack_insert) {
12688c2ecf20Sopenharmony_ci		snd_soc_dapm_force_enable_pin(dapm,
12698c2ecf20Sopenharmony_ci			"Mic Det Power");
12708c2ecf20Sopenharmony_ci		snd_soc_dapm_sync(dapm);
12718c2ecf20Sopenharmony_ci		reg_63 = snd_soc_component_read(component, RT5659_PWR_ANLG_1);
12728c2ecf20Sopenharmony_ci
12738c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_PWR_ANLG_1,
12748c2ecf20Sopenharmony_ci			RT5659_PWR_VREF2 | RT5659_PWR_MB,
12758c2ecf20Sopenharmony_ci			RT5659_PWR_VREF2 | RT5659_PWR_MB);
12768c2ecf20Sopenharmony_ci		msleep(20);
12778c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_PWR_ANLG_1,
12788c2ecf20Sopenharmony_ci			RT5659_PWR_FV2, RT5659_PWR_FV2);
12798c2ecf20Sopenharmony_ci
12808c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_EJD_CTRL_2, 0x4160);
12818c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_EJD_CTRL_1,
12828c2ecf20Sopenharmony_ci			0x20, 0x0);
12838c2ecf20Sopenharmony_ci		msleep(20);
12848c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_EJD_CTRL_1,
12858c2ecf20Sopenharmony_ci			0x20, 0x20);
12868c2ecf20Sopenharmony_ci
12878c2ecf20Sopenharmony_ci		while (i < 5) {
12888c2ecf20Sopenharmony_ci			msleep(sleep_time[i]);
12898c2ecf20Sopenharmony_ci			val = snd_soc_component_read(component, RT5659_EJD_CTRL_2) & 0x0003;
12908c2ecf20Sopenharmony_ci			i++;
12918c2ecf20Sopenharmony_ci			if (val == 0x1 || val == 0x2 || val == 0x3)
12928c2ecf20Sopenharmony_ci				break;
12938c2ecf20Sopenharmony_ci		}
12948c2ecf20Sopenharmony_ci
12958c2ecf20Sopenharmony_ci		switch (val) {
12968c2ecf20Sopenharmony_ci		case 1:
12978c2ecf20Sopenharmony_ci			rt5659->jack_type = SND_JACK_HEADSET;
12988c2ecf20Sopenharmony_ci			rt5659_enable_push_button_irq(component, true);
12998c2ecf20Sopenharmony_ci			break;
13008c2ecf20Sopenharmony_ci		default:
13018c2ecf20Sopenharmony_ci			snd_soc_component_write(component, RT5659_PWR_ANLG_1, reg_63);
13028c2ecf20Sopenharmony_ci			rt5659->jack_type = SND_JACK_HEADPHONE;
13038c2ecf20Sopenharmony_ci			snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
13048c2ecf20Sopenharmony_ci			snd_soc_dapm_sync(dapm);
13058c2ecf20Sopenharmony_ci			break;
13068c2ecf20Sopenharmony_ci		}
13078c2ecf20Sopenharmony_ci	} else {
13088c2ecf20Sopenharmony_ci		snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
13098c2ecf20Sopenharmony_ci		snd_soc_dapm_sync(dapm);
13108c2ecf20Sopenharmony_ci		if (rt5659->jack_type == SND_JACK_HEADSET)
13118c2ecf20Sopenharmony_ci			rt5659_enable_push_button_irq(component, false);
13128c2ecf20Sopenharmony_ci		rt5659->jack_type = 0;
13138c2ecf20Sopenharmony_ci	}
13148c2ecf20Sopenharmony_ci
13158c2ecf20Sopenharmony_ci	dev_dbg(component->dev, "jack_type = %d\n", rt5659->jack_type);
13168c2ecf20Sopenharmony_ci	return rt5659->jack_type;
13178c2ecf20Sopenharmony_ci}
13188c2ecf20Sopenharmony_ci
13198c2ecf20Sopenharmony_cistatic int rt5659_button_detect(struct snd_soc_component *component)
13208c2ecf20Sopenharmony_ci{
13218c2ecf20Sopenharmony_ci	int btn_type, val;
13228c2ecf20Sopenharmony_ci
13238c2ecf20Sopenharmony_ci	val = snd_soc_component_read(component, RT5659_4BTN_IL_CMD_1);
13248c2ecf20Sopenharmony_ci	btn_type = val & 0xfff0;
13258c2ecf20Sopenharmony_ci	snd_soc_component_write(component, RT5659_4BTN_IL_CMD_1, val);
13268c2ecf20Sopenharmony_ci
13278c2ecf20Sopenharmony_ci	return btn_type;
13288c2ecf20Sopenharmony_ci}
13298c2ecf20Sopenharmony_ci
13308c2ecf20Sopenharmony_cistatic irqreturn_t rt5659_irq(int irq, void *data)
13318c2ecf20Sopenharmony_ci{
13328c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = data;
13338c2ecf20Sopenharmony_ci
13348c2ecf20Sopenharmony_ci	queue_delayed_work(system_power_efficient_wq,
13358c2ecf20Sopenharmony_ci			   &rt5659->jack_detect_work, msecs_to_jiffies(250));
13368c2ecf20Sopenharmony_ci
13378c2ecf20Sopenharmony_ci	return IRQ_HANDLED;
13388c2ecf20Sopenharmony_ci}
13398c2ecf20Sopenharmony_ci
13408c2ecf20Sopenharmony_ciint rt5659_set_jack_detect(struct snd_soc_component *component,
13418c2ecf20Sopenharmony_ci	struct snd_soc_jack *hs_jack)
13428c2ecf20Sopenharmony_ci{
13438c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
13448c2ecf20Sopenharmony_ci
13458c2ecf20Sopenharmony_ci	rt5659->hs_jack = hs_jack;
13468c2ecf20Sopenharmony_ci
13478c2ecf20Sopenharmony_ci	rt5659_irq(0, rt5659);
13488c2ecf20Sopenharmony_ci
13498c2ecf20Sopenharmony_ci	return 0;
13508c2ecf20Sopenharmony_ci}
13518c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(rt5659_set_jack_detect);
13528c2ecf20Sopenharmony_ci
13538c2ecf20Sopenharmony_cistatic void rt5659_jack_detect_work(struct work_struct *work)
13548c2ecf20Sopenharmony_ci{
13558c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 =
13568c2ecf20Sopenharmony_ci		container_of(work, struct rt5659_priv, jack_detect_work.work);
13578c2ecf20Sopenharmony_ci	int val, btn_type, report = 0;
13588c2ecf20Sopenharmony_ci
13598c2ecf20Sopenharmony_ci	if (!rt5659->component)
13608c2ecf20Sopenharmony_ci		return;
13618c2ecf20Sopenharmony_ci
13628c2ecf20Sopenharmony_ci	val = snd_soc_component_read(rt5659->component, RT5659_INT_ST_1) & 0x0080;
13638c2ecf20Sopenharmony_ci	if (!val) {
13648c2ecf20Sopenharmony_ci		/* jack in */
13658c2ecf20Sopenharmony_ci		if (rt5659->jack_type == 0) {
13668c2ecf20Sopenharmony_ci			/* jack was out, report jack type */
13678c2ecf20Sopenharmony_ci			report = rt5659_headset_detect(rt5659->component, 1);
13688c2ecf20Sopenharmony_ci		} else {
13698c2ecf20Sopenharmony_ci			/* jack is already in, report button event */
13708c2ecf20Sopenharmony_ci			report = SND_JACK_HEADSET;
13718c2ecf20Sopenharmony_ci			btn_type = rt5659_button_detect(rt5659->component);
13728c2ecf20Sopenharmony_ci			/**
13738c2ecf20Sopenharmony_ci			 * rt5659 can report three kinds of button behavior,
13748c2ecf20Sopenharmony_ci			 * one click, double click and hold. However,
13758c2ecf20Sopenharmony_ci			 * currently we will report button pressed/released
13768c2ecf20Sopenharmony_ci			 * event. So all the three button behaviors are
13778c2ecf20Sopenharmony_ci			 * treated as button pressed.
13788c2ecf20Sopenharmony_ci			 */
13798c2ecf20Sopenharmony_ci			switch (btn_type) {
13808c2ecf20Sopenharmony_ci			case 0x8000:
13818c2ecf20Sopenharmony_ci			case 0x4000:
13828c2ecf20Sopenharmony_ci			case 0x2000:
13838c2ecf20Sopenharmony_ci				report |= SND_JACK_BTN_0;
13848c2ecf20Sopenharmony_ci				break;
13858c2ecf20Sopenharmony_ci			case 0x1000:
13868c2ecf20Sopenharmony_ci			case 0x0800:
13878c2ecf20Sopenharmony_ci			case 0x0400:
13888c2ecf20Sopenharmony_ci				report |= SND_JACK_BTN_1;
13898c2ecf20Sopenharmony_ci				break;
13908c2ecf20Sopenharmony_ci			case 0x0200:
13918c2ecf20Sopenharmony_ci			case 0x0100:
13928c2ecf20Sopenharmony_ci			case 0x0080:
13938c2ecf20Sopenharmony_ci				report |= SND_JACK_BTN_2;
13948c2ecf20Sopenharmony_ci				break;
13958c2ecf20Sopenharmony_ci			case 0x0040:
13968c2ecf20Sopenharmony_ci			case 0x0020:
13978c2ecf20Sopenharmony_ci			case 0x0010:
13988c2ecf20Sopenharmony_ci				report |= SND_JACK_BTN_3;
13998c2ecf20Sopenharmony_ci				break;
14008c2ecf20Sopenharmony_ci			case 0x0000: /* unpressed */
14018c2ecf20Sopenharmony_ci				break;
14028c2ecf20Sopenharmony_ci			default:
14038c2ecf20Sopenharmony_ci				btn_type = 0;
14048c2ecf20Sopenharmony_ci				dev_err(rt5659->component->dev,
14058c2ecf20Sopenharmony_ci					"Unexpected button code 0x%04x\n",
14068c2ecf20Sopenharmony_ci					btn_type);
14078c2ecf20Sopenharmony_ci				break;
14088c2ecf20Sopenharmony_ci			}
14098c2ecf20Sopenharmony_ci
14108c2ecf20Sopenharmony_ci			/* button release or spurious interrput*/
14118c2ecf20Sopenharmony_ci			if (btn_type == 0)
14128c2ecf20Sopenharmony_ci				report =  rt5659->jack_type;
14138c2ecf20Sopenharmony_ci		}
14148c2ecf20Sopenharmony_ci	} else {
14158c2ecf20Sopenharmony_ci		/* jack out */
14168c2ecf20Sopenharmony_ci		report = rt5659_headset_detect(rt5659->component, 0);
14178c2ecf20Sopenharmony_ci	}
14188c2ecf20Sopenharmony_ci
14198c2ecf20Sopenharmony_ci	snd_soc_jack_report(rt5659->hs_jack, report, SND_JACK_HEADSET |
14208c2ecf20Sopenharmony_ci			    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
14218c2ecf20Sopenharmony_ci			    SND_JACK_BTN_2 | SND_JACK_BTN_3);
14228c2ecf20Sopenharmony_ci}
14238c2ecf20Sopenharmony_ci
14248c2ecf20Sopenharmony_cistatic void rt5659_jack_detect_intel_hd_header(struct work_struct *work)
14258c2ecf20Sopenharmony_ci{
14268c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 =
14278c2ecf20Sopenharmony_ci		container_of(work, struct rt5659_priv, jack_detect_work.work);
14288c2ecf20Sopenharmony_ci	unsigned int value;
14298c2ecf20Sopenharmony_ci	bool hp_flag, mic_flag;
14308c2ecf20Sopenharmony_ci
14318c2ecf20Sopenharmony_ci	if (!rt5659->hs_jack)
14328c2ecf20Sopenharmony_ci		return;
14338c2ecf20Sopenharmony_ci
14348c2ecf20Sopenharmony_ci	/* headphone jack */
14358c2ecf20Sopenharmony_ci	regmap_read(rt5659->regmap, RT5659_GPIO_STA, &value);
14368c2ecf20Sopenharmony_ci	hp_flag = (!(value & 0x8)) ? true : false;
14378c2ecf20Sopenharmony_ci
14388c2ecf20Sopenharmony_ci	if (hp_flag != rt5659->hda_hp_plugged) {
14398c2ecf20Sopenharmony_ci		rt5659->hda_hp_plugged = hp_flag;
14408c2ecf20Sopenharmony_ci
14418c2ecf20Sopenharmony_ci		if (hp_flag) {
14428c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_1,
14438c2ecf20Sopenharmony_ci				0x10, 0x0);
14448c2ecf20Sopenharmony_ci			rt5659->jack_type |= SND_JACK_HEADPHONE;
14458c2ecf20Sopenharmony_ci		} else {
14468c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_1,
14478c2ecf20Sopenharmony_ci				0x10, 0x10);
14488c2ecf20Sopenharmony_ci			rt5659->jack_type = rt5659->jack_type &
14498c2ecf20Sopenharmony_ci				(~SND_JACK_HEADPHONE);
14508c2ecf20Sopenharmony_ci		}
14518c2ecf20Sopenharmony_ci
14528c2ecf20Sopenharmony_ci		snd_soc_jack_report(rt5659->hs_jack, rt5659->jack_type,
14538c2ecf20Sopenharmony_ci			SND_JACK_HEADPHONE);
14548c2ecf20Sopenharmony_ci	}
14558c2ecf20Sopenharmony_ci
14568c2ecf20Sopenharmony_ci	/* mic jack */
14578c2ecf20Sopenharmony_ci	regmap_read(rt5659->regmap, RT5659_4BTN_IL_CMD_1, &value);
14588c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_4BTN_IL_CMD_1, value);
14598c2ecf20Sopenharmony_ci	mic_flag = (value & 0x2000) ? true : false;
14608c2ecf20Sopenharmony_ci
14618c2ecf20Sopenharmony_ci	if (mic_flag != rt5659->hda_mic_plugged) {
14628c2ecf20Sopenharmony_ci		rt5659->hda_mic_plugged = mic_flag;
14638c2ecf20Sopenharmony_ci		if (mic_flag) {
14648c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2,
14658c2ecf20Sopenharmony_ci				0x2, 0x2);
14668c2ecf20Sopenharmony_ci			rt5659->jack_type |= SND_JACK_MICROPHONE;
14678c2ecf20Sopenharmony_ci		} else {
14688c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2,
14698c2ecf20Sopenharmony_ci				0x2, 0x0);
14708c2ecf20Sopenharmony_ci			rt5659->jack_type = rt5659->jack_type
14718c2ecf20Sopenharmony_ci				& (~SND_JACK_MICROPHONE);
14728c2ecf20Sopenharmony_ci		}
14738c2ecf20Sopenharmony_ci
14748c2ecf20Sopenharmony_ci		snd_soc_jack_report(rt5659->hs_jack, rt5659->jack_type,
14758c2ecf20Sopenharmony_ci			SND_JACK_MICROPHONE);
14768c2ecf20Sopenharmony_ci	}
14778c2ecf20Sopenharmony_ci}
14788c2ecf20Sopenharmony_ci
14798c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_snd_controls[] = {
14808c2ecf20Sopenharmony_ci	/* Speaker Output Volume */
14818c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("Speaker Playback Volume", RT5659_SPO_VOL,
14828c2ecf20Sopenharmony_ci		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 39, 1, out_vol_tlv),
14838c2ecf20Sopenharmony_ci
14848c2ecf20Sopenharmony_ci	/* Headphone Output Volume */
14858c2ecf20Sopenharmony_ci	SOC_DOUBLE_R_EXT_TLV("Headphone Playback Volume", RT5659_HPL_GAIN,
14868c2ecf20Sopenharmony_ci		RT5659_HPR_GAIN, RT5659_G_HP_SFT, 31, 1, snd_soc_get_volsw,
14878c2ecf20Sopenharmony_ci		rt5659_hp_vol_put, hp_vol_tlv),
14888c2ecf20Sopenharmony_ci
14898c2ecf20Sopenharmony_ci	/* Mono Output Volume */
14908c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Mono Playback Volume", RT5659_MONO_OUT,
14918c2ecf20Sopenharmony_ci		RT5659_L_VOL_SFT, 39, 1, out_vol_tlv),
14928c2ecf20Sopenharmony_ci
14938c2ecf20Sopenharmony_ci	/* Output Volume */
14948c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("OUT Playback Volume", RT5659_LOUT,
14958c2ecf20Sopenharmony_ci		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 39, 1, out_vol_tlv),
14968c2ecf20Sopenharmony_ci
14978c2ecf20Sopenharmony_ci	/* DAC Digital Volume */
14988c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5659_DAC1_DIG_VOL,
14998c2ecf20Sopenharmony_ci		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 175, 0, dac_vol_tlv),
15008c2ecf20Sopenharmony_ci	SOC_DOUBLE("DAC1 Playback Switch", RT5659_AD_DA_MIXER,
15018c2ecf20Sopenharmony_ci		RT5659_M_DAC1_L_SFT, RT5659_M_DAC1_R_SFT, 1, 1),
15028c2ecf20Sopenharmony_ci
15038c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5659_DAC2_DIG_VOL,
15048c2ecf20Sopenharmony_ci		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 175, 0, dac_vol_tlv),
15058c2ecf20Sopenharmony_ci	SOC_DOUBLE("DAC2 Playback Switch", RT5659_DAC_CTRL,
15068c2ecf20Sopenharmony_ci		RT5659_M_DAC2_L_VOL_SFT, RT5659_M_DAC2_R_VOL_SFT, 1, 1),
15078c2ecf20Sopenharmony_ci
15088c2ecf20Sopenharmony_ci	/* IN1/IN2/IN3/IN4 Volume */
15098c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("IN1 Boost Volume", RT5659_IN1_IN2,
15108c2ecf20Sopenharmony_ci		RT5659_BST1_SFT, 69, 0, in_bst_tlv),
15118c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("IN2 Boost Volume", RT5659_IN1_IN2,
15128c2ecf20Sopenharmony_ci		RT5659_BST2_SFT, 69, 0, in_bst_tlv),
15138c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("IN3 Boost Volume", RT5659_IN3_IN4,
15148c2ecf20Sopenharmony_ci		RT5659_BST3_SFT, 69, 0, in_bst_tlv),
15158c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("IN4 Boost Volume", RT5659_IN3_IN4,
15168c2ecf20Sopenharmony_ci		RT5659_BST4_SFT, 69, 0, in_bst_tlv),
15178c2ecf20Sopenharmony_ci
15188c2ecf20Sopenharmony_ci	/* INL/INR Volume Control */
15198c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("IN Capture Volume", RT5659_INL1_INR1_VOL,
15208c2ecf20Sopenharmony_ci		RT5659_INL_VOL_SFT, RT5659_INR_VOL_SFT, 31, 1, in_vol_tlv),
15218c2ecf20Sopenharmony_ci
15228c2ecf20Sopenharmony_ci	/* ADC Digital Volume Control */
15238c2ecf20Sopenharmony_ci	SOC_DOUBLE("STO1 ADC Capture Switch", RT5659_STO1_ADC_DIG_VOL,
15248c2ecf20Sopenharmony_ci		RT5659_L_MUTE_SFT, RT5659_R_MUTE_SFT, 1, 1),
15258c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("STO1 ADC Capture Volume", RT5659_STO1_ADC_DIG_VOL,
15268c2ecf20Sopenharmony_ci		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 127, 0, adc_vol_tlv),
15278c2ecf20Sopenharmony_ci	SOC_DOUBLE("Mono ADC Capture Switch", RT5659_MONO_ADC_DIG_VOL,
15288c2ecf20Sopenharmony_ci		RT5659_L_MUTE_SFT, RT5659_R_MUTE_SFT, 1, 1),
15298c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5659_MONO_ADC_DIG_VOL,
15308c2ecf20Sopenharmony_ci		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 127, 0, adc_vol_tlv),
15318c2ecf20Sopenharmony_ci	SOC_DOUBLE("STO2 ADC Capture Switch", RT5659_STO2_ADC_DIG_VOL,
15328c2ecf20Sopenharmony_ci		RT5659_L_MUTE_SFT, RT5659_R_MUTE_SFT, 1, 1),
15338c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("STO2 ADC Capture Volume", RT5659_STO2_ADC_DIG_VOL,
15348c2ecf20Sopenharmony_ci		RT5659_L_VOL_SFT, RT5659_R_VOL_SFT, 127, 0, adc_vol_tlv),
15358c2ecf20Sopenharmony_ci
15368c2ecf20Sopenharmony_ci	/* ADC Boost Volume Control */
15378c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("STO1 ADC Boost Gain Volume", RT5659_STO1_BOOST,
15388c2ecf20Sopenharmony_ci		RT5659_STO1_ADC_L_BST_SFT, RT5659_STO1_ADC_R_BST_SFT,
15398c2ecf20Sopenharmony_ci		3, 0, adc_bst_tlv),
15408c2ecf20Sopenharmony_ci
15418c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("Mono ADC Boost Gain Volume", RT5659_MONO_BOOST,
15428c2ecf20Sopenharmony_ci		RT5659_MONO_ADC_L_BST_SFT, RT5659_MONO_ADC_R_BST_SFT,
15438c2ecf20Sopenharmony_ci		3, 0, adc_bst_tlv),
15448c2ecf20Sopenharmony_ci
15458c2ecf20Sopenharmony_ci	SOC_DOUBLE_TLV("STO2 ADC Boost Gain Volume", RT5659_STO2_BOOST,
15468c2ecf20Sopenharmony_ci		RT5659_STO2_ADC_L_BST_SFT, RT5659_STO2_ADC_R_BST_SFT,
15478c2ecf20Sopenharmony_ci		3, 0, adc_bst_tlv),
15488c2ecf20Sopenharmony_ci
15498c2ecf20Sopenharmony_ci	SOC_SINGLE("DAC IF1 DAC1 L Data Switch", RT5659_TDM_CTRL_4, 12, 7, 0),
15508c2ecf20Sopenharmony_ci	SOC_SINGLE("DAC IF1 DAC1 R Data Switch", RT5659_TDM_CTRL_4, 8, 7, 0),
15518c2ecf20Sopenharmony_ci	SOC_SINGLE("DAC IF1 DAC2 L Data Switch", RT5659_TDM_CTRL_4, 4, 7, 0),
15528c2ecf20Sopenharmony_ci	SOC_SINGLE("DAC IF1 DAC2 R Data Switch", RT5659_TDM_CTRL_4, 0, 7, 0),
15538c2ecf20Sopenharmony_ci};
15548c2ecf20Sopenharmony_ci
15558c2ecf20Sopenharmony_ci/**
15568c2ecf20Sopenharmony_ci * set_dmic_clk - Set parameter of dmic.
15578c2ecf20Sopenharmony_ci *
15588c2ecf20Sopenharmony_ci * @w: DAPM widget.
15598c2ecf20Sopenharmony_ci * @kcontrol: The kcontrol of this widget.
15608c2ecf20Sopenharmony_ci * @event: Event id.
15618c2ecf20Sopenharmony_ci *
15628c2ecf20Sopenharmony_ci * Choose dmic clock between 1MHz and 3MHz.
15638c2ecf20Sopenharmony_ci * It is better for clock to approximate 3MHz.
15648c2ecf20Sopenharmony_ci */
15658c2ecf20Sopenharmony_cistatic int set_dmic_clk(struct snd_soc_dapm_widget *w,
15668c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol, int event)
15678c2ecf20Sopenharmony_ci{
15688c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
15698c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
15708c2ecf20Sopenharmony_ci	int pd, idx;
15718c2ecf20Sopenharmony_ci
15728c2ecf20Sopenharmony_ci	pd = rl6231_get_pre_div(rt5659->regmap,
15738c2ecf20Sopenharmony_ci		RT5659_ADDA_CLK_1, RT5659_I2S_PD1_SFT);
15748c2ecf20Sopenharmony_ci	idx = rl6231_calc_dmic_clk(rt5659->sysclk / pd);
15758c2ecf20Sopenharmony_ci
15768c2ecf20Sopenharmony_ci	if (idx < 0)
15778c2ecf20Sopenharmony_ci		dev_err(component->dev, "Failed to set DMIC clock\n");
15788c2ecf20Sopenharmony_ci	else {
15798c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_DMIC_CTRL_1,
15808c2ecf20Sopenharmony_ci			RT5659_DMIC_CLK_MASK, idx << RT5659_DMIC_CLK_SFT);
15818c2ecf20Sopenharmony_ci	}
15828c2ecf20Sopenharmony_ci	return idx;
15838c2ecf20Sopenharmony_ci}
15848c2ecf20Sopenharmony_ci
15858c2ecf20Sopenharmony_cistatic int set_adc1_clk(struct snd_soc_dapm_widget *w,
15868c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol, int event)
15878c2ecf20Sopenharmony_ci{
15888c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
15898c2ecf20Sopenharmony_ci
15908c2ecf20Sopenharmony_ci	switch (event) {
15918c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMU:
15928c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_CHOP_ADC,
15938c2ecf20Sopenharmony_ci			RT5659_CKXEN_ADC1_MASK | RT5659_CKGEN_ADC1_MASK,
15948c2ecf20Sopenharmony_ci			RT5659_CKXEN_ADC1_MASK | RT5659_CKGEN_ADC1_MASK);
15958c2ecf20Sopenharmony_ci		break;
15968c2ecf20Sopenharmony_ci
15978c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_PRE_PMD:
15988c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_CHOP_ADC,
15998c2ecf20Sopenharmony_ci			RT5659_CKXEN_ADC1_MASK | RT5659_CKGEN_ADC1_MASK, 0);
16008c2ecf20Sopenharmony_ci		break;
16018c2ecf20Sopenharmony_ci
16028c2ecf20Sopenharmony_ci	default:
16038c2ecf20Sopenharmony_ci		return 0;
16048c2ecf20Sopenharmony_ci	}
16058c2ecf20Sopenharmony_ci
16068c2ecf20Sopenharmony_ci	return 0;
16078c2ecf20Sopenharmony_ci
16088c2ecf20Sopenharmony_ci}
16098c2ecf20Sopenharmony_ci
16108c2ecf20Sopenharmony_cistatic int set_adc2_clk(struct snd_soc_dapm_widget *w,
16118c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol, int event)
16128c2ecf20Sopenharmony_ci{
16138c2ecf20Sopenharmony_ci	struct snd_soc_component *component =
16148c2ecf20Sopenharmony_ci		snd_soc_dapm_to_component(w->dapm);
16158c2ecf20Sopenharmony_ci
16168c2ecf20Sopenharmony_ci	switch (event) {
16178c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMU:
16188c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_CHOP_ADC,
16198c2ecf20Sopenharmony_ci			RT5659_CKXEN_ADC2_MASK | RT5659_CKGEN_ADC2_MASK,
16208c2ecf20Sopenharmony_ci			RT5659_CKXEN_ADC2_MASK | RT5659_CKGEN_ADC2_MASK);
16218c2ecf20Sopenharmony_ci		break;
16228c2ecf20Sopenharmony_ci
16238c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_PRE_PMD:
16248c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_CHOP_ADC,
16258c2ecf20Sopenharmony_ci			RT5659_CKXEN_ADC2_MASK | RT5659_CKGEN_ADC2_MASK, 0);
16268c2ecf20Sopenharmony_ci		break;
16278c2ecf20Sopenharmony_ci
16288c2ecf20Sopenharmony_ci	default:
16298c2ecf20Sopenharmony_ci		return 0;
16308c2ecf20Sopenharmony_ci	}
16318c2ecf20Sopenharmony_ci
16328c2ecf20Sopenharmony_ci	return 0;
16338c2ecf20Sopenharmony_ci
16348c2ecf20Sopenharmony_ci}
16358c2ecf20Sopenharmony_ci
16368c2ecf20Sopenharmony_cistatic int rt5659_charge_pump_event(struct snd_soc_dapm_widget *w,
16378c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol, int event)
16388c2ecf20Sopenharmony_ci{
16398c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
16408c2ecf20Sopenharmony_ci
16418c2ecf20Sopenharmony_ci	switch (event) {
16428c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_PRE_PMU:
16438c2ecf20Sopenharmony_ci		/* Depop */
16448c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_DEPOP_1, 0x0009);
16458c2ecf20Sopenharmony_ci		break;
16468c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMD:
16478c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_HP_CHARGE_PUMP_1, 0x0c16);
16488c2ecf20Sopenharmony_ci		break;
16498c2ecf20Sopenharmony_ci	default:
16508c2ecf20Sopenharmony_ci		return 0;
16518c2ecf20Sopenharmony_ci	}
16528c2ecf20Sopenharmony_ci
16538c2ecf20Sopenharmony_ci	return 0;
16548c2ecf20Sopenharmony_ci}
16558c2ecf20Sopenharmony_ci
16568c2ecf20Sopenharmony_cistatic int is_sys_clk_from_pll(struct snd_soc_dapm_widget *w,
16578c2ecf20Sopenharmony_ci			 struct snd_soc_dapm_widget *sink)
16588c2ecf20Sopenharmony_ci{
16598c2ecf20Sopenharmony_ci	unsigned int val;
16608c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
16618c2ecf20Sopenharmony_ci
16628c2ecf20Sopenharmony_ci	val = snd_soc_component_read(component, RT5659_GLB_CLK);
16638c2ecf20Sopenharmony_ci	val &= RT5659_SCLK_SRC_MASK;
16648c2ecf20Sopenharmony_ci	if (val == RT5659_SCLK_SRC_PLL1)
16658c2ecf20Sopenharmony_ci		return 1;
16668c2ecf20Sopenharmony_ci	else
16678c2ecf20Sopenharmony_ci		return 0;
16688c2ecf20Sopenharmony_ci}
16698c2ecf20Sopenharmony_ci
16708c2ecf20Sopenharmony_cistatic int is_using_asrc(struct snd_soc_dapm_widget *w,
16718c2ecf20Sopenharmony_ci			 struct snd_soc_dapm_widget *sink)
16728c2ecf20Sopenharmony_ci{
16738c2ecf20Sopenharmony_ci	unsigned int reg, shift, val;
16748c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
16758c2ecf20Sopenharmony_ci
16768c2ecf20Sopenharmony_ci	switch (w->shift) {
16778c2ecf20Sopenharmony_ci	case RT5659_ADC_MONO_R_ASRC_SFT:
16788c2ecf20Sopenharmony_ci		reg = RT5659_ASRC_3;
16798c2ecf20Sopenharmony_ci		shift = RT5659_AD_MONO_R_T_SFT;
16808c2ecf20Sopenharmony_ci		break;
16818c2ecf20Sopenharmony_ci	case RT5659_ADC_MONO_L_ASRC_SFT:
16828c2ecf20Sopenharmony_ci		reg = RT5659_ASRC_3;
16838c2ecf20Sopenharmony_ci		shift = RT5659_AD_MONO_L_T_SFT;
16848c2ecf20Sopenharmony_ci		break;
16858c2ecf20Sopenharmony_ci	case RT5659_ADC_STO1_ASRC_SFT:
16868c2ecf20Sopenharmony_ci		reg = RT5659_ASRC_2;
16878c2ecf20Sopenharmony_ci		shift = RT5659_AD_STO1_T_SFT;
16888c2ecf20Sopenharmony_ci		break;
16898c2ecf20Sopenharmony_ci	case RT5659_DAC_MONO_R_ASRC_SFT:
16908c2ecf20Sopenharmony_ci		reg = RT5659_ASRC_2;
16918c2ecf20Sopenharmony_ci		shift = RT5659_DA_MONO_R_T_SFT;
16928c2ecf20Sopenharmony_ci		break;
16938c2ecf20Sopenharmony_ci	case RT5659_DAC_MONO_L_ASRC_SFT:
16948c2ecf20Sopenharmony_ci		reg = RT5659_ASRC_2;
16958c2ecf20Sopenharmony_ci		shift = RT5659_DA_MONO_L_T_SFT;
16968c2ecf20Sopenharmony_ci		break;
16978c2ecf20Sopenharmony_ci	case RT5659_DAC_STO_ASRC_SFT:
16988c2ecf20Sopenharmony_ci		reg = RT5659_ASRC_2;
16998c2ecf20Sopenharmony_ci		shift = RT5659_DA_STO_T_SFT;
17008c2ecf20Sopenharmony_ci		break;
17018c2ecf20Sopenharmony_ci	default:
17028c2ecf20Sopenharmony_ci		return 0;
17038c2ecf20Sopenharmony_ci	}
17048c2ecf20Sopenharmony_ci
17058c2ecf20Sopenharmony_ci	val = (snd_soc_component_read(component, reg) >> shift) & 0xf;
17068c2ecf20Sopenharmony_ci	switch (val) {
17078c2ecf20Sopenharmony_ci	case 1:
17088c2ecf20Sopenharmony_ci	case 2:
17098c2ecf20Sopenharmony_ci	case 3:
17108c2ecf20Sopenharmony_ci		/* I2S_Pre_Div1 should be 1 in asrc mode */
17118c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1,
17128c2ecf20Sopenharmony_ci			RT5659_I2S_PD1_MASK, RT5659_I2S_PD1_2);
17138c2ecf20Sopenharmony_ci		return 1;
17148c2ecf20Sopenharmony_ci	default:
17158c2ecf20Sopenharmony_ci		return 0;
17168c2ecf20Sopenharmony_ci	}
17178c2ecf20Sopenharmony_ci
17188c2ecf20Sopenharmony_ci}
17198c2ecf20Sopenharmony_ci
17208c2ecf20Sopenharmony_ci/* Digital Mixer */
17218c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_sto1_adc_l_mix[] = {
17228c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("ADC1 Switch", RT5659_STO1_ADC_MIXER,
17238c2ecf20Sopenharmony_ci			RT5659_M_STO1_ADC_L1_SFT, 1, 1),
17248c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("ADC2 Switch", RT5659_STO1_ADC_MIXER,
17258c2ecf20Sopenharmony_ci			RT5659_M_STO1_ADC_L2_SFT, 1, 1),
17268c2ecf20Sopenharmony_ci};
17278c2ecf20Sopenharmony_ci
17288c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_sto1_adc_r_mix[] = {
17298c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("ADC1 Switch", RT5659_STO1_ADC_MIXER,
17308c2ecf20Sopenharmony_ci			RT5659_M_STO1_ADC_R1_SFT, 1, 1),
17318c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("ADC2 Switch", RT5659_STO1_ADC_MIXER,
17328c2ecf20Sopenharmony_ci			RT5659_M_STO1_ADC_R2_SFT, 1, 1),
17338c2ecf20Sopenharmony_ci};
17348c2ecf20Sopenharmony_ci
17358c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_adc_l_mix[] = {
17368c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("ADC1 Switch", RT5659_MONO_ADC_MIXER,
17378c2ecf20Sopenharmony_ci			RT5659_M_MONO_ADC_L1_SFT, 1, 1),
17388c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("ADC2 Switch", RT5659_MONO_ADC_MIXER,
17398c2ecf20Sopenharmony_ci			RT5659_M_MONO_ADC_L2_SFT, 1, 1),
17408c2ecf20Sopenharmony_ci};
17418c2ecf20Sopenharmony_ci
17428c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_adc_r_mix[] = {
17438c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("ADC1 Switch", RT5659_MONO_ADC_MIXER,
17448c2ecf20Sopenharmony_ci			RT5659_M_MONO_ADC_R1_SFT, 1, 1),
17458c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("ADC2 Switch", RT5659_MONO_ADC_MIXER,
17468c2ecf20Sopenharmony_ci			RT5659_M_MONO_ADC_R2_SFT, 1, 1),
17478c2ecf20Sopenharmony_ci};
17488c2ecf20Sopenharmony_ci
17498c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_dac_l_mix[] = {
17508c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Stereo ADC Switch", RT5659_AD_DA_MIXER,
17518c2ecf20Sopenharmony_ci			RT5659_M_ADCMIX_L_SFT, 1, 1),
17528c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC1 Switch", RT5659_AD_DA_MIXER,
17538c2ecf20Sopenharmony_ci			RT5659_M_DAC1_L_SFT, 1, 1),
17548c2ecf20Sopenharmony_ci};
17558c2ecf20Sopenharmony_ci
17568c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_dac_r_mix[] = {
17578c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Stereo ADC Switch", RT5659_AD_DA_MIXER,
17588c2ecf20Sopenharmony_ci			RT5659_M_ADCMIX_R_SFT, 1, 1),
17598c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC1 Switch", RT5659_AD_DA_MIXER,
17608c2ecf20Sopenharmony_ci			RT5659_M_DAC1_R_SFT, 1, 1),
17618c2ecf20Sopenharmony_ci};
17628c2ecf20Sopenharmony_ci
17638c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_sto_dac_l_mix[] = {
17648c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L1 Switch", RT5659_STO_DAC_MIXER,
17658c2ecf20Sopenharmony_ci			RT5659_M_DAC_L1_STO_L_SFT, 1, 1),
17668c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R1 Switch", RT5659_STO_DAC_MIXER,
17678c2ecf20Sopenharmony_ci			RT5659_M_DAC_R1_STO_L_SFT, 1, 1),
17688c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_STO_DAC_MIXER,
17698c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_STO_L_SFT, 1, 1),
17708c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_STO_DAC_MIXER,
17718c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_STO_L_SFT, 1, 1),
17728c2ecf20Sopenharmony_ci};
17738c2ecf20Sopenharmony_ci
17748c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_sto_dac_r_mix[] = {
17758c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L1 Switch", RT5659_STO_DAC_MIXER,
17768c2ecf20Sopenharmony_ci			RT5659_M_DAC_L1_STO_R_SFT, 1, 1),
17778c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R1 Switch", RT5659_STO_DAC_MIXER,
17788c2ecf20Sopenharmony_ci			RT5659_M_DAC_R1_STO_R_SFT, 1, 1),
17798c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_STO_DAC_MIXER,
17808c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_STO_R_SFT, 1, 1),
17818c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_STO_DAC_MIXER,
17828c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_STO_R_SFT, 1, 1),
17838c2ecf20Sopenharmony_ci};
17848c2ecf20Sopenharmony_ci
17858c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_dac_l_mix[] = {
17868c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L1 Switch", RT5659_MONO_DAC_MIXER,
17878c2ecf20Sopenharmony_ci			RT5659_M_DAC_L1_MONO_L_SFT, 1, 1),
17888c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R1 Switch", RT5659_MONO_DAC_MIXER,
17898c2ecf20Sopenharmony_ci			RT5659_M_DAC_R1_MONO_L_SFT, 1, 1),
17908c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_MONO_DAC_MIXER,
17918c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_MONO_L_SFT, 1, 1),
17928c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_MONO_DAC_MIXER,
17938c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_MONO_L_SFT, 1, 1),
17948c2ecf20Sopenharmony_ci};
17958c2ecf20Sopenharmony_ci
17968c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_dac_r_mix[] = {
17978c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L1 Switch", RT5659_MONO_DAC_MIXER,
17988c2ecf20Sopenharmony_ci			RT5659_M_DAC_L1_MONO_R_SFT, 1, 1),
17998c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R1 Switch", RT5659_MONO_DAC_MIXER,
18008c2ecf20Sopenharmony_ci			RT5659_M_DAC_R1_MONO_R_SFT, 1, 1),
18018c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_MONO_DAC_MIXER,
18028c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_MONO_R_SFT, 1, 1),
18038c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_MONO_DAC_MIXER,
18048c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_MONO_R_SFT, 1, 1),
18058c2ecf20Sopenharmony_ci};
18068c2ecf20Sopenharmony_ci
18078c2ecf20Sopenharmony_ci/* Analog Input Mixer */
18088c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_rec1_l_mix[] = {
18098c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("SPKVOLL Switch", RT5659_REC1_L2_MIXER,
18108c2ecf20Sopenharmony_ci			RT5659_M_SPKVOLL_RM1_L_SFT, 1, 1),
18118c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("INL Switch", RT5659_REC1_L2_MIXER,
18128c2ecf20Sopenharmony_ci			RT5659_M_INL_RM1_L_SFT, 1, 1),
18138c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST4 Switch", RT5659_REC1_L2_MIXER,
18148c2ecf20Sopenharmony_ci			RT5659_M_BST4_RM1_L_SFT, 1, 1),
18158c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_REC1_L2_MIXER,
18168c2ecf20Sopenharmony_ci			RT5659_M_BST3_RM1_L_SFT, 1, 1),
18178c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST2 Switch", RT5659_REC1_L2_MIXER,
18188c2ecf20Sopenharmony_ci			RT5659_M_BST2_RM1_L_SFT, 1, 1),
18198c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST1 Switch", RT5659_REC1_L2_MIXER,
18208c2ecf20Sopenharmony_ci			RT5659_M_BST1_RM1_L_SFT, 1, 1),
18218c2ecf20Sopenharmony_ci};
18228c2ecf20Sopenharmony_ci
18238c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_rec1_r_mix[] = {
18248c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("HPOVOLR Switch", RT5659_REC1_L2_MIXER,
18258c2ecf20Sopenharmony_ci			RT5659_M_HPOVOLR_RM1_R_SFT, 1, 1),
18268c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("INR Switch", RT5659_REC1_R2_MIXER,
18278c2ecf20Sopenharmony_ci			RT5659_M_INR_RM1_R_SFT, 1, 1),
18288c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST4 Switch", RT5659_REC1_R2_MIXER,
18298c2ecf20Sopenharmony_ci			RT5659_M_BST4_RM1_R_SFT, 1, 1),
18308c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_REC1_R2_MIXER,
18318c2ecf20Sopenharmony_ci			RT5659_M_BST3_RM1_R_SFT, 1, 1),
18328c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST2 Switch", RT5659_REC1_R2_MIXER,
18338c2ecf20Sopenharmony_ci			RT5659_M_BST2_RM1_R_SFT, 1, 1),
18348c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST1 Switch", RT5659_REC1_R2_MIXER,
18358c2ecf20Sopenharmony_ci			RT5659_M_BST1_RM1_R_SFT, 1, 1),
18368c2ecf20Sopenharmony_ci};
18378c2ecf20Sopenharmony_ci
18388c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_rec2_l_mix[] = {
18398c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("SPKVOLL Switch", RT5659_REC2_L2_MIXER,
18408c2ecf20Sopenharmony_ci			RT5659_M_SPKVOL_RM2_L_SFT, 1, 1),
18418c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("OUTVOLL Switch", RT5659_REC2_L2_MIXER,
18428c2ecf20Sopenharmony_ci			RT5659_M_OUTVOLL_RM2_L_SFT, 1, 1),
18438c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST4 Switch", RT5659_REC2_L2_MIXER,
18448c2ecf20Sopenharmony_ci			RT5659_M_BST4_RM2_L_SFT, 1, 1),
18458c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_REC2_L2_MIXER,
18468c2ecf20Sopenharmony_ci			RT5659_M_BST3_RM2_L_SFT, 1, 1),
18478c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST2 Switch", RT5659_REC2_L2_MIXER,
18488c2ecf20Sopenharmony_ci			RT5659_M_BST2_RM2_L_SFT, 1, 1),
18498c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST1 Switch", RT5659_REC2_L2_MIXER,
18508c2ecf20Sopenharmony_ci			RT5659_M_BST1_RM2_L_SFT, 1, 1),
18518c2ecf20Sopenharmony_ci};
18528c2ecf20Sopenharmony_ci
18538c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_rec2_r_mix[] = {
18548c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MONOVOL Switch", RT5659_REC2_R2_MIXER,
18558c2ecf20Sopenharmony_ci			RT5659_M_MONOVOL_RM2_R_SFT, 1, 1),
18568c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("OUTVOLR Switch", RT5659_REC2_R2_MIXER,
18578c2ecf20Sopenharmony_ci			RT5659_M_OUTVOLR_RM2_R_SFT, 1, 1),
18588c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST4 Switch", RT5659_REC2_R2_MIXER,
18598c2ecf20Sopenharmony_ci			RT5659_M_BST4_RM2_R_SFT, 1, 1),
18608c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_REC2_R2_MIXER,
18618c2ecf20Sopenharmony_ci			RT5659_M_BST3_RM2_R_SFT, 1, 1),
18628c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST2 Switch", RT5659_REC2_R2_MIXER,
18638c2ecf20Sopenharmony_ci			RT5659_M_BST2_RM2_R_SFT, 1, 1),
18648c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST1 Switch", RT5659_REC2_R2_MIXER,
18658c2ecf20Sopenharmony_ci			RT5659_M_BST1_RM2_R_SFT, 1, 1),
18668c2ecf20Sopenharmony_ci};
18678c2ecf20Sopenharmony_ci
18688c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_spk_l_mix[] = {
18698c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_SPK_L_MIXER,
18708c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_SM_L_SFT, 1, 1),
18718c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST1 Switch", RT5659_SPK_L_MIXER,
18728c2ecf20Sopenharmony_ci			RT5659_M_BST1_SM_L_SFT, 1, 1),
18738c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("INL Switch", RT5659_SPK_L_MIXER,
18748c2ecf20Sopenharmony_ci			RT5659_M_IN_L_SM_L_SFT, 1, 1),
18758c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("INR Switch", RT5659_SPK_L_MIXER,
18768c2ecf20Sopenharmony_ci			RT5659_M_IN_R_SM_L_SFT, 1, 1),
18778c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_SPK_L_MIXER,
18788c2ecf20Sopenharmony_ci			RT5659_M_BST3_SM_L_SFT, 1, 1),
18798c2ecf20Sopenharmony_ci};
18808c2ecf20Sopenharmony_ci
18818c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_spk_r_mix[] = {
18828c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_SPK_R_MIXER,
18838c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_SM_R_SFT, 1, 1),
18848c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST4 Switch", RT5659_SPK_R_MIXER,
18858c2ecf20Sopenharmony_ci			RT5659_M_BST4_SM_R_SFT, 1, 1),
18868c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("INL Switch", RT5659_SPK_R_MIXER,
18878c2ecf20Sopenharmony_ci			RT5659_M_IN_L_SM_R_SFT, 1, 1),
18888c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("INR Switch", RT5659_SPK_R_MIXER,
18898c2ecf20Sopenharmony_ci			RT5659_M_IN_R_SM_R_SFT, 1, 1),
18908c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_SPK_R_MIXER,
18918c2ecf20Sopenharmony_ci			RT5659_M_BST3_SM_R_SFT, 1, 1),
18928c2ecf20Sopenharmony_ci};
18938c2ecf20Sopenharmony_ci
18948c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_monovol_mix[] = {
18958c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_MONOMIX_IN_GAIN,
18968c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_MM_SFT, 1, 1),
18978c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_MONOMIX_IN_GAIN,
18988c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_MM_SFT, 1, 1),
18998c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST1 Switch", RT5659_MONOMIX_IN_GAIN,
19008c2ecf20Sopenharmony_ci			RT5659_M_BST1_MM_SFT, 1, 1),
19018c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST2 Switch", RT5659_MONOMIX_IN_GAIN,
19028c2ecf20Sopenharmony_ci			RT5659_M_BST2_MM_SFT, 1, 1),
19038c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_MONOMIX_IN_GAIN,
19048c2ecf20Sopenharmony_ci			RT5659_M_BST3_MM_SFT, 1, 1),
19058c2ecf20Sopenharmony_ci};
19068c2ecf20Sopenharmony_ci
19078c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_out_l_mix[] = {
19088c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_OUT_L_MIXER,
19098c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_OM_L_SFT, 1, 1),
19108c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("INL Switch", RT5659_OUT_L_MIXER,
19118c2ecf20Sopenharmony_ci			RT5659_M_IN_L_OM_L_SFT, 1, 1),
19128c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST1 Switch", RT5659_OUT_L_MIXER,
19138c2ecf20Sopenharmony_ci			RT5659_M_BST1_OM_L_SFT, 1, 1),
19148c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST2 Switch", RT5659_OUT_L_MIXER,
19158c2ecf20Sopenharmony_ci			RT5659_M_BST2_OM_L_SFT, 1, 1),
19168c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_OUT_L_MIXER,
19178c2ecf20Sopenharmony_ci			RT5659_M_BST3_OM_L_SFT, 1, 1),
19188c2ecf20Sopenharmony_ci};
19198c2ecf20Sopenharmony_ci
19208c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_out_r_mix[] = {
19218c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_OUT_R_MIXER,
19228c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_OM_R_SFT, 1, 1),
19238c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("INR Switch", RT5659_OUT_R_MIXER,
19248c2ecf20Sopenharmony_ci			RT5659_M_IN_R_OM_R_SFT, 1, 1),
19258c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST2 Switch", RT5659_OUT_R_MIXER,
19268c2ecf20Sopenharmony_ci			RT5659_M_BST2_OM_R_SFT, 1, 1),
19278c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST3 Switch", RT5659_OUT_R_MIXER,
19288c2ecf20Sopenharmony_ci			RT5659_M_BST3_OM_R_SFT, 1, 1),
19298c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("BST4 Switch", RT5659_OUT_R_MIXER,
19308c2ecf20Sopenharmony_ci			RT5659_M_BST4_OM_R_SFT, 1, 1),
19318c2ecf20Sopenharmony_ci};
19328c2ecf20Sopenharmony_ci
19338c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_spo_l_mix[] = {
19348c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_SPO_AMP_GAIN,
19358c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_SPKOMIX_SFT, 1, 0),
19368c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("SPKVOL L Switch", RT5659_SPO_AMP_GAIN,
19378c2ecf20Sopenharmony_ci			RT5659_M_SPKVOLL_SPKOMIX_SFT, 1, 0),
19388c2ecf20Sopenharmony_ci};
19398c2ecf20Sopenharmony_ci
19408c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_spo_r_mix[] = {
19418c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_SPO_AMP_GAIN,
19428c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_SPKOMIX_SFT, 1, 0),
19438c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("SPKVOL R Switch", RT5659_SPO_AMP_GAIN,
19448c2ecf20Sopenharmony_ci			RT5659_M_SPKVOLR_SPKOMIX_SFT, 1, 0),
19458c2ecf20Sopenharmony_ci};
19468c2ecf20Sopenharmony_ci
19478c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_mix[] = {
19488c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_MONOMIX_IN_GAIN,
19498c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_MA_SFT, 1, 1),
19508c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MONOVOL Switch", RT5659_MONOMIX_IN_GAIN,
19518c2ecf20Sopenharmony_ci			RT5659_M_MONOVOL_MA_SFT, 1, 1),
19528c2ecf20Sopenharmony_ci};
19538c2ecf20Sopenharmony_ci
19548c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_lout_l_mix[] = {
19558c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC L2 Switch", RT5659_LOUT_MIXER,
19568c2ecf20Sopenharmony_ci			RT5659_M_DAC_L2_LM_SFT, 1, 1),
19578c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("OUTVOL L Switch", RT5659_LOUT_MIXER,
19588c2ecf20Sopenharmony_ci			RT5659_M_OV_L_LM_SFT, 1, 1),
19598c2ecf20Sopenharmony_ci};
19608c2ecf20Sopenharmony_ci
19618c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_lout_r_mix[] = {
19628c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("DAC R2 Switch", RT5659_LOUT_MIXER,
19638c2ecf20Sopenharmony_ci			RT5659_M_DAC_R2_LM_SFT, 1, 1),
19648c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("OUTVOL R Switch", RT5659_LOUT_MIXER,
19658c2ecf20Sopenharmony_ci			RT5659_M_OV_R_LM_SFT, 1, 1),
19668c2ecf20Sopenharmony_ci};
19678c2ecf20Sopenharmony_ci
19688c2ecf20Sopenharmony_ci/*DAC L2, DAC R2*/
19698c2ecf20Sopenharmony_ci/*MX-1B [6:4], MX-1B [2:0]*/
19708c2ecf20Sopenharmony_cistatic const char * const rt5659_dac2_src[] = {
19718c2ecf20Sopenharmony_ci	"IF1 DAC2", "IF2 DAC", "IF3 DAC", "Mono ADC MIX"
19728c2ecf20Sopenharmony_ci};
19738c2ecf20Sopenharmony_ci
19748c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
19758c2ecf20Sopenharmony_ci	rt5659_dac_l2_enum, RT5659_DAC_CTRL,
19768c2ecf20Sopenharmony_ci	RT5659_DAC_L2_SEL_SFT, rt5659_dac2_src);
19778c2ecf20Sopenharmony_ci
19788c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_dac_l2_mux =
19798c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("DAC L2 Source", rt5659_dac_l2_enum);
19808c2ecf20Sopenharmony_ci
19818c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
19828c2ecf20Sopenharmony_ci	rt5659_dac_r2_enum, RT5659_DAC_CTRL,
19838c2ecf20Sopenharmony_ci	RT5659_DAC_R2_SEL_SFT, rt5659_dac2_src);
19848c2ecf20Sopenharmony_ci
19858c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_dac_r2_mux =
19868c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("DAC R2 Source", rt5659_dac_r2_enum);
19878c2ecf20Sopenharmony_ci
19888c2ecf20Sopenharmony_ci
19898c2ecf20Sopenharmony_ci/* STO1 ADC1 Source */
19908c2ecf20Sopenharmony_ci/* MX-26 [13] */
19918c2ecf20Sopenharmony_cistatic const char * const rt5659_sto1_adc1_src[] = {
19928c2ecf20Sopenharmony_ci	"DAC MIX", "ADC"
19938c2ecf20Sopenharmony_ci};
19948c2ecf20Sopenharmony_ci
19958c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
19968c2ecf20Sopenharmony_ci	rt5659_sto1_adc1_enum, RT5659_STO1_ADC_MIXER,
19978c2ecf20Sopenharmony_ci	RT5659_STO1_ADC1_SRC_SFT, rt5659_sto1_adc1_src);
19988c2ecf20Sopenharmony_ci
19998c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_sto1_adc1_mux =
20008c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5659_sto1_adc1_enum);
20018c2ecf20Sopenharmony_ci
20028c2ecf20Sopenharmony_ci/* STO1 ADC Source */
20038c2ecf20Sopenharmony_ci/* MX-26 [12] */
20048c2ecf20Sopenharmony_cistatic const char * const rt5659_sto1_adc_src[] = {
20058c2ecf20Sopenharmony_ci	"ADC1", "ADC2"
20068c2ecf20Sopenharmony_ci};
20078c2ecf20Sopenharmony_ci
20088c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
20098c2ecf20Sopenharmony_ci	rt5659_sto1_adc_enum, RT5659_STO1_ADC_MIXER,
20108c2ecf20Sopenharmony_ci	RT5659_STO1_ADC_SRC_SFT, rt5659_sto1_adc_src);
20118c2ecf20Sopenharmony_ci
20128c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_sto1_adc_mux =
20138c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Stereo1 ADC Source", rt5659_sto1_adc_enum);
20148c2ecf20Sopenharmony_ci
20158c2ecf20Sopenharmony_ci/* STO1 ADC2 Source */
20168c2ecf20Sopenharmony_ci/* MX-26 [11] */
20178c2ecf20Sopenharmony_cistatic const char * const rt5659_sto1_adc2_src[] = {
20188c2ecf20Sopenharmony_ci	"DAC MIX", "DMIC"
20198c2ecf20Sopenharmony_ci};
20208c2ecf20Sopenharmony_ci
20218c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
20228c2ecf20Sopenharmony_ci	rt5659_sto1_adc2_enum, RT5659_STO1_ADC_MIXER,
20238c2ecf20Sopenharmony_ci	RT5659_STO1_ADC2_SRC_SFT, rt5659_sto1_adc2_src);
20248c2ecf20Sopenharmony_ci
20258c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_sto1_adc2_mux =
20268c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5659_sto1_adc2_enum);
20278c2ecf20Sopenharmony_ci
20288c2ecf20Sopenharmony_ci/* STO1 DMIC Source */
20298c2ecf20Sopenharmony_ci/* MX-26 [8] */
20308c2ecf20Sopenharmony_cistatic const char * const rt5659_sto1_dmic_src[] = {
20318c2ecf20Sopenharmony_ci	"DMIC1", "DMIC2"
20328c2ecf20Sopenharmony_ci};
20338c2ecf20Sopenharmony_ci
20348c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
20358c2ecf20Sopenharmony_ci	rt5659_sto1_dmic_enum, RT5659_STO1_ADC_MIXER,
20368c2ecf20Sopenharmony_ci	RT5659_STO1_DMIC_SRC_SFT, rt5659_sto1_dmic_src);
20378c2ecf20Sopenharmony_ci
20388c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_sto1_dmic_mux =
20398c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5659_sto1_dmic_enum);
20408c2ecf20Sopenharmony_ci
20418c2ecf20Sopenharmony_ci
20428c2ecf20Sopenharmony_ci/* MONO ADC L2 Source */
20438c2ecf20Sopenharmony_ci/* MX-27 [12] */
20448c2ecf20Sopenharmony_cistatic const char * const rt5659_mono_adc_l2_src[] = {
20458c2ecf20Sopenharmony_ci	"Mono DAC MIXL", "DMIC"
20468c2ecf20Sopenharmony_ci};
20478c2ecf20Sopenharmony_ci
20488c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
20498c2ecf20Sopenharmony_ci	rt5659_mono_adc_l2_enum, RT5659_MONO_ADC_MIXER,
20508c2ecf20Sopenharmony_ci	RT5659_MONO_ADC_L2_SRC_SFT, rt5659_mono_adc_l2_src);
20518c2ecf20Sopenharmony_ci
20528c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_adc_l2_mux =
20538c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Mono ADC L2 Source", rt5659_mono_adc_l2_enum);
20548c2ecf20Sopenharmony_ci
20558c2ecf20Sopenharmony_ci
20568c2ecf20Sopenharmony_ci/* MONO ADC L1 Source */
20578c2ecf20Sopenharmony_ci/* MX-27 [11] */
20588c2ecf20Sopenharmony_cistatic const char * const rt5659_mono_adc_l1_src[] = {
20598c2ecf20Sopenharmony_ci	"Mono DAC MIXL", "ADC"
20608c2ecf20Sopenharmony_ci};
20618c2ecf20Sopenharmony_ci
20628c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
20638c2ecf20Sopenharmony_ci	rt5659_mono_adc_l1_enum, RT5659_MONO_ADC_MIXER,
20648c2ecf20Sopenharmony_ci	RT5659_MONO_ADC_L1_SRC_SFT, rt5659_mono_adc_l1_src);
20658c2ecf20Sopenharmony_ci
20668c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_adc_l1_mux =
20678c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Mono ADC L1 Source", rt5659_mono_adc_l1_enum);
20688c2ecf20Sopenharmony_ci
20698c2ecf20Sopenharmony_ci/* MONO ADC L Source, MONO ADC R Source*/
20708c2ecf20Sopenharmony_ci/* MX-27 [10:9], MX-27 [2:1] */
20718c2ecf20Sopenharmony_cistatic const char * const rt5659_mono_adc_src[] = {
20728c2ecf20Sopenharmony_ci	"ADC1 L", "ADC1 R", "ADC2 L", "ADC2 R"
20738c2ecf20Sopenharmony_ci};
20748c2ecf20Sopenharmony_ci
20758c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
20768c2ecf20Sopenharmony_ci	rt5659_mono_adc_l_enum, RT5659_MONO_ADC_MIXER,
20778c2ecf20Sopenharmony_ci	RT5659_MONO_ADC_L_SRC_SFT, rt5659_mono_adc_src);
20788c2ecf20Sopenharmony_ci
20798c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_adc_l_mux =
20808c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Mono ADC L Source", rt5659_mono_adc_l_enum);
20818c2ecf20Sopenharmony_ci
20828c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
20838c2ecf20Sopenharmony_ci	rt5659_mono_adcr_enum, RT5659_MONO_ADC_MIXER,
20848c2ecf20Sopenharmony_ci	RT5659_MONO_ADC_R_SRC_SFT, rt5659_mono_adc_src);
20858c2ecf20Sopenharmony_ci
20868c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_adc_r_mux =
20878c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Mono ADC R Source", rt5659_mono_adcr_enum);
20888c2ecf20Sopenharmony_ci
20898c2ecf20Sopenharmony_ci/* MONO DMIC L Source */
20908c2ecf20Sopenharmony_ci/* MX-27 [8] */
20918c2ecf20Sopenharmony_cistatic const char * const rt5659_mono_dmic_l_src[] = {
20928c2ecf20Sopenharmony_ci	"DMIC1 L", "DMIC2 L"
20938c2ecf20Sopenharmony_ci};
20948c2ecf20Sopenharmony_ci
20958c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
20968c2ecf20Sopenharmony_ci	rt5659_mono_dmic_l_enum, RT5659_MONO_ADC_MIXER,
20978c2ecf20Sopenharmony_ci	RT5659_MONO_DMIC_L_SRC_SFT, rt5659_mono_dmic_l_src);
20988c2ecf20Sopenharmony_ci
20998c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_dmic_l_mux =
21008c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Mono DMIC L Source", rt5659_mono_dmic_l_enum);
21018c2ecf20Sopenharmony_ci
21028c2ecf20Sopenharmony_ci/* MONO ADC R2 Source */
21038c2ecf20Sopenharmony_ci/* MX-27 [4] */
21048c2ecf20Sopenharmony_cistatic const char * const rt5659_mono_adc_r2_src[] = {
21058c2ecf20Sopenharmony_ci	"Mono DAC MIXR", "DMIC"
21068c2ecf20Sopenharmony_ci};
21078c2ecf20Sopenharmony_ci
21088c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21098c2ecf20Sopenharmony_ci	rt5659_mono_adc_r2_enum, RT5659_MONO_ADC_MIXER,
21108c2ecf20Sopenharmony_ci	RT5659_MONO_ADC_R2_SRC_SFT, rt5659_mono_adc_r2_src);
21118c2ecf20Sopenharmony_ci
21128c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_adc_r2_mux =
21138c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Mono ADC R2 Source", rt5659_mono_adc_r2_enum);
21148c2ecf20Sopenharmony_ci
21158c2ecf20Sopenharmony_ci/* MONO ADC R1 Source */
21168c2ecf20Sopenharmony_ci/* MX-27 [3] */
21178c2ecf20Sopenharmony_cistatic const char * const rt5659_mono_adc_r1_src[] = {
21188c2ecf20Sopenharmony_ci	"Mono DAC MIXR", "ADC"
21198c2ecf20Sopenharmony_ci};
21208c2ecf20Sopenharmony_ci
21218c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21228c2ecf20Sopenharmony_ci	rt5659_mono_adc_r1_enum, RT5659_MONO_ADC_MIXER,
21238c2ecf20Sopenharmony_ci	RT5659_MONO_ADC_R1_SRC_SFT, rt5659_mono_adc_r1_src);
21248c2ecf20Sopenharmony_ci
21258c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_adc_r1_mux =
21268c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Mono ADC R1 Source", rt5659_mono_adc_r1_enum);
21278c2ecf20Sopenharmony_ci
21288c2ecf20Sopenharmony_ci/* MONO DMIC R Source */
21298c2ecf20Sopenharmony_ci/* MX-27 [0] */
21308c2ecf20Sopenharmony_cistatic const char * const rt5659_mono_dmic_r_src[] = {
21318c2ecf20Sopenharmony_ci	"DMIC1 R", "DMIC2 R"
21328c2ecf20Sopenharmony_ci};
21338c2ecf20Sopenharmony_ci
21348c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21358c2ecf20Sopenharmony_ci	rt5659_mono_dmic_r_enum, RT5659_MONO_ADC_MIXER,
21368c2ecf20Sopenharmony_ci	RT5659_MONO_DMIC_R_SRC_SFT, rt5659_mono_dmic_r_src);
21378c2ecf20Sopenharmony_ci
21388c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_mono_dmic_r_mux =
21398c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Mono DMIC R Source", rt5659_mono_dmic_r_enum);
21408c2ecf20Sopenharmony_ci
21418c2ecf20Sopenharmony_ci
21428c2ecf20Sopenharmony_ci/* DAC R1 Source, DAC L1 Source*/
21438c2ecf20Sopenharmony_ci/* MX-29 [11:10], MX-29 [9:8]*/
21448c2ecf20Sopenharmony_cistatic const char * const rt5659_dac1_src[] = {
21458c2ecf20Sopenharmony_ci	"IF1 DAC1", "IF2 DAC", "IF3 DAC"
21468c2ecf20Sopenharmony_ci};
21478c2ecf20Sopenharmony_ci
21488c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21498c2ecf20Sopenharmony_ci	rt5659_dac_r1_enum, RT5659_AD_DA_MIXER,
21508c2ecf20Sopenharmony_ci	RT5659_DAC1_R_SEL_SFT, rt5659_dac1_src);
21518c2ecf20Sopenharmony_ci
21528c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_dac_r1_mux =
21538c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("DAC R1 Source", rt5659_dac_r1_enum);
21548c2ecf20Sopenharmony_ci
21558c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21568c2ecf20Sopenharmony_ci	rt5659_dac_l1_enum, RT5659_AD_DA_MIXER,
21578c2ecf20Sopenharmony_ci	RT5659_DAC1_L_SEL_SFT, rt5659_dac1_src);
21588c2ecf20Sopenharmony_ci
21598c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_dac_l1_mux =
21608c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("DAC L1 Source", rt5659_dac_l1_enum);
21618c2ecf20Sopenharmony_ci
21628c2ecf20Sopenharmony_ci/* DAC Digital Mixer L Source, DAC Digital Mixer R Source*/
21638c2ecf20Sopenharmony_ci/* MX-2C [6], MX-2C [4]*/
21648c2ecf20Sopenharmony_cistatic const char * const rt5659_dig_dac_mix_src[] = {
21658c2ecf20Sopenharmony_ci	"Stereo DAC Mixer", "Mono DAC Mixer"
21668c2ecf20Sopenharmony_ci};
21678c2ecf20Sopenharmony_ci
21688c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21698c2ecf20Sopenharmony_ci	rt5659_dig_dac_mixl_enum, RT5659_DIG_MIXER,
21708c2ecf20Sopenharmony_ci	RT5659_DAC_MIX_L_SFT, rt5659_dig_dac_mix_src);
21718c2ecf20Sopenharmony_ci
21728c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_dig_dac_mixl_mux =
21738c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("DAC Digital Mixer L Source", rt5659_dig_dac_mixl_enum);
21748c2ecf20Sopenharmony_ci
21758c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21768c2ecf20Sopenharmony_ci	rt5659_dig_dac_mixr_enum, RT5659_DIG_MIXER,
21778c2ecf20Sopenharmony_ci	RT5659_DAC_MIX_R_SFT, rt5659_dig_dac_mix_src);
21788c2ecf20Sopenharmony_ci
21798c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_dig_dac_mixr_mux =
21808c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("DAC Digital Mixer R Source", rt5659_dig_dac_mixr_enum);
21818c2ecf20Sopenharmony_ci
21828c2ecf20Sopenharmony_ci/* Analog DAC L1 Source, Analog DAC R1 Source*/
21838c2ecf20Sopenharmony_ci/* MX-2D [3], MX-2D [2]*/
21848c2ecf20Sopenharmony_cistatic const char * const rt5659_alg_dac1_src[] = {
21858c2ecf20Sopenharmony_ci	"DAC", "Stereo DAC Mixer"
21868c2ecf20Sopenharmony_ci};
21878c2ecf20Sopenharmony_ci
21888c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21898c2ecf20Sopenharmony_ci	rt5659_alg_dac_l1_enum, RT5659_A_DAC_MUX,
21908c2ecf20Sopenharmony_ci	RT5659_A_DACL1_SFT, rt5659_alg_dac1_src);
21918c2ecf20Sopenharmony_ci
21928c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_alg_dac_l1_mux =
21938c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Analog DACL1 Source", rt5659_alg_dac_l1_enum);
21948c2ecf20Sopenharmony_ci
21958c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
21968c2ecf20Sopenharmony_ci	rt5659_alg_dac_r1_enum, RT5659_A_DAC_MUX,
21978c2ecf20Sopenharmony_ci	RT5659_A_DACR1_SFT, rt5659_alg_dac1_src);
21988c2ecf20Sopenharmony_ci
21998c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_alg_dac_r1_mux =
22008c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Analog DACR1 Source", rt5659_alg_dac_r1_enum);
22018c2ecf20Sopenharmony_ci
22028c2ecf20Sopenharmony_ci/* Analog DAC LR Source, Analog DAC R2 Source*/
22038c2ecf20Sopenharmony_ci/* MX-2D [1], MX-2D [0]*/
22048c2ecf20Sopenharmony_cistatic const char * const rt5659_alg_dac2_src[] = {
22058c2ecf20Sopenharmony_ci	"Stereo DAC Mixer", "Mono DAC Mixer"
22068c2ecf20Sopenharmony_ci};
22078c2ecf20Sopenharmony_ci
22088c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
22098c2ecf20Sopenharmony_ci	rt5659_alg_dac_l2_enum, RT5659_A_DAC_MUX,
22108c2ecf20Sopenharmony_ci	RT5659_A_DACL2_SFT, rt5659_alg_dac2_src);
22118c2ecf20Sopenharmony_ci
22128c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_alg_dac_l2_mux =
22138c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Analog DAC L2 Source", rt5659_alg_dac_l2_enum);
22148c2ecf20Sopenharmony_ci
22158c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
22168c2ecf20Sopenharmony_ci	rt5659_alg_dac_r2_enum, RT5659_A_DAC_MUX,
22178c2ecf20Sopenharmony_ci	RT5659_A_DACR2_SFT, rt5659_alg_dac2_src);
22188c2ecf20Sopenharmony_ci
22198c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_alg_dac_r2_mux =
22208c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("Analog DAC R2 Source", rt5659_alg_dac_r2_enum);
22218c2ecf20Sopenharmony_ci
22228c2ecf20Sopenharmony_ci/* Interface2 ADC Data Input*/
22238c2ecf20Sopenharmony_ci/* MX-2F [13:12] */
22248c2ecf20Sopenharmony_cistatic const char * const rt5659_if2_adc_in_src[] = {
22258c2ecf20Sopenharmony_ci	"IF_ADC1", "IF_ADC2", "DAC_REF", "IF_ADC3"
22268c2ecf20Sopenharmony_ci};
22278c2ecf20Sopenharmony_ci
22288c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
22298c2ecf20Sopenharmony_ci	rt5659_if2_adc_in_enum, RT5659_DIG_INF23_DATA,
22308c2ecf20Sopenharmony_ci	RT5659_IF2_ADC_IN_SFT, rt5659_if2_adc_in_src);
22318c2ecf20Sopenharmony_ci
22328c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if2_adc_in_mux =
22338c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF2 ADC IN Source", rt5659_if2_adc_in_enum);
22348c2ecf20Sopenharmony_ci
22358c2ecf20Sopenharmony_ci/* Interface3 ADC Data Input*/
22368c2ecf20Sopenharmony_ci/* MX-2F [1:0] */
22378c2ecf20Sopenharmony_cistatic const char * const rt5659_if3_adc_in_src[] = {
22388c2ecf20Sopenharmony_ci	"IF_ADC1", "IF_ADC2", "DAC_REF", "Stereo2_ADC_L/R"
22398c2ecf20Sopenharmony_ci};
22408c2ecf20Sopenharmony_ci
22418c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
22428c2ecf20Sopenharmony_ci	rt5659_if3_adc_in_enum, RT5659_DIG_INF23_DATA,
22438c2ecf20Sopenharmony_ci	RT5659_IF3_ADC_IN_SFT, rt5659_if3_adc_in_src);
22448c2ecf20Sopenharmony_ci
22458c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_if3_adc_in_mux =
22468c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("IF3 ADC IN Source", rt5659_if3_adc_in_enum);
22478c2ecf20Sopenharmony_ci
22488c2ecf20Sopenharmony_ci/* PDM 1 L/R*/
22498c2ecf20Sopenharmony_ci/* MX-31 [15] [13] */
22508c2ecf20Sopenharmony_cistatic const char * const rt5659_pdm_src[] = {
22518c2ecf20Sopenharmony_ci	"Mono DAC", "Stereo DAC"
22528c2ecf20Sopenharmony_ci};
22538c2ecf20Sopenharmony_ci
22548c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
22558c2ecf20Sopenharmony_ci	rt5659_pdm_l_enum, RT5659_PDM_OUT_CTRL,
22568c2ecf20Sopenharmony_ci	RT5659_PDM1_L_SFT, rt5659_pdm_src);
22578c2ecf20Sopenharmony_ci
22588c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_pdm_l_mux =
22598c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("PDM L Source", rt5659_pdm_l_enum);
22608c2ecf20Sopenharmony_ci
22618c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
22628c2ecf20Sopenharmony_ci	rt5659_pdm_r_enum, RT5659_PDM_OUT_CTRL,
22638c2ecf20Sopenharmony_ci	RT5659_PDM1_R_SFT, rt5659_pdm_src);
22648c2ecf20Sopenharmony_ci
22658c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_pdm_r_mux =
22668c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("PDM R Source", rt5659_pdm_r_enum);
22678c2ecf20Sopenharmony_ci
22688c2ecf20Sopenharmony_ci/* SPDIF Output source*/
22698c2ecf20Sopenharmony_ci/* MX-36 [1:0] */
22708c2ecf20Sopenharmony_cistatic const char * const rt5659_spdif_src[] = {
22718c2ecf20Sopenharmony_ci	"IF1_DAC1", "IF1_DAC2", "IF2_DAC", "IF3_DAC"
22728c2ecf20Sopenharmony_ci};
22738c2ecf20Sopenharmony_ci
22748c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
22758c2ecf20Sopenharmony_ci	rt5659_spdif_enum, RT5659_SPDIF_CTRL,
22768c2ecf20Sopenharmony_ci	RT5659_SPDIF_SEL_SFT, rt5659_spdif_src);
22778c2ecf20Sopenharmony_ci
22788c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_spdif_mux =
22798c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("SPDIF Source", rt5659_spdif_enum);
22808c2ecf20Sopenharmony_ci
22818c2ecf20Sopenharmony_ci/* I2S1 TDM ADCDAT Source */
22828c2ecf20Sopenharmony_ci/* MX-78[4:0] */
22838c2ecf20Sopenharmony_cistatic const char * const rt5659_rx_adc_data_src[] = {
22848c2ecf20Sopenharmony_ci	"AD1:AD2:DAC:NUL", "AD1:AD2:NUL:DAC", "AD1:DAC:AD2:NUL",
22858c2ecf20Sopenharmony_ci	"AD1:DAC:NUL:AD2", "AD1:NUL:DAC:AD2", "AD1:NUL:AD2:DAC",
22868c2ecf20Sopenharmony_ci	"AD2:AD1:DAC:NUL", "AD2:AD1:NUL:DAC", "AD2:DAC:AD1:NUL",
22878c2ecf20Sopenharmony_ci	"AD2:DAC:NUL:AD1", "AD2:NUL:DAC:AD1", "AD1:NUL:AD1:DAC",
22888c2ecf20Sopenharmony_ci	"DAC:AD1:AD2:NUL", "DAC:AD1:NUL:AD2", "DAC:AD2:AD1:NUL",
22898c2ecf20Sopenharmony_ci	"DAC:AD2:NUL:AD1", "DAC:NUL:DAC:AD2", "DAC:NUL:AD2:DAC",
22908c2ecf20Sopenharmony_ci	"NUL:AD1:AD2:DAC", "NUL:AD1:DAC:AD2", "NUL:AD2:AD1:DAC",
22918c2ecf20Sopenharmony_ci	"NUL:AD2:DAC:AD1", "NUL:DAC:DAC:AD2", "NUL:DAC:AD2:DAC"
22928c2ecf20Sopenharmony_ci};
22938c2ecf20Sopenharmony_ci
22948c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(
22958c2ecf20Sopenharmony_ci	rt5659_rx_adc_data_enum, RT5659_TDM_CTRL_2,
22968c2ecf20Sopenharmony_ci	RT5659_ADCDAT_SRC_SFT, rt5659_rx_adc_data_src);
22978c2ecf20Sopenharmony_ci
22988c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5659_rx_adc_dac_mux =
22998c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("TDM ADCDAT Source", rt5659_rx_adc_data_enum);
23008c2ecf20Sopenharmony_ci
23018c2ecf20Sopenharmony_ci/* Out Volume Switch */
23028c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new spkvol_l_switch =
23038c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_SPO_VOL, RT5659_VOL_L_SFT, 1, 1);
23048c2ecf20Sopenharmony_ci
23058c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new spkvol_r_switch =
23068c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_SPO_VOL, RT5659_VOL_R_SFT, 1, 1);
23078c2ecf20Sopenharmony_ci
23088c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new monovol_switch =
23098c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_MONO_OUT, RT5659_VOL_L_SFT, 1, 1);
23108c2ecf20Sopenharmony_ci
23118c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new outvol_l_switch =
23128c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_LOUT, RT5659_VOL_L_SFT, 1, 1);
23138c2ecf20Sopenharmony_ci
23148c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new outvol_r_switch =
23158c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_LOUT, RT5659_VOL_R_SFT, 1, 1);
23168c2ecf20Sopenharmony_ci
23178c2ecf20Sopenharmony_ci/* Out Switch */
23188c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new spo_switch =
23198c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_CLASSD_2, RT5659_M_RF_DIG_SFT, 1, 1);
23208c2ecf20Sopenharmony_ci
23218c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mono_switch =
23228c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_MONO_OUT, RT5659_L_MUTE_SFT, 1, 1);
23238c2ecf20Sopenharmony_ci
23248c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new hpo_l_switch =
23258c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_HP_VOL, RT5659_L_MUTE_SFT, 1, 1);
23268c2ecf20Sopenharmony_ci
23278c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new hpo_r_switch =
23288c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_HP_VOL, RT5659_R_MUTE_SFT, 1, 1);
23298c2ecf20Sopenharmony_ci
23308c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new lout_l_switch =
23318c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_LOUT, RT5659_L_MUTE_SFT, 1, 1);
23328c2ecf20Sopenharmony_ci
23338c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new lout_r_switch =
23348c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_LOUT, RT5659_R_MUTE_SFT, 1, 1);
23358c2ecf20Sopenharmony_ci
23368c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new pdm_l_switch =
23378c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_PDM_OUT_CTRL, RT5659_M_PDM1_L_SFT, 1,
23388c2ecf20Sopenharmony_ci		1);
23398c2ecf20Sopenharmony_ci
23408c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new pdm_r_switch =
23418c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Switch", RT5659_PDM_OUT_CTRL, RT5659_M_PDM1_R_SFT, 1,
23428c2ecf20Sopenharmony_ci		1);
23438c2ecf20Sopenharmony_ci
23448c2ecf20Sopenharmony_cistatic int rt5659_spk_event(struct snd_soc_dapm_widget *w,
23458c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol, int event)
23468c2ecf20Sopenharmony_ci{
23478c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
23488c2ecf20Sopenharmony_ci
23498c2ecf20Sopenharmony_ci	switch (event) {
23508c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_PRE_PMU:
23518c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_CLASSD_CTRL_1,
23528c2ecf20Sopenharmony_ci			RT5659_POW_CLSD_DB_MASK, RT5659_POW_CLSD_DB_EN);
23538c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_CLASSD_2,
23548c2ecf20Sopenharmony_ci			RT5659_M_RI_DIG, RT5659_M_RI_DIG);
23558c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_CLASSD_1, 0x0803);
23568c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_SPK_DC_CAILB_CTRL_3, 0x0000);
23578c2ecf20Sopenharmony_ci		break;
23588c2ecf20Sopenharmony_ci
23598c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMD:
23608c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_CLASSD_1, 0x0011);
23618c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_CLASSD_2,
23628c2ecf20Sopenharmony_ci			RT5659_M_RI_DIG, 0x0);
23638c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_SPK_DC_CAILB_CTRL_3, 0x0003);
23648c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_CLASSD_CTRL_1,
23658c2ecf20Sopenharmony_ci			RT5659_POW_CLSD_DB_MASK, RT5659_POW_CLSD_DB_DIS);
23668c2ecf20Sopenharmony_ci		break;
23678c2ecf20Sopenharmony_ci
23688c2ecf20Sopenharmony_ci	default:
23698c2ecf20Sopenharmony_ci		return 0;
23708c2ecf20Sopenharmony_ci	}
23718c2ecf20Sopenharmony_ci
23728c2ecf20Sopenharmony_ci	return 0;
23738c2ecf20Sopenharmony_ci
23748c2ecf20Sopenharmony_ci}
23758c2ecf20Sopenharmony_ci
23768c2ecf20Sopenharmony_cistatic int rt5659_mono_event(struct snd_soc_dapm_widget *w,
23778c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol, int event)
23788c2ecf20Sopenharmony_ci{
23798c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
23808c2ecf20Sopenharmony_ci
23818c2ecf20Sopenharmony_ci	switch (event) {
23828c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_PRE_PMU:
23838c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e00);
23848c2ecf20Sopenharmony_ci		break;
23858c2ecf20Sopenharmony_ci
23868c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMD:
23878c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e04);
23888c2ecf20Sopenharmony_ci		break;
23898c2ecf20Sopenharmony_ci
23908c2ecf20Sopenharmony_ci	default:
23918c2ecf20Sopenharmony_ci		return 0;
23928c2ecf20Sopenharmony_ci	}
23938c2ecf20Sopenharmony_ci
23948c2ecf20Sopenharmony_ci	return 0;
23958c2ecf20Sopenharmony_ci
23968c2ecf20Sopenharmony_ci}
23978c2ecf20Sopenharmony_ci
23988c2ecf20Sopenharmony_cistatic int rt5659_hp_event(struct snd_soc_dapm_widget *w,
23998c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol, int event)
24008c2ecf20Sopenharmony_ci{
24018c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
24028c2ecf20Sopenharmony_ci
24038c2ecf20Sopenharmony_ci	switch (event) {
24048c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMU:
24058c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_HP_CHARGE_PUMP_1, 0x0e1e);
24068c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_DEPOP_1, 0x0010, 0x0010);
24078c2ecf20Sopenharmony_ci		break;
24088c2ecf20Sopenharmony_ci
24098c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_PRE_PMD:
24108c2ecf20Sopenharmony_ci		snd_soc_component_write(component, RT5659_DEPOP_1, 0x0000);
24118c2ecf20Sopenharmony_ci		break;
24128c2ecf20Sopenharmony_ci
24138c2ecf20Sopenharmony_ci	default:
24148c2ecf20Sopenharmony_ci		return 0;
24158c2ecf20Sopenharmony_ci	}
24168c2ecf20Sopenharmony_ci
24178c2ecf20Sopenharmony_ci	return 0;
24188c2ecf20Sopenharmony_ci}
24198c2ecf20Sopenharmony_ci
24208c2ecf20Sopenharmony_cistatic int set_dmic_power(struct snd_soc_dapm_widget *w,
24218c2ecf20Sopenharmony_ci	struct snd_kcontrol *kcontrol, int event)
24228c2ecf20Sopenharmony_ci{
24238c2ecf20Sopenharmony_ci	switch (event) {
24248c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMU:
24258c2ecf20Sopenharmony_ci		/*Add delay to avoid pop noise*/
24268c2ecf20Sopenharmony_ci		msleep(450);
24278c2ecf20Sopenharmony_ci		break;
24288c2ecf20Sopenharmony_ci
24298c2ecf20Sopenharmony_ci	default:
24308c2ecf20Sopenharmony_ci		return 0;
24318c2ecf20Sopenharmony_ci	}
24328c2ecf20Sopenharmony_ci
24338c2ecf20Sopenharmony_ci	return 0;
24348c2ecf20Sopenharmony_ci}
24358c2ecf20Sopenharmony_ci
24368c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget rt5659_particular_dapm_widgets[] = {
24378c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("LDO2", RT5659_PWR_ANLG_3, RT5659_PWR_LDO2_BIT, 0,
24388c2ecf20Sopenharmony_ci		NULL, 0),
24398c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT,
24408c2ecf20Sopenharmony_ci		0, NULL, 0),
24418c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5659_PWR_VOL,
24428c2ecf20Sopenharmony_ci		RT5659_PWR_MIC_DET_BIT, 0, NULL, 0),
24438c2ecf20Sopenharmony_ci};
24448c2ecf20Sopenharmony_ci
24458c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = {
24468c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0,
24478c2ecf20Sopenharmony_ci		NULL, 0),
24488c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("Mono Vref", RT5659_PWR_ANLG_1,
24498c2ecf20Sopenharmony_ci		RT5659_PWR_VREF3_BIT, 0, NULL, 0),
24508c2ecf20Sopenharmony_ci
24518c2ecf20Sopenharmony_ci	/* ASRC */
24528c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5659_ASRC_1,
24538c2ecf20Sopenharmony_ci		RT5659_I2S1_ASRC_SFT, 0, NULL, 0),
24548c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5659_ASRC_1,
24558c2ecf20Sopenharmony_ci		RT5659_I2S2_ASRC_SFT, 0, NULL, 0),
24568c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5659_ASRC_1,
24578c2ecf20Sopenharmony_ci		RT5659_I2S3_ASRC_SFT, 0, NULL, 0),
24588c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5659_ASRC_1,
24598c2ecf20Sopenharmony_ci		RT5659_DAC_STO_ASRC_SFT, 0, NULL, 0),
24608c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("DAC Mono L ASRC", 1, RT5659_ASRC_1,
24618c2ecf20Sopenharmony_ci		RT5659_DAC_MONO_L_ASRC_SFT, 0, NULL, 0),
24628c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("DAC Mono R ASRC", 1, RT5659_ASRC_1,
24638c2ecf20Sopenharmony_ci		RT5659_DAC_MONO_R_ASRC_SFT, 0, NULL, 0),
24648c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5659_ASRC_1,
24658c2ecf20Sopenharmony_ci		RT5659_ADC_STO1_ASRC_SFT, 0, NULL, 0),
24668c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("ADC Mono L ASRC", 1, RT5659_ASRC_1,
24678c2ecf20Sopenharmony_ci		RT5659_ADC_MONO_L_ASRC_SFT, 0, NULL, 0),
24688c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("ADC Mono R ASRC", 1, RT5659_ASRC_1,
24698c2ecf20Sopenharmony_ci		RT5659_ADC_MONO_R_ASRC_SFT, 0, NULL, 0),
24708c2ecf20Sopenharmony_ci
24718c2ecf20Sopenharmony_ci	/* Input Side */
24728c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("MICBIAS2", RT5659_PWR_ANLG_2, RT5659_PWR_MB2_BIT,
24738c2ecf20Sopenharmony_ci		0, NULL, 0),
24748c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("MICBIAS3", RT5659_PWR_ANLG_2, RT5659_PWR_MB3_BIT,
24758c2ecf20Sopenharmony_ci		0, NULL, 0),
24768c2ecf20Sopenharmony_ci
24778c2ecf20Sopenharmony_ci	/* Input Lines */
24788c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("DMIC L1"),
24798c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("DMIC R1"),
24808c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("DMIC L2"),
24818c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("DMIC R2"),
24828c2ecf20Sopenharmony_ci
24838c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN1P"),
24848c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN1N"),
24858c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN2P"),
24868c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN2N"),
24878c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN3P"),
24888c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN3N"),
24898c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN4P"),
24908c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN4N"),
24918c2ecf20Sopenharmony_ci
24928c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0),
24938c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0),
24948c2ecf20Sopenharmony_ci
24958c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0,
24968c2ecf20Sopenharmony_ci		set_dmic_clk, SND_SOC_DAPM_PRE_PMU),
24978c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DMIC1 Power", RT5659_DMIC_CTRL_1,
24988c2ecf20Sopenharmony_ci		RT5659_DMIC_1_EN_SFT, 0, set_dmic_power, SND_SOC_DAPM_POST_PMU),
24998c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DMIC2 Power", RT5659_DMIC_CTRL_1,
25008c2ecf20Sopenharmony_ci		RT5659_DMIC_2_EN_SFT, 0, set_dmic_power, SND_SOC_DAPM_POST_PMU),
25018c2ecf20Sopenharmony_ci
25028c2ecf20Sopenharmony_ci	/* Boost */
25038c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("BST1", RT5659_PWR_ANLG_2,
25048c2ecf20Sopenharmony_ci		RT5659_PWR_BST1_P_BIT, 0, NULL, 0),
25058c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("BST2", RT5659_PWR_ANLG_2,
25068c2ecf20Sopenharmony_ci		RT5659_PWR_BST2_P_BIT, 0, NULL, 0),
25078c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("BST3", RT5659_PWR_ANLG_2,
25088c2ecf20Sopenharmony_ci		RT5659_PWR_BST3_P_BIT, 0, NULL, 0),
25098c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("BST4", RT5659_PWR_ANLG_2,
25108c2ecf20Sopenharmony_ci		RT5659_PWR_BST4_P_BIT, 0, NULL, 0),
25118c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("BST1 Power", RT5659_PWR_ANLG_2,
25128c2ecf20Sopenharmony_ci		RT5659_PWR_BST1_BIT, 0, NULL, 0),
25138c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("BST2 Power", RT5659_PWR_ANLG_2,
25148c2ecf20Sopenharmony_ci		RT5659_PWR_BST2_BIT, 0, NULL, 0),
25158c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("BST3 Power", RT5659_PWR_ANLG_2,
25168c2ecf20Sopenharmony_ci		RT5659_PWR_BST3_BIT, 0, NULL, 0),
25178c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("BST4 Power", RT5659_PWR_ANLG_2,
25188c2ecf20Sopenharmony_ci		RT5659_PWR_BST4_BIT, 0, NULL, 0),
25198c2ecf20Sopenharmony_ci
25208c2ecf20Sopenharmony_ci
25218c2ecf20Sopenharmony_ci	/* Input Volume */
25228c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("INL VOL", RT5659_PWR_VOL, RT5659_PWR_IN_L_BIT,
25238c2ecf20Sopenharmony_ci		0, NULL, 0),
25248c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("INR VOL", RT5659_PWR_VOL, RT5659_PWR_IN_R_BIT,
25258c2ecf20Sopenharmony_ci		0, NULL, 0),
25268c2ecf20Sopenharmony_ci
25278c2ecf20Sopenharmony_ci	/* REC Mixer */
25288c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("RECMIX1L", RT5659_PWR_MIXER, RT5659_PWR_RM1_L_BIT,
25298c2ecf20Sopenharmony_ci		0, rt5659_rec1_l_mix, ARRAY_SIZE(rt5659_rec1_l_mix)),
25308c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("RECMIX1R", RT5659_PWR_MIXER, RT5659_PWR_RM1_R_BIT,
25318c2ecf20Sopenharmony_ci		0, rt5659_rec1_r_mix, ARRAY_SIZE(rt5659_rec1_r_mix)),
25328c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("RECMIX2L", RT5659_PWR_MIXER, RT5659_PWR_RM2_L_BIT,
25338c2ecf20Sopenharmony_ci		0, rt5659_rec2_l_mix, ARRAY_SIZE(rt5659_rec2_l_mix)),
25348c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("RECMIX2R", RT5659_PWR_MIXER, RT5659_PWR_RM2_R_BIT,
25358c2ecf20Sopenharmony_ci		0, rt5659_rec2_r_mix, ARRAY_SIZE(rt5659_rec2_r_mix)),
25368c2ecf20Sopenharmony_ci
25378c2ecf20Sopenharmony_ci	/* ADCs */
25388c2ecf20Sopenharmony_ci	SND_SOC_DAPM_ADC("ADC1 L", NULL, SND_SOC_NOPM, 0, 0),
25398c2ecf20Sopenharmony_ci	SND_SOC_DAPM_ADC("ADC1 R", NULL, SND_SOC_NOPM, 0, 0),
25408c2ecf20Sopenharmony_ci	SND_SOC_DAPM_ADC("ADC2 L", NULL, SND_SOC_NOPM, 0, 0),
25418c2ecf20Sopenharmony_ci	SND_SOC_DAPM_ADC("ADC2 R", NULL, SND_SOC_NOPM, 0, 0),
25428c2ecf20Sopenharmony_ci
25438c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC1 L Power", RT5659_PWR_DIG_1,
25448c2ecf20Sopenharmony_ci		RT5659_PWR_ADC_L1_BIT, 0, NULL, 0),
25458c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC1 R Power", RT5659_PWR_DIG_1,
25468c2ecf20Sopenharmony_ci		RT5659_PWR_ADC_R1_BIT, 0, NULL, 0),
25478c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC2 L Power", RT5659_PWR_DIG_1,
25488c2ecf20Sopenharmony_ci		RT5659_PWR_ADC_L2_BIT, 0, NULL, 0),
25498c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC2 R Power", RT5659_PWR_DIG_1,
25508c2ecf20Sopenharmony_ci		RT5659_PWR_ADC_R2_BIT, 0, NULL, 0),
25518c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC1 clock", SND_SOC_NOPM, 0, 0, set_adc1_clk,
25528c2ecf20Sopenharmony_ci		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
25538c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC2 clock", SND_SOC_NOPM, 0, 0, set_adc2_clk,
25548c2ecf20Sopenharmony_ci		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
25558c2ecf20Sopenharmony_ci
25568c2ecf20Sopenharmony_ci	/* ADC Mux */
25578c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Stereo1 DMIC L Mux", SND_SOC_NOPM, 0, 0,
25588c2ecf20Sopenharmony_ci		&rt5659_sto1_dmic_mux),
25598c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Stereo1 DMIC R Mux", SND_SOC_NOPM, 0, 0,
25608c2ecf20Sopenharmony_ci		&rt5659_sto1_dmic_mux),
25618c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM, 0, 0,
25628c2ecf20Sopenharmony_ci		&rt5659_sto1_adc1_mux),
25638c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM, 0, 0,
25648c2ecf20Sopenharmony_ci		&rt5659_sto1_adc1_mux),
25658c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM, 0, 0,
25668c2ecf20Sopenharmony_ci		&rt5659_sto1_adc2_mux),
25678c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM, 0, 0,
25688c2ecf20Sopenharmony_ci		&rt5659_sto1_adc2_mux),
25698c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Stereo1 ADC L Mux", SND_SOC_NOPM, 0, 0,
25708c2ecf20Sopenharmony_ci		&rt5659_sto1_adc_mux),
25718c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Stereo1 ADC R Mux", SND_SOC_NOPM, 0, 0,
25728c2ecf20Sopenharmony_ci		&rt5659_sto1_adc_mux),
25738c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0,
25748c2ecf20Sopenharmony_ci		&rt5659_mono_adc_l2_mux),
25758c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0,
25768c2ecf20Sopenharmony_ci		&rt5659_mono_adc_r2_mux),
25778c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0,
25788c2ecf20Sopenharmony_ci		&rt5659_mono_adc_l1_mux),
25798c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0,
25808c2ecf20Sopenharmony_ci		&rt5659_mono_adc_r1_mux),
25818c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
25828c2ecf20Sopenharmony_ci		&rt5659_mono_dmic_l_mux),
25838c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
25848c2ecf20Sopenharmony_ci		&rt5659_mono_dmic_r_mux),
25858c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Mono ADC L Mux", SND_SOC_NOPM, 0, 0,
25868c2ecf20Sopenharmony_ci		&rt5659_mono_adc_l_mux),
25878c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("Mono ADC R Mux", SND_SOC_NOPM, 0, 0,
25888c2ecf20Sopenharmony_ci		&rt5659_mono_adc_r_mux),
25898c2ecf20Sopenharmony_ci	/* ADC Mixer */
25908c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC Stereo1 Filter", RT5659_PWR_DIG_2,
25918c2ecf20Sopenharmony_ci		RT5659_PWR_ADC_S1F_BIT, 0, NULL, 0),
25928c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC Stereo2 Filter", RT5659_PWR_DIG_2,
25938c2ecf20Sopenharmony_ci		RT5659_PWR_ADC_S2F_BIT, 0, NULL, 0),
25948c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Stereo1 ADC MIXL", SND_SOC_NOPM,
25958c2ecf20Sopenharmony_ci		0, 0, rt5659_sto1_adc_l_mix,
25968c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_sto1_adc_l_mix)),
25978c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Stereo1 ADC MIXR", SND_SOC_NOPM,
25988c2ecf20Sopenharmony_ci		0, 0, rt5659_sto1_adc_r_mix,
25998c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_sto1_adc_r_mix)),
26008c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5659_PWR_DIG_2,
26018c2ecf20Sopenharmony_ci		RT5659_PWR_ADC_MF_L_BIT, 0, NULL, 0),
26028c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5659_MONO_ADC_DIG_VOL,
26038c2ecf20Sopenharmony_ci		RT5659_L_MUTE_SFT, 1, rt5659_mono_adc_l_mix,
26048c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_mono_adc_l_mix)),
26058c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5659_PWR_DIG_2,
26068c2ecf20Sopenharmony_ci		RT5659_PWR_ADC_MF_R_BIT, 0, NULL, 0),
26078c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5659_MONO_ADC_DIG_VOL,
26088c2ecf20Sopenharmony_ci		RT5659_R_MUTE_SFT, 1, rt5659_mono_adc_r_mix,
26098c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_mono_adc_r_mix)),
26108c2ecf20Sopenharmony_ci
26118c2ecf20Sopenharmony_ci	/* ADC PGA */
26128c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
26138c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
26148c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
26158c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
26168c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
26178c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
26188c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1_ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
26198c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("Stereo2 ADC LR", SND_SOC_NOPM, 0, 0, NULL, 0),
26208c2ecf20Sopenharmony_ci
26218c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("Stereo1 ADC Volume L", RT5659_STO1_ADC_DIG_VOL,
26228c2ecf20Sopenharmony_ci		RT5659_L_MUTE_SFT, 1, NULL, 0),
26238c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("Stereo1 ADC Volume R", RT5659_STO1_ADC_DIG_VOL,
26248c2ecf20Sopenharmony_ci		RT5659_R_MUTE_SFT, 1, NULL, 0),
26258c2ecf20Sopenharmony_ci
26268c2ecf20Sopenharmony_ci	/* Digital Interface */
26278c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("I2S1", RT5659_PWR_DIG_1, RT5659_PWR_I2S1_BIT,
26288c2ecf20Sopenharmony_ci		0, NULL, 0),
26298c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
26308c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
26318c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 DAC1 L", SND_SOC_NOPM, 0, 0, NULL, 0),
26328c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 DAC1 R", SND_SOC_NOPM, 0, 0, NULL, 0),
26338c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 DAC2 L", SND_SOC_NOPM, 0, 0, NULL, 0),
26348c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 DAC2 R", SND_SOC_NOPM, 0, 0, NULL, 0),
26358c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
26368c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
26378c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF1 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
26388c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("I2S2", RT5659_PWR_DIG_1, RT5659_PWR_I2S2_BIT, 0,
26398c2ecf20Sopenharmony_ci		NULL, 0),
26408c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF2 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
26418c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF2 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
26428c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF2 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
26438c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
26448c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
26458c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
26468c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("I2S3", RT5659_PWR_DIG_1, RT5659_PWR_I2S3_BIT, 0,
26478c2ecf20Sopenharmony_ci		NULL, 0),
26488c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
26498c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
26508c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
26518c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
26528c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
26538c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
26548c2ecf20Sopenharmony_ci
26558c2ecf20Sopenharmony_ci	/* Digital Interface Select */
26568c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("TDM AD1:AD2:DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
26578c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("TDM AD2:DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
26588c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("TDM Data Mux", SND_SOC_NOPM, 0, 0,
26598c2ecf20Sopenharmony_ci		&rt5659_rx_adc_dac_mux),
26608c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF2 ADC Mux", SND_SOC_NOPM, 0, 0,
26618c2ecf20Sopenharmony_ci		&rt5659_if2_adc_in_mux),
26628c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0,
26638c2ecf20Sopenharmony_ci		&rt5659_if3_adc_in_mux),
26648c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF1 01 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
26658c2ecf20Sopenharmony_ci			&rt5659_if1_01_adc_swap_mux),
26668c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF1 23 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
26678c2ecf20Sopenharmony_ci			&rt5659_if1_23_adc_swap_mux),
26688c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF1 45 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
26698c2ecf20Sopenharmony_ci			&rt5659_if1_45_adc_swap_mux),
26708c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF1 67 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
26718c2ecf20Sopenharmony_ci			&rt5659_if1_67_adc_swap_mux),
26728c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF2 DAC Swap Mux", SND_SOC_NOPM, 0, 0,
26738c2ecf20Sopenharmony_ci			&rt5659_if2_dac_swap_mux),
26748c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF2 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
26758c2ecf20Sopenharmony_ci			&rt5659_if2_adc_swap_mux),
26768c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF3 DAC Swap Mux", SND_SOC_NOPM, 0, 0,
26778c2ecf20Sopenharmony_ci			&rt5659_if3_dac_swap_mux),
26788c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("IF3 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
26798c2ecf20Sopenharmony_ci			&rt5659_if3_adc_swap_mux),
26808c2ecf20Sopenharmony_ci
26818c2ecf20Sopenharmony_ci	/* Audio Interface */
26828c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
26838c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
26848c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
26858c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
26868c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
26878c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
26888c2ecf20Sopenharmony_ci
26898c2ecf20Sopenharmony_ci	/* Output Side */
26908c2ecf20Sopenharmony_ci	/* DAC mixer before sound effect  */
26918c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0,
26928c2ecf20Sopenharmony_ci		rt5659_dac_l_mix, ARRAY_SIZE(rt5659_dac_l_mix)),
26938c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0,
26948c2ecf20Sopenharmony_ci		rt5659_dac_r_mix, ARRAY_SIZE(rt5659_dac_r_mix)),
26958c2ecf20Sopenharmony_ci
26968c2ecf20Sopenharmony_ci	/* DAC channel Mux */
26978c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC L1 Mux", SND_SOC_NOPM, 0, 0, &rt5659_dac_l1_mux),
26988c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC R1 Mux", SND_SOC_NOPM, 0, 0, &rt5659_dac_r1_mux),
26998c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM, 0, 0, &rt5659_dac_l2_mux),
27008c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM, 0, 0, &rt5659_dac_r2_mux),
27018c2ecf20Sopenharmony_ci
27028c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC L1 Source", SND_SOC_NOPM, 0, 0,
27038c2ecf20Sopenharmony_ci		&rt5659_alg_dac_l1_mux),
27048c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC R1 Source", SND_SOC_NOPM, 0, 0,
27058c2ecf20Sopenharmony_ci		&rt5659_alg_dac_r1_mux),
27068c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC L2 Source", SND_SOC_NOPM, 0, 0,
27078c2ecf20Sopenharmony_ci		&rt5659_alg_dac_l2_mux),
27088c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC R2 Source", SND_SOC_NOPM, 0, 0,
27098c2ecf20Sopenharmony_ci		&rt5659_alg_dac_r2_mux),
27108c2ecf20Sopenharmony_ci
27118c2ecf20Sopenharmony_ci	/* DAC Mixer */
27128c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DAC Stereo1 Filter", RT5659_PWR_DIG_2,
27138c2ecf20Sopenharmony_ci		RT5659_PWR_DAC_S1F_BIT, 0, NULL, 0),
27148c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DAC Mono Left Filter", RT5659_PWR_DIG_2,
27158c2ecf20Sopenharmony_ci		RT5659_PWR_DAC_MF_L_BIT, 0, NULL, 0),
27168c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DAC Mono Right Filter", RT5659_PWR_DIG_2,
27178c2ecf20Sopenharmony_ci		RT5659_PWR_DAC_MF_R_BIT, 0, NULL, 0),
27188c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
27198c2ecf20Sopenharmony_ci		rt5659_sto_dac_l_mix, ARRAY_SIZE(rt5659_sto_dac_l_mix)),
27208c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0,
27218c2ecf20Sopenharmony_ci		rt5659_sto_dac_r_mix, ARRAY_SIZE(rt5659_sto_dac_r_mix)),
27228c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
27238c2ecf20Sopenharmony_ci		rt5659_mono_dac_l_mix, ARRAY_SIZE(rt5659_mono_dac_l_mix)),
27248c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
27258c2ecf20Sopenharmony_ci		rt5659_mono_dac_r_mix, ARRAY_SIZE(rt5659_mono_dac_r_mix)),
27268c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC MIXL", SND_SOC_NOPM, 0, 0,
27278c2ecf20Sopenharmony_ci		&rt5659_dig_dac_mixl_mux),
27288c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DAC MIXR", SND_SOC_NOPM, 0, 0,
27298c2ecf20Sopenharmony_ci		&rt5659_dig_dac_mixr_mux),
27308c2ecf20Sopenharmony_ci
27318c2ecf20Sopenharmony_ci	/* DACs */
27328c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("DAC L1 Power", 1, RT5659_PWR_DIG_1,
27338c2ecf20Sopenharmony_ci		RT5659_PWR_DAC_L1_BIT, 0, NULL, 0),
27348c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY_S("DAC R1 Power", 1, RT5659_PWR_DIG_1,
27358c2ecf20Sopenharmony_ci		RT5659_PWR_DAC_R1_BIT, 0, NULL, 0),
27368c2ecf20Sopenharmony_ci	SND_SOC_DAPM_DAC("DAC L1", NULL, SND_SOC_NOPM, 0, 0),
27378c2ecf20Sopenharmony_ci	SND_SOC_DAPM_DAC("DAC R1", NULL, SND_SOC_NOPM, 0, 0),
27388c2ecf20Sopenharmony_ci
27398c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DAC L2 Power", RT5659_PWR_DIG_1,
27408c2ecf20Sopenharmony_ci		RT5659_PWR_DAC_L2_BIT, 0, NULL, 0),
27418c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DAC R2 Power", RT5659_PWR_DIG_1,
27428c2ecf20Sopenharmony_ci		RT5659_PWR_DAC_R2_BIT, 0, NULL, 0),
27438c2ecf20Sopenharmony_ci	SND_SOC_DAPM_DAC("DAC L2", NULL, SND_SOC_NOPM, 0, 0),
27448c2ecf20Sopenharmony_ci	SND_SOC_DAPM_DAC("DAC R2", NULL, SND_SOC_NOPM, 0, 0),
27458c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("DAC_REF", SND_SOC_NOPM, 0, 0, NULL, 0),
27468c2ecf20Sopenharmony_ci
27478c2ecf20Sopenharmony_ci	/* OUT Mixer */
27488c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("SPK MIXL", RT5659_PWR_MIXER, RT5659_PWR_SM_L_BIT,
27498c2ecf20Sopenharmony_ci		0, rt5659_spk_l_mix, ARRAY_SIZE(rt5659_spk_l_mix)),
27508c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("SPK MIXR", RT5659_PWR_MIXER, RT5659_PWR_SM_R_BIT,
27518c2ecf20Sopenharmony_ci		0, rt5659_spk_r_mix, ARRAY_SIZE(rt5659_spk_r_mix)),
27528c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("MONOVOL MIX", RT5659_PWR_MIXER, RT5659_PWR_MM_BIT,
27538c2ecf20Sopenharmony_ci		0, rt5659_monovol_mix, ARRAY_SIZE(rt5659_monovol_mix)),
27548c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("OUT MIXL", RT5659_PWR_MIXER, RT5659_PWR_OM_L_BIT,
27558c2ecf20Sopenharmony_ci		0, rt5659_out_l_mix, ARRAY_SIZE(rt5659_out_l_mix)),
27568c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("OUT MIXR", RT5659_PWR_MIXER, RT5659_PWR_OM_R_BIT,
27578c2ecf20Sopenharmony_ci		0, rt5659_out_r_mix, ARRAY_SIZE(rt5659_out_r_mix)),
27588c2ecf20Sopenharmony_ci
27598c2ecf20Sopenharmony_ci	/* Output Volume */
27608c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("SPKVOL L", RT5659_PWR_VOL, RT5659_PWR_SV_L_BIT, 0,
27618c2ecf20Sopenharmony_ci		&spkvol_l_switch),
27628c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("SPKVOL R", RT5659_PWR_VOL, RT5659_PWR_SV_R_BIT, 0,
27638c2ecf20Sopenharmony_ci		&spkvol_r_switch),
27648c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("MONOVOL", RT5659_PWR_VOL, RT5659_PWR_MV_BIT, 0,
27658c2ecf20Sopenharmony_ci		&monovol_switch),
27668c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("OUTVOL L", RT5659_PWR_VOL, RT5659_PWR_OV_L_BIT, 0,
27678c2ecf20Sopenharmony_ci		&outvol_l_switch),
27688c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("OUTVOL R", RT5659_PWR_VOL, RT5659_PWR_OV_R_BIT, 0,
27698c2ecf20Sopenharmony_ci		&outvol_r_switch),
27708c2ecf20Sopenharmony_ci
27718c2ecf20Sopenharmony_ci	/* SPO/MONO/HPO/LOUT */
27728c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("SPO L MIX", SND_SOC_NOPM, 0, 0, rt5659_spo_l_mix,
27738c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_spo_l_mix)),
27748c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("SPO R MIX", SND_SOC_NOPM, 0, 0, rt5659_spo_r_mix,
27758c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_spo_r_mix)),
27768c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Mono MIX", SND_SOC_NOPM, 0,	0, rt5659_mono_mix,
27778c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_mono_mix)),
27788c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("LOUT L MIX", SND_SOC_NOPM, 0, 0, rt5659_lout_l_mix,
27798c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_lout_l_mix)),
27808c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("LOUT R MIX", SND_SOC_NOPM, 0, 0, rt5659_lout_r_mix,
27818c2ecf20Sopenharmony_ci		ARRAY_SIZE(rt5659_lout_r_mix)),
27828c2ecf20Sopenharmony_ci
27838c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA_S("SPK Amp", 1, RT5659_PWR_DIG_1, RT5659_PWR_CLS_D_BIT,
27848c2ecf20Sopenharmony_ci		0, rt5659_spk_event, SND_SOC_DAPM_POST_PMD |
27858c2ecf20Sopenharmony_ci		SND_SOC_DAPM_PRE_PMU),
27868c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA_S("Mono Amp", 1, RT5659_PWR_ANLG_1, RT5659_PWR_MA_BIT,
27878c2ecf20Sopenharmony_ci		0, rt5659_mono_event, SND_SOC_DAPM_POST_PMD |
27888c2ecf20Sopenharmony_ci		SND_SOC_DAPM_PRE_PMU),
27898c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, rt5659_hp_event,
27908c2ecf20Sopenharmony_ci		SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
27918c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA_S("LOUT Amp", 1,  RT5659_PWR_ANLG_1, RT5659_PWR_LM_BIT,
27928c2ecf20Sopenharmony_ci		0,  NULL, 0),
27938c2ecf20Sopenharmony_ci
27948c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("Charge Pump", SND_SOC_NOPM, 0, 0,
27958c2ecf20Sopenharmony_ci		rt5659_charge_pump_event, SND_SOC_DAPM_PRE_PMU |
27968c2ecf20Sopenharmony_ci		SND_SOC_DAPM_POST_PMD),
27978c2ecf20Sopenharmony_ci
27988c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("SPO Playback", SND_SOC_NOPM, 0, 0, &spo_switch),
27998c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("Mono Playback", SND_SOC_NOPM, 0, 0,
28008c2ecf20Sopenharmony_ci		&mono_switch),
28018c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("HPO L Playback", SND_SOC_NOPM, 0, 0,
28028c2ecf20Sopenharmony_ci		&hpo_l_switch),
28038c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("HPO R Playback", SND_SOC_NOPM, 0, 0,
28048c2ecf20Sopenharmony_ci		&hpo_r_switch),
28058c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("LOUT L Playback", SND_SOC_NOPM, 0, 0,
28068c2ecf20Sopenharmony_ci		&lout_l_switch),
28078c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("LOUT R Playback", SND_SOC_NOPM, 0, 0,
28088c2ecf20Sopenharmony_ci		&lout_r_switch),
28098c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("PDM L Playback", SND_SOC_NOPM, 0, 0,
28108c2ecf20Sopenharmony_ci		&pdm_l_switch),
28118c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SWITCH("PDM R Playback", SND_SOC_NOPM, 0, 0,
28128c2ecf20Sopenharmony_ci		&pdm_r_switch),
28138c2ecf20Sopenharmony_ci
28148c2ecf20Sopenharmony_ci	/* PDM */
28158c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("PDM Power", RT5659_PWR_DIG_2,
28168c2ecf20Sopenharmony_ci		RT5659_PWR_PDM1_BIT, 0, NULL, 0),
28178c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("PDM L Mux", RT5659_PDM_OUT_CTRL,
28188c2ecf20Sopenharmony_ci		RT5659_M_PDM1_L_SFT, 1, &rt5659_pdm_l_mux),
28198c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("PDM R Mux", RT5659_PDM_OUT_CTRL,
28208c2ecf20Sopenharmony_ci		RT5659_M_PDM1_R_SFT, 1, &rt5659_pdm_r_mux),
28218c2ecf20Sopenharmony_ci
28228c2ecf20Sopenharmony_ci	/* SPDIF */
28238c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("SPDIF Mux", SND_SOC_NOPM, 0, 0, &rt5659_spdif_mux),
28248c2ecf20Sopenharmony_ci
28258c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("SYS CLK DET", RT5659_CLK_DET, 3, 0, NULL, 0),
28268c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("CLKDET", RT5659_CLK_DET, 0, 0, NULL, 0),
28278c2ecf20Sopenharmony_ci
28288c2ecf20Sopenharmony_ci	/* Output Lines */
28298c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("HPOL"),
28308c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("HPOR"),
28318c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("SPOL"),
28328c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("SPOR"),
28338c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("LOUTL"),
28348c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("LOUTR"),
28358c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("MONOOUT"),
28368c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("PDML"),
28378c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("PDMR"),
28388c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("SPDIF"),
28398c2ecf20Sopenharmony_ci};
28408c2ecf20Sopenharmony_ci
28418c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route rt5659_dapm_routes[] = {
28428c2ecf20Sopenharmony_ci	/*PLL*/
28438c2ecf20Sopenharmony_ci	{ "ADC Stereo1 Filter", NULL, "PLL", is_sys_clk_from_pll },
28448c2ecf20Sopenharmony_ci	{ "ADC Stereo2 Filter", NULL, "PLL", is_sys_clk_from_pll },
28458c2ecf20Sopenharmony_ci	{ "ADC Mono Left Filter", NULL, "PLL", is_sys_clk_from_pll },
28468c2ecf20Sopenharmony_ci	{ "ADC Mono Right Filter", NULL, "PLL", is_sys_clk_from_pll },
28478c2ecf20Sopenharmony_ci	{ "DAC Stereo1 Filter", NULL, "PLL", is_sys_clk_from_pll },
28488c2ecf20Sopenharmony_ci	{ "DAC Mono Left Filter", NULL, "PLL", is_sys_clk_from_pll },
28498c2ecf20Sopenharmony_ci	{ "DAC Mono Right Filter", NULL, "PLL", is_sys_clk_from_pll },
28508c2ecf20Sopenharmony_ci
28518c2ecf20Sopenharmony_ci	/*ASRC*/
28528c2ecf20Sopenharmony_ci	{ "ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc },
28538c2ecf20Sopenharmony_ci	{ "ADC Mono Left Filter", NULL, "ADC Mono L ASRC", is_using_asrc },
28548c2ecf20Sopenharmony_ci	{ "ADC Mono Right Filter", NULL, "ADC Mono R ASRC", is_using_asrc },
28558c2ecf20Sopenharmony_ci	{ "DAC Mono Left Filter", NULL, "DAC Mono L ASRC", is_using_asrc },
28568c2ecf20Sopenharmony_ci	{ "DAC Mono Right Filter", NULL, "DAC Mono R ASRC", is_using_asrc },
28578c2ecf20Sopenharmony_ci	{ "DAC Stereo1 Filter", NULL, "DAC STO ASRC", is_using_asrc },
28588c2ecf20Sopenharmony_ci
28598c2ecf20Sopenharmony_ci	{ "SYS CLK DET", NULL, "CLKDET" },
28608c2ecf20Sopenharmony_ci
28618c2ecf20Sopenharmony_ci	{ "I2S1", NULL, "I2S1 ASRC" },
28628c2ecf20Sopenharmony_ci	{ "I2S2", NULL, "I2S2 ASRC" },
28638c2ecf20Sopenharmony_ci	{ "I2S3", NULL, "I2S3 ASRC" },
28648c2ecf20Sopenharmony_ci
28658c2ecf20Sopenharmony_ci	{ "DMIC1", NULL, "DMIC L1" },
28668c2ecf20Sopenharmony_ci	{ "DMIC1", NULL, "DMIC R1" },
28678c2ecf20Sopenharmony_ci	{ "DMIC2", NULL, "DMIC L2" },
28688c2ecf20Sopenharmony_ci	{ "DMIC2", NULL, "DMIC R2" },
28698c2ecf20Sopenharmony_ci
28708c2ecf20Sopenharmony_ci	{ "BST1", NULL, "IN1P" },
28718c2ecf20Sopenharmony_ci	{ "BST1", NULL, "IN1N" },
28728c2ecf20Sopenharmony_ci	{ "BST1", NULL, "BST1 Power" },
28738c2ecf20Sopenharmony_ci	{ "BST2", NULL, "IN2P" },
28748c2ecf20Sopenharmony_ci	{ "BST2", NULL, "IN2N" },
28758c2ecf20Sopenharmony_ci	{ "BST2", NULL, "BST2 Power" },
28768c2ecf20Sopenharmony_ci	{ "BST3", NULL, "IN3P" },
28778c2ecf20Sopenharmony_ci	{ "BST3", NULL, "IN3N" },
28788c2ecf20Sopenharmony_ci	{ "BST3", NULL, "BST3 Power" },
28798c2ecf20Sopenharmony_ci	{ "BST4", NULL, "IN4P" },
28808c2ecf20Sopenharmony_ci	{ "BST4", NULL, "IN4N" },
28818c2ecf20Sopenharmony_ci	{ "BST4", NULL, "BST4 Power" },
28828c2ecf20Sopenharmony_ci
28838c2ecf20Sopenharmony_ci	{ "INL VOL", NULL, "IN2P" },
28848c2ecf20Sopenharmony_ci	{ "INR VOL", NULL, "IN2N" },
28858c2ecf20Sopenharmony_ci
28868c2ecf20Sopenharmony_ci	{ "RECMIX1L", "SPKVOLL Switch", "SPKVOL L" },
28878c2ecf20Sopenharmony_ci	{ "RECMIX1L", "INL Switch", "INL VOL" },
28888c2ecf20Sopenharmony_ci	{ "RECMIX1L", "BST4 Switch", "BST4" },
28898c2ecf20Sopenharmony_ci	{ "RECMIX1L", "BST3 Switch", "BST3" },
28908c2ecf20Sopenharmony_ci	{ "RECMIX1L", "BST2 Switch", "BST2" },
28918c2ecf20Sopenharmony_ci	{ "RECMIX1L", "BST1 Switch", "BST1" },
28928c2ecf20Sopenharmony_ci
28938c2ecf20Sopenharmony_ci	{ "RECMIX1R", "HPOVOLR Switch", "HPO R Playback" },
28948c2ecf20Sopenharmony_ci	{ "RECMIX1R", "INR Switch", "INR VOL" },
28958c2ecf20Sopenharmony_ci	{ "RECMIX1R", "BST4 Switch", "BST4" },
28968c2ecf20Sopenharmony_ci	{ "RECMIX1R", "BST3 Switch", "BST3" },
28978c2ecf20Sopenharmony_ci	{ "RECMIX1R", "BST2 Switch", "BST2" },
28988c2ecf20Sopenharmony_ci	{ "RECMIX1R", "BST1 Switch", "BST1" },
28998c2ecf20Sopenharmony_ci
29008c2ecf20Sopenharmony_ci	{ "RECMIX2L", "SPKVOLL Switch", "SPKVOL L" },
29018c2ecf20Sopenharmony_ci	{ "RECMIX2L", "OUTVOLL Switch", "OUTVOL L" },
29028c2ecf20Sopenharmony_ci	{ "RECMIX2L", "BST4 Switch", "BST4" },
29038c2ecf20Sopenharmony_ci	{ "RECMIX2L", "BST3 Switch", "BST3" },
29048c2ecf20Sopenharmony_ci	{ "RECMIX2L", "BST2 Switch", "BST2" },
29058c2ecf20Sopenharmony_ci	{ "RECMIX2L", "BST1 Switch", "BST1" },
29068c2ecf20Sopenharmony_ci
29078c2ecf20Sopenharmony_ci	{ "RECMIX2R", "MONOVOL Switch", "MONOVOL" },
29088c2ecf20Sopenharmony_ci	{ "RECMIX2R", "OUTVOLR Switch", "OUTVOL R" },
29098c2ecf20Sopenharmony_ci	{ "RECMIX2R", "BST4 Switch", "BST4" },
29108c2ecf20Sopenharmony_ci	{ "RECMIX2R", "BST3 Switch", "BST3" },
29118c2ecf20Sopenharmony_ci	{ "RECMIX2R", "BST2 Switch", "BST2" },
29128c2ecf20Sopenharmony_ci	{ "RECMIX2R", "BST1 Switch", "BST1" },
29138c2ecf20Sopenharmony_ci
29148c2ecf20Sopenharmony_ci	{ "ADC1 L", NULL, "RECMIX1L" },
29158c2ecf20Sopenharmony_ci	{ "ADC1 L", NULL, "ADC1 L Power" },
29168c2ecf20Sopenharmony_ci	{ "ADC1 L", NULL, "ADC1 clock" },
29178c2ecf20Sopenharmony_ci	{ "ADC1 R", NULL, "RECMIX1R" },
29188c2ecf20Sopenharmony_ci	{ "ADC1 R", NULL, "ADC1 R Power" },
29198c2ecf20Sopenharmony_ci	{ "ADC1 R", NULL, "ADC1 clock" },
29208c2ecf20Sopenharmony_ci
29218c2ecf20Sopenharmony_ci	{ "ADC2 L", NULL, "RECMIX2L" },
29228c2ecf20Sopenharmony_ci	{ "ADC2 L", NULL, "ADC2 L Power" },
29238c2ecf20Sopenharmony_ci	{ "ADC2 L", NULL, "ADC2 clock" },
29248c2ecf20Sopenharmony_ci	{ "ADC2 R", NULL, "RECMIX2R" },
29258c2ecf20Sopenharmony_ci	{ "ADC2 R", NULL, "ADC2 R Power" },
29268c2ecf20Sopenharmony_ci	{ "ADC2 R", NULL, "ADC2 clock" },
29278c2ecf20Sopenharmony_ci
29288c2ecf20Sopenharmony_ci	{ "DMIC L1", NULL, "DMIC CLK" },
29298c2ecf20Sopenharmony_ci	{ "DMIC L1", NULL, "DMIC1 Power" },
29308c2ecf20Sopenharmony_ci	{ "DMIC R1", NULL, "DMIC CLK" },
29318c2ecf20Sopenharmony_ci	{ "DMIC R1", NULL, "DMIC1 Power" },
29328c2ecf20Sopenharmony_ci	{ "DMIC L2", NULL, "DMIC CLK" },
29338c2ecf20Sopenharmony_ci	{ "DMIC L2", NULL, "DMIC2 Power" },
29348c2ecf20Sopenharmony_ci	{ "DMIC R2", NULL, "DMIC CLK" },
29358c2ecf20Sopenharmony_ci	{ "DMIC R2", NULL, "DMIC2 Power" },
29368c2ecf20Sopenharmony_ci
29378c2ecf20Sopenharmony_ci	{ "Stereo1 DMIC L Mux", "DMIC1", "DMIC L1" },
29388c2ecf20Sopenharmony_ci	{ "Stereo1 DMIC L Mux", "DMIC2", "DMIC L2" },
29398c2ecf20Sopenharmony_ci
29408c2ecf20Sopenharmony_ci	{ "Stereo1 DMIC R Mux", "DMIC1", "DMIC R1" },
29418c2ecf20Sopenharmony_ci	{ "Stereo1 DMIC R Mux", "DMIC2", "DMIC R2" },
29428c2ecf20Sopenharmony_ci
29438c2ecf20Sopenharmony_ci	{ "Mono DMIC L Mux", "DMIC1 L", "DMIC L1" },
29448c2ecf20Sopenharmony_ci	{ "Mono DMIC L Mux", "DMIC2 L", "DMIC L2" },
29458c2ecf20Sopenharmony_ci
29468c2ecf20Sopenharmony_ci	{ "Mono DMIC R Mux", "DMIC1 R", "DMIC R1" },
29478c2ecf20Sopenharmony_ci	{ "Mono DMIC R Mux", "DMIC2 R", "DMIC R2" },
29488c2ecf20Sopenharmony_ci
29498c2ecf20Sopenharmony_ci	{ "Stereo1 ADC L Mux", "ADC1", "ADC1 L" },
29508c2ecf20Sopenharmony_ci	{ "Stereo1 ADC L Mux", "ADC2", "ADC2 L" },
29518c2ecf20Sopenharmony_ci	{ "Stereo1 ADC R Mux", "ADC1", "ADC1 R" },
29528c2ecf20Sopenharmony_ci	{ "Stereo1 ADC R Mux", "ADC2", "ADC2 R" },
29538c2ecf20Sopenharmony_ci
29548c2ecf20Sopenharmony_ci	{ "Stereo1 ADC L1 Mux", "ADC", "Stereo1 ADC L Mux" },
29558c2ecf20Sopenharmony_ci	{ "Stereo1 ADC L1 Mux", "DAC MIX", "DAC MIXL" },
29568c2ecf20Sopenharmony_ci	{ "Stereo1 ADC L2 Mux", "DMIC", "Stereo1 DMIC L Mux" },
29578c2ecf20Sopenharmony_ci	{ "Stereo1 ADC L2 Mux", "DAC MIX", "DAC MIXL" },
29588c2ecf20Sopenharmony_ci
29598c2ecf20Sopenharmony_ci	{ "Stereo1 ADC R1 Mux", "ADC", "Stereo1 ADC R Mux" },
29608c2ecf20Sopenharmony_ci	{ "Stereo1 ADC R1 Mux", "DAC MIX", "DAC MIXR" },
29618c2ecf20Sopenharmony_ci	{ "Stereo1 ADC R2 Mux", "DMIC", "Stereo1 DMIC R Mux" },
29628c2ecf20Sopenharmony_ci	{ "Stereo1 ADC R2 Mux", "DAC MIX", "DAC MIXR" },
29638c2ecf20Sopenharmony_ci
29648c2ecf20Sopenharmony_ci	{ "Mono ADC L Mux", "ADC1 L", "ADC1 L" },
29658c2ecf20Sopenharmony_ci	{ "Mono ADC L Mux", "ADC1 R", "ADC1 R" },
29668c2ecf20Sopenharmony_ci	{ "Mono ADC L Mux", "ADC2 L", "ADC2 L" },
29678c2ecf20Sopenharmony_ci	{ "Mono ADC L Mux", "ADC2 R", "ADC2 R" },
29688c2ecf20Sopenharmony_ci
29698c2ecf20Sopenharmony_ci	{ "Mono ADC R Mux", "ADC1 L", "ADC1 L" },
29708c2ecf20Sopenharmony_ci	{ "Mono ADC R Mux", "ADC1 R", "ADC1 R" },
29718c2ecf20Sopenharmony_ci	{ "Mono ADC R Mux", "ADC2 L", "ADC2 L" },
29728c2ecf20Sopenharmony_ci	{ "Mono ADC R Mux", "ADC2 R", "ADC2 R" },
29738c2ecf20Sopenharmony_ci
29748c2ecf20Sopenharmony_ci	{ "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" },
29758c2ecf20Sopenharmony_ci	{ "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
29768c2ecf20Sopenharmony_ci	{ "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
29778c2ecf20Sopenharmony_ci	{ "Mono ADC L1 Mux", "ADC",  "Mono ADC L Mux" },
29788c2ecf20Sopenharmony_ci
29798c2ecf20Sopenharmony_ci	{ "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
29808c2ecf20Sopenharmony_ci	{ "Mono ADC R1 Mux", "ADC", "Mono ADC R Mux" },
29818c2ecf20Sopenharmony_ci	{ "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" },
29828c2ecf20Sopenharmony_ci	{ "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
29838c2ecf20Sopenharmony_ci
29848c2ecf20Sopenharmony_ci	{ "Stereo1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux" },
29858c2ecf20Sopenharmony_ci	{ "Stereo1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux" },
29868c2ecf20Sopenharmony_ci	{ "Stereo1 ADC MIXL", NULL, "ADC Stereo1 Filter" },
29878c2ecf20Sopenharmony_ci
29888c2ecf20Sopenharmony_ci	{ "Stereo1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux" },
29898c2ecf20Sopenharmony_ci	{ "Stereo1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC R2 Mux" },
29908c2ecf20Sopenharmony_ci	{ "Stereo1 ADC MIXR", NULL, "ADC Stereo1 Filter" },
29918c2ecf20Sopenharmony_ci
29928c2ecf20Sopenharmony_ci	{ "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" },
29938c2ecf20Sopenharmony_ci	{ "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" },
29948c2ecf20Sopenharmony_ci	{ "Mono ADC MIXL", NULL, "ADC Mono Left Filter" },
29958c2ecf20Sopenharmony_ci
29968c2ecf20Sopenharmony_ci	{ "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" },
29978c2ecf20Sopenharmony_ci	{ "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" },
29988c2ecf20Sopenharmony_ci	{ "Mono ADC MIXR", NULL, "ADC Mono Right Filter" },
29998c2ecf20Sopenharmony_ci
30008c2ecf20Sopenharmony_ci	{ "Stereo1 ADC Volume L", NULL, "Stereo1 ADC MIXL" },
30018c2ecf20Sopenharmony_ci	{ "Stereo1 ADC Volume R", NULL, "Stereo1 ADC MIXR" },
30028c2ecf20Sopenharmony_ci
30038c2ecf20Sopenharmony_ci	{ "IF_ADC1", NULL, "Stereo1 ADC Volume L" },
30048c2ecf20Sopenharmony_ci	{ "IF_ADC1", NULL, "Stereo1 ADC Volume R" },
30058c2ecf20Sopenharmony_ci	{ "IF_ADC2", NULL, "Mono ADC MIXL" },
30068c2ecf20Sopenharmony_ci	{ "IF_ADC2", NULL, "Mono ADC MIXR" },
30078c2ecf20Sopenharmony_ci
30088c2ecf20Sopenharmony_ci	{ "TDM AD1:AD2:DAC", NULL, "IF_ADC1" },
30098c2ecf20Sopenharmony_ci	{ "TDM AD1:AD2:DAC", NULL, "IF_ADC2" },
30108c2ecf20Sopenharmony_ci	{ "TDM AD1:AD2:DAC", NULL, "DAC_REF" },
30118c2ecf20Sopenharmony_ci	{ "TDM AD2:DAC", NULL, "IF_ADC2" },
30128c2ecf20Sopenharmony_ci	{ "TDM AD2:DAC", NULL, "DAC_REF" },
30138c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD1:AD2:DAC:NUL", "TDM AD1:AD2:DAC" },
30148c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD1:AD2:NUL:DAC", "TDM AD1:AD2:DAC" },
30158c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD1:DAC:AD2:NUL", "TDM AD1:AD2:DAC" },
30168c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD1:DAC:NUL:AD2", "TDM AD1:AD2:DAC" },
30178c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD1:NUL:DAC:AD2", "TDM AD1:AD2:DAC" },
30188c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD1:NUL:AD2:DAC", "TDM AD1:AD2:DAC" },
30198c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD2:AD1:DAC:NUL", "TDM AD1:AD2:DAC" },
30208c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD2:AD1:NUL:DAC", "TDM AD1:AD2:DAC" },
30218c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD2:DAC:AD1:NUL", "TDM AD1:AD2:DAC" },
30228c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD2:DAC:NUL:AD1", "TDM AD1:AD2:DAC" },
30238c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD2:NUL:DAC:AD1", "TDM AD1:AD2:DAC" },
30248c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "AD1:NUL:AD1:DAC", "TDM AD1:AD2:DAC" },
30258c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "DAC:AD1:AD2:NUL", "TDM AD1:AD2:DAC" },
30268c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "DAC:AD1:NUL:AD2", "TDM AD1:AD2:DAC" },
30278c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "DAC:AD2:AD1:NUL", "TDM AD1:AD2:DAC" },
30288c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "DAC:AD2:NUL:AD1", "TDM AD1:AD2:DAC" },
30298c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "DAC:NUL:DAC:AD2", "TDM AD2:DAC" },
30308c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "DAC:NUL:AD2:DAC", "TDM AD2:DAC" },
30318c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "NUL:AD1:AD2:DAC", "TDM AD1:AD2:DAC" },
30328c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "NUL:AD1:DAC:AD2", "TDM AD1:AD2:DAC" },
30338c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "NUL:AD2:AD1:DAC", "TDM AD1:AD2:DAC" },
30348c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "NUL:AD2:DAC:AD1", "TDM AD1:AD2:DAC" },
30358c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "NUL:DAC:DAC:AD2", "TDM AD2:DAC" },
30368c2ecf20Sopenharmony_ci	{ "TDM Data Mux", "NUL:DAC:AD2:DAC", "TDM AD2:DAC" },
30378c2ecf20Sopenharmony_ci	{ "IF1 01 ADC Swap Mux", "L/R", "TDM Data Mux" },
30388c2ecf20Sopenharmony_ci	{ "IF1 01 ADC Swap Mux", "R/L", "TDM Data Mux" },
30398c2ecf20Sopenharmony_ci	{ "IF1 01 ADC Swap Mux", "L/L", "TDM Data Mux" },
30408c2ecf20Sopenharmony_ci	{ "IF1 01 ADC Swap Mux", "R/R", "TDM Data Mux" },
30418c2ecf20Sopenharmony_ci	{ "IF1 23 ADC Swap Mux", "L/R", "TDM Data Mux" },
30428c2ecf20Sopenharmony_ci	{ "IF1 23 ADC Swap Mux", "R/L", "TDM Data Mux" },
30438c2ecf20Sopenharmony_ci	{ "IF1 23 ADC Swap Mux", "L/L", "TDM Data Mux" },
30448c2ecf20Sopenharmony_ci	{ "IF1 23 ADC Swap Mux", "R/R", "TDM Data Mux" },
30458c2ecf20Sopenharmony_ci	{ "IF1 45 ADC Swap Mux", "L/R", "TDM Data Mux" },
30468c2ecf20Sopenharmony_ci	{ "IF1 45 ADC Swap Mux", "R/L", "TDM Data Mux" },
30478c2ecf20Sopenharmony_ci	{ "IF1 45 ADC Swap Mux", "L/L", "TDM Data Mux" },
30488c2ecf20Sopenharmony_ci	{ "IF1 45 ADC Swap Mux", "R/R", "TDM Data Mux" },
30498c2ecf20Sopenharmony_ci	{ "IF1 67 ADC Swap Mux", "L/R", "TDM Data Mux" },
30508c2ecf20Sopenharmony_ci	{ "IF1 67 ADC Swap Mux", "R/L", "TDM Data Mux" },
30518c2ecf20Sopenharmony_ci	{ "IF1 67 ADC Swap Mux", "L/L", "TDM Data Mux" },
30528c2ecf20Sopenharmony_ci	{ "IF1 67 ADC Swap Mux", "R/R", "TDM Data Mux" },
30538c2ecf20Sopenharmony_ci	{ "IF1 ADC", NULL, "IF1 01 ADC Swap Mux" },
30548c2ecf20Sopenharmony_ci	{ "IF1 ADC", NULL, "IF1 23 ADC Swap Mux" },
30558c2ecf20Sopenharmony_ci	{ "IF1 ADC", NULL, "IF1 45 ADC Swap Mux" },
30568c2ecf20Sopenharmony_ci	{ "IF1 ADC", NULL, "IF1 67 ADC Swap Mux" },
30578c2ecf20Sopenharmony_ci	{ "IF1 ADC", NULL, "I2S1" },
30588c2ecf20Sopenharmony_ci
30598c2ecf20Sopenharmony_ci	{ "IF2 ADC Mux", "IF_ADC1", "IF_ADC1" },
30608c2ecf20Sopenharmony_ci	{ "IF2 ADC Mux", "IF_ADC2", "IF_ADC2" },
30618c2ecf20Sopenharmony_ci	{ "IF2 ADC Mux", "IF_ADC3", "IF_ADC3" },
30628c2ecf20Sopenharmony_ci	{ "IF2 ADC Mux", "DAC_REF", "DAC_REF" },
30638c2ecf20Sopenharmony_ci	{ "IF2 ADC", NULL, "IF2 ADC Mux"},
30648c2ecf20Sopenharmony_ci	{ "IF2 ADC", NULL, "I2S2" },
30658c2ecf20Sopenharmony_ci
30668c2ecf20Sopenharmony_ci	{ "IF3 ADC Mux", "IF_ADC1", "IF_ADC1" },
30678c2ecf20Sopenharmony_ci	{ "IF3 ADC Mux", "IF_ADC2", "IF_ADC2" },
30688c2ecf20Sopenharmony_ci	{ "IF3 ADC Mux", "Stereo2_ADC_L/R", "Stereo2 ADC LR" },
30698c2ecf20Sopenharmony_ci	{ "IF3 ADC Mux", "DAC_REF", "DAC_REF" },
30708c2ecf20Sopenharmony_ci	{ "IF3 ADC", NULL, "IF3 ADC Mux"},
30718c2ecf20Sopenharmony_ci	{ "IF3 ADC", NULL, "I2S3" },
30728c2ecf20Sopenharmony_ci
30738c2ecf20Sopenharmony_ci	{ "AIF1TX", NULL, "IF1 ADC" },
30748c2ecf20Sopenharmony_ci	{ "IF2 ADC Swap Mux", "L/R", "IF2 ADC" },
30758c2ecf20Sopenharmony_ci	{ "IF2 ADC Swap Mux", "R/L", "IF2 ADC" },
30768c2ecf20Sopenharmony_ci	{ "IF2 ADC Swap Mux", "L/L", "IF2 ADC" },
30778c2ecf20Sopenharmony_ci	{ "IF2 ADC Swap Mux", "R/R", "IF2 ADC" },
30788c2ecf20Sopenharmony_ci	{ "AIF2TX", NULL, "IF2 ADC Swap Mux" },
30798c2ecf20Sopenharmony_ci	{ "IF3 ADC Swap Mux", "L/R", "IF3 ADC" },
30808c2ecf20Sopenharmony_ci	{ "IF3 ADC Swap Mux", "R/L", "IF3 ADC" },
30818c2ecf20Sopenharmony_ci	{ "IF3 ADC Swap Mux", "L/L", "IF3 ADC" },
30828c2ecf20Sopenharmony_ci	{ "IF3 ADC Swap Mux", "R/R", "IF3 ADC" },
30838c2ecf20Sopenharmony_ci	{ "AIF3TX", NULL, "IF3 ADC Swap Mux" },
30848c2ecf20Sopenharmony_ci
30858c2ecf20Sopenharmony_ci	{ "IF1 DAC1", NULL, "AIF1RX" },
30868c2ecf20Sopenharmony_ci	{ "IF1 DAC2", NULL, "AIF1RX" },
30878c2ecf20Sopenharmony_ci	{ "IF2 DAC Swap Mux", "L/R", "AIF2RX" },
30888c2ecf20Sopenharmony_ci	{ "IF2 DAC Swap Mux", "R/L", "AIF2RX" },
30898c2ecf20Sopenharmony_ci	{ "IF2 DAC Swap Mux", "L/L", "AIF2RX" },
30908c2ecf20Sopenharmony_ci	{ "IF2 DAC Swap Mux", "R/R", "AIF2RX" },
30918c2ecf20Sopenharmony_ci	{ "IF2 DAC", NULL, "IF2 DAC Swap Mux" },
30928c2ecf20Sopenharmony_ci	{ "IF3 DAC Swap Mux", "L/R", "AIF3RX" },
30938c2ecf20Sopenharmony_ci	{ "IF3 DAC Swap Mux", "R/L", "AIF3RX" },
30948c2ecf20Sopenharmony_ci	{ "IF3 DAC Swap Mux", "L/L", "AIF3RX" },
30958c2ecf20Sopenharmony_ci	{ "IF3 DAC Swap Mux", "R/R", "AIF3RX" },
30968c2ecf20Sopenharmony_ci	{ "IF3 DAC", NULL, "IF3 DAC Swap Mux" },
30978c2ecf20Sopenharmony_ci
30988c2ecf20Sopenharmony_ci	{ "IF1 DAC1", NULL, "I2S1" },
30998c2ecf20Sopenharmony_ci	{ "IF1 DAC2", NULL, "I2S1" },
31008c2ecf20Sopenharmony_ci	{ "IF2 DAC", NULL, "I2S2" },
31018c2ecf20Sopenharmony_ci	{ "IF3 DAC", NULL, "I2S3" },
31028c2ecf20Sopenharmony_ci
31038c2ecf20Sopenharmony_ci	{ "IF1 DAC2 L", NULL, "IF1 DAC2" },
31048c2ecf20Sopenharmony_ci	{ "IF1 DAC2 R", NULL, "IF1 DAC2" },
31058c2ecf20Sopenharmony_ci	{ "IF1 DAC1 L", NULL, "IF1 DAC1" },
31068c2ecf20Sopenharmony_ci	{ "IF1 DAC1 R", NULL, "IF1 DAC1" },
31078c2ecf20Sopenharmony_ci	{ "IF2 DAC L", NULL, "IF2 DAC" },
31088c2ecf20Sopenharmony_ci	{ "IF2 DAC R", NULL, "IF2 DAC" },
31098c2ecf20Sopenharmony_ci	{ "IF3 DAC L", NULL, "IF3 DAC" },
31108c2ecf20Sopenharmony_ci	{ "IF3 DAC R", NULL, "IF3 DAC" },
31118c2ecf20Sopenharmony_ci
31128c2ecf20Sopenharmony_ci	{ "DAC L1 Mux", "IF1 DAC1", "IF1 DAC1 L" },
31138c2ecf20Sopenharmony_ci	{ "DAC L1 Mux", "IF2 DAC", "IF2 DAC L" },
31148c2ecf20Sopenharmony_ci	{ "DAC L1 Mux", "IF3 DAC", "IF3 DAC L" },
31158c2ecf20Sopenharmony_ci	{ "DAC L1 Mux", NULL, "DAC Stereo1 Filter" },
31168c2ecf20Sopenharmony_ci
31178c2ecf20Sopenharmony_ci	{ "DAC R1 Mux", "IF1 DAC1", "IF1 DAC1 R" },
31188c2ecf20Sopenharmony_ci	{ "DAC R1 Mux", "IF2 DAC", "IF2 DAC R" },
31198c2ecf20Sopenharmony_ci	{ "DAC R1 Mux", "IF3 DAC", "IF3 DAC R" },
31208c2ecf20Sopenharmony_ci	{ "DAC R1 Mux", NULL, "DAC Stereo1 Filter" },
31218c2ecf20Sopenharmony_ci
31228c2ecf20Sopenharmony_ci	{ "DAC1 MIXL", "Stereo ADC Switch", "Stereo1 ADC Volume L" },
31238c2ecf20Sopenharmony_ci	{ "DAC1 MIXL", "DAC1 Switch", "DAC L1 Mux" },
31248c2ecf20Sopenharmony_ci	{ "DAC1 MIXR", "Stereo ADC Switch", "Stereo1 ADC Volume R" },
31258c2ecf20Sopenharmony_ci	{ "DAC1 MIXR", "DAC1 Switch", "DAC R1 Mux" },
31268c2ecf20Sopenharmony_ci
31278c2ecf20Sopenharmony_ci	{ "DAC_REF", NULL, "DAC1 MIXL" },
31288c2ecf20Sopenharmony_ci	{ "DAC_REF", NULL, "DAC1 MIXR" },
31298c2ecf20Sopenharmony_ci
31308c2ecf20Sopenharmony_ci	{ "DAC L2 Mux", "IF1 DAC2", "IF1 DAC2 L" },
31318c2ecf20Sopenharmony_ci	{ "DAC L2 Mux", "IF2 DAC", "IF2 DAC L" },
31328c2ecf20Sopenharmony_ci	{ "DAC L2 Mux", "IF3 DAC", "IF3 DAC L" },
31338c2ecf20Sopenharmony_ci	{ "DAC L2 Mux", "Mono ADC MIX", "Mono ADC MIXL" },
31348c2ecf20Sopenharmony_ci	{ "DAC L2 Mux", NULL, "DAC Mono Left Filter" },
31358c2ecf20Sopenharmony_ci
31368c2ecf20Sopenharmony_ci	{ "DAC R2 Mux", "IF1 DAC2", "IF1 DAC2 R" },
31378c2ecf20Sopenharmony_ci	{ "DAC R2 Mux", "IF2 DAC", "IF2 DAC R" },
31388c2ecf20Sopenharmony_ci	{ "DAC R2 Mux", "IF3 DAC", "IF3 DAC R" },
31398c2ecf20Sopenharmony_ci	{ "DAC R2 Mux", "Mono ADC MIX", "Mono ADC MIXR" },
31408c2ecf20Sopenharmony_ci	{ "DAC R2 Mux", NULL, "DAC Mono Right Filter" },
31418c2ecf20Sopenharmony_ci
31428c2ecf20Sopenharmony_ci	{ "Stereo DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
31438c2ecf20Sopenharmony_ci	{ "Stereo DAC MIXL", "DAC R1 Switch", "DAC1 MIXR" },
31448c2ecf20Sopenharmony_ci	{ "Stereo DAC MIXL", "DAC L2 Switch", "DAC L2 Mux" },
31458c2ecf20Sopenharmony_ci	{ "Stereo DAC MIXL", "DAC R2 Switch", "DAC R2 Mux" },
31468c2ecf20Sopenharmony_ci
31478c2ecf20Sopenharmony_ci	{ "Stereo DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
31488c2ecf20Sopenharmony_ci	{ "Stereo DAC MIXR", "DAC L1 Switch", "DAC1 MIXL" },
31498c2ecf20Sopenharmony_ci	{ "Stereo DAC MIXR", "DAC L2 Switch", "DAC L2 Mux" },
31508c2ecf20Sopenharmony_ci	{ "Stereo DAC MIXR", "DAC R2 Switch", "DAC R2 Mux" },
31518c2ecf20Sopenharmony_ci
31528c2ecf20Sopenharmony_ci	{ "Mono DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
31538c2ecf20Sopenharmony_ci	{ "Mono DAC MIXL", "DAC R1 Switch", "DAC1 MIXR" },
31548c2ecf20Sopenharmony_ci	{ "Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Mux" },
31558c2ecf20Sopenharmony_ci	{ "Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Mux" },
31568c2ecf20Sopenharmony_ci	{ "Mono DAC MIXR", "DAC L1 Switch", "DAC1 MIXL" },
31578c2ecf20Sopenharmony_ci	{ "Mono DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
31588c2ecf20Sopenharmony_ci	{ "Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Mux" },
31598c2ecf20Sopenharmony_ci	{ "Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Mux" },
31608c2ecf20Sopenharmony_ci
31618c2ecf20Sopenharmony_ci	{ "DAC MIXL", "Stereo DAC Mixer", "Stereo DAC MIXL" },
31628c2ecf20Sopenharmony_ci	{ "DAC MIXL", "Mono DAC Mixer", "Mono DAC MIXL" },
31638c2ecf20Sopenharmony_ci	{ "DAC MIXR", "Stereo DAC Mixer", "Stereo DAC MIXR" },
31648c2ecf20Sopenharmony_ci	{ "DAC MIXR", "Mono DAC Mixer", "Mono DAC MIXR" },
31658c2ecf20Sopenharmony_ci
31668c2ecf20Sopenharmony_ci	{ "DAC L1 Source", NULL, "DAC L1 Power" },
31678c2ecf20Sopenharmony_ci	{ "DAC L1 Source", "DAC", "DAC1 MIXL" },
31688c2ecf20Sopenharmony_ci	{ "DAC L1 Source", "Stereo DAC Mixer", "Stereo DAC MIXL" },
31698c2ecf20Sopenharmony_ci	{ "DAC R1 Source", NULL, "DAC R1 Power" },
31708c2ecf20Sopenharmony_ci	{ "DAC R1 Source", "DAC", "DAC1 MIXR" },
31718c2ecf20Sopenharmony_ci	{ "DAC R1 Source", "Stereo DAC Mixer", "Stereo DAC MIXR" },
31728c2ecf20Sopenharmony_ci	{ "DAC L2 Source", "Stereo DAC Mixer", "Stereo DAC MIXL" },
31738c2ecf20Sopenharmony_ci	{ "DAC L2 Source", "Mono DAC Mixer", "Mono DAC MIXL" },
31748c2ecf20Sopenharmony_ci	{ "DAC L2 Source", NULL, "DAC L2 Power" },
31758c2ecf20Sopenharmony_ci	{ "DAC R2 Source", "Stereo DAC Mixer", "Stereo DAC MIXR" },
31768c2ecf20Sopenharmony_ci	{ "DAC R2 Source", "Mono DAC Mixer", "Mono DAC MIXR" },
31778c2ecf20Sopenharmony_ci	{ "DAC R2 Source", NULL, "DAC R2 Power" },
31788c2ecf20Sopenharmony_ci
31798c2ecf20Sopenharmony_ci	{ "DAC L1", NULL, "DAC L1 Source" },
31808c2ecf20Sopenharmony_ci	{ "DAC R1", NULL, "DAC R1 Source" },
31818c2ecf20Sopenharmony_ci	{ "DAC L2", NULL, "DAC L2 Source" },
31828c2ecf20Sopenharmony_ci	{ "DAC R2", NULL, "DAC R2 Source" },
31838c2ecf20Sopenharmony_ci
31848c2ecf20Sopenharmony_ci	{ "SPK MIXL", "DAC L2 Switch", "DAC L2" },
31858c2ecf20Sopenharmony_ci	{ "SPK MIXL", "BST1 Switch", "BST1" },
31868c2ecf20Sopenharmony_ci	{ "SPK MIXL", "INL Switch", "INL VOL" },
31878c2ecf20Sopenharmony_ci	{ "SPK MIXL", "INR Switch", "INR VOL" },
31888c2ecf20Sopenharmony_ci	{ "SPK MIXL", "BST3 Switch", "BST3" },
31898c2ecf20Sopenharmony_ci	{ "SPK MIXR", "DAC R2 Switch", "DAC R2" },
31908c2ecf20Sopenharmony_ci	{ "SPK MIXR", "BST4 Switch", "BST4" },
31918c2ecf20Sopenharmony_ci	{ "SPK MIXR", "INL Switch", "INL VOL" },
31928c2ecf20Sopenharmony_ci	{ "SPK MIXR", "INR Switch", "INR VOL" },
31938c2ecf20Sopenharmony_ci	{ "SPK MIXR", "BST3 Switch", "BST3" },
31948c2ecf20Sopenharmony_ci
31958c2ecf20Sopenharmony_ci	{ "MONOVOL MIX", "DAC L2 Switch", "DAC L2" },
31968c2ecf20Sopenharmony_ci	{ "MONOVOL MIX", "DAC R2 Switch", "DAC R2" },
31978c2ecf20Sopenharmony_ci	{ "MONOVOL MIX", "BST1 Switch", "BST1" },
31988c2ecf20Sopenharmony_ci	{ "MONOVOL MIX", "BST2 Switch", "BST2" },
31998c2ecf20Sopenharmony_ci	{ "MONOVOL MIX", "BST3 Switch", "BST3" },
32008c2ecf20Sopenharmony_ci
32018c2ecf20Sopenharmony_ci	{ "OUT MIXL", "DAC L2 Switch", "DAC L2" },
32028c2ecf20Sopenharmony_ci	{ "OUT MIXL", "INL Switch", "INL VOL" },
32038c2ecf20Sopenharmony_ci	{ "OUT MIXL", "BST1 Switch", "BST1" },
32048c2ecf20Sopenharmony_ci	{ "OUT MIXL", "BST2 Switch", "BST2" },
32058c2ecf20Sopenharmony_ci	{ "OUT MIXL", "BST3 Switch", "BST3" },
32068c2ecf20Sopenharmony_ci	{ "OUT MIXR", "DAC R2 Switch", "DAC R2" },
32078c2ecf20Sopenharmony_ci	{ "OUT MIXR", "INR Switch", "INR VOL" },
32088c2ecf20Sopenharmony_ci	{ "OUT MIXR", "BST2 Switch", "BST2" },
32098c2ecf20Sopenharmony_ci	{ "OUT MIXR", "BST3 Switch", "BST3" },
32108c2ecf20Sopenharmony_ci	{ "OUT MIXR", "BST4 Switch", "BST4" },
32118c2ecf20Sopenharmony_ci
32128c2ecf20Sopenharmony_ci	{ "SPKVOL L", "Switch", "SPK MIXL" },
32138c2ecf20Sopenharmony_ci	{ "SPKVOL R", "Switch", "SPK MIXR" },
32148c2ecf20Sopenharmony_ci	{ "SPO L MIX", "DAC L2 Switch", "DAC L2" },
32158c2ecf20Sopenharmony_ci	{ "SPO L MIX", "SPKVOL L Switch", "SPKVOL L" },
32168c2ecf20Sopenharmony_ci	{ "SPO R MIX", "DAC R2 Switch", "DAC R2" },
32178c2ecf20Sopenharmony_ci	{ "SPO R MIX", "SPKVOL R Switch", "SPKVOL R" },
32188c2ecf20Sopenharmony_ci	{ "SPK Amp", NULL, "SPO L MIX" },
32198c2ecf20Sopenharmony_ci	{ "SPK Amp", NULL, "SPO R MIX" },
32208c2ecf20Sopenharmony_ci	{ "SPK Amp", NULL, "SYS CLK DET" },
32218c2ecf20Sopenharmony_ci	{ "SPO Playback", "Switch", "SPK Amp" },
32228c2ecf20Sopenharmony_ci	{ "SPOL", NULL, "SPO Playback" },
32238c2ecf20Sopenharmony_ci	{ "SPOR", NULL, "SPO Playback" },
32248c2ecf20Sopenharmony_ci
32258c2ecf20Sopenharmony_ci	{ "MONOVOL", "Switch", "MONOVOL MIX" },
32268c2ecf20Sopenharmony_ci	{ "Mono MIX", "DAC L2 Switch", "DAC L2" },
32278c2ecf20Sopenharmony_ci	{ "Mono MIX", "MONOVOL Switch", "MONOVOL" },
32288c2ecf20Sopenharmony_ci	{ "Mono Amp", NULL, "Mono MIX" },
32298c2ecf20Sopenharmony_ci	{ "Mono Amp", NULL, "Mono Vref" },
32308c2ecf20Sopenharmony_ci	{ "Mono Amp", NULL, "SYS CLK DET" },
32318c2ecf20Sopenharmony_ci	{ "Mono Playback", "Switch", "Mono Amp" },
32328c2ecf20Sopenharmony_ci	{ "MONOOUT", NULL, "Mono Playback" },
32338c2ecf20Sopenharmony_ci
32348c2ecf20Sopenharmony_ci	{ "HP Amp", NULL, "DAC L1" },
32358c2ecf20Sopenharmony_ci	{ "HP Amp", NULL, "DAC R1" },
32368c2ecf20Sopenharmony_ci	{ "HP Amp", NULL, "Charge Pump" },
32378c2ecf20Sopenharmony_ci	{ "HP Amp", NULL, "SYS CLK DET" },
32388c2ecf20Sopenharmony_ci	{ "HPO L Playback", "Switch", "HP Amp"},
32398c2ecf20Sopenharmony_ci	{ "HPO R Playback", "Switch", "HP Amp"},
32408c2ecf20Sopenharmony_ci	{ "HPOL", NULL, "HPO L Playback" },
32418c2ecf20Sopenharmony_ci	{ "HPOR", NULL, "HPO R Playback" },
32428c2ecf20Sopenharmony_ci
32438c2ecf20Sopenharmony_ci	{ "OUTVOL L", "Switch", "OUT MIXL" },
32448c2ecf20Sopenharmony_ci	{ "OUTVOL R", "Switch", "OUT MIXR" },
32458c2ecf20Sopenharmony_ci	{ "LOUT L MIX", "DAC L2 Switch", "DAC L2" },
32468c2ecf20Sopenharmony_ci	{ "LOUT L MIX", "OUTVOL L Switch", "OUTVOL L" },
32478c2ecf20Sopenharmony_ci	{ "LOUT R MIX", "DAC R2 Switch", "DAC R2" },
32488c2ecf20Sopenharmony_ci	{ "LOUT R MIX", "OUTVOL R Switch", "OUTVOL R" },
32498c2ecf20Sopenharmony_ci	{ "LOUT Amp", NULL, "LOUT L MIX" },
32508c2ecf20Sopenharmony_ci	{ "LOUT Amp", NULL, "LOUT R MIX" },
32518c2ecf20Sopenharmony_ci	{ "LOUT Amp", NULL, "Charge Pump" },
32528c2ecf20Sopenharmony_ci	{ "LOUT Amp", NULL, "SYS CLK DET" },
32538c2ecf20Sopenharmony_ci	{ "LOUT L Playback", "Switch", "LOUT Amp" },
32548c2ecf20Sopenharmony_ci	{ "LOUT R Playback", "Switch", "LOUT Amp" },
32558c2ecf20Sopenharmony_ci	{ "LOUTL", NULL, "LOUT L Playback" },
32568c2ecf20Sopenharmony_ci	{ "LOUTR", NULL, "LOUT R Playback" },
32578c2ecf20Sopenharmony_ci
32588c2ecf20Sopenharmony_ci	{ "PDM L Mux", "Mono DAC", "Mono DAC MIXL" },
32598c2ecf20Sopenharmony_ci	{ "PDM L Mux", "Stereo DAC", "Stereo DAC MIXL" },
32608c2ecf20Sopenharmony_ci	{ "PDM L Mux", NULL, "PDM Power" },
32618c2ecf20Sopenharmony_ci	{ "PDM R Mux", "Mono DAC", "Mono DAC MIXR" },
32628c2ecf20Sopenharmony_ci	{ "PDM R Mux", "Stereo DAC", "Stereo DAC MIXR" },
32638c2ecf20Sopenharmony_ci	{ "PDM R Mux", NULL, "PDM Power" },
32648c2ecf20Sopenharmony_ci	{ "PDM L Playback", "Switch", "PDM L Mux" },
32658c2ecf20Sopenharmony_ci	{ "PDM R Playback", "Switch", "PDM R Mux" },
32668c2ecf20Sopenharmony_ci	{ "PDML", NULL, "PDM L Playback" },
32678c2ecf20Sopenharmony_ci	{ "PDMR", NULL, "PDM R Playback" },
32688c2ecf20Sopenharmony_ci
32698c2ecf20Sopenharmony_ci	{ "SPDIF Mux", "IF3_DAC", "IF3 DAC" },
32708c2ecf20Sopenharmony_ci	{ "SPDIF Mux", "IF2_DAC", "IF2 DAC" },
32718c2ecf20Sopenharmony_ci	{ "SPDIF Mux", "IF1_DAC2", "IF1 DAC2" },
32728c2ecf20Sopenharmony_ci	{ "SPDIF Mux", "IF1_DAC1", "IF1 DAC1" },
32738c2ecf20Sopenharmony_ci	{ "SPDIF", NULL, "SPDIF Mux" },
32748c2ecf20Sopenharmony_ci};
32758c2ecf20Sopenharmony_ci
32768c2ecf20Sopenharmony_cistatic int rt5659_hw_params(struct snd_pcm_substream *substream,
32778c2ecf20Sopenharmony_ci	struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
32788c2ecf20Sopenharmony_ci{
32798c2ecf20Sopenharmony_ci	struct snd_soc_component *component = dai->component;
32808c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
32818c2ecf20Sopenharmony_ci	unsigned int val_len = 0, val_clk, mask_clk;
32828c2ecf20Sopenharmony_ci	int pre_div, frame_size;
32838c2ecf20Sopenharmony_ci
32848c2ecf20Sopenharmony_ci	rt5659->lrck[dai->id] = params_rate(params);
32858c2ecf20Sopenharmony_ci	pre_div = rl6231_get_clk_info(rt5659->sysclk, rt5659->lrck[dai->id]);
32868c2ecf20Sopenharmony_ci	if (pre_div < 0) {
32878c2ecf20Sopenharmony_ci		dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n",
32888c2ecf20Sopenharmony_ci			rt5659->lrck[dai->id], dai->id);
32898c2ecf20Sopenharmony_ci		return -EINVAL;
32908c2ecf20Sopenharmony_ci	}
32918c2ecf20Sopenharmony_ci	frame_size = snd_soc_params_to_frame_size(params);
32928c2ecf20Sopenharmony_ci	if (frame_size < 0) {
32938c2ecf20Sopenharmony_ci		dev_err(component->dev, "Unsupported frame size: %d\n", frame_size);
32948c2ecf20Sopenharmony_ci		return -EINVAL;
32958c2ecf20Sopenharmony_ci	}
32968c2ecf20Sopenharmony_ci
32978c2ecf20Sopenharmony_ci	dev_dbg(dai->dev, "lrck is %dHz and pre_div is %d for iis %d\n",
32988c2ecf20Sopenharmony_ci				rt5659->lrck[dai->id], pre_div, dai->id);
32998c2ecf20Sopenharmony_ci
33008c2ecf20Sopenharmony_ci	switch (params_width(params)) {
33018c2ecf20Sopenharmony_ci	case 16:
33028c2ecf20Sopenharmony_ci		break;
33038c2ecf20Sopenharmony_ci	case 20:
33048c2ecf20Sopenharmony_ci		val_len |= RT5659_I2S_DL_20;
33058c2ecf20Sopenharmony_ci		break;
33068c2ecf20Sopenharmony_ci	case 24:
33078c2ecf20Sopenharmony_ci		val_len |= RT5659_I2S_DL_24;
33088c2ecf20Sopenharmony_ci		break;
33098c2ecf20Sopenharmony_ci	case 8:
33108c2ecf20Sopenharmony_ci		val_len |= RT5659_I2S_DL_8;
33118c2ecf20Sopenharmony_ci		break;
33128c2ecf20Sopenharmony_ci	default:
33138c2ecf20Sopenharmony_ci		return -EINVAL;
33148c2ecf20Sopenharmony_ci	}
33158c2ecf20Sopenharmony_ci
33168c2ecf20Sopenharmony_ci	switch (dai->id) {
33178c2ecf20Sopenharmony_ci	case RT5659_AIF1:
33188c2ecf20Sopenharmony_ci		mask_clk = RT5659_I2S_PD1_MASK;
33198c2ecf20Sopenharmony_ci		val_clk = pre_div << RT5659_I2S_PD1_SFT;
33208c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_I2S1_SDP,
33218c2ecf20Sopenharmony_ci			RT5659_I2S_DL_MASK, val_len);
33228c2ecf20Sopenharmony_ci		break;
33238c2ecf20Sopenharmony_ci	case RT5659_AIF2:
33248c2ecf20Sopenharmony_ci		mask_clk = RT5659_I2S_PD2_MASK;
33258c2ecf20Sopenharmony_ci		val_clk = pre_div << RT5659_I2S_PD2_SFT;
33268c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_I2S2_SDP,
33278c2ecf20Sopenharmony_ci			RT5659_I2S_DL_MASK, val_len);
33288c2ecf20Sopenharmony_ci		break;
33298c2ecf20Sopenharmony_ci	case RT5659_AIF3:
33308c2ecf20Sopenharmony_ci		mask_clk = RT5659_I2S_PD3_MASK;
33318c2ecf20Sopenharmony_ci		val_clk = pre_div << RT5659_I2S_PD3_SFT;
33328c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_I2S3_SDP,
33338c2ecf20Sopenharmony_ci			RT5659_I2S_DL_MASK, val_len);
33348c2ecf20Sopenharmony_ci		break;
33358c2ecf20Sopenharmony_ci	default:
33368c2ecf20Sopenharmony_ci		dev_err(component->dev, "Invalid dai->id: %d\n", dai->id);
33378c2ecf20Sopenharmony_ci		return -EINVAL;
33388c2ecf20Sopenharmony_ci	}
33398c2ecf20Sopenharmony_ci
33408c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1, mask_clk, val_clk);
33418c2ecf20Sopenharmony_ci
33428c2ecf20Sopenharmony_ci	switch (rt5659->lrck[dai->id]) {
33438c2ecf20Sopenharmony_ci	case 192000:
33448c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1,
33458c2ecf20Sopenharmony_ci			RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_32);
33468c2ecf20Sopenharmony_ci		break;
33478c2ecf20Sopenharmony_ci	case 96000:
33488c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1,
33498c2ecf20Sopenharmony_ci			RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_64);
33508c2ecf20Sopenharmony_ci		break;
33518c2ecf20Sopenharmony_ci	default:
33528c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1,
33538c2ecf20Sopenharmony_ci			RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_128);
33548c2ecf20Sopenharmony_ci		break;
33558c2ecf20Sopenharmony_ci	}
33568c2ecf20Sopenharmony_ci
33578c2ecf20Sopenharmony_ci	return 0;
33588c2ecf20Sopenharmony_ci}
33598c2ecf20Sopenharmony_ci
33608c2ecf20Sopenharmony_cistatic int rt5659_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
33618c2ecf20Sopenharmony_ci{
33628c2ecf20Sopenharmony_ci	struct snd_soc_component *component = dai->component;
33638c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
33648c2ecf20Sopenharmony_ci	unsigned int reg_val = 0;
33658c2ecf20Sopenharmony_ci
33668c2ecf20Sopenharmony_ci	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
33678c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_CBM_CFM:
33688c2ecf20Sopenharmony_ci		rt5659->master[dai->id] = 1;
33698c2ecf20Sopenharmony_ci		break;
33708c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_CBS_CFS:
33718c2ecf20Sopenharmony_ci		reg_val |= RT5659_I2S_MS_S;
33728c2ecf20Sopenharmony_ci		rt5659->master[dai->id] = 0;
33738c2ecf20Sopenharmony_ci		break;
33748c2ecf20Sopenharmony_ci	default:
33758c2ecf20Sopenharmony_ci		return -EINVAL;
33768c2ecf20Sopenharmony_ci	}
33778c2ecf20Sopenharmony_ci
33788c2ecf20Sopenharmony_ci	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
33798c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_NB_NF:
33808c2ecf20Sopenharmony_ci		break;
33818c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_IB_NF:
33828c2ecf20Sopenharmony_ci		reg_val |= RT5659_I2S_BP_INV;
33838c2ecf20Sopenharmony_ci		break;
33848c2ecf20Sopenharmony_ci	default:
33858c2ecf20Sopenharmony_ci		return -EINVAL;
33868c2ecf20Sopenharmony_ci	}
33878c2ecf20Sopenharmony_ci
33888c2ecf20Sopenharmony_ci	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
33898c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_I2S:
33908c2ecf20Sopenharmony_ci		break;
33918c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_LEFT_J:
33928c2ecf20Sopenharmony_ci		reg_val |= RT5659_I2S_DF_LEFT;
33938c2ecf20Sopenharmony_ci		break;
33948c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_DSP_A:
33958c2ecf20Sopenharmony_ci		reg_val |= RT5659_I2S_DF_PCM_A;
33968c2ecf20Sopenharmony_ci		break;
33978c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_DSP_B:
33988c2ecf20Sopenharmony_ci		reg_val |= RT5659_I2S_DF_PCM_B;
33998c2ecf20Sopenharmony_ci		break;
34008c2ecf20Sopenharmony_ci	default:
34018c2ecf20Sopenharmony_ci		return -EINVAL;
34028c2ecf20Sopenharmony_ci	}
34038c2ecf20Sopenharmony_ci
34048c2ecf20Sopenharmony_ci	switch (dai->id) {
34058c2ecf20Sopenharmony_ci	case RT5659_AIF1:
34068c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_I2S1_SDP,
34078c2ecf20Sopenharmony_ci			RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK |
34088c2ecf20Sopenharmony_ci			RT5659_I2S_DF_MASK, reg_val);
34098c2ecf20Sopenharmony_ci		break;
34108c2ecf20Sopenharmony_ci	case RT5659_AIF2:
34118c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_I2S2_SDP,
34128c2ecf20Sopenharmony_ci			RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK |
34138c2ecf20Sopenharmony_ci			RT5659_I2S_DF_MASK, reg_val);
34148c2ecf20Sopenharmony_ci		break;
34158c2ecf20Sopenharmony_ci	case RT5659_AIF3:
34168c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_I2S3_SDP,
34178c2ecf20Sopenharmony_ci			RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK |
34188c2ecf20Sopenharmony_ci			RT5659_I2S_DF_MASK, reg_val);
34198c2ecf20Sopenharmony_ci		break;
34208c2ecf20Sopenharmony_ci	default:
34218c2ecf20Sopenharmony_ci		dev_err(component->dev, "Invalid dai->id: %d\n", dai->id);
34228c2ecf20Sopenharmony_ci		return -EINVAL;
34238c2ecf20Sopenharmony_ci	}
34248c2ecf20Sopenharmony_ci	return 0;
34258c2ecf20Sopenharmony_ci}
34268c2ecf20Sopenharmony_ci
34278c2ecf20Sopenharmony_cistatic int rt5659_set_component_sysclk(struct snd_soc_component *component, int clk_id,
34288c2ecf20Sopenharmony_ci				   int source, unsigned int freq, int dir)
34298c2ecf20Sopenharmony_ci{
34308c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
34318c2ecf20Sopenharmony_ci	unsigned int reg_val = 0;
34328c2ecf20Sopenharmony_ci	int ret;
34338c2ecf20Sopenharmony_ci
34348c2ecf20Sopenharmony_ci	if (freq == rt5659->sysclk && clk_id == rt5659->sysclk_src)
34358c2ecf20Sopenharmony_ci		return 0;
34368c2ecf20Sopenharmony_ci
34378c2ecf20Sopenharmony_ci	switch (clk_id) {
34388c2ecf20Sopenharmony_ci	case RT5659_SCLK_S_MCLK:
34398c2ecf20Sopenharmony_ci		ret = clk_set_rate(rt5659->mclk, freq);
34408c2ecf20Sopenharmony_ci		if (ret)
34418c2ecf20Sopenharmony_ci			return ret;
34428c2ecf20Sopenharmony_ci
34438c2ecf20Sopenharmony_ci		reg_val |= RT5659_SCLK_SRC_MCLK;
34448c2ecf20Sopenharmony_ci		break;
34458c2ecf20Sopenharmony_ci	case RT5659_SCLK_S_PLL1:
34468c2ecf20Sopenharmony_ci		reg_val |= RT5659_SCLK_SRC_PLL1;
34478c2ecf20Sopenharmony_ci		break;
34488c2ecf20Sopenharmony_ci	case RT5659_SCLK_S_RCCLK:
34498c2ecf20Sopenharmony_ci		reg_val |= RT5659_SCLK_SRC_RCCLK;
34508c2ecf20Sopenharmony_ci		break;
34518c2ecf20Sopenharmony_ci	default:
34528c2ecf20Sopenharmony_ci		dev_err(component->dev, "Invalid clock id (%d)\n", clk_id);
34538c2ecf20Sopenharmony_ci		return -EINVAL;
34548c2ecf20Sopenharmony_ci	}
34558c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, RT5659_GLB_CLK,
34568c2ecf20Sopenharmony_ci		RT5659_SCLK_SRC_MASK, reg_val);
34578c2ecf20Sopenharmony_ci	rt5659->sysclk = freq;
34588c2ecf20Sopenharmony_ci	rt5659->sysclk_src = clk_id;
34598c2ecf20Sopenharmony_ci
34608c2ecf20Sopenharmony_ci	dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n",
34618c2ecf20Sopenharmony_ci		freq, clk_id);
34628c2ecf20Sopenharmony_ci
34638c2ecf20Sopenharmony_ci	return 0;
34648c2ecf20Sopenharmony_ci}
34658c2ecf20Sopenharmony_ci
34668c2ecf20Sopenharmony_cistatic int rt5659_set_component_pll(struct snd_soc_component *component, int pll_id,
34678c2ecf20Sopenharmony_ci				int source, unsigned int freq_in,
34688c2ecf20Sopenharmony_ci				unsigned int freq_out)
34698c2ecf20Sopenharmony_ci{
34708c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
34718c2ecf20Sopenharmony_ci	struct rl6231_pll_code pll_code;
34728c2ecf20Sopenharmony_ci	int ret;
34738c2ecf20Sopenharmony_ci
34748c2ecf20Sopenharmony_ci	if (source == rt5659->pll_src && freq_in == rt5659->pll_in &&
34758c2ecf20Sopenharmony_ci	    freq_out == rt5659->pll_out)
34768c2ecf20Sopenharmony_ci		return 0;
34778c2ecf20Sopenharmony_ci
34788c2ecf20Sopenharmony_ci	if (!freq_in || !freq_out) {
34798c2ecf20Sopenharmony_ci		dev_dbg(component->dev, "PLL disabled\n");
34808c2ecf20Sopenharmony_ci
34818c2ecf20Sopenharmony_ci		rt5659->pll_in = 0;
34828c2ecf20Sopenharmony_ci		rt5659->pll_out = 0;
34838c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_GLB_CLK,
34848c2ecf20Sopenharmony_ci			RT5659_SCLK_SRC_MASK, RT5659_SCLK_SRC_MCLK);
34858c2ecf20Sopenharmony_ci		return 0;
34868c2ecf20Sopenharmony_ci	}
34878c2ecf20Sopenharmony_ci
34888c2ecf20Sopenharmony_ci	switch (source) {
34898c2ecf20Sopenharmony_ci	case RT5659_PLL1_S_MCLK:
34908c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_GLB_CLK,
34918c2ecf20Sopenharmony_ci			RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_MCLK);
34928c2ecf20Sopenharmony_ci		break;
34938c2ecf20Sopenharmony_ci	case RT5659_PLL1_S_BCLK1:
34948c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_GLB_CLK,
34958c2ecf20Sopenharmony_ci				RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK1);
34968c2ecf20Sopenharmony_ci		break;
34978c2ecf20Sopenharmony_ci	case RT5659_PLL1_S_BCLK2:
34988c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_GLB_CLK,
34998c2ecf20Sopenharmony_ci				RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK2);
35008c2ecf20Sopenharmony_ci		break;
35018c2ecf20Sopenharmony_ci	case RT5659_PLL1_S_BCLK3:
35028c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, RT5659_GLB_CLK,
35038c2ecf20Sopenharmony_ci				RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK3);
35048c2ecf20Sopenharmony_ci		break;
35058c2ecf20Sopenharmony_ci	default:
35068c2ecf20Sopenharmony_ci		dev_err(component->dev, "Unknown PLL source %d\n", source);
35078c2ecf20Sopenharmony_ci		return -EINVAL;
35088c2ecf20Sopenharmony_ci	}
35098c2ecf20Sopenharmony_ci
35108c2ecf20Sopenharmony_ci	ret = rl6231_pll_calc(freq_in, freq_out, &pll_code);
35118c2ecf20Sopenharmony_ci	if (ret < 0) {
35128c2ecf20Sopenharmony_ci		dev_err(component->dev, "Unsupport input clock %d\n", freq_in);
35138c2ecf20Sopenharmony_ci		return ret;
35148c2ecf20Sopenharmony_ci	}
35158c2ecf20Sopenharmony_ci
35168c2ecf20Sopenharmony_ci	dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n",
35178c2ecf20Sopenharmony_ci		pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
35188c2ecf20Sopenharmony_ci		pll_code.n_code, pll_code.k_code);
35198c2ecf20Sopenharmony_ci
35208c2ecf20Sopenharmony_ci	snd_soc_component_write(component, RT5659_PLL_CTRL_1,
35218c2ecf20Sopenharmony_ci		pll_code.n_code << RT5659_PLL_N_SFT | pll_code.k_code);
35228c2ecf20Sopenharmony_ci	snd_soc_component_write(component, RT5659_PLL_CTRL_2,
35238c2ecf20Sopenharmony_ci		(pll_code.m_bp ? 0 : pll_code.m_code) << RT5659_PLL_M_SFT |
35248c2ecf20Sopenharmony_ci		pll_code.m_bp << RT5659_PLL_M_BP_SFT);
35258c2ecf20Sopenharmony_ci
35268c2ecf20Sopenharmony_ci	rt5659->pll_in = freq_in;
35278c2ecf20Sopenharmony_ci	rt5659->pll_out = freq_out;
35288c2ecf20Sopenharmony_ci	rt5659->pll_src = source;
35298c2ecf20Sopenharmony_ci
35308c2ecf20Sopenharmony_ci	return 0;
35318c2ecf20Sopenharmony_ci}
35328c2ecf20Sopenharmony_ci
35338c2ecf20Sopenharmony_cistatic int rt5659_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
35348c2ecf20Sopenharmony_ci			unsigned int rx_mask, int slots, int slot_width)
35358c2ecf20Sopenharmony_ci{
35368c2ecf20Sopenharmony_ci	struct snd_soc_component *component = dai->component;
35378c2ecf20Sopenharmony_ci	unsigned int val = 0;
35388c2ecf20Sopenharmony_ci
35398c2ecf20Sopenharmony_ci	if (rx_mask || tx_mask)
35408c2ecf20Sopenharmony_ci		val |= (1 << 15);
35418c2ecf20Sopenharmony_ci
35428c2ecf20Sopenharmony_ci	switch (slots) {
35438c2ecf20Sopenharmony_ci	case 4:
35448c2ecf20Sopenharmony_ci		val |= (1 << 10);
35458c2ecf20Sopenharmony_ci		val |= (1 << 8);
35468c2ecf20Sopenharmony_ci		break;
35478c2ecf20Sopenharmony_ci	case 6:
35488c2ecf20Sopenharmony_ci		val |= (2 << 10);
35498c2ecf20Sopenharmony_ci		val |= (2 << 8);
35508c2ecf20Sopenharmony_ci		break;
35518c2ecf20Sopenharmony_ci	case 8:
35528c2ecf20Sopenharmony_ci		val |= (3 << 10);
35538c2ecf20Sopenharmony_ci		val |= (3 << 8);
35548c2ecf20Sopenharmony_ci		break;
35558c2ecf20Sopenharmony_ci	case 2:
35568c2ecf20Sopenharmony_ci		break;
35578c2ecf20Sopenharmony_ci	default:
35588c2ecf20Sopenharmony_ci		return -EINVAL;
35598c2ecf20Sopenharmony_ci	}
35608c2ecf20Sopenharmony_ci
35618c2ecf20Sopenharmony_ci	switch (slot_width) {
35628c2ecf20Sopenharmony_ci	case 20:
35638c2ecf20Sopenharmony_ci		val |= (1 << 6);
35648c2ecf20Sopenharmony_ci		val |= (1 << 4);
35658c2ecf20Sopenharmony_ci		break;
35668c2ecf20Sopenharmony_ci	case 24:
35678c2ecf20Sopenharmony_ci		val |= (2 << 6);
35688c2ecf20Sopenharmony_ci		val |= (2 << 4);
35698c2ecf20Sopenharmony_ci		break;
35708c2ecf20Sopenharmony_ci	case 32:
35718c2ecf20Sopenharmony_ci		val |= (3 << 6);
35728c2ecf20Sopenharmony_ci		val |= (3 << 4);
35738c2ecf20Sopenharmony_ci		break;
35748c2ecf20Sopenharmony_ci	case 16:
35758c2ecf20Sopenharmony_ci		break;
35768c2ecf20Sopenharmony_ci	default:
35778c2ecf20Sopenharmony_ci		return -EINVAL;
35788c2ecf20Sopenharmony_ci	}
35798c2ecf20Sopenharmony_ci
35808c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, RT5659_TDM_CTRL_1, 0x8ff0, val);
35818c2ecf20Sopenharmony_ci
35828c2ecf20Sopenharmony_ci	return 0;
35838c2ecf20Sopenharmony_ci}
35848c2ecf20Sopenharmony_ci
35858c2ecf20Sopenharmony_cistatic int rt5659_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
35868c2ecf20Sopenharmony_ci{
35878c2ecf20Sopenharmony_ci	struct snd_soc_component *component = dai->component;
35888c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
35898c2ecf20Sopenharmony_ci
35908c2ecf20Sopenharmony_ci	dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio);
35918c2ecf20Sopenharmony_ci
35928c2ecf20Sopenharmony_ci	rt5659->bclk[dai->id] = ratio;
35938c2ecf20Sopenharmony_ci
35948c2ecf20Sopenharmony_ci	if (ratio == 64) {
35958c2ecf20Sopenharmony_ci		switch (dai->id) {
35968c2ecf20Sopenharmony_ci		case RT5659_AIF2:
35978c2ecf20Sopenharmony_ci			snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1,
35988c2ecf20Sopenharmony_ci				RT5659_I2S_BCLK_MS2_MASK,
35998c2ecf20Sopenharmony_ci				RT5659_I2S_BCLK_MS2_64);
36008c2ecf20Sopenharmony_ci			break;
36018c2ecf20Sopenharmony_ci		case RT5659_AIF3:
36028c2ecf20Sopenharmony_ci			snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1,
36038c2ecf20Sopenharmony_ci				RT5659_I2S_BCLK_MS3_MASK,
36048c2ecf20Sopenharmony_ci				RT5659_I2S_BCLK_MS3_64);
36058c2ecf20Sopenharmony_ci			break;
36068c2ecf20Sopenharmony_ci		}
36078c2ecf20Sopenharmony_ci	}
36088c2ecf20Sopenharmony_ci
36098c2ecf20Sopenharmony_ci	return 0;
36108c2ecf20Sopenharmony_ci}
36118c2ecf20Sopenharmony_ci
36128c2ecf20Sopenharmony_cistatic int rt5659_set_bias_level(struct snd_soc_component *component,
36138c2ecf20Sopenharmony_ci			enum snd_soc_bias_level level)
36148c2ecf20Sopenharmony_ci{
36158c2ecf20Sopenharmony_ci	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
36168c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
36178c2ecf20Sopenharmony_ci	int ret;
36188c2ecf20Sopenharmony_ci
36198c2ecf20Sopenharmony_ci	switch (level) {
36208c2ecf20Sopenharmony_ci	case SND_SOC_BIAS_PREPARE:
36218c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_DIG_MISC,
36228c2ecf20Sopenharmony_ci			RT5659_DIG_GATE_CTRL, RT5659_DIG_GATE_CTRL);
36238c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_PWR_DIG_1,
36248c2ecf20Sopenharmony_ci			RT5659_PWR_LDO,	RT5659_PWR_LDO);
36258c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
36268c2ecf20Sopenharmony_ci			RT5659_PWR_MB | RT5659_PWR_VREF1 | RT5659_PWR_VREF2,
36278c2ecf20Sopenharmony_ci			RT5659_PWR_MB | RT5659_PWR_VREF1 | RT5659_PWR_VREF2);
36288c2ecf20Sopenharmony_ci		msleep(20);
36298c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
36308c2ecf20Sopenharmony_ci			RT5659_PWR_FV1 | RT5659_PWR_FV2,
36318c2ecf20Sopenharmony_ci			RT5659_PWR_FV1 | RT5659_PWR_FV2);
36328c2ecf20Sopenharmony_ci		break;
36338c2ecf20Sopenharmony_ci
36348c2ecf20Sopenharmony_ci	case SND_SOC_BIAS_STANDBY:
36358c2ecf20Sopenharmony_ci		if (dapm->bias_level == SND_SOC_BIAS_OFF) {
36368c2ecf20Sopenharmony_ci			ret = clk_prepare_enable(rt5659->mclk);
36378c2ecf20Sopenharmony_ci			if (ret) {
36388c2ecf20Sopenharmony_ci				dev_err(component->dev,
36398c2ecf20Sopenharmony_ci					"failed to enable MCLK: %d\n", ret);
36408c2ecf20Sopenharmony_ci				return ret;
36418c2ecf20Sopenharmony_ci			}
36428c2ecf20Sopenharmony_ci		}
36438c2ecf20Sopenharmony_ci		break;
36448c2ecf20Sopenharmony_ci
36458c2ecf20Sopenharmony_ci	case SND_SOC_BIAS_OFF:
36468c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_PWR_DIG_1,
36478c2ecf20Sopenharmony_ci			RT5659_PWR_LDO, 0);
36488c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
36498c2ecf20Sopenharmony_ci			RT5659_PWR_MB | RT5659_PWR_VREF1 | RT5659_PWR_VREF2
36508c2ecf20Sopenharmony_ci			| RT5659_PWR_FV1 | RT5659_PWR_FV2,
36518c2ecf20Sopenharmony_ci			RT5659_PWR_MB | RT5659_PWR_VREF2);
36528c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_DIG_MISC,
36538c2ecf20Sopenharmony_ci			RT5659_DIG_GATE_CTRL, 0);
36548c2ecf20Sopenharmony_ci		clk_disable_unprepare(rt5659->mclk);
36558c2ecf20Sopenharmony_ci		break;
36568c2ecf20Sopenharmony_ci
36578c2ecf20Sopenharmony_ci	default:
36588c2ecf20Sopenharmony_ci		break;
36598c2ecf20Sopenharmony_ci	}
36608c2ecf20Sopenharmony_ci
36618c2ecf20Sopenharmony_ci	return 0;
36628c2ecf20Sopenharmony_ci}
36638c2ecf20Sopenharmony_ci
36648c2ecf20Sopenharmony_cistatic int rt5659_probe(struct snd_soc_component *component)
36658c2ecf20Sopenharmony_ci{
36668c2ecf20Sopenharmony_ci	struct snd_soc_dapm_context *dapm =
36678c2ecf20Sopenharmony_ci		snd_soc_component_get_dapm(component);
36688c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
36698c2ecf20Sopenharmony_ci
36708c2ecf20Sopenharmony_ci	rt5659->component = component;
36718c2ecf20Sopenharmony_ci
36728c2ecf20Sopenharmony_ci	switch (rt5659->pdata.jd_src) {
36738c2ecf20Sopenharmony_ci	case RT5659_JD_HDA_HEADER:
36748c2ecf20Sopenharmony_ci		break;
36758c2ecf20Sopenharmony_ci
36768c2ecf20Sopenharmony_ci	default:
36778c2ecf20Sopenharmony_ci		snd_soc_dapm_new_controls(dapm,
36788c2ecf20Sopenharmony_ci			rt5659_particular_dapm_widgets,
36798c2ecf20Sopenharmony_ci			ARRAY_SIZE(rt5659_particular_dapm_widgets));
36808c2ecf20Sopenharmony_ci		break;
36818c2ecf20Sopenharmony_ci	}
36828c2ecf20Sopenharmony_ci
36838c2ecf20Sopenharmony_ci	return 0;
36848c2ecf20Sopenharmony_ci}
36858c2ecf20Sopenharmony_ci
36868c2ecf20Sopenharmony_cistatic void rt5659_remove(struct snd_soc_component *component)
36878c2ecf20Sopenharmony_ci{
36888c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
36898c2ecf20Sopenharmony_ci
36908c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_RESET, 0);
36918c2ecf20Sopenharmony_ci}
36928c2ecf20Sopenharmony_ci
36938c2ecf20Sopenharmony_ci#ifdef CONFIG_PM
36948c2ecf20Sopenharmony_cistatic int rt5659_suspend(struct snd_soc_component *component)
36958c2ecf20Sopenharmony_ci{
36968c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
36978c2ecf20Sopenharmony_ci
36988c2ecf20Sopenharmony_ci	regcache_cache_only(rt5659->regmap, true);
36998c2ecf20Sopenharmony_ci	regcache_mark_dirty(rt5659->regmap);
37008c2ecf20Sopenharmony_ci	return 0;
37018c2ecf20Sopenharmony_ci}
37028c2ecf20Sopenharmony_ci
37038c2ecf20Sopenharmony_cistatic int rt5659_resume(struct snd_soc_component *component)
37048c2ecf20Sopenharmony_ci{
37058c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
37068c2ecf20Sopenharmony_ci
37078c2ecf20Sopenharmony_ci	regcache_cache_only(rt5659->regmap, false);
37088c2ecf20Sopenharmony_ci	regcache_sync(rt5659->regmap);
37098c2ecf20Sopenharmony_ci
37108c2ecf20Sopenharmony_ci	return 0;
37118c2ecf20Sopenharmony_ci}
37128c2ecf20Sopenharmony_ci#else
37138c2ecf20Sopenharmony_ci#define rt5659_suspend NULL
37148c2ecf20Sopenharmony_ci#define rt5659_resume NULL
37158c2ecf20Sopenharmony_ci#endif
37168c2ecf20Sopenharmony_ci
37178c2ecf20Sopenharmony_ci#define RT5659_STEREO_RATES SNDRV_PCM_RATE_8000_192000
37188c2ecf20Sopenharmony_ci#define RT5659_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
37198c2ecf20Sopenharmony_ci		SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
37208c2ecf20Sopenharmony_ci
37218c2ecf20Sopenharmony_cistatic const struct snd_soc_dai_ops rt5659_aif_dai_ops = {
37228c2ecf20Sopenharmony_ci	.hw_params = rt5659_hw_params,
37238c2ecf20Sopenharmony_ci	.set_fmt = rt5659_set_dai_fmt,
37248c2ecf20Sopenharmony_ci	.set_tdm_slot = rt5659_set_tdm_slot,
37258c2ecf20Sopenharmony_ci	.set_bclk_ratio = rt5659_set_bclk_ratio,
37268c2ecf20Sopenharmony_ci};
37278c2ecf20Sopenharmony_ci
37288c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver rt5659_dai[] = {
37298c2ecf20Sopenharmony_ci	{
37308c2ecf20Sopenharmony_ci		.name = "rt5659-aif1",
37318c2ecf20Sopenharmony_ci		.id = RT5659_AIF1,
37328c2ecf20Sopenharmony_ci		.playback = {
37338c2ecf20Sopenharmony_ci			.stream_name = "AIF1 Playback",
37348c2ecf20Sopenharmony_ci			.channels_min = 1,
37358c2ecf20Sopenharmony_ci			.channels_max = 2,
37368c2ecf20Sopenharmony_ci			.rates = RT5659_STEREO_RATES,
37378c2ecf20Sopenharmony_ci			.formats = RT5659_FORMATS,
37388c2ecf20Sopenharmony_ci		},
37398c2ecf20Sopenharmony_ci		.capture = {
37408c2ecf20Sopenharmony_ci			.stream_name = "AIF1 Capture",
37418c2ecf20Sopenharmony_ci			.channels_min = 1,
37428c2ecf20Sopenharmony_ci			.channels_max = 2,
37438c2ecf20Sopenharmony_ci			.rates = RT5659_STEREO_RATES,
37448c2ecf20Sopenharmony_ci			.formats = RT5659_FORMATS,
37458c2ecf20Sopenharmony_ci		},
37468c2ecf20Sopenharmony_ci		.ops = &rt5659_aif_dai_ops,
37478c2ecf20Sopenharmony_ci	},
37488c2ecf20Sopenharmony_ci	{
37498c2ecf20Sopenharmony_ci		.name = "rt5659-aif2",
37508c2ecf20Sopenharmony_ci		.id = RT5659_AIF2,
37518c2ecf20Sopenharmony_ci		.playback = {
37528c2ecf20Sopenharmony_ci			.stream_name = "AIF2 Playback",
37538c2ecf20Sopenharmony_ci			.channels_min = 1,
37548c2ecf20Sopenharmony_ci			.channels_max = 2,
37558c2ecf20Sopenharmony_ci			.rates = RT5659_STEREO_RATES,
37568c2ecf20Sopenharmony_ci			.formats = RT5659_FORMATS,
37578c2ecf20Sopenharmony_ci		},
37588c2ecf20Sopenharmony_ci		.capture = {
37598c2ecf20Sopenharmony_ci			.stream_name = "AIF2 Capture",
37608c2ecf20Sopenharmony_ci			.channels_min = 1,
37618c2ecf20Sopenharmony_ci			.channels_max = 2,
37628c2ecf20Sopenharmony_ci			.rates = RT5659_STEREO_RATES,
37638c2ecf20Sopenharmony_ci			.formats = RT5659_FORMATS,
37648c2ecf20Sopenharmony_ci		},
37658c2ecf20Sopenharmony_ci		.ops = &rt5659_aif_dai_ops,
37668c2ecf20Sopenharmony_ci	},
37678c2ecf20Sopenharmony_ci	{
37688c2ecf20Sopenharmony_ci		.name = "rt5659-aif3",
37698c2ecf20Sopenharmony_ci		.id = RT5659_AIF3,
37708c2ecf20Sopenharmony_ci		.playback = {
37718c2ecf20Sopenharmony_ci			.stream_name = "AIF3 Playback",
37728c2ecf20Sopenharmony_ci			.channels_min = 1,
37738c2ecf20Sopenharmony_ci			.channels_max = 2,
37748c2ecf20Sopenharmony_ci			.rates = RT5659_STEREO_RATES,
37758c2ecf20Sopenharmony_ci			.formats = RT5659_FORMATS,
37768c2ecf20Sopenharmony_ci		},
37778c2ecf20Sopenharmony_ci		.capture = {
37788c2ecf20Sopenharmony_ci			.stream_name = "AIF3 Capture",
37798c2ecf20Sopenharmony_ci			.channels_min = 1,
37808c2ecf20Sopenharmony_ci			.channels_max = 2,
37818c2ecf20Sopenharmony_ci			.rates = RT5659_STEREO_RATES,
37828c2ecf20Sopenharmony_ci			.formats = RT5659_FORMATS,
37838c2ecf20Sopenharmony_ci		},
37848c2ecf20Sopenharmony_ci		.ops = &rt5659_aif_dai_ops,
37858c2ecf20Sopenharmony_ci	},
37868c2ecf20Sopenharmony_ci};
37878c2ecf20Sopenharmony_ci
37888c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver soc_component_dev_rt5659 = {
37898c2ecf20Sopenharmony_ci	.probe			= rt5659_probe,
37908c2ecf20Sopenharmony_ci	.remove			= rt5659_remove,
37918c2ecf20Sopenharmony_ci	.suspend		= rt5659_suspend,
37928c2ecf20Sopenharmony_ci	.resume			= rt5659_resume,
37938c2ecf20Sopenharmony_ci	.set_bias_level		= rt5659_set_bias_level,
37948c2ecf20Sopenharmony_ci	.controls		= rt5659_snd_controls,
37958c2ecf20Sopenharmony_ci	.num_controls		= ARRAY_SIZE(rt5659_snd_controls),
37968c2ecf20Sopenharmony_ci	.dapm_widgets		= rt5659_dapm_widgets,
37978c2ecf20Sopenharmony_ci	.num_dapm_widgets	= ARRAY_SIZE(rt5659_dapm_widgets),
37988c2ecf20Sopenharmony_ci	.dapm_routes		= rt5659_dapm_routes,
37998c2ecf20Sopenharmony_ci	.num_dapm_routes	= ARRAY_SIZE(rt5659_dapm_routes),
38008c2ecf20Sopenharmony_ci	.set_sysclk		= rt5659_set_component_sysclk,
38018c2ecf20Sopenharmony_ci	.set_pll		= rt5659_set_component_pll,
38028c2ecf20Sopenharmony_ci	.use_pmdown_time	= 1,
38038c2ecf20Sopenharmony_ci	.endianness		= 1,
38048c2ecf20Sopenharmony_ci	.non_legacy_dai_naming	= 1,
38058c2ecf20Sopenharmony_ci};
38068c2ecf20Sopenharmony_ci
38078c2ecf20Sopenharmony_ci
38088c2ecf20Sopenharmony_cistatic const struct regmap_config rt5659_regmap = {
38098c2ecf20Sopenharmony_ci	.reg_bits = 16,
38108c2ecf20Sopenharmony_ci	.val_bits = 16,
38118c2ecf20Sopenharmony_ci	.max_register = 0x0400,
38128c2ecf20Sopenharmony_ci	.volatile_reg = rt5659_volatile_register,
38138c2ecf20Sopenharmony_ci	.readable_reg = rt5659_readable_register,
38148c2ecf20Sopenharmony_ci	.cache_type = REGCACHE_RBTREE,
38158c2ecf20Sopenharmony_ci	.reg_defaults = rt5659_reg,
38168c2ecf20Sopenharmony_ci	.num_reg_defaults = ARRAY_SIZE(rt5659_reg),
38178c2ecf20Sopenharmony_ci};
38188c2ecf20Sopenharmony_ci
38198c2ecf20Sopenharmony_cistatic const struct i2c_device_id rt5659_i2c_id[] = {
38208c2ecf20Sopenharmony_ci	{ "rt5658", 0 },
38218c2ecf20Sopenharmony_ci	{ "rt5659", 0 },
38228c2ecf20Sopenharmony_ci	{ }
38238c2ecf20Sopenharmony_ci};
38248c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, rt5659_i2c_id);
38258c2ecf20Sopenharmony_ci
38268c2ecf20Sopenharmony_cistatic int rt5659_parse_dt(struct rt5659_priv *rt5659, struct device *dev)
38278c2ecf20Sopenharmony_ci{
38288c2ecf20Sopenharmony_ci	rt5659->pdata.in1_diff = device_property_read_bool(dev,
38298c2ecf20Sopenharmony_ci					"realtek,in1-differential");
38308c2ecf20Sopenharmony_ci	rt5659->pdata.in3_diff = device_property_read_bool(dev,
38318c2ecf20Sopenharmony_ci					"realtek,in3-differential");
38328c2ecf20Sopenharmony_ci	rt5659->pdata.in4_diff = device_property_read_bool(dev,
38338c2ecf20Sopenharmony_ci					"realtek,in4-differential");
38348c2ecf20Sopenharmony_ci
38358c2ecf20Sopenharmony_ci
38368c2ecf20Sopenharmony_ci	device_property_read_u32(dev, "realtek,dmic1-data-pin",
38378c2ecf20Sopenharmony_ci		&rt5659->pdata.dmic1_data_pin);
38388c2ecf20Sopenharmony_ci	device_property_read_u32(dev, "realtek,dmic2-data-pin",
38398c2ecf20Sopenharmony_ci		&rt5659->pdata.dmic2_data_pin);
38408c2ecf20Sopenharmony_ci	device_property_read_u32(dev, "realtek,jd-src",
38418c2ecf20Sopenharmony_ci		&rt5659->pdata.jd_src);
38428c2ecf20Sopenharmony_ci
38438c2ecf20Sopenharmony_ci	return 0;
38448c2ecf20Sopenharmony_ci}
38458c2ecf20Sopenharmony_ci
38468c2ecf20Sopenharmony_cistatic void rt5659_calibrate(struct rt5659_priv *rt5659)
38478c2ecf20Sopenharmony_ci{
38488c2ecf20Sopenharmony_ci	int value, count;
38498c2ecf20Sopenharmony_ci
38508c2ecf20Sopenharmony_ci	/* Calibrate HPO Start */
38518c2ecf20Sopenharmony_ci	/* Fine tune HP Performance */
38528c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_BIAS_CUR_CTRL_8, 0xa502);
38538c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CHOP_DAC, 0x3030);
38548c2ecf20Sopenharmony_ci
38558c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PRE_DIV_1, 0xef00);
38568c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PRE_DIV_2, 0xeffc);
38578c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MICBIAS_2, 0x0280);
38588c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_DIG_MISC, 0x0001);
38598c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_GLB_CLK, 0x8000);
38608c2ecf20Sopenharmony_ci
38618c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_1, 0xaa7e);
38628c2ecf20Sopenharmony_ci	msleep(60);
38638c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_1, 0xfe7e);
38648c2ecf20Sopenharmony_ci	msleep(50);
38658c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_3, 0x0004);
38668c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_DIG_2, 0x0400);
38678c2ecf20Sopenharmony_ci	msleep(50);
38688c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_DIG_1, 0x0080);
38698c2ecf20Sopenharmony_ci	usleep_range(10000, 10005);
38708c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_DEPOP_1, 0x0009);
38718c2ecf20Sopenharmony_ci	msleep(50);
38728c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_DIG_1, 0x0f80);
38738c2ecf20Sopenharmony_ci	msleep(50);
38748c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CHARGE_PUMP_1, 0x0e16);
38758c2ecf20Sopenharmony_ci	msleep(50);
38768c2ecf20Sopenharmony_ci
38778c2ecf20Sopenharmony_ci	/* Enalbe K ADC Power And Clock */
38788c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CAL_REC, 0x0505);
38798c2ecf20Sopenharmony_ci	msleep(50);
38808c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_3, 0x0184);
38818c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CALIB_ADC_CTRL, 0x3c05);
38828c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x20c1);
38838c2ecf20Sopenharmony_ci
38848c2ecf20Sopenharmony_ci	/* K Headphone */
38858c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x2cc1);
38868c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, 0x5100);
38878c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_7, 0x0014);
38888c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, 0xd100);
38898c2ecf20Sopenharmony_ci	msleep(60);
38908c2ecf20Sopenharmony_ci
38918c2ecf20Sopenharmony_ci	/* Manual K ADC Offset */
38928c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x2cc1);
38938c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, 0x4900);
38948c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_7, 0x0016);
38958c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_HP_CALIB_CTRL_1,
38968c2ecf20Sopenharmony_ci		0x8000, 0x8000);
38978c2ecf20Sopenharmony_ci
38988c2ecf20Sopenharmony_ci	count = 0;
38998c2ecf20Sopenharmony_ci	while (true) {
39008c2ecf20Sopenharmony_ci		regmap_read(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, &value);
39018c2ecf20Sopenharmony_ci		if (value & 0x8000)
39028c2ecf20Sopenharmony_ci			usleep_range(10000, 10005);
39038c2ecf20Sopenharmony_ci		else
39048c2ecf20Sopenharmony_ci			break;
39058c2ecf20Sopenharmony_ci
39068c2ecf20Sopenharmony_ci		if (count > 30) {
39078c2ecf20Sopenharmony_ci			dev_err(rt5659->component->dev,
39088c2ecf20Sopenharmony_ci				"HP Calibration 1 Failure\n");
39098c2ecf20Sopenharmony_ci			return;
39108c2ecf20Sopenharmony_ci		}
39118c2ecf20Sopenharmony_ci
39128c2ecf20Sopenharmony_ci		count++;
39138c2ecf20Sopenharmony_ci	}
39148c2ecf20Sopenharmony_ci
39158c2ecf20Sopenharmony_ci	/* Manual K Internal Path Offset */
39168c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x2cc1);
39178c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_VOL, 0x0000);
39188c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, 0x4500);
39198c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_7, 0x001f);
39208c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_HP_CALIB_CTRL_1,
39218c2ecf20Sopenharmony_ci		0x8000, 0x8000);
39228c2ecf20Sopenharmony_ci
39238c2ecf20Sopenharmony_ci	count = 0;
39248c2ecf20Sopenharmony_ci	while (true) {
39258c2ecf20Sopenharmony_ci		regmap_read(rt5659->regmap, RT5659_HP_CALIB_CTRL_1, &value);
39268c2ecf20Sopenharmony_ci		if (value & 0x8000)
39278c2ecf20Sopenharmony_ci			usleep_range(10000, 10005);
39288c2ecf20Sopenharmony_ci		else
39298c2ecf20Sopenharmony_ci			break;
39308c2ecf20Sopenharmony_ci
39318c2ecf20Sopenharmony_ci		if (count > 85) {
39328c2ecf20Sopenharmony_ci			dev_err(rt5659->component->dev,
39338c2ecf20Sopenharmony_ci				"HP Calibration 2 Failure\n");
39348c2ecf20Sopenharmony_ci			return;
39358c2ecf20Sopenharmony_ci		}
39368c2ecf20Sopenharmony_ci
39378c2ecf20Sopenharmony_ci		count++;
39388c2ecf20Sopenharmony_ci	}
39398c2ecf20Sopenharmony_ci
39408c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_7, 0x0000);
39418c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x20c0);
39428c2ecf20Sopenharmony_ci	/* Calibrate HPO End */
39438c2ecf20Sopenharmony_ci
39448c2ecf20Sopenharmony_ci	/* Calibrate SPO Start */
39458c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_0, 0x2021);
39468c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_CTRL_1, 0x0260);
39478c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_MIXER, 0x3000);
39488c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_VOL, 0xc000);
39498c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_A_DAC_MUX, 0x000c);
39508c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_DIG_MISC, 0x8000);
39518c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_SPO_VOL, 0x0808);
39528c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_SPK_L_MIXER, 0x001e);
39538c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_SPK_R_MIXER, 0x001e);
39548c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_1, 0x0803);
39558c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_2, 0x0554);
39568c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_SPO_AMP_GAIN, 0x1103);
39578c2ecf20Sopenharmony_ci
39588c2ecf20Sopenharmony_ci	/* Enalbe K ADC Power And Clock */
39598c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CAL_REC, 0x0909);
39608c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x0001,
39618c2ecf20Sopenharmony_ci		0x0001);
39628c2ecf20Sopenharmony_ci
39638c2ecf20Sopenharmony_ci	/* Start Calibration */
39648c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_3, 0x0000);
39658c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_0, 0x0021);
39668c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_1, 0x3e80);
39678c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_1,
39688c2ecf20Sopenharmony_ci		0x8000, 0x8000);
39698c2ecf20Sopenharmony_ci
39708c2ecf20Sopenharmony_ci	count = 0;
39718c2ecf20Sopenharmony_ci	while (true) {
39728c2ecf20Sopenharmony_ci		regmap_read(rt5659->regmap,
39738c2ecf20Sopenharmony_ci				RT5659_SPK_DC_CAILB_CTRL_1, &value);
39748c2ecf20Sopenharmony_ci		if (value & 0x8000)
39758c2ecf20Sopenharmony_ci			usleep_range(10000, 10005);
39768c2ecf20Sopenharmony_ci		else
39778c2ecf20Sopenharmony_ci			break;
39788c2ecf20Sopenharmony_ci
39798c2ecf20Sopenharmony_ci		if (count > 10) {
39808c2ecf20Sopenharmony_ci			dev_err(rt5659->component->dev,
39818c2ecf20Sopenharmony_ci				"SPK Calibration Failure\n");
39828c2ecf20Sopenharmony_ci			return;
39838c2ecf20Sopenharmony_ci		}
39848c2ecf20Sopenharmony_ci
39858c2ecf20Sopenharmony_ci		count++;
39868c2ecf20Sopenharmony_ci	}
39878c2ecf20Sopenharmony_ci	/* Calibrate SPO End */
39888c2ecf20Sopenharmony_ci
39898c2ecf20Sopenharmony_ci	/* Calibrate MONO Start */
39908c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_DIG_MISC, 0x0000);
39918c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MONOMIX_IN_GAIN, 0x021f);
39928c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MONO_OUT, 0x480a);
39938c2ecf20Sopenharmony_ci	/* MONO NG2 GAIN 5dB */
39948c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MONO_GAIN, 0x0003);
39958c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MONO_NG2_CTRL_5, 0x0009);
39968c2ecf20Sopenharmony_ci
39978c2ecf20Sopenharmony_ci	/* Start Calibration */
39988c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_3, 0x000f);
39998c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e00);
40008c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_MONO_AMP_CALIB_CTRL_1,
40018c2ecf20Sopenharmony_ci		0x8000, 0x8000);
40028c2ecf20Sopenharmony_ci
40038c2ecf20Sopenharmony_ci	count = 0;
40048c2ecf20Sopenharmony_ci	while (true) {
40058c2ecf20Sopenharmony_ci		regmap_read(rt5659->regmap, RT5659_MONO_AMP_CALIB_CTRL_1,
40068c2ecf20Sopenharmony_ci			&value);
40078c2ecf20Sopenharmony_ci		if (value & 0x8000)
40088c2ecf20Sopenharmony_ci			usleep_range(10000, 10005);
40098c2ecf20Sopenharmony_ci		else
40108c2ecf20Sopenharmony_ci			break;
40118c2ecf20Sopenharmony_ci
40128c2ecf20Sopenharmony_ci		if (count > 35) {
40138c2ecf20Sopenharmony_ci			dev_err(rt5659->component->dev,
40148c2ecf20Sopenharmony_ci				"Mono Calibration Failure\n");
40158c2ecf20Sopenharmony_ci			return;
40168c2ecf20Sopenharmony_ci		}
40178c2ecf20Sopenharmony_ci
40188c2ecf20Sopenharmony_ci		count++;
40198c2ecf20Sopenharmony_ci	}
40208c2ecf20Sopenharmony_ci
40218c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_SPK_DC_CAILB_CTRL_3, 0x0003);
40228c2ecf20Sopenharmony_ci	/* Calibrate MONO End */
40238c2ecf20Sopenharmony_ci
40248c2ecf20Sopenharmony_ci	/* Power Off */
40258c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CAL_REC, 0x0808);
40268c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_3, 0x0000);
40278c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CALIB_ADC_CTRL, 0x2005);
40288c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CALIB_CTRL_2, 0x20c0);
40298c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_DEPOP_1, 0x0000);
40308c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_1, 0x0011);
40318c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_2, 0x0150);
40328c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_1, 0xfe3e);
40338c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MONO_OUT, 0xc80a);
40348c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e04);
40358c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_MIXER, 0x0000);
40368c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_VOL, 0x0000);
40378c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_DIG_1, 0x0000);
40388c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_DIG_2, 0x0000);
40398c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_PWR_ANLG_1, 0x003e);
40408c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_CTRL_1, 0x0060);
40418c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_CLASSD_0, 0x2021);
40428c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_GLB_CLK, 0x0000);
40438c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_MICBIAS_2, 0x0080);
40448c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_VOL, 0x8080);
40458c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_HP_CHARGE_PUMP_1, 0x0c16);
40468c2ecf20Sopenharmony_ci}
40478c2ecf20Sopenharmony_ci
40488c2ecf20Sopenharmony_cistatic void rt5659_intel_hd_header_probe_setup(struct rt5659_priv *rt5659)
40498c2ecf20Sopenharmony_ci{
40508c2ecf20Sopenharmony_ci	int value;
40518c2ecf20Sopenharmony_ci
40528c2ecf20Sopenharmony_ci	regmap_read(rt5659->regmap, RT5659_GPIO_STA, &value);
40538c2ecf20Sopenharmony_ci	if (!(value & 0x8)) {
40548c2ecf20Sopenharmony_ci		rt5659->hda_hp_plugged = true;
40558c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_1,
40568c2ecf20Sopenharmony_ci			0x10, 0x0);
40578c2ecf20Sopenharmony_ci	} else {
40588c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_1,
40598c2ecf20Sopenharmony_ci			0x10, 0x10);
40608c2ecf20Sopenharmony_ci	}
40618c2ecf20Sopenharmony_ci
40628c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
40638c2ecf20Sopenharmony_ci		RT5659_PWR_VREF2 | RT5659_PWR_MB,
40648c2ecf20Sopenharmony_ci		RT5659_PWR_VREF2 | RT5659_PWR_MB);
40658c2ecf20Sopenharmony_ci	msleep(20);
40668c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
40678c2ecf20Sopenharmony_ci		RT5659_PWR_FV2, RT5659_PWR_FV2);
40688c2ecf20Sopenharmony_ci
40698c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_3, RT5659_PWR_LDO2,
40708c2ecf20Sopenharmony_ci		RT5659_PWR_LDO2);
40718c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_2, RT5659_PWR_MB1,
40728c2ecf20Sopenharmony_ci		RT5659_PWR_MB1);
40738c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_PWR_VOL, RT5659_PWR_MIC_DET,
40748c2ecf20Sopenharmony_ci		RT5659_PWR_MIC_DET);
40758c2ecf20Sopenharmony_ci	msleep(20);
40768c2ecf20Sopenharmony_ci
40778c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_4BTN_IL_CMD_2,
40788c2ecf20Sopenharmony_ci		RT5659_4BTN_IL_MASK, RT5659_4BTN_IL_EN);
40798c2ecf20Sopenharmony_ci	regmap_read(rt5659->regmap, RT5659_4BTN_IL_CMD_1, &value);
40808c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_4BTN_IL_CMD_1, value);
40818c2ecf20Sopenharmony_ci	regmap_read(rt5659->regmap, RT5659_4BTN_IL_CMD_1, &value);
40828c2ecf20Sopenharmony_ci
40838c2ecf20Sopenharmony_ci	if (value & 0x2000) {
40848c2ecf20Sopenharmony_ci		rt5659->hda_mic_plugged = true;
40858c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2,
40868c2ecf20Sopenharmony_ci			0x2, 0x2);
40878c2ecf20Sopenharmony_ci	} else {
40888c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2,
40898c2ecf20Sopenharmony_ci			0x2, 0x0);
40908c2ecf20Sopenharmony_ci	}
40918c2ecf20Sopenharmony_ci
40928c2ecf20Sopenharmony_ci	regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2,
40938c2ecf20Sopenharmony_ci		RT5659_IL_IRQ_MASK, RT5659_IL_IRQ_EN);
40948c2ecf20Sopenharmony_ci}
40958c2ecf20Sopenharmony_ci
40968c2ecf20Sopenharmony_cistatic int rt5659_i2c_probe(struct i2c_client *i2c,
40978c2ecf20Sopenharmony_ci		    const struct i2c_device_id *id)
40988c2ecf20Sopenharmony_ci{
40998c2ecf20Sopenharmony_ci	struct rt5659_platform_data *pdata = dev_get_platdata(&i2c->dev);
41008c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659;
41018c2ecf20Sopenharmony_ci	int ret;
41028c2ecf20Sopenharmony_ci	unsigned int val;
41038c2ecf20Sopenharmony_ci
41048c2ecf20Sopenharmony_ci	rt5659 = devm_kzalloc(&i2c->dev, sizeof(struct rt5659_priv),
41058c2ecf20Sopenharmony_ci		GFP_KERNEL);
41068c2ecf20Sopenharmony_ci
41078c2ecf20Sopenharmony_ci	if (rt5659 == NULL)
41088c2ecf20Sopenharmony_ci		return -ENOMEM;
41098c2ecf20Sopenharmony_ci
41108c2ecf20Sopenharmony_ci	i2c_set_clientdata(i2c, rt5659);
41118c2ecf20Sopenharmony_ci
41128c2ecf20Sopenharmony_ci	if (pdata)
41138c2ecf20Sopenharmony_ci		rt5659->pdata = *pdata;
41148c2ecf20Sopenharmony_ci	else
41158c2ecf20Sopenharmony_ci		rt5659_parse_dt(rt5659, &i2c->dev);
41168c2ecf20Sopenharmony_ci
41178c2ecf20Sopenharmony_ci	rt5659->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev, "ldo1-en",
41188c2ecf20Sopenharmony_ci							GPIOD_OUT_HIGH);
41198c2ecf20Sopenharmony_ci	if (IS_ERR(rt5659->gpiod_ldo1_en))
41208c2ecf20Sopenharmony_ci		dev_warn(&i2c->dev, "Request ldo1-en GPIO failed\n");
41218c2ecf20Sopenharmony_ci
41228c2ecf20Sopenharmony_ci	rt5659->gpiod_reset = devm_gpiod_get_optional(&i2c->dev, "reset",
41238c2ecf20Sopenharmony_ci							GPIOD_OUT_HIGH);
41248c2ecf20Sopenharmony_ci
41258c2ecf20Sopenharmony_ci	/* Sleep for 300 ms miniumum */
41268c2ecf20Sopenharmony_ci	msleep(300);
41278c2ecf20Sopenharmony_ci
41288c2ecf20Sopenharmony_ci	rt5659->regmap = devm_regmap_init_i2c(i2c, &rt5659_regmap);
41298c2ecf20Sopenharmony_ci	if (IS_ERR(rt5659->regmap)) {
41308c2ecf20Sopenharmony_ci		ret = PTR_ERR(rt5659->regmap);
41318c2ecf20Sopenharmony_ci		dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
41328c2ecf20Sopenharmony_ci			ret);
41338c2ecf20Sopenharmony_ci		return ret;
41348c2ecf20Sopenharmony_ci	}
41358c2ecf20Sopenharmony_ci
41368c2ecf20Sopenharmony_ci	regmap_read(rt5659->regmap, RT5659_DEVICE_ID, &val);
41378c2ecf20Sopenharmony_ci	if (val != DEVICE_ID) {
41388c2ecf20Sopenharmony_ci		dev_err(&i2c->dev,
41398c2ecf20Sopenharmony_ci			"Device with ID register %x is not rt5659\n", val);
41408c2ecf20Sopenharmony_ci		return -ENODEV;
41418c2ecf20Sopenharmony_ci	}
41428c2ecf20Sopenharmony_ci
41438c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_RESET, 0);
41448c2ecf20Sopenharmony_ci
41458c2ecf20Sopenharmony_ci	/* Check if MCLK provided */
41468c2ecf20Sopenharmony_ci	rt5659->mclk = devm_clk_get(&i2c->dev, "mclk");
41478c2ecf20Sopenharmony_ci	if (IS_ERR(rt5659->mclk)) {
41488c2ecf20Sopenharmony_ci		if (PTR_ERR(rt5659->mclk) != -ENOENT)
41498c2ecf20Sopenharmony_ci			return PTR_ERR(rt5659->mclk);
41508c2ecf20Sopenharmony_ci		/* Otherwise mark the mclk pointer to NULL */
41518c2ecf20Sopenharmony_ci		rt5659->mclk = NULL;
41528c2ecf20Sopenharmony_ci	}
41538c2ecf20Sopenharmony_ci
41548c2ecf20Sopenharmony_ci	rt5659_calibrate(rt5659);
41558c2ecf20Sopenharmony_ci
41568c2ecf20Sopenharmony_ci	/* line in diff mode*/
41578c2ecf20Sopenharmony_ci	if (rt5659->pdata.in1_diff)
41588c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_IN1_IN2,
41598c2ecf20Sopenharmony_ci			RT5659_IN1_DF_MASK, RT5659_IN1_DF_MASK);
41608c2ecf20Sopenharmony_ci	if (rt5659->pdata.in3_diff)
41618c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_IN3_IN4,
41628c2ecf20Sopenharmony_ci			RT5659_IN3_DF_MASK, RT5659_IN3_DF_MASK);
41638c2ecf20Sopenharmony_ci	if (rt5659->pdata.in4_diff)
41648c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_IN3_IN4,
41658c2ecf20Sopenharmony_ci			RT5659_IN4_DF_MASK, RT5659_IN4_DF_MASK);
41668c2ecf20Sopenharmony_ci
41678c2ecf20Sopenharmony_ci	/* DMIC pin*/
41688c2ecf20Sopenharmony_ci	if (rt5659->pdata.dmic1_data_pin != RT5659_DMIC1_NULL ||
41698c2ecf20Sopenharmony_ci		rt5659->pdata.dmic2_data_pin != RT5659_DMIC2_NULL) {
41708c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
41718c2ecf20Sopenharmony_ci			RT5659_GP2_PIN_MASK, RT5659_GP2_PIN_DMIC1_SCL);
41728c2ecf20Sopenharmony_ci
41738c2ecf20Sopenharmony_ci		switch (rt5659->pdata.dmic1_data_pin) {
41748c2ecf20Sopenharmony_ci		case RT5659_DMIC1_DATA_IN2N:
41758c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
41768c2ecf20Sopenharmony_ci				RT5659_DMIC_1_DP_MASK, RT5659_DMIC_1_DP_IN2N);
41778c2ecf20Sopenharmony_ci			break;
41788c2ecf20Sopenharmony_ci
41798c2ecf20Sopenharmony_ci		case RT5659_DMIC1_DATA_GPIO5:
41808c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap,
41818c2ecf20Sopenharmony_ci				RT5659_GPIO_CTRL_3,
41828c2ecf20Sopenharmony_ci				RT5659_I2S2_PIN_MASK,
41838c2ecf20Sopenharmony_ci				RT5659_I2S2_PIN_GPIO);
41848c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
41858c2ecf20Sopenharmony_ci				RT5659_DMIC_1_DP_MASK, RT5659_DMIC_1_DP_GPIO5);
41868c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
41878c2ecf20Sopenharmony_ci				RT5659_GP5_PIN_MASK, RT5659_GP5_PIN_DMIC1_SDA);
41888c2ecf20Sopenharmony_ci			break;
41898c2ecf20Sopenharmony_ci
41908c2ecf20Sopenharmony_ci		case RT5659_DMIC1_DATA_GPIO9:
41918c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
41928c2ecf20Sopenharmony_ci				RT5659_DMIC_1_DP_MASK, RT5659_DMIC_1_DP_GPIO9);
41938c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
41948c2ecf20Sopenharmony_ci				RT5659_GP9_PIN_MASK, RT5659_GP9_PIN_DMIC1_SDA);
41958c2ecf20Sopenharmony_ci			break;
41968c2ecf20Sopenharmony_ci
41978c2ecf20Sopenharmony_ci		case RT5659_DMIC1_DATA_GPIO11:
41988c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
41998c2ecf20Sopenharmony_ci				RT5659_DMIC_1_DP_MASK, RT5659_DMIC_1_DP_GPIO11);
42008c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
42018c2ecf20Sopenharmony_ci				RT5659_GP11_PIN_MASK,
42028c2ecf20Sopenharmony_ci				RT5659_GP11_PIN_DMIC1_SDA);
42038c2ecf20Sopenharmony_ci			break;
42048c2ecf20Sopenharmony_ci
42058c2ecf20Sopenharmony_ci		default:
42068c2ecf20Sopenharmony_ci			dev_dbg(&i2c->dev, "no DMIC1\n");
42078c2ecf20Sopenharmony_ci			break;
42088c2ecf20Sopenharmony_ci		}
42098c2ecf20Sopenharmony_ci
42108c2ecf20Sopenharmony_ci		switch (rt5659->pdata.dmic2_data_pin) {
42118c2ecf20Sopenharmony_ci		case RT5659_DMIC2_DATA_IN2P:
42128c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap,
42138c2ecf20Sopenharmony_ci				RT5659_DMIC_CTRL_1,
42148c2ecf20Sopenharmony_ci				RT5659_DMIC_2_DP_MASK,
42158c2ecf20Sopenharmony_ci				RT5659_DMIC_2_DP_IN2P);
42168c2ecf20Sopenharmony_ci			break;
42178c2ecf20Sopenharmony_ci
42188c2ecf20Sopenharmony_ci		case RT5659_DMIC2_DATA_GPIO6:
42198c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap,
42208c2ecf20Sopenharmony_ci				RT5659_DMIC_CTRL_1,
42218c2ecf20Sopenharmony_ci				RT5659_DMIC_2_DP_MASK,
42228c2ecf20Sopenharmony_ci				RT5659_DMIC_2_DP_GPIO6);
42238c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap,
42248c2ecf20Sopenharmony_ci				RT5659_GPIO_CTRL_1,
42258c2ecf20Sopenharmony_ci				RT5659_GP6_PIN_MASK,
42268c2ecf20Sopenharmony_ci				RT5659_GP6_PIN_DMIC2_SDA);
42278c2ecf20Sopenharmony_ci			break;
42288c2ecf20Sopenharmony_ci
42298c2ecf20Sopenharmony_ci		case RT5659_DMIC2_DATA_GPIO10:
42308c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap,
42318c2ecf20Sopenharmony_ci				RT5659_DMIC_CTRL_1,
42328c2ecf20Sopenharmony_ci				RT5659_DMIC_2_DP_MASK,
42338c2ecf20Sopenharmony_ci				RT5659_DMIC_2_DP_GPIO10);
42348c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap,
42358c2ecf20Sopenharmony_ci				RT5659_GPIO_CTRL_1,
42368c2ecf20Sopenharmony_ci				RT5659_GP10_PIN_MASK,
42378c2ecf20Sopenharmony_ci				RT5659_GP10_PIN_DMIC2_SDA);
42388c2ecf20Sopenharmony_ci			break;
42398c2ecf20Sopenharmony_ci
42408c2ecf20Sopenharmony_ci		case RT5659_DMIC2_DATA_GPIO12:
42418c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap,
42428c2ecf20Sopenharmony_ci				RT5659_DMIC_CTRL_1,
42438c2ecf20Sopenharmony_ci				RT5659_DMIC_2_DP_MASK,
42448c2ecf20Sopenharmony_ci				RT5659_DMIC_2_DP_GPIO12);
42458c2ecf20Sopenharmony_ci			regmap_update_bits(rt5659->regmap,
42468c2ecf20Sopenharmony_ci				RT5659_GPIO_CTRL_1,
42478c2ecf20Sopenharmony_ci				RT5659_GP12_PIN_MASK,
42488c2ecf20Sopenharmony_ci				RT5659_GP12_PIN_DMIC2_SDA);
42498c2ecf20Sopenharmony_ci			break;
42508c2ecf20Sopenharmony_ci
42518c2ecf20Sopenharmony_ci		default:
42528c2ecf20Sopenharmony_ci			dev_dbg(&i2c->dev, "no DMIC2\n");
42538c2ecf20Sopenharmony_ci			break;
42548c2ecf20Sopenharmony_ci
42558c2ecf20Sopenharmony_ci		}
42568c2ecf20Sopenharmony_ci	} else {
42578c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
42588c2ecf20Sopenharmony_ci			RT5659_GP2_PIN_MASK | RT5659_GP5_PIN_MASK |
42598c2ecf20Sopenharmony_ci			RT5659_GP9_PIN_MASK | RT5659_GP11_PIN_MASK |
42608c2ecf20Sopenharmony_ci			RT5659_GP6_PIN_MASK | RT5659_GP10_PIN_MASK |
42618c2ecf20Sopenharmony_ci			RT5659_GP12_PIN_MASK,
42628c2ecf20Sopenharmony_ci			RT5659_GP2_PIN_GPIO2 | RT5659_GP5_PIN_GPIO5 |
42638c2ecf20Sopenharmony_ci			RT5659_GP9_PIN_GPIO9 | RT5659_GP11_PIN_GPIO11 |
42648c2ecf20Sopenharmony_ci			RT5659_GP6_PIN_GPIO6 | RT5659_GP10_PIN_GPIO10 |
42658c2ecf20Sopenharmony_ci			RT5659_GP12_PIN_GPIO12);
42668c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_DMIC_CTRL_1,
42678c2ecf20Sopenharmony_ci			RT5659_DMIC_1_DP_MASK | RT5659_DMIC_2_DP_MASK,
42688c2ecf20Sopenharmony_ci			RT5659_DMIC_1_DP_IN2N | RT5659_DMIC_2_DP_IN2P);
42698c2ecf20Sopenharmony_ci	}
42708c2ecf20Sopenharmony_ci
42718c2ecf20Sopenharmony_ci	switch (rt5659->pdata.jd_src) {
42728c2ecf20Sopenharmony_ci	case RT5659_JD3:
42738c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_EJD_CTRL_1, 0xa880);
42748c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_RC_CLK_CTRL, 0x9000);
42758c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_GPIO_CTRL_1, 0xc800);
42768c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1,
42778c2ecf20Sopenharmony_ci				RT5659_PWR_MB, RT5659_PWR_MB);
42788c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_PWR_ANLG_2, 0x0001);
42798c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_IRQ_CTRL_2, 0x0040);
42808c2ecf20Sopenharmony_ci		INIT_DELAYED_WORK(&rt5659->jack_detect_work,
42818c2ecf20Sopenharmony_ci			rt5659_jack_detect_work);
42828c2ecf20Sopenharmony_ci		break;
42838c2ecf20Sopenharmony_ci	case RT5659_JD_HDA_HEADER:
42848c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_GPIO_CTRL_3, 0x8000);
42858c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_RC_CLK_CTRL, 0x0900);
42868c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_EJD_CTRL_1,  0x70c0);
42878c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_JD_CTRL_1,   0x2000);
42888c2ecf20Sopenharmony_ci		regmap_write(rt5659->regmap, RT5659_IRQ_CTRL_1,  0x0040);
42898c2ecf20Sopenharmony_ci		INIT_DELAYED_WORK(&rt5659->jack_detect_work,
42908c2ecf20Sopenharmony_ci			rt5659_jack_detect_intel_hd_header);
42918c2ecf20Sopenharmony_ci		rt5659_intel_hd_header_probe_setup(rt5659);
42928c2ecf20Sopenharmony_ci		break;
42938c2ecf20Sopenharmony_ci	default:
42948c2ecf20Sopenharmony_ci		break;
42958c2ecf20Sopenharmony_ci	}
42968c2ecf20Sopenharmony_ci
42978c2ecf20Sopenharmony_ci	if (i2c->irq) {
42988c2ecf20Sopenharmony_ci		ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL,
42998c2ecf20Sopenharmony_ci			rt5659_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
43008c2ecf20Sopenharmony_ci			| IRQF_ONESHOT, "rt5659", rt5659);
43018c2ecf20Sopenharmony_ci		if (ret)
43028c2ecf20Sopenharmony_ci			dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret);
43038c2ecf20Sopenharmony_ci
43048c2ecf20Sopenharmony_ci		/* Enable IRQ output for GPIO1 pin any way */
43058c2ecf20Sopenharmony_ci		regmap_update_bits(rt5659->regmap, RT5659_GPIO_CTRL_1,
43068c2ecf20Sopenharmony_ci				   RT5659_GP1_PIN_MASK, RT5659_GP1_PIN_IRQ);
43078c2ecf20Sopenharmony_ci	}
43088c2ecf20Sopenharmony_ci
43098c2ecf20Sopenharmony_ci	return devm_snd_soc_register_component(&i2c->dev,
43108c2ecf20Sopenharmony_ci			&soc_component_dev_rt5659,
43118c2ecf20Sopenharmony_ci			rt5659_dai, ARRAY_SIZE(rt5659_dai));
43128c2ecf20Sopenharmony_ci}
43138c2ecf20Sopenharmony_ci
43148c2ecf20Sopenharmony_cistatic void rt5659_i2c_shutdown(struct i2c_client *client)
43158c2ecf20Sopenharmony_ci{
43168c2ecf20Sopenharmony_ci	struct rt5659_priv *rt5659 = i2c_get_clientdata(client);
43178c2ecf20Sopenharmony_ci
43188c2ecf20Sopenharmony_ci	regmap_write(rt5659->regmap, RT5659_RESET, 0);
43198c2ecf20Sopenharmony_ci}
43208c2ecf20Sopenharmony_ci
43218c2ecf20Sopenharmony_ci#ifdef CONFIG_OF
43228c2ecf20Sopenharmony_cistatic const struct of_device_id rt5659_of_match[] = {
43238c2ecf20Sopenharmony_ci	{ .compatible = "realtek,rt5658", },
43248c2ecf20Sopenharmony_ci	{ .compatible = "realtek,rt5659", },
43258c2ecf20Sopenharmony_ci	{ },
43268c2ecf20Sopenharmony_ci};
43278c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, rt5659_of_match);
43288c2ecf20Sopenharmony_ci#endif
43298c2ecf20Sopenharmony_ci
43308c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI
43318c2ecf20Sopenharmony_cistatic const struct acpi_device_id rt5659_acpi_match[] = {
43328c2ecf20Sopenharmony_ci	{ "10EC5658", 0, },
43338c2ecf20Sopenharmony_ci	{ "10EC5659", 0, },
43348c2ecf20Sopenharmony_ci	{ },
43358c2ecf20Sopenharmony_ci};
43368c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(acpi, rt5659_acpi_match);
43378c2ecf20Sopenharmony_ci#endif
43388c2ecf20Sopenharmony_ci
43398c2ecf20Sopenharmony_cistatic struct i2c_driver rt5659_i2c_driver = {
43408c2ecf20Sopenharmony_ci	.driver = {
43418c2ecf20Sopenharmony_ci		.name = "rt5659",
43428c2ecf20Sopenharmony_ci		.of_match_table = of_match_ptr(rt5659_of_match),
43438c2ecf20Sopenharmony_ci		.acpi_match_table = ACPI_PTR(rt5659_acpi_match),
43448c2ecf20Sopenharmony_ci	},
43458c2ecf20Sopenharmony_ci	.probe = rt5659_i2c_probe,
43468c2ecf20Sopenharmony_ci	.shutdown = rt5659_i2c_shutdown,
43478c2ecf20Sopenharmony_ci	.id_table = rt5659_i2c_id,
43488c2ecf20Sopenharmony_ci};
43498c2ecf20Sopenharmony_cimodule_i2c_driver(rt5659_i2c_driver);
43508c2ecf20Sopenharmony_ci
43518c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("ASoC RT5659 driver");
43528c2ecf20Sopenharmony_ciMODULE_AUTHOR("Bard Liao <bardliao@realtek.com>");
43538c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
4354