Commit e83ce4a51757cf63970a76090662f636112231a7

Authored by Takashi Iwai

Merge tag 'asoc-fix-v3.19-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/…

…broonie/sound into for-linus

ASoC: Fixes for v3.19

A few fixes for v3.19, a few driver specifics and one core fix which
fixes a boot crash on OMAP if deferred probing kicks in due to
attempting to modify static data.

Showing 9 changed files Inline Diff

sound/soc/codecs/rt5677.c
1 /* 1 /*
2 * rt5677.c -- RT5677 ALSA SoC audio codec driver 2 * rt5677.c -- RT5677 ALSA SoC audio codec driver
3 * 3 *
4 * Copyright 2013 Realtek Semiconductor Corp. 4 * Copyright 2013 Realtek Semiconductor Corp.
5 * Author: Oder Chiou <oder_chiou@realtek.com> 5 * Author: Oder Chiou <oder_chiou@realtek.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12 #include <linux/fs.h> 12 #include <linux/fs.h>
13 #include <linux/module.h> 13 #include <linux/module.h>
14 #include <linux/moduleparam.h> 14 #include <linux/moduleparam.h>
15 #include <linux/init.h> 15 #include <linux/init.h>
16 #include <linux/delay.h> 16 #include <linux/delay.h>
17 #include <linux/pm.h> 17 #include <linux/pm.h>
18 #include <linux/of_gpio.h> 18 #include <linux/of_gpio.h>
19 #include <linux/regmap.h> 19 #include <linux/regmap.h>
20 #include <linux/i2c.h> 20 #include <linux/i2c.h>
21 #include <linux/platform_device.h> 21 #include <linux/platform_device.h>
22 #include <linux/spi/spi.h> 22 #include <linux/spi/spi.h>
23 #include <linux/firmware.h> 23 #include <linux/firmware.h>
24 #include <linux/gpio.h> 24 #include <linux/gpio.h>
25 #include <sound/core.h> 25 #include <sound/core.h>
26 #include <sound/pcm.h> 26 #include <sound/pcm.h>
27 #include <sound/pcm_params.h> 27 #include <sound/pcm_params.h>
28 #include <sound/soc.h> 28 #include <sound/soc.h>
29 #include <sound/soc-dapm.h> 29 #include <sound/soc-dapm.h>
30 #include <sound/initval.h> 30 #include <sound/initval.h>
31 #include <sound/tlv.h> 31 #include <sound/tlv.h>
32 32
33 #include "rl6231.h" 33 #include "rl6231.h"
34 #include "rt5677.h" 34 #include "rt5677.h"
35 #include "rt5677-spi.h" 35 #include "rt5677-spi.h"
36 36
37 #define RT5677_DEVICE_ID 0x6327 37 #define RT5677_DEVICE_ID 0x6327
38 38
39 #define RT5677_PR_RANGE_BASE (0xff + 1) 39 #define RT5677_PR_RANGE_BASE (0xff + 1)
40 #define RT5677_PR_SPACING 0x100 40 #define RT5677_PR_SPACING 0x100
41 41
42 #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING)) 42 #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
43 43
44 static const struct regmap_range_cfg rt5677_ranges[] = { 44 static const struct regmap_range_cfg rt5677_ranges[] = {
45 { 45 {
46 .name = "PR", 46 .name = "PR",
47 .range_min = RT5677_PR_BASE, 47 .range_min = RT5677_PR_BASE,
48 .range_max = RT5677_PR_BASE + 0xfd, 48 .range_max = RT5677_PR_BASE + 0xfd,
49 .selector_reg = RT5677_PRIV_INDEX, 49 .selector_reg = RT5677_PRIV_INDEX,
50 .selector_mask = 0xff, 50 .selector_mask = 0xff,
51 .selector_shift = 0x0, 51 .selector_shift = 0x0,
52 .window_start = RT5677_PRIV_DATA, 52 .window_start = RT5677_PRIV_DATA,
53 .window_len = 0x1, 53 .window_len = 0x1,
54 }, 54 },
55 }; 55 };
56 56
57 static const struct reg_default init_list[] = { 57 static const struct reg_default init_list[] = {
58 {RT5677_ASRC_12, 0x0018}, 58 {RT5677_ASRC_12, 0x0018},
59 {RT5677_PR_BASE + 0x3d, 0x364d}, 59 {RT5677_PR_BASE + 0x3d, 0x364d},
60 {RT5677_PR_BASE + 0x17, 0x4fc0}, 60 {RT5677_PR_BASE + 0x17, 0x4fc0},
61 {RT5677_PR_BASE + 0x13, 0x0312}, 61 {RT5677_PR_BASE + 0x13, 0x0312},
62 {RT5677_PR_BASE + 0x1e, 0x0000}, 62 {RT5677_PR_BASE + 0x1e, 0x0000},
63 {RT5677_PR_BASE + 0x12, 0x0eaa}, 63 {RT5677_PR_BASE + 0x12, 0x0eaa},
64 {RT5677_PR_BASE + 0x14, 0x018a}, 64 {RT5677_PR_BASE + 0x14, 0x018a},
65 }; 65 };
66 #define RT5677_INIT_REG_LEN ARRAY_SIZE(init_list) 66 #define RT5677_INIT_REG_LEN ARRAY_SIZE(init_list)
67 67
68 static const struct reg_default rt5677_reg[] = { 68 static const struct reg_default rt5677_reg[] = {
69 {RT5677_RESET , 0x0000}, 69 {RT5677_RESET , 0x0000},
70 {RT5677_LOUT1 , 0xa800}, 70 {RT5677_LOUT1 , 0xa800},
71 {RT5677_IN1 , 0x0000}, 71 {RT5677_IN1 , 0x0000},
72 {RT5677_MICBIAS , 0x0000}, 72 {RT5677_MICBIAS , 0x0000},
73 {RT5677_SLIMBUS_PARAM , 0x0000}, 73 {RT5677_SLIMBUS_PARAM , 0x0000},
74 {RT5677_SLIMBUS_RX , 0x0000}, 74 {RT5677_SLIMBUS_RX , 0x0000},
75 {RT5677_SLIMBUS_CTRL , 0x0000}, 75 {RT5677_SLIMBUS_CTRL , 0x0000},
76 {RT5677_SIDETONE_CTRL , 0x000b}, 76 {RT5677_SIDETONE_CTRL , 0x000b},
77 {RT5677_ANA_DAC1_2_3_SRC , 0x0000}, 77 {RT5677_ANA_DAC1_2_3_SRC , 0x0000},
78 {RT5677_IF_DSP_DAC3_4_MIXER , 0x1111}, 78 {RT5677_IF_DSP_DAC3_4_MIXER , 0x1111},
79 {RT5677_DAC4_DIG_VOL , 0xafaf}, 79 {RT5677_DAC4_DIG_VOL , 0xafaf},
80 {RT5677_DAC3_DIG_VOL , 0xafaf}, 80 {RT5677_DAC3_DIG_VOL , 0xafaf},
81 {RT5677_DAC1_DIG_VOL , 0xafaf}, 81 {RT5677_DAC1_DIG_VOL , 0xafaf},
82 {RT5677_DAC2_DIG_VOL , 0xafaf}, 82 {RT5677_DAC2_DIG_VOL , 0xafaf},
83 {RT5677_IF_DSP_DAC2_MIXER , 0x0011}, 83 {RT5677_IF_DSP_DAC2_MIXER , 0x0011},
84 {RT5677_STO1_ADC_DIG_VOL , 0x2f2f}, 84 {RT5677_STO1_ADC_DIG_VOL , 0x2f2f},
85 {RT5677_MONO_ADC_DIG_VOL , 0x2f2f}, 85 {RT5677_MONO_ADC_DIG_VOL , 0x2f2f},
86 {RT5677_STO1_2_ADC_BST , 0x0000}, 86 {RT5677_STO1_2_ADC_BST , 0x0000},
87 {RT5677_STO2_ADC_DIG_VOL , 0x2f2f}, 87 {RT5677_STO2_ADC_DIG_VOL , 0x2f2f},
88 {RT5677_ADC_BST_CTRL2 , 0x0000}, 88 {RT5677_ADC_BST_CTRL2 , 0x0000},
89 {RT5677_STO3_4_ADC_BST , 0x0000}, 89 {RT5677_STO3_4_ADC_BST , 0x0000},
90 {RT5677_STO3_ADC_DIG_VOL , 0x2f2f}, 90 {RT5677_STO3_ADC_DIG_VOL , 0x2f2f},
91 {RT5677_STO4_ADC_DIG_VOL , 0x2f2f}, 91 {RT5677_STO4_ADC_DIG_VOL , 0x2f2f},
92 {RT5677_STO4_ADC_MIXER , 0xd4c0}, 92 {RT5677_STO4_ADC_MIXER , 0xd4c0},
93 {RT5677_STO3_ADC_MIXER , 0xd4c0}, 93 {RT5677_STO3_ADC_MIXER , 0xd4c0},
94 {RT5677_STO2_ADC_MIXER , 0xd4c0}, 94 {RT5677_STO2_ADC_MIXER , 0xd4c0},
95 {RT5677_STO1_ADC_MIXER , 0xd4c0}, 95 {RT5677_STO1_ADC_MIXER , 0xd4c0},
96 {RT5677_MONO_ADC_MIXER , 0xd4d1}, 96 {RT5677_MONO_ADC_MIXER , 0xd4d1},
97 {RT5677_ADC_IF_DSP_DAC1_MIXER , 0x8080}, 97 {RT5677_ADC_IF_DSP_DAC1_MIXER , 0x8080},
98 {RT5677_STO1_DAC_MIXER , 0xaaaa}, 98 {RT5677_STO1_DAC_MIXER , 0xaaaa},
99 {RT5677_MONO_DAC_MIXER , 0xaaaa}, 99 {RT5677_MONO_DAC_MIXER , 0xaaaa},
100 {RT5677_DD1_MIXER , 0xaaaa}, 100 {RT5677_DD1_MIXER , 0xaaaa},
101 {RT5677_DD2_MIXER , 0xaaaa}, 101 {RT5677_DD2_MIXER , 0xaaaa},
102 {RT5677_IF3_DATA , 0x0000}, 102 {RT5677_IF3_DATA , 0x0000},
103 {RT5677_IF4_DATA , 0x0000}, 103 {RT5677_IF4_DATA , 0x0000},
104 {RT5677_PDM_OUT_CTRL , 0x8888}, 104 {RT5677_PDM_OUT_CTRL , 0x8888},
105 {RT5677_PDM_DATA_CTRL1 , 0x0000}, 105 {RT5677_PDM_DATA_CTRL1 , 0x0000},
106 {RT5677_PDM_DATA_CTRL2 , 0x0000}, 106 {RT5677_PDM_DATA_CTRL2 , 0x0000},
107 {RT5677_PDM1_DATA_CTRL2 , 0x0000}, 107 {RT5677_PDM1_DATA_CTRL2 , 0x0000},
108 {RT5677_PDM1_DATA_CTRL3 , 0x0000}, 108 {RT5677_PDM1_DATA_CTRL3 , 0x0000},
109 {RT5677_PDM1_DATA_CTRL4 , 0x0000}, 109 {RT5677_PDM1_DATA_CTRL4 , 0x0000},
110 {RT5677_PDM2_DATA_CTRL2 , 0x0000}, 110 {RT5677_PDM2_DATA_CTRL2 , 0x0000},
111 {RT5677_PDM2_DATA_CTRL3 , 0x0000}, 111 {RT5677_PDM2_DATA_CTRL3 , 0x0000},
112 {RT5677_PDM2_DATA_CTRL4 , 0x0000}, 112 {RT5677_PDM2_DATA_CTRL4 , 0x0000},
113 {RT5677_TDM1_CTRL1 , 0x0300}, 113 {RT5677_TDM1_CTRL1 , 0x0300},
114 {RT5677_TDM1_CTRL2 , 0x0000}, 114 {RT5677_TDM1_CTRL2 , 0x0000},
115 {RT5677_TDM1_CTRL3 , 0x4000}, 115 {RT5677_TDM1_CTRL3 , 0x4000},
116 {RT5677_TDM1_CTRL4 , 0x0123}, 116 {RT5677_TDM1_CTRL4 , 0x0123},
117 {RT5677_TDM1_CTRL5 , 0x4567}, 117 {RT5677_TDM1_CTRL5 , 0x4567},
118 {RT5677_TDM2_CTRL1 , 0x0300}, 118 {RT5677_TDM2_CTRL1 , 0x0300},
119 {RT5677_TDM2_CTRL2 , 0x0000}, 119 {RT5677_TDM2_CTRL2 , 0x0000},
120 {RT5677_TDM2_CTRL3 , 0x4000}, 120 {RT5677_TDM2_CTRL3 , 0x4000},
121 {RT5677_TDM2_CTRL4 , 0x0123}, 121 {RT5677_TDM2_CTRL4 , 0x0123},
122 {RT5677_TDM2_CTRL5 , 0x4567}, 122 {RT5677_TDM2_CTRL5 , 0x4567},
123 {RT5677_I2C_MASTER_CTRL1 , 0x0001}, 123 {RT5677_I2C_MASTER_CTRL1 , 0x0001},
124 {RT5677_I2C_MASTER_CTRL2 , 0x0000}, 124 {RT5677_I2C_MASTER_CTRL2 , 0x0000},
125 {RT5677_I2C_MASTER_CTRL3 , 0x0000}, 125 {RT5677_I2C_MASTER_CTRL3 , 0x0000},
126 {RT5677_I2C_MASTER_CTRL4 , 0x0000}, 126 {RT5677_I2C_MASTER_CTRL4 , 0x0000},
127 {RT5677_I2C_MASTER_CTRL5 , 0x0000}, 127 {RT5677_I2C_MASTER_CTRL5 , 0x0000},
128 {RT5677_I2C_MASTER_CTRL6 , 0x0000}, 128 {RT5677_I2C_MASTER_CTRL6 , 0x0000},
129 {RT5677_I2C_MASTER_CTRL7 , 0x0000}, 129 {RT5677_I2C_MASTER_CTRL7 , 0x0000},
130 {RT5677_I2C_MASTER_CTRL8 , 0x0000}, 130 {RT5677_I2C_MASTER_CTRL8 , 0x0000},
131 {RT5677_DMIC_CTRL1 , 0x1505}, 131 {RT5677_DMIC_CTRL1 , 0x1505},
132 {RT5677_DMIC_CTRL2 , 0x0055}, 132 {RT5677_DMIC_CTRL2 , 0x0055},
133 {RT5677_HAP_GENE_CTRL1 , 0x0111}, 133 {RT5677_HAP_GENE_CTRL1 , 0x0111},
134 {RT5677_HAP_GENE_CTRL2 , 0x0064}, 134 {RT5677_HAP_GENE_CTRL2 , 0x0064},
135 {RT5677_HAP_GENE_CTRL3 , 0xef0e}, 135 {RT5677_HAP_GENE_CTRL3 , 0xef0e},
136 {RT5677_HAP_GENE_CTRL4 , 0xf0f0}, 136 {RT5677_HAP_GENE_CTRL4 , 0xf0f0},
137 {RT5677_HAP_GENE_CTRL5 , 0xef0e}, 137 {RT5677_HAP_GENE_CTRL5 , 0xef0e},
138 {RT5677_HAP_GENE_CTRL6 , 0xf0f0}, 138 {RT5677_HAP_GENE_CTRL6 , 0xf0f0},
139 {RT5677_HAP_GENE_CTRL7 , 0xef0e}, 139 {RT5677_HAP_GENE_CTRL7 , 0xef0e},
140 {RT5677_HAP_GENE_CTRL8 , 0xf0f0}, 140 {RT5677_HAP_GENE_CTRL8 , 0xf0f0},
141 {RT5677_HAP_GENE_CTRL9 , 0xf000}, 141 {RT5677_HAP_GENE_CTRL9 , 0xf000},
142 {RT5677_HAP_GENE_CTRL10 , 0x0000}, 142 {RT5677_HAP_GENE_CTRL10 , 0x0000},
143 {RT5677_PWR_DIG1 , 0x0000}, 143 {RT5677_PWR_DIG1 , 0x0000},
144 {RT5677_PWR_DIG2 , 0x0000}, 144 {RT5677_PWR_DIG2 , 0x0000},
145 {RT5677_PWR_ANLG1 , 0x0055}, 145 {RT5677_PWR_ANLG1 , 0x0055},
146 {RT5677_PWR_ANLG2 , 0x0000}, 146 {RT5677_PWR_ANLG2 , 0x0000},
147 {RT5677_PWR_DSP1 , 0x0001}, 147 {RT5677_PWR_DSP1 , 0x0001},
148 {RT5677_PWR_DSP_ST , 0x0000}, 148 {RT5677_PWR_DSP_ST , 0x0000},
149 {RT5677_PWR_DSP2 , 0x0000}, 149 {RT5677_PWR_DSP2 , 0x0000},
150 {RT5677_ADC_DAC_HPF_CTRL1 , 0x0e00}, 150 {RT5677_ADC_DAC_HPF_CTRL1 , 0x0e00},
151 {RT5677_PRIV_INDEX , 0x0000}, 151 {RT5677_PRIV_INDEX , 0x0000},
152 {RT5677_PRIV_DATA , 0x0000}, 152 {RT5677_PRIV_DATA , 0x0000},
153 {RT5677_I2S4_SDP , 0x8000}, 153 {RT5677_I2S4_SDP , 0x8000},
154 {RT5677_I2S1_SDP , 0x8000}, 154 {RT5677_I2S1_SDP , 0x8000},
155 {RT5677_I2S2_SDP , 0x8000}, 155 {RT5677_I2S2_SDP , 0x8000},
156 {RT5677_I2S3_SDP , 0x8000}, 156 {RT5677_I2S3_SDP , 0x8000},
157 {RT5677_CLK_TREE_CTRL1 , 0x1111}, 157 {RT5677_CLK_TREE_CTRL1 , 0x1111},
158 {RT5677_CLK_TREE_CTRL2 , 0x1111}, 158 {RT5677_CLK_TREE_CTRL2 , 0x1111},
159 {RT5677_CLK_TREE_CTRL3 , 0x0000}, 159 {RT5677_CLK_TREE_CTRL3 , 0x0000},
160 {RT5677_PLL1_CTRL1 , 0x0000}, 160 {RT5677_PLL1_CTRL1 , 0x0000},
161 {RT5677_PLL1_CTRL2 , 0x0000}, 161 {RT5677_PLL1_CTRL2 , 0x0000},
162 {RT5677_PLL2_CTRL1 , 0x0c60}, 162 {RT5677_PLL2_CTRL1 , 0x0c60},
163 {RT5677_PLL2_CTRL2 , 0x2000}, 163 {RT5677_PLL2_CTRL2 , 0x2000},
164 {RT5677_GLB_CLK1 , 0x0000}, 164 {RT5677_GLB_CLK1 , 0x0000},
165 {RT5677_GLB_CLK2 , 0x0000}, 165 {RT5677_GLB_CLK2 , 0x0000},
166 {RT5677_ASRC_1 , 0x0000}, 166 {RT5677_ASRC_1 , 0x0000},
167 {RT5677_ASRC_2 , 0x0000}, 167 {RT5677_ASRC_2 , 0x0000},
168 {RT5677_ASRC_3 , 0x0000}, 168 {RT5677_ASRC_3 , 0x0000},
169 {RT5677_ASRC_4 , 0x0000}, 169 {RT5677_ASRC_4 , 0x0000},
170 {RT5677_ASRC_5 , 0x0000}, 170 {RT5677_ASRC_5 , 0x0000},
171 {RT5677_ASRC_6 , 0x0000}, 171 {RT5677_ASRC_6 , 0x0000},
172 {RT5677_ASRC_7 , 0x0000}, 172 {RT5677_ASRC_7 , 0x0000},
173 {RT5677_ASRC_8 , 0x0000}, 173 {RT5677_ASRC_8 , 0x0000},
174 {RT5677_ASRC_9 , 0x0000}, 174 {RT5677_ASRC_9 , 0x0000},
175 {RT5677_ASRC_10 , 0x0000}, 175 {RT5677_ASRC_10 , 0x0000},
176 {RT5677_ASRC_11 , 0x0000}, 176 {RT5677_ASRC_11 , 0x0000},
177 {RT5677_ASRC_12 , 0x0018}, 177 {RT5677_ASRC_12 , 0x0018},
178 {RT5677_ASRC_13 , 0x0000}, 178 {RT5677_ASRC_13 , 0x0000},
179 {RT5677_ASRC_14 , 0x0000}, 179 {RT5677_ASRC_14 , 0x0000},
180 {RT5677_ASRC_15 , 0x0000}, 180 {RT5677_ASRC_15 , 0x0000},
181 {RT5677_ASRC_16 , 0x0000}, 181 {RT5677_ASRC_16 , 0x0000},
182 {RT5677_ASRC_17 , 0x0000}, 182 {RT5677_ASRC_17 , 0x0000},
183 {RT5677_ASRC_18 , 0x0000}, 183 {RT5677_ASRC_18 , 0x0000},
184 {RT5677_ASRC_19 , 0x0000}, 184 {RT5677_ASRC_19 , 0x0000},
185 {RT5677_ASRC_20 , 0x0000}, 185 {RT5677_ASRC_20 , 0x0000},
186 {RT5677_ASRC_21 , 0x000c}, 186 {RT5677_ASRC_21 , 0x000c},
187 {RT5677_ASRC_22 , 0x0000}, 187 {RT5677_ASRC_22 , 0x0000},
188 {RT5677_ASRC_23 , 0x0000}, 188 {RT5677_ASRC_23 , 0x0000},
189 {RT5677_VAD_CTRL1 , 0x2184}, 189 {RT5677_VAD_CTRL1 , 0x2184},
190 {RT5677_VAD_CTRL2 , 0x010a}, 190 {RT5677_VAD_CTRL2 , 0x010a},
191 {RT5677_VAD_CTRL3 , 0x0aea}, 191 {RT5677_VAD_CTRL3 , 0x0aea},
192 {RT5677_VAD_CTRL4 , 0x000c}, 192 {RT5677_VAD_CTRL4 , 0x000c},
193 {RT5677_VAD_CTRL5 , 0x0000}, 193 {RT5677_VAD_CTRL5 , 0x0000},
194 {RT5677_DSP_INB_CTRL1 , 0x0000}, 194 {RT5677_DSP_INB_CTRL1 , 0x0000},
195 {RT5677_DSP_INB_CTRL2 , 0x0000}, 195 {RT5677_DSP_INB_CTRL2 , 0x0000},
196 {RT5677_DSP_IN_OUTB_CTRL , 0x0000}, 196 {RT5677_DSP_IN_OUTB_CTRL , 0x0000},
197 {RT5677_DSP_OUTB0_1_DIG_VOL , 0x2f2f}, 197 {RT5677_DSP_OUTB0_1_DIG_VOL , 0x2f2f},
198 {RT5677_DSP_OUTB2_3_DIG_VOL , 0x2f2f}, 198 {RT5677_DSP_OUTB2_3_DIG_VOL , 0x2f2f},
199 {RT5677_DSP_OUTB4_5_DIG_VOL , 0x2f2f}, 199 {RT5677_DSP_OUTB4_5_DIG_VOL , 0x2f2f},
200 {RT5677_DSP_OUTB6_7_DIG_VOL , 0x2f2f}, 200 {RT5677_DSP_OUTB6_7_DIG_VOL , 0x2f2f},
201 {RT5677_ADC_EQ_CTRL1 , 0x6000}, 201 {RT5677_ADC_EQ_CTRL1 , 0x6000},
202 {RT5677_ADC_EQ_CTRL2 , 0x0000}, 202 {RT5677_ADC_EQ_CTRL2 , 0x0000},
203 {RT5677_EQ_CTRL1 , 0xc000}, 203 {RT5677_EQ_CTRL1 , 0xc000},
204 {RT5677_EQ_CTRL2 , 0x0000}, 204 {RT5677_EQ_CTRL2 , 0x0000},
205 {RT5677_EQ_CTRL3 , 0x0000}, 205 {RT5677_EQ_CTRL3 , 0x0000},
206 {RT5677_SOFT_VOL_ZERO_CROSS1 , 0x0009}, 206 {RT5677_SOFT_VOL_ZERO_CROSS1 , 0x0009},
207 {RT5677_JD_CTRL1 , 0x0000}, 207 {RT5677_JD_CTRL1 , 0x0000},
208 {RT5677_JD_CTRL2 , 0x0000}, 208 {RT5677_JD_CTRL2 , 0x0000},
209 {RT5677_JD_CTRL3 , 0x0000}, 209 {RT5677_JD_CTRL3 , 0x0000},
210 {RT5677_IRQ_CTRL1 , 0x0000}, 210 {RT5677_IRQ_CTRL1 , 0x0000},
211 {RT5677_IRQ_CTRL2 , 0x0000}, 211 {RT5677_IRQ_CTRL2 , 0x0000},
212 {RT5677_GPIO_ST , 0x0000}, 212 {RT5677_GPIO_ST , 0x0000},
213 {RT5677_GPIO_CTRL1 , 0x0000}, 213 {RT5677_GPIO_CTRL1 , 0x0000},
214 {RT5677_GPIO_CTRL2 , 0x0000}, 214 {RT5677_GPIO_CTRL2 , 0x0000},
215 {RT5677_GPIO_CTRL3 , 0x0000}, 215 {RT5677_GPIO_CTRL3 , 0x0000},
216 {RT5677_STO1_ADC_HI_FILTER1 , 0xb320}, 216 {RT5677_STO1_ADC_HI_FILTER1 , 0xb320},
217 {RT5677_STO1_ADC_HI_FILTER2 , 0x0000}, 217 {RT5677_STO1_ADC_HI_FILTER2 , 0x0000},
218 {RT5677_MONO_ADC_HI_FILTER1 , 0xb300}, 218 {RT5677_MONO_ADC_HI_FILTER1 , 0xb300},
219 {RT5677_MONO_ADC_HI_FILTER2 , 0x0000}, 219 {RT5677_MONO_ADC_HI_FILTER2 , 0x0000},
220 {RT5677_STO2_ADC_HI_FILTER1 , 0xb300}, 220 {RT5677_STO2_ADC_HI_FILTER1 , 0xb300},
221 {RT5677_STO2_ADC_HI_FILTER2 , 0x0000}, 221 {RT5677_STO2_ADC_HI_FILTER2 , 0x0000},
222 {RT5677_STO3_ADC_HI_FILTER1 , 0xb300}, 222 {RT5677_STO3_ADC_HI_FILTER1 , 0xb300},
223 {RT5677_STO3_ADC_HI_FILTER2 , 0x0000}, 223 {RT5677_STO3_ADC_HI_FILTER2 , 0x0000},
224 {RT5677_STO4_ADC_HI_FILTER1 , 0xb300}, 224 {RT5677_STO4_ADC_HI_FILTER1 , 0xb300},
225 {RT5677_STO4_ADC_HI_FILTER2 , 0x0000}, 225 {RT5677_STO4_ADC_HI_FILTER2 , 0x0000},
226 {RT5677_MB_DRC_CTRL1 , 0x0f20}, 226 {RT5677_MB_DRC_CTRL1 , 0x0f20},
227 {RT5677_DRC1_CTRL1 , 0x001f}, 227 {RT5677_DRC1_CTRL1 , 0x001f},
228 {RT5677_DRC1_CTRL2 , 0x020c}, 228 {RT5677_DRC1_CTRL2 , 0x020c},
229 {RT5677_DRC1_CTRL3 , 0x1f00}, 229 {RT5677_DRC1_CTRL3 , 0x1f00},
230 {RT5677_DRC1_CTRL4 , 0x0000}, 230 {RT5677_DRC1_CTRL4 , 0x0000},
231 {RT5677_DRC1_CTRL5 , 0x0000}, 231 {RT5677_DRC1_CTRL5 , 0x0000},
232 {RT5677_DRC1_CTRL6 , 0x0029}, 232 {RT5677_DRC1_CTRL6 , 0x0029},
233 {RT5677_DRC2_CTRL1 , 0x001f}, 233 {RT5677_DRC2_CTRL1 , 0x001f},
234 {RT5677_DRC2_CTRL2 , 0x020c}, 234 {RT5677_DRC2_CTRL2 , 0x020c},
235 {RT5677_DRC2_CTRL3 , 0x1f00}, 235 {RT5677_DRC2_CTRL3 , 0x1f00},
236 {RT5677_DRC2_CTRL4 , 0x0000}, 236 {RT5677_DRC2_CTRL4 , 0x0000},
237 {RT5677_DRC2_CTRL5 , 0x0000}, 237 {RT5677_DRC2_CTRL5 , 0x0000},
238 {RT5677_DRC2_CTRL6 , 0x0029}, 238 {RT5677_DRC2_CTRL6 , 0x0029},
239 {RT5677_DRC1_HL_CTRL1 , 0x8000}, 239 {RT5677_DRC1_HL_CTRL1 , 0x8000},
240 {RT5677_DRC1_HL_CTRL2 , 0x0200}, 240 {RT5677_DRC1_HL_CTRL2 , 0x0200},
241 {RT5677_DRC2_HL_CTRL1 , 0x8000}, 241 {RT5677_DRC2_HL_CTRL1 , 0x8000},
242 {RT5677_DRC2_HL_CTRL2 , 0x0200}, 242 {RT5677_DRC2_HL_CTRL2 , 0x0200},
243 {RT5677_DSP_INB1_SRC_CTRL1 , 0x5800}, 243 {RT5677_DSP_INB1_SRC_CTRL1 , 0x5800},
244 {RT5677_DSP_INB1_SRC_CTRL2 , 0x0000}, 244 {RT5677_DSP_INB1_SRC_CTRL2 , 0x0000},
245 {RT5677_DSP_INB1_SRC_CTRL3 , 0x0000}, 245 {RT5677_DSP_INB1_SRC_CTRL3 , 0x0000},
246 {RT5677_DSP_INB1_SRC_CTRL4 , 0x0800}, 246 {RT5677_DSP_INB1_SRC_CTRL4 , 0x0800},
247 {RT5677_DSP_INB2_SRC_CTRL1 , 0x5800}, 247 {RT5677_DSP_INB2_SRC_CTRL1 , 0x5800},
248 {RT5677_DSP_INB2_SRC_CTRL2 , 0x0000}, 248 {RT5677_DSP_INB2_SRC_CTRL2 , 0x0000},
249 {RT5677_DSP_INB2_SRC_CTRL3 , 0x0000}, 249 {RT5677_DSP_INB2_SRC_CTRL3 , 0x0000},
250 {RT5677_DSP_INB2_SRC_CTRL4 , 0x0800}, 250 {RT5677_DSP_INB2_SRC_CTRL4 , 0x0800},
251 {RT5677_DSP_INB3_SRC_CTRL1 , 0x5800}, 251 {RT5677_DSP_INB3_SRC_CTRL1 , 0x5800},
252 {RT5677_DSP_INB3_SRC_CTRL2 , 0x0000}, 252 {RT5677_DSP_INB3_SRC_CTRL2 , 0x0000},
253 {RT5677_DSP_INB3_SRC_CTRL3 , 0x0000}, 253 {RT5677_DSP_INB3_SRC_CTRL3 , 0x0000},
254 {RT5677_DSP_INB3_SRC_CTRL4 , 0x0800}, 254 {RT5677_DSP_INB3_SRC_CTRL4 , 0x0800},
255 {RT5677_DSP_OUTB1_SRC_CTRL1 , 0x5800}, 255 {RT5677_DSP_OUTB1_SRC_CTRL1 , 0x5800},
256 {RT5677_DSP_OUTB1_SRC_CTRL2 , 0x0000}, 256 {RT5677_DSP_OUTB1_SRC_CTRL2 , 0x0000},
257 {RT5677_DSP_OUTB1_SRC_CTRL3 , 0x0000}, 257 {RT5677_DSP_OUTB1_SRC_CTRL3 , 0x0000},
258 {RT5677_DSP_OUTB1_SRC_CTRL4 , 0x0800}, 258 {RT5677_DSP_OUTB1_SRC_CTRL4 , 0x0800},
259 {RT5677_DSP_OUTB2_SRC_CTRL1 , 0x5800}, 259 {RT5677_DSP_OUTB2_SRC_CTRL1 , 0x5800},
260 {RT5677_DSP_OUTB2_SRC_CTRL2 , 0x0000}, 260 {RT5677_DSP_OUTB2_SRC_CTRL2 , 0x0000},
261 {RT5677_DSP_OUTB2_SRC_CTRL3 , 0x0000}, 261 {RT5677_DSP_OUTB2_SRC_CTRL3 , 0x0000},
262 {RT5677_DSP_OUTB2_SRC_CTRL4 , 0x0800}, 262 {RT5677_DSP_OUTB2_SRC_CTRL4 , 0x0800},
263 {RT5677_DSP_OUTB_0123_MIXER_CTRL, 0xfefe}, 263 {RT5677_DSP_OUTB_0123_MIXER_CTRL, 0xfefe},
264 {RT5677_DSP_OUTB_45_MIXER_CTRL , 0xfefe}, 264 {RT5677_DSP_OUTB_45_MIXER_CTRL , 0xfefe},
265 {RT5677_DSP_OUTB_67_MIXER_CTRL , 0xfefe}, 265 {RT5677_DSP_OUTB_67_MIXER_CTRL , 0xfefe},
266 {RT5677_DIG_MISC , 0x0000}, 266 {RT5677_DIG_MISC , 0x0000},
267 {RT5677_GEN_CTRL1 , 0x0000}, 267 {RT5677_GEN_CTRL1 , 0x0000},
268 {RT5677_GEN_CTRL2 , 0x0000}, 268 {RT5677_GEN_CTRL2 , 0x0000},
269 {RT5677_VENDOR_ID , 0x0000}, 269 {RT5677_VENDOR_ID , 0x0000},
270 {RT5677_VENDOR_ID1 , 0x10ec}, 270 {RT5677_VENDOR_ID1 , 0x10ec},
271 {RT5677_VENDOR_ID2 , 0x6327}, 271 {RT5677_VENDOR_ID2 , 0x6327},
272 }; 272 };
273 273
274 static bool rt5677_volatile_register(struct device *dev, unsigned int reg) 274 static bool rt5677_volatile_register(struct device *dev, unsigned int reg)
275 { 275 {
276 int i; 276 int i;
277 277
278 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) { 278 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
279 if (reg >= rt5677_ranges[i].range_min && 279 if (reg >= rt5677_ranges[i].range_min &&
280 reg <= rt5677_ranges[i].range_max) { 280 reg <= rt5677_ranges[i].range_max) {
281 return true; 281 return true;
282 } 282 }
283 } 283 }
284 284
285 switch (reg) { 285 switch (reg) {
286 case RT5677_RESET: 286 case RT5677_RESET:
287 case RT5677_SLIMBUS_PARAM: 287 case RT5677_SLIMBUS_PARAM:
288 case RT5677_PDM_DATA_CTRL1: 288 case RT5677_PDM_DATA_CTRL1:
289 case RT5677_PDM_DATA_CTRL2: 289 case RT5677_PDM_DATA_CTRL2:
290 case RT5677_PDM1_DATA_CTRL4: 290 case RT5677_PDM1_DATA_CTRL4:
291 case RT5677_PDM2_DATA_CTRL4: 291 case RT5677_PDM2_DATA_CTRL4:
292 case RT5677_I2C_MASTER_CTRL1: 292 case RT5677_I2C_MASTER_CTRL1:
293 case RT5677_I2C_MASTER_CTRL7: 293 case RT5677_I2C_MASTER_CTRL7:
294 case RT5677_I2C_MASTER_CTRL8: 294 case RT5677_I2C_MASTER_CTRL8:
295 case RT5677_HAP_GENE_CTRL2: 295 case RT5677_HAP_GENE_CTRL2:
296 case RT5677_PWR_DSP_ST: 296 case RT5677_PWR_DSP_ST:
297 case RT5677_PRIV_DATA: 297 case RT5677_PRIV_DATA:
298 case RT5677_PLL1_CTRL2: 298 case RT5677_PLL1_CTRL2:
299 case RT5677_PLL2_CTRL2: 299 case RT5677_PLL2_CTRL2:
300 case RT5677_ASRC_22: 300 case RT5677_ASRC_22:
301 case RT5677_ASRC_23: 301 case RT5677_ASRC_23:
302 case RT5677_VAD_CTRL5: 302 case RT5677_VAD_CTRL5:
303 case RT5677_ADC_EQ_CTRL1: 303 case RT5677_ADC_EQ_CTRL1:
304 case RT5677_EQ_CTRL1: 304 case RT5677_EQ_CTRL1:
305 case RT5677_IRQ_CTRL1: 305 case RT5677_IRQ_CTRL1:
306 case RT5677_IRQ_CTRL2: 306 case RT5677_IRQ_CTRL2:
307 case RT5677_GPIO_ST: 307 case RT5677_GPIO_ST:
308 case RT5677_DSP_INB1_SRC_CTRL4: 308 case RT5677_DSP_INB1_SRC_CTRL4:
309 case RT5677_DSP_INB2_SRC_CTRL4: 309 case RT5677_DSP_INB2_SRC_CTRL4:
310 case RT5677_DSP_INB3_SRC_CTRL4: 310 case RT5677_DSP_INB3_SRC_CTRL4:
311 case RT5677_DSP_OUTB1_SRC_CTRL4: 311 case RT5677_DSP_OUTB1_SRC_CTRL4:
312 case RT5677_DSP_OUTB2_SRC_CTRL4: 312 case RT5677_DSP_OUTB2_SRC_CTRL4:
313 case RT5677_VENDOR_ID: 313 case RT5677_VENDOR_ID:
314 case RT5677_VENDOR_ID1: 314 case RT5677_VENDOR_ID1:
315 case RT5677_VENDOR_ID2: 315 case RT5677_VENDOR_ID2:
316 return true; 316 return true;
317 default: 317 default:
318 return false; 318 return false;
319 } 319 }
320 } 320 }
321 321
322 static bool rt5677_readable_register(struct device *dev, unsigned int reg) 322 static bool rt5677_readable_register(struct device *dev, unsigned int reg)
323 { 323 {
324 int i; 324 int i;
325 325
326 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) { 326 for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
327 if (reg >= rt5677_ranges[i].range_min && 327 if (reg >= rt5677_ranges[i].range_min &&
328 reg <= rt5677_ranges[i].range_max) { 328 reg <= rt5677_ranges[i].range_max) {
329 return true; 329 return true;
330 } 330 }
331 } 331 }
332 332
333 switch (reg) { 333 switch (reg) {
334 case RT5677_RESET: 334 case RT5677_RESET:
335 case RT5677_LOUT1: 335 case RT5677_LOUT1:
336 case RT5677_IN1: 336 case RT5677_IN1:
337 case RT5677_MICBIAS: 337 case RT5677_MICBIAS:
338 case RT5677_SLIMBUS_PARAM: 338 case RT5677_SLIMBUS_PARAM:
339 case RT5677_SLIMBUS_RX: 339 case RT5677_SLIMBUS_RX:
340 case RT5677_SLIMBUS_CTRL: 340 case RT5677_SLIMBUS_CTRL:
341 case RT5677_SIDETONE_CTRL: 341 case RT5677_SIDETONE_CTRL:
342 case RT5677_ANA_DAC1_2_3_SRC: 342 case RT5677_ANA_DAC1_2_3_SRC:
343 case RT5677_IF_DSP_DAC3_4_MIXER: 343 case RT5677_IF_DSP_DAC3_4_MIXER:
344 case RT5677_DAC4_DIG_VOL: 344 case RT5677_DAC4_DIG_VOL:
345 case RT5677_DAC3_DIG_VOL: 345 case RT5677_DAC3_DIG_VOL:
346 case RT5677_DAC1_DIG_VOL: 346 case RT5677_DAC1_DIG_VOL:
347 case RT5677_DAC2_DIG_VOL: 347 case RT5677_DAC2_DIG_VOL:
348 case RT5677_IF_DSP_DAC2_MIXER: 348 case RT5677_IF_DSP_DAC2_MIXER:
349 case RT5677_STO1_ADC_DIG_VOL: 349 case RT5677_STO1_ADC_DIG_VOL:
350 case RT5677_MONO_ADC_DIG_VOL: 350 case RT5677_MONO_ADC_DIG_VOL:
351 case RT5677_STO1_2_ADC_BST: 351 case RT5677_STO1_2_ADC_BST:
352 case RT5677_STO2_ADC_DIG_VOL: 352 case RT5677_STO2_ADC_DIG_VOL:
353 case RT5677_ADC_BST_CTRL2: 353 case RT5677_ADC_BST_CTRL2:
354 case RT5677_STO3_4_ADC_BST: 354 case RT5677_STO3_4_ADC_BST:
355 case RT5677_STO3_ADC_DIG_VOL: 355 case RT5677_STO3_ADC_DIG_VOL:
356 case RT5677_STO4_ADC_DIG_VOL: 356 case RT5677_STO4_ADC_DIG_VOL:
357 case RT5677_STO4_ADC_MIXER: 357 case RT5677_STO4_ADC_MIXER:
358 case RT5677_STO3_ADC_MIXER: 358 case RT5677_STO3_ADC_MIXER:
359 case RT5677_STO2_ADC_MIXER: 359 case RT5677_STO2_ADC_MIXER:
360 case RT5677_STO1_ADC_MIXER: 360 case RT5677_STO1_ADC_MIXER:
361 case RT5677_MONO_ADC_MIXER: 361 case RT5677_MONO_ADC_MIXER:
362 case RT5677_ADC_IF_DSP_DAC1_MIXER: 362 case RT5677_ADC_IF_DSP_DAC1_MIXER:
363 case RT5677_STO1_DAC_MIXER: 363 case RT5677_STO1_DAC_MIXER:
364 case RT5677_MONO_DAC_MIXER: 364 case RT5677_MONO_DAC_MIXER:
365 case RT5677_DD1_MIXER: 365 case RT5677_DD1_MIXER:
366 case RT5677_DD2_MIXER: 366 case RT5677_DD2_MIXER:
367 case RT5677_IF3_DATA: 367 case RT5677_IF3_DATA:
368 case RT5677_IF4_DATA: 368 case RT5677_IF4_DATA:
369 case RT5677_PDM_OUT_CTRL: 369 case RT5677_PDM_OUT_CTRL:
370 case RT5677_PDM_DATA_CTRL1: 370 case RT5677_PDM_DATA_CTRL1:
371 case RT5677_PDM_DATA_CTRL2: 371 case RT5677_PDM_DATA_CTRL2:
372 case RT5677_PDM1_DATA_CTRL2: 372 case RT5677_PDM1_DATA_CTRL2:
373 case RT5677_PDM1_DATA_CTRL3: 373 case RT5677_PDM1_DATA_CTRL3:
374 case RT5677_PDM1_DATA_CTRL4: 374 case RT5677_PDM1_DATA_CTRL4:
375 case RT5677_PDM2_DATA_CTRL2: 375 case RT5677_PDM2_DATA_CTRL2:
376 case RT5677_PDM2_DATA_CTRL3: 376 case RT5677_PDM2_DATA_CTRL3:
377 case RT5677_PDM2_DATA_CTRL4: 377 case RT5677_PDM2_DATA_CTRL4:
378 case RT5677_TDM1_CTRL1: 378 case RT5677_TDM1_CTRL1:
379 case RT5677_TDM1_CTRL2: 379 case RT5677_TDM1_CTRL2:
380 case RT5677_TDM1_CTRL3: 380 case RT5677_TDM1_CTRL3:
381 case RT5677_TDM1_CTRL4: 381 case RT5677_TDM1_CTRL4:
382 case RT5677_TDM1_CTRL5: 382 case RT5677_TDM1_CTRL5:
383 case RT5677_TDM2_CTRL1: 383 case RT5677_TDM2_CTRL1:
384 case RT5677_TDM2_CTRL2: 384 case RT5677_TDM2_CTRL2:
385 case RT5677_TDM2_CTRL3: 385 case RT5677_TDM2_CTRL3:
386 case RT5677_TDM2_CTRL4: 386 case RT5677_TDM2_CTRL4:
387 case RT5677_TDM2_CTRL5: 387 case RT5677_TDM2_CTRL5:
388 case RT5677_I2C_MASTER_CTRL1: 388 case RT5677_I2C_MASTER_CTRL1:
389 case RT5677_I2C_MASTER_CTRL2: 389 case RT5677_I2C_MASTER_CTRL2:
390 case RT5677_I2C_MASTER_CTRL3: 390 case RT5677_I2C_MASTER_CTRL3:
391 case RT5677_I2C_MASTER_CTRL4: 391 case RT5677_I2C_MASTER_CTRL4:
392 case RT5677_I2C_MASTER_CTRL5: 392 case RT5677_I2C_MASTER_CTRL5:
393 case RT5677_I2C_MASTER_CTRL6: 393 case RT5677_I2C_MASTER_CTRL6:
394 case RT5677_I2C_MASTER_CTRL7: 394 case RT5677_I2C_MASTER_CTRL7:
395 case RT5677_I2C_MASTER_CTRL8: 395 case RT5677_I2C_MASTER_CTRL8:
396 case RT5677_DMIC_CTRL1: 396 case RT5677_DMIC_CTRL1:
397 case RT5677_DMIC_CTRL2: 397 case RT5677_DMIC_CTRL2:
398 case RT5677_HAP_GENE_CTRL1: 398 case RT5677_HAP_GENE_CTRL1:
399 case RT5677_HAP_GENE_CTRL2: 399 case RT5677_HAP_GENE_CTRL2:
400 case RT5677_HAP_GENE_CTRL3: 400 case RT5677_HAP_GENE_CTRL3:
401 case RT5677_HAP_GENE_CTRL4: 401 case RT5677_HAP_GENE_CTRL4:
402 case RT5677_HAP_GENE_CTRL5: 402 case RT5677_HAP_GENE_CTRL5:
403 case RT5677_HAP_GENE_CTRL6: 403 case RT5677_HAP_GENE_CTRL6:
404 case RT5677_HAP_GENE_CTRL7: 404 case RT5677_HAP_GENE_CTRL7:
405 case RT5677_HAP_GENE_CTRL8: 405 case RT5677_HAP_GENE_CTRL8:
406 case RT5677_HAP_GENE_CTRL9: 406 case RT5677_HAP_GENE_CTRL9:
407 case RT5677_HAP_GENE_CTRL10: 407 case RT5677_HAP_GENE_CTRL10:
408 case RT5677_PWR_DIG1: 408 case RT5677_PWR_DIG1:
409 case RT5677_PWR_DIG2: 409 case RT5677_PWR_DIG2:
410 case RT5677_PWR_ANLG1: 410 case RT5677_PWR_ANLG1:
411 case RT5677_PWR_ANLG2: 411 case RT5677_PWR_ANLG2:
412 case RT5677_PWR_DSP1: 412 case RT5677_PWR_DSP1:
413 case RT5677_PWR_DSP_ST: 413 case RT5677_PWR_DSP_ST:
414 case RT5677_PWR_DSP2: 414 case RT5677_PWR_DSP2:
415 case RT5677_ADC_DAC_HPF_CTRL1: 415 case RT5677_ADC_DAC_HPF_CTRL1:
416 case RT5677_PRIV_INDEX: 416 case RT5677_PRIV_INDEX:
417 case RT5677_PRIV_DATA: 417 case RT5677_PRIV_DATA:
418 case RT5677_I2S4_SDP: 418 case RT5677_I2S4_SDP:
419 case RT5677_I2S1_SDP: 419 case RT5677_I2S1_SDP:
420 case RT5677_I2S2_SDP: 420 case RT5677_I2S2_SDP:
421 case RT5677_I2S3_SDP: 421 case RT5677_I2S3_SDP:
422 case RT5677_CLK_TREE_CTRL1: 422 case RT5677_CLK_TREE_CTRL1:
423 case RT5677_CLK_TREE_CTRL2: 423 case RT5677_CLK_TREE_CTRL2:
424 case RT5677_CLK_TREE_CTRL3: 424 case RT5677_CLK_TREE_CTRL3:
425 case RT5677_PLL1_CTRL1: 425 case RT5677_PLL1_CTRL1:
426 case RT5677_PLL1_CTRL2: 426 case RT5677_PLL1_CTRL2:
427 case RT5677_PLL2_CTRL1: 427 case RT5677_PLL2_CTRL1:
428 case RT5677_PLL2_CTRL2: 428 case RT5677_PLL2_CTRL2:
429 case RT5677_GLB_CLK1: 429 case RT5677_GLB_CLK1:
430 case RT5677_GLB_CLK2: 430 case RT5677_GLB_CLK2:
431 case RT5677_ASRC_1: 431 case RT5677_ASRC_1:
432 case RT5677_ASRC_2: 432 case RT5677_ASRC_2:
433 case RT5677_ASRC_3: 433 case RT5677_ASRC_3:
434 case RT5677_ASRC_4: 434 case RT5677_ASRC_4:
435 case RT5677_ASRC_5: 435 case RT5677_ASRC_5:
436 case RT5677_ASRC_6: 436 case RT5677_ASRC_6:
437 case RT5677_ASRC_7: 437 case RT5677_ASRC_7:
438 case RT5677_ASRC_8: 438 case RT5677_ASRC_8:
439 case RT5677_ASRC_9: 439 case RT5677_ASRC_9:
440 case RT5677_ASRC_10: 440 case RT5677_ASRC_10:
441 case RT5677_ASRC_11: 441 case RT5677_ASRC_11:
442 case RT5677_ASRC_12: 442 case RT5677_ASRC_12:
443 case RT5677_ASRC_13: 443 case RT5677_ASRC_13:
444 case RT5677_ASRC_14: 444 case RT5677_ASRC_14:
445 case RT5677_ASRC_15: 445 case RT5677_ASRC_15:
446 case RT5677_ASRC_16: 446 case RT5677_ASRC_16:
447 case RT5677_ASRC_17: 447 case RT5677_ASRC_17:
448 case RT5677_ASRC_18: 448 case RT5677_ASRC_18:
449 case RT5677_ASRC_19: 449 case RT5677_ASRC_19:
450 case RT5677_ASRC_20: 450 case RT5677_ASRC_20:
451 case RT5677_ASRC_21: 451 case RT5677_ASRC_21:
452 case RT5677_ASRC_22: 452 case RT5677_ASRC_22:
453 case RT5677_ASRC_23: 453 case RT5677_ASRC_23:
454 case RT5677_VAD_CTRL1: 454 case RT5677_VAD_CTRL1:
455 case RT5677_VAD_CTRL2: 455 case RT5677_VAD_CTRL2:
456 case RT5677_VAD_CTRL3: 456 case RT5677_VAD_CTRL3:
457 case RT5677_VAD_CTRL4: 457 case RT5677_VAD_CTRL4:
458 case RT5677_VAD_CTRL5: 458 case RT5677_VAD_CTRL5:
459 case RT5677_DSP_INB_CTRL1: 459 case RT5677_DSP_INB_CTRL1:
460 case RT5677_DSP_INB_CTRL2: 460 case RT5677_DSP_INB_CTRL2:
461 case RT5677_DSP_IN_OUTB_CTRL: 461 case RT5677_DSP_IN_OUTB_CTRL:
462 case RT5677_DSP_OUTB0_1_DIG_VOL: 462 case RT5677_DSP_OUTB0_1_DIG_VOL:
463 case RT5677_DSP_OUTB2_3_DIG_VOL: 463 case RT5677_DSP_OUTB2_3_DIG_VOL:
464 case RT5677_DSP_OUTB4_5_DIG_VOL: 464 case RT5677_DSP_OUTB4_5_DIG_VOL:
465 case RT5677_DSP_OUTB6_7_DIG_VOL: 465 case RT5677_DSP_OUTB6_7_DIG_VOL:
466 case RT5677_ADC_EQ_CTRL1: 466 case RT5677_ADC_EQ_CTRL1:
467 case RT5677_ADC_EQ_CTRL2: 467 case RT5677_ADC_EQ_CTRL2:
468 case RT5677_EQ_CTRL1: 468 case RT5677_EQ_CTRL1:
469 case RT5677_EQ_CTRL2: 469 case RT5677_EQ_CTRL2:
470 case RT5677_EQ_CTRL3: 470 case RT5677_EQ_CTRL3:
471 case RT5677_SOFT_VOL_ZERO_CROSS1: 471 case RT5677_SOFT_VOL_ZERO_CROSS1:
472 case RT5677_JD_CTRL1: 472 case RT5677_JD_CTRL1:
473 case RT5677_JD_CTRL2: 473 case RT5677_JD_CTRL2:
474 case RT5677_JD_CTRL3: 474 case RT5677_JD_CTRL3:
475 case RT5677_IRQ_CTRL1: 475 case RT5677_IRQ_CTRL1:
476 case RT5677_IRQ_CTRL2: 476 case RT5677_IRQ_CTRL2:
477 case RT5677_GPIO_ST: 477 case RT5677_GPIO_ST:
478 case RT5677_GPIO_CTRL1: 478 case RT5677_GPIO_CTRL1:
479 case RT5677_GPIO_CTRL2: 479 case RT5677_GPIO_CTRL2:
480 case RT5677_GPIO_CTRL3: 480 case RT5677_GPIO_CTRL3:
481 case RT5677_STO1_ADC_HI_FILTER1: 481 case RT5677_STO1_ADC_HI_FILTER1:
482 case RT5677_STO1_ADC_HI_FILTER2: 482 case RT5677_STO1_ADC_HI_FILTER2:
483 case RT5677_MONO_ADC_HI_FILTER1: 483 case RT5677_MONO_ADC_HI_FILTER1:
484 case RT5677_MONO_ADC_HI_FILTER2: 484 case RT5677_MONO_ADC_HI_FILTER2:
485 case RT5677_STO2_ADC_HI_FILTER1: 485 case RT5677_STO2_ADC_HI_FILTER1:
486 case RT5677_STO2_ADC_HI_FILTER2: 486 case RT5677_STO2_ADC_HI_FILTER2:
487 case RT5677_STO3_ADC_HI_FILTER1: 487 case RT5677_STO3_ADC_HI_FILTER1:
488 case RT5677_STO3_ADC_HI_FILTER2: 488 case RT5677_STO3_ADC_HI_FILTER2:
489 case RT5677_STO4_ADC_HI_FILTER1: 489 case RT5677_STO4_ADC_HI_FILTER1:
490 case RT5677_STO4_ADC_HI_FILTER2: 490 case RT5677_STO4_ADC_HI_FILTER2:
491 case RT5677_MB_DRC_CTRL1: 491 case RT5677_MB_DRC_CTRL1:
492 case RT5677_DRC1_CTRL1: 492 case RT5677_DRC1_CTRL1:
493 case RT5677_DRC1_CTRL2: 493 case RT5677_DRC1_CTRL2:
494 case RT5677_DRC1_CTRL3: 494 case RT5677_DRC1_CTRL3:
495 case RT5677_DRC1_CTRL4: 495 case RT5677_DRC1_CTRL4:
496 case RT5677_DRC1_CTRL5: 496 case RT5677_DRC1_CTRL5:
497 case RT5677_DRC1_CTRL6: 497 case RT5677_DRC1_CTRL6:
498 case RT5677_DRC2_CTRL1: 498 case RT5677_DRC2_CTRL1:
499 case RT5677_DRC2_CTRL2: 499 case RT5677_DRC2_CTRL2:
500 case RT5677_DRC2_CTRL3: 500 case RT5677_DRC2_CTRL3:
501 case RT5677_DRC2_CTRL4: 501 case RT5677_DRC2_CTRL4:
502 case RT5677_DRC2_CTRL5: 502 case RT5677_DRC2_CTRL5:
503 case RT5677_DRC2_CTRL6: 503 case RT5677_DRC2_CTRL6:
504 case RT5677_DRC1_HL_CTRL1: 504 case RT5677_DRC1_HL_CTRL1:
505 case RT5677_DRC1_HL_CTRL2: 505 case RT5677_DRC1_HL_CTRL2:
506 case RT5677_DRC2_HL_CTRL1: 506 case RT5677_DRC2_HL_CTRL1:
507 case RT5677_DRC2_HL_CTRL2: 507 case RT5677_DRC2_HL_CTRL2:
508 case RT5677_DSP_INB1_SRC_CTRL1: 508 case RT5677_DSP_INB1_SRC_CTRL1:
509 case RT5677_DSP_INB1_SRC_CTRL2: 509 case RT5677_DSP_INB1_SRC_CTRL2:
510 case RT5677_DSP_INB1_SRC_CTRL3: 510 case RT5677_DSP_INB1_SRC_CTRL3:
511 case RT5677_DSP_INB1_SRC_CTRL4: 511 case RT5677_DSP_INB1_SRC_CTRL4:
512 case RT5677_DSP_INB2_SRC_CTRL1: 512 case RT5677_DSP_INB2_SRC_CTRL1:
513 case RT5677_DSP_INB2_SRC_CTRL2: 513 case RT5677_DSP_INB2_SRC_CTRL2:
514 case RT5677_DSP_INB2_SRC_CTRL3: 514 case RT5677_DSP_INB2_SRC_CTRL3:
515 case RT5677_DSP_INB2_SRC_CTRL4: 515 case RT5677_DSP_INB2_SRC_CTRL4:
516 case RT5677_DSP_INB3_SRC_CTRL1: 516 case RT5677_DSP_INB3_SRC_CTRL1:
517 case RT5677_DSP_INB3_SRC_CTRL2: 517 case RT5677_DSP_INB3_SRC_CTRL2:
518 case RT5677_DSP_INB3_SRC_CTRL3: 518 case RT5677_DSP_INB3_SRC_CTRL3:
519 case RT5677_DSP_INB3_SRC_CTRL4: 519 case RT5677_DSP_INB3_SRC_CTRL4:
520 case RT5677_DSP_OUTB1_SRC_CTRL1: 520 case RT5677_DSP_OUTB1_SRC_CTRL1:
521 case RT5677_DSP_OUTB1_SRC_CTRL2: 521 case RT5677_DSP_OUTB1_SRC_CTRL2:
522 case RT5677_DSP_OUTB1_SRC_CTRL3: 522 case RT5677_DSP_OUTB1_SRC_CTRL3:
523 case RT5677_DSP_OUTB1_SRC_CTRL4: 523 case RT5677_DSP_OUTB1_SRC_CTRL4:
524 case RT5677_DSP_OUTB2_SRC_CTRL1: 524 case RT5677_DSP_OUTB2_SRC_CTRL1:
525 case RT5677_DSP_OUTB2_SRC_CTRL2: 525 case RT5677_DSP_OUTB2_SRC_CTRL2:
526 case RT5677_DSP_OUTB2_SRC_CTRL3: 526 case RT5677_DSP_OUTB2_SRC_CTRL3:
527 case RT5677_DSP_OUTB2_SRC_CTRL4: 527 case RT5677_DSP_OUTB2_SRC_CTRL4:
528 case RT5677_DSP_OUTB_0123_MIXER_CTRL: 528 case RT5677_DSP_OUTB_0123_MIXER_CTRL:
529 case RT5677_DSP_OUTB_45_MIXER_CTRL: 529 case RT5677_DSP_OUTB_45_MIXER_CTRL:
530 case RT5677_DSP_OUTB_67_MIXER_CTRL: 530 case RT5677_DSP_OUTB_67_MIXER_CTRL:
531 case RT5677_DIG_MISC: 531 case RT5677_DIG_MISC:
532 case RT5677_GEN_CTRL1: 532 case RT5677_GEN_CTRL1:
533 case RT5677_GEN_CTRL2: 533 case RT5677_GEN_CTRL2:
534 case RT5677_VENDOR_ID: 534 case RT5677_VENDOR_ID:
535 case RT5677_VENDOR_ID1: 535 case RT5677_VENDOR_ID1:
536 case RT5677_VENDOR_ID2: 536 case RT5677_VENDOR_ID2:
537 return true; 537 return true;
538 default: 538 default:
539 return false; 539 return false;
540 } 540 }
541 } 541 }
542 542
543 /** 543 /**
544 * rt5677_dsp_mode_i2c_write_addr - Write value to address on DSP mode. 544 * rt5677_dsp_mode_i2c_write_addr - Write value to address on DSP mode.
545 * @rt5677: Private Data. 545 * @rt5677: Private Data.
546 * @addr: Address index. 546 * @addr: Address index.
547 * @value: Address data. 547 * @value: Address data.
548 * 548 *
549 * 549 *
550 * Returns 0 for success or negative error code. 550 * Returns 0 for success or negative error code.
551 */ 551 */
552 static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677, 552 static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677,
553 unsigned int addr, unsigned int value, unsigned int opcode) 553 unsigned int addr, unsigned int value, unsigned int opcode)
554 { 554 {
555 struct snd_soc_codec *codec = rt5677->codec; 555 struct snd_soc_codec *codec = rt5677->codec;
556 int ret; 556 int ret;
557 557
558 mutex_lock(&rt5677->dsp_cmd_lock); 558 mutex_lock(&rt5677->dsp_cmd_lock);
559 559
560 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB, 560 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
561 addr >> 16); 561 addr >> 16);
562 if (ret < 0) { 562 if (ret < 0) {
563 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret); 563 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
564 goto err; 564 goto err;
565 } 565 }
566 566
567 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB, 567 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
568 addr & 0xffff); 568 addr & 0xffff);
569 if (ret < 0) { 569 if (ret < 0) {
570 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret); 570 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
571 goto err; 571 goto err;
572 } 572 }
573 573
574 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, 574 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB,
575 value >> 16); 575 value >> 16);
576 if (ret < 0) { 576 if (ret < 0) {
577 dev_err(codec->dev, "Failed to set data msb value: %d\n", ret); 577 dev_err(codec->dev, "Failed to set data msb value: %d\n", ret);
578 goto err; 578 goto err;
579 } 579 }
580 580
581 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, 581 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB,
582 value & 0xffff); 582 value & 0xffff);
583 if (ret < 0) { 583 if (ret < 0) {
584 dev_err(codec->dev, "Failed to set data lsb value: %d\n", ret); 584 dev_err(codec->dev, "Failed to set data lsb value: %d\n", ret);
585 goto err; 585 goto err;
586 } 586 }
587 587
588 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE, 588 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
589 opcode); 589 opcode);
590 if (ret < 0) { 590 if (ret < 0) {
591 dev_err(codec->dev, "Failed to set op code value: %d\n", ret); 591 dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
592 goto err; 592 goto err;
593 } 593 }
594 594
595 err: 595 err:
596 mutex_unlock(&rt5677->dsp_cmd_lock); 596 mutex_unlock(&rt5677->dsp_cmd_lock);
597 597
598 return ret; 598 return ret;
599 } 599 }
600 600
601 /** 601 /**
602 * rt5677_dsp_mode_i2c_read_addr - Read value from address on DSP mode. 602 * rt5677_dsp_mode_i2c_read_addr - Read value from address on DSP mode.
603 * rt5677: Private Data. 603 * rt5677: Private Data.
604 * @addr: Address index. 604 * @addr: Address index.
605 * @value: Address data. 605 * @value: Address data.
606 * 606 *
607 * 607 *
608 * Returns 0 for success or negative error code. 608 * Returns 0 for success or negative error code.
609 */ 609 */
610 static int rt5677_dsp_mode_i2c_read_addr( 610 static int rt5677_dsp_mode_i2c_read_addr(
611 struct rt5677_priv *rt5677, unsigned int addr, unsigned int *value) 611 struct rt5677_priv *rt5677, unsigned int addr, unsigned int *value)
612 { 612 {
613 struct snd_soc_codec *codec = rt5677->codec; 613 struct snd_soc_codec *codec = rt5677->codec;
614 int ret; 614 int ret;
615 unsigned int msb, lsb; 615 unsigned int msb, lsb;
616 616
617 mutex_lock(&rt5677->dsp_cmd_lock); 617 mutex_lock(&rt5677->dsp_cmd_lock);
618 618
619 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB, 619 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
620 addr >> 16); 620 addr >> 16);
621 if (ret < 0) { 621 if (ret < 0) {
622 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret); 622 dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
623 goto err; 623 goto err;
624 } 624 }
625 625
626 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB, 626 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
627 addr & 0xffff); 627 addr & 0xffff);
628 if (ret < 0) { 628 if (ret < 0) {
629 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret); 629 dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
630 goto err; 630 goto err;
631 } 631 }
632 632
633 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE, 633 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
634 0x0002); 634 0x0002);
635 if (ret < 0) { 635 if (ret < 0) {
636 dev_err(codec->dev, "Failed to set op code value: %d\n", ret); 636 dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
637 goto err; 637 goto err;
638 } 638 }
639 639
640 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, &msb); 640 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, &msb);
641 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, &lsb); 641 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, &lsb);
642 *value = (msb << 16) | lsb; 642 *value = (msb << 16) | lsb;
643 643
644 err: 644 err:
645 mutex_unlock(&rt5677->dsp_cmd_lock); 645 mutex_unlock(&rt5677->dsp_cmd_lock);
646 646
647 return ret; 647 return ret;
648 } 648 }
649 649
650 /** 650 /**
651 * rt5677_dsp_mode_i2c_write - Write register on DSP mode. 651 * rt5677_dsp_mode_i2c_write - Write register on DSP mode.
652 * rt5677: Private Data. 652 * rt5677: Private Data.
653 * @reg: Register index. 653 * @reg: Register index.
654 * @value: Register data. 654 * @value: Register data.
655 * 655 *
656 * 656 *
657 * Returns 0 for success or negative error code. 657 * Returns 0 for success or negative error code.
658 */ 658 */
659 static int rt5677_dsp_mode_i2c_write(struct rt5677_priv *rt5677, 659 static int rt5677_dsp_mode_i2c_write(struct rt5677_priv *rt5677,
660 unsigned int reg, unsigned int value) 660 unsigned int reg, unsigned int value)
661 { 661 {
662 return rt5677_dsp_mode_i2c_write_addr(rt5677, 0x18020000 + reg * 2, 662 return rt5677_dsp_mode_i2c_write_addr(rt5677, 0x18020000 + reg * 2,
663 value, 0x0001); 663 value, 0x0001);
664 } 664 }
665 665
666 /** 666 /**
667 * rt5677_dsp_mode_i2c_read - Read register on DSP mode. 667 * rt5677_dsp_mode_i2c_read - Read register on DSP mode.
668 * @codec: SoC audio codec device. 668 * @codec: SoC audio codec device.
669 * @reg: Register index. 669 * @reg: Register index.
670 * @value: Register data. 670 * @value: Register data.
671 * 671 *
672 * 672 *
673 * Returns 0 for success or negative error code. 673 * Returns 0 for success or negative error code.
674 */ 674 */
675 static int rt5677_dsp_mode_i2c_read( 675 static int rt5677_dsp_mode_i2c_read(
676 struct rt5677_priv *rt5677, unsigned int reg, unsigned int *value) 676 struct rt5677_priv *rt5677, unsigned int reg, unsigned int *value)
677 { 677 {
678 int ret = rt5677_dsp_mode_i2c_read_addr(rt5677, 0x18020000 + reg * 2, 678 int ret = rt5677_dsp_mode_i2c_read_addr(rt5677, 0x18020000 + reg * 2,
679 value); 679 value);
680 680
681 *value &= 0xffff; 681 *value &= 0xffff;
682 682
683 return ret; 683 return ret;
684 } 684 }
685 685
686 static void rt5677_set_dsp_mode(struct snd_soc_codec *codec, bool on) 686 static void rt5677_set_dsp_mode(struct snd_soc_codec *codec, bool on)
687 { 687 {
688 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 688 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
689 689
690 if (on) { 690 if (on) {
691 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x2); 691 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x2);
692 rt5677->is_dsp_mode = true; 692 rt5677->is_dsp_mode = true;
693 } else { 693 } else {
694 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x0); 694 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x0);
695 rt5677->is_dsp_mode = false; 695 rt5677->is_dsp_mode = false;
696 } 696 }
697 } 697 }
698 698
699 static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on) 699 static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
700 { 700 {
701 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 701 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
702 static bool activity; 702 static bool activity;
703 int ret; 703 int ret;
704 704
705 if (on && !activity) { 705 if (on && !activity) {
706 activity = true; 706 activity = true;
707 707
708 regcache_cache_only(rt5677->regmap, false); 708 regcache_cache_only(rt5677->regmap, false);
709 regcache_cache_bypass(rt5677->regmap, true); 709 regcache_cache_bypass(rt5677->regmap, true);
710 710
711 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x1); 711 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x1);
712 regmap_update_bits(rt5677->regmap, 712 regmap_update_bits(rt5677->regmap,
713 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0f00); 713 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0f00);
714 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, 714 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
715 RT5677_LDO1_SEL_MASK, 0x0); 715 RT5677_LDO1_SEL_MASK, 0x0);
716 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 716 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
717 RT5677_PWR_LDO1, RT5677_PWR_LDO1); 717 RT5677_PWR_LDO1, RT5677_PWR_LDO1);
718 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 718 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
719 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC); 719 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC);
720 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2, 720 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
721 RT5677_PLL2_PR_SRC_MASK | RT5677_DSP_CLK_SRC_MASK, 721 RT5677_PLL2_PR_SRC_MASK | RT5677_DSP_CLK_SRC_MASK,
722 RT5677_PLL2_PR_SRC_MCLK2 | RT5677_DSP_CLK_SRC_BYPASS); 722 RT5677_PLL2_PR_SRC_MCLK2 | RT5677_DSP_CLK_SRC_BYPASS);
723 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff); 723 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff);
724 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd); 724 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd);
725 rt5677_set_dsp_mode(codec, true); 725 rt5677_set_dsp_mode(codec, true);
726 726
727 ret = request_firmware(&rt5677->fw1, RT5677_FIRMWARE1, 727 ret = request_firmware(&rt5677->fw1, RT5677_FIRMWARE1,
728 codec->dev); 728 codec->dev);
729 if (ret == 0) { 729 if (ret == 0) {
730 rt5677_spi_burst_write(0x50000000, rt5677->fw1); 730 rt5677_spi_burst_write(0x50000000, rt5677->fw1);
731 release_firmware(rt5677->fw1); 731 release_firmware(rt5677->fw1);
732 } 732 }
733 733
734 ret = request_firmware(&rt5677->fw2, RT5677_FIRMWARE2, 734 ret = request_firmware(&rt5677->fw2, RT5677_FIRMWARE2,
735 codec->dev); 735 codec->dev);
736 if (ret == 0) { 736 if (ret == 0) {
737 rt5677_spi_burst_write(0x60000000, rt5677->fw2); 737 rt5677_spi_burst_write(0x60000000, rt5677->fw2);
738 release_firmware(rt5677->fw2); 738 release_firmware(rt5677->fw2);
739 } 739 }
740 740
741 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x0); 741 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x0);
742 742
743 regcache_cache_bypass(rt5677->regmap, false); 743 regcache_cache_bypass(rt5677->regmap, false);
744 regcache_cache_only(rt5677->regmap, true); 744 regcache_cache_only(rt5677->regmap, true);
745 } else if (!on && activity) { 745 } else if (!on && activity) {
746 activity = false; 746 activity = false;
747 747
748 regcache_cache_only(rt5677->regmap, false); 748 regcache_cache_only(rt5677->regmap, false);
749 regcache_cache_bypass(rt5677->regmap, true); 749 regcache_cache_bypass(rt5677->regmap, true);
750 750
751 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x1); 751 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x1);
752 rt5677_set_dsp_mode(codec, false); 752 rt5677_set_dsp_mode(codec, false);
753 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x0001); 753 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x0001);
754 754
755 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); 755 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
756 756
757 regcache_cache_bypass(rt5677->regmap, false); 757 regcache_cache_bypass(rt5677->regmap, false);
758 regcache_mark_dirty(rt5677->regmap); 758 regcache_mark_dirty(rt5677->regmap);
759 regcache_sync(rt5677->regmap); 759 regcache_sync(rt5677->regmap);
760 } 760 }
761 761
762 return 0; 762 return 0;
763 } 763 }
764 764
765 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); 765 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
766 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0); 766 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
767 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); 767 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
768 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0); 768 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
769 static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); 769 static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
770 static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0); 770 static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
771 771
772 /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ 772 /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
773 static unsigned int bst_tlv[] = { 773 static unsigned int bst_tlv[] = {
774 TLV_DB_RANGE_HEAD(7), 774 TLV_DB_RANGE_HEAD(7),
775 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 775 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
776 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 776 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
777 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 777 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
778 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), 778 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
779 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), 779 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
780 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), 780 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
781 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), 781 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0),
782 }; 782 };
783 783
784 static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol, 784 static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
785 struct snd_ctl_elem_value *ucontrol) 785 struct snd_ctl_elem_value *ucontrol)
786 { 786 {
787 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 787 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
788 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 788 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
789 789
790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en; 790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en;
791 791
792 return 0; 792 return 0;
793 } 793 }
794 794
795 static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol, 795 static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol,
796 struct snd_ctl_elem_value *ucontrol) 796 struct snd_ctl_elem_value *ucontrol)
797 { 797 {
798 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 798 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
799 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 799 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
800 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
800 801
801 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0]; 802 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0];
802 803
803 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) 804 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
804 rt5677_set_dsp_vad(codec, rt5677->dsp_vad_en); 805 rt5677_set_dsp_vad(codec, rt5677->dsp_vad_en);
805 806
806 return 0; 807 return 0;
807 } 808 }
808 809
809 static const struct snd_kcontrol_new rt5677_snd_controls[] = { 810 static const struct snd_kcontrol_new rt5677_snd_controls[] = {
810 /* OUTPUT Control */ 811 /* OUTPUT Control */
811 SOC_SINGLE("OUT1 Playback Switch", RT5677_LOUT1, 812 SOC_SINGLE("OUT1 Playback Switch", RT5677_LOUT1,
812 RT5677_LOUT1_L_MUTE_SFT, 1, 1), 813 RT5677_LOUT1_L_MUTE_SFT, 1, 1),
813 SOC_SINGLE("OUT2 Playback Switch", RT5677_LOUT1, 814 SOC_SINGLE("OUT2 Playback Switch", RT5677_LOUT1,
814 RT5677_LOUT2_L_MUTE_SFT, 1, 1), 815 RT5677_LOUT2_L_MUTE_SFT, 1, 1),
815 SOC_SINGLE("OUT3 Playback Switch", RT5677_LOUT1, 816 SOC_SINGLE("OUT3 Playback Switch", RT5677_LOUT1,
816 RT5677_LOUT3_L_MUTE_SFT, 1, 1), 817 RT5677_LOUT3_L_MUTE_SFT, 1, 1),
817 818
818 /* DAC Digital Volume */ 819 /* DAC Digital Volume */
819 SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5677_DAC1_DIG_VOL, 820 SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5677_DAC1_DIG_VOL,
820 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv), 821 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
821 SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5677_DAC2_DIG_VOL, 822 SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5677_DAC2_DIG_VOL,
822 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv), 823 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
823 SOC_DOUBLE_TLV("DAC3 Playback Volume", RT5677_DAC3_DIG_VOL, 824 SOC_DOUBLE_TLV("DAC3 Playback Volume", RT5677_DAC3_DIG_VOL,
824 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv), 825 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
825 SOC_DOUBLE_TLV("DAC4 Playback Volume", RT5677_DAC4_DIG_VOL, 826 SOC_DOUBLE_TLV("DAC4 Playback Volume", RT5677_DAC4_DIG_VOL,
826 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv), 827 RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
827 828
828 /* IN1/IN2 Control */ 829 /* IN1/IN2 Control */
829 SOC_SINGLE_TLV("IN1 Boost", RT5677_IN1, RT5677_BST_SFT1, 8, 0, bst_tlv), 830 SOC_SINGLE_TLV("IN1 Boost", RT5677_IN1, RT5677_BST_SFT1, 8, 0, bst_tlv),
830 SOC_SINGLE_TLV("IN2 Boost", RT5677_IN1, RT5677_BST_SFT2, 8, 0, bst_tlv), 831 SOC_SINGLE_TLV("IN2 Boost", RT5677_IN1, RT5677_BST_SFT2, 8, 0, bst_tlv),
831 832
832 /* ADC Digital Volume Control */ 833 /* ADC Digital Volume Control */
833 SOC_DOUBLE("ADC1 Capture Switch", RT5677_STO1_ADC_DIG_VOL, 834 SOC_DOUBLE("ADC1 Capture Switch", RT5677_STO1_ADC_DIG_VOL,
834 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), 835 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
835 SOC_DOUBLE("ADC2 Capture Switch", RT5677_STO2_ADC_DIG_VOL, 836 SOC_DOUBLE("ADC2 Capture Switch", RT5677_STO2_ADC_DIG_VOL,
836 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), 837 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
837 SOC_DOUBLE("ADC3 Capture Switch", RT5677_STO3_ADC_DIG_VOL, 838 SOC_DOUBLE("ADC3 Capture Switch", RT5677_STO3_ADC_DIG_VOL,
838 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), 839 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
839 SOC_DOUBLE("ADC4 Capture Switch", RT5677_STO4_ADC_DIG_VOL, 840 SOC_DOUBLE("ADC4 Capture Switch", RT5677_STO4_ADC_DIG_VOL,
840 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), 841 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
841 SOC_DOUBLE("Mono ADC Capture Switch", RT5677_MONO_ADC_DIG_VOL, 842 SOC_DOUBLE("Mono ADC Capture Switch", RT5677_MONO_ADC_DIG_VOL,
842 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), 843 RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
843 844
844 SOC_DOUBLE_TLV("ADC1 Capture Volume", RT5677_STO1_ADC_DIG_VOL, 845 SOC_DOUBLE_TLV("ADC1 Capture Volume", RT5677_STO1_ADC_DIG_VOL,
845 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0, 846 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
846 adc_vol_tlv), 847 adc_vol_tlv),
847 SOC_DOUBLE_TLV("ADC2 Capture Volume", RT5677_STO2_ADC_DIG_VOL, 848 SOC_DOUBLE_TLV("ADC2 Capture Volume", RT5677_STO2_ADC_DIG_VOL,
848 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0, 849 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
849 adc_vol_tlv), 850 adc_vol_tlv),
850 SOC_DOUBLE_TLV("ADC3 Capture Volume", RT5677_STO3_ADC_DIG_VOL, 851 SOC_DOUBLE_TLV("ADC3 Capture Volume", RT5677_STO3_ADC_DIG_VOL,
851 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0, 852 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
852 adc_vol_tlv), 853 adc_vol_tlv),
853 SOC_DOUBLE_TLV("ADC4 Capture Volume", RT5677_STO4_ADC_DIG_VOL, 854 SOC_DOUBLE_TLV("ADC4 Capture Volume", RT5677_STO4_ADC_DIG_VOL,
854 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0, 855 RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
855 adc_vol_tlv), 856 adc_vol_tlv),
856 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5677_MONO_ADC_DIG_VOL, 857 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5677_MONO_ADC_DIG_VOL,
857 RT5677_MONO_ADC_L_VOL_SFT, RT5677_MONO_ADC_R_VOL_SFT, 63, 0, 858 RT5677_MONO_ADC_L_VOL_SFT, RT5677_MONO_ADC_R_VOL_SFT, 63, 0,
858 adc_vol_tlv), 859 adc_vol_tlv),
859 860
860 /* Sidetone Control */ 861 /* Sidetone Control */
861 SOC_SINGLE_TLV("Sidetone Volume", RT5677_SIDETONE_CTRL, 862 SOC_SINGLE_TLV("Sidetone Volume", RT5677_SIDETONE_CTRL,
862 RT5677_ST_VOL_SFT, 31, 0, st_vol_tlv), 863 RT5677_ST_VOL_SFT, 31, 0, st_vol_tlv),
863 864
864 /* ADC Boost Volume Control */ 865 /* ADC Boost Volume Control */
865 SOC_DOUBLE_TLV("STO1 ADC Boost Volume", RT5677_STO1_2_ADC_BST, 866 SOC_DOUBLE_TLV("STO1 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
866 RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0, 867 RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0,
867 adc_bst_tlv), 868 adc_bst_tlv),
868 SOC_DOUBLE_TLV("STO2 ADC Boost Volume", RT5677_STO1_2_ADC_BST, 869 SOC_DOUBLE_TLV("STO2 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
869 RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0, 870 RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0,
870 adc_bst_tlv), 871 adc_bst_tlv),
871 SOC_DOUBLE_TLV("STO3 ADC Boost Volume", RT5677_STO3_4_ADC_BST, 872 SOC_DOUBLE_TLV("STO3 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
872 RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0, 873 RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0,
873 adc_bst_tlv), 874 adc_bst_tlv),
874 SOC_DOUBLE_TLV("STO4 ADC Boost Volume", RT5677_STO3_4_ADC_BST, 875 SOC_DOUBLE_TLV("STO4 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
875 RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0, 876 RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0,
876 adc_bst_tlv), 877 adc_bst_tlv),
877 SOC_DOUBLE_TLV("Mono ADC Boost Volume", RT5677_ADC_BST_CTRL2, 878 SOC_DOUBLE_TLV("Mono ADC Boost Volume", RT5677_ADC_BST_CTRL2,
878 RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0, 879 RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0,
879 adc_bst_tlv), 880 adc_bst_tlv),
880 881
881 SOC_SINGLE_EXT("DSP VAD Switch", SND_SOC_NOPM, 0, 1, 0, 882 SOC_SINGLE_EXT("DSP VAD Switch", SND_SOC_NOPM, 0, 1, 0,
882 rt5677_dsp_vad_get, rt5677_dsp_vad_put), 883 rt5677_dsp_vad_get, rt5677_dsp_vad_put),
883 }; 884 };
884 885
885 /** 886 /**
886 * set_dmic_clk - Set parameter of dmic. 887 * set_dmic_clk - Set parameter of dmic.
887 * 888 *
888 * @w: DAPM widget. 889 * @w: DAPM widget.
889 * @kcontrol: The kcontrol of this widget. 890 * @kcontrol: The kcontrol of this widget.
890 * @event: Event id. 891 * @event: Event id.
891 * 892 *
892 * Choose dmic clock between 1MHz and 3MHz. 893 * Choose dmic clock between 1MHz and 3MHz.
893 * It is better for clock to approximate 3MHz. 894 * It is better for clock to approximate 3MHz.
894 */ 895 */
895 static int set_dmic_clk(struct snd_soc_dapm_widget *w, 896 static int set_dmic_clk(struct snd_soc_dapm_widget *w,
896 struct snd_kcontrol *kcontrol, int event) 897 struct snd_kcontrol *kcontrol, int event)
897 { 898 {
898 struct snd_soc_codec *codec = w->codec; 899 struct snd_soc_codec *codec = w->codec;
899 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 900 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
900 int idx = rl6231_calc_dmic_clk(rt5677->sysclk); 901 int idx = rl6231_calc_dmic_clk(rt5677->sysclk);
901 902
902 if (idx < 0) 903 if (idx < 0)
903 dev_err(codec->dev, "Failed to set DMIC clock\n"); 904 dev_err(codec->dev, "Failed to set DMIC clock\n");
904 else 905 else
905 regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1, 906 regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1,
906 RT5677_DMIC_CLK_MASK, idx << RT5677_DMIC_CLK_SFT); 907 RT5677_DMIC_CLK_MASK, idx << RT5677_DMIC_CLK_SFT);
907 return idx; 908 return idx;
908 } 909 }
909 910
910 static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, 911 static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
911 struct snd_soc_dapm_widget *sink) 912 struct snd_soc_dapm_widget *sink)
912 { 913 {
913 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(source->codec); 914 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(source->codec);
914 unsigned int val; 915 unsigned int val;
915 916
916 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val); 917 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val);
917 val &= RT5677_SCLK_SRC_MASK; 918 val &= RT5677_SCLK_SRC_MASK;
918 if (val == RT5677_SCLK_SRC_PLL1) 919 if (val == RT5677_SCLK_SRC_PLL1)
919 return 1; 920 return 1;
920 else 921 else
921 return 0; 922 return 0;
922 } 923 }
923 924
924 /* Digital Mixer */ 925 /* Digital Mixer */
925 static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = { 926 static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = {
926 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER, 927 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
927 RT5677_M_STO1_ADC_L1_SFT, 1, 1), 928 RT5677_M_STO1_ADC_L1_SFT, 1, 1),
928 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER, 929 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
929 RT5677_M_STO1_ADC_L2_SFT, 1, 1), 930 RT5677_M_STO1_ADC_L2_SFT, 1, 1),
930 }; 931 };
931 932
932 static const struct snd_kcontrol_new rt5677_sto1_adc_r_mix[] = { 933 static const struct snd_kcontrol_new rt5677_sto1_adc_r_mix[] = {
933 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER, 934 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
934 RT5677_M_STO1_ADC_R1_SFT, 1, 1), 935 RT5677_M_STO1_ADC_R1_SFT, 1, 1),
935 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER, 936 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
936 RT5677_M_STO1_ADC_R2_SFT, 1, 1), 937 RT5677_M_STO1_ADC_R2_SFT, 1, 1),
937 }; 938 };
938 939
939 static const struct snd_kcontrol_new rt5677_sto2_adc_l_mix[] = { 940 static const struct snd_kcontrol_new rt5677_sto2_adc_l_mix[] = {
940 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER, 941 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
941 RT5677_M_STO2_ADC_L1_SFT, 1, 1), 942 RT5677_M_STO2_ADC_L1_SFT, 1, 1),
942 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER, 943 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
943 RT5677_M_STO2_ADC_L2_SFT, 1, 1), 944 RT5677_M_STO2_ADC_L2_SFT, 1, 1),
944 }; 945 };
945 946
946 static const struct snd_kcontrol_new rt5677_sto2_adc_r_mix[] = { 947 static const struct snd_kcontrol_new rt5677_sto2_adc_r_mix[] = {
947 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER, 948 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
948 RT5677_M_STO2_ADC_R1_SFT, 1, 1), 949 RT5677_M_STO2_ADC_R1_SFT, 1, 1),
949 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER, 950 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
950 RT5677_M_STO2_ADC_R2_SFT, 1, 1), 951 RT5677_M_STO2_ADC_R2_SFT, 1, 1),
951 }; 952 };
952 953
953 static const struct snd_kcontrol_new rt5677_sto3_adc_l_mix[] = { 954 static const struct snd_kcontrol_new rt5677_sto3_adc_l_mix[] = {
954 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER, 955 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
955 RT5677_M_STO3_ADC_L1_SFT, 1, 1), 956 RT5677_M_STO3_ADC_L1_SFT, 1, 1),
956 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER, 957 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
957 RT5677_M_STO3_ADC_L2_SFT, 1, 1), 958 RT5677_M_STO3_ADC_L2_SFT, 1, 1),
958 }; 959 };
959 960
960 static const struct snd_kcontrol_new rt5677_sto3_adc_r_mix[] = { 961 static const struct snd_kcontrol_new rt5677_sto3_adc_r_mix[] = {
961 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER, 962 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
962 RT5677_M_STO3_ADC_R1_SFT, 1, 1), 963 RT5677_M_STO3_ADC_R1_SFT, 1, 1),
963 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER, 964 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
964 RT5677_M_STO3_ADC_R2_SFT, 1, 1), 965 RT5677_M_STO3_ADC_R2_SFT, 1, 1),
965 }; 966 };
966 967
967 static const struct snd_kcontrol_new rt5677_sto4_adc_l_mix[] = { 968 static const struct snd_kcontrol_new rt5677_sto4_adc_l_mix[] = {
968 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER, 969 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
969 RT5677_M_STO4_ADC_L1_SFT, 1, 1), 970 RT5677_M_STO4_ADC_L1_SFT, 1, 1),
970 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER, 971 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
971 RT5677_M_STO4_ADC_L2_SFT, 1, 1), 972 RT5677_M_STO4_ADC_L2_SFT, 1, 1),
972 }; 973 };
973 974
974 static const struct snd_kcontrol_new rt5677_sto4_adc_r_mix[] = { 975 static const struct snd_kcontrol_new rt5677_sto4_adc_r_mix[] = {
975 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER, 976 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
976 RT5677_M_STO4_ADC_R1_SFT, 1, 1), 977 RT5677_M_STO4_ADC_R1_SFT, 1, 1),
977 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER, 978 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
978 RT5677_M_STO4_ADC_R2_SFT, 1, 1), 979 RT5677_M_STO4_ADC_R2_SFT, 1, 1),
979 }; 980 };
980 981
981 static const struct snd_kcontrol_new rt5677_mono_adc_l_mix[] = { 982 static const struct snd_kcontrol_new rt5677_mono_adc_l_mix[] = {
982 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER, 983 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
983 RT5677_M_MONO_ADC_L1_SFT, 1, 1), 984 RT5677_M_MONO_ADC_L1_SFT, 1, 1),
984 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER, 985 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
985 RT5677_M_MONO_ADC_L2_SFT, 1, 1), 986 RT5677_M_MONO_ADC_L2_SFT, 1, 1),
986 }; 987 };
987 988
988 static const struct snd_kcontrol_new rt5677_mono_adc_r_mix[] = { 989 static const struct snd_kcontrol_new rt5677_mono_adc_r_mix[] = {
989 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER, 990 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
990 RT5677_M_MONO_ADC_R1_SFT, 1, 1), 991 RT5677_M_MONO_ADC_R1_SFT, 1, 1),
991 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER, 992 SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
992 RT5677_M_MONO_ADC_R2_SFT, 1, 1), 993 RT5677_M_MONO_ADC_R2_SFT, 1, 1),
993 }; 994 };
994 995
995 static const struct snd_kcontrol_new rt5677_dac_l_mix[] = { 996 static const struct snd_kcontrol_new rt5677_dac_l_mix[] = {
996 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER, 997 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
997 RT5677_M_ADDA_MIXER1_L_SFT, 1, 1), 998 RT5677_M_ADDA_MIXER1_L_SFT, 1, 1),
998 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER, 999 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
999 RT5677_M_DAC1_L_SFT, 1, 1), 1000 RT5677_M_DAC1_L_SFT, 1, 1),
1000 }; 1001 };
1001 1002
1002 static const struct snd_kcontrol_new rt5677_dac_r_mix[] = { 1003 static const struct snd_kcontrol_new rt5677_dac_r_mix[] = {
1003 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER, 1004 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1004 RT5677_M_ADDA_MIXER1_R_SFT, 1, 1), 1005 RT5677_M_ADDA_MIXER1_R_SFT, 1, 1),
1005 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER, 1006 SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
1006 RT5677_M_DAC1_R_SFT, 1, 1), 1007 RT5677_M_DAC1_R_SFT, 1, 1),
1007 }; 1008 };
1008 1009
1009 static const struct snd_kcontrol_new rt5677_sto1_dac_l_mix[] = { 1010 static const struct snd_kcontrol_new rt5677_sto1_dac_l_mix[] = {
1010 SOC_DAPM_SINGLE("ST L Switch", RT5677_STO1_DAC_MIXER, 1011 SOC_DAPM_SINGLE("ST L Switch", RT5677_STO1_DAC_MIXER,
1011 RT5677_M_ST_DAC1_L_SFT, 1, 1), 1012 RT5677_M_ST_DAC1_L_SFT, 1, 1),
1012 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER, 1013 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
1013 RT5677_M_DAC1_L_STO_L_SFT, 1, 1), 1014 RT5677_M_DAC1_L_STO_L_SFT, 1, 1),
1014 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_STO1_DAC_MIXER, 1015 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_STO1_DAC_MIXER,
1015 RT5677_M_DAC2_L_STO_L_SFT, 1, 1), 1016 RT5677_M_DAC2_L_STO_L_SFT, 1, 1),
1016 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER, 1017 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
1017 RT5677_M_DAC1_R_STO_L_SFT, 1, 1), 1018 RT5677_M_DAC1_R_STO_L_SFT, 1, 1),
1018 }; 1019 };
1019 1020
1020 static const struct snd_kcontrol_new rt5677_sto1_dac_r_mix[] = { 1021 static const struct snd_kcontrol_new rt5677_sto1_dac_r_mix[] = {
1021 SOC_DAPM_SINGLE("ST R Switch", RT5677_STO1_DAC_MIXER, 1022 SOC_DAPM_SINGLE("ST R Switch", RT5677_STO1_DAC_MIXER,
1022 RT5677_M_ST_DAC1_R_SFT, 1, 1), 1023 RT5677_M_ST_DAC1_R_SFT, 1, 1),
1023 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER, 1024 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
1024 RT5677_M_DAC1_R_STO_R_SFT, 1, 1), 1025 RT5677_M_DAC1_R_STO_R_SFT, 1, 1),
1025 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_STO1_DAC_MIXER, 1026 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_STO1_DAC_MIXER,
1026 RT5677_M_DAC2_R_STO_R_SFT, 1, 1), 1027 RT5677_M_DAC2_R_STO_R_SFT, 1, 1),
1027 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER, 1028 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
1028 RT5677_M_DAC1_L_STO_R_SFT, 1, 1), 1029 RT5677_M_DAC1_L_STO_R_SFT, 1, 1),
1029 }; 1030 };
1030 1031
1031 static const struct snd_kcontrol_new rt5677_mono_dac_l_mix[] = { 1032 static const struct snd_kcontrol_new rt5677_mono_dac_l_mix[] = {
1032 SOC_DAPM_SINGLE("ST L Switch", RT5677_MONO_DAC_MIXER, 1033 SOC_DAPM_SINGLE("ST L Switch", RT5677_MONO_DAC_MIXER,
1033 RT5677_M_ST_DAC2_L_SFT, 1, 1), 1034 RT5677_M_ST_DAC2_L_SFT, 1, 1),
1034 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_MONO_DAC_MIXER, 1035 SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_MONO_DAC_MIXER,
1035 RT5677_M_DAC1_L_MONO_L_SFT, 1, 1), 1036 RT5677_M_DAC1_L_MONO_L_SFT, 1, 1),
1036 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER, 1037 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
1037 RT5677_M_DAC2_L_MONO_L_SFT, 1, 1), 1038 RT5677_M_DAC2_L_MONO_L_SFT, 1, 1),
1038 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER, 1039 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
1039 RT5677_M_DAC2_R_MONO_L_SFT, 1, 1), 1040 RT5677_M_DAC2_R_MONO_L_SFT, 1, 1),
1040 }; 1041 };
1041 1042
1042 static const struct snd_kcontrol_new rt5677_mono_dac_r_mix[] = { 1043 static const struct snd_kcontrol_new rt5677_mono_dac_r_mix[] = {
1043 SOC_DAPM_SINGLE("ST R Switch", RT5677_MONO_DAC_MIXER, 1044 SOC_DAPM_SINGLE("ST R Switch", RT5677_MONO_DAC_MIXER,
1044 RT5677_M_ST_DAC2_R_SFT, 1, 1), 1045 RT5677_M_ST_DAC2_R_SFT, 1, 1),
1045 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_MONO_DAC_MIXER, 1046 SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_MONO_DAC_MIXER,
1046 RT5677_M_DAC1_R_MONO_R_SFT, 1, 1), 1047 RT5677_M_DAC1_R_MONO_R_SFT, 1, 1),
1047 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER, 1048 SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
1048 RT5677_M_DAC2_R_MONO_R_SFT, 1, 1), 1049 RT5677_M_DAC2_R_MONO_R_SFT, 1, 1),
1049 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER, 1050 SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
1050 RT5677_M_DAC2_L_MONO_R_SFT, 1, 1), 1051 RT5677_M_DAC2_L_MONO_R_SFT, 1, 1),
1051 }; 1052 };
1052 1053
1053 static const struct snd_kcontrol_new rt5677_dd1_l_mix[] = { 1054 static const struct snd_kcontrol_new rt5677_dd1_l_mix[] = {
1054 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD1_MIXER, 1055 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD1_MIXER,
1055 RT5677_M_STO_L_DD1_L_SFT, 1, 1), 1056 RT5677_M_STO_L_DD1_L_SFT, 1, 1),
1056 SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD1_MIXER, 1057 SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD1_MIXER,
1057 RT5677_M_MONO_L_DD1_L_SFT, 1, 1), 1058 RT5677_M_MONO_L_DD1_L_SFT, 1, 1),
1058 SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER, 1059 SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER,
1059 RT5677_M_DAC3_L_DD1_L_SFT, 1, 1), 1060 RT5677_M_DAC3_L_DD1_L_SFT, 1, 1),
1060 SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER, 1061 SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER,
1061 RT5677_M_DAC3_R_DD1_L_SFT, 1, 1), 1062 RT5677_M_DAC3_R_DD1_L_SFT, 1, 1),
1062 }; 1063 };
1063 1064
1064 static const struct snd_kcontrol_new rt5677_dd1_r_mix[] = { 1065 static const struct snd_kcontrol_new rt5677_dd1_r_mix[] = {
1065 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD1_MIXER, 1066 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD1_MIXER,
1066 RT5677_M_STO_R_DD1_R_SFT, 1, 1), 1067 RT5677_M_STO_R_DD1_R_SFT, 1, 1),
1067 SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD1_MIXER, 1068 SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD1_MIXER,
1068 RT5677_M_MONO_R_DD1_R_SFT, 1, 1), 1069 RT5677_M_MONO_R_DD1_R_SFT, 1, 1),
1069 SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER, 1070 SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER,
1070 RT5677_M_DAC3_R_DD1_R_SFT, 1, 1), 1071 RT5677_M_DAC3_R_DD1_R_SFT, 1, 1),
1071 SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER, 1072 SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER,
1072 RT5677_M_DAC3_L_DD1_R_SFT, 1, 1), 1073 RT5677_M_DAC3_L_DD1_R_SFT, 1, 1),
1073 }; 1074 };
1074 1075
1075 static const struct snd_kcontrol_new rt5677_dd2_l_mix[] = { 1076 static const struct snd_kcontrol_new rt5677_dd2_l_mix[] = {
1076 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD2_MIXER, 1077 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD2_MIXER,
1077 RT5677_M_STO_L_DD2_L_SFT, 1, 1), 1078 RT5677_M_STO_L_DD2_L_SFT, 1, 1),
1078 SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD2_MIXER, 1079 SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD2_MIXER,
1079 RT5677_M_MONO_L_DD2_L_SFT, 1, 1), 1080 RT5677_M_MONO_L_DD2_L_SFT, 1, 1),
1080 SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER, 1081 SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER,
1081 RT5677_M_DAC4_L_DD2_L_SFT, 1, 1), 1082 RT5677_M_DAC4_L_DD2_L_SFT, 1, 1),
1082 SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER, 1083 SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER,
1083 RT5677_M_DAC4_R_DD2_L_SFT, 1, 1), 1084 RT5677_M_DAC4_R_DD2_L_SFT, 1, 1),
1084 }; 1085 };
1085 1086
1086 static const struct snd_kcontrol_new rt5677_dd2_r_mix[] = { 1087 static const struct snd_kcontrol_new rt5677_dd2_r_mix[] = {
1087 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD2_MIXER, 1088 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD2_MIXER,
1088 RT5677_M_STO_R_DD2_R_SFT, 1, 1), 1089 RT5677_M_STO_R_DD2_R_SFT, 1, 1),
1089 SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD2_MIXER, 1090 SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD2_MIXER,
1090 RT5677_M_MONO_R_DD2_R_SFT, 1, 1), 1091 RT5677_M_MONO_R_DD2_R_SFT, 1, 1),
1091 SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER, 1092 SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER,
1092 RT5677_M_DAC4_R_DD2_R_SFT, 1, 1), 1093 RT5677_M_DAC4_R_DD2_R_SFT, 1, 1),
1093 SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER, 1094 SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER,
1094 RT5677_M_DAC4_L_DD2_R_SFT, 1, 1), 1095 RT5677_M_DAC4_L_DD2_R_SFT, 1, 1),
1095 }; 1096 };
1096 1097
1097 static const struct snd_kcontrol_new rt5677_ob_01_mix[] = { 1098 static const struct snd_kcontrol_new rt5677_ob_01_mix[] = {
1098 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1099 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1099 RT5677_DSP_IB_01_H_SFT, 1, 1), 1100 RT5677_DSP_IB_01_H_SFT, 1, 1),
1100 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1101 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1101 RT5677_DSP_IB_23_H_SFT, 1, 1), 1102 RT5677_DSP_IB_23_H_SFT, 1, 1),
1102 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1103 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1103 RT5677_DSP_IB_45_H_SFT, 1, 1), 1104 RT5677_DSP_IB_45_H_SFT, 1, 1),
1104 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1105 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1105 RT5677_DSP_IB_6_H_SFT, 1, 1), 1106 RT5677_DSP_IB_6_H_SFT, 1, 1),
1106 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1107 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1107 RT5677_DSP_IB_7_H_SFT, 1, 1), 1108 RT5677_DSP_IB_7_H_SFT, 1, 1),
1108 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1109 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1109 RT5677_DSP_IB_8_H_SFT, 1, 1), 1110 RT5677_DSP_IB_8_H_SFT, 1, 1),
1110 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1111 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1111 RT5677_DSP_IB_9_H_SFT, 1, 1), 1112 RT5677_DSP_IB_9_H_SFT, 1, 1),
1112 }; 1113 };
1113 1114
1114 static const struct snd_kcontrol_new rt5677_ob_23_mix[] = { 1115 static const struct snd_kcontrol_new rt5677_ob_23_mix[] = {
1115 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1116 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1116 RT5677_DSP_IB_01_L_SFT, 1, 1), 1117 RT5677_DSP_IB_01_L_SFT, 1, 1),
1117 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1118 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1118 RT5677_DSP_IB_23_L_SFT, 1, 1), 1119 RT5677_DSP_IB_23_L_SFT, 1, 1),
1119 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1120 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1120 RT5677_DSP_IB_45_L_SFT, 1, 1), 1121 RT5677_DSP_IB_45_L_SFT, 1, 1),
1121 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1122 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1122 RT5677_DSP_IB_6_L_SFT, 1, 1), 1123 RT5677_DSP_IB_6_L_SFT, 1, 1),
1123 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1124 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1124 RT5677_DSP_IB_7_L_SFT, 1, 1), 1125 RT5677_DSP_IB_7_L_SFT, 1, 1),
1125 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1126 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1126 RT5677_DSP_IB_8_L_SFT, 1, 1), 1127 RT5677_DSP_IB_8_L_SFT, 1, 1),
1127 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, 1128 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
1128 RT5677_DSP_IB_9_L_SFT, 1, 1), 1129 RT5677_DSP_IB_9_L_SFT, 1, 1),
1129 }; 1130 };
1130 1131
1131 static const struct snd_kcontrol_new rt5677_ob_4_mix[] = { 1132 static const struct snd_kcontrol_new rt5677_ob_4_mix[] = {
1132 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1133 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1133 RT5677_DSP_IB_01_H_SFT, 1, 1), 1134 RT5677_DSP_IB_01_H_SFT, 1, 1),
1134 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1135 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1135 RT5677_DSP_IB_23_H_SFT, 1, 1), 1136 RT5677_DSP_IB_23_H_SFT, 1, 1),
1136 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1137 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1137 RT5677_DSP_IB_45_H_SFT, 1, 1), 1138 RT5677_DSP_IB_45_H_SFT, 1, 1),
1138 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1139 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1139 RT5677_DSP_IB_6_H_SFT, 1, 1), 1140 RT5677_DSP_IB_6_H_SFT, 1, 1),
1140 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1141 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1141 RT5677_DSP_IB_7_H_SFT, 1, 1), 1142 RT5677_DSP_IB_7_H_SFT, 1, 1),
1142 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1143 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1143 RT5677_DSP_IB_8_H_SFT, 1, 1), 1144 RT5677_DSP_IB_8_H_SFT, 1, 1),
1144 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1145 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1145 RT5677_DSP_IB_9_H_SFT, 1, 1), 1146 RT5677_DSP_IB_9_H_SFT, 1, 1),
1146 }; 1147 };
1147 1148
1148 static const struct snd_kcontrol_new rt5677_ob_5_mix[] = { 1149 static const struct snd_kcontrol_new rt5677_ob_5_mix[] = {
1149 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1150 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1150 RT5677_DSP_IB_01_L_SFT, 1, 1), 1151 RT5677_DSP_IB_01_L_SFT, 1, 1),
1151 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1152 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1152 RT5677_DSP_IB_23_L_SFT, 1, 1), 1153 RT5677_DSP_IB_23_L_SFT, 1, 1),
1153 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1154 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1154 RT5677_DSP_IB_45_L_SFT, 1, 1), 1155 RT5677_DSP_IB_45_L_SFT, 1, 1),
1155 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1156 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1156 RT5677_DSP_IB_6_L_SFT, 1, 1), 1157 RT5677_DSP_IB_6_L_SFT, 1, 1),
1157 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1158 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1158 RT5677_DSP_IB_7_L_SFT, 1, 1), 1159 RT5677_DSP_IB_7_L_SFT, 1, 1),
1159 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1160 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1160 RT5677_DSP_IB_8_L_SFT, 1, 1), 1161 RT5677_DSP_IB_8_L_SFT, 1, 1),
1161 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, 1162 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
1162 RT5677_DSP_IB_9_L_SFT, 1, 1), 1163 RT5677_DSP_IB_9_L_SFT, 1, 1),
1163 }; 1164 };
1164 1165
1165 static const struct snd_kcontrol_new rt5677_ob_6_mix[] = { 1166 static const struct snd_kcontrol_new rt5677_ob_6_mix[] = {
1166 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1167 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1167 RT5677_DSP_IB_01_H_SFT, 1, 1), 1168 RT5677_DSP_IB_01_H_SFT, 1, 1),
1168 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1169 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1169 RT5677_DSP_IB_23_H_SFT, 1, 1), 1170 RT5677_DSP_IB_23_H_SFT, 1, 1),
1170 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1171 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1171 RT5677_DSP_IB_45_H_SFT, 1, 1), 1172 RT5677_DSP_IB_45_H_SFT, 1, 1),
1172 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1173 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1173 RT5677_DSP_IB_6_H_SFT, 1, 1), 1174 RT5677_DSP_IB_6_H_SFT, 1, 1),
1174 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1175 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1175 RT5677_DSP_IB_7_H_SFT, 1, 1), 1176 RT5677_DSP_IB_7_H_SFT, 1, 1),
1176 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1177 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1177 RT5677_DSP_IB_8_H_SFT, 1, 1), 1178 RT5677_DSP_IB_8_H_SFT, 1, 1),
1178 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1179 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1179 RT5677_DSP_IB_9_H_SFT, 1, 1), 1180 RT5677_DSP_IB_9_H_SFT, 1, 1),
1180 }; 1181 };
1181 1182
1182 static const struct snd_kcontrol_new rt5677_ob_7_mix[] = { 1183 static const struct snd_kcontrol_new rt5677_ob_7_mix[] = {
1183 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1184 SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1184 RT5677_DSP_IB_01_L_SFT, 1, 1), 1185 RT5677_DSP_IB_01_L_SFT, 1, 1),
1185 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1186 SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1186 RT5677_DSP_IB_23_L_SFT, 1, 1), 1187 RT5677_DSP_IB_23_L_SFT, 1, 1),
1187 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1188 SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1188 RT5677_DSP_IB_45_L_SFT, 1, 1), 1189 RT5677_DSP_IB_45_L_SFT, 1, 1),
1189 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1190 SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1190 RT5677_DSP_IB_6_L_SFT, 1, 1), 1191 RT5677_DSP_IB_6_L_SFT, 1, 1),
1191 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1192 SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1192 RT5677_DSP_IB_7_L_SFT, 1, 1), 1193 RT5677_DSP_IB_7_L_SFT, 1, 1),
1193 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1194 SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1194 RT5677_DSP_IB_8_L_SFT, 1, 1), 1195 RT5677_DSP_IB_8_L_SFT, 1, 1),
1195 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, 1196 SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
1196 RT5677_DSP_IB_9_L_SFT, 1, 1), 1197 RT5677_DSP_IB_9_L_SFT, 1, 1),
1197 }; 1198 };
1198 1199
1199 1200
1200 /* Mux */ 1201 /* Mux */
1201 /* DAC1 L/R Source */ /* MX-29 [10:8] */ 1202 /* DAC1 L/R Source */ /* MX-29 [10:8] */
1202 static const char * const rt5677_dac1_src[] = { 1203 static const char * const rt5677_dac1_src[] = {
1203 "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01", 1204 "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01",
1204 "OB 01" 1205 "OB 01"
1205 }; 1206 };
1206 1207
1207 static SOC_ENUM_SINGLE_DECL( 1208 static SOC_ENUM_SINGLE_DECL(
1208 rt5677_dac1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER, 1209 rt5677_dac1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
1209 RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src); 1210 RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src);
1210 1211
1211 static const struct snd_kcontrol_new rt5677_dac1_mux = 1212 static const struct snd_kcontrol_new rt5677_dac1_mux =
1212 SOC_DAPM_ENUM("DAC1 Source", rt5677_dac1_enum); 1213 SOC_DAPM_ENUM("DAC1 Source", rt5677_dac1_enum);
1213 1214
1214 /* ADDA1 L/R Source */ /* MX-29 [1:0] */ 1215 /* ADDA1 L/R Source */ /* MX-29 [1:0] */
1215 static const char * const rt5677_adda1_src[] = { 1216 static const char * const rt5677_adda1_src[] = {
1216 "STO1 ADC MIX", "STO2 ADC MIX", "OB 67", 1217 "STO1 ADC MIX", "STO2 ADC MIX", "OB 67",
1217 }; 1218 };
1218 1219
1219 static SOC_ENUM_SINGLE_DECL( 1220 static SOC_ENUM_SINGLE_DECL(
1220 rt5677_adda1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER, 1221 rt5677_adda1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
1221 RT5677_ADDA1_SEL_SFT, rt5677_adda1_src); 1222 RT5677_ADDA1_SEL_SFT, rt5677_adda1_src);
1222 1223
1223 static const struct snd_kcontrol_new rt5677_adda1_mux = 1224 static const struct snd_kcontrol_new rt5677_adda1_mux =
1224 SOC_DAPM_ENUM("ADDA1 Source", rt5677_adda1_enum); 1225 SOC_DAPM_ENUM("ADDA1 Source", rt5677_adda1_enum);
1225 1226
1226 1227
1227 /*DAC2 L/R Source*/ /* MX-1B [6:4] [2:0] */ 1228 /*DAC2 L/R Source*/ /* MX-1B [6:4] [2:0] */
1228 static const char * const rt5677_dac2l_src[] = { 1229 static const char * const rt5677_dac2l_src[] = {
1229 "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2", 1230 "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2",
1230 "OB 2", 1231 "OB 2",
1231 }; 1232 };
1232 1233
1233 static SOC_ENUM_SINGLE_DECL( 1234 static SOC_ENUM_SINGLE_DECL(
1234 rt5677_dac2l_enum, RT5677_IF_DSP_DAC2_MIXER, 1235 rt5677_dac2l_enum, RT5677_IF_DSP_DAC2_MIXER,
1235 RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src); 1236 RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src);
1236 1237
1237 static const struct snd_kcontrol_new rt5677_dac2_l_mux = 1238 static const struct snd_kcontrol_new rt5677_dac2_l_mux =
1238 SOC_DAPM_ENUM("DAC2 L Source", rt5677_dac2l_enum); 1239 SOC_DAPM_ENUM("DAC2 L Source", rt5677_dac2l_enum);
1239 1240
1240 static const char * const rt5677_dac2r_src[] = { 1241 static const char * const rt5677_dac2r_src[] = {
1241 "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3", 1242 "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3",
1242 "OB 3", "Haptic Generator", "VAD ADC" 1243 "OB 3", "Haptic Generator", "VAD ADC"
1243 }; 1244 };
1244 1245
1245 static SOC_ENUM_SINGLE_DECL( 1246 static SOC_ENUM_SINGLE_DECL(
1246 rt5677_dac2r_enum, RT5677_IF_DSP_DAC2_MIXER, 1247 rt5677_dac2r_enum, RT5677_IF_DSP_DAC2_MIXER,
1247 RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src); 1248 RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src);
1248 1249
1249 static const struct snd_kcontrol_new rt5677_dac2_r_mux = 1250 static const struct snd_kcontrol_new rt5677_dac2_r_mux =
1250 SOC_DAPM_ENUM("DAC2 R Source", rt5677_dac2r_enum); 1251 SOC_DAPM_ENUM("DAC2 R Source", rt5677_dac2r_enum);
1251 1252
1252 /*DAC3 L/R Source*/ /* MX-16 [6:4] [2:0] */ 1253 /*DAC3 L/R Source*/ /* MX-16 [6:4] [2:0] */
1253 static const char * const rt5677_dac3l_src[] = { 1254 static const char * const rt5677_dac3l_src[] = {
1254 "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L", 1255 "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L",
1255 "SLB DAC 4", "OB 4" 1256 "SLB DAC 4", "OB 4"
1256 }; 1257 };
1257 1258
1258 static SOC_ENUM_SINGLE_DECL( 1259 static SOC_ENUM_SINGLE_DECL(
1259 rt5677_dac3l_enum, RT5677_IF_DSP_DAC3_4_MIXER, 1260 rt5677_dac3l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1260 RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src); 1261 RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src);
1261 1262
1262 static const struct snd_kcontrol_new rt5677_dac3_l_mux = 1263 static const struct snd_kcontrol_new rt5677_dac3_l_mux =
1263 SOC_DAPM_ENUM("DAC3 L Source", rt5677_dac3l_enum); 1264 SOC_DAPM_ENUM("DAC3 L Source", rt5677_dac3l_enum);
1264 1265
1265 static const char * const rt5677_dac3r_src[] = { 1266 static const char * const rt5677_dac3r_src[] = {
1266 "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R", 1267 "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R",
1267 "SLB DAC 5", "OB 5" 1268 "SLB DAC 5", "OB 5"
1268 }; 1269 };
1269 1270
1270 static SOC_ENUM_SINGLE_DECL( 1271 static SOC_ENUM_SINGLE_DECL(
1271 rt5677_dac3r_enum, RT5677_IF_DSP_DAC3_4_MIXER, 1272 rt5677_dac3r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1272 RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src); 1273 RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src);
1273 1274
1274 static const struct snd_kcontrol_new rt5677_dac3_r_mux = 1275 static const struct snd_kcontrol_new rt5677_dac3_r_mux =
1275 SOC_DAPM_ENUM("DAC3 R Source", rt5677_dac3r_enum); 1276 SOC_DAPM_ENUM("DAC3 R Source", rt5677_dac3r_enum);
1276 1277
1277 /*DAC4 L/R Source*/ /* MX-16 [14:12] [10:8] */ 1278 /*DAC4 L/R Source*/ /* MX-16 [14:12] [10:8] */
1278 static const char * const rt5677_dac4l_src[] = { 1279 static const char * const rt5677_dac4l_src[] = {
1279 "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L", 1280 "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L",
1280 "SLB DAC 6", "OB 6" 1281 "SLB DAC 6", "OB 6"
1281 }; 1282 };
1282 1283
1283 static SOC_ENUM_SINGLE_DECL( 1284 static SOC_ENUM_SINGLE_DECL(
1284 rt5677_dac4l_enum, RT5677_IF_DSP_DAC3_4_MIXER, 1285 rt5677_dac4l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1285 RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src); 1286 RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src);
1286 1287
1287 static const struct snd_kcontrol_new rt5677_dac4_l_mux = 1288 static const struct snd_kcontrol_new rt5677_dac4_l_mux =
1288 SOC_DAPM_ENUM("DAC4 L Source", rt5677_dac4l_enum); 1289 SOC_DAPM_ENUM("DAC4 L Source", rt5677_dac4l_enum);
1289 1290
1290 static const char * const rt5677_dac4r_src[] = { 1291 static const char * const rt5677_dac4r_src[] = {
1291 "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R", 1292 "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R",
1292 "SLB DAC 7", "OB 7" 1293 "SLB DAC 7", "OB 7"
1293 }; 1294 };
1294 1295
1295 static SOC_ENUM_SINGLE_DECL( 1296 static SOC_ENUM_SINGLE_DECL(
1296 rt5677_dac4r_enum, RT5677_IF_DSP_DAC3_4_MIXER, 1297 rt5677_dac4r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
1297 RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src); 1298 RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src);
1298 1299
1299 static const struct snd_kcontrol_new rt5677_dac4_r_mux = 1300 static const struct snd_kcontrol_new rt5677_dac4_r_mux =
1300 SOC_DAPM_ENUM("DAC4 R Source", rt5677_dac4r_enum); 1301 SOC_DAPM_ENUM("DAC4 R Source", rt5677_dac4r_enum);
1301 1302
1302 /* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */ 1303 /* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */
1303 static const char * const rt5677_iob_bypass_src[] = { 1304 static const char * const rt5677_iob_bypass_src[] = {
1304 "Bypass", "Pass SRC" 1305 "Bypass", "Pass SRC"
1305 }; 1306 };
1306 1307
1307 static SOC_ENUM_SINGLE_DECL( 1308 static SOC_ENUM_SINGLE_DECL(
1308 rt5677_ob01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, 1309 rt5677_ob01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1309 RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src); 1310 RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src);
1310 1311
1311 static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux = 1312 static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux =
1312 SOC_DAPM_ENUM("OB01 Bypass Source", rt5677_ob01_bypass_src_enum); 1313 SOC_DAPM_ENUM("OB01 Bypass Source", rt5677_ob01_bypass_src_enum);
1313 1314
1314 static SOC_ENUM_SINGLE_DECL( 1315 static SOC_ENUM_SINGLE_DECL(
1315 rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, 1316 rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1316 RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src); 1317 RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src);
1317 1318
1318 static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux = 1319 static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux =
1319 SOC_DAPM_ENUM("OB23 Bypass Source", rt5677_ob23_bypass_src_enum); 1320 SOC_DAPM_ENUM("OB23 Bypass Source", rt5677_ob23_bypass_src_enum);
1320 1321
1321 static SOC_ENUM_SINGLE_DECL( 1322 static SOC_ENUM_SINGLE_DECL(
1322 rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, 1323 rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1323 RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src); 1324 RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src);
1324 1325
1325 static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux = 1326 static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux =
1326 SOC_DAPM_ENUM("IB01 Bypass Source", rt5677_ib01_bypass_src_enum); 1327 SOC_DAPM_ENUM("IB01 Bypass Source", rt5677_ib01_bypass_src_enum);
1327 1328
1328 static SOC_ENUM_SINGLE_DECL( 1329 static SOC_ENUM_SINGLE_DECL(
1329 rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, 1330 rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1330 RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src); 1331 RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src);
1331 1332
1332 static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux = 1333 static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux =
1333 SOC_DAPM_ENUM("IB23 Bypass Source", rt5677_ib23_bypass_src_enum); 1334 SOC_DAPM_ENUM("IB23 Bypass Source", rt5677_ib23_bypass_src_enum);
1334 1335
1335 static SOC_ENUM_SINGLE_DECL( 1336 static SOC_ENUM_SINGLE_DECL(
1336 rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, 1337 rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
1337 RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src); 1338 RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src);
1338 1339
1339 static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux = 1340 static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux =
1340 SOC_DAPM_ENUM("IB45 Bypass Source", rt5677_ib45_bypass_src_enum); 1341 SOC_DAPM_ENUM("IB45 Bypass Source", rt5677_ib45_bypass_src_enum);
1341 1342
1342 /* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */ 1343 /* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */
1343 static const char * const rt5677_stereo_adc2_src[] = { 1344 static const char * const rt5677_stereo_adc2_src[] = {
1344 "DD MIX1", "DMIC", "Stereo DAC MIX" 1345 "DD MIX1", "DMIC", "Stereo DAC MIX"
1345 }; 1346 };
1346 1347
1347 static SOC_ENUM_SINGLE_DECL( 1348 static SOC_ENUM_SINGLE_DECL(
1348 rt5677_stereo1_adc2_enum, RT5677_STO1_ADC_MIXER, 1349 rt5677_stereo1_adc2_enum, RT5677_STO1_ADC_MIXER,
1349 RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src); 1350 RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src);
1350 1351
1351 static const struct snd_kcontrol_new rt5677_sto1_adc2_mux = 1352 static const struct snd_kcontrol_new rt5677_sto1_adc2_mux =
1352 SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5677_stereo1_adc2_enum); 1353 SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5677_stereo1_adc2_enum);
1353 1354
1354 static SOC_ENUM_SINGLE_DECL( 1355 static SOC_ENUM_SINGLE_DECL(
1355 rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER, 1356 rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER,
1356 RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src); 1357 RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src);
1357 1358
1358 static const struct snd_kcontrol_new rt5677_sto2_adc2_mux = 1359 static const struct snd_kcontrol_new rt5677_sto2_adc2_mux =
1359 SOC_DAPM_ENUM("Stereo2 ADC2 Source", rt5677_stereo2_adc2_enum); 1360 SOC_DAPM_ENUM("Stereo2 ADC2 Source", rt5677_stereo2_adc2_enum);
1360 1361
1361 static SOC_ENUM_SINGLE_DECL( 1362 static SOC_ENUM_SINGLE_DECL(
1362 rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER, 1363 rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER,
1363 RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src); 1364 RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src);
1364 1365
1365 static const struct snd_kcontrol_new rt5677_sto3_adc2_mux = 1366 static const struct snd_kcontrol_new rt5677_sto3_adc2_mux =
1366 SOC_DAPM_ENUM("Stereo3 ADC2 Source", rt5677_stereo3_adc2_enum); 1367 SOC_DAPM_ENUM("Stereo3 ADC2 Source", rt5677_stereo3_adc2_enum);
1367 1368
1368 /* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */ 1369 /* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */
1369 static const char * const rt5677_dmic_src[] = { 1370 static const char * const rt5677_dmic_src[] = {
1370 "DMIC1", "DMIC2", "DMIC3", "DMIC4" 1371 "DMIC1", "DMIC2", "DMIC3", "DMIC4"
1371 }; 1372 };
1372 1373
1373 static SOC_ENUM_SINGLE_DECL( 1374 static SOC_ENUM_SINGLE_DECL(
1374 rt5677_mono_dmic_l_enum, RT5677_MONO_ADC_MIXER, 1375 rt5677_mono_dmic_l_enum, RT5677_MONO_ADC_MIXER,
1375 RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src); 1376 RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src);
1376 1377
1377 static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux = 1378 static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux =
1378 SOC_DAPM_ENUM("Mono DMIC L Source", rt5677_mono_dmic_l_enum); 1379 SOC_DAPM_ENUM("Mono DMIC L Source", rt5677_mono_dmic_l_enum);
1379 1380
1380 static SOC_ENUM_SINGLE_DECL( 1381 static SOC_ENUM_SINGLE_DECL(
1381 rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER, 1382 rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER,
1382 RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src); 1383 RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src);
1383 1384
1384 static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux = 1385 static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux =
1385 SOC_DAPM_ENUM("Mono DMIC R Source", rt5677_mono_dmic_r_enum); 1386 SOC_DAPM_ENUM("Mono DMIC R Source", rt5677_mono_dmic_r_enum);
1386 1387
1387 static SOC_ENUM_SINGLE_DECL( 1388 static SOC_ENUM_SINGLE_DECL(
1388 rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER, 1389 rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER,
1389 RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src); 1390 RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src);
1390 1391
1391 static const struct snd_kcontrol_new rt5677_sto1_dmic_mux = 1392 static const struct snd_kcontrol_new rt5677_sto1_dmic_mux =
1392 SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5677_stereo1_dmic_enum); 1393 SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5677_stereo1_dmic_enum);
1393 1394
1394 static SOC_ENUM_SINGLE_DECL( 1395 static SOC_ENUM_SINGLE_DECL(
1395 rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER, 1396 rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER,
1396 RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src); 1397 RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src);
1397 1398
1398 static const struct snd_kcontrol_new rt5677_sto2_dmic_mux = 1399 static const struct snd_kcontrol_new rt5677_sto2_dmic_mux =
1399 SOC_DAPM_ENUM("Stereo2 DMIC Source", rt5677_stereo2_dmic_enum); 1400 SOC_DAPM_ENUM("Stereo2 DMIC Source", rt5677_stereo2_dmic_enum);
1400 1401
1401 static SOC_ENUM_SINGLE_DECL( 1402 static SOC_ENUM_SINGLE_DECL(
1402 rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER, 1403 rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER,
1403 RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src); 1404 RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src);
1404 1405
1405 static const struct snd_kcontrol_new rt5677_sto3_dmic_mux = 1406 static const struct snd_kcontrol_new rt5677_sto3_dmic_mux =
1406 SOC_DAPM_ENUM("Stereo3 DMIC Source", rt5677_stereo3_dmic_enum); 1407 SOC_DAPM_ENUM("Stereo3 DMIC Source", rt5677_stereo3_dmic_enum);
1407 1408
1408 static SOC_ENUM_SINGLE_DECL( 1409 static SOC_ENUM_SINGLE_DECL(
1409 rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER, 1410 rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER,
1410 RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src); 1411 RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src);
1411 1412
1412 static const struct snd_kcontrol_new rt5677_sto4_dmic_mux = 1413 static const struct snd_kcontrol_new rt5677_sto4_dmic_mux =
1413 SOC_DAPM_ENUM("Stereo4 DMIC Source", rt5677_stereo4_dmic_enum); 1414 SOC_DAPM_ENUM("Stereo4 DMIC Source", rt5677_stereo4_dmic_enum);
1414 1415
1415 /* Stereo2 ADC Source */ /* MX-26 [0] */ 1416 /* Stereo2 ADC Source */ /* MX-26 [0] */
1416 static const char * const rt5677_stereo2_adc_lr_src[] = { 1417 static const char * const rt5677_stereo2_adc_lr_src[] = {
1417 "L", "LR" 1418 "L", "LR"
1418 }; 1419 };
1419 1420
1420 static SOC_ENUM_SINGLE_DECL( 1421 static SOC_ENUM_SINGLE_DECL(
1421 rt5677_stereo2_adc_lr_enum, RT5677_STO2_ADC_MIXER, 1422 rt5677_stereo2_adc_lr_enum, RT5677_STO2_ADC_MIXER,
1422 RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src); 1423 RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src);
1423 1424
1424 static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux = 1425 static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux =
1425 SOC_DAPM_ENUM("Stereo2 ADC LR Source", rt5677_stereo2_adc_lr_enum); 1426 SOC_DAPM_ENUM("Stereo2 ADC LR Source", rt5677_stereo2_adc_lr_enum);
1426 1427
1427 /* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */ 1428 /* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */
1428 static const char * const rt5677_stereo_adc1_src[] = { 1429 static const char * const rt5677_stereo_adc1_src[] = {
1429 "DD MIX1", "ADC1/2", "Stereo DAC MIX" 1430 "DD MIX1", "ADC1/2", "Stereo DAC MIX"
1430 }; 1431 };
1431 1432
1432 static SOC_ENUM_SINGLE_DECL( 1433 static SOC_ENUM_SINGLE_DECL(
1433 rt5677_stereo1_adc1_enum, RT5677_STO1_ADC_MIXER, 1434 rt5677_stereo1_adc1_enum, RT5677_STO1_ADC_MIXER,
1434 RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src); 1435 RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src);
1435 1436
1436 static const struct snd_kcontrol_new rt5677_sto1_adc1_mux = 1437 static const struct snd_kcontrol_new rt5677_sto1_adc1_mux =
1437 SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5677_stereo1_adc1_enum); 1438 SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5677_stereo1_adc1_enum);
1438 1439
1439 static SOC_ENUM_SINGLE_DECL( 1440 static SOC_ENUM_SINGLE_DECL(
1440 rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER, 1441 rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER,
1441 RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src); 1442 RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src);
1442 1443
1443 static const struct snd_kcontrol_new rt5677_sto2_adc1_mux = 1444 static const struct snd_kcontrol_new rt5677_sto2_adc1_mux =
1444 SOC_DAPM_ENUM("Stereo2 ADC1 Source", rt5677_stereo2_adc1_enum); 1445 SOC_DAPM_ENUM("Stereo2 ADC1 Source", rt5677_stereo2_adc1_enum);
1445 1446
1446 static SOC_ENUM_SINGLE_DECL( 1447 static SOC_ENUM_SINGLE_DECL(
1447 rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER, 1448 rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER,
1448 RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src); 1449 RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src);
1449 1450
1450 static const struct snd_kcontrol_new rt5677_sto3_adc1_mux = 1451 static const struct snd_kcontrol_new rt5677_sto3_adc1_mux =
1451 SOC_DAPM_ENUM("Stereo3 ADC1 Source", rt5677_stereo3_adc1_enum); 1452 SOC_DAPM_ENUM("Stereo3 ADC1 Source", rt5677_stereo3_adc1_enum);
1452 1453
1453 /* Mono ADC Left Source 2 */ /* MX-28 [11:10] */ 1454 /* Mono ADC Left Source 2 */ /* MX-28 [11:10] */
1454 static const char * const rt5677_mono_adc2_l_src[] = { 1455 static const char * const rt5677_mono_adc2_l_src[] = {
1455 "DD MIX1L", "DMIC", "MONO DAC MIXL" 1456 "DD MIX1L", "DMIC", "MONO DAC MIXL"
1456 }; 1457 };
1457 1458
1458 static SOC_ENUM_SINGLE_DECL( 1459 static SOC_ENUM_SINGLE_DECL(
1459 rt5677_mono_adc2_l_enum, RT5677_MONO_ADC_MIXER, 1460 rt5677_mono_adc2_l_enum, RT5677_MONO_ADC_MIXER,
1460 RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src); 1461 RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src);
1461 1462
1462 static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux = 1463 static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux =
1463 SOC_DAPM_ENUM("Mono ADC2 L Source", rt5677_mono_adc2_l_enum); 1464 SOC_DAPM_ENUM("Mono ADC2 L Source", rt5677_mono_adc2_l_enum);
1464 1465
1465 /* Mono ADC Left Source 1 */ /* MX-28 [13:12] */ 1466 /* Mono ADC Left Source 1 */ /* MX-28 [13:12] */
1466 static const char * const rt5677_mono_adc1_l_src[] = { 1467 static const char * const rt5677_mono_adc1_l_src[] = {
1467 "DD MIX1L", "ADC1", "MONO DAC MIXL" 1468 "DD MIX1L", "ADC1", "MONO DAC MIXL"
1468 }; 1469 };
1469 1470
1470 static SOC_ENUM_SINGLE_DECL( 1471 static SOC_ENUM_SINGLE_DECL(
1471 rt5677_mono_adc1_l_enum, RT5677_MONO_ADC_MIXER, 1472 rt5677_mono_adc1_l_enum, RT5677_MONO_ADC_MIXER,
1472 RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src); 1473 RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src);
1473 1474
1474 static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux = 1475 static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux =
1475 SOC_DAPM_ENUM("Mono ADC1 L Source", rt5677_mono_adc1_l_enum); 1476 SOC_DAPM_ENUM("Mono ADC1 L Source", rt5677_mono_adc1_l_enum);
1476 1477
1477 /* Mono ADC Right Source 2 */ /* MX-28 [3:2] */ 1478 /* Mono ADC Right Source 2 */ /* MX-28 [3:2] */
1478 static const char * const rt5677_mono_adc2_r_src[] = { 1479 static const char * const rt5677_mono_adc2_r_src[] = {
1479 "DD MIX1R", "DMIC", "MONO DAC MIXR" 1480 "DD MIX1R", "DMIC", "MONO DAC MIXR"
1480 }; 1481 };
1481 1482
1482 static SOC_ENUM_SINGLE_DECL( 1483 static SOC_ENUM_SINGLE_DECL(
1483 rt5677_mono_adc2_r_enum, RT5677_MONO_ADC_MIXER, 1484 rt5677_mono_adc2_r_enum, RT5677_MONO_ADC_MIXER,
1484 RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src); 1485 RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src);
1485 1486
1486 static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux = 1487 static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux =
1487 SOC_DAPM_ENUM("Mono ADC2 R Source", rt5677_mono_adc2_r_enum); 1488 SOC_DAPM_ENUM("Mono ADC2 R Source", rt5677_mono_adc2_r_enum);
1488 1489
1489 /* Mono ADC Right Source 1 */ /* MX-28 [5:4] */ 1490 /* Mono ADC Right Source 1 */ /* MX-28 [5:4] */
1490 static const char * const rt5677_mono_adc1_r_src[] = { 1491 static const char * const rt5677_mono_adc1_r_src[] = {
1491 "DD MIX1R", "ADC2", "MONO DAC MIXR" 1492 "DD MIX1R", "ADC2", "MONO DAC MIXR"
1492 }; 1493 };
1493 1494
1494 static SOC_ENUM_SINGLE_DECL( 1495 static SOC_ENUM_SINGLE_DECL(
1495 rt5677_mono_adc1_r_enum, RT5677_MONO_ADC_MIXER, 1496 rt5677_mono_adc1_r_enum, RT5677_MONO_ADC_MIXER,
1496 RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src); 1497 RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src);
1497 1498
1498 static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux = 1499 static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux =
1499 SOC_DAPM_ENUM("Mono ADC1 R Source", rt5677_mono_adc1_r_enum); 1500 SOC_DAPM_ENUM("Mono ADC1 R Source", rt5677_mono_adc1_r_enum);
1500 1501
1501 /* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */ 1502 /* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */
1502 static const char * const rt5677_stereo4_adc2_src[] = { 1503 static const char * const rt5677_stereo4_adc2_src[] = {
1503 "DD MIX1", "DMIC", "DD MIX2" 1504 "DD MIX1", "DMIC", "DD MIX2"
1504 }; 1505 };
1505 1506
1506 static SOC_ENUM_SINGLE_DECL( 1507 static SOC_ENUM_SINGLE_DECL(
1507 rt5677_stereo4_adc2_enum, RT5677_STO4_ADC_MIXER, 1508 rt5677_stereo4_adc2_enum, RT5677_STO4_ADC_MIXER,
1508 RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src); 1509 RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src);
1509 1510
1510 static const struct snd_kcontrol_new rt5677_sto4_adc2_mux = 1511 static const struct snd_kcontrol_new rt5677_sto4_adc2_mux =
1511 SOC_DAPM_ENUM("Stereo4 ADC2 Source", rt5677_stereo4_adc2_enum); 1512 SOC_DAPM_ENUM("Stereo4 ADC2 Source", rt5677_stereo4_adc2_enum);
1512 1513
1513 1514
1514 /* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */ 1515 /* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */
1515 static const char * const rt5677_stereo4_adc1_src[] = { 1516 static const char * const rt5677_stereo4_adc1_src[] = {
1516 "DD MIX1", "ADC1/2", "DD MIX2" 1517 "DD MIX1", "ADC1/2", "DD MIX2"
1517 }; 1518 };
1518 1519
1519 static SOC_ENUM_SINGLE_DECL( 1520 static SOC_ENUM_SINGLE_DECL(
1520 rt5677_stereo4_adc1_enum, RT5677_STO4_ADC_MIXER, 1521 rt5677_stereo4_adc1_enum, RT5677_STO4_ADC_MIXER,
1521 RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src); 1522 RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src);
1522 1523
1523 static const struct snd_kcontrol_new rt5677_sto4_adc1_mux = 1524 static const struct snd_kcontrol_new rt5677_sto4_adc1_mux =
1524 SOC_DAPM_ENUM("Stereo4 ADC1 Source", rt5677_stereo4_adc1_enum); 1525 SOC_DAPM_ENUM("Stereo4 ADC1 Source", rt5677_stereo4_adc1_enum);
1525 1526
1526 /* InBound0/1 Source */ /* MX-A3 [14:12] */ 1527 /* InBound0/1 Source */ /* MX-A3 [14:12] */
1527 static const char * const rt5677_inbound01_src[] = { 1528 static const char * const rt5677_inbound01_src[] = {
1528 "IF1 DAC 01", "IF2 DAC 01", "SLB DAC 01", "STO1 ADC MIX", 1529 "IF1 DAC 01", "IF2 DAC 01", "SLB DAC 01", "STO1 ADC MIX",
1529 "VAD ADC/DAC1 FS" 1530 "VAD ADC/DAC1 FS"
1530 }; 1531 };
1531 1532
1532 static SOC_ENUM_SINGLE_DECL( 1533 static SOC_ENUM_SINGLE_DECL(
1533 rt5677_inbound01_enum, RT5677_DSP_INB_CTRL1, 1534 rt5677_inbound01_enum, RT5677_DSP_INB_CTRL1,
1534 RT5677_IB01_SRC_SFT, rt5677_inbound01_src); 1535 RT5677_IB01_SRC_SFT, rt5677_inbound01_src);
1535 1536
1536 static const struct snd_kcontrol_new rt5677_ib01_src_mux = 1537 static const struct snd_kcontrol_new rt5677_ib01_src_mux =
1537 SOC_DAPM_ENUM("InBound0/1 Source", rt5677_inbound01_enum); 1538 SOC_DAPM_ENUM("InBound0/1 Source", rt5677_inbound01_enum);
1538 1539
1539 /* InBound2/3 Source */ /* MX-A3 [10:8] */ 1540 /* InBound2/3 Source */ /* MX-A3 [10:8] */
1540 static const char * const rt5677_inbound23_src[] = { 1541 static const char * const rt5677_inbound23_src[] = {
1541 "IF1 DAC 23", "IF2 DAC 23", "SLB DAC 23", "STO2 ADC MIX", 1542 "IF1 DAC 23", "IF2 DAC 23", "SLB DAC 23", "STO2 ADC MIX",
1542 "DAC1 FS", "IF4 DAC" 1543 "DAC1 FS", "IF4 DAC"
1543 }; 1544 };
1544 1545
1545 static SOC_ENUM_SINGLE_DECL( 1546 static SOC_ENUM_SINGLE_DECL(
1546 rt5677_inbound23_enum, RT5677_DSP_INB_CTRL1, 1547 rt5677_inbound23_enum, RT5677_DSP_INB_CTRL1,
1547 RT5677_IB23_SRC_SFT, rt5677_inbound23_src); 1548 RT5677_IB23_SRC_SFT, rt5677_inbound23_src);
1548 1549
1549 static const struct snd_kcontrol_new rt5677_ib23_src_mux = 1550 static const struct snd_kcontrol_new rt5677_ib23_src_mux =
1550 SOC_DAPM_ENUM("InBound2/3 Source", rt5677_inbound23_enum); 1551 SOC_DAPM_ENUM("InBound2/3 Source", rt5677_inbound23_enum);
1551 1552
1552 /* InBound4/5 Source */ /* MX-A3 [6:4] */ 1553 /* InBound4/5 Source */ /* MX-A3 [6:4] */
1553 static const char * const rt5677_inbound45_src[] = { 1554 static const char * const rt5677_inbound45_src[] = {
1554 "IF1 DAC 45", "IF2 DAC 45", "SLB DAC 45", "STO3 ADC MIX", 1555 "IF1 DAC 45", "IF2 DAC 45", "SLB DAC 45", "STO3 ADC MIX",
1555 "IF3 DAC" 1556 "IF3 DAC"
1556 }; 1557 };
1557 1558
1558 static SOC_ENUM_SINGLE_DECL( 1559 static SOC_ENUM_SINGLE_DECL(
1559 rt5677_inbound45_enum, RT5677_DSP_INB_CTRL1, 1560 rt5677_inbound45_enum, RT5677_DSP_INB_CTRL1,
1560 RT5677_IB45_SRC_SFT, rt5677_inbound45_src); 1561 RT5677_IB45_SRC_SFT, rt5677_inbound45_src);
1561 1562
1562 static const struct snd_kcontrol_new rt5677_ib45_src_mux = 1563 static const struct snd_kcontrol_new rt5677_ib45_src_mux =
1563 SOC_DAPM_ENUM("InBound4/5 Source", rt5677_inbound45_enum); 1564 SOC_DAPM_ENUM("InBound4/5 Source", rt5677_inbound45_enum);
1564 1565
1565 /* InBound6 Source */ /* MX-A3 [2:0] */ 1566 /* InBound6 Source */ /* MX-A3 [2:0] */
1566 static const char * const rt5677_inbound6_src[] = { 1567 static const char * const rt5677_inbound6_src[] = {
1567 "IF1 DAC 6", "IF2 DAC 6", "SLB DAC 6", "STO4 ADC MIX L", 1568 "IF1 DAC 6", "IF2 DAC 6", "SLB DAC 6", "STO4 ADC MIX L",
1568 "IF4 DAC L", "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L" 1569 "IF4 DAC L", "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L"
1569 }; 1570 };
1570 1571
1571 static SOC_ENUM_SINGLE_DECL( 1572 static SOC_ENUM_SINGLE_DECL(
1572 rt5677_inbound6_enum, RT5677_DSP_INB_CTRL1, 1573 rt5677_inbound6_enum, RT5677_DSP_INB_CTRL1,
1573 RT5677_IB6_SRC_SFT, rt5677_inbound6_src); 1574 RT5677_IB6_SRC_SFT, rt5677_inbound6_src);
1574 1575
1575 static const struct snd_kcontrol_new rt5677_ib6_src_mux = 1576 static const struct snd_kcontrol_new rt5677_ib6_src_mux =
1576 SOC_DAPM_ENUM("InBound6 Source", rt5677_inbound6_enum); 1577 SOC_DAPM_ENUM("InBound6 Source", rt5677_inbound6_enum);
1577 1578
1578 /* InBound7 Source */ /* MX-A4 [14:12] */ 1579 /* InBound7 Source */ /* MX-A4 [14:12] */
1579 static const char * const rt5677_inbound7_src[] = { 1580 static const char * const rt5677_inbound7_src[] = {
1580 "IF1 DAC 7", "IF2 DAC 7", "SLB DAC 7", "STO4 ADC MIX R", 1581 "IF1 DAC 7", "IF2 DAC 7", "SLB DAC 7", "STO4 ADC MIX R",
1581 "IF4 DAC R", "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R" 1582 "IF4 DAC R", "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R"
1582 }; 1583 };
1583 1584
1584 static SOC_ENUM_SINGLE_DECL( 1585 static SOC_ENUM_SINGLE_DECL(
1585 rt5677_inbound7_enum, RT5677_DSP_INB_CTRL2, 1586 rt5677_inbound7_enum, RT5677_DSP_INB_CTRL2,
1586 RT5677_IB7_SRC_SFT, rt5677_inbound7_src); 1587 RT5677_IB7_SRC_SFT, rt5677_inbound7_src);
1587 1588
1588 static const struct snd_kcontrol_new rt5677_ib7_src_mux = 1589 static const struct snd_kcontrol_new rt5677_ib7_src_mux =
1589 SOC_DAPM_ENUM("InBound7 Source", rt5677_inbound7_enum); 1590 SOC_DAPM_ENUM("InBound7 Source", rt5677_inbound7_enum);
1590 1591
1591 /* InBound8 Source */ /* MX-A4 [10:8] */ 1592 /* InBound8 Source */ /* MX-A4 [10:8] */
1592 static const char * const rt5677_inbound8_src[] = { 1593 static const char * const rt5677_inbound8_src[] = {
1593 "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L", "STO4 ADC MIX L", 1594 "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L", "STO4 ADC MIX L",
1594 "MONO ADC MIX L", "DACL1 FS" 1595 "MONO ADC MIX L", "DACL1 FS"
1595 }; 1596 };
1596 1597
1597 static SOC_ENUM_SINGLE_DECL( 1598 static SOC_ENUM_SINGLE_DECL(
1598 rt5677_inbound8_enum, RT5677_DSP_INB_CTRL2, 1599 rt5677_inbound8_enum, RT5677_DSP_INB_CTRL2,
1599 RT5677_IB8_SRC_SFT, rt5677_inbound8_src); 1600 RT5677_IB8_SRC_SFT, rt5677_inbound8_src);
1600 1601
1601 static const struct snd_kcontrol_new rt5677_ib8_src_mux = 1602 static const struct snd_kcontrol_new rt5677_ib8_src_mux =
1602 SOC_DAPM_ENUM("InBound8 Source", rt5677_inbound8_enum); 1603 SOC_DAPM_ENUM("InBound8 Source", rt5677_inbound8_enum);
1603 1604
1604 /* InBound9 Source */ /* MX-A4 [6:4] */ 1605 /* InBound9 Source */ /* MX-A4 [6:4] */
1605 static const char * const rt5677_inbound9_src[] = { 1606 static const char * const rt5677_inbound9_src[] = {
1606 "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R", "STO4 ADC MIX R", 1607 "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R", "STO4 ADC MIX R",
1607 "MONO ADC MIX R", "DACR1 FS", "DAC1 FS" 1608 "MONO ADC MIX R", "DACR1 FS", "DAC1 FS"
1608 }; 1609 };
1609 1610
1610 static SOC_ENUM_SINGLE_DECL( 1611 static SOC_ENUM_SINGLE_DECL(
1611 rt5677_inbound9_enum, RT5677_DSP_INB_CTRL2, 1612 rt5677_inbound9_enum, RT5677_DSP_INB_CTRL2,
1612 RT5677_IB9_SRC_SFT, rt5677_inbound9_src); 1613 RT5677_IB9_SRC_SFT, rt5677_inbound9_src);
1613 1614
1614 static const struct snd_kcontrol_new rt5677_ib9_src_mux = 1615 static const struct snd_kcontrol_new rt5677_ib9_src_mux =
1615 SOC_DAPM_ENUM("InBound9 Source", rt5677_inbound9_enum); 1616 SOC_DAPM_ENUM("InBound9 Source", rt5677_inbound9_enum);
1616 1617
1617 /* VAD Source */ /* MX-9F [6:4] */ 1618 /* VAD Source */ /* MX-9F [6:4] */
1618 static const char * const rt5677_vad_src[] = { 1619 static const char * const rt5677_vad_src[] = {
1619 "STO1 ADC MIX L", "MONO ADC MIX L", "MONO ADC MIX R", "STO2 ADC MIX L", 1620 "STO1 ADC MIX L", "MONO ADC MIX L", "MONO ADC MIX R", "STO2 ADC MIX L",
1620 "STO3 ADC MIX L" 1621 "STO3 ADC MIX L"
1621 }; 1622 };
1622 1623
1623 static SOC_ENUM_SINGLE_DECL( 1624 static SOC_ENUM_SINGLE_DECL(
1624 rt5677_vad_enum, RT5677_VAD_CTRL4, 1625 rt5677_vad_enum, RT5677_VAD_CTRL4,
1625 RT5677_VAD_SRC_SFT, rt5677_vad_src); 1626 RT5677_VAD_SRC_SFT, rt5677_vad_src);
1626 1627
1627 static const struct snd_kcontrol_new rt5677_vad_src_mux = 1628 static const struct snd_kcontrol_new rt5677_vad_src_mux =
1628 SOC_DAPM_ENUM("VAD Source", rt5677_vad_enum); 1629 SOC_DAPM_ENUM("VAD Source", rt5677_vad_enum);
1629 1630
1630 /* Sidetone Source */ /* MX-13 [11:9] */ 1631 /* Sidetone Source */ /* MX-13 [11:9] */
1631 static const char * const rt5677_sidetone_src[] = { 1632 static const char * const rt5677_sidetone_src[] = {
1632 "DMIC1 L", "DMIC2 L", "DMIC3 L", "DMIC4 L", "ADC1", "ADC2" 1633 "DMIC1 L", "DMIC2 L", "DMIC3 L", "DMIC4 L", "ADC1", "ADC2"
1633 }; 1634 };
1634 1635
1635 static SOC_ENUM_SINGLE_DECL( 1636 static SOC_ENUM_SINGLE_DECL(
1636 rt5677_sidetone_enum, RT5677_SIDETONE_CTRL, 1637 rt5677_sidetone_enum, RT5677_SIDETONE_CTRL,
1637 RT5677_ST_SEL_SFT, rt5677_sidetone_src); 1638 RT5677_ST_SEL_SFT, rt5677_sidetone_src);
1638 1639
1639 static const struct snd_kcontrol_new rt5677_sidetone_mux = 1640 static const struct snd_kcontrol_new rt5677_sidetone_mux =
1640 SOC_DAPM_ENUM("Sidetone Source", rt5677_sidetone_enum); 1641 SOC_DAPM_ENUM("Sidetone Source", rt5677_sidetone_enum);
1641 1642
1642 /* DAC1/2 Source */ /* MX-15 [1:0] */ 1643 /* DAC1/2 Source */ /* MX-15 [1:0] */
1643 static const char * const rt5677_dac12_src[] = { 1644 static const char * const rt5677_dac12_src[] = {
1644 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2" 1645 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
1645 }; 1646 };
1646 1647
1647 static SOC_ENUM_SINGLE_DECL( 1648 static SOC_ENUM_SINGLE_DECL(
1648 rt5677_dac12_enum, RT5677_ANA_DAC1_2_3_SRC, 1649 rt5677_dac12_enum, RT5677_ANA_DAC1_2_3_SRC,
1649 RT5677_ANA_DAC1_2_SRC_SEL_SFT, rt5677_dac12_src); 1650 RT5677_ANA_DAC1_2_SRC_SEL_SFT, rt5677_dac12_src);
1650 1651
1651 static const struct snd_kcontrol_new rt5677_dac12_mux = 1652 static const struct snd_kcontrol_new rt5677_dac12_mux =
1652 SOC_DAPM_ENUM("Analog DAC1/2 Source", rt5677_dac12_enum); 1653 SOC_DAPM_ENUM("Analog DAC1/2 Source", rt5677_dac12_enum);
1653 1654
1654 /* DAC3 Source */ /* MX-15 [5:4] */ 1655 /* DAC3 Source */ /* MX-15 [5:4] */
1655 static const char * const rt5677_dac3_src[] = { 1656 static const char * const rt5677_dac3_src[] = {
1656 "MONO DAC MIXL", "MONO DAC MIXR", "DD MIX1L", "DD MIX2L" 1657 "MONO DAC MIXL", "MONO DAC MIXR", "DD MIX1L", "DD MIX2L"
1657 }; 1658 };
1658 1659
1659 static SOC_ENUM_SINGLE_DECL( 1660 static SOC_ENUM_SINGLE_DECL(
1660 rt5677_dac3_enum, RT5677_ANA_DAC1_2_3_SRC, 1661 rt5677_dac3_enum, RT5677_ANA_DAC1_2_3_SRC,
1661 RT5677_ANA_DAC3_SRC_SEL_SFT, rt5677_dac3_src); 1662 RT5677_ANA_DAC3_SRC_SEL_SFT, rt5677_dac3_src);
1662 1663
1663 static const struct snd_kcontrol_new rt5677_dac3_mux = 1664 static const struct snd_kcontrol_new rt5677_dac3_mux =
1664 SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum); 1665 SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum);
1665 1666
1666 /* PDM channel Source */ /* MX-31 [13:12][9:8][5:4][1:0] */ 1667 /* PDM channel Source */ /* MX-31 [13:12][9:8][5:4][1:0] */
1667 static const char * const rt5677_pdm_src[] = { 1668 static const char * const rt5677_pdm_src[] = {
1668 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2" 1669 "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
1669 }; 1670 };
1670 1671
1671 static SOC_ENUM_SINGLE_DECL( 1672 static SOC_ENUM_SINGLE_DECL(
1672 rt5677_pdm1_l_enum, RT5677_PDM_OUT_CTRL, 1673 rt5677_pdm1_l_enum, RT5677_PDM_OUT_CTRL,
1673 RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src); 1674 RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src);
1674 1675
1675 static const struct snd_kcontrol_new rt5677_pdm1_l_mux = 1676 static const struct snd_kcontrol_new rt5677_pdm1_l_mux =
1676 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_l_enum); 1677 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_l_enum);
1677 1678
1678 static SOC_ENUM_SINGLE_DECL( 1679 static SOC_ENUM_SINGLE_DECL(
1679 rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL, 1680 rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL,
1680 RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src); 1681 RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src);
1681 1682
1682 static const struct snd_kcontrol_new rt5677_pdm2_l_mux = 1683 static const struct snd_kcontrol_new rt5677_pdm2_l_mux =
1683 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_l_enum); 1684 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_l_enum);
1684 1685
1685 static SOC_ENUM_SINGLE_DECL( 1686 static SOC_ENUM_SINGLE_DECL(
1686 rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL, 1687 rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL,
1687 RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src); 1688 RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src);
1688 1689
1689 static const struct snd_kcontrol_new rt5677_pdm1_r_mux = 1690 static const struct snd_kcontrol_new rt5677_pdm1_r_mux =
1690 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_r_enum); 1691 SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_r_enum);
1691 1692
1692 static SOC_ENUM_SINGLE_DECL( 1693 static SOC_ENUM_SINGLE_DECL(
1693 rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL, 1694 rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL,
1694 RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src); 1695 RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src);
1695 1696
1696 static const struct snd_kcontrol_new rt5677_pdm2_r_mux = 1697 static const struct snd_kcontrol_new rt5677_pdm2_r_mux =
1697 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_r_enum); 1698 SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_r_enum);
1698 1699
1699 /* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0] */ 1700 /* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0] */
1700 static const char * const rt5677_if12_adc1_src[] = { 1701 static const char * const rt5677_if12_adc1_src[] = {
1701 "STO1 ADC MIX", "OB01", "VAD ADC" 1702 "STO1 ADC MIX", "OB01", "VAD ADC"
1702 }; 1703 };
1703 1704
1704 static SOC_ENUM_SINGLE_DECL( 1705 static SOC_ENUM_SINGLE_DECL(
1705 rt5677_if1_adc1_enum, RT5677_TDM1_CTRL2, 1706 rt5677_if1_adc1_enum, RT5677_TDM1_CTRL2,
1706 RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src); 1707 RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src);
1707 1708
1708 static const struct snd_kcontrol_new rt5677_if1_adc1_mux = 1709 static const struct snd_kcontrol_new rt5677_if1_adc1_mux =
1709 SOC_DAPM_ENUM("IF1 ADC1 Source", rt5677_if1_adc1_enum); 1710 SOC_DAPM_ENUM("IF1 ADC1 Source", rt5677_if1_adc1_enum);
1710 1711
1711 static SOC_ENUM_SINGLE_DECL( 1712 static SOC_ENUM_SINGLE_DECL(
1712 rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2, 1713 rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2,
1713 RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src); 1714 RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src);
1714 1715
1715 static const struct snd_kcontrol_new rt5677_if2_adc1_mux = 1716 static const struct snd_kcontrol_new rt5677_if2_adc1_mux =
1716 SOC_DAPM_ENUM("IF2 ADC1 Source", rt5677_if2_adc1_enum); 1717 SOC_DAPM_ENUM("IF2 ADC1 Source", rt5677_if2_adc1_enum);
1717 1718
1718 static SOC_ENUM_SINGLE_DECL( 1719 static SOC_ENUM_SINGLE_DECL(
1719 rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX, 1720 rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX,
1720 RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src); 1721 RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src);
1721 1722
1722 static const struct snd_kcontrol_new rt5677_slb_adc1_mux = 1723 static const struct snd_kcontrol_new rt5677_slb_adc1_mux =
1723 SOC_DAPM_ENUM("SLB ADC1 Source", rt5677_slb_adc1_enum); 1724 SOC_DAPM_ENUM("SLB ADC1 Source", rt5677_slb_adc1_enum);
1724 1725
1725 /* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */ 1726 /* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */
1726 static const char * const rt5677_if12_adc2_src[] = { 1727 static const char * const rt5677_if12_adc2_src[] = {
1727 "STO2 ADC MIX", "OB23" 1728 "STO2 ADC MIX", "OB23"
1728 }; 1729 };
1729 1730
1730 static SOC_ENUM_SINGLE_DECL( 1731 static SOC_ENUM_SINGLE_DECL(
1731 rt5677_if1_adc2_enum, RT5677_TDM1_CTRL2, 1732 rt5677_if1_adc2_enum, RT5677_TDM1_CTRL2,
1732 RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src); 1733 RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src);
1733 1734
1734 static const struct snd_kcontrol_new rt5677_if1_adc2_mux = 1735 static const struct snd_kcontrol_new rt5677_if1_adc2_mux =
1735 SOC_DAPM_ENUM("IF1 ADC2 Source", rt5677_if1_adc2_enum); 1736 SOC_DAPM_ENUM("IF1 ADC2 Source", rt5677_if1_adc2_enum);
1736 1737
1737 static SOC_ENUM_SINGLE_DECL( 1738 static SOC_ENUM_SINGLE_DECL(
1738 rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2, 1739 rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2,
1739 RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src); 1740 RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src);
1740 1741
1741 static const struct snd_kcontrol_new rt5677_if2_adc2_mux = 1742 static const struct snd_kcontrol_new rt5677_if2_adc2_mux =
1742 SOC_DAPM_ENUM("IF2 ADC2 Source", rt5677_if2_adc2_enum); 1743 SOC_DAPM_ENUM("IF2 ADC2 Source", rt5677_if2_adc2_enum);
1743 1744
1744 static SOC_ENUM_SINGLE_DECL( 1745 static SOC_ENUM_SINGLE_DECL(
1745 rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX, 1746 rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX,
1746 RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src); 1747 RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src);
1747 1748
1748 static const struct snd_kcontrol_new rt5677_slb_adc2_mux = 1749 static const struct snd_kcontrol_new rt5677_slb_adc2_mux =
1749 SOC_DAPM_ENUM("SLB ADC2 Source", rt5677_slb_adc2_enum); 1750 SOC_DAPM_ENUM("SLB ADC2 Source", rt5677_slb_adc2_enum);
1750 1751
1751 /* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */ 1752 /* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */
1752 static const char * const rt5677_if12_adc3_src[] = { 1753 static const char * const rt5677_if12_adc3_src[] = {
1753 "STO3 ADC MIX", "MONO ADC MIX", "OB45" 1754 "STO3 ADC MIX", "MONO ADC MIX", "OB45"
1754 }; 1755 };
1755 1756
1756 static SOC_ENUM_SINGLE_DECL( 1757 static SOC_ENUM_SINGLE_DECL(
1757 rt5677_if1_adc3_enum, RT5677_TDM1_CTRL2, 1758 rt5677_if1_adc3_enum, RT5677_TDM1_CTRL2,
1758 RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src); 1759 RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src);
1759 1760
1760 static const struct snd_kcontrol_new rt5677_if1_adc3_mux = 1761 static const struct snd_kcontrol_new rt5677_if1_adc3_mux =
1761 SOC_DAPM_ENUM("IF1 ADC3 Source", rt5677_if1_adc3_enum); 1762 SOC_DAPM_ENUM("IF1 ADC3 Source", rt5677_if1_adc3_enum);
1762 1763
1763 static SOC_ENUM_SINGLE_DECL( 1764 static SOC_ENUM_SINGLE_DECL(
1764 rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2, 1765 rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2,
1765 RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src); 1766 RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src);
1766 1767
1767 static const struct snd_kcontrol_new rt5677_if2_adc3_mux = 1768 static const struct snd_kcontrol_new rt5677_if2_adc3_mux =
1768 SOC_DAPM_ENUM("IF2 ADC3 Source", rt5677_if2_adc3_enum); 1769 SOC_DAPM_ENUM("IF2 ADC3 Source", rt5677_if2_adc3_enum);
1769 1770
1770 static SOC_ENUM_SINGLE_DECL( 1771 static SOC_ENUM_SINGLE_DECL(
1771 rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX, 1772 rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX,
1772 RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src); 1773 RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src);
1773 1774
1774 static const struct snd_kcontrol_new rt5677_slb_adc3_mux = 1775 static const struct snd_kcontrol_new rt5677_slb_adc3_mux =
1775 SOC_DAPM_ENUM("SLB ADC3 Source", rt5677_slb_adc3_enum); 1776 SOC_DAPM_ENUM("SLB ADC3 Source", rt5677_slb_adc3_enum);
1776 1777
1777 /* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */ 1778 /* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */
1778 static const char * const rt5677_if12_adc4_src[] = { 1779 static const char * const rt5677_if12_adc4_src[] = {
1779 "STO4 ADC MIX", "OB67", "OB01" 1780 "STO4 ADC MIX", "OB67", "OB01"
1780 }; 1781 };
1781 1782
1782 static SOC_ENUM_SINGLE_DECL( 1783 static SOC_ENUM_SINGLE_DECL(
1783 rt5677_if1_adc4_enum, RT5677_TDM1_CTRL2, 1784 rt5677_if1_adc4_enum, RT5677_TDM1_CTRL2,
1784 RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src); 1785 RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src);
1785 1786
1786 static const struct snd_kcontrol_new rt5677_if1_adc4_mux = 1787 static const struct snd_kcontrol_new rt5677_if1_adc4_mux =
1787 SOC_DAPM_ENUM("IF1 ADC4 Source", rt5677_if1_adc4_enum); 1788 SOC_DAPM_ENUM("IF1 ADC4 Source", rt5677_if1_adc4_enum);
1788 1789
1789 static SOC_ENUM_SINGLE_DECL( 1790 static SOC_ENUM_SINGLE_DECL(
1790 rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2, 1791 rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2,
1791 RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src); 1792 RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src);
1792 1793
1793 static const struct snd_kcontrol_new rt5677_if2_adc4_mux = 1794 static const struct snd_kcontrol_new rt5677_if2_adc4_mux =
1794 SOC_DAPM_ENUM("IF2 ADC4 Source", rt5677_if2_adc4_enum); 1795 SOC_DAPM_ENUM("IF2 ADC4 Source", rt5677_if2_adc4_enum);
1795 1796
1796 static SOC_ENUM_SINGLE_DECL( 1797 static SOC_ENUM_SINGLE_DECL(
1797 rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX, 1798 rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX,
1798 RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src); 1799 RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src);
1799 1800
1800 static const struct snd_kcontrol_new rt5677_slb_adc4_mux = 1801 static const struct snd_kcontrol_new rt5677_slb_adc4_mux =
1801 SOC_DAPM_ENUM("SLB ADC4 Source", rt5677_slb_adc4_enum); 1802 SOC_DAPM_ENUM("SLB ADC4 Source", rt5677_slb_adc4_enum);
1802 1803
1803 /* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4] */ 1804 /* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4] */
1804 static const char * const rt5677_if34_adc_src[] = { 1805 static const char * const rt5677_if34_adc_src[] = {
1805 "STO1 ADC MIX", "STO2 ADC MIX", "STO3 ADC MIX", "STO4 ADC MIX", 1806 "STO1 ADC MIX", "STO2 ADC MIX", "STO3 ADC MIX", "STO4 ADC MIX",
1806 "MONO ADC MIX", "OB01", "OB23", "VAD ADC" 1807 "MONO ADC MIX", "OB01", "OB23", "VAD ADC"
1807 }; 1808 };
1808 1809
1809 static SOC_ENUM_SINGLE_DECL( 1810 static SOC_ENUM_SINGLE_DECL(
1810 rt5677_if3_adc_enum, RT5677_IF3_DATA, 1811 rt5677_if3_adc_enum, RT5677_IF3_DATA,
1811 RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src); 1812 RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src);
1812 1813
1813 static const struct snd_kcontrol_new rt5677_if3_adc_mux = 1814 static const struct snd_kcontrol_new rt5677_if3_adc_mux =
1814 SOC_DAPM_ENUM("IF3 ADC Source", rt5677_if3_adc_enum); 1815 SOC_DAPM_ENUM("IF3 ADC Source", rt5677_if3_adc_enum);
1815 1816
1816 static SOC_ENUM_SINGLE_DECL( 1817 static SOC_ENUM_SINGLE_DECL(
1817 rt5677_if4_adc_enum, RT5677_IF4_DATA, 1818 rt5677_if4_adc_enum, RT5677_IF4_DATA,
1818 RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src); 1819 RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src);
1819 1820
1820 static const struct snd_kcontrol_new rt5677_if4_adc_mux = 1821 static const struct snd_kcontrol_new rt5677_if4_adc_mux =
1821 SOC_DAPM_ENUM("IF4 ADC Source", rt5677_if4_adc_enum); 1822 SOC_DAPM_ENUM("IF4 ADC Source", rt5677_if4_adc_enum);
1822 1823
1823 /* TDM IF1/2 ADC Data Selection */ /* MX-3B MX-40 [7:6][5:4][3:2][1:0] */ 1824 /* TDM IF1/2 ADC Data Selection */ /* MX-3B MX-40 [7:6][5:4][3:2][1:0] */
1824 static const char * const rt5677_if12_adc_swap_src[] = { 1825 static const char * const rt5677_if12_adc_swap_src[] = {
1825 "L/R", "R/L", "L/L", "R/R" 1826 "L/R", "R/L", "L/L", "R/R"
1826 }; 1827 };
1827 1828
1828 static SOC_ENUM_SINGLE_DECL( 1829 static SOC_ENUM_SINGLE_DECL(
1829 rt5677_if1_adc1_swap_enum, RT5677_TDM1_CTRL1, 1830 rt5677_if1_adc1_swap_enum, RT5677_TDM1_CTRL1,
1830 RT5677_IF1_ADC1_SWAP_SFT, rt5677_if12_adc_swap_src); 1831 RT5677_IF1_ADC1_SWAP_SFT, rt5677_if12_adc_swap_src);
1831 1832
1832 static const struct snd_kcontrol_new rt5677_if1_adc1_swap_mux = 1833 static const struct snd_kcontrol_new rt5677_if1_adc1_swap_mux =
1833 SOC_DAPM_ENUM("IF1 ADC1 Swap Source", rt5677_if1_adc1_swap_enum); 1834 SOC_DAPM_ENUM("IF1 ADC1 Swap Source", rt5677_if1_adc1_swap_enum);
1834 1835
1835 static SOC_ENUM_SINGLE_DECL( 1836 static SOC_ENUM_SINGLE_DECL(
1836 rt5677_if1_adc2_swap_enum, RT5677_TDM1_CTRL1, 1837 rt5677_if1_adc2_swap_enum, RT5677_TDM1_CTRL1,
1837 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src); 1838 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1838 1839
1839 static const struct snd_kcontrol_new rt5677_if1_adc2_swap_mux = 1840 static const struct snd_kcontrol_new rt5677_if1_adc2_swap_mux =
1840 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if1_adc2_swap_enum); 1841 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if1_adc2_swap_enum);
1841 1842
1842 static SOC_ENUM_SINGLE_DECL( 1843 static SOC_ENUM_SINGLE_DECL(
1843 rt5677_if1_adc3_swap_enum, RT5677_TDM1_CTRL1, 1844 rt5677_if1_adc3_swap_enum, RT5677_TDM1_CTRL1,
1844 RT5677_IF1_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src); 1845 RT5677_IF1_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
1845 1846
1846 static const struct snd_kcontrol_new rt5677_if1_adc3_swap_mux = 1847 static const struct snd_kcontrol_new rt5677_if1_adc3_swap_mux =
1847 SOC_DAPM_ENUM("IF1 ADC3 Swap Source", rt5677_if1_adc3_swap_enum); 1848 SOC_DAPM_ENUM("IF1 ADC3 Swap Source", rt5677_if1_adc3_swap_enum);
1848 1849
1849 static SOC_ENUM_SINGLE_DECL( 1850 static SOC_ENUM_SINGLE_DECL(
1850 rt5677_if1_adc4_swap_enum, RT5677_TDM1_CTRL1, 1851 rt5677_if1_adc4_swap_enum, RT5677_TDM1_CTRL1,
1851 RT5677_IF1_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src); 1852 RT5677_IF1_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
1852 1853
1853 static const struct snd_kcontrol_new rt5677_if1_adc4_swap_mux = 1854 static const struct snd_kcontrol_new rt5677_if1_adc4_swap_mux =
1854 SOC_DAPM_ENUM("IF1 ADC4 Swap Source", rt5677_if1_adc4_swap_enum); 1855 SOC_DAPM_ENUM("IF1 ADC4 Swap Source", rt5677_if1_adc4_swap_enum);
1855 1856
1856 static SOC_ENUM_SINGLE_DECL( 1857 static SOC_ENUM_SINGLE_DECL(
1857 rt5677_if2_adc1_swap_enum, RT5677_TDM2_CTRL1, 1858 rt5677_if2_adc1_swap_enum, RT5677_TDM2_CTRL1,
1858 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src); 1859 RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1859 1860
1860 static const struct snd_kcontrol_new rt5677_if2_adc1_swap_mux = 1861 static const struct snd_kcontrol_new rt5677_if2_adc1_swap_mux =
1861 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if2_adc1_swap_enum); 1862 SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if2_adc1_swap_enum);
1862 1863
1863 static SOC_ENUM_SINGLE_DECL( 1864 static SOC_ENUM_SINGLE_DECL(
1864 rt5677_if2_adc2_swap_enum, RT5677_TDM2_CTRL1, 1865 rt5677_if2_adc2_swap_enum, RT5677_TDM2_CTRL1,
1865 RT5677_IF2_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src); 1866 RT5677_IF2_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
1866 1867
1867 static const struct snd_kcontrol_new rt5677_if2_adc2_swap_mux = 1868 static const struct snd_kcontrol_new rt5677_if2_adc2_swap_mux =
1868 SOC_DAPM_ENUM("IF2 ADC2 Swap Source", rt5677_if2_adc2_swap_enum); 1869 SOC_DAPM_ENUM("IF2 ADC2 Swap Source", rt5677_if2_adc2_swap_enum);
1869 1870
1870 static SOC_ENUM_SINGLE_DECL( 1871 static SOC_ENUM_SINGLE_DECL(
1871 rt5677_if2_adc3_swap_enum, RT5677_TDM2_CTRL1, 1872 rt5677_if2_adc3_swap_enum, RT5677_TDM2_CTRL1,
1872 RT5677_IF2_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src); 1873 RT5677_IF2_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
1873 1874
1874 static const struct snd_kcontrol_new rt5677_if2_adc3_swap_mux = 1875 static const struct snd_kcontrol_new rt5677_if2_adc3_swap_mux =
1875 SOC_DAPM_ENUM("IF2 ADC3 Swap Source", rt5677_if2_adc3_swap_enum); 1876 SOC_DAPM_ENUM("IF2 ADC3 Swap Source", rt5677_if2_adc3_swap_enum);
1876 1877
1877 static SOC_ENUM_SINGLE_DECL( 1878 static SOC_ENUM_SINGLE_DECL(
1878 rt5677_if2_adc4_swap_enum, RT5677_TDM2_CTRL1, 1879 rt5677_if2_adc4_swap_enum, RT5677_TDM2_CTRL1,
1879 RT5677_IF2_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src); 1880 RT5677_IF2_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
1880 1881
1881 static const struct snd_kcontrol_new rt5677_if2_adc4_swap_mux = 1882 static const struct snd_kcontrol_new rt5677_if2_adc4_swap_mux =
1882 SOC_DAPM_ENUM("IF2 ADC4 Swap Source", rt5677_if2_adc4_swap_enum); 1883 SOC_DAPM_ENUM("IF2 ADC4 Swap Source", rt5677_if2_adc4_swap_enum);
1883 1884
1884 /* TDM IF1 ADC Data Selection */ /* MX-3C [2:0] */ 1885 /* TDM IF1 ADC Data Selection */ /* MX-3C [2:0] */
1885 static const char * const rt5677_if1_adc_tdm_swap_src[] = { 1886 static const char * const rt5677_if1_adc_tdm_swap_src[] = {
1886 "1/2/3/4", "2/1/3/4", "2/3/1/4", "4/1/2/3", "1/3/2/4", "1/4/2/3", 1887 "1/2/3/4", "2/1/3/4", "2/3/1/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
1887 "3/1/2/4", "3/4/1/2" 1888 "3/1/2/4", "3/4/1/2"
1888 }; 1889 };
1889 1890
1890 static SOC_ENUM_SINGLE_DECL( 1891 static SOC_ENUM_SINGLE_DECL(
1891 rt5677_if1_adc_tdm_swap_enum, RT5677_TDM1_CTRL2, 1892 rt5677_if1_adc_tdm_swap_enum, RT5677_TDM1_CTRL2,
1892 RT5677_IF1_ADC_CTRL_SFT, rt5677_if1_adc_tdm_swap_src); 1893 RT5677_IF1_ADC_CTRL_SFT, rt5677_if1_adc_tdm_swap_src);
1893 1894
1894 static const struct snd_kcontrol_new rt5677_if1_adc_tdm_swap_mux = 1895 static const struct snd_kcontrol_new rt5677_if1_adc_tdm_swap_mux =
1895 SOC_DAPM_ENUM("IF1 ADC TDM Swap Source", rt5677_if1_adc_tdm_swap_enum); 1896 SOC_DAPM_ENUM("IF1 ADC TDM Swap Source", rt5677_if1_adc_tdm_swap_enum);
1896 1897
1897 /* TDM IF2 ADC Data Selection */ /* MX-41[2:0] */ 1898 /* TDM IF2 ADC Data Selection */ /* MX-41[2:0] */
1898 static const char * const rt5677_if2_adc_tdm_swap_src[] = { 1899 static const char * const rt5677_if2_adc_tdm_swap_src[] = {
1899 "1/2/3/4", "2/1/3/4", "3/1/2/4", "4/1/2/3", "1/3/2/4", "1/4/2/3", 1900 "1/2/3/4", "2/1/3/4", "3/1/2/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
1900 "2/3/1/4", "3/4/1/2" 1901 "2/3/1/4", "3/4/1/2"
1901 }; 1902 };
1902 1903
1903 static SOC_ENUM_SINGLE_DECL( 1904 static SOC_ENUM_SINGLE_DECL(
1904 rt5677_if2_adc_tdm_swap_enum, RT5677_TDM2_CTRL2, 1905 rt5677_if2_adc_tdm_swap_enum, RT5677_TDM2_CTRL2,
1905 RT5677_IF2_ADC_CTRL_SFT, rt5677_if2_adc_tdm_swap_src); 1906 RT5677_IF2_ADC_CTRL_SFT, rt5677_if2_adc_tdm_swap_src);
1906 1907
1907 static const struct snd_kcontrol_new rt5677_if2_adc_tdm_swap_mux = 1908 static const struct snd_kcontrol_new rt5677_if2_adc_tdm_swap_mux =
1908 SOC_DAPM_ENUM("IF2 ADC TDM Swap Source", rt5677_if2_adc_tdm_swap_enum); 1909 SOC_DAPM_ENUM("IF2 ADC TDM Swap Source", rt5677_if2_adc_tdm_swap_enum);
1909 1910
1910 /* TDM IF1/2 DAC Data Selection */ /* MX-3E[14:12][10:8][6:4][2:0] 1911 /* TDM IF1/2 DAC Data Selection */ /* MX-3E[14:12][10:8][6:4][2:0]
1911 MX-3F[14:12][10:8][6:4][2:0] 1912 MX-3F[14:12][10:8][6:4][2:0]
1912 MX-43[14:12][10:8][6:4][2:0] 1913 MX-43[14:12][10:8][6:4][2:0]
1913 MX-44[14:12][10:8][6:4][2:0] */ 1914 MX-44[14:12][10:8][6:4][2:0] */
1914 static const char * const rt5677_if12_dac_tdm_sel_src[] = { 1915 static const char * const rt5677_if12_dac_tdm_sel_src[] = {
1915 "Slot0", "Slot1", "Slot2", "Slot3", "Slot4", "Slot5", "Slot6", "Slot7" 1916 "Slot0", "Slot1", "Slot2", "Slot3", "Slot4", "Slot5", "Slot6", "Slot7"
1916 }; 1917 };
1917 1918
1918 static SOC_ENUM_SINGLE_DECL( 1919 static SOC_ENUM_SINGLE_DECL(
1919 rt5677_if1_dac0_tdm_sel_enum, RT5677_TDM1_CTRL4, 1920 rt5677_if1_dac0_tdm_sel_enum, RT5677_TDM1_CTRL4,
1920 RT5677_IF1_DAC0_SFT, rt5677_if12_dac_tdm_sel_src); 1921 RT5677_IF1_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
1921 1922
1922 static const struct snd_kcontrol_new rt5677_if1_dac0_tdm_sel_mux = 1923 static const struct snd_kcontrol_new rt5677_if1_dac0_tdm_sel_mux =
1923 SOC_DAPM_ENUM("IF1 DAC0 TDM Source", rt5677_if1_dac0_tdm_sel_enum); 1924 SOC_DAPM_ENUM("IF1 DAC0 TDM Source", rt5677_if1_dac0_tdm_sel_enum);
1924 1925
1925 static SOC_ENUM_SINGLE_DECL( 1926 static SOC_ENUM_SINGLE_DECL(
1926 rt5677_if1_dac1_tdm_sel_enum, RT5677_TDM1_CTRL4, 1927 rt5677_if1_dac1_tdm_sel_enum, RT5677_TDM1_CTRL4,
1927 RT5677_IF1_DAC1_SFT, rt5677_if12_dac_tdm_sel_src); 1928 RT5677_IF1_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
1928 1929
1929 static const struct snd_kcontrol_new rt5677_if1_dac1_tdm_sel_mux = 1930 static const struct snd_kcontrol_new rt5677_if1_dac1_tdm_sel_mux =
1930 SOC_DAPM_ENUM("IF1 DAC1 TDM Source", rt5677_if1_dac1_tdm_sel_enum); 1931 SOC_DAPM_ENUM("IF1 DAC1 TDM Source", rt5677_if1_dac1_tdm_sel_enum);
1931 1932
1932 static SOC_ENUM_SINGLE_DECL( 1933 static SOC_ENUM_SINGLE_DECL(
1933 rt5677_if1_dac2_tdm_sel_enum, RT5677_TDM1_CTRL4, 1934 rt5677_if1_dac2_tdm_sel_enum, RT5677_TDM1_CTRL4,
1934 RT5677_IF1_DAC2_SFT, rt5677_if12_dac_tdm_sel_src); 1935 RT5677_IF1_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
1935 1936
1936 static const struct snd_kcontrol_new rt5677_if1_dac2_tdm_sel_mux = 1937 static const struct snd_kcontrol_new rt5677_if1_dac2_tdm_sel_mux =
1937 SOC_DAPM_ENUM("IF1 DAC2 TDM Source", rt5677_if1_dac2_tdm_sel_enum); 1938 SOC_DAPM_ENUM("IF1 DAC2 TDM Source", rt5677_if1_dac2_tdm_sel_enum);
1938 1939
1939 static SOC_ENUM_SINGLE_DECL( 1940 static SOC_ENUM_SINGLE_DECL(
1940 rt5677_if1_dac3_tdm_sel_enum, RT5677_TDM1_CTRL4, 1941 rt5677_if1_dac3_tdm_sel_enum, RT5677_TDM1_CTRL4,
1941 RT5677_IF1_DAC3_SFT, rt5677_if12_dac_tdm_sel_src); 1942 RT5677_IF1_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
1942 1943
1943 static const struct snd_kcontrol_new rt5677_if1_dac3_tdm_sel_mux = 1944 static const struct snd_kcontrol_new rt5677_if1_dac3_tdm_sel_mux =
1944 SOC_DAPM_ENUM("IF1 DAC3 TDM Source", rt5677_if1_dac3_tdm_sel_enum); 1945 SOC_DAPM_ENUM("IF1 DAC3 TDM Source", rt5677_if1_dac3_tdm_sel_enum);
1945 1946
1946 static SOC_ENUM_SINGLE_DECL( 1947 static SOC_ENUM_SINGLE_DECL(
1947 rt5677_if1_dac4_tdm_sel_enum, RT5677_TDM1_CTRL5, 1948 rt5677_if1_dac4_tdm_sel_enum, RT5677_TDM1_CTRL5,
1948 RT5677_IF1_DAC4_SFT, rt5677_if12_dac_tdm_sel_src); 1949 RT5677_IF1_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
1949 1950
1950 static const struct snd_kcontrol_new rt5677_if1_dac4_tdm_sel_mux = 1951 static const struct snd_kcontrol_new rt5677_if1_dac4_tdm_sel_mux =
1951 SOC_DAPM_ENUM("IF1 DAC4 TDM Source", rt5677_if1_dac4_tdm_sel_enum); 1952 SOC_DAPM_ENUM("IF1 DAC4 TDM Source", rt5677_if1_dac4_tdm_sel_enum);
1952 1953
1953 static SOC_ENUM_SINGLE_DECL( 1954 static SOC_ENUM_SINGLE_DECL(
1954 rt5677_if1_dac5_tdm_sel_enum, RT5677_TDM1_CTRL5, 1955 rt5677_if1_dac5_tdm_sel_enum, RT5677_TDM1_CTRL5,
1955 RT5677_IF1_DAC5_SFT, rt5677_if12_dac_tdm_sel_src); 1956 RT5677_IF1_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
1956 1957
1957 static const struct snd_kcontrol_new rt5677_if1_dac5_tdm_sel_mux = 1958 static const struct snd_kcontrol_new rt5677_if1_dac5_tdm_sel_mux =
1958 SOC_DAPM_ENUM("IF1 DAC5 TDM Source", rt5677_if1_dac5_tdm_sel_enum); 1959 SOC_DAPM_ENUM("IF1 DAC5 TDM Source", rt5677_if1_dac5_tdm_sel_enum);
1959 1960
1960 static SOC_ENUM_SINGLE_DECL( 1961 static SOC_ENUM_SINGLE_DECL(
1961 rt5677_if1_dac6_tdm_sel_enum, RT5677_TDM1_CTRL5, 1962 rt5677_if1_dac6_tdm_sel_enum, RT5677_TDM1_CTRL5,
1962 RT5677_IF1_DAC6_SFT, rt5677_if12_dac_tdm_sel_src); 1963 RT5677_IF1_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
1963 1964
1964 static const struct snd_kcontrol_new rt5677_if1_dac6_tdm_sel_mux = 1965 static const struct snd_kcontrol_new rt5677_if1_dac6_tdm_sel_mux =
1965 SOC_DAPM_ENUM("IF1 DAC6 TDM Source", rt5677_if1_dac6_tdm_sel_enum); 1966 SOC_DAPM_ENUM("IF1 DAC6 TDM Source", rt5677_if1_dac6_tdm_sel_enum);
1966 1967
1967 static SOC_ENUM_SINGLE_DECL( 1968 static SOC_ENUM_SINGLE_DECL(
1968 rt5677_if1_dac7_tdm_sel_enum, RT5677_TDM1_CTRL5, 1969 rt5677_if1_dac7_tdm_sel_enum, RT5677_TDM1_CTRL5,
1969 RT5677_IF1_DAC7_SFT, rt5677_if12_dac_tdm_sel_src); 1970 RT5677_IF1_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
1970 1971
1971 static const struct snd_kcontrol_new rt5677_if1_dac7_tdm_sel_mux = 1972 static const struct snd_kcontrol_new rt5677_if1_dac7_tdm_sel_mux =
1972 SOC_DAPM_ENUM("IF1 DAC7 TDM Source", rt5677_if1_dac7_tdm_sel_enum); 1973 SOC_DAPM_ENUM("IF1 DAC7 TDM Source", rt5677_if1_dac7_tdm_sel_enum);
1973 1974
1974 static SOC_ENUM_SINGLE_DECL( 1975 static SOC_ENUM_SINGLE_DECL(
1975 rt5677_if2_dac0_tdm_sel_enum, RT5677_TDM2_CTRL4, 1976 rt5677_if2_dac0_tdm_sel_enum, RT5677_TDM2_CTRL4,
1976 RT5677_IF2_DAC0_SFT, rt5677_if12_dac_tdm_sel_src); 1977 RT5677_IF2_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
1977 1978
1978 static const struct snd_kcontrol_new rt5677_if2_dac0_tdm_sel_mux = 1979 static const struct snd_kcontrol_new rt5677_if2_dac0_tdm_sel_mux =
1979 SOC_DAPM_ENUM("IF2 DAC0 TDM Source", rt5677_if2_dac0_tdm_sel_enum); 1980 SOC_DAPM_ENUM("IF2 DAC0 TDM Source", rt5677_if2_dac0_tdm_sel_enum);
1980 1981
1981 static SOC_ENUM_SINGLE_DECL( 1982 static SOC_ENUM_SINGLE_DECL(
1982 rt5677_if2_dac1_tdm_sel_enum, RT5677_TDM2_CTRL4, 1983 rt5677_if2_dac1_tdm_sel_enum, RT5677_TDM2_CTRL4,
1983 RT5677_IF2_DAC1_SFT, rt5677_if12_dac_tdm_sel_src); 1984 RT5677_IF2_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
1984 1985
1985 static const struct snd_kcontrol_new rt5677_if2_dac1_tdm_sel_mux = 1986 static const struct snd_kcontrol_new rt5677_if2_dac1_tdm_sel_mux =
1986 SOC_DAPM_ENUM("IF2 DAC1 TDM Source", rt5677_if2_dac1_tdm_sel_enum); 1987 SOC_DAPM_ENUM("IF2 DAC1 TDM Source", rt5677_if2_dac1_tdm_sel_enum);
1987 1988
1988 static SOC_ENUM_SINGLE_DECL( 1989 static SOC_ENUM_SINGLE_DECL(
1989 rt5677_if2_dac2_tdm_sel_enum, RT5677_TDM2_CTRL4, 1990 rt5677_if2_dac2_tdm_sel_enum, RT5677_TDM2_CTRL4,
1990 RT5677_IF2_DAC2_SFT, rt5677_if12_dac_tdm_sel_src); 1991 RT5677_IF2_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
1991 1992
1992 static const struct snd_kcontrol_new rt5677_if2_dac2_tdm_sel_mux = 1993 static const struct snd_kcontrol_new rt5677_if2_dac2_tdm_sel_mux =
1993 SOC_DAPM_ENUM("IF2 DAC2 TDM Source", rt5677_if2_dac2_tdm_sel_enum); 1994 SOC_DAPM_ENUM("IF2 DAC2 TDM Source", rt5677_if2_dac2_tdm_sel_enum);
1994 1995
1995 static SOC_ENUM_SINGLE_DECL( 1996 static SOC_ENUM_SINGLE_DECL(
1996 rt5677_if2_dac3_tdm_sel_enum, RT5677_TDM2_CTRL4, 1997 rt5677_if2_dac3_tdm_sel_enum, RT5677_TDM2_CTRL4,
1997 RT5677_IF2_DAC3_SFT, rt5677_if12_dac_tdm_sel_src); 1998 RT5677_IF2_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
1998 1999
1999 static const struct snd_kcontrol_new rt5677_if2_dac3_tdm_sel_mux = 2000 static const struct snd_kcontrol_new rt5677_if2_dac3_tdm_sel_mux =
2000 SOC_DAPM_ENUM("IF2 DAC3 TDM Source", rt5677_if2_dac3_tdm_sel_enum); 2001 SOC_DAPM_ENUM("IF2 DAC3 TDM Source", rt5677_if2_dac3_tdm_sel_enum);
2001 2002
2002 static SOC_ENUM_SINGLE_DECL( 2003 static SOC_ENUM_SINGLE_DECL(
2003 rt5677_if2_dac4_tdm_sel_enum, RT5677_TDM2_CTRL5, 2004 rt5677_if2_dac4_tdm_sel_enum, RT5677_TDM2_CTRL5,
2004 RT5677_IF2_DAC4_SFT, rt5677_if12_dac_tdm_sel_src); 2005 RT5677_IF2_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
2005 2006
2006 static const struct snd_kcontrol_new rt5677_if2_dac4_tdm_sel_mux = 2007 static const struct snd_kcontrol_new rt5677_if2_dac4_tdm_sel_mux =
2007 SOC_DAPM_ENUM("IF2 DAC4 TDM Source", rt5677_if2_dac4_tdm_sel_enum); 2008 SOC_DAPM_ENUM("IF2 DAC4 TDM Source", rt5677_if2_dac4_tdm_sel_enum);
2008 2009
2009 static SOC_ENUM_SINGLE_DECL( 2010 static SOC_ENUM_SINGLE_DECL(
2010 rt5677_if2_dac5_tdm_sel_enum, RT5677_TDM2_CTRL5, 2011 rt5677_if2_dac5_tdm_sel_enum, RT5677_TDM2_CTRL5,
2011 RT5677_IF2_DAC5_SFT, rt5677_if12_dac_tdm_sel_src); 2012 RT5677_IF2_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
2012 2013
2013 static const struct snd_kcontrol_new rt5677_if2_dac5_tdm_sel_mux = 2014 static const struct snd_kcontrol_new rt5677_if2_dac5_tdm_sel_mux =
2014 SOC_DAPM_ENUM("IF2 DAC5 TDM Source", rt5677_if2_dac5_tdm_sel_enum); 2015 SOC_DAPM_ENUM("IF2 DAC5 TDM Source", rt5677_if2_dac5_tdm_sel_enum);
2015 2016
2016 static SOC_ENUM_SINGLE_DECL( 2017 static SOC_ENUM_SINGLE_DECL(
2017 rt5677_if2_dac6_tdm_sel_enum, RT5677_TDM2_CTRL5, 2018 rt5677_if2_dac6_tdm_sel_enum, RT5677_TDM2_CTRL5,
2018 RT5677_IF2_DAC6_SFT, rt5677_if12_dac_tdm_sel_src); 2019 RT5677_IF2_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
2019 2020
2020 static const struct snd_kcontrol_new rt5677_if2_dac6_tdm_sel_mux = 2021 static const struct snd_kcontrol_new rt5677_if2_dac6_tdm_sel_mux =
2021 SOC_DAPM_ENUM("IF2 DAC6 TDM Source", rt5677_if2_dac6_tdm_sel_enum); 2022 SOC_DAPM_ENUM("IF2 DAC6 TDM Source", rt5677_if2_dac6_tdm_sel_enum);
2022 2023
2023 static SOC_ENUM_SINGLE_DECL( 2024 static SOC_ENUM_SINGLE_DECL(
2024 rt5677_if2_dac7_tdm_sel_enum, RT5677_TDM2_CTRL5, 2025 rt5677_if2_dac7_tdm_sel_enum, RT5677_TDM2_CTRL5,
2025 RT5677_IF2_DAC7_SFT, rt5677_if12_dac_tdm_sel_src); 2026 RT5677_IF2_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
2026 2027
2027 static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux = 2028 static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux =
2028 SOC_DAPM_ENUM("IF2 DAC7 TDM Source", rt5677_if2_dac7_tdm_sel_enum); 2029 SOC_DAPM_ENUM("IF2 DAC7 TDM Source", rt5677_if2_dac7_tdm_sel_enum);
2029 2030
2030 static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, 2031 static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
2031 struct snd_kcontrol *kcontrol, int event) 2032 struct snd_kcontrol *kcontrol, int event)
2032 { 2033 {
2033 struct snd_soc_codec *codec = w->codec; 2034 struct snd_soc_codec *codec = w->codec;
2034 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2035 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2035 2036
2036 switch (event) { 2037 switch (event) {
2037 case SND_SOC_DAPM_POST_PMU: 2038 case SND_SOC_DAPM_POST_PMU:
2038 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 2039 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2039 RT5677_PWR_BST1_P, RT5677_PWR_BST1_P); 2040 RT5677_PWR_BST1_P, RT5677_PWR_BST1_P);
2040 break; 2041 break;
2041 2042
2042 case SND_SOC_DAPM_PRE_PMD: 2043 case SND_SOC_DAPM_PRE_PMD:
2043 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 2044 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2044 RT5677_PWR_BST1_P, 0); 2045 RT5677_PWR_BST1_P, 0);
2045 break; 2046 break;
2046 2047
2047 default: 2048 default:
2048 return 0; 2049 return 0;
2049 } 2050 }
2050 2051
2051 return 0; 2052 return 0;
2052 } 2053 }
2053 2054
2054 static int rt5677_bst2_event(struct snd_soc_dapm_widget *w, 2055 static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
2055 struct snd_kcontrol *kcontrol, int event) 2056 struct snd_kcontrol *kcontrol, int event)
2056 { 2057 {
2057 struct snd_soc_codec *codec = w->codec; 2058 struct snd_soc_codec *codec = w->codec;
2058 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2059 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2059 2060
2060 switch (event) { 2061 switch (event) {
2061 case SND_SOC_DAPM_POST_PMU: 2062 case SND_SOC_DAPM_POST_PMU:
2062 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 2063 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2063 RT5677_PWR_BST2_P, RT5677_PWR_BST2_P); 2064 RT5677_PWR_BST2_P, RT5677_PWR_BST2_P);
2064 break; 2065 break;
2065 2066
2066 case SND_SOC_DAPM_PRE_PMD: 2067 case SND_SOC_DAPM_PRE_PMD:
2067 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 2068 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2068 RT5677_PWR_BST2_P, 0); 2069 RT5677_PWR_BST2_P, 0);
2069 break; 2070 break;
2070 2071
2071 default: 2072 default:
2072 return 0; 2073 return 0;
2073 } 2074 }
2074 2075
2075 return 0; 2076 return 0;
2076 } 2077 }
2077 2078
2078 static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w, 2079 static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
2079 struct snd_kcontrol *kcontrol, int event) 2080 struct snd_kcontrol *kcontrol, int event)
2080 { 2081 {
2081 struct snd_soc_codec *codec = w->codec; 2082 struct snd_soc_codec *codec = w->codec;
2082 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2083 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2083 2084
2084 switch (event) { 2085 switch (event) {
2085 case SND_SOC_DAPM_POST_PMU: 2086 case SND_SOC_DAPM_POST_PMU:
2086 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2); 2087 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2);
2087 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0); 2088 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0);
2088 break; 2089 break;
2089 default: 2090 default:
2090 return 0; 2091 return 0;
2091 } 2092 }
2092 2093
2093 return 0; 2094 return 0;
2094 } 2095 }
2095 2096
2096 static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w, 2097 static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
2097 struct snd_kcontrol *kcontrol, int event) 2098 struct snd_kcontrol *kcontrol, int event)
2098 { 2099 {
2099 struct snd_soc_codec *codec = w->codec; 2100 struct snd_soc_codec *codec = w->codec;
2100 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2101 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2101 2102
2102 switch (event) { 2103 switch (event) {
2103 case SND_SOC_DAPM_POST_PMU: 2104 case SND_SOC_DAPM_POST_PMU:
2104 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2); 2105 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2);
2105 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0); 2106 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0);
2106 break; 2107 break;
2107 default: 2108 default:
2108 return 0; 2109 return 0;
2109 } 2110 }
2110 2111
2111 return 0; 2112 return 0;
2112 } 2113 }
2113 2114
2114 static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, 2115 static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
2115 struct snd_kcontrol *kcontrol, int event) 2116 struct snd_kcontrol *kcontrol, int event)
2116 { 2117 {
2117 struct snd_soc_codec *codec = w->codec; 2118 struct snd_soc_codec *codec = w->codec;
2118 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2119 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2119 2120
2120 switch (event) { 2121 switch (event) {
2121 case SND_SOC_DAPM_POST_PMU: 2122 case SND_SOC_DAPM_POST_PMU:
2122 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 2123 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2123 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 | 2124 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
2124 RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 | 2125 RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 |
2125 RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB); 2126 RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB);
2126 break; 2127 break;
2127 2128
2128 case SND_SOC_DAPM_PRE_PMD: 2129 case SND_SOC_DAPM_PRE_PMD:
2129 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 2130 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
2130 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 | 2131 RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
2131 RT5677_PWR_CLK_MB, 0); 2132 RT5677_PWR_CLK_MB, 0);
2132 break; 2133 break;
2133 2134
2134 default: 2135 default:
2135 return 0; 2136 return 0;
2136 } 2137 }
2137 2138
2138 return 0; 2139 return 0;
2139 } 2140 }
2140 2141
2141 static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w, 2142 static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
2142 struct snd_kcontrol *kcontrol, int event) 2143 struct snd_kcontrol *kcontrol, int event)
2143 { 2144 {
2144 struct snd_soc_codec *codec = w->codec; 2145 struct snd_soc_codec *codec = w->codec;
2145 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2146 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2146 unsigned int value; 2147 unsigned int value;
2147 2148
2148 switch (event) { 2149 switch (event) {
2149 case SND_SOC_DAPM_PRE_PMU: 2150 case SND_SOC_DAPM_PRE_PMU:
2150 regmap_read(rt5677->regmap, RT5677_TDM1_CTRL2, &value); 2151 regmap_read(rt5677->regmap, RT5677_TDM1_CTRL2, &value);
2151 if (value & RT5677_IF1_ADC_CTRL_MASK) 2152 if (value & RT5677_IF1_ADC_CTRL_MASK)
2152 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 2153 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1,
2153 RT5677_IF1_ADC_MODE_MASK, 2154 RT5677_IF1_ADC_MODE_MASK,
2154 RT5677_IF1_ADC_MODE_TDM); 2155 RT5677_IF1_ADC_MODE_TDM);
2155 break; 2156 break;
2156 2157
2157 default: 2158 default:
2158 return 0; 2159 return 0;
2159 } 2160 }
2160 2161
2161 return 0; 2162 return 0;
2162 } 2163 }
2163 2164
2164 static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w, 2165 static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
2165 struct snd_kcontrol *kcontrol, int event) 2166 struct snd_kcontrol *kcontrol, int event)
2166 { 2167 {
2167 struct snd_soc_codec *codec = w->codec; 2168 struct snd_soc_codec *codec = w->codec;
2168 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2169 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2169 unsigned int value; 2170 unsigned int value;
2170 2171
2171 switch (event) { 2172 switch (event) {
2172 case SND_SOC_DAPM_PRE_PMU: 2173 case SND_SOC_DAPM_PRE_PMU:
2173 regmap_read(rt5677->regmap, RT5677_TDM2_CTRL2, &value); 2174 regmap_read(rt5677->regmap, RT5677_TDM2_CTRL2, &value);
2174 if (value & RT5677_IF2_ADC_CTRL_MASK) 2175 if (value & RT5677_IF2_ADC_CTRL_MASK)
2175 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 2176 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1,
2176 RT5677_IF2_ADC_MODE_MASK, 2177 RT5677_IF2_ADC_MODE_MASK,
2177 RT5677_IF2_ADC_MODE_TDM); 2178 RT5677_IF2_ADC_MODE_TDM);
2178 break; 2179 break;
2179 2180
2180 default: 2181 default:
2181 return 0; 2182 return 0;
2182 } 2183 }
2183 2184
2184 return 0; 2185 return 0;
2185 } 2186 }
2186 2187
2187 static int rt5677_vref_event(struct snd_soc_dapm_widget *w, 2188 static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
2188 struct snd_kcontrol *kcontrol, int event) 2189 struct snd_kcontrol *kcontrol, int event)
2189 { 2190 {
2190 struct snd_soc_codec *codec = w->codec; 2191 struct snd_soc_codec *codec = w->codec;
2191 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2192 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2192 2193
2193 switch (event) { 2194 switch (event) {
2194 case SND_SOC_DAPM_POST_PMU: 2195 case SND_SOC_DAPM_POST_PMU:
2195 if (codec->dapm.bias_level != SND_SOC_BIAS_ON && 2196 if (codec->dapm.bias_level != SND_SOC_BIAS_ON &&
2196 !rt5677->is_vref_slow) { 2197 !rt5677->is_vref_slow) {
2197 mdelay(20); 2198 mdelay(20);
2198 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, 2199 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
2199 RT5677_PWR_FV1 | RT5677_PWR_FV2, 2200 RT5677_PWR_FV1 | RT5677_PWR_FV2,
2200 RT5677_PWR_FV1 | RT5677_PWR_FV2); 2201 RT5677_PWR_FV1 | RT5677_PWR_FV2);
2201 rt5677->is_vref_slow = true; 2202 rt5677->is_vref_slow = true;
2202 } 2203 }
2203 break; 2204 break;
2204 2205
2205 default: 2206 default:
2206 return 0; 2207 return 0;
2207 } 2208 }
2208 2209
2209 return 0; 2210 return 0;
2210 } 2211 }
2211 2212
2212 static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = { 2213 static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2213 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT, 2214 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT,
2214 0, rt5677_set_pll1_event, SND_SOC_DAPM_POST_PMU), 2215 0, rt5677_set_pll1_event, SND_SOC_DAPM_POST_PMU),
2215 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT, 2216 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT,
2216 0, rt5677_set_pll2_event, SND_SOC_DAPM_POST_PMU), 2217 0, rt5677_set_pll2_event, SND_SOC_DAPM_POST_PMU),
2217 2218
2218 /* Input Side */ 2219 /* Input Side */
2219 /* micbias */ 2220 /* micbias */
2220 SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT, 2221 SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT,
2221 0, rt5677_set_micbias1_event, SND_SOC_DAPM_PRE_PMD | 2222 0, rt5677_set_micbias1_event, SND_SOC_DAPM_PRE_PMD |
2222 SND_SOC_DAPM_POST_PMU), 2223 SND_SOC_DAPM_POST_PMU),
2223 2224
2224 /* Input Lines */ 2225 /* Input Lines */
2225 SND_SOC_DAPM_INPUT("DMIC L1"), 2226 SND_SOC_DAPM_INPUT("DMIC L1"),
2226 SND_SOC_DAPM_INPUT("DMIC R1"), 2227 SND_SOC_DAPM_INPUT("DMIC R1"),
2227 SND_SOC_DAPM_INPUT("DMIC L2"), 2228 SND_SOC_DAPM_INPUT("DMIC L2"),
2228 SND_SOC_DAPM_INPUT("DMIC R2"), 2229 SND_SOC_DAPM_INPUT("DMIC R2"),
2229 SND_SOC_DAPM_INPUT("DMIC L3"), 2230 SND_SOC_DAPM_INPUT("DMIC L3"),
2230 SND_SOC_DAPM_INPUT("DMIC R3"), 2231 SND_SOC_DAPM_INPUT("DMIC R3"),
2231 SND_SOC_DAPM_INPUT("DMIC L4"), 2232 SND_SOC_DAPM_INPUT("DMIC L4"),
2232 SND_SOC_DAPM_INPUT("DMIC R4"), 2233 SND_SOC_DAPM_INPUT("DMIC R4"),
2233 2234
2234 SND_SOC_DAPM_INPUT("IN1P"), 2235 SND_SOC_DAPM_INPUT("IN1P"),
2235 SND_SOC_DAPM_INPUT("IN1N"), 2236 SND_SOC_DAPM_INPUT("IN1N"),
2236 SND_SOC_DAPM_INPUT("IN2P"), 2237 SND_SOC_DAPM_INPUT("IN2P"),
2237 SND_SOC_DAPM_INPUT("IN2N"), 2238 SND_SOC_DAPM_INPUT("IN2N"),
2238 2239
2239 SND_SOC_DAPM_INPUT("Haptic Generator"), 2240 SND_SOC_DAPM_INPUT("Haptic Generator"),
2240 2241
2241 SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0), 2242 SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2242 SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0), 2243 SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2243 SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM, 0, 0, NULL, 0), 2244 SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2244 SND_SOC_DAPM_PGA("DMIC4", SND_SOC_NOPM, 0, 0, NULL, 0), 2245 SND_SOC_DAPM_PGA("DMIC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2245 2246
2246 SND_SOC_DAPM_SUPPLY("DMIC1 power", RT5677_DMIC_CTRL1, 2247 SND_SOC_DAPM_SUPPLY("DMIC1 power", RT5677_DMIC_CTRL1,
2247 RT5677_DMIC_1_EN_SFT, 0, NULL, 0), 2248 RT5677_DMIC_1_EN_SFT, 0, NULL, 0),
2248 SND_SOC_DAPM_SUPPLY("DMIC2 power", RT5677_DMIC_CTRL1, 2249 SND_SOC_DAPM_SUPPLY("DMIC2 power", RT5677_DMIC_CTRL1,
2249 RT5677_DMIC_2_EN_SFT, 0, NULL, 0), 2250 RT5677_DMIC_2_EN_SFT, 0, NULL, 0),
2250 SND_SOC_DAPM_SUPPLY("DMIC3 power", RT5677_DMIC_CTRL1, 2251 SND_SOC_DAPM_SUPPLY("DMIC3 power", RT5677_DMIC_CTRL1,
2251 RT5677_DMIC_3_EN_SFT, 0, NULL, 0), 2252 RT5677_DMIC_3_EN_SFT, 0, NULL, 0),
2252 SND_SOC_DAPM_SUPPLY("DMIC4 power", RT5677_DMIC_CTRL2, 2253 SND_SOC_DAPM_SUPPLY("DMIC4 power", RT5677_DMIC_CTRL2,
2253 RT5677_DMIC_4_EN_SFT, 0, NULL, 0), 2254 RT5677_DMIC_4_EN_SFT, 0, NULL, 0),
2254 2255
2255 SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0, 2256 SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0,
2256 set_dmic_clk, SND_SOC_DAPM_PRE_PMU), 2257 set_dmic_clk, SND_SOC_DAPM_PRE_PMU),
2257 2258
2258 /* Boost */ 2259 /* Boost */
2259 SND_SOC_DAPM_PGA_E("BST1", RT5677_PWR_ANLG2, 2260 SND_SOC_DAPM_PGA_E("BST1", RT5677_PWR_ANLG2,
2260 RT5677_PWR_BST1_BIT, 0, NULL, 0, rt5677_bst1_event, 2261 RT5677_PWR_BST1_BIT, 0, NULL, 0, rt5677_bst1_event,
2261 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 2262 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2262 SND_SOC_DAPM_PGA_E("BST2", RT5677_PWR_ANLG2, 2263 SND_SOC_DAPM_PGA_E("BST2", RT5677_PWR_ANLG2,
2263 RT5677_PWR_BST2_BIT, 0, NULL, 0, rt5677_bst2_event, 2264 RT5677_PWR_BST2_BIT, 0, NULL, 0, rt5677_bst2_event,
2264 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 2265 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2265 2266
2266 /* ADCs */ 2267 /* ADCs */
2267 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 2268 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM,
2268 0, 0), 2269 0, 0),
2269 SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM, 2270 SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM,
2270 0, 0), 2271 0, 0),
2271 SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0), 2272 SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0),
2272 2273
2273 SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5677_PWR_DIG1, 2274 SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5677_PWR_DIG1,
2274 RT5677_PWR_ADC_L_BIT, 0, NULL, 0), 2275 RT5677_PWR_ADC_L_BIT, 0, NULL, 0),
2275 SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5677_PWR_DIG1, 2276 SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5677_PWR_DIG1,
2276 RT5677_PWR_ADC_R_BIT, 0, NULL, 0), 2277 RT5677_PWR_ADC_R_BIT, 0, NULL, 0),
2277 SND_SOC_DAPM_SUPPLY("ADC1 clock", RT5677_PWR_DIG1, 2278 SND_SOC_DAPM_SUPPLY("ADC1 clock", RT5677_PWR_DIG1,
2278 RT5677_PWR_ADCFED1_BIT, 0, NULL, 0), 2279 RT5677_PWR_ADCFED1_BIT, 0, NULL, 0),
2279 SND_SOC_DAPM_SUPPLY("ADC2 clock", RT5677_PWR_DIG1, 2280 SND_SOC_DAPM_SUPPLY("ADC2 clock", RT5677_PWR_DIG1,
2280 RT5677_PWR_ADCFED2_BIT, 0, NULL, 0), 2281 RT5677_PWR_ADCFED2_BIT, 0, NULL, 0),
2281 2282
2282 /* ADC Mux */ 2283 /* ADC Mux */
2283 SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0, 2284 SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0,
2284 &rt5677_sto1_dmic_mux), 2285 &rt5677_sto1_dmic_mux),
2285 SND_SOC_DAPM_MUX("Stereo1 ADC1 Mux", SND_SOC_NOPM, 0, 0, 2286 SND_SOC_DAPM_MUX("Stereo1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2286 &rt5677_sto1_adc1_mux), 2287 &rt5677_sto1_adc1_mux),
2287 SND_SOC_DAPM_MUX("Stereo1 ADC2 Mux", SND_SOC_NOPM, 0, 0, 2288 SND_SOC_DAPM_MUX("Stereo1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2288 &rt5677_sto1_adc2_mux), 2289 &rt5677_sto1_adc2_mux),
2289 SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0, 2290 SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0,
2290 &rt5677_sto2_dmic_mux), 2291 &rt5677_sto2_dmic_mux),
2291 SND_SOC_DAPM_MUX("Stereo2 ADC1 Mux", SND_SOC_NOPM, 0, 0, 2292 SND_SOC_DAPM_MUX("Stereo2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2292 &rt5677_sto2_adc1_mux), 2293 &rt5677_sto2_adc1_mux),
2293 SND_SOC_DAPM_MUX("Stereo2 ADC2 Mux", SND_SOC_NOPM, 0, 0, 2294 SND_SOC_DAPM_MUX("Stereo2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2294 &rt5677_sto2_adc2_mux), 2295 &rt5677_sto2_adc2_mux),
2295 SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0, 2296 SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0,
2296 &rt5677_sto2_adc_lr_mux), 2297 &rt5677_sto2_adc_lr_mux),
2297 SND_SOC_DAPM_MUX("Stereo3 DMIC Mux", SND_SOC_NOPM, 0, 0, 2298 SND_SOC_DAPM_MUX("Stereo3 DMIC Mux", SND_SOC_NOPM, 0, 0,
2298 &rt5677_sto3_dmic_mux), 2299 &rt5677_sto3_dmic_mux),
2299 SND_SOC_DAPM_MUX("Stereo3 ADC1 Mux", SND_SOC_NOPM, 0, 0, 2300 SND_SOC_DAPM_MUX("Stereo3 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2300 &rt5677_sto3_adc1_mux), 2301 &rt5677_sto3_adc1_mux),
2301 SND_SOC_DAPM_MUX("Stereo3 ADC2 Mux", SND_SOC_NOPM, 0, 0, 2302 SND_SOC_DAPM_MUX("Stereo3 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2302 &rt5677_sto3_adc2_mux), 2303 &rt5677_sto3_adc2_mux),
2303 SND_SOC_DAPM_MUX("Stereo4 DMIC Mux", SND_SOC_NOPM, 0, 0, 2304 SND_SOC_DAPM_MUX("Stereo4 DMIC Mux", SND_SOC_NOPM, 0, 0,
2304 &rt5677_sto4_dmic_mux), 2305 &rt5677_sto4_dmic_mux),
2305 SND_SOC_DAPM_MUX("Stereo4 ADC1 Mux", SND_SOC_NOPM, 0, 0, 2306 SND_SOC_DAPM_MUX("Stereo4 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2306 &rt5677_sto4_adc1_mux), 2307 &rt5677_sto4_adc1_mux),
2307 SND_SOC_DAPM_MUX("Stereo4 ADC2 Mux", SND_SOC_NOPM, 0, 0, 2308 SND_SOC_DAPM_MUX("Stereo4 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2308 &rt5677_sto4_adc2_mux), 2309 &rt5677_sto4_adc2_mux),
2309 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0, 2310 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
2310 &rt5677_mono_dmic_l_mux), 2311 &rt5677_mono_dmic_l_mux),
2311 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0, 2312 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
2312 &rt5677_mono_dmic_r_mux), 2313 &rt5677_mono_dmic_r_mux),
2313 SND_SOC_DAPM_MUX("Mono ADC2 L Mux", SND_SOC_NOPM, 0, 0, 2314 SND_SOC_DAPM_MUX("Mono ADC2 L Mux", SND_SOC_NOPM, 0, 0,
2314 &rt5677_mono_adc2_l_mux), 2315 &rt5677_mono_adc2_l_mux),
2315 SND_SOC_DAPM_MUX("Mono ADC1 L Mux", SND_SOC_NOPM, 0, 0, 2316 SND_SOC_DAPM_MUX("Mono ADC1 L Mux", SND_SOC_NOPM, 0, 0,
2316 &rt5677_mono_adc1_l_mux), 2317 &rt5677_mono_adc1_l_mux),
2317 SND_SOC_DAPM_MUX("Mono ADC1 R Mux", SND_SOC_NOPM, 0, 0, 2318 SND_SOC_DAPM_MUX("Mono ADC1 R Mux", SND_SOC_NOPM, 0, 0,
2318 &rt5677_mono_adc1_r_mux), 2319 &rt5677_mono_adc1_r_mux),
2319 SND_SOC_DAPM_MUX("Mono ADC2 R Mux", SND_SOC_NOPM, 0, 0, 2320 SND_SOC_DAPM_MUX("Mono ADC2 R Mux", SND_SOC_NOPM, 0, 0,
2320 &rt5677_mono_adc2_r_mux), 2321 &rt5677_mono_adc2_r_mux),
2321 2322
2322 /* ADC Mixer */ 2323 /* ADC Mixer */
2323 SND_SOC_DAPM_SUPPLY("adc stereo1 filter", RT5677_PWR_DIG2, 2324 SND_SOC_DAPM_SUPPLY("adc stereo1 filter", RT5677_PWR_DIG2,
2324 RT5677_PWR_ADC_S1F_BIT, 0, NULL, 0), 2325 RT5677_PWR_ADC_S1F_BIT, 0, NULL, 0),
2325 SND_SOC_DAPM_SUPPLY("adc stereo2 filter", RT5677_PWR_DIG2, 2326 SND_SOC_DAPM_SUPPLY("adc stereo2 filter", RT5677_PWR_DIG2,
2326 RT5677_PWR_ADC_S2F_BIT, 0, NULL, 0), 2327 RT5677_PWR_ADC_S2F_BIT, 0, NULL, 0),
2327 SND_SOC_DAPM_SUPPLY("adc stereo3 filter", RT5677_PWR_DIG2, 2328 SND_SOC_DAPM_SUPPLY("adc stereo3 filter", RT5677_PWR_DIG2,
2328 RT5677_PWR_ADC_S3F_BIT, 0, NULL, 0), 2329 RT5677_PWR_ADC_S3F_BIT, 0, NULL, 0),
2329 SND_SOC_DAPM_SUPPLY("adc stereo4 filter", RT5677_PWR_DIG2, 2330 SND_SOC_DAPM_SUPPLY("adc stereo4 filter", RT5677_PWR_DIG2,
2330 RT5677_PWR_ADC_S4F_BIT, 0, NULL, 0), 2331 RT5677_PWR_ADC_S4F_BIT, 0, NULL, 0),
2331 SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0, 2332 SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0,
2332 rt5677_sto1_adc_l_mix, ARRAY_SIZE(rt5677_sto1_adc_l_mix)), 2333 rt5677_sto1_adc_l_mix, ARRAY_SIZE(rt5677_sto1_adc_l_mix)),
2333 SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0, 2334 SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0,
2334 rt5677_sto1_adc_r_mix, ARRAY_SIZE(rt5677_sto1_adc_r_mix)), 2335 rt5677_sto1_adc_r_mix, ARRAY_SIZE(rt5677_sto1_adc_r_mix)),
2335 SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0, 2336 SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0,
2336 rt5677_sto2_adc_l_mix, ARRAY_SIZE(rt5677_sto2_adc_l_mix)), 2337 rt5677_sto2_adc_l_mix, ARRAY_SIZE(rt5677_sto2_adc_l_mix)),
2337 SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0, 2338 SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0,
2338 rt5677_sto2_adc_r_mix, ARRAY_SIZE(rt5677_sto2_adc_r_mix)), 2339 rt5677_sto2_adc_r_mix, ARRAY_SIZE(rt5677_sto2_adc_r_mix)),
2339 SND_SOC_DAPM_MIXER("Sto3 ADC MIXL", SND_SOC_NOPM, 0, 0, 2340 SND_SOC_DAPM_MIXER("Sto3 ADC MIXL", SND_SOC_NOPM, 0, 0,
2340 rt5677_sto3_adc_l_mix, ARRAY_SIZE(rt5677_sto3_adc_l_mix)), 2341 rt5677_sto3_adc_l_mix, ARRAY_SIZE(rt5677_sto3_adc_l_mix)),
2341 SND_SOC_DAPM_MIXER("Sto3 ADC MIXR", SND_SOC_NOPM, 0, 0, 2342 SND_SOC_DAPM_MIXER("Sto3 ADC MIXR", SND_SOC_NOPM, 0, 0,
2342 rt5677_sto3_adc_r_mix, ARRAY_SIZE(rt5677_sto3_adc_r_mix)), 2343 rt5677_sto3_adc_r_mix, ARRAY_SIZE(rt5677_sto3_adc_r_mix)),
2343 SND_SOC_DAPM_MIXER("Sto4 ADC MIXL", SND_SOC_NOPM, 0, 0, 2344 SND_SOC_DAPM_MIXER("Sto4 ADC MIXL", SND_SOC_NOPM, 0, 0,
2344 rt5677_sto4_adc_l_mix, ARRAY_SIZE(rt5677_sto4_adc_l_mix)), 2345 rt5677_sto4_adc_l_mix, ARRAY_SIZE(rt5677_sto4_adc_l_mix)),
2345 SND_SOC_DAPM_MIXER("Sto4 ADC MIXR", SND_SOC_NOPM, 0, 0, 2346 SND_SOC_DAPM_MIXER("Sto4 ADC MIXR", SND_SOC_NOPM, 0, 0,
2346 rt5677_sto4_adc_r_mix, ARRAY_SIZE(rt5677_sto4_adc_r_mix)), 2347 rt5677_sto4_adc_r_mix, ARRAY_SIZE(rt5677_sto4_adc_r_mix)),
2347 SND_SOC_DAPM_SUPPLY("adc mono left filter", RT5677_PWR_DIG2, 2348 SND_SOC_DAPM_SUPPLY("adc mono left filter", RT5677_PWR_DIG2,
2348 RT5677_PWR_ADC_MF_L_BIT, 0, NULL, 0), 2349 RT5677_PWR_ADC_MF_L_BIT, 0, NULL, 0),
2349 SND_SOC_DAPM_MIXER("Mono ADC MIXL", SND_SOC_NOPM, 0, 0, 2350 SND_SOC_DAPM_MIXER("Mono ADC MIXL", SND_SOC_NOPM, 0, 0,
2350 rt5677_mono_adc_l_mix, ARRAY_SIZE(rt5677_mono_adc_l_mix)), 2351 rt5677_mono_adc_l_mix, ARRAY_SIZE(rt5677_mono_adc_l_mix)),
2351 SND_SOC_DAPM_SUPPLY("adc mono right filter", RT5677_PWR_DIG2, 2352 SND_SOC_DAPM_SUPPLY("adc mono right filter", RT5677_PWR_DIG2,
2352 RT5677_PWR_ADC_MF_R_BIT, 0, NULL, 0), 2353 RT5677_PWR_ADC_MF_R_BIT, 0, NULL, 0),
2353 SND_SOC_DAPM_MIXER("Mono ADC MIXR", SND_SOC_NOPM, 0, 0, 2354 SND_SOC_DAPM_MIXER("Mono ADC MIXR", SND_SOC_NOPM, 0, 0,
2354 rt5677_mono_adc_r_mix, ARRAY_SIZE(rt5677_mono_adc_r_mix)), 2355 rt5677_mono_adc_r_mix, ARRAY_SIZE(rt5677_mono_adc_r_mix)),
2355 2356
2356 /* ADC PGA */ 2357 /* ADC PGA */
2357 SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), 2358 SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2358 SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), 2359 SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2359 SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2360 SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2360 SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), 2361 SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2361 SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), 2362 SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2362 SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2363 SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2363 SND_SOC_DAPM_PGA("Stereo3 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), 2364 SND_SOC_DAPM_PGA("Stereo3 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2364 SND_SOC_DAPM_PGA("Stereo3 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), 2365 SND_SOC_DAPM_PGA("Stereo3 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2365 SND_SOC_DAPM_PGA("Stereo3 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2366 SND_SOC_DAPM_PGA("Stereo3 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2366 SND_SOC_DAPM_PGA("Stereo4 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), 2367 SND_SOC_DAPM_PGA("Stereo4 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
2367 SND_SOC_DAPM_PGA("Stereo4 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), 2368 SND_SOC_DAPM_PGA("Stereo4 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
2368 SND_SOC_DAPM_PGA("Stereo4 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2369 SND_SOC_DAPM_PGA("Stereo4 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2369 SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2370 SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2370 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2371 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2371 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 2372 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2372 SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 2373 SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2373 2374
2374 /* DSP */ 2375 /* DSP */
2375 SND_SOC_DAPM_MUX("IB9 Mux", SND_SOC_NOPM, 0, 0, 2376 SND_SOC_DAPM_MUX("IB9 Mux", SND_SOC_NOPM, 0, 0,
2376 &rt5677_ib9_src_mux), 2377 &rt5677_ib9_src_mux),
2377 SND_SOC_DAPM_MUX("IB8 Mux", SND_SOC_NOPM, 0, 0, 2378 SND_SOC_DAPM_MUX("IB8 Mux", SND_SOC_NOPM, 0, 0,
2378 &rt5677_ib8_src_mux), 2379 &rt5677_ib8_src_mux),
2379 SND_SOC_DAPM_MUX("IB7 Mux", SND_SOC_NOPM, 0, 0, 2380 SND_SOC_DAPM_MUX("IB7 Mux", SND_SOC_NOPM, 0, 0,
2380 &rt5677_ib7_src_mux), 2381 &rt5677_ib7_src_mux),
2381 SND_SOC_DAPM_MUX("IB6 Mux", SND_SOC_NOPM, 0, 0, 2382 SND_SOC_DAPM_MUX("IB6 Mux", SND_SOC_NOPM, 0, 0,
2382 &rt5677_ib6_src_mux), 2383 &rt5677_ib6_src_mux),
2383 SND_SOC_DAPM_MUX("IB45 Mux", SND_SOC_NOPM, 0, 0, 2384 SND_SOC_DAPM_MUX("IB45 Mux", SND_SOC_NOPM, 0, 0,
2384 &rt5677_ib45_src_mux), 2385 &rt5677_ib45_src_mux),
2385 SND_SOC_DAPM_MUX("IB23 Mux", SND_SOC_NOPM, 0, 0, 2386 SND_SOC_DAPM_MUX("IB23 Mux", SND_SOC_NOPM, 0, 0,
2386 &rt5677_ib23_src_mux), 2387 &rt5677_ib23_src_mux),
2387 SND_SOC_DAPM_MUX("IB01 Mux", SND_SOC_NOPM, 0, 0, 2388 SND_SOC_DAPM_MUX("IB01 Mux", SND_SOC_NOPM, 0, 0,
2388 &rt5677_ib01_src_mux), 2389 &rt5677_ib01_src_mux),
2389 SND_SOC_DAPM_MUX("IB45 Bypass Mux", SND_SOC_NOPM, 0, 0, 2390 SND_SOC_DAPM_MUX("IB45 Bypass Mux", SND_SOC_NOPM, 0, 0,
2390 &rt5677_ib45_bypass_src_mux), 2391 &rt5677_ib45_bypass_src_mux),
2391 SND_SOC_DAPM_MUX("IB23 Bypass Mux", SND_SOC_NOPM, 0, 0, 2392 SND_SOC_DAPM_MUX("IB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
2392 &rt5677_ib23_bypass_src_mux), 2393 &rt5677_ib23_bypass_src_mux),
2393 SND_SOC_DAPM_MUX("IB01 Bypass Mux", SND_SOC_NOPM, 0, 0, 2394 SND_SOC_DAPM_MUX("IB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
2394 &rt5677_ib01_bypass_src_mux), 2395 &rt5677_ib01_bypass_src_mux),
2395 SND_SOC_DAPM_MUX("OB23 Bypass Mux", SND_SOC_NOPM, 0, 0, 2396 SND_SOC_DAPM_MUX("OB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
2396 &rt5677_ob23_bypass_src_mux), 2397 &rt5677_ob23_bypass_src_mux),
2397 SND_SOC_DAPM_MUX("OB01 Bypass Mux", SND_SOC_NOPM, 0, 0, 2398 SND_SOC_DAPM_MUX("OB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
2398 &rt5677_ob01_bypass_src_mux), 2399 &rt5677_ob01_bypass_src_mux),
2399 2400
2400 SND_SOC_DAPM_PGA("OB45", SND_SOC_NOPM, 0, 0, NULL, 0), 2401 SND_SOC_DAPM_PGA("OB45", SND_SOC_NOPM, 0, 0, NULL, 0),
2401 SND_SOC_DAPM_PGA("OB67", SND_SOC_NOPM, 0, 0, NULL, 0), 2402 SND_SOC_DAPM_PGA("OB67", SND_SOC_NOPM, 0, 0, NULL, 0),
2402 2403
2403 SND_SOC_DAPM_PGA("OutBound2", SND_SOC_NOPM, 0, 0, NULL, 0), 2404 SND_SOC_DAPM_PGA("OutBound2", SND_SOC_NOPM, 0, 0, NULL, 0),
2404 SND_SOC_DAPM_PGA("OutBound3", SND_SOC_NOPM, 0, 0, NULL, 0), 2405 SND_SOC_DAPM_PGA("OutBound3", SND_SOC_NOPM, 0, 0, NULL, 0),
2405 SND_SOC_DAPM_PGA("OutBound4", SND_SOC_NOPM, 0, 0, NULL, 0), 2406 SND_SOC_DAPM_PGA("OutBound4", SND_SOC_NOPM, 0, 0, NULL, 0),
2406 SND_SOC_DAPM_PGA("OutBound5", SND_SOC_NOPM, 0, 0, NULL, 0), 2407 SND_SOC_DAPM_PGA("OutBound5", SND_SOC_NOPM, 0, 0, NULL, 0),
2407 SND_SOC_DAPM_PGA("OutBound6", SND_SOC_NOPM, 0, 0, NULL, 0), 2408 SND_SOC_DAPM_PGA("OutBound6", SND_SOC_NOPM, 0, 0, NULL, 0),
2408 SND_SOC_DAPM_PGA("OutBound7", SND_SOC_NOPM, 0, 0, NULL, 0), 2409 SND_SOC_DAPM_PGA("OutBound7", SND_SOC_NOPM, 0, 0, NULL, 0),
2409 2410
2410 /* Digital Interface */ 2411 /* Digital Interface */
2411 SND_SOC_DAPM_SUPPLY("I2S1", RT5677_PWR_DIG1, 2412 SND_SOC_DAPM_SUPPLY("I2S1", RT5677_PWR_DIG1,
2412 RT5677_PWR_I2S1_BIT, 0, NULL, 0), 2413 RT5677_PWR_I2S1_BIT, 0, NULL, 0),
2413 SND_SOC_DAPM_PGA("IF1 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0), 2414 SND_SOC_DAPM_PGA("IF1 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2414 SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), 2415 SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2415 SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), 2416 SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2416 SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0), 2417 SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2417 SND_SOC_DAPM_PGA("IF1 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0), 2418 SND_SOC_DAPM_PGA("IF1 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2418 SND_SOC_DAPM_PGA("IF1 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0), 2419 SND_SOC_DAPM_PGA("IF1 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2419 SND_SOC_DAPM_PGA("IF1 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0), 2420 SND_SOC_DAPM_PGA("IF1 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2420 SND_SOC_DAPM_PGA("IF1 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0), 2421 SND_SOC_DAPM_PGA("IF1 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2421 SND_SOC_DAPM_PGA("IF1 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0), 2422 SND_SOC_DAPM_PGA("IF1 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2422 SND_SOC_DAPM_PGA("IF1 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0), 2423 SND_SOC_DAPM_PGA("IF1 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2423 SND_SOC_DAPM_PGA("IF1 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0), 2424 SND_SOC_DAPM_PGA("IF1 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2424 SND_SOC_DAPM_PGA("IF1 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0), 2425 SND_SOC_DAPM_PGA("IF1 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2425 SND_SOC_DAPM_PGA("IF1 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), 2426 SND_SOC_DAPM_PGA("IF1 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2426 SND_SOC_DAPM_PGA("IF1 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), 2427 SND_SOC_DAPM_PGA("IF1 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2427 SND_SOC_DAPM_PGA("IF1 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), 2428 SND_SOC_DAPM_PGA("IF1 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2428 SND_SOC_DAPM_PGA("IF1 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), 2429 SND_SOC_DAPM_PGA("IF1 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2429 2430
2430 SND_SOC_DAPM_SUPPLY("I2S2", RT5677_PWR_DIG1, 2431 SND_SOC_DAPM_SUPPLY("I2S2", RT5677_PWR_DIG1,
2431 RT5677_PWR_I2S2_BIT, 0, NULL, 0), 2432 RT5677_PWR_I2S2_BIT, 0, NULL, 0),
2432 SND_SOC_DAPM_PGA("IF2 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0), 2433 SND_SOC_DAPM_PGA("IF2 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2433 SND_SOC_DAPM_PGA("IF2 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), 2434 SND_SOC_DAPM_PGA("IF2 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2434 SND_SOC_DAPM_PGA("IF2 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), 2435 SND_SOC_DAPM_PGA("IF2 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2435 SND_SOC_DAPM_PGA("IF2 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0), 2436 SND_SOC_DAPM_PGA("IF2 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2436 SND_SOC_DAPM_PGA("IF2 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0), 2437 SND_SOC_DAPM_PGA("IF2 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2437 SND_SOC_DAPM_PGA("IF2 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0), 2438 SND_SOC_DAPM_PGA("IF2 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2438 SND_SOC_DAPM_PGA("IF2 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0), 2439 SND_SOC_DAPM_PGA("IF2 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2439 SND_SOC_DAPM_PGA("IF2 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0), 2440 SND_SOC_DAPM_PGA("IF2 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2440 SND_SOC_DAPM_PGA("IF2 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0), 2441 SND_SOC_DAPM_PGA("IF2 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2441 SND_SOC_DAPM_PGA("IF2 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0), 2442 SND_SOC_DAPM_PGA("IF2 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2442 SND_SOC_DAPM_PGA("IF2 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0), 2443 SND_SOC_DAPM_PGA("IF2 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2443 SND_SOC_DAPM_PGA("IF2 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0), 2444 SND_SOC_DAPM_PGA("IF2 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2444 SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), 2445 SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2445 SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), 2446 SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2446 SND_SOC_DAPM_PGA("IF2 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), 2447 SND_SOC_DAPM_PGA("IF2 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2447 SND_SOC_DAPM_PGA("IF2 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), 2448 SND_SOC_DAPM_PGA("IF2 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2448 2449
2449 SND_SOC_DAPM_SUPPLY("I2S3", RT5677_PWR_DIG1, 2450 SND_SOC_DAPM_SUPPLY("I2S3", RT5677_PWR_DIG1,
2450 RT5677_PWR_I2S3_BIT, 0, NULL, 0), 2451 RT5677_PWR_I2S3_BIT, 0, NULL, 0),
2451 SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0), 2452 SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2452 SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0), 2453 SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2453 SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0), 2454 SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2454 SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 2455 SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2455 SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), 2456 SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2456 SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), 2457 SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2457 2458
2458 SND_SOC_DAPM_SUPPLY("I2S4", RT5677_PWR_DIG1, 2459 SND_SOC_DAPM_SUPPLY("I2S4", RT5677_PWR_DIG1,
2459 RT5677_PWR_I2S4_BIT, 0, NULL, 0), 2460 RT5677_PWR_I2S4_BIT, 0, NULL, 0),
2460 SND_SOC_DAPM_PGA("IF4 DAC", SND_SOC_NOPM, 0, 0, NULL, 0), 2461 SND_SOC_DAPM_PGA("IF4 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
2461 SND_SOC_DAPM_PGA("IF4 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0), 2462 SND_SOC_DAPM_PGA("IF4 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2462 SND_SOC_DAPM_PGA("IF4 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0), 2463 SND_SOC_DAPM_PGA("IF4 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2463 SND_SOC_DAPM_PGA("IF4 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 2464 SND_SOC_DAPM_PGA("IF4 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2464 SND_SOC_DAPM_PGA("IF4 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), 2465 SND_SOC_DAPM_PGA("IF4 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
2465 SND_SOC_DAPM_PGA("IF4 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), 2466 SND_SOC_DAPM_PGA("IF4 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
2466 2467
2467 SND_SOC_DAPM_SUPPLY("SLB", RT5677_PWR_DIG1, 2468 SND_SOC_DAPM_SUPPLY("SLB", RT5677_PWR_DIG1,
2468 RT5677_PWR_SLB_BIT, 0, NULL, 0), 2469 RT5677_PWR_SLB_BIT, 0, NULL, 0),
2469 SND_SOC_DAPM_PGA("SLB DAC0", SND_SOC_NOPM, 0, 0, NULL, 0), 2470 SND_SOC_DAPM_PGA("SLB DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
2470 SND_SOC_DAPM_PGA("SLB DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), 2471 SND_SOC_DAPM_PGA("SLB DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2471 SND_SOC_DAPM_PGA("SLB DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), 2472 SND_SOC_DAPM_PGA("SLB DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2472 SND_SOC_DAPM_PGA("SLB DAC3", SND_SOC_NOPM, 0, 0, NULL, 0), 2473 SND_SOC_DAPM_PGA("SLB DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2473 SND_SOC_DAPM_PGA("SLB DAC4", SND_SOC_NOPM, 0, 0, NULL, 0), 2474 SND_SOC_DAPM_PGA("SLB DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2474 SND_SOC_DAPM_PGA("SLB DAC5", SND_SOC_NOPM, 0, 0, NULL, 0), 2475 SND_SOC_DAPM_PGA("SLB DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
2475 SND_SOC_DAPM_PGA("SLB DAC6", SND_SOC_NOPM, 0, 0, NULL, 0), 2476 SND_SOC_DAPM_PGA("SLB DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
2476 SND_SOC_DAPM_PGA("SLB DAC7", SND_SOC_NOPM, 0, 0, NULL, 0), 2477 SND_SOC_DAPM_PGA("SLB DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
2477 SND_SOC_DAPM_PGA("SLB DAC01", SND_SOC_NOPM, 0, 0, NULL, 0), 2478 SND_SOC_DAPM_PGA("SLB DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
2478 SND_SOC_DAPM_PGA("SLB DAC23", SND_SOC_NOPM, 0, 0, NULL, 0), 2479 SND_SOC_DAPM_PGA("SLB DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
2479 SND_SOC_DAPM_PGA("SLB DAC45", SND_SOC_NOPM, 0, 0, NULL, 0), 2480 SND_SOC_DAPM_PGA("SLB DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
2480 SND_SOC_DAPM_PGA("SLB DAC67", SND_SOC_NOPM, 0, 0, NULL, 0), 2481 SND_SOC_DAPM_PGA("SLB DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
2481 SND_SOC_DAPM_PGA("SLB ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), 2482 SND_SOC_DAPM_PGA("SLB ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
2482 SND_SOC_DAPM_PGA("SLB ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), 2483 SND_SOC_DAPM_PGA("SLB ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
2483 SND_SOC_DAPM_PGA("SLB ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), 2484 SND_SOC_DAPM_PGA("SLB ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
2484 SND_SOC_DAPM_PGA("SLB ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), 2485 SND_SOC_DAPM_PGA("SLB ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
2485 2486
2486 /* Digital Interface Select */ 2487 /* Digital Interface Select */
2487 SND_SOC_DAPM_MUX("IF1 ADC1 Mux", SND_SOC_NOPM, 0, 0, 2488 SND_SOC_DAPM_MUX("IF1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2488 &rt5677_if1_adc1_mux), 2489 &rt5677_if1_adc1_mux),
2489 SND_SOC_DAPM_MUX("IF1 ADC2 Mux", SND_SOC_NOPM, 0, 0, 2490 SND_SOC_DAPM_MUX("IF1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2490 &rt5677_if1_adc2_mux), 2491 &rt5677_if1_adc2_mux),
2491 SND_SOC_DAPM_MUX("IF1 ADC3 Mux", SND_SOC_NOPM, 0, 0, 2492 SND_SOC_DAPM_MUX("IF1 ADC3 Mux", SND_SOC_NOPM, 0, 0,
2492 &rt5677_if1_adc3_mux), 2493 &rt5677_if1_adc3_mux),
2493 SND_SOC_DAPM_MUX("IF1 ADC4 Mux", SND_SOC_NOPM, 0, 0, 2494 SND_SOC_DAPM_MUX("IF1 ADC4 Mux", SND_SOC_NOPM, 0, 0,
2494 &rt5677_if1_adc4_mux), 2495 &rt5677_if1_adc4_mux),
2495 SND_SOC_DAPM_MUX("IF1 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0, 2496 SND_SOC_DAPM_MUX("IF1 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
2496 &rt5677_if1_adc1_swap_mux), 2497 &rt5677_if1_adc1_swap_mux),
2497 SND_SOC_DAPM_MUX("IF1 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0, 2498 SND_SOC_DAPM_MUX("IF1 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
2498 &rt5677_if1_adc2_swap_mux), 2499 &rt5677_if1_adc2_swap_mux),
2499 SND_SOC_DAPM_MUX("IF1 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0, 2500 SND_SOC_DAPM_MUX("IF1 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
2500 &rt5677_if1_adc3_swap_mux), 2501 &rt5677_if1_adc3_swap_mux),
2501 SND_SOC_DAPM_MUX("IF1 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0, 2502 SND_SOC_DAPM_MUX("IF1 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
2502 &rt5677_if1_adc4_swap_mux), 2503 &rt5677_if1_adc4_swap_mux),
2503 SND_SOC_DAPM_MUX_E("IF1 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0, 2504 SND_SOC_DAPM_MUX_E("IF1 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
2504 &rt5677_if1_adc_tdm_swap_mux, rt5677_if1_adc_tdm_event, 2505 &rt5677_if1_adc_tdm_swap_mux, rt5677_if1_adc_tdm_event,
2505 SND_SOC_DAPM_PRE_PMU), 2506 SND_SOC_DAPM_PRE_PMU),
2506 SND_SOC_DAPM_MUX("IF2 ADC1 Mux", SND_SOC_NOPM, 0, 0, 2507 SND_SOC_DAPM_MUX("IF2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
2507 &rt5677_if2_adc1_mux), 2508 &rt5677_if2_adc1_mux),
2508 SND_SOC_DAPM_MUX("IF2 ADC2 Mux", SND_SOC_NOPM, 0, 0, 2509 SND_SOC_DAPM_MUX("IF2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
2509 &rt5677_if2_adc2_mux), 2510 &rt5677_if2_adc2_mux),
2510 SND_SOC_DAPM_MUX("IF2 ADC3 Mux", SND_SOC_NOPM, 0, 0, 2511 SND_SOC_DAPM_MUX("IF2 ADC3 Mux", SND_SOC_NOPM, 0, 0,
2511 &rt5677_if2_adc3_mux), 2512 &rt5677_if2_adc3_mux),
2512 SND_SOC_DAPM_MUX("IF2 ADC4 Mux", SND_SOC_NOPM, 0, 0, 2513 SND_SOC_DAPM_MUX("IF2 ADC4 Mux", SND_SOC_NOPM, 0, 0,
2513 &rt5677_if2_adc4_mux), 2514 &rt5677_if2_adc4_mux),
2514 SND_SOC_DAPM_MUX("IF2 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0, 2515 SND_SOC_DAPM_MUX("IF2 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
2515 &rt5677_if2_adc1_swap_mux), 2516 &rt5677_if2_adc1_swap_mux),
2516 SND_SOC_DAPM_MUX("IF2 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0, 2517 SND_SOC_DAPM_MUX("IF2 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
2517 &rt5677_if2_adc2_swap_mux), 2518 &rt5677_if2_adc2_swap_mux),
2518 SND_SOC_DAPM_MUX("IF2 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0, 2519 SND_SOC_DAPM_MUX("IF2 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
2519 &rt5677_if2_adc3_swap_mux), 2520 &rt5677_if2_adc3_swap_mux),
2520 SND_SOC_DAPM_MUX("IF2 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0, 2521 SND_SOC_DAPM_MUX("IF2 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
2521 &rt5677_if2_adc4_swap_mux), 2522 &rt5677_if2_adc4_swap_mux),
2522 SND_SOC_DAPM_MUX_E("IF2 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0, 2523 SND_SOC_DAPM_MUX_E("IF2 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
2523 &rt5677_if2_adc_tdm_swap_mux, rt5677_if2_adc_tdm_event, 2524 &rt5677_if2_adc_tdm_swap_mux, rt5677_if2_adc_tdm_event,
2524 SND_SOC_DAPM_PRE_PMU), 2525 SND_SOC_DAPM_PRE_PMU),
2525 SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0, 2526 SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0,
2526 &rt5677_if3_adc_mux), 2527 &rt5677_if3_adc_mux),
2527 SND_SOC_DAPM_MUX("IF4 ADC Mux", SND_SOC_NOPM, 0, 0, 2528 SND_SOC_DAPM_MUX("IF4 ADC Mux", SND_SOC_NOPM, 0, 0,
2528 &rt5677_if4_adc_mux), 2529 &rt5677_if4_adc_mux),
2529 SND_SOC_DAPM_MUX("SLB ADC1 Mux", SND_SOC_NOPM, 0, 0, 2530 SND_SOC_DAPM_MUX("SLB ADC1 Mux", SND_SOC_NOPM, 0, 0,
2530 &rt5677_slb_adc1_mux), 2531 &rt5677_slb_adc1_mux),
2531 SND_SOC_DAPM_MUX("SLB ADC2 Mux", SND_SOC_NOPM, 0, 0, 2532 SND_SOC_DAPM_MUX("SLB ADC2 Mux", SND_SOC_NOPM, 0, 0,
2532 &rt5677_slb_adc2_mux), 2533 &rt5677_slb_adc2_mux),
2533 SND_SOC_DAPM_MUX("SLB ADC3 Mux", SND_SOC_NOPM, 0, 0, 2534 SND_SOC_DAPM_MUX("SLB ADC3 Mux", SND_SOC_NOPM, 0, 0,
2534 &rt5677_slb_adc3_mux), 2535 &rt5677_slb_adc3_mux),
2535 SND_SOC_DAPM_MUX("SLB ADC4 Mux", SND_SOC_NOPM, 0, 0, 2536 SND_SOC_DAPM_MUX("SLB ADC4 Mux", SND_SOC_NOPM, 0, 0,
2536 &rt5677_slb_adc4_mux), 2537 &rt5677_slb_adc4_mux),
2537 2538
2538 SND_SOC_DAPM_MUX("IF1 DAC0 Mux", SND_SOC_NOPM, 0, 0, 2539 SND_SOC_DAPM_MUX("IF1 DAC0 Mux", SND_SOC_NOPM, 0, 0,
2539 &rt5677_if1_dac0_tdm_sel_mux), 2540 &rt5677_if1_dac0_tdm_sel_mux),
2540 SND_SOC_DAPM_MUX("IF1 DAC1 Mux", SND_SOC_NOPM, 0, 0, 2541 SND_SOC_DAPM_MUX("IF1 DAC1 Mux", SND_SOC_NOPM, 0, 0,
2541 &rt5677_if1_dac1_tdm_sel_mux), 2542 &rt5677_if1_dac1_tdm_sel_mux),
2542 SND_SOC_DAPM_MUX("IF1 DAC2 Mux", SND_SOC_NOPM, 0, 0, 2543 SND_SOC_DAPM_MUX("IF1 DAC2 Mux", SND_SOC_NOPM, 0, 0,
2543 &rt5677_if1_dac2_tdm_sel_mux), 2544 &rt5677_if1_dac2_tdm_sel_mux),
2544 SND_SOC_DAPM_MUX("IF1 DAC3 Mux", SND_SOC_NOPM, 0, 0, 2545 SND_SOC_DAPM_MUX("IF1 DAC3 Mux", SND_SOC_NOPM, 0, 0,
2545 &rt5677_if1_dac3_tdm_sel_mux), 2546 &rt5677_if1_dac3_tdm_sel_mux),
2546 SND_SOC_DAPM_MUX("IF1 DAC4 Mux", SND_SOC_NOPM, 0, 0, 2547 SND_SOC_DAPM_MUX("IF1 DAC4 Mux", SND_SOC_NOPM, 0, 0,
2547 &rt5677_if1_dac4_tdm_sel_mux), 2548 &rt5677_if1_dac4_tdm_sel_mux),
2548 SND_SOC_DAPM_MUX("IF1 DAC5 Mux", SND_SOC_NOPM, 0, 0, 2549 SND_SOC_DAPM_MUX("IF1 DAC5 Mux", SND_SOC_NOPM, 0, 0,
2549 &rt5677_if1_dac5_tdm_sel_mux), 2550 &rt5677_if1_dac5_tdm_sel_mux),
2550 SND_SOC_DAPM_MUX("IF1 DAC6 Mux", SND_SOC_NOPM, 0, 0, 2551 SND_SOC_DAPM_MUX("IF1 DAC6 Mux", SND_SOC_NOPM, 0, 0,
2551 &rt5677_if1_dac6_tdm_sel_mux), 2552 &rt5677_if1_dac6_tdm_sel_mux),
2552 SND_SOC_DAPM_MUX("IF1 DAC7 Mux", SND_SOC_NOPM, 0, 0, 2553 SND_SOC_DAPM_MUX("IF1 DAC7 Mux", SND_SOC_NOPM, 0, 0,
2553 &rt5677_if1_dac7_tdm_sel_mux), 2554 &rt5677_if1_dac7_tdm_sel_mux),
2554 2555
2555 SND_SOC_DAPM_MUX("IF2 DAC0 Mux", SND_SOC_NOPM, 0, 0, 2556 SND_SOC_DAPM_MUX("IF2 DAC0 Mux", SND_SOC_NOPM, 0, 0,
2556 &rt5677_if2_dac0_tdm_sel_mux), 2557 &rt5677_if2_dac0_tdm_sel_mux),
2557 SND_SOC_DAPM_MUX("IF2 DAC1 Mux", SND_SOC_NOPM, 0, 0, 2558 SND_SOC_DAPM_MUX("IF2 DAC1 Mux", SND_SOC_NOPM, 0, 0,
2558 &rt5677_if2_dac1_tdm_sel_mux), 2559 &rt5677_if2_dac1_tdm_sel_mux),
2559 SND_SOC_DAPM_MUX("IF2 DAC2 Mux", SND_SOC_NOPM, 0, 0, 2560 SND_SOC_DAPM_MUX("IF2 DAC2 Mux", SND_SOC_NOPM, 0, 0,
2560 &rt5677_if2_dac2_tdm_sel_mux), 2561 &rt5677_if2_dac2_tdm_sel_mux),
2561 SND_SOC_DAPM_MUX("IF2 DAC3 Mux", SND_SOC_NOPM, 0, 0, 2562 SND_SOC_DAPM_MUX("IF2 DAC3 Mux", SND_SOC_NOPM, 0, 0,
2562 &rt5677_if2_dac3_tdm_sel_mux), 2563 &rt5677_if2_dac3_tdm_sel_mux),
2563 SND_SOC_DAPM_MUX("IF2 DAC4 Mux", SND_SOC_NOPM, 0, 0, 2564 SND_SOC_DAPM_MUX("IF2 DAC4 Mux", SND_SOC_NOPM, 0, 0,
2564 &rt5677_if2_dac4_tdm_sel_mux), 2565 &rt5677_if2_dac4_tdm_sel_mux),
2565 SND_SOC_DAPM_MUX("IF2 DAC5 Mux", SND_SOC_NOPM, 0, 0, 2566 SND_SOC_DAPM_MUX("IF2 DAC5 Mux", SND_SOC_NOPM, 0, 0,
2566 &rt5677_if2_dac5_tdm_sel_mux), 2567 &rt5677_if2_dac5_tdm_sel_mux),
2567 SND_SOC_DAPM_MUX("IF2 DAC6 Mux", SND_SOC_NOPM, 0, 0, 2568 SND_SOC_DAPM_MUX("IF2 DAC6 Mux", SND_SOC_NOPM, 0, 0,
2568 &rt5677_if2_dac6_tdm_sel_mux), 2569 &rt5677_if2_dac6_tdm_sel_mux),
2569 SND_SOC_DAPM_MUX("IF2 DAC7 Mux", SND_SOC_NOPM, 0, 0, 2570 SND_SOC_DAPM_MUX("IF2 DAC7 Mux", SND_SOC_NOPM, 0, 0,
2570 &rt5677_if2_dac7_tdm_sel_mux), 2571 &rt5677_if2_dac7_tdm_sel_mux),
2571 2572
2572 /* Audio Interface */ 2573 /* Audio Interface */
2573 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), 2574 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
2574 SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), 2575 SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
2575 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0), 2576 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
2576 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0), 2577 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
2577 SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0), 2578 SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
2578 SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0), 2579 SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
2579 SND_SOC_DAPM_AIF_IN("AIF4RX", "AIF4 Playback", 0, SND_SOC_NOPM, 0, 0), 2580 SND_SOC_DAPM_AIF_IN("AIF4RX", "AIF4 Playback", 0, SND_SOC_NOPM, 0, 0),
2580 SND_SOC_DAPM_AIF_OUT("AIF4TX", "AIF4 Capture", 0, SND_SOC_NOPM, 0, 0), 2581 SND_SOC_DAPM_AIF_OUT("AIF4TX", "AIF4 Capture", 0, SND_SOC_NOPM, 0, 0),
2581 SND_SOC_DAPM_AIF_IN("SLBRX", "SLIMBus Playback", 0, SND_SOC_NOPM, 0, 0), 2582 SND_SOC_DAPM_AIF_IN("SLBRX", "SLIMBus Playback", 0, SND_SOC_NOPM, 0, 0),
2582 SND_SOC_DAPM_AIF_OUT("SLBTX", "SLIMBus Capture", 0, SND_SOC_NOPM, 0, 0), 2583 SND_SOC_DAPM_AIF_OUT("SLBTX", "SLIMBus Capture", 0, SND_SOC_NOPM, 0, 0),
2583 2584
2584 /* Sidetone Mux */ 2585 /* Sidetone Mux */
2585 SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0, 2586 SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0,
2586 &rt5677_sidetone_mux), 2587 &rt5677_sidetone_mux),
2587 SND_SOC_DAPM_SUPPLY("Sidetone Power", RT5677_SIDETONE_CTRL, 2588 SND_SOC_DAPM_SUPPLY("Sidetone Power", RT5677_SIDETONE_CTRL,
2588 RT5677_ST_EN_SFT, 0, NULL, 0), 2589 RT5677_ST_EN_SFT, 0, NULL, 0),
2589 2590
2590 /* VAD Mux*/ 2591 /* VAD Mux*/
2591 SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0, 2592 SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0,
2592 &rt5677_vad_src_mux), 2593 &rt5677_vad_src_mux),
2593 2594
2594 /* Tensilica DSP */ 2595 /* Tensilica DSP */
2595 SND_SOC_DAPM_PGA("Tensilica DSP", SND_SOC_NOPM, 0, 0, NULL, 0), 2596 SND_SOC_DAPM_PGA("Tensilica DSP", SND_SOC_NOPM, 0, 0, NULL, 0),
2596 SND_SOC_DAPM_MIXER("OB01 MIX", SND_SOC_NOPM, 0, 0, 2597 SND_SOC_DAPM_MIXER("OB01 MIX", SND_SOC_NOPM, 0, 0,
2597 rt5677_ob_01_mix, ARRAY_SIZE(rt5677_ob_01_mix)), 2598 rt5677_ob_01_mix, ARRAY_SIZE(rt5677_ob_01_mix)),
2598 SND_SOC_DAPM_MIXER("OB23 MIX", SND_SOC_NOPM, 0, 0, 2599 SND_SOC_DAPM_MIXER("OB23 MIX", SND_SOC_NOPM, 0, 0,
2599 rt5677_ob_23_mix, ARRAY_SIZE(rt5677_ob_23_mix)), 2600 rt5677_ob_23_mix, ARRAY_SIZE(rt5677_ob_23_mix)),
2600 SND_SOC_DAPM_MIXER("OB4 MIX", SND_SOC_NOPM, 0, 0, 2601 SND_SOC_DAPM_MIXER("OB4 MIX", SND_SOC_NOPM, 0, 0,
2601 rt5677_ob_4_mix, ARRAY_SIZE(rt5677_ob_4_mix)), 2602 rt5677_ob_4_mix, ARRAY_SIZE(rt5677_ob_4_mix)),
2602 SND_SOC_DAPM_MIXER("OB5 MIX", SND_SOC_NOPM, 0, 0, 2603 SND_SOC_DAPM_MIXER("OB5 MIX", SND_SOC_NOPM, 0, 0,
2603 rt5677_ob_5_mix, ARRAY_SIZE(rt5677_ob_5_mix)), 2604 rt5677_ob_5_mix, ARRAY_SIZE(rt5677_ob_5_mix)),
2604 SND_SOC_DAPM_MIXER("OB6 MIX", SND_SOC_NOPM, 0, 0, 2605 SND_SOC_DAPM_MIXER("OB6 MIX", SND_SOC_NOPM, 0, 0,
2605 rt5677_ob_6_mix, ARRAY_SIZE(rt5677_ob_6_mix)), 2606 rt5677_ob_6_mix, ARRAY_SIZE(rt5677_ob_6_mix)),
2606 SND_SOC_DAPM_MIXER("OB7 MIX", SND_SOC_NOPM, 0, 0, 2607 SND_SOC_DAPM_MIXER("OB7 MIX", SND_SOC_NOPM, 0, 0,
2607 rt5677_ob_7_mix, ARRAY_SIZE(rt5677_ob_7_mix)), 2608 rt5677_ob_7_mix, ARRAY_SIZE(rt5677_ob_7_mix)),
2608 2609
2609 /* Output Side */ 2610 /* Output Side */
2610 /* DAC mixer before sound effect */ 2611 /* DAC mixer before sound effect */
2611 SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0, 2612 SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0,
2612 rt5677_dac_l_mix, ARRAY_SIZE(rt5677_dac_l_mix)), 2613 rt5677_dac_l_mix, ARRAY_SIZE(rt5677_dac_l_mix)),
2613 SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0, 2614 SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0,
2614 rt5677_dac_r_mix, ARRAY_SIZE(rt5677_dac_r_mix)), 2615 rt5677_dac_r_mix, ARRAY_SIZE(rt5677_dac_r_mix)),
2615 SND_SOC_DAPM_PGA("DAC1 FS", SND_SOC_NOPM, 0, 0, NULL, 0), 2616 SND_SOC_DAPM_PGA("DAC1 FS", SND_SOC_NOPM, 0, 0, NULL, 0),
2616 2617
2617 /* DAC Mux */ 2618 /* DAC Mux */
2618 SND_SOC_DAPM_MUX("DAC1 Mux", SND_SOC_NOPM, 0, 0, 2619 SND_SOC_DAPM_MUX("DAC1 Mux", SND_SOC_NOPM, 0, 0,
2619 &rt5677_dac1_mux), 2620 &rt5677_dac1_mux),
2620 SND_SOC_DAPM_MUX("ADDA1 Mux", SND_SOC_NOPM, 0, 0, 2621 SND_SOC_DAPM_MUX("ADDA1 Mux", SND_SOC_NOPM, 0, 0,
2621 &rt5677_adda1_mux), 2622 &rt5677_adda1_mux),
2622 SND_SOC_DAPM_MUX("DAC12 SRC Mux", SND_SOC_NOPM, 0, 0, 2623 SND_SOC_DAPM_MUX("DAC12 SRC Mux", SND_SOC_NOPM, 0, 0,
2623 &rt5677_dac12_mux), 2624 &rt5677_dac12_mux),
2624 SND_SOC_DAPM_MUX("DAC3 SRC Mux", SND_SOC_NOPM, 0, 0, 2625 SND_SOC_DAPM_MUX("DAC3 SRC Mux", SND_SOC_NOPM, 0, 0,
2625 &rt5677_dac3_mux), 2626 &rt5677_dac3_mux),
2626 2627
2627 /* DAC2 channel Mux */ 2628 /* DAC2 channel Mux */
2628 SND_SOC_DAPM_MUX("DAC2 L Mux", SND_SOC_NOPM, 0, 0, 2629 SND_SOC_DAPM_MUX("DAC2 L Mux", SND_SOC_NOPM, 0, 0,
2629 &rt5677_dac2_l_mux), 2630 &rt5677_dac2_l_mux),
2630 SND_SOC_DAPM_MUX("DAC2 R Mux", SND_SOC_NOPM, 0, 0, 2631 SND_SOC_DAPM_MUX("DAC2 R Mux", SND_SOC_NOPM, 0, 0,
2631 &rt5677_dac2_r_mux), 2632 &rt5677_dac2_r_mux),
2632 2633
2633 /* DAC3 channel Mux */ 2634 /* DAC3 channel Mux */
2634 SND_SOC_DAPM_MUX("DAC3 L Mux", SND_SOC_NOPM, 0, 0, 2635 SND_SOC_DAPM_MUX("DAC3 L Mux", SND_SOC_NOPM, 0, 0,
2635 &rt5677_dac3_l_mux), 2636 &rt5677_dac3_l_mux),
2636 SND_SOC_DAPM_MUX("DAC3 R Mux", SND_SOC_NOPM, 0, 0, 2637 SND_SOC_DAPM_MUX("DAC3 R Mux", SND_SOC_NOPM, 0, 0,
2637 &rt5677_dac3_r_mux), 2638 &rt5677_dac3_r_mux),
2638 2639
2639 /* DAC4 channel Mux */ 2640 /* DAC4 channel Mux */
2640 SND_SOC_DAPM_MUX("DAC4 L Mux", SND_SOC_NOPM, 0, 0, 2641 SND_SOC_DAPM_MUX("DAC4 L Mux", SND_SOC_NOPM, 0, 0,
2641 &rt5677_dac4_l_mux), 2642 &rt5677_dac4_l_mux),
2642 SND_SOC_DAPM_MUX("DAC4 R Mux", SND_SOC_NOPM, 0, 0, 2643 SND_SOC_DAPM_MUX("DAC4 R Mux", SND_SOC_NOPM, 0, 0,
2643 &rt5677_dac4_r_mux), 2644 &rt5677_dac4_r_mux),
2644 2645
2645 /* DAC Mixer */ 2646 /* DAC Mixer */
2646 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2, 2647 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2,
2647 RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0), 2648 RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0),
2648 SND_SOC_DAPM_SUPPLY("dac mono left filter", RT5677_PWR_DIG2, 2649 SND_SOC_DAPM_SUPPLY("dac mono left filter", RT5677_PWR_DIG2,
2649 RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0), 2650 RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0),
2650 SND_SOC_DAPM_SUPPLY("dac mono right filter", RT5677_PWR_DIG2, 2651 SND_SOC_DAPM_SUPPLY("dac mono right filter", RT5677_PWR_DIG2,
2651 RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0), 2652 RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0),
2652 2653
2653 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, 2654 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
2654 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)), 2655 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)),
2655 SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0, 2656 SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0,
2656 rt5677_sto1_dac_r_mix, ARRAY_SIZE(rt5677_sto1_dac_r_mix)), 2657 rt5677_sto1_dac_r_mix, ARRAY_SIZE(rt5677_sto1_dac_r_mix)),
2657 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0, 2658 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
2658 rt5677_mono_dac_l_mix, ARRAY_SIZE(rt5677_mono_dac_l_mix)), 2659 rt5677_mono_dac_l_mix, ARRAY_SIZE(rt5677_mono_dac_l_mix)),
2659 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0, 2660 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
2660 rt5677_mono_dac_r_mix, ARRAY_SIZE(rt5677_mono_dac_r_mix)), 2661 rt5677_mono_dac_r_mix, ARRAY_SIZE(rt5677_mono_dac_r_mix)),
2661 SND_SOC_DAPM_MIXER("DD1 MIXL", SND_SOC_NOPM, 0, 0, 2662 SND_SOC_DAPM_MIXER("DD1 MIXL", SND_SOC_NOPM, 0, 0,
2662 rt5677_dd1_l_mix, ARRAY_SIZE(rt5677_dd1_l_mix)), 2663 rt5677_dd1_l_mix, ARRAY_SIZE(rt5677_dd1_l_mix)),
2663 SND_SOC_DAPM_MIXER("DD1 MIXR", SND_SOC_NOPM, 0, 0, 2664 SND_SOC_DAPM_MIXER("DD1 MIXR", SND_SOC_NOPM, 0, 0,
2664 rt5677_dd1_r_mix, ARRAY_SIZE(rt5677_dd1_r_mix)), 2665 rt5677_dd1_r_mix, ARRAY_SIZE(rt5677_dd1_r_mix)),
2665 SND_SOC_DAPM_MIXER("DD2 MIXL", SND_SOC_NOPM, 0, 0, 2666 SND_SOC_DAPM_MIXER("DD2 MIXL", SND_SOC_NOPM, 0, 0,
2666 rt5677_dd2_l_mix, ARRAY_SIZE(rt5677_dd2_l_mix)), 2667 rt5677_dd2_l_mix, ARRAY_SIZE(rt5677_dd2_l_mix)),
2667 SND_SOC_DAPM_MIXER("DD2 MIXR", SND_SOC_NOPM, 0, 0, 2668 SND_SOC_DAPM_MIXER("DD2 MIXR", SND_SOC_NOPM, 0, 0,
2668 rt5677_dd2_r_mix, ARRAY_SIZE(rt5677_dd2_r_mix)), 2669 rt5677_dd2_r_mix, ARRAY_SIZE(rt5677_dd2_r_mix)),
2669 SND_SOC_DAPM_PGA("Stereo DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2670 SND_SOC_DAPM_PGA("Stereo DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2670 SND_SOC_DAPM_PGA("Mono DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2671 SND_SOC_DAPM_PGA("Mono DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2671 SND_SOC_DAPM_PGA("DD1 MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2672 SND_SOC_DAPM_PGA("DD1 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2672 SND_SOC_DAPM_PGA("DD2 MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 2673 SND_SOC_DAPM_PGA("DD2 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2673 2674
2674 /* DACs */ 2675 /* DACs */
2675 SND_SOC_DAPM_DAC("DAC 1", NULL, RT5677_PWR_DIG1, 2676 SND_SOC_DAPM_DAC("DAC 1", NULL, RT5677_PWR_DIG1,
2676 RT5677_PWR_DAC1_BIT, 0), 2677 RT5677_PWR_DAC1_BIT, 0),
2677 SND_SOC_DAPM_DAC("DAC 2", NULL, RT5677_PWR_DIG1, 2678 SND_SOC_DAPM_DAC("DAC 2", NULL, RT5677_PWR_DIG1,
2678 RT5677_PWR_DAC2_BIT, 0), 2679 RT5677_PWR_DAC2_BIT, 0),
2679 SND_SOC_DAPM_DAC("DAC 3", NULL, RT5677_PWR_DIG1, 2680 SND_SOC_DAPM_DAC("DAC 3", NULL, RT5677_PWR_DIG1,
2680 RT5677_PWR_DAC3_BIT, 0), 2681 RT5677_PWR_DAC3_BIT, 0),
2681 2682
2682 /* PDM */ 2683 /* PDM */
2683 SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5677_PWR_DIG2, 2684 SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5677_PWR_DIG2,
2684 RT5677_PWR_PDM1_BIT, 0, NULL, 0), 2685 RT5677_PWR_PDM1_BIT, 0, NULL, 0),
2685 SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5677_PWR_DIG2, 2686 SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5677_PWR_DIG2,
2686 RT5677_PWR_PDM2_BIT, 0, NULL, 0), 2687 RT5677_PWR_PDM2_BIT, 0, NULL, 0),
2687 2688
2688 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_L_SFT, 2689 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_L_SFT,
2689 1, &rt5677_pdm1_l_mux), 2690 1, &rt5677_pdm1_l_mux),
2690 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_R_SFT, 2691 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_R_SFT,
2691 1, &rt5677_pdm1_r_mux), 2692 1, &rt5677_pdm1_r_mux),
2692 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_L_SFT, 2693 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_L_SFT,
2693 1, &rt5677_pdm2_l_mux), 2694 1, &rt5677_pdm2_l_mux),
2694 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_R_SFT, 2695 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_R_SFT,
2695 1, &rt5677_pdm2_r_mux), 2696 1, &rt5677_pdm2_r_mux),
2696 2697
2697 SND_SOC_DAPM_PGA_S("LOUT1 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO1_BIT, 2698 SND_SOC_DAPM_PGA_S("LOUT1 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO1_BIT,
2698 0, NULL, 0), 2699 0, NULL, 0),
2699 SND_SOC_DAPM_PGA_S("LOUT2 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO2_BIT, 2700 SND_SOC_DAPM_PGA_S("LOUT2 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO2_BIT,
2700 0, NULL, 0), 2701 0, NULL, 0),
2701 SND_SOC_DAPM_PGA_S("LOUT3 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO3_BIT, 2702 SND_SOC_DAPM_PGA_S("LOUT3 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO3_BIT,
2702 0, NULL, 0), 2703 0, NULL, 0),
2703 2704
2704 SND_SOC_DAPM_PGA_S("LOUT1 vref", 1, SND_SOC_NOPM, 0, 0, 2705 SND_SOC_DAPM_PGA_S("LOUT1 vref", 1, SND_SOC_NOPM, 0, 0,
2705 rt5677_vref_event, SND_SOC_DAPM_POST_PMU), 2706 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2706 SND_SOC_DAPM_PGA_S("LOUT2 vref", 1, SND_SOC_NOPM, 0, 0, 2707 SND_SOC_DAPM_PGA_S("LOUT2 vref", 1, SND_SOC_NOPM, 0, 0,
2707 rt5677_vref_event, SND_SOC_DAPM_POST_PMU), 2708 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2708 SND_SOC_DAPM_PGA_S("LOUT3 vref", 1, SND_SOC_NOPM, 0, 0, 2709 SND_SOC_DAPM_PGA_S("LOUT3 vref", 1, SND_SOC_NOPM, 0, 0,
2709 rt5677_vref_event, SND_SOC_DAPM_POST_PMU), 2710 rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
2710 2711
2711 /* Output Lines */ 2712 /* Output Lines */
2712 SND_SOC_DAPM_OUTPUT("LOUT1"), 2713 SND_SOC_DAPM_OUTPUT("LOUT1"),
2713 SND_SOC_DAPM_OUTPUT("LOUT2"), 2714 SND_SOC_DAPM_OUTPUT("LOUT2"),
2714 SND_SOC_DAPM_OUTPUT("LOUT3"), 2715 SND_SOC_DAPM_OUTPUT("LOUT3"),
2715 SND_SOC_DAPM_OUTPUT("PDM1L"), 2716 SND_SOC_DAPM_OUTPUT("PDM1L"),
2716 SND_SOC_DAPM_OUTPUT("PDM1R"), 2717 SND_SOC_DAPM_OUTPUT("PDM1R"),
2717 SND_SOC_DAPM_OUTPUT("PDM2L"), 2718 SND_SOC_DAPM_OUTPUT("PDM2L"),
2718 SND_SOC_DAPM_OUTPUT("PDM2R"), 2719 SND_SOC_DAPM_OUTPUT("PDM2R"),
2719 2720
2720 SND_SOC_DAPM_POST("vref", rt5677_vref_event), 2721 SND_SOC_DAPM_POST("vref", rt5677_vref_event),
2721 }; 2722 };
2722 2723
2723 static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { 2724 static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2724 { "DMIC1", NULL, "DMIC L1" }, 2725 { "DMIC1", NULL, "DMIC L1" },
2725 { "DMIC1", NULL, "DMIC R1" }, 2726 { "DMIC1", NULL, "DMIC R1" },
2726 { "DMIC2", NULL, "DMIC L2" }, 2727 { "DMIC2", NULL, "DMIC L2" },
2727 { "DMIC2", NULL, "DMIC R2" }, 2728 { "DMIC2", NULL, "DMIC R2" },
2728 { "DMIC3", NULL, "DMIC L3" }, 2729 { "DMIC3", NULL, "DMIC L3" },
2729 { "DMIC3", NULL, "DMIC R3" }, 2730 { "DMIC3", NULL, "DMIC R3" },
2730 { "DMIC4", NULL, "DMIC L4" }, 2731 { "DMIC4", NULL, "DMIC L4" },
2731 { "DMIC4", NULL, "DMIC R4" }, 2732 { "DMIC4", NULL, "DMIC R4" },
2732 2733
2733 { "DMIC L1", NULL, "DMIC CLK" }, 2734 { "DMIC L1", NULL, "DMIC CLK" },
2734 { "DMIC R1", NULL, "DMIC CLK" }, 2735 { "DMIC R1", NULL, "DMIC CLK" },
2735 { "DMIC L2", NULL, "DMIC CLK" }, 2736 { "DMIC L2", NULL, "DMIC CLK" },
2736 { "DMIC R2", NULL, "DMIC CLK" }, 2737 { "DMIC R2", NULL, "DMIC CLK" },
2737 { "DMIC L3", NULL, "DMIC CLK" }, 2738 { "DMIC L3", NULL, "DMIC CLK" },
2738 { "DMIC R3", NULL, "DMIC CLK" }, 2739 { "DMIC R3", NULL, "DMIC CLK" },
2739 { "DMIC L4", NULL, "DMIC CLK" }, 2740 { "DMIC L4", NULL, "DMIC CLK" },
2740 { "DMIC R4", NULL, "DMIC CLK" }, 2741 { "DMIC R4", NULL, "DMIC CLK" },
2741 2742
2742 { "DMIC L1", NULL, "DMIC1 power" }, 2743 { "DMIC L1", NULL, "DMIC1 power" },
2743 { "DMIC R1", NULL, "DMIC1 power" }, 2744 { "DMIC R1", NULL, "DMIC1 power" },
2744 { "DMIC L3", NULL, "DMIC3 power" }, 2745 { "DMIC L3", NULL, "DMIC3 power" },
2745 { "DMIC R3", NULL, "DMIC3 power" }, 2746 { "DMIC R3", NULL, "DMIC3 power" },
2746 { "DMIC L4", NULL, "DMIC4 power" }, 2747 { "DMIC L4", NULL, "DMIC4 power" },
2747 { "DMIC R4", NULL, "DMIC4 power" }, 2748 { "DMIC R4", NULL, "DMIC4 power" },
2748 2749
2749 { "BST1", NULL, "IN1P" }, 2750 { "BST1", NULL, "IN1P" },
2750 { "BST1", NULL, "IN1N" }, 2751 { "BST1", NULL, "IN1N" },
2751 { "BST2", NULL, "IN2P" }, 2752 { "BST2", NULL, "IN2P" },
2752 { "BST2", NULL, "IN2N" }, 2753 { "BST2", NULL, "IN2N" },
2753 2754
2754 { "IN1P", NULL, "MICBIAS1" }, 2755 { "IN1P", NULL, "MICBIAS1" },
2755 { "IN1N", NULL, "MICBIAS1" }, 2756 { "IN1N", NULL, "MICBIAS1" },
2756 { "IN2P", NULL, "MICBIAS1" }, 2757 { "IN2P", NULL, "MICBIAS1" },
2757 { "IN2N", NULL, "MICBIAS1" }, 2758 { "IN2N", NULL, "MICBIAS1" },
2758 2759
2759 { "ADC 1", NULL, "BST1" }, 2760 { "ADC 1", NULL, "BST1" },
2760 { "ADC 1", NULL, "ADC 1 power" }, 2761 { "ADC 1", NULL, "ADC 1 power" },
2761 { "ADC 1", NULL, "ADC1 clock" }, 2762 { "ADC 1", NULL, "ADC1 clock" },
2762 { "ADC 2", NULL, "BST2" }, 2763 { "ADC 2", NULL, "BST2" },
2763 { "ADC 2", NULL, "ADC 2 power" }, 2764 { "ADC 2", NULL, "ADC 2 power" },
2764 { "ADC 2", NULL, "ADC2 clock" }, 2765 { "ADC 2", NULL, "ADC2 clock" },
2765 2766
2766 { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" }, 2767 { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" },
2767 { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" }, 2768 { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" },
2768 { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" }, 2769 { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" },
2769 { "Stereo1 DMIC Mux", "DMIC4", "DMIC4" }, 2770 { "Stereo1 DMIC Mux", "DMIC4", "DMIC4" },
2770 2771
2771 { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" }, 2772 { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" },
2772 { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" }, 2773 { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" },
2773 { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" }, 2774 { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" },
2774 { "Stereo2 DMIC Mux", "DMIC4", "DMIC4" }, 2775 { "Stereo2 DMIC Mux", "DMIC4", "DMIC4" },
2775 2776
2776 { "Stereo3 DMIC Mux", "DMIC1", "DMIC1" }, 2777 { "Stereo3 DMIC Mux", "DMIC1", "DMIC1" },
2777 { "Stereo3 DMIC Mux", "DMIC2", "DMIC2" }, 2778 { "Stereo3 DMIC Mux", "DMIC2", "DMIC2" },
2778 { "Stereo3 DMIC Mux", "DMIC3", "DMIC3" }, 2779 { "Stereo3 DMIC Mux", "DMIC3", "DMIC3" },
2779 { "Stereo3 DMIC Mux", "DMIC4", "DMIC4" }, 2780 { "Stereo3 DMIC Mux", "DMIC4", "DMIC4" },
2780 2781
2781 { "Stereo4 DMIC Mux", "DMIC1", "DMIC1" }, 2782 { "Stereo4 DMIC Mux", "DMIC1", "DMIC1" },
2782 { "Stereo4 DMIC Mux", "DMIC2", "DMIC2" }, 2783 { "Stereo4 DMIC Mux", "DMIC2", "DMIC2" },
2783 { "Stereo4 DMIC Mux", "DMIC3", "DMIC3" }, 2784 { "Stereo4 DMIC Mux", "DMIC3", "DMIC3" },
2784 { "Stereo4 DMIC Mux", "DMIC4", "DMIC4" }, 2785 { "Stereo4 DMIC Mux", "DMIC4", "DMIC4" },
2785 2786
2786 { "Mono DMIC L Mux", "DMIC1", "DMIC1" }, 2787 { "Mono DMIC L Mux", "DMIC1", "DMIC1" },
2787 { "Mono DMIC L Mux", "DMIC2", "DMIC2" }, 2788 { "Mono DMIC L Mux", "DMIC2", "DMIC2" },
2788 { "Mono DMIC L Mux", "DMIC3", "DMIC3" }, 2789 { "Mono DMIC L Mux", "DMIC3", "DMIC3" },
2789 { "Mono DMIC L Mux", "DMIC4", "DMIC4" }, 2790 { "Mono DMIC L Mux", "DMIC4", "DMIC4" },
2790 2791
2791 { "Mono DMIC R Mux", "DMIC1", "DMIC1" }, 2792 { "Mono DMIC R Mux", "DMIC1", "DMIC1" },
2792 { "Mono DMIC R Mux", "DMIC2", "DMIC2" }, 2793 { "Mono DMIC R Mux", "DMIC2", "DMIC2" },
2793 { "Mono DMIC R Mux", "DMIC3", "DMIC3" }, 2794 { "Mono DMIC R Mux", "DMIC3", "DMIC3" },
2794 { "Mono DMIC R Mux", "DMIC4", "DMIC4" }, 2795 { "Mono DMIC R Mux", "DMIC4", "DMIC4" },
2795 2796
2796 { "ADC 1_2", NULL, "ADC 1" }, 2797 { "ADC 1_2", NULL, "ADC 1" },
2797 { "ADC 1_2", NULL, "ADC 2" }, 2798 { "ADC 1_2", NULL, "ADC 2" },
2798 2799
2799 { "Stereo1 ADC1 Mux", "DD MIX1", "DD1 MIX" }, 2800 { "Stereo1 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2800 { "Stereo1 ADC1 Mux", "ADC1/2", "ADC 1_2" }, 2801 { "Stereo1 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2801 { "Stereo1 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, 2802 { "Stereo1 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2802 2803
2803 { "Stereo1 ADC2 Mux", "DD MIX1", "DD1 MIX" }, 2804 { "Stereo1 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2804 { "Stereo1 ADC2 Mux", "DMIC", "Stereo1 DMIC Mux" }, 2805 { "Stereo1 ADC2 Mux", "DMIC", "Stereo1 DMIC Mux" },
2805 { "Stereo1 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, 2806 { "Stereo1 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2806 2807
2807 { "Stereo2 ADC1 Mux", "DD MIX1", "DD1 MIX" }, 2808 { "Stereo2 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2808 { "Stereo2 ADC1 Mux", "ADC1/2", "ADC 1_2" }, 2809 { "Stereo2 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2809 { "Stereo2 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, 2810 { "Stereo2 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2810 2811
2811 { "Stereo2 ADC2 Mux", "DD MIX1", "DD1 MIX" }, 2812 { "Stereo2 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2812 { "Stereo2 ADC2 Mux", "DMIC", "Stereo2 DMIC Mux" }, 2813 { "Stereo2 ADC2 Mux", "DMIC", "Stereo2 DMIC Mux" },
2813 { "Stereo2 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, 2814 { "Stereo2 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2814 2815
2815 { "Stereo3 ADC1 Mux", "DD MIX1", "DD1 MIX" }, 2816 { "Stereo3 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2816 { "Stereo3 ADC1 Mux", "ADC1/2", "ADC 1_2" }, 2817 { "Stereo3 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2817 { "Stereo3 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, 2818 { "Stereo3 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2818 2819
2819 { "Stereo3 ADC2 Mux", "DD MIX1", "DD1 MIX" }, 2820 { "Stereo3 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2820 { "Stereo3 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" }, 2821 { "Stereo3 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
2821 { "Stereo3 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, 2822 { "Stereo3 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
2822 2823
2823 { "Stereo4 ADC1 Mux", "DD MIX1", "DD1 MIX" }, 2824 { "Stereo4 ADC1 Mux", "DD MIX1", "DD1 MIX" },
2824 { "Stereo4 ADC1 Mux", "ADC1/2", "ADC 1_2" }, 2825 { "Stereo4 ADC1 Mux", "ADC1/2", "ADC 1_2" },
2825 { "Stereo4 ADC1 Mux", "DD MIX2", "DD2 MIX" }, 2826 { "Stereo4 ADC1 Mux", "DD MIX2", "DD2 MIX" },
2826 2827
2827 { "Stereo4 ADC2 Mux", "DD MIX1", "DD1 MIX" }, 2828 { "Stereo4 ADC2 Mux", "DD MIX1", "DD1 MIX" },
2828 { "Stereo4 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" }, 2829 { "Stereo4 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
2829 { "Stereo4 ADC2 Mux", "DD MIX2", "DD2 MIX" }, 2830 { "Stereo4 ADC2 Mux", "DD MIX2", "DD2 MIX" },
2830 2831
2831 { "Mono ADC2 L Mux", "DD MIX1L", "DD1 MIXL" }, 2832 { "Mono ADC2 L Mux", "DD MIX1L", "DD1 MIXL" },
2832 { "Mono ADC2 L Mux", "DMIC", "Mono DMIC L Mux" }, 2833 { "Mono ADC2 L Mux", "DMIC", "Mono DMIC L Mux" },
2833 { "Mono ADC2 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" }, 2834 { "Mono ADC2 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
2834 2835
2835 { "Mono ADC1 L Mux", "DD MIX1L", "DD1 MIXL" }, 2836 { "Mono ADC1 L Mux", "DD MIX1L", "DD1 MIXL" },
2836 { "Mono ADC1 L Mux", "ADC1", "ADC 1" }, 2837 { "Mono ADC1 L Mux", "ADC1", "ADC 1" },
2837 { "Mono ADC1 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" }, 2838 { "Mono ADC1 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
2838 2839
2839 { "Mono ADC1 R Mux", "DD MIX1R", "DD1 MIXR" }, 2840 { "Mono ADC1 R Mux", "DD MIX1R", "DD1 MIXR" },
2840 { "Mono ADC1 R Mux", "ADC2", "ADC 2" }, 2841 { "Mono ADC1 R Mux", "ADC2", "ADC 2" },
2841 { "Mono ADC1 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" }, 2842 { "Mono ADC1 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
2842 2843
2843 { "Mono ADC2 R Mux", "DD MIX1R", "DD1 MIXR" }, 2844 { "Mono ADC2 R Mux", "DD MIX1R", "DD1 MIXR" },
2844 { "Mono ADC2 R Mux", "DMIC", "Mono DMIC R Mux" }, 2845 { "Mono ADC2 R Mux", "DMIC", "Mono DMIC R Mux" },
2845 { "Mono ADC2 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" }, 2846 { "Mono ADC2 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
2846 2847
2847 { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC1 Mux" }, 2848 { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC1 Mux" },
2848 { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC2 Mux" }, 2849 { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC2 Mux" },
2849 { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC1 Mux" }, 2850 { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC1 Mux" },
2850 { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC2 Mux" }, 2851 { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC2 Mux" },
2851 2852
2852 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" }, 2853 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" },
2853 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" }, 2854 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" },
2854 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, 2855 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
2855 2856
2856 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" }, 2857 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" },
2857 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" }, 2858 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" },
2858 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, 2859 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
2859 2860
2860 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" }, 2861 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" },
2861 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" }, 2862 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" },
2862 2863
2863 { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC1 Mux" }, 2864 { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC1 Mux" },
2864 { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC2 Mux" }, 2865 { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC2 Mux" },
2865 { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC1 Mux" }, 2866 { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC1 Mux" },
2866 { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC2 Mux" }, 2867 { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC2 Mux" },
2867 2868
2868 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" }, 2869 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" },
2869 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" }, 2870 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" },
2870 2871
2871 { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" }, 2872 { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" },
2872 { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" }, 2873 { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" },
2873 2874
2874 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" }, 2875 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" },
2875 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" }, 2876 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" },
2876 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll }, 2877 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
2877 2878
2878 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" }, 2879 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" },
2879 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" }, 2880 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" },
2880 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll }, 2881 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
2881 2882
2882 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXL" }, 2883 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXL" },
2883 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR" }, 2884 { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR" },
2884 2885
2885 { "Sto3 ADC MIXL", "ADC1 Switch", "Stereo3 ADC1 Mux" }, 2886 { "Sto3 ADC MIXL", "ADC1 Switch", "Stereo3 ADC1 Mux" },
2886 { "Sto3 ADC MIXL", "ADC2 Switch", "Stereo3 ADC2 Mux" }, 2887 { "Sto3 ADC MIXL", "ADC2 Switch", "Stereo3 ADC2 Mux" },
2887 { "Sto3 ADC MIXR", "ADC1 Switch", "Stereo3 ADC1 Mux" }, 2888 { "Sto3 ADC MIXR", "ADC1 Switch", "Stereo3 ADC1 Mux" },
2888 { "Sto3 ADC MIXR", "ADC2 Switch", "Stereo3 ADC2 Mux" }, 2889 { "Sto3 ADC MIXR", "ADC2 Switch", "Stereo3 ADC2 Mux" },
2889 2890
2890 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" }, 2891 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" },
2891 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" }, 2892 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" },
2892 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll }, 2893 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
2893 2894
2894 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" }, 2895 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" },
2895 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" }, 2896 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" },
2896 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll }, 2897 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
2897 2898
2898 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXL" }, 2899 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXL" },
2899 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXR" }, 2900 { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXR" },
2900 2901
2901 { "Sto4 ADC MIXL", "ADC1 Switch", "Stereo4 ADC1 Mux" }, 2902 { "Sto4 ADC MIXL", "ADC1 Switch", "Stereo4 ADC1 Mux" },
2902 { "Sto4 ADC MIXL", "ADC2 Switch", "Stereo4 ADC2 Mux" }, 2903 { "Sto4 ADC MIXL", "ADC2 Switch", "Stereo4 ADC2 Mux" },
2903 { "Sto4 ADC MIXR", "ADC1 Switch", "Stereo4 ADC1 Mux" }, 2904 { "Sto4 ADC MIXR", "ADC1 Switch", "Stereo4 ADC1 Mux" },
2904 { "Sto4 ADC MIXR", "ADC2 Switch", "Stereo4 ADC2 Mux" }, 2905 { "Sto4 ADC MIXR", "ADC2 Switch", "Stereo4 ADC2 Mux" },
2905 2906
2906 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" }, 2907 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" },
2907 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" }, 2908 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" },
2908 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll }, 2909 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
2909 2910
2910 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" }, 2911 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" },
2911 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" }, 2912 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" },
2912 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll }, 2913 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
2913 2914
2914 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXL" }, 2915 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXL" },
2915 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXR" }, 2916 { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXR" },
2916 2917
2917 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC1 L Mux" }, 2918 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC1 L Mux" },
2918 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC2 L Mux" }, 2919 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC2 L Mux" },
2919 { "Mono ADC MIXL", NULL, "adc mono left filter" }, 2920 { "Mono ADC MIXL", NULL, "adc mono left filter" },
2920 { "adc mono left filter", NULL, "PLL1", is_sys_clk_from_pll }, 2921 { "adc mono left filter", NULL, "PLL1", is_sys_clk_from_pll },
2921 2922
2922 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC1 R Mux" }, 2923 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC1 R Mux" },
2923 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC2 R Mux" }, 2924 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC2 R Mux" },
2924 { "Mono ADC MIXR", NULL, "adc mono right filter" }, 2925 { "Mono ADC MIXR", NULL, "adc mono right filter" },
2925 { "adc mono right filter", NULL, "PLL1", is_sys_clk_from_pll }, 2926 { "adc mono right filter", NULL, "PLL1", is_sys_clk_from_pll },
2926 2927
2927 { "Mono ADC MIX", NULL, "Mono ADC MIXL" }, 2928 { "Mono ADC MIX", NULL, "Mono ADC MIXL" },
2928 { "Mono ADC MIX", NULL, "Mono ADC MIXR" }, 2929 { "Mono ADC MIX", NULL, "Mono ADC MIXR" },
2929 2930
2930 { "VAD ADC Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" }, 2931 { "VAD ADC Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
2931 { "VAD ADC Mux", "MONO ADC MIX L", "Mono ADC MIXL" }, 2932 { "VAD ADC Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
2932 { "VAD ADC Mux", "MONO ADC MIX R", "Mono ADC MIXR" }, 2933 { "VAD ADC Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
2933 { "VAD ADC Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" }, 2934 { "VAD ADC Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
2934 { "VAD ADC Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" }, 2935 { "VAD ADC Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
2935 2936
2936 { "IF1 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, 2937 { "IF1 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
2937 { "IF1 ADC1 Mux", "OB01", "OB01 Bypass Mux" }, 2938 { "IF1 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
2938 { "IF1 ADC1 Mux", "VAD ADC", "VAD ADC Mux" }, 2939 { "IF1 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
2939 2940
2940 { "IF1 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, 2941 { "IF1 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
2941 { "IF1 ADC2 Mux", "OB23", "OB23 Bypass Mux" }, 2942 { "IF1 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
2942 2943
2943 { "IF1 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, 2944 { "IF1 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
2944 { "IF1 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" }, 2945 { "IF1 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
2945 { "IF1 ADC3 Mux", "OB45", "OB45" }, 2946 { "IF1 ADC3 Mux", "OB45", "OB45" },
2946 2947
2947 { "IF1 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, 2948 { "IF1 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
2948 { "IF1 ADC4 Mux", "OB67", "OB67" }, 2949 { "IF1 ADC4 Mux", "OB67", "OB67" },
2949 { "IF1 ADC4 Mux", "OB01", "OB01 Bypass Mux" }, 2950 { "IF1 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
2950 2951
2951 { "IF1 ADC1 Swap Mux", "L/R", "IF1 ADC1 Mux" }, 2952 { "IF1 ADC1 Swap Mux", "L/R", "IF1 ADC1 Mux" },
2952 { "IF1 ADC1 Swap Mux", "R/L", "IF1 ADC1 Mux" }, 2953 { "IF1 ADC1 Swap Mux", "R/L", "IF1 ADC1 Mux" },
2953 { "IF1 ADC1 Swap Mux", "L/L", "IF1 ADC1 Mux" }, 2954 { "IF1 ADC1 Swap Mux", "L/L", "IF1 ADC1 Mux" },
2954 { "IF1 ADC1 Swap Mux", "R/R", "IF1 ADC1 Mux" }, 2955 { "IF1 ADC1 Swap Mux", "R/R", "IF1 ADC1 Mux" },
2955 2956
2956 { "IF1 ADC2 Swap Mux", "L/R", "IF1 ADC2 Mux" }, 2957 { "IF1 ADC2 Swap Mux", "L/R", "IF1 ADC2 Mux" },
2957 { "IF1 ADC2 Swap Mux", "R/L", "IF1 ADC2 Mux" }, 2958 { "IF1 ADC2 Swap Mux", "R/L", "IF1 ADC2 Mux" },
2958 { "IF1 ADC2 Swap Mux", "L/L", "IF1 ADC2 Mux" }, 2959 { "IF1 ADC2 Swap Mux", "L/L", "IF1 ADC2 Mux" },
2959 { "IF1 ADC2 Swap Mux", "R/R", "IF1 ADC2 Mux" }, 2960 { "IF1 ADC2 Swap Mux", "R/R", "IF1 ADC2 Mux" },
2960 2961
2961 { "IF1 ADC3 Swap Mux", "L/R", "IF1 ADC3 Mux" }, 2962 { "IF1 ADC3 Swap Mux", "L/R", "IF1 ADC3 Mux" },
2962 { "IF1 ADC3 Swap Mux", "R/L", "IF1 ADC3 Mux" }, 2963 { "IF1 ADC3 Swap Mux", "R/L", "IF1 ADC3 Mux" },
2963 { "IF1 ADC3 Swap Mux", "L/L", "IF1 ADC3 Mux" }, 2964 { "IF1 ADC3 Swap Mux", "L/L", "IF1 ADC3 Mux" },
2964 { "IF1 ADC3 Swap Mux", "R/R", "IF1 ADC3 Mux" }, 2965 { "IF1 ADC3 Swap Mux", "R/R", "IF1 ADC3 Mux" },
2965 2966
2966 { "IF1 ADC4 Swap Mux", "L/R", "IF1 ADC4 Mux" }, 2967 { "IF1 ADC4 Swap Mux", "L/R", "IF1 ADC4 Mux" },
2967 { "IF1 ADC4 Swap Mux", "R/L", "IF1 ADC4 Mux" }, 2968 { "IF1 ADC4 Swap Mux", "R/L", "IF1 ADC4 Mux" },
2968 { "IF1 ADC4 Swap Mux", "L/L", "IF1 ADC4 Mux" }, 2969 { "IF1 ADC4 Swap Mux", "L/L", "IF1 ADC4 Mux" },
2969 { "IF1 ADC4 Swap Mux", "R/R", "IF1 ADC4 Mux" }, 2970 { "IF1 ADC4 Swap Mux", "R/R", "IF1 ADC4 Mux" },
2970 2971
2971 { "IF1 ADC", NULL, "IF1 ADC1 Swap Mux" }, 2972 { "IF1 ADC", NULL, "IF1 ADC1 Swap Mux" },
2972 { "IF1 ADC", NULL, "IF1 ADC2 Swap Mux" }, 2973 { "IF1 ADC", NULL, "IF1 ADC2 Swap Mux" },
2973 { "IF1 ADC", NULL, "IF1 ADC3 Swap Mux" }, 2974 { "IF1 ADC", NULL, "IF1 ADC3 Swap Mux" },
2974 { "IF1 ADC", NULL, "IF1 ADC4 Swap Mux" }, 2975 { "IF1 ADC", NULL, "IF1 ADC4 Swap Mux" },
2975 2976
2976 { "IF1 ADC TDM Swap Mux", "1/2/3/4", "IF1 ADC" }, 2977 { "IF1 ADC TDM Swap Mux", "1/2/3/4", "IF1 ADC" },
2977 { "IF1 ADC TDM Swap Mux", "2/1/3/4", "IF1 ADC" }, 2978 { "IF1 ADC TDM Swap Mux", "2/1/3/4", "IF1 ADC" },
2978 { "IF1 ADC TDM Swap Mux", "2/3/1/4", "IF1 ADC" }, 2979 { "IF1 ADC TDM Swap Mux", "2/3/1/4", "IF1 ADC" },
2979 { "IF1 ADC TDM Swap Mux", "4/1/2/3", "IF1 ADC" }, 2980 { "IF1 ADC TDM Swap Mux", "4/1/2/3", "IF1 ADC" },
2980 { "IF1 ADC TDM Swap Mux", "1/3/2/4", "IF1 ADC" }, 2981 { "IF1 ADC TDM Swap Mux", "1/3/2/4", "IF1 ADC" },
2981 { "IF1 ADC TDM Swap Mux", "1/4/2/3", "IF1 ADC" }, 2982 { "IF1 ADC TDM Swap Mux", "1/4/2/3", "IF1 ADC" },
2982 { "IF1 ADC TDM Swap Mux", "3/1/2/4", "IF1 ADC" }, 2983 { "IF1 ADC TDM Swap Mux", "3/1/2/4", "IF1 ADC" },
2983 { "IF1 ADC TDM Swap Mux", "3/4/1/2", "IF1 ADC" }, 2984 { "IF1 ADC TDM Swap Mux", "3/4/1/2", "IF1 ADC" },
2984 2985
2985 { "AIF1TX", NULL, "I2S1" }, 2986 { "AIF1TX", NULL, "I2S1" },
2986 { "AIF1TX", NULL, "IF1 ADC TDM Swap Mux" }, 2987 { "AIF1TX", NULL, "IF1 ADC TDM Swap Mux" },
2987 2988
2988 { "IF2 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, 2989 { "IF2 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
2989 { "IF2 ADC1 Mux", "OB01", "OB01 Bypass Mux" }, 2990 { "IF2 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
2990 { "IF2 ADC1 Mux", "VAD ADC", "VAD ADC Mux" }, 2991 { "IF2 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
2991 2992
2992 { "IF2 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, 2993 { "IF2 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
2993 { "IF2 ADC2 Mux", "OB23", "OB23 Bypass Mux" }, 2994 { "IF2 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
2994 2995
2995 { "IF2 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, 2996 { "IF2 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
2996 { "IF2 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" }, 2997 { "IF2 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
2997 { "IF2 ADC3 Mux", "OB45", "OB45" }, 2998 { "IF2 ADC3 Mux", "OB45", "OB45" },
2998 2999
2999 { "IF2 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, 3000 { "IF2 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3000 { "IF2 ADC4 Mux", "OB67", "OB67" }, 3001 { "IF2 ADC4 Mux", "OB67", "OB67" },
3001 { "IF2 ADC4 Mux", "OB01", "OB01 Bypass Mux" }, 3002 { "IF2 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3002 3003
3003 { "IF2 ADC1 Swap Mux", "L/R", "IF2 ADC1 Mux" }, 3004 { "IF2 ADC1 Swap Mux", "L/R", "IF2 ADC1 Mux" },
3004 { "IF2 ADC1 Swap Mux", "R/L", "IF2 ADC1 Mux" }, 3005 { "IF2 ADC1 Swap Mux", "R/L", "IF2 ADC1 Mux" },
3005 { "IF2 ADC1 Swap Mux", "L/L", "IF2 ADC1 Mux" }, 3006 { "IF2 ADC1 Swap Mux", "L/L", "IF2 ADC1 Mux" },
3006 { "IF2 ADC1 Swap Mux", "R/R", "IF2 ADC1 Mux" }, 3007 { "IF2 ADC1 Swap Mux", "R/R", "IF2 ADC1 Mux" },
3007 3008
3008 { "IF2 ADC2 Swap Mux", "L/R", "IF2 ADC2 Mux" }, 3009 { "IF2 ADC2 Swap Mux", "L/R", "IF2 ADC2 Mux" },
3009 { "IF2 ADC2 Swap Mux", "R/L", "IF2 ADC2 Mux" }, 3010 { "IF2 ADC2 Swap Mux", "R/L", "IF2 ADC2 Mux" },
3010 { "IF2 ADC2 Swap Mux", "L/L", "IF2 ADC2 Mux" }, 3011 { "IF2 ADC2 Swap Mux", "L/L", "IF2 ADC2 Mux" },
3011 { "IF2 ADC2 Swap Mux", "R/R", "IF2 ADC2 Mux" }, 3012 { "IF2 ADC2 Swap Mux", "R/R", "IF2 ADC2 Mux" },
3012 3013
3013 { "IF2 ADC3 Swap Mux", "L/R", "IF2 ADC3 Mux" }, 3014 { "IF2 ADC3 Swap Mux", "L/R", "IF2 ADC3 Mux" },
3014 { "IF2 ADC3 Swap Mux", "R/L", "IF2 ADC3 Mux" }, 3015 { "IF2 ADC3 Swap Mux", "R/L", "IF2 ADC3 Mux" },
3015 { "IF2 ADC3 Swap Mux", "L/L", "IF2 ADC3 Mux" }, 3016 { "IF2 ADC3 Swap Mux", "L/L", "IF2 ADC3 Mux" },
3016 { "IF2 ADC3 Swap Mux", "R/R", "IF2 ADC3 Mux" }, 3017 { "IF2 ADC3 Swap Mux", "R/R", "IF2 ADC3 Mux" },
3017 3018
3018 { "IF2 ADC4 Swap Mux", "L/R", "IF2 ADC4 Mux" }, 3019 { "IF2 ADC4 Swap Mux", "L/R", "IF2 ADC4 Mux" },
3019 { "IF2 ADC4 Swap Mux", "R/L", "IF2 ADC4 Mux" }, 3020 { "IF2 ADC4 Swap Mux", "R/L", "IF2 ADC4 Mux" },
3020 { "IF2 ADC4 Swap Mux", "L/L", "IF2 ADC4 Mux" }, 3021 { "IF2 ADC4 Swap Mux", "L/L", "IF2 ADC4 Mux" },
3021 { "IF2 ADC4 Swap Mux", "R/R", "IF2 ADC4 Mux" }, 3022 { "IF2 ADC4 Swap Mux", "R/R", "IF2 ADC4 Mux" },
3022 3023
3023 { "IF2 ADC", NULL, "IF2 ADC1 Swap Mux" }, 3024 { "IF2 ADC", NULL, "IF2 ADC1 Swap Mux" },
3024 { "IF2 ADC", NULL, "IF2 ADC2 Swap Mux" }, 3025 { "IF2 ADC", NULL, "IF2 ADC2 Swap Mux" },
3025 { "IF2 ADC", NULL, "IF2 ADC3 Swap Mux" }, 3026 { "IF2 ADC", NULL, "IF2 ADC3 Swap Mux" },
3026 { "IF2 ADC", NULL, "IF2 ADC4 Swap Mux" }, 3027 { "IF2 ADC", NULL, "IF2 ADC4 Swap Mux" },
3027 3028
3028 { "IF2 ADC TDM Swap Mux", "1/2/3/4", "IF2 ADC" }, 3029 { "IF2 ADC TDM Swap Mux", "1/2/3/4", "IF2 ADC" },
3029 { "IF2 ADC TDM Swap Mux", "2/1/3/4", "IF2 ADC" }, 3030 { "IF2 ADC TDM Swap Mux", "2/1/3/4", "IF2 ADC" },
3030 { "IF2 ADC TDM Swap Mux", "3/1/2/4", "IF2 ADC" }, 3031 { "IF2 ADC TDM Swap Mux", "3/1/2/4", "IF2 ADC" },
3031 { "IF2 ADC TDM Swap Mux", "4/1/2/3", "IF2 ADC" }, 3032 { "IF2 ADC TDM Swap Mux", "4/1/2/3", "IF2 ADC" },
3032 { "IF2 ADC TDM Swap Mux", "1/3/2/4", "IF2 ADC" }, 3033 { "IF2 ADC TDM Swap Mux", "1/3/2/4", "IF2 ADC" },
3033 { "IF2 ADC TDM Swap Mux", "1/4/2/3", "IF2 ADC" }, 3034 { "IF2 ADC TDM Swap Mux", "1/4/2/3", "IF2 ADC" },
3034 { "IF2 ADC TDM Swap Mux", "2/3/1/4", "IF2 ADC" }, 3035 { "IF2 ADC TDM Swap Mux", "2/3/1/4", "IF2 ADC" },
3035 { "IF2 ADC TDM Swap Mux", "3/4/1/2", "IF2 ADC" }, 3036 { "IF2 ADC TDM Swap Mux", "3/4/1/2", "IF2 ADC" },
3036 3037
3037 { "AIF2TX", NULL, "I2S2" }, 3038 { "AIF2TX", NULL, "I2S2" },
3038 { "AIF2TX", NULL, "IF2 ADC TDM Swap Mux" }, 3039 { "AIF2TX", NULL, "IF2 ADC TDM Swap Mux" },
3039 3040
3040 { "IF3 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, 3041 { "IF3 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3041 { "IF3 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, 3042 { "IF3 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3042 { "IF3 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, 3043 { "IF3 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3043 { "IF3 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, 3044 { "IF3 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3044 { "IF3 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" }, 3045 { "IF3 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
3045 { "IF3 ADC Mux", "OB01", "OB01 Bypass Mux" }, 3046 { "IF3 ADC Mux", "OB01", "OB01 Bypass Mux" },
3046 { "IF3 ADC Mux", "OB23", "OB23 Bypass Mux" }, 3047 { "IF3 ADC Mux", "OB23", "OB23 Bypass Mux" },
3047 { "IF3 ADC Mux", "VAD ADC", "VAD ADC Mux" }, 3048 { "IF3 ADC Mux", "VAD ADC", "VAD ADC Mux" },
3048 3049
3049 { "AIF3TX", NULL, "I2S3" }, 3050 { "AIF3TX", NULL, "I2S3" },
3050 { "AIF3TX", NULL, "IF3 ADC Mux" }, 3051 { "AIF3TX", NULL, "IF3 ADC Mux" },
3051 3052
3052 { "IF4 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, 3053 { "IF4 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3053 { "IF4 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, 3054 { "IF4 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3054 { "IF4 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, 3055 { "IF4 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3055 { "IF4 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, 3056 { "IF4 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3056 { "IF4 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" }, 3057 { "IF4 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
3057 { "IF4 ADC Mux", "OB01", "OB01 Bypass Mux" }, 3058 { "IF4 ADC Mux", "OB01", "OB01 Bypass Mux" },
3058 { "IF4 ADC Mux", "OB23", "OB23 Bypass Mux" }, 3059 { "IF4 ADC Mux", "OB23", "OB23 Bypass Mux" },
3059 { "IF4 ADC Mux", "VAD ADC", "VAD ADC Mux" }, 3060 { "IF4 ADC Mux", "VAD ADC", "VAD ADC Mux" },
3060 3061
3061 { "AIF4TX", NULL, "I2S4" }, 3062 { "AIF4TX", NULL, "I2S4" },
3062 { "AIF4TX", NULL, "IF4 ADC Mux" }, 3063 { "AIF4TX", NULL, "IF4 ADC Mux" },
3063 3064
3064 { "SLB ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, 3065 { "SLB ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3065 { "SLB ADC1 Mux", "OB01", "OB01 Bypass Mux" }, 3066 { "SLB ADC1 Mux", "OB01", "OB01 Bypass Mux" },
3066 { "SLB ADC1 Mux", "VAD ADC", "VAD ADC Mux" }, 3067 { "SLB ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
3067 3068
3068 { "SLB ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, 3069 { "SLB ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3069 { "SLB ADC2 Mux", "OB23", "OB23 Bypass Mux" }, 3070 { "SLB ADC2 Mux", "OB23", "OB23 Bypass Mux" },
3070 3071
3071 { "SLB ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, 3072 { "SLB ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3072 { "SLB ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" }, 3073 { "SLB ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
3073 { "SLB ADC3 Mux", "OB45", "OB45" }, 3074 { "SLB ADC3 Mux", "OB45", "OB45" },
3074 3075
3075 { "SLB ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, 3076 { "SLB ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
3076 { "SLB ADC4 Mux", "OB67", "OB67" }, 3077 { "SLB ADC4 Mux", "OB67", "OB67" },
3077 { "SLB ADC4 Mux", "OB01", "OB01 Bypass Mux" }, 3078 { "SLB ADC4 Mux", "OB01", "OB01 Bypass Mux" },
3078 3079
3079 { "SLBTX", NULL, "SLB" }, 3080 { "SLBTX", NULL, "SLB" },
3080 { "SLBTX", NULL, "SLB ADC1 Mux" }, 3081 { "SLBTX", NULL, "SLB ADC1 Mux" },
3081 { "SLBTX", NULL, "SLB ADC2 Mux" }, 3082 { "SLBTX", NULL, "SLB ADC2 Mux" },
3082 { "SLBTX", NULL, "SLB ADC3 Mux" }, 3083 { "SLBTX", NULL, "SLB ADC3 Mux" },
3083 { "SLBTX", NULL, "SLB ADC4 Mux" }, 3084 { "SLBTX", NULL, "SLB ADC4 Mux" },
3084 3085
3085 { "IB01 Mux", "IF1 DAC 01", "IF1 DAC01" }, 3086 { "IB01 Mux", "IF1 DAC 01", "IF1 DAC01" },
3086 { "IB01 Mux", "IF2 DAC 01", "IF2 DAC01" }, 3087 { "IB01 Mux", "IF2 DAC 01", "IF2 DAC01" },
3087 { "IB01 Mux", "SLB DAC 01", "SLB DAC01" }, 3088 { "IB01 Mux", "SLB DAC 01", "SLB DAC01" },
3088 { "IB01 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, 3089 { "IB01 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3089 { "IB01 Mux", "VAD ADC/DAC1 FS", "DAC1 FS" }, 3090 { "IB01 Mux", "VAD ADC/DAC1 FS", "DAC1 FS" },
3090 3091
3091 { "IB01 Bypass Mux", "Bypass", "IB01 Mux" }, 3092 { "IB01 Bypass Mux", "Bypass", "IB01 Mux" },
3092 { "IB01 Bypass Mux", "Pass SRC", "IB01 Mux" }, 3093 { "IB01 Bypass Mux", "Pass SRC", "IB01 Mux" },
3093 3094
3094 { "IB23 Mux", "IF1 DAC 23", "IF1 DAC23" }, 3095 { "IB23 Mux", "IF1 DAC 23", "IF1 DAC23" },
3095 { "IB23 Mux", "IF2 DAC 23", "IF2 DAC23" }, 3096 { "IB23 Mux", "IF2 DAC 23", "IF2 DAC23" },
3096 { "IB23 Mux", "SLB DAC 23", "SLB DAC23" }, 3097 { "IB23 Mux", "SLB DAC 23", "SLB DAC23" },
3097 { "IB23 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, 3098 { "IB23 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3098 { "IB23 Mux", "DAC1 FS", "DAC1 FS" }, 3099 { "IB23 Mux", "DAC1 FS", "DAC1 FS" },
3099 { "IB23 Mux", "IF4 DAC", "IF4 DAC" }, 3100 { "IB23 Mux", "IF4 DAC", "IF4 DAC" },
3100 3101
3101 { "IB23 Bypass Mux", "Bypass", "IB23 Mux" }, 3102 { "IB23 Bypass Mux", "Bypass", "IB23 Mux" },
3102 { "IB23 Bypass Mux", "Pass SRC", "IB23 Mux" }, 3103 { "IB23 Bypass Mux", "Pass SRC", "IB23 Mux" },
3103 3104
3104 { "IB45 Mux", "IF1 DAC 45", "IF1 DAC45" }, 3105 { "IB45 Mux", "IF1 DAC 45", "IF1 DAC45" },
3105 { "IB45 Mux", "IF2 DAC 45", "IF2 DAC45" }, 3106 { "IB45 Mux", "IF2 DAC 45", "IF2 DAC45" },
3106 { "IB45 Mux", "SLB DAC 45", "SLB DAC45" }, 3107 { "IB45 Mux", "SLB DAC 45", "SLB DAC45" },
3107 { "IB45 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, 3108 { "IB45 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
3108 { "IB45 Mux", "IF3 DAC", "IF3 DAC" }, 3109 { "IB45 Mux", "IF3 DAC", "IF3 DAC" },
3109 3110
3110 { "IB45 Bypass Mux", "Bypass", "IB45 Mux" }, 3111 { "IB45 Bypass Mux", "Bypass", "IB45 Mux" },
3111 { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" }, 3112 { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" },
3112 3113
3113 { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6" }, 3114 { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6" },
3114 { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6" }, 3115 { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6" },
3115 { "IB6 Mux", "SLB DAC 6", "SLB DAC6" }, 3116 { "IB6 Mux", "SLB DAC 6", "SLB DAC6" },
3116 { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" }, 3117 { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3117 { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" }, 3118 { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" },
3118 { "IB6 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" }, 3119 { "IB6 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3119 { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" }, 3120 { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3120 { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" }, 3121 { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3121 3122
3122 { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7" }, 3123 { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7" },
3123 { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7" }, 3124 { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7" },
3124 { "IB7 Mux", "SLB DAC 7", "SLB DAC7" }, 3125 { "IB7 Mux", "SLB DAC 7", "SLB DAC7" },
3125 { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" }, 3126 { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3126 { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" }, 3127 { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" },
3127 { "IB7 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" }, 3128 { "IB7 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
3128 { "IB7 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" }, 3129 { "IB7 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
3129 { "IB7 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" }, 3130 { "IB7 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
3130 3131
3131 { "IB8 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" }, 3132 { "IB8 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
3132 { "IB8 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" }, 3133 { "IB8 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3133 { "IB8 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" }, 3134 { "IB8 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3134 { "IB8 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" }, 3135 { "IB8 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3135 { "IB8 Mux", "MONO ADC MIX L", "Mono ADC MIXL" }, 3136 { "IB8 Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
3136 { "IB8 Mux", "DACL1 FS", "DAC1 MIXL" }, 3137 { "IB8 Mux", "DACL1 FS", "DAC1 MIXL" },
3137 3138
3138 { "IB9 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" }, 3139 { "IB9 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
3139 { "IB9 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" }, 3140 { "IB9 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
3140 { "IB9 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" }, 3141 { "IB9 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
3141 { "IB9 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" }, 3142 { "IB9 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3142 { "IB9 Mux", "MONO ADC MIX R", "Mono ADC MIXR" }, 3143 { "IB9 Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
3143 { "IB9 Mux", "DACR1 FS", "DAC1 MIXR" }, 3144 { "IB9 Mux", "DACR1 FS", "DAC1 MIXR" },
3144 { "IB9 Mux", "DAC1 FS", "DAC1 FS" }, 3145 { "IB9 Mux", "DAC1 FS", "DAC1 FS" },
3145 3146
3146 { "OB01 MIX", "IB01 Switch", "IB01 Bypass Mux" }, 3147 { "OB01 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3147 { "OB01 MIX", "IB23 Switch", "IB23 Bypass Mux" }, 3148 { "OB01 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3148 { "OB01 MIX", "IB45 Switch", "IB45 Bypass Mux" }, 3149 { "OB01 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3149 { "OB01 MIX", "IB6 Switch", "IB6 Mux" }, 3150 { "OB01 MIX", "IB6 Switch", "IB6 Mux" },
3150 { "OB01 MIX", "IB7 Switch", "IB7 Mux" }, 3151 { "OB01 MIX", "IB7 Switch", "IB7 Mux" },
3151 { "OB01 MIX", "IB8 Switch", "IB8 Mux" }, 3152 { "OB01 MIX", "IB8 Switch", "IB8 Mux" },
3152 { "OB01 MIX", "IB9 Switch", "IB9 Mux" }, 3153 { "OB01 MIX", "IB9 Switch", "IB9 Mux" },
3153 3154
3154 { "OB23 MIX", "IB01 Switch", "IB01 Bypass Mux" }, 3155 { "OB23 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3155 { "OB23 MIX", "IB23 Switch", "IB23 Bypass Mux" }, 3156 { "OB23 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3156 { "OB23 MIX", "IB45 Switch", "IB45 Bypass Mux" }, 3157 { "OB23 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3157 { "OB23 MIX", "IB6 Switch", "IB6 Mux" }, 3158 { "OB23 MIX", "IB6 Switch", "IB6 Mux" },
3158 { "OB23 MIX", "IB7 Switch", "IB7 Mux" }, 3159 { "OB23 MIX", "IB7 Switch", "IB7 Mux" },
3159 { "OB23 MIX", "IB8 Switch", "IB8 Mux" }, 3160 { "OB23 MIX", "IB8 Switch", "IB8 Mux" },
3160 { "OB23 MIX", "IB9 Switch", "IB9 Mux" }, 3161 { "OB23 MIX", "IB9 Switch", "IB9 Mux" },
3161 3162
3162 { "OB4 MIX", "IB01 Switch", "IB01 Bypass Mux" }, 3163 { "OB4 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3163 { "OB4 MIX", "IB23 Switch", "IB23 Bypass Mux" }, 3164 { "OB4 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3164 { "OB4 MIX", "IB45 Switch", "IB45 Bypass Mux" }, 3165 { "OB4 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3165 { "OB4 MIX", "IB6 Switch", "IB6 Mux" }, 3166 { "OB4 MIX", "IB6 Switch", "IB6 Mux" },
3166 { "OB4 MIX", "IB7 Switch", "IB7 Mux" }, 3167 { "OB4 MIX", "IB7 Switch", "IB7 Mux" },
3167 { "OB4 MIX", "IB8 Switch", "IB8 Mux" }, 3168 { "OB4 MIX", "IB8 Switch", "IB8 Mux" },
3168 { "OB4 MIX", "IB9 Switch", "IB9 Mux" }, 3169 { "OB4 MIX", "IB9 Switch", "IB9 Mux" },
3169 3170
3170 { "OB5 MIX", "IB01 Switch", "IB01 Bypass Mux" }, 3171 { "OB5 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3171 { "OB5 MIX", "IB23 Switch", "IB23 Bypass Mux" }, 3172 { "OB5 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3172 { "OB5 MIX", "IB45 Switch", "IB45 Bypass Mux" }, 3173 { "OB5 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3173 { "OB5 MIX", "IB6 Switch", "IB6 Mux" }, 3174 { "OB5 MIX", "IB6 Switch", "IB6 Mux" },
3174 { "OB5 MIX", "IB7 Switch", "IB7 Mux" }, 3175 { "OB5 MIX", "IB7 Switch", "IB7 Mux" },
3175 { "OB5 MIX", "IB8 Switch", "IB8 Mux" }, 3176 { "OB5 MIX", "IB8 Switch", "IB8 Mux" },
3176 { "OB5 MIX", "IB9 Switch", "IB9 Mux" }, 3177 { "OB5 MIX", "IB9 Switch", "IB9 Mux" },
3177 3178
3178 { "OB6 MIX", "IB01 Switch", "IB01 Bypass Mux" }, 3179 { "OB6 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3179 { "OB6 MIX", "IB23 Switch", "IB23 Bypass Mux" }, 3180 { "OB6 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3180 { "OB6 MIX", "IB45 Switch", "IB45 Bypass Mux" }, 3181 { "OB6 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3181 { "OB6 MIX", "IB6 Switch", "IB6 Mux" }, 3182 { "OB6 MIX", "IB6 Switch", "IB6 Mux" },
3182 { "OB6 MIX", "IB7 Switch", "IB7 Mux" }, 3183 { "OB6 MIX", "IB7 Switch", "IB7 Mux" },
3183 { "OB6 MIX", "IB8 Switch", "IB8 Mux" }, 3184 { "OB6 MIX", "IB8 Switch", "IB8 Mux" },
3184 { "OB6 MIX", "IB9 Switch", "IB9 Mux" }, 3185 { "OB6 MIX", "IB9 Switch", "IB9 Mux" },
3185 3186
3186 { "OB7 MIX", "IB01 Switch", "IB01 Bypass Mux" }, 3187 { "OB7 MIX", "IB01 Switch", "IB01 Bypass Mux" },
3187 { "OB7 MIX", "IB23 Switch", "IB23 Bypass Mux" }, 3188 { "OB7 MIX", "IB23 Switch", "IB23 Bypass Mux" },
3188 { "OB7 MIX", "IB45 Switch", "IB45 Bypass Mux" }, 3189 { "OB7 MIX", "IB45 Switch", "IB45 Bypass Mux" },
3189 { "OB7 MIX", "IB6 Switch", "IB6 Mux" }, 3190 { "OB7 MIX", "IB6 Switch", "IB6 Mux" },
3190 { "OB7 MIX", "IB7 Switch", "IB7 Mux" }, 3191 { "OB7 MIX", "IB7 Switch", "IB7 Mux" },
3191 { "OB7 MIX", "IB8 Switch", "IB8 Mux" }, 3192 { "OB7 MIX", "IB8 Switch", "IB8 Mux" },
3192 { "OB7 MIX", "IB9 Switch", "IB9 Mux" }, 3193 { "OB7 MIX", "IB9 Switch", "IB9 Mux" },
3193 3194
3194 { "OB01 Bypass Mux", "Bypass", "OB01 MIX" }, 3195 { "OB01 Bypass Mux", "Bypass", "OB01 MIX" },
3195 { "OB01 Bypass Mux", "Pass SRC", "OB01 MIX" }, 3196 { "OB01 Bypass Mux", "Pass SRC", "OB01 MIX" },
3196 { "OB23 Bypass Mux", "Bypass", "OB23 MIX" }, 3197 { "OB23 Bypass Mux", "Bypass", "OB23 MIX" },
3197 { "OB23 Bypass Mux", "Pass SRC", "OB23 MIX" }, 3198 { "OB23 Bypass Mux", "Pass SRC", "OB23 MIX" },
3198 3199
3199 { "OutBound2", NULL, "OB23 Bypass Mux" }, 3200 { "OutBound2", NULL, "OB23 Bypass Mux" },
3200 { "OutBound3", NULL, "OB23 Bypass Mux" }, 3201 { "OutBound3", NULL, "OB23 Bypass Mux" },
3201 { "OutBound4", NULL, "OB4 MIX" }, 3202 { "OutBound4", NULL, "OB4 MIX" },
3202 { "OutBound5", NULL, "OB5 MIX" }, 3203 { "OutBound5", NULL, "OB5 MIX" },
3203 { "OutBound6", NULL, "OB6 MIX" }, 3204 { "OutBound6", NULL, "OB6 MIX" },
3204 { "OutBound7", NULL, "OB7 MIX" }, 3205 { "OutBound7", NULL, "OB7 MIX" },
3205 3206
3206 { "OB45", NULL, "OutBound4" }, 3207 { "OB45", NULL, "OutBound4" },
3207 { "OB45", NULL, "OutBound5" }, 3208 { "OB45", NULL, "OutBound5" },
3208 { "OB67", NULL, "OutBound6" }, 3209 { "OB67", NULL, "OutBound6" },
3209 { "OB67", NULL, "OutBound7" }, 3210 { "OB67", NULL, "OutBound7" },
3210 3211
3211 { "IF1 DAC0", NULL, "AIF1RX" }, 3212 { "IF1 DAC0", NULL, "AIF1RX" },
3212 { "IF1 DAC1", NULL, "AIF1RX" }, 3213 { "IF1 DAC1", NULL, "AIF1RX" },
3213 { "IF1 DAC2", NULL, "AIF1RX" }, 3214 { "IF1 DAC2", NULL, "AIF1RX" },
3214 { "IF1 DAC3", NULL, "AIF1RX" }, 3215 { "IF1 DAC3", NULL, "AIF1RX" },
3215 { "IF1 DAC4", NULL, "AIF1RX" }, 3216 { "IF1 DAC4", NULL, "AIF1RX" },
3216 { "IF1 DAC5", NULL, "AIF1RX" }, 3217 { "IF1 DAC5", NULL, "AIF1RX" },
3217 { "IF1 DAC6", NULL, "AIF1RX" }, 3218 { "IF1 DAC6", NULL, "AIF1RX" },
3218 { "IF1 DAC7", NULL, "AIF1RX" }, 3219 { "IF1 DAC7", NULL, "AIF1RX" },
3219 { "IF1 DAC0", NULL, "I2S1" }, 3220 { "IF1 DAC0", NULL, "I2S1" },
3220 { "IF1 DAC1", NULL, "I2S1" }, 3221 { "IF1 DAC1", NULL, "I2S1" },
3221 { "IF1 DAC2", NULL, "I2S1" }, 3222 { "IF1 DAC2", NULL, "I2S1" },
3222 { "IF1 DAC3", NULL, "I2S1" }, 3223 { "IF1 DAC3", NULL, "I2S1" },
3223 { "IF1 DAC4", NULL, "I2S1" }, 3224 { "IF1 DAC4", NULL, "I2S1" },
3224 { "IF1 DAC5", NULL, "I2S1" }, 3225 { "IF1 DAC5", NULL, "I2S1" },
3225 { "IF1 DAC6", NULL, "I2S1" }, 3226 { "IF1 DAC6", NULL, "I2S1" },
3226 { "IF1 DAC7", NULL, "I2S1" }, 3227 { "IF1 DAC7", NULL, "I2S1" },
3227 3228
3228 { "IF1 DAC0 Mux", "Slot0", "IF1 DAC0" }, 3229 { "IF1 DAC0 Mux", "Slot0", "IF1 DAC0" },
3229 { "IF1 DAC0 Mux", "Slot1", "IF1 DAC1" }, 3230 { "IF1 DAC0 Mux", "Slot1", "IF1 DAC1" },
3230 { "IF1 DAC0 Mux", "Slot2", "IF1 DAC2" }, 3231 { "IF1 DAC0 Mux", "Slot2", "IF1 DAC2" },
3231 { "IF1 DAC0 Mux", "Slot3", "IF1 DAC3" }, 3232 { "IF1 DAC0 Mux", "Slot3", "IF1 DAC3" },
3232 { "IF1 DAC0 Mux", "Slot4", "IF1 DAC4" }, 3233 { "IF1 DAC0 Mux", "Slot4", "IF1 DAC4" },
3233 { "IF1 DAC0 Mux", "Slot5", "IF1 DAC5" }, 3234 { "IF1 DAC0 Mux", "Slot5", "IF1 DAC5" },
3234 { "IF1 DAC0 Mux", "Slot6", "IF1 DAC6" }, 3235 { "IF1 DAC0 Mux", "Slot6", "IF1 DAC6" },
3235 { "IF1 DAC0 Mux", "Slot7", "IF1 DAC7" }, 3236 { "IF1 DAC0 Mux", "Slot7", "IF1 DAC7" },
3236 3237
3237 { "IF1 DAC1 Mux", "Slot0", "IF1 DAC0" }, 3238 { "IF1 DAC1 Mux", "Slot0", "IF1 DAC0" },
3238 { "IF1 DAC1 Mux", "Slot1", "IF1 DAC1" }, 3239 { "IF1 DAC1 Mux", "Slot1", "IF1 DAC1" },
3239 { "IF1 DAC1 Mux", "Slot2", "IF1 DAC2" }, 3240 { "IF1 DAC1 Mux", "Slot2", "IF1 DAC2" },
3240 { "IF1 DAC1 Mux", "Slot3", "IF1 DAC3" }, 3241 { "IF1 DAC1 Mux", "Slot3", "IF1 DAC3" },
3241 { "IF1 DAC1 Mux", "Slot4", "IF1 DAC4" }, 3242 { "IF1 DAC1 Mux", "Slot4", "IF1 DAC4" },
3242 { "IF1 DAC1 Mux", "Slot5", "IF1 DAC5" }, 3243 { "IF1 DAC1 Mux", "Slot5", "IF1 DAC5" },
3243 { "IF1 DAC1 Mux", "Slot6", "IF1 DAC6" }, 3244 { "IF1 DAC1 Mux", "Slot6", "IF1 DAC6" },
3244 { "IF1 DAC1 Mux", "Slot7", "IF1 DAC7" }, 3245 { "IF1 DAC1 Mux", "Slot7", "IF1 DAC7" },
3245 3246
3246 { "IF1 DAC2 Mux", "Slot0", "IF1 DAC0" }, 3247 { "IF1 DAC2 Mux", "Slot0", "IF1 DAC0" },
3247 { "IF1 DAC2 Mux", "Slot1", "IF1 DAC1" }, 3248 { "IF1 DAC2 Mux", "Slot1", "IF1 DAC1" },
3248 { "IF1 DAC2 Mux", "Slot2", "IF1 DAC2" }, 3249 { "IF1 DAC2 Mux", "Slot2", "IF1 DAC2" },
3249 { "IF1 DAC2 Mux", "Slot3", "IF1 DAC3" }, 3250 { "IF1 DAC2 Mux", "Slot3", "IF1 DAC3" },
3250 { "IF1 DAC2 Mux", "Slot4", "IF1 DAC4" }, 3251 { "IF1 DAC2 Mux", "Slot4", "IF1 DAC4" },
3251 { "IF1 DAC2 Mux", "Slot5", "IF1 DAC5" }, 3252 { "IF1 DAC2 Mux", "Slot5", "IF1 DAC5" },
3252 { "IF1 DAC2 Mux", "Slot6", "IF1 DAC6" }, 3253 { "IF1 DAC2 Mux", "Slot6", "IF1 DAC6" },
3253 { "IF1 DAC2 Mux", "Slot7", "IF1 DAC7" }, 3254 { "IF1 DAC2 Mux", "Slot7", "IF1 DAC7" },
3254 3255
3255 { "IF1 DAC3 Mux", "Slot0", "IF1 DAC0" }, 3256 { "IF1 DAC3 Mux", "Slot0", "IF1 DAC0" },
3256 { "IF1 DAC3 Mux", "Slot1", "IF1 DAC1" }, 3257 { "IF1 DAC3 Mux", "Slot1", "IF1 DAC1" },
3257 { "IF1 DAC3 Mux", "Slot2", "IF1 DAC2" }, 3258 { "IF1 DAC3 Mux", "Slot2", "IF1 DAC2" },
3258 { "IF1 DAC3 Mux", "Slot3", "IF1 DAC3" }, 3259 { "IF1 DAC3 Mux", "Slot3", "IF1 DAC3" },
3259 { "IF1 DAC3 Mux", "Slot4", "IF1 DAC4" }, 3260 { "IF1 DAC3 Mux", "Slot4", "IF1 DAC4" },
3260 { "IF1 DAC3 Mux", "Slot5", "IF1 DAC5" }, 3261 { "IF1 DAC3 Mux", "Slot5", "IF1 DAC5" },
3261 { "IF1 DAC3 Mux", "Slot6", "IF1 DAC6" }, 3262 { "IF1 DAC3 Mux", "Slot6", "IF1 DAC6" },
3262 { "IF1 DAC3 Mux", "Slot7", "IF1 DAC7" }, 3263 { "IF1 DAC3 Mux", "Slot7", "IF1 DAC7" },
3263 3264
3264 { "IF1 DAC4 Mux", "Slot0", "IF1 DAC0" }, 3265 { "IF1 DAC4 Mux", "Slot0", "IF1 DAC0" },
3265 { "IF1 DAC4 Mux", "Slot1", "IF1 DAC1" }, 3266 { "IF1 DAC4 Mux", "Slot1", "IF1 DAC1" },
3266 { "IF1 DAC4 Mux", "Slot2", "IF1 DAC2" }, 3267 { "IF1 DAC4 Mux", "Slot2", "IF1 DAC2" },
3267 { "IF1 DAC4 Mux", "Slot3", "IF1 DAC3" }, 3268 { "IF1 DAC4 Mux", "Slot3", "IF1 DAC3" },
3268 { "IF1 DAC4 Mux", "Slot4", "IF1 DAC4" }, 3269 { "IF1 DAC4 Mux", "Slot4", "IF1 DAC4" },
3269 { "IF1 DAC4 Mux", "Slot5", "IF1 DAC5" }, 3270 { "IF1 DAC4 Mux", "Slot5", "IF1 DAC5" },
3270 { "IF1 DAC4 Mux", "Slot6", "IF1 DAC6" }, 3271 { "IF1 DAC4 Mux", "Slot6", "IF1 DAC6" },
3271 { "IF1 DAC4 Mux", "Slot7", "IF1 DAC7" }, 3272 { "IF1 DAC4 Mux", "Slot7", "IF1 DAC7" },
3272 3273
3273 { "IF1 DAC5 Mux", "Slot0", "IF1 DAC0" }, 3274 { "IF1 DAC5 Mux", "Slot0", "IF1 DAC0" },
3274 { "IF1 DAC5 Mux", "Slot1", "IF1 DAC1" }, 3275 { "IF1 DAC5 Mux", "Slot1", "IF1 DAC1" },
3275 { "IF1 DAC5 Mux", "Slot2", "IF1 DAC2" }, 3276 { "IF1 DAC5 Mux", "Slot2", "IF1 DAC2" },
3276 { "IF1 DAC5 Mux", "Slot3", "IF1 DAC3" }, 3277 { "IF1 DAC5 Mux", "Slot3", "IF1 DAC3" },
3277 { "IF1 DAC5 Mux", "Slot4", "IF1 DAC4" }, 3278 { "IF1 DAC5 Mux", "Slot4", "IF1 DAC4" },
3278 { "IF1 DAC5 Mux", "Slot5", "IF1 DAC5" }, 3279 { "IF1 DAC5 Mux", "Slot5", "IF1 DAC5" },
3279 { "IF1 DAC5 Mux", "Slot6", "IF1 DAC6" }, 3280 { "IF1 DAC5 Mux", "Slot6", "IF1 DAC6" },
3280 { "IF1 DAC5 Mux", "Slot7", "IF1 DAC7" }, 3281 { "IF1 DAC5 Mux", "Slot7", "IF1 DAC7" },
3281 3282
3282 { "IF1 DAC6 Mux", "Slot0", "IF1 DAC0" }, 3283 { "IF1 DAC6 Mux", "Slot0", "IF1 DAC0" },
3283 { "IF1 DAC6 Mux", "Slot1", "IF1 DAC1" }, 3284 { "IF1 DAC6 Mux", "Slot1", "IF1 DAC1" },
3284 { "IF1 DAC6 Mux", "Slot2", "IF1 DAC2" }, 3285 { "IF1 DAC6 Mux", "Slot2", "IF1 DAC2" },
3285 { "IF1 DAC6 Mux", "Slot3", "IF1 DAC3" }, 3286 { "IF1 DAC6 Mux", "Slot3", "IF1 DAC3" },
3286 { "IF1 DAC6 Mux", "Slot4", "IF1 DAC4" }, 3287 { "IF1 DAC6 Mux", "Slot4", "IF1 DAC4" },
3287 { "IF1 DAC6 Mux", "Slot5", "IF1 DAC5" }, 3288 { "IF1 DAC6 Mux", "Slot5", "IF1 DAC5" },
3288 { "IF1 DAC6 Mux", "Slot6", "IF1 DAC6" }, 3289 { "IF1 DAC6 Mux", "Slot6", "IF1 DAC6" },
3289 { "IF1 DAC6 Mux", "Slot7", "IF1 DAC7" }, 3290 { "IF1 DAC6 Mux", "Slot7", "IF1 DAC7" },
3290 3291
3291 { "IF1 DAC7 Mux", "Slot0", "IF1 DAC0" }, 3292 { "IF1 DAC7 Mux", "Slot0", "IF1 DAC0" },
3292 { "IF1 DAC7 Mux", "Slot1", "IF1 DAC1" }, 3293 { "IF1 DAC7 Mux", "Slot1", "IF1 DAC1" },
3293 { "IF1 DAC7 Mux", "Slot2", "IF1 DAC2" }, 3294 { "IF1 DAC7 Mux", "Slot2", "IF1 DAC2" },
3294 { "IF1 DAC7 Mux", "Slot3", "IF1 DAC3" }, 3295 { "IF1 DAC7 Mux", "Slot3", "IF1 DAC3" },
3295 { "IF1 DAC7 Mux", "Slot4", "IF1 DAC4" }, 3296 { "IF1 DAC7 Mux", "Slot4", "IF1 DAC4" },
3296 { "IF1 DAC7 Mux", "Slot5", "IF1 DAC5" }, 3297 { "IF1 DAC7 Mux", "Slot5", "IF1 DAC5" },
3297 { "IF1 DAC7 Mux", "Slot6", "IF1 DAC6" }, 3298 { "IF1 DAC7 Mux", "Slot6", "IF1 DAC6" },
3298 { "IF1 DAC7 Mux", "Slot7", "IF1 DAC7" }, 3299 { "IF1 DAC7 Mux", "Slot7", "IF1 DAC7" },
3299 3300
3300 { "IF1 DAC01", NULL, "IF1 DAC0 Mux" }, 3301 { "IF1 DAC01", NULL, "IF1 DAC0 Mux" },
3301 { "IF1 DAC01", NULL, "IF1 DAC1 Mux" }, 3302 { "IF1 DAC01", NULL, "IF1 DAC1 Mux" },
3302 { "IF1 DAC23", NULL, "IF1 DAC2 Mux" }, 3303 { "IF1 DAC23", NULL, "IF1 DAC2 Mux" },
3303 { "IF1 DAC23", NULL, "IF1 DAC3 Mux" }, 3304 { "IF1 DAC23", NULL, "IF1 DAC3 Mux" },
3304 { "IF1 DAC45", NULL, "IF1 DAC4 Mux" }, 3305 { "IF1 DAC45", NULL, "IF1 DAC4 Mux" },
3305 { "IF1 DAC45", NULL, "IF1 DAC5 Mux" }, 3306 { "IF1 DAC45", NULL, "IF1 DAC5 Mux" },
3306 { "IF1 DAC67", NULL, "IF1 DAC6 Mux" }, 3307 { "IF1 DAC67", NULL, "IF1 DAC6 Mux" },
3307 { "IF1 DAC67", NULL, "IF1 DAC7 Mux" }, 3308 { "IF1 DAC67", NULL, "IF1 DAC7 Mux" },
3308 3309
3309 { "IF2 DAC0", NULL, "AIF2RX" }, 3310 { "IF2 DAC0", NULL, "AIF2RX" },
3310 { "IF2 DAC1", NULL, "AIF2RX" }, 3311 { "IF2 DAC1", NULL, "AIF2RX" },
3311 { "IF2 DAC2", NULL, "AIF2RX" }, 3312 { "IF2 DAC2", NULL, "AIF2RX" },
3312 { "IF2 DAC3", NULL, "AIF2RX" }, 3313 { "IF2 DAC3", NULL, "AIF2RX" },
3313 { "IF2 DAC4", NULL, "AIF2RX" }, 3314 { "IF2 DAC4", NULL, "AIF2RX" },
3314 { "IF2 DAC5", NULL, "AIF2RX" }, 3315 { "IF2 DAC5", NULL, "AIF2RX" },
3315 { "IF2 DAC6", NULL, "AIF2RX" }, 3316 { "IF2 DAC6", NULL, "AIF2RX" },
3316 { "IF2 DAC7", NULL, "AIF2RX" }, 3317 { "IF2 DAC7", NULL, "AIF2RX" },
3317 { "IF2 DAC0", NULL, "I2S2" }, 3318 { "IF2 DAC0", NULL, "I2S2" },
3318 { "IF2 DAC1", NULL, "I2S2" }, 3319 { "IF2 DAC1", NULL, "I2S2" },
3319 { "IF2 DAC2", NULL, "I2S2" }, 3320 { "IF2 DAC2", NULL, "I2S2" },
3320 { "IF2 DAC3", NULL, "I2S2" }, 3321 { "IF2 DAC3", NULL, "I2S2" },
3321 { "IF2 DAC4", NULL, "I2S2" }, 3322 { "IF2 DAC4", NULL, "I2S2" },
3322 { "IF2 DAC5", NULL, "I2S2" }, 3323 { "IF2 DAC5", NULL, "I2S2" },
3323 { "IF2 DAC6", NULL, "I2S2" }, 3324 { "IF2 DAC6", NULL, "I2S2" },
3324 { "IF2 DAC7", NULL, "I2S2" }, 3325 { "IF2 DAC7", NULL, "I2S2" },
3325 3326
3326 { "IF2 DAC0 Mux", "Slot0", "IF2 DAC0" }, 3327 { "IF2 DAC0 Mux", "Slot0", "IF2 DAC0" },
3327 { "IF2 DAC0 Mux", "Slot1", "IF2 DAC1" }, 3328 { "IF2 DAC0 Mux", "Slot1", "IF2 DAC1" },
3328 { "IF2 DAC0 Mux", "Slot2", "IF2 DAC2" }, 3329 { "IF2 DAC0 Mux", "Slot2", "IF2 DAC2" },
3329 { "IF2 DAC0 Mux", "Slot3", "IF2 DAC3" }, 3330 { "IF2 DAC0 Mux", "Slot3", "IF2 DAC3" },
3330 { "IF2 DAC0 Mux", "Slot4", "IF2 DAC4" }, 3331 { "IF2 DAC0 Mux", "Slot4", "IF2 DAC4" },
3331 { "IF2 DAC0 Mux", "Slot5", "IF2 DAC5" }, 3332 { "IF2 DAC0 Mux", "Slot5", "IF2 DAC5" },
3332 { "IF2 DAC0 Mux", "Slot6", "IF2 DAC6" }, 3333 { "IF2 DAC0 Mux", "Slot6", "IF2 DAC6" },
3333 { "IF2 DAC0 Mux", "Slot7", "IF2 DAC7" }, 3334 { "IF2 DAC0 Mux", "Slot7", "IF2 DAC7" },
3334 3335
3335 { "IF2 DAC1 Mux", "Slot0", "IF2 DAC0" }, 3336 { "IF2 DAC1 Mux", "Slot0", "IF2 DAC0" },
3336 { "IF2 DAC1 Mux", "Slot1", "IF2 DAC1" }, 3337 { "IF2 DAC1 Mux", "Slot1", "IF2 DAC1" },
3337 { "IF2 DAC1 Mux", "Slot2", "IF2 DAC2" }, 3338 { "IF2 DAC1 Mux", "Slot2", "IF2 DAC2" },
3338 { "IF2 DAC1 Mux", "Slot3", "IF2 DAC3" }, 3339 { "IF2 DAC1 Mux", "Slot3", "IF2 DAC3" },
3339 { "IF2 DAC1 Mux", "Slot4", "IF2 DAC4" }, 3340 { "IF2 DAC1 Mux", "Slot4", "IF2 DAC4" },
3340 { "IF2 DAC1 Mux", "Slot5", "IF2 DAC5" }, 3341 { "IF2 DAC1 Mux", "Slot5", "IF2 DAC5" },
3341 { "IF2 DAC1 Mux", "Slot6", "IF2 DAC6" }, 3342 { "IF2 DAC1 Mux", "Slot6", "IF2 DAC6" },
3342 { "IF2 DAC1 Mux", "Slot7", "IF2 DAC7" }, 3343 { "IF2 DAC1 Mux", "Slot7", "IF2 DAC7" },
3343 3344
3344 { "IF2 DAC2 Mux", "Slot0", "IF2 DAC0" }, 3345 { "IF2 DAC2 Mux", "Slot0", "IF2 DAC0" },
3345 { "IF2 DAC2 Mux", "Slot1", "IF2 DAC1" }, 3346 { "IF2 DAC2 Mux", "Slot1", "IF2 DAC1" },
3346 { "IF2 DAC2 Mux", "Slot2", "IF2 DAC2" }, 3347 { "IF2 DAC2 Mux", "Slot2", "IF2 DAC2" },
3347 { "IF2 DAC2 Mux", "Slot3", "IF2 DAC3" }, 3348 { "IF2 DAC2 Mux", "Slot3", "IF2 DAC3" },
3348 { "IF2 DAC2 Mux", "Slot4", "IF2 DAC4" }, 3349 { "IF2 DAC2 Mux", "Slot4", "IF2 DAC4" },
3349 { "IF2 DAC2 Mux", "Slot5", "IF2 DAC5" }, 3350 { "IF2 DAC2 Mux", "Slot5", "IF2 DAC5" },
3350 { "IF2 DAC2 Mux", "Slot6", "IF2 DAC6" }, 3351 { "IF2 DAC2 Mux", "Slot6", "IF2 DAC6" },
3351 { "IF2 DAC2 Mux", "Slot7", "IF2 DAC7" }, 3352 { "IF2 DAC2 Mux", "Slot7", "IF2 DAC7" },
3352 3353
3353 { "IF2 DAC3 Mux", "Slot0", "IF2 DAC0" }, 3354 { "IF2 DAC3 Mux", "Slot0", "IF2 DAC0" },
3354 { "IF2 DAC3 Mux", "Slot1", "IF2 DAC1" }, 3355 { "IF2 DAC3 Mux", "Slot1", "IF2 DAC1" },
3355 { "IF2 DAC3 Mux", "Slot2", "IF2 DAC2" }, 3356 { "IF2 DAC3 Mux", "Slot2", "IF2 DAC2" },
3356 { "IF2 DAC3 Mux", "Slot3", "IF2 DAC3" }, 3357 { "IF2 DAC3 Mux", "Slot3", "IF2 DAC3" },
3357 { "IF2 DAC3 Mux", "Slot4", "IF2 DAC4" }, 3358 { "IF2 DAC3 Mux", "Slot4", "IF2 DAC4" },
3358 { "IF2 DAC3 Mux", "Slot5", "IF2 DAC5" }, 3359 { "IF2 DAC3 Mux", "Slot5", "IF2 DAC5" },
3359 { "IF2 DAC3 Mux", "Slot6", "IF2 DAC6" }, 3360 { "IF2 DAC3 Mux", "Slot6", "IF2 DAC6" },
3360 { "IF2 DAC3 Mux", "Slot7", "IF2 DAC7" }, 3361 { "IF2 DAC3 Mux", "Slot7", "IF2 DAC7" },
3361 3362
3362 { "IF2 DAC4 Mux", "Slot0", "IF2 DAC0" }, 3363 { "IF2 DAC4 Mux", "Slot0", "IF2 DAC0" },
3363 { "IF2 DAC4 Mux", "Slot1", "IF2 DAC1" }, 3364 { "IF2 DAC4 Mux", "Slot1", "IF2 DAC1" },
3364 { "IF2 DAC4 Mux", "Slot2", "IF2 DAC2" }, 3365 { "IF2 DAC4 Mux", "Slot2", "IF2 DAC2" },
3365 { "IF2 DAC4 Mux", "Slot3", "IF2 DAC3" }, 3366 { "IF2 DAC4 Mux", "Slot3", "IF2 DAC3" },
3366 { "IF2 DAC4 Mux", "Slot4", "IF2 DAC4" }, 3367 { "IF2 DAC4 Mux", "Slot4", "IF2 DAC4" },
3367 { "IF2 DAC4 Mux", "Slot5", "IF2 DAC5" }, 3368 { "IF2 DAC4 Mux", "Slot5", "IF2 DAC5" },
3368 { "IF2 DAC4 Mux", "Slot6", "IF2 DAC6" }, 3369 { "IF2 DAC4 Mux", "Slot6", "IF2 DAC6" },
3369 { "IF2 DAC4 Mux", "Slot7", "IF2 DAC7" }, 3370 { "IF2 DAC4 Mux", "Slot7", "IF2 DAC7" },
3370 3371
3371 { "IF2 DAC5 Mux", "Slot0", "IF2 DAC0" }, 3372 { "IF2 DAC5 Mux", "Slot0", "IF2 DAC0" },
3372 { "IF2 DAC5 Mux", "Slot1", "IF2 DAC1" }, 3373 { "IF2 DAC5 Mux", "Slot1", "IF2 DAC1" },
3373 { "IF2 DAC5 Mux", "Slot2", "IF2 DAC2" }, 3374 { "IF2 DAC5 Mux", "Slot2", "IF2 DAC2" },
3374 { "IF2 DAC5 Mux", "Slot3", "IF2 DAC3" }, 3375 { "IF2 DAC5 Mux", "Slot3", "IF2 DAC3" },
3375 { "IF2 DAC5 Mux", "Slot4", "IF2 DAC4" }, 3376 { "IF2 DAC5 Mux", "Slot4", "IF2 DAC4" },
3376 { "IF2 DAC5 Mux", "Slot5", "IF2 DAC5" }, 3377 { "IF2 DAC5 Mux", "Slot5", "IF2 DAC5" },
3377 { "IF2 DAC5 Mux", "Slot6", "IF2 DAC6" }, 3378 { "IF2 DAC5 Mux", "Slot6", "IF2 DAC6" },
3378 { "IF2 DAC5 Mux", "Slot7", "IF2 DAC7" }, 3379 { "IF2 DAC5 Mux", "Slot7", "IF2 DAC7" },
3379 3380
3380 { "IF2 DAC6 Mux", "Slot0", "IF2 DAC0" }, 3381 { "IF2 DAC6 Mux", "Slot0", "IF2 DAC0" },
3381 { "IF2 DAC6 Mux", "Slot1", "IF2 DAC1" }, 3382 { "IF2 DAC6 Mux", "Slot1", "IF2 DAC1" },
3382 { "IF2 DAC6 Mux", "Slot2", "IF2 DAC2" }, 3383 { "IF2 DAC6 Mux", "Slot2", "IF2 DAC2" },
3383 { "IF2 DAC6 Mux", "Slot3", "IF2 DAC3" }, 3384 { "IF2 DAC6 Mux", "Slot3", "IF2 DAC3" },
3384 { "IF2 DAC6 Mux", "Slot4", "IF2 DAC4" }, 3385 { "IF2 DAC6 Mux", "Slot4", "IF2 DAC4" },
3385 { "IF2 DAC6 Mux", "Slot5", "IF2 DAC5" }, 3386 { "IF2 DAC6 Mux", "Slot5", "IF2 DAC5" },
3386 { "IF2 DAC6 Mux", "Slot6", "IF2 DAC6" }, 3387 { "IF2 DAC6 Mux", "Slot6", "IF2 DAC6" },
3387 { "IF2 DAC6 Mux", "Slot7", "IF2 DAC7" }, 3388 { "IF2 DAC6 Mux", "Slot7", "IF2 DAC7" },
3388 3389
3389 { "IF2 DAC7 Mux", "Slot0", "IF2 DAC0" }, 3390 { "IF2 DAC7 Mux", "Slot0", "IF2 DAC0" },
3390 { "IF2 DAC7 Mux", "Slot1", "IF2 DAC1" }, 3391 { "IF2 DAC7 Mux", "Slot1", "IF2 DAC1" },
3391 { "IF2 DAC7 Mux", "Slot2", "IF2 DAC2" }, 3392 { "IF2 DAC7 Mux", "Slot2", "IF2 DAC2" },
3392 { "IF2 DAC7 Mux", "Slot3", "IF2 DAC3" }, 3393 { "IF2 DAC7 Mux", "Slot3", "IF2 DAC3" },
3393 { "IF2 DAC7 Mux", "Slot4", "IF2 DAC4" }, 3394 { "IF2 DAC7 Mux", "Slot4", "IF2 DAC4" },
3394 { "IF2 DAC7 Mux", "Slot5", "IF2 DAC5" }, 3395 { "IF2 DAC7 Mux", "Slot5", "IF2 DAC5" },
3395 { "IF2 DAC7 Mux", "Slot6", "IF2 DAC6" }, 3396 { "IF2 DAC7 Mux", "Slot6", "IF2 DAC6" },
3396 { "IF2 DAC7 Mux", "Slot7", "IF2 DAC7" }, 3397 { "IF2 DAC7 Mux", "Slot7", "IF2 DAC7" },
3397 3398
3398 { "IF2 DAC01", NULL, "IF2 DAC0 Mux" }, 3399 { "IF2 DAC01", NULL, "IF2 DAC0 Mux" },
3399 { "IF2 DAC01", NULL, "IF2 DAC1 Mux" }, 3400 { "IF2 DAC01", NULL, "IF2 DAC1 Mux" },
3400 { "IF2 DAC23", NULL, "IF2 DAC2 Mux" }, 3401 { "IF2 DAC23", NULL, "IF2 DAC2 Mux" },
3401 { "IF2 DAC23", NULL, "IF2 DAC3 Mux" }, 3402 { "IF2 DAC23", NULL, "IF2 DAC3 Mux" },
3402 { "IF2 DAC45", NULL, "IF2 DAC4 Mux" }, 3403 { "IF2 DAC45", NULL, "IF2 DAC4 Mux" },
3403 { "IF2 DAC45", NULL, "IF2 DAC5 Mux" }, 3404 { "IF2 DAC45", NULL, "IF2 DAC5 Mux" },
3404 { "IF2 DAC67", NULL, "IF2 DAC6 Mux" }, 3405 { "IF2 DAC67", NULL, "IF2 DAC6 Mux" },
3405 { "IF2 DAC67", NULL, "IF2 DAC7 Mux" }, 3406 { "IF2 DAC67", NULL, "IF2 DAC7 Mux" },
3406 3407
3407 { "IF3 DAC", NULL, "AIF3RX" }, 3408 { "IF3 DAC", NULL, "AIF3RX" },
3408 { "IF3 DAC", NULL, "I2S3" }, 3409 { "IF3 DAC", NULL, "I2S3" },
3409 3410
3410 { "IF4 DAC", NULL, "AIF4RX" }, 3411 { "IF4 DAC", NULL, "AIF4RX" },
3411 { "IF4 DAC", NULL, "I2S4" }, 3412 { "IF4 DAC", NULL, "I2S4" },
3412 3413
3413 { "IF3 DAC L", NULL, "IF3 DAC" }, 3414 { "IF3 DAC L", NULL, "IF3 DAC" },
3414 { "IF3 DAC R", NULL, "IF3 DAC" }, 3415 { "IF3 DAC R", NULL, "IF3 DAC" },
3415 3416
3416 { "IF4 DAC L", NULL, "IF4 DAC" }, 3417 { "IF4 DAC L", NULL, "IF4 DAC" },
3417 { "IF4 DAC R", NULL, "IF4 DAC" }, 3418 { "IF4 DAC R", NULL, "IF4 DAC" },
3418 3419
3419 { "SLB DAC0", NULL, "SLBRX" }, 3420 { "SLB DAC0", NULL, "SLBRX" },
3420 { "SLB DAC1", NULL, "SLBRX" }, 3421 { "SLB DAC1", NULL, "SLBRX" },
3421 { "SLB DAC2", NULL, "SLBRX" }, 3422 { "SLB DAC2", NULL, "SLBRX" },
3422 { "SLB DAC3", NULL, "SLBRX" }, 3423 { "SLB DAC3", NULL, "SLBRX" },
3423 { "SLB DAC4", NULL, "SLBRX" }, 3424 { "SLB DAC4", NULL, "SLBRX" },
3424 { "SLB DAC5", NULL, "SLBRX" }, 3425 { "SLB DAC5", NULL, "SLBRX" },
3425 { "SLB DAC6", NULL, "SLBRX" }, 3426 { "SLB DAC6", NULL, "SLBRX" },
3426 { "SLB DAC7", NULL, "SLBRX" }, 3427 { "SLB DAC7", NULL, "SLBRX" },
3427 { "SLB DAC0", NULL, "SLB" }, 3428 { "SLB DAC0", NULL, "SLB" },
3428 { "SLB DAC1", NULL, "SLB" }, 3429 { "SLB DAC1", NULL, "SLB" },
3429 { "SLB DAC2", NULL, "SLB" }, 3430 { "SLB DAC2", NULL, "SLB" },
3430 { "SLB DAC3", NULL, "SLB" }, 3431 { "SLB DAC3", NULL, "SLB" },
3431 { "SLB DAC4", NULL, "SLB" }, 3432 { "SLB DAC4", NULL, "SLB" },
3432 { "SLB DAC5", NULL, "SLB" }, 3433 { "SLB DAC5", NULL, "SLB" },
3433 { "SLB DAC6", NULL, "SLB" }, 3434 { "SLB DAC6", NULL, "SLB" },
3434 { "SLB DAC7", NULL, "SLB" }, 3435 { "SLB DAC7", NULL, "SLB" },
3435 3436
3436 { "SLB DAC01", NULL, "SLB DAC0" }, 3437 { "SLB DAC01", NULL, "SLB DAC0" },
3437 { "SLB DAC01", NULL, "SLB DAC1" }, 3438 { "SLB DAC01", NULL, "SLB DAC1" },
3438 { "SLB DAC23", NULL, "SLB DAC2" }, 3439 { "SLB DAC23", NULL, "SLB DAC2" },
3439 { "SLB DAC23", NULL, "SLB DAC3" }, 3440 { "SLB DAC23", NULL, "SLB DAC3" },
3440 { "SLB DAC45", NULL, "SLB DAC4" }, 3441 { "SLB DAC45", NULL, "SLB DAC4" },
3441 { "SLB DAC45", NULL, "SLB DAC5" }, 3442 { "SLB DAC45", NULL, "SLB DAC5" },
3442 { "SLB DAC67", NULL, "SLB DAC6" }, 3443 { "SLB DAC67", NULL, "SLB DAC6" },
3443 { "SLB DAC67", NULL, "SLB DAC7" }, 3444 { "SLB DAC67", NULL, "SLB DAC7" },
3444 3445
3445 { "ADDA1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, 3446 { "ADDA1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
3446 { "ADDA1 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, 3447 { "ADDA1 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
3447 { "ADDA1 Mux", "OB 67", "OB67" }, 3448 { "ADDA1 Mux", "OB 67", "OB67" },
3448 3449
3449 { "DAC1 Mux", "IF1 DAC 01", "IF1 DAC01" }, 3450 { "DAC1 Mux", "IF1 DAC 01", "IF1 DAC01" },
3450 { "DAC1 Mux", "IF2 DAC 01", "IF2 DAC01" }, 3451 { "DAC1 Mux", "IF2 DAC 01", "IF2 DAC01" },
3451 { "DAC1 Mux", "IF3 DAC LR", "IF3 DAC" }, 3452 { "DAC1 Mux", "IF3 DAC LR", "IF3 DAC" },
3452 { "DAC1 Mux", "IF4 DAC LR", "IF4 DAC" }, 3453 { "DAC1 Mux", "IF4 DAC LR", "IF4 DAC" },
3453 { "DAC1 Mux", "SLB DAC 01", "SLB DAC01" }, 3454 { "DAC1 Mux", "SLB DAC 01", "SLB DAC01" },
3454 { "DAC1 Mux", "OB 01", "OB01 Bypass Mux" }, 3455 { "DAC1 Mux", "OB 01", "OB01 Bypass Mux" },
3455 3456
3456 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" }, 3457 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" },
3457 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" }, 3458 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" },
3458 { "DAC1 MIXL", NULL, "dac stereo1 filter" }, 3459 { "DAC1 MIXL", NULL, "dac stereo1 filter" },
3459 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" }, 3460 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" },
3460 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" }, 3461 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" },
3461 { "DAC1 MIXR", NULL, "dac stereo1 filter" }, 3462 { "DAC1 MIXR", NULL, "dac stereo1 filter" },
3462 3463
3463 { "DAC1 FS", NULL, "DAC1 MIXL" }, 3464 { "DAC1 FS", NULL, "DAC1 MIXL" },
3464 { "DAC1 FS", NULL, "DAC1 MIXR" }, 3465 { "DAC1 FS", NULL, "DAC1 MIXR" },
3465 3466
3466 { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2" }, 3467 { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2" },
3467 { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2" }, 3468 { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2" },
3468 { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" }, 3469 { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" },
3469 { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" }, 3470 { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" },
3470 { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" }, 3471 { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" },
3471 { "DAC2 L Mux", "OB 2", "OutBound2" }, 3472 { "DAC2 L Mux", "OB 2", "OutBound2" },
3472 3473
3473 { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3" }, 3474 { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3" },
3474 { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3" }, 3475 { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3" },
3475 { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" }, 3476 { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" },
3476 { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" }, 3477 { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" },
3477 { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" }, 3478 { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" },
3478 { "DAC2 R Mux", "OB 3", "OutBound3" }, 3479 { "DAC2 R Mux", "OB 3", "OutBound3" },
3479 { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" }, 3480 { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" },
3480 { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" }, 3481 { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" },
3481 3482
3482 { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4" }, 3483 { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4" },
3483 { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4" }, 3484 { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4" },
3484 { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" }, 3485 { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" },
3485 { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" }, 3486 { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" },
3486 { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" }, 3487 { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" },
3487 { "DAC3 L Mux", "OB 4", "OutBound4" }, 3488 { "DAC3 L Mux", "OB 4", "OutBound4" },
3488 3489
3489 { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC4" }, 3490 { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC4" },
3490 { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC4" }, 3491 { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC4" },
3491 { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" }, 3492 { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" },
3492 { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" }, 3493 { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" },
3493 { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" }, 3494 { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" },
3494 { "DAC3 R Mux", "OB 5", "OutBound5" }, 3495 { "DAC3 R Mux", "OB 5", "OutBound5" },
3495 3496
3496 { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6" }, 3497 { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6" },
3497 { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6" }, 3498 { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6" },
3498 { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" }, 3499 { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" },
3499 { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" }, 3500 { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" },
3500 { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" }, 3501 { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" },
3501 { "DAC4 L Mux", "OB 6", "OutBound6" }, 3502 { "DAC4 L Mux", "OB 6", "OutBound6" },
3502 3503
3503 { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7" }, 3504 { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7" },
3504 { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7" }, 3505 { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7" },
3505 { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" }, 3506 { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" },
3506 { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" }, 3507 { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" },
3507 { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" }, 3508 { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" },
3508 { "DAC4 R Mux", "OB 7", "OutBound7" }, 3509 { "DAC4 R Mux", "OB 7", "OutBound7" },
3509 3510
3510 { "Sidetone Mux", "DMIC1 L", "DMIC L1" }, 3511 { "Sidetone Mux", "DMIC1 L", "DMIC L1" },
3511 { "Sidetone Mux", "DMIC2 L", "DMIC L2" }, 3512 { "Sidetone Mux", "DMIC2 L", "DMIC L2" },
3512 { "Sidetone Mux", "DMIC3 L", "DMIC L3" }, 3513 { "Sidetone Mux", "DMIC3 L", "DMIC L3" },
3513 { "Sidetone Mux", "DMIC4 L", "DMIC L4" }, 3514 { "Sidetone Mux", "DMIC4 L", "DMIC L4" },
3514 { "Sidetone Mux", "ADC1", "ADC 1" }, 3515 { "Sidetone Mux", "ADC1", "ADC 1" },
3515 { "Sidetone Mux", "ADC2", "ADC 2" }, 3516 { "Sidetone Mux", "ADC2", "ADC 2" },
3516 { "Sidetone Mux", NULL, "Sidetone Power" }, 3517 { "Sidetone Mux", NULL, "Sidetone Power" },
3517 3518
3518 { "Stereo DAC MIXL", "ST L Switch", "Sidetone Mux" }, 3519 { "Stereo DAC MIXL", "ST L Switch", "Sidetone Mux" },
3519 { "Stereo DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" }, 3520 { "Stereo DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3520 { "Stereo DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" }, 3521 { "Stereo DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3521 { "Stereo DAC MIXL", "DAC1 R Switch", "DAC1 MIXR" }, 3522 { "Stereo DAC MIXL", "DAC1 R Switch", "DAC1 MIXR" },
3522 { "Stereo DAC MIXL", NULL, "dac stereo1 filter" }, 3523 { "Stereo DAC MIXL", NULL, "dac stereo1 filter" },
3523 { "Stereo DAC MIXR", "ST R Switch", "Sidetone Mux" }, 3524 { "Stereo DAC MIXR", "ST R Switch", "Sidetone Mux" },
3524 { "Stereo DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" }, 3525 { "Stereo DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3525 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, 3526 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3526 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" }, 3527 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" },
3527 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" }, 3528 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" },
3528 3529
3529 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" }, 3530 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" },
3530 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" }, 3531 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3531 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" }, 3532 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3532 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" }, 3533 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" },
3533 { "Mono DAC MIXL", NULL, "dac mono left filter" }, 3534 { "Mono DAC MIXL", NULL, "dac mono left filter" },
3534 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" }, 3535 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" },
3535 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" }, 3536 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3536 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, 3537 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3537 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" }, 3538 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" },
3538 { "Mono DAC MIXR", NULL, "dac mono right filter" }, 3539 { "Mono DAC MIXR", NULL, "dac mono right filter" },
3539 3540
3540 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, 3541 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3541 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, 3542 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3542 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" }, 3543 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" },
3543 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" }, 3544 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" },
3544 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, 3545 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3545 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, 3546 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3546 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" }, 3547 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" },
3547 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" }, 3548 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" },
3548 3549
3549 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, 3550 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3550 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, 3551 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3551 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" }, 3552 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" },
3552 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" }, 3553 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" },
3553 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, 3554 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3554 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, 3555 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3555 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" }, 3556 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" },
3556 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" }, 3557 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" },
3557 3558
3558 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" }, 3559 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" },
3559 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" }, 3560 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" },
3560 { "Mono DAC MIX", NULL, "Mono DAC MIXL" }, 3561 { "Mono DAC MIX", NULL, "Mono DAC MIXL" },
3561 { "Mono DAC MIX", NULL, "Mono DAC MIXR" }, 3562 { "Mono DAC MIX", NULL, "Mono DAC MIXR" },
3562 { "DD1 MIX", NULL, "DD1 MIXL" }, 3563 { "DD1 MIX", NULL, "DD1 MIXL" },
3563 { "DD1 MIX", NULL, "DD1 MIXR" }, 3564 { "DD1 MIX", NULL, "DD1 MIXR" },
3564 { "DD2 MIX", NULL, "DD2 MIXL" }, 3565 { "DD2 MIX", NULL, "DD2 MIXL" },
3565 { "DD2 MIX", NULL, "DD2 MIXR" }, 3566 { "DD2 MIX", NULL, "DD2 MIXR" },
3566 3567
3567 { "DAC12 SRC Mux", "STO1 DAC MIX", "Stereo DAC MIX" }, 3568 { "DAC12 SRC Mux", "STO1 DAC MIX", "Stereo DAC MIX" },
3568 { "DAC12 SRC Mux", "MONO DAC MIX", "Mono DAC MIX" }, 3569 { "DAC12 SRC Mux", "MONO DAC MIX", "Mono DAC MIX" },
3569 { "DAC12 SRC Mux", "DD MIX1", "DD1 MIX" }, 3570 { "DAC12 SRC Mux", "DD MIX1", "DD1 MIX" },
3570 { "DAC12 SRC Mux", "DD MIX2", "DD2 MIX" }, 3571 { "DAC12 SRC Mux", "DD MIX2", "DD2 MIX" },
3571 3572
3572 { "DAC3 SRC Mux", "MONO DAC MIXL", "Mono DAC MIXL" }, 3573 { "DAC3 SRC Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
3573 { "DAC3 SRC Mux", "MONO DAC MIXR", "Mono DAC MIXR" }, 3574 { "DAC3 SRC Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
3574 { "DAC3 SRC Mux", "DD MIX1L", "DD1 MIXL" }, 3575 { "DAC3 SRC Mux", "DD MIX1L", "DD1 MIXL" },
3575 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" }, 3576 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" },
3576 3577
3577 { "DAC 1", NULL, "DAC12 SRC Mux" }, 3578 { "DAC 1", NULL, "DAC12 SRC Mux" },
3578 { "DAC 1", NULL, "PLL1", is_sys_clk_from_pll }, 3579 { "DAC 1", NULL, "PLL1", is_sys_clk_from_pll },
3579 { "DAC 2", NULL, "DAC12 SRC Mux" }, 3580 { "DAC 2", NULL, "DAC12 SRC Mux" },
3580 { "DAC 2", NULL, "PLL1", is_sys_clk_from_pll }, 3581 { "DAC 2", NULL, "PLL1", is_sys_clk_from_pll },
3581 { "DAC 3", NULL, "DAC3 SRC Mux" }, 3582 { "DAC 3", NULL, "DAC3 SRC Mux" },
3582 { "DAC 3", NULL, "PLL1", is_sys_clk_from_pll }, 3583 { "DAC 3", NULL, "PLL1", is_sys_clk_from_pll },
3583 3584
3584 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" }, 3585 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
3585 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" }, 3586 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
3586 { "PDM1 L Mux", "DD MIX1", "DD1 MIXL" }, 3587 { "PDM1 L Mux", "DD MIX1", "DD1 MIXL" },
3587 { "PDM1 L Mux", "DD MIX2", "DD2 MIXL" }, 3588 { "PDM1 L Mux", "DD MIX2", "DD2 MIXL" },
3588 { "PDM1 L Mux", NULL, "PDM1 Power" }, 3589 { "PDM1 L Mux", NULL, "PDM1 Power" },
3589 { "PDM1 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" }, 3590 { "PDM1 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
3590 { "PDM1 R Mux", "MONO DAC MIX", "Mono DAC MIXR" }, 3591 { "PDM1 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
3591 { "PDM1 R Mux", "DD MIX1", "DD1 MIXR" }, 3592 { "PDM1 R Mux", "DD MIX1", "DD1 MIXR" },
3592 { "PDM1 R Mux", "DD MIX2", "DD2 MIXR" }, 3593 { "PDM1 R Mux", "DD MIX2", "DD2 MIXR" },
3593 { "PDM1 R Mux", NULL, "PDM1 Power" }, 3594 { "PDM1 R Mux", NULL, "PDM1 Power" },
3594 { "PDM2 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" }, 3595 { "PDM2 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
3595 { "PDM2 L Mux", "MONO DAC MIX", "Mono DAC MIXL" }, 3596 { "PDM2 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
3596 { "PDM2 L Mux", "DD MIX1", "DD1 MIXL" }, 3597 { "PDM2 L Mux", "DD MIX1", "DD1 MIXL" },
3597 { "PDM2 L Mux", "DD MIX2", "DD2 MIXL" }, 3598 { "PDM2 L Mux", "DD MIX2", "DD2 MIXL" },
3598 { "PDM2 L Mux", NULL, "PDM2 Power" }, 3599 { "PDM2 L Mux", NULL, "PDM2 Power" },
3599 { "PDM2 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" }, 3600 { "PDM2 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
3600 { "PDM2 R Mux", "MONO DAC MIX", "Mono DAC MIXR" }, 3601 { "PDM2 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
3601 { "PDM2 R Mux", "DD MIX1", "DD1 MIXR" }, 3602 { "PDM2 R Mux", "DD MIX1", "DD1 MIXR" },
3602 { "PDM2 R Mux", "DD MIX1", "DD2 MIXR" }, 3603 { "PDM2 R Mux", "DD MIX1", "DD2 MIXR" },
3603 { "PDM2 R Mux", NULL, "PDM2 Power" }, 3604 { "PDM2 R Mux", NULL, "PDM2 Power" },
3604 3605
3605 { "LOUT1 amp", NULL, "DAC 1" }, 3606 { "LOUT1 amp", NULL, "DAC 1" },
3606 { "LOUT2 amp", NULL, "DAC 2" }, 3607 { "LOUT2 amp", NULL, "DAC 2" },
3607 { "LOUT3 amp", NULL, "DAC 3" }, 3608 { "LOUT3 amp", NULL, "DAC 3" },
3608 3609
3609 { "LOUT1 vref", NULL, "LOUT1 amp" }, 3610 { "LOUT1 vref", NULL, "LOUT1 amp" },
3610 { "LOUT2 vref", NULL, "LOUT2 amp" }, 3611 { "LOUT2 vref", NULL, "LOUT2 amp" },
3611 { "LOUT3 vref", NULL, "LOUT3 amp" }, 3612 { "LOUT3 vref", NULL, "LOUT3 amp" },
3612 3613
3613 { "LOUT1", NULL, "LOUT1 vref" }, 3614 { "LOUT1", NULL, "LOUT1 vref" },
3614 { "LOUT2", NULL, "LOUT2 vref" }, 3615 { "LOUT2", NULL, "LOUT2 vref" },
3615 { "LOUT3", NULL, "LOUT3 vref" }, 3616 { "LOUT3", NULL, "LOUT3 vref" },
3616 3617
3617 { "PDM1L", NULL, "PDM1 L Mux" }, 3618 { "PDM1L", NULL, "PDM1 L Mux" },
3618 { "PDM1R", NULL, "PDM1 R Mux" }, 3619 { "PDM1R", NULL, "PDM1 R Mux" },
3619 { "PDM2L", NULL, "PDM2 L Mux" }, 3620 { "PDM2L", NULL, "PDM2 L Mux" },
3620 { "PDM2R", NULL, "PDM2 R Mux" }, 3621 { "PDM2R", NULL, "PDM2 R Mux" },
3621 }; 3622 };
3622 3623
3623 static const struct snd_soc_dapm_route rt5677_dmic2_clk_1[] = { 3624 static const struct snd_soc_dapm_route rt5677_dmic2_clk_1[] = {
3624 { "DMIC L2", NULL, "DMIC1 power" }, 3625 { "DMIC L2", NULL, "DMIC1 power" },
3625 { "DMIC R2", NULL, "DMIC1 power" }, 3626 { "DMIC R2", NULL, "DMIC1 power" },
3626 }; 3627 };
3627 3628
3628 static const struct snd_soc_dapm_route rt5677_dmic2_clk_2[] = { 3629 static const struct snd_soc_dapm_route rt5677_dmic2_clk_2[] = {
3629 { "DMIC L2", NULL, "DMIC2 power" }, 3630 { "DMIC L2", NULL, "DMIC2 power" },
3630 { "DMIC R2", NULL, "DMIC2 power" }, 3631 { "DMIC R2", NULL, "DMIC2 power" },
3631 }; 3632 };
3632 3633
3633 static int rt5677_hw_params(struct snd_pcm_substream *substream, 3634 static int rt5677_hw_params(struct snd_pcm_substream *substream,
3634 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 3635 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
3635 { 3636 {
3636 struct snd_soc_codec *codec = dai->codec; 3637 struct snd_soc_codec *codec = dai->codec;
3637 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 3638 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3638 unsigned int val_len = 0, val_clk, mask_clk; 3639 unsigned int val_len = 0, val_clk, mask_clk;
3639 int pre_div, bclk_ms, frame_size; 3640 int pre_div, bclk_ms, frame_size;
3640 3641
3641 rt5677->lrck[dai->id] = params_rate(params); 3642 rt5677->lrck[dai->id] = params_rate(params);
3642 pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]); 3643 pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]);
3643 if (pre_div < 0) { 3644 if (pre_div < 0) {
3644 dev_err(codec->dev, "Unsupported clock setting: sysclk=%dHz lrck=%dHz\n", 3645 dev_err(codec->dev, "Unsupported clock setting: sysclk=%dHz lrck=%dHz\n",
3645 rt5677->sysclk, rt5677->lrck[dai->id]); 3646 rt5677->sysclk, rt5677->lrck[dai->id]);
3646 return -EINVAL; 3647 return -EINVAL;
3647 } 3648 }
3648 frame_size = snd_soc_params_to_frame_size(params); 3649 frame_size = snd_soc_params_to_frame_size(params);
3649 if (frame_size < 0) { 3650 if (frame_size < 0) {
3650 dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); 3651 dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
3651 return -EINVAL; 3652 return -EINVAL;
3652 } 3653 }
3653 bclk_ms = frame_size > 32; 3654 bclk_ms = frame_size > 32;
3654 rt5677->bclk[dai->id] = rt5677->lrck[dai->id] * (32 << bclk_ms); 3655 rt5677->bclk[dai->id] = rt5677->lrck[dai->id] * (32 << bclk_ms);
3655 3656
3656 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", 3657 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n",
3657 rt5677->bclk[dai->id], rt5677->lrck[dai->id]); 3658 rt5677->bclk[dai->id], rt5677->lrck[dai->id]);
3658 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", 3659 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n",
3659 bclk_ms, pre_div, dai->id); 3660 bclk_ms, pre_div, dai->id);
3660 3661
3661 switch (params_width(params)) { 3662 switch (params_width(params)) {
3662 case 16: 3663 case 16:
3663 break; 3664 break;
3664 case 20: 3665 case 20:
3665 val_len |= RT5677_I2S_DL_20; 3666 val_len |= RT5677_I2S_DL_20;
3666 break; 3667 break;
3667 case 24: 3668 case 24:
3668 val_len |= RT5677_I2S_DL_24; 3669 val_len |= RT5677_I2S_DL_24;
3669 break; 3670 break;
3670 case 8: 3671 case 8:
3671 val_len |= RT5677_I2S_DL_8; 3672 val_len |= RT5677_I2S_DL_8;
3672 break; 3673 break;
3673 default: 3674 default:
3674 return -EINVAL; 3675 return -EINVAL;
3675 } 3676 }
3676 3677
3677 switch (dai->id) { 3678 switch (dai->id) {
3678 case RT5677_AIF1: 3679 case RT5677_AIF1:
3679 mask_clk = RT5677_I2S_PD1_MASK; 3680 mask_clk = RT5677_I2S_PD1_MASK;
3680 val_clk = pre_div << RT5677_I2S_PD1_SFT; 3681 val_clk = pre_div << RT5677_I2S_PD1_SFT;
3681 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP, 3682 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
3682 RT5677_I2S_DL_MASK, val_len); 3683 RT5677_I2S_DL_MASK, val_len);
3683 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, 3684 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3684 mask_clk, val_clk); 3685 mask_clk, val_clk);
3685 break; 3686 break;
3686 case RT5677_AIF2: 3687 case RT5677_AIF2:
3687 mask_clk = RT5677_I2S_PD2_MASK; 3688 mask_clk = RT5677_I2S_PD2_MASK;
3688 val_clk = pre_div << RT5677_I2S_PD2_SFT; 3689 val_clk = pre_div << RT5677_I2S_PD2_SFT;
3689 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP, 3690 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
3690 RT5677_I2S_DL_MASK, val_len); 3691 RT5677_I2S_DL_MASK, val_len);
3691 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, 3692 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3692 mask_clk, val_clk); 3693 mask_clk, val_clk);
3693 break; 3694 break;
3694 case RT5677_AIF3: 3695 case RT5677_AIF3:
3695 mask_clk = RT5677_I2S_BCLK_MS3_MASK | RT5677_I2S_PD3_MASK; 3696 mask_clk = RT5677_I2S_BCLK_MS3_MASK | RT5677_I2S_PD3_MASK;
3696 val_clk = bclk_ms << RT5677_I2S_BCLK_MS3_SFT | 3697 val_clk = bclk_ms << RT5677_I2S_BCLK_MS3_SFT |
3697 pre_div << RT5677_I2S_PD3_SFT; 3698 pre_div << RT5677_I2S_PD3_SFT;
3698 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP, 3699 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
3699 RT5677_I2S_DL_MASK, val_len); 3700 RT5677_I2S_DL_MASK, val_len);
3700 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, 3701 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3701 mask_clk, val_clk); 3702 mask_clk, val_clk);
3702 break; 3703 break;
3703 case RT5677_AIF4: 3704 case RT5677_AIF4:
3704 mask_clk = RT5677_I2S_BCLK_MS4_MASK | RT5677_I2S_PD4_MASK; 3705 mask_clk = RT5677_I2S_BCLK_MS4_MASK | RT5677_I2S_PD4_MASK;
3705 val_clk = bclk_ms << RT5677_I2S_BCLK_MS4_SFT | 3706 val_clk = bclk_ms << RT5677_I2S_BCLK_MS4_SFT |
3706 pre_div << RT5677_I2S_PD4_SFT; 3707 pre_div << RT5677_I2S_PD4_SFT;
3707 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP, 3708 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
3708 RT5677_I2S_DL_MASK, val_len); 3709 RT5677_I2S_DL_MASK, val_len);
3709 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, 3710 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
3710 mask_clk, val_clk); 3711 mask_clk, val_clk);
3711 break; 3712 break;
3712 default: 3713 default:
3713 break; 3714 break;
3714 } 3715 }
3715 3716
3716 return 0; 3717 return 0;
3717 } 3718 }
3718 3719
3719 static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) 3720 static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
3720 { 3721 {
3721 struct snd_soc_codec *codec = dai->codec; 3722 struct snd_soc_codec *codec = dai->codec;
3722 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 3723 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3723 unsigned int reg_val = 0; 3724 unsigned int reg_val = 0;
3724 3725
3725 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 3726 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
3726 case SND_SOC_DAIFMT_CBM_CFM: 3727 case SND_SOC_DAIFMT_CBM_CFM:
3727 rt5677->master[dai->id] = 1; 3728 rt5677->master[dai->id] = 1;
3728 break; 3729 break;
3729 case SND_SOC_DAIFMT_CBS_CFS: 3730 case SND_SOC_DAIFMT_CBS_CFS:
3730 reg_val |= RT5677_I2S_MS_S; 3731 reg_val |= RT5677_I2S_MS_S;
3731 rt5677->master[dai->id] = 0; 3732 rt5677->master[dai->id] = 0;
3732 break; 3733 break;
3733 default: 3734 default:
3734 return -EINVAL; 3735 return -EINVAL;
3735 } 3736 }
3736 3737
3737 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 3738 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
3738 case SND_SOC_DAIFMT_NB_NF: 3739 case SND_SOC_DAIFMT_NB_NF:
3739 break; 3740 break;
3740 case SND_SOC_DAIFMT_IB_NF: 3741 case SND_SOC_DAIFMT_IB_NF:
3741 reg_val |= RT5677_I2S_BP_INV; 3742 reg_val |= RT5677_I2S_BP_INV;
3742 break; 3743 break;
3743 default: 3744 default:
3744 return -EINVAL; 3745 return -EINVAL;
3745 } 3746 }
3746 3747
3747 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 3748 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
3748 case SND_SOC_DAIFMT_I2S: 3749 case SND_SOC_DAIFMT_I2S:
3749 break; 3750 break;
3750 case SND_SOC_DAIFMT_LEFT_J: 3751 case SND_SOC_DAIFMT_LEFT_J:
3751 reg_val |= RT5677_I2S_DF_LEFT; 3752 reg_val |= RT5677_I2S_DF_LEFT;
3752 break; 3753 break;
3753 case SND_SOC_DAIFMT_DSP_A: 3754 case SND_SOC_DAIFMT_DSP_A:
3754 reg_val |= RT5677_I2S_DF_PCM_A; 3755 reg_val |= RT5677_I2S_DF_PCM_A;
3755 break; 3756 break;
3756 case SND_SOC_DAIFMT_DSP_B: 3757 case SND_SOC_DAIFMT_DSP_B:
3757 reg_val |= RT5677_I2S_DF_PCM_B; 3758 reg_val |= RT5677_I2S_DF_PCM_B;
3758 break; 3759 break;
3759 default: 3760 default:
3760 return -EINVAL; 3761 return -EINVAL;
3761 } 3762 }
3762 3763
3763 switch (dai->id) { 3764 switch (dai->id) {
3764 case RT5677_AIF1: 3765 case RT5677_AIF1:
3765 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP, 3766 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
3766 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK | 3767 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3767 RT5677_I2S_DF_MASK, reg_val); 3768 RT5677_I2S_DF_MASK, reg_val);
3768 break; 3769 break;
3769 case RT5677_AIF2: 3770 case RT5677_AIF2:
3770 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP, 3771 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
3771 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK | 3772 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3772 RT5677_I2S_DF_MASK, reg_val); 3773 RT5677_I2S_DF_MASK, reg_val);
3773 break; 3774 break;
3774 case RT5677_AIF3: 3775 case RT5677_AIF3:
3775 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP, 3776 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
3776 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK | 3777 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3777 RT5677_I2S_DF_MASK, reg_val); 3778 RT5677_I2S_DF_MASK, reg_val);
3778 break; 3779 break;
3779 case RT5677_AIF4: 3780 case RT5677_AIF4:
3780 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP, 3781 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
3781 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK | 3782 RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
3782 RT5677_I2S_DF_MASK, reg_val); 3783 RT5677_I2S_DF_MASK, reg_val);
3783 break; 3784 break;
3784 default: 3785 default:
3785 break; 3786 break;
3786 } 3787 }
3787 3788
3788 3789
3789 return 0; 3790 return 0;
3790 } 3791 }
3791 3792
3792 static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai, 3793 static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai,
3793 int clk_id, unsigned int freq, int dir) 3794 int clk_id, unsigned int freq, int dir)
3794 { 3795 {
3795 struct snd_soc_codec *codec = dai->codec; 3796 struct snd_soc_codec *codec = dai->codec;
3796 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 3797 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3797 unsigned int reg_val = 0; 3798 unsigned int reg_val = 0;
3798 3799
3799 if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src) 3800 if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src)
3800 return 0; 3801 return 0;
3801 3802
3802 switch (clk_id) { 3803 switch (clk_id) {
3803 case RT5677_SCLK_S_MCLK: 3804 case RT5677_SCLK_S_MCLK:
3804 reg_val |= RT5677_SCLK_SRC_MCLK; 3805 reg_val |= RT5677_SCLK_SRC_MCLK;
3805 break; 3806 break;
3806 case RT5677_SCLK_S_PLL1: 3807 case RT5677_SCLK_S_PLL1:
3807 reg_val |= RT5677_SCLK_SRC_PLL1; 3808 reg_val |= RT5677_SCLK_SRC_PLL1;
3808 break; 3809 break;
3809 case RT5677_SCLK_S_RCCLK: 3810 case RT5677_SCLK_S_RCCLK:
3810 reg_val |= RT5677_SCLK_SRC_RCCLK; 3811 reg_val |= RT5677_SCLK_SRC_RCCLK;
3811 break; 3812 break;
3812 default: 3813 default:
3813 dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); 3814 dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
3814 return -EINVAL; 3815 return -EINVAL;
3815 } 3816 }
3816 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 3817 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
3817 RT5677_SCLK_SRC_MASK, reg_val); 3818 RT5677_SCLK_SRC_MASK, reg_val);
3818 rt5677->sysclk = freq; 3819 rt5677->sysclk = freq;
3819 rt5677->sysclk_src = clk_id; 3820 rt5677->sysclk_src = clk_id;
3820 3821
3821 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); 3822 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id);
3822 3823
3823 return 0; 3824 return 0;
3824 } 3825 }
3825 3826
3826 /** 3827 /**
3827 * rt5677_pll_calc - Calcualte PLL M/N/K code. 3828 * rt5677_pll_calc - Calcualte PLL M/N/K code.
3828 * @freq_in: external clock provided to codec. 3829 * @freq_in: external clock provided to codec.
3829 * @freq_out: target clock which codec works on. 3830 * @freq_out: target clock which codec works on.
3830 * @pll_code: Pointer to structure with M, N, K, bypass K and bypass M flag. 3831 * @pll_code: Pointer to structure with M, N, K, bypass K and bypass M flag.
3831 * 3832 *
3832 * Calcualte M/N/K code and bypass K/M flag to configure PLL for codec. 3833 * Calcualte M/N/K code and bypass K/M flag to configure PLL for codec.
3833 * 3834 *
3834 * Returns 0 for success or negative error code. 3835 * Returns 0 for success or negative error code.
3835 */ 3836 */
3836 static int rt5677_pll_calc(const unsigned int freq_in, 3837 static int rt5677_pll_calc(const unsigned int freq_in,
3837 const unsigned int freq_out, struct rl6231_pll_code *pll_code) 3838 const unsigned int freq_out, struct rl6231_pll_code *pll_code)
3838 { 3839 {
3839 if (RT5677_PLL_INP_MIN > freq_in) 3840 if (RT5677_PLL_INP_MIN > freq_in)
3840 return -EINVAL; 3841 return -EINVAL;
3841 3842
3842 return rl6231_pll_calc(freq_in, freq_out, pll_code); 3843 return rl6231_pll_calc(freq_in, freq_out, pll_code);
3843 } 3844 }
3844 3845
3845 static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, 3846 static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
3846 unsigned int freq_in, unsigned int freq_out) 3847 unsigned int freq_in, unsigned int freq_out)
3847 { 3848 {
3848 struct snd_soc_codec *codec = dai->codec; 3849 struct snd_soc_codec *codec = dai->codec;
3849 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 3850 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3850 struct rl6231_pll_code pll_code; 3851 struct rl6231_pll_code pll_code;
3851 int ret; 3852 int ret;
3852 3853
3853 if (source == rt5677->pll_src && freq_in == rt5677->pll_in && 3854 if (source == rt5677->pll_src && freq_in == rt5677->pll_in &&
3854 freq_out == rt5677->pll_out) 3855 freq_out == rt5677->pll_out)
3855 return 0; 3856 return 0;
3856 3857
3857 if (!freq_in || !freq_out) { 3858 if (!freq_in || !freq_out) {
3858 dev_dbg(codec->dev, "PLL disabled\n"); 3859 dev_dbg(codec->dev, "PLL disabled\n");
3859 3860
3860 rt5677->pll_in = 0; 3861 rt5677->pll_in = 0;
3861 rt5677->pll_out = 0; 3862 rt5677->pll_out = 0;
3862 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 3863 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
3863 RT5677_SCLK_SRC_MASK, RT5677_SCLK_SRC_MCLK); 3864 RT5677_SCLK_SRC_MASK, RT5677_SCLK_SRC_MCLK);
3864 return 0; 3865 return 0;
3865 } 3866 }
3866 3867
3867 switch (source) { 3868 switch (source) {
3868 case RT5677_PLL1_S_MCLK: 3869 case RT5677_PLL1_S_MCLK:
3869 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 3870 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
3870 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_MCLK); 3871 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_MCLK);
3871 break; 3872 break;
3872 case RT5677_PLL1_S_BCLK1: 3873 case RT5677_PLL1_S_BCLK1:
3873 case RT5677_PLL1_S_BCLK2: 3874 case RT5677_PLL1_S_BCLK2:
3874 case RT5677_PLL1_S_BCLK3: 3875 case RT5677_PLL1_S_BCLK3:
3875 case RT5677_PLL1_S_BCLK4: 3876 case RT5677_PLL1_S_BCLK4:
3876 switch (dai->id) { 3877 switch (dai->id) {
3877 case RT5677_AIF1: 3878 case RT5677_AIF1:
3878 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 3879 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
3879 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK1); 3880 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK1);
3880 break; 3881 break;
3881 case RT5677_AIF2: 3882 case RT5677_AIF2:
3882 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 3883 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
3883 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK2); 3884 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK2);
3884 break; 3885 break;
3885 case RT5677_AIF3: 3886 case RT5677_AIF3:
3886 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 3887 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
3887 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK3); 3888 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK3);
3888 break; 3889 break;
3889 case RT5677_AIF4: 3890 case RT5677_AIF4:
3890 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 3891 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
3891 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK4); 3892 RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK4);
3892 break; 3893 break;
3893 default: 3894 default:
3894 break; 3895 break;
3895 } 3896 }
3896 break; 3897 break;
3897 default: 3898 default:
3898 dev_err(codec->dev, "Unknown PLL source %d\n", source); 3899 dev_err(codec->dev, "Unknown PLL source %d\n", source);
3899 return -EINVAL; 3900 return -EINVAL;
3900 } 3901 }
3901 3902
3902 ret = rt5677_pll_calc(freq_in, freq_out, &pll_code); 3903 ret = rt5677_pll_calc(freq_in, freq_out, &pll_code);
3903 if (ret < 0) { 3904 if (ret < 0) {
3904 dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); 3905 dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
3905 return ret; 3906 return ret;
3906 } 3907 }
3907 3908
3908 dev_dbg(codec->dev, "m_bypass=%d m=%d n=%d k=%d\n", 3909 dev_dbg(codec->dev, "m_bypass=%d m=%d n=%d k=%d\n",
3909 pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), 3910 pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
3910 pll_code.n_code, pll_code.k_code); 3911 pll_code.n_code, pll_code.k_code);
3911 3912
3912 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1, 3913 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1,
3913 pll_code.n_code << RT5677_PLL_N_SFT | pll_code.k_code); 3914 pll_code.n_code << RT5677_PLL_N_SFT | pll_code.k_code);
3914 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2, 3915 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2,
3915 (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT | 3916 (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT |
3916 pll_code.m_bp << RT5677_PLL_M_BP_SFT); 3917 pll_code.m_bp << RT5677_PLL_M_BP_SFT);
3917 3918
3918 rt5677->pll_in = freq_in; 3919 rt5677->pll_in = freq_in;
3919 rt5677->pll_out = freq_out; 3920 rt5677->pll_out = freq_out;
3920 rt5677->pll_src = source; 3921 rt5677->pll_src = source;
3921 3922
3922 return 0; 3923 return 0;
3923 } 3924 }
3924 3925
3925 static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 3926 static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3926 unsigned int rx_mask, int slots, int slot_width) 3927 unsigned int rx_mask, int slots, int slot_width)
3927 { 3928 {
3928 struct snd_soc_codec *codec = dai->codec; 3929 struct snd_soc_codec *codec = dai->codec;
3929 unsigned int val = 0; 3930 unsigned int val = 0;
3930 3931
3931 if (rx_mask || tx_mask) 3932 if (rx_mask || tx_mask)
3932 val |= (1 << 12); 3933 val |= (1 << 12);
3933 3934
3934 switch (slots) { 3935 switch (slots) {
3935 case 4: 3936 case 4:
3936 val |= (1 << 10); 3937 val |= (1 << 10);
3937 break; 3938 break;
3938 case 6: 3939 case 6:
3939 val |= (2 << 10); 3940 val |= (2 << 10);
3940 break; 3941 break;
3941 case 8: 3942 case 8:
3942 val |= (3 << 10); 3943 val |= (3 << 10);
3943 break; 3944 break;
3944 case 2: 3945 case 2:
3945 default: 3946 default:
3946 break; 3947 break;
3947 } 3948 }
3948 3949
3949 switch (slot_width) { 3950 switch (slot_width) {
3950 case 20: 3951 case 20:
3951 val |= (1 << 8); 3952 val |= (1 << 8);
3952 break; 3953 break;
3953 case 24: 3954 case 24:
3954 val |= (2 << 8); 3955 val |= (2 << 8);
3955 break; 3956 break;
3956 case 32: 3957 case 32:
3957 val |= (3 << 8); 3958 val |= (3 << 8);
3958 break; 3959 break;
3959 case 16: 3960 case 16:
3960 default: 3961 default:
3961 break; 3962 break;
3962 } 3963 }
3963 3964
3964 switch (dai->id) { 3965 switch (dai->id) {
3965 case RT5677_AIF1: 3966 case RT5677_AIF1:
3966 snd_soc_update_bits(codec, RT5677_TDM1_CTRL1, 0x1f00, val); 3967 snd_soc_update_bits(codec, RT5677_TDM1_CTRL1, 0x1f00, val);
3967 break; 3968 break;
3968 case RT5677_AIF2: 3969 case RT5677_AIF2:
3969 snd_soc_update_bits(codec, RT5677_TDM2_CTRL1, 0x1f00, val); 3970 snd_soc_update_bits(codec, RT5677_TDM2_CTRL1, 0x1f00, val);
3970 break; 3971 break;
3971 default: 3972 default:
3972 break; 3973 break;
3973 } 3974 }
3974 3975
3975 return 0; 3976 return 0;
3976 } 3977 }
3977 3978
3978 static int rt5677_set_bias_level(struct snd_soc_codec *codec, 3979 static int rt5677_set_bias_level(struct snd_soc_codec *codec,
3979 enum snd_soc_bias_level level) 3980 enum snd_soc_bias_level level)
3980 { 3981 {
3981 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 3982 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
3982 3983
3983 switch (level) { 3984 switch (level) {
3984 case SND_SOC_BIAS_ON: 3985 case SND_SOC_BIAS_ON:
3985 break; 3986 break;
3986 3987
3987 case SND_SOC_BIAS_PREPARE: 3988 case SND_SOC_BIAS_PREPARE:
3988 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) { 3989 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) {
3989 rt5677_set_dsp_vad(codec, false); 3990 rt5677_set_dsp_vad(codec, false);
3990 3991
3991 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, 3992 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
3992 RT5677_LDO1_SEL_MASK | RT5677_LDO2_SEL_MASK, 3993 RT5677_LDO1_SEL_MASK | RT5677_LDO2_SEL_MASK,
3993 0x0055); 3994 0x0055);
3994 regmap_update_bits(rt5677->regmap, 3995 regmap_update_bits(rt5677->regmap,
3995 RT5677_PR_BASE + RT5677_BIAS_CUR4, 3996 RT5677_PR_BASE + RT5677_BIAS_CUR4,
3996 0x0f00, 0x0f00); 3997 0x0f00, 0x0f00);
3997 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, 3998 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
3998 RT5677_PWR_FV1 | RT5677_PWR_FV2 | 3999 RT5677_PWR_FV1 | RT5677_PWR_FV2 |
3999 RT5677_PWR_VREF1 | RT5677_PWR_MB | 4000 RT5677_PWR_VREF1 | RT5677_PWR_MB |
4000 RT5677_PWR_BG | RT5677_PWR_VREF2, 4001 RT5677_PWR_BG | RT5677_PWR_VREF2,
4001 RT5677_PWR_VREF1 | RT5677_PWR_MB | 4002 RT5677_PWR_VREF1 | RT5677_PWR_MB |
4002 RT5677_PWR_BG | RT5677_PWR_VREF2); 4003 RT5677_PWR_BG | RT5677_PWR_VREF2);
4003 rt5677->is_vref_slow = false; 4004 rt5677->is_vref_slow = false;
4004 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 4005 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
4005 RT5677_PWR_CORE, RT5677_PWR_CORE); 4006 RT5677_PWR_CORE, RT5677_PWR_CORE);
4006 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 4007 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC,
4007 0x1, 0x1); 4008 0x1, 0x1);
4008 } 4009 }
4009 break; 4010 break;
4010 4011
4011 case SND_SOC_BIAS_STANDBY: 4012 case SND_SOC_BIAS_STANDBY:
4012 break; 4013 break;
4013 4014
4014 case SND_SOC_BIAS_OFF: 4015 case SND_SOC_BIAS_OFF:
4015 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0); 4016 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0);
4016 regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000); 4017 regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000);
4017 regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000); 4018 regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000);
4018 regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0022); 4019 regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0022);
4019 regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000); 4020 regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000);
4020 regmap_update_bits(rt5677->regmap, 4021 regmap_update_bits(rt5677->regmap,
4021 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000); 4022 RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000);
4022 4023
4023 if (rt5677->dsp_vad_en) 4024 if (rt5677->dsp_vad_en)
4024 rt5677_set_dsp_vad(codec, true); 4025 rt5677_set_dsp_vad(codec, true);
4025 break; 4026 break;
4026 4027
4027 default: 4028 default:
4028 break; 4029 break;
4029 } 4030 }
4030 codec->dapm.bias_level = level; 4031 codec->dapm.bias_level = level;
4031 4032
4032 return 0; 4033 return 0;
4033 } 4034 }
4034 4035
4035 #ifdef CONFIG_GPIOLIB 4036 #ifdef CONFIG_GPIOLIB
4036 static inline struct rt5677_priv *gpio_to_rt5677(struct gpio_chip *chip) 4037 static inline struct rt5677_priv *gpio_to_rt5677(struct gpio_chip *chip)
4037 { 4038 {
4038 return container_of(chip, struct rt5677_priv, gpio_chip); 4039 return container_of(chip, struct rt5677_priv, gpio_chip);
4039 } 4040 }
4040 4041
4041 static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 4042 static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
4042 { 4043 {
4043 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4044 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4044 4045
4045 switch (offset) { 4046 switch (offset) {
4046 case RT5677_GPIO1 ... RT5677_GPIO5: 4047 case RT5677_GPIO1 ... RT5677_GPIO5:
4047 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, 4048 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4048 0x1 << (offset * 3 + 1), !!value << (offset * 3 + 1)); 4049 0x1 << (offset * 3 + 1), !!value << (offset * 3 + 1));
4049 break; 4050 break;
4050 4051
4051 case RT5677_GPIO6: 4052 case RT5677_GPIO6:
4052 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, 4053 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4053 RT5677_GPIO6_OUT_MASK, !!value << RT5677_GPIO6_OUT_SFT); 4054 RT5677_GPIO6_OUT_MASK, !!value << RT5677_GPIO6_OUT_SFT);
4054 break; 4055 break;
4055 4056
4056 default: 4057 default:
4057 break; 4058 break;
4058 } 4059 }
4059 } 4060 }
4060 4061
4061 static int rt5677_gpio_direction_out(struct gpio_chip *chip, 4062 static int rt5677_gpio_direction_out(struct gpio_chip *chip,
4062 unsigned offset, int value) 4063 unsigned offset, int value)
4063 { 4064 {
4064 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4065 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4065 4066
4066 switch (offset) { 4067 switch (offset) {
4067 case RT5677_GPIO1 ... RT5677_GPIO5: 4068 case RT5677_GPIO1 ... RT5677_GPIO5:
4068 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, 4069 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4069 0x3 << (offset * 3 + 1), 4070 0x3 << (offset * 3 + 1),
4070 (0x2 | !!value) << (offset * 3 + 1)); 4071 (0x2 | !!value) << (offset * 3 + 1));
4071 break; 4072 break;
4072 4073
4073 case RT5677_GPIO6: 4074 case RT5677_GPIO6:
4074 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, 4075 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4075 RT5677_GPIO6_DIR_MASK | RT5677_GPIO6_OUT_MASK, 4076 RT5677_GPIO6_DIR_MASK | RT5677_GPIO6_OUT_MASK,
4076 RT5677_GPIO6_DIR_OUT | !!value << RT5677_GPIO6_OUT_SFT); 4077 RT5677_GPIO6_DIR_OUT | !!value << RT5677_GPIO6_OUT_SFT);
4077 break; 4078 break;
4078 4079
4079 default: 4080 default:
4080 break; 4081 break;
4081 } 4082 }
4082 4083
4083 return 0; 4084 return 0;
4084 } 4085 }
4085 4086
4086 static int rt5677_gpio_get(struct gpio_chip *chip, unsigned offset) 4087 static int rt5677_gpio_get(struct gpio_chip *chip, unsigned offset)
4087 { 4088 {
4088 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4089 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4089 int value, ret; 4090 int value, ret;
4090 4091
4091 ret = regmap_read(rt5677->regmap, RT5677_GPIO_ST, &value); 4092 ret = regmap_read(rt5677->regmap, RT5677_GPIO_ST, &value);
4092 if (ret < 0) 4093 if (ret < 0)
4093 return ret; 4094 return ret;
4094 4095
4095 return (value & (0x1 << offset)) >> offset; 4096 return (value & (0x1 << offset)) >> offset;
4096 } 4097 }
4097 4098
4098 static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset) 4099 static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
4099 { 4100 {
4100 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4101 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4101 4102
4102 switch (offset) { 4103 switch (offset) {
4103 case RT5677_GPIO1 ... RT5677_GPIO5: 4104 case RT5677_GPIO1 ... RT5677_GPIO5:
4104 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, 4105 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4105 0x1 << (offset * 3 + 2), 0x0); 4106 0x1 << (offset * 3 + 2), 0x0);
4106 break; 4107 break;
4107 4108
4108 case RT5677_GPIO6: 4109 case RT5677_GPIO6:
4109 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, 4110 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
4110 RT5677_GPIO6_DIR_MASK, RT5677_GPIO6_DIR_IN); 4111 RT5677_GPIO6_DIR_MASK, RT5677_GPIO6_DIR_IN);
4111 break; 4112 break;
4112 4113
4113 default: 4114 default:
4114 break; 4115 break;
4115 } 4116 }
4116 4117
4117 return 0; 4118 return 0;
4118 } 4119 }
4119 4120
4120 /** Configures the gpio as 4121 /** Configures the gpio as
4121 * 0 - floating 4122 * 0 - floating
4122 * 1 - pull down 4123 * 1 - pull down
4123 * 2 - pull up 4124 * 2 - pull up
4124 */ 4125 */
4125 static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset, 4126 static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
4126 int value) 4127 int value)
4127 { 4128 {
4128 int shift; 4129 int shift;
4129 4130
4130 switch (offset) { 4131 switch (offset) {
4131 case RT5677_GPIO1 ... RT5677_GPIO2: 4132 case RT5677_GPIO1 ... RT5677_GPIO2:
4132 shift = 2 * (1 - offset); 4133 shift = 2 * (1 - offset);
4133 regmap_update_bits(rt5677->regmap, 4134 regmap_update_bits(rt5677->regmap,
4134 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL2, 4135 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL2,
4135 0x3 << shift, 4136 0x3 << shift,
4136 (value & 0x3) << shift); 4137 (value & 0x3) << shift);
4137 break; 4138 break;
4138 4139
4139 case RT5677_GPIO3 ... RT5677_GPIO6: 4140 case RT5677_GPIO3 ... RT5677_GPIO6:
4140 shift = 2 * (9 - offset); 4141 shift = 2 * (9 - offset);
4141 regmap_update_bits(rt5677->regmap, 4142 regmap_update_bits(rt5677->regmap,
4142 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL3, 4143 RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL3,
4143 0x3 << shift, 4144 0x3 << shift,
4144 (value & 0x3) << shift); 4145 (value & 0x3) << shift);
4145 break; 4146 break;
4146 4147
4147 default: 4148 default:
4148 break; 4149 break;
4149 } 4150 }
4150 } 4151 }
4151 4152
4152 static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset) 4153 static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset)
4153 { 4154 {
4154 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4155 struct rt5677_priv *rt5677 = gpio_to_rt5677(chip);
4155 struct regmap_irq_chip_data *data = rt5677->irq_data; 4156 struct regmap_irq_chip_data *data = rt5677->irq_data;
4156 int irq; 4157 int irq;
4157 4158
4158 if (offset >= RT5677_GPIO1 && offset <= RT5677_GPIO3) { 4159 if (offset >= RT5677_GPIO1 && offset <= RT5677_GPIO3) {
4159 if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) || 4160 if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) ||
4160 (rt5677->pdata.jd1_gpio == 2 && 4161 (rt5677->pdata.jd1_gpio == 2 &&
4161 offset == RT5677_GPIO2) || 4162 offset == RT5677_GPIO2) ||
4162 (rt5677->pdata.jd1_gpio == 3 && 4163 (rt5677->pdata.jd1_gpio == 3 &&
4163 offset == RT5677_GPIO3)) { 4164 offset == RT5677_GPIO3)) {
4164 irq = RT5677_IRQ_JD1; 4165 irq = RT5677_IRQ_JD1;
4165 } else { 4166 } else {
4166 return -ENXIO; 4167 return -ENXIO;
4167 } 4168 }
4168 } 4169 }
4169 4170
4170 if (offset >= RT5677_GPIO4 && offset <= RT5677_GPIO6) { 4171 if (offset >= RT5677_GPIO4 && offset <= RT5677_GPIO6) {
4171 if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) || 4172 if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) ||
4172 (rt5677->pdata.jd2_gpio == 2 && 4173 (rt5677->pdata.jd2_gpio == 2 &&
4173 offset == RT5677_GPIO5) || 4174 offset == RT5677_GPIO5) ||
4174 (rt5677->pdata.jd2_gpio == 3 && 4175 (rt5677->pdata.jd2_gpio == 3 &&
4175 offset == RT5677_GPIO6)) { 4176 offset == RT5677_GPIO6)) {
4176 irq = RT5677_IRQ_JD2; 4177 irq = RT5677_IRQ_JD2;
4177 } else if ((rt5677->pdata.jd3_gpio == 1 && 4178 } else if ((rt5677->pdata.jd3_gpio == 1 &&
4178 offset == RT5677_GPIO4) || 4179 offset == RT5677_GPIO4) ||
4179 (rt5677->pdata.jd3_gpio == 2 && 4180 (rt5677->pdata.jd3_gpio == 2 &&
4180 offset == RT5677_GPIO5) || 4181 offset == RT5677_GPIO5) ||
4181 (rt5677->pdata.jd3_gpio == 3 && 4182 (rt5677->pdata.jd3_gpio == 3 &&
4182 offset == RT5677_GPIO6)) { 4183 offset == RT5677_GPIO6)) {
4183 irq = RT5677_IRQ_JD3; 4184 irq = RT5677_IRQ_JD3;
4184 } else { 4185 } else {
4185 return -ENXIO; 4186 return -ENXIO;
4186 } 4187 }
4187 } 4188 }
4188 4189
4189 return regmap_irq_get_virq(data, irq); 4190 return regmap_irq_get_virq(data, irq);
4190 } 4191 }
4191 4192
4192 static struct gpio_chip rt5677_template_chip = { 4193 static struct gpio_chip rt5677_template_chip = {
4193 .label = "rt5677", 4194 .label = "rt5677",
4194 .owner = THIS_MODULE, 4195 .owner = THIS_MODULE,
4195 .direction_output = rt5677_gpio_direction_out, 4196 .direction_output = rt5677_gpio_direction_out,
4196 .set = rt5677_gpio_set, 4197 .set = rt5677_gpio_set,
4197 .direction_input = rt5677_gpio_direction_in, 4198 .direction_input = rt5677_gpio_direction_in,
4198 .get = rt5677_gpio_get, 4199 .get = rt5677_gpio_get,
4199 .to_irq = rt5677_to_irq, 4200 .to_irq = rt5677_to_irq,
4200 .can_sleep = 1, 4201 .can_sleep = 1,
4201 }; 4202 };
4202 4203
4203 static void rt5677_init_gpio(struct i2c_client *i2c) 4204 static void rt5677_init_gpio(struct i2c_client *i2c)
4204 { 4205 {
4205 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); 4206 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4206 int ret; 4207 int ret;
4207 4208
4208 rt5677->gpio_chip = rt5677_template_chip; 4209 rt5677->gpio_chip = rt5677_template_chip;
4209 rt5677->gpio_chip.ngpio = RT5677_GPIO_NUM; 4210 rt5677->gpio_chip.ngpio = RT5677_GPIO_NUM;
4210 rt5677->gpio_chip.dev = &i2c->dev; 4211 rt5677->gpio_chip.dev = &i2c->dev;
4211 rt5677->gpio_chip.base = -1; 4212 rt5677->gpio_chip.base = -1;
4212 4213
4213 ret = gpiochip_add(&rt5677->gpio_chip); 4214 ret = gpiochip_add(&rt5677->gpio_chip);
4214 if (ret != 0) 4215 if (ret != 0)
4215 dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret); 4216 dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret);
4216 } 4217 }
4217 4218
4218 static void rt5677_free_gpio(struct i2c_client *i2c) 4219 static void rt5677_free_gpio(struct i2c_client *i2c)
4219 { 4220 {
4220 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); 4221 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4221 4222
4222 gpiochip_remove(&rt5677->gpio_chip); 4223 gpiochip_remove(&rt5677->gpio_chip);
4223 } 4224 }
4224 #else 4225 #else
4225 static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset, 4226 static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
4226 int value) 4227 int value)
4227 { 4228 {
4228 } 4229 }
4229 4230
4230 static void rt5677_init_gpio(struct i2c_client *i2c) 4231 static void rt5677_init_gpio(struct i2c_client *i2c)
4231 { 4232 {
4232 } 4233 }
4233 4234
4234 static void rt5677_free_gpio(struct i2c_client *i2c) 4235 static void rt5677_free_gpio(struct i2c_client *i2c)
4235 { 4236 {
4236 } 4237 }
4237 #endif 4238 #endif
4238 4239
4239 static int rt5677_probe(struct snd_soc_codec *codec) 4240 static int rt5677_probe(struct snd_soc_codec *codec)
4240 { 4241 {
4241 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4242 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4242 int i; 4243 int i;
4243 4244
4244 rt5677->codec = codec; 4245 rt5677->codec = codec;
4245 4246
4246 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) { 4247 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
4247 snd_soc_dapm_add_routes(&codec->dapm, 4248 snd_soc_dapm_add_routes(&codec->dapm,
4248 rt5677_dmic2_clk_2, 4249 rt5677_dmic2_clk_2,
4249 ARRAY_SIZE(rt5677_dmic2_clk_2)); 4250 ARRAY_SIZE(rt5677_dmic2_clk_2));
4250 } else { /*use dmic1 clock by default*/ 4251 } else { /*use dmic1 clock by default*/
4251 snd_soc_dapm_add_routes(&codec->dapm, 4252 snd_soc_dapm_add_routes(&codec->dapm,
4252 rt5677_dmic2_clk_1, 4253 rt5677_dmic2_clk_1,
4253 ARRAY_SIZE(rt5677_dmic2_clk_1)); 4254 ARRAY_SIZE(rt5677_dmic2_clk_1));
4254 } 4255 }
4255 4256
4256 rt5677_set_bias_level(codec, SND_SOC_BIAS_OFF); 4257 rt5677_set_bias_level(codec, SND_SOC_BIAS_OFF);
4257 4258
4258 regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020); 4259 regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020);
4259 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00); 4260 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00);
4260 4261
4261 for (i = 0; i < RT5677_GPIO_NUM; i++) 4262 for (i = 0; i < RT5677_GPIO_NUM; i++)
4262 rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]); 4263 rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]);
4263 4264
4264 if (rt5677->irq_data) { 4265 if (rt5677->irq_data) {
4265 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, 0x8000, 4266 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, 0x8000,
4266 0x8000); 4267 0x8000);
4267 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x0018, 4268 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x0018,
4268 0x0008); 4269 0x0008);
4269 4270
4270 if (rt5677->pdata.jd1_gpio) 4271 if (rt5677->pdata.jd1_gpio)
4271 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1, 4272 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4272 RT5677_SEL_GPIO_JD1_MASK, 4273 RT5677_SEL_GPIO_JD1_MASK,
4273 rt5677->pdata.jd1_gpio << 4274 rt5677->pdata.jd1_gpio <<
4274 RT5677_SEL_GPIO_JD1_SFT); 4275 RT5677_SEL_GPIO_JD1_SFT);
4275 4276
4276 if (rt5677->pdata.jd2_gpio) 4277 if (rt5677->pdata.jd2_gpio)
4277 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1, 4278 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4278 RT5677_SEL_GPIO_JD2_MASK, 4279 RT5677_SEL_GPIO_JD2_MASK,
4279 rt5677->pdata.jd2_gpio << 4280 rt5677->pdata.jd2_gpio <<
4280 RT5677_SEL_GPIO_JD2_SFT); 4281 RT5677_SEL_GPIO_JD2_SFT);
4281 4282
4282 if (rt5677->pdata.jd3_gpio) 4283 if (rt5677->pdata.jd3_gpio)
4283 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1, 4284 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
4284 RT5677_SEL_GPIO_JD3_MASK, 4285 RT5677_SEL_GPIO_JD3_MASK,
4285 rt5677->pdata.jd3_gpio << 4286 rt5677->pdata.jd3_gpio <<
4286 RT5677_SEL_GPIO_JD3_SFT); 4287 RT5677_SEL_GPIO_JD3_SFT);
4287 } 4288 }
4288 4289
4289 mutex_init(&rt5677->dsp_cmd_lock); 4290 mutex_init(&rt5677->dsp_cmd_lock);
4290 mutex_init(&rt5677->dsp_pri_lock); 4291 mutex_init(&rt5677->dsp_pri_lock);
4291 4292
4292 return 0; 4293 return 0;
4293 } 4294 }
4294 4295
4295 static int rt5677_remove(struct snd_soc_codec *codec) 4296 static int rt5677_remove(struct snd_soc_codec *codec)
4296 { 4297 {
4297 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4298 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4298 4299
4299 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); 4300 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
4300 if (gpio_is_valid(rt5677->pow_ldo2)) 4301 if (gpio_is_valid(rt5677->pow_ldo2))
4301 gpio_set_value_cansleep(rt5677->pow_ldo2, 0); 4302 gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
4302 4303
4303 return 0; 4304 return 0;
4304 } 4305 }
4305 4306
4306 #ifdef CONFIG_PM 4307 #ifdef CONFIG_PM
4307 static int rt5677_suspend(struct snd_soc_codec *codec) 4308 static int rt5677_suspend(struct snd_soc_codec *codec)
4308 { 4309 {
4309 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4310 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4310 4311
4311 if (!rt5677->dsp_vad_en) { 4312 if (!rt5677->dsp_vad_en) {
4312 regcache_cache_only(rt5677->regmap, true); 4313 regcache_cache_only(rt5677->regmap, true);
4313 regcache_mark_dirty(rt5677->regmap); 4314 regcache_mark_dirty(rt5677->regmap);
4314 } 4315 }
4315 4316
4316 if (gpio_is_valid(rt5677->pow_ldo2)) 4317 if (gpio_is_valid(rt5677->pow_ldo2))
4317 gpio_set_value_cansleep(rt5677->pow_ldo2, 0); 4318 gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
4318 4319
4319 return 0; 4320 return 0;
4320 } 4321 }
4321 4322
4322 static int rt5677_resume(struct snd_soc_codec *codec) 4323 static int rt5677_resume(struct snd_soc_codec *codec)
4323 { 4324 {
4324 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4325 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4325 4326
4326 if (gpio_is_valid(rt5677->pow_ldo2)) { 4327 if (gpio_is_valid(rt5677->pow_ldo2)) {
4327 gpio_set_value_cansleep(rt5677->pow_ldo2, 1); 4328 gpio_set_value_cansleep(rt5677->pow_ldo2, 1);
4328 msleep(10); 4329 msleep(10);
4329 } 4330 }
4330 4331
4331 if (!rt5677->dsp_vad_en) { 4332 if (!rt5677->dsp_vad_en) {
4332 regcache_cache_only(rt5677->regmap, false); 4333 regcache_cache_only(rt5677->regmap, false);
4333 regcache_sync(rt5677->regmap); 4334 regcache_sync(rt5677->regmap);
4334 } 4335 }
4335 4336
4336 return 0; 4337 return 0;
4337 } 4338 }
4338 #else 4339 #else
4339 #define rt5677_suspend NULL 4340 #define rt5677_suspend NULL
4340 #define rt5677_resume NULL 4341 #define rt5677_resume NULL
4341 #endif 4342 #endif
4342 4343
4343 static int rt5677_read(void *context, unsigned int reg, unsigned int *val) 4344 static int rt5677_read(void *context, unsigned int reg, unsigned int *val)
4344 { 4345 {
4345 struct i2c_client *client = context; 4346 struct i2c_client *client = context;
4346 struct rt5677_priv *rt5677 = i2c_get_clientdata(client); 4347 struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
4347 4348
4348 if (rt5677->is_dsp_mode) { 4349 if (rt5677->is_dsp_mode) {
4349 if (reg > 0xff) { 4350 if (reg > 0xff) {
4350 mutex_lock(&rt5677->dsp_pri_lock); 4351 mutex_lock(&rt5677->dsp_pri_lock);
4351 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX, 4352 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
4352 reg & 0xff); 4353 reg & 0xff);
4353 rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val); 4354 rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val);
4354 mutex_unlock(&rt5677->dsp_pri_lock); 4355 mutex_unlock(&rt5677->dsp_pri_lock);
4355 } else { 4356 } else {
4356 rt5677_dsp_mode_i2c_read(rt5677, reg, val); 4357 rt5677_dsp_mode_i2c_read(rt5677, reg, val);
4357 } 4358 }
4358 } else { 4359 } else {
4359 regmap_read(rt5677->regmap_physical, reg, val); 4360 regmap_read(rt5677->regmap_physical, reg, val);
4360 } 4361 }
4361 4362
4362 return 0; 4363 return 0;
4363 } 4364 }
4364 4365
4365 static int rt5677_write(void *context, unsigned int reg, unsigned int val) 4366 static int rt5677_write(void *context, unsigned int reg, unsigned int val)
4366 { 4367 {
4367 struct i2c_client *client = context; 4368 struct i2c_client *client = context;
4368 struct rt5677_priv *rt5677 = i2c_get_clientdata(client); 4369 struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
4369 4370
4370 if (rt5677->is_dsp_mode) { 4371 if (rt5677->is_dsp_mode) {
4371 if (reg > 0xff) { 4372 if (reg > 0xff) {
4372 mutex_lock(&rt5677->dsp_pri_lock); 4373 mutex_lock(&rt5677->dsp_pri_lock);
4373 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX, 4374 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
4374 reg & 0xff); 4375 reg & 0xff);
4375 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA, 4376 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA,
4376 val); 4377 val);
4377 mutex_unlock(&rt5677->dsp_pri_lock); 4378 mutex_unlock(&rt5677->dsp_pri_lock);
4378 } else { 4379 } else {
4379 rt5677_dsp_mode_i2c_write(rt5677, reg, val); 4380 rt5677_dsp_mode_i2c_write(rt5677, reg, val);
4380 } 4381 }
4381 } else { 4382 } else {
4382 regmap_write(rt5677->regmap_physical, reg, val); 4383 regmap_write(rt5677->regmap_physical, reg, val);
4383 } 4384 }
4384 4385
4385 return 0; 4386 return 0;
4386 } 4387 }
4387 4388
4388 #define RT5677_STEREO_RATES SNDRV_PCM_RATE_8000_96000 4389 #define RT5677_STEREO_RATES SNDRV_PCM_RATE_8000_96000
4389 #define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 4390 #define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
4390 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) 4391 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
4391 4392
4392 static struct snd_soc_dai_ops rt5677_aif_dai_ops = { 4393 static struct snd_soc_dai_ops rt5677_aif_dai_ops = {
4393 .hw_params = rt5677_hw_params, 4394 .hw_params = rt5677_hw_params,
4394 .set_fmt = rt5677_set_dai_fmt, 4395 .set_fmt = rt5677_set_dai_fmt,
4395 .set_sysclk = rt5677_set_dai_sysclk, 4396 .set_sysclk = rt5677_set_dai_sysclk,
4396 .set_pll = rt5677_set_dai_pll, 4397 .set_pll = rt5677_set_dai_pll,
4397 .set_tdm_slot = rt5677_set_tdm_slot, 4398 .set_tdm_slot = rt5677_set_tdm_slot,
4398 }; 4399 };
4399 4400
4400 static struct snd_soc_dai_driver rt5677_dai[] = { 4401 static struct snd_soc_dai_driver rt5677_dai[] = {
4401 { 4402 {
4402 .name = "rt5677-aif1", 4403 .name = "rt5677-aif1",
4403 .id = RT5677_AIF1, 4404 .id = RT5677_AIF1,
4404 .playback = { 4405 .playback = {
4405 .stream_name = "AIF1 Playback", 4406 .stream_name = "AIF1 Playback",
4406 .channels_min = 1, 4407 .channels_min = 1,
4407 .channels_max = 2, 4408 .channels_max = 2,
4408 .rates = RT5677_STEREO_RATES, 4409 .rates = RT5677_STEREO_RATES,
4409 .formats = RT5677_FORMATS, 4410 .formats = RT5677_FORMATS,
4410 }, 4411 },
4411 .capture = { 4412 .capture = {
4412 .stream_name = "AIF1 Capture", 4413 .stream_name = "AIF1 Capture",
4413 .channels_min = 1, 4414 .channels_min = 1,
4414 .channels_max = 2, 4415 .channels_max = 2,
4415 .rates = RT5677_STEREO_RATES, 4416 .rates = RT5677_STEREO_RATES,
4416 .formats = RT5677_FORMATS, 4417 .formats = RT5677_FORMATS,
4417 }, 4418 },
4418 .ops = &rt5677_aif_dai_ops, 4419 .ops = &rt5677_aif_dai_ops,
4419 }, 4420 },
4420 { 4421 {
4421 .name = "rt5677-aif2", 4422 .name = "rt5677-aif2",
4422 .id = RT5677_AIF2, 4423 .id = RT5677_AIF2,
4423 .playback = { 4424 .playback = {
4424 .stream_name = "AIF2 Playback", 4425 .stream_name = "AIF2 Playback",
4425 .channels_min = 1, 4426 .channels_min = 1,
4426 .channels_max = 2, 4427 .channels_max = 2,
4427 .rates = RT5677_STEREO_RATES, 4428 .rates = RT5677_STEREO_RATES,
4428 .formats = RT5677_FORMATS, 4429 .formats = RT5677_FORMATS,
4429 }, 4430 },
4430 .capture = { 4431 .capture = {
4431 .stream_name = "AIF2 Capture", 4432 .stream_name = "AIF2 Capture",
4432 .channels_min = 1, 4433 .channels_min = 1,
4433 .channels_max = 2, 4434 .channels_max = 2,
4434 .rates = RT5677_STEREO_RATES, 4435 .rates = RT5677_STEREO_RATES,
4435 .formats = RT5677_FORMATS, 4436 .formats = RT5677_FORMATS,
4436 }, 4437 },
4437 .ops = &rt5677_aif_dai_ops, 4438 .ops = &rt5677_aif_dai_ops,
4438 }, 4439 },
4439 { 4440 {
4440 .name = "rt5677-aif3", 4441 .name = "rt5677-aif3",
4441 .id = RT5677_AIF3, 4442 .id = RT5677_AIF3,
4442 .playback = { 4443 .playback = {
4443 .stream_name = "AIF3 Playback", 4444 .stream_name = "AIF3 Playback",
4444 .channels_min = 1, 4445 .channels_min = 1,
4445 .channels_max = 2, 4446 .channels_max = 2,
4446 .rates = RT5677_STEREO_RATES, 4447 .rates = RT5677_STEREO_RATES,
4447 .formats = RT5677_FORMATS, 4448 .formats = RT5677_FORMATS,
4448 }, 4449 },
4449 .capture = { 4450 .capture = {
4450 .stream_name = "AIF3 Capture", 4451 .stream_name = "AIF3 Capture",
4451 .channels_min = 1, 4452 .channels_min = 1,
4452 .channels_max = 2, 4453 .channels_max = 2,
4453 .rates = RT5677_STEREO_RATES, 4454 .rates = RT5677_STEREO_RATES,
4454 .formats = RT5677_FORMATS, 4455 .formats = RT5677_FORMATS,
4455 }, 4456 },
4456 .ops = &rt5677_aif_dai_ops, 4457 .ops = &rt5677_aif_dai_ops,
4457 }, 4458 },
4458 { 4459 {
4459 .name = "rt5677-aif4", 4460 .name = "rt5677-aif4",
4460 .id = RT5677_AIF4, 4461 .id = RT5677_AIF4,
4461 .playback = { 4462 .playback = {
4462 .stream_name = "AIF4 Playback", 4463 .stream_name = "AIF4 Playback",
4463 .channels_min = 1, 4464 .channels_min = 1,
4464 .channels_max = 2, 4465 .channels_max = 2,
4465 .rates = RT5677_STEREO_RATES, 4466 .rates = RT5677_STEREO_RATES,
4466 .formats = RT5677_FORMATS, 4467 .formats = RT5677_FORMATS,
4467 }, 4468 },
4468 .capture = { 4469 .capture = {
4469 .stream_name = "AIF4 Capture", 4470 .stream_name = "AIF4 Capture",
4470 .channels_min = 1, 4471 .channels_min = 1,
4471 .channels_max = 2, 4472 .channels_max = 2,
4472 .rates = RT5677_STEREO_RATES, 4473 .rates = RT5677_STEREO_RATES,
4473 .formats = RT5677_FORMATS, 4474 .formats = RT5677_FORMATS,
4474 }, 4475 },
4475 .ops = &rt5677_aif_dai_ops, 4476 .ops = &rt5677_aif_dai_ops,
4476 }, 4477 },
4477 { 4478 {
4478 .name = "rt5677-slimbus", 4479 .name = "rt5677-slimbus",
4479 .id = RT5677_AIF5, 4480 .id = RT5677_AIF5,
4480 .playback = { 4481 .playback = {
4481 .stream_name = "SLIMBus Playback", 4482 .stream_name = "SLIMBus Playback",
4482 .channels_min = 1, 4483 .channels_min = 1,
4483 .channels_max = 2, 4484 .channels_max = 2,
4484 .rates = RT5677_STEREO_RATES, 4485 .rates = RT5677_STEREO_RATES,
4485 .formats = RT5677_FORMATS, 4486 .formats = RT5677_FORMATS,
4486 }, 4487 },
4487 .capture = { 4488 .capture = {
4488 .stream_name = "SLIMBus Capture", 4489 .stream_name = "SLIMBus Capture",
4489 .channels_min = 1, 4490 .channels_min = 1,
4490 .channels_max = 2, 4491 .channels_max = 2,
4491 .rates = RT5677_STEREO_RATES, 4492 .rates = RT5677_STEREO_RATES,
4492 .formats = RT5677_FORMATS, 4493 .formats = RT5677_FORMATS,
4493 }, 4494 },
4494 .ops = &rt5677_aif_dai_ops, 4495 .ops = &rt5677_aif_dai_ops,
4495 }, 4496 },
4496 }; 4497 };
4497 4498
4498 static struct snd_soc_codec_driver soc_codec_dev_rt5677 = { 4499 static struct snd_soc_codec_driver soc_codec_dev_rt5677 = {
4499 .probe = rt5677_probe, 4500 .probe = rt5677_probe,
4500 .remove = rt5677_remove, 4501 .remove = rt5677_remove,
4501 .suspend = rt5677_suspend, 4502 .suspend = rt5677_suspend,
4502 .resume = rt5677_resume, 4503 .resume = rt5677_resume,
4503 .set_bias_level = rt5677_set_bias_level, 4504 .set_bias_level = rt5677_set_bias_level,
4504 .idle_bias_off = true, 4505 .idle_bias_off = true,
4505 .controls = rt5677_snd_controls, 4506 .controls = rt5677_snd_controls,
4506 .num_controls = ARRAY_SIZE(rt5677_snd_controls), 4507 .num_controls = ARRAY_SIZE(rt5677_snd_controls),
4507 .dapm_widgets = rt5677_dapm_widgets, 4508 .dapm_widgets = rt5677_dapm_widgets,
4508 .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets), 4509 .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets),
4509 .dapm_routes = rt5677_dapm_routes, 4510 .dapm_routes = rt5677_dapm_routes,
4510 .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes), 4511 .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes),
4511 }; 4512 };
4512 4513
4513 static const struct regmap_config rt5677_regmap_physical = { 4514 static const struct regmap_config rt5677_regmap_physical = {
4514 .name = "physical", 4515 .name = "physical",
4515 .reg_bits = 8, 4516 .reg_bits = 8,
4516 .val_bits = 16, 4517 .val_bits = 16,
4517 4518
4518 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) * 4519 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
4519 RT5677_PR_SPACING), 4520 RT5677_PR_SPACING),
4520 .readable_reg = rt5677_readable_register, 4521 .readable_reg = rt5677_readable_register,
4521 4522
4522 .cache_type = REGCACHE_NONE, 4523 .cache_type = REGCACHE_NONE,
4523 .ranges = rt5677_ranges, 4524 .ranges = rt5677_ranges,
4524 .num_ranges = ARRAY_SIZE(rt5677_ranges), 4525 .num_ranges = ARRAY_SIZE(rt5677_ranges),
4525 }; 4526 };
4526 4527
4527 static const struct regmap_config rt5677_regmap = { 4528 static const struct regmap_config rt5677_regmap = {
4528 .reg_bits = 8, 4529 .reg_bits = 8,
4529 .val_bits = 16, 4530 .val_bits = 16,
4530 4531
4531 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) * 4532 .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
4532 RT5677_PR_SPACING), 4533 RT5677_PR_SPACING),
4533 4534
4534 .volatile_reg = rt5677_volatile_register, 4535 .volatile_reg = rt5677_volatile_register,
4535 .readable_reg = rt5677_readable_register, 4536 .readable_reg = rt5677_readable_register,
4536 .reg_read = rt5677_read, 4537 .reg_read = rt5677_read,
4537 .reg_write = rt5677_write, 4538 .reg_write = rt5677_write,
4538 4539
4539 .cache_type = REGCACHE_RBTREE, 4540 .cache_type = REGCACHE_RBTREE,
4540 .reg_defaults = rt5677_reg, 4541 .reg_defaults = rt5677_reg,
4541 .num_reg_defaults = ARRAY_SIZE(rt5677_reg), 4542 .num_reg_defaults = ARRAY_SIZE(rt5677_reg),
4542 .ranges = rt5677_ranges, 4543 .ranges = rt5677_ranges,
4543 .num_ranges = ARRAY_SIZE(rt5677_ranges), 4544 .num_ranges = ARRAY_SIZE(rt5677_ranges),
4544 }; 4545 };
4545 4546
4546 static const struct i2c_device_id rt5677_i2c_id[] = { 4547 static const struct i2c_device_id rt5677_i2c_id[] = {
4547 { "rt5677", 0 }, 4548 { "rt5677", 0 },
4548 { } 4549 { }
4549 }; 4550 };
4550 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); 4551 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
4551 4552
4552 static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) 4553 static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np)
4553 { 4554 {
4554 rt5677->pdata.in1_diff = of_property_read_bool(np, 4555 rt5677->pdata.in1_diff = of_property_read_bool(np,
4555 "realtek,in1-differential"); 4556 "realtek,in1-differential");
4556 rt5677->pdata.in2_diff = of_property_read_bool(np, 4557 rt5677->pdata.in2_diff = of_property_read_bool(np,
4557 "realtek,in2-differential"); 4558 "realtek,in2-differential");
4558 rt5677->pdata.lout1_diff = of_property_read_bool(np, 4559 rt5677->pdata.lout1_diff = of_property_read_bool(np,
4559 "realtek,lout1-differential"); 4560 "realtek,lout1-differential");
4560 rt5677->pdata.lout2_diff = of_property_read_bool(np, 4561 rt5677->pdata.lout2_diff = of_property_read_bool(np,
4561 "realtek,lout2-differential"); 4562 "realtek,lout2-differential");
4562 rt5677->pdata.lout3_diff = of_property_read_bool(np, 4563 rt5677->pdata.lout3_diff = of_property_read_bool(np,
4563 "realtek,lout3-differential"); 4564 "realtek,lout3-differential");
4564 4565
4565 rt5677->pow_ldo2 = of_get_named_gpio(np, 4566 rt5677->pow_ldo2 = of_get_named_gpio(np,
4566 "realtek,pow-ldo2-gpio", 0); 4567 "realtek,pow-ldo2-gpio", 0);
4567 4568
4568 /* 4569 /*
4569 * POW_LDO2 is optional (it may be statically tied on the board). 4570 * POW_LDO2 is optional (it may be statically tied on the board).
4570 * -ENOENT means that the property doesn't exist, i.e. there is no 4571 * -ENOENT means that the property doesn't exist, i.e. there is no
4571 * GPIO, so is not an error. Any other error code means the property 4572 * GPIO, so is not an error. Any other error code means the property
4572 * exists, but could not be parsed. 4573 * exists, but could not be parsed.
4573 */ 4574 */
4574 if (!gpio_is_valid(rt5677->pow_ldo2) && 4575 if (!gpio_is_valid(rt5677->pow_ldo2) &&
4575 (rt5677->pow_ldo2 != -ENOENT)) 4576 (rt5677->pow_ldo2 != -ENOENT))
4576 return rt5677->pow_ldo2; 4577 return rt5677->pow_ldo2;
4577 4578
4578 of_property_read_u8_array(np, "realtek,gpio-config", 4579 of_property_read_u8_array(np, "realtek,gpio-config",
4579 rt5677->pdata.gpio_config, RT5677_GPIO_NUM); 4580 rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
4580 4581
4581 of_property_read_u32(np, "realtek,jd1-gpio", &rt5677->pdata.jd1_gpio); 4582 of_property_read_u32(np, "realtek,jd1-gpio", &rt5677->pdata.jd1_gpio);
4582 of_property_read_u32(np, "realtek,jd2-gpio", &rt5677->pdata.jd2_gpio); 4583 of_property_read_u32(np, "realtek,jd2-gpio", &rt5677->pdata.jd2_gpio);
4583 of_property_read_u32(np, "realtek,jd3-gpio", &rt5677->pdata.jd3_gpio); 4584 of_property_read_u32(np, "realtek,jd3-gpio", &rt5677->pdata.jd3_gpio);
4584 4585
4585 return 0; 4586 return 0;
4586 } 4587 }
4587 4588
4588 static struct regmap_irq rt5677_irqs[] = { 4589 static struct regmap_irq rt5677_irqs[] = {
4589 [RT5677_IRQ_JD1] = { 4590 [RT5677_IRQ_JD1] = {
4590 .reg_offset = 0, 4591 .reg_offset = 0,
4591 .mask = RT5677_EN_IRQ_GPIO_JD1, 4592 .mask = RT5677_EN_IRQ_GPIO_JD1,
4592 }, 4593 },
4593 [RT5677_IRQ_JD2] = { 4594 [RT5677_IRQ_JD2] = {
4594 .reg_offset = 0, 4595 .reg_offset = 0,
4595 .mask = RT5677_EN_IRQ_GPIO_JD2, 4596 .mask = RT5677_EN_IRQ_GPIO_JD2,
4596 }, 4597 },
4597 [RT5677_IRQ_JD3] = { 4598 [RT5677_IRQ_JD3] = {
4598 .reg_offset = 0, 4599 .reg_offset = 0,
4599 .mask = RT5677_EN_IRQ_GPIO_JD3, 4600 .mask = RT5677_EN_IRQ_GPIO_JD3,
4600 }, 4601 },
4601 }; 4602 };
4602 4603
4603 static struct regmap_irq_chip rt5677_irq_chip = { 4604 static struct regmap_irq_chip rt5677_irq_chip = {
4604 .name = "rt5677", 4605 .name = "rt5677",
4605 .irqs = rt5677_irqs, 4606 .irqs = rt5677_irqs,
4606 .num_irqs = ARRAY_SIZE(rt5677_irqs), 4607 .num_irqs = ARRAY_SIZE(rt5677_irqs),
4607 4608
4608 .num_regs = 1, 4609 .num_regs = 1,
4609 .status_base = RT5677_IRQ_CTRL1, 4610 .status_base = RT5677_IRQ_CTRL1,
4610 .mask_base = RT5677_IRQ_CTRL1, 4611 .mask_base = RT5677_IRQ_CTRL1,
4611 .mask_invert = 1, 4612 .mask_invert = 1,
4612 }; 4613 };
4613 4614
4614 static int rt5677_init_irq(struct i2c_client *i2c) 4615 static int rt5677_init_irq(struct i2c_client *i2c)
4615 { 4616 {
4616 int ret; 4617 int ret;
4617 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); 4618 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4618 4619
4619 if (!rt5677->pdata.jd1_gpio && 4620 if (!rt5677->pdata.jd1_gpio &&
4620 !rt5677->pdata.jd2_gpio && 4621 !rt5677->pdata.jd2_gpio &&
4621 !rt5677->pdata.jd3_gpio) 4622 !rt5677->pdata.jd3_gpio)
4622 return 0; 4623 return 0;
4623 4624
4624 if (!i2c->irq) { 4625 if (!i2c->irq) {
4625 dev_err(&i2c->dev, "No interrupt specified\n"); 4626 dev_err(&i2c->dev, "No interrupt specified\n");
4626 return -EINVAL; 4627 return -EINVAL;
4627 } 4628 }
4628 4629
4629 ret = regmap_add_irq_chip(rt5677->regmap, i2c->irq, 4630 ret = regmap_add_irq_chip(rt5677->regmap, i2c->irq,
4630 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0, 4631 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
4631 &rt5677_irq_chip, &rt5677->irq_data); 4632 &rt5677_irq_chip, &rt5677->irq_data);
4632 4633
4633 if (ret != 0) { 4634 if (ret != 0) {
4634 dev_err(&i2c->dev, "Failed to register IRQ chip: %d\n", ret); 4635 dev_err(&i2c->dev, "Failed to register IRQ chip: %d\n", ret);
4635 return ret; 4636 return ret;
4636 } 4637 }
4637 4638
4638 return 0; 4639 return 0;
4639 } 4640 }
4640 4641
4641 static void rt5677_free_irq(struct i2c_client *i2c) 4642 static void rt5677_free_irq(struct i2c_client *i2c)
4642 { 4643 {
4643 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); 4644 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
4644 4645
4645 if (rt5677->irq_data) 4646 if (rt5677->irq_data)
4646 regmap_del_irq_chip(i2c->irq, rt5677->irq_data); 4647 regmap_del_irq_chip(i2c->irq, rt5677->irq_data);
4647 } 4648 }
4648 4649
4649 static int rt5677_i2c_probe(struct i2c_client *i2c, 4650 static int rt5677_i2c_probe(struct i2c_client *i2c,
4650 const struct i2c_device_id *id) 4651 const struct i2c_device_id *id)
4651 { 4652 {
4652 struct rt5677_platform_data *pdata = dev_get_platdata(&i2c->dev); 4653 struct rt5677_platform_data *pdata = dev_get_platdata(&i2c->dev);
4653 struct rt5677_priv *rt5677; 4654 struct rt5677_priv *rt5677;
4654 int ret; 4655 int ret;
4655 unsigned int val; 4656 unsigned int val;
4656 4657
4657 rt5677 = devm_kzalloc(&i2c->dev, sizeof(struct rt5677_priv), 4658 rt5677 = devm_kzalloc(&i2c->dev, sizeof(struct rt5677_priv),
4658 GFP_KERNEL); 4659 GFP_KERNEL);
4659 if (rt5677 == NULL) 4660 if (rt5677 == NULL)
4660 return -ENOMEM; 4661 return -ENOMEM;
4661 4662
4662 i2c_set_clientdata(i2c, rt5677); 4663 i2c_set_clientdata(i2c, rt5677);
4663 4664
4664 if (pdata) 4665 if (pdata)
4665 rt5677->pdata = *pdata; 4666 rt5677->pdata = *pdata;
4666 4667
4667 if (i2c->dev.of_node) { 4668 if (i2c->dev.of_node) {
4668 ret = rt5677_parse_dt(rt5677, i2c->dev.of_node); 4669 ret = rt5677_parse_dt(rt5677, i2c->dev.of_node);
4669 if (ret) { 4670 if (ret) {
4670 dev_err(&i2c->dev, "Failed to parse device tree: %d\n", 4671 dev_err(&i2c->dev, "Failed to parse device tree: %d\n",
4671 ret); 4672 ret);
4672 return ret; 4673 return ret;
4673 } 4674 }
4674 } else { 4675 } else {
4675 rt5677->pow_ldo2 = -EINVAL; 4676 rt5677->pow_ldo2 = -EINVAL;
4676 } 4677 }
4677 4678
4678 if (gpio_is_valid(rt5677->pow_ldo2)) { 4679 if (gpio_is_valid(rt5677->pow_ldo2)) {
4679 ret = devm_gpio_request_one(&i2c->dev, rt5677->pow_ldo2, 4680 ret = devm_gpio_request_one(&i2c->dev, rt5677->pow_ldo2,
4680 GPIOF_OUT_INIT_HIGH, 4681 GPIOF_OUT_INIT_HIGH,
4681 "RT5677 POW_LDO2"); 4682 "RT5677 POW_LDO2");
4682 if (ret < 0) { 4683 if (ret < 0) {
4683 dev_err(&i2c->dev, "Failed to request POW_LDO2 %d: %d\n", 4684 dev_err(&i2c->dev, "Failed to request POW_LDO2 %d: %d\n",
4684 rt5677->pow_ldo2, ret); 4685 rt5677->pow_ldo2, ret);
4685 return ret; 4686 return ret;
4686 } 4687 }
4687 /* Wait a while until I2C bus becomes available. The datasheet 4688 /* Wait a while until I2C bus becomes available. The datasheet
4688 * does not specify the exact we should wait but startup 4689 * does not specify the exact we should wait but startup
4689 * sequence mentiones at least a few milliseconds. 4690 * sequence mentiones at least a few milliseconds.
4690 */ 4691 */
4691 msleep(10); 4692 msleep(10);
4692 } 4693 }
4693 4694
4694 rt5677->regmap_physical = devm_regmap_init_i2c(i2c, 4695 rt5677->regmap_physical = devm_regmap_init_i2c(i2c,
4695 &rt5677_regmap_physical); 4696 &rt5677_regmap_physical);
4696 if (IS_ERR(rt5677->regmap_physical)) { 4697 if (IS_ERR(rt5677->regmap_physical)) {
4697 ret = PTR_ERR(rt5677->regmap_physical); 4698 ret = PTR_ERR(rt5677->regmap_physical);
4698 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 4699 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
4699 ret); 4700 ret);
4700 return ret; 4701 return ret;
4701 } 4702 }
4702 4703
4703 rt5677->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5677_regmap); 4704 rt5677->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5677_regmap);
4704 if (IS_ERR(rt5677->regmap)) { 4705 if (IS_ERR(rt5677->regmap)) {
4705 ret = PTR_ERR(rt5677->regmap); 4706 ret = PTR_ERR(rt5677->regmap);
4706 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 4707 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
4707 ret); 4708 ret);
4708 return ret; 4709 return ret;
4709 } 4710 }
4710 4711
4711 regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val); 4712 regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val);
4712 if (val != RT5677_DEVICE_ID) { 4713 if (val != RT5677_DEVICE_ID) {
4713 dev_err(&i2c->dev, 4714 dev_err(&i2c->dev,
4714 "Device with ID register %x is not rt5677\n", val); 4715 "Device with ID register %x is not rt5677\n", val);
4715 return -ENODEV; 4716 return -ENODEV;
4716 } 4717 }
4717 4718
4718 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); 4719 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
4719 4720
4720 ret = regmap_register_patch(rt5677->regmap, init_list, 4721 ret = regmap_register_patch(rt5677->regmap, init_list,
4721 ARRAY_SIZE(init_list)); 4722 ARRAY_SIZE(init_list));
4722 if (ret != 0) 4723 if (ret != 0)
4723 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); 4724 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
4724 4725
4725 if (rt5677->pdata.in1_diff) 4726 if (rt5677->pdata.in1_diff)
4726 regmap_update_bits(rt5677->regmap, RT5677_IN1, 4727 regmap_update_bits(rt5677->regmap, RT5677_IN1,
4727 RT5677_IN_DF1, RT5677_IN_DF1); 4728 RT5677_IN_DF1, RT5677_IN_DF1);
4728 4729
4729 if (rt5677->pdata.in2_diff) 4730 if (rt5677->pdata.in2_diff)
4730 regmap_update_bits(rt5677->regmap, RT5677_IN1, 4731 regmap_update_bits(rt5677->regmap, RT5677_IN1,
4731 RT5677_IN_DF2, RT5677_IN_DF2); 4732 RT5677_IN_DF2, RT5677_IN_DF2);
4732 4733
4733 if (rt5677->pdata.lout1_diff) 4734 if (rt5677->pdata.lout1_diff)
4734 regmap_update_bits(rt5677->regmap, RT5677_LOUT1, 4735 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4735 RT5677_LOUT1_L_DF, RT5677_LOUT1_L_DF); 4736 RT5677_LOUT1_L_DF, RT5677_LOUT1_L_DF);
4736 4737
4737 if (rt5677->pdata.lout2_diff) 4738 if (rt5677->pdata.lout2_diff)
4738 regmap_update_bits(rt5677->regmap, RT5677_LOUT1, 4739 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4739 RT5677_LOUT2_L_DF, RT5677_LOUT2_L_DF); 4740 RT5677_LOUT2_L_DF, RT5677_LOUT2_L_DF);
4740 4741
4741 if (rt5677->pdata.lout3_diff) 4742 if (rt5677->pdata.lout3_diff)
4742 regmap_update_bits(rt5677->regmap, RT5677_LOUT1, 4743 regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
4743 RT5677_LOUT3_L_DF, RT5677_LOUT3_L_DF); 4744 RT5677_LOUT3_L_DF, RT5677_LOUT3_L_DF);
4744 4745
4745 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) { 4746 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
4746 regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL2, 4747 regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL2,
4747 RT5677_GPIO5_FUNC_MASK, 4748 RT5677_GPIO5_FUNC_MASK,
4748 RT5677_GPIO5_FUNC_DMIC); 4749 RT5677_GPIO5_FUNC_DMIC);
4749 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, 4750 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
4750 RT5677_GPIO5_DIR_MASK, 4751 RT5677_GPIO5_DIR_MASK,
4751 RT5677_GPIO5_DIR_OUT); 4752 RT5677_GPIO5_DIR_OUT);
4752 } 4753 }
4753 4754
4754 rt5677_init_gpio(i2c); 4755 rt5677_init_gpio(i2c);
4755 rt5677_init_irq(i2c); 4756 rt5677_init_irq(i2c);
4756 4757
4757 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677, 4758 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677,
4758 rt5677_dai, ARRAY_SIZE(rt5677_dai)); 4759 rt5677_dai, ARRAY_SIZE(rt5677_dai));
4759 } 4760 }
4760 4761
4761 static int rt5677_i2c_remove(struct i2c_client *i2c) 4762 static int rt5677_i2c_remove(struct i2c_client *i2c)
4762 { 4763 {
4763 snd_soc_unregister_codec(&i2c->dev); 4764 snd_soc_unregister_codec(&i2c->dev);
4764 rt5677_free_irq(i2c); 4765 rt5677_free_irq(i2c);
4765 rt5677_free_gpio(i2c); 4766 rt5677_free_gpio(i2c);
4766 4767
4767 return 0; 4768 return 0;
4768 } 4769 }
4769 4770
4770 static struct i2c_driver rt5677_i2c_driver = { 4771 static struct i2c_driver rt5677_i2c_driver = {
4771 .driver = { 4772 .driver = {
4772 .name = "rt5677", 4773 .name = "rt5677",
4773 .owner = THIS_MODULE, 4774 .owner = THIS_MODULE,
4774 }, 4775 },
4775 .probe = rt5677_i2c_probe, 4776 .probe = rt5677_i2c_probe,
4776 .remove = rt5677_i2c_remove, 4777 .remove = rt5677_i2c_remove,
4777 .id_table = rt5677_i2c_id, 4778 .id_table = rt5677_i2c_id,
4778 }; 4779 };
4779 module_i2c_driver(rt5677_i2c_driver); 4780 module_i2c_driver(rt5677_i2c_driver);
4780 4781
4781 MODULE_DESCRIPTION("ASoC RT5677 driver"); 4782 MODULE_DESCRIPTION("ASoC RT5677 driver");
4782 MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); 4783 MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>");
4783 MODULE_LICENSE("GPL v2"); 4784 MODULE_LICENSE("GPL v2");
4784 4785
sound/soc/dwc/designware_i2s.c
1 /* 1 /*
2 * ALSA SoC Synopsys I2S Audio Layer 2 * ALSA SoC Synopsys I2S Audio Layer
3 * 3 *
4 * sound/soc/dwc/designware_i2s.c 4 * sound/soc/dwc/designware_i2s.c
5 * 5 *
6 * Copyright (C) 2010 ST Microelectronics 6 * Copyright (C) 2010 ST Microelectronics
7 * Rajeev Kumar <rajeevkumar.linux@gmail.com> 7 * Rajeev Kumar <rajeevkumar.linux@gmail.com>
8 * 8 *
9 * This file is licensed under the terms of the GNU General Public 9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any 10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied. 11 * warranty of any kind, whether express or implied.
12 */ 12 */
13 13
14 #include <linux/clk.h> 14 #include <linux/clk.h>
15 #include <linux/device.h> 15 #include <linux/device.h>
16 #include <linux/init.h> 16 #include <linux/init.h>
17 #include <linux/io.h> 17 #include <linux/io.h>
18 #include <linux/interrupt.h> 18 #include <linux/interrupt.h>
19 #include <linux/module.h> 19 #include <linux/module.h>
20 #include <linux/slab.h> 20 #include <linux/slab.h>
21 #include <sound/designware_i2s.h> 21 #include <sound/designware_i2s.h>
22 #include <sound/pcm.h> 22 #include <sound/pcm.h>
23 #include <sound/pcm_params.h> 23 #include <sound/pcm_params.h>
24 #include <sound/soc.h> 24 #include <sound/soc.h>
25 25
26 /* common register for all channel */ 26 /* common register for all channel */
27 #define IER 0x000 27 #define IER 0x000
28 #define IRER 0x004 28 #define IRER 0x004
29 #define ITER 0x008 29 #define ITER 0x008
30 #define CER 0x00C 30 #define CER 0x00C
31 #define CCR 0x010 31 #define CCR 0x010
32 #define RXFFR 0x014 32 #define RXFFR 0x014
33 #define TXFFR 0x018 33 #define TXFFR 0x018
34 34
35 /* I2STxRxRegisters for all channels */ 35 /* I2STxRxRegisters for all channels */
36 #define LRBR_LTHR(x) (0x40 * x + 0x020) 36 #define LRBR_LTHR(x) (0x40 * x + 0x020)
37 #define RRBR_RTHR(x) (0x40 * x + 0x024) 37 #define RRBR_RTHR(x) (0x40 * x + 0x024)
38 #define RER(x) (0x40 * x + 0x028) 38 #define RER(x) (0x40 * x + 0x028)
39 #define TER(x) (0x40 * x + 0x02C) 39 #define TER(x) (0x40 * x + 0x02C)
40 #define RCR(x) (0x40 * x + 0x030) 40 #define RCR(x) (0x40 * x + 0x030)
41 #define TCR(x) (0x40 * x + 0x034) 41 #define TCR(x) (0x40 * x + 0x034)
42 #define ISR(x) (0x40 * x + 0x038) 42 #define ISR(x) (0x40 * x + 0x038)
43 #define IMR(x) (0x40 * x + 0x03C) 43 #define IMR(x) (0x40 * x + 0x03C)
44 #define ROR(x) (0x40 * x + 0x040) 44 #define ROR(x) (0x40 * x + 0x040)
45 #define TOR(x) (0x40 * x + 0x044) 45 #define TOR(x) (0x40 * x + 0x044)
46 #define RFCR(x) (0x40 * x + 0x048) 46 #define RFCR(x) (0x40 * x + 0x048)
47 #define TFCR(x) (0x40 * x + 0x04C) 47 #define TFCR(x) (0x40 * x + 0x04C)
48 #define RFF(x) (0x40 * x + 0x050) 48 #define RFF(x) (0x40 * x + 0x050)
49 #define TFF(x) (0x40 * x + 0x054) 49 #define TFF(x) (0x40 * x + 0x054)
50 50
51 /* I2SCOMPRegisters */ 51 /* I2SCOMPRegisters */
52 #define I2S_COMP_PARAM_2 0x01F0 52 #define I2S_COMP_PARAM_2 0x01F0
53 #define I2S_COMP_PARAM_1 0x01F4 53 #define I2S_COMP_PARAM_1 0x01F4
54 #define I2S_COMP_VERSION 0x01F8 54 #define I2S_COMP_VERSION 0x01F8
55 #define I2S_COMP_TYPE 0x01FC 55 #define I2S_COMP_TYPE 0x01FC
56 56
57 #define MAX_CHANNEL_NUM 8 57 #define MAX_CHANNEL_NUM 8
58 #define MIN_CHANNEL_NUM 2 58 #define MIN_CHANNEL_NUM 2
59 59
60 struct dw_i2s_dev { 60 struct dw_i2s_dev {
61 void __iomem *i2s_base; 61 void __iomem *i2s_base;
62 struct clk *clk; 62 struct clk *clk;
63 int active; 63 int active;
64 unsigned int capability; 64 unsigned int capability;
65 struct device *dev; 65 struct device *dev;
66 66
67 /* data related to DMA transfers b/w i2s and DMAC */ 67 /* data related to DMA transfers b/w i2s and DMAC */
68 struct i2s_dma_data play_dma_data; 68 struct i2s_dma_data play_dma_data;
69 struct i2s_dma_data capture_dma_data; 69 struct i2s_dma_data capture_dma_data;
70 struct i2s_clk_config_data config; 70 struct i2s_clk_config_data config;
71 int (*i2s_clk_cfg)(struct i2s_clk_config_data *config); 71 int (*i2s_clk_cfg)(struct i2s_clk_config_data *config);
72 }; 72 };
73 73
74 static inline void i2s_write_reg(void __iomem *io_base, int reg, u32 val) 74 static inline void i2s_write_reg(void __iomem *io_base, int reg, u32 val)
75 { 75 {
76 writel(val, io_base + reg); 76 writel(val, io_base + reg);
77 } 77 }
78 78
79 static inline u32 i2s_read_reg(void __iomem *io_base, int reg) 79 static inline u32 i2s_read_reg(void __iomem *io_base, int reg)
80 { 80 {
81 return readl(io_base + reg); 81 return readl(io_base + reg);
82 } 82 }
83 83
84 static inline void i2s_disable_channels(struct dw_i2s_dev *dev, u32 stream) 84 static inline void i2s_disable_channels(struct dw_i2s_dev *dev, u32 stream)
85 { 85 {
86 u32 i = 0; 86 u32 i = 0;
87 87
88 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 88 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
89 for (i = 0; i < 4; i++) 89 for (i = 0; i < 4; i++)
90 i2s_write_reg(dev->i2s_base, TER(i), 0); 90 i2s_write_reg(dev->i2s_base, TER(i), 0);
91 } else { 91 } else {
92 for (i = 0; i < 4; i++) 92 for (i = 0; i < 4; i++)
93 i2s_write_reg(dev->i2s_base, RER(i), 0); 93 i2s_write_reg(dev->i2s_base, RER(i), 0);
94 } 94 }
95 } 95 }
96 96
97 static inline void i2s_clear_irqs(struct dw_i2s_dev *dev, u32 stream) 97 static inline void i2s_clear_irqs(struct dw_i2s_dev *dev, u32 stream)
98 { 98 {
99 u32 i = 0; 99 u32 i = 0;
100 100
101 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 101 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
102 for (i = 0; i < 4; i++) 102 for (i = 0; i < 4; i++)
103 i2s_write_reg(dev->i2s_base, TOR(i), 0); 103 i2s_write_reg(dev->i2s_base, TOR(i), 0);
104 } else { 104 } else {
105 for (i = 0; i < 4; i++) 105 for (i = 0; i < 4; i++)
106 i2s_write_reg(dev->i2s_base, ROR(i), 0); 106 i2s_write_reg(dev->i2s_base, ROR(i), 0);
107 } 107 }
108 } 108 }
109 109
110 static void i2s_start(struct dw_i2s_dev *dev, 110 static void i2s_start(struct dw_i2s_dev *dev,
111 struct snd_pcm_substream *substream) 111 struct snd_pcm_substream *substream)
112 { 112 {
113 113
114 i2s_write_reg(dev->i2s_base, IER, 1); 114 i2s_write_reg(dev->i2s_base, IER, 1);
115 115
116 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 116 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
117 i2s_write_reg(dev->i2s_base, ITER, 1); 117 i2s_write_reg(dev->i2s_base, ITER, 1);
118 else 118 else
119 i2s_write_reg(dev->i2s_base, IRER, 1); 119 i2s_write_reg(dev->i2s_base, IRER, 1);
120 120
121 i2s_write_reg(dev->i2s_base, CER, 1); 121 i2s_write_reg(dev->i2s_base, CER, 1);
122 } 122 }
123 123
124 static void i2s_stop(struct dw_i2s_dev *dev, 124 static void i2s_stop(struct dw_i2s_dev *dev,
125 struct snd_pcm_substream *substream) 125 struct snd_pcm_substream *substream)
126 { 126 {
127 u32 i = 0, irq; 127 u32 i = 0, irq;
128 128
129 i2s_clear_irqs(dev, substream->stream); 129 i2s_clear_irqs(dev, substream->stream);
130 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 130 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
131 i2s_write_reg(dev->i2s_base, ITER, 0); 131 i2s_write_reg(dev->i2s_base, ITER, 0);
132 132
133 for (i = 0; i < 4; i++) { 133 for (i = 0; i < 4; i++) {
134 irq = i2s_read_reg(dev->i2s_base, IMR(i)); 134 irq = i2s_read_reg(dev->i2s_base, IMR(i));
135 i2s_write_reg(dev->i2s_base, IMR(i), irq | 0x30); 135 i2s_write_reg(dev->i2s_base, IMR(i), irq | 0x30);
136 } 136 }
137 } else { 137 } else {
138 i2s_write_reg(dev->i2s_base, IRER, 0); 138 i2s_write_reg(dev->i2s_base, IRER, 0);
139 139
140 for (i = 0; i < 4; i++) { 140 for (i = 0; i < 4; i++) {
141 irq = i2s_read_reg(dev->i2s_base, IMR(i)); 141 irq = i2s_read_reg(dev->i2s_base, IMR(i));
142 i2s_write_reg(dev->i2s_base, IMR(i), irq | 0x03); 142 i2s_write_reg(dev->i2s_base, IMR(i), irq | 0x03);
143 } 143 }
144 } 144 }
145 145
146 if (!dev->active) { 146 if (!dev->active) {
147 i2s_write_reg(dev->i2s_base, CER, 0); 147 i2s_write_reg(dev->i2s_base, CER, 0);
148 i2s_write_reg(dev->i2s_base, IER, 0); 148 i2s_write_reg(dev->i2s_base, IER, 0);
149 } 149 }
150 } 150 }
151 151
152 static int dw_i2s_startup(struct snd_pcm_substream *substream, 152 static int dw_i2s_startup(struct snd_pcm_substream *substream,
153 struct snd_soc_dai *cpu_dai) 153 struct snd_soc_dai *cpu_dai)
154 { 154 {
155 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); 155 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
156 struct i2s_dma_data *dma_data = NULL; 156 struct i2s_dma_data *dma_data = NULL;
157 157
158 if (!(dev->capability & DWC_I2S_RECORD) && 158 if (!(dev->capability & DWC_I2S_RECORD) &&
159 (substream->stream == SNDRV_PCM_STREAM_CAPTURE)) 159 (substream->stream == SNDRV_PCM_STREAM_CAPTURE))
160 return -EINVAL; 160 return -EINVAL;
161 161
162 if (!(dev->capability & DWC_I2S_PLAY) && 162 if (!(dev->capability & DWC_I2S_PLAY) &&
163 (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)) 163 (substream->stream == SNDRV_PCM_STREAM_PLAYBACK))
164 return -EINVAL; 164 return -EINVAL;
165 165
166 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 166 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
167 dma_data = &dev->play_dma_data; 167 dma_data = &dev->play_dma_data;
168 else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) 168 else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
169 dma_data = &dev->capture_dma_data; 169 dma_data = &dev->capture_dma_data;
170 170
171 snd_soc_dai_set_dma_data(cpu_dai, substream, (void *)dma_data); 171 snd_soc_dai_set_dma_data(cpu_dai, substream, (void *)dma_data);
172 172
173 return 0; 173 return 0;
174 } 174 }
175 175
176 static int dw_i2s_hw_params(struct snd_pcm_substream *substream, 176 static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
177 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 177 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
178 { 178 {
179 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); 179 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
180 struct i2s_clk_config_data *config = &dev->config; 180 struct i2s_clk_config_data *config = &dev->config;
181 u32 ccr, xfer_resolution, ch_reg, irq; 181 u32 ccr, xfer_resolution, ch_reg, irq;
182 int ret; 182 int ret;
183 183
184 switch (params_format(params)) { 184 switch (params_format(params)) {
185 case SNDRV_PCM_FORMAT_S16_LE: 185 case SNDRV_PCM_FORMAT_S16_LE:
186 config->data_width = 16; 186 config->data_width = 16;
187 ccr = 0x00; 187 ccr = 0x00;
188 xfer_resolution = 0x02; 188 xfer_resolution = 0x02;
189 break; 189 break;
190 190
191 case SNDRV_PCM_FORMAT_S24_LE: 191 case SNDRV_PCM_FORMAT_S24_LE:
192 config->data_width = 24; 192 config->data_width = 24;
193 ccr = 0x08; 193 ccr = 0x08;
194 xfer_resolution = 0x04; 194 xfer_resolution = 0x04;
195 break; 195 break;
196 196
197 case SNDRV_PCM_FORMAT_S32_LE: 197 case SNDRV_PCM_FORMAT_S32_LE:
198 config->data_width = 32; 198 config->data_width = 32;
199 ccr = 0x10; 199 ccr = 0x10;
200 xfer_resolution = 0x05; 200 xfer_resolution = 0x05;
201 break; 201 break;
202 202
203 default: 203 default:
204 dev_err(dev->dev, "designware-i2s: unsuppted PCM fmt"); 204 dev_err(dev->dev, "designware-i2s: unsuppted PCM fmt");
205 return -EINVAL; 205 return -EINVAL;
206 } 206 }
207 207
208 config->chan_nr = params_channels(params); 208 config->chan_nr = params_channels(params);
209 209
210 switch (config->chan_nr) { 210 switch (config->chan_nr) {
211 case EIGHT_CHANNEL_SUPPORT: 211 case EIGHT_CHANNEL_SUPPORT:
212 ch_reg = 3;
213 break;
214 case SIX_CHANNEL_SUPPORT: 212 case SIX_CHANNEL_SUPPORT:
215 ch_reg = 2;
216 break;
217 case FOUR_CHANNEL_SUPPORT: 213 case FOUR_CHANNEL_SUPPORT:
218 ch_reg = 1;
219 break;
220 case TWO_CHANNEL_SUPPORT: 214 case TWO_CHANNEL_SUPPORT:
221 ch_reg = 0;
222 break; 215 break;
223 default: 216 default:
224 dev_err(dev->dev, "channel not supported\n"); 217 dev_err(dev->dev, "channel not supported\n");
225 return -EINVAL; 218 return -EINVAL;
226 } 219 }
227 220
228 i2s_disable_channels(dev, substream->stream); 221 i2s_disable_channels(dev, substream->stream);
229 222
230 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 223 for (ch_reg = 0; ch_reg < (config->chan_nr / 2); ch_reg++) {
231 i2s_write_reg(dev->i2s_base, TCR(ch_reg), xfer_resolution); 224 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
232 i2s_write_reg(dev->i2s_base, TFCR(ch_reg), 0x02); 225 i2s_write_reg(dev->i2s_base, TCR(ch_reg),
233 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg)); 226 xfer_resolution);
234 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x30); 227 i2s_write_reg(dev->i2s_base, TFCR(ch_reg), 0x02);
235 i2s_write_reg(dev->i2s_base, TER(ch_reg), 1); 228 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg));
236 } else { 229 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x30);
237 i2s_write_reg(dev->i2s_base, RCR(ch_reg), xfer_resolution); 230 i2s_write_reg(dev->i2s_base, TER(ch_reg), 1);
238 i2s_write_reg(dev->i2s_base, RFCR(ch_reg), 0x07); 231 } else {
239 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg)); 232 i2s_write_reg(dev->i2s_base, RCR(ch_reg),
240 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x03); 233 xfer_resolution);
241 i2s_write_reg(dev->i2s_base, RER(ch_reg), 1); 234 i2s_write_reg(dev->i2s_base, RFCR(ch_reg), 0x07);
235 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg));
236 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x03);
237 i2s_write_reg(dev->i2s_base, RER(ch_reg), 1);
238 }
242 } 239 }
243 240
244 i2s_write_reg(dev->i2s_base, CCR, ccr); 241 i2s_write_reg(dev->i2s_base, CCR, ccr);
245 242
246 config->sample_rate = params_rate(params); 243 config->sample_rate = params_rate(params);
247 244
248 if (!dev->i2s_clk_cfg) 245 if (!dev->i2s_clk_cfg)
249 return -EINVAL; 246 return -EINVAL;
250 247
251 ret = dev->i2s_clk_cfg(config); 248 ret = dev->i2s_clk_cfg(config);
252 if (ret < 0) { 249 if (ret < 0) {
253 dev_err(dev->dev, "runtime audio clk config fail\n"); 250 dev_err(dev->dev, "runtime audio clk config fail\n");
254 return ret; 251 return ret;
255 } 252 }
256 253
257 return 0; 254 return 0;
258 } 255 }
259 256
260 static void dw_i2s_shutdown(struct snd_pcm_substream *substream, 257 static void dw_i2s_shutdown(struct snd_pcm_substream *substream,
261 struct snd_soc_dai *dai) 258 struct snd_soc_dai *dai)
262 { 259 {
263 snd_soc_dai_set_dma_data(dai, substream, NULL); 260 snd_soc_dai_set_dma_data(dai, substream, NULL);
264 } 261 }
265 262
263 static int dw_i2s_prepare(struct snd_pcm_substream *substream,
264 struct snd_soc_dai *dai)
265 {
266 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
267
268 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
269 i2s_write_reg(dev->i2s_base, TXFFR, 1);
270 else
271 i2s_write_reg(dev->i2s_base, RXFFR, 1);
272
273 return 0;
274 }
275
266 static int dw_i2s_trigger(struct snd_pcm_substream *substream, 276 static int dw_i2s_trigger(struct snd_pcm_substream *substream,
267 int cmd, struct snd_soc_dai *dai) 277 int cmd, struct snd_soc_dai *dai)
268 { 278 {
269 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); 279 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
270 int ret = 0; 280 int ret = 0;
271 281
272 switch (cmd) { 282 switch (cmd) {
273 case SNDRV_PCM_TRIGGER_START: 283 case SNDRV_PCM_TRIGGER_START:
274 case SNDRV_PCM_TRIGGER_RESUME: 284 case SNDRV_PCM_TRIGGER_RESUME:
275 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 285 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
276 dev->active++; 286 dev->active++;
277 i2s_start(dev, substream); 287 i2s_start(dev, substream);
278 break; 288 break;
279 289
280 case SNDRV_PCM_TRIGGER_STOP: 290 case SNDRV_PCM_TRIGGER_STOP:
281 case SNDRV_PCM_TRIGGER_SUSPEND: 291 case SNDRV_PCM_TRIGGER_SUSPEND:
282 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 292 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
283 dev->active--; 293 dev->active--;
284 i2s_stop(dev, substream); 294 i2s_stop(dev, substream);
285 break; 295 break;
286 default: 296 default:
287 ret = -EINVAL; 297 ret = -EINVAL;
288 break; 298 break;
289 } 299 }
290 return ret; 300 return ret;
291 } 301 }
292 302
293 static struct snd_soc_dai_ops dw_i2s_dai_ops = { 303 static struct snd_soc_dai_ops dw_i2s_dai_ops = {
294 .startup = dw_i2s_startup, 304 .startup = dw_i2s_startup,
295 .shutdown = dw_i2s_shutdown, 305 .shutdown = dw_i2s_shutdown,
296 .hw_params = dw_i2s_hw_params, 306 .hw_params = dw_i2s_hw_params,
307 .prepare = dw_i2s_prepare,
297 .trigger = dw_i2s_trigger, 308 .trigger = dw_i2s_trigger,
298 }; 309 };
299 310
300 static const struct snd_soc_component_driver dw_i2s_component = { 311 static const struct snd_soc_component_driver dw_i2s_component = {
301 .name = "dw-i2s", 312 .name = "dw-i2s",
302 }; 313 };
303 314
304 #ifdef CONFIG_PM 315 #ifdef CONFIG_PM
305 316
306 static int dw_i2s_suspend(struct snd_soc_dai *dai) 317 static int dw_i2s_suspend(struct snd_soc_dai *dai)
307 { 318 {
308 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); 319 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
309 320
310 clk_disable(dev->clk); 321 clk_disable(dev->clk);
311 return 0; 322 return 0;
312 } 323 }
313 324
314 static int dw_i2s_resume(struct snd_soc_dai *dai) 325 static int dw_i2s_resume(struct snd_soc_dai *dai)
315 { 326 {
316 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); 327 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
317 328
318 clk_enable(dev->clk); 329 clk_enable(dev->clk);
319 return 0; 330 return 0;
320 } 331 }
321 332
322 #else 333 #else
323 #define dw_i2s_suspend NULL 334 #define dw_i2s_suspend NULL
324 #define dw_i2s_resume NULL 335 #define dw_i2s_resume NULL
325 #endif 336 #endif
326 337
327 static int dw_i2s_probe(struct platform_device *pdev) 338 static int dw_i2s_probe(struct platform_device *pdev)
328 { 339 {
329 const struct i2s_platform_data *pdata = pdev->dev.platform_data; 340 const struct i2s_platform_data *pdata = pdev->dev.platform_data;
330 struct dw_i2s_dev *dev; 341 struct dw_i2s_dev *dev;
331 struct resource *res; 342 struct resource *res;
332 int ret; 343 int ret;
333 unsigned int cap; 344 unsigned int cap;
334 struct snd_soc_dai_driver *dw_i2s_dai; 345 struct snd_soc_dai_driver *dw_i2s_dai;
335 346
336 if (!pdata) { 347 if (!pdata) {
337 dev_err(&pdev->dev, "Invalid platform data\n"); 348 dev_err(&pdev->dev, "Invalid platform data\n");
338 return -EINVAL; 349 return -EINVAL;
339 } 350 }
340 351
341 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); 352 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
342 if (!dev) { 353 if (!dev) {
343 dev_warn(&pdev->dev, "kzalloc fail\n"); 354 dev_warn(&pdev->dev, "kzalloc fail\n");
344 return -ENOMEM; 355 return -ENOMEM;
345 } 356 }
346 357
347 dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL); 358 dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL);
348 if (!dw_i2s_dai) { 359 if (!dw_i2s_dai) {
349 dev_err(&pdev->dev, "mem allocation failed for dai driver\n"); 360 dev_err(&pdev->dev, "mem allocation failed for dai driver\n");
350 return -ENOMEM; 361 return -ENOMEM;
351 } 362 }
352 363
353 dw_i2s_dai->ops = &dw_i2s_dai_ops; 364 dw_i2s_dai->ops = &dw_i2s_dai_ops;
354 dw_i2s_dai->suspend = dw_i2s_suspend; 365 dw_i2s_dai->suspend = dw_i2s_suspend;
355 dw_i2s_dai->resume = dw_i2s_resume; 366 dw_i2s_dai->resume = dw_i2s_resume;
356 367
357 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 368 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
358 if (!res) { 369 if (!res) {
359 dev_err(&pdev->dev, "no i2s resource defined\n"); 370 dev_err(&pdev->dev, "no i2s resource defined\n");
360 return -ENODEV; 371 return -ENODEV;
361 } 372 }
362 373
363 dev->i2s_base = devm_ioremap_resource(&pdev->dev, res); 374 dev->i2s_base = devm_ioremap_resource(&pdev->dev, res);
364 if (IS_ERR(dev->i2s_base)) { 375 if (IS_ERR(dev->i2s_base)) {
365 dev_err(&pdev->dev, "ioremap fail for i2s_region\n"); 376 dev_err(&pdev->dev, "ioremap fail for i2s_region\n");
366 return PTR_ERR(dev->i2s_base); 377 return PTR_ERR(dev->i2s_base);
367 } 378 }
368 379
369 cap = pdata->cap; 380 cap = pdata->cap;
370 dev->capability = cap; 381 dev->capability = cap;
371 dev->i2s_clk_cfg = pdata->i2s_clk_cfg; 382 dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
372 383
373 /* Set DMA slaves info */ 384 /* Set DMA slaves info */
374 385
375 dev->play_dma_data.data = pdata->play_dma_data; 386 dev->play_dma_data.data = pdata->play_dma_data;
376 dev->capture_dma_data.data = pdata->capture_dma_data; 387 dev->capture_dma_data.data = pdata->capture_dma_data;
377 dev->play_dma_data.addr = res->start + I2S_TXDMA; 388 dev->play_dma_data.addr = res->start + I2S_TXDMA;
378 dev->capture_dma_data.addr = res->start + I2S_RXDMA; 389 dev->capture_dma_data.addr = res->start + I2S_RXDMA;
379 dev->play_dma_data.max_burst = 16; 390 dev->play_dma_data.max_burst = 16;
380 dev->capture_dma_data.max_burst = 16; 391 dev->capture_dma_data.max_burst = 16;
381 dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; 392 dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
382 dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; 393 dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
383 dev->play_dma_data.filter = pdata->filter; 394 dev->play_dma_data.filter = pdata->filter;
384 dev->capture_dma_data.filter = pdata->filter; 395 dev->capture_dma_data.filter = pdata->filter;
385 396
386 dev->clk = clk_get(&pdev->dev, NULL); 397 dev->clk = clk_get(&pdev->dev, NULL);
387 if (IS_ERR(dev->clk)) 398 if (IS_ERR(dev->clk))
388 return PTR_ERR(dev->clk); 399 return PTR_ERR(dev->clk);
389 400
390 ret = clk_enable(dev->clk); 401 ret = clk_enable(dev->clk);
391 if (ret < 0) 402 if (ret < 0)
392 goto err_clk_put; 403 goto err_clk_put;
393 404
394 if (cap & DWC_I2S_PLAY) { 405 if (cap & DWC_I2S_PLAY) {
395 dev_dbg(&pdev->dev, " designware: play supported\n"); 406 dev_dbg(&pdev->dev, " designware: play supported\n");
396 dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM; 407 dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM;
397 dw_i2s_dai->playback.channels_max = pdata->channel; 408 dw_i2s_dai->playback.channels_max = pdata->channel;
398 dw_i2s_dai->playback.formats = pdata->snd_fmts; 409 dw_i2s_dai->playback.formats = pdata->snd_fmts;
399 dw_i2s_dai->playback.rates = pdata->snd_rates; 410 dw_i2s_dai->playback.rates = pdata->snd_rates;
400 } 411 }
401 412
402 if (cap & DWC_I2S_RECORD) { 413 if (cap & DWC_I2S_RECORD) {
403 dev_dbg(&pdev->dev, "designware: record supported\n"); 414 dev_dbg(&pdev->dev, "designware: record supported\n");
404 dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM; 415 dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM;
405 dw_i2s_dai->capture.channels_max = pdata->channel; 416 dw_i2s_dai->capture.channels_max = pdata->channel;
406 dw_i2s_dai->capture.formats = pdata->snd_fmts; 417 dw_i2s_dai->capture.formats = pdata->snd_fmts;
407 dw_i2s_dai->capture.rates = pdata->snd_rates; 418 dw_i2s_dai->capture.rates = pdata->snd_rates;
408 } 419 }
409 420
410 dev->dev = &pdev->dev; 421 dev->dev = &pdev->dev;
411 dev_set_drvdata(&pdev->dev, dev); 422 dev_set_drvdata(&pdev->dev, dev);
412 ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, 423 ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component,
413 dw_i2s_dai, 1); 424 dw_i2s_dai, 1);
414 if (ret != 0) { 425 if (ret != 0) {
415 dev_err(&pdev->dev, "not able to register dai\n"); 426 dev_err(&pdev->dev, "not able to register dai\n");
416 goto err_clk_disable; 427 goto err_clk_disable;
417 } 428 }
418 429
419 return 0; 430 return 0;
420 431
421 err_clk_disable: 432 err_clk_disable:
422 clk_disable(dev->clk); 433 clk_disable(dev->clk);
423 err_clk_put: 434 err_clk_put:
424 clk_put(dev->clk); 435 clk_put(dev->clk);
425 return ret; 436 return ret;
426 } 437 }
427 438
428 static int dw_i2s_remove(struct platform_device *pdev) 439 static int dw_i2s_remove(struct platform_device *pdev)
429 { 440 {
430 struct dw_i2s_dev *dev = dev_get_drvdata(&pdev->dev); 441 struct dw_i2s_dev *dev = dev_get_drvdata(&pdev->dev);
431 442
432 snd_soc_unregister_component(&pdev->dev); 443 snd_soc_unregister_component(&pdev->dev);
433 444
434 clk_put(dev->clk); 445 clk_put(dev->clk);
435 446
436 return 0; 447 return 0;
437 } 448 }
438 449
439 static struct platform_driver dw_i2s_driver = { 450 static struct platform_driver dw_i2s_driver = {
440 .probe = dw_i2s_probe, 451 .probe = dw_i2s_probe,
441 .remove = dw_i2s_remove, 452 .remove = dw_i2s_remove,
442 .driver = { 453 .driver = {
443 .name = "designware-i2s", 454 .name = "designware-i2s",
444 }, 455 },
445 }; 456 };
446 457
sound/soc/intel/Kconfig
1 config SND_MFLD_MACHINE 1 config SND_MFLD_MACHINE
2 tristate "SOC Machine Audio driver for Intel Medfield MID platform" 2 tristate "SOC Machine Audio driver for Intel Medfield MID platform"
3 depends on INTEL_SCU_IPC 3 depends on INTEL_SCU_IPC
4 select SND_SOC_SN95031 4 select SND_SOC_SN95031
5 select SND_SST_MFLD_PLATFORM 5 select SND_SST_MFLD_PLATFORM
6 select SND_SST_IPC_PCI 6 select SND_SST_IPC_PCI
7 help 7 help
8 This adds support for ASoC machine driver for Intel(R) MID Medfield platform 8 This adds support for ASoC machine driver for Intel(R) MID Medfield platform
9 used as alsa device in audio substem in Intel(R) MID devices 9 used as alsa device in audio substem in Intel(R) MID devices
10 Say Y if you have such a device 10 Say Y if you have such a device
11 If unsure select "N". 11 If unsure select "N".
12 12
13 config SND_SST_MFLD_PLATFORM 13 config SND_SST_MFLD_PLATFORM
14 tristate 14 tristate
15 15
16 config SND_SST_IPC 16 config SND_SST_IPC
17 tristate 17 tristate
18 18
19 config SND_SST_IPC_PCI 19 config SND_SST_IPC_PCI
20 tristate 20 tristate
21 select SND_SST_IPC 21 select SND_SST_IPC
22 22
23 config SND_SST_IPC_ACPI 23 config SND_SST_IPC_ACPI
24 tristate 24 tristate
25 select SND_SST_IPC 25 select SND_SST_IPC
26 depends on ACPI 26 depends on ACPI
27 27
28 config SND_SOC_INTEL_SST 28 config SND_SOC_INTEL_SST
29 tristate "ASoC support for Intel(R) Smart Sound Technology" 29 tristate "ASoC support for Intel(R) Smart Sound Technology"
30 select SND_SOC_INTEL_SST_ACPI if ACPI 30 select SND_SOC_INTEL_SST_ACPI if ACPI
31 depends on (X86 || COMPILE_TEST) 31 depends on (X86 || COMPILE_TEST)
32 depends on DW_DMAC_CORE 32 depends on DW_DMAC_CORE
33 help 33 help
34 This adds support for Intel(R) Smart Sound Technology (SST). 34 This adds support for Intel(R) Smart Sound Technology (SST).
35 Say Y if you have such a device 35 Say Y if you have such a device
36 If unsure select "N". 36 If unsure select "N".
37 37
38 config SND_SOC_INTEL_SST_ACPI 38 config SND_SOC_INTEL_SST_ACPI
39 tristate 39 tristate
40 40
41 config SND_SOC_INTEL_HASWELL 41 config SND_SOC_INTEL_HASWELL
42 tristate 42 tristate
43 43
44 config SND_SOC_INTEL_BAYTRAIL 44 config SND_SOC_INTEL_BAYTRAIL
45 tristate 45 tristate
46 46
47 config SND_SOC_INTEL_HASWELL_MACH 47 config SND_SOC_INTEL_HASWELL_MACH
48 tristate "ASoC Audio DSP support for Intel Haswell Lynxpoint" 48 tristate "ASoC Audio DSP support for Intel Haswell Lynxpoint"
49 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C && \\ 49 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C && \\
50 I2C_DESIGNWARE_PLATFORM 50 I2C_DESIGNWARE_PLATFORM
51 select SND_SOC_INTEL_HASWELL 51 select SND_SOC_INTEL_HASWELL
52 select SND_SOC_RT5640 52 select SND_SOC_RT5640
53 help 53 help
54 This adds support for the Lynxpoint Audio DSP on Intel(R) Haswell 54 This adds support for the Lynxpoint Audio DSP on Intel(R) Haswell
55 Ultrabook platforms. 55 Ultrabook platforms.
56 Say Y if you have such a device 56 Say Y if you have such a device
57 If unsure select "N". 57 If unsure select "N".
58 58
59 config SND_SOC_INTEL_BYT_RT5640_MACH 59 config SND_SOC_INTEL_BYT_RT5640_MACH
60 tristate "ASoC Audio driver for Intel Baytrail with RT5640 codec" 60 tristate "ASoC Audio driver for Intel Baytrail with RT5640 codec"
61 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C 61 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C
62 select SND_SOC_INTEL_BAYTRAIL 62 select SND_SOC_INTEL_BAYTRAIL
63 select SND_SOC_RT5640 63 select SND_SOC_RT5640
64 help 64 help
65 This adds audio driver for Intel Baytrail platform based boards 65 This adds audio driver for Intel Baytrail platform based boards
66 with the RT5640 audio codec. 66 with the RT5640 audio codec.
67 67
68 config SND_SOC_INTEL_BYT_MAX98090_MACH 68 config SND_SOC_INTEL_BYT_MAX98090_MACH
69 tristate "ASoC Audio driver for Intel Baytrail with MAX98090 codec" 69 tristate "ASoC Audio driver for Intel Baytrail with MAX98090 codec"
70 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C 70 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C
71 select SND_SOC_INTEL_BAYTRAIL 71 select SND_SOC_INTEL_BAYTRAIL
72 select SND_SOC_MAX98090 72 select SND_SOC_MAX98090
73 help 73 help
74 This adds audio driver for Intel Baytrail platform based boards 74 This adds audio driver for Intel Baytrail platform based boards
75 with the MAX98090 audio codec. 75 with the MAX98090 audio codec.
76 76
77 config SND_SOC_INTEL_BROADWELL_MACH 77 config SND_SOC_INTEL_BROADWELL_MACH
78 tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint" 78 tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
79 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && DW_DMAC && \\ 79 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && DW_DMAC && \\
80 I2C_DESIGNWARE_PLATFORM 80 I2C_DESIGNWARE_PLATFORM
81 select SND_SOC_INTEL_HASWELL 81 select SND_SOC_INTEL_HASWELL
82 select SND_COMPRESS_OFFLOAD 82 select SND_COMPRESS_OFFLOAD
83 select SND_SOC_RT286 83 select SND_SOC_RT286
84 help 84 help
85 This adds support for the Wilcatpoint Audio DSP on Intel(R) Broadwell 85 This adds support for the Wilcatpoint Audio DSP on Intel(R) Broadwell
86 Ultrabook platforms. 86 Ultrabook platforms.
87 Say Y if you have such a device 87 Say Y if you have such a device
88 If unsure select "N". 88 If unsure select "N".
89 89
90 config SND_SOC_INTEL_BYTCR_RT5640_MACH 90 config SND_SOC_INTEL_BYTCR_RT5640_MACH
91 tristate "ASoC Audio DSP Support for MID BYT Platform" 91 tristate "ASoC Audio DSP Support for MID BYT Platform"
92 depends on X86 92 depends on X86 && I2C
93 select SND_SOC_RT5640 93 select SND_SOC_RT5640
94 select SND_SST_MFLD_PLATFORM 94 select SND_SST_MFLD_PLATFORM
95 select SND_SST_IPC_ACPI 95 select SND_SST_IPC_ACPI
96 help 96 help
97 This adds support for ASoC machine driver for Intel(R) MID Baytrail platform 97 This adds support for ASoC machine driver for Intel(R) MID Baytrail platform
98 used as alsa device in audio substem in Intel(R) MID devices 98 used as alsa device in audio substem in Intel(R) MID devices
99 Say Y if you have such a device 99 Say Y if you have such a device
100 If unsure select "N". 100 If unsure select "N".
101 101
102 config SND_SOC_INTEL_CHT_BSW_RT5672_MACH 102 config SND_SOC_INTEL_CHT_BSW_RT5672_MACH
103 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec" 103 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec"
104 depends on X86_INTEL_LPSS 104 depends on X86_INTEL_LPSS && I2C
105 select SND_SOC_RT5670 105 select SND_SOC_RT5670
106 select SND_SST_MFLD_PLATFORM 106 select SND_SST_MFLD_PLATFORM
107 select SND_SST_IPC_ACPI 107 select SND_SST_IPC_ACPI
108 help 108 help
109 This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell 109 This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
110 platforms with RT5672 audio codec. 110 platforms with RT5672 audio codec.
111 Say Y if you have such a device 111 Say Y if you have such a device
112 If unsure select "N". 112 If unsure select "N".
113 113
sound/soc/intel/bytcr_dpcm_rt5640.c
1 /* 1 /*
2 * byt_cr_dpcm_rt5640.c - ASoc Machine driver for Intel Byt CR platform 2 * byt_cr_dpcm_rt5640.c - ASoc Machine driver for Intel Byt CR platform
3 * 3 *
4 * Copyright (C) 2014 Intel Corp 4 * Copyright (C) 2014 Intel Corp
5 * Author: Subhransu S. Prusty <subhransu.s.prusty@intel.com> 5 * Author: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License. 10 * the Free Software Foundation; version 2 of the License.
11 * 11 *
12 * This program is distributed in the hope that it will be useful, but 12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details. 15 * General Public License for more details.
16 * 16 *
17 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 17 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 */ 18 */
19 19
20 #include <linux/init.h> 20 #include <linux/init.h>
21 #include <linux/module.h> 21 #include <linux/module.h>
22 #include <linux/platform_device.h> 22 #include <linux/platform_device.h>
23 #include <linux/device.h> 23 #include <linux/device.h>
24 #include <linux/slab.h> 24 #include <linux/slab.h>
25 #include <linux/input.h> 25 #include <linux/input.h>
26 #include <sound/pcm.h> 26 #include <sound/pcm.h>
27 #include <sound/pcm_params.h> 27 #include <sound/pcm_params.h>
28 #include <sound/soc.h> 28 #include <sound/soc.h>
29 #include "../codecs/rt5640.h" 29 #include "../codecs/rt5640.h"
30 #include "sst-atom-controls.h" 30 #include "sst-atom-controls.h"
31 31
32 static const struct snd_soc_dapm_widget byt_dapm_widgets[] = { 32 static const struct snd_soc_dapm_widget byt_dapm_widgets[] = {
33 SND_SOC_DAPM_HP("Headphone", NULL), 33 SND_SOC_DAPM_HP("Headphone", NULL),
34 SND_SOC_DAPM_MIC("Headset Mic", NULL), 34 SND_SOC_DAPM_MIC("Headset Mic", NULL),
35 SND_SOC_DAPM_MIC("Int Mic", NULL), 35 SND_SOC_DAPM_MIC("Int Mic", NULL),
36 SND_SOC_DAPM_SPK("Ext Spk", NULL), 36 SND_SOC_DAPM_SPK("Ext Spk", NULL),
37 }; 37 };
38 38
39 static const struct snd_soc_dapm_route byt_audio_map[] = { 39 static const struct snd_soc_dapm_route byt_audio_map[] = {
40 {"IN2P", NULL, "Headset Mic"}, 40 {"IN2P", NULL, "Headset Mic"},
41 {"IN2N", NULL, "Headset Mic"}, 41 {"IN2N", NULL, "Headset Mic"},
42 {"Headset Mic", NULL, "MICBIAS1"}, 42 {"Headset Mic", NULL, "MICBIAS1"},
43 {"IN1P", NULL, "MICBIAS1"}, 43 {"IN1P", NULL, "MICBIAS1"},
44 {"LDO2", NULL, "Int Mic"}, 44 {"LDO2", NULL, "Int Mic"},
45 {"Headphone", NULL, "HPOL"}, 45 {"Headphone", NULL, "HPOL"},
46 {"Headphone", NULL, "HPOR"}, 46 {"Headphone", NULL, "HPOR"},
47 {"Ext Spk", NULL, "SPOLP"}, 47 {"Ext Spk", NULL, "SPOLP"},
48 {"Ext Spk", NULL, "SPOLN"}, 48 {"Ext Spk", NULL, "SPOLN"},
49 {"Ext Spk", NULL, "SPORP"}, 49 {"Ext Spk", NULL, "SPORP"},
50 {"Ext Spk", NULL, "SPORN"}, 50 {"Ext Spk", NULL, "SPORN"},
51 51
52 {"AIF1 Playback", NULL, "ssp2 Tx"}, 52 {"AIF1 Playback", NULL, "ssp2 Tx"},
53 {"ssp2 Tx", NULL, "codec_out0"}, 53 {"ssp2 Tx", NULL, "codec_out0"},
54 {"ssp2 Tx", NULL, "codec_out1"}, 54 {"ssp2 Tx", NULL, "codec_out1"},
55 {"codec_in0", NULL, "ssp2 Rx"}, 55 {"codec_in0", NULL, "ssp2 Rx"},
56 {"codec_in1", NULL, "ssp2 Rx"}, 56 {"codec_in1", NULL, "ssp2 Rx"},
57 {"ssp2 Rx", NULL, "AIF1 Capture"}, 57 {"ssp2 Rx", NULL, "AIF1 Capture"},
58 }; 58 };
59 59
60 static const struct snd_kcontrol_new byt_mc_controls[] = { 60 static const struct snd_kcontrol_new byt_mc_controls[] = {
61 SOC_DAPM_PIN_SWITCH("Headphone"), 61 SOC_DAPM_PIN_SWITCH("Headphone"),
62 SOC_DAPM_PIN_SWITCH("Headset Mic"), 62 SOC_DAPM_PIN_SWITCH("Headset Mic"),
63 SOC_DAPM_PIN_SWITCH("Int Mic"), 63 SOC_DAPM_PIN_SWITCH("Int Mic"),
64 SOC_DAPM_PIN_SWITCH("Ext Spk"), 64 SOC_DAPM_PIN_SWITCH("Ext Spk"),
65 }; 65 };
66 66
67 static int byt_aif1_hw_params(struct snd_pcm_substream *substream, 67 static int byt_aif1_hw_params(struct snd_pcm_substream *substream,
68 struct snd_pcm_hw_params *params) 68 struct snd_pcm_hw_params *params)
69 { 69 {
70 struct snd_soc_pcm_runtime *rtd = substream->private_data; 70 struct snd_soc_pcm_runtime *rtd = substream->private_data;
71 struct snd_soc_dai *codec_dai = rtd->codec_dai; 71 struct snd_soc_dai *codec_dai = rtd->codec_dai;
72 int ret; 72 int ret;
73 73
74 snd_soc_dai_set_bclk_ratio(codec_dai, 50); 74 snd_soc_dai_set_bclk_ratio(codec_dai, 50);
75 75
76 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1, 76 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1,
77 params_rate(params) * 512, 77 params_rate(params) * 512,
78 SND_SOC_CLOCK_IN); 78 SND_SOC_CLOCK_IN);
79 if (ret < 0) { 79 if (ret < 0) {
80 dev_err(rtd->dev, "can't set codec clock %d\n", ret); 80 dev_err(rtd->dev, "can't set codec clock %d\n", ret);
81 return ret; 81 return ret;
82 } 82 }
83 83
84 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5640_PLL1_S_BCLK1, 84 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5640_PLL1_S_BCLK1,
85 params_rate(params) * 50, 85 params_rate(params) * 50,
86 params_rate(params) * 512); 86 params_rate(params) * 512);
87 if (ret < 0) { 87 if (ret < 0) {
88 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); 88 dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
89 return ret; 89 return ret;
90 } 90 }
91 91
92 return 0; 92 return 0;
93 } 93 }
94 94
95 static const struct snd_soc_pcm_stream byt_dai_params = { 95 static const struct snd_soc_pcm_stream byt_dai_params = {
96 .formats = SNDRV_PCM_FMTBIT_S24_LE, 96 .formats = SNDRV_PCM_FMTBIT_S24_LE,
97 .rate_min = 48000, 97 .rate_min = 48000,
98 .rate_max = 48000, 98 .rate_max = 48000,
99 .channels_min = 2, 99 .channels_min = 2,
100 .channels_max = 2, 100 .channels_max = 2,
101 }; 101 };
102 102
103 static int byt_codec_fixup(struct snd_soc_pcm_runtime *rtd, 103 static int byt_codec_fixup(struct snd_soc_pcm_runtime *rtd,
104 struct snd_pcm_hw_params *params) 104 struct snd_pcm_hw_params *params)
105 { 105 {
106 struct snd_interval *rate = hw_param_interval(params, 106 struct snd_interval *rate = hw_param_interval(params,
107 SNDRV_PCM_HW_PARAM_RATE); 107 SNDRV_PCM_HW_PARAM_RATE);
108 struct snd_interval *channels = hw_param_interval(params, 108 struct snd_interval *channels = hw_param_interval(params,
109 SNDRV_PCM_HW_PARAM_CHANNELS); 109 SNDRV_PCM_HW_PARAM_CHANNELS);
110 110
111 /* The DSP will covert the FE rate to 48k, stereo, 24bits */ 111 /* The DSP will covert the FE rate to 48k, stereo, 24bits */
112 rate->min = rate->max = 48000; 112 rate->min = rate->max = 48000;
113 channels->min = channels->max = 2; 113 channels->min = channels->max = 2;
114 114
115 /* set SSP2 to 24-bit */ 115 /* set SSP2 to 24-bit */
116 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 116 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
117 SNDRV_PCM_HW_PARAM_FIRST_MASK], 117 SNDRV_PCM_HW_PARAM_FIRST_MASK],
118 SNDRV_PCM_FORMAT_S24_LE); 118 SNDRV_PCM_FORMAT_S24_LE);
119 return 0; 119 return 0;
120 } 120 }
121 121
122 static unsigned int rates_48000[] = { 122 static unsigned int rates_48000[] = {
123 48000, 123 48000,
124 }; 124 };
125 125
126 static struct snd_pcm_hw_constraint_list constraints_48000 = { 126 static struct snd_pcm_hw_constraint_list constraints_48000 = {
127 .count = ARRAY_SIZE(rates_48000), 127 .count = ARRAY_SIZE(rates_48000),
128 .list = rates_48000, 128 .list = rates_48000,
129 }; 129 };
130 130
131 static int byt_aif1_startup(struct snd_pcm_substream *substream) 131 static int byt_aif1_startup(struct snd_pcm_substream *substream)
132 { 132 {
133 return snd_pcm_hw_constraint_list(substream->runtime, 0, 133 return snd_pcm_hw_constraint_list(substream->runtime, 0,
134 SNDRV_PCM_HW_PARAM_RATE, 134 SNDRV_PCM_HW_PARAM_RATE,
135 &constraints_48000); 135 &constraints_48000);
136 } 136 }
137 137
138 static struct snd_soc_ops byt_aif1_ops = { 138 static struct snd_soc_ops byt_aif1_ops = {
139 .startup = byt_aif1_startup, 139 .startup = byt_aif1_startup,
140 }; 140 };
141 141
142 static struct snd_soc_ops byt_be_ssp2_ops = { 142 static struct snd_soc_ops byt_be_ssp2_ops = {
143 .hw_params = byt_aif1_hw_params, 143 .hw_params = byt_aif1_hw_params,
144 }; 144 };
145 145
146 static struct snd_soc_dai_link byt_dailink[] = { 146 static struct snd_soc_dai_link byt_dailink[] = {
147 [MERR_DPCM_AUDIO] = { 147 [MERR_DPCM_AUDIO] = {
148 .name = "Baytrail Audio Port", 148 .name = "Baytrail Audio Port",
149 .stream_name = "Baytrail Audio", 149 .stream_name = "Baytrail Audio",
150 .cpu_dai_name = "media-cpu-dai", 150 .cpu_dai_name = "media-cpu-dai",
151 .codec_dai_name = "snd-soc-dummy-dai", 151 .codec_dai_name = "snd-soc-dummy-dai",
152 .codec_name = "snd-soc-dummy", 152 .codec_name = "snd-soc-dummy",
153 .platform_name = "sst-mfld-platform", 153 .platform_name = "sst-mfld-platform",
154 .ignore_suspend = 1, 154 .ignore_suspend = 1,
155 .dynamic = 1, 155 .dynamic = 1,
156 .dpcm_playback = 1, 156 .dpcm_playback = 1,
157 .dpcm_capture = 1, 157 .dpcm_capture = 1,
158 .ops = &byt_aif1_ops, 158 .ops = &byt_aif1_ops,
159 }, 159 },
160 [MERR_DPCM_COMPR] = { 160 [MERR_DPCM_COMPR] = {
161 .name = "Baytrail Compressed Port", 161 .name = "Baytrail Compressed Port",
162 .stream_name = "Baytrail Compress", 162 .stream_name = "Baytrail Compress",
163 .cpu_dai_name = "compress-cpu-dai", 163 .cpu_dai_name = "compress-cpu-dai",
164 .codec_dai_name = "snd-soc-dummy-dai", 164 .codec_dai_name = "snd-soc-dummy-dai",
165 .codec_name = "snd-soc-dummy", 165 .codec_name = "snd-soc-dummy",
166 .platform_name = "sst-mfld-platform", 166 .platform_name = "sst-mfld-platform",
167 }, 167 },
168 /* back ends */ 168 /* back ends */
169 { 169 {
170 .name = "SSP2-Codec", 170 .name = "SSP2-Codec",
171 .be_id = 1, 171 .be_id = 1,
172 .cpu_dai_name = "ssp2-port", 172 .cpu_dai_name = "ssp2-port",
173 .platform_name = "sst-mfld-platform", 173 .platform_name = "sst-mfld-platform",
174 .no_pcm = 1, 174 .no_pcm = 1,
175 .codec_dai_name = "rt5640-aif1", 175 .codec_dai_name = "rt5640-aif1",
176 .codec_name = "i2c-10EC5640:00", 176 .codec_name = "i2c-10EC5640:00",
177 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 177 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
178 | SND_SOC_DAIFMT_CBS_CFS, 178 | SND_SOC_DAIFMT_CBS_CFS,
179 .be_hw_params_fixup = byt_codec_fixup, 179 .be_hw_params_fixup = byt_codec_fixup,
180 .ignore_suspend = 1, 180 .ignore_suspend = 1,
181 .dpcm_playback = 1, 181 .dpcm_playback = 1,
182 .dpcm_capture = 1, 182 .dpcm_capture = 1,
183 .ops = &byt_be_ssp2_ops, 183 .ops = &byt_be_ssp2_ops,
184 }, 184 },
185 }; 185 };
186 186
187 /* SoC card */ 187 /* SoC card */
188 static struct snd_soc_card snd_soc_card_byt = { 188 static struct snd_soc_card snd_soc_card_byt = {
189 .name = "baytrailcraudio", 189 .name = "baytrailcraudio",
190 .dai_link = byt_dailink, 190 .dai_link = byt_dailink,
191 .num_links = ARRAY_SIZE(byt_dailink), 191 .num_links = ARRAY_SIZE(byt_dailink),
192 .dapm_widgets = byt_dapm_widgets, 192 .dapm_widgets = byt_dapm_widgets,
193 .num_dapm_widgets = ARRAY_SIZE(byt_dapm_widgets), 193 .num_dapm_widgets = ARRAY_SIZE(byt_dapm_widgets),
194 .dapm_routes = byt_audio_map, 194 .dapm_routes = byt_audio_map,
195 .num_dapm_routes = ARRAY_SIZE(byt_audio_map), 195 .num_dapm_routes = ARRAY_SIZE(byt_audio_map),
196 .controls = byt_mc_controls, 196 .controls = byt_mc_controls,
197 .num_controls = ARRAY_SIZE(byt_mc_controls), 197 .num_controls = ARRAY_SIZE(byt_mc_controls),
198 }; 198 };
199 199
200 static int snd_byt_mc_probe(struct platform_device *pdev) 200 static int snd_byt_mc_probe(struct platform_device *pdev)
201 { 201 {
202 int ret_val = 0; 202 int ret_val = 0;
203 203
204 /* register the soc card */ 204 /* register the soc card */
205 snd_soc_card_byt.dev = &pdev->dev; 205 snd_soc_card_byt.dev = &pdev->dev;
206 206
207 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_byt); 207 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_byt);
208 if (ret_val) { 208 if (ret_val) {
209 dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n", ret_val); 209 dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n", ret_val);
210 return ret_val; 210 return ret_val;
211 } 211 }
212 platform_set_drvdata(pdev, &snd_soc_card_byt); 212 platform_set_drvdata(pdev, &snd_soc_card_byt);
213 return ret_val; 213 return ret_val;
214 } 214 }
215 215
216 static struct platform_driver snd_byt_mc_driver = { 216 static struct platform_driver snd_byt_mc_driver = {
217 .driver = { 217 .driver = {
218 .owner = THIS_MODULE, 218 .owner = THIS_MODULE,
219 .name = "bytt100_rt5640", 219 .name = "bytt100_rt5640",
220 .pm = &snd_soc_pm_ops, 220 .pm = &snd_soc_pm_ops,
221 }, 221 },
222 .probe = snd_byt_mc_probe, 222 .probe = snd_byt_mc_probe,
223 }; 223 };
224 224
225 module_platform_driver(snd_byt_mc_driver); 225 module_platform_driver(snd_byt_mc_driver);
226 226
227 MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver"); 227 MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver");
228 MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>"); 228 MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>");
229 MODULE_LICENSE("GPL v2"); 229 MODULE_LICENSE("GPL v2");
230 MODULE_ALIAS("platform:bytrt5640-audio"); 230 MODULE_ALIAS("platform:bytt100_rt5640");
231 231
sound/soc/intel/sst-firmware.c
1 /* 1 /*
2 * Intel SST Firmware Loader 2 * Intel SST Firmware Loader
3 * 3 *
4 * Copyright (C) 2013, Intel Corporation. All rights reserved. 4 * Copyright (C) 2013, Intel Corporation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation. 8 * 2 as published by the Free Software Foundation.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 */ 15 */
16 16
17 #include <linux/kernel.h> 17 #include <linux/kernel.h>
18 #include <linux/slab.h> 18 #include <linux/slab.h>
19 #include <linux/sched.h> 19 #include <linux/sched.h>
20 #include <linux/firmware.h> 20 #include <linux/firmware.h>
21 #include <linux/export.h> 21 #include <linux/export.h>
22 #include <linux/platform_device.h> 22 #include <linux/platform_device.h>
23 #include <linux/dma-mapping.h> 23 #include <linux/dma-mapping.h>
24 #include <linux/dmaengine.h> 24 #include <linux/dmaengine.h>
25 #include <linux/pci.h> 25 #include <linux/pci.h>
26 #include <linux/acpi.h> 26 #include <linux/acpi.h>
27 27
28 /* supported DMA engine drivers */ 28 /* supported DMA engine drivers */
29 #include <linux/platform_data/dma-dw.h> 29 #include <linux/platform_data/dma-dw.h>
30 #include <linux/dma/dw.h> 30 #include <linux/dma/dw.h>
31 31
32 #include <asm/page.h> 32 #include <asm/page.h>
33 #include <asm/pgtable.h> 33 #include <asm/pgtable.h>
34 34
35 #include "sst-dsp.h" 35 #include "sst-dsp.h"
36 #include "sst-dsp-priv.h" 36 #include "sst-dsp-priv.h"
37 37
38 #define SST_DMA_RESOURCES 2 38 #define SST_DMA_RESOURCES 2
39 #define SST_DSP_DMA_MAX_BURST 0x3 39 #define SST_DSP_DMA_MAX_BURST 0x3
40 #define SST_HSW_BLOCK_ANY 0xffffffff 40 #define SST_HSW_BLOCK_ANY 0xffffffff
41 41
42 #define SST_HSW_MASK_DMA_ADDR_DSP 0xfff00000 42 #define SST_HSW_MASK_DMA_ADDR_DSP 0xfff00000
43 43
44 struct sst_dma { 44 struct sst_dma {
45 struct sst_dsp *sst; 45 struct sst_dsp *sst;
46 46
47 struct dw_dma_chip *chip; 47 struct dw_dma_chip *chip;
48 48
49 struct dma_async_tx_descriptor *desc; 49 struct dma_async_tx_descriptor *desc;
50 struct dma_chan *ch; 50 struct dma_chan *ch;
51 }; 51 };
52 52
53 static inline void sst_memcpy32(volatile void __iomem *dest, void *src, u32 bytes) 53 static inline void sst_memcpy32(volatile void __iomem *dest, void *src, u32 bytes)
54 { 54 {
55 /* __iowrite32_copy use 32bit size values so divide by 4 */ 55 /* __iowrite32_copy use 32bit size values so divide by 4 */
56 __iowrite32_copy((void *)dest, src, bytes/4); 56 __iowrite32_copy((void *)dest, src, bytes/4);
57 } 57 }
58 58
59 static void sst_dma_transfer_complete(void *arg) 59 static void sst_dma_transfer_complete(void *arg)
60 { 60 {
61 struct sst_dsp *sst = (struct sst_dsp *)arg; 61 struct sst_dsp *sst = (struct sst_dsp *)arg;
62 62
63 dev_dbg(sst->dev, "DMA: callback\n"); 63 dev_dbg(sst->dev, "DMA: callback\n");
64 } 64 }
65 65
66 static int sst_dsp_dma_copy(struct sst_dsp *sst, dma_addr_t dest_addr, 66 static int sst_dsp_dma_copy(struct sst_dsp *sst, dma_addr_t dest_addr,
67 dma_addr_t src_addr, size_t size) 67 dma_addr_t src_addr, size_t size)
68 { 68 {
69 struct dma_async_tx_descriptor *desc; 69 struct dma_async_tx_descriptor *desc;
70 struct sst_dma *dma = sst->dma; 70 struct sst_dma *dma = sst->dma;
71 71
72 if (dma->ch == NULL) { 72 if (dma->ch == NULL) {
73 dev_err(sst->dev, "error: no DMA channel\n"); 73 dev_err(sst->dev, "error: no DMA channel\n");
74 return -ENODEV; 74 return -ENODEV;
75 } 75 }
76 76
77 dev_dbg(sst->dev, "DMA: src: 0x%lx dest 0x%lx size %zu\n", 77 dev_dbg(sst->dev, "DMA: src: 0x%lx dest 0x%lx size %zu\n",
78 (unsigned long)src_addr, (unsigned long)dest_addr, size); 78 (unsigned long)src_addr, (unsigned long)dest_addr, size);
79 79
80 desc = dma->ch->device->device_prep_dma_memcpy(dma->ch, dest_addr, 80 desc = dma->ch->device->device_prep_dma_memcpy(dma->ch, dest_addr,
81 src_addr, size, DMA_CTRL_ACK); 81 src_addr, size, DMA_CTRL_ACK);
82 if (!desc){ 82 if (!desc){
83 dev_err(sst->dev, "error: dma prep memcpy failed\n"); 83 dev_err(sst->dev, "error: dma prep memcpy failed\n");
84 return -EINVAL; 84 return -EINVAL;
85 } 85 }
86 86
87 desc->callback = sst_dma_transfer_complete; 87 desc->callback = sst_dma_transfer_complete;
88 desc->callback_param = sst; 88 desc->callback_param = sst;
89 89
90 desc->tx_submit(desc); 90 desc->tx_submit(desc);
91 dma_wait_for_async_tx(desc); 91 dma_wait_for_async_tx(desc);
92 92
93 return 0; 93 return 0;
94 } 94 }
95 95
96 /* copy to DSP */ 96 /* copy to DSP */
97 int sst_dsp_dma_copyto(struct sst_dsp *sst, dma_addr_t dest_addr, 97 int sst_dsp_dma_copyto(struct sst_dsp *sst, dma_addr_t dest_addr,
98 dma_addr_t src_addr, size_t size) 98 dma_addr_t src_addr, size_t size)
99 { 99 {
100 return sst_dsp_dma_copy(sst, dest_addr | SST_HSW_MASK_DMA_ADDR_DSP, 100 return sst_dsp_dma_copy(sst, dest_addr | SST_HSW_MASK_DMA_ADDR_DSP,
101 src_addr, size); 101 src_addr, size);
102 } 102 }
103 EXPORT_SYMBOL_GPL(sst_dsp_dma_copyto); 103 EXPORT_SYMBOL_GPL(sst_dsp_dma_copyto);
104 104
105 /* copy from DSP */ 105 /* copy from DSP */
106 int sst_dsp_dma_copyfrom(struct sst_dsp *sst, dma_addr_t dest_addr, 106 int sst_dsp_dma_copyfrom(struct sst_dsp *sst, dma_addr_t dest_addr,
107 dma_addr_t src_addr, size_t size) 107 dma_addr_t src_addr, size_t size)
108 { 108 {
109 return sst_dsp_dma_copy(sst, dest_addr, 109 return sst_dsp_dma_copy(sst, dest_addr,
110 src_addr | SST_HSW_MASK_DMA_ADDR_DSP, size); 110 src_addr | SST_HSW_MASK_DMA_ADDR_DSP, size);
111 } 111 }
112 EXPORT_SYMBOL_GPL(sst_dsp_dma_copyfrom); 112 EXPORT_SYMBOL_GPL(sst_dsp_dma_copyfrom);
113 113
114 /* remove module from memory - callers hold locks */ 114 /* remove module from memory - callers hold locks */
115 static void block_list_remove(struct sst_dsp *dsp, 115 static void block_list_remove(struct sst_dsp *dsp,
116 struct list_head *block_list) 116 struct list_head *block_list)
117 { 117 {
118 struct sst_mem_block *block, *tmp; 118 struct sst_mem_block *block, *tmp;
119 int err; 119 int err;
120 120
121 /* disable each block */ 121 /* disable each block */
122 list_for_each_entry(block, block_list, module_list) { 122 list_for_each_entry(block, block_list, module_list) {
123 123
124 if (block->ops && block->ops->disable) { 124 if (block->ops && block->ops->disable) {
125 err = block->ops->disable(block); 125 err = block->ops->disable(block);
126 if (err < 0) 126 if (err < 0)
127 dev_err(dsp->dev, 127 dev_err(dsp->dev,
128 "error: cant disable block %d:%d\n", 128 "error: cant disable block %d:%d\n",
129 block->type, block->index); 129 block->type, block->index);
130 } 130 }
131 } 131 }
132 132
133 /* mark each block as free */ 133 /* mark each block as free */
134 list_for_each_entry_safe(block, tmp, block_list, module_list) { 134 list_for_each_entry_safe(block, tmp, block_list, module_list) {
135 list_del(&block->module_list); 135 list_del(&block->module_list);
136 list_move(&block->list, &dsp->free_block_list); 136 list_move(&block->list, &dsp->free_block_list);
137 dev_dbg(dsp->dev, "block freed %d:%d at offset 0x%x\n", 137 dev_dbg(dsp->dev, "block freed %d:%d at offset 0x%x\n",
138 block->type, block->index, block->offset); 138 block->type, block->index, block->offset);
139 } 139 }
140 } 140 }
141 141
142 /* prepare the memory block to receive data from host - callers hold locks */ 142 /* prepare the memory block to receive data from host - callers hold locks */
143 static int block_list_prepare(struct sst_dsp *dsp, 143 static int block_list_prepare(struct sst_dsp *dsp,
144 struct list_head *block_list) 144 struct list_head *block_list)
145 { 145 {
146 struct sst_mem_block *block; 146 struct sst_mem_block *block;
147 int ret = 0; 147 int ret = 0;
148 148
149 /* enable each block so that's it'e ready for data */ 149 /* enable each block so that's it'e ready for data */
150 list_for_each_entry(block, block_list, module_list) { 150 list_for_each_entry(block, block_list, module_list) {
151 151
152 if (block->ops && block->ops->enable && !block->users) { 152 if (block->ops && block->ops->enable && !block->users) {
153 ret = block->ops->enable(block); 153 ret = block->ops->enable(block);
154 if (ret < 0) { 154 if (ret < 0) {
155 dev_err(dsp->dev, 155 dev_err(dsp->dev,
156 "error: cant disable block %d:%d\n", 156 "error: cant disable block %d:%d\n",
157 block->type, block->index); 157 block->type, block->index);
158 goto err; 158 goto err;
159 } 159 }
160 } 160 }
161 } 161 }
162 return ret; 162 return ret;
163 163
164 err: 164 err:
165 list_for_each_entry(block, block_list, module_list) { 165 list_for_each_entry(block, block_list, module_list) {
166 if (block->ops && block->ops->disable) 166 if (block->ops && block->ops->disable)
167 block->ops->disable(block); 167 block->ops->disable(block);
168 } 168 }
169 return ret; 169 return ret;
170 } 170 }
171 171
172 static struct dw_dma_platform_data dw_pdata = { 172 static struct dw_dma_platform_data dw_pdata = {
173 .is_private = 1, 173 .is_private = 1,
174 .chan_allocation_order = CHAN_ALLOCATION_ASCENDING, 174 .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
175 .chan_priority = CHAN_PRIORITY_ASCENDING, 175 .chan_priority = CHAN_PRIORITY_ASCENDING,
176 }; 176 };
177 177
178 static struct dw_dma_chip *dw_probe(struct device *dev, struct resource *mem, 178 static struct dw_dma_chip *dw_probe(struct device *dev, struct resource *mem,
179 int irq) 179 int irq)
180 { 180 {
181 struct dw_dma_chip *chip; 181 struct dw_dma_chip *chip;
182 int err; 182 int err;
183 183
184 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); 184 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
185 if (!chip) 185 if (!chip)
186 return ERR_PTR(-ENOMEM); 186 return ERR_PTR(-ENOMEM);
187 187
188 chip->irq = irq; 188 chip->irq = irq;
189 chip->regs = devm_ioremap_resource(dev, mem); 189 chip->regs = devm_ioremap_resource(dev, mem);
190 if (IS_ERR(chip->regs)) 190 if (IS_ERR(chip->regs))
191 return ERR_CAST(chip->regs); 191 return ERR_CAST(chip->regs);
192 192
193 err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(31)); 193 err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(31));
194 if (err) 194 if (err)
195 return ERR_PTR(err); 195 return ERR_PTR(err);
196 196
197 chip->dev = dev; 197 chip->dev = dev;
198 err = dw_dma_probe(chip, &dw_pdata); 198 err = dw_dma_probe(chip, &dw_pdata);
199 if (err) 199 if (err)
200 return ERR_PTR(err); 200 return ERR_PTR(err);
201 201
202 return chip; 202 return chip;
203 } 203 }
204 204
205 static void dw_remove(struct dw_dma_chip *chip) 205 static void dw_remove(struct dw_dma_chip *chip)
206 { 206 {
207 dw_dma_remove(chip); 207 dw_dma_remove(chip);
208 } 208 }
209 209
210 static bool dma_chan_filter(struct dma_chan *chan, void *param) 210 static bool dma_chan_filter(struct dma_chan *chan, void *param)
211 { 211 {
212 struct sst_dsp *dsp = (struct sst_dsp *)param; 212 struct sst_dsp *dsp = (struct sst_dsp *)param;
213 213
214 return chan->device->dev == dsp->dma_dev; 214 return chan->device->dev == dsp->dma_dev;
215 } 215 }
216 216
217 int sst_dsp_dma_get_channel(struct sst_dsp *dsp, int chan_id) 217 int sst_dsp_dma_get_channel(struct sst_dsp *dsp, int chan_id)
218 { 218 {
219 struct sst_dma *dma = dsp->dma; 219 struct sst_dma *dma = dsp->dma;
220 struct dma_slave_config slave; 220 struct dma_slave_config slave;
221 dma_cap_mask_t mask; 221 dma_cap_mask_t mask;
222 int ret; 222 int ret;
223 223
224 /* The Intel MID DMA engine driver needs the slave config set but 224 /* The Intel MID DMA engine driver needs the slave config set but
225 * Synopsis DMA engine driver safely ignores the slave config */ 225 * Synopsis DMA engine driver safely ignores the slave config */
226 dma_cap_zero(mask); 226 dma_cap_zero(mask);
227 dma_cap_set(DMA_SLAVE, mask); 227 dma_cap_set(DMA_SLAVE, mask);
228 dma_cap_set(DMA_MEMCPY, mask); 228 dma_cap_set(DMA_MEMCPY, mask);
229 229
230 dma->ch = dma_request_channel(mask, dma_chan_filter, dsp); 230 dma->ch = dma_request_channel(mask, dma_chan_filter, dsp);
231 if (dma->ch == NULL) { 231 if (dma->ch == NULL) {
232 dev_err(dsp->dev, "error: DMA request channel failed\n"); 232 dev_err(dsp->dev, "error: DMA request channel failed\n");
233 return -EIO; 233 return -EIO;
234 } 234 }
235 235
236 memset(&slave, 0, sizeof(slave)); 236 memset(&slave, 0, sizeof(slave));
237 slave.direction = DMA_MEM_TO_DEV; 237 slave.direction = DMA_MEM_TO_DEV;
238 slave.src_addr_width = 238 slave.src_addr_width =
239 slave.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 239 slave.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
240 slave.src_maxburst = slave.dst_maxburst = SST_DSP_DMA_MAX_BURST; 240 slave.src_maxburst = slave.dst_maxburst = SST_DSP_DMA_MAX_BURST;
241 241
242 ret = dmaengine_slave_config(dma->ch, &slave); 242 ret = dmaengine_slave_config(dma->ch, &slave);
243 if (ret) { 243 if (ret) {
244 dev_err(dsp->dev, "error: unable to set DMA slave config %d\n", 244 dev_err(dsp->dev, "error: unable to set DMA slave config %d\n",
245 ret); 245 ret);
246 dma_release_channel(dma->ch); 246 dma_release_channel(dma->ch);
247 dma->ch = NULL; 247 dma->ch = NULL;
248 } 248 }
249 249
250 return ret; 250 return ret;
251 } 251 }
252 EXPORT_SYMBOL_GPL(sst_dsp_dma_get_channel); 252 EXPORT_SYMBOL_GPL(sst_dsp_dma_get_channel);
253 253
254 void sst_dsp_dma_put_channel(struct sst_dsp *dsp) 254 void sst_dsp_dma_put_channel(struct sst_dsp *dsp)
255 { 255 {
256 struct sst_dma *dma = dsp->dma; 256 struct sst_dma *dma = dsp->dma;
257 257
258 if (!dma->ch) 258 if (!dma->ch)
259 return; 259 return;
260 260
261 dma_release_channel(dma->ch); 261 dma_release_channel(dma->ch);
262 dma->ch = NULL; 262 dma->ch = NULL;
263 } 263 }
264 EXPORT_SYMBOL_GPL(sst_dsp_dma_put_channel); 264 EXPORT_SYMBOL_GPL(sst_dsp_dma_put_channel);
265 265
266 int sst_dma_new(struct sst_dsp *sst) 266 int sst_dma_new(struct sst_dsp *sst)
267 { 267 {
268 struct sst_pdata *sst_pdata = sst->pdata; 268 struct sst_pdata *sst_pdata = sst->pdata;
269 struct sst_dma *dma; 269 struct sst_dma *dma;
270 struct resource mem; 270 struct resource mem;
271 const char *dma_dev_name; 271 const char *dma_dev_name;
272 int ret = 0; 272 int ret = 0;
273 273
274 /* configure the correct platform data for whatever DMA engine 274 /* configure the correct platform data for whatever DMA engine
275 * is attached to the ADSP IP. */ 275 * is attached to the ADSP IP. */
276 switch (sst->pdata->dma_engine) { 276 switch (sst->pdata->dma_engine) {
277 case SST_DMA_TYPE_DW: 277 case SST_DMA_TYPE_DW:
278 dma_dev_name = "dw_dmac"; 278 dma_dev_name = "dw_dmac";
279 break; 279 break;
280 case SST_DMA_TYPE_MID: 280 case SST_DMA_TYPE_MID:
281 dma_dev_name = "Intel MID DMA"; 281 dma_dev_name = "Intel MID DMA";
282 break; 282 break;
283 default: 283 default:
284 dev_err(sst->dev, "error: invalid DMA engine %d\n", 284 dev_err(sst->dev, "error: invalid DMA engine %d\n",
285 sst->pdata->dma_engine); 285 sst->pdata->dma_engine);
286 return -EINVAL; 286 return -EINVAL;
287 } 287 }
288 288
289 dma = devm_kzalloc(sst->dev, sizeof(struct sst_dma), GFP_KERNEL); 289 dma = devm_kzalloc(sst->dev, sizeof(struct sst_dma), GFP_KERNEL);
290 if (!dma) 290 if (!dma)
291 return -ENOMEM; 291 return -ENOMEM;
292 292
293 dma->sst = sst; 293 dma->sst = sst;
294 294
295 memset(&mem, 0, sizeof(mem)); 295 memset(&mem, 0, sizeof(mem));
296 296
297 mem.start = sst->addr.lpe_base + sst_pdata->dma_base; 297 mem.start = sst->addr.lpe_base + sst_pdata->dma_base;
298 mem.end = sst->addr.lpe_base + sst_pdata->dma_base + sst_pdata->dma_size - 1; 298 mem.end = sst->addr.lpe_base + sst_pdata->dma_base + sst_pdata->dma_size - 1;
299 mem.flags = IORESOURCE_MEM; 299 mem.flags = IORESOURCE_MEM;
300 300
301 /* now register DMA engine device */ 301 /* now register DMA engine device */
302 dma->chip = dw_probe(sst->dma_dev, &mem, sst_pdata->irq); 302 dma->chip = dw_probe(sst->dma_dev, &mem, sst_pdata->irq);
303 if (IS_ERR(dma->chip)) { 303 if (IS_ERR(dma->chip)) {
304 dev_err(sst->dev, "error: DMA device register failed\n"); 304 dev_err(sst->dev, "error: DMA device register failed\n");
305 ret = PTR_ERR(dma->chip); 305 ret = PTR_ERR(dma->chip);
306 goto err_dma_dev; 306 goto err_dma_dev;
307 } 307 }
308 308
309 sst->dma = dma; 309 sst->dma = dma;
310 sst->fw_use_dma = true; 310 sst->fw_use_dma = true;
311 return 0; 311 return 0;
312 312
313 err_dma_dev: 313 err_dma_dev:
314 devm_kfree(sst->dev, dma); 314 devm_kfree(sst->dev, dma);
315 return ret; 315 return ret;
316 } 316 }
317 EXPORT_SYMBOL(sst_dma_new); 317 EXPORT_SYMBOL(sst_dma_new);
318 318
319 void sst_dma_free(struct sst_dma *dma) 319 void sst_dma_free(struct sst_dma *dma)
320 { 320 {
321 321
322 if (dma == NULL) 322 if (dma == NULL)
323 return; 323 return;
324 324
325 if (dma->ch) 325 if (dma->ch)
326 dma_release_channel(dma->ch); 326 dma_release_channel(dma->ch);
327 327
328 if (dma->chip) 328 if (dma->chip)
329 dw_remove(dma->chip); 329 dw_remove(dma->chip);
330 330
331 } 331 }
332 EXPORT_SYMBOL(sst_dma_free); 332 EXPORT_SYMBOL(sst_dma_free);
333 333
334 /* create new generic firmware object */ 334 /* create new generic firmware object */
335 struct sst_fw *sst_fw_new(struct sst_dsp *dsp, 335 struct sst_fw *sst_fw_new(struct sst_dsp *dsp,
336 const struct firmware *fw, void *private) 336 const struct firmware *fw, void *private)
337 { 337 {
338 struct sst_fw *sst_fw; 338 struct sst_fw *sst_fw;
339 int err; 339 int err;
340 340
341 if (!dsp->ops->parse_fw) 341 if (!dsp->ops->parse_fw)
342 return NULL; 342 return NULL;
343 343
344 sst_fw = kzalloc(sizeof(*sst_fw), GFP_KERNEL); 344 sst_fw = kzalloc(sizeof(*sst_fw), GFP_KERNEL);
345 if (sst_fw == NULL) 345 if (sst_fw == NULL)
346 return NULL; 346 return NULL;
347 347
348 sst_fw->dsp = dsp; 348 sst_fw->dsp = dsp;
349 sst_fw->private = private; 349 sst_fw->private = private;
350 sst_fw->size = fw->size; 350 sst_fw->size = fw->size;
351 351
352 /* allocate DMA buffer to store FW data */ 352 /* allocate DMA buffer to store FW data */
353 sst_fw->dma_buf = dma_alloc_coherent(dsp->dma_dev, sst_fw->size, 353 sst_fw->dma_buf = dma_alloc_coherent(dsp->dma_dev, sst_fw->size,
354 &sst_fw->dmable_fw_paddr, GFP_DMA | GFP_KERNEL); 354 &sst_fw->dmable_fw_paddr, GFP_DMA | GFP_KERNEL);
355 if (!sst_fw->dma_buf) { 355 if (!sst_fw->dma_buf) {
356 dev_err(dsp->dev, "error: DMA alloc failed\n"); 356 dev_err(dsp->dev, "error: DMA alloc failed\n");
357 kfree(sst_fw); 357 kfree(sst_fw);
358 return NULL; 358 return NULL;
359 } 359 }
360 360
361 /* copy FW data to DMA-able memory */ 361 /* copy FW data to DMA-able memory */
362 memcpy((void *)sst_fw->dma_buf, (void *)fw->data, fw->size); 362 memcpy((void *)sst_fw->dma_buf, (void *)fw->data, fw->size);
363 363
364 if (dsp->fw_use_dma) { 364 if (dsp->fw_use_dma) {
365 err = sst_dsp_dma_get_channel(dsp, 0); 365 err = sst_dsp_dma_get_channel(dsp, 0);
366 if (err < 0) 366 if (err < 0)
367 goto chan_err; 367 goto chan_err;
368 } 368 }
369 369
370 /* call core specific FW paser to load FW data into DSP */ 370 /* call core specific FW paser to load FW data into DSP */
371 err = dsp->ops->parse_fw(sst_fw); 371 err = dsp->ops->parse_fw(sst_fw);
372 if (err < 0) { 372 if (err < 0) {
373 dev_err(dsp->dev, "error: parse fw failed %d\n", err); 373 dev_err(dsp->dev, "error: parse fw failed %d\n", err);
374 goto parse_err; 374 goto parse_err;
375 } 375 }
376 376
377 if (dsp->fw_use_dma) 377 if (dsp->fw_use_dma)
378 sst_dsp_dma_put_channel(dsp); 378 sst_dsp_dma_put_channel(dsp);
379 379
380 mutex_lock(&dsp->mutex); 380 mutex_lock(&dsp->mutex);
381 list_add(&sst_fw->list, &dsp->fw_list); 381 list_add(&sst_fw->list, &dsp->fw_list);
382 mutex_unlock(&dsp->mutex); 382 mutex_unlock(&dsp->mutex);
383 383
384 return sst_fw; 384 return sst_fw;
385 385
386 parse_err: 386 parse_err:
387 if (dsp->fw_use_dma) 387 if (dsp->fw_use_dma)
388 sst_dsp_dma_put_channel(dsp); 388 sst_dsp_dma_put_channel(dsp);
389 chan_err: 389 chan_err:
390 dma_free_coherent(dsp->dma_dev, sst_fw->size, 390 dma_free_coherent(dsp->dma_dev, sst_fw->size,
391 sst_fw->dma_buf, 391 sst_fw->dma_buf,
392 sst_fw->dmable_fw_paddr); 392 sst_fw->dmable_fw_paddr);
393 sst_fw->dma_buf = NULL; 393 sst_fw->dma_buf = NULL;
394 kfree(sst_fw); 394 kfree(sst_fw);
395 return NULL; 395 return NULL;
396 } 396 }
397 EXPORT_SYMBOL_GPL(sst_fw_new); 397 EXPORT_SYMBOL_GPL(sst_fw_new);
398 398
399 int sst_fw_reload(struct sst_fw *sst_fw) 399 int sst_fw_reload(struct sst_fw *sst_fw)
400 { 400 {
401 struct sst_dsp *dsp = sst_fw->dsp; 401 struct sst_dsp *dsp = sst_fw->dsp;
402 int ret; 402 int ret;
403 403
404 dev_dbg(dsp->dev, "reloading firmware\n"); 404 dev_dbg(dsp->dev, "reloading firmware\n");
405 405
406 /* call core specific FW paser to load FW data into DSP */ 406 /* call core specific FW paser to load FW data into DSP */
407 ret = dsp->ops->parse_fw(sst_fw); 407 ret = dsp->ops->parse_fw(sst_fw);
408 if (ret < 0) 408 if (ret < 0)
409 dev_err(dsp->dev, "error: parse fw failed %d\n", ret); 409 dev_err(dsp->dev, "error: parse fw failed %d\n", ret);
410 410
411 return ret; 411 return ret;
412 } 412 }
413 EXPORT_SYMBOL_GPL(sst_fw_reload); 413 EXPORT_SYMBOL_GPL(sst_fw_reload);
414 414
415 void sst_fw_unload(struct sst_fw *sst_fw) 415 void sst_fw_unload(struct sst_fw *sst_fw)
416 { 416 {
417 struct sst_dsp *dsp = sst_fw->dsp; 417 struct sst_dsp *dsp = sst_fw->dsp;
418 struct sst_module *module, *mtmp; 418 struct sst_module *module, *mtmp;
419 struct sst_module_runtime *runtime, *rtmp; 419 struct sst_module_runtime *runtime, *rtmp;
420 420
421 dev_dbg(dsp->dev, "unloading firmware\n"); 421 dev_dbg(dsp->dev, "unloading firmware\n");
422 422
423 mutex_lock(&dsp->mutex); 423 mutex_lock(&dsp->mutex);
424 424
425 /* check module by module */ 425 /* check module by module */
426 list_for_each_entry_safe(module, mtmp, &dsp->module_list, list) { 426 list_for_each_entry_safe(module, mtmp, &dsp->module_list, list) {
427 if (module->sst_fw == sst_fw) { 427 if (module->sst_fw == sst_fw) {
428 428
429 /* remove runtime modules */ 429 /* remove runtime modules */
430 list_for_each_entry_safe(runtime, rtmp, &module->runtime_list, list) { 430 list_for_each_entry_safe(runtime, rtmp, &module->runtime_list, list) {
431 431
432 block_list_remove(dsp, &runtime->block_list); 432 block_list_remove(dsp, &runtime->block_list);
433 list_del(&runtime->list); 433 list_del(&runtime->list);
434 kfree(runtime); 434 kfree(runtime);
435 } 435 }
436 436
437 /* now remove the module */ 437 /* now remove the module */
438 block_list_remove(dsp, &module->block_list); 438 block_list_remove(dsp, &module->block_list);
439 list_del(&module->list); 439 list_del(&module->list);
440 kfree(module); 440 kfree(module);
441 } 441 }
442 } 442 }
443 443
444 /* remove all scratch blocks */ 444 /* remove all scratch blocks */
445 block_list_remove(dsp, &dsp->scratch_block_list); 445 block_list_remove(dsp, &dsp->scratch_block_list);
446 446
447 mutex_unlock(&dsp->mutex); 447 mutex_unlock(&dsp->mutex);
448 } 448 }
449 EXPORT_SYMBOL_GPL(sst_fw_unload); 449 EXPORT_SYMBOL_GPL(sst_fw_unload);
450 450
451 /* free single firmware object */ 451 /* free single firmware object */
452 void sst_fw_free(struct sst_fw *sst_fw) 452 void sst_fw_free(struct sst_fw *sst_fw)
453 { 453 {
454 struct sst_dsp *dsp = sst_fw->dsp; 454 struct sst_dsp *dsp = sst_fw->dsp;
455 455
456 mutex_lock(&dsp->mutex); 456 mutex_lock(&dsp->mutex);
457 list_del(&sst_fw->list); 457 list_del(&sst_fw->list);
458 mutex_unlock(&dsp->mutex); 458 mutex_unlock(&dsp->mutex);
459 459
460 if (sst_fw->dma_buf) 460 if (sst_fw->dma_buf)
461 dma_free_coherent(dsp->dma_dev, sst_fw->size, sst_fw->dma_buf, 461 dma_free_coherent(dsp->dma_dev, sst_fw->size, sst_fw->dma_buf,
462 sst_fw->dmable_fw_paddr); 462 sst_fw->dmable_fw_paddr);
463 kfree(sst_fw); 463 kfree(sst_fw);
464 } 464 }
465 EXPORT_SYMBOL_GPL(sst_fw_free); 465 EXPORT_SYMBOL_GPL(sst_fw_free);
466 466
467 /* free all firmware objects */ 467 /* free all firmware objects */
468 void sst_fw_free_all(struct sst_dsp *dsp) 468 void sst_fw_free_all(struct sst_dsp *dsp)
469 { 469 {
470 struct sst_fw *sst_fw, *t; 470 struct sst_fw *sst_fw, *t;
471 471
472 mutex_lock(&dsp->mutex); 472 mutex_lock(&dsp->mutex);
473 list_for_each_entry_safe(sst_fw, t, &dsp->fw_list, list) { 473 list_for_each_entry_safe(sst_fw, t, &dsp->fw_list, list) {
474 474
475 list_del(&sst_fw->list); 475 list_del(&sst_fw->list);
476 dma_free_coherent(dsp->dev, sst_fw->size, sst_fw->dma_buf, 476 dma_free_coherent(dsp->dev, sst_fw->size, sst_fw->dma_buf,
477 sst_fw->dmable_fw_paddr); 477 sst_fw->dmable_fw_paddr);
478 kfree(sst_fw); 478 kfree(sst_fw);
479 } 479 }
480 mutex_unlock(&dsp->mutex); 480 mutex_unlock(&dsp->mutex);
481 } 481 }
482 EXPORT_SYMBOL_GPL(sst_fw_free_all); 482 EXPORT_SYMBOL_GPL(sst_fw_free_all);
483 483
484 /* create a new SST generic module from FW template */ 484 /* create a new SST generic module from FW template */
485 struct sst_module *sst_module_new(struct sst_fw *sst_fw, 485 struct sst_module *sst_module_new(struct sst_fw *sst_fw,
486 struct sst_module_template *template, void *private) 486 struct sst_module_template *template, void *private)
487 { 487 {
488 struct sst_dsp *dsp = sst_fw->dsp; 488 struct sst_dsp *dsp = sst_fw->dsp;
489 struct sst_module *sst_module; 489 struct sst_module *sst_module;
490 490
491 sst_module = kzalloc(sizeof(*sst_module), GFP_KERNEL); 491 sst_module = kzalloc(sizeof(*sst_module), GFP_KERNEL);
492 if (sst_module == NULL) 492 if (sst_module == NULL)
493 return NULL; 493 return NULL;
494 494
495 sst_module->id = template->id; 495 sst_module->id = template->id;
496 sst_module->dsp = dsp; 496 sst_module->dsp = dsp;
497 sst_module->sst_fw = sst_fw; 497 sst_module->sst_fw = sst_fw;
498 sst_module->scratch_size = template->scratch_size; 498 sst_module->scratch_size = template->scratch_size;
499 sst_module->persistent_size = template->persistent_size; 499 sst_module->persistent_size = template->persistent_size;
500 500
501 INIT_LIST_HEAD(&sst_module->block_list); 501 INIT_LIST_HEAD(&sst_module->block_list);
502 INIT_LIST_HEAD(&sst_module->runtime_list); 502 INIT_LIST_HEAD(&sst_module->runtime_list);
503 503
504 mutex_lock(&dsp->mutex); 504 mutex_lock(&dsp->mutex);
505 list_add(&sst_module->list, &dsp->module_list); 505 list_add(&sst_module->list, &dsp->module_list);
506 mutex_unlock(&dsp->mutex); 506 mutex_unlock(&dsp->mutex);
507 507
508 return sst_module; 508 return sst_module;
509 } 509 }
510 EXPORT_SYMBOL_GPL(sst_module_new); 510 EXPORT_SYMBOL_GPL(sst_module_new);
511 511
512 /* free firmware module and remove from available list */ 512 /* free firmware module and remove from available list */
513 void sst_module_free(struct sst_module *sst_module) 513 void sst_module_free(struct sst_module *sst_module)
514 { 514 {
515 struct sst_dsp *dsp = sst_module->dsp; 515 struct sst_dsp *dsp = sst_module->dsp;
516 516
517 mutex_lock(&dsp->mutex); 517 mutex_lock(&dsp->mutex);
518 list_del(&sst_module->list); 518 list_del(&sst_module->list);
519 mutex_unlock(&dsp->mutex); 519 mutex_unlock(&dsp->mutex);
520 520
521 kfree(sst_module); 521 kfree(sst_module);
522 } 522 }
523 EXPORT_SYMBOL_GPL(sst_module_free); 523 EXPORT_SYMBOL_GPL(sst_module_free);
524 524
525 struct sst_module_runtime *sst_module_runtime_new(struct sst_module *module, 525 struct sst_module_runtime *sst_module_runtime_new(struct sst_module *module,
526 int id, void *private) 526 int id, void *private)
527 { 527 {
528 struct sst_dsp *dsp = module->dsp; 528 struct sst_dsp *dsp = module->dsp;
529 struct sst_module_runtime *runtime; 529 struct sst_module_runtime *runtime;
530 530
531 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); 531 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
532 if (runtime == NULL) 532 if (runtime == NULL)
533 return NULL; 533 return NULL;
534 534
535 runtime->id = id; 535 runtime->id = id;
536 runtime->dsp = dsp; 536 runtime->dsp = dsp;
537 runtime->module = module; 537 runtime->module = module;
538 INIT_LIST_HEAD(&runtime->block_list); 538 INIT_LIST_HEAD(&runtime->block_list);
539 539
540 mutex_lock(&dsp->mutex); 540 mutex_lock(&dsp->mutex);
541 list_add(&runtime->list, &module->runtime_list); 541 list_add(&runtime->list, &module->runtime_list);
542 mutex_unlock(&dsp->mutex); 542 mutex_unlock(&dsp->mutex);
543 543
544 return runtime; 544 return runtime;
545 } 545 }
546 EXPORT_SYMBOL_GPL(sst_module_runtime_new); 546 EXPORT_SYMBOL_GPL(sst_module_runtime_new);
547 547
548 void sst_module_runtime_free(struct sst_module_runtime *runtime) 548 void sst_module_runtime_free(struct sst_module_runtime *runtime)
549 { 549 {
550 struct sst_dsp *dsp = runtime->dsp; 550 struct sst_dsp *dsp = runtime->dsp;
551 551
552 mutex_lock(&dsp->mutex); 552 mutex_lock(&dsp->mutex);
553 list_del(&runtime->list); 553 list_del(&runtime->list);
554 mutex_unlock(&dsp->mutex); 554 mutex_unlock(&dsp->mutex);
555 555
556 kfree(runtime); 556 kfree(runtime);
557 } 557 }
558 EXPORT_SYMBOL_GPL(sst_module_runtime_free); 558 EXPORT_SYMBOL_GPL(sst_module_runtime_free);
559 559
560 static struct sst_mem_block *find_block(struct sst_dsp *dsp, 560 static struct sst_mem_block *find_block(struct sst_dsp *dsp,
561 struct sst_block_allocator *ba) 561 struct sst_block_allocator *ba)
562 { 562 {
563 struct sst_mem_block *block; 563 struct sst_mem_block *block;
564 564
565 list_for_each_entry(block, &dsp->free_block_list, list) { 565 list_for_each_entry(block, &dsp->free_block_list, list) {
566 if (block->type == ba->type && block->offset == ba->offset) 566 if (block->type == ba->type && block->offset == ba->offset)
567 return block; 567 return block;
568 } 568 }
569 569
570 return NULL; 570 return NULL;
571 } 571 }
572 572
573 /* Block allocator must be on block boundary */ 573 /* Block allocator must be on block boundary */
574 static int block_alloc_contiguous(struct sst_dsp *dsp, 574 static int block_alloc_contiguous(struct sst_dsp *dsp,
575 struct sst_block_allocator *ba, struct list_head *block_list) 575 struct sst_block_allocator *ba, struct list_head *block_list)
576 { 576 {
577 struct list_head tmp = LIST_HEAD_INIT(tmp); 577 struct list_head tmp = LIST_HEAD_INIT(tmp);
578 struct sst_mem_block *block; 578 struct sst_mem_block *block;
579 u32 block_start = SST_HSW_BLOCK_ANY; 579 u32 block_start = SST_HSW_BLOCK_ANY;
580 int size = ba->size, offset = ba->offset; 580 int size = ba->size, offset = ba->offset;
581 581
582 while (ba->size > 0) { 582 while (ba->size > 0) {
583 583
584 block = find_block(dsp, ba); 584 block = find_block(dsp, ba);
585 if (!block) { 585 if (!block) {
586 list_splice(&tmp, &dsp->free_block_list); 586 list_splice(&tmp, &dsp->free_block_list);
587 587
588 ba->size = size; 588 ba->size = size;
589 ba->offset = offset; 589 ba->offset = offset;
590 return -ENOMEM; 590 return -ENOMEM;
591 } 591 }
592 592
593 list_move_tail(&block->list, &tmp); 593 list_move_tail(&block->list, &tmp);
594 ba->offset += block->size; 594 ba->offset += block->size;
595 ba->size -= block->size; 595 ba->size -= block->size;
596 } 596 }
597 ba->size = size; 597 ba->size = size;
598 ba->offset = offset; 598 ba->offset = offset;
599 599
600 list_for_each_entry(block, &tmp, list) { 600 list_for_each_entry(block, &tmp, list) {
601 601
602 if (block->offset < block_start) 602 if (block->offset < block_start)
603 block_start = block->offset; 603 block_start = block->offset;
604 604
605 list_add(&block->module_list, block_list); 605 list_add(&block->module_list, block_list);
606 606
607 dev_dbg(dsp->dev, "block allocated %d:%d at offset 0x%x\n", 607 dev_dbg(dsp->dev, "block allocated %d:%d at offset 0x%x\n",
608 block->type, block->index, block->offset); 608 block->type, block->index, block->offset);
609 } 609 }
610 610
611 list_splice(&tmp, &dsp->used_block_list); 611 list_splice(&tmp, &dsp->used_block_list);
612 return 0; 612 return 0;
613 } 613 }
614 614
615 /* allocate first free DSP blocks for data - callers hold locks */ 615 /* allocate first free DSP blocks for data - callers hold locks */
616 static int block_alloc(struct sst_dsp *dsp, struct sst_block_allocator *ba, 616 static int block_alloc(struct sst_dsp *dsp, struct sst_block_allocator *ba,
617 struct list_head *block_list) 617 struct list_head *block_list)
618 { 618 {
619 struct sst_mem_block *block, *tmp; 619 struct sst_mem_block *block, *tmp;
620 int ret = 0; 620 int ret = 0;
621 621
622 if (ba->size == 0) 622 if (ba->size == 0)
623 return 0; 623 return 0;
624 624
625 /* find first free whole blocks that can hold module */ 625 /* find first free whole blocks that can hold module */
626 list_for_each_entry_safe(block, tmp, &dsp->free_block_list, list) { 626 list_for_each_entry_safe(block, tmp, &dsp->free_block_list, list) {
627 627
628 /* ignore blocks with wrong type */ 628 /* ignore blocks with wrong type */
629 if (block->type != ba->type) 629 if (block->type != ba->type)
630 continue; 630 continue;
631 631
632 if (ba->size > block->size) 632 if (ba->size > block->size)
633 continue; 633 continue;
634 634
635 ba->offset = block->offset; 635 ba->offset = block->offset;
636 block->bytes_used = ba->size % block->size; 636 block->bytes_used = ba->size % block->size;
637 list_add(&block->module_list, block_list); 637 list_add(&block->module_list, block_list);
638 list_move(&block->list, &dsp->used_block_list); 638 list_move(&block->list, &dsp->used_block_list);
639 dev_dbg(dsp->dev, "block allocated %d:%d at offset 0x%x\n", 639 dev_dbg(dsp->dev, "block allocated %d:%d at offset 0x%x\n",
640 block->type, block->index, block->offset); 640 block->type, block->index, block->offset);
641 return 0; 641 return 0;
642 } 642 }
643 643
644 /* then find free multiple blocks that can hold module */ 644 /* then find free multiple blocks that can hold module */
645 list_for_each_entry_safe(block, tmp, &dsp->free_block_list, list) { 645 list_for_each_entry_safe(block, tmp, &dsp->free_block_list, list) {
646 646
647 /* ignore blocks with wrong type */ 647 /* ignore blocks with wrong type */
648 if (block->type != ba->type) 648 if (block->type != ba->type)
649 continue; 649 continue;
650 650
651 /* do we span > 1 blocks */ 651 /* do we span > 1 blocks */
652 if (ba->size > block->size) { 652 if (ba->size > block->size) {
653 653
654 /* align ba to block boundary */ 654 /* align ba to block boundary */
655 ba->offset = block->offset; 655 ba->offset = block->offset;
656 656
657 ret = block_alloc_contiguous(dsp, ba, block_list); 657 ret = block_alloc_contiguous(dsp, ba, block_list);
658 if (ret == 0) 658 if (ret == 0)
659 return ret; 659 return ret;
660 660
661 } 661 }
662 } 662 }
663 663
664 /* not enough free block space */ 664 /* not enough free block space */
665 return -ENOMEM; 665 return -ENOMEM;
666 } 666 }
667 667
668 int sst_alloc_blocks(struct sst_dsp *dsp, struct sst_block_allocator *ba, 668 int sst_alloc_blocks(struct sst_dsp *dsp, struct sst_block_allocator *ba,
669 struct list_head *block_list) 669 struct list_head *block_list)
670 { 670 {
671 int ret; 671 int ret;
672 672
673 dev_dbg(dsp->dev, "block request 0x%x bytes at offset 0x%x type %d\n", 673 dev_dbg(dsp->dev, "block request 0x%x bytes at offset 0x%x type %d\n",
674 ba->size, ba->offset, ba->type); 674 ba->size, ba->offset, ba->type);
675 675
676 mutex_lock(&dsp->mutex); 676 mutex_lock(&dsp->mutex);
677 677
678 ret = block_alloc(dsp, ba, block_list); 678 ret = block_alloc(dsp, ba, block_list);
679 if (ret < 0) { 679 if (ret < 0) {
680 dev_err(dsp->dev, "error: can't alloc blocks %d\n", ret); 680 dev_err(dsp->dev, "error: can't alloc blocks %d\n", ret);
681 goto out; 681 goto out;
682 } 682 }
683 683
684 /* prepare DSP blocks for module usage */ 684 /* prepare DSP blocks for module usage */
685 ret = block_list_prepare(dsp, block_list); 685 ret = block_list_prepare(dsp, block_list);
686 if (ret < 0) 686 if (ret < 0)
687 dev_err(dsp->dev, "error: prepare failed\n"); 687 dev_err(dsp->dev, "error: prepare failed\n");
688 688
689 out: 689 out:
690 mutex_unlock(&dsp->mutex); 690 mutex_unlock(&dsp->mutex);
691 return ret; 691 return ret;
692 } 692 }
693 EXPORT_SYMBOL_GPL(sst_alloc_blocks); 693 EXPORT_SYMBOL_GPL(sst_alloc_blocks);
694 694
695 int sst_free_blocks(struct sst_dsp *dsp, struct list_head *block_list) 695 int sst_free_blocks(struct sst_dsp *dsp, struct list_head *block_list)
696 { 696 {
697 mutex_lock(&dsp->mutex); 697 mutex_lock(&dsp->mutex);
698 block_list_remove(dsp, block_list); 698 block_list_remove(dsp, block_list);
699 mutex_unlock(&dsp->mutex); 699 mutex_unlock(&dsp->mutex);
700 return 0; 700 return 0;
701 } 701 }
702 EXPORT_SYMBOL_GPL(sst_free_blocks); 702 EXPORT_SYMBOL_GPL(sst_free_blocks);
703 703
704 /* allocate memory blocks for static module addresses - callers hold locks */ 704 /* allocate memory blocks for static module addresses - callers hold locks */
705 static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba, 705 static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba,
706 struct list_head *block_list) 706 struct list_head *block_list)
707 { 707 {
708 struct sst_mem_block *block, *tmp; 708 struct sst_mem_block *block, *tmp;
709 u32 end = ba->offset + ba->size, block_end; 709 u32 end = ba->offset + ba->size, block_end;
710 int err; 710 int err;
711 711
712 /* only IRAM/DRAM blocks are managed */ 712 /* only IRAM/DRAM blocks are managed */
713 if (ba->type != SST_MEM_IRAM && ba->type != SST_MEM_DRAM) 713 if (ba->type != SST_MEM_IRAM && ba->type != SST_MEM_DRAM)
714 return 0; 714 return 0;
715 715
716 /* are blocks already attached to this module */ 716 /* are blocks already attached to this module */
717 list_for_each_entry_safe(block, tmp, block_list, module_list) { 717 list_for_each_entry_safe(block, tmp, block_list, module_list) {
718 718
719 /* ignore blocks with wrong type */ 719 /* ignore blocks with wrong type */
720 if (block->type != ba->type) 720 if (block->type != ba->type)
721 continue; 721 continue;
722 722
723 block_end = block->offset + block->size; 723 block_end = block->offset + block->size;
724 724
725 /* find block that holds section */ 725 /* find block that holds section */
726 if (ba->offset >= block->offset && end <= block_end) 726 if (ba->offset >= block->offset && end <= block_end)
727 return 0; 727 return 0;
728 728
729 /* does block span more than 1 section */ 729 /* does block span more than 1 section */
730 if (ba->offset >= block->offset && ba->offset < block_end) { 730 if (ba->offset >= block->offset && ba->offset < block_end) {
731 731
732 /* align ba to block boundary */ 732 /* align ba to block boundary */
733 ba->size -= block_end - ba->offset; 733 ba->size -= block_end - ba->offset;
734 ba->offset = block_end; 734 ba->offset = block_end;
735 err = block_alloc_contiguous(dsp, ba, block_list); 735 err = block_alloc_contiguous(dsp, ba, block_list);
736 if (err < 0) 736 if (err < 0)
737 return -ENOMEM; 737 return -ENOMEM;
738 738
739 /* module already owns blocks */ 739 /* module already owns blocks */
740 return 0; 740 return 0;
741 } 741 }
742 } 742 }
743 743
744 /* find first free blocks that can hold section in free list */ 744 /* find first free blocks that can hold section in free list */
745 list_for_each_entry_safe(block, tmp, &dsp->free_block_list, list) { 745 list_for_each_entry_safe(block, tmp, &dsp->free_block_list, list) {
746 block_end = block->offset + block->size; 746 block_end = block->offset + block->size;
747 747
748 /* ignore blocks with wrong type */ 748 /* ignore blocks with wrong type */
749 if (block->type != ba->type) 749 if (block->type != ba->type)
750 continue; 750 continue;
751 751
752 /* find block that holds section */ 752 /* find block that holds section */
753 if (ba->offset >= block->offset && end <= block_end) { 753 if (ba->offset >= block->offset && end <= block_end) {
754 754
755 /* add block */ 755 /* add block */
756 list_move(&block->list, &dsp->used_block_list); 756 list_move(&block->list, &dsp->used_block_list);
757 list_add(&block->module_list, block_list); 757 list_add(&block->module_list, block_list);
758 dev_dbg(dsp->dev, "block allocated %d:%d at offset 0x%x\n", 758 dev_dbg(dsp->dev, "block allocated %d:%d at offset 0x%x\n",
759 block->type, block->index, block->offset); 759 block->type, block->index, block->offset);
760 return 0; 760 return 0;
761 } 761 }
762 762
763 /* does block span more than 1 section */ 763 /* does block span more than 1 section */
764 if (ba->offset >= block->offset && ba->offset < block_end) { 764 if (ba->offset >= block->offset && ba->offset < block_end) {
765 765
766 /* add block */
767 list_move(&block->list, &dsp->used_block_list);
768 list_add(&block->module_list, block_list);
766 /* align ba to block boundary */ 769 /* align ba to block boundary */
767 ba->offset = block->offset; 770 ba->size -= block_end - ba->offset;
771 ba->offset = block_end;
768 772
769 err = block_alloc_contiguous(dsp, ba, block_list); 773 err = block_alloc_contiguous(dsp, ba, block_list);
770 if (err < 0) 774 if (err < 0)
771 return -ENOMEM; 775 return -ENOMEM;
772 776
773 return 0; 777 return 0;
774 } 778 }
775 } 779 }
776 780
777 return -ENOMEM; 781 return -ENOMEM;
778 } 782 }
779 783
780 /* Load fixed module data into DSP memory blocks */ 784 /* Load fixed module data into DSP memory blocks */
781 int sst_module_alloc_blocks(struct sst_module *module) 785 int sst_module_alloc_blocks(struct sst_module *module)
782 { 786 {
783 struct sst_dsp *dsp = module->dsp; 787 struct sst_dsp *dsp = module->dsp;
784 struct sst_fw *sst_fw = module->sst_fw; 788 struct sst_fw *sst_fw = module->sst_fw;
785 struct sst_block_allocator ba; 789 struct sst_block_allocator ba;
786 int ret; 790 int ret;
787 791
788 ba.size = module->size; 792 ba.size = module->size;
789 ba.type = module->type; 793 ba.type = module->type;
790 ba.offset = module->offset; 794 ba.offset = module->offset;
791 795
792 dev_dbg(dsp->dev, "block request 0x%x bytes at offset 0x%x type %d\n", 796 dev_dbg(dsp->dev, "block request 0x%x bytes at offset 0x%x type %d\n",
793 ba.size, ba.offset, ba.type); 797 ba.size, ba.offset, ba.type);
794 798
795 mutex_lock(&dsp->mutex); 799 mutex_lock(&dsp->mutex);
796 800
797 /* alloc blocks that includes this section */ 801 /* alloc blocks that includes this section */
798 ret = block_alloc_fixed(dsp, &ba, &module->block_list); 802 ret = block_alloc_fixed(dsp, &ba, &module->block_list);
799 if (ret < 0) { 803 if (ret < 0) {
800 dev_err(dsp->dev, 804 dev_err(dsp->dev,
801 "error: no free blocks for section at offset 0x%x size 0x%x\n", 805 "error: no free blocks for section at offset 0x%x size 0x%x\n",
802 module->offset, module->size); 806 module->offset, module->size);
803 mutex_unlock(&dsp->mutex); 807 mutex_unlock(&dsp->mutex);
804 return -ENOMEM; 808 return -ENOMEM;
805 } 809 }
806 810
807 /* prepare DSP blocks for module copy */ 811 /* prepare DSP blocks for module copy */
808 ret = block_list_prepare(dsp, &module->block_list); 812 ret = block_list_prepare(dsp, &module->block_list);
809 if (ret < 0) { 813 if (ret < 0) {
810 dev_err(dsp->dev, "error: fw module prepare failed\n"); 814 dev_err(dsp->dev, "error: fw module prepare failed\n");
811 goto err; 815 goto err;
812 } 816 }
813 817
814 /* copy partial module data to blocks */ 818 /* copy partial module data to blocks */
815 if (dsp->fw_use_dma) { 819 if (dsp->fw_use_dma) {
816 ret = sst_dsp_dma_copyto(dsp, 820 ret = sst_dsp_dma_copyto(dsp,
817 dsp->addr.lpe_base + module->offset, 821 dsp->addr.lpe_base + module->offset,
818 sst_fw->dmable_fw_paddr + module->data_offset, 822 sst_fw->dmable_fw_paddr + module->data_offset,
819 module->size); 823 module->size);
820 if (ret < 0) { 824 if (ret < 0) {
821 dev_err(dsp->dev, "error: module copy failed\n"); 825 dev_err(dsp->dev, "error: module copy failed\n");
822 goto err; 826 goto err;
823 } 827 }
824 } else 828 } else
825 sst_memcpy32(dsp->addr.lpe + module->offset, module->data, 829 sst_memcpy32(dsp->addr.lpe + module->offset, module->data,
826 module->size); 830 module->size);
827 831
828 mutex_unlock(&dsp->mutex); 832 mutex_unlock(&dsp->mutex);
829 return ret; 833 return ret;
830 834
831 err: 835 err:
832 block_list_remove(dsp, &module->block_list); 836 block_list_remove(dsp, &module->block_list);
833 mutex_unlock(&dsp->mutex); 837 mutex_unlock(&dsp->mutex);
834 return ret; 838 return ret;
835 } 839 }
836 EXPORT_SYMBOL_GPL(sst_module_alloc_blocks); 840 EXPORT_SYMBOL_GPL(sst_module_alloc_blocks);
837 841
838 /* Unload entire module from DSP memory */ 842 /* Unload entire module from DSP memory */
839 int sst_module_free_blocks(struct sst_module *module) 843 int sst_module_free_blocks(struct sst_module *module)
840 { 844 {
841 struct sst_dsp *dsp = module->dsp; 845 struct sst_dsp *dsp = module->dsp;
842 846
843 mutex_lock(&dsp->mutex); 847 mutex_lock(&dsp->mutex);
844 block_list_remove(dsp, &module->block_list); 848 block_list_remove(dsp, &module->block_list);
845 mutex_unlock(&dsp->mutex); 849 mutex_unlock(&dsp->mutex);
846 return 0; 850 return 0;
847 } 851 }
848 EXPORT_SYMBOL_GPL(sst_module_free_blocks); 852 EXPORT_SYMBOL_GPL(sst_module_free_blocks);
849 853
850 int sst_module_runtime_alloc_blocks(struct sst_module_runtime *runtime, 854 int sst_module_runtime_alloc_blocks(struct sst_module_runtime *runtime,
851 int offset) 855 int offset)
852 { 856 {
853 struct sst_dsp *dsp = runtime->dsp; 857 struct sst_dsp *dsp = runtime->dsp;
854 struct sst_module *module = runtime->module; 858 struct sst_module *module = runtime->module;
855 struct sst_block_allocator ba; 859 struct sst_block_allocator ba;
856 int ret; 860 int ret;
857 861
858 if (module->persistent_size == 0) 862 if (module->persistent_size == 0)
859 return 0; 863 return 0;
860 864
861 ba.size = module->persistent_size; 865 ba.size = module->persistent_size;
862 ba.type = SST_MEM_DRAM; 866 ba.type = SST_MEM_DRAM;
863 867
864 mutex_lock(&dsp->mutex); 868 mutex_lock(&dsp->mutex);
865 869
866 /* do we need to allocate at a fixed address ? */ 870 /* do we need to allocate at a fixed address ? */
867 if (offset != 0) { 871 if (offset != 0) {
868 872
869 ba.offset = offset; 873 ba.offset = offset;
870 874
871 dev_dbg(dsp->dev, "persistent fixed block request 0x%x bytes type %d offset 0x%x\n", 875 dev_dbg(dsp->dev, "persistent fixed block request 0x%x bytes type %d offset 0x%x\n",
872 ba.size, ba.type, ba.offset); 876 ba.size, ba.type, ba.offset);
873 877
874 /* alloc blocks that includes this section */ 878 /* alloc blocks that includes this section */
875 ret = block_alloc_fixed(dsp, &ba, &runtime->block_list); 879 ret = block_alloc_fixed(dsp, &ba, &runtime->block_list);
876 880
877 } else { 881 } else {
878 dev_dbg(dsp->dev, "persistent block request 0x%x bytes type %d\n", 882 dev_dbg(dsp->dev, "persistent block request 0x%x bytes type %d\n",
879 ba.size, ba.type); 883 ba.size, ba.type);
880 884
881 /* alloc blocks that includes this section */ 885 /* alloc blocks that includes this section */
882 ret = block_alloc(dsp, &ba, &runtime->block_list); 886 ret = block_alloc(dsp, &ba, &runtime->block_list);
883 } 887 }
884 if (ret < 0) { 888 if (ret < 0) {
885 dev_err(dsp->dev, 889 dev_err(dsp->dev,
886 "error: no free blocks for runtime module size 0x%x\n", 890 "error: no free blocks for runtime module size 0x%x\n",
887 module->persistent_size); 891 module->persistent_size);
888 mutex_unlock(&dsp->mutex); 892 mutex_unlock(&dsp->mutex);
889 return -ENOMEM; 893 return -ENOMEM;
890 } 894 }
891 runtime->persistent_offset = ba.offset; 895 runtime->persistent_offset = ba.offset;
892 896
893 /* prepare DSP blocks for module copy */ 897 /* prepare DSP blocks for module copy */
894 ret = block_list_prepare(dsp, &runtime->block_list); 898 ret = block_list_prepare(dsp, &runtime->block_list);
895 if (ret < 0) { 899 if (ret < 0) {
896 dev_err(dsp->dev, "error: runtime block prepare failed\n"); 900 dev_err(dsp->dev, "error: runtime block prepare failed\n");
897 goto err; 901 goto err;
898 } 902 }
899 903
900 mutex_unlock(&dsp->mutex); 904 mutex_unlock(&dsp->mutex);
901 return ret; 905 return ret;
902 906
903 err: 907 err:
904 block_list_remove(dsp, &module->block_list); 908 block_list_remove(dsp, &module->block_list);
905 mutex_unlock(&dsp->mutex); 909 mutex_unlock(&dsp->mutex);
906 return ret; 910 return ret;
907 } 911 }
908 EXPORT_SYMBOL_GPL(sst_module_runtime_alloc_blocks); 912 EXPORT_SYMBOL_GPL(sst_module_runtime_alloc_blocks);
909 913
910 int sst_module_runtime_free_blocks(struct sst_module_runtime *runtime) 914 int sst_module_runtime_free_blocks(struct sst_module_runtime *runtime)
911 { 915 {
912 struct sst_dsp *dsp = runtime->dsp; 916 struct sst_dsp *dsp = runtime->dsp;
913 917
914 mutex_lock(&dsp->mutex); 918 mutex_lock(&dsp->mutex);
915 block_list_remove(dsp, &runtime->block_list); 919 block_list_remove(dsp, &runtime->block_list);
916 mutex_unlock(&dsp->mutex); 920 mutex_unlock(&dsp->mutex);
917 return 0; 921 return 0;
918 } 922 }
919 EXPORT_SYMBOL_GPL(sst_module_runtime_free_blocks); 923 EXPORT_SYMBOL_GPL(sst_module_runtime_free_blocks);
920 924
921 int sst_module_runtime_save(struct sst_module_runtime *runtime, 925 int sst_module_runtime_save(struct sst_module_runtime *runtime,
922 struct sst_module_runtime_context *context) 926 struct sst_module_runtime_context *context)
923 { 927 {
924 struct sst_dsp *dsp = runtime->dsp; 928 struct sst_dsp *dsp = runtime->dsp;
925 struct sst_module *module = runtime->module; 929 struct sst_module *module = runtime->module;
926 int ret = 0; 930 int ret = 0;
927 931
928 dev_dbg(dsp->dev, "saving runtime %d memory at 0x%x size 0x%x\n", 932 dev_dbg(dsp->dev, "saving runtime %d memory at 0x%x size 0x%x\n",
929 runtime->id, runtime->persistent_offset, 933 runtime->id, runtime->persistent_offset,
930 module->persistent_size); 934 module->persistent_size);
931 935
932 context->buffer = dma_alloc_coherent(dsp->dma_dev, 936 context->buffer = dma_alloc_coherent(dsp->dma_dev,
933 module->persistent_size, 937 module->persistent_size,
934 &context->dma_buffer, GFP_DMA | GFP_KERNEL); 938 &context->dma_buffer, GFP_DMA | GFP_KERNEL);
935 if (!context->buffer) { 939 if (!context->buffer) {
936 dev_err(dsp->dev, "error: DMA context alloc failed\n"); 940 dev_err(dsp->dev, "error: DMA context alloc failed\n");
937 return -ENOMEM; 941 return -ENOMEM;
938 } 942 }
939 943
940 mutex_lock(&dsp->mutex); 944 mutex_lock(&dsp->mutex);
941 945
942 if (dsp->fw_use_dma) { 946 if (dsp->fw_use_dma) {
943 947
944 ret = sst_dsp_dma_get_channel(dsp, 0); 948 ret = sst_dsp_dma_get_channel(dsp, 0);
945 if (ret < 0) 949 if (ret < 0)
946 goto err; 950 goto err;
947 951
948 ret = sst_dsp_dma_copyfrom(dsp, context->dma_buffer, 952 ret = sst_dsp_dma_copyfrom(dsp, context->dma_buffer,
949 dsp->addr.lpe_base + runtime->persistent_offset, 953 dsp->addr.lpe_base + runtime->persistent_offset,
950 module->persistent_size); 954 module->persistent_size);
951 sst_dsp_dma_put_channel(dsp); 955 sst_dsp_dma_put_channel(dsp);
952 if (ret < 0) { 956 if (ret < 0) {
953 dev_err(dsp->dev, "error: context copy failed\n"); 957 dev_err(dsp->dev, "error: context copy failed\n");
954 goto err; 958 goto err;
955 } 959 }
956 } else 960 } else
957 sst_memcpy32(context->buffer, dsp->addr.lpe + 961 sst_memcpy32(context->buffer, dsp->addr.lpe +
958 runtime->persistent_offset, 962 runtime->persistent_offset,
959 module->persistent_size); 963 module->persistent_size);
960 964
961 err: 965 err:
962 mutex_unlock(&dsp->mutex); 966 mutex_unlock(&dsp->mutex);
963 return ret; 967 return ret;
964 } 968 }
965 EXPORT_SYMBOL_GPL(sst_module_runtime_save); 969 EXPORT_SYMBOL_GPL(sst_module_runtime_save);
966 970
967 int sst_module_runtime_restore(struct sst_module_runtime *runtime, 971 int sst_module_runtime_restore(struct sst_module_runtime *runtime,
968 struct sst_module_runtime_context *context) 972 struct sst_module_runtime_context *context)
969 { 973 {
970 struct sst_dsp *dsp = runtime->dsp; 974 struct sst_dsp *dsp = runtime->dsp;
971 struct sst_module *module = runtime->module; 975 struct sst_module *module = runtime->module;
972 int ret = 0; 976 int ret = 0;
973 977
974 dev_dbg(dsp->dev, "restoring runtime %d memory at 0x%x size 0x%x\n", 978 dev_dbg(dsp->dev, "restoring runtime %d memory at 0x%x size 0x%x\n",
975 runtime->id, runtime->persistent_offset, 979 runtime->id, runtime->persistent_offset,
976 module->persistent_size); 980 module->persistent_size);
977 981
978 mutex_lock(&dsp->mutex); 982 mutex_lock(&dsp->mutex);
979 983
980 if (!context->buffer) { 984 if (!context->buffer) {
981 dev_info(dsp->dev, "no context buffer need to restore!\n"); 985 dev_info(dsp->dev, "no context buffer need to restore!\n");
982 goto err; 986 goto err;
983 } 987 }
984 988
985 if (dsp->fw_use_dma) { 989 if (dsp->fw_use_dma) {
986 990
987 ret = sst_dsp_dma_get_channel(dsp, 0); 991 ret = sst_dsp_dma_get_channel(dsp, 0);
988 if (ret < 0) 992 if (ret < 0)
989 goto err; 993 goto err;
990 994
991 ret = sst_dsp_dma_copyto(dsp, 995 ret = sst_dsp_dma_copyto(dsp,
992 dsp->addr.lpe_base + runtime->persistent_offset, 996 dsp->addr.lpe_base + runtime->persistent_offset,
993 context->dma_buffer, module->persistent_size); 997 context->dma_buffer, module->persistent_size);
994 sst_dsp_dma_put_channel(dsp); 998 sst_dsp_dma_put_channel(dsp);
995 if (ret < 0) { 999 if (ret < 0) {
996 dev_err(dsp->dev, "error: module copy failed\n"); 1000 dev_err(dsp->dev, "error: module copy failed\n");
997 goto err; 1001 goto err;
998 } 1002 }
999 } else 1003 } else
1000 sst_memcpy32(dsp->addr.lpe + runtime->persistent_offset, 1004 sst_memcpy32(dsp->addr.lpe + runtime->persistent_offset,
1001 context->buffer, module->persistent_size); 1005 context->buffer, module->persistent_size);
1002 1006
1003 dma_free_coherent(dsp->dma_dev, module->persistent_size, 1007 dma_free_coherent(dsp->dma_dev, module->persistent_size,
1004 context->buffer, context->dma_buffer); 1008 context->buffer, context->dma_buffer);
1005 context->buffer = NULL; 1009 context->buffer = NULL;
1006 1010
1007 err: 1011 err:
1008 mutex_unlock(&dsp->mutex); 1012 mutex_unlock(&dsp->mutex);
1009 return ret; 1013 return ret;
1010 } 1014 }
1011 EXPORT_SYMBOL_GPL(sst_module_runtime_restore); 1015 EXPORT_SYMBOL_GPL(sst_module_runtime_restore);
1012 1016
1013 /* register a DSP memory block for use with FW based modules */ 1017 /* register a DSP memory block for use with FW based modules */
1014 struct sst_mem_block *sst_mem_block_register(struct sst_dsp *dsp, u32 offset, 1018 struct sst_mem_block *sst_mem_block_register(struct sst_dsp *dsp, u32 offset,
1015 u32 size, enum sst_mem_type type, struct sst_block_ops *ops, u32 index, 1019 u32 size, enum sst_mem_type type, struct sst_block_ops *ops, u32 index,
1016 void *private) 1020 void *private)
1017 { 1021 {
1018 struct sst_mem_block *block; 1022 struct sst_mem_block *block;
1019 1023
1020 block = kzalloc(sizeof(*block), GFP_KERNEL); 1024 block = kzalloc(sizeof(*block), GFP_KERNEL);
1021 if (block == NULL) 1025 if (block == NULL)
1022 return NULL; 1026 return NULL;
1023 1027
1024 block->offset = offset; 1028 block->offset = offset;
1025 block->size = size; 1029 block->size = size;
1026 block->index = index; 1030 block->index = index;
1027 block->type = type; 1031 block->type = type;
1028 block->dsp = dsp; 1032 block->dsp = dsp;
1029 block->private = private; 1033 block->private = private;
1030 block->ops = ops; 1034 block->ops = ops;
1031 1035
1032 mutex_lock(&dsp->mutex); 1036 mutex_lock(&dsp->mutex);
1033 list_add(&block->list, &dsp->free_block_list); 1037 list_add(&block->list, &dsp->free_block_list);
1034 mutex_unlock(&dsp->mutex); 1038 mutex_unlock(&dsp->mutex);
1035 1039
1036 return block; 1040 return block;
1037 } 1041 }
1038 EXPORT_SYMBOL_GPL(sst_mem_block_register); 1042 EXPORT_SYMBOL_GPL(sst_mem_block_register);
1039 1043
1040 /* unregister all DSP memory blocks */ 1044 /* unregister all DSP memory blocks */
1041 void sst_mem_block_unregister_all(struct sst_dsp *dsp) 1045 void sst_mem_block_unregister_all(struct sst_dsp *dsp)
1042 { 1046 {
1043 struct sst_mem_block *block, *tmp; 1047 struct sst_mem_block *block, *tmp;
1044 1048
1045 mutex_lock(&dsp->mutex); 1049 mutex_lock(&dsp->mutex);
1046 1050
1047 /* unregister used blocks */ 1051 /* unregister used blocks */
1048 list_for_each_entry_safe(block, tmp, &dsp->used_block_list, list) { 1052 list_for_each_entry_safe(block, tmp, &dsp->used_block_list, list) {
1049 list_del(&block->list); 1053 list_del(&block->list);
1050 kfree(block); 1054 kfree(block);
1051 } 1055 }
1052 1056
1053 /* unregister free blocks */ 1057 /* unregister free blocks */
1054 list_for_each_entry_safe(block, tmp, &dsp->free_block_list, list) { 1058 list_for_each_entry_safe(block, tmp, &dsp->free_block_list, list) {
1055 list_del(&block->list); 1059 list_del(&block->list);
1056 kfree(block); 1060 kfree(block);
1057 } 1061 }
1058 1062
1059 mutex_unlock(&dsp->mutex); 1063 mutex_unlock(&dsp->mutex);
1060 } 1064 }
1061 EXPORT_SYMBOL_GPL(sst_mem_block_unregister_all); 1065 EXPORT_SYMBOL_GPL(sst_mem_block_unregister_all);
1062 1066
1063 /* allocate scratch buffer blocks */ 1067 /* allocate scratch buffer blocks */
1064 int sst_block_alloc_scratch(struct sst_dsp *dsp) 1068 int sst_block_alloc_scratch(struct sst_dsp *dsp)
1065 { 1069 {
1066 struct sst_module *module; 1070 struct sst_module *module;
1067 struct sst_block_allocator ba; 1071 struct sst_block_allocator ba;
1068 int ret; 1072 int ret;
1069 1073
1070 mutex_lock(&dsp->mutex); 1074 mutex_lock(&dsp->mutex);
1071 1075
1072 /* calculate required scratch size */ 1076 /* calculate required scratch size */
1073 dsp->scratch_size = 0; 1077 dsp->scratch_size = 0;
1074 list_for_each_entry(module, &dsp->module_list, list) { 1078 list_for_each_entry(module, &dsp->module_list, list) {
1075 dev_dbg(dsp->dev, "module %d scratch req 0x%x bytes\n", 1079 dev_dbg(dsp->dev, "module %d scratch req 0x%x bytes\n",
1076 module->id, module->scratch_size); 1080 module->id, module->scratch_size);
1077 if (dsp->scratch_size < module->scratch_size) 1081 if (dsp->scratch_size < module->scratch_size)
1078 dsp->scratch_size = module->scratch_size; 1082 dsp->scratch_size = module->scratch_size;
1079 } 1083 }
1080 1084
1081 dev_dbg(dsp->dev, "scratch buffer required is 0x%x bytes\n", 1085 dev_dbg(dsp->dev, "scratch buffer required is 0x%x bytes\n",
1082 dsp->scratch_size); 1086 dsp->scratch_size);
1083 1087
1084 if (dsp->scratch_size == 0) { 1088 if (dsp->scratch_size == 0) {
1085 dev_info(dsp->dev, "no modules need scratch buffer\n"); 1089 dev_info(dsp->dev, "no modules need scratch buffer\n");
1086 mutex_unlock(&dsp->mutex); 1090 mutex_unlock(&dsp->mutex);
1087 return 0; 1091 return 0;
1088 } 1092 }
1089 1093
1090 /* allocate blocks for module scratch buffers */ 1094 /* allocate blocks for module scratch buffers */
1091 dev_dbg(dsp->dev, "allocating scratch blocks\n"); 1095 dev_dbg(dsp->dev, "allocating scratch blocks\n");
1092 1096
1093 ba.size = dsp->scratch_size; 1097 ba.size = dsp->scratch_size;
1094 ba.type = SST_MEM_DRAM; 1098 ba.type = SST_MEM_DRAM;
1095 1099
1096 /* do we need to allocate at fixed offset */ 1100 /* do we need to allocate at fixed offset */
1097 if (dsp->scratch_offset != 0) { 1101 if (dsp->scratch_offset != 0) {
1098 1102
1099 dev_dbg(dsp->dev, "block request 0x%x bytes type %d at 0x%x\n", 1103 dev_dbg(dsp->dev, "block request 0x%x bytes type %d at 0x%x\n",
1100 ba.size, ba.type, ba.offset); 1104 ba.size, ba.type, ba.offset);
1101 1105
1102 ba.offset = dsp->scratch_offset; 1106 ba.offset = dsp->scratch_offset;
1103 1107
1104 /* alloc blocks that includes this section */ 1108 /* alloc blocks that includes this section */
1105 ret = block_alloc_fixed(dsp, &ba, &dsp->scratch_block_list); 1109 ret = block_alloc_fixed(dsp, &ba, &dsp->scratch_block_list);
1106 1110
1107 } else { 1111 } else {
1108 dev_dbg(dsp->dev, "block request 0x%x bytes type %d\n", 1112 dev_dbg(dsp->dev, "block request 0x%x bytes type %d\n",
1109 ba.size, ba.type); 1113 ba.size, ba.type);
1110 1114
1111 ba.offset = 0; 1115 ba.offset = 0;
1112 ret = block_alloc(dsp, &ba, &dsp->scratch_block_list); 1116 ret = block_alloc(dsp, &ba, &dsp->scratch_block_list);
1113 } 1117 }
1114 if (ret < 0) { 1118 if (ret < 0) {
1115 dev_err(dsp->dev, "error: can't alloc scratch blocks\n"); 1119 dev_err(dsp->dev, "error: can't alloc scratch blocks\n");
1116 mutex_unlock(&dsp->mutex); 1120 mutex_unlock(&dsp->mutex);
1117 return ret; 1121 return ret;
1118 } 1122 }
1119 1123
1120 ret = block_list_prepare(dsp, &dsp->scratch_block_list); 1124 ret = block_list_prepare(dsp, &dsp->scratch_block_list);
1121 if (ret < 0) { 1125 if (ret < 0) {
1122 dev_err(dsp->dev, "error: scratch block prepare failed\n"); 1126 dev_err(dsp->dev, "error: scratch block prepare failed\n");
1123 mutex_unlock(&dsp->mutex); 1127 mutex_unlock(&dsp->mutex);
1124 return ret; 1128 return ret;
1125 } 1129 }
1126 1130
1127 /* assign the same offset of scratch to each module */ 1131 /* assign the same offset of scratch to each module */
1128 dsp->scratch_offset = ba.offset; 1132 dsp->scratch_offset = ba.offset;
1129 mutex_unlock(&dsp->mutex); 1133 mutex_unlock(&dsp->mutex);
1130 return dsp->scratch_size; 1134 return dsp->scratch_size;
1131 } 1135 }
1132 EXPORT_SYMBOL_GPL(sst_block_alloc_scratch); 1136 EXPORT_SYMBOL_GPL(sst_block_alloc_scratch);
1133 1137
1134 /* free all scratch blocks */ 1138 /* free all scratch blocks */
1135 void sst_block_free_scratch(struct sst_dsp *dsp) 1139 void sst_block_free_scratch(struct sst_dsp *dsp)
1136 { 1140 {
1137 mutex_lock(&dsp->mutex); 1141 mutex_lock(&dsp->mutex);
1138 block_list_remove(dsp, &dsp->scratch_block_list); 1142 block_list_remove(dsp, &dsp->scratch_block_list);
1139 mutex_unlock(&dsp->mutex); 1143 mutex_unlock(&dsp->mutex);
1140 } 1144 }
1141 EXPORT_SYMBOL_GPL(sst_block_free_scratch); 1145 EXPORT_SYMBOL_GPL(sst_block_free_scratch);
1142 1146
1143 /* get a module from it's unique ID */ 1147 /* get a module from it's unique ID */
1144 struct sst_module *sst_module_get_from_id(struct sst_dsp *dsp, u32 id) 1148 struct sst_module *sst_module_get_from_id(struct sst_dsp *dsp, u32 id)
1145 { 1149 {
1146 struct sst_module *module; 1150 struct sst_module *module;
1147 1151
1148 mutex_lock(&dsp->mutex); 1152 mutex_lock(&dsp->mutex);
1149 1153
1150 list_for_each_entry(module, &dsp->module_list, list) { 1154 list_for_each_entry(module, &dsp->module_list, list) {
1151 if (module->id == id) { 1155 if (module->id == id) {
1152 mutex_unlock(&dsp->mutex); 1156 mutex_unlock(&dsp->mutex);
1153 return module; 1157 return module;
1154 } 1158 }
1155 } 1159 }
1156 1160
1157 mutex_unlock(&dsp->mutex); 1161 mutex_unlock(&dsp->mutex);
1158 return NULL; 1162 return NULL;
1159 } 1163 }
1160 EXPORT_SYMBOL_GPL(sst_module_get_from_id); 1164 EXPORT_SYMBOL_GPL(sst_module_get_from_id);
1161 1165
1162 struct sst_module_runtime *sst_module_runtime_get_from_id( 1166 struct sst_module_runtime *sst_module_runtime_get_from_id(
1163 struct sst_module *module, u32 id) 1167 struct sst_module *module, u32 id)
1164 { 1168 {
1165 struct sst_module_runtime *runtime; 1169 struct sst_module_runtime *runtime;
1166 struct sst_dsp *dsp = module->dsp; 1170 struct sst_dsp *dsp = module->dsp;
1167 1171
1168 mutex_lock(&dsp->mutex); 1172 mutex_lock(&dsp->mutex);
1169 1173
1170 list_for_each_entry(runtime, &module->runtime_list, list) { 1174 list_for_each_entry(runtime, &module->runtime_list, list) {
1171 if (runtime->id == id) { 1175 if (runtime->id == id) {
1172 mutex_unlock(&dsp->mutex); 1176 mutex_unlock(&dsp->mutex);
1173 return runtime; 1177 return runtime;
1174 } 1178 }
1175 } 1179 }
1176 1180
1177 mutex_unlock(&dsp->mutex); 1181 mutex_unlock(&dsp->mutex);
1178 return NULL; 1182 return NULL;
1179 } 1183 }
1180 EXPORT_SYMBOL_GPL(sst_module_runtime_get_from_id); 1184 EXPORT_SYMBOL_GPL(sst_module_runtime_get_from_id);
1181 1185
1182 /* returns block address in DSP address space */ 1186 /* returns block address in DSP address space */
1183 u32 sst_dsp_get_offset(struct sst_dsp *dsp, u32 offset, 1187 u32 sst_dsp_get_offset(struct sst_dsp *dsp, u32 offset,
1184 enum sst_mem_type type) 1188 enum sst_mem_type type)
1185 { 1189 {
1186 switch (type) { 1190 switch (type) {
1187 case SST_MEM_IRAM: 1191 case SST_MEM_IRAM:
1188 return offset - dsp->addr.iram_offset + 1192 return offset - dsp->addr.iram_offset +
1189 dsp->addr.dsp_iram_offset; 1193 dsp->addr.dsp_iram_offset;
1190 case SST_MEM_DRAM: 1194 case SST_MEM_DRAM:
1191 return offset - dsp->addr.dram_offset + 1195 return offset - dsp->addr.dram_offset +
1192 dsp->addr.dsp_dram_offset; 1196 dsp->addr.dsp_dram_offset;
1193 default: 1197 default:
1194 return 0; 1198 return 0;
1195 } 1199 }
1196 } 1200 }
1197 EXPORT_SYMBOL_GPL(sst_dsp_get_offset); 1201 EXPORT_SYMBOL_GPL(sst_dsp_get_offset);
1198 1202
sound/soc/intel/sst/sst_acpi.c
1 /* 1 /*
2 * sst_acpi.c - SST (LPE) driver init file for ACPI enumeration. 2 * sst_acpi.c - SST (LPE) driver init file for ACPI enumeration.
3 * 3 *
4 * Copyright (c) 2013, Intel Corporation. 4 * Copyright (c) 2013, Intel Corporation.
5 * 5 *
6 * Authors: Ramesh Babu K V <Ramesh.Babu@intel.com> 6 * Authors: Ramesh Babu K V <Ramesh.Babu@intel.com>
7 * Authors: Omair Mohammed Abdullah <omair.m.abdullah@intel.com> 7 * Authors: Omair Mohammed Abdullah <omair.m.abdullah@intel.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License, 10 * under the terms and conditions of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation. 11 * version 2, as published by the Free Software Foundation.
12 * 12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT 13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details. 16 * more details.
17 * 17 *
18 * 18 *
19 */ 19 */
20 20
21 #include <linux/module.h> 21 #include <linux/module.h>
22 #include <linux/fs.h> 22 #include <linux/fs.h>
23 #include <linux/interrupt.h> 23 #include <linux/interrupt.h>
24 #include <linux/slab.h> 24 #include <linux/slab.h>
25 #include <linux/io.h> 25 #include <linux/io.h>
26 #include <linux/miscdevice.h> 26 #include <linux/miscdevice.h>
27 #include <linux/platform_device.h> 27 #include <linux/platform_device.h>
28 #include <linux/firmware.h> 28 #include <linux/firmware.h>
29 #include <linux/pm_runtime.h> 29 #include <linux/pm_runtime.h>
30 #include <linux/pm_qos.h> 30 #include <linux/pm_qos.h>
31 #include <linux/acpi.h> 31 #include <linux/acpi.h>
32 #include <asm/platform_sst_audio.h> 32 #include <asm/platform_sst_audio.h>
33 #include <sound/core.h> 33 #include <sound/core.h>
34 #include <sound/soc.h> 34 #include <sound/soc.h>
35 #include <sound/compress_driver.h> 35 #include <sound/compress_driver.h>
36 #include <acpi/acbuffer.h> 36 #include <acpi/acbuffer.h>
37 #include <acpi/platform/acenv.h> 37 #include <acpi/platform/acenv.h>
38 #include <acpi/platform/aclinux.h> 38 #include <acpi/platform/aclinux.h>
39 #include <acpi/actypes.h> 39 #include <acpi/actypes.h>
40 #include <acpi/acpi_bus.h> 40 #include <acpi/acpi_bus.h>
41 #include "../sst-mfld-platform.h" 41 #include "../sst-mfld-platform.h"
42 #include "../sst-dsp.h" 42 #include "../sst-dsp.h"
43 #include "sst.h" 43 #include "sst.h"
44 44
45 struct sst_machines { 45 struct sst_machines {
46 char *codec_id; 46 char *codec_id;
47 char board[32]; 47 char board[32];
48 char machine[32]; 48 char machine[32];
49 void (*machine_quirk)(void); 49 void (*machine_quirk)(void);
50 char firmware[32]; 50 char firmware[32];
51 struct sst_platform_info *pdata; 51 struct sst_platform_info *pdata;
52 52
53 }; 53 };
54 54
55 /* LPE viewpoint addresses */ 55 /* LPE viewpoint addresses */
56 #define SST_BYT_IRAM_PHY_START 0xff2c0000 56 #define SST_BYT_IRAM_PHY_START 0xff2c0000
57 #define SST_BYT_IRAM_PHY_END 0xff2d4000 57 #define SST_BYT_IRAM_PHY_END 0xff2d4000
58 #define SST_BYT_DRAM_PHY_START 0xff300000 58 #define SST_BYT_DRAM_PHY_START 0xff300000
59 #define SST_BYT_DRAM_PHY_END 0xff320000 59 #define SST_BYT_DRAM_PHY_END 0xff320000
60 #define SST_BYT_IMR_VIRT_START 0xc0000000 /* virtual addr in LPE */ 60 #define SST_BYT_IMR_VIRT_START 0xc0000000 /* virtual addr in LPE */
61 #define SST_BYT_IMR_VIRT_END 0xc01fffff 61 #define SST_BYT_IMR_VIRT_END 0xc01fffff
62 #define SST_BYT_SHIM_PHY_ADDR 0xff340000 62 #define SST_BYT_SHIM_PHY_ADDR 0xff340000
63 #define SST_BYT_MBOX_PHY_ADDR 0xff344000 63 #define SST_BYT_MBOX_PHY_ADDR 0xff344000
64 #define SST_BYT_DMA0_PHY_ADDR 0xff298000 64 #define SST_BYT_DMA0_PHY_ADDR 0xff298000
65 #define SST_BYT_DMA1_PHY_ADDR 0xff29c000 65 #define SST_BYT_DMA1_PHY_ADDR 0xff29c000
66 #define SST_BYT_SSP0_PHY_ADDR 0xff2a0000 66 #define SST_BYT_SSP0_PHY_ADDR 0xff2a0000
67 #define SST_BYT_SSP2_PHY_ADDR 0xff2a2000 67 #define SST_BYT_SSP2_PHY_ADDR 0xff2a2000
68 68
69 #define BYT_FW_MOD_TABLE_OFFSET 0x80000 69 #define BYT_FW_MOD_TABLE_OFFSET 0x80000
70 #define BYT_FW_MOD_TABLE_SIZE 0x100 70 #define BYT_FW_MOD_TABLE_SIZE 0x100
71 #define BYT_FW_MOD_OFFSET (BYT_FW_MOD_TABLE_OFFSET + BYT_FW_MOD_TABLE_SIZE) 71 #define BYT_FW_MOD_OFFSET (BYT_FW_MOD_TABLE_OFFSET + BYT_FW_MOD_TABLE_SIZE)
72 72
73 static const struct sst_info byt_fwparse_info = { 73 static const struct sst_info byt_fwparse_info = {
74 .use_elf = false, 74 .use_elf = false,
75 .max_streams = 25, 75 .max_streams = 25,
76 .iram_start = SST_BYT_IRAM_PHY_START, 76 .iram_start = SST_BYT_IRAM_PHY_START,
77 .iram_end = SST_BYT_IRAM_PHY_END, 77 .iram_end = SST_BYT_IRAM_PHY_END,
78 .iram_use = true, 78 .iram_use = true,
79 .dram_start = SST_BYT_DRAM_PHY_START, 79 .dram_start = SST_BYT_DRAM_PHY_START,
80 .dram_end = SST_BYT_DRAM_PHY_END, 80 .dram_end = SST_BYT_DRAM_PHY_END,
81 .dram_use = true, 81 .dram_use = true,
82 .imr_start = SST_BYT_IMR_VIRT_START, 82 .imr_start = SST_BYT_IMR_VIRT_START,
83 .imr_end = SST_BYT_IMR_VIRT_END, 83 .imr_end = SST_BYT_IMR_VIRT_END,
84 .imr_use = true, 84 .imr_use = true,
85 .mailbox_start = SST_BYT_MBOX_PHY_ADDR, 85 .mailbox_start = SST_BYT_MBOX_PHY_ADDR,
86 .num_probes = 0, 86 .num_probes = 0,
87 .lpe_viewpt_rqd = true, 87 .lpe_viewpt_rqd = true,
88 }; 88 };
89 89
90 static const struct sst_ipc_info byt_ipc_info = { 90 static const struct sst_ipc_info byt_ipc_info = {
91 .ipc_offset = 0, 91 .ipc_offset = 0,
92 .mbox_recv_off = 0x400, 92 .mbox_recv_off = 0x400,
93 }; 93 };
94 94
95 static const struct sst_lib_dnld_info byt_lib_dnld_info = { 95 static const struct sst_lib_dnld_info byt_lib_dnld_info = {
96 .mod_base = SST_BYT_IMR_VIRT_START, 96 .mod_base = SST_BYT_IMR_VIRT_START,
97 .mod_end = SST_BYT_IMR_VIRT_END, 97 .mod_end = SST_BYT_IMR_VIRT_END,
98 .mod_table_offset = BYT_FW_MOD_TABLE_OFFSET, 98 .mod_table_offset = BYT_FW_MOD_TABLE_OFFSET,
99 .mod_table_size = BYT_FW_MOD_TABLE_SIZE, 99 .mod_table_size = BYT_FW_MOD_TABLE_SIZE,
100 .mod_ddr_dnld = false, 100 .mod_ddr_dnld = false,
101 }; 101 };
102 102
103 static const struct sst_res_info byt_rvp_res_info = { 103 static const struct sst_res_info byt_rvp_res_info = {
104 .shim_offset = 0x140000, 104 .shim_offset = 0x140000,
105 .shim_size = 0x000100, 105 .shim_size = 0x000100,
106 .shim_phy_addr = SST_BYT_SHIM_PHY_ADDR, 106 .shim_phy_addr = SST_BYT_SHIM_PHY_ADDR,
107 .ssp0_offset = 0xa0000, 107 .ssp0_offset = 0xa0000,
108 .ssp0_size = 0x1000, 108 .ssp0_size = 0x1000,
109 .dma0_offset = 0x98000, 109 .dma0_offset = 0x98000,
110 .dma0_size = 0x4000, 110 .dma0_size = 0x4000,
111 .dma1_offset = 0x9c000, 111 .dma1_offset = 0x9c000,
112 .dma1_size = 0x4000, 112 .dma1_size = 0x4000,
113 .iram_offset = 0x0c0000, 113 .iram_offset = 0x0c0000,
114 .iram_size = 0x14000, 114 .iram_size = 0x14000,
115 .dram_offset = 0x100000, 115 .dram_offset = 0x100000,
116 .dram_size = 0x28000, 116 .dram_size = 0x28000,
117 .mbox_offset = 0x144000, 117 .mbox_offset = 0x144000,
118 .mbox_size = 0x1000, 118 .mbox_size = 0x1000,
119 .acpi_lpe_res_index = 0, 119 .acpi_lpe_res_index = 0,
120 .acpi_ddr_index = 2, 120 .acpi_ddr_index = 2,
121 .acpi_ipc_irq_index = 5, 121 .acpi_ipc_irq_index = 5,
122 }; 122 };
123 123
124 static struct sst_platform_info byt_rvp_platform_data = { 124 static struct sst_platform_info byt_rvp_platform_data = {
125 .probe_data = &byt_fwparse_info, 125 .probe_data = &byt_fwparse_info,
126 .ipc_info = &byt_ipc_info, 126 .ipc_info = &byt_ipc_info,
127 .lib_info = &byt_lib_dnld_info, 127 .lib_info = &byt_lib_dnld_info,
128 .res_info = &byt_rvp_res_info, 128 .res_info = &byt_rvp_res_info,
129 .platform = "sst-mfld-platform", 129 .platform = "sst-mfld-platform",
130 }; 130 };
131 131
132 /* Cherryview (Cherrytrail and Braswell) uses same mrfld dpcm fw as Baytrail, 132 /* Cherryview (Cherrytrail and Braswell) uses same mrfld dpcm fw as Baytrail,
133 * so pdata is same as Baytrail. 133 * so pdata is same as Baytrail.
134 */ 134 */
135 static struct sst_platform_info chv_platform_data = { 135 static struct sst_platform_info chv_platform_data = {
136 .probe_data = &byt_fwparse_info, 136 .probe_data = &byt_fwparse_info,
137 .ipc_info = &byt_ipc_info, 137 .ipc_info = &byt_ipc_info,
138 .lib_info = &byt_lib_dnld_info, 138 .lib_info = &byt_lib_dnld_info,
139 .res_info = &byt_rvp_res_info, 139 .res_info = &byt_rvp_res_info,
140 .platform = "sst-mfld-platform", 140 .platform = "sst-mfld-platform",
141 }; 141 };
142 142
143 static int sst_platform_get_resources(struct intel_sst_drv *ctx) 143 static int sst_platform_get_resources(struct intel_sst_drv *ctx)
144 { 144 {
145 struct resource *rsrc; 145 struct resource *rsrc;
146 struct platform_device *pdev = to_platform_device(ctx->dev); 146 struct platform_device *pdev = to_platform_device(ctx->dev);
147 147
148 /* All ACPI resource request here */ 148 /* All ACPI resource request here */
149 /* Get Shim addr */ 149 /* Get Shim addr */
150 rsrc = platform_get_resource(pdev, IORESOURCE_MEM, 150 rsrc = platform_get_resource(pdev, IORESOURCE_MEM,
151 ctx->pdata->res_info->acpi_lpe_res_index); 151 ctx->pdata->res_info->acpi_lpe_res_index);
152 if (!rsrc) { 152 if (!rsrc) {
153 dev_err(ctx->dev, "Invalid SHIM base from IFWI"); 153 dev_err(ctx->dev, "Invalid SHIM base from IFWI");
154 return -EIO; 154 return -EIO;
155 } 155 }
156 dev_info(ctx->dev, "LPE base: %#x size:%#x", (unsigned int) rsrc->start, 156 dev_info(ctx->dev, "LPE base: %#x size:%#x", (unsigned int) rsrc->start,
157 (unsigned int)resource_size(rsrc)); 157 (unsigned int)resource_size(rsrc));
158 158
159 ctx->iram_base = rsrc->start + ctx->pdata->res_info->iram_offset; 159 ctx->iram_base = rsrc->start + ctx->pdata->res_info->iram_offset;
160 ctx->iram_end = ctx->iram_base + ctx->pdata->res_info->iram_size - 1; 160 ctx->iram_end = ctx->iram_base + ctx->pdata->res_info->iram_size - 1;
161 dev_info(ctx->dev, "IRAM base: %#x", ctx->iram_base); 161 dev_info(ctx->dev, "IRAM base: %#x", ctx->iram_base);
162 ctx->iram = devm_ioremap_nocache(ctx->dev, ctx->iram_base, 162 ctx->iram = devm_ioremap_nocache(ctx->dev, ctx->iram_base,
163 ctx->pdata->res_info->iram_size); 163 ctx->pdata->res_info->iram_size);
164 if (!ctx->iram) { 164 if (!ctx->iram) {
165 dev_err(ctx->dev, "unable to map IRAM"); 165 dev_err(ctx->dev, "unable to map IRAM");
166 return -EIO; 166 return -EIO;
167 } 167 }
168 168
169 ctx->dram_base = rsrc->start + ctx->pdata->res_info->dram_offset; 169 ctx->dram_base = rsrc->start + ctx->pdata->res_info->dram_offset;
170 ctx->dram_end = ctx->dram_base + ctx->pdata->res_info->dram_size - 1; 170 ctx->dram_end = ctx->dram_base + ctx->pdata->res_info->dram_size - 1;
171 dev_info(ctx->dev, "DRAM base: %#x", ctx->dram_base); 171 dev_info(ctx->dev, "DRAM base: %#x", ctx->dram_base);
172 ctx->dram = devm_ioremap_nocache(ctx->dev, ctx->dram_base, 172 ctx->dram = devm_ioremap_nocache(ctx->dev, ctx->dram_base,
173 ctx->pdata->res_info->dram_size); 173 ctx->pdata->res_info->dram_size);
174 if (!ctx->dram) { 174 if (!ctx->dram) {
175 dev_err(ctx->dev, "unable to map DRAM"); 175 dev_err(ctx->dev, "unable to map DRAM");
176 return -EIO; 176 return -EIO;
177 } 177 }
178 178
179 ctx->shim_phy_add = rsrc->start + ctx->pdata->res_info->shim_offset; 179 ctx->shim_phy_add = rsrc->start + ctx->pdata->res_info->shim_offset;
180 dev_info(ctx->dev, "SHIM base: %#x", ctx->shim_phy_add); 180 dev_info(ctx->dev, "SHIM base: %#x", ctx->shim_phy_add);
181 ctx->shim = devm_ioremap_nocache(ctx->dev, ctx->shim_phy_add, 181 ctx->shim = devm_ioremap_nocache(ctx->dev, ctx->shim_phy_add,
182 ctx->pdata->res_info->shim_size); 182 ctx->pdata->res_info->shim_size);
183 if (!ctx->shim) { 183 if (!ctx->shim) {
184 dev_err(ctx->dev, "unable to map SHIM"); 184 dev_err(ctx->dev, "unable to map SHIM");
185 return -EIO; 185 return -EIO;
186 } 186 }
187 187
188 /* reassign physical address to LPE viewpoint address */ 188 /* reassign physical address to LPE viewpoint address */
189 ctx->shim_phy_add = ctx->pdata->res_info->shim_phy_addr; 189 ctx->shim_phy_add = ctx->pdata->res_info->shim_phy_addr;
190 190
191 /* Get mailbox addr */ 191 /* Get mailbox addr */
192 ctx->mailbox_add = rsrc->start + ctx->pdata->res_info->mbox_offset; 192 ctx->mailbox_add = rsrc->start + ctx->pdata->res_info->mbox_offset;
193 dev_info(ctx->dev, "Mailbox base: %#x", ctx->mailbox_add); 193 dev_info(ctx->dev, "Mailbox base: %#x", ctx->mailbox_add);
194 ctx->mailbox = devm_ioremap_nocache(ctx->dev, ctx->mailbox_add, 194 ctx->mailbox = devm_ioremap_nocache(ctx->dev, ctx->mailbox_add,
195 ctx->pdata->res_info->mbox_size); 195 ctx->pdata->res_info->mbox_size);
196 if (!ctx->mailbox) { 196 if (!ctx->mailbox) {
197 dev_err(ctx->dev, "unable to map mailbox"); 197 dev_err(ctx->dev, "unable to map mailbox");
198 return -EIO; 198 return -EIO;
199 } 199 }
200 200
201 /* reassign physical address to LPE viewpoint address */ 201 /* reassign physical address to LPE viewpoint address */
202 ctx->mailbox_add = ctx->info.mailbox_start; 202 ctx->mailbox_add = ctx->info.mailbox_start;
203 203
204 rsrc = platform_get_resource(pdev, IORESOURCE_MEM, 204 rsrc = platform_get_resource(pdev, IORESOURCE_MEM,
205 ctx->pdata->res_info->acpi_ddr_index); 205 ctx->pdata->res_info->acpi_ddr_index);
206 if (!rsrc) { 206 if (!rsrc) {
207 dev_err(ctx->dev, "Invalid DDR base from IFWI"); 207 dev_err(ctx->dev, "Invalid DDR base from IFWI");
208 return -EIO; 208 return -EIO;
209 } 209 }
210 ctx->ddr_base = rsrc->start; 210 ctx->ddr_base = rsrc->start;
211 ctx->ddr_end = rsrc->end; 211 ctx->ddr_end = rsrc->end;
212 dev_info(ctx->dev, "DDR base: %#x", ctx->ddr_base); 212 dev_info(ctx->dev, "DDR base: %#x", ctx->ddr_base);
213 ctx->ddr = devm_ioremap_nocache(ctx->dev, ctx->ddr_base, 213 ctx->ddr = devm_ioremap_nocache(ctx->dev, ctx->ddr_base,
214 resource_size(rsrc)); 214 resource_size(rsrc));
215 if (!ctx->ddr) { 215 if (!ctx->ddr) {
216 dev_err(ctx->dev, "unable to map DDR"); 216 dev_err(ctx->dev, "unable to map DDR");
217 return -EIO; 217 return -EIO;
218 } 218 }
219 219
220 /* Find the IRQ */ 220 /* Find the IRQ */
221 ctx->irq_num = platform_get_irq(pdev, 221 ctx->irq_num = platform_get_irq(pdev,
222 ctx->pdata->res_info->acpi_ipc_irq_index); 222 ctx->pdata->res_info->acpi_ipc_irq_index);
223 return 0; 223 return 0;
224 } 224 }
225 225
226 static acpi_status sst_acpi_mach_match(acpi_handle handle, u32 level, 226 static acpi_status sst_acpi_mach_match(acpi_handle handle, u32 level,
227 void *context, void **ret) 227 void *context, void **ret)
228 { 228 {
229 *(bool *)context = true; 229 *(bool *)context = true;
230 return AE_OK; 230 return AE_OK;
231 } 231 }
232 232
233 static struct sst_machines *sst_acpi_find_machine( 233 static struct sst_machines *sst_acpi_find_machine(
234 struct sst_machines *machines) 234 struct sst_machines *machines)
235 { 235 {
236 struct sst_machines *mach; 236 struct sst_machines *mach;
237 bool found = false; 237 bool found = false;
238 238
239 for (mach = machines; mach->codec_id; mach++) 239 for (mach = machines; mach->codec_id; mach++)
240 if (ACPI_SUCCESS(acpi_get_devices(mach->codec_id, 240 if (ACPI_SUCCESS(acpi_get_devices(mach->codec_id,
241 sst_acpi_mach_match, 241 sst_acpi_mach_match,
242 &found, NULL)) && found) 242 &found, NULL)) && found)
243 return mach; 243 return mach;
244 244
245 return NULL; 245 return NULL;
246 } 246 }
247 247
248 int sst_acpi_probe(struct platform_device *pdev) 248 int sst_acpi_probe(struct platform_device *pdev)
249 { 249 {
250 struct device *dev = &pdev->dev; 250 struct device *dev = &pdev->dev;
251 int ret = 0; 251 int ret = 0;
252 struct intel_sst_drv *ctx; 252 struct intel_sst_drv *ctx;
253 const struct acpi_device_id *id; 253 const struct acpi_device_id *id;
254 struct sst_machines *mach; 254 struct sst_machines *mach;
255 struct platform_device *mdev; 255 struct platform_device *mdev;
256 struct platform_device *plat_dev; 256 struct platform_device *plat_dev;
257 unsigned int dev_id; 257 unsigned int dev_id;
258 258
259 id = acpi_match_device(dev->driver->acpi_match_table, dev); 259 id = acpi_match_device(dev->driver->acpi_match_table, dev);
260 if (!id) 260 if (!id)
261 return -ENODEV; 261 return -ENODEV;
262 dev_dbg(dev, "for %s", id->id); 262 dev_dbg(dev, "for %s", id->id);
263 263
264 mach = (struct sst_machines *)id->driver_data; 264 mach = (struct sst_machines *)id->driver_data;
265 mach = sst_acpi_find_machine(mach); 265 mach = sst_acpi_find_machine(mach);
266 if (mach == NULL) { 266 if (mach == NULL) {
267 dev_err(dev, "No matching machine driver found\n"); 267 dev_err(dev, "No matching machine driver found\n");
268 return -ENODEV; 268 return -ENODEV;
269 } 269 }
270 270
271 ret = kstrtouint(id->id, 16, &dev_id); 271 ret = kstrtouint(id->id, 16, &dev_id);
272 if (ret < 0) { 272 if (ret < 0) {
273 dev_err(dev, "Unique device id conversion error: %d\n", ret); 273 dev_err(dev, "Unique device id conversion error: %d\n", ret);
274 return ret; 274 return ret;
275 } 275 }
276 276
277 dev_dbg(dev, "ACPI device id: %x\n", dev_id); 277 dev_dbg(dev, "ACPI device id: %x\n", dev_id);
278 278
279 plat_dev = platform_device_register_data(dev, mach->pdata->platform, -1, NULL, 0); 279 plat_dev = platform_device_register_data(dev, mach->pdata->platform, -1, NULL, 0);
280 if (IS_ERR(plat_dev)) { 280 if (IS_ERR(plat_dev)) {
281 dev_err(dev, "Failed to create machine device: %s\n", mach->pdata->platform); 281 dev_err(dev, "Failed to create machine device: %s\n", mach->pdata->platform);
282 return PTR_ERR(plat_dev); 282 return PTR_ERR(plat_dev);
283 } 283 }
284 284
285 /* Create platform device for sst machine driver */ 285 /* Create platform device for sst machine driver */
286 mdev = platform_device_register_data(dev, mach->machine, -1, NULL, 0); 286 mdev = platform_device_register_data(dev, mach->machine, -1, NULL, 0);
287 if (IS_ERR(mdev)) { 287 if (IS_ERR(mdev)) {
288 dev_err(dev, "Failed to create machine device: %s\n", mach->machine); 288 dev_err(dev, "Failed to create machine device: %s\n", mach->machine);
289 return PTR_ERR(mdev); 289 return PTR_ERR(mdev);
290 } 290 }
291 291
292 ret = sst_alloc_drv_context(&ctx, dev, dev_id); 292 ret = sst_alloc_drv_context(&ctx, dev, dev_id);
293 if (ret < 0) 293 if (ret < 0)
294 return ret; 294 return ret;
295 295
296 /* Fill sst platform data */ 296 /* Fill sst platform data */
297 ctx->pdata = mach->pdata; 297 ctx->pdata = mach->pdata;
298 strcpy(ctx->firmware_name, mach->firmware); 298 strcpy(ctx->firmware_name, mach->firmware);
299 299
300 ret = sst_platform_get_resources(ctx); 300 ret = sst_platform_get_resources(ctx);
301 if (ret) 301 if (ret)
302 return ret; 302 return ret;
303 303
304 ret = sst_context_init(ctx); 304 ret = sst_context_init(ctx);
305 if (ret < 0) 305 if (ret < 0)
306 return ret; 306 return ret;
307 307
308 /* need to save shim registers in BYT */ 308 /* need to save shim registers in BYT */
309 ctx->shim_regs64 = devm_kzalloc(ctx->dev, sizeof(*ctx->shim_regs64), 309 ctx->shim_regs64 = devm_kzalloc(ctx->dev, sizeof(*ctx->shim_regs64),
310 GFP_KERNEL); 310 GFP_KERNEL);
311 if (!ctx->shim_regs64) { 311 if (!ctx->shim_regs64) {
312 return -ENOMEM; 312 return -ENOMEM;
313 goto do_sst_cleanup; 313 goto do_sst_cleanup;
314 } 314 }
315 315
316 sst_configure_runtime_pm(ctx); 316 sst_configure_runtime_pm(ctx);
317 platform_set_drvdata(pdev, ctx); 317 platform_set_drvdata(pdev, ctx);
318 return ret; 318 return ret;
319 319
320 do_sst_cleanup: 320 do_sst_cleanup:
321 sst_context_cleanup(ctx); 321 sst_context_cleanup(ctx);
322 platform_set_drvdata(pdev, NULL); 322 platform_set_drvdata(pdev, NULL);
323 dev_err(ctx->dev, "failed with %d\n", ret); 323 dev_err(ctx->dev, "failed with %d\n", ret);
324 return ret; 324 return ret;
325 } 325 }
326 326
327 /** 327 /**
328 * intel_sst_remove - remove function 328 * intel_sst_remove - remove function
329 * 329 *
330 * @pdev: platform device structure 330 * @pdev: platform device structure
331 * 331 *
332 * This function is called by OS when a device is unloaded 332 * This function is called by OS when a device is unloaded
333 * This frees the interrupt etc 333 * This frees the interrupt etc
334 */ 334 */
335 int sst_acpi_remove(struct platform_device *pdev) 335 int sst_acpi_remove(struct platform_device *pdev)
336 { 336 {
337 struct intel_sst_drv *ctx; 337 struct intel_sst_drv *ctx;
338 338
339 ctx = platform_get_drvdata(pdev); 339 ctx = platform_get_drvdata(pdev);
340 sst_context_cleanup(ctx); 340 sst_context_cleanup(ctx);
341 platform_set_drvdata(pdev, NULL); 341 platform_set_drvdata(pdev, NULL);
342 return 0; 342 return 0;
343 } 343 }
344 344
345 static struct sst_machines sst_acpi_bytcr[] = { 345 static struct sst_machines sst_acpi_bytcr[] = {
346 {"10EC5640", "T100", "bytt100_rt5640", NULL, "fw_sst_0f28.bin", 346 {"10EC5640", "T100", "bytt100_rt5640", NULL, "intel/fw_sst_0f28.bin",
347 &byt_rvp_platform_data }, 347 &byt_rvp_platform_data },
348 {}, 348 {},
349 }; 349 };
350 350
351 /* Cherryview-based platforms: CherryTrail and Braswell */ 351 /* Cherryview-based platforms: CherryTrail and Braswell */
352 static struct sst_machines sst_acpi_chv[] = { 352 static struct sst_machines sst_acpi_chv[] = {
353 {"10EC5670", "cht-bsw", "cht-bsw-rt5672", NULL, "fw_sst_22a8.bin", 353 {"10EC5670", "cht-bsw", "cht-bsw-rt5672", NULL, "fw_sst_22a8.bin",
354 &chv_platform_data }, 354 &chv_platform_data },
355 {}, 355 {},
356 }; 356 };
357 357
358 static const struct acpi_device_id sst_acpi_ids[] = { 358 static const struct acpi_device_id sst_acpi_ids[] = {
359 { "80860F28", (unsigned long)&sst_acpi_bytcr}, 359 { "80860F28", (unsigned long)&sst_acpi_bytcr},
360 { "808622A8", (unsigned long) &sst_acpi_chv}, 360 { "808622A8", (unsigned long) &sst_acpi_chv},
361 { }, 361 { },
362 }; 362 };
363 363
364 MODULE_DEVICE_TABLE(acpi, sst_acpi_ids); 364 MODULE_DEVICE_TABLE(acpi, sst_acpi_ids);
365 365
366 static struct platform_driver sst_acpi_driver = { 366 static struct platform_driver sst_acpi_driver = {
367 .driver = { 367 .driver = {
368 .name = "intel_sst_acpi", 368 .name = "intel_sst_acpi",
369 .owner = THIS_MODULE, 369 .owner = THIS_MODULE,
370 .acpi_match_table = ACPI_PTR(sst_acpi_ids), 370 .acpi_match_table = ACPI_PTR(sst_acpi_ids),
371 .pm = &intel_sst_pm, 371 .pm = &intel_sst_pm,
372 }, 372 },
373 .probe = sst_acpi_probe, 373 .probe = sst_acpi_probe,
374 .remove = sst_acpi_remove, 374 .remove = sst_acpi_remove,
375 }; 375 };
376 376
377 module_platform_driver(sst_acpi_driver); 377 module_platform_driver(sst_acpi_driver);
378 378
379 MODULE_DESCRIPTION("Intel (R) SST(R) Audio Engine ACPI Driver"); 379 MODULE_DESCRIPTION("Intel (R) SST(R) Audio Engine ACPI Driver");
380 MODULE_AUTHOR("Ramesh Babu K V"); 380 MODULE_AUTHOR("Ramesh Babu K V");
381 MODULE_AUTHOR("Omair Mohammed Abdullah"); 381 MODULE_AUTHOR("Omair Mohammed Abdullah");
382 MODULE_LICENSE("GPL v2"); 382 MODULE_LICENSE("GPL v2");
383 MODULE_ALIAS("sst"); 383 MODULE_ALIAS("sst");
384 384
sound/soc/rockchip/rockchip_i2s.c
1 /* sound/soc/rockchip/rockchip_i2s.c 1 /* sound/soc/rockchip/rockchip_i2s.c
2 * 2 *
3 * ALSA SoC Audio Layer - Rockchip I2S Controller driver 3 * ALSA SoC Audio Layer - Rockchip I2S Controller driver
4 * 4 *
5 * Copyright (c) 2014 Rockchip Electronics Co. Ltd. 5 * Copyright (c) 2014 Rockchip Electronics Co. Ltd.
6 * Author: Jianqun <jay.xu@rock-chips.com> 6 * Author: Jianqun <jay.xu@rock-chips.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13 #include <linux/module.h> 13 #include <linux/module.h>
14 #include <linux/delay.h> 14 #include <linux/delay.h>
15 #include <linux/of_gpio.h> 15 #include <linux/of_gpio.h>
16 #include <linux/clk.h> 16 #include <linux/clk.h>
17 #include <linux/pm_runtime.h> 17 #include <linux/pm_runtime.h>
18 #include <linux/regmap.h> 18 #include <linux/regmap.h>
19 #include <sound/pcm_params.h> 19 #include <sound/pcm_params.h>
20 #include <sound/dmaengine_pcm.h> 20 #include <sound/dmaengine_pcm.h>
21 21
22 #include "rockchip_i2s.h" 22 #include "rockchip_i2s.h"
23 23
24 #define DRV_NAME "rockchip-i2s" 24 #define DRV_NAME "rockchip-i2s"
25 25
26 struct rk_i2s_dev { 26 struct rk_i2s_dev {
27 struct device *dev; 27 struct device *dev;
28 28
29 struct clk *hclk; 29 struct clk *hclk;
30 struct clk *mclk; 30 struct clk *mclk;
31 31
32 struct snd_dmaengine_dai_dma_data capture_dma_data; 32 struct snd_dmaengine_dai_dma_data capture_dma_data;
33 struct snd_dmaengine_dai_dma_data playback_dma_data; 33 struct snd_dmaengine_dai_dma_data playback_dma_data;
34 34
35 struct regmap *regmap; 35 struct regmap *regmap;
36 36
37 /* 37 /*
38 * Used to indicate the tx/rx status. 38 * Used to indicate the tx/rx status.
39 * I2S controller hopes to start the tx and rx together, 39 * I2S controller hopes to start the tx and rx together,
40 * also to stop them when they are both try to stop. 40 * also to stop them when they are both try to stop.
41 */ 41 */
42 bool tx_start; 42 bool tx_start;
43 bool rx_start; 43 bool rx_start;
44 }; 44 };
45 45
46 static int i2s_runtime_suspend(struct device *dev) 46 static int i2s_runtime_suspend(struct device *dev)
47 { 47 {
48 struct rk_i2s_dev *i2s = dev_get_drvdata(dev); 48 struct rk_i2s_dev *i2s = dev_get_drvdata(dev);
49 49
50 clk_disable_unprepare(i2s->mclk); 50 clk_disable_unprepare(i2s->mclk);
51 51
52 return 0; 52 return 0;
53 } 53 }
54 54
55 static int i2s_runtime_resume(struct device *dev) 55 static int i2s_runtime_resume(struct device *dev)
56 { 56 {
57 struct rk_i2s_dev *i2s = dev_get_drvdata(dev); 57 struct rk_i2s_dev *i2s = dev_get_drvdata(dev);
58 int ret; 58 int ret;
59 59
60 ret = clk_prepare_enable(i2s->mclk); 60 ret = clk_prepare_enable(i2s->mclk);
61 if (ret) { 61 if (ret) {
62 dev_err(i2s->dev, "clock enable failed %d\n", ret); 62 dev_err(i2s->dev, "clock enable failed %d\n", ret);
63 return ret; 63 return ret;
64 } 64 }
65 65
66 return 0; 66 return 0;
67 } 67 }
68 68
69 static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai) 69 static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai)
70 { 70 {
71 return snd_soc_dai_get_drvdata(dai); 71 return snd_soc_dai_get_drvdata(dai);
72 } 72 }
73 73
74 static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) 74 static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
75 { 75 {
76 unsigned int val = 0; 76 unsigned int val = 0;
77 int retry = 10; 77 int retry = 10;
78 78
79 if (on) { 79 if (on) {
80 regmap_update_bits(i2s->regmap, I2S_DMACR, 80 regmap_update_bits(i2s->regmap, I2S_DMACR,
81 I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_ENABLE); 81 I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_ENABLE);
82 82
83 regmap_update_bits(i2s->regmap, I2S_XFER, 83 regmap_update_bits(i2s->regmap, I2S_XFER,
84 I2S_XFER_TXS_START | I2S_XFER_RXS_START, 84 I2S_XFER_TXS_START | I2S_XFER_RXS_START,
85 I2S_XFER_TXS_START | I2S_XFER_RXS_START); 85 I2S_XFER_TXS_START | I2S_XFER_RXS_START);
86 86
87 i2s->tx_start = true; 87 i2s->tx_start = true;
88 } else { 88 } else {
89 i2s->tx_start = false; 89 i2s->tx_start = false;
90 90
91 regmap_update_bits(i2s->regmap, I2S_DMACR, 91 regmap_update_bits(i2s->regmap, I2S_DMACR,
92 I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_DISABLE); 92 I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_DISABLE);
93 93
94 if (!i2s->rx_start) { 94 if (!i2s->rx_start) {
95 regmap_update_bits(i2s->regmap, I2S_XFER, 95 regmap_update_bits(i2s->regmap, I2S_XFER,
96 I2S_XFER_TXS_START | 96 I2S_XFER_TXS_START |
97 I2S_XFER_RXS_START, 97 I2S_XFER_RXS_START,
98 I2S_XFER_TXS_STOP | 98 I2S_XFER_TXS_STOP |
99 I2S_XFER_RXS_STOP); 99 I2S_XFER_RXS_STOP);
100 100
101 regmap_update_bits(i2s->regmap, I2S_CLR, 101 regmap_update_bits(i2s->regmap, I2S_CLR,
102 I2S_CLR_TXC | I2S_CLR_RXC, 102 I2S_CLR_TXC | I2S_CLR_RXC,
103 I2S_CLR_TXC | I2S_CLR_RXC); 103 I2S_CLR_TXC | I2S_CLR_RXC);
104 104
105 regmap_read(i2s->regmap, I2S_CLR, &val); 105 regmap_read(i2s->regmap, I2S_CLR, &val);
106 106
107 /* Should wait for clear operation to finish */ 107 /* Should wait for clear operation to finish */
108 while (val) { 108 while (val) {
109 regmap_read(i2s->regmap, I2S_CLR, &val); 109 regmap_read(i2s->regmap, I2S_CLR, &val);
110 retry--; 110 retry--;
111 if (!retry) { 111 if (!retry) {
112 dev_warn(i2s->dev, "fail to clear\n"); 112 dev_warn(i2s->dev, "fail to clear\n");
113 break; 113 break;
114 } 114 }
115 } 115 }
116 } 116 }
117 } 117 }
118 } 118 }
119 119
120 static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) 120 static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
121 { 121 {
122 unsigned int val = 0; 122 unsigned int val = 0;
123 int retry = 10; 123 int retry = 10;
124 124
125 if (on) { 125 if (on) {
126 regmap_update_bits(i2s->regmap, I2S_DMACR, 126 regmap_update_bits(i2s->regmap, I2S_DMACR,
127 I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_ENABLE); 127 I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_ENABLE);
128 128
129 regmap_update_bits(i2s->regmap, I2S_XFER, 129 regmap_update_bits(i2s->regmap, I2S_XFER,
130 I2S_XFER_TXS_START | I2S_XFER_RXS_START, 130 I2S_XFER_TXS_START | I2S_XFER_RXS_START,
131 I2S_XFER_TXS_START | I2S_XFER_RXS_START); 131 I2S_XFER_TXS_START | I2S_XFER_RXS_START);
132 132
133 i2s->rx_start = true; 133 i2s->rx_start = true;
134 } else { 134 } else {
135 i2s->rx_start = false; 135 i2s->rx_start = false;
136 136
137 regmap_update_bits(i2s->regmap, I2S_DMACR, 137 regmap_update_bits(i2s->regmap, I2S_DMACR,
138 I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_DISABLE); 138 I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_DISABLE);
139 139
140 if (!i2s->tx_start) { 140 if (!i2s->tx_start) {
141 regmap_update_bits(i2s->regmap, I2S_XFER, 141 regmap_update_bits(i2s->regmap, I2S_XFER,
142 I2S_XFER_TXS_START | 142 I2S_XFER_TXS_START |
143 I2S_XFER_RXS_START, 143 I2S_XFER_RXS_START,
144 I2S_XFER_TXS_STOP | 144 I2S_XFER_TXS_STOP |
145 I2S_XFER_RXS_STOP); 145 I2S_XFER_RXS_STOP);
146 146
147 regmap_update_bits(i2s->regmap, I2S_CLR, 147 regmap_update_bits(i2s->regmap, I2S_CLR,
148 I2S_CLR_TXC | I2S_CLR_RXC, 148 I2S_CLR_TXC | I2S_CLR_RXC,
149 I2S_CLR_TXC | I2S_CLR_RXC); 149 I2S_CLR_TXC | I2S_CLR_RXC);
150 150
151 regmap_read(i2s->regmap, I2S_CLR, &val); 151 regmap_read(i2s->regmap, I2S_CLR, &val);
152 152
153 /* Should wait for clear operation to finish */ 153 /* Should wait for clear operation to finish */
154 while (val) { 154 while (val) {
155 regmap_read(i2s->regmap, I2S_CLR, &val); 155 regmap_read(i2s->regmap, I2S_CLR, &val);
156 retry--; 156 retry--;
157 if (!retry) { 157 if (!retry) {
158 dev_warn(i2s->dev, "fail to clear\n"); 158 dev_warn(i2s->dev, "fail to clear\n");
159 break; 159 break;
160 } 160 }
161 } 161 }
162 } 162 }
163 } 163 }
164 } 164 }
165 165
166 static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, 166 static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
167 unsigned int fmt) 167 unsigned int fmt)
168 { 168 {
169 struct rk_i2s_dev *i2s = to_info(cpu_dai); 169 struct rk_i2s_dev *i2s = to_info(cpu_dai);
170 unsigned int mask = 0, val = 0; 170 unsigned int mask = 0, val = 0;
171 171
172 mask = I2S_CKR_MSS_MASK; 172 mask = I2S_CKR_MSS_MASK;
173 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 173 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
174 case SND_SOC_DAIFMT_CBS_CFS: 174 case SND_SOC_DAIFMT_CBS_CFS:
175 /* Set source clock in Master mode */ 175 /* Set source clock in Master mode */
176 val = I2S_CKR_MSS_MASTER; 176 val = I2S_CKR_MSS_MASTER;
177 break; 177 break;
178 case SND_SOC_DAIFMT_CBM_CFM: 178 case SND_SOC_DAIFMT_CBM_CFM:
179 val = I2S_CKR_MSS_SLAVE; 179 val = I2S_CKR_MSS_SLAVE;
180 break; 180 break;
181 default: 181 default:
182 return -EINVAL; 182 return -EINVAL;
183 } 183 }
184 184
185 regmap_update_bits(i2s->regmap, I2S_CKR, mask, val); 185 regmap_update_bits(i2s->regmap, I2S_CKR, mask, val);
186 186
187 mask = I2S_TXCR_IBM_MASK; 187 mask = I2S_TXCR_IBM_MASK;
188 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 188 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
189 case SND_SOC_DAIFMT_RIGHT_J: 189 case SND_SOC_DAIFMT_RIGHT_J:
190 val = I2S_TXCR_IBM_RSJM; 190 val = I2S_TXCR_IBM_RSJM;
191 break; 191 break;
192 case SND_SOC_DAIFMT_LEFT_J: 192 case SND_SOC_DAIFMT_LEFT_J:
193 val = I2S_TXCR_IBM_LSJM; 193 val = I2S_TXCR_IBM_LSJM;
194 break; 194 break;
195 case SND_SOC_DAIFMT_I2S: 195 case SND_SOC_DAIFMT_I2S:
196 val = I2S_TXCR_IBM_NORMAL; 196 val = I2S_TXCR_IBM_NORMAL;
197 break; 197 break;
198 default: 198 default:
199 return -EINVAL; 199 return -EINVAL;
200 } 200 }
201 201
202 regmap_update_bits(i2s->regmap, I2S_TXCR, mask, val); 202 regmap_update_bits(i2s->regmap, I2S_TXCR, mask, val);
203 203
204 mask = I2S_RXCR_IBM_MASK; 204 mask = I2S_RXCR_IBM_MASK;
205 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 205 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
206 case SND_SOC_DAIFMT_RIGHT_J: 206 case SND_SOC_DAIFMT_RIGHT_J:
207 val = I2S_RXCR_IBM_RSJM; 207 val = I2S_RXCR_IBM_RSJM;
208 break; 208 break;
209 case SND_SOC_DAIFMT_LEFT_J: 209 case SND_SOC_DAIFMT_LEFT_J:
210 val = I2S_RXCR_IBM_LSJM; 210 val = I2S_RXCR_IBM_LSJM;
211 break; 211 break;
212 case SND_SOC_DAIFMT_I2S: 212 case SND_SOC_DAIFMT_I2S:
213 val = I2S_RXCR_IBM_NORMAL; 213 val = I2S_RXCR_IBM_NORMAL;
214 break; 214 break;
215 default: 215 default:
216 return -EINVAL; 216 return -EINVAL;
217 } 217 }
218 218
219 regmap_update_bits(i2s->regmap, I2S_RXCR, mask, val); 219 regmap_update_bits(i2s->regmap, I2S_RXCR, mask, val);
220 220
221 return 0; 221 return 0;
222 } 222 }
223 223
224 static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, 224 static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
225 struct snd_pcm_hw_params *params, 225 struct snd_pcm_hw_params *params,
226 struct snd_soc_dai *dai) 226 struct snd_soc_dai *dai)
227 { 227 {
228 struct rk_i2s_dev *i2s = to_info(dai); 228 struct rk_i2s_dev *i2s = to_info(dai);
229 unsigned int val = 0; 229 unsigned int val = 0;
230 230
231 switch (params_format(params)) { 231 switch (params_format(params)) {
232 case SNDRV_PCM_FORMAT_S8: 232 case SNDRV_PCM_FORMAT_S8:
233 val |= I2S_TXCR_VDW(8); 233 val |= I2S_TXCR_VDW(8);
234 break; 234 break;
235 case SNDRV_PCM_FORMAT_S16_LE: 235 case SNDRV_PCM_FORMAT_S16_LE:
236 val |= I2S_TXCR_VDW(16); 236 val |= I2S_TXCR_VDW(16);
237 break; 237 break;
238 case SNDRV_PCM_FORMAT_S20_3LE: 238 case SNDRV_PCM_FORMAT_S20_3LE:
239 val |= I2S_TXCR_VDW(20); 239 val |= I2S_TXCR_VDW(20);
240 break; 240 break;
241 case SNDRV_PCM_FORMAT_S24_LE: 241 case SNDRV_PCM_FORMAT_S24_LE:
242 val |= I2S_TXCR_VDW(24); 242 val |= I2S_TXCR_VDW(24);
243 break; 243 break;
244 default: 244 default:
245 return -EINVAL; 245 return -EINVAL;
246 } 246 }
247 247
248 regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); 248 regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val);
249 regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val); 249 regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val);
250 250
251 return 0; 251 return 0;
252 } 252 }
253 253
254 static int rockchip_i2s_trigger(struct snd_pcm_substream *substream, 254 static int rockchip_i2s_trigger(struct snd_pcm_substream *substream,
255 int cmd, struct snd_soc_dai *dai) 255 int cmd, struct snd_soc_dai *dai)
256 { 256 {
257 struct rk_i2s_dev *i2s = to_info(dai); 257 struct rk_i2s_dev *i2s = to_info(dai);
258 int ret = 0; 258 int ret = 0;
259 259
260 switch (cmd) { 260 switch (cmd) {
261 case SNDRV_PCM_TRIGGER_START: 261 case SNDRV_PCM_TRIGGER_START:
262 case SNDRV_PCM_TRIGGER_RESUME: 262 case SNDRV_PCM_TRIGGER_RESUME:
263 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 263 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
264 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) 264 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
265 rockchip_snd_rxctrl(i2s, 1); 265 rockchip_snd_rxctrl(i2s, 1);
266 else 266 else
267 rockchip_snd_txctrl(i2s, 1); 267 rockchip_snd_txctrl(i2s, 1);
268 break; 268 break;
269 case SNDRV_PCM_TRIGGER_SUSPEND: 269 case SNDRV_PCM_TRIGGER_SUSPEND:
270 case SNDRV_PCM_TRIGGER_STOP: 270 case SNDRV_PCM_TRIGGER_STOP:
271 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 271 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
272 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) 272 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
273 rockchip_snd_rxctrl(i2s, 0); 273 rockchip_snd_rxctrl(i2s, 0);
274 else 274 else
275 rockchip_snd_txctrl(i2s, 0); 275 rockchip_snd_txctrl(i2s, 0);
276 break; 276 break;
277 default: 277 default:
278 ret = -EINVAL; 278 ret = -EINVAL;
279 break; 279 break;
280 } 280 }
281 281
282 return ret; 282 return ret;
283 } 283 }
284 284
285 static int rockchip_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, 285 static int rockchip_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id,
286 unsigned int freq, int dir) 286 unsigned int freq, int dir)
287 { 287 {
288 struct rk_i2s_dev *i2s = to_info(cpu_dai); 288 struct rk_i2s_dev *i2s = to_info(cpu_dai);
289 int ret; 289 int ret;
290 290
291 ret = clk_set_rate(i2s->mclk, freq); 291 ret = clk_set_rate(i2s->mclk, freq);
292 if (ret) 292 if (ret)
293 dev_err(i2s->dev, "Fail to set mclk %d\n", ret); 293 dev_err(i2s->dev, "Fail to set mclk %d\n", ret);
294 294
295 return ret; 295 return ret;
296 } 296 }
297 297
298 static int rockchip_i2s_dai_probe(struct snd_soc_dai *dai) 298 static int rockchip_i2s_dai_probe(struct snd_soc_dai *dai)
299 { 299 {
300 struct rk_i2s_dev *i2s = snd_soc_dai_get_drvdata(dai); 300 struct rk_i2s_dev *i2s = snd_soc_dai_get_drvdata(dai);
301 301
302 dai->capture_dma_data = &i2s->capture_dma_data; 302 dai->capture_dma_data = &i2s->capture_dma_data;
303 dai->playback_dma_data = &i2s->playback_dma_data; 303 dai->playback_dma_data = &i2s->playback_dma_data;
304 304
305 return 0; 305 return 0;
306 } 306 }
307 307
308 static const struct snd_soc_dai_ops rockchip_i2s_dai_ops = { 308 static const struct snd_soc_dai_ops rockchip_i2s_dai_ops = {
309 .hw_params = rockchip_i2s_hw_params, 309 .hw_params = rockchip_i2s_hw_params,
310 .set_sysclk = rockchip_i2s_set_sysclk, 310 .set_sysclk = rockchip_i2s_set_sysclk,
311 .set_fmt = rockchip_i2s_set_fmt, 311 .set_fmt = rockchip_i2s_set_fmt,
312 .trigger = rockchip_i2s_trigger, 312 .trigger = rockchip_i2s_trigger,
313 }; 313 };
314 314
315 static struct snd_soc_dai_driver rockchip_i2s_dai = { 315 static struct snd_soc_dai_driver rockchip_i2s_dai = {
316 .probe = rockchip_i2s_dai_probe, 316 .probe = rockchip_i2s_dai_probe,
317 .playback = { 317 .playback = {
318 .stream_name = "Playback", 318 .stream_name = "Playback",
319 .channels_min = 2, 319 .channels_min = 2,
320 .channels_max = 8, 320 .channels_max = 8,
321 .rates = SNDRV_PCM_RATE_8000_192000, 321 .rates = SNDRV_PCM_RATE_8000_192000,
322 .formats = (SNDRV_PCM_FMTBIT_S8 | 322 .formats = (SNDRV_PCM_FMTBIT_S8 |
323 SNDRV_PCM_FMTBIT_S16_LE | 323 SNDRV_PCM_FMTBIT_S16_LE |
324 SNDRV_PCM_FMTBIT_S20_3LE | 324 SNDRV_PCM_FMTBIT_S20_3LE |
325 SNDRV_PCM_FMTBIT_S24_LE), 325 SNDRV_PCM_FMTBIT_S24_LE),
326 }, 326 },
327 .capture = { 327 .capture = {
328 .stream_name = "Capture", 328 .stream_name = "Capture",
329 .channels_min = 2, 329 .channels_min = 2,
330 .channels_max = 2, 330 .channels_max = 2,
331 .rates = SNDRV_PCM_RATE_8000_192000, 331 .rates = SNDRV_PCM_RATE_8000_192000,
332 .formats = (SNDRV_PCM_FMTBIT_S8 | 332 .formats = (SNDRV_PCM_FMTBIT_S8 |
333 SNDRV_PCM_FMTBIT_S16_LE | 333 SNDRV_PCM_FMTBIT_S16_LE |
334 SNDRV_PCM_FMTBIT_S20_3LE | 334 SNDRV_PCM_FMTBIT_S20_3LE |
335 SNDRV_PCM_FMTBIT_S24_LE), 335 SNDRV_PCM_FMTBIT_S24_LE),
336 }, 336 },
337 .ops = &rockchip_i2s_dai_ops, 337 .ops = &rockchip_i2s_dai_ops,
338 }; 338 };
339 339
340 static const struct snd_soc_component_driver rockchip_i2s_component = { 340 static const struct snd_soc_component_driver rockchip_i2s_component = {
341 .name = DRV_NAME, 341 .name = DRV_NAME,
342 }; 342 };
343 343
344 static bool rockchip_i2s_wr_reg(struct device *dev, unsigned int reg) 344 static bool rockchip_i2s_wr_reg(struct device *dev, unsigned int reg)
345 { 345 {
346 switch (reg) { 346 switch (reg) {
347 case I2S_TXCR: 347 case I2S_TXCR:
348 case I2S_RXCR: 348 case I2S_RXCR:
349 case I2S_CKR: 349 case I2S_CKR:
350 case I2S_DMACR: 350 case I2S_DMACR:
351 case I2S_INTCR: 351 case I2S_INTCR:
352 case I2S_XFER: 352 case I2S_XFER:
353 case I2S_CLR: 353 case I2S_CLR:
354 case I2S_TXDR: 354 case I2S_TXDR:
355 return true; 355 return true;
356 default: 356 default:
357 return false; 357 return false;
358 } 358 }
359 } 359 }
360 360
361 static bool rockchip_i2s_rd_reg(struct device *dev, unsigned int reg) 361 static bool rockchip_i2s_rd_reg(struct device *dev, unsigned int reg)
362 { 362 {
363 switch (reg) { 363 switch (reg) {
364 case I2S_TXCR: 364 case I2S_TXCR:
365 case I2S_RXCR: 365 case I2S_RXCR:
366 case I2S_CKR: 366 case I2S_CKR:
367 case I2S_DMACR: 367 case I2S_DMACR:
368 case I2S_INTCR: 368 case I2S_INTCR:
369 case I2S_XFER: 369 case I2S_XFER:
370 case I2S_CLR: 370 case I2S_CLR:
371 case I2S_RXDR: 371 case I2S_RXDR:
372 case I2S_FIFOLR: 372 case I2S_FIFOLR:
373 case I2S_INTSR: 373 case I2S_INTSR:
374 return true; 374 return true;
375 default: 375 default:
376 return false; 376 return false;
377 } 377 }
378 } 378 }
379 379
380 static bool rockchip_i2s_volatile_reg(struct device *dev, unsigned int reg) 380 static bool rockchip_i2s_volatile_reg(struct device *dev, unsigned int reg)
381 { 381 {
382 switch (reg) { 382 switch (reg) {
383 case I2S_INTSR: 383 case I2S_INTSR:
384 case I2S_CLR: 384 case I2S_CLR:
385 return true; 385 return true;
386 default: 386 default:
387 return false; 387 return false;
388 } 388 }
389 } 389 }
390 390
391 static bool rockchip_i2s_precious_reg(struct device *dev, unsigned int reg) 391 static bool rockchip_i2s_precious_reg(struct device *dev, unsigned int reg)
392 { 392 {
393 switch (reg) { 393 switch (reg) {
394 default: 394 default:
395 return false; 395 return false;
396 } 396 }
397 } 397 }
398 398
399 static const struct regmap_config rockchip_i2s_regmap_config = { 399 static const struct regmap_config rockchip_i2s_regmap_config = {
400 .reg_bits = 32, 400 .reg_bits = 32,
401 .reg_stride = 4, 401 .reg_stride = 4,
402 .val_bits = 32, 402 .val_bits = 32,
403 .max_register = I2S_RXDR, 403 .max_register = I2S_RXDR,
404 .writeable_reg = rockchip_i2s_wr_reg, 404 .writeable_reg = rockchip_i2s_wr_reg,
405 .readable_reg = rockchip_i2s_rd_reg, 405 .readable_reg = rockchip_i2s_rd_reg,
406 .volatile_reg = rockchip_i2s_volatile_reg, 406 .volatile_reg = rockchip_i2s_volatile_reg,
407 .precious_reg = rockchip_i2s_precious_reg, 407 .precious_reg = rockchip_i2s_precious_reg,
408 .cache_type = REGCACHE_FLAT, 408 .cache_type = REGCACHE_FLAT,
409 }; 409 };
410 410
411 static int rockchip_i2s_probe(struct platform_device *pdev) 411 static int rockchip_i2s_probe(struct platform_device *pdev)
412 { 412 {
413 struct rk_i2s_dev *i2s; 413 struct rk_i2s_dev *i2s;
414 struct resource *res; 414 struct resource *res;
415 void __iomem *regs; 415 void __iomem *regs;
416 int ret; 416 int ret;
417 417
418 i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); 418 i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
419 if (!i2s) { 419 if (!i2s) {
420 dev_err(&pdev->dev, "Can't allocate rk_i2s_dev\n"); 420 dev_err(&pdev->dev, "Can't allocate rk_i2s_dev\n");
421 return -ENOMEM; 421 return -ENOMEM;
422 } 422 }
423 423
424 /* try to prepare related clocks */ 424 /* try to prepare related clocks */
425 i2s->hclk = devm_clk_get(&pdev->dev, "i2s_hclk"); 425 i2s->hclk = devm_clk_get(&pdev->dev, "i2s_hclk");
426 if (IS_ERR(i2s->hclk)) { 426 if (IS_ERR(i2s->hclk)) {
427 dev_err(&pdev->dev, "Can't retrieve i2s bus clock\n"); 427 dev_err(&pdev->dev, "Can't retrieve i2s bus clock\n");
428 return PTR_ERR(i2s->hclk); 428 return PTR_ERR(i2s->hclk);
429 } 429 }
430 ret = clk_prepare_enable(i2s->hclk); 430 ret = clk_prepare_enable(i2s->hclk);
431 if (ret) { 431 if (ret) {
432 dev_err(i2s->dev, "hclock enable failed %d\n", ret); 432 dev_err(i2s->dev, "hclock enable failed %d\n", ret);
433 return ret; 433 return ret;
434 } 434 }
435 435
436 i2s->mclk = devm_clk_get(&pdev->dev, "i2s_clk"); 436 i2s->mclk = devm_clk_get(&pdev->dev, "i2s_clk");
437 if (IS_ERR(i2s->mclk)) { 437 if (IS_ERR(i2s->mclk)) {
438 dev_err(&pdev->dev, "Can't retrieve i2s master clock\n"); 438 dev_err(&pdev->dev, "Can't retrieve i2s master clock\n");
439 return PTR_ERR(i2s->mclk); 439 return PTR_ERR(i2s->mclk);
440 } 440 }
441 441
442 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 442 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
443 regs = devm_ioremap_resource(&pdev->dev, res); 443 regs = devm_ioremap_resource(&pdev->dev, res);
444 if (IS_ERR(regs)) 444 if (IS_ERR(regs))
445 return PTR_ERR(regs); 445 return PTR_ERR(regs);
446 446
447 i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs, 447 i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
448 &rockchip_i2s_regmap_config); 448 &rockchip_i2s_regmap_config);
449 if (IS_ERR(i2s->regmap)) { 449 if (IS_ERR(i2s->regmap)) {
450 dev_err(&pdev->dev, 450 dev_err(&pdev->dev,
451 "Failed to initialise managed register map\n"); 451 "Failed to initialise managed register map\n");
452 return PTR_ERR(i2s->regmap); 452 return PTR_ERR(i2s->regmap);
453 } 453 }
454 454
455 i2s->playback_dma_data.addr = res->start + I2S_TXDR; 455 i2s->playback_dma_data.addr = res->start + I2S_TXDR;
456 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 456 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
457 i2s->playback_dma_data.maxburst = 16; 457 i2s->playback_dma_data.maxburst = 4;
458 458
459 i2s->capture_dma_data.addr = res->start + I2S_RXDR; 459 i2s->capture_dma_data.addr = res->start + I2S_RXDR;
460 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 460 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
461 i2s->capture_dma_data.maxburst = 16; 461 i2s->capture_dma_data.maxburst = 4;
462 462
463 i2s->dev = &pdev->dev; 463 i2s->dev = &pdev->dev;
464 dev_set_drvdata(&pdev->dev, i2s); 464 dev_set_drvdata(&pdev->dev, i2s);
465 465
466 pm_runtime_enable(&pdev->dev); 466 pm_runtime_enable(&pdev->dev);
467 if (!pm_runtime_enabled(&pdev->dev)) { 467 if (!pm_runtime_enabled(&pdev->dev)) {
468 ret = i2s_runtime_resume(&pdev->dev); 468 ret = i2s_runtime_resume(&pdev->dev);
469 if (ret) 469 if (ret)
470 goto err_pm_disable; 470 goto err_pm_disable;
471 } 471 }
472 472
473 ret = devm_snd_soc_register_component(&pdev->dev, 473 ret = devm_snd_soc_register_component(&pdev->dev,
474 &rockchip_i2s_component, 474 &rockchip_i2s_component,
475 &rockchip_i2s_dai, 1); 475 &rockchip_i2s_dai, 1);
476 if (ret) { 476 if (ret) {
477 dev_err(&pdev->dev, "Could not register DAI\n"); 477 dev_err(&pdev->dev, "Could not register DAI\n");
478 goto err_suspend; 478 goto err_suspend;
479 } 479 }
480 480
481 ret = snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); 481 ret = snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
482 if (ret) { 482 if (ret) {
483 dev_err(&pdev->dev, "Could not register PCM\n"); 483 dev_err(&pdev->dev, "Could not register PCM\n");
484 goto err_pcm_register; 484 goto err_pcm_register;
485 } 485 }
486 486
487 return 0; 487 return 0;
488 488
489 err_pcm_register: 489 err_pcm_register:
490 snd_dmaengine_pcm_unregister(&pdev->dev); 490 snd_dmaengine_pcm_unregister(&pdev->dev);
491 err_suspend: 491 err_suspend:
492 if (!pm_runtime_status_suspended(&pdev->dev)) 492 if (!pm_runtime_status_suspended(&pdev->dev))
493 i2s_runtime_suspend(&pdev->dev); 493 i2s_runtime_suspend(&pdev->dev);
494 err_pm_disable: 494 err_pm_disable:
495 pm_runtime_disable(&pdev->dev); 495 pm_runtime_disable(&pdev->dev);
496 496
497 return ret; 497 return ret;
498 } 498 }
499 499
500 static int rockchip_i2s_remove(struct platform_device *pdev) 500 static int rockchip_i2s_remove(struct platform_device *pdev)
501 { 501 {
502 struct rk_i2s_dev *i2s = dev_get_drvdata(&pdev->dev); 502 struct rk_i2s_dev *i2s = dev_get_drvdata(&pdev->dev);
503 503
504 pm_runtime_disable(&pdev->dev); 504 pm_runtime_disable(&pdev->dev);
505 if (!pm_runtime_status_suspended(&pdev->dev)) 505 if (!pm_runtime_status_suspended(&pdev->dev))
506 i2s_runtime_suspend(&pdev->dev); 506 i2s_runtime_suspend(&pdev->dev);
507 507
508 clk_disable_unprepare(i2s->mclk); 508 clk_disable_unprepare(i2s->mclk);
509 clk_disable_unprepare(i2s->hclk); 509 clk_disable_unprepare(i2s->hclk);
510 snd_dmaengine_pcm_unregister(&pdev->dev); 510 snd_dmaengine_pcm_unregister(&pdev->dev);
511 snd_soc_unregister_component(&pdev->dev); 511 snd_soc_unregister_component(&pdev->dev);
512 512
513 return 0; 513 return 0;
514 } 514 }
515 515
516 static const struct of_device_id rockchip_i2s_match[] = { 516 static const struct of_device_id rockchip_i2s_match[] = {
517 { .compatible = "rockchip,rk3066-i2s", }, 517 { .compatible = "rockchip,rk3066-i2s", },
518 {}, 518 {},
519 }; 519 };
520 520
521 static const struct dev_pm_ops rockchip_i2s_pm_ops = { 521 static const struct dev_pm_ops rockchip_i2s_pm_ops = {
522 SET_RUNTIME_PM_OPS(i2s_runtime_suspend, i2s_runtime_resume, 522 SET_RUNTIME_PM_OPS(i2s_runtime_suspend, i2s_runtime_resume,
523 NULL) 523 NULL)
524 }; 524 };
525 525
526 static struct platform_driver rockchip_i2s_driver = { 526 static struct platform_driver rockchip_i2s_driver = {
527 .probe = rockchip_i2s_probe, 527 .probe = rockchip_i2s_probe,
528 .remove = rockchip_i2s_remove, 528 .remove = rockchip_i2s_remove,
529 .driver = { 529 .driver = {
530 .name = DRV_NAME, 530 .name = DRV_NAME,
531 .of_match_table = of_match_ptr(rockchip_i2s_match), 531 .of_match_table = of_match_ptr(rockchip_i2s_match),
532 .pm = &rockchip_i2s_pm_ops, 532 .pm = &rockchip_i2s_pm_ops,
533 }, 533 },
534 }; 534 };
535 module_platform_driver(rockchip_i2s_driver); 535 module_platform_driver(rockchip_i2s_driver);
536 536
537 MODULE_DESCRIPTION("ROCKCHIP IIS ASoC Interface"); 537 MODULE_DESCRIPTION("ROCKCHIP IIS ASoC Interface");
538 MODULE_AUTHOR("jianqun <jay.xu@rock-chips.com>"); 538 MODULE_AUTHOR("jianqun <jay.xu@rock-chips.com>");
539 MODULE_LICENSE("GPL v2"); 539 MODULE_LICENSE("GPL v2");
540 MODULE_ALIAS("platform:" DRV_NAME); 540 MODULE_ALIAS("platform:" DRV_NAME);
541 MODULE_DEVICE_TABLE(of, rockchip_i2s_match); 541 MODULE_DEVICE_TABLE(of, rockchip_i2s_match);
542 542
sound/soc/rockchip/rockchip_i2s.h
1 /* 1 /*
2 * sound/soc/rockchip/rockchip_i2s.h 2 * sound/soc/rockchip/rockchip_i2s.h
3 * 3 *
4 * ALSA SoC Audio Layer - Rockchip I2S Controller driver 4 * ALSA SoC Audio Layer - Rockchip I2S Controller driver
5 * 5 *
6 * Copyright (c) 2014 Rockchip Electronics Co. Ltd. 6 * Copyright (c) 2014 Rockchip Electronics Co. Ltd.
7 * Author: Jianqun xu <jay.xu@rock-chips.com> 7 * Author: Jianqun xu <jay.xu@rock-chips.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13 13
14 #ifndef _ROCKCHIP_IIS_H 14 #ifndef _ROCKCHIP_IIS_H
15 #define _ROCKCHIP_IIS_H 15 #define _ROCKCHIP_IIS_H
16 16
17 /* 17 /*
18 * TXCR 18 * TXCR
19 * transmit operation control register 19 * transmit operation control register
20 */ 20 */
21 #define I2S_TXCR_RCNT_SHIFT 17 21 #define I2S_TXCR_RCNT_SHIFT 17
22 #define I2S_TXCR_RCNT_MASK (0x3f << I2S_TXCR_RCNT_SHIFT) 22 #define I2S_TXCR_RCNT_MASK (0x3f << I2S_TXCR_RCNT_SHIFT)
23 #define I2S_TXCR_CSR_SHIFT 15 23 #define I2S_TXCR_CSR_SHIFT 15
24 #define I2S_TXCR_CSR(x) (x << I2S_TXCR_CSR_SHIFT) 24 #define I2S_TXCR_CSR(x) (x << I2S_TXCR_CSR_SHIFT)
25 #define I2S_TXCR_CSR_MASK (3 << I2S_TXCR_CSR_SHIFT) 25 #define I2S_TXCR_CSR_MASK (3 << I2S_TXCR_CSR_SHIFT)
26 #define I2S_TXCR_HWT BIT(14) 26 #define I2S_TXCR_HWT BIT(14)
27 #define I2S_TXCR_SJM_SHIFT 12 27 #define I2S_TXCR_SJM_SHIFT 12
28 #define I2S_TXCR_SJM_R (0 << I2S_TXCR_SJM_SHIFT) 28 #define I2S_TXCR_SJM_R (0 << I2S_TXCR_SJM_SHIFT)
29 #define I2S_TXCR_SJM_L (1 << I2S_TXCR_SJM_SHIFT) 29 #define I2S_TXCR_SJM_L (1 << I2S_TXCR_SJM_SHIFT)
30 #define I2S_TXCR_FBM_SHIFT 11 30 #define I2S_TXCR_FBM_SHIFT 11
31 #define I2S_TXCR_FBM_MSB (0 << I2S_TXCR_FBM_SHIFT) 31 #define I2S_TXCR_FBM_MSB (0 << I2S_TXCR_FBM_SHIFT)
32 #define I2S_TXCR_FBM_LSB (1 << I2S_TXCR_FBM_SHIFT) 32 #define I2S_TXCR_FBM_LSB (1 << I2S_TXCR_FBM_SHIFT)
33 #define I2S_TXCR_IBM_SHIFT 9 33 #define I2S_TXCR_IBM_SHIFT 9
34 #define I2S_TXCR_IBM_NORMAL (0 << I2S_TXCR_IBM_SHIFT) 34 #define I2S_TXCR_IBM_NORMAL (0 << I2S_TXCR_IBM_SHIFT)
35 #define I2S_TXCR_IBM_LSJM (1 << I2S_TXCR_IBM_SHIFT) 35 #define I2S_TXCR_IBM_LSJM (1 << I2S_TXCR_IBM_SHIFT)
36 #define I2S_TXCR_IBM_RSJM (2 << I2S_TXCR_IBM_SHIFT) 36 #define I2S_TXCR_IBM_RSJM (2 << I2S_TXCR_IBM_SHIFT)
37 #define I2S_TXCR_IBM_MASK (3 << I2S_TXCR_IBM_SHIFT) 37 #define I2S_TXCR_IBM_MASK (3 << I2S_TXCR_IBM_SHIFT)
38 #define I2S_TXCR_PBM_SHIFT 7 38 #define I2S_TXCR_PBM_SHIFT 7
39 #define I2S_TXCR_PBM_MODE(x) (x << I2S_TXCR_PBM_SHIFT) 39 #define I2S_TXCR_PBM_MODE(x) (x << I2S_TXCR_PBM_SHIFT)
40 #define I2S_TXCR_PBM_MASK (3 << I2S_TXCR_PBM_SHIFT) 40 #define I2S_TXCR_PBM_MASK (3 << I2S_TXCR_PBM_SHIFT)
41 #define I2S_TXCR_TFS_SHIFT 5 41 #define I2S_TXCR_TFS_SHIFT 5
42 #define I2S_TXCR_TFS_I2S (0 << I2S_TXCR_TFS_SHIFT) 42 #define I2S_TXCR_TFS_I2S (0 << I2S_TXCR_TFS_SHIFT)
43 #define I2S_TXCR_TFS_PCM (1 << I2S_TXCR_TFS_SHIFT) 43 #define I2S_TXCR_TFS_PCM (1 << I2S_TXCR_TFS_SHIFT)
44 #define I2S_TXCR_VDW_SHIFT 0 44 #define I2S_TXCR_VDW_SHIFT 0
45 #define I2S_TXCR_VDW(x) ((x - 1) << I2S_TXCR_VDW_SHIFT) 45 #define I2S_TXCR_VDW(x) ((x - 1) << I2S_TXCR_VDW_SHIFT)
46 #define I2S_TXCR_VDW_MASK (0x1f << I2S_TXCR_VDW_SHIFT) 46 #define I2S_TXCR_VDW_MASK (0x1f << I2S_TXCR_VDW_SHIFT)
47 47
48 /* 48 /*
49 * RXCR 49 * RXCR
50 * receive operation control register 50 * receive operation control register
51 */ 51 */
52 #define I2S_RXCR_HWT BIT(14) 52 #define I2S_RXCR_HWT BIT(14)
53 #define I2S_RXCR_SJM_SHIFT 12 53 #define I2S_RXCR_SJM_SHIFT 12
54 #define I2S_RXCR_SJM_R (0 << I2S_RXCR_SJM_SHIFT) 54 #define I2S_RXCR_SJM_R (0 << I2S_RXCR_SJM_SHIFT)
55 #define I2S_RXCR_SJM_L (1 << I2S_RXCR_SJM_SHIFT) 55 #define I2S_RXCR_SJM_L (1 << I2S_RXCR_SJM_SHIFT)
56 #define I2S_RXCR_FBM_SHIFT 11 56 #define I2S_RXCR_FBM_SHIFT 11
57 #define I2S_RXCR_FBM_MSB (0 << I2S_RXCR_FBM_SHIFT) 57 #define I2S_RXCR_FBM_MSB (0 << I2S_RXCR_FBM_SHIFT)
58 #define I2S_RXCR_FBM_LSB (1 << I2S_RXCR_FBM_SHIFT) 58 #define I2S_RXCR_FBM_LSB (1 << I2S_RXCR_FBM_SHIFT)
59 #define I2S_RXCR_IBM_SHIFT 9 59 #define I2S_RXCR_IBM_SHIFT 9
60 #define I2S_RXCR_IBM_NORMAL (0 << I2S_RXCR_IBM_SHIFT) 60 #define I2S_RXCR_IBM_NORMAL (0 << I2S_RXCR_IBM_SHIFT)
61 #define I2S_RXCR_IBM_LSJM (1 << I2S_RXCR_IBM_SHIFT) 61 #define I2S_RXCR_IBM_LSJM (1 << I2S_RXCR_IBM_SHIFT)
62 #define I2S_RXCR_IBM_RSJM (2 << I2S_RXCR_IBM_SHIFT) 62 #define I2S_RXCR_IBM_RSJM (2 << I2S_RXCR_IBM_SHIFT)
63 #define I2S_RXCR_IBM_MASK (3 << I2S_RXCR_IBM_SHIFT) 63 #define I2S_RXCR_IBM_MASK (3 << I2S_RXCR_IBM_SHIFT)
64 #define I2S_RXCR_PBM_SHIFT 7 64 #define I2S_RXCR_PBM_SHIFT 7
65 #define I2S_RXCR_PBM_MODE(x) (x << I2S_RXCR_PBM_SHIFT) 65 #define I2S_RXCR_PBM_MODE(x) (x << I2S_RXCR_PBM_SHIFT)
66 #define I2S_RXCR_PBM_MASK (3 << I2S_RXCR_PBM_SHIFT) 66 #define I2S_RXCR_PBM_MASK (3 << I2S_RXCR_PBM_SHIFT)
67 #define I2S_RXCR_TFS_SHIFT 5 67 #define I2S_RXCR_TFS_SHIFT 5
68 #define I2S_RXCR_TFS_I2S (0 << I2S_RXCR_TFS_SHIFT) 68 #define I2S_RXCR_TFS_I2S (0 << I2S_RXCR_TFS_SHIFT)
69 #define I2S_RXCR_TFS_PCM (1 << I2S_RXCR_TFS_SHIFT) 69 #define I2S_RXCR_TFS_PCM (1 << I2S_RXCR_TFS_SHIFT)
70 #define I2S_RXCR_VDW_SHIFT 0 70 #define I2S_RXCR_VDW_SHIFT 0
71 #define I2S_RXCR_VDW(x) ((x - 1) << I2S_RXCR_VDW_SHIFT) 71 #define I2S_RXCR_VDW(x) ((x - 1) << I2S_RXCR_VDW_SHIFT)
72 #define I2S_RXCR_VDW_MASK (0x1f << I2S_RXCR_VDW_SHIFT) 72 #define I2S_RXCR_VDW_MASK (0x1f << I2S_RXCR_VDW_SHIFT)
73 73
74 /* 74 /*
75 * CKR 75 * CKR
76 * clock generation register 76 * clock generation register
77 */ 77 */
78 #define I2S_CKR_MSS_SHIFT 27 78 #define I2S_CKR_MSS_SHIFT 27
79 #define I2S_CKR_MSS_MASTER (0 << I2S_CKR_MSS_SHIFT) 79 #define I2S_CKR_MSS_MASTER (0 << I2S_CKR_MSS_SHIFT)
80 #define I2S_CKR_MSS_SLAVE (1 << I2S_CKR_MSS_SHIFT) 80 #define I2S_CKR_MSS_SLAVE (1 << I2S_CKR_MSS_SHIFT)
81 #define I2S_CKR_MSS_MASK (1 << I2S_CKR_MSS_SHIFT) 81 #define I2S_CKR_MSS_MASK (1 << I2S_CKR_MSS_SHIFT)
82 #define I2S_CKR_CKP_SHIFT 26 82 #define I2S_CKR_CKP_SHIFT 26
83 #define I2S_CKR_CKP_NEG (0 << I2S_CKR_CKP_SHIFT) 83 #define I2S_CKR_CKP_NEG (0 << I2S_CKR_CKP_SHIFT)
84 #define I2S_CKR_CKP_POS (1 << I2S_CKR_CKP_SHIFT) 84 #define I2S_CKR_CKP_POS (1 << I2S_CKR_CKP_SHIFT)
85 #define I2S_CKR_RLP_SHIFT 25 85 #define I2S_CKR_RLP_SHIFT 25
86 #define I2S_CKR_RLP_NORMAL (0 << I2S_CKR_RLP_SHIFT) 86 #define I2S_CKR_RLP_NORMAL (0 << I2S_CKR_RLP_SHIFT)
87 #define I2S_CKR_RLP_OPPSITE (1 << I2S_CKR_RLP_SHIFT) 87 #define I2S_CKR_RLP_OPPSITE (1 << I2S_CKR_RLP_SHIFT)
88 #define I2S_CKR_TLP_SHIFT 24 88 #define I2S_CKR_TLP_SHIFT 24
89 #define I2S_CKR_TLP_NORMAL (0 << I2S_CKR_TLP_SHIFT) 89 #define I2S_CKR_TLP_NORMAL (0 << I2S_CKR_TLP_SHIFT)
90 #define I2S_CKR_TLP_OPPSITE (1 << I2S_CKR_TLP_SHIFT) 90 #define I2S_CKR_TLP_OPPSITE (1 << I2S_CKR_TLP_SHIFT)
91 #define I2S_CKR_MDIV_SHIFT 16 91 #define I2S_CKR_MDIV_SHIFT 16
92 #define I2S_CKR_MDIV(x) ((x - 1) << I2S_CKR_MDIV_SHIFT) 92 #define I2S_CKR_MDIV(x) ((x - 1) << I2S_CKR_MDIV_SHIFT)
93 #define I2S_CKR_MDIV_MASK (0xff << I2S_CKR_MDIV_SHIFT) 93 #define I2S_CKR_MDIV_MASK (0xff << I2S_CKR_MDIV_SHIFT)
94 #define I2S_CKR_RSD_SHIFT 8 94 #define I2S_CKR_RSD_SHIFT 8
95 #define I2S_CKR_RSD(x) ((x - 1) << I2S_CKR_RSD_SHIFT) 95 #define I2S_CKR_RSD(x) ((x - 1) << I2S_CKR_RSD_SHIFT)
96 #define I2S_CKR_RSD_MASK (0xff << I2S_CKR_RSD_SHIFT) 96 #define I2S_CKR_RSD_MASK (0xff << I2S_CKR_RSD_SHIFT)
97 #define I2S_CKR_TSD_SHIFT 0 97 #define I2S_CKR_TSD_SHIFT 0
98 #define I2S_CKR_TSD(x) ((x - 1) << I2S_CKR_TSD_SHIFT) 98 #define I2S_CKR_TSD(x) ((x - 1) << I2S_CKR_TSD_SHIFT)
99 #define I2S_CKR_TSD_MASK (0xff << I2S_CKR_TSD_SHIFT) 99 #define I2S_CKR_TSD_MASK (0xff << I2S_CKR_TSD_SHIFT)
100 100
101 /* 101 /*
102 * FIFOLR 102 * FIFOLR
103 * FIFO level register 103 * FIFO level register
104 */ 104 */
105 #define I2S_FIFOLR_RFL_SHIFT 24 105 #define I2S_FIFOLR_RFL_SHIFT 24
106 #define I2S_FIFOLR_RFL_MASK (0x3f << I2S_FIFOLR_RFL_SHIFT) 106 #define I2S_FIFOLR_RFL_MASK (0x3f << I2S_FIFOLR_RFL_SHIFT)
107 #define I2S_FIFOLR_TFL3_SHIFT 18 107 #define I2S_FIFOLR_TFL3_SHIFT 18
108 #define I2S_FIFOLR_TFL3_MASK (0x3f << I2S_FIFOLR_TFL3_SHIFT) 108 #define I2S_FIFOLR_TFL3_MASK (0x3f << I2S_FIFOLR_TFL3_SHIFT)
109 #define I2S_FIFOLR_TFL2_SHIFT 12 109 #define I2S_FIFOLR_TFL2_SHIFT 12
110 #define I2S_FIFOLR_TFL2_MASK (0x3f << I2S_FIFOLR_TFL2_SHIFT) 110 #define I2S_FIFOLR_TFL2_MASK (0x3f << I2S_FIFOLR_TFL2_SHIFT)
111 #define I2S_FIFOLR_TFL1_SHIFT 6 111 #define I2S_FIFOLR_TFL1_SHIFT 6
112 #define I2S_FIFOLR_TFL1_MASK (0x3f << I2S_FIFOLR_TFL1_SHIFT) 112 #define I2S_FIFOLR_TFL1_MASK (0x3f << I2S_FIFOLR_TFL1_SHIFT)
113 #define I2S_FIFOLR_TFL0_SHIFT 0 113 #define I2S_FIFOLR_TFL0_SHIFT 0
114 #define I2S_FIFOLR_TFL0_MASK (0x3f << I2S_FIFOLR_TFL0_SHIFT) 114 #define I2S_FIFOLR_TFL0_MASK (0x3f << I2S_FIFOLR_TFL0_SHIFT)
115 115
116 /* 116 /*
117 * DMACR 117 * DMACR
118 * DMA control register 118 * DMA control register
119 */ 119 */
120 #define I2S_DMACR_RDE_SHIFT 24 120 #define I2S_DMACR_RDE_SHIFT 24
121 #define I2S_DMACR_RDE_DISABLE (0 << I2S_DMACR_RDE_SHIFT) 121 #define I2S_DMACR_RDE_DISABLE (0 << I2S_DMACR_RDE_SHIFT)
122 #define I2S_DMACR_RDE_ENABLE (1 << I2S_DMACR_RDE_SHIFT) 122 #define I2S_DMACR_RDE_ENABLE (1 << I2S_DMACR_RDE_SHIFT)
123 #define I2S_DMACR_RDL_SHIFT 16 123 #define I2S_DMACR_RDL_SHIFT 16
124 #define I2S_DMACR_RDL(x) ((x - 1) << I2S_DMACR_RDL_SHIFT) 124 #define I2S_DMACR_RDL(x) ((x - 1) << I2S_DMACR_RDL_SHIFT)
125 #define I2S_DMACR_RDL_MASK (0x1f << I2S_DMACR_RDL_SHIFT) 125 #define I2S_DMACR_RDL_MASK (0x1f << I2S_DMACR_RDL_SHIFT)
126 #define I2S_DMACR_TDE_SHIFT 8 126 #define I2S_DMACR_TDE_SHIFT 8
127 #define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT) 127 #define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT)
128 #define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT) 128 #define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT)
129 #define I2S_DMACR_TDL_SHIFT 0 129 #define I2S_DMACR_TDL_SHIFT 0
130 #define I2S_DMACR_TDL(x) ((x - 1) << I2S_DMACR_TDL_SHIFT) 130 #define I2S_DMACR_TDL(x) ((x) << I2S_DMACR_TDL_SHIFT)
131 #define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT) 131 #define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT)
132 132
133 /* 133 /*
134 * INTCR 134 * INTCR
135 * interrupt control register 135 * interrupt control register
136 */ 136 */
137 #define I2S_INTCR_RFT_SHIFT 20 137 #define I2S_INTCR_RFT_SHIFT 20
138 #define I2S_INTCR_RFT(x) ((x - 1) << I2S_INTCR_RFT_SHIFT) 138 #define I2S_INTCR_RFT(x) ((x - 1) << I2S_INTCR_RFT_SHIFT)
139 #define I2S_INTCR_RXOIC BIT(18) 139 #define I2S_INTCR_RXOIC BIT(18)
140 #define I2S_INTCR_RXOIE_SHIFT 17 140 #define I2S_INTCR_RXOIE_SHIFT 17
141 #define I2S_INTCR_RXOIE_DISABLE (0 << I2S_INTCR_RXOIE_SHIFT) 141 #define I2S_INTCR_RXOIE_DISABLE (0 << I2S_INTCR_RXOIE_SHIFT)
142 #define I2S_INTCR_RXOIE_ENABLE (1 << I2S_INTCR_RXOIE_SHIFT) 142 #define I2S_INTCR_RXOIE_ENABLE (1 << I2S_INTCR_RXOIE_SHIFT)
143 #define I2S_INTCR_RXFIE_SHIFT 16 143 #define I2S_INTCR_RXFIE_SHIFT 16
144 #define I2S_INTCR_RXFIE_DISABLE (0 << I2S_INTCR_RXFIE_SHIFT) 144 #define I2S_INTCR_RXFIE_DISABLE (0 << I2S_INTCR_RXFIE_SHIFT)
145 #define I2S_INTCR_RXFIE_ENABLE (1 << I2S_INTCR_RXFIE_SHIFT) 145 #define I2S_INTCR_RXFIE_ENABLE (1 << I2S_INTCR_RXFIE_SHIFT)
146 #define I2S_INTCR_TFT_SHIFT 4 146 #define I2S_INTCR_TFT_SHIFT 4
147 #define I2S_INTCR_TFT(x) ((x - 1) << I2S_INTCR_TFT_SHIFT) 147 #define I2S_INTCR_TFT(x) ((x - 1) << I2S_INTCR_TFT_SHIFT)
148 #define I2S_INTCR_TFT_MASK (0x1f << I2S_INTCR_TFT_SHIFT) 148 #define I2S_INTCR_TFT_MASK (0x1f << I2S_INTCR_TFT_SHIFT)
149 #define I2S_INTCR_TXUIC BIT(2) 149 #define I2S_INTCR_TXUIC BIT(2)
150 #define I2S_INTCR_TXUIE_SHIFT 1 150 #define I2S_INTCR_TXUIE_SHIFT 1
151 #define I2S_INTCR_TXUIE_DISABLE (0 << I2S_INTCR_TXUIE_SHIFT) 151 #define I2S_INTCR_TXUIE_DISABLE (0 << I2S_INTCR_TXUIE_SHIFT)
152 #define I2S_INTCR_TXUIE_ENABLE (1 << I2S_INTCR_TXUIE_SHIFT) 152 #define I2S_INTCR_TXUIE_ENABLE (1 << I2S_INTCR_TXUIE_SHIFT)
153 153
154 /* 154 /*
155 * INTSR 155 * INTSR
156 * interrupt status register 156 * interrupt status register
157 */ 157 */
158 #define I2S_INTSR_TXEIE_SHIFT 0 158 #define I2S_INTSR_TXEIE_SHIFT 0
159 #define I2S_INTSR_TXEIE_DISABLE (0 << I2S_INTSR_TXEIE_SHIFT) 159 #define I2S_INTSR_TXEIE_DISABLE (0 << I2S_INTSR_TXEIE_SHIFT)
160 #define I2S_INTSR_TXEIE_ENABLE (1 << I2S_INTSR_TXEIE_SHIFT) 160 #define I2S_INTSR_TXEIE_ENABLE (1 << I2S_INTSR_TXEIE_SHIFT)
161 #define I2S_INTSR_RXOI_SHIFT 17 161 #define I2S_INTSR_RXOI_SHIFT 17
162 #define I2S_INTSR_RXOI_INA (0 << I2S_INTSR_RXOI_SHIFT) 162 #define I2S_INTSR_RXOI_INA (0 << I2S_INTSR_RXOI_SHIFT)
163 #define I2S_INTSR_RXOI_ACT (1 << I2S_INTSR_RXOI_SHIFT) 163 #define I2S_INTSR_RXOI_ACT (1 << I2S_INTSR_RXOI_SHIFT)
164 #define I2S_INTSR_RXFI_SHIFT 16 164 #define I2S_INTSR_RXFI_SHIFT 16
165 #define I2S_INTSR_RXFI_INA (0 << I2S_INTSR_RXFI_SHIFT) 165 #define I2S_INTSR_RXFI_INA (0 << I2S_INTSR_RXFI_SHIFT)
166 #define I2S_INTSR_RXFI_ACT (1 << I2S_INTSR_RXFI_SHIFT) 166 #define I2S_INTSR_RXFI_ACT (1 << I2S_INTSR_RXFI_SHIFT)
167 #define I2S_INTSR_TXUI_SHIFT 1 167 #define I2S_INTSR_TXUI_SHIFT 1
168 #define I2S_INTSR_TXUI_INA (0 << I2S_INTSR_TXUI_SHIFT) 168 #define I2S_INTSR_TXUI_INA (0 << I2S_INTSR_TXUI_SHIFT)
169 #define I2S_INTSR_TXUI_ACT (1 << I2S_INTSR_TXUI_SHIFT) 169 #define I2S_INTSR_TXUI_ACT (1 << I2S_INTSR_TXUI_SHIFT)
170 #define I2S_INTSR_TXEI_SHIFT 0 170 #define I2S_INTSR_TXEI_SHIFT 0
171 #define I2S_INTSR_TXEI_INA (0 << I2S_INTSR_TXEI_SHIFT) 171 #define I2S_INTSR_TXEI_INA (0 << I2S_INTSR_TXEI_SHIFT)
172 #define I2S_INTSR_TXEI_ACT (1 << I2S_INTSR_TXEI_SHIFT) 172 #define I2S_INTSR_TXEI_ACT (1 << I2S_INTSR_TXEI_SHIFT)
173 173
174 /* 174 /*
175 * XFER 175 * XFER
176 * Transfer start register 176 * Transfer start register
177 */ 177 */
178 #define I2S_XFER_RXS_SHIFT 1 178 #define I2S_XFER_RXS_SHIFT 1
179 #define I2S_XFER_RXS_STOP (0 << I2S_XFER_RXS_SHIFT) 179 #define I2S_XFER_RXS_STOP (0 << I2S_XFER_RXS_SHIFT)
180 #define I2S_XFER_RXS_START (1 << I2S_XFER_RXS_SHIFT) 180 #define I2S_XFER_RXS_START (1 << I2S_XFER_RXS_SHIFT)
181 #define I2S_XFER_TXS_SHIFT 0 181 #define I2S_XFER_TXS_SHIFT 0
182 #define I2S_XFER_TXS_STOP (0 << I2S_XFER_TXS_SHIFT) 182 #define I2S_XFER_TXS_STOP (0 << I2S_XFER_TXS_SHIFT)
183 #define I2S_XFER_TXS_START (1 << I2S_XFER_TXS_SHIFT) 183 #define I2S_XFER_TXS_START (1 << I2S_XFER_TXS_SHIFT)
184 184
185 /* 185 /*
186 * CLR 186 * CLR
187 * clear SCLK domain logic register 187 * clear SCLK domain logic register
188 */ 188 */
189 #define I2S_CLR_RXC BIT(1) 189 #define I2S_CLR_RXC BIT(1)
190 #define I2S_CLR_TXC BIT(0) 190 #define I2S_CLR_TXC BIT(0)
191 191
192 /* 192 /*
193 * TXDR 193 * TXDR
194 * Transimt FIFO data register, write only. 194 * Transimt FIFO data register, write only.
195 */ 195 */
196 #define I2S_TXDR_MASK (0xff) 196 #define I2S_TXDR_MASK (0xff)
197 197
198 /* 198 /*
199 * RXDR 199 * RXDR
200 * Receive FIFO data register, write only. 200 * Receive FIFO data register, write only.
201 */ 201 */
202 #define I2S_RXDR_MASK (0xff) 202 #define I2S_RXDR_MASK (0xff)
203 203
204 /* Clock divider id */ 204 /* Clock divider id */
205 enum { 205 enum {
206 ROCKCHIP_DIV_MCLK = 0, 206 ROCKCHIP_DIV_MCLK = 0,
207 ROCKCHIP_DIV_BCLK, 207 ROCKCHIP_DIV_BCLK,
208 }; 208 };
209 209
210 /* I2S REGS */ 210 /* I2S REGS */
211 #define I2S_TXCR (0x0000) 211 #define I2S_TXCR (0x0000)
212 #define I2S_RXCR (0x0004) 212 #define I2S_RXCR (0x0004)
213 #define I2S_CKR (0x0008) 213 #define I2S_CKR (0x0008)
214 #define I2S_FIFOLR (0x000c) 214 #define I2S_FIFOLR (0x000c)
215 #define I2S_DMACR (0x0010) 215 #define I2S_DMACR (0x0010)
216 #define I2S_INTCR (0x0014) 216 #define I2S_INTCR (0x0014)
217 #define I2S_INTSR (0x0018) 217 #define I2S_INTSR (0x0018)
218 #define I2S_XFER (0x001c) 218 #define I2S_XFER (0x001c)
219 #define I2S_CLR (0x0020) 219 #define I2S_CLR (0x0020)
220 #define I2S_TXDR (0x0024) 220 #define I2S_TXDR (0x0024)
221 #define I2S_RXDR (0x0028) 221 #define I2S_RXDR (0x0028)
222 222
223 #endif /* _ROCKCHIP_IIS_H */ 223 #endif /* _ROCKCHIP_IIS_H */
224 224
sound/soc/soc-core.c
1 /* 1 /*
2 * soc-core.c -- ALSA SoC Audio Layer 2 * soc-core.c -- ALSA SoC Audio Layer
3 * 3 *
4 * Copyright 2005 Wolfson Microelectronics PLC. 4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Copyright 2005 Openedhand Ltd. 5 * Copyright 2005 Openedhand Ltd.
6 * Copyright (C) 2010 Slimlogic Ltd. 6 * Copyright (C) 2010 Slimlogic Ltd.
7 * Copyright (C) 2010 Texas Instruments Inc. 7 * Copyright (C) 2010 Texas Instruments Inc.
8 * 8 *
9 * Author: Liam Girdwood <lrg@slimlogic.co.uk> 9 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
10 * with code, comments and ideas from :- 10 * with code, comments and ideas from :-
11 * Richard Purdie <richard@openedhand.com> 11 * Richard Purdie <richard@openedhand.com>
12 * 12 *
13 * This program is free software; you can redistribute it and/or modify it 13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the 14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your 15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. 16 * option) any later version.
17 * 17 *
18 * TODO: 18 * TODO:
19 * o Add hw rules to enforce rates, etc. 19 * o Add hw rules to enforce rates, etc.
20 * o More testing with other codecs/machines. 20 * o More testing with other codecs/machines.
21 * o Add more codecs and platforms to ensure good API coverage. 21 * o Add more codecs and platforms to ensure good API coverage.
22 * o Support TDM on PCM and I2S 22 * o Support TDM on PCM and I2S
23 */ 23 */
24 24
25 #include <linux/module.h> 25 #include <linux/module.h>
26 #include <linux/moduleparam.h> 26 #include <linux/moduleparam.h>
27 #include <linux/init.h> 27 #include <linux/init.h>
28 #include <linux/delay.h> 28 #include <linux/delay.h>
29 #include <linux/pm.h> 29 #include <linux/pm.h>
30 #include <linux/bitops.h> 30 #include <linux/bitops.h>
31 #include <linux/debugfs.h> 31 #include <linux/debugfs.h>
32 #include <linux/platform_device.h> 32 #include <linux/platform_device.h>
33 #include <linux/pinctrl/consumer.h> 33 #include <linux/pinctrl/consumer.h>
34 #include <linux/ctype.h> 34 #include <linux/ctype.h>
35 #include <linux/slab.h> 35 #include <linux/slab.h>
36 #include <linux/of.h> 36 #include <linux/of.h>
37 #include <sound/core.h> 37 #include <sound/core.h>
38 #include <sound/jack.h> 38 #include <sound/jack.h>
39 #include <sound/pcm.h> 39 #include <sound/pcm.h>
40 #include <sound/pcm_params.h> 40 #include <sound/pcm_params.h>
41 #include <sound/soc.h> 41 #include <sound/soc.h>
42 #include <sound/soc-dpcm.h> 42 #include <sound/soc-dpcm.h>
43 #include <sound/initval.h> 43 #include <sound/initval.h>
44 44
45 #define CREATE_TRACE_POINTS 45 #define CREATE_TRACE_POINTS
46 #include <trace/events/asoc.h> 46 #include <trace/events/asoc.h>
47 47
48 #define NAME_SIZE 32 48 #define NAME_SIZE 32
49 49
50 #ifdef CONFIG_DEBUG_FS 50 #ifdef CONFIG_DEBUG_FS
51 struct dentry *snd_soc_debugfs_root; 51 struct dentry *snd_soc_debugfs_root;
52 EXPORT_SYMBOL_GPL(snd_soc_debugfs_root); 52 EXPORT_SYMBOL_GPL(snd_soc_debugfs_root);
53 #endif 53 #endif
54 54
55 static DEFINE_MUTEX(client_mutex); 55 static DEFINE_MUTEX(client_mutex);
56 static LIST_HEAD(platform_list); 56 static LIST_HEAD(platform_list);
57 static LIST_HEAD(codec_list); 57 static LIST_HEAD(codec_list);
58 static LIST_HEAD(component_list); 58 static LIST_HEAD(component_list);
59 59
60 /* 60 /*
61 * This is a timeout to do a DAPM powerdown after a stream is closed(). 61 * This is a timeout to do a DAPM powerdown after a stream is closed().
62 * It can be used to eliminate pops between different playback streams, e.g. 62 * It can be used to eliminate pops between different playback streams, e.g.
63 * between two audio tracks. 63 * between two audio tracks.
64 */ 64 */
65 static int pmdown_time = 5000; 65 static int pmdown_time = 5000;
66 module_param(pmdown_time, int, 0); 66 module_param(pmdown_time, int, 0);
67 MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)"); 67 MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
68 68
69 /* returns the minimum number of bytes needed to represent 69 /* returns the minimum number of bytes needed to represent
70 * a particular given value */ 70 * a particular given value */
71 static int min_bytes_needed(unsigned long val) 71 static int min_bytes_needed(unsigned long val)
72 { 72 {
73 int c = 0; 73 int c = 0;
74 int i; 74 int i;
75 75
76 for (i = (sizeof val * 8) - 1; i >= 0; --i, ++c) 76 for (i = (sizeof val * 8) - 1; i >= 0; --i, ++c)
77 if (val & (1UL << i)) 77 if (val & (1UL << i))
78 break; 78 break;
79 c = (sizeof val * 8) - c; 79 c = (sizeof val * 8) - c;
80 if (!c || (c % 8)) 80 if (!c || (c % 8))
81 c = (c + 8) / 8; 81 c = (c + 8) / 8;
82 else 82 else
83 c /= 8; 83 c /= 8;
84 return c; 84 return c;
85 } 85 }
86 86
87 /* fill buf which is 'len' bytes with a formatted 87 /* fill buf which is 'len' bytes with a formatted
88 * string of the form 'reg: value\n' */ 88 * string of the form 'reg: value\n' */
89 static int format_register_str(struct snd_soc_codec *codec, 89 static int format_register_str(struct snd_soc_codec *codec,
90 unsigned int reg, char *buf, size_t len) 90 unsigned int reg, char *buf, size_t len)
91 { 91 {
92 int wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2; 92 int wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2;
93 int regsize = codec->driver->reg_word_size * 2; 93 int regsize = codec->driver->reg_word_size * 2;
94 int ret; 94 int ret;
95 char tmpbuf[len + 1]; 95 char tmpbuf[len + 1];
96 char regbuf[regsize + 1]; 96 char regbuf[regsize + 1];
97 97
98 /* since tmpbuf is allocated on the stack, warn the callers if they 98 /* since tmpbuf is allocated on the stack, warn the callers if they
99 * try to abuse this function */ 99 * try to abuse this function */
100 WARN_ON(len > 63); 100 WARN_ON(len > 63);
101 101
102 /* +2 for ': ' and + 1 for '\n' */ 102 /* +2 for ': ' and + 1 for '\n' */
103 if (wordsize + regsize + 2 + 1 != len) 103 if (wordsize + regsize + 2 + 1 != len)
104 return -EINVAL; 104 return -EINVAL;
105 105
106 ret = snd_soc_read(codec, reg); 106 ret = snd_soc_read(codec, reg);
107 if (ret < 0) { 107 if (ret < 0) {
108 memset(regbuf, 'X', regsize); 108 memset(regbuf, 'X', regsize);
109 regbuf[regsize] = '\0'; 109 regbuf[regsize] = '\0';
110 } else { 110 } else {
111 snprintf(regbuf, regsize + 1, "%.*x", regsize, ret); 111 snprintf(regbuf, regsize + 1, "%.*x", regsize, ret);
112 } 112 }
113 113
114 /* prepare the buffer */ 114 /* prepare the buffer */
115 snprintf(tmpbuf, len + 1, "%.*x: %s\n", wordsize, reg, regbuf); 115 snprintf(tmpbuf, len + 1, "%.*x: %s\n", wordsize, reg, regbuf);
116 /* copy it back to the caller without the '\0' */ 116 /* copy it back to the caller without the '\0' */
117 memcpy(buf, tmpbuf, len); 117 memcpy(buf, tmpbuf, len);
118 118
119 return 0; 119 return 0;
120 } 120 }
121 121
122 /* codec register dump */ 122 /* codec register dump */
123 static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf, 123 static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf,
124 size_t count, loff_t pos) 124 size_t count, loff_t pos)
125 { 125 {
126 int i, step = 1; 126 int i, step = 1;
127 int wordsize, regsize; 127 int wordsize, regsize;
128 int len; 128 int len;
129 size_t total = 0; 129 size_t total = 0;
130 loff_t p = 0; 130 loff_t p = 0;
131 131
132 wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2; 132 wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2;
133 regsize = codec->driver->reg_word_size * 2; 133 regsize = codec->driver->reg_word_size * 2;
134 134
135 len = wordsize + regsize + 2 + 1; 135 len = wordsize + regsize + 2 + 1;
136 136
137 if (!codec->driver->reg_cache_size) 137 if (!codec->driver->reg_cache_size)
138 return 0; 138 return 0;
139 139
140 if (codec->driver->reg_cache_step) 140 if (codec->driver->reg_cache_step)
141 step = codec->driver->reg_cache_step; 141 step = codec->driver->reg_cache_step;
142 142
143 for (i = 0; i < codec->driver->reg_cache_size; i += step) { 143 for (i = 0; i < codec->driver->reg_cache_size; i += step) {
144 /* only support larger than PAGE_SIZE bytes debugfs 144 /* only support larger than PAGE_SIZE bytes debugfs
145 * entries for the default case */ 145 * entries for the default case */
146 if (p >= pos) { 146 if (p >= pos) {
147 if (total + len >= count - 1) 147 if (total + len >= count - 1)
148 break; 148 break;
149 format_register_str(codec, i, buf + total, len); 149 format_register_str(codec, i, buf + total, len);
150 total += len; 150 total += len;
151 } 151 }
152 p += len; 152 p += len;
153 } 153 }
154 154
155 total = min(total, count - 1); 155 total = min(total, count - 1);
156 156
157 return total; 157 return total;
158 } 158 }
159 159
160 static ssize_t codec_reg_show(struct device *dev, 160 static ssize_t codec_reg_show(struct device *dev,
161 struct device_attribute *attr, char *buf) 161 struct device_attribute *attr, char *buf)
162 { 162 {
163 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); 163 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
164 164
165 return soc_codec_reg_show(rtd->codec, buf, PAGE_SIZE, 0); 165 return soc_codec_reg_show(rtd->codec, buf, PAGE_SIZE, 0);
166 } 166 }
167 167
168 static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL); 168 static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
169 169
170 static ssize_t pmdown_time_show(struct device *dev, 170 static ssize_t pmdown_time_show(struct device *dev,
171 struct device_attribute *attr, char *buf) 171 struct device_attribute *attr, char *buf)
172 { 172 {
173 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); 173 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
174 174
175 return sprintf(buf, "%ld\n", rtd->pmdown_time); 175 return sprintf(buf, "%ld\n", rtd->pmdown_time);
176 } 176 }
177 177
178 static ssize_t pmdown_time_set(struct device *dev, 178 static ssize_t pmdown_time_set(struct device *dev,
179 struct device_attribute *attr, 179 struct device_attribute *attr,
180 const char *buf, size_t count) 180 const char *buf, size_t count)
181 { 181 {
182 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); 182 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
183 int ret; 183 int ret;
184 184
185 ret = kstrtol(buf, 10, &rtd->pmdown_time); 185 ret = kstrtol(buf, 10, &rtd->pmdown_time);
186 if (ret) 186 if (ret)
187 return ret; 187 return ret;
188 188
189 return count; 189 return count;
190 } 190 }
191 191
192 static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set); 192 static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set);
193 193
194 #ifdef CONFIG_DEBUG_FS 194 #ifdef CONFIG_DEBUG_FS
195 static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, 195 static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf,
196 size_t count, loff_t *ppos) 196 size_t count, loff_t *ppos)
197 { 197 {
198 ssize_t ret; 198 ssize_t ret;
199 struct snd_soc_codec *codec = file->private_data; 199 struct snd_soc_codec *codec = file->private_data;
200 char *buf; 200 char *buf;
201 201
202 if (*ppos < 0 || !count) 202 if (*ppos < 0 || !count)
203 return -EINVAL; 203 return -EINVAL;
204 204
205 buf = kmalloc(count, GFP_KERNEL); 205 buf = kmalloc(count, GFP_KERNEL);
206 if (!buf) 206 if (!buf)
207 return -ENOMEM; 207 return -ENOMEM;
208 208
209 ret = soc_codec_reg_show(codec, buf, count, *ppos); 209 ret = soc_codec_reg_show(codec, buf, count, *ppos);
210 if (ret >= 0) { 210 if (ret >= 0) {
211 if (copy_to_user(user_buf, buf, ret)) { 211 if (copy_to_user(user_buf, buf, ret)) {
212 kfree(buf); 212 kfree(buf);
213 return -EFAULT; 213 return -EFAULT;
214 } 214 }
215 *ppos += ret; 215 *ppos += ret;
216 } 216 }
217 217
218 kfree(buf); 218 kfree(buf);
219 return ret; 219 return ret;
220 } 220 }
221 221
222 static ssize_t codec_reg_write_file(struct file *file, 222 static ssize_t codec_reg_write_file(struct file *file,
223 const char __user *user_buf, size_t count, loff_t *ppos) 223 const char __user *user_buf, size_t count, loff_t *ppos)
224 { 224 {
225 char buf[32]; 225 char buf[32];
226 size_t buf_size; 226 size_t buf_size;
227 char *start = buf; 227 char *start = buf;
228 unsigned long reg, value; 228 unsigned long reg, value;
229 struct snd_soc_codec *codec = file->private_data; 229 struct snd_soc_codec *codec = file->private_data;
230 int ret; 230 int ret;
231 231
232 buf_size = min(count, (sizeof(buf)-1)); 232 buf_size = min(count, (sizeof(buf)-1));
233 if (copy_from_user(buf, user_buf, buf_size)) 233 if (copy_from_user(buf, user_buf, buf_size))
234 return -EFAULT; 234 return -EFAULT;
235 buf[buf_size] = 0; 235 buf[buf_size] = 0;
236 236
237 while (*start == ' ') 237 while (*start == ' ')
238 start++; 238 start++;
239 reg = simple_strtoul(start, &start, 16); 239 reg = simple_strtoul(start, &start, 16);
240 while (*start == ' ') 240 while (*start == ' ')
241 start++; 241 start++;
242 ret = kstrtoul(start, 16, &value); 242 ret = kstrtoul(start, 16, &value);
243 if (ret) 243 if (ret)
244 return ret; 244 return ret;
245 245
246 /* Userspace has been fiddling around behind the kernel's back */ 246 /* Userspace has been fiddling around behind the kernel's back */
247 add_taint(TAINT_USER, LOCKDEP_NOW_UNRELIABLE); 247 add_taint(TAINT_USER, LOCKDEP_NOW_UNRELIABLE);
248 248
249 snd_soc_write(codec, reg, value); 249 snd_soc_write(codec, reg, value);
250 return buf_size; 250 return buf_size;
251 } 251 }
252 252
253 static const struct file_operations codec_reg_fops = { 253 static const struct file_operations codec_reg_fops = {
254 .open = simple_open, 254 .open = simple_open,
255 .read = codec_reg_read_file, 255 .read = codec_reg_read_file,
256 .write = codec_reg_write_file, 256 .write = codec_reg_write_file,
257 .llseek = default_llseek, 257 .llseek = default_llseek,
258 }; 258 };
259 259
260 static void soc_init_component_debugfs(struct snd_soc_component *component) 260 static void soc_init_component_debugfs(struct snd_soc_component *component)
261 { 261 {
262 if (component->debugfs_prefix) { 262 if (component->debugfs_prefix) {
263 char *name; 263 char *name;
264 264
265 name = kasprintf(GFP_KERNEL, "%s:%s", 265 name = kasprintf(GFP_KERNEL, "%s:%s",
266 component->debugfs_prefix, component->name); 266 component->debugfs_prefix, component->name);
267 if (name) { 267 if (name) {
268 component->debugfs_root = debugfs_create_dir(name, 268 component->debugfs_root = debugfs_create_dir(name,
269 component->card->debugfs_card_root); 269 component->card->debugfs_card_root);
270 kfree(name); 270 kfree(name);
271 } 271 }
272 } else { 272 } else {
273 component->debugfs_root = debugfs_create_dir(component->name, 273 component->debugfs_root = debugfs_create_dir(component->name,
274 component->card->debugfs_card_root); 274 component->card->debugfs_card_root);
275 } 275 }
276 276
277 if (!component->debugfs_root) { 277 if (!component->debugfs_root) {
278 dev_warn(component->dev, 278 dev_warn(component->dev,
279 "ASoC: Failed to create component debugfs directory\n"); 279 "ASoC: Failed to create component debugfs directory\n");
280 return; 280 return;
281 } 281 }
282 282
283 snd_soc_dapm_debugfs_init(snd_soc_component_get_dapm(component), 283 snd_soc_dapm_debugfs_init(snd_soc_component_get_dapm(component),
284 component->debugfs_root); 284 component->debugfs_root);
285 285
286 if (component->init_debugfs) 286 if (component->init_debugfs)
287 component->init_debugfs(component); 287 component->init_debugfs(component);
288 } 288 }
289 289
290 static void soc_cleanup_component_debugfs(struct snd_soc_component *component) 290 static void soc_cleanup_component_debugfs(struct snd_soc_component *component)
291 { 291 {
292 debugfs_remove_recursive(component->debugfs_root); 292 debugfs_remove_recursive(component->debugfs_root);
293 } 293 }
294 294
295 static void soc_init_codec_debugfs(struct snd_soc_component *component) 295 static void soc_init_codec_debugfs(struct snd_soc_component *component)
296 { 296 {
297 struct snd_soc_codec *codec = snd_soc_component_to_codec(component); 297 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
298 298
299 codec->debugfs_reg = debugfs_create_file("codec_reg", 0644, 299 codec->debugfs_reg = debugfs_create_file("codec_reg", 0644,
300 codec->component.debugfs_root, 300 codec->component.debugfs_root,
301 codec, &codec_reg_fops); 301 codec, &codec_reg_fops);
302 if (!codec->debugfs_reg) 302 if (!codec->debugfs_reg)
303 dev_warn(codec->dev, 303 dev_warn(codec->dev,
304 "ASoC: Failed to create codec register debugfs file\n"); 304 "ASoC: Failed to create codec register debugfs file\n");
305 } 305 }
306 306
307 static ssize_t codec_list_read_file(struct file *file, char __user *user_buf, 307 static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
308 size_t count, loff_t *ppos) 308 size_t count, loff_t *ppos)
309 { 309 {
310 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 310 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
311 ssize_t len, ret = 0; 311 ssize_t len, ret = 0;
312 struct snd_soc_codec *codec; 312 struct snd_soc_codec *codec;
313 313
314 if (!buf) 314 if (!buf)
315 return -ENOMEM; 315 return -ENOMEM;
316 316
317 list_for_each_entry(codec, &codec_list, list) { 317 list_for_each_entry(codec, &codec_list, list) {
318 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", 318 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
319 codec->component.name); 319 codec->component.name);
320 if (len >= 0) 320 if (len >= 0)
321 ret += len; 321 ret += len;
322 if (ret > PAGE_SIZE) { 322 if (ret > PAGE_SIZE) {
323 ret = PAGE_SIZE; 323 ret = PAGE_SIZE;
324 break; 324 break;
325 } 325 }
326 } 326 }
327 327
328 if (ret >= 0) 328 if (ret >= 0)
329 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 329 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
330 330
331 kfree(buf); 331 kfree(buf);
332 332
333 return ret; 333 return ret;
334 } 334 }
335 335
336 static const struct file_operations codec_list_fops = { 336 static const struct file_operations codec_list_fops = {
337 .read = codec_list_read_file, 337 .read = codec_list_read_file,
338 .llseek = default_llseek,/* read accesses f_pos */ 338 .llseek = default_llseek,/* read accesses f_pos */
339 }; 339 };
340 340
341 static ssize_t dai_list_read_file(struct file *file, char __user *user_buf, 341 static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
342 size_t count, loff_t *ppos) 342 size_t count, loff_t *ppos)
343 { 343 {
344 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 344 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
345 ssize_t len, ret = 0; 345 ssize_t len, ret = 0;
346 struct snd_soc_component *component; 346 struct snd_soc_component *component;
347 struct snd_soc_dai *dai; 347 struct snd_soc_dai *dai;
348 348
349 if (!buf) 349 if (!buf)
350 return -ENOMEM; 350 return -ENOMEM;
351 351
352 list_for_each_entry(component, &component_list, list) { 352 list_for_each_entry(component, &component_list, list) {
353 list_for_each_entry(dai, &component->dai_list, list) { 353 list_for_each_entry(dai, &component->dai_list, list) {
354 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", 354 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
355 dai->name); 355 dai->name);
356 if (len >= 0) 356 if (len >= 0)
357 ret += len; 357 ret += len;
358 if (ret > PAGE_SIZE) { 358 if (ret > PAGE_SIZE) {
359 ret = PAGE_SIZE; 359 ret = PAGE_SIZE;
360 break; 360 break;
361 } 361 }
362 } 362 }
363 } 363 }
364 364
365 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 365 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
366 366
367 kfree(buf); 367 kfree(buf);
368 368
369 return ret; 369 return ret;
370 } 370 }
371 371
372 static const struct file_operations dai_list_fops = { 372 static const struct file_operations dai_list_fops = {
373 .read = dai_list_read_file, 373 .read = dai_list_read_file,
374 .llseek = default_llseek,/* read accesses f_pos */ 374 .llseek = default_llseek,/* read accesses f_pos */
375 }; 375 };
376 376
377 static ssize_t platform_list_read_file(struct file *file, 377 static ssize_t platform_list_read_file(struct file *file,
378 char __user *user_buf, 378 char __user *user_buf,
379 size_t count, loff_t *ppos) 379 size_t count, loff_t *ppos)
380 { 380 {
381 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 381 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
382 ssize_t len, ret = 0; 382 ssize_t len, ret = 0;
383 struct snd_soc_platform *platform; 383 struct snd_soc_platform *platform;
384 384
385 if (!buf) 385 if (!buf)
386 return -ENOMEM; 386 return -ENOMEM;
387 387
388 list_for_each_entry(platform, &platform_list, list) { 388 list_for_each_entry(platform, &platform_list, list) {
389 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", 389 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
390 platform->component.name); 390 platform->component.name);
391 if (len >= 0) 391 if (len >= 0)
392 ret += len; 392 ret += len;
393 if (ret > PAGE_SIZE) { 393 if (ret > PAGE_SIZE) {
394 ret = PAGE_SIZE; 394 ret = PAGE_SIZE;
395 break; 395 break;
396 } 396 }
397 } 397 }
398 398
399 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 399 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
400 400
401 kfree(buf); 401 kfree(buf);
402 402
403 return ret; 403 return ret;
404 } 404 }
405 405
406 static const struct file_operations platform_list_fops = { 406 static const struct file_operations platform_list_fops = {
407 .read = platform_list_read_file, 407 .read = platform_list_read_file,
408 .llseek = default_llseek,/* read accesses f_pos */ 408 .llseek = default_llseek,/* read accesses f_pos */
409 }; 409 };
410 410
411 static void soc_init_card_debugfs(struct snd_soc_card *card) 411 static void soc_init_card_debugfs(struct snd_soc_card *card)
412 { 412 {
413 card->debugfs_card_root = debugfs_create_dir(card->name, 413 card->debugfs_card_root = debugfs_create_dir(card->name,
414 snd_soc_debugfs_root); 414 snd_soc_debugfs_root);
415 if (!card->debugfs_card_root) { 415 if (!card->debugfs_card_root) {
416 dev_warn(card->dev, 416 dev_warn(card->dev,
417 "ASoC: Failed to create card debugfs directory\n"); 417 "ASoC: Failed to create card debugfs directory\n");
418 return; 418 return;
419 } 419 }
420 420
421 card->debugfs_pop_time = debugfs_create_u32("dapm_pop_time", 0644, 421 card->debugfs_pop_time = debugfs_create_u32("dapm_pop_time", 0644,
422 card->debugfs_card_root, 422 card->debugfs_card_root,
423 &card->pop_time); 423 &card->pop_time);
424 if (!card->debugfs_pop_time) 424 if (!card->debugfs_pop_time)
425 dev_warn(card->dev, 425 dev_warn(card->dev,
426 "ASoC: Failed to create pop time debugfs file\n"); 426 "ASoC: Failed to create pop time debugfs file\n");
427 } 427 }
428 428
429 static void soc_cleanup_card_debugfs(struct snd_soc_card *card) 429 static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
430 { 430 {
431 debugfs_remove_recursive(card->debugfs_card_root); 431 debugfs_remove_recursive(card->debugfs_card_root);
432 } 432 }
433 433
434 #else 434 #else
435 435
436 #define soc_init_codec_debugfs NULL 436 #define soc_init_codec_debugfs NULL
437 437
438 static inline void soc_init_component_debugfs( 438 static inline void soc_init_component_debugfs(
439 struct snd_soc_component *component) 439 struct snd_soc_component *component)
440 { 440 {
441 } 441 }
442 442
443 static inline void soc_cleanup_component_debugfs( 443 static inline void soc_cleanup_component_debugfs(
444 struct snd_soc_component *component) 444 struct snd_soc_component *component)
445 { 445 {
446 } 446 }
447 447
448 static inline void soc_init_card_debugfs(struct snd_soc_card *card) 448 static inline void soc_init_card_debugfs(struct snd_soc_card *card)
449 { 449 {
450 } 450 }
451 451
452 static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card) 452 static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card)
453 { 453 {
454 } 454 }
455 #endif 455 #endif
456 456
457 struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, 457 struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
458 const char *dai_link, int stream) 458 const char *dai_link, int stream)
459 { 459 {
460 int i; 460 int i;
461 461
462 for (i = 0; i < card->num_links; i++) { 462 for (i = 0; i < card->num_links; i++) {
463 if (card->rtd[i].dai_link->no_pcm && 463 if (card->rtd[i].dai_link->no_pcm &&
464 !strcmp(card->rtd[i].dai_link->name, dai_link)) 464 !strcmp(card->rtd[i].dai_link->name, dai_link))
465 return card->rtd[i].pcm->streams[stream].substream; 465 return card->rtd[i].pcm->streams[stream].substream;
466 } 466 }
467 dev_dbg(card->dev, "ASoC: failed to find dai link %s\n", dai_link); 467 dev_dbg(card->dev, "ASoC: failed to find dai link %s\n", dai_link);
468 return NULL; 468 return NULL;
469 } 469 }
470 EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream); 470 EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream);
471 471
472 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, 472 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
473 const char *dai_link) 473 const char *dai_link)
474 { 474 {
475 int i; 475 int i;
476 476
477 for (i = 0; i < card->num_links; i++) { 477 for (i = 0; i < card->num_links; i++) {
478 if (!strcmp(card->rtd[i].dai_link->name, dai_link)) 478 if (!strcmp(card->rtd[i].dai_link->name, dai_link))
479 return &card->rtd[i]; 479 return &card->rtd[i];
480 } 480 }
481 dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link); 481 dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link);
482 return NULL; 482 return NULL;
483 } 483 }
484 EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); 484 EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime);
485 485
486 static void codec2codec_close_delayed_work(struct work_struct *work) 486 static void codec2codec_close_delayed_work(struct work_struct *work)
487 { 487 {
488 /* Currently nothing to do for c2c links 488 /* Currently nothing to do for c2c links
489 * Since c2c links are internal nodes in the DAPM graph and 489 * Since c2c links are internal nodes in the DAPM graph and
490 * don't interface with the outside world or application layer 490 * don't interface with the outside world or application layer
491 * we don't have to do any special handling on close. 491 * we don't have to do any special handling on close.
492 */ 492 */
493 } 493 }
494 494
495 #ifdef CONFIG_PM_SLEEP 495 #ifdef CONFIG_PM_SLEEP
496 /* powers down audio subsystem for suspend */ 496 /* powers down audio subsystem for suspend */
497 int snd_soc_suspend(struct device *dev) 497 int snd_soc_suspend(struct device *dev)
498 { 498 {
499 struct snd_soc_card *card = dev_get_drvdata(dev); 499 struct snd_soc_card *card = dev_get_drvdata(dev);
500 struct snd_soc_codec *codec; 500 struct snd_soc_codec *codec;
501 int i, j; 501 int i, j;
502 502
503 /* If the card is not initialized yet there is nothing to do */ 503 /* If the card is not initialized yet there is nothing to do */
504 if (!card->instantiated) 504 if (!card->instantiated)
505 return 0; 505 return 0;
506 506
507 /* Due to the resume being scheduled into a workqueue we could 507 /* Due to the resume being scheduled into a workqueue we could
508 * suspend before that's finished - wait for it to complete. 508 * suspend before that's finished - wait for it to complete.
509 */ 509 */
510 snd_power_lock(card->snd_card); 510 snd_power_lock(card->snd_card);
511 snd_power_wait(card->snd_card, SNDRV_CTL_POWER_D0); 511 snd_power_wait(card->snd_card, SNDRV_CTL_POWER_D0);
512 snd_power_unlock(card->snd_card); 512 snd_power_unlock(card->snd_card);
513 513
514 /* we're going to block userspace touching us until resume completes */ 514 /* we're going to block userspace touching us until resume completes */
515 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot); 515 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot);
516 516
517 /* mute any active DACs */ 517 /* mute any active DACs */
518 for (i = 0; i < card->num_rtd; i++) { 518 for (i = 0; i < card->num_rtd; i++) {
519 519
520 if (card->rtd[i].dai_link->ignore_suspend) 520 if (card->rtd[i].dai_link->ignore_suspend)
521 continue; 521 continue;
522 522
523 for (j = 0; j < card->rtd[i].num_codecs; j++) { 523 for (j = 0; j < card->rtd[i].num_codecs; j++) {
524 struct snd_soc_dai *dai = card->rtd[i].codec_dais[j]; 524 struct snd_soc_dai *dai = card->rtd[i].codec_dais[j];
525 struct snd_soc_dai_driver *drv = dai->driver; 525 struct snd_soc_dai_driver *drv = dai->driver;
526 526
527 if (drv->ops->digital_mute && dai->playback_active) 527 if (drv->ops->digital_mute && dai->playback_active)
528 drv->ops->digital_mute(dai, 1); 528 drv->ops->digital_mute(dai, 1);
529 } 529 }
530 } 530 }
531 531
532 /* suspend all pcms */ 532 /* suspend all pcms */
533 for (i = 0; i < card->num_rtd; i++) { 533 for (i = 0; i < card->num_rtd; i++) {
534 if (card->rtd[i].dai_link->ignore_suspend) 534 if (card->rtd[i].dai_link->ignore_suspend)
535 continue; 535 continue;
536 536
537 snd_pcm_suspend_all(card->rtd[i].pcm); 537 snd_pcm_suspend_all(card->rtd[i].pcm);
538 } 538 }
539 539
540 if (card->suspend_pre) 540 if (card->suspend_pre)
541 card->suspend_pre(card); 541 card->suspend_pre(card);
542 542
543 for (i = 0; i < card->num_rtd; i++) { 543 for (i = 0; i < card->num_rtd; i++) {
544 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; 544 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
545 545
546 if (card->rtd[i].dai_link->ignore_suspend) 546 if (card->rtd[i].dai_link->ignore_suspend)
547 continue; 547 continue;
548 548
549 if (cpu_dai->driver->suspend && !cpu_dai->driver->bus_control) 549 if (cpu_dai->driver->suspend && !cpu_dai->driver->bus_control)
550 cpu_dai->driver->suspend(cpu_dai); 550 cpu_dai->driver->suspend(cpu_dai);
551 } 551 }
552 552
553 /* close any waiting streams and save state */ 553 /* close any waiting streams and save state */
554 for (i = 0; i < card->num_rtd; i++) { 554 for (i = 0; i < card->num_rtd; i++) {
555 struct snd_soc_dai **codec_dais = card->rtd[i].codec_dais; 555 struct snd_soc_dai **codec_dais = card->rtd[i].codec_dais;
556 flush_delayed_work(&card->rtd[i].delayed_work); 556 flush_delayed_work(&card->rtd[i].delayed_work);
557 for (j = 0; j < card->rtd[i].num_codecs; j++) { 557 for (j = 0; j < card->rtd[i].num_codecs; j++) {
558 codec_dais[j]->codec->dapm.suspend_bias_level = 558 codec_dais[j]->codec->dapm.suspend_bias_level =
559 codec_dais[j]->codec->dapm.bias_level; 559 codec_dais[j]->codec->dapm.bias_level;
560 } 560 }
561 } 561 }
562 562
563 for (i = 0; i < card->num_rtd; i++) { 563 for (i = 0; i < card->num_rtd; i++) {
564 564
565 if (card->rtd[i].dai_link->ignore_suspend) 565 if (card->rtd[i].dai_link->ignore_suspend)
566 continue; 566 continue;
567 567
568 snd_soc_dapm_stream_event(&card->rtd[i], 568 snd_soc_dapm_stream_event(&card->rtd[i],
569 SNDRV_PCM_STREAM_PLAYBACK, 569 SNDRV_PCM_STREAM_PLAYBACK,
570 SND_SOC_DAPM_STREAM_SUSPEND); 570 SND_SOC_DAPM_STREAM_SUSPEND);
571 571
572 snd_soc_dapm_stream_event(&card->rtd[i], 572 snd_soc_dapm_stream_event(&card->rtd[i],
573 SNDRV_PCM_STREAM_CAPTURE, 573 SNDRV_PCM_STREAM_CAPTURE,
574 SND_SOC_DAPM_STREAM_SUSPEND); 574 SND_SOC_DAPM_STREAM_SUSPEND);
575 } 575 }
576 576
577 /* Recheck all endpoints too, their state is affected by suspend */ 577 /* Recheck all endpoints too, their state is affected by suspend */
578 dapm_mark_endpoints_dirty(card); 578 dapm_mark_endpoints_dirty(card);
579 snd_soc_dapm_sync(&card->dapm); 579 snd_soc_dapm_sync(&card->dapm);
580 580
581 /* suspend all CODECs */ 581 /* suspend all CODECs */
582 list_for_each_entry(codec, &card->codec_dev_list, card_list) { 582 list_for_each_entry(codec, &card->codec_dev_list, card_list) {
583 /* If there are paths active then the CODEC will be held with 583 /* If there are paths active then the CODEC will be held with
584 * bias _ON and should not be suspended. */ 584 * bias _ON and should not be suspended. */
585 if (!codec->suspended) { 585 if (!codec->suspended) {
586 switch (codec->dapm.bias_level) { 586 switch (codec->dapm.bias_level) {
587 case SND_SOC_BIAS_STANDBY: 587 case SND_SOC_BIAS_STANDBY:
588 /* 588 /*
589 * If the CODEC is capable of idle 589 * If the CODEC is capable of idle
590 * bias off then being in STANDBY 590 * bias off then being in STANDBY
591 * means it's doing something, 591 * means it's doing something,
592 * otherwise fall through. 592 * otherwise fall through.
593 */ 593 */
594 if (codec->dapm.idle_bias_off) { 594 if (codec->dapm.idle_bias_off) {
595 dev_dbg(codec->dev, 595 dev_dbg(codec->dev,
596 "ASoC: idle_bias_off CODEC on over suspend\n"); 596 "ASoC: idle_bias_off CODEC on over suspend\n");
597 break; 597 break;
598 } 598 }
599 599
600 case SND_SOC_BIAS_OFF: 600 case SND_SOC_BIAS_OFF:
601 if (codec->driver->suspend) 601 if (codec->driver->suspend)
602 codec->driver->suspend(codec); 602 codec->driver->suspend(codec);
603 codec->suspended = 1; 603 codec->suspended = 1;
604 if (codec->component.regmap) 604 if (codec->component.regmap)
605 regcache_mark_dirty(codec->component.regmap); 605 regcache_mark_dirty(codec->component.regmap);
606 /* deactivate pins to sleep state */ 606 /* deactivate pins to sleep state */
607 pinctrl_pm_select_sleep_state(codec->dev); 607 pinctrl_pm_select_sleep_state(codec->dev);
608 break; 608 break;
609 default: 609 default:
610 dev_dbg(codec->dev, 610 dev_dbg(codec->dev,
611 "ASoC: CODEC is on over suspend\n"); 611 "ASoC: CODEC is on over suspend\n");
612 break; 612 break;
613 } 613 }
614 } 614 }
615 } 615 }
616 616
617 for (i = 0; i < card->num_rtd; i++) { 617 for (i = 0; i < card->num_rtd; i++) {
618 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; 618 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
619 619
620 if (card->rtd[i].dai_link->ignore_suspend) 620 if (card->rtd[i].dai_link->ignore_suspend)
621 continue; 621 continue;
622 622
623 if (cpu_dai->driver->suspend && cpu_dai->driver->bus_control) 623 if (cpu_dai->driver->suspend && cpu_dai->driver->bus_control)
624 cpu_dai->driver->suspend(cpu_dai); 624 cpu_dai->driver->suspend(cpu_dai);
625 625
626 /* deactivate pins to sleep state */ 626 /* deactivate pins to sleep state */
627 pinctrl_pm_select_sleep_state(cpu_dai->dev); 627 pinctrl_pm_select_sleep_state(cpu_dai->dev);
628 } 628 }
629 629
630 if (card->suspend_post) 630 if (card->suspend_post)
631 card->suspend_post(card); 631 card->suspend_post(card);
632 632
633 return 0; 633 return 0;
634 } 634 }
635 EXPORT_SYMBOL_GPL(snd_soc_suspend); 635 EXPORT_SYMBOL_GPL(snd_soc_suspend);
636 636
637 /* deferred resume work, so resume can complete before we finished 637 /* deferred resume work, so resume can complete before we finished
638 * setting our codec back up, which can be very slow on I2C 638 * setting our codec back up, which can be very slow on I2C
639 */ 639 */
640 static void soc_resume_deferred(struct work_struct *work) 640 static void soc_resume_deferred(struct work_struct *work)
641 { 641 {
642 struct snd_soc_card *card = 642 struct snd_soc_card *card =
643 container_of(work, struct snd_soc_card, deferred_resume_work); 643 container_of(work, struct snd_soc_card, deferred_resume_work);
644 struct snd_soc_codec *codec; 644 struct snd_soc_codec *codec;
645 int i, j; 645 int i, j;
646 646
647 /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time, 647 /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
648 * so userspace apps are blocked from touching us 648 * so userspace apps are blocked from touching us
649 */ 649 */
650 650
651 dev_dbg(card->dev, "ASoC: starting resume work\n"); 651 dev_dbg(card->dev, "ASoC: starting resume work\n");
652 652
653 /* Bring us up into D2 so that DAPM starts enabling things */ 653 /* Bring us up into D2 so that DAPM starts enabling things */
654 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2); 654 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2);
655 655
656 if (card->resume_pre) 656 if (card->resume_pre)
657 card->resume_pre(card); 657 card->resume_pre(card);
658 658
659 /* resume control bus DAIs */ 659 /* resume control bus DAIs */
660 for (i = 0; i < card->num_rtd; i++) { 660 for (i = 0; i < card->num_rtd; i++) {
661 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; 661 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
662 662
663 if (card->rtd[i].dai_link->ignore_suspend) 663 if (card->rtd[i].dai_link->ignore_suspend)
664 continue; 664 continue;
665 665
666 if (cpu_dai->driver->resume && cpu_dai->driver->bus_control) 666 if (cpu_dai->driver->resume && cpu_dai->driver->bus_control)
667 cpu_dai->driver->resume(cpu_dai); 667 cpu_dai->driver->resume(cpu_dai);
668 } 668 }
669 669
670 list_for_each_entry(codec, &card->codec_dev_list, card_list) { 670 list_for_each_entry(codec, &card->codec_dev_list, card_list) {
671 /* If the CODEC was idle over suspend then it will have been 671 /* If the CODEC was idle over suspend then it will have been
672 * left with bias OFF or STANDBY and suspended so we must now 672 * left with bias OFF or STANDBY and suspended so we must now
673 * resume. Otherwise the suspend was suppressed. 673 * resume. Otherwise the suspend was suppressed.
674 */ 674 */
675 if (codec->suspended) { 675 if (codec->suspended) {
676 switch (codec->dapm.bias_level) { 676 switch (codec->dapm.bias_level) {
677 case SND_SOC_BIAS_STANDBY: 677 case SND_SOC_BIAS_STANDBY:
678 case SND_SOC_BIAS_OFF: 678 case SND_SOC_BIAS_OFF:
679 if (codec->driver->resume) 679 if (codec->driver->resume)
680 codec->driver->resume(codec); 680 codec->driver->resume(codec);
681 codec->suspended = 0; 681 codec->suspended = 0;
682 break; 682 break;
683 default: 683 default:
684 dev_dbg(codec->dev, 684 dev_dbg(codec->dev,
685 "ASoC: CODEC was on over suspend\n"); 685 "ASoC: CODEC was on over suspend\n");
686 break; 686 break;
687 } 687 }
688 } 688 }
689 } 689 }
690 690
691 for (i = 0; i < card->num_rtd; i++) { 691 for (i = 0; i < card->num_rtd; i++) {
692 692
693 if (card->rtd[i].dai_link->ignore_suspend) 693 if (card->rtd[i].dai_link->ignore_suspend)
694 continue; 694 continue;
695 695
696 snd_soc_dapm_stream_event(&card->rtd[i], 696 snd_soc_dapm_stream_event(&card->rtd[i],
697 SNDRV_PCM_STREAM_PLAYBACK, 697 SNDRV_PCM_STREAM_PLAYBACK,
698 SND_SOC_DAPM_STREAM_RESUME); 698 SND_SOC_DAPM_STREAM_RESUME);
699 699
700 snd_soc_dapm_stream_event(&card->rtd[i], 700 snd_soc_dapm_stream_event(&card->rtd[i],
701 SNDRV_PCM_STREAM_CAPTURE, 701 SNDRV_PCM_STREAM_CAPTURE,
702 SND_SOC_DAPM_STREAM_RESUME); 702 SND_SOC_DAPM_STREAM_RESUME);
703 } 703 }
704 704
705 /* unmute any active DACs */ 705 /* unmute any active DACs */
706 for (i = 0; i < card->num_rtd; i++) { 706 for (i = 0; i < card->num_rtd; i++) {
707 707
708 if (card->rtd[i].dai_link->ignore_suspend) 708 if (card->rtd[i].dai_link->ignore_suspend)
709 continue; 709 continue;
710 710
711 for (j = 0; j < card->rtd[i].num_codecs; j++) { 711 for (j = 0; j < card->rtd[i].num_codecs; j++) {
712 struct snd_soc_dai *dai = card->rtd[i].codec_dais[j]; 712 struct snd_soc_dai *dai = card->rtd[i].codec_dais[j];
713 struct snd_soc_dai_driver *drv = dai->driver; 713 struct snd_soc_dai_driver *drv = dai->driver;
714 714
715 if (drv->ops->digital_mute && dai->playback_active) 715 if (drv->ops->digital_mute && dai->playback_active)
716 drv->ops->digital_mute(dai, 0); 716 drv->ops->digital_mute(dai, 0);
717 } 717 }
718 } 718 }
719 719
720 for (i = 0; i < card->num_rtd; i++) { 720 for (i = 0; i < card->num_rtd; i++) {
721 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; 721 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
722 722
723 if (card->rtd[i].dai_link->ignore_suspend) 723 if (card->rtd[i].dai_link->ignore_suspend)
724 continue; 724 continue;
725 725
726 if (cpu_dai->driver->resume && !cpu_dai->driver->bus_control) 726 if (cpu_dai->driver->resume && !cpu_dai->driver->bus_control)
727 cpu_dai->driver->resume(cpu_dai); 727 cpu_dai->driver->resume(cpu_dai);
728 } 728 }
729 729
730 if (card->resume_post) 730 if (card->resume_post)
731 card->resume_post(card); 731 card->resume_post(card);
732 732
733 dev_dbg(card->dev, "ASoC: resume work completed\n"); 733 dev_dbg(card->dev, "ASoC: resume work completed\n");
734 734
735 /* userspace can access us now we are back as we were before */ 735 /* userspace can access us now we are back as we were before */
736 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0); 736 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);
737 737
738 /* Recheck all endpoints too, their state is affected by suspend */ 738 /* Recheck all endpoints too, their state is affected by suspend */
739 dapm_mark_endpoints_dirty(card); 739 dapm_mark_endpoints_dirty(card);
740 snd_soc_dapm_sync(&card->dapm); 740 snd_soc_dapm_sync(&card->dapm);
741 } 741 }
742 742
743 /* powers up audio subsystem after a suspend */ 743 /* powers up audio subsystem after a suspend */
744 int snd_soc_resume(struct device *dev) 744 int snd_soc_resume(struct device *dev)
745 { 745 {
746 struct snd_soc_card *card = dev_get_drvdata(dev); 746 struct snd_soc_card *card = dev_get_drvdata(dev);
747 bool bus_control = false; 747 bool bus_control = false;
748 int i; 748 int i;
749 749
750 /* If the card is not initialized yet there is nothing to do */ 750 /* If the card is not initialized yet there is nothing to do */
751 if (!card->instantiated) 751 if (!card->instantiated)
752 return 0; 752 return 0;
753 753
754 /* activate pins from sleep state */ 754 /* activate pins from sleep state */
755 for (i = 0; i < card->num_rtd; i++) { 755 for (i = 0; i < card->num_rtd; i++) {
756 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; 756 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
757 struct snd_soc_dai **codec_dais = rtd->codec_dais; 757 struct snd_soc_dai **codec_dais = rtd->codec_dais;
758 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 758 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
759 int j; 759 int j;
760 760
761 if (cpu_dai->active) 761 if (cpu_dai->active)
762 pinctrl_pm_select_default_state(cpu_dai->dev); 762 pinctrl_pm_select_default_state(cpu_dai->dev);
763 763
764 for (j = 0; j < rtd->num_codecs; j++) { 764 for (j = 0; j < rtd->num_codecs; j++) {
765 struct snd_soc_dai *codec_dai = codec_dais[j]; 765 struct snd_soc_dai *codec_dai = codec_dais[j];
766 if (codec_dai->active) 766 if (codec_dai->active)
767 pinctrl_pm_select_default_state(codec_dai->dev); 767 pinctrl_pm_select_default_state(codec_dai->dev);
768 } 768 }
769 } 769 }
770 770
771 /* 771 /*
772 * DAIs that also act as the control bus master might have other drivers 772 * DAIs that also act as the control bus master might have other drivers
773 * hanging off them so need to resume immediately. Other drivers don't 773 * hanging off them so need to resume immediately. Other drivers don't
774 * have that problem and may take a substantial amount of time to resume 774 * have that problem and may take a substantial amount of time to resume
775 * due to I/O costs and anti-pop so handle them out of line. 775 * due to I/O costs and anti-pop so handle them out of line.
776 */ 776 */
777 for (i = 0; i < card->num_rtd; i++) { 777 for (i = 0; i < card->num_rtd; i++) {
778 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; 778 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
779 bus_control |= cpu_dai->driver->bus_control; 779 bus_control |= cpu_dai->driver->bus_control;
780 } 780 }
781 if (bus_control) { 781 if (bus_control) {
782 dev_dbg(dev, "ASoC: Resuming control bus master immediately\n"); 782 dev_dbg(dev, "ASoC: Resuming control bus master immediately\n");
783 soc_resume_deferred(&card->deferred_resume_work); 783 soc_resume_deferred(&card->deferred_resume_work);
784 } else { 784 } else {
785 dev_dbg(dev, "ASoC: Scheduling resume work\n"); 785 dev_dbg(dev, "ASoC: Scheduling resume work\n");
786 if (!schedule_work(&card->deferred_resume_work)) 786 if (!schedule_work(&card->deferred_resume_work))
787 dev_err(dev, "ASoC: resume work item may be lost\n"); 787 dev_err(dev, "ASoC: resume work item may be lost\n");
788 } 788 }
789 789
790 return 0; 790 return 0;
791 } 791 }
792 EXPORT_SYMBOL_GPL(snd_soc_resume); 792 EXPORT_SYMBOL_GPL(snd_soc_resume);
793 #else 793 #else
794 #define snd_soc_suspend NULL 794 #define snd_soc_suspend NULL
795 #define snd_soc_resume NULL 795 #define snd_soc_resume NULL
796 #endif 796 #endif
797 797
798 static const struct snd_soc_dai_ops null_dai_ops = { 798 static const struct snd_soc_dai_ops null_dai_ops = {
799 }; 799 };
800 800
801 static struct snd_soc_component *soc_find_component( 801 static struct snd_soc_component *soc_find_component(
802 const struct device_node *of_node, const char *name) 802 const struct device_node *of_node, const char *name)
803 { 803 {
804 struct snd_soc_component *component; 804 struct snd_soc_component *component;
805 805
806 list_for_each_entry(component, &component_list, list) { 806 list_for_each_entry(component, &component_list, list) {
807 if (of_node) { 807 if (of_node) {
808 if (component->dev->of_node == of_node) 808 if (component->dev->of_node == of_node)
809 return component; 809 return component;
810 } else if (strcmp(component->name, name) == 0) { 810 } else if (strcmp(component->name, name) == 0) {
811 return component; 811 return component;
812 } 812 }
813 } 813 }
814 814
815 return NULL; 815 return NULL;
816 } 816 }
817 817
818 static struct snd_soc_dai *snd_soc_find_dai( 818 static struct snd_soc_dai *snd_soc_find_dai(
819 const struct snd_soc_dai_link_component *dlc) 819 const struct snd_soc_dai_link_component *dlc)
820 { 820 {
821 struct snd_soc_component *component; 821 struct snd_soc_component *component;
822 struct snd_soc_dai *dai; 822 struct snd_soc_dai *dai;
823 823
824 /* Find CPU DAI from registered DAIs*/ 824 /* Find CPU DAI from registered DAIs*/
825 list_for_each_entry(component, &component_list, list) { 825 list_for_each_entry(component, &component_list, list) {
826 if (dlc->of_node && component->dev->of_node != dlc->of_node) 826 if (dlc->of_node && component->dev->of_node != dlc->of_node)
827 continue; 827 continue;
828 if (dlc->name && strcmp(component->name, dlc->name)) 828 if (dlc->name && strcmp(component->name, dlc->name))
829 continue; 829 continue;
830 list_for_each_entry(dai, &component->dai_list, list) { 830 list_for_each_entry(dai, &component->dai_list, list) {
831 if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)) 831 if (dlc->dai_name && strcmp(dai->name, dlc->dai_name))
832 continue; 832 continue;
833 833
834 return dai; 834 return dai;
835 } 835 }
836 } 836 }
837 837
838 return NULL; 838 return NULL;
839 } 839 }
840 840
841 static int soc_bind_dai_link(struct snd_soc_card *card, int num) 841 static int soc_bind_dai_link(struct snd_soc_card *card, int num)
842 { 842 {
843 struct snd_soc_dai_link *dai_link = &card->dai_link[num]; 843 struct snd_soc_dai_link *dai_link = &card->dai_link[num];
844 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; 844 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
845 struct snd_soc_dai_link_component *codecs = dai_link->codecs; 845 struct snd_soc_dai_link_component *codecs = dai_link->codecs;
846 struct snd_soc_dai_link_component cpu_dai_component; 846 struct snd_soc_dai_link_component cpu_dai_component;
847 struct snd_soc_dai **codec_dais = rtd->codec_dais; 847 struct snd_soc_dai **codec_dais = rtd->codec_dais;
848 struct snd_soc_platform *platform; 848 struct snd_soc_platform *platform;
849 const char *platform_name; 849 const char *platform_name;
850 int i; 850 int i;
851 851
852 dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num); 852 dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num);
853 853
854 cpu_dai_component.name = dai_link->cpu_name; 854 cpu_dai_component.name = dai_link->cpu_name;
855 cpu_dai_component.of_node = dai_link->cpu_of_node; 855 cpu_dai_component.of_node = dai_link->cpu_of_node;
856 cpu_dai_component.dai_name = dai_link->cpu_dai_name; 856 cpu_dai_component.dai_name = dai_link->cpu_dai_name;
857 rtd->cpu_dai = snd_soc_find_dai(&cpu_dai_component); 857 rtd->cpu_dai = snd_soc_find_dai(&cpu_dai_component);
858 if (!rtd->cpu_dai) { 858 if (!rtd->cpu_dai) {
859 dev_err(card->dev, "ASoC: CPU DAI %s not registered\n", 859 dev_err(card->dev, "ASoC: CPU DAI %s not registered\n",
860 dai_link->cpu_dai_name); 860 dai_link->cpu_dai_name);
861 return -EPROBE_DEFER; 861 return -EPROBE_DEFER;
862 } 862 }
863 863
864 rtd->num_codecs = dai_link->num_codecs; 864 rtd->num_codecs = dai_link->num_codecs;
865 865
866 /* Find CODEC from registered CODECs */ 866 /* Find CODEC from registered CODECs */
867 for (i = 0; i < rtd->num_codecs; i++) { 867 for (i = 0; i < rtd->num_codecs; i++) {
868 codec_dais[i] = snd_soc_find_dai(&codecs[i]); 868 codec_dais[i] = snd_soc_find_dai(&codecs[i]);
869 if (!codec_dais[i]) { 869 if (!codec_dais[i]) {
870 dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", 870 dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n",
871 codecs[i].dai_name); 871 codecs[i].dai_name);
872 return -EPROBE_DEFER; 872 return -EPROBE_DEFER;
873 } 873 }
874 } 874 }
875 875
876 /* Single codec links expect codec and codec_dai in runtime data */ 876 /* Single codec links expect codec and codec_dai in runtime data */
877 rtd->codec_dai = codec_dais[0]; 877 rtd->codec_dai = codec_dais[0];
878 rtd->codec = rtd->codec_dai->codec; 878 rtd->codec = rtd->codec_dai->codec;
879 879
880 /* if there's no platform we match on the empty platform */ 880 /* if there's no platform we match on the empty platform */
881 platform_name = dai_link->platform_name; 881 platform_name = dai_link->platform_name;
882 if (!platform_name && !dai_link->platform_of_node) 882 if (!platform_name && !dai_link->platform_of_node)
883 platform_name = "snd-soc-dummy"; 883 platform_name = "snd-soc-dummy";
884 884
885 /* find one from the set of registered platforms */ 885 /* find one from the set of registered platforms */
886 list_for_each_entry(platform, &platform_list, list) { 886 list_for_each_entry(platform, &platform_list, list) {
887 if (dai_link->platform_of_node) { 887 if (dai_link->platform_of_node) {
888 if (platform->dev->of_node != 888 if (platform->dev->of_node !=
889 dai_link->platform_of_node) 889 dai_link->platform_of_node)
890 continue; 890 continue;
891 } else { 891 } else {
892 if (strcmp(platform->component.name, platform_name)) 892 if (strcmp(platform->component.name, platform_name))
893 continue; 893 continue;
894 } 894 }
895 895
896 rtd->platform = platform; 896 rtd->platform = platform;
897 } 897 }
898 if (!rtd->platform) { 898 if (!rtd->platform) {
899 dev_err(card->dev, "ASoC: platform %s not registered\n", 899 dev_err(card->dev, "ASoC: platform %s not registered\n",
900 dai_link->platform_name); 900 dai_link->platform_name);
901 return -EPROBE_DEFER; 901 return -EPROBE_DEFER;
902 } 902 }
903 903
904 card->num_rtd++; 904 card->num_rtd++;
905 905
906 return 0; 906 return 0;
907 } 907 }
908 908
909 static void soc_remove_component(struct snd_soc_component *component) 909 static void soc_remove_component(struct snd_soc_component *component)
910 { 910 {
911 if (!component->probed) 911 if (!component->probed)
912 return; 912 return;
913 913
914 /* This is a HACK and will be removed soon */ 914 /* This is a HACK and will be removed soon */
915 if (component->codec) 915 if (component->codec)
916 list_del(&component->codec->card_list); 916 list_del(&component->codec->card_list);
917 917
918 if (component->remove) 918 if (component->remove)
919 component->remove(component); 919 component->remove(component);
920 920
921 snd_soc_dapm_free(snd_soc_component_get_dapm(component)); 921 snd_soc_dapm_free(snd_soc_component_get_dapm(component));
922 922
923 soc_cleanup_component_debugfs(component); 923 soc_cleanup_component_debugfs(component);
924 component->probed = 0; 924 component->probed = 0;
925 module_put(component->dev->driver->owner); 925 module_put(component->dev->driver->owner);
926 } 926 }
927 927
928 static void soc_remove_dai(struct snd_soc_dai *dai, int order) 928 static void soc_remove_dai(struct snd_soc_dai *dai, int order)
929 { 929 {
930 int err; 930 int err;
931 931
932 if (dai && dai->probed && 932 if (dai && dai->probed &&
933 dai->driver->remove_order == order) { 933 dai->driver->remove_order == order) {
934 if (dai->driver->remove) { 934 if (dai->driver->remove) {
935 err = dai->driver->remove(dai); 935 err = dai->driver->remove(dai);
936 if (err < 0) 936 if (err < 0)
937 dev_err(dai->dev, 937 dev_err(dai->dev,
938 "ASoC: failed to remove %s: %d\n", 938 "ASoC: failed to remove %s: %d\n",
939 dai->name, err); 939 dai->name, err);
940 } 940 }
941 dai->probed = 0; 941 dai->probed = 0;
942 } 942 }
943 } 943 }
944 944
945 static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) 945 static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
946 { 946 {
947 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; 947 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
948 int i; 948 int i;
949 949
950 /* unregister the rtd device */ 950 /* unregister the rtd device */
951 if (rtd->dev_registered) { 951 if (rtd->dev_registered) {
952 device_remove_file(rtd->dev, &dev_attr_pmdown_time); 952 device_remove_file(rtd->dev, &dev_attr_pmdown_time);
953 device_remove_file(rtd->dev, &dev_attr_codec_reg); 953 device_remove_file(rtd->dev, &dev_attr_codec_reg);
954 device_unregister(rtd->dev); 954 device_unregister(rtd->dev);
955 rtd->dev_registered = 0; 955 rtd->dev_registered = 0;
956 } 956 }
957 957
958 /* remove the CODEC DAI */ 958 /* remove the CODEC DAI */
959 for (i = 0; i < rtd->num_codecs; i++) 959 for (i = 0; i < rtd->num_codecs; i++)
960 soc_remove_dai(rtd->codec_dais[i], order); 960 soc_remove_dai(rtd->codec_dais[i], order);
961 961
962 soc_remove_dai(rtd->cpu_dai, order); 962 soc_remove_dai(rtd->cpu_dai, order);
963 } 963 }
964 964
965 static void soc_remove_link_components(struct snd_soc_card *card, int num, 965 static void soc_remove_link_components(struct snd_soc_card *card, int num,
966 int order) 966 int order)
967 { 967 {
968 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; 968 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
969 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 969 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
970 struct snd_soc_platform *platform = rtd->platform; 970 struct snd_soc_platform *platform = rtd->platform;
971 struct snd_soc_component *component; 971 struct snd_soc_component *component;
972 int i; 972 int i;
973 973
974 /* remove the platform */ 974 /* remove the platform */
975 if (platform && platform->component.driver->remove_order == order) 975 if (platform && platform->component.driver->remove_order == order)
976 soc_remove_component(&platform->component); 976 soc_remove_component(&platform->component);
977 977
978 /* remove the CODEC-side CODEC */ 978 /* remove the CODEC-side CODEC */
979 for (i = 0; i < rtd->num_codecs; i++) { 979 for (i = 0; i < rtd->num_codecs; i++) {
980 component = rtd->codec_dais[i]->component; 980 component = rtd->codec_dais[i]->component;
981 if (component->driver->remove_order == order) 981 if (component->driver->remove_order == order)
982 soc_remove_component(component); 982 soc_remove_component(component);
983 } 983 }
984 984
985 /* remove any CPU-side CODEC */ 985 /* remove any CPU-side CODEC */
986 if (cpu_dai) { 986 if (cpu_dai) {
987 if (cpu_dai->component->driver->remove_order == order) 987 if (cpu_dai->component->driver->remove_order == order)
988 soc_remove_component(cpu_dai->component); 988 soc_remove_component(cpu_dai->component);
989 } 989 }
990 } 990 }
991 991
992 static void soc_remove_dai_links(struct snd_soc_card *card) 992 static void soc_remove_dai_links(struct snd_soc_card *card)
993 { 993 {
994 int dai, order; 994 int dai, order;
995 995
996 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; 996 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
997 order++) { 997 order++) {
998 for (dai = 0; dai < card->num_rtd; dai++) 998 for (dai = 0; dai < card->num_rtd; dai++)
999 soc_remove_link_dais(card, dai, order); 999 soc_remove_link_dais(card, dai, order);
1000 } 1000 }
1001 1001
1002 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; 1002 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
1003 order++) { 1003 order++) {
1004 for (dai = 0; dai < card->num_rtd; dai++) 1004 for (dai = 0; dai < card->num_rtd; dai++)
1005 soc_remove_link_components(card, dai, order); 1005 soc_remove_link_components(card, dai, order);
1006 } 1006 }
1007 1007
1008 card->num_rtd = 0; 1008 card->num_rtd = 0;
1009 } 1009 }
1010 1010
1011 static void soc_set_name_prefix(struct snd_soc_card *card, 1011 static void soc_set_name_prefix(struct snd_soc_card *card,
1012 struct snd_soc_component *component) 1012 struct snd_soc_component *component)
1013 { 1013 {
1014 int i; 1014 int i;
1015 1015
1016 if (card->codec_conf == NULL) 1016 if (card->codec_conf == NULL)
1017 return; 1017 return;
1018 1018
1019 for (i = 0; i < card->num_configs; i++) { 1019 for (i = 0; i < card->num_configs; i++) {
1020 struct snd_soc_codec_conf *map = &card->codec_conf[i]; 1020 struct snd_soc_codec_conf *map = &card->codec_conf[i];
1021 if (map->of_node && component->dev->of_node != map->of_node) 1021 if (map->of_node && component->dev->of_node != map->of_node)
1022 continue; 1022 continue;
1023 if (map->dev_name && strcmp(component->name, map->dev_name)) 1023 if (map->dev_name && strcmp(component->name, map->dev_name))
1024 continue; 1024 continue;
1025 component->name_prefix = map->name_prefix; 1025 component->name_prefix = map->name_prefix;
1026 break; 1026 break;
1027 } 1027 }
1028 } 1028 }
1029 1029
1030 static int soc_probe_component(struct snd_soc_card *card, 1030 static int soc_probe_component(struct snd_soc_card *card,
1031 struct snd_soc_component *component) 1031 struct snd_soc_component *component)
1032 { 1032 {
1033 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 1033 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
1034 struct snd_soc_dai *dai; 1034 struct snd_soc_dai *dai;
1035 int ret; 1035 int ret;
1036 1036
1037 if (component->probed) 1037 if (component->probed)
1038 return 0; 1038 return 0;
1039 1039
1040 component->card = card; 1040 component->card = card;
1041 dapm->card = card; 1041 dapm->card = card;
1042 soc_set_name_prefix(card, component); 1042 soc_set_name_prefix(card, component);
1043 1043
1044 if (!try_module_get(component->dev->driver->owner)) 1044 if (!try_module_get(component->dev->driver->owner))
1045 return -ENODEV; 1045 return -ENODEV;
1046 1046
1047 soc_init_component_debugfs(component); 1047 soc_init_component_debugfs(component);
1048 1048
1049 if (component->dapm_widgets) { 1049 if (component->dapm_widgets) {
1050 ret = snd_soc_dapm_new_controls(dapm, component->dapm_widgets, 1050 ret = snd_soc_dapm_new_controls(dapm, component->dapm_widgets,
1051 component->num_dapm_widgets); 1051 component->num_dapm_widgets);
1052 1052
1053 if (ret != 0) { 1053 if (ret != 0) {
1054 dev_err(component->dev, 1054 dev_err(component->dev,
1055 "Failed to create new controls %d\n", ret); 1055 "Failed to create new controls %d\n", ret);
1056 goto err_probe; 1056 goto err_probe;
1057 } 1057 }
1058 } 1058 }
1059 1059
1060 list_for_each_entry(dai, &component->dai_list, list) { 1060 list_for_each_entry(dai, &component->dai_list, list) {
1061 ret = snd_soc_dapm_new_dai_widgets(dapm, dai); 1061 ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
1062 if (ret != 0) { 1062 if (ret != 0) {
1063 dev_err(component->dev, 1063 dev_err(component->dev,
1064 "Failed to create DAI widgets %d\n", ret); 1064 "Failed to create DAI widgets %d\n", ret);
1065 goto err_probe; 1065 goto err_probe;
1066 } 1066 }
1067 } 1067 }
1068 1068
1069 if (component->probe) { 1069 if (component->probe) {
1070 ret = component->probe(component); 1070 ret = component->probe(component);
1071 if (ret < 0) { 1071 if (ret < 0) {
1072 dev_err(component->dev, 1072 dev_err(component->dev,
1073 "ASoC: failed to probe component %d\n", ret); 1073 "ASoC: failed to probe component %d\n", ret);
1074 goto err_probe; 1074 goto err_probe;
1075 } 1075 }
1076 1076
1077 WARN(dapm->idle_bias_off && 1077 WARN(dapm->idle_bias_off &&
1078 dapm->bias_level != SND_SOC_BIAS_OFF, 1078 dapm->bias_level != SND_SOC_BIAS_OFF,
1079 "codec %s can not start from non-off bias with idle_bias_off==1\n", 1079 "codec %s can not start from non-off bias with idle_bias_off==1\n",
1080 component->name); 1080 component->name);
1081 } 1081 }
1082 1082
1083 if (component->controls) 1083 if (component->controls)
1084 snd_soc_add_component_controls(component, component->controls, 1084 snd_soc_add_component_controls(component, component->controls,
1085 component->num_controls); 1085 component->num_controls);
1086 if (component->dapm_routes) 1086 if (component->dapm_routes)
1087 snd_soc_dapm_add_routes(dapm, component->dapm_routes, 1087 snd_soc_dapm_add_routes(dapm, component->dapm_routes,
1088 component->num_dapm_routes); 1088 component->num_dapm_routes);
1089 1089
1090 component->probed = 1; 1090 component->probed = 1;
1091 list_add(&dapm->list, &card->dapm_list); 1091 list_add(&dapm->list, &card->dapm_list);
1092 1092
1093 /* This is a HACK and will be removed soon */ 1093 /* This is a HACK and will be removed soon */
1094 if (component->codec) 1094 if (component->codec)
1095 list_add(&component->codec->card_list, &card->codec_dev_list); 1095 list_add(&component->codec->card_list, &card->codec_dev_list);
1096 1096
1097 return 0; 1097 return 0;
1098 1098
1099 err_probe: 1099 err_probe:
1100 soc_cleanup_component_debugfs(component); 1100 soc_cleanup_component_debugfs(component);
1101 module_put(component->dev->driver->owner); 1101 module_put(component->dev->driver->owner);
1102 1102
1103 return ret; 1103 return ret;
1104 } 1104 }
1105 1105
1106 static void rtd_release(struct device *dev) 1106 static void rtd_release(struct device *dev)
1107 { 1107 {
1108 kfree(dev); 1108 kfree(dev);
1109 } 1109 }
1110 1110
1111 static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd, 1111 static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd,
1112 const char *name) 1112 const char *name)
1113 { 1113 {
1114 int ret = 0; 1114 int ret = 0;
1115 1115
1116 /* register the rtd device */ 1116 /* register the rtd device */
1117 rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL); 1117 rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
1118 if (!rtd->dev) 1118 if (!rtd->dev)
1119 return -ENOMEM; 1119 return -ENOMEM;
1120 device_initialize(rtd->dev); 1120 device_initialize(rtd->dev);
1121 rtd->dev->parent = rtd->card->dev; 1121 rtd->dev->parent = rtd->card->dev;
1122 rtd->dev->release = rtd_release; 1122 rtd->dev->release = rtd_release;
1123 dev_set_name(rtd->dev, "%s", name); 1123 dev_set_name(rtd->dev, "%s", name);
1124 dev_set_drvdata(rtd->dev, rtd); 1124 dev_set_drvdata(rtd->dev, rtd);
1125 mutex_init(&rtd->pcm_mutex); 1125 mutex_init(&rtd->pcm_mutex);
1126 INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].be_clients); 1126 INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].be_clients);
1127 INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].be_clients); 1127 INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].be_clients);
1128 INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].fe_clients); 1128 INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].fe_clients);
1129 INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].fe_clients); 1129 INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].fe_clients);
1130 ret = device_add(rtd->dev); 1130 ret = device_add(rtd->dev);
1131 if (ret < 0) { 1131 if (ret < 0) {
1132 /* calling put_device() here to free the rtd->dev */ 1132 /* calling put_device() here to free the rtd->dev */
1133 put_device(rtd->dev); 1133 put_device(rtd->dev);
1134 dev_err(rtd->card->dev, 1134 dev_err(rtd->card->dev,
1135 "ASoC: failed to register runtime device: %d\n", ret); 1135 "ASoC: failed to register runtime device: %d\n", ret);
1136 return ret; 1136 return ret;
1137 } 1137 }
1138 rtd->dev_registered = 1; 1138 rtd->dev_registered = 1;
1139 1139
1140 if (rtd->codec) { 1140 if (rtd->codec) {
1141 /* add DAPM sysfs entries for this codec */ 1141 /* add DAPM sysfs entries for this codec */
1142 ret = snd_soc_dapm_sys_add(rtd->dev); 1142 ret = snd_soc_dapm_sys_add(rtd->dev);
1143 if (ret < 0) 1143 if (ret < 0)
1144 dev_err(rtd->dev, 1144 dev_err(rtd->dev,
1145 "ASoC: failed to add codec dapm sysfs entries: %d\n", 1145 "ASoC: failed to add codec dapm sysfs entries: %d\n",
1146 ret); 1146 ret);
1147 1147
1148 /* add codec sysfs entries */ 1148 /* add codec sysfs entries */
1149 ret = device_create_file(rtd->dev, &dev_attr_codec_reg); 1149 ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
1150 if (ret < 0) 1150 if (ret < 0)
1151 dev_err(rtd->dev, 1151 dev_err(rtd->dev,
1152 "ASoC: failed to add codec sysfs files: %d\n", 1152 "ASoC: failed to add codec sysfs files: %d\n",
1153 ret); 1153 ret);
1154 } 1154 }
1155 1155
1156 return 0; 1156 return 0;
1157 } 1157 }
1158 1158
1159 static int soc_probe_link_components(struct snd_soc_card *card, int num, 1159 static int soc_probe_link_components(struct snd_soc_card *card, int num,
1160 int order) 1160 int order)
1161 { 1161 {
1162 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; 1162 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
1163 struct snd_soc_platform *platform = rtd->platform; 1163 struct snd_soc_platform *platform = rtd->platform;
1164 struct snd_soc_component *component; 1164 struct snd_soc_component *component;
1165 int i, ret; 1165 int i, ret;
1166 1166
1167 /* probe the CPU-side component, if it is a CODEC */ 1167 /* probe the CPU-side component, if it is a CODEC */
1168 component = rtd->cpu_dai->component; 1168 component = rtd->cpu_dai->component;
1169 if (component->driver->probe_order == order) { 1169 if (component->driver->probe_order == order) {
1170 ret = soc_probe_component(card, component); 1170 ret = soc_probe_component(card, component);
1171 if (ret < 0) 1171 if (ret < 0)
1172 return ret; 1172 return ret;
1173 } 1173 }
1174 1174
1175 /* probe the CODEC-side components */ 1175 /* probe the CODEC-side components */
1176 for (i = 0; i < rtd->num_codecs; i++) { 1176 for (i = 0; i < rtd->num_codecs; i++) {
1177 component = rtd->codec_dais[i]->component; 1177 component = rtd->codec_dais[i]->component;
1178 if (component->driver->probe_order == order) { 1178 if (component->driver->probe_order == order) {
1179 ret = soc_probe_component(card, component); 1179 ret = soc_probe_component(card, component);
1180 if (ret < 0) 1180 if (ret < 0)
1181 return ret; 1181 return ret;
1182 } 1182 }
1183 } 1183 }
1184 1184
1185 /* probe the platform */ 1185 /* probe the platform */
1186 if (platform->component.driver->probe_order == order) { 1186 if (platform->component.driver->probe_order == order) {
1187 ret = soc_probe_component(card, &platform->component); 1187 ret = soc_probe_component(card, &platform->component);
1188 if (ret < 0) 1188 if (ret < 0)
1189 return ret; 1189 return ret;
1190 } 1190 }
1191 1191
1192 return 0; 1192 return 0;
1193 } 1193 }
1194 1194
1195 static int soc_probe_dai(struct snd_soc_dai *dai, int order) 1195 static int soc_probe_dai(struct snd_soc_dai *dai, int order)
1196 { 1196 {
1197 int ret; 1197 int ret;
1198 1198
1199 if (!dai->probed && dai->driver->probe_order == order) { 1199 if (!dai->probed && dai->driver->probe_order == order) {
1200 if (dai->driver->probe) { 1200 if (dai->driver->probe) {
1201 ret = dai->driver->probe(dai); 1201 ret = dai->driver->probe(dai);
1202 if (ret < 0) { 1202 if (ret < 0) {
1203 dev_err(dai->dev, 1203 dev_err(dai->dev,
1204 "ASoC: failed to probe DAI %s: %d\n", 1204 "ASoC: failed to probe DAI %s: %d\n",
1205 dai->name, ret); 1205 dai->name, ret);
1206 return ret; 1206 return ret;
1207 } 1207 }
1208 } 1208 }
1209 1209
1210 dai->probed = 1; 1210 dai->probed = 1;
1211 } 1211 }
1212 1212
1213 return 0; 1213 return 0;
1214 } 1214 }
1215 1215
1216 static int soc_link_dai_widgets(struct snd_soc_card *card, 1216 static int soc_link_dai_widgets(struct snd_soc_card *card,
1217 struct snd_soc_dai_link *dai_link, 1217 struct snd_soc_dai_link *dai_link,
1218 struct snd_soc_pcm_runtime *rtd) 1218 struct snd_soc_pcm_runtime *rtd)
1219 { 1219 {
1220 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 1220 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1221 struct snd_soc_dai *codec_dai = rtd->codec_dai; 1221 struct snd_soc_dai *codec_dai = rtd->codec_dai;
1222 struct snd_soc_dapm_widget *play_w, *capture_w; 1222 struct snd_soc_dapm_widget *play_w, *capture_w;
1223 int ret; 1223 int ret;
1224 1224
1225 if (rtd->num_codecs > 1) 1225 if (rtd->num_codecs > 1)
1226 dev_warn(card->dev, "ASoC: Multiple codecs not supported yet\n"); 1226 dev_warn(card->dev, "ASoC: Multiple codecs not supported yet\n");
1227 1227
1228 /* link the DAI widgets */ 1228 /* link the DAI widgets */
1229 play_w = codec_dai->playback_widget; 1229 play_w = codec_dai->playback_widget;
1230 capture_w = cpu_dai->capture_widget; 1230 capture_w = cpu_dai->capture_widget;
1231 if (play_w && capture_w) { 1231 if (play_w && capture_w) {
1232 ret = snd_soc_dapm_new_pcm(card, dai_link->params, 1232 ret = snd_soc_dapm_new_pcm(card, dai_link->params,
1233 capture_w, play_w); 1233 capture_w, play_w);
1234 if (ret != 0) { 1234 if (ret != 0) {
1235 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", 1235 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
1236 play_w->name, capture_w->name, ret); 1236 play_w->name, capture_w->name, ret);
1237 return ret; 1237 return ret;
1238 } 1238 }
1239 } 1239 }
1240 1240
1241 play_w = cpu_dai->playback_widget; 1241 play_w = cpu_dai->playback_widget;
1242 capture_w = codec_dai->capture_widget; 1242 capture_w = codec_dai->capture_widget;
1243 if (play_w && capture_w) { 1243 if (play_w && capture_w) {
1244 ret = snd_soc_dapm_new_pcm(card, dai_link->params, 1244 ret = snd_soc_dapm_new_pcm(card, dai_link->params,
1245 capture_w, play_w); 1245 capture_w, play_w);
1246 if (ret != 0) { 1246 if (ret != 0) {
1247 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", 1247 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
1248 play_w->name, capture_w->name, ret); 1248 play_w->name, capture_w->name, ret);
1249 return ret; 1249 return ret;
1250 } 1250 }
1251 } 1251 }
1252 1252
1253 return 0; 1253 return 0;
1254 } 1254 }
1255 1255
1256 static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) 1256 static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1257 { 1257 {
1258 struct snd_soc_dai_link *dai_link = &card->dai_link[num]; 1258 struct snd_soc_dai_link *dai_link = &card->dai_link[num];
1259 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; 1259 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
1260 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 1260 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1261 int i, ret; 1261 int i, ret;
1262 1262
1263 dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", 1263 dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n",
1264 card->name, num, order); 1264 card->name, num, order);
1265 1265
1266 /* set default power off timeout */ 1266 /* set default power off timeout */
1267 rtd->pmdown_time = pmdown_time; 1267 rtd->pmdown_time = pmdown_time;
1268 1268
1269 ret = soc_probe_dai(cpu_dai, order); 1269 ret = soc_probe_dai(cpu_dai, order);
1270 if (ret) 1270 if (ret)
1271 return ret; 1271 return ret;
1272 1272
1273 /* probe the CODEC DAI */ 1273 /* probe the CODEC DAI */
1274 for (i = 0; i < rtd->num_codecs; i++) { 1274 for (i = 0; i < rtd->num_codecs; i++) {
1275 ret = soc_probe_dai(rtd->codec_dais[i], order); 1275 ret = soc_probe_dai(rtd->codec_dais[i], order);
1276 if (ret) 1276 if (ret)
1277 return ret; 1277 return ret;
1278 } 1278 }
1279 1279
1280 /* complete DAI probe during last probe */ 1280 /* complete DAI probe during last probe */
1281 if (order != SND_SOC_COMP_ORDER_LAST) 1281 if (order != SND_SOC_COMP_ORDER_LAST)
1282 return 0; 1282 return 0;
1283 1283
1284 /* do machine specific initialization */ 1284 /* do machine specific initialization */
1285 if (dai_link->init) { 1285 if (dai_link->init) {
1286 ret = dai_link->init(rtd); 1286 ret = dai_link->init(rtd);
1287 if (ret < 0) { 1287 if (ret < 0) {
1288 dev_err(card->dev, "ASoC: failed to init %s: %d\n", 1288 dev_err(card->dev, "ASoC: failed to init %s: %d\n",
1289 dai_link->name, ret); 1289 dai_link->name, ret);
1290 return ret; 1290 return ret;
1291 } 1291 }
1292 } 1292 }
1293 1293
1294 ret = soc_post_component_init(rtd, dai_link->name); 1294 ret = soc_post_component_init(rtd, dai_link->name);
1295 if (ret) 1295 if (ret)
1296 return ret; 1296 return ret;
1297 1297
1298 #ifdef CONFIG_DEBUG_FS 1298 #ifdef CONFIG_DEBUG_FS
1299 /* add DPCM sysfs entries */ 1299 /* add DPCM sysfs entries */
1300 if (dai_link->dynamic) { 1300 if (dai_link->dynamic) {
1301 ret = soc_dpcm_debugfs_add(rtd); 1301 ret = soc_dpcm_debugfs_add(rtd);
1302 if (ret < 0) { 1302 if (ret < 0) {
1303 dev_err(rtd->dev, 1303 dev_err(rtd->dev,
1304 "ASoC: failed to add dpcm sysfs entries: %d\n", 1304 "ASoC: failed to add dpcm sysfs entries: %d\n",
1305 ret); 1305 ret);
1306 return ret; 1306 return ret;
1307 } 1307 }
1308 } 1308 }
1309 #endif 1309 #endif
1310 1310
1311 ret = device_create_file(rtd->dev, &dev_attr_pmdown_time); 1311 ret = device_create_file(rtd->dev, &dev_attr_pmdown_time);
1312 if (ret < 0) 1312 if (ret < 0)
1313 dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n", 1313 dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n",
1314 ret); 1314 ret);
1315 1315
1316 if (cpu_dai->driver->compress_dai) { 1316 if (cpu_dai->driver->compress_dai) {
1317 /*create compress_device"*/ 1317 /*create compress_device"*/
1318 ret = soc_new_compress(rtd, num); 1318 ret = soc_new_compress(rtd, num);
1319 if (ret < 0) { 1319 if (ret < 0) {
1320 dev_err(card->dev, "ASoC: can't create compress %s\n", 1320 dev_err(card->dev, "ASoC: can't create compress %s\n",
1321 dai_link->stream_name); 1321 dai_link->stream_name);
1322 return ret; 1322 return ret;
1323 } 1323 }
1324 } else { 1324 } else {
1325 1325
1326 if (!dai_link->params) { 1326 if (!dai_link->params) {
1327 /* create the pcm */ 1327 /* create the pcm */
1328 ret = soc_new_pcm(rtd, num); 1328 ret = soc_new_pcm(rtd, num);
1329 if (ret < 0) { 1329 if (ret < 0) {
1330 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", 1330 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n",
1331 dai_link->stream_name, ret); 1331 dai_link->stream_name, ret);
1332 return ret; 1332 return ret;
1333 } 1333 }
1334 } else { 1334 } else {
1335 INIT_DELAYED_WORK(&rtd->delayed_work, 1335 INIT_DELAYED_WORK(&rtd->delayed_work,
1336 codec2codec_close_delayed_work); 1336 codec2codec_close_delayed_work);
1337 1337
1338 /* link the DAI widgets */ 1338 /* link the DAI widgets */
1339 ret = soc_link_dai_widgets(card, dai_link, rtd); 1339 ret = soc_link_dai_widgets(card, dai_link, rtd);
1340 if (ret) 1340 if (ret)
1341 return ret; 1341 return ret;
1342 } 1342 }
1343 } 1343 }
1344 1344
1345 return 0; 1345 return 0;
1346 } 1346 }
1347 1347
1348 static int soc_bind_aux_dev(struct snd_soc_card *card, int num) 1348 static int soc_bind_aux_dev(struct snd_soc_card *card, int num)
1349 { 1349 {
1350 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; 1350 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1351 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; 1351 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1352 const char *name = aux_dev->codec_name; 1352 const char *name = aux_dev->codec_name;
1353 1353
1354 rtd->component = soc_find_component(aux_dev->codec_of_node, name); 1354 rtd->component = soc_find_component(aux_dev->codec_of_node, name);
1355 if (!rtd->component) { 1355 if (!rtd->component) {
1356 if (aux_dev->codec_of_node) 1356 if (aux_dev->codec_of_node)
1357 name = of_node_full_name(aux_dev->codec_of_node); 1357 name = of_node_full_name(aux_dev->codec_of_node);
1358 1358
1359 dev_err(card->dev, "ASoC: %s not registered\n", name); 1359 dev_err(card->dev, "ASoC: %s not registered\n", name);
1360 return -EPROBE_DEFER; 1360 return -EPROBE_DEFER;
1361 } 1361 }
1362 1362
1363 /* 1363 /*
1364 * Some places still reference rtd->codec, so we have to keep that 1364 * Some places still reference rtd->codec, so we have to keep that
1365 * initialized if the component is a CODEC. Once all those references 1365 * initialized if the component is a CODEC. Once all those references
1366 * have been removed, this code can be removed as well. 1366 * have been removed, this code can be removed as well.
1367 */ 1367 */
1368 rtd->codec = rtd->component->codec; 1368 rtd->codec = rtd->component->codec;
1369 1369
1370 return 0; 1370 return 0;
1371 } 1371 }
1372 1372
1373 static int soc_probe_aux_dev(struct snd_soc_card *card, int num) 1373 static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
1374 { 1374 {
1375 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; 1375 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1376 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; 1376 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1377 int ret; 1377 int ret;
1378 1378
1379 ret = soc_probe_component(card, rtd->component); 1379 ret = soc_probe_component(card, rtd->component);
1380 if (ret < 0) 1380 if (ret < 0)
1381 return ret; 1381 return ret;
1382 1382
1383 /* do machine specific initialization */ 1383 /* do machine specific initialization */
1384 if (aux_dev->init) { 1384 if (aux_dev->init) {
1385 ret = aux_dev->init(rtd->component); 1385 ret = aux_dev->init(rtd->component);
1386 if (ret < 0) { 1386 if (ret < 0) {
1387 dev_err(card->dev, "ASoC: failed to init %s: %d\n", 1387 dev_err(card->dev, "ASoC: failed to init %s: %d\n",
1388 aux_dev->name, ret); 1388 aux_dev->name, ret);
1389 return ret; 1389 return ret;
1390 } 1390 }
1391 } 1391 }
1392 1392
1393 return soc_post_component_init(rtd, aux_dev->name); 1393 return soc_post_component_init(rtd, aux_dev->name);
1394 } 1394 }
1395 1395
1396 static void soc_remove_aux_dev(struct snd_soc_card *card, int num) 1396 static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
1397 { 1397 {
1398 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; 1398 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1399 struct snd_soc_component *component = rtd->component; 1399 struct snd_soc_component *component = rtd->component;
1400 1400
1401 /* unregister the rtd device */ 1401 /* unregister the rtd device */
1402 if (rtd->dev_registered) { 1402 if (rtd->dev_registered) {
1403 device_remove_file(rtd->dev, &dev_attr_codec_reg); 1403 device_remove_file(rtd->dev, &dev_attr_codec_reg);
1404 device_unregister(rtd->dev); 1404 device_unregister(rtd->dev);
1405 rtd->dev_registered = 0; 1405 rtd->dev_registered = 0;
1406 } 1406 }
1407 1407
1408 if (component && component->probed) 1408 if (component && component->probed)
1409 soc_remove_component(component); 1409 soc_remove_component(component);
1410 } 1410 }
1411 1411
1412 static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) 1412 static int snd_soc_init_codec_cache(struct snd_soc_codec *codec)
1413 { 1413 {
1414 int ret; 1414 int ret;
1415 1415
1416 if (codec->cache_init) 1416 if (codec->cache_init)
1417 return 0; 1417 return 0;
1418 1418
1419 ret = snd_soc_cache_init(codec); 1419 ret = snd_soc_cache_init(codec);
1420 if (ret < 0) { 1420 if (ret < 0) {
1421 dev_err(codec->dev, 1421 dev_err(codec->dev,
1422 "ASoC: Failed to set cache compression type: %d\n", 1422 "ASoC: Failed to set cache compression type: %d\n",
1423 ret); 1423 ret);
1424 return ret; 1424 return ret;
1425 } 1425 }
1426 codec->cache_init = 1; 1426 codec->cache_init = 1;
1427 return 0; 1427 return 0;
1428 } 1428 }
1429 1429
1430 static int snd_soc_instantiate_card(struct snd_soc_card *card) 1430 static int snd_soc_instantiate_card(struct snd_soc_card *card)
1431 { 1431 {
1432 struct snd_soc_codec *codec; 1432 struct snd_soc_codec *codec;
1433 struct snd_soc_dai_link *dai_link; 1433 struct snd_soc_dai_link *dai_link;
1434 int ret, i, order, dai_fmt; 1434 int ret, i, order, dai_fmt;
1435 1435
1436 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); 1436 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
1437 1437
1438 /* bind DAIs */ 1438 /* bind DAIs */
1439 for (i = 0; i < card->num_links; i++) { 1439 for (i = 0; i < card->num_links; i++) {
1440 ret = soc_bind_dai_link(card, i); 1440 ret = soc_bind_dai_link(card, i);
1441 if (ret != 0) 1441 if (ret != 0)
1442 goto base_error; 1442 goto base_error;
1443 } 1443 }
1444 1444
1445 /* bind aux_devs too */ 1445 /* bind aux_devs too */
1446 for (i = 0; i < card->num_aux_devs; i++) { 1446 for (i = 0; i < card->num_aux_devs; i++) {
1447 ret = soc_bind_aux_dev(card, i); 1447 ret = soc_bind_aux_dev(card, i);
1448 if (ret != 0) 1448 if (ret != 0)
1449 goto base_error; 1449 goto base_error;
1450 } 1450 }
1451 1451
1452 /* initialize the register cache for each available codec */ 1452 /* initialize the register cache for each available codec */
1453 list_for_each_entry(codec, &codec_list, list) { 1453 list_for_each_entry(codec, &codec_list, list) {
1454 if (codec->cache_init) 1454 if (codec->cache_init)
1455 continue; 1455 continue;
1456 ret = snd_soc_init_codec_cache(codec); 1456 ret = snd_soc_init_codec_cache(codec);
1457 if (ret < 0) 1457 if (ret < 0)
1458 goto base_error; 1458 goto base_error;
1459 } 1459 }
1460 1460
1461 /* card bind complete so register a sound card */ 1461 /* card bind complete so register a sound card */
1462 ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, 1462 ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
1463 card->owner, 0, &card->snd_card); 1463 card->owner, 0, &card->snd_card);
1464 if (ret < 0) { 1464 if (ret < 0) {
1465 dev_err(card->dev, 1465 dev_err(card->dev,
1466 "ASoC: can't create sound card for card %s: %d\n", 1466 "ASoC: can't create sound card for card %s: %d\n",
1467 card->name, ret); 1467 card->name, ret);
1468 goto base_error; 1468 goto base_error;
1469 } 1469 }
1470 1470
1471 card->dapm.bias_level = SND_SOC_BIAS_OFF; 1471 card->dapm.bias_level = SND_SOC_BIAS_OFF;
1472 card->dapm.dev = card->dev; 1472 card->dapm.dev = card->dev;
1473 card->dapm.card = card; 1473 card->dapm.card = card;
1474 list_add(&card->dapm.list, &card->dapm_list); 1474 list_add(&card->dapm.list, &card->dapm_list);
1475 1475
1476 #ifdef CONFIG_DEBUG_FS 1476 #ifdef CONFIG_DEBUG_FS
1477 snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root); 1477 snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root);
1478 #endif 1478 #endif
1479 1479
1480 #ifdef CONFIG_PM_SLEEP 1480 #ifdef CONFIG_PM_SLEEP
1481 /* deferred resume work */ 1481 /* deferred resume work */
1482 INIT_WORK(&card->deferred_resume_work, soc_resume_deferred); 1482 INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
1483 #endif 1483 #endif
1484 1484
1485 if (card->dapm_widgets) 1485 if (card->dapm_widgets)
1486 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets, 1486 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
1487 card->num_dapm_widgets); 1487 card->num_dapm_widgets);
1488 1488
1489 /* initialise the sound card only once */ 1489 /* initialise the sound card only once */
1490 if (card->probe) { 1490 if (card->probe) {
1491 ret = card->probe(card); 1491 ret = card->probe(card);
1492 if (ret < 0) 1492 if (ret < 0)
1493 goto card_probe_error; 1493 goto card_probe_error;
1494 } 1494 }
1495 1495
1496 /* probe all components used by DAI links on this card */ 1496 /* probe all components used by DAI links on this card */
1497 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; 1497 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
1498 order++) { 1498 order++) {
1499 for (i = 0; i < card->num_links; i++) { 1499 for (i = 0; i < card->num_links; i++) {
1500 ret = soc_probe_link_components(card, i, order); 1500 ret = soc_probe_link_components(card, i, order);
1501 if (ret < 0) { 1501 if (ret < 0) {
1502 dev_err(card->dev, 1502 dev_err(card->dev,
1503 "ASoC: failed to instantiate card %d\n", 1503 "ASoC: failed to instantiate card %d\n",
1504 ret); 1504 ret);
1505 goto probe_dai_err; 1505 goto probe_dai_err;
1506 } 1506 }
1507 } 1507 }
1508 } 1508 }
1509 1509
1510 /* probe all DAI links on this card */ 1510 /* probe all DAI links on this card */
1511 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; 1511 for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
1512 order++) { 1512 order++) {
1513 for (i = 0; i < card->num_links; i++) { 1513 for (i = 0; i < card->num_links; i++) {
1514 ret = soc_probe_link_dais(card, i, order); 1514 ret = soc_probe_link_dais(card, i, order);
1515 if (ret < 0) { 1515 if (ret < 0) {
1516 dev_err(card->dev, 1516 dev_err(card->dev,
1517 "ASoC: failed to instantiate card %d\n", 1517 "ASoC: failed to instantiate card %d\n",
1518 ret); 1518 ret);
1519 goto probe_dai_err; 1519 goto probe_dai_err;
1520 } 1520 }
1521 } 1521 }
1522 } 1522 }
1523 1523
1524 for (i = 0; i < card->num_aux_devs; i++) { 1524 for (i = 0; i < card->num_aux_devs; i++) {
1525 ret = soc_probe_aux_dev(card, i); 1525 ret = soc_probe_aux_dev(card, i);
1526 if (ret < 0) { 1526 if (ret < 0) {
1527 dev_err(card->dev, 1527 dev_err(card->dev,
1528 "ASoC: failed to add auxiliary devices %d\n", 1528 "ASoC: failed to add auxiliary devices %d\n",
1529 ret); 1529 ret);
1530 goto probe_aux_dev_err; 1530 goto probe_aux_dev_err;
1531 } 1531 }
1532 } 1532 }
1533 1533
1534 snd_soc_dapm_link_dai_widgets(card); 1534 snd_soc_dapm_link_dai_widgets(card);
1535 snd_soc_dapm_connect_dai_link_widgets(card); 1535 snd_soc_dapm_connect_dai_link_widgets(card);
1536 1536
1537 if (card->controls) 1537 if (card->controls)
1538 snd_soc_add_card_controls(card, card->controls, card->num_controls); 1538 snd_soc_add_card_controls(card, card->controls, card->num_controls);
1539 1539
1540 if (card->dapm_routes) 1540 if (card->dapm_routes)
1541 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, 1541 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
1542 card->num_dapm_routes); 1542 card->num_dapm_routes);
1543 1543
1544 for (i = 0; i < card->num_links; i++) { 1544 for (i = 0; i < card->num_links; i++) {
1545 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; 1545 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
1546 dai_link = &card->dai_link[i]; 1546 dai_link = &card->dai_link[i];
1547 dai_fmt = dai_link->dai_fmt; 1547 dai_fmt = dai_link->dai_fmt;
1548 1548
1549 if (dai_fmt) { 1549 if (dai_fmt) {
1550 struct snd_soc_dai **codec_dais = rtd->codec_dais; 1550 struct snd_soc_dai **codec_dais = rtd->codec_dais;
1551 int j; 1551 int j;
1552 1552
1553 for (j = 0; j < rtd->num_codecs; j++) { 1553 for (j = 0; j < rtd->num_codecs; j++) {
1554 struct snd_soc_dai *codec_dai = codec_dais[j]; 1554 struct snd_soc_dai *codec_dai = codec_dais[j];
1555 1555
1556 ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); 1556 ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
1557 if (ret != 0 && ret != -ENOTSUPP) 1557 if (ret != 0 && ret != -ENOTSUPP)
1558 dev_warn(codec_dai->dev, 1558 dev_warn(codec_dai->dev,
1559 "ASoC: Failed to set DAI format: %d\n", 1559 "ASoC: Failed to set DAI format: %d\n",
1560 ret); 1560 ret);
1561 } 1561 }
1562 } 1562 }
1563 1563
1564 /* If this is a regular CPU link there will be a platform */ 1564 /* If this is a regular CPU link there will be a platform */
1565 if (dai_fmt && 1565 if (dai_fmt &&
1566 (dai_link->platform_name || dai_link->platform_of_node)) { 1566 (dai_link->platform_name || dai_link->platform_of_node)) {
1567 ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai, 1567 ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai,
1568 dai_fmt); 1568 dai_fmt);
1569 if (ret != 0 && ret != -ENOTSUPP) 1569 if (ret != 0 && ret != -ENOTSUPP)
1570 dev_warn(card->rtd[i].cpu_dai->dev, 1570 dev_warn(card->rtd[i].cpu_dai->dev,
1571 "ASoC: Failed to set DAI format: %d\n", 1571 "ASoC: Failed to set DAI format: %d\n",
1572 ret); 1572 ret);
1573 } else if (dai_fmt) { 1573 } else if (dai_fmt) {
1574 /* Flip the polarity for the "CPU" end */ 1574 /* Flip the polarity for the "CPU" end */
1575 dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK; 1575 dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
1576 switch (dai_link->dai_fmt & 1576 switch (dai_link->dai_fmt &
1577 SND_SOC_DAIFMT_MASTER_MASK) { 1577 SND_SOC_DAIFMT_MASTER_MASK) {
1578 case SND_SOC_DAIFMT_CBM_CFM: 1578 case SND_SOC_DAIFMT_CBM_CFM:
1579 dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; 1579 dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
1580 break; 1580 break;
1581 case SND_SOC_DAIFMT_CBM_CFS: 1581 case SND_SOC_DAIFMT_CBM_CFS:
1582 dai_fmt |= SND_SOC_DAIFMT_CBS_CFM; 1582 dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
1583 break; 1583 break;
1584 case SND_SOC_DAIFMT_CBS_CFM: 1584 case SND_SOC_DAIFMT_CBS_CFM:
1585 dai_fmt |= SND_SOC_DAIFMT_CBM_CFS; 1585 dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
1586 break; 1586 break;
1587 case SND_SOC_DAIFMT_CBS_CFS: 1587 case SND_SOC_DAIFMT_CBS_CFS:
1588 dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; 1588 dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
1589 break; 1589 break;
1590 } 1590 }
1591 1591
1592 ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai, 1592 ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai,
1593 dai_fmt); 1593 dai_fmt);
1594 if (ret != 0 && ret != -ENOTSUPP) 1594 if (ret != 0 && ret != -ENOTSUPP)
1595 dev_warn(card->rtd[i].cpu_dai->dev, 1595 dev_warn(card->rtd[i].cpu_dai->dev,
1596 "ASoC: Failed to set DAI format: %d\n", 1596 "ASoC: Failed to set DAI format: %d\n",
1597 ret); 1597 ret);
1598 } 1598 }
1599 } 1599 }
1600 1600
1601 snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname), 1601 snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
1602 "%s", card->name); 1602 "%s", card->name);
1603 snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), 1603 snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
1604 "%s", card->long_name ? card->long_name : card->name); 1604 "%s", card->long_name ? card->long_name : card->name);
1605 snprintf(card->snd_card->driver, sizeof(card->snd_card->driver), 1605 snprintf(card->snd_card->driver, sizeof(card->snd_card->driver),
1606 "%s", card->driver_name ? card->driver_name : card->name); 1606 "%s", card->driver_name ? card->driver_name : card->name);
1607 for (i = 0; i < ARRAY_SIZE(card->snd_card->driver); i++) { 1607 for (i = 0; i < ARRAY_SIZE(card->snd_card->driver); i++) {
1608 switch (card->snd_card->driver[i]) { 1608 switch (card->snd_card->driver[i]) {
1609 case '_': 1609 case '_':
1610 case '-': 1610 case '-':
1611 case '\0': 1611 case '\0':
1612 break; 1612 break;
1613 default: 1613 default:
1614 if (!isalnum(card->snd_card->driver[i])) 1614 if (!isalnum(card->snd_card->driver[i]))
1615 card->snd_card->driver[i] = '_'; 1615 card->snd_card->driver[i] = '_';
1616 break; 1616 break;
1617 } 1617 }
1618 } 1618 }
1619 1619
1620 if (card->late_probe) { 1620 if (card->late_probe) {
1621 ret = card->late_probe(card); 1621 ret = card->late_probe(card);
1622 if (ret < 0) { 1622 if (ret < 0) {
1623 dev_err(card->dev, "ASoC: %s late_probe() failed: %d\n", 1623 dev_err(card->dev, "ASoC: %s late_probe() failed: %d\n",
1624 card->name, ret); 1624 card->name, ret);
1625 goto probe_aux_dev_err; 1625 goto probe_aux_dev_err;
1626 } 1626 }
1627 } 1627 }
1628 1628
1629 if (card->fully_routed) 1629 if (card->fully_routed)
1630 snd_soc_dapm_auto_nc_pins(card); 1630 snd_soc_dapm_auto_nc_pins(card);
1631 1631
1632 snd_soc_dapm_new_widgets(card); 1632 snd_soc_dapm_new_widgets(card);
1633 1633
1634 ret = snd_card_register(card->snd_card); 1634 ret = snd_card_register(card->snd_card);
1635 if (ret < 0) { 1635 if (ret < 0) {
1636 dev_err(card->dev, "ASoC: failed to register soundcard %d\n", 1636 dev_err(card->dev, "ASoC: failed to register soundcard %d\n",
1637 ret); 1637 ret);
1638 goto probe_aux_dev_err; 1638 goto probe_aux_dev_err;
1639 } 1639 }
1640 1640
1641 card->instantiated = 1; 1641 card->instantiated = 1;
1642 snd_soc_dapm_sync(&card->dapm); 1642 snd_soc_dapm_sync(&card->dapm);
1643 mutex_unlock(&card->mutex); 1643 mutex_unlock(&card->mutex);
1644 1644
1645 return 0; 1645 return 0;
1646 1646
1647 probe_aux_dev_err: 1647 probe_aux_dev_err:
1648 for (i = 0; i < card->num_aux_devs; i++) 1648 for (i = 0; i < card->num_aux_devs; i++)
1649 soc_remove_aux_dev(card, i); 1649 soc_remove_aux_dev(card, i);
1650 1650
1651 probe_dai_err: 1651 probe_dai_err:
1652 soc_remove_dai_links(card); 1652 soc_remove_dai_links(card);
1653 1653
1654 card_probe_error: 1654 card_probe_error:
1655 if (card->remove) 1655 if (card->remove)
1656 card->remove(card); 1656 card->remove(card);
1657 1657
1658 snd_card_free(card->snd_card); 1658 snd_card_free(card->snd_card);
1659 1659
1660 base_error: 1660 base_error:
1661 mutex_unlock(&card->mutex); 1661 mutex_unlock(&card->mutex);
1662 1662
1663 return ret; 1663 return ret;
1664 } 1664 }
1665 1665
1666 /* probes a new socdev */ 1666 /* probes a new socdev */
1667 static int soc_probe(struct platform_device *pdev) 1667 static int soc_probe(struct platform_device *pdev)
1668 { 1668 {
1669 struct snd_soc_card *card = platform_get_drvdata(pdev); 1669 struct snd_soc_card *card = platform_get_drvdata(pdev);
1670 1670
1671 /* 1671 /*
1672 * no card, so machine driver should be registering card 1672 * no card, so machine driver should be registering card
1673 * we should not be here in that case so ret error 1673 * we should not be here in that case so ret error
1674 */ 1674 */
1675 if (!card) 1675 if (!card)
1676 return -EINVAL; 1676 return -EINVAL;
1677 1677
1678 dev_warn(&pdev->dev, 1678 dev_warn(&pdev->dev,
1679 "ASoC: machine %s should use snd_soc_register_card()\n", 1679 "ASoC: machine %s should use snd_soc_register_card()\n",
1680 card->name); 1680 card->name);
1681 1681
1682 /* Bodge while we unpick instantiation */ 1682 /* Bodge while we unpick instantiation */
1683 card->dev = &pdev->dev; 1683 card->dev = &pdev->dev;
1684 1684
1685 return snd_soc_register_card(card); 1685 return snd_soc_register_card(card);
1686 } 1686 }
1687 1687
1688 static int soc_cleanup_card_resources(struct snd_soc_card *card) 1688 static int soc_cleanup_card_resources(struct snd_soc_card *card)
1689 { 1689 {
1690 int i; 1690 int i;
1691 1691
1692 /* make sure any delayed work runs */ 1692 /* make sure any delayed work runs */
1693 for (i = 0; i < card->num_rtd; i++) { 1693 for (i = 0; i < card->num_rtd; i++) {
1694 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; 1694 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
1695 flush_delayed_work(&rtd->delayed_work); 1695 flush_delayed_work(&rtd->delayed_work);
1696 } 1696 }
1697 1697
1698 /* remove auxiliary devices */ 1698 /* remove auxiliary devices */
1699 for (i = 0; i < card->num_aux_devs; i++) 1699 for (i = 0; i < card->num_aux_devs; i++)
1700 soc_remove_aux_dev(card, i); 1700 soc_remove_aux_dev(card, i);
1701 1701
1702 /* remove and free each DAI */ 1702 /* remove and free each DAI */
1703 soc_remove_dai_links(card); 1703 soc_remove_dai_links(card);
1704 1704
1705 soc_cleanup_card_debugfs(card); 1705 soc_cleanup_card_debugfs(card);
1706 1706
1707 /* remove the card */ 1707 /* remove the card */
1708 if (card->remove) 1708 if (card->remove)
1709 card->remove(card); 1709 card->remove(card);
1710 1710
1711 snd_soc_dapm_free(&card->dapm); 1711 snd_soc_dapm_free(&card->dapm);
1712 1712
1713 snd_card_free(card->snd_card); 1713 snd_card_free(card->snd_card);
1714 return 0; 1714 return 0;
1715 1715
1716 } 1716 }
1717 1717
1718 /* removes a socdev */ 1718 /* removes a socdev */
1719 static int soc_remove(struct platform_device *pdev) 1719 static int soc_remove(struct platform_device *pdev)
1720 { 1720 {
1721 struct snd_soc_card *card = platform_get_drvdata(pdev); 1721 struct snd_soc_card *card = platform_get_drvdata(pdev);
1722 1722
1723 snd_soc_unregister_card(card); 1723 snd_soc_unregister_card(card);
1724 return 0; 1724 return 0;
1725 } 1725 }
1726 1726
1727 int snd_soc_poweroff(struct device *dev) 1727 int snd_soc_poweroff(struct device *dev)
1728 { 1728 {
1729 struct snd_soc_card *card = dev_get_drvdata(dev); 1729 struct snd_soc_card *card = dev_get_drvdata(dev);
1730 int i; 1730 int i;
1731 1731
1732 if (!card->instantiated) 1732 if (!card->instantiated)
1733 return 0; 1733 return 0;
1734 1734
1735 /* Flush out pmdown_time work - we actually do want to run it 1735 /* Flush out pmdown_time work - we actually do want to run it
1736 * now, we're shutting down so no imminent restart. */ 1736 * now, we're shutting down so no imminent restart. */
1737 for (i = 0; i < card->num_rtd; i++) { 1737 for (i = 0; i < card->num_rtd; i++) {
1738 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; 1738 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
1739 flush_delayed_work(&rtd->delayed_work); 1739 flush_delayed_work(&rtd->delayed_work);
1740 } 1740 }
1741 1741
1742 snd_soc_dapm_shutdown(card); 1742 snd_soc_dapm_shutdown(card);
1743 1743
1744 /* deactivate pins to sleep state */ 1744 /* deactivate pins to sleep state */
1745 for (i = 0; i < card->num_rtd; i++) { 1745 for (i = 0; i < card->num_rtd; i++) {
1746 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; 1746 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
1747 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 1747 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1748 int j; 1748 int j;
1749 1749
1750 pinctrl_pm_select_sleep_state(cpu_dai->dev); 1750 pinctrl_pm_select_sleep_state(cpu_dai->dev);
1751 for (j = 0; j < rtd->num_codecs; j++) { 1751 for (j = 0; j < rtd->num_codecs; j++) {
1752 struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; 1752 struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
1753 pinctrl_pm_select_sleep_state(codec_dai->dev); 1753 pinctrl_pm_select_sleep_state(codec_dai->dev);
1754 } 1754 }
1755 } 1755 }
1756 1756
1757 return 0; 1757 return 0;
1758 } 1758 }
1759 EXPORT_SYMBOL_GPL(snd_soc_poweroff); 1759 EXPORT_SYMBOL_GPL(snd_soc_poweroff);
1760 1760
1761 const struct dev_pm_ops snd_soc_pm_ops = { 1761 const struct dev_pm_ops snd_soc_pm_ops = {
1762 .suspend = snd_soc_suspend, 1762 .suspend = snd_soc_suspend,
1763 .resume = snd_soc_resume, 1763 .resume = snd_soc_resume,
1764 .freeze = snd_soc_suspend, 1764 .freeze = snd_soc_suspend,
1765 .thaw = snd_soc_resume, 1765 .thaw = snd_soc_resume,
1766 .poweroff = snd_soc_poweroff, 1766 .poweroff = snd_soc_poweroff,
1767 .restore = snd_soc_resume, 1767 .restore = snd_soc_resume,
1768 }; 1768 };
1769 EXPORT_SYMBOL_GPL(snd_soc_pm_ops); 1769 EXPORT_SYMBOL_GPL(snd_soc_pm_ops);
1770 1770
1771 /* ASoC platform driver */ 1771 /* ASoC platform driver */
1772 static struct platform_driver soc_driver = { 1772 static struct platform_driver soc_driver = {
1773 .driver = { 1773 .driver = {
1774 .name = "soc-audio", 1774 .name = "soc-audio",
1775 .pm = &snd_soc_pm_ops, 1775 .pm = &snd_soc_pm_ops,
1776 }, 1776 },
1777 .probe = soc_probe, 1777 .probe = soc_probe,
1778 .remove = soc_remove, 1778 .remove = soc_remove,
1779 }; 1779 };
1780 1780
1781 /** 1781 /**
1782 * snd_soc_cnew - create new control 1782 * snd_soc_cnew - create new control
1783 * @_template: control template 1783 * @_template: control template
1784 * @data: control private data 1784 * @data: control private data
1785 * @long_name: control long name 1785 * @long_name: control long name
1786 * @prefix: control name prefix 1786 * @prefix: control name prefix
1787 * 1787 *
1788 * Create a new mixer control from a template control. 1788 * Create a new mixer control from a template control.
1789 * 1789 *
1790 * Returns 0 for success, else error. 1790 * Returns 0 for success, else error.
1791 */ 1791 */
1792 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, 1792 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
1793 void *data, const char *long_name, 1793 void *data, const char *long_name,
1794 const char *prefix) 1794 const char *prefix)
1795 { 1795 {
1796 struct snd_kcontrol_new template; 1796 struct snd_kcontrol_new template;
1797 struct snd_kcontrol *kcontrol; 1797 struct snd_kcontrol *kcontrol;
1798 char *name = NULL; 1798 char *name = NULL;
1799 1799
1800 memcpy(&template, _template, sizeof(template)); 1800 memcpy(&template, _template, sizeof(template));
1801 template.index = 0; 1801 template.index = 0;
1802 1802
1803 if (!long_name) 1803 if (!long_name)
1804 long_name = template.name; 1804 long_name = template.name;
1805 1805
1806 if (prefix) { 1806 if (prefix) {
1807 name = kasprintf(GFP_KERNEL, "%s %s", prefix, long_name); 1807 name = kasprintf(GFP_KERNEL, "%s %s", prefix, long_name);
1808 if (!name) 1808 if (!name)
1809 return NULL; 1809 return NULL;
1810 1810
1811 template.name = name; 1811 template.name = name;
1812 } else { 1812 } else {
1813 template.name = long_name; 1813 template.name = long_name;
1814 } 1814 }
1815 1815
1816 kcontrol = snd_ctl_new1(&template, data); 1816 kcontrol = snd_ctl_new1(&template, data);
1817 1817
1818 kfree(name); 1818 kfree(name);
1819 1819
1820 return kcontrol; 1820 return kcontrol;
1821 } 1821 }
1822 EXPORT_SYMBOL_GPL(snd_soc_cnew); 1822 EXPORT_SYMBOL_GPL(snd_soc_cnew);
1823 1823
1824 static int snd_soc_add_controls(struct snd_card *card, struct device *dev, 1824 static int snd_soc_add_controls(struct snd_card *card, struct device *dev,
1825 const struct snd_kcontrol_new *controls, int num_controls, 1825 const struct snd_kcontrol_new *controls, int num_controls,
1826 const char *prefix, void *data) 1826 const char *prefix, void *data)
1827 { 1827 {
1828 int err, i; 1828 int err, i;
1829 1829
1830 for (i = 0; i < num_controls; i++) { 1830 for (i = 0; i < num_controls; i++) {
1831 const struct snd_kcontrol_new *control = &controls[i]; 1831 const struct snd_kcontrol_new *control = &controls[i];
1832 err = snd_ctl_add(card, snd_soc_cnew(control, data, 1832 err = snd_ctl_add(card, snd_soc_cnew(control, data,
1833 control->name, prefix)); 1833 control->name, prefix));
1834 if (err < 0) { 1834 if (err < 0) {
1835 dev_err(dev, "ASoC: Failed to add %s: %d\n", 1835 dev_err(dev, "ASoC: Failed to add %s: %d\n",
1836 control->name, err); 1836 control->name, err);
1837 return err; 1837 return err;
1838 } 1838 }
1839 } 1839 }
1840 1840
1841 return 0; 1841 return 0;
1842 } 1842 }
1843 1843
1844 struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, 1844 struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
1845 const char *name) 1845 const char *name)
1846 { 1846 {
1847 struct snd_card *card = soc_card->snd_card; 1847 struct snd_card *card = soc_card->snd_card;
1848 struct snd_kcontrol *kctl; 1848 struct snd_kcontrol *kctl;
1849 1849
1850 if (unlikely(!name)) 1850 if (unlikely(!name))
1851 return NULL; 1851 return NULL;
1852 1852
1853 list_for_each_entry(kctl, &card->controls, list) 1853 list_for_each_entry(kctl, &card->controls, list)
1854 if (!strncmp(kctl->id.name, name, sizeof(kctl->id.name))) 1854 if (!strncmp(kctl->id.name, name, sizeof(kctl->id.name)))
1855 return kctl; 1855 return kctl;
1856 return NULL; 1856 return NULL;
1857 } 1857 }
1858 EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); 1858 EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol);
1859 1859
1860 /** 1860 /**
1861 * snd_soc_add_component_controls - Add an array of controls to a component. 1861 * snd_soc_add_component_controls - Add an array of controls to a component.
1862 * 1862 *
1863 * @component: Component to add controls to 1863 * @component: Component to add controls to
1864 * @controls: Array of controls to add 1864 * @controls: Array of controls to add
1865 * @num_controls: Number of elements in the array 1865 * @num_controls: Number of elements in the array
1866 * 1866 *
1867 * Return: 0 for success, else error. 1867 * Return: 0 for success, else error.
1868 */ 1868 */
1869 int snd_soc_add_component_controls(struct snd_soc_component *component, 1869 int snd_soc_add_component_controls(struct snd_soc_component *component,
1870 const struct snd_kcontrol_new *controls, unsigned int num_controls) 1870 const struct snd_kcontrol_new *controls, unsigned int num_controls)
1871 { 1871 {
1872 struct snd_card *card = component->card->snd_card; 1872 struct snd_card *card = component->card->snd_card;
1873 1873
1874 return snd_soc_add_controls(card, component->dev, controls, 1874 return snd_soc_add_controls(card, component->dev, controls,
1875 num_controls, component->name_prefix, component); 1875 num_controls, component->name_prefix, component);
1876 } 1876 }
1877 EXPORT_SYMBOL_GPL(snd_soc_add_component_controls); 1877 EXPORT_SYMBOL_GPL(snd_soc_add_component_controls);
1878 1878
1879 /** 1879 /**
1880 * snd_soc_add_codec_controls - add an array of controls to a codec. 1880 * snd_soc_add_codec_controls - add an array of controls to a codec.
1881 * Convenience function to add a list of controls. Many codecs were 1881 * Convenience function to add a list of controls. Many codecs were
1882 * duplicating this code. 1882 * duplicating this code.
1883 * 1883 *
1884 * @codec: codec to add controls to 1884 * @codec: codec to add controls to
1885 * @controls: array of controls to add 1885 * @controls: array of controls to add
1886 * @num_controls: number of elements in the array 1886 * @num_controls: number of elements in the array
1887 * 1887 *
1888 * Return 0 for success, else error. 1888 * Return 0 for success, else error.
1889 */ 1889 */
1890 int snd_soc_add_codec_controls(struct snd_soc_codec *codec, 1890 int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
1891 const struct snd_kcontrol_new *controls, unsigned int num_controls) 1891 const struct snd_kcontrol_new *controls, unsigned int num_controls)
1892 { 1892 {
1893 return snd_soc_add_component_controls(&codec->component, controls, 1893 return snd_soc_add_component_controls(&codec->component, controls,
1894 num_controls); 1894 num_controls);
1895 } 1895 }
1896 EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); 1896 EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls);
1897 1897
1898 /** 1898 /**
1899 * snd_soc_add_platform_controls - add an array of controls to a platform. 1899 * snd_soc_add_platform_controls - add an array of controls to a platform.
1900 * Convenience function to add a list of controls. 1900 * Convenience function to add a list of controls.
1901 * 1901 *
1902 * @platform: platform to add controls to 1902 * @platform: platform to add controls to
1903 * @controls: array of controls to add 1903 * @controls: array of controls to add
1904 * @num_controls: number of elements in the array 1904 * @num_controls: number of elements in the array
1905 * 1905 *
1906 * Return 0 for success, else error. 1906 * Return 0 for success, else error.
1907 */ 1907 */
1908 int snd_soc_add_platform_controls(struct snd_soc_platform *platform, 1908 int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
1909 const struct snd_kcontrol_new *controls, unsigned int num_controls) 1909 const struct snd_kcontrol_new *controls, unsigned int num_controls)
1910 { 1910 {
1911 return snd_soc_add_component_controls(&platform->component, controls, 1911 return snd_soc_add_component_controls(&platform->component, controls,
1912 num_controls); 1912 num_controls);
1913 } 1913 }
1914 EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); 1914 EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls);
1915 1915
1916 /** 1916 /**
1917 * snd_soc_add_card_controls - add an array of controls to a SoC card. 1917 * snd_soc_add_card_controls - add an array of controls to a SoC card.
1918 * Convenience function to add a list of controls. 1918 * Convenience function to add a list of controls.
1919 * 1919 *
1920 * @soc_card: SoC card to add controls to 1920 * @soc_card: SoC card to add controls to
1921 * @controls: array of controls to add 1921 * @controls: array of controls to add
1922 * @num_controls: number of elements in the array 1922 * @num_controls: number of elements in the array
1923 * 1923 *
1924 * Return 0 for success, else error. 1924 * Return 0 for success, else error.
1925 */ 1925 */
1926 int snd_soc_add_card_controls(struct snd_soc_card *soc_card, 1926 int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
1927 const struct snd_kcontrol_new *controls, int num_controls) 1927 const struct snd_kcontrol_new *controls, int num_controls)
1928 { 1928 {
1929 struct snd_card *card = soc_card->snd_card; 1929 struct snd_card *card = soc_card->snd_card;
1930 1930
1931 return snd_soc_add_controls(card, soc_card->dev, controls, num_controls, 1931 return snd_soc_add_controls(card, soc_card->dev, controls, num_controls,
1932 NULL, soc_card); 1932 NULL, soc_card);
1933 } 1933 }
1934 EXPORT_SYMBOL_GPL(snd_soc_add_card_controls); 1934 EXPORT_SYMBOL_GPL(snd_soc_add_card_controls);
1935 1935
1936 /** 1936 /**
1937 * snd_soc_add_dai_controls - add an array of controls to a DAI. 1937 * snd_soc_add_dai_controls - add an array of controls to a DAI.
1938 * Convienience function to add a list of controls. 1938 * Convienience function to add a list of controls.
1939 * 1939 *
1940 * @dai: DAI to add controls to 1940 * @dai: DAI to add controls to
1941 * @controls: array of controls to add 1941 * @controls: array of controls to add
1942 * @num_controls: number of elements in the array 1942 * @num_controls: number of elements in the array
1943 * 1943 *
1944 * Return 0 for success, else error. 1944 * Return 0 for success, else error.
1945 */ 1945 */
1946 int snd_soc_add_dai_controls(struct snd_soc_dai *dai, 1946 int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
1947 const struct snd_kcontrol_new *controls, int num_controls) 1947 const struct snd_kcontrol_new *controls, int num_controls)
1948 { 1948 {
1949 struct snd_card *card = dai->component->card->snd_card; 1949 struct snd_card *card = dai->component->card->snd_card;
1950 1950
1951 return snd_soc_add_controls(card, dai->dev, controls, num_controls, 1951 return snd_soc_add_controls(card, dai->dev, controls, num_controls,
1952 NULL, dai); 1952 NULL, dai);
1953 } 1953 }
1954 EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls); 1954 EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
1955 1955
1956 /** 1956 /**
1957 * snd_soc_dai_set_sysclk - configure DAI system or master clock. 1957 * snd_soc_dai_set_sysclk - configure DAI system or master clock.
1958 * @dai: DAI 1958 * @dai: DAI
1959 * @clk_id: DAI specific clock ID 1959 * @clk_id: DAI specific clock ID
1960 * @freq: new clock frequency in Hz 1960 * @freq: new clock frequency in Hz
1961 * @dir: new clock direction - input/output. 1961 * @dir: new clock direction - input/output.
1962 * 1962 *
1963 * Configures the DAI master (MCLK) or system (SYSCLK) clocking. 1963 * Configures the DAI master (MCLK) or system (SYSCLK) clocking.
1964 */ 1964 */
1965 int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, 1965 int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
1966 unsigned int freq, int dir) 1966 unsigned int freq, int dir)
1967 { 1967 {
1968 if (dai->driver && dai->driver->ops->set_sysclk) 1968 if (dai->driver && dai->driver->ops->set_sysclk)
1969 return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir); 1969 return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
1970 else if (dai->codec && dai->codec->driver->set_sysclk) 1970 else if (dai->codec && dai->codec->driver->set_sysclk)
1971 return dai->codec->driver->set_sysclk(dai->codec, clk_id, 0, 1971 return dai->codec->driver->set_sysclk(dai->codec, clk_id, 0,
1972 freq, dir); 1972 freq, dir);
1973 else 1973 else
1974 return -ENOTSUPP; 1974 return -ENOTSUPP;
1975 } 1975 }
1976 EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); 1976 EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
1977 1977
1978 /** 1978 /**
1979 * snd_soc_codec_set_sysclk - configure CODEC system or master clock. 1979 * snd_soc_codec_set_sysclk - configure CODEC system or master clock.
1980 * @codec: CODEC 1980 * @codec: CODEC
1981 * @clk_id: DAI specific clock ID 1981 * @clk_id: DAI specific clock ID
1982 * @source: Source for the clock 1982 * @source: Source for the clock
1983 * @freq: new clock frequency in Hz 1983 * @freq: new clock frequency in Hz
1984 * @dir: new clock direction - input/output. 1984 * @dir: new clock direction - input/output.
1985 * 1985 *
1986 * Configures the CODEC master (MCLK) or system (SYSCLK) clocking. 1986 * Configures the CODEC master (MCLK) or system (SYSCLK) clocking.
1987 */ 1987 */
1988 int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, 1988 int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
1989 int source, unsigned int freq, int dir) 1989 int source, unsigned int freq, int dir)
1990 { 1990 {
1991 if (codec->driver->set_sysclk) 1991 if (codec->driver->set_sysclk)
1992 return codec->driver->set_sysclk(codec, clk_id, source, 1992 return codec->driver->set_sysclk(codec, clk_id, source,
1993 freq, dir); 1993 freq, dir);
1994 else 1994 else
1995 return -ENOTSUPP; 1995 return -ENOTSUPP;
1996 } 1996 }
1997 EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk); 1997 EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk);
1998 1998
1999 /** 1999 /**
2000 * snd_soc_dai_set_clkdiv - configure DAI clock dividers. 2000 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
2001 * @dai: DAI 2001 * @dai: DAI
2002 * @div_id: DAI specific clock divider ID 2002 * @div_id: DAI specific clock divider ID
2003 * @div: new clock divisor. 2003 * @div: new clock divisor.
2004 * 2004 *
2005 * Configures the clock dividers. This is used to derive the best DAI bit and 2005 * Configures the clock dividers. This is used to derive the best DAI bit and
2006 * frame clocks from the system or master clock. It's best to set the DAI bit 2006 * frame clocks from the system or master clock. It's best to set the DAI bit
2007 * and frame clocks as low as possible to save system power. 2007 * and frame clocks as low as possible to save system power.
2008 */ 2008 */
2009 int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, 2009 int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
2010 int div_id, int div) 2010 int div_id, int div)
2011 { 2011 {
2012 if (dai->driver && dai->driver->ops->set_clkdiv) 2012 if (dai->driver && dai->driver->ops->set_clkdiv)
2013 return dai->driver->ops->set_clkdiv(dai, div_id, div); 2013 return dai->driver->ops->set_clkdiv(dai, div_id, div);
2014 else 2014 else
2015 return -EINVAL; 2015 return -EINVAL;
2016 } 2016 }
2017 EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv); 2017 EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv);
2018 2018
2019 /** 2019 /**
2020 * snd_soc_dai_set_pll - configure DAI PLL. 2020 * snd_soc_dai_set_pll - configure DAI PLL.
2021 * @dai: DAI 2021 * @dai: DAI
2022 * @pll_id: DAI specific PLL ID 2022 * @pll_id: DAI specific PLL ID
2023 * @source: DAI specific source for the PLL 2023 * @source: DAI specific source for the PLL
2024 * @freq_in: PLL input clock frequency in Hz 2024 * @freq_in: PLL input clock frequency in Hz
2025 * @freq_out: requested PLL output clock frequency in Hz 2025 * @freq_out: requested PLL output clock frequency in Hz
2026 * 2026 *
2027 * Configures and enables PLL to generate output clock based on input clock. 2027 * Configures and enables PLL to generate output clock based on input clock.
2028 */ 2028 */
2029 int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, 2029 int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
2030 unsigned int freq_in, unsigned int freq_out) 2030 unsigned int freq_in, unsigned int freq_out)
2031 { 2031 {
2032 if (dai->driver && dai->driver->ops->set_pll) 2032 if (dai->driver && dai->driver->ops->set_pll)
2033 return dai->driver->ops->set_pll(dai, pll_id, source, 2033 return dai->driver->ops->set_pll(dai, pll_id, source,
2034 freq_in, freq_out); 2034 freq_in, freq_out);
2035 else if (dai->codec && dai->codec->driver->set_pll) 2035 else if (dai->codec && dai->codec->driver->set_pll)
2036 return dai->codec->driver->set_pll(dai->codec, pll_id, source, 2036 return dai->codec->driver->set_pll(dai->codec, pll_id, source,
2037 freq_in, freq_out); 2037 freq_in, freq_out);
2038 else 2038 else
2039 return -EINVAL; 2039 return -EINVAL;
2040 } 2040 }
2041 EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll); 2041 EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
2042 2042
2043 /* 2043 /*
2044 * snd_soc_codec_set_pll - configure codec PLL. 2044 * snd_soc_codec_set_pll - configure codec PLL.
2045 * @codec: CODEC 2045 * @codec: CODEC
2046 * @pll_id: DAI specific PLL ID 2046 * @pll_id: DAI specific PLL ID
2047 * @source: DAI specific source for the PLL 2047 * @source: DAI specific source for the PLL
2048 * @freq_in: PLL input clock frequency in Hz 2048 * @freq_in: PLL input clock frequency in Hz
2049 * @freq_out: requested PLL output clock frequency in Hz 2049 * @freq_out: requested PLL output clock frequency in Hz
2050 * 2050 *
2051 * Configures and enables PLL to generate output clock based on input clock. 2051 * Configures and enables PLL to generate output clock based on input clock.
2052 */ 2052 */
2053 int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, 2053 int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
2054 unsigned int freq_in, unsigned int freq_out) 2054 unsigned int freq_in, unsigned int freq_out)
2055 { 2055 {
2056 if (codec->driver->set_pll) 2056 if (codec->driver->set_pll)
2057 return codec->driver->set_pll(codec, pll_id, source, 2057 return codec->driver->set_pll(codec, pll_id, source,
2058 freq_in, freq_out); 2058 freq_in, freq_out);
2059 else 2059 else
2060 return -EINVAL; 2060 return -EINVAL;
2061 } 2061 }
2062 EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll); 2062 EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll);
2063 2063
2064 /** 2064 /**
2065 * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio. 2065 * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio.
2066 * @dai: DAI 2066 * @dai: DAI
2067 * @ratio Ratio of BCLK to Sample rate. 2067 * @ratio Ratio of BCLK to Sample rate.
2068 * 2068 *
2069 * Configures the DAI for a preset BCLK to sample rate ratio. 2069 * Configures the DAI for a preset BCLK to sample rate ratio.
2070 */ 2070 */
2071 int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) 2071 int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
2072 { 2072 {
2073 if (dai->driver && dai->driver->ops->set_bclk_ratio) 2073 if (dai->driver && dai->driver->ops->set_bclk_ratio)
2074 return dai->driver->ops->set_bclk_ratio(dai, ratio); 2074 return dai->driver->ops->set_bclk_ratio(dai, ratio);
2075 else 2075 else
2076 return -EINVAL; 2076 return -EINVAL;
2077 } 2077 }
2078 EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio); 2078 EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
2079 2079
2080 /** 2080 /**
2081 * snd_soc_dai_set_fmt - configure DAI hardware audio format. 2081 * snd_soc_dai_set_fmt - configure DAI hardware audio format.
2082 * @dai: DAI 2082 * @dai: DAI
2083 * @fmt: SND_SOC_DAIFMT_ format value. 2083 * @fmt: SND_SOC_DAIFMT_ format value.
2084 * 2084 *
2085 * Configures the DAI hardware format and clocking. 2085 * Configures the DAI hardware format and clocking.
2086 */ 2086 */
2087 int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 2087 int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
2088 { 2088 {
2089 if (dai->driver == NULL) 2089 if (dai->driver == NULL)
2090 return -EINVAL; 2090 return -EINVAL;
2091 if (dai->driver->ops->set_fmt == NULL) 2091 if (dai->driver->ops->set_fmt == NULL)
2092 return -ENOTSUPP; 2092 return -ENOTSUPP;
2093 return dai->driver->ops->set_fmt(dai, fmt); 2093 return dai->driver->ops->set_fmt(dai, fmt);
2094 } 2094 }
2095 EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt); 2095 EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
2096 2096
2097 /** 2097 /**
2098 * snd_soc_xlate_tdm_slot - generate tx/rx slot mask. 2098 * snd_soc_xlate_tdm_slot - generate tx/rx slot mask.
2099 * @slots: Number of slots in use. 2099 * @slots: Number of slots in use.
2100 * @tx_mask: bitmask representing active TX slots. 2100 * @tx_mask: bitmask representing active TX slots.
2101 * @rx_mask: bitmask representing active RX slots. 2101 * @rx_mask: bitmask representing active RX slots.
2102 * 2102 *
2103 * Generates the TDM tx and rx slot default masks for DAI. 2103 * Generates the TDM tx and rx slot default masks for DAI.
2104 */ 2104 */
2105 static int snd_soc_xlate_tdm_slot_mask(unsigned int slots, 2105 static int snd_soc_xlate_tdm_slot_mask(unsigned int slots,
2106 unsigned int *tx_mask, 2106 unsigned int *tx_mask,
2107 unsigned int *rx_mask) 2107 unsigned int *rx_mask)
2108 { 2108 {
2109 if (*tx_mask || *rx_mask) 2109 if (*tx_mask || *rx_mask)
2110 return 0; 2110 return 0;
2111 2111
2112 if (!slots) 2112 if (!slots)
2113 return -EINVAL; 2113 return -EINVAL;
2114 2114
2115 *tx_mask = (1 << slots) - 1; 2115 *tx_mask = (1 << slots) - 1;
2116 *rx_mask = (1 << slots) - 1; 2116 *rx_mask = (1 << slots) - 1;
2117 2117
2118 return 0; 2118 return 0;
2119 } 2119 }
2120 2120
2121 /** 2121 /**
2122 * snd_soc_dai_set_tdm_slot - configure DAI TDM. 2122 * snd_soc_dai_set_tdm_slot - configure DAI TDM.
2123 * @dai: DAI 2123 * @dai: DAI
2124 * @tx_mask: bitmask representing active TX slots. 2124 * @tx_mask: bitmask representing active TX slots.
2125 * @rx_mask: bitmask representing active RX slots. 2125 * @rx_mask: bitmask representing active RX slots.
2126 * @slots: Number of slots in use. 2126 * @slots: Number of slots in use.
2127 * @slot_width: Width in bits for each slot. 2127 * @slot_width: Width in bits for each slot.
2128 * 2128 *
2129 * Configures a DAI for TDM operation. Both mask and slots are codec and DAI 2129 * Configures a DAI for TDM operation. Both mask and slots are codec and DAI
2130 * specific. 2130 * specific.
2131 */ 2131 */
2132 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, 2132 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
2133 unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) 2133 unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
2134 { 2134 {
2135 if (dai->driver && dai->driver->ops->xlate_tdm_slot_mask) 2135 if (dai->driver && dai->driver->ops->xlate_tdm_slot_mask)
2136 dai->driver->ops->xlate_tdm_slot_mask(slots, 2136 dai->driver->ops->xlate_tdm_slot_mask(slots,
2137 &tx_mask, &rx_mask); 2137 &tx_mask, &rx_mask);
2138 else 2138 else
2139 snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask); 2139 snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
2140 2140
2141 dai->tx_mask = tx_mask; 2141 dai->tx_mask = tx_mask;
2142 dai->rx_mask = rx_mask; 2142 dai->rx_mask = rx_mask;
2143 2143
2144 if (dai->driver && dai->driver->ops->set_tdm_slot) 2144 if (dai->driver && dai->driver->ops->set_tdm_slot)
2145 return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask, 2145 return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
2146 slots, slot_width); 2146 slots, slot_width);
2147 else 2147 else
2148 return -ENOTSUPP; 2148 return -ENOTSUPP;
2149 } 2149 }
2150 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot); 2150 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
2151 2151
2152 /** 2152 /**
2153 * snd_soc_dai_set_channel_map - configure DAI audio channel map 2153 * snd_soc_dai_set_channel_map - configure DAI audio channel map
2154 * @dai: DAI 2154 * @dai: DAI
2155 * @tx_num: how many TX channels 2155 * @tx_num: how many TX channels
2156 * @tx_slot: pointer to an array which imply the TX slot number channel 2156 * @tx_slot: pointer to an array which imply the TX slot number channel
2157 * 0~num-1 uses 2157 * 0~num-1 uses
2158 * @rx_num: how many RX channels 2158 * @rx_num: how many RX channels
2159 * @rx_slot: pointer to an array which imply the RX slot number channel 2159 * @rx_slot: pointer to an array which imply the RX slot number channel
2160 * 0~num-1 uses 2160 * 0~num-1 uses
2161 * 2161 *
2162 * configure the relationship between channel number and TDM slot number. 2162 * configure the relationship between channel number and TDM slot number.
2163 */ 2163 */
2164 int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, 2164 int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
2165 unsigned int tx_num, unsigned int *tx_slot, 2165 unsigned int tx_num, unsigned int *tx_slot,
2166 unsigned int rx_num, unsigned int *rx_slot) 2166 unsigned int rx_num, unsigned int *rx_slot)
2167 { 2167 {
2168 if (dai->driver && dai->driver->ops->set_channel_map) 2168 if (dai->driver && dai->driver->ops->set_channel_map)
2169 return dai->driver->ops->set_channel_map(dai, tx_num, tx_slot, 2169 return dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
2170 rx_num, rx_slot); 2170 rx_num, rx_slot);
2171 else 2171 else
2172 return -EINVAL; 2172 return -EINVAL;
2173 } 2173 }
2174 EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map); 2174 EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map);
2175 2175
2176 /** 2176 /**
2177 * snd_soc_dai_set_tristate - configure DAI system or master clock. 2177 * snd_soc_dai_set_tristate - configure DAI system or master clock.
2178 * @dai: DAI 2178 * @dai: DAI
2179 * @tristate: tristate enable 2179 * @tristate: tristate enable
2180 * 2180 *
2181 * Tristates the DAI so that others can use it. 2181 * Tristates the DAI so that others can use it.
2182 */ 2182 */
2183 int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) 2183 int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
2184 { 2184 {
2185 if (dai->driver && dai->driver->ops->set_tristate) 2185 if (dai->driver && dai->driver->ops->set_tristate)
2186 return dai->driver->ops->set_tristate(dai, tristate); 2186 return dai->driver->ops->set_tristate(dai, tristate);
2187 else 2187 else
2188 return -EINVAL; 2188 return -EINVAL;
2189 } 2189 }
2190 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate); 2190 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
2191 2191
2192 /** 2192 /**
2193 * snd_soc_dai_digital_mute - configure DAI system or master clock. 2193 * snd_soc_dai_digital_mute - configure DAI system or master clock.
2194 * @dai: DAI 2194 * @dai: DAI
2195 * @mute: mute enable 2195 * @mute: mute enable
2196 * @direction: stream to mute 2196 * @direction: stream to mute
2197 * 2197 *
2198 * Mutes the DAI DAC. 2198 * Mutes the DAI DAC.
2199 */ 2199 */
2200 int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, 2200 int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
2201 int direction) 2201 int direction)
2202 { 2202 {
2203 if (!dai->driver) 2203 if (!dai->driver)
2204 return -ENOTSUPP; 2204 return -ENOTSUPP;
2205 2205
2206 if (dai->driver->ops->mute_stream) 2206 if (dai->driver->ops->mute_stream)
2207 return dai->driver->ops->mute_stream(dai, mute, direction); 2207 return dai->driver->ops->mute_stream(dai, mute, direction);
2208 else if (direction == SNDRV_PCM_STREAM_PLAYBACK && 2208 else if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
2209 dai->driver->ops->digital_mute) 2209 dai->driver->ops->digital_mute)
2210 return dai->driver->ops->digital_mute(dai, mute); 2210 return dai->driver->ops->digital_mute(dai, mute);
2211 else 2211 else
2212 return -ENOTSUPP; 2212 return -ENOTSUPP;
2213 } 2213 }
2214 EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); 2214 EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
2215 2215
2216 static int snd_soc_init_multicodec(struct snd_soc_card *card, 2216 static int snd_soc_init_multicodec(struct snd_soc_card *card,
2217 struct snd_soc_dai_link *dai_link) 2217 struct snd_soc_dai_link *dai_link)
2218 { 2218 {
2219 /* Legacy codec/codec_dai link is a single entry in multicodec */ 2219 /* Legacy codec/codec_dai link is a single entry in multicodec */
2220 if (dai_link->codec_name || dai_link->codec_of_node || 2220 if (dai_link->codec_name || dai_link->codec_of_node ||
2221 dai_link->codec_dai_name) { 2221 dai_link->codec_dai_name) {
2222 dai_link->num_codecs = 1; 2222 dai_link->num_codecs = 1;
2223 2223
2224 dai_link->codecs = devm_kzalloc(card->dev, 2224 dai_link->codecs = devm_kzalloc(card->dev,
2225 sizeof(struct snd_soc_dai_link_component), 2225 sizeof(struct snd_soc_dai_link_component),
2226 GFP_KERNEL); 2226 GFP_KERNEL);
2227 if (!dai_link->codecs) 2227 if (!dai_link->codecs)
2228 return -ENOMEM; 2228 return -ENOMEM;
2229 2229
2230 dai_link->codecs[0].name = dai_link->codec_name; 2230 dai_link->codecs[0].name = dai_link->codec_name;
2231 dai_link->codecs[0].of_node = dai_link->codec_of_node; 2231 dai_link->codecs[0].of_node = dai_link->codec_of_node;
2232 dai_link->codecs[0].dai_name = dai_link->codec_dai_name; 2232 dai_link->codecs[0].dai_name = dai_link->codec_dai_name;
2233 } 2233 }
2234 2234
2235 if (!dai_link->codecs) { 2235 if (!dai_link->codecs) {
2236 dev_err(card->dev, "ASoC: DAI link has no CODECs\n"); 2236 dev_err(card->dev, "ASoC: DAI link has no CODECs\n");
2237 return -EINVAL; 2237 return -EINVAL;
2238 } 2238 }
2239 2239
2240 return 0; 2240 return 0;
2241 } 2241 }
2242 2242
2243 /** 2243 /**
2244 * snd_soc_register_card - Register a card with the ASoC core 2244 * snd_soc_register_card - Register a card with the ASoC core
2245 * 2245 *
2246 * @card: Card to register 2246 * @card: Card to register
2247 * 2247 *
2248 */ 2248 */
2249 int snd_soc_register_card(struct snd_soc_card *card) 2249 int snd_soc_register_card(struct snd_soc_card *card)
2250 { 2250 {
2251 int i, j, ret; 2251 int i, j, ret;
2252 2252
2253 if (!card->name || !card->dev) 2253 if (!card->name || !card->dev)
2254 return -EINVAL; 2254 return -EINVAL;
2255 2255
2256 for (i = 0; i < card->num_links; i++) { 2256 for (i = 0; i < card->num_links; i++) {
2257 struct snd_soc_dai_link *link = &card->dai_link[i]; 2257 struct snd_soc_dai_link *link = &card->dai_link[i];
2258 2258
2259 ret = snd_soc_init_multicodec(card, link); 2259 ret = snd_soc_init_multicodec(card, link);
2260 if (ret) { 2260 if (ret) {
2261 dev_err(card->dev, "ASoC: failed to init multicodec\n"); 2261 dev_err(card->dev, "ASoC: failed to init multicodec\n");
2262 return ret; 2262 return ret;
2263 } 2263 }
2264 2264
2265 for (j = 0; j < link->num_codecs; j++) { 2265 for (j = 0; j < link->num_codecs; j++) {
2266 /* 2266 /*
2267 * Codec must be specified by 1 of name or OF node, 2267 * Codec must be specified by 1 of name or OF node,
2268 * not both or neither. 2268 * not both or neither.
2269 */ 2269 */
2270 if (!!link->codecs[j].name == 2270 if (!!link->codecs[j].name ==
2271 !!link->codecs[j].of_node) { 2271 !!link->codecs[j].of_node) {
2272 dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n", 2272 dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n",
2273 link->name); 2273 link->name);
2274 return -EINVAL; 2274 return -EINVAL;
2275 } 2275 }
2276 /* Codec DAI name must be specified */ 2276 /* Codec DAI name must be specified */
2277 if (!link->codecs[j].dai_name) { 2277 if (!link->codecs[j].dai_name) {
2278 dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n", 2278 dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n",
2279 link->name); 2279 link->name);
2280 return -EINVAL; 2280 return -EINVAL;
2281 } 2281 }
2282 } 2282 }
2283 2283
2284 /* 2284 /*
2285 * Platform may be specified by either name or OF node, but 2285 * Platform may be specified by either name or OF node, but
2286 * can be left unspecified, and a dummy platform will be used. 2286 * can be left unspecified, and a dummy platform will be used.
2287 */ 2287 */
2288 if (link->platform_name && link->platform_of_node) { 2288 if (link->platform_name && link->platform_of_node) {
2289 dev_err(card->dev, 2289 dev_err(card->dev,
2290 "ASoC: Both platform name/of_node are set for %s\n", 2290 "ASoC: Both platform name/of_node are set for %s\n",
2291 link->name); 2291 link->name);
2292 return -EINVAL; 2292 return -EINVAL;
2293 } 2293 }
2294 2294
2295 /* 2295 /*
2296 * CPU device may be specified by either name or OF node, but 2296 * CPU device may be specified by either name or OF node, but
2297 * can be left unspecified, and will be matched based on DAI 2297 * can be left unspecified, and will be matched based on DAI
2298 * name alone.. 2298 * name alone..
2299 */ 2299 */
2300 if (link->cpu_name && link->cpu_of_node) { 2300 if (link->cpu_name && link->cpu_of_node) {
2301 dev_err(card->dev, 2301 dev_err(card->dev,
2302 "ASoC: Neither/both cpu name/of_node are set for %s\n", 2302 "ASoC: Neither/both cpu name/of_node are set for %s\n",
2303 link->name); 2303 link->name);
2304 return -EINVAL; 2304 return -EINVAL;
2305 } 2305 }
2306 /* 2306 /*
2307 * At least one of CPU DAI name or CPU device name/node must be 2307 * At least one of CPU DAI name or CPU device name/node must be
2308 * specified 2308 * specified
2309 */ 2309 */
2310 if (!link->cpu_dai_name && 2310 if (!link->cpu_dai_name &&
2311 !(link->cpu_name || link->cpu_of_node)) { 2311 !(link->cpu_name || link->cpu_of_node)) {
2312 dev_err(card->dev, 2312 dev_err(card->dev,
2313 "ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for %s\n", 2313 "ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for %s\n",
2314 link->name); 2314 link->name);
2315 return -EINVAL; 2315 return -EINVAL;
2316 } 2316 }
2317 } 2317 }
2318 2318
2319 dev_set_drvdata(card->dev, card); 2319 dev_set_drvdata(card->dev, card);
2320 2320
2321 snd_soc_initialize_card_lists(card); 2321 snd_soc_initialize_card_lists(card);
2322 2322
2323 soc_init_card_debugfs(card); 2323 soc_init_card_debugfs(card);
2324 2324
2325 card->rtd = devm_kzalloc(card->dev, 2325 card->rtd = devm_kzalloc(card->dev,
2326 sizeof(struct snd_soc_pcm_runtime) * 2326 sizeof(struct snd_soc_pcm_runtime) *
2327 (card->num_links + card->num_aux_devs), 2327 (card->num_links + card->num_aux_devs),
2328 GFP_KERNEL); 2328 GFP_KERNEL);
2329 if (card->rtd == NULL) 2329 if (card->rtd == NULL)
2330 return -ENOMEM; 2330 return -ENOMEM;
2331 card->num_rtd = 0; 2331 card->num_rtd = 0;
2332 card->rtd_aux = &card->rtd[card->num_links]; 2332 card->rtd_aux = &card->rtd[card->num_links];
2333 2333
2334 for (i = 0; i < card->num_links; i++) { 2334 for (i = 0; i < card->num_links; i++) {
2335 card->rtd[i].card = card; 2335 card->rtd[i].card = card;
2336 card->rtd[i].dai_link = &card->dai_link[i]; 2336 card->rtd[i].dai_link = &card->dai_link[i];
2337 card->rtd[i].codec_dais = devm_kzalloc(card->dev, 2337 card->rtd[i].codec_dais = devm_kzalloc(card->dev,
2338 sizeof(struct snd_soc_dai *) * 2338 sizeof(struct snd_soc_dai *) *
2339 (card->rtd[i].dai_link->num_codecs), 2339 (card->rtd[i].dai_link->num_codecs),
2340 GFP_KERNEL); 2340 GFP_KERNEL);
2341 if (card->rtd[i].codec_dais == NULL) 2341 if (card->rtd[i].codec_dais == NULL)
2342 return -ENOMEM; 2342 return -ENOMEM;
2343 } 2343 }
2344 2344
2345 for (i = 0; i < card->num_aux_devs; i++) 2345 for (i = 0; i < card->num_aux_devs; i++)
2346 card->rtd_aux[i].card = card; 2346 card->rtd_aux[i].card = card;
2347 2347
2348 INIT_LIST_HEAD(&card->dapm_dirty); 2348 INIT_LIST_HEAD(&card->dapm_dirty);
2349 card->instantiated = 0; 2349 card->instantiated = 0;
2350 mutex_init(&card->mutex); 2350 mutex_init(&card->mutex);
2351 mutex_init(&card->dapm_mutex); 2351 mutex_init(&card->dapm_mutex);
2352 2352
2353 ret = snd_soc_instantiate_card(card); 2353 ret = snd_soc_instantiate_card(card);
2354 if (ret != 0) 2354 if (ret != 0)
2355 soc_cleanup_card_debugfs(card); 2355 soc_cleanup_card_debugfs(card);
2356 2356
2357 /* deactivate pins to sleep state */ 2357 /* deactivate pins to sleep state */
2358 for (i = 0; i < card->num_rtd; i++) { 2358 for (i = 0; i < card->num_rtd; i++) {
2359 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; 2359 struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
2360 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 2360 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
2361 int j; 2361 int j;
2362 2362
2363 for (j = 0; j < rtd->num_codecs; j++) { 2363 for (j = 0; j < rtd->num_codecs; j++) {
2364 struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; 2364 struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
2365 if (!codec_dai->active) 2365 if (!codec_dai->active)
2366 pinctrl_pm_select_sleep_state(codec_dai->dev); 2366 pinctrl_pm_select_sleep_state(codec_dai->dev);
2367 } 2367 }
2368 2368
2369 if (!cpu_dai->active) 2369 if (!cpu_dai->active)
2370 pinctrl_pm_select_sleep_state(cpu_dai->dev); 2370 pinctrl_pm_select_sleep_state(cpu_dai->dev);
2371 } 2371 }
2372 2372
2373 return ret; 2373 return ret;
2374 } 2374 }
2375 EXPORT_SYMBOL_GPL(snd_soc_register_card); 2375 EXPORT_SYMBOL_GPL(snd_soc_register_card);
2376 2376
2377 /** 2377 /**
2378 * snd_soc_unregister_card - Unregister a card with the ASoC core 2378 * snd_soc_unregister_card - Unregister a card with the ASoC core
2379 * 2379 *
2380 * @card: Card to unregister 2380 * @card: Card to unregister
2381 * 2381 *
2382 */ 2382 */
2383 int snd_soc_unregister_card(struct snd_soc_card *card) 2383 int snd_soc_unregister_card(struct snd_soc_card *card)
2384 { 2384 {
2385 if (card->instantiated) { 2385 if (card->instantiated) {
2386 card->instantiated = false; 2386 card->instantiated = false;
2387 snd_soc_dapm_shutdown(card); 2387 snd_soc_dapm_shutdown(card);
2388 soc_cleanup_card_resources(card); 2388 soc_cleanup_card_resources(card);
2389 } 2389 }
2390 dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); 2390 dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
2391 2391
2392 return 0; 2392 return 0;
2393 } 2393 }
2394 EXPORT_SYMBOL_GPL(snd_soc_unregister_card); 2394 EXPORT_SYMBOL_GPL(snd_soc_unregister_card);
2395 2395
2396 /* 2396 /*
2397 * Simplify DAI link configuration by removing ".-1" from device names 2397 * Simplify DAI link configuration by removing ".-1" from device names
2398 * and sanitizing names. 2398 * and sanitizing names.
2399 */ 2399 */
2400 static char *fmt_single_name(struct device *dev, int *id) 2400 static char *fmt_single_name(struct device *dev, int *id)
2401 { 2401 {
2402 char *found, name[NAME_SIZE]; 2402 char *found, name[NAME_SIZE];
2403 int id1, id2; 2403 int id1, id2;
2404 2404
2405 if (dev_name(dev) == NULL) 2405 if (dev_name(dev) == NULL)
2406 return NULL; 2406 return NULL;
2407 2407
2408 strlcpy(name, dev_name(dev), NAME_SIZE); 2408 strlcpy(name, dev_name(dev), NAME_SIZE);
2409 2409
2410 /* are we a "%s.%d" name (platform and SPI components) */ 2410 /* are we a "%s.%d" name (platform and SPI components) */
2411 found = strstr(name, dev->driver->name); 2411 found = strstr(name, dev->driver->name);
2412 if (found) { 2412 if (found) {
2413 /* get ID */ 2413 /* get ID */
2414 if (sscanf(&found[strlen(dev->driver->name)], ".%d", id) == 1) { 2414 if (sscanf(&found[strlen(dev->driver->name)], ".%d", id) == 1) {
2415 2415
2416 /* discard ID from name if ID == -1 */ 2416 /* discard ID from name if ID == -1 */
2417 if (*id == -1) 2417 if (*id == -1)
2418 found[strlen(dev->driver->name)] = '\0'; 2418 found[strlen(dev->driver->name)] = '\0';
2419 } 2419 }
2420 2420
2421 } else { 2421 } else {
2422 /* I2C component devices are named "bus-addr" */ 2422 /* I2C component devices are named "bus-addr" */
2423 if (sscanf(name, "%x-%x", &id1, &id2) == 2) { 2423 if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
2424 char tmp[NAME_SIZE]; 2424 char tmp[NAME_SIZE];
2425 2425
2426 /* create unique ID number from I2C addr and bus */ 2426 /* create unique ID number from I2C addr and bus */
2427 *id = ((id1 & 0xffff) << 16) + id2; 2427 *id = ((id1 & 0xffff) << 16) + id2;
2428 2428
2429 /* sanitize component name for DAI link creation */ 2429 /* sanitize component name for DAI link creation */
2430 snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name, name); 2430 snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name, name);
2431 strlcpy(name, tmp, NAME_SIZE); 2431 strlcpy(name, tmp, NAME_SIZE);
2432 } else 2432 } else
2433 *id = 0; 2433 *id = 0;
2434 } 2434 }
2435 2435
2436 return kstrdup(name, GFP_KERNEL); 2436 return kstrdup(name, GFP_KERNEL);
2437 } 2437 }
2438 2438
2439 /* 2439 /*
2440 * Simplify DAI link naming for single devices with multiple DAIs by removing 2440 * Simplify DAI link naming for single devices with multiple DAIs by removing
2441 * any ".-1" and using the DAI name (instead of device name). 2441 * any ".-1" and using the DAI name (instead of device name).
2442 */ 2442 */
2443 static inline char *fmt_multiple_name(struct device *dev, 2443 static inline char *fmt_multiple_name(struct device *dev,
2444 struct snd_soc_dai_driver *dai_drv) 2444 struct snd_soc_dai_driver *dai_drv)
2445 { 2445 {
2446 if (dai_drv->name == NULL) { 2446 if (dai_drv->name == NULL) {
2447 dev_err(dev, 2447 dev_err(dev,
2448 "ASoC: error - multiple DAI %s registered with no name\n", 2448 "ASoC: error - multiple DAI %s registered with no name\n",
2449 dev_name(dev)); 2449 dev_name(dev));
2450 return NULL; 2450 return NULL;
2451 } 2451 }
2452 2452
2453 return kstrdup(dai_drv->name, GFP_KERNEL); 2453 return kstrdup(dai_drv->name, GFP_KERNEL);
2454 } 2454 }
2455 2455
2456 /** 2456 /**
2457 * snd_soc_unregister_dai - Unregister DAIs from the ASoC core 2457 * snd_soc_unregister_dai - Unregister DAIs from the ASoC core
2458 * 2458 *
2459 * @component: The component for which the DAIs should be unregistered 2459 * @component: The component for which the DAIs should be unregistered
2460 */ 2460 */
2461 static void snd_soc_unregister_dais(struct snd_soc_component *component) 2461 static void snd_soc_unregister_dais(struct snd_soc_component *component)
2462 { 2462 {
2463 struct snd_soc_dai *dai, *_dai; 2463 struct snd_soc_dai *dai, *_dai;
2464 2464
2465 list_for_each_entry_safe(dai, _dai, &component->dai_list, list) { 2465 list_for_each_entry_safe(dai, _dai, &component->dai_list, list) {
2466 dev_dbg(component->dev, "ASoC: Unregistered DAI '%s'\n", 2466 dev_dbg(component->dev, "ASoC: Unregistered DAI '%s'\n",
2467 dai->name); 2467 dai->name);
2468 list_del(&dai->list); 2468 list_del(&dai->list);
2469 kfree(dai->name); 2469 kfree(dai->name);
2470 kfree(dai); 2470 kfree(dai);
2471 } 2471 }
2472 } 2472 }
2473 2473
2474 /** 2474 /**
2475 * snd_soc_register_dais - Register a DAI with the ASoC core 2475 * snd_soc_register_dais - Register a DAI with the ASoC core
2476 * 2476 *
2477 * @component: The component the DAIs are registered for 2477 * @component: The component the DAIs are registered for
2478 * @dai_drv: DAI driver to use for the DAIs 2478 * @dai_drv: DAI driver to use for the DAIs
2479 * @count: Number of DAIs 2479 * @count: Number of DAIs
2480 * @legacy_dai_naming: Use the legacy naming scheme and let the DAI inherit the 2480 * @legacy_dai_naming: Use the legacy naming scheme and let the DAI inherit the
2481 * parent's name. 2481 * parent's name.
2482 */ 2482 */
2483 static int snd_soc_register_dais(struct snd_soc_component *component, 2483 static int snd_soc_register_dais(struct snd_soc_component *component,
2484 struct snd_soc_dai_driver *dai_drv, size_t count, 2484 struct snd_soc_dai_driver *dai_drv, size_t count,
2485 bool legacy_dai_naming) 2485 bool legacy_dai_naming)
2486 { 2486 {
2487 struct device *dev = component->dev; 2487 struct device *dev = component->dev;
2488 struct snd_soc_dai *dai; 2488 struct snd_soc_dai *dai;
2489 unsigned int i; 2489 unsigned int i;
2490 int ret; 2490 int ret;
2491 2491
2492 dev_dbg(dev, "ASoC: dai register %s #%Zu\n", dev_name(dev), count); 2492 dev_dbg(dev, "ASoC: dai register %s #%Zu\n", dev_name(dev), count);
2493 2493
2494 component->dai_drv = dai_drv; 2494 component->dai_drv = dai_drv;
2495 component->num_dai = count; 2495 component->num_dai = count;
2496 2496
2497 for (i = 0; i < count; i++) { 2497 for (i = 0; i < count; i++) {
2498 2498
2499 dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL); 2499 dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
2500 if (dai == NULL) { 2500 if (dai == NULL) {
2501 ret = -ENOMEM; 2501 ret = -ENOMEM;
2502 goto err; 2502 goto err;
2503 } 2503 }
2504 2504
2505 /* 2505 /*
2506 * Back in the old days when we still had component-less DAIs, 2506 * Back in the old days when we still had component-less DAIs,
2507 * instead of having a static name, component-less DAIs would 2507 * instead of having a static name, component-less DAIs would
2508 * inherit the name of the parent device so it is possible to 2508 * inherit the name of the parent device so it is possible to
2509 * register multiple instances of the DAI. We still need to keep 2509 * register multiple instances of the DAI. We still need to keep
2510 * the same naming style even though those DAIs are not 2510 * the same naming style even though those DAIs are not
2511 * component-less anymore. 2511 * component-less anymore.
2512 */ 2512 */
2513 if (count == 1 && legacy_dai_naming) { 2513 if (count == 1 && legacy_dai_naming) {
2514 dai->name = fmt_single_name(dev, &dai->id); 2514 dai->name = fmt_single_name(dev, &dai->id);
2515 } else { 2515 } else {
2516 dai->name = fmt_multiple_name(dev, &dai_drv[i]); 2516 dai->name = fmt_multiple_name(dev, &dai_drv[i]);
2517 if (dai_drv[i].id) 2517 if (dai_drv[i].id)
2518 dai->id = dai_drv[i].id; 2518 dai->id = dai_drv[i].id;
2519 else 2519 else
2520 dai->id = i; 2520 dai->id = i;
2521 } 2521 }
2522 if (dai->name == NULL) { 2522 if (dai->name == NULL) {
2523 kfree(dai); 2523 kfree(dai);
2524 ret = -ENOMEM; 2524 ret = -ENOMEM;
2525 goto err; 2525 goto err;
2526 } 2526 }
2527 2527
2528 dai->component = component; 2528 dai->component = component;
2529 dai->dev = dev; 2529 dai->dev = dev;
2530 dai->driver = &dai_drv[i]; 2530 dai->driver = &dai_drv[i];
2531 if (!dai->driver->ops) 2531 if (!dai->driver->ops)
2532 dai->driver->ops = &null_dai_ops; 2532 dai->driver->ops = &null_dai_ops;
2533 2533
2534 list_add(&dai->list, &component->dai_list); 2534 list_add(&dai->list, &component->dai_list);
2535 2535
2536 dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); 2536 dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name);
2537 } 2537 }
2538 2538
2539 return 0; 2539 return 0;
2540 2540
2541 err: 2541 err:
2542 snd_soc_unregister_dais(component); 2542 snd_soc_unregister_dais(component);
2543 2543
2544 return ret; 2544 return ret;
2545 } 2545 }
2546 2546
2547 static void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm, 2547 static void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm,
2548 enum snd_soc_dapm_type type, int subseq) 2548 enum snd_soc_dapm_type type, int subseq)
2549 { 2549 {
2550 struct snd_soc_component *component = dapm->component; 2550 struct snd_soc_component *component = dapm->component;
2551 2551
2552 component->driver->seq_notifier(component, type, subseq); 2552 component->driver->seq_notifier(component, type, subseq);
2553 } 2553 }
2554 2554
2555 static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm, 2555 static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm,
2556 int event) 2556 int event)
2557 { 2557 {
2558 struct snd_soc_component *component = dapm->component; 2558 struct snd_soc_component *component = dapm->component;
2559 2559
2560 return component->driver->stream_event(component, event); 2560 return component->driver->stream_event(component, event);
2561 } 2561 }
2562 2562
2563 static int snd_soc_component_initialize(struct snd_soc_component *component, 2563 static int snd_soc_component_initialize(struct snd_soc_component *component,
2564 const struct snd_soc_component_driver *driver, struct device *dev) 2564 const struct snd_soc_component_driver *driver, struct device *dev)
2565 { 2565 {
2566 struct snd_soc_dapm_context *dapm; 2566 struct snd_soc_dapm_context *dapm;
2567 2567
2568 component->name = fmt_single_name(dev, &component->id); 2568 component->name = fmt_single_name(dev, &component->id);
2569 if (!component->name) { 2569 if (!component->name) {
2570 dev_err(dev, "ASoC: Failed to allocate name\n"); 2570 dev_err(dev, "ASoC: Failed to allocate name\n");
2571 return -ENOMEM; 2571 return -ENOMEM;
2572 } 2572 }
2573 2573
2574 component->dev = dev; 2574 component->dev = dev;
2575 component->driver = driver; 2575 component->driver = driver;
2576 component->probe = component->driver->probe; 2576 component->probe = component->driver->probe;
2577 component->remove = component->driver->remove; 2577 component->remove = component->driver->remove;
2578 2578
2579 if (!component->dapm_ptr) 2579 if (!component->dapm_ptr)
2580 component->dapm_ptr = &component->dapm; 2580 component->dapm_ptr = &component->dapm;
2581 2581
2582 dapm = component->dapm_ptr; 2582 dapm = component->dapm_ptr;
2583 dapm->dev = dev; 2583 dapm->dev = dev;
2584 dapm->component = component; 2584 dapm->component = component;
2585 dapm->bias_level = SND_SOC_BIAS_OFF; 2585 dapm->bias_level = SND_SOC_BIAS_OFF;
2586 dapm->idle_bias_off = true; 2586 dapm->idle_bias_off = true;
2587 if (driver->seq_notifier) 2587 if (driver->seq_notifier)
2588 dapm->seq_notifier = snd_soc_component_seq_notifier; 2588 dapm->seq_notifier = snd_soc_component_seq_notifier;
2589 if (driver->stream_event) 2589 if (driver->stream_event)
2590 dapm->stream_event = snd_soc_component_stream_event; 2590 dapm->stream_event = snd_soc_component_stream_event;
2591 2591
2592 component->controls = driver->controls; 2592 component->controls = driver->controls;
2593 component->num_controls = driver->num_controls; 2593 component->num_controls = driver->num_controls;
2594 component->dapm_widgets = driver->dapm_widgets; 2594 component->dapm_widgets = driver->dapm_widgets;
2595 component->num_dapm_widgets = driver->num_dapm_widgets; 2595 component->num_dapm_widgets = driver->num_dapm_widgets;
2596 component->dapm_routes = driver->dapm_routes; 2596 component->dapm_routes = driver->dapm_routes;
2597 component->num_dapm_routes = driver->num_dapm_routes; 2597 component->num_dapm_routes = driver->num_dapm_routes;
2598 2598
2599 INIT_LIST_HEAD(&component->dai_list); 2599 INIT_LIST_HEAD(&component->dai_list);
2600 mutex_init(&component->io_mutex); 2600 mutex_init(&component->io_mutex);
2601 2601
2602 return 0; 2602 return 0;
2603 } 2603 }
2604 2604
2605 static void snd_soc_component_setup_regmap(struct snd_soc_component *component) 2605 static void snd_soc_component_setup_regmap(struct snd_soc_component *component)
2606 { 2606 {
2607 int val_bytes = regmap_get_val_bytes(component->regmap); 2607 int val_bytes = regmap_get_val_bytes(component->regmap);
2608 2608
2609 /* Errors are legitimate for non-integer byte multiples */ 2609 /* Errors are legitimate for non-integer byte multiples */
2610 if (val_bytes > 0) 2610 if (val_bytes > 0)
2611 component->val_bytes = val_bytes; 2611 component->val_bytes = val_bytes;
2612 } 2612 }
2613 2613
2614 #ifdef CONFIG_REGMAP 2614 #ifdef CONFIG_REGMAP
2615 2615
2616 /** 2616 /**
2617 * snd_soc_component_init_regmap() - Initialize regmap instance for the component 2617 * snd_soc_component_init_regmap() - Initialize regmap instance for the component
2618 * @component: The component for which to initialize the regmap instance 2618 * @component: The component for which to initialize the regmap instance
2619 * @regmap: The regmap instance that should be used by the component 2619 * @regmap: The regmap instance that should be used by the component
2620 * 2620 *
2621 * This function allows deferred assignment of the regmap instance that is 2621 * This function allows deferred assignment of the regmap instance that is
2622 * associated with the component. Only use this if the regmap instance is not 2622 * associated with the component. Only use this if the regmap instance is not
2623 * yet ready when the component is registered. The function must also be called 2623 * yet ready when the component is registered. The function must also be called
2624 * before the first IO attempt of the component. 2624 * before the first IO attempt of the component.
2625 */ 2625 */
2626 void snd_soc_component_init_regmap(struct snd_soc_component *component, 2626 void snd_soc_component_init_regmap(struct snd_soc_component *component,
2627 struct regmap *regmap) 2627 struct regmap *regmap)
2628 { 2628 {
2629 component->regmap = regmap; 2629 component->regmap = regmap;
2630 snd_soc_component_setup_regmap(component); 2630 snd_soc_component_setup_regmap(component);
2631 } 2631 }
2632 EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap); 2632 EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
2633 2633
2634 /** 2634 /**
2635 * snd_soc_component_exit_regmap() - De-initialize regmap instance for the component 2635 * snd_soc_component_exit_regmap() - De-initialize regmap instance for the component
2636 * @component: The component for which to de-initialize the regmap instance 2636 * @component: The component for which to de-initialize the regmap instance
2637 * 2637 *
2638 * Calls regmap_exit() on the regmap instance associated to the component and 2638 * Calls regmap_exit() on the regmap instance associated to the component and
2639 * removes the regmap instance from the component. 2639 * removes the regmap instance from the component.
2640 * 2640 *
2641 * This function should only be used if snd_soc_component_init_regmap() was used 2641 * This function should only be used if snd_soc_component_init_regmap() was used
2642 * to initialize the regmap instance. 2642 * to initialize the regmap instance.
2643 */ 2643 */
2644 void snd_soc_component_exit_regmap(struct snd_soc_component *component) 2644 void snd_soc_component_exit_regmap(struct snd_soc_component *component)
2645 { 2645 {
2646 regmap_exit(component->regmap); 2646 regmap_exit(component->regmap);
2647 component->regmap = NULL; 2647 component->regmap = NULL;
2648 } 2648 }
2649 EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap); 2649 EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
2650 2650
2651 #endif 2651 #endif
2652 2652
2653 static void snd_soc_component_add_unlocked(struct snd_soc_component *component) 2653 static void snd_soc_component_add_unlocked(struct snd_soc_component *component)
2654 { 2654 {
2655 if (!component->write && !component->read) { 2655 if (!component->write && !component->read) {
2656 if (!component->regmap) 2656 if (!component->regmap)
2657 component->regmap = dev_get_regmap(component->dev, NULL); 2657 component->regmap = dev_get_regmap(component->dev, NULL);
2658 if (component->regmap) 2658 if (component->regmap)
2659 snd_soc_component_setup_regmap(component); 2659 snd_soc_component_setup_regmap(component);
2660 } 2660 }
2661 2661
2662 list_add(&component->list, &component_list); 2662 list_add(&component->list, &component_list);
2663 } 2663 }
2664 2664
2665 static void snd_soc_component_add(struct snd_soc_component *component) 2665 static void snd_soc_component_add(struct snd_soc_component *component)
2666 { 2666 {
2667 mutex_lock(&client_mutex); 2667 mutex_lock(&client_mutex);
2668 snd_soc_component_add_unlocked(component); 2668 snd_soc_component_add_unlocked(component);
2669 mutex_unlock(&client_mutex); 2669 mutex_unlock(&client_mutex);
2670 } 2670 }
2671 2671
2672 static void snd_soc_component_cleanup(struct snd_soc_component *component) 2672 static void snd_soc_component_cleanup(struct snd_soc_component *component)
2673 { 2673 {
2674 snd_soc_unregister_dais(component); 2674 snd_soc_unregister_dais(component);
2675 kfree(component->name); 2675 kfree(component->name);
2676 } 2676 }
2677 2677
2678 static void snd_soc_component_del_unlocked(struct snd_soc_component *component) 2678 static void snd_soc_component_del_unlocked(struct snd_soc_component *component)
2679 { 2679 {
2680 list_del(&component->list); 2680 list_del(&component->list);
2681 } 2681 }
2682 2682
2683 static void snd_soc_component_del(struct snd_soc_component *component) 2683 static void snd_soc_component_del(struct snd_soc_component *component)
2684 { 2684 {
2685 mutex_lock(&client_mutex); 2685 mutex_lock(&client_mutex);
2686 snd_soc_component_del_unlocked(component); 2686 snd_soc_component_del_unlocked(component);
2687 mutex_unlock(&client_mutex); 2687 mutex_unlock(&client_mutex);
2688 } 2688 }
2689 2689
2690 int snd_soc_register_component(struct device *dev, 2690 int snd_soc_register_component(struct device *dev,
2691 const struct snd_soc_component_driver *cmpnt_drv, 2691 const struct snd_soc_component_driver *cmpnt_drv,
2692 struct snd_soc_dai_driver *dai_drv, 2692 struct snd_soc_dai_driver *dai_drv,
2693 int num_dai) 2693 int num_dai)
2694 { 2694 {
2695 struct snd_soc_component *cmpnt; 2695 struct snd_soc_component *cmpnt;
2696 int ret; 2696 int ret;
2697 2697
2698 cmpnt = kzalloc(sizeof(*cmpnt), GFP_KERNEL); 2698 cmpnt = kzalloc(sizeof(*cmpnt), GFP_KERNEL);
2699 if (!cmpnt) { 2699 if (!cmpnt) {
2700 dev_err(dev, "ASoC: Failed to allocate memory\n"); 2700 dev_err(dev, "ASoC: Failed to allocate memory\n");
2701 return -ENOMEM; 2701 return -ENOMEM;
2702 } 2702 }
2703 2703
2704 ret = snd_soc_component_initialize(cmpnt, cmpnt_drv, dev); 2704 ret = snd_soc_component_initialize(cmpnt, cmpnt_drv, dev);
2705 if (ret) 2705 if (ret)
2706 goto err_free; 2706 goto err_free;
2707 2707
2708 cmpnt->ignore_pmdown_time = true; 2708 cmpnt->ignore_pmdown_time = true;
2709 cmpnt->registered_as_component = true; 2709 cmpnt->registered_as_component = true;
2710 2710
2711 ret = snd_soc_register_dais(cmpnt, dai_drv, num_dai, true); 2711 ret = snd_soc_register_dais(cmpnt, dai_drv, num_dai, true);
2712 if (ret < 0) { 2712 if (ret < 0) {
2713 dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); 2713 dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret);
2714 goto err_cleanup; 2714 goto err_cleanup;
2715 } 2715 }
2716 2716
2717 snd_soc_component_add(cmpnt); 2717 snd_soc_component_add(cmpnt);
2718 2718
2719 return 0; 2719 return 0;
2720 2720
2721 err_cleanup: 2721 err_cleanup:
2722 snd_soc_component_cleanup(cmpnt); 2722 snd_soc_component_cleanup(cmpnt);
2723 err_free: 2723 err_free:
2724 kfree(cmpnt); 2724 kfree(cmpnt);
2725 return ret; 2725 return ret;
2726 } 2726 }
2727 EXPORT_SYMBOL_GPL(snd_soc_register_component); 2727 EXPORT_SYMBOL_GPL(snd_soc_register_component);
2728 2728
2729 /** 2729 /**
2730 * snd_soc_unregister_component - Unregister a component from the ASoC core 2730 * snd_soc_unregister_component - Unregister a component from the ASoC core
2731 * 2731 *
2732 */ 2732 */
2733 void snd_soc_unregister_component(struct device *dev) 2733 void snd_soc_unregister_component(struct device *dev)
2734 { 2734 {
2735 struct snd_soc_component *cmpnt; 2735 struct snd_soc_component *cmpnt;
2736 2736
2737 list_for_each_entry(cmpnt, &component_list, list) { 2737 list_for_each_entry(cmpnt, &component_list, list) {
2738 if (dev == cmpnt->dev && cmpnt->registered_as_component) 2738 if (dev == cmpnt->dev && cmpnt->registered_as_component)
2739 goto found; 2739 goto found;
2740 } 2740 }
2741 return; 2741 return;
2742 2742
2743 found: 2743 found:
2744 snd_soc_component_del(cmpnt); 2744 snd_soc_component_del(cmpnt);
2745 snd_soc_component_cleanup(cmpnt); 2745 snd_soc_component_cleanup(cmpnt);
2746 kfree(cmpnt); 2746 kfree(cmpnt);
2747 } 2747 }
2748 EXPORT_SYMBOL_GPL(snd_soc_unregister_component); 2748 EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
2749 2749
2750 static int snd_soc_platform_drv_probe(struct snd_soc_component *component) 2750 static int snd_soc_platform_drv_probe(struct snd_soc_component *component)
2751 { 2751 {
2752 struct snd_soc_platform *platform = snd_soc_component_to_platform(component); 2752 struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
2753 2753
2754 return platform->driver->probe(platform); 2754 return platform->driver->probe(platform);
2755 } 2755 }
2756 2756
2757 static void snd_soc_platform_drv_remove(struct snd_soc_component *component) 2757 static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
2758 { 2758 {
2759 struct snd_soc_platform *platform = snd_soc_component_to_platform(component); 2759 struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
2760 2760
2761 platform->driver->remove(platform); 2761 platform->driver->remove(platform);
2762 } 2762 }
2763 2763
2764 /** 2764 /**
2765 * snd_soc_add_platform - Add a platform to the ASoC core 2765 * snd_soc_add_platform - Add a platform to the ASoC core
2766 * @dev: The parent device for the platform 2766 * @dev: The parent device for the platform
2767 * @platform: The platform to add 2767 * @platform: The platform to add
2768 * @platform_driver: The driver for the platform 2768 * @platform_driver: The driver for the platform
2769 */ 2769 */
2770 int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, 2770 int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
2771 const struct snd_soc_platform_driver *platform_drv) 2771 const struct snd_soc_platform_driver *platform_drv)
2772 { 2772 {
2773 int ret; 2773 int ret;
2774 2774
2775 ret = snd_soc_component_initialize(&platform->component, 2775 ret = snd_soc_component_initialize(&platform->component,
2776 &platform_drv->component_driver, dev); 2776 &platform_drv->component_driver, dev);
2777 if (ret) 2777 if (ret)
2778 return ret; 2778 return ret;
2779 2779
2780 platform->dev = dev; 2780 platform->dev = dev;
2781 platform->driver = platform_drv; 2781 platform->driver = platform_drv;
2782 2782
2783 if (platform_drv->probe) 2783 if (platform_drv->probe)
2784 platform->component.probe = snd_soc_platform_drv_probe; 2784 platform->component.probe = snd_soc_platform_drv_probe;
2785 if (platform_drv->remove) 2785 if (platform_drv->remove)
2786 platform->component.remove = snd_soc_platform_drv_remove; 2786 platform->component.remove = snd_soc_platform_drv_remove;
2787 2787
2788 #ifdef CONFIG_DEBUG_FS 2788 #ifdef CONFIG_DEBUG_FS
2789 platform->component.debugfs_prefix = "platform"; 2789 platform->component.debugfs_prefix = "platform";
2790 #endif 2790 #endif
2791 2791
2792 mutex_lock(&client_mutex); 2792 mutex_lock(&client_mutex);
2793 snd_soc_component_add_unlocked(&platform->component); 2793 snd_soc_component_add_unlocked(&platform->component);
2794 list_add(&platform->list, &platform_list); 2794 list_add(&platform->list, &platform_list);
2795 mutex_unlock(&client_mutex); 2795 mutex_unlock(&client_mutex);
2796 2796
2797 dev_dbg(dev, "ASoC: Registered platform '%s'\n", 2797 dev_dbg(dev, "ASoC: Registered platform '%s'\n",
2798 platform->component.name); 2798 platform->component.name);
2799 2799
2800 return 0; 2800 return 0;
2801 } 2801 }
2802 EXPORT_SYMBOL_GPL(snd_soc_add_platform); 2802 EXPORT_SYMBOL_GPL(snd_soc_add_platform);
2803 2803
2804 /** 2804 /**
2805 * snd_soc_register_platform - Register a platform with the ASoC core 2805 * snd_soc_register_platform - Register a platform with the ASoC core
2806 * 2806 *
2807 * @platform: platform to register 2807 * @platform: platform to register
2808 */ 2808 */
2809 int snd_soc_register_platform(struct device *dev, 2809 int snd_soc_register_platform(struct device *dev,
2810 const struct snd_soc_platform_driver *platform_drv) 2810 const struct snd_soc_platform_driver *platform_drv)
2811 { 2811 {
2812 struct snd_soc_platform *platform; 2812 struct snd_soc_platform *platform;
2813 int ret; 2813 int ret;
2814 2814
2815 dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev)); 2815 dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev));
2816 2816
2817 platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); 2817 platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL);
2818 if (platform == NULL) 2818 if (platform == NULL)
2819 return -ENOMEM; 2819 return -ENOMEM;
2820 2820
2821 ret = snd_soc_add_platform(dev, platform, platform_drv); 2821 ret = snd_soc_add_platform(dev, platform, platform_drv);
2822 if (ret) 2822 if (ret)
2823 kfree(platform); 2823 kfree(platform);
2824 2824
2825 return ret; 2825 return ret;
2826 } 2826 }
2827 EXPORT_SYMBOL_GPL(snd_soc_register_platform); 2827 EXPORT_SYMBOL_GPL(snd_soc_register_platform);
2828 2828
2829 /** 2829 /**
2830 * snd_soc_remove_platform - Remove a platform from the ASoC core 2830 * snd_soc_remove_platform - Remove a platform from the ASoC core
2831 * @platform: the platform to remove 2831 * @platform: the platform to remove
2832 */ 2832 */
2833 void snd_soc_remove_platform(struct snd_soc_platform *platform) 2833 void snd_soc_remove_platform(struct snd_soc_platform *platform)
2834 { 2834 {
2835 2835
2836 mutex_lock(&client_mutex); 2836 mutex_lock(&client_mutex);
2837 list_del(&platform->list); 2837 list_del(&platform->list);
2838 snd_soc_component_del_unlocked(&platform->component); 2838 snd_soc_component_del_unlocked(&platform->component);
2839 mutex_unlock(&client_mutex); 2839 mutex_unlock(&client_mutex);
2840 2840
2841 dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n", 2841 dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n",
2842 platform->component.name); 2842 platform->component.name);
2843 2843
2844 snd_soc_component_cleanup(&platform->component); 2844 snd_soc_component_cleanup(&platform->component);
2845 } 2845 }
2846 EXPORT_SYMBOL_GPL(snd_soc_remove_platform); 2846 EXPORT_SYMBOL_GPL(snd_soc_remove_platform);
2847 2847
2848 struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev) 2848 struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev)
2849 { 2849 {
2850 struct snd_soc_platform *platform; 2850 struct snd_soc_platform *platform;
2851 2851
2852 list_for_each_entry(platform, &platform_list, list) { 2852 list_for_each_entry(platform, &platform_list, list) {
2853 if (dev == platform->dev) 2853 if (dev == platform->dev)
2854 return platform; 2854 return platform;
2855 } 2855 }
2856 2856
2857 return NULL; 2857 return NULL;
2858 } 2858 }
2859 EXPORT_SYMBOL_GPL(snd_soc_lookup_platform); 2859 EXPORT_SYMBOL_GPL(snd_soc_lookup_platform);
2860 2860
2861 /** 2861 /**
2862 * snd_soc_unregister_platform - Unregister a platform from the ASoC core 2862 * snd_soc_unregister_platform - Unregister a platform from the ASoC core
2863 * 2863 *
2864 * @platform: platform to unregister 2864 * @platform: platform to unregister
2865 */ 2865 */
2866 void snd_soc_unregister_platform(struct device *dev) 2866 void snd_soc_unregister_platform(struct device *dev)
2867 { 2867 {
2868 struct snd_soc_platform *platform; 2868 struct snd_soc_platform *platform;
2869 2869
2870 platform = snd_soc_lookup_platform(dev); 2870 platform = snd_soc_lookup_platform(dev);
2871 if (!platform) 2871 if (!platform)
2872 return; 2872 return;
2873 2873
2874 snd_soc_remove_platform(platform); 2874 snd_soc_remove_platform(platform);
2875 kfree(platform); 2875 kfree(platform);
2876 } 2876 }
2877 EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); 2877 EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
2878 2878
2879 static u64 codec_format_map[] = { 2879 static u64 codec_format_map[] = {
2880 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, 2880 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE,
2881 SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE, 2881 SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE,
2882 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE, 2882 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE,
2883 SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE, 2883 SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE,
2884 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE, 2884 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE,
2885 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE, 2885 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE,
2886 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3BE, 2886 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3BE,
2887 SNDRV_PCM_FMTBIT_U24_3LE | SNDRV_PCM_FMTBIT_U24_3BE, 2887 SNDRV_PCM_FMTBIT_U24_3LE | SNDRV_PCM_FMTBIT_U24_3BE,
2888 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE, 2888 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE,
2889 SNDRV_PCM_FMTBIT_U20_3LE | SNDRV_PCM_FMTBIT_U20_3BE, 2889 SNDRV_PCM_FMTBIT_U20_3LE | SNDRV_PCM_FMTBIT_U20_3BE,
2890 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE, 2890 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE,
2891 SNDRV_PCM_FMTBIT_U18_3LE | SNDRV_PCM_FMTBIT_U18_3BE, 2891 SNDRV_PCM_FMTBIT_U18_3LE | SNDRV_PCM_FMTBIT_U18_3BE,
2892 SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE, 2892 SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE,
2893 SNDRV_PCM_FMTBIT_FLOAT64_LE | SNDRV_PCM_FMTBIT_FLOAT64_BE, 2893 SNDRV_PCM_FMTBIT_FLOAT64_LE | SNDRV_PCM_FMTBIT_FLOAT64_BE,
2894 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE 2894 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
2895 | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE, 2895 | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE,
2896 }; 2896 };
2897 2897
2898 /* Fix up the DAI formats for endianness: codecs don't actually see 2898 /* Fix up the DAI formats for endianness: codecs don't actually see
2899 * the endianness of the data but we're using the CPU format 2899 * the endianness of the data but we're using the CPU format
2900 * definitions which do need to include endianness so we ensure that 2900 * definitions which do need to include endianness so we ensure that
2901 * codec DAIs always have both big and little endian variants set. 2901 * codec DAIs always have both big and little endian variants set.
2902 */ 2902 */
2903 static void fixup_codec_formats(struct snd_soc_pcm_stream *stream) 2903 static void fixup_codec_formats(struct snd_soc_pcm_stream *stream)
2904 { 2904 {
2905 int i; 2905 int i;
2906 2906
2907 for (i = 0; i < ARRAY_SIZE(codec_format_map); i++) 2907 for (i = 0; i < ARRAY_SIZE(codec_format_map); i++)
2908 if (stream->formats & codec_format_map[i]) 2908 if (stream->formats & codec_format_map[i])
2909 stream->formats |= codec_format_map[i]; 2909 stream->formats |= codec_format_map[i];
2910 } 2910 }
2911 2911
2912 static int snd_soc_codec_drv_probe(struct snd_soc_component *component) 2912 static int snd_soc_codec_drv_probe(struct snd_soc_component *component)
2913 { 2913 {
2914 struct snd_soc_codec *codec = snd_soc_component_to_codec(component); 2914 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
2915 2915
2916 return codec->driver->probe(codec); 2916 return codec->driver->probe(codec);
2917 } 2917 }
2918 2918
2919 static void snd_soc_codec_drv_remove(struct snd_soc_component *component) 2919 static void snd_soc_codec_drv_remove(struct snd_soc_component *component)
2920 { 2920 {
2921 struct snd_soc_codec *codec = snd_soc_component_to_codec(component); 2921 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
2922 2922
2923 codec->driver->remove(codec); 2923 codec->driver->remove(codec);
2924 } 2924 }
2925 2925
2926 static int snd_soc_codec_drv_write(struct snd_soc_component *component, 2926 static int snd_soc_codec_drv_write(struct snd_soc_component *component,
2927 unsigned int reg, unsigned int val) 2927 unsigned int reg, unsigned int val)
2928 { 2928 {
2929 struct snd_soc_codec *codec = snd_soc_component_to_codec(component); 2929 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
2930 2930
2931 return codec->driver->write(codec, reg, val); 2931 return codec->driver->write(codec, reg, val);
2932 } 2932 }
2933 2933
2934 static int snd_soc_codec_drv_read(struct snd_soc_component *component, 2934 static int snd_soc_codec_drv_read(struct snd_soc_component *component,
2935 unsigned int reg, unsigned int *val) 2935 unsigned int reg, unsigned int *val)
2936 { 2936 {
2937 struct snd_soc_codec *codec = snd_soc_component_to_codec(component); 2937 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
2938 2938
2939 *val = codec->driver->read(codec, reg); 2939 *val = codec->driver->read(codec, reg);
2940 2940
2941 return 0; 2941 return 0;
2942 } 2942 }
2943 2943
2944 static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm, 2944 static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm,
2945 enum snd_soc_bias_level level) 2945 enum snd_soc_bias_level level)
2946 { 2946 {
2947 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); 2947 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
2948 2948
2949 return codec->driver->set_bias_level(codec, level); 2949 return codec->driver->set_bias_level(codec, level);
2950 } 2950 }
2951 2951
2952 /** 2952 /**
2953 * snd_soc_register_codec - Register a codec with the ASoC core 2953 * snd_soc_register_codec - Register a codec with the ASoC core
2954 * 2954 *
2955 * @codec: codec to register 2955 * @codec: codec to register
2956 */ 2956 */
2957 int snd_soc_register_codec(struct device *dev, 2957 int snd_soc_register_codec(struct device *dev,
2958 const struct snd_soc_codec_driver *codec_drv, 2958 const struct snd_soc_codec_driver *codec_drv,
2959 struct snd_soc_dai_driver *dai_drv, 2959 struct snd_soc_dai_driver *dai_drv,
2960 int num_dai) 2960 int num_dai)
2961 { 2961 {
2962 struct snd_soc_codec *codec; 2962 struct snd_soc_codec *codec;
2963 struct snd_soc_dai *dai; 2963 struct snd_soc_dai *dai;
2964 int ret, i; 2964 int ret, i;
2965 2965
2966 dev_dbg(dev, "codec register %s\n", dev_name(dev)); 2966 dev_dbg(dev, "codec register %s\n", dev_name(dev));
2967 2967
2968 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); 2968 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
2969 if (codec == NULL) 2969 if (codec == NULL)
2970 return -ENOMEM; 2970 return -ENOMEM;
2971 2971
2972 codec->component.dapm_ptr = &codec->dapm; 2972 codec->component.dapm_ptr = &codec->dapm;
2973 codec->component.codec = codec; 2973 codec->component.codec = codec;
2974 2974
2975 ret = snd_soc_component_initialize(&codec->component, 2975 ret = snd_soc_component_initialize(&codec->component,
2976 &codec_drv->component_driver, dev); 2976 &codec_drv->component_driver, dev);
2977 if (ret) 2977 if (ret)
2978 goto err_free; 2978 goto err_free;
2979 2979
2980 if (codec_drv->controls) { 2980 if (codec_drv->controls) {
2981 codec->component.controls = codec_drv->controls; 2981 codec->component.controls = codec_drv->controls;
2982 codec->component.num_controls = codec_drv->num_controls; 2982 codec->component.num_controls = codec_drv->num_controls;
2983 } 2983 }
2984 if (codec_drv->dapm_widgets) { 2984 if (codec_drv->dapm_widgets) {
2985 codec->component.dapm_widgets = codec_drv->dapm_widgets; 2985 codec->component.dapm_widgets = codec_drv->dapm_widgets;
2986 codec->component.num_dapm_widgets = codec_drv->num_dapm_widgets; 2986 codec->component.num_dapm_widgets = codec_drv->num_dapm_widgets;
2987 } 2987 }
2988 if (codec_drv->dapm_routes) { 2988 if (codec_drv->dapm_routes) {
2989 codec->component.dapm_routes = codec_drv->dapm_routes; 2989 codec->component.dapm_routes = codec_drv->dapm_routes;
2990 codec->component.num_dapm_routes = codec_drv->num_dapm_routes; 2990 codec->component.num_dapm_routes = codec_drv->num_dapm_routes;
2991 } 2991 }
2992 2992
2993 if (codec_drv->probe) 2993 if (codec_drv->probe)
2994 codec->component.probe = snd_soc_codec_drv_probe; 2994 codec->component.probe = snd_soc_codec_drv_probe;
2995 if (codec_drv->remove) 2995 if (codec_drv->remove)
2996 codec->component.remove = snd_soc_codec_drv_remove; 2996 codec->component.remove = snd_soc_codec_drv_remove;
2997 if (codec_drv->write) 2997 if (codec_drv->write)
2998 codec->component.write = snd_soc_codec_drv_write; 2998 codec->component.write = snd_soc_codec_drv_write;
2999 if (codec_drv->read) 2999 if (codec_drv->read)
3000 codec->component.read = snd_soc_codec_drv_read; 3000 codec->component.read = snd_soc_codec_drv_read;
3001 codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; 3001 codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time;
3002 codec->dapm.idle_bias_off = codec_drv->idle_bias_off; 3002 codec->dapm.idle_bias_off = codec_drv->idle_bias_off;
3003 codec->dapm.suspend_bias_off = codec_drv->suspend_bias_off; 3003 codec->dapm.suspend_bias_off = codec_drv->suspend_bias_off;
3004 if (codec_drv->seq_notifier) 3004 if (codec_drv->seq_notifier)
3005 codec->dapm.seq_notifier = codec_drv->seq_notifier; 3005 codec->dapm.seq_notifier = codec_drv->seq_notifier;
3006 if (codec_drv->set_bias_level) 3006 if (codec_drv->set_bias_level)
3007 codec->dapm.set_bias_level = snd_soc_codec_set_bias_level; 3007 codec->dapm.set_bias_level = snd_soc_codec_set_bias_level;
3008 codec->dev = dev; 3008 codec->dev = dev;
3009 codec->driver = codec_drv; 3009 codec->driver = codec_drv;
3010 codec->component.val_bytes = codec_drv->reg_word_size; 3010 codec->component.val_bytes = codec_drv->reg_word_size;
3011 3011
3012 #ifdef CONFIG_DEBUG_FS 3012 #ifdef CONFIG_DEBUG_FS
3013 codec->component.init_debugfs = soc_init_codec_debugfs; 3013 codec->component.init_debugfs = soc_init_codec_debugfs;
3014 codec->component.debugfs_prefix = "codec"; 3014 codec->component.debugfs_prefix = "codec";
3015 #endif 3015 #endif
3016 3016
3017 if (codec_drv->get_regmap) 3017 if (codec_drv->get_regmap)
3018 codec->component.regmap = codec_drv->get_regmap(dev); 3018 codec->component.regmap = codec_drv->get_regmap(dev);
3019 3019
3020 for (i = 0; i < num_dai; i++) { 3020 for (i = 0; i < num_dai; i++) {
3021 fixup_codec_formats(&dai_drv[i].playback); 3021 fixup_codec_formats(&dai_drv[i].playback);
3022 fixup_codec_formats(&dai_drv[i].capture); 3022 fixup_codec_formats(&dai_drv[i].capture);
3023 } 3023 }
3024 3024
3025 ret = snd_soc_register_dais(&codec->component, dai_drv, num_dai, false); 3025 ret = snd_soc_register_dais(&codec->component, dai_drv, num_dai, false);
3026 if (ret < 0) { 3026 if (ret < 0) {
3027 dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); 3027 dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret);
3028 goto err_cleanup; 3028 goto err_cleanup;
3029 } 3029 }
3030 3030
3031 list_for_each_entry(dai, &codec->component.dai_list, list) 3031 list_for_each_entry(dai, &codec->component.dai_list, list)
3032 dai->codec = codec; 3032 dai->codec = codec;
3033 3033
3034 mutex_lock(&client_mutex); 3034 mutex_lock(&client_mutex);
3035 snd_soc_component_add_unlocked(&codec->component); 3035 snd_soc_component_add_unlocked(&codec->component);
3036 list_add(&codec->list, &codec_list); 3036 list_add(&codec->list, &codec_list);
3037 mutex_unlock(&client_mutex); 3037 mutex_unlock(&client_mutex);
3038 3038
3039 dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n", 3039 dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n",
3040 codec->component.name); 3040 codec->component.name);
3041 return 0; 3041 return 0;
3042 3042
3043 err_cleanup: 3043 err_cleanup:
3044 snd_soc_component_cleanup(&codec->component); 3044 snd_soc_component_cleanup(&codec->component);
3045 err_free: 3045 err_free:
3046 kfree(codec); 3046 kfree(codec);
3047 return ret; 3047 return ret;
3048 } 3048 }
3049 EXPORT_SYMBOL_GPL(snd_soc_register_codec); 3049 EXPORT_SYMBOL_GPL(snd_soc_register_codec);
3050 3050
3051 /** 3051 /**
3052 * snd_soc_unregister_codec - Unregister a codec from the ASoC core 3052 * snd_soc_unregister_codec - Unregister a codec from the ASoC core
3053 * 3053 *
3054 * @codec: codec to unregister 3054 * @codec: codec to unregister
3055 */ 3055 */
3056 void snd_soc_unregister_codec(struct device *dev) 3056 void snd_soc_unregister_codec(struct device *dev)
3057 { 3057 {
3058 struct snd_soc_codec *codec; 3058 struct snd_soc_codec *codec;
3059 3059
3060 list_for_each_entry(codec, &codec_list, list) { 3060 list_for_each_entry(codec, &codec_list, list) {
3061 if (dev == codec->dev) 3061 if (dev == codec->dev)
3062 goto found; 3062 goto found;
3063 } 3063 }
3064 return; 3064 return;
3065 3065
3066 found: 3066 found:
3067 3067
3068 mutex_lock(&client_mutex); 3068 mutex_lock(&client_mutex);
3069 list_del(&codec->list); 3069 list_del(&codec->list);
3070 snd_soc_component_del_unlocked(&codec->component); 3070 snd_soc_component_del_unlocked(&codec->component);
3071 mutex_unlock(&client_mutex); 3071 mutex_unlock(&client_mutex);
3072 3072
3073 dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", 3073 dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n",
3074 codec->component.name); 3074 codec->component.name);
3075 3075
3076 snd_soc_component_cleanup(&codec->component); 3076 snd_soc_component_cleanup(&codec->component);
3077 snd_soc_cache_exit(codec); 3077 snd_soc_cache_exit(codec);
3078 kfree(codec); 3078 kfree(codec);
3079 } 3079 }
3080 EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); 3080 EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
3081 3081
3082 /* Retrieve a card's name from device tree */ 3082 /* Retrieve a card's name from device tree */
3083 int snd_soc_of_parse_card_name(struct snd_soc_card *card, 3083 int snd_soc_of_parse_card_name(struct snd_soc_card *card,
3084 const char *propname) 3084 const char *propname)
3085 { 3085 {
3086 struct device_node *np; 3086 struct device_node *np;
3087 int ret; 3087 int ret;
3088 3088
3089 if (!card->dev) { 3089 if (!card->dev) {
3090 pr_err("card->dev is not set before calling %s\n", __func__); 3090 pr_err("card->dev is not set before calling %s\n", __func__);
3091 return -EINVAL; 3091 return -EINVAL;
3092 } 3092 }
3093 3093
3094 np = card->dev->of_node; 3094 np = card->dev->of_node;
3095 3095
3096 ret = of_property_read_string_index(np, propname, 0, &card->name); 3096 ret = of_property_read_string_index(np, propname, 0, &card->name);
3097 /* 3097 /*
3098 * EINVAL means the property does not exist. This is fine providing 3098 * EINVAL means the property does not exist. This is fine providing
3099 * card->name was previously set, which is checked later in 3099 * card->name was previously set, which is checked later in
3100 * snd_soc_register_card. 3100 * snd_soc_register_card.
3101 */ 3101 */
3102 if (ret < 0 && ret != -EINVAL) { 3102 if (ret < 0 && ret != -EINVAL) {
3103 dev_err(card->dev, 3103 dev_err(card->dev,
3104 "ASoC: Property '%s' could not be read: %d\n", 3104 "ASoC: Property '%s' could not be read: %d\n",
3105 propname, ret); 3105 propname, ret);
3106 return ret; 3106 return ret;
3107 } 3107 }
3108 3108
3109 return 0; 3109 return 0;
3110 } 3110 }
3111 EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name); 3111 EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name);
3112 3112
3113 static const struct snd_soc_dapm_widget simple_widgets[] = { 3113 static const struct snd_soc_dapm_widget simple_widgets[] = {
3114 SND_SOC_DAPM_MIC("Microphone", NULL), 3114 SND_SOC_DAPM_MIC("Microphone", NULL),
3115 SND_SOC_DAPM_LINE("Line", NULL), 3115 SND_SOC_DAPM_LINE("Line", NULL),
3116 SND_SOC_DAPM_HP("Headphone", NULL), 3116 SND_SOC_DAPM_HP("Headphone", NULL),
3117 SND_SOC_DAPM_SPK("Speaker", NULL), 3117 SND_SOC_DAPM_SPK("Speaker", NULL),
3118 }; 3118 };
3119 3119
3120 int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card, 3120 int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
3121 const char *propname) 3121 const char *propname)
3122 { 3122 {
3123 struct device_node *np = card->dev->of_node; 3123 struct device_node *np = card->dev->of_node;
3124 struct snd_soc_dapm_widget *widgets; 3124 struct snd_soc_dapm_widget *widgets;
3125 const char *template, *wname; 3125 const char *template, *wname;
3126 int i, j, num_widgets, ret; 3126 int i, j, num_widgets, ret;
3127 3127
3128 num_widgets = of_property_count_strings(np, propname); 3128 num_widgets = of_property_count_strings(np, propname);
3129 if (num_widgets < 0) { 3129 if (num_widgets < 0) {
3130 dev_err(card->dev, 3130 dev_err(card->dev,
3131 "ASoC: Property '%s' does not exist\n", propname); 3131 "ASoC: Property '%s' does not exist\n", propname);
3132 return -EINVAL; 3132 return -EINVAL;
3133 } 3133 }
3134 if (num_widgets & 1) { 3134 if (num_widgets & 1) {
3135 dev_err(card->dev, 3135 dev_err(card->dev,
3136 "ASoC: Property '%s' length is not even\n", propname); 3136 "ASoC: Property '%s' length is not even\n", propname);
3137 return -EINVAL; 3137 return -EINVAL;
3138 } 3138 }
3139 3139
3140 num_widgets /= 2; 3140 num_widgets /= 2;
3141 if (!num_widgets) { 3141 if (!num_widgets) {
3142 dev_err(card->dev, "ASoC: Property '%s's length is zero\n", 3142 dev_err(card->dev, "ASoC: Property '%s's length is zero\n",
3143 propname); 3143 propname);
3144 return -EINVAL; 3144 return -EINVAL;
3145 } 3145 }
3146 3146
3147 widgets = devm_kcalloc(card->dev, num_widgets, sizeof(*widgets), 3147 widgets = devm_kcalloc(card->dev, num_widgets, sizeof(*widgets),
3148 GFP_KERNEL); 3148 GFP_KERNEL);
3149 if (!widgets) { 3149 if (!widgets) {
3150 dev_err(card->dev, 3150 dev_err(card->dev,
3151 "ASoC: Could not allocate memory for widgets\n"); 3151 "ASoC: Could not allocate memory for widgets\n");
3152 return -ENOMEM; 3152 return -ENOMEM;
3153 } 3153 }
3154 3154
3155 for (i = 0; i < num_widgets; i++) { 3155 for (i = 0; i < num_widgets; i++) {
3156 ret = of_property_read_string_index(np, propname, 3156 ret = of_property_read_string_index(np, propname,
3157 2 * i, &template); 3157 2 * i, &template);
3158 if (ret) { 3158 if (ret) {
3159 dev_err(card->dev, 3159 dev_err(card->dev,
3160 "ASoC: Property '%s' index %d read error:%d\n", 3160 "ASoC: Property '%s' index %d read error:%d\n",
3161 propname, 2 * i, ret); 3161 propname, 2 * i, ret);
3162 return -EINVAL; 3162 return -EINVAL;
3163 } 3163 }
3164 3164
3165 for (j = 0; j < ARRAY_SIZE(simple_widgets); j++) { 3165 for (j = 0; j < ARRAY_SIZE(simple_widgets); j++) {
3166 if (!strncmp(template, simple_widgets[j].name, 3166 if (!strncmp(template, simple_widgets[j].name,
3167 strlen(simple_widgets[j].name))) { 3167 strlen(simple_widgets[j].name))) {
3168 widgets[i] = simple_widgets[j]; 3168 widgets[i] = simple_widgets[j];
3169 break; 3169 break;
3170 } 3170 }
3171 } 3171 }
3172 3172
3173 if (j >= ARRAY_SIZE(simple_widgets)) { 3173 if (j >= ARRAY_SIZE(simple_widgets)) {
3174 dev_err(card->dev, 3174 dev_err(card->dev,
3175 "ASoC: DAPM widget '%s' is not supported\n", 3175 "ASoC: DAPM widget '%s' is not supported\n",
3176 template); 3176 template);
3177 return -EINVAL; 3177 return -EINVAL;
3178 } 3178 }
3179 3179
3180 ret = of_property_read_string_index(np, propname, 3180 ret = of_property_read_string_index(np, propname,
3181 (2 * i) + 1, 3181 (2 * i) + 1,
3182 &wname); 3182 &wname);
3183 if (ret) { 3183 if (ret) {
3184 dev_err(card->dev, 3184 dev_err(card->dev,
3185 "ASoC: Property '%s' index %d read error:%d\n", 3185 "ASoC: Property '%s' index %d read error:%d\n",
3186 propname, (2 * i) + 1, ret); 3186 propname, (2 * i) + 1, ret);
3187 return -EINVAL; 3187 return -EINVAL;
3188 } 3188 }
3189 3189
3190 widgets[i].name = wname; 3190 widgets[i].name = wname;
3191 } 3191 }
3192 3192
3193 card->dapm_widgets = widgets; 3193 card->dapm_widgets = widgets;
3194 card->num_dapm_widgets = num_widgets; 3194 card->num_dapm_widgets = num_widgets;
3195 3195
3196 return 0; 3196 return 0;
3197 } 3197 }
3198 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_simple_widgets); 3198 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_simple_widgets);
3199 3199
3200 int snd_soc_of_parse_tdm_slot(struct device_node *np, 3200 int snd_soc_of_parse_tdm_slot(struct device_node *np,
3201 unsigned int *slots, 3201 unsigned int *slots,
3202 unsigned int *slot_width) 3202 unsigned int *slot_width)
3203 { 3203 {
3204 u32 val; 3204 u32 val;
3205 int ret; 3205 int ret;
3206 3206
3207 if (of_property_read_bool(np, "dai-tdm-slot-num")) { 3207 if (of_property_read_bool(np, "dai-tdm-slot-num")) {
3208 ret = of_property_read_u32(np, "dai-tdm-slot-num", &val); 3208 ret = of_property_read_u32(np, "dai-tdm-slot-num", &val);
3209 if (ret) 3209 if (ret)
3210 return ret; 3210 return ret;
3211 3211
3212 if (slots) 3212 if (slots)
3213 *slots = val; 3213 *slots = val;
3214 } 3214 }
3215 3215
3216 if (of_property_read_bool(np, "dai-tdm-slot-width")) { 3216 if (of_property_read_bool(np, "dai-tdm-slot-width")) {
3217 ret = of_property_read_u32(np, "dai-tdm-slot-width", &val); 3217 ret = of_property_read_u32(np, "dai-tdm-slot-width", &val);
3218 if (ret) 3218 if (ret)
3219 return ret; 3219 return ret;
3220 3220
3221 if (slot_width) 3221 if (slot_width)
3222 *slot_width = val; 3222 *slot_width = val;
3223 } 3223 }
3224 3224
3225 return 0; 3225 return 0;
3226 } 3226 }
3227 EXPORT_SYMBOL_GPL(snd_soc_of_parse_tdm_slot); 3227 EXPORT_SYMBOL_GPL(snd_soc_of_parse_tdm_slot);
3228 3228
3229 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, 3229 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3230 const char *propname) 3230 const char *propname)
3231 { 3231 {
3232 struct device_node *np = card->dev->of_node; 3232 struct device_node *np = card->dev->of_node;
3233 int num_routes, old_routes; 3233 int num_routes;
3234 struct snd_soc_dapm_route *routes; 3234 struct snd_soc_dapm_route *routes;
3235 int i, ret; 3235 int i, ret;
3236 3236
3237 num_routes = of_property_count_strings(np, propname); 3237 num_routes = of_property_count_strings(np, propname);
3238 if (num_routes < 0 || num_routes & 1) { 3238 if (num_routes < 0 || num_routes & 1) {
3239 dev_err(card->dev, 3239 dev_err(card->dev,
3240 "ASoC: Property '%s' does not exist or its length is not even\n", 3240 "ASoC: Property '%s' does not exist or its length is not even\n",
3241 propname); 3241 propname);
3242 return -EINVAL; 3242 return -EINVAL;
3243 } 3243 }
3244 num_routes /= 2; 3244 num_routes /= 2;
3245 if (!num_routes) { 3245 if (!num_routes) {
3246 dev_err(card->dev, "ASoC: Property '%s's length is zero\n", 3246 dev_err(card->dev, "ASoC: Property '%s's length is zero\n",
3247 propname); 3247 propname);
3248 return -EINVAL; 3248 return -EINVAL;
3249 } 3249 }
3250 3250
3251 old_routes = card->num_dapm_routes; 3251 routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
3252 routes = devm_kzalloc(card->dev,
3253 (old_routes + num_routes) * sizeof(*routes),
3254 GFP_KERNEL); 3252 GFP_KERNEL);
3255 if (!routes) { 3253 if (!routes) {
3256 dev_err(card->dev, 3254 dev_err(card->dev,
3257 "ASoC: Could not allocate DAPM route table\n"); 3255 "ASoC: Could not allocate DAPM route table\n");
3258 return -EINVAL; 3256 return -EINVAL;
3259 } 3257 }
3260 3258
3261 memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));
3262
3263 for (i = 0; i < num_routes; i++) { 3259 for (i = 0; i < num_routes; i++) {
3264 ret = of_property_read_string_index(np, propname, 3260 ret = of_property_read_string_index(np, propname,
3265 2 * i, &routes[old_routes + i].sink); 3261 2 * i, &routes[i].sink);
3266 if (ret) { 3262 if (ret) {
3267 dev_err(card->dev, 3263 dev_err(card->dev,
3268 "ASoC: Property '%s' index %d could not be read: %d\n", 3264 "ASoC: Property '%s' index %d could not be read: %d\n",
3269 propname, 2 * i, ret); 3265 propname, 2 * i, ret);
3270 return -EINVAL; 3266 return -EINVAL;
3271 } 3267 }
3272 ret = of_property_read_string_index(np, propname, 3268 ret = of_property_read_string_index(np, propname,
3273 (2 * i) + 1, &routes[old_routes + i].source); 3269 (2 * i) + 1, &routes[i].source);
3274 if (ret) { 3270 if (ret) {
3275 dev_err(card->dev, 3271 dev_err(card->dev,
3276 "ASoC: Property '%s' index %d could not be read: %d\n", 3272 "ASoC: Property '%s' index %d could not be read: %d\n",
3277 propname, (2 * i) + 1, ret); 3273 propname, (2 * i) + 1, ret);
3278 return -EINVAL; 3274 return -EINVAL;
3279 } 3275 }
3280 } 3276 }
3281 3277
3282 card->num_dapm_routes += num_routes; 3278 card->num_dapm_routes = num_routes;
3283 card->dapm_routes = routes; 3279 card->dapm_routes = routes;
3284 3280
3285 return 0; 3281 return 0;
3286 } 3282 }
3287 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing); 3283 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing);
3288 3284
3289 unsigned int snd_soc_of_parse_daifmt(struct device_node *np, 3285 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
3290 const char *prefix, 3286 const char *prefix,
3291 struct device_node **bitclkmaster, 3287 struct device_node **bitclkmaster,
3292 struct device_node **framemaster) 3288 struct device_node **framemaster)
3293 { 3289 {
3294 int ret, i; 3290 int ret, i;
3295 char prop[128]; 3291 char prop[128];
3296 unsigned int format = 0; 3292 unsigned int format = 0;
3297 int bit, frame; 3293 int bit, frame;
3298 const char *str; 3294 const char *str;
3299 struct { 3295 struct {
3300 char *name; 3296 char *name;
3301 unsigned int val; 3297 unsigned int val;
3302 } of_fmt_table[] = { 3298 } of_fmt_table[] = {
3303 { "i2s", SND_SOC_DAIFMT_I2S }, 3299 { "i2s", SND_SOC_DAIFMT_I2S },
3304 { "right_j", SND_SOC_DAIFMT_RIGHT_J }, 3300 { "right_j", SND_SOC_DAIFMT_RIGHT_J },
3305 { "left_j", SND_SOC_DAIFMT_LEFT_J }, 3301 { "left_j", SND_SOC_DAIFMT_LEFT_J },
3306 { "dsp_a", SND_SOC_DAIFMT_DSP_A }, 3302 { "dsp_a", SND_SOC_DAIFMT_DSP_A },
3307 { "dsp_b", SND_SOC_DAIFMT_DSP_B }, 3303 { "dsp_b", SND_SOC_DAIFMT_DSP_B },
3308 { "ac97", SND_SOC_DAIFMT_AC97 }, 3304 { "ac97", SND_SOC_DAIFMT_AC97 },
3309 { "pdm", SND_SOC_DAIFMT_PDM}, 3305 { "pdm", SND_SOC_DAIFMT_PDM},
3310 { "msb", SND_SOC_DAIFMT_MSB }, 3306 { "msb", SND_SOC_DAIFMT_MSB },
3311 { "lsb", SND_SOC_DAIFMT_LSB }, 3307 { "lsb", SND_SOC_DAIFMT_LSB },
3312 }; 3308 };
3313 3309
3314 if (!prefix) 3310 if (!prefix)
3315 prefix = ""; 3311 prefix = "";
3316 3312
3317 /* 3313 /*
3318 * check "[prefix]format = xxx" 3314 * check "[prefix]format = xxx"
3319 * SND_SOC_DAIFMT_FORMAT_MASK area 3315 * SND_SOC_DAIFMT_FORMAT_MASK area
3320 */ 3316 */
3321 snprintf(prop, sizeof(prop), "%sformat", prefix); 3317 snprintf(prop, sizeof(prop), "%sformat", prefix);
3322 ret = of_property_read_string(np, prop, &str); 3318 ret = of_property_read_string(np, prop, &str);
3323 if (ret == 0) { 3319 if (ret == 0) {
3324 for (i = 0; i < ARRAY_SIZE(of_fmt_table); i++) { 3320 for (i = 0; i < ARRAY_SIZE(of_fmt_table); i++) {
3325 if (strcmp(str, of_fmt_table[i].name) == 0) { 3321 if (strcmp(str, of_fmt_table[i].name) == 0) {
3326 format |= of_fmt_table[i].val; 3322 format |= of_fmt_table[i].val;
3327 break; 3323 break;
3328 } 3324 }
3329 } 3325 }
3330 } 3326 }
3331 3327
3332 /* 3328 /*
3333 * check "[prefix]continuous-clock" 3329 * check "[prefix]continuous-clock"
3334 * SND_SOC_DAIFMT_CLOCK_MASK area 3330 * SND_SOC_DAIFMT_CLOCK_MASK area
3335 */ 3331 */
3336 snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix); 3332 snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix);
3337 if (of_get_property(np, prop, NULL)) 3333 if (of_get_property(np, prop, NULL))
3338 format |= SND_SOC_DAIFMT_CONT; 3334 format |= SND_SOC_DAIFMT_CONT;
3339 else 3335 else
3340 format |= SND_SOC_DAIFMT_GATED; 3336 format |= SND_SOC_DAIFMT_GATED;
3341 3337
3342 /* 3338 /*
3343 * check "[prefix]bitclock-inversion" 3339 * check "[prefix]bitclock-inversion"
3344 * check "[prefix]frame-inversion" 3340 * check "[prefix]frame-inversion"
3345 * SND_SOC_DAIFMT_INV_MASK area 3341 * SND_SOC_DAIFMT_INV_MASK area
3346 */ 3342 */
3347 snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix); 3343 snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix);
3348 bit = !!of_get_property(np, prop, NULL); 3344 bit = !!of_get_property(np, prop, NULL);
3349 3345
3350 snprintf(prop, sizeof(prop), "%sframe-inversion", prefix); 3346 snprintf(prop, sizeof(prop), "%sframe-inversion", prefix);
3351 frame = !!of_get_property(np, prop, NULL); 3347 frame = !!of_get_property(np, prop, NULL);
3352 3348
3353 switch ((bit << 4) + frame) { 3349 switch ((bit << 4) + frame) {
3354 case 0x11: 3350 case 0x11:
3355 format |= SND_SOC_DAIFMT_IB_IF; 3351 format |= SND_SOC_DAIFMT_IB_IF;
3356 break; 3352 break;
3357 case 0x10: 3353 case 0x10:
3358 format |= SND_SOC_DAIFMT_IB_NF; 3354 format |= SND_SOC_DAIFMT_IB_NF;
3359 break; 3355 break;
3360 case 0x01: 3356 case 0x01:
3361 format |= SND_SOC_DAIFMT_NB_IF; 3357 format |= SND_SOC_DAIFMT_NB_IF;
3362 break; 3358 break;
3363 default: 3359 default:
3364 /* SND_SOC_DAIFMT_NB_NF is default */ 3360 /* SND_SOC_DAIFMT_NB_NF is default */
3365 break; 3361 break;
3366 } 3362 }
3367 3363
3368 /* 3364 /*
3369 * check "[prefix]bitclock-master" 3365 * check "[prefix]bitclock-master"
3370 * check "[prefix]frame-master" 3366 * check "[prefix]frame-master"
3371 * SND_SOC_DAIFMT_MASTER_MASK area 3367 * SND_SOC_DAIFMT_MASTER_MASK area
3372 */ 3368 */
3373 snprintf(prop, sizeof(prop), "%sbitclock-master", prefix); 3369 snprintf(prop, sizeof(prop), "%sbitclock-master", prefix);
3374 bit = !!of_get_property(np, prop, NULL); 3370 bit = !!of_get_property(np, prop, NULL);
3375 if (bit && bitclkmaster) 3371 if (bit && bitclkmaster)
3376 *bitclkmaster = of_parse_phandle(np, prop, 0); 3372 *bitclkmaster = of_parse_phandle(np, prop, 0);
3377 3373
3378 snprintf(prop, sizeof(prop), "%sframe-master", prefix); 3374 snprintf(prop, sizeof(prop), "%sframe-master", prefix);
3379 frame = !!of_get_property(np, prop, NULL); 3375 frame = !!of_get_property(np, prop, NULL);
3380 if (frame && framemaster) 3376 if (frame && framemaster)
3381 *framemaster = of_parse_phandle(np, prop, 0); 3377 *framemaster = of_parse_phandle(np, prop, 0);
3382 3378
3383 switch ((bit << 4) + frame) { 3379 switch ((bit << 4) + frame) {
3384 case 0x11: 3380 case 0x11:
3385 format |= SND_SOC_DAIFMT_CBM_CFM; 3381 format |= SND_SOC_DAIFMT_CBM_CFM;
3386 break; 3382 break;
3387 case 0x10: 3383 case 0x10:
3388 format |= SND_SOC_DAIFMT_CBM_CFS; 3384 format |= SND_SOC_DAIFMT_CBM_CFS;
3389 break; 3385 break;
3390 case 0x01: 3386 case 0x01:
3391 format |= SND_SOC_DAIFMT_CBS_CFM; 3387 format |= SND_SOC_DAIFMT_CBS_CFM;
3392 break; 3388 break;
3393 default: 3389 default:
3394 format |= SND_SOC_DAIFMT_CBS_CFS; 3390 format |= SND_SOC_DAIFMT_CBS_CFS;
3395 break; 3391 break;
3396 } 3392 }
3397 3393
3398 return format; 3394 return format;
3399 } 3395 }
3400 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); 3396 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
3401 3397
3402 static int snd_soc_get_dai_name(struct of_phandle_args *args, 3398 static int snd_soc_get_dai_name(struct of_phandle_args *args,
3403 const char **dai_name) 3399 const char **dai_name)
3404 { 3400 {
3405 struct snd_soc_component *pos; 3401 struct snd_soc_component *pos;
3406 int ret = -EPROBE_DEFER; 3402 int ret = -EPROBE_DEFER;
3407 3403
3408 mutex_lock(&client_mutex); 3404 mutex_lock(&client_mutex);
3409 list_for_each_entry(pos, &component_list, list) { 3405 list_for_each_entry(pos, &component_list, list) {
3410 if (pos->dev->of_node != args->np) 3406 if (pos->dev->of_node != args->np)
3411 continue; 3407 continue;
3412 3408
3413 if (pos->driver->of_xlate_dai_name) { 3409 if (pos->driver->of_xlate_dai_name) {
3414 ret = pos->driver->of_xlate_dai_name(pos, 3410 ret = pos->driver->of_xlate_dai_name(pos,
3415 args, 3411 args,
3416 dai_name); 3412 dai_name);
3417 } else { 3413 } else {
3418 int id = -1; 3414 int id = -1;
3419 3415
3420 switch (args->args_count) { 3416 switch (args->args_count) {
3421 case 0: 3417 case 0:
3422 id = 0; /* same as dai_drv[0] */ 3418 id = 0; /* same as dai_drv[0] */
3423 break; 3419 break;
3424 case 1: 3420 case 1:
3425 id = args->args[0]; 3421 id = args->args[0];
3426 break; 3422 break;
3427 default: 3423 default:
3428 /* not supported */ 3424 /* not supported */
3429 break; 3425 break;
3430 } 3426 }
3431 3427
3432 if (id < 0 || id >= pos->num_dai) { 3428 if (id < 0 || id >= pos->num_dai) {
3433 ret = -EINVAL; 3429 ret = -EINVAL;
3434 continue; 3430 continue;
3435 } 3431 }
3436 3432
3437 ret = 0; 3433 ret = 0;
3438 3434
3439 *dai_name = pos->dai_drv[id].name; 3435 *dai_name = pos->dai_drv[id].name;
3440 if (!*dai_name) 3436 if (!*dai_name)
3441 *dai_name = pos->name; 3437 *dai_name = pos->name;
3442 } 3438 }
3443 3439
3444 break; 3440 break;
3445 } 3441 }
3446 mutex_unlock(&client_mutex); 3442 mutex_unlock(&client_mutex);
3447 return ret; 3443 return ret;
3448 } 3444 }
3449 3445
3450 int snd_soc_of_get_dai_name(struct device_node *of_node, 3446 int snd_soc_of_get_dai_name(struct device_node *of_node,
3451 const char **dai_name) 3447 const char **dai_name)
3452 { 3448 {
3453 struct of_phandle_args args; 3449 struct of_phandle_args args;
3454 int ret; 3450 int ret;
3455 3451
3456 ret = of_parse_phandle_with_args(of_node, "sound-dai", 3452 ret = of_parse_phandle_with_args(of_node, "sound-dai",
3457 "#sound-dai-cells", 0, &args); 3453 "#sound-dai-cells", 0, &args);
3458 if (ret) 3454 if (ret)
3459 return ret; 3455 return ret;
3460 3456
3461 ret = snd_soc_get_dai_name(&args, dai_name); 3457 ret = snd_soc_get_dai_name(&args, dai_name);
3462 3458
3463 of_node_put(args.np); 3459 of_node_put(args.np);
3464 3460
3465 return ret; 3461 return ret;
3466 } 3462 }
3467 EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); 3463 EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name);
3468 3464
3469 /* 3465 /*
3470 * snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree 3466 * snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree
3471 * @dev: Card device 3467 * @dev: Card device
3472 * @of_node: Device node 3468 * @of_node: Device node
3473 * @dai_link: DAI link 3469 * @dai_link: DAI link
3474 * 3470 *
3475 * Builds an array of CODEC DAI components from the DAI link property 3471 * Builds an array of CODEC DAI components from the DAI link property
3476 * 'sound-dai'. 3472 * 'sound-dai'.
3477 * The array is set in the DAI link and the number of DAIs is set accordingly. 3473 * The array is set in the DAI link and the number of DAIs is set accordingly.
3478 * The device nodes in the array (of_node) must be dereferenced by the caller. 3474 * The device nodes in the array (of_node) must be dereferenced by the caller.
3479 * 3475 *
3480 * Returns 0 for success 3476 * Returns 0 for success
3481 */ 3477 */
3482 int snd_soc_of_get_dai_link_codecs(struct device *dev, 3478 int snd_soc_of_get_dai_link_codecs(struct device *dev,
3483 struct device_node *of_node, 3479 struct device_node *of_node,
3484 struct snd_soc_dai_link *dai_link) 3480 struct snd_soc_dai_link *dai_link)
3485 { 3481 {
3486 struct of_phandle_args args; 3482 struct of_phandle_args args;
3487 struct snd_soc_dai_link_component *component; 3483 struct snd_soc_dai_link_component *component;
3488 char *name; 3484 char *name;
3489 int index, num_codecs, ret; 3485 int index, num_codecs, ret;
3490 3486
3491 /* Count the number of CODECs */ 3487 /* Count the number of CODECs */
3492 name = "sound-dai"; 3488 name = "sound-dai";
3493 num_codecs = of_count_phandle_with_args(of_node, name, 3489 num_codecs = of_count_phandle_with_args(of_node, name,
3494 "#sound-dai-cells"); 3490 "#sound-dai-cells");
3495 if (num_codecs <= 0) { 3491 if (num_codecs <= 0) {
3496 if (num_codecs == -ENOENT) 3492 if (num_codecs == -ENOENT)
3497 dev_err(dev, "No 'sound-dai' property\n"); 3493 dev_err(dev, "No 'sound-dai' property\n");
3498 else 3494 else
3499 dev_err(dev, "Bad phandle in 'sound-dai'\n"); 3495 dev_err(dev, "Bad phandle in 'sound-dai'\n");
3500 return num_codecs; 3496 return num_codecs;
3501 } 3497 }
3502 component = devm_kzalloc(dev, 3498 component = devm_kzalloc(dev,
3503 sizeof *component * num_codecs, 3499 sizeof *component * num_codecs,
3504 GFP_KERNEL); 3500 GFP_KERNEL);
3505 if (!component) 3501 if (!component)
3506 return -ENOMEM; 3502 return -ENOMEM;
3507 dai_link->codecs = component; 3503 dai_link->codecs = component;
3508 dai_link->num_codecs = num_codecs; 3504 dai_link->num_codecs = num_codecs;
3509 3505
3510 /* Parse the list */ 3506 /* Parse the list */
3511 for (index = 0, component = dai_link->codecs; 3507 for (index = 0, component = dai_link->codecs;
3512 index < dai_link->num_codecs; 3508 index < dai_link->num_codecs;
3513 index++, component++) { 3509 index++, component++) {
3514 ret = of_parse_phandle_with_args(of_node, name, 3510 ret = of_parse_phandle_with_args(of_node, name,
3515 "#sound-dai-cells", 3511 "#sound-dai-cells",
3516 index, &args); 3512 index, &args);
3517 if (ret) 3513 if (ret)
3518 goto err; 3514 goto err;
3519 component->of_node = args.np; 3515 component->of_node = args.np;
3520 ret = snd_soc_get_dai_name(&args, &component->dai_name); 3516 ret = snd_soc_get_dai_name(&args, &component->dai_name);
3521 if (ret < 0) 3517 if (ret < 0)
3522 goto err; 3518 goto err;
3523 } 3519 }
3524 return 0; 3520 return 0;
3525 err: 3521 err:
3526 for (index = 0, component = dai_link->codecs; 3522 for (index = 0, component = dai_link->codecs;
3527 index < dai_link->num_codecs; 3523 index < dai_link->num_codecs;
3528 index++, component++) { 3524 index++, component++) {
3529 if (!component->of_node) 3525 if (!component->of_node)
3530 break; 3526 break;
3531 of_node_put(component->of_node); 3527 of_node_put(component->of_node);
3532 component->of_node = NULL; 3528 component->of_node = NULL;
3533 } 3529 }
3534 dai_link->codecs = NULL; 3530 dai_link->codecs = NULL;
3535 dai_link->num_codecs = 0; 3531 dai_link->num_codecs = 0;
3536 return ret; 3532 return ret;
3537 } 3533 }
3538 EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_link_codecs); 3534 EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_link_codecs);
3539 3535
3540 static int __init snd_soc_init(void) 3536 static int __init snd_soc_init(void)
3541 { 3537 {
3542 #ifdef CONFIG_DEBUG_FS 3538 #ifdef CONFIG_DEBUG_FS
3543 snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL); 3539 snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL);
3544 if (IS_ERR(snd_soc_debugfs_root) || !snd_soc_debugfs_root) { 3540 if (IS_ERR(snd_soc_debugfs_root) || !snd_soc_debugfs_root) {
3545 pr_warn("ASoC: Failed to create debugfs directory\n"); 3541 pr_warn("ASoC: Failed to create debugfs directory\n");
3546 snd_soc_debugfs_root = NULL; 3542 snd_soc_debugfs_root = NULL;
3547 } 3543 }
3548 3544
3549 if (!debugfs_create_file("codecs", 0444, snd_soc_debugfs_root, NULL, 3545 if (!debugfs_create_file("codecs", 0444, snd_soc_debugfs_root, NULL,
3550 &codec_list_fops)) 3546 &codec_list_fops))
3551 pr_warn("ASoC: Failed to create CODEC list debugfs file\n"); 3547 pr_warn("ASoC: Failed to create CODEC list debugfs file\n");
3552 3548
3553 if (!debugfs_create_file("dais", 0444, snd_soc_debugfs_root, NULL, 3549 if (!debugfs_create_file("dais", 0444, snd_soc_debugfs_root, NULL,
3554 &dai_list_fops)) 3550 &dai_list_fops))
3555 pr_warn("ASoC: Failed to create DAI list debugfs file\n"); 3551 pr_warn("ASoC: Failed to create DAI list debugfs file\n");
3556 3552
3557 if (!debugfs_create_file("platforms", 0444, snd_soc_debugfs_root, NULL, 3553 if (!debugfs_create_file("platforms", 0444, snd_soc_debugfs_root, NULL,
3558 &platform_list_fops)) 3554 &platform_list_fops))
3559 pr_warn("ASoC: Failed to create platform list debugfs file\n"); 3555 pr_warn("ASoC: Failed to create platform list debugfs file\n");
3560 #endif 3556 #endif
3561 3557
3562 snd_soc_util_init(); 3558 snd_soc_util_init();
3563 3559
3564 return platform_driver_register(&soc_driver); 3560 return platform_driver_register(&soc_driver);
3565 } 3561 }
3566 module_init(snd_soc_init); 3562 module_init(snd_soc_init);
3567 3563
3568 static void __exit snd_soc_exit(void) 3564 static void __exit snd_soc_exit(void)
3569 { 3565 {
3570 snd_soc_util_exit(); 3566 snd_soc_util_exit();
3571 3567
3572 #ifdef CONFIG_DEBUG_FS 3568 #ifdef CONFIG_DEBUG_FS
3573 debugfs_remove_recursive(snd_soc_debugfs_root); 3569 debugfs_remove_recursive(snd_soc_debugfs_root);
3574 #endif 3570 #endif
3575 platform_driver_unregister(&soc_driver); 3571 platform_driver_unregister(&soc_driver);
3576 } 3572 }
3577 module_exit(snd_soc_exit); 3573 module_exit(snd_soc_exit);
3578 3574
3579 /* Module information */ 3575 /* Module information */
3580 MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk"); 3576 MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk");
3581 MODULE_DESCRIPTION("ALSA SoC Core"); 3577 MODULE_DESCRIPTION("ALSA SoC Core");
3582 MODULE_LICENSE("GPL"); 3578 MODULE_LICENSE("GPL");
3583 MODULE_ALIAS("platform:soc-audio"); 3579 MODULE_ALIAS("platform:soc-audio");
3584 3580