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