1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019, Linaro Limited
5 #include <linux/clk-provider.h>
6 #include <linux/gpio.h>
7 #include <linux/interrupt.h>
8 #include <linux/kernel.h>
9 #include <linux/mfd/wcd934x/registers.h>
10 #include <linux/mfd/wcd934x/wcd934x.h>
11 #include <linux/module.h>
12 #include <linux/mutex.h>
13 #include <linux/of_clk.h>
14 #include <linux/of_device.h>
15 #include <linux/of_gpio.h>
17 #include <linux/of_irq.h>
18 #include <linux/platform_device.h>
19 #include <linux/regmap.h>
20 #include <linux/regulator/consumer.h>
21 #include <linux/slab.h>
22 #include <linux/slimbus.h>
23 #include <sound/pcm_params.h>
24 #include <sound/soc.h>
25 #include <sound/soc-dapm.h>
26 #include <sound/tlv.h>
27 #include "wcd-clsh-v2.h"
29 #define WCD934X_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
30 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
31 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
32 /* Fractional Rates */
33 #define WCD934X_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\
34 SNDRV_PCM_RATE_176400)
35 #define WCD934X_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
36 SNDRV_PCM_FMTBIT_S24_LE)
38 /* slave port water mark level
39 * (0: 6bytes, 1: 9bytes, 2: 12 bytes, 3: 15 bytes)
41 #define SLAVE_PORT_WATER_MARK_6BYTES 0
42 #define SLAVE_PORT_WATER_MARK_9BYTES 1
43 #define SLAVE_PORT_WATER_MARK_12BYTES 2
44 #define SLAVE_PORT_WATER_MARK_15BYTES 3
45 #define SLAVE_PORT_WATER_MARK_SHIFT 1
46 #define SLAVE_PORT_ENABLE 1
47 #define SLAVE_PORT_DISABLE 0
48 #define WCD934X_SLIM_WATER_MARK_VAL \
49 ((SLAVE_PORT_WATER_MARK_12BYTES << SLAVE_PORT_WATER_MARK_SHIFT) | \
52 #define WCD934X_SLIM_NUM_PORT_REG 3
53 #define WCD934X_SLIM_PGD_PORT_INT_TX_EN0 (WCD934X_SLIM_PGD_PORT_INT_EN0 + 2)
54 #define WCD934X_SLIM_IRQ_OVERFLOW BIT(0)
55 #define WCD934X_SLIM_IRQ_UNDERFLOW BIT(1)
56 #define WCD934X_SLIM_IRQ_PORT_CLOSED BIT(2)
58 #define WCD934X_MCLK_CLK_12P288MHZ 12288000
59 #define WCD934X_MCLK_CLK_9P6MHZ 9600000
61 /* Only valid for 9.6 MHz mclk */
62 #define WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ 2400000
63 #define WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ 4800000
65 /* Only valid for 12.288 MHz mclk */
66 #define WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ 4096000
68 #define WCD934X_DMIC_CLK_DIV_2 0x0
69 #define WCD934X_DMIC_CLK_DIV_3 0x1
70 #define WCD934X_DMIC_CLK_DIV_4 0x2
71 #define WCD934X_DMIC_CLK_DIV_6 0x3
72 #define WCD934X_DMIC_CLK_DIV_8 0x4
73 #define WCD934X_DMIC_CLK_DIV_16 0x5
74 #define WCD934X_DMIC_CLK_DRIVE_DEFAULT 0x02
76 #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
77 #define CF_MIN_3DB_4HZ 0x0
78 #define CF_MIN_3DB_75HZ 0x1
79 #define CF_MIN_3DB_150HZ 0x2
81 #define WCD934X_RX_START 16
82 #define WCD934X_NUM_INTERPOLATORS 9
83 #define WCD934X_RX_PATH_CTL_OFFSET 20
84 #define WCD934X_MAX_VALID_ADC_MUX 13
85 #define WCD934X_INVALID_ADC_MUX 9
87 #define WCD934X_SLIM_RX_CH(p) \
88 {.port = p + WCD934X_RX_START, .shift = p,}
90 #define WCD934X_SLIM_TX_CH(p) \
91 {.port = p, .shift = p,}
93 /* Feature masks to distinguish codec version */
94 #define DSD_DISABLED_MASK 0
95 #define SLNQ_DISABLED_MASK 1
97 #define DSD_DISABLED BIT(DSD_DISABLED_MASK)
98 #define SLNQ_DISABLED BIT(SLNQ_DISABLED_MASK)
100 /* As fine version info cannot be retrieved before wcd probe.
101 * Define three coarse versions for possible future use before wcd probe.
103 #define WCD_VERSION_WCD9340_1_0 0x400
104 #define WCD_VERSION_WCD9341_1_0 0x410
105 #define WCD_VERSION_WCD9340_1_1 0x401
106 #define WCD_VERSION_WCD9341_1_1 0x411
107 #define WCD934X_AMIC_PWR_LEVEL_LP 0
108 #define WCD934X_AMIC_PWR_LEVEL_DEFAULT 1
109 #define WCD934X_AMIC_PWR_LEVEL_HP 2
110 #define WCD934X_AMIC_PWR_LEVEL_HYBRID 3
111 #define WCD934X_AMIC_PWR_LVL_MASK 0x60
112 #define WCD934X_AMIC_PWR_LVL_SHIFT 0x5
114 #define WCD934X_DEC_PWR_LVL_MASK 0x06
115 #define WCD934X_DEC_PWR_LVL_LP 0x02
116 #define WCD934X_DEC_PWR_LVL_HP 0x04
117 #define WCD934X_DEC_PWR_LVL_DF 0x00
118 #define WCD934X_DEC_PWR_LVL_HYBRID WCD934X_DEC_PWR_LVL_DF
120 #define WCD934X_DEF_MICBIAS_MV 1800
121 #define WCD934X_MAX_MICBIAS_MV 2850
123 #define WCD_IIR_FILTER_SIZE (sizeof(u32) * BAND_MAX)
125 #define WCD_IIR_FILTER_CTL(xname, iidx, bidx) \
127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
128 .info = wcd934x_iir_filter_info, \
129 .get = wcd934x_get_iir_band_audio_mixer, \
130 .put = wcd934x_put_iir_band_audio_mixer, \
131 .private_value = (unsigned long)&(struct wcd_iir_filter_ctl) { \
134 .bytes_ext = {.max = WCD_IIR_FILTER_SIZE, }, \
138 #define WCD934X_INTERPOLATOR_PATH(id) \
139 {"RX INT" #id "_1 MIX1 INP0", "RX0", "SLIM RX0"}, \
140 {"RX INT" #id "_1 MIX1 INP0", "RX1", "SLIM RX1"}, \
141 {"RX INT" #id "_1 MIX1 INP0", "RX2", "SLIM RX2"}, \
142 {"RX INT" #id "_1 MIX1 INP0", "RX3", "SLIM RX3"}, \
143 {"RX INT" #id "_1 MIX1 INP0", "RX4", "SLIM RX4"}, \
144 {"RX INT" #id "_1 MIX1 INP0", "RX5", "SLIM RX5"}, \
145 {"RX INT" #id "_1 MIX1 INP0", "RX6", "SLIM RX6"}, \
146 {"RX INT" #id "_1 MIX1 INP0", "RX7", "SLIM RX7"}, \
147 {"RX INT" #id "_1 MIX1 INP0", "IIR0", "IIR0"}, \
148 {"RX INT" #id "_1 MIX1 INP0", "IIR1", "IIR1"}, \
149 {"RX INT" #id "_1 MIX1 INP1", "RX0", "SLIM RX0"}, \
150 {"RX INT" #id "_1 MIX1 INP1", "RX1", "SLIM RX1"}, \
151 {"RX INT" #id "_1 MIX1 INP1", "RX2", "SLIM RX2"}, \
152 {"RX INT" #id "_1 MIX1 INP1", "RX3", "SLIM RX3"}, \
153 {"RX INT" #id "_1 MIX1 INP1", "RX4", "SLIM RX4"}, \
154 {"RX INT" #id "_1 MIX1 INP1", "RX5", "SLIM RX5"}, \
155 {"RX INT" #id "_1 MIX1 INP1", "RX6", "SLIM RX6"}, \
156 {"RX INT" #id "_1 MIX1 INP1", "RX7", "SLIM RX7"}, \
157 {"RX INT" #id "_1 MIX1 INP1", "IIR0", "IIR0"}, \
158 {"RX INT" #id "_1 MIX1 INP1", "IIR1", "IIR1"}, \
159 {"RX INT" #id "_1 MIX1 INP2", "RX0", "SLIM RX0"}, \
160 {"RX INT" #id "_1 MIX1 INP2", "RX1", "SLIM RX1"}, \
161 {"RX INT" #id "_1 MIX1 INP2", "RX2", "SLIM RX2"}, \
162 {"RX INT" #id "_1 MIX1 INP2", "RX3", "SLIM RX3"}, \
163 {"RX INT" #id "_1 MIX1 INP2", "RX4", "SLIM RX4"}, \
164 {"RX INT" #id "_1 MIX1 INP2", "RX5", "SLIM RX5"}, \
165 {"RX INT" #id "_1 MIX1 INP2", "RX6", "SLIM RX6"}, \
166 {"RX INT" #id "_1 MIX1 INP2", "RX7", "SLIM RX7"}, \
167 {"RX INT" #id "_1 MIX1 INP2", "IIR0", "IIR0"}, \
168 {"RX INT" #id "_1 MIX1 INP2", "IIR1", "IIR1"}, \
169 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP0"}, \
170 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP1"}, \
171 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP2"}, \
172 {"RX INT" #id "_2 MUX", "RX0", "SLIM RX0"}, \
173 {"RX INT" #id "_2 MUX", "RX1", "SLIM RX1"}, \
174 {"RX INT" #id "_2 MUX", "RX2", "SLIM RX2"}, \
175 {"RX INT" #id "_2 MUX", "RX3", "SLIM RX3"}, \
176 {"RX INT" #id "_2 MUX", "RX4", "SLIM RX4"}, \
177 {"RX INT" #id "_2 MUX", "RX5", "SLIM RX5"}, \
178 {"RX INT" #id "_2 MUX", "RX6", "SLIM RX6"}, \
179 {"RX INT" #id "_2 MUX", "RX7", "SLIM RX7"}, \
180 {"RX INT" #id "_2 MUX", NULL, "INT" #id "_CLK"}, \
181 {"RX INT" #id "_2 MUX", NULL, "DSMDEM" #id "_CLK"}, \
182 {"RX INT" #id "_2 INTERP", NULL, "RX INT" #id "_2 MUX"}, \
183 {"RX INT" #id " SEC MIX", NULL, "RX INT" #id "_2 INTERP"}, \
184 {"RX INT" #id "_1 INTERP", NULL, "RX INT" #id "_1 MIX1"}, \
185 {"RX INT" #id "_1 INTERP", NULL, "INT" #id "_CLK"}, \
186 {"RX INT" #id "_1 INTERP", NULL, "DSMDEM" #id "_CLK"}, \
187 {"RX INT" #id " SEC MIX", NULL, "RX INT" #id "_1 INTERP"}
189 #define WCD934X_INTERPOLATOR_MIX2(id) \
190 {"RX INT" #id " MIX2", NULL, "RX INT" #id " SEC MIX"}, \
191 {"RX INT" #id " MIX2", NULL, "RX INT" #id " MIX2 INP"}
193 #define WCD934X_SLIM_RX_AIF_PATH(id) \
194 {"SLIM RX"#id" MUX", "AIF1_PB", "AIF1 PB"}, \
195 {"SLIM RX"#id" MUX", "AIF2_PB", "AIF2 PB"}, \
196 {"SLIM RX"#id" MUX", "AIF3_PB", "AIF3 PB"}, \
197 {"SLIM RX"#id" MUX", "AIF4_PB", "AIF4 PB"}, \
198 {"SLIM RX"#id, NULL, "SLIM RX"#id" MUX"}
200 #define WCD934X_ADC_MUX(id) \
201 {"ADC MUX" #id, "DMIC", "DMIC MUX" #id }, \
202 {"ADC MUX" #id, "AMIC", "AMIC MUX" #id }, \
203 {"DMIC MUX" #id, "DMIC0", "DMIC0"}, \
204 {"DMIC MUX" #id, "DMIC1", "DMIC1"}, \
205 {"DMIC MUX" #id, "DMIC2", "DMIC2"}, \
206 {"DMIC MUX" #id, "DMIC3", "DMIC3"}, \
207 {"DMIC MUX" #id, "DMIC4", "DMIC4"}, \
208 {"DMIC MUX" #id, "DMIC5", "DMIC5"}, \
209 {"AMIC MUX" #id, "ADC1", "ADC1"}, \
210 {"AMIC MUX" #id, "ADC2", "ADC2"}, \
211 {"AMIC MUX" #id, "ADC3", "ADC3"}, \
212 {"AMIC MUX" #id, "ADC4", "ADC4"}
214 #define WCD934X_IIR_INP_MUX(id) \
215 {"IIR" #id, NULL, "IIR" #id " INP0 MUX"}, \
216 {"IIR" #id " INP0 MUX", "DEC0", "ADC MUX0"}, \
217 {"IIR" #id " INP0 MUX", "DEC1", "ADC MUX1"}, \
218 {"IIR" #id " INP0 MUX", "DEC2", "ADC MUX2"}, \
219 {"IIR" #id " INP0 MUX", "DEC3", "ADC MUX3"}, \
220 {"IIR" #id " INP0 MUX", "DEC4", "ADC MUX4"}, \
221 {"IIR" #id " INP0 MUX", "DEC5", "ADC MUX5"}, \
222 {"IIR" #id " INP0 MUX", "DEC6", "ADC MUX6"}, \
223 {"IIR" #id " INP0 MUX", "DEC7", "ADC MUX7"}, \
224 {"IIR" #id " INP0 MUX", "DEC8", "ADC MUX8"}, \
225 {"IIR" #id " INP0 MUX", "RX0", "SLIM RX0"}, \
226 {"IIR" #id " INP0 MUX", "RX1", "SLIM RX1"}, \
227 {"IIR" #id " INP0 MUX", "RX2", "SLIM RX2"}, \
228 {"IIR" #id " INP0 MUX", "RX3", "SLIM RX3"}, \
229 {"IIR" #id " INP0 MUX", "RX4", "SLIM RX4"}, \
230 {"IIR" #id " INP0 MUX", "RX5", "SLIM RX5"}, \
231 {"IIR" #id " INP0 MUX", "RX6", "SLIM RX6"}, \
232 {"IIR" #id " INP0 MUX", "RX7", "SLIM RX7"}, \
233 {"IIR" #id, NULL, "IIR" #id " INP1 MUX"}, \
234 {"IIR" #id " INP1 MUX", "DEC0", "ADC MUX0"}, \
235 {"IIR" #id " INP1 MUX", "DEC1", "ADC MUX1"}, \
236 {"IIR" #id " INP1 MUX", "DEC2", "ADC MUX2"}, \
237 {"IIR" #id " INP1 MUX", "DEC3", "ADC MUX3"}, \
238 {"IIR" #id " INP1 MUX", "DEC4", "ADC MUX4"}, \
239 {"IIR" #id " INP1 MUX", "DEC5", "ADC MUX5"}, \
240 {"IIR" #id " INP1 MUX", "DEC6", "ADC MUX6"}, \
241 {"IIR" #id " INP1 MUX", "DEC7", "ADC MUX7"}, \
242 {"IIR" #id " INP1 MUX", "DEC8", "ADC MUX8"}, \
243 {"IIR" #id " INP1 MUX", "RX0", "SLIM RX0"}, \
244 {"IIR" #id " INP1 MUX", "RX1", "SLIM RX1"}, \
245 {"IIR" #id " INP1 MUX", "RX2", "SLIM RX2"}, \
246 {"IIR" #id " INP1 MUX", "RX3", "SLIM RX3"}, \
247 {"IIR" #id " INP1 MUX", "RX4", "SLIM RX4"}, \
248 {"IIR" #id " INP1 MUX", "RX5", "SLIM RX5"}, \
249 {"IIR" #id " INP1 MUX", "RX6", "SLIM RX6"}, \
250 {"IIR" #id " INP1 MUX", "RX7", "SLIM RX7"}, \
251 {"IIR" #id, NULL, "IIR" #id " INP2 MUX"}, \
252 {"IIR" #id " INP2 MUX", "DEC0", "ADC MUX0"}, \
253 {"IIR" #id " INP2 MUX", "DEC1", "ADC MUX1"}, \
254 {"IIR" #id " INP2 MUX", "DEC2", "ADC MUX2"}, \
255 {"IIR" #id " INP2 MUX", "DEC3", "ADC MUX3"}, \
256 {"IIR" #id " INP2 MUX", "DEC4", "ADC MUX4"}, \
257 {"IIR" #id " INP2 MUX", "DEC5", "ADC MUX5"}, \
258 {"IIR" #id " INP2 MUX", "DEC6", "ADC MUX6"}, \
259 {"IIR" #id " INP2 MUX", "DEC7", "ADC MUX7"}, \
260 {"IIR" #id " INP2 MUX", "DEC8", "ADC MUX8"}, \
261 {"IIR" #id " INP2 MUX", "RX0", "SLIM RX0"}, \
262 {"IIR" #id " INP2 MUX", "RX1", "SLIM RX1"}, \
263 {"IIR" #id " INP2 MUX", "RX2", "SLIM RX2"}, \
264 {"IIR" #id " INP2 MUX", "RX3", "SLIM RX3"}, \
265 {"IIR" #id " INP2 MUX", "RX4", "SLIM RX4"}, \
266 {"IIR" #id " INP2 MUX", "RX5", "SLIM RX5"}, \
267 {"IIR" #id " INP2 MUX", "RX6", "SLIM RX6"}, \
268 {"IIR" #id " INP2 MUX", "RX7", "SLIM RX7"}, \
269 {"IIR" #id, NULL, "IIR" #id " INP3 MUX"}, \
270 {"IIR" #id " INP3 MUX", "DEC0", "ADC MUX0"}, \
271 {"IIR" #id " INP3 MUX", "DEC1", "ADC MUX1"}, \
272 {"IIR" #id " INP3 MUX", "DEC2", "ADC MUX2"}, \
273 {"IIR" #id " INP3 MUX", "DEC3", "ADC MUX3"}, \
274 {"IIR" #id " INP3 MUX", "DEC4", "ADC MUX4"}, \
275 {"IIR" #id " INP3 MUX", "DEC5", "ADC MUX5"}, \
276 {"IIR" #id " INP3 MUX", "DEC6", "ADC MUX6"}, \
277 {"IIR" #id " INP3 MUX", "DEC7", "ADC MUX7"}, \
278 {"IIR" #id " INP3 MUX", "DEC8", "ADC MUX8"}, \
279 {"IIR" #id " INP3 MUX", "RX0", "SLIM RX0"}, \
280 {"IIR" #id " INP3 MUX", "RX1", "SLIM RX1"}, \
281 {"IIR" #id " INP3 MUX", "RX2", "SLIM RX2"}, \
282 {"IIR" #id " INP3 MUX", "RX3", "SLIM RX3"}, \
283 {"IIR" #id " INP3 MUX", "RX4", "SLIM RX4"}, \
284 {"IIR" #id " INP3 MUX", "RX5", "SLIM RX5"}, \
285 {"IIR" #id " INP3 MUX", "RX6", "SLIM RX6"}, \
286 {"IIR" #id " INP3 MUX", "RX7", "SLIM RX7"}
288 #define WCD934X_SLIM_TX_AIF_PATH(id) \
289 {"AIF1_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id }, \
290 {"AIF2_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id }, \
291 {"AIF3_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id }, \
292 {"SLIM TX" #id, NULL, "CDC_IF TX" #id " MUX"}
302 SIDO_SOURCE_INTERNAL
,
312 INTERP_LO3_NA
, /* LO3 not avalible in Tavil */
314 INTERP_SPKR1
, /*INT7 WSA Speakers via soundwire */
315 INTERP_SPKR2
, /*INT8 WSA Speakers via soundwire */
356 struct wcd934x_slim_ch
{
360 struct list_head list
;
363 static const struct wcd934x_slim_ch wcd934x_tx_chs
[WCD934X_TX_MAX
] = {
364 WCD934X_SLIM_TX_CH(0),
365 WCD934X_SLIM_TX_CH(1),
366 WCD934X_SLIM_TX_CH(2),
367 WCD934X_SLIM_TX_CH(3),
368 WCD934X_SLIM_TX_CH(4),
369 WCD934X_SLIM_TX_CH(5),
370 WCD934X_SLIM_TX_CH(6),
371 WCD934X_SLIM_TX_CH(7),
372 WCD934X_SLIM_TX_CH(8),
373 WCD934X_SLIM_TX_CH(9),
374 WCD934X_SLIM_TX_CH(10),
375 WCD934X_SLIM_TX_CH(11),
376 WCD934X_SLIM_TX_CH(12),
377 WCD934X_SLIM_TX_CH(13),
378 WCD934X_SLIM_TX_CH(14),
379 WCD934X_SLIM_TX_CH(15),
382 static const struct wcd934x_slim_ch wcd934x_rx_chs
[WCD934X_RX_MAX
] = {
383 WCD934X_SLIM_RX_CH(0), /* 16 */
384 WCD934X_SLIM_RX_CH(1), /* 17 */
385 WCD934X_SLIM_RX_CH(2),
386 WCD934X_SLIM_RX_CH(3),
387 WCD934X_SLIM_RX_CH(4),
388 WCD934X_SLIM_RX_CH(5),
389 WCD934X_SLIM_RX_CH(6),
390 WCD934X_SLIM_RX_CH(7),
391 WCD934X_SLIM_RX_CH(8),
392 WCD934X_SLIM_RX_CH(9),
393 WCD934X_SLIM_RX_CH(10),
394 WCD934X_SLIM_RX_CH(11),
395 WCD934X_SLIM_RX_CH(12),
398 /* Codec supports 2 IIR filters */
405 /* Each IIR has 5 Filter Stages */
416 COMPANDER_1
, /* HPH_L */
417 COMPANDER_2
, /* HPH_R */
418 COMPANDER_3
, /* LO1_DIFF */
419 COMPANDER_4
, /* LO2_DIFF */
420 COMPANDER_5
, /* LO3_SE - not used in Tavil */
421 COMPANDER_6
, /* LO4_SE - not used in Tavil */
422 COMPANDER_7
, /* SWR SPK CH1 */
423 COMPANDER_8
, /* SWR SPK CH2 */
441 INTn_1_INP_SEL_ZERO
= 0,
457 INTn_2_INP_SEL_ZERO
= 0,
466 INTn_2_INP_SEL_PROXIMITY
,
474 struct interp_sample_rate
{
479 static struct interp_sample_rate sr_val_tbl
[] = {
493 struct wcd_slim_codec_dai_data
{
494 struct list_head slim_ch_list
;
495 struct slim_stream_config sconfig
;
496 struct slim_stream_runtime
*sruntime
;
499 static const struct regmap_range_cfg wcd934x_ifc_ranges
[] = {
501 .name
= "WCD9335-IFC-DEV",
504 .selector_reg
= 0x800,
505 .selector_mask
= 0xfff,
507 .window_start
= 0x800,
512 static struct regmap_config wcd934x_ifc_regmap_config
= {
515 .max_register
= 0xffff,
516 .ranges
= wcd934x_ifc_ranges
,
517 .num_ranges
= ARRAY_SIZE(wcd934x_ifc_ranges
),
520 struct wcd934x_codec
{
524 struct regmap
*regmap
;
525 struct regmap
*if_regmap
;
526 struct slim_device
*sdev
;
527 struct slim_device
*sidev
;
528 struct wcd_clsh_ctrl
*clsh_ctrl
;
529 struct snd_soc_component
*component
;
530 struct wcd934x_slim_ch rx_chs
[WCD934X_RX_MAX
];
531 struct wcd934x_slim_ch tx_chs
[WCD934X_TX_MAX
];
532 struct wcd_slim_codec_dai_data dai
[NUM_CODEC_DAIS
];
538 u32 tx_port_value
[WCD934X_TX_MAX
];
539 u32 rx_port_value
[WCD934X_RX_MAX
];
541 int dmic_0_1_clk_cnt
;
542 int dmic_2_3_clk_cnt
;
543 int dmic_4_5_clk_cnt
;
544 int dmic_sample_rate
;
545 int comp_enabled
[COMPANDER_MAX
];
547 struct mutex sysclk_mutex
;
550 #define to_wcd934x_codec(_hw) container_of(_hw, struct wcd934x_codec, hw)
552 struct wcd_iir_filter_ctl
{
553 unsigned int iir_idx
;
554 unsigned int band_idx
;
555 struct soc_bytes_ext bytes_ext
;
558 static const DECLARE_TLV_DB_SCALE(digital_gain
, 0, 1, 0);
559 static const DECLARE_TLV_DB_SCALE(line_gain
, 0, 7, 1);
560 static const DECLARE_TLV_DB_SCALE(analog_gain
, 0, 25, 1);
561 static const DECLARE_TLV_DB_SCALE(ear_pa_gain
, 0, 150, 0);
563 /* Cutoff frequency for high pass filter */
564 static const char * const cf_text
[] = {
565 "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
568 static const char * const rx_cf_text
[] = {
569 "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
573 static const char * const rx_hph_mode_mux_text
[] = {
574 "Class H Invalid", "Class-H Hi-Fi", "Class-H Low Power", "Class-AB",
575 "Class-H Hi-Fi Low Power"
578 static const char *const slim_rx_mux_text
[] = {
579 "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB",
582 static const char * const rx_int0_7_mix_mux_text
[] = {
583 "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
584 "RX6", "RX7", "PROXIMITY"
587 static const char * const rx_int_mix_mux_text
[] = {
588 "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
592 static const char * const rx_prim_mix_text
[] = {
593 "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
594 "RX3", "RX4", "RX5", "RX6", "RX7"
597 static const char * const rx_sidetone_mix_text
[] = {
598 "ZERO", "SRC0", "SRC1", "SRC_SUM"
601 static const char * const iir_inp_mux_text
[] = {
602 "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
603 "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
606 static const char * const rx_int_dem_inp_mux_text
[] = {
607 "NORMAL_DSM_OUT", "CLSH_DSM_OUT",
610 static const char * const rx_int0_1_interp_mux_text
[] = {
611 "ZERO", "RX INT0_1 MIX1",
614 static const char * const rx_int1_1_interp_mux_text
[] = {
615 "ZERO", "RX INT1_1 MIX1",
618 static const char * const rx_int2_1_interp_mux_text
[] = {
619 "ZERO", "RX INT2_1 MIX1",
622 static const char * const rx_int3_1_interp_mux_text
[] = {
623 "ZERO", "RX INT3_1 MIX1",
626 static const char * const rx_int4_1_interp_mux_text
[] = {
627 "ZERO", "RX INT4_1 MIX1",
630 static const char * const rx_int7_1_interp_mux_text
[] = {
631 "ZERO", "RX INT7_1 MIX1",
634 static const char * const rx_int8_1_interp_mux_text
[] = {
635 "ZERO", "RX INT8_1 MIX1",
638 static const char * const rx_int0_2_interp_mux_text
[] = {
639 "ZERO", "RX INT0_2 MUX",
642 static const char * const rx_int1_2_interp_mux_text
[] = {
643 "ZERO", "RX INT1_2 MUX",
646 static const char * const rx_int2_2_interp_mux_text
[] = {
647 "ZERO", "RX INT2_2 MUX",
650 static const char * const rx_int3_2_interp_mux_text
[] = {
651 "ZERO", "RX INT3_2 MUX",
654 static const char * const rx_int4_2_interp_mux_text
[] = {
655 "ZERO", "RX INT4_2 MUX",
658 static const char * const rx_int7_2_interp_mux_text
[] = {
659 "ZERO", "RX INT7_2 MUX",
662 static const char * const rx_int8_2_interp_mux_text
[] = {
663 "ZERO", "RX INT8_2 MUX",
666 static const char * const dmic_mux_text
[] = {
667 "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5"
670 static const char * const amic_mux_text
[] = {
671 "ZERO", "ADC1", "ADC2", "ADC3", "ADC4"
674 static const char * const amic4_5_sel_text
[] = {
678 static const char * const adc_mux_text
[] = {
679 "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
682 static const char * const cdc_if_tx0_mux_text
[] = {
683 "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
686 static const char * const cdc_if_tx1_mux_text
[] = {
687 "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
690 static const char * const cdc_if_tx2_mux_text
[] = {
691 "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
694 static const char * const cdc_if_tx3_mux_text
[] = {
695 "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
698 static const char * const cdc_if_tx4_mux_text
[] = {
699 "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
702 static const char * const cdc_if_tx5_mux_text
[] = {
703 "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
706 static const char * const cdc_if_tx6_mux_text
[] = {
707 "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
710 static const char * const cdc_if_tx7_mux_text
[] = {
711 "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
714 static const char * const cdc_if_tx8_mux_text
[] = {
715 "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
718 static const char * const cdc_if_tx9_mux_text
[] = {
719 "ZERO", "DEC7", "DEC7_192"
722 static const char * const cdc_if_tx10_mux_text
[] = {
723 "ZERO", "DEC6", "DEC6_192"
726 static const char * const cdc_if_tx11_mux_text
[] = {
727 "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
730 static const char * const cdc_if_tx11_inp1_mux_text
[] = {
731 "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
732 "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
735 static const char * const cdc_if_tx13_mux_text
[] = {
736 "CDC_DEC_5", "MAD_BRDCST"
739 static const char * const cdc_if_tx13_inp1_mux_text
[] = {
740 "ZERO", "DEC5", "DEC5_192"
743 static const struct soc_enum cf_dec0_enum
=
744 SOC_ENUM_SINGLE(WCD934X_CDC_TX0_TX_PATH_CFG0
, 5, 3, cf_text
);
746 static const struct soc_enum cf_dec1_enum
=
747 SOC_ENUM_SINGLE(WCD934X_CDC_TX1_TX_PATH_CFG0
, 5, 3, cf_text
);
749 static const struct soc_enum cf_dec2_enum
=
750 SOC_ENUM_SINGLE(WCD934X_CDC_TX2_TX_PATH_CFG0
, 5, 3, cf_text
);
752 static const struct soc_enum cf_dec3_enum
=
753 SOC_ENUM_SINGLE(WCD934X_CDC_TX3_TX_PATH_CFG0
, 5, 3, cf_text
);
755 static const struct soc_enum cf_dec4_enum
=
756 SOC_ENUM_SINGLE(WCD934X_CDC_TX4_TX_PATH_CFG0
, 5, 3, cf_text
);
758 static const struct soc_enum cf_dec5_enum
=
759 SOC_ENUM_SINGLE(WCD934X_CDC_TX5_TX_PATH_CFG0
, 5, 3, cf_text
);
761 static const struct soc_enum cf_dec6_enum
=
762 SOC_ENUM_SINGLE(WCD934X_CDC_TX6_TX_PATH_CFG0
, 5, 3, cf_text
);
764 static const struct soc_enum cf_dec7_enum
=
765 SOC_ENUM_SINGLE(WCD934X_CDC_TX7_TX_PATH_CFG0
, 5, 3, cf_text
);
767 static const struct soc_enum cf_dec8_enum
=
768 SOC_ENUM_SINGLE(WCD934X_CDC_TX8_TX_PATH_CFG0
, 5, 3, cf_text
);
770 static const struct soc_enum cf_int0_1_enum
=
771 SOC_ENUM_SINGLE(WCD934X_CDC_RX0_RX_PATH_CFG2
, 0, 4, rx_cf_text
);
773 static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum
, WCD934X_CDC_RX0_RX_PATH_MIX_CFG
, 2,
776 static const struct soc_enum cf_int1_1_enum
=
777 SOC_ENUM_SINGLE(WCD934X_CDC_RX1_RX_PATH_CFG2
, 0, 4, rx_cf_text
);
779 static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum
, WCD934X_CDC_RX1_RX_PATH_MIX_CFG
, 2,
782 static const struct soc_enum cf_int2_1_enum
=
783 SOC_ENUM_SINGLE(WCD934X_CDC_RX2_RX_PATH_CFG2
, 0, 4, rx_cf_text
);
785 static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum
, WCD934X_CDC_RX2_RX_PATH_MIX_CFG
, 2,
788 static const struct soc_enum cf_int3_1_enum
=
789 SOC_ENUM_SINGLE(WCD934X_CDC_RX3_RX_PATH_CFG2
, 0, 4, rx_cf_text
);
791 static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum
, WCD934X_CDC_RX3_RX_PATH_MIX_CFG
, 2,
794 static const struct soc_enum cf_int4_1_enum
=
795 SOC_ENUM_SINGLE(WCD934X_CDC_RX4_RX_PATH_CFG2
, 0, 4, rx_cf_text
);
797 static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum
, WCD934X_CDC_RX4_RX_PATH_MIX_CFG
, 2,
800 static const struct soc_enum cf_int7_1_enum
=
801 SOC_ENUM_SINGLE(WCD934X_CDC_RX7_RX_PATH_CFG2
, 0, 4, rx_cf_text
);
803 static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum
, WCD934X_CDC_RX7_RX_PATH_MIX_CFG
, 2,
806 static const struct soc_enum cf_int8_1_enum
=
807 SOC_ENUM_SINGLE(WCD934X_CDC_RX8_RX_PATH_CFG2
, 0, 4, rx_cf_text
);
809 static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum
, WCD934X_CDC_RX8_RX_PATH_MIX_CFG
, 2,
812 static const struct soc_enum rx_hph_mode_mux_enum
=
813 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text
),
814 rx_hph_mode_mux_text
);
816 static const struct soc_enum slim_rx_mux_enum
=
817 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text
), slim_rx_mux_text
);
819 static const struct soc_enum rx_int0_2_mux_chain_enum
=
820 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1
, 0, 10,
821 rx_int0_7_mix_mux_text
);
823 static const struct soc_enum rx_int1_2_mux_chain_enum
=
824 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1
, 0, 9,
825 rx_int_mix_mux_text
);
827 static const struct soc_enum rx_int2_2_mux_chain_enum
=
828 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1
, 0, 9,
829 rx_int_mix_mux_text
);
831 static const struct soc_enum rx_int3_2_mux_chain_enum
=
832 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1
, 0, 9,
833 rx_int_mix_mux_text
);
835 static const struct soc_enum rx_int4_2_mux_chain_enum
=
836 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1
, 0, 9,
837 rx_int_mix_mux_text
);
839 static const struct soc_enum rx_int7_2_mux_chain_enum
=
840 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1
, 0, 10,
841 rx_int0_7_mix_mux_text
);
843 static const struct soc_enum rx_int8_2_mux_chain_enum
=
844 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1
, 0, 9,
845 rx_int_mix_mux_text
);
847 static const struct soc_enum rx_int0_1_mix_inp0_chain_enum
=
848 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0
, 0, 13,
851 static const struct soc_enum rx_int0_1_mix_inp1_chain_enum
=
852 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0
, 4, 13,
855 static const struct soc_enum rx_int0_1_mix_inp2_chain_enum
=
856 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1
, 4, 13,
859 static const struct soc_enum rx_int1_1_mix_inp0_chain_enum
=
860 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0
, 0, 13,
863 static const struct soc_enum rx_int1_1_mix_inp1_chain_enum
=
864 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0
, 4, 13,
867 static const struct soc_enum rx_int1_1_mix_inp2_chain_enum
=
868 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1
, 4, 13,
871 static const struct soc_enum rx_int2_1_mix_inp0_chain_enum
=
872 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0
, 0, 13,
875 static const struct soc_enum rx_int2_1_mix_inp1_chain_enum
=
876 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0
, 4, 13,
879 static const struct soc_enum rx_int2_1_mix_inp2_chain_enum
=
880 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1
, 4, 13,
883 static const struct soc_enum rx_int3_1_mix_inp0_chain_enum
=
884 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0
, 0, 13,
887 static const struct soc_enum rx_int3_1_mix_inp1_chain_enum
=
888 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0
, 4, 13,
891 static const struct soc_enum rx_int3_1_mix_inp2_chain_enum
=
892 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1
, 4, 13,
895 static const struct soc_enum rx_int4_1_mix_inp0_chain_enum
=
896 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0
, 0, 13,
899 static const struct soc_enum rx_int4_1_mix_inp1_chain_enum
=
900 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0
, 4, 13,
903 static const struct soc_enum rx_int4_1_mix_inp2_chain_enum
=
904 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1
, 4, 13,
907 static const struct soc_enum rx_int7_1_mix_inp0_chain_enum
=
908 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0
, 0, 13,
911 static const struct soc_enum rx_int7_1_mix_inp1_chain_enum
=
912 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0
, 4, 13,
915 static const struct soc_enum rx_int7_1_mix_inp2_chain_enum
=
916 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1
, 4, 13,
919 static const struct soc_enum rx_int8_1_mix_inp0_chain_enum
=
920 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0
, 0, 13,
923 static const struct soc_enum rx_int8_1_mix_inp1_chain_enum
=
924 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0
, 4, 13,
927 static const struct soc_enum rx_int8_1_mix_inp2_chain_enum
=
928 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1
, 4, 13,
931 static const struct soc_enum rx_int0_mix2_inp_mux_enum
=
932 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0
, 0, 4,
933 rx_sidetone_mix_text
);
935 static const struct soc_enum rx_int1_mix2_inp_mux_enum
=
936 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0
, 2, 4,
937 rx_sidetone_mix_text
);
939 static const struct soc_enum rx_int2_mix2_inp_mux_enum
=
940 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0
, 4, 4,
941 rx_sidetone_mix_text
);
943 static const struct soc_enum rx_int3_mix2_inp_mux_enum
=
944 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0
, 6, 4,
945 rx_sidetone_mix_text
);
947 static const struct soc_enum rx_int4_mix2_inp_mux_enum
=
948 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1
, 0, 4,
949 rx_sidetone_mix_text
);
951 static const struct soc_enum rx_int7_mix2_inp_mux_enum
=
952 SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1
, 2, 4,
953 rx_sidetone_mix_text
);
955 static const struct soc_enum iir0_inp0_mux_enum
=
956 SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0
,
957 0, 18, iir_inp_mux_text
);
959 static const struct soc_enum iir0_inp1_mux_enum
=
960 SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1
,
961 0, 18, iir_inp_mux_text
);
963 static const struct soc_enum iir0_inp2_mux_enum
=
964 SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2
,
965 0, 18, iir_inp_mux_text
);
967 static const struct soc_enum iir0_inp3_mux_enum
=
968 SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3
,
969 0, 18, iir_inp_mux_text
);
971 static const struct soc_enum iir1_inp0_mux_enum
=
972 SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0
,
973 0, 18, iir_inp_mux_text
);
975 static const struct soc_enum iir1_inp1_mux_enum
=
976 SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1
,
977 0, 18, iir_inp_mux_text
);
979 static const struct soc_enum iir1_inp2_mux_enum
=
980 SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2
,
981 0, 18, iir_inp_mux_text
);
983 static const struct soc_enum iir1_inp3_mux_enum
=
984 SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3
,
985 0, 18, iir_inp_mux_text
);
987 static const struct soc_enum rx_int0_dem_inp_mux_enum
=
988 SOC_ENUM_SINGLE(WCD934X_CDC_RX0_RX_PATH_SEC0
, 0,
989 ARRAY_SIZE(rx_int_dem_inp_mux_text
),
990 rx_int_dem_inp_mux_text
);
992 static const struct soc_enum rx_int1_dem_inp_mux_enum
=
993 SOC_ENUM_SINGLE(WCD934X_CDC_RX1_RX_PATH_SEC0
, 0,
994 ARRAY_SIZE(rx_int_dem_inp_mux_text
),
995 rx_int_dem_inp_mux_text
);
997 static const struct soc_enum rx_int2_dem_inp_mux_enum
=
998 SOC_ENUM_SINGLE(WCD934X_CDC_RX2_RX_PATH_SEC0
, 0,
999 ARRAY_SIZE(rx_int_dem_inp_mux_text
),
1000 rx_int_dem_inp_mux_text
);
1002 static const struct soc_enum tx_adc_mux0_enum
=
1003 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1
, 0,
1004 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1005 static const struct soc_enum tx_adc_mux1_enum
=
1006 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1
, 0,
1007 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1008 static const struct soc_enum tx_adc_mux2_enum
=
1009 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1
, 0,
1010 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1011 static const struct soc_enum tx_adc_mux3_enum
=
1012 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1
, 0,
1013 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1014 static const struct soc_enum tx_adc_mux4_enum
=
1015 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1
, 2,
1016 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1017 static const struct soc_enum tx_adc_mux5_enum
=
1018 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1
, 2,
1019 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1020 static const struct soc_enum tx_adc_mux6_enum
=
1021 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1
, 2,
1022 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1023 static const struct soc_enum tx_adc_mux7_enum
=
1024 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1
, 2,
1025 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1026 static const struct soc_enum tx_adc_mux8_enum
=
1027 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1
, 4,
1028 ARRAY_SIZE(adc_mux_text
), adc_mux_text
);
1030 static const struct soc_enum rx_int0_1_interp_mux_enum
=
1031 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2,
1032 rx_int0_1_interp_mux_text
);
1034 static const struct soc_enum rx_int1_1_interp_mux_enum
=
1035 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2,
1036 rx_int1_1_interp_mux_text
);
1038 static const struct soc_enum rx_int2_1_interp_mux_enum
=
1039 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2,
1040 rx_int2_1_interp_mux_text
);
1042 static const struct soc_enum rx_int3_1_interp_mux_enum
=
1043 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int3_1_interp_mux_text
);
1045 static const struct soc_enum rx_int4_1_interp_mux_enum
=
1046 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int4_1_interp_mux_text
);
1048 static const struct soc_enum rx_int7_1_interp_mux_enum
=
1049 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int7_1_interp_mux_text
);
1051 static const struct soc_enum rx_int8_1_interp_mux_enum
=
1052 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int8_1_interp_mux_text
);
1054 static const struct soc_enum rx_int0_2_interp_mux_enum
=
1055 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int0_2_interp_mux_text
);
1057 static const struct soc_enum rx_int1_2_interp_mux_enum
=
1058 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int1_2_interp_mux_text
);
1060 static const struct soc_enum rx_int2_2_interp_mux_enum
=
1061 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int2_2_interp_mux_text
);
1063 static const struct soc_enum rx_int3_2_interp_mux_enum
=
1064 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int3_2_interp_mux_text
);
1066 static const struct soc_enum rx_int4_2_interp_mux_enum
=
1067 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int4_2_interp_mux_text
);
1069 static const struct soc_enum rx_int7_2_interp_mux_enum
=
1070 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int7_2_interp_mux_text
);
1072 static const struct soc_enum rx_int8_2_interp_mux_enum
=
1073 SOC_ENUM_SINGLE(SND_SOC_NOPM
, 0, 2, rx_int8_2_interp_mux_text
);
1075 static const struct soc_enum tx_dmic_mux0_enum
=
1076 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0
, 3, 7,
1079 static const struct soc_enum tx_dmic_mux1_enum
=
1080 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0
, 3, 7,
1083 static const struct soc_enum tx_dmic_mux2_enum
=
1084 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0
, 3, 7,
1087 static const struct soc_enum tx_dmic_mux3_enum
=
1088 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0
, 3, 7,
1091 static const struct soc_enum tx_dmic_mux4_enum
=
1092 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0
, 3, 7,
1095 static const struct soc_enum tx_dmic_mux5_enum
=
1096 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0
, 3, 7,
1099 static const struct soc_enum tx_dmic_mux6_enum
=
1100 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0
, 3, 7,
1103 static const struct soc_enum tx_dmic_mux7_enum
=
1104 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0
, 3, 7,
1107 static const struct soc_enum tx_dmic_mux8_enum
=
1108 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0
, 3, 7,
1111 static const struct soc_enum tx_amic_mux0_enum
=
1112 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0
, 0, 5,
1114 static const struct soc_enum tx_amic_mux1_enum
=
1115 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0
, 0, 5,
1117 static const struct soc_enum tx_amic_mux2_enum
=
1118 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0
, 0, 5,
1120 static const struct soc_enum tx_amic_mux3_enum
=
1121 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0
, 0, 5,
1123 static const struct soc_enum tx_amic_mux4_enum
=
1124 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0
, 0, 5,
1126 static const struct soc_enum tx_amic_mux5_enum
=
1127 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0
, 0, 5,
1129 static const struct soc_enum tx_amic_mux6_enum
=
1130 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0
, 0, 5,
1132 static const struct soc_enum tx_amic_mux7_enum
=
1133 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0
, 0, 5,
1135 static const struct soc_enum tx_amic_mux8_enum
=
1136 SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0
, 0, 5,
1139 static const struct soc_enum tx_amic4_5_enum
=
1140 SOC_ENUM_SINGLE(WCD934X_TX_NEW_AMIC_4_5_SEL
, 7, 2, amic4_5_sel_text
);
1142 static const struct soc_enum cdc_if_tx0_mux_enum
=
1143 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0
, 0,
1144 ARRAY_SIZE(cdc_if_tx0_mux_text
), cdc_if_tx0_mux_text
);
1145 static const struct soc_enum cdc_if_tx1_mux_enum
=
1146 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0
, 2,
1147 ARRAY_SIZE(cdc_if_tx1_mux_text
), cdc_if_tx1_mux_text
);
1148 static const struct soc_enum cdc_if_tx2_mux_enum
=
1149 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0
, 4,
1150 ARRAY_SIZE(cdc_if_tx2_mux_text
), cdc_if_tx2_mux_text
);
1151 static const struct soc_enum cdc_if_tx3_mux_enum
=
1152 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0
, 6,
1153 ARRAY_SIZE(cdc_if_tx3_mux_text
), cdc_if_tx3_mux_text
);
1154 static const struct soc_enum cdc_if_tx4_mux_enum
=
1155 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1
, 0,
1156 ARRAY_SIZE(cdc_if_tx4_mux_text
), cdc_if_tx4_mux_text
);
1157 static const struct soc_enum cdc_if_tx5_mux_enum
=
1158 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1
, 2,
1159 ARRAY_SIZE(cdc_if_tx5_mux_text
), cdc_if_tx5_mux_text
);
1160 static const struct soc_enum cdc_if_tx6_mux_enum
=
1161 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1
, 4,
1162 ARRAY_SIZE(cdc_if_tx6_mux_text
), cdc_if_tx6_mux_text
);
1163 static const struct soc_enum cdc_if_tx7_mux_enum
=
1164 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1
, 6,
1165 ARRAY_SIZE(cdc_if_tx7_mux_text
), cdc_if_tx7_mux_text
);
1166 static const struct soc_enum cdc_if_tx8_mux_enum
=
1167 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2
, 0,
1168 ARRAY_SIZE(cdc_if_tx8_mux_text
), cdc_if_tx8_mux_text
);
1169 static const struct soc_enum cdc_if_tx9_mux_enum
=
1170 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2
, 2,
1171 ARRAY_SIZE(cdc_if_tx9_mux_text
), cdc_if_tx9_mux_text
);
1172 static const struct soc_enum cdc_if_tx10_mux_enum
=
1173 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2
, 4,
1174 ARRAY_SIZE(cdc_if_tx10_mux_text
), cdc_if_tx10_mux_text
);
1175 static const struct soc_enum cdc_if_tx11_inp1_mux_enum
=
1176 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3
, 0,
1177 ARRAY_SIZE(cdc_if_tx11_inp1_mux_text
),
1178 cdc_if_tx11_inp1_mux_text
);
1179 static const struct soc_enum cdc_if_tx11_mux_enum
=
1180 SOC_ENUM_SINGLE(WCD934X_DATA_HUB_SB_TX11_INP_CFG
, 0,
1181 ARRAY_SIZE(cdc_if_tx11_mux_text
), cdc_if_tx11_mux_text
);
1182 static const struct soc_enum cdc_if_tx13_inp1_mux_enum
=
1183 SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3
, 4,
1184 ARRAY_SIZE(cdc_if_tx13_inp1_mux_text
),
1185 cdc_if_tx13_inp1_mux_text
);
1186 static const struct soc_enum cdc_if_tx13_mux_enum
=
1187 SOC_ENUM_SINGLE(WCD934X_DATA_HUB_SB_TX13_INP_CFG
, 0,
1188 ARRAY_SIZE(cdc_if_tx13_mux_text
), cdc_if_tx13_mux_text
);
1190 static int wcd934x_set_sido_input_src(struct wcd934x_codec
*wcd
, int sido_src
)
1192 if (sido_src
== wcd
->sido_input_src
)
1195 if (sido_src
== SIDO_SOURCE_INTERNAL
) {
1196 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BUCK_CTL
,
1197 WCD934X_ANA_BUCK_HI_ACCU_EN_MASK
, 0);
1198 usleep_range(100, 110);
1199 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BUCK_CTL
,
1200 WCD934X_ANA_BUCK_HI_ACCU_PRE_ENX_MASK
, 0x0);
1201 usleep_range(100, 110);
1202 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_RCO
,
1203 WCD934X_ANA_RCO_BG_EN_MASK
, 0);
1204 usleep_range(100, 110);
1205 } else if (sido_src
== SIDO_SOURCE_RCO_BG
) {
1206 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_RCO
,
1207 WCD934X_ANA_RCO_BG_EN_MASK
,
1208 WCD934X_ANA_RCO_BG_ENABLE
);
1209 usleep_range(100, 110);
1210 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BUCK_CTL
,
1211 WCD934X_ANA_BUCK_PRE_EN1_MASK
,
1212 WCD934X_ANA_BUCK_PRE_EN1_ENABLE
);
1213 usleep_range(100, 110);
1214 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BUCK_CTL
,
1215 WCD934X_ANA_BUCK_PRE_EN2_MASK
,
1216 WCD934X_ANA_BUCK_PRE_EN2_ENABLE
);
1217 usleep_range(100, 110);
1218 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BUCK_CTL
,
1219 WCD934X_ANA_BUCK_HI_ACCU_EN_MASK
,
1220 WCD934X_ANA_BUCK_HI_ACCU_ENABLE
);
1221 usleep_range(100, 110);
1223 wcd
->sido_input_src
= sido_src
;
1228 static int wcd934x_enable_ana_bias_and_sysclk(struct wcd934x_codec
*wcd
)
1230 mutex_lock(&wcd
->sysclk_mutex
);
1232 if (++wcd
->sysclk_users
!= 1) {
1233 mutex_unlock(&wcd
->sysclk_mutex
);
1236 mutex_unlock(&wcd
->sysclk_mutex
);
1238 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BIAS
,
1239 WCD934X_ANA_BIAS_EN_MASK
,
1240 WCD934X_ANA_BIAS_EN
);
1241 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BIAS
,
1242 WCD934X_ANA_PRECHRG_EN_MASK
,
1243 WCD934X_ANA_PRECHRG_EN
);
1245 * 1ms delay is required after pre-charge is enabled
1246 * as per HW requirement
1248 usleep_range(1000, 1100);
1249 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BIAS
,
1250 WCD934X_ANA_PRECHRG_EN_MASK
, 0);
1251 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BIAS
,
1252 WCD934X_ANA_PRECHRG_MODE_MASK
, 0);
1255 * In data clock contrl register is changed
1256 * to CLK_SYS_MCLK_PRG
1259 regmap_update_bits(wcd
->regmap
, WCD934X_CLK_SYS_MCLK_PRG
,
1260 WCD934X_EXT_CLK_BUF_EN_MASK
,
1261 WCD934X_EXT_CLK_BUF_EN
);
1262 regmap_update_bits(wcd
->regmap
, WCD934X_CLK_SYS_MCLK_PRG
,
1263 WCD934X_EXT_CLK_DIV_RATIO_MASK
,
1264 WCD934X_EXT_CLK_DIV_BY_2
);
1265 regmap_update_bits(wcd
->regmap
, WCD934X_CLK_SYS_MCLK_PRG
,
1266 WCD934X_MCLK_SRC_MASK
,
1267 WCD934X_MCLK_SRC_EXT_CLK
);
1268 regmap_update_bits(wcd
->regmap
, WCD934X_CLK_SYS_MCLK_PRG
,
1269 WCD934X_MCLK_EN_MASK
, WCD934X_MCLK_EN
);
1270 regmap_update_bits(wcd
->regmap
,
1271 WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL
,
1272 WCD934X_CDC_FS_MCLK_CNT_EN_MASK
,
1273 WCD934X_CDC_FS_MCLK_CNT_ENABLE
);
1274 regmap_update_bits(wcd
->regmap
,
1275 WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL
,
1276 WCD934X_MCLK_EN_MASK
,
1278 regmap_update_bits(wcd
->regmap
, WCD934X_CODEC_RPM_CLK_GATE
,
1279 WCD934X_CODEC_RPM_CLK_GATE_MASK
, 0x0);
1281 * 10us sleep is required after clock is enabled
1282 * as per HW requirement
1284 usleep_range(10, 15);
1286 wcd934x_set_sido_input_src(wcd
, SIDO_SOURCE_RCO_BG
);
1291 static int wcd934x_disable_ana_bias_and_syclk(struct wcd934x_codec
*wcd
)
1293 mutex_lock(&wcd
->sysclk_mutex
);
1294 if (--wcd
->sysclk_users
!= 0) {
1295 mutex_unlock(&wcd
->sysclk_mutex
);
1298 mutex_unlock(&wcd
->sysclk_mutex
);
1300 regmap_update_bits(wcd
->regmap
, WCD934X_CLK_SYS_MCLK_PRG
,
1301 WCD934X_EXT_CLK_BUF_EN_MASK
|
1302 WCD934X_MCLK_EN_MASK
, 0x0);
1303 wcd934x_set_sido_input_src(wcd
, SIDO_SOURCE_INTERNAL
);
1305 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BIAS
,
1306 WCD934X_ANA_BIAS_EN_MASK
, 0);
1307 regmap_update_bits(wcd
->regmap
, WCD934X_ANA_BIAS
,
1308 WCD934X_ANA_PRECHRG_EN_MASK
, 0);
1313 static int __wcd934x_cdc_mclk_enable(struct wcd934x_codec
*wcd
, bool enable
)
1318 ret
= clk_prepare_enable(wcd
->extclk
);
1321 dev_err(wcd
->dev
, "%s: ext clk enable failed\n",
1325 ret
= wcd934x_enable_ana_bias_and_sysclk(wcd
);
1329 regmap_read(wcd
->regmap
, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL
,
1332 /* Don't disable clock if soundwire using it.*/
1333 if (val
& WCD934X_CDC_SWR_CLK_EN_MASK
)
1336 wcd934x_disable_ana_bias_and_syclk(wcd
);
1337 clk_disable_unprepare(wcd
->extclk
);
1343 static int wcd934x_codec_enable_mclk(struct snd_soc_dapm_widget
*w
,
1344 struct snd_kcontrol
*kc
, int event
)
1346 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
1347 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
1350 case SND_SOC_DAPM_PRE_PMU
:
1351 return __wcd934x_cdc_mclk_enable(wcd
, true);
1352 case SND_SOC_DAPM_POST_PMD
:
1353 return __wcd934x_cdc_mclk_enable(wcd
, false);
1359 static int wcd934x_get_version(struct wcd934x_codec
*wcd
)
1361 int val1
, val2
, ver
, ret
;
1362 struct regmap
*regmap
;
1364 u32 version_mask
= 0;
1366 regmap
= wcd
->regmap
;
1369 ret
= regmap_bulk_read(regmap
, WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0
,
1370 (u8
*)&id_minor
, sizeof(u16
));
1375 regmap_read(regmap
, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14
, &val1
);
1376 regmap_read(regmap
, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT15
, &val2
);
1378 version_mask
|= (!!((u8
)val1
& 0x80)) << DSD_DISABLED_MASK
;
1379 version_mask
|= (!!((u8
)val2
& 0x01)) << SLNQ_DISABLED_MASK
;
1381 switch (version_mask
) {
1382 case DSD_DISABLED
| SLNQ_DISABLED
:
1384 ver
= WCD_VERSION_WCD9340_1_0
;
1385 else if (id_minor
== 0x01)
1386 ver
= WCD_VERSION_WCD9340_1_1
;
1390 ver
= WCD_VERSION_WCD9341_1_0
;
1391 else if (id_minor
== 0x01)
1392 ver
= WCD_VERSION_WCD9341_1_1
;
1397 dev_info(wcd
->dev
, "WCD934X Minor:0x%x Version:0x%x\n", id_minor
, ver
);
1402 static void wcd934x_enable_efuse_sensing(struct wcd934x_codec
*wcd
)
1406 __wcd934x_cdc_mclk_enable(wcd
, true);
1408 regmap_update_bits(wcd
->regmap
,
1409 WCD934X_CHIP_TIER_CTRL_EFUSE_CTL
,
1410 WCD934X_EFUSE_SENSE_STATE_MASK
,
1411 WCD934X_EFUSE_SENSE_STATE_DEF
);
1412 regmap_update_bits(wcd
->regmap
,
1413 WCD934X_CHIP_TIER_CTRL_EFUSE_CTL
,
1414 WCD934X_EFUSE_SENSE_EN_MASK
,
1415 WCD934X_EFUSE_SENSE_ENABLE
);
1417 * 5ms sleep required after enabling efuse control
1418 * before checking the status.
1420 usleep_range(5000, 5500);
1421 wcd934x_set_sido_input_src(wcd
, SIDO_SOURCE_RCO_BG
);
1423 rc
= regmap_read(wcd
->regmap
,
1424 WCD934X_CHIP_TIER_CTRL_EFUSE_STATUS
, &val
);
1425 if (rc
|| (!(val
& 0x01)))
1426 WARN(1, "%s: Efuse sense is not complete val=%x, ret=%d\n",
1429 __wcd934x_cdc_mclk_enable(wcd
, false);
1432 static int wcd934x_swrm_clock(struct wcd934x_codec
*wcd
, bool enable
)
1435 __wcd934x_cdc_mclk_enable(wcd
, true);
1436 regmap_update_bits(wcd
->regmap
,
1437 WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL
,
1438 WCD934X_CDC_SWR_CLK_EN_MASK
,
1439 WCD934X_CDC_SWR_CLK_ENABLE
);
1441 regmap_update_bits(wcd
->regmap
,
1442 WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL
,
1443 WCD934X_CDC_SWR_CLK_EN_MASK
, 0);
1444 __wcd934x_cdc_mclk_enable(wcd
, false);
1450 static int wcd934x_set_prim_interpolator_rate(struct snd_soc_dai
*dai
,
1451 u8 rate_val
, u32 rate
)
1453 struct snd_soc_component
*comp
= dai
->component
;
1454 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
1455 struct wcd934x_slim_ch
*ch
;
1456 u8 cfg0
, cfg1
, inp0_sel
, inp1_sel
, inp2_sel
;
1459 list_for_each_entry(ch
, &wcd
->dai
[dai
->id
].slim_ch_list
, list
) {
1460 inp
= ch
->shift
+ INTn_1_INP_SEL_RX0
;
1462 * Loop through all interpolator MUX inputs and find out
1463 * to which interpolator input, the slim rx port
1466 for (j
= 0; j
< WCD934X_NUM_INTERPOLATORS
; j
++) {
1467 /* Interpolators 5 and 6 are not aviliable in Tavil */
1468 if (j
== INTERP_LO3_NA
|| j
== INTERP_LO4_NA
)
1471 cfg0
= snd_soc_component_read32(comp
,
1472 WCD934X_CDC_RX_INP_MUX_RX_INT_CFG0(j
));
1473 cfg1
= snd_soc_component_read32(comp
,
1474 WCD934X_CDC_RX_INP_MUX_RX_INT_CFG1(j
));
1477 WCD934X_CDC_RX_INP_MUX_RX_INT_SEL_MASK
;
1478 inp1_sel
= (cfg0
>> 4) &
1479 WCD934X_CDC_RX_INP_MUX_RX_INT_SEL_MASK
;
1480 inp2_sel
= (cfg1
>> 4) &
1481 WCD934X_CDC_RX_INP_MUX_RX_INT_SEL_MASK
;
1483 if ((inp0_sel
== inp
) || (inp1_sel
== inp
) ||
1484 (inp2_sel
== inp
)) {
1487 * Ear and speaker primary path does not support
1488 * native sample rates
1490 if ((j
== INTERP_EAR
|| j
== INTERP_SPKR1
||
1491 j
== INTERP_SPKR2
) && rate
== 44100)
1493 "Cannot set 44.1KHz on INT%d\n",
1496 snd_soc_component_update_bits(comp
,
1497 WCD934X_CDC_RX_PATH_CTL(j
),
1498 WCD934X_CDC_MIX_PCM_RATE_MASK
,
1507 static int wcd934x_set_mix_interpolator_rate(struct snd_soc_dai
*dai
,
1508 int rate_val
, u32 rate
)
1510 struct snd_soc_component
*component
= dai
->component
;
1511 struct wcd934x_codec
*wcd
= dev_get_drvdata(component
->dev
);
1512 struct wcd934x_slim_ch
*ch
;
1515 list_for_each_entry(ch
, &wcd
->dai
[dai
->id
].slim_ch_list
, list
) {
1516 for (j
= 0; j
< WCD934X_NUM_INTERPOLATORS
; j
++) {
1517 /* Interpolators 5 and 6 are not aviliable in Tavil */
1518 if (j
== INTERP_LO3_NA
|| j
== INTERP_LO4_NA
)
1520 val
= snd_soc_component_read32(component
,
1521 WCD934X_CDC_RX_INP_MUX_RX_INT_CFG1(j
)) &
1522 WCD934X_CDC_RX_INP_MUX_RX_INT_SEL_MASK
;
1524 if (val
== (ch
->shift
+ INTn_2_INP_SEL_RX0
)) {
1526 * Ear mix path supports only 48, 96, 192,
1529 if ((j
== INTERP_EAR
) &&
1532 dev_err(component
->dev
,
1533 "Invalid rate for AIF_PB DAI(%d)\n",
1538 snd_soc_component_update_bits(component
,
1539 WCD934X_CDC_RX_PATH_MIX_CTL(j
),
1540 WCD934X_CDC_MIX_PCM_RATE_MASK
,
1549 static int wcd934x_set_interpolator_rate(struct snd_soc_dai
*dai
,
1555 for (i
= 0; i
< ARRAY_SIZE(sr_val_tbl
); i
++) {
1556 if (sample_rate
== sr_val_tbl
[i
].sample_rate
) {
1557 rate_val
= sr_val_tbl
[i
].rate_val
;
1561 if ((i
== ARRAY_SIZE(sr_val_tbl
)) || (rate_val
< 0)) {
1562 dev_err(dai
->dev
, "Unsupported sample rate: %d\n", sample_rate
);
1566 ret
= wcd934x_set_prim_interpolator_rate(dai
, (u8
)rate_val
,
1570 ret
= wcd934x_set_mix_interpolator_rate(dai
, (u8
)rate_val
,
1578 static int wcd934x_set_decimator_rate(struct snd_soc_dai
*dai
,
1579 u8 rate_val
, u32 rate
)
1581 struct snd_soc_component
*comp
= dai
->component
;
1582 struct wcd934x_codec
*wcd
= snd_soc_component_get_drvdata(comp
);
1583 u8 shift
= 0, shift_val
= 0, tx_mux_sel
;
1584 struct wcd934x_slim_ch
*ch
;
1585 int tx_port
, tx_port_reg
;
1588 list_for_each_entry(ch
, &wcd
->dai
[dai
->id
].slim_ch_list
, list
) {
1590 /* Find the SB TX MUX input - which decimator is connected */
1593 tx_port_reg
= WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0
;
1594 shift
= (tx_port
<< 1);
1598 tx_port_reg
= WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1
;
1599 shift
= ((tx_port
- 4) << 1);
1603 tx_port_reg
= WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2
;
1604 shift
= ((tx_port
- 8) << 1);
1608 tx_port_reg
= WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3
;
1613 tx_port_reg
= WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3
;
1618 dev_err(wcd
->dev
, "Invalid SLIM TX%u port DAI ID:%d\n",
1623 tx_mux_sel
= snd_soc_component_read32(comp
, tx_port_reg
) &
1624 (shift_val
<< shift
);
1626 tx_mux_sel
= tx_mux_sel
>> shift
;
1629 if ((tx_mux_sel
== 0x2) || (tx_mux_sel
== 0x3))
1630 decimator
= tx_port
;
1633 if ((tx_mux_sel
== 0x1) || (tx_mux_sel
== 0x2))
1634 decimator
= ((tx_port
== 9) ? 7 : 6);
1637 if ((tx_mux_sel
>= 1) && (tx_mux_sel
< 7))
1638 decimator
= tx_mux_sel
- 1;
1641 if ((tx_mux_sel
== 0x1) || (tx_mux_sel
== 0x2))
1645 dev_err(wcd
->dev
, "ERROR: Invalid tx_port: %d\n",
1650 snd_soc_component_update_bits(comp
,
1651 WCD934X_CDC_TX_PATH_CTL(decimator
),
1652 WCD934X_CDC_TX_PATH_CTL_PCM_RATE_MASK
,
1659 static int wcd934x_slim_set_hw_params(struct wcd934x_codec
*wcd
,
1660 struct wcd_slim_codec_dai_data
*dai_data
,
1663 struct list_head
*slim_ch_list
= &dai_data
->slim_ch_list
;
1664 struct slim_stream_config
*cfg
= &dai_data
->sconfig
;
1665 struct wcd934x_slim_ch
*ch
;
1670 cfg
->direction
= direction
;
1673 /* Configure slave interface device */
1674 list_for_each_entry(ch
, slim_ch_list
, list
) {
1676 payload
|= 1 << ch
->shift
;
1677 cfg
->port_mask
|= BIT(ch
->port
);
1680 cfg
->chs
= kcalloc(cfg
->ch_count
, sizeof(unsigned int), GFP_KERNEL
);
1685 list_for_each_entry(ch
, slim_ch_list
, list
) {
1686 cfg
->chs
[i
++] = ch
->ch_num
;
1687 if (direction
== SNDRV_PCM_STREAM_PLAYBACK
) {
1688 /* write to interface device */
1689 ret
= regmap_write(wcd
->if_regmap
,
1690 WCD934X_SLIM_PGD_RX_PORT_MULTI_CHNL_0(ch
->port
),
1696 /* configure the slave port for water mark and enable*/
1697 ret
= regmap_write(wcd
->if_regmap
,
1698 WCD934X_SLIM_PGD_RX_PORT_CFG(ch
->port
),
1699 WCD934X_SLIM_WATER_MARK_VAL
);
1703 ret
= regmap_write(wcd
->if_regmap
,
1704 WCD934X_SLIM_PGD_TX_PORT_MULTI_CHNL_0(ch
->port
),
1710 ret
= regmap_write(wcd
->if_regmap
,
1711 WCD934X_SLIM_PGD_TX_PORT_MULTI_CHNL_1(ch
->port
),
1712 (payload
& 0xFF00) >> 8);
1716 /* configure the slave port for water mark and enable*/
1717 ret
= regmap_write(wcd
->if_regmap
,
1718 WCD934X_SLIM_PGD_TX_PORT_CFG(ch
->port
),
1719 WCD934X_SLIM_WATER_MARK_VAL
);
1726 dai_data
->sruntime
= slim_stream_allocate(wcd
->sdev
, "WCD934x-SLIM");
1731 dev_err(wcd
->dev
, "Error Setting slim hw params\n");
1738 static int wcd934x_hw_params(struct snd_pcm_substream
*substream
,
1739 struct snd_pcm_hw_params
*params
,
1740 struct snd_soc_dai
*dai
)
1742 struct wcd934x_codec
*wcd
;
1743 int ret
, tx_fs_rate
= 0;
1745 wcd
= snd_soc_component_get_drvdata(dai
->component
);
1747 switch (substream
->stream
) {
1748 case SNDRV_PCM_STREAM_PLAYBACK
:
1749 ret
= wcd934x_set_interpolator_rate(dai
, params_rate(params
));
1751 dev_err(wcd
->dev
, "cannot set sample rate: %u\n",
1752 params_rate(params
));
1755 switch (params_width(params
)) {
1757 wcd
->dai
[dai
->id
].sconfig
.bps
= params_width(params
);
1760 dev_err(wcd
->dev
, "Invalid format 0x%x\n",
1761 params_width(params
));
1766 case SNDRV_PCM_STREAM_CAPTURE
:
1767 switch (params_rate(params
)) {
1790 dev_err(wcd
->dev
, "Invalid TX sample rate: %d\n",
1791 params_rate(params
));
1796 ret
= wcd934x_set_decimator_rate(dai
, tx_fs_rate
,
1797 params_rate(params
));
1799 dev_err(wcd
->dev
, "Cannot set TX Decimator rate\n");
1802 switch (params_width(params
)) {
1804 wcd
->dai
[dai
->id
].sconfig
.bps
= params_width(params
);
1807 dev_err(wcd
->dev
, "Invalid format 0x%x\n",
1808 params_width(params
));
1813 dev_err(wcd
->dev
, "Invalid stream type %d\n",
1818 wcd
->dai
[dai
->id
].sconfig
.rate
= params_rate(params
);
1819 wcd934x_slim_set_hw_params(wcd
, &wcd
->dai
[dai
->id
], substream
->stream
);
1824 static int wcd934x_hw_free(struct snd_pcm_substream
*substream
,
1825 struct snd_soc_dai
*dai
)
1827 struct wcd_slim_codec_dai_data
*dai_data
;
1828 struct wcd934x_codec
*wcd
;
1830 wcd
= snd_soc_component_get_drvdata(dai
->component
);
1832 dai_data
= &wcd
->dai
[dai
->id
];
1834 kfree(dai_data
->sconfig
.chs
);
1839 static int wcd934x_trigger(struct snd_pcm_substream
*substream
, int cmd
,
1840 struct snd_soc_dai
*dai
)
1842 struct wcd_slim_codec_dai_data
*dai_data
;
1843 struct wcd934x_codec
*wcd
;
1844 struct slim_stream_config
*cfg
;
1846 wcd
= snd_soc_component_get_drvdata(dai
->component
);
1848 dai_data
= &wcd
->dai
[dai
->id
];
1851 case SNDRV_PCM_TRIGGER_START
:
1852 case SNDRV_PCM_TRIGGER_RESUME
:
1853 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
1854 cfg
= &dai_data
->sconfig
;
1855 slim_stream_prepare(dai_data
->sruntime
, cfg
);
1856 slim_stream_enable(dai_data
->sruntime
);
1858 case SNDRV_PCM_TRIGGER_STOP
:
1859 case SNDRV_PCM_TRIGGER_SUSPEND
:
1860 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
1861 slim_stream_unprepare(dai_data
->sruntime
);
1862 slim_stream_disable(dai_data
->sruntime
);
1871 static int wcd934x_set_channel_map(struct snd_soc_dai
*dai
,
1872 unsigned int tx_num
, unsigned int *tx_slot
,
1873 unsigned int rx_num
, unsigned int *rx_slot
)
1875 struct wcd934x_codec
*wcd
;
1878 wcd
= snd_soc_component_get_drvdata(dai
->component
);
1880 if (!tx_slot
|| !rx_slot
) {
1881 dev_err(wcd
->dev
, "Invalid tx_slot=%p, rx_slot=%p\n",
1887 wcd
->num_rx_port
= rx_num
;
1888 for (i
= 0; i
< rx_num
; i
++) {
1889 wcd
->rx_chs
[i
].ch_num
= rx_slot
[i
];
1890 INIT_LIST_HEAD(&wcd
->rx_chs
[i
].list
);
1895 wcd
->num_tx_port
= tx_num
;
1896 for (i
= 0; i
< tx_num
; i
++) {
1897 wcd
->tx_chs
[i
].ch_num
= tx_slot
[i
];
1898 INIT_LIST_HEAD(&wcd
->tx_chs
[i
].list
);
1905 static int wcd934x_get_channel_map(struct snd_soc_dai
*dai
,
1906 unsigned int *tx_num
, unsigned int *tx_slot
,
1907 unsigned int *rx_num
, unsigned int *rx_slot
)
1909 struct wcd934x_slim_ch
*ch
;
1910 struct wcd934x_codec
*wcd
;
1913 wcd
= snd_soc_component_get_drvdata(dai
->component
);
1920 if (!rx_slot
|| !rx_num
) {
1921 dev_err(wcd
->dev
, "Invalid rx_slot %p or rx_num %p\n",
1926 list_for_each_entry(ch
, &wcd
->dai
[dai
->id
].slim_ch_list
, list
)
1927 rx_slot
[i
++] = ch
->ch_num
;
1934 if (!tx_slot
|| !tx_num
) {
1935 dev_err(wcd
->dev
, "Invalid tx_slot %p or tx_num %p\n",
1940 list_for_each_entry(ch
, &wcd
->dai
[dai
->id
].slim_ch_list
, list
)
1941 tx_slot
[i
++] = ch
->ch_num
;
1946 dev_err(wcd
->dev
, "Invalid DAI ID %x\n", dai
->id
);
1953 static struct snd_soc_dai_ops wcd934x_dai_ops
= {
1954 .hw_params
= wcd934x_hw_params
,
1955 .hw_free
= wcd934x_hw_free
,
1956 .trigger
= wcd934x_trigger
,
1957 .set_channel_map
= wcd934x_set_channel_map
,
1958 .get_channel_map
= wcd934x_get_channel_map
,
1961 static struct snd_soc_dai_driver wcd934x_slim_dais
[] = {
1963 .name
= "wcd934x_rx1",
1966 .stream_name
= "AIF1 Playback",
1967 .rates
= WCD934X_RATES_MASK
| WCD934X_FRAC_RATES_MASK
,
1968 .formats
= WCD934X_FORMATS_S16_S24_LE
,
1974 .ops
= &wcd934x_dai_ops
,
1977 .name
= "wcd934x_tx1",
1980 .stream_name
= "AIF1 Capture",
1981 .rates
= WCD934X_RATES_MASK
,
1982 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
1988 .ops
= &wcd934x_dai_ops
,
1991 .name
= "wcd934x_rx2",
1994 .stream_name
= "AIF2 Playback",
1995 .rates
= WCD934X_RATES_MASK
| WCD934X_FRAC_RATES_MASK
,
1996 .formats
= WCD934X_FORMATS_S16_S24_LE
,
2002 .ops
= &wcd934x_dai_ops
,
2005 .name
= "wcd934x_tx2",
2008 .stream_name
= "AIF2 Capture",
2009 .rates
= WCD934X_RATES_MASK
,
2010 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
2016 .ops
= &wcd934x_dai_ops
,
2019 .name
= "wcd934x_rx3",
2022 .stream_name
= "AIF3 Playback",
2023 .rates
= WCD934X_RATES_MASK
| WCD934X_FRAC_RATES_MASK
,
2024 .formats
= WCD934X_FORMATS_S16_S24_LE
,
2030 .ops
= &wcd934x_dai_ops
,
2033 .name
= "wcd934x_tx3",
2036 .stream_name
= "AIF3 Capture",
2037 .rates
= WCD934X_RATES_MASK
,
2038 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
2044 .ops
= &wcd934x_dai_ops
,
2047 .name
= "wcd934x_rx4",
2050 .stream_name
= "AIF4 Playback",
2051 .rates
= WCD934X_RATES_MASK
| WCD934X_FRAC_RATES_MASK
,
2052 .formats
= WCD934X_FORMATS_S16_S24_LE
,
2058 .ops
= &wcd934x_dai_ops
,
2062 static int swclk_gate_enable(struct clk_hw
*hw
)
2064 return wcd934x_swrm_clock(to_wcd934x_codec(hw
), true);
2067 static void swclk_gate_disable(struct clk_hw
*hw
)
2069 wcd934x_swrm_clock(to_wcd934x_codec(hw
), false);
2072 static int swclk_gate_is_enabled(struct clk_hw
*hw
)
2074 struct wcd934x_codec
*wcd
= to_wcd934x_codec(hw
);
2077 regmap_read(wcd
->regmap
, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL
, &val
);
2078 ret
= val
& WCD934X_CDC_SWR_CLK_EN_MASK
;
2083 static unsigned long swclk_recalc_rate(struct clk_hw
*hw
,
2084 unsigned long parent_rate
)
2086 return parent_rate
/ 2;
2089 static const struct clk_ops swclk_gate_ops
= {
2090 .prepare
= swclk_gate_enable
,
2091 .unprepare
= swclk_gate_disable
,
2092 .is_enabled
= swclk_gate_is_enabled
,
2093 .recalc_rate
= swclk_recalc_rate
,
2097 static struct clk
*wcd934x_register_mclk_output(struct wcd934x_codec
*wcd
)
2099 struct clk
*parent
= wcd
->extclk
;
2100 struct device
*dev
= wcd
->dev
;
2101 struct device_node
*np
= dev
->parent
->of_node
;
2102 const char *parent_clk_name
= NULL
;
2103 const char *clk_name
= "mclk";
2105 struct clk_init_data init
;
2108 if (of_property_read_u32(np
, "clock-frequency", &wcd
->rate
))
2111 parent_clk_name
= __clk_get_name(parent
);
2113 of_property_read_string(np
, "clock-output-names", &clk_name
);
2115 init
.name
= clk_name
;
2116 init
.ops
= &swclk_gate_ops
;
2118 init
.parent_names
= &parent_clk_name
;
2119 init
.num_parents
= 1;
2120 wcd
->hw
.init
= &init
;
2123 ret
= clk_hw_register(wcd
->dev
->parent
, hw
);
2125 return ERR_PTR(ret
);
2127 of_clk_add_provider(np
, of_clk_src_simple_get
, hw
->clk
);
2132 static int wcd934x_get_micbias_val(struct device
*dev
, const char *micbias
)
2136 if (of_property_read_u32(dev
->parent
->of_node
, micbias
, &mv
)) {
2137 dev_err(dev
, "%s value not found, using default\n", micbias
);
2138 mv
= WCD934X_DEF_MICBIAS_MV
;
2140 /* convert it to milli volts */
2144 if (mv
< 1000 || mv
> 2850) {
2145 dev_err(dev
, "%s value not in valid range, using default\n",
2147 mv
= WCD934X_DEF_MICBIAS_MV
;
2150 return (mv
- 1000) / 50;
2153 static int wcd934x_init_dmic(struct snd_soc_component
*comp
)
2155 int vout_ctl_1
, vout_ctl_2
, vout_ctl_3
, vout_ctl_4
;
2156 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
2157 u32 def_dmic_rate
, dmic_clk_drv
;
2159 vout_ctl_1
= wcd934x_get_micbias_val(comp
->dev
,
2160 "qcom,micbias1-microvolt");
2161 vout_ctl_2
= wcd934x_get_micbias_val(comp
->dev
,
2162 "qcom,micbias2-microvolt");
2163 vout_ctl_3
= wcd934x_get_micbias_val(comp
->dev
,
2164 "qcom,micbias3-microvolt");
2165 vout_ctl_4
= wcd934x_get_micbias_val(comp
->dev
,
2166 "qcom,micbias4-microvolt");
2168 snd_soc_component_update_bits(comp
, WCD934X_ANA_MICB1
,
2169 WCD934X_MICB_VAL_MASK
, vout_ctl_1
);
2170 snd_soc_component_update_bits(comp
, WCD934X_ANA_MICB2
,
2171 WCD934X_MICB_VAL_MASK
, vout_ctl_2
);
2172 snd_soc_component_update_bits(comp
, WCD934X_ANA_MICB3
,
2173 WCD934X_MICB_VAL_MASK
, vout_ctl_3
);
2174 snd_soc_component_update_bits(comp
, WCD934X_ANA_MICB4
,
2175 WCD934X_MICB_VAL_MASK
, vout_ctl_4
);
2177 if (wcd
->rate
== WCD934X_MCLK_CLK_9P6MHZ
)
2178 def_dmic_rate
= WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ
;
2180 def_dmic_rate
= WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ
;
2182 wcd
->dmic_sample_rate
= def_dmic_rate
;
2185 snd_soc_component_update_bits(comp
, WCD934X_TEST_DEBUG_PAD_DRVCTL_0
,
2186 0x0C, dmic_clk_drv
<< 2);
2191 static void wcd934x_hw_init(struct wcd934x_codec
*wcd
)
2193 struct regmap
*rm
= wcd
->regmap
;
2195 /* set SPKR rate to FS_2P4_3P072 */
2196 regmap_update_bits(rm
, WCD934X_CDC_RX7_RX_PATH_CFG1
, 0x08, 0x08);
2197 regmap_update_bits(rm
, WCD934X_CDC_RX8_RX_PATH_CFG1
, 0x08, 0x08);
2199 /* Take DMICs out of reset */
2200 regmap_update_bits(rm
, WCD934X_CPE_SS_DMIC_CFG
, 0x80, 0x00);
2203 static int wcd934x_comp_init(struct snd_soc_component
*component
)
2205 struct wcd934x_codec
*wcd
= dev_get_drvdata(component
->dev
);
2207 wcd934x_hw_init(wcd
);
2208 wcd934x_enable_efuse_sensing(wcd
);
2209 wcd934x_get_version(wcd
);
2214 static irqreturn_t
wcd934x_slim_irq_handler(int irq
, void *data
)
2216 struct wcd934x_codec
*wcd
= data
;
2217 unsigned long status
= 0;
2219 unsigned int val
, int_val
= 0;
2220 irqreturn_t ret
= IRQ_NONE
;
2222 unsigned short reg
= 0;
2224 for (i
= WCD934X_SLIM_PGD_PORT_INT_STATUS_RX_0
, j
= 0;
2225 i
<= WCD934X_SLIM_PGD_PORT_INT_STATUS_TX_1
; i
++, j
++) {
2226 regmap_read(wcd
->if_regmap
, i
, &val
);
2227 status
|= ((u32
)val
<< (8 * j
));
2230 for_each_set_bit(j
, &status
, 32) {
2239 regmap_read(wcd
->if_regmap
,
2240 WCD934X_SLIM_PGD_PORT_INT_RX_SOURCE0
+ j
, &val
);
2243 reg
= WCD934X_SLIM_PGD_PORT_INT_EN0
+
2246 reg
= WCD934X_SLIM_PGD_PORT_INT_TX_EN0
+
2248 regmap_read(wcd
->if_regmap
, reg
, &int_val
);
2251 if (val
& WCD934X_SLIM_IRQ_OVERFLOW
)
2252 dev_err_ratelimited(wcd
->dev
,
2253 "overflow error on %s port %d, value %x\n",
2254 (tx
? "TX" : "RX"), port_id
, val
);
2256 if (val
& WCD934X_SLIM_IRQ_UNDERFLOW
)
2257 dev_err_ratelimited(wcd
->dev
,
2258 "underflow error on %s port %d, value %x\n",
2259 (tx
? "TX" : "RX"), port_id
, val
);
2261 if ((val
& WCD934X_SLIM_IRQ_OVERFLOW
) ||
2262 (val
& WCD934X_SLIM_IRQ_UNDERFLOW
)) {
2264 reg
= WCD934X_SLIM_PGD_PORT_INT_EN0
+
2267 reg
= WCD934X_SLIM_PGD_PORT_INT_TX_EN0
+
2270 wcd
->if_regmap
, reg
, &int_val
);
2271 if (int_val
& (1 << (port_id
% 8))) {
2272 int_val
= int_val
^ (1 << (port_id
% 8));
2273 regmap_write(wcd
->if_regmap
,
2278 if (val
& WCD934X_SLIM_IRQ_PORT_CLOSED
)
2279 dev_err_ratelimited(wcd
->dev
,
2280 "Port Closed %s port %d, value %x\n",
2281 (tx
? "TX" : "RX"), port_id
, val
);
2283 regmap_write(wcd
->if_regmap
,
2284 WCD934X_SLIM_PGD_PORT_INT_CLR_RX_0
+ (j
/ 8),
2292 static int wcd934x_comp_probe(struct snd_soc_component
*component
)
2294 struct wcd934x_codec
*wcd
= dev_get_drvdata(component
->dev
);
2297 snd_soc_component_init_regmap(component
, wcd
->regmap
);
2298 wcd
->component
= component
;
2301 wcd
->clsh_ctrl
= wcd_clsh_ctrl_alloc(component
, wcd
->version
);
2302 if (IS_ERR(wcd
->clsh_ctrl
))
2303 return PTR_ERR(wcd
->clsh_ctrl
);
2305 /* Default HPH Mode to Class-H Low HiFi */
2306 wcd
->hph_mode
= CLS_H_LOHIFI
;
2308 wcd934x_comp_init(component
);
2310 for (i
= 0; i
< NUM_CODEC_DAIS
; i
++)
2311 INIT_LIST_HEAD(&wcd
->dai
[i
].slim_ch_list
);
2313 wcd934x_init_dmic(component
);
2317 static void wcd934x_comp_remove(struct snd_soc_component
*comp
)
2319 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
2321 wcd_clsh_ctrl_free(wcd
->clsh_ctrl
);
2324 static int wcd934x_comp_set_sysclk(struct snd_soc_component
*comp
,
2325 int clk_id
, int source
,
2326 unsigned int freq
, int dir
)
2328 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
2329 int val
= WCD934X_CODEC_RPM_CLK_MCLK_CFG_9P6MHZ
;
2333 if (wcd
->rate
== WCD934X_MCLK_CLK_12P288MHZ
)
2334 val
= WCD934X_CODEC_RPM_CLK_MCLK_CFG_12P288MHZ
;
2336 snd_soc_component_update_bits(comp
, WCD934X_CODEC_RPM_CLK_MCLK_CFG
,
2337 WCD934X_CODEC_RPM_CLK_MCLK_CFG_MCLK_MASK
,
2340 return clk_set_rate(wcd
->extclk
, freq
);
2343 static uint32_t get_iir_band_coeff(struct snd_soc_component
*component
,
2344 int iir_idx
, int band_idx
, int coeff_idx
)
2349 /* Address does not automatically update if reading */
2350 reg
= WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL
+ 16 * iir_idx
;
2351 b2_reg
= WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL
+ 16 * iir_idx
;
2353 snd_soc_component_write(component
, reg
,
2354 ((band_idx
* BAND_MAX
+ coeff_idx
) *
2355 sizeof(uint32_t)) & 0x7F);
2357 value
|= snd_soc_component_read32(component
, b2_reg
);
2358 snd_soc_component_write(component
, reg
,
2359 ((band_idx
* BAND_MAX
+ coeff_idx
)
2360 * sizeof(uint32_t) + 1) & 0x7F);
2362 value
|= (snd_soc_component_read32(component
, b2_reg
) << 8);
2363 snd_soc_component_write(component
, reg
,
2364 ((band_idx
* BAND_MAX
+ coeff_idx
)
2365 * sizeof(uint32_t) + 2) & 0x7F);
2367 value
|= (snd_soc_component_read32(component
, b2_reg
) << 16);
2368 snd_soc_component_write(component
, reg
,
2369 ((band_idx
* BAND_MAX
+ coeff_idx
)
2370 * sizeof(uint32_t) + 3) & 0x7F);
2372 /* Mask bits top 2 bits since they are reserved */
2373 value
|= (snd_soc_component_read32(component
, b2_reg
) << 24);
2377 static void set_iir_band_coeff(struct snd_soc_component
*component
,
2378 int iir_idx
, int band_idx
, uint32_t value
)
2380 int reg
= WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL
+ 16 * iir_idx
;
2382 snd_soc_component_write(component
, reg
, (value
& 0xFF));
2383 snd_soc_component_write(component
, reg
, (value
>> 8) & 0xFF);
2384 snd_soc_component_write(component
, reg
, (value
>> 16) & 0xFF);
2385 /* Mask top 2 bits, 7-8 are reserved */
2386 snd_soc_component_write(component
, reg
, (value
>> 24) & 0x3F);
2389 static int wcd934x_put_iir_band_audio_mixer(
2390 struct snd_kcontrol
*kcontrol
,
2391 struct snd_ctl_elem_value
*ucontrol
)
2393 struct snd_soc_component
*component
=
2394 snd_soc_kcontrol_component(kcontrol
);
2395 struct wcd_iir_filter_ctl
*ctl
=
2396 (struct wcd_iir_filter_ctl
*)kcontrol
->private_value
;
2397 struct soc_bytes_ext
*params
= &ctl
->bytes_ext
;
2398 int iir_idx
= ctl
->iir_idx
;
2399 int band_idx
= ctl
->band_idx
;
2400 u32 coeff
[BAND_MAX
];
2401 int reg
= WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL
+ 16 * iir_idx
;
2403 memcpy(&coeff
[0], ucontrol
->value
.bytes
.data
, params
->max
);
2405 /* Mask top bit it is reserved */
2406 /* Updates addr automatically for each B2 write */
2407 snd_soc_component_write(component
, reg
, (band_idx
* BAND_MAX
*
2408 sizeof(uint32_t)) & 0x7F);
2410 set_iir_band_coeff(component
, iir_idx
, band_idx
, coeff
[0]);
2411 set_iir_band_coeff(component
, iir_idx
, band_idx
, coeff
[1]);
2412 set_iir_band_coeff(component
, iir_idx
, band_idx
, coeff
[2]);
2413 set_iir_band_coeff(component
, iir_idx
, band_idx
, coeff
[3]);
2414 set_iir_band_coeff(component
, iir_idx
, band_idx
, coeff
[4]);
2419 static int wcd934x_get_iir_band_audio_mixer(struct snd_kcontrol
*kcontrol
,
2420 struct snd_ctl_elem_value
*ucontrol
)
2422 struct snd_soc_component
*component
=
2423 snd_soc_kcontrol_component(kcontrol
);
2424 struct wcd_iir_filter_ctl
*ctl
=
2425 (struct wcd_iir_filter_ctl
*)kcontrol
->private_value
;
2426 struct soc_bytes_ext
*params
= &ctl
->bytes_ext
;
2427 int iir_idx
= ctl
->iir_idx
;
2428 int band_idx
= ctl
->band_idx
;
2429 u32 coeff
[BAND_MAX
];
2431 coeff
[0] = get_iir_band_coeff(component
, iir_idx
, band_idx
, 0);
2432 coeff
[1] = get_iir_band_coeff(component
, iir_idx
, band_idx
, 1);
2433 coeff
[2] = get_iir_band_coeff(component
, iir_idx
, band_idx
, 2);
2434 coeff
[3] = get_iir_band_coeff(component
, iir_idx
, band_idx
, 3);
2435 coeff
[4] = get_iir_band_coeff(component
, iir_idx
, band_idx
, 4);
2437 memcpy(ucontrol
->value
.bytes
.data
, &coeff
[0], params
->max
);
2442 static int wcd934x_iir_filter_info(struct snd_kcontrol
*kcontrol
,
2443 struct snd_ctl_elem_info
*ucontrol
)
2445 struct wcd_iir_filter_ctl
*ctl
=
2446 (struct wcd_iir_filter_ctl
*)kcontrol
->private_value
;
2447 struct soc_bytes_ext
*params
= &ctl
->bytes_ext
;
2449 ucontrol
->type
= SNDRV_CTL_ELEM_TYPE_BYTES
;
2450 ucontrol
->count
= params
->max
;
2455 static int wcd934x_compander_get(struct snd_kcontrol
*kc
,
2456 struct snd_ctl_elem_value
*ucontrol
)
2458 struct snd_soc_component
*component
= snd_soc_kcontrol_component(kc
);
2459 int comp
= ((struct soc_mixer_control
*)kc
->private_value
)->shift
;
2460 struct wcd934x_codec
*wcd
= dev_get_drvdata(component
->dev
);
2462 ucontrol
->value
.integer
.value
[0] = wcd
->comp_enabled
[comp
];
2467 static int wcd934x_compander_set(struct snd_kcontrol
*kc
,
2468 struct snd_ctl_elem_value
*ucontrol
)
2470 struct snd_soc_component
*component
= snd_soc_kcontrol_component(kc
);
2471 struct wcd934x_codec
*wcd
= dev_get_drvdata(component
->dev
);
2472 int comp
= ((struct soc_mixer_control
*)kc
->private_value
)->shift
;
2473 int value
= ucontrol
->value
.integer
.value
[0];
2476 wcd
->comp_enabled
[comp
] = value
;
2477 sel
= value
? WCD934X_HPH_GAIN_SRC_SEL_COMPANDER
:
2478 WCD934X_HPH_GAIN_SRC_SEL_REGISTER
;
2480 /* Any specific register configuration for compander */
2483 /* Set Gain Source Select based on compander enable/disable */
2484 snd_soc_component_update_bits(component
, WCD934X_HPH_L_EN
,
2485 WCD934X_HPH_GAIN_SRC_SEL_MASK
,
2489 snd_soc_component_update_bits(component
, WCD934X_HPH_R_EN
,
2490 WCD934X_HPH_GAIN_SRC_SEL_MASK
,
2505 static int wcd934x_rx_hph_mode_get(struct snd_kcontrol
*kc
,
2506 struct snd_ctl_elem_value
*ucontrol
)
2508 struct snd_soc_component
*component
= snd_soc_kcontrol_component(kc
);
2509 struct wcd934x_codec
*wcd
= dev_get_drvdata(component
->dev
);
2511 ucontrol
->value
.enumerated
.item
[0] = wcd
->hph_mode
;
2516 static int wcd934x_rx_hph_mode_put(struct snd_kcontrol
*kc
,
2517 struct snd_ctl_elem_value
*ucontrol
)
2519 struct snd_soc_component
*component
= snd_soc_kcontrol_component(kc
);
2520 struct wcd934x_codec
*wcd
= dev_get_drvdata(component
->dev
);
2523 mode_val
= ucontrol
->value
.enumerated
.item
[0];
2525 if (mode_val
== 0) {
2526 dev_err(wcd
->dev
, "Invalid HPH Mode, default to ClSH HiFi\n");
2527 mode_val
= CLS_H_LOHIFI
;
2529 wcd
->hph_mode
= mode_val
;
2534 static int slim_rx_mux_get(struct snd_kcontrol
*kc
,
2535 struct snd_ctl_elem_value
*ucontrol
)
2537 struct snd_soc_dapm_context
*dapm
= snd_soc_dapm_kcontrol_dapm(kc
);
2538 struct snd_soc_dapm_widget
*w
= snd_soc_dapm_kcontrol_widget(kc
);
2539 struct wcd934x_codec
*wcd
= dev_get_drvdata(dapm
->dev
);
2541 ucontrol
->value
.enumerated
.item
[0] = wcd
->rx_port_value
[w
->shift
];
2546 static int slim_rx_mux_put(struct snd_kcontrol
*kc
,
2547 struct snd_ctl_elem_value
*ucontrol
)
2549 struct snd_soc_dapm_widget
*w
= snd_soc_dapm_kcontrol_widget(kc
);
2550 struct wcd934x_codec
*wcd
= dev_get_drvdata(w
->dapm
->dev
);
2551 struct soc_enum
*e
= (struct soc_enum
*)kc
->private_value
;
2552 struct snd_soc_dapm_update
*update
= NULL
;
2553 u32 port_id
= w
->shift
;
2555 if (wcd
->rx_port_value
[port_id
] == ucontrol
->value
.enumerated
.item
[0])
2558 wcd
->rx_port_value
[port_id
] = ucontrol
->value
.enumerated
.item
[0];
2560 switch (wcd
->rx_port_value
[port_id
]) {
2562 list_del_init(&wcd
->rx_chs
[port_id
].list
);
2565 list_add_tail(&wcd
->rx_chs
[port_id
].list
,
2566 &wcd
->dai
[AIF1_PB
].slim_ch_list
);
2569 list_add_tail(&wcd
->rx_chs
[port_id
].list
,
2570 &wcd
->dai
[AIF2_PB
].slim_ch_list
);
2573 list_add_tail(&wcd
->rx_chs
[port_id
].list
,
2574 &wcd
->dai
[AIF3_PB
].slim_ch_list
);
2577 list_add_tail(&wcd
->rx_chs
[port_id
].list
,
2578 &wcd
->dai
[AIF4_PB
].slim_ch_list
);
2581 dev_err(wcd
->dev
, "Unknown AIF %d\n",
2582 wcd
->rx_port_value
[port_id
]);
2586 snd_soc_dapm_mux_update_power(w
->dapm
, kc
, wcd
->rx_port_value
[port_id
],
2594 static int wcd934x_int_dem_inp_mux_put(struct snd_kcontrol
*kc
,
2595 struct snd_ctl_elem_value
*ucontrol
)
2597 struct soc_enum
*e
= (struct soc_enum
*)kc
->private_value
;
2598 struct snd_soc_component
*component
;
2601 component
= snd_soc_dapm_kcontrol_component(kc
);
2602 val
= ucontrol
->value
.enumerated
.item
[0];
2603 if (e
->reg
== WCD934X_CDC_RX0_RX_PATH_SEC0
)
2604 reg
= WCD934X_CDC_RX0_RX_PATH_CFG0
;
2605 else if (e
->reg
== WCD934X_CDC_RX1_RX_PATH_SEC0
)
2606 reg
= WCD934X_CDC_RX1_RX_PATH_CFG0
;
2607 else if (e
->reg
== WCD934X_CDC_RX2_RX_PATH_SEC0
)
2608 reg
= WCD934X_CDC_RX2_RX_PATH_CFG0
;
2612 /* Set Look Ahead Delay */
2614 snd_soc_component_update_bits(component
, reg
,
2615 WCD934X_RX_DLY_ZN_EN_MASK
,
2616 WCD934X_RX_DLY_ZN_ENABLE
);
2618 snd_soc_component_update_bits(component
, reg
,
2619 WCD934X_RX_DLY_ZN_EN_MASK
,
2620 WCD934X_RX_DLY_ZN_DISABLE
);
2622 ret
= snd_soc_dapm_put_enum_double(kc
, ucontrol
);
2627 static int wcd934x_dec_enum_put(struct snd_kcontrol
*kcontrol
,
2628 struct snd_ctl_elem_value
*ucontrol
)
2630 struct snd_soc_component
*comp
;
2631 struct soc_enum
*e
= (struct soc_enum
*)kcontrol
->private_value
;
2633 u16 mic_sel_reg
= 0;
2636 comp
= snd_soc_dapm_kcontrol_component(kcontrol
);
2638 val
= ucontrol
->value
.enumerated
.item
[0];
2639 if (val
> e
->items
- 1)
2643 case WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1
:
2644 if (e
->shift_l
== 0)
2645 mic_sel_reg
= WCD934X_CDC_TX0_TX_PATH_CFG0
;
2646 else if (e
->shift_l
== 2)
2647 mic_sel_reg
= WCD934X_CDC_TX4_TX_PATH_CFG0
;
2648 else if (e
->shift_l
== 4)
2649 mic_sel_reg
= WCD934X_CDC_TX8_TX_PATH_CFG0
;
2651 case WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1
:
2652 if (e
->shift_l
== 0)
2653 mic_sel_reg
= WCD934X_CDC_TX1_TX_PATH_CFG0
;
2654 else if (e
->shift_l
== 2)
2655 mic_sel_reg
= WCD934X_CDC_TX5_TX_PATH_CFG0
;
2657 case WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1
:
2658 if (e
->shift_l
== 0)
2659 mic_sel_reg
= WCD934X_CDC_TX2_TX_PATH_CFG0
;
2660 else if (e
->shift_l
== 2)
2661 mic_sel_reg
= WCD934X_CDC_TX6_TX_PATH_CFG0
;
2663 case WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1
:
2664 if (e
->shift_l
== 0)
2665 mic_sel_reg
= WCD934X_CDC_TX3_TX_PATH_CFG0
;
2666 else if (e
->shift_l
== 2)
2667 mic_sel_reg
= WCD934X_CDC_TX7_TX_PATH_CFG0
;
2670 dev_err(comp
->dev
, "%s: e->reg: 0x%x not expected\n",
2675 /* ADC: 0, DMIC: 1 */
2676 mic_sel
= val
? 0x0 : 0x1;
2678 snd_soc_component_update_bits(comp
, mic_sel_reg
, BIT(7),
2681 return snd_soc_dapm_put_enum_double(kcontrol
, ucontrol
);
2684 static const struct snd_kcontrol_new rx_int0_2_mux
=
2685 SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum
);
2687 static const struct snd_kcontrol_new rx_int1_2_mux
=
2688 SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum
);
2690 static const struct snd_kcontrol_new rx_int2_2_mux
=
2691 SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum
);
2693 static const struct snd_kcontrol_new rx_int3_2_mux
=
2694 SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum
);
2696 static const struct snd_kcontrol_new rx_int4_2_mux
=
2697 SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum
);
2699 static const struct snd_kcontrol_new rx_int7_2_mux
=
2700 SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum
);
2702 static const struct snd_kcontrol_new rx_int8_2_mux
=
2703 SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum
);
2705 static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux
=
2706 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum
);
2708 static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux
=
2709 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum
);
2711 static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux
=
2712 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum
);
2714 static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux
=
2715 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum
);
2717 static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux
=
2718 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum
);
2720 static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux
=
2721 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum
);
2723 static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux
=
2724 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum
);
2726 static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux
=
2727 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum
);
2729 static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux
=
2730 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum
);
2732 static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux
=
2733 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum
);
2735 static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux
=
2736 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum
);
2738 static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux
=
2739 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum
);
2741 static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux
=
2742 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum
);
2744 static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux
=
2745 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum
);
2747 static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux
=
2748 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum
);
2750 static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux
=
2751 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum
);
2753 static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux
=
2754 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum
);
2756 static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux
=
2757 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum
);
2759 static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux
=
2760 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum
);
2762 static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux
=
2763 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum
);
2765 static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux
=
2766 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum
);
2768 static const struct snd_kcontrol_new rx_int0_mix2_inp_mux
=
2769 SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_mix2_inp_mux_enum
);
2771 static const struct snd_kcontrol_new rx_int1_mix2_inp_mux
=
2772 SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_mix2_inp_mux_enum
);
2774 static const struct snd_kcontrol_new rx_int2_mix2_inp_mux
=
2775 SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_mix2_inp_mux_enum
);
2777 static const struct snd_kcontrol_new rx_int3_mix2_inp_mux
=
2778 SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_mix2_inp_mux_enum
);
2780 static const struct snd_kcontrol_new rx_int4_mix2_inp_mux
=
2781 SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_mix2_inp_mux_enum
);
2783 static const struct snd_kcontrol_new rx_int7_mix2_inp_mux
=
2784 SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_mix2_inp_mux_enum
);
2786 static const struct snd_kcontrol_new iir0_inp0_mux
=
2787 SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum
);
2788 static const struct snd_kcontrol_new iir0_inp1_mux
=
2789 SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum
);
2790 static const struct snd_kcontrol_new iir0_inp2_mux
=
2791 SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum
);
2792 static const struct snd_kcontrol_new iir0_inp3_mux
=
2793 SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum
);
2795 static const struct snd_kcontrol_new iir1_inp0_mux
=
2796 SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum
);
2797 static const struct snd_kcontrol_new iir1_inp1_mux
=
2798 SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum
);
2799 static const struct snd_kcontrol_new iir1_inp2_mux
=
2800 SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum
);
2801 static const struct snd_kcontrol_new iir1_inp3_mux
=
2802 SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum
);
2804 static const struct snd_kcontrol_new slim_rx_mux
[WCD934X_RX_MAX
] = {
2805 SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum
,
2806 slim_rx_mux_get
, slim_rx_mux_put
),
2807 SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum
,
2808 slim_rx_mux_get
, slim_rx_mux_put
),
2809 SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum
,
2810 slim_rx_mux_get
, slim_rx_mux_put
),
2811 SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum
,
2812 slim_rx_mux_get
, slim_rx_mux_put
),
2813 SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum
,
2814 slim_rx_mux_get
, slim_rx_mux_put
),
2815 SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum
,
2816 slim_rx_mux_get
, slim_rx_mux_put
),
2817 SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum
,
2818 slim_rx_mux_get
, slim_rx_mux_put
),
2819 SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum
,
2820 slim_rx_mux_get
, slim_rx_mux_put
),
2823 static const struct snd_kcontrol_new rx_int1_asrc_switch
[] = {
2824 SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM
, 0, 1, 0),
2827 static const struct snd_kcontrol_new rx_int2_asrc_switch
[] = {
2828 SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM
, 0, 1, 0),
2831 static const struct snd_kcontrol_new rx_int3_asrc_switch
[] = {
2832 SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM
, 0, 1, 0),
2835 static const struct snd_kcontrol_new rx_int4_asrc_switch
[] = {
2836 SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM
, 0, 1, 0),
2839 static const struct snd_kcontrol_new rx_int0_dem_inp_mux
=
2840 SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum
,
2841 snd_soc_dapm_get_enum_double
,
2842 wcd934x_int_dem_inp_mux_put
);
2844 static const struct snd_kcontrol_new rx_int1_dem_inp_mux
=
2845 SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum
,
2846 snd_soc_dapm_get_enum_double
,
2847 wcd934x_int_dem_inp_mux_put
);
2849 static const struct snd_kcontrol_new rx_int2_dem_inp_mux
=
2850 SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum
,
2851 snd_soc_dapm_get_enum_double
,
2852 wcd934x_int_dem_inp_mux_put
);
2854 static const struct snd_kcontrol_new rx_int0_1_interp_mux
=
2855 SOC_DAPM_ENUM("RX INT0_1 INTERP Mux", rx_int0_1_interp_mux_enum
);
2857 static const struct snd_kcontrol_new rx_int1_1_interp_mux
=
2858 SOC_DAPM_ENUM("RX INT1_1 INTERP Mux", rx_int1_1_interp_mux_enum
);
2860 static const struct snd_kcontrol_new rx_int2_1_interp_mux
=
2861 SOC_DAPM_ENUM("RX INT2_1 INTERP Mux", rx_int2_1_interp_mux_enum
);
2863 static const struct snd_kcontrol_new rx_int3_1_interp_mux
=
2864 SOC_DAPM_ENUM("RX INT3_1 INTERP Mux", rx_int3_1_interp_mux_enum
);
2866 static const struct snd_kcontrol_new rx_int4_1_interp_mux
=
2867 SOC_DAPM_ENUM("RX INT4_1 INTERP Mux", rx_int4_1_interp_mux_enum
);
2869 static const struct snd_kcontrol_new rx_int7_1_interp_mux
=
2870 SOC_DAPM_ENUM("RX INT7_1 INTERP Mux", rx_int7_1_interp_mux_enum
);
2872 static const struct snd_kcontrol_new rx_int8_1_interp_mux
=
2873 SOC_DAPM_ENUM("RX INT8_1 INTERP Mux", rx_int8_1_interp_mux_enum
);
2875 static const struct snd_kcontrol_new rx_int0_2_interp_mux
=
2876 SOC_DAPM_ENUM("RX INT0_2 INTERP Mux", rx_int0_2_interp_mux_enum
);
2878 static const struct snd_kcontrol_new rx_int1_2_interp_mux
=
2879 SOC_DAPM_ENUM("RX INT1_2 INTERP Mux", rx_int1_2_interp_mux_enum
);
2881 static const struct snd_kcontrol_new rx_int2_2_interp_mux
=
2882 SOC_DAPM_ENUM("RX INT2_2 INTERP Mux", rx_int2_2_interp_mux_enum
);
2884 static const struct snd_kcontrol_new rx_int3_2_interp_mux
=
2885 SOC_DAPM_ENUM("RX INT3_2 INTERP Mux", rx_int3_2_interp_mux_enum
);
2887 static const struct snd_kcontrol_new rx_int4_2_interp_mux
=
2888 SOC_DAPM_ENUM("RX INT4_2 INTERP Mux", rx_int4_2_interp_mux_enum
);
2890 static const struct snd_kcontrol_new rx_int7_2_interp_mux
=
2891 SOC_DAPM_ENUM("RX INT7_2 INTERP Mux", rx_int7_2_interp_mux_enum
);
2893 static const struct snd_kcontrol_new rx_int8_2_interp_mux
=
2894 SOC_DAPM_ENUM("RX INT8_2 INTERP Mux", rx_int8_2_interp_mux_enum
);
2896 static const struct snd_kcontrol_new tx_dmic_mux0
=
2897 SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum
);
2899 static const struct snd_kcontrol_new tx_dmic_mux1
=
2900 SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum
);
2902 static const struct snd_kcontrol_new tx_dmic_mux2
=
2903 SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum
);
2905 static const struct snd_kcontrol_new tx_dmic_mux3
=
2906 SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum
);
2908 static const struct snd_kcontrol_new tx_dmic_mux4
=
2909 SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum
);
2911 static const struct snd_kcontrol_new tx_dmic_mux5
=
2912 SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum
);
2914 static const struct snd_kcontrol_new tx_dmic_mux6
=
2915 SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum
);
2917 static const struct snd_kcontrol_new tx_dmic_mux7
=
2918 SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum
);
2920 static const struct snd_kcontrol_new tx_dmic_mux8
=
2921 SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum
);
2923 static const struct snd_kcontrol_new tx_amic_mux0
=
2924 SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum
);
2926 static const struct snd_kcontrol_new tx_amic_mux1
=
2927 SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum
);
2929 static const struct snd_kcontrol_new tx_amic_mux2
=
2930 SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum
);
2932 static const struct snd_kcontrol_new tx_amic_mux3
=
2933 SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum
);
2935 static const struct snd_kcontrol_new tx_amic_mux4
=
2936 SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum
);
2938 static const struct snd_kcontrol_new tx_amic_mux5
=
2939 SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum
);
2941 static const struct snd_kcontrol_new tx_amic_mux6
=
2942 SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum
);
2944 static const struct snd_kcontrol_new tx_amic_mux7
=
2945 SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum
);
2947 static const struct snd_kcontrol_new tx_amic_mux8
=
2948 SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum
);
2950 static const struct snd_kcontrol_new tx_amic4_5
=
2951 SOC_DAPM_ENUM("AMIC4_5 SEL Mux", tx_amic4_5_enum
);
2953 static const struct snd_kcontrol_new tx_adc_mux0_mux
=
2954 SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_enum
,
2955 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2956 static const struct snd_kcontrol_new tx_adc_mux1_mux
=
2957 SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_enum
,
2958 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2959 static const struct snd_kcontrol_new tx_adc_mux2_mux
=
2960 SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_enum
,
2961 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2962 static const struct snd_kcontrol_new tx_adc_mux3_mux
=
2963 SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_enum
,
2964 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2965 static const struct snd_kcontrol_new tx_adc_mux4_mux
=
2966 SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_enum
,
2967 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2968 static const struct snd_kcontrol_new tx_adc_mux5_mux
=
2969 SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_enum
,
2970 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2971 static const struct snd_kcontrol_new tx_adc_mux6_mux
=
2972 SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_enum
,
2973 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2974 static const struct snd_kcontrol_new tx_adc_mux7_mux
=
2975 SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_enum
,
2976 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2977 static const struct snd_kcontrol_new tx_adc_mux8_mux
=
2978 SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_enum
,
2979 snd_soc_dapm_get_enum_double
, wcd934x_dec_enum_put
);
2981 static const struct snd_kcontrol_new cdc_if_tx0_mux
=
2982 SOC_DAPM_ENUM("CDC_IF TX0 MUX Mux", cdc_if_tx0_mux_enum
);
2983 static const struct snd_kcontrol_new cdc_if_tx1_mux
=
2984 SOC_DAPM_ENUM("CDC_IF TX1 MUX Mux", cdc_if_tx1_mux_enum
);
2985 static const struct snd_kcontrol_new cdc_if_tx2_mux
=
2986 SOC_DAPM_ENUM("CDC_IF TX2 MUX Mux", cdc_if_tx2_mux_enum
);
2987 static const struct snd_kcontrol_new cdc_if_tx3_mux
=
2988 SOC_DAPM_ENUM("CDC_IF TX3 MUX Mux", cdc_if_tx3_mux_enum
);
2989 static const struct snd_kcontrol_new cdc_if_tx4_mux
=
2990 SOC_DAPM_ENUM("CDC_IF TX4 MUX Mux", cdc_if_tx4_mux_enum
);
2991 static const struct snd_kcontrol_new cdc_if_tx5_mux
=
2992 SOC_DAPM_ENUM("CDC_IF TX5 MUX Mux", cdc_if_tx5_mux_enum
);
2993 static const struct snd_kcontrol_new cdc_if_tx6_mux
=
2994 SOC_DAPM_ENUM("CDC_IF TX6 MUX Mux", cdc_if_tx6_mux_enum
);
2995 static const struct snd_kcontrol_new cdc_if_tx7_mux
=
2996 SOC_DAPM_ENUM("CDC_IF TX7 MUX Mux", cdc_if_tx7_mux_enum
);
2997 static const struct snd_kcontrol_new cdc_if_tx8_mux
=
2998 SOC_DAPM_ENUM("CDC_IF TX8 MUX Mux", cdc_if_tx8_mux_enum
);
2999 static const struct snd_kcontrol_new cdc_if_tx9_mux
=
3000 SOC_DAPM_ENUM("CDC_IF TX9 MUX Mux", cdc_if_tx9_mux_enum
);
3001 static const struct snd_kcontrol_new cdc_if_tx10_mux
=
3002 SOC_DAPM_ENUM("CDC_IF TX10 MUX Mux", cdc_if_tx10_mux_enum
);
3003 static const struct snd_kcontrol_new cdc_if_tx11_mux
=
3004 SOC_DAPM_ENUM("CDC_IF TX11 MUX Mux", cdc_if_tx11_mux_enum
);
3005 static const struct snd_kcontrol_new cdc_if_tx11_inp1_mux
=
3006 SOC_DAPM_ENUM("CDC_IF TX11 INP1 MUX Mux", cdc_if_tx11_inp1_mux_enum
);
3007 static const struct snd_kcontrol_new cdc_if_tx13_mux
=
3008 SOC_DAPM_ENUM("CDC_IF TX13 MUX Mux", cdc_if_tx13_mux_enum
);
3009 static const struct snd_kcontrol_new cdc_if_tx13_inp1_mux
=
3010 SOC_DAPM_ENUM("CDC_IF TX13 INP1 MUX Mux", cdc_if_tx13_inp1_mux_enum
);
3012 static int slim_tx_mixer_get(struct snd_kcontrol
*kc
,
3013 struct snd_ctl_elem_value
*ucontrol
)
3015 struct snd_soc_dapm_context
*dapm
= snd_soc_dapm_kcontrol_dapm(kc
);
3016 struct wcd934x_codec
*wcd
= dev_get_drvdata(dapm
->dev
);
3017 struct soc_mixer_control
*mixer
=
3018 (struct soc_mixer_control
*)kc
->private_value
;
3019 int port_id
= mixer
->shift
;
3021 ucontrol
->value
.integer
.value
[0] = wcd
->tx_port_value
[port_id
];
3026 static int slim_tx_mixer_put(struct snd_kcontrol
*kc
,
3027 struct snd_ctl_elem_value
*ucontrol
)
3029 struct snd_soc_dapm_widget
*widget
= snd_soc_dapm_kcontrol_widget(kc
);
3030 struct wcd934x_codec
*wcd
= dev_get_drvdata(widget
->dapm
->dev
);
3031 struct snd_soc_dapm_update
*update
= NULL
;
3032 struct soc_mixer_control
*mixer
=
3033 (struct soc_mixer_control
*)kc
->private_value
;
3034 int enable
= ucontrol
->value
.integer
.value
[0];
3035 int dai_id
= widget
->shift
;
3036 int port_id
= mixer
->shift
;
3038 /* only add to the list if value not set */
3039 if (enable
== wcd
->tx_port_value
[port_id
])
3042 wcd
->tx_port_value
[port_id
] = enable
;
3045 list_add_tail(&wcd
->tx_chs
[port_id
].list
,
3046 &wcd
->dai
[dai_id
].slim_ch_list
);
3048 list_del_init(&wcd
->tx_chs
[port_id
].list
);
3050 snd_soc_dapm_mixer_update_power(widget
->dapm
, kc
, enable
, update
);
3055 static const struct snd_kcontrol_new aif1_slim_cap_mixer
[] = {
3056 SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM
, WCD934X_TX0
, 1, 0,
3057 slim_tx_mixer_get
, slim_tx_mixer_put
),
3058 SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM
, WCD934X_TX1
, 1, 0,
3059 slim_tx_mixer_get
, slim_tx_mixer_put
),
3060 SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM
, WCD934X_TX2
, 1, 0,
3061 slim_tx_mixer_get
, slim_tx_mixer_put
),
3062 SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM
, WCD934X_TX3
, 1, 0,
3063 slim_tx_mixer_get
, slim_tx_mixer_put
),
3064 SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM
, WCD934X_TX4
, 1, 0,
3065 slim_tx_mixer_get
, slim_tx_mixer_put
),
3066 SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM
, WCD934X_TX5
, 1, 0,
3067 slim_tx_mixer_get
, slim_tx_mixer_put
),
3068 SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM
, WCD934X_TX6
, 1, 0,
3069 slim_tx_mixer_get
, slim_tx_mixer_put
),
3070 SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM
, WCD934X_TX7
, 1, 0,
3071 slim_tx_mixer_get
, slim_tx_mixer_put
),
3072 SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM
, WCD934X_TX8
, 1, 0,
3073 slim_tx_mixer_get
, slim_tx_mixer_put
),
3074 SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM
, WCD934X_TX9
, 1, 0,
3075 slim_tx_mixer_get
, slim_tx_mixer_put
),
3076 SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM
, WCD934X_TX10
, 1, 0,
3077 slim_tx_mixer_get
, slim_tx_mixer_put
),
3078 SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM
, WCD934X_TX11
, 1, 0,
3079 slim_tx_mixer_get
, slim_tx_mixer_put
),
3080 SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM
, WCD934X_TX13
, 1, 0,
3081 slim_tx_mixer_get
, slim_tx_mixer_put
),
3084 static const struct snd_kcontrol_new aif2_slim_cap_mixer
[] = {
3085 SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM
, WCD934X_TX0
, 1, 0,
3086 slim_tx_mixer_get
, slim_tx_mixer_put
),
3087 SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM
, WCD934X_TX1
, 1, 0,
3088 slim_tx_mixer_get
, slim_tx_mixer_put
),
3089 SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM
, WCD934X_TX2
, 1, 0,
3090 slim_tx_mixer_get
, slim_tx_mixer_put
),
3091 SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM
, WCD934X_TX3
, 1, 0,
3092 slim_tx_mixer_get
, slim_tx_mixer_put
),
3093 SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM
, WCD934X_TX4
, 1, 0,
3094 slim_tx_mixer_get
, slim_tx_mixer_put
),
3095 SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM
, WCD934X_TX5
, 1, 0,
3096 slim_tx_mixer_get
, slim_tx_mixer_put
),
3097 SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM
, WCD934X_TX6
, 1, 0,
3098 slim_tx_mixer_get
, slim_tx_mixer_put
),
3099 SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM
, WCD934X_TX7
, 1, 0,
3100 slim_tx_mixer_get
, slim_tx_mixer_put
),
3101 SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM
, WCD934X_TX8
, 1, 0,
3102 slim_tx_mixer_get
, slim_tx_mixer_put
),
3103 SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM
, WCD934X_TX9
, 1, 0,
3104 slim_tx_mixer_get
, slim_tx_mixer_put
),
3105 SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM
, WCD934X_TX10
, 1, 0,
3106 slim_tx_mixer_get
, slim_tx_mixer_put
),
3107 SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM
, WCD934X_TX11
, 1, 0,
3108 slim_tx_mixer_get
, slim_tx_mixer_put
),
3109 SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM
, WCD934X_TX13
, 1, 0,
3110 slim_tx_mixer_get
, slim_tx_mixer_put
),
3113 static const struct snd_kcontrol_new aif3_slim_cap_mixer
[] = {
3114 SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM
, WCD934X_TX0
, 1, 0,
3115 slim_tx_mixer_get
, slim_tx_mixer_put
),
3116 SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM
, WCD934X_TX1
, 1, 0,
3117 slim_tx_mixer_get
, slim_tx_mixer_put
),
3118 SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM
, WCD934X_TX2
, 1, 0,
3119 slim_tx_mixer_get
, slim_tx_mixer_put
),
3120 SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM
, WCD934X_TX3
, 1, 0,
3121 slim_tx_mixer_get
, slim_tx_mixer_put
),
3122 SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM
, WCD934X_TX4
, 1, 0,
3123 slim_tx_mixer_get
, slim_tx_mixer_put
),
3124 SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM
, WCD934X_TX5
, 1, 0,
3125 slim_tx_mixer_get
, slim_tx_mixer_put
),
3126 SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM
, WCD934X_TX6
, 1, 0,
3127 slim_tx_mixer_get
, slim_tx_mixer_put
),
3128 SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM
, WCD934X_TX7
, 1, 0,
3129 slim_tx_mixer_get
, slim_tx_mixer_put
),
3130 SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM
, WCD934X_TX8
, 1, 0,
3131 slim_tx_mixer_get
, slim_tx_mixer_put
),
3132 SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM
, WCD934X_TX9
, 1, 0,
3133 slim_tx_mixer_get
, slim_tx_mixer_put
),
3134 SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM
, WCD934X_TX10
, 1, 0,
3135 slim_tx_mixer_get
, slim_tx_mixer_put
),
3136 SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM
, WCD934X_TX11
, 1, 0,
3137 slim_tx_mixer_get
, slim_tx_mixer_put
),
3138 SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM
, WCD934X_TX13
, 1, 0,
3139 slim_tx_mixer_get
, slim_tx_mixer_put
),
3142 static const struct snd_kcontrol_new wcd934x_snd_controls
[] = {
3144 SOC_SINGLE_TLV("EAR PA Volume", WCD934X_ANA_EAR
, 4, 4, 1, ear_pa_gain
),
3145 SOC_SINGLE_TLV("HPHL Volume", WCD934X_HPH_L_EN
, 0, 24, 1, line_gain
),
3146 SOC_SINGLE_TLV("HPHR Volume", WCD934X_HPH_R_EN
, 0, 24, 1, line_gain
),
3147 SOC_SINGLE_TLV("LINEOUT1 Volume", WCD934X_DIFF_LO_LO1_COMPANDER
,
3148 3, 16, 1, line_gain
),
3149 SOC_SINGLE_TLV("LINEOUT2 Volume", WCD934X_DIFF_LO_LO2_COMPANDER
,
3150 3, 16, 1, line_gain
),
3152 SOC_SINGLE_TLV("ADC1 Volume", WCD934X_ANA_AMIC1
, 0, 20, 0, analog_gain
),
3153 SOC_SINGLE_TLV("ADC2 Volume", WCD934X_ANA_AMIC2
, 0, 20, 0, analog_gain
),
3154 SOC_SINGLE_TLV("ADC3 Volume", WCD934X_ANA_AMIC3
, 0, 20, 0, analog_gain
),
3155 SOC_SINGLE_TLV("ADC4 Volume", WCD934X_ANA_AMIC4
, 0, 20, 0, analog_gain
),
3157 SOC_SINGLE_S8_TLV("RX0 Digital Volume", WCD934X_CDC_RX0_RX_VOL_CTL
,
3158 -84, 40, digital_gain
), /* -84dB min - 40dB max */
3159 SOC_SINGLE_S8_TLV("RX1 Digital Volume", WCD934X_CDC_RX1_RX_VOL_CTL
,
3160 -84, 40, digital_gain
),
3161 SOC_SINGLE_S8_TLV("RX2 Digital Volume", WCD934X_CDC_RX2_RX_VOL_CTL
,
3162 -84, 40, digital_gain
),
3163 SOC_SINGLE_S8_TLV("RX3 Digital Volume", WCD934X_CDC_RX3_RX_VOL_CTL
,
3164 -84, 40, digital_gain
),
3165 SOC_SINGLE_S8_TLV("RX4 Digital Volume", WCD934X_CDC_RX4_RX_VOL_CTL
,
3166 -84, 40, digital_gain
),
3167 SOC_SINGLE_S8_TLV("RX7 Digital Volume", WCD934X_CDC_RX7_RX_VOL_CTL
,
3168 -84, 40, digital_gain
),
3169 SOC_SINGLE_S8_TLV("RX8 Digital Volume", WCD934X_CDC_RX8_RX_VOL_CTL
,
3170 -84, 40, digital_gain
),
3171 SOC_SINGLE_S8_TLV("RX0 Mix Digital Volume",
3172 WCD934X_CDC_RX0_RX_VOL_MIX_CTL
,
3173 -84, 40, digital_gain
),
3174 SOC_SINGLE_S8_TLV("RX1 Mix Digital Volume",
3175 WCD934X_CDC_RX1_RX_VOL_MIX_CTL
,
3176 -84, 40, digital_gain
),
3177 SOC_SINGLE_S8_TLV("RX2 Mix Digital Volume",
3178 WCD934X_CDC_RX2_RX_VOL_MIX_CTL
,
3179 -84, 40, digital_gain
),
3180 SOC_SINGLE_S8_TLV("RX3 Mix Digital Volume",
3181 WCD934X_CDC_RX3_RX_VOL_MIX_CTL
,
3182 -84, 40, digital_gain
),
3183 SOC_SINGLE_S8_TLV("RX4 Mix Digital Volume",
3184 WCD934X_CDC_RX4_RX_VOL_MIX_CTL
,
3185 -84, 40, digital_gain
),
3186 SOC_SINGLE_S8_TLV("RX7 Mix Digital Volume",
3187 WCD934X_CDC_RX7_RX_VOL_MIX_CTL
,
3188 -84, 40, digital_gain
),
3189 SOC_SINGLE_S8_TLV("RX8 Mix Digital Volume",
3190 WCD934X_CDC_RX8_RX_VOL_MIX_CTL
,
3191 -84, 40, digital_gain
),
3193 SOC_SINGLE_S8_TLV("DEC0 Volume", WCD934X_CDC_TX0_TX_VOL_CTL
,
3194 -84, 40, digital_gain
),
3195 SOC_SINGLE_S8_TLV("DEC1 Volume", WCD934X_CDC_TX1_TX_VOL_CTL
,
3196 -84, 40, digital_gain
),
3197 SOC_SINGLE_S8_TLV("DEC2 Volume", WCD934X_CDC_TX2_TX_VOL_CTL
,
3198 -84, 40, digital_gain
),
3199 SOC_SINGLE_S8_TLV("DEC3 Volume", WCD934X_CDC_TX3_TX_VOL_CTL
,
3200 -84, 40, digital_gain
),
3201 SOC_SINGLE_S8_TLV("DEC4 Volume", WCD934X_CDC_TX4_TX_VOL_CTL
,
3202 -84, 40, digital_gain
),
3203 SOC_SINGLE_S8_TLV("DEC5 Volume", WCD934X_CDC_TX5_TX_VOL_CTL
,
3204 -84, 40, digital_gain
),
3205 SOC_SINGLE_S8_TLV("DEC6 Volume", WCD934X_CDC_TX6_TX_VOL_CTL
,
3206 -84, 40, digital_gain
),
3207 SOC_SINGLE_S8_TLV("DEC7 Volume", WCD934X_CDC_TX7_TX_VOL_CTL
,
3208 -84, 40, digital_gain
),
3209 SOC_SINGLE_S8_TLV("DEC8 Volume", WCD934X_CDC_TX8_TX_VOL_CTL
,
3210 -84, 40, digital_gain
),
3212 SOC_SINGLE_S8_TLV("IIR0 INP0 Volume",
3213 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL
, -84, 40,
3215 SOC_SINGLE_S8_TLV("IIR0 INP1 Volume",
3216 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL
, -84, 40,
3218 SOC_SINGLE_S8_TLV("IIR0 INP2 Volume",
3219 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL
, -84, 40,
3221 SOC_SINGLE_S8_TLV("IIR0 INP3 Volume",
3222 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL
, -84, 40,
3224 SOC_SINGLE_S8_TLV("IIR1 INP0 Volume",
3225 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL
, -84, 40,
3227 SOC_SINGLE_S8_TLV("IIR1 INP1 Volume",
3228 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL
, -84, 40,
3230 SOC_SINGLE_S8_TLV("IIR1 INP2 Volume",
3231 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL
, -84, 40,
3233 SOC_SINGLE_S8_TLV("IIR1 INP3 Volume",
3234 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL
, -84, 40,
3237 SOC_ENUM("TX0 HPF cut off", cf_dec0_enum
),
3238 SOC_ENUM("TX1 HPF cut off", cf_dec1_enum
),
3239 SOC_ENUM("TX2 HPF cut off", cf_dec2_enum
),
3240 SOC_ENUM("TX3 HPF cut off", cf_dec3_enum
),
3241 SOC_ENUM("TX4 HPF cut off", cf_dec4_enum
),
3242 SOC_ENUM("TX5 HPF cut off", cf_dec5_enum
),
3243 SOC_ENUM("TX6 HPF cut off", cf_dec6_enum
),
3244 SOC_ENUM("TX7 HPF cut off", cf_dec7_enum
),
3245 SOC_ENUM("TX8 HPF cut off", cf_dec8_enum
),
3247 SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum
),
3248 SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum
),
3249 SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum
),
3250 SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum
),
3251 SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum
),
3252 SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum
),
3253 SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum
),
3254 SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum
),
3255 SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum
),
3256 SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum
),
3257 SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum
),
3258 SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum
),
3259 SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum
),
3260 SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum
),
3262 SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum
,
3263 wcd934x_rx_hph_mode_get
, wcd934x_rx_hph_mode_put
),
3265 SOC_SINGLE("IIR1 Band1 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL
,
3267 SOC_SINGLE("IIR1 Band2 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL
,
3269 SOC_SINGLE("IIR1 Band3 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL
,
3271 SOC_SINGLE("IIR1 Band4 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL
,
3273 SOC_SINGLE("IIR1 Band5 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL
,
3275 SOC_SINGLE("IIR2 Band1 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL
,
3277 SOC_SINGLE("IIR2 Band2 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL
,
3279 SOC_SINGLE("IIR2 Band3 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL
,
3281 SOC_SINGLE("IIR2 Band4 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL
,
3283 SOC_SINGLE("IIR2 Band5 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL
,
3285 WCD_IIR_FILTER_CTL("IIR0 Band1", IIR0
, BAND1
),
3286 WCD_IIR_FILTER_CTL("IIR0 Band2", IIR0
, BAND2
),
3287 WCD_IIR_FILTER_CTL("IIR0 Band3", IIR0
, BAND3
),
3288 WCD_IIR_FILTER_CTL("IIR0 Band4", IIR0
, BAND4
),
3289 WCD_IIR_FILTER_CTL("IIR0 Band5", IIR0
, BAND5
),
3291 WCD_IIR_FILTER_CTL("IIR1 Band1", IIR1
, BAND1
),
3292 WCD_IIR_FILTER_CTL("IIR1 Band2", IIR1
, BAND2
),
3293 WCD_IIR_FILTER_CTL("IIR1 Band3", IIR1
, BAND3
),
3294 WCD_IIR_FILTER_CTL("IIR1 Band4", IIR1
, BAND4
),
3295 WCD_IIR_FILTER_CTL("IIR1 Band5", IIR1
, BAND5
),
3297 SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM
, COMPANDER_1
, 1, 0,
3298 wcd934x_compander_get
, wcd934x_compander_set
),
3299 SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM
, COMPANDER_2
, 1, 0,
3300 wcd934x_compander_get
, wcd934x_compander_set
),
3301 SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM
, COMPANDER_3
, 1, 0,
3302 wcd934x_compander_get
, wcd934x_compander_set
),
3303 SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM
, COMPANDER_4
, 1, 0,
3304 wcd934x_compander_get
, wcd934x_compander_set
),
3305 SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM
, COMPANDER_7
, 1, 0,
3306 wcd934x_compander_get
, wcd934x_compander_set
),
3307 SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM
, COMPANDER_8
, 1, 0,
3308 wcd934x_compander_get
, wcd934x_compander_set
),
3311 static void wcd934x_codec_enable_int_port(struct wcd_slim_codec_dai_data
*dai
,
3312 struct snd_soc_component
*component
)
3315 unsigned short reg
= 0;
3316 unsigned int val
= 0;
3317 struct wcd934x_codec
*wcd
= dev_get_drvdata(component
->dev
);
3318 struct wcd934x_slim_ch
*ch
;
3320 list_for_each_entry(ch
, &dai
->slim_ch_list
, list
) {
3321 if (ch
->port
>= WCD934X_RX_START
) {
3322 port_num
= ch
->port
- WCD934X_RX_START
;
3323 reg
= WCD934X_SLIM_PGD_PORT_INT_EN0
+ (port_num
/ 8);
3325 port_num
= ch
->port
;
3326 reg
= WCD934X_SLIM_PGD_PORT_INT_TX_EN0
+ (port_num
/ 8);
3329 regmap_read(wcd
->if_regmap
, reg
, &val
);
3330 if (!(val
& BIT(port_num
% 8)))
3331 regmap_write(wcd
->if_regmap
, reg
,
3332 val
| BIT(port_num
% 8));
3336 static int wcd934x_codec_enable_slim(struct snd_soc_dapm_widget
*w
,
3337 struct snd_kcontrol
*kc
, int event
)
3339 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3340 struct wcd934x_codec
*wcd
= snd_soc_component_get_drvdata(comp
);
3341 struct wcd_slim_codec_dai_data
*dai
= &wcd
->dai
[w
->shift
];
3344 case SND_SOC_DAPM_POST_PMU
:
3345 wcd934x_codec_enable_int_port(dai
, comp
);
3352 static void wcd934x_codec_hd2_control(struct snd_soc_component
*component
,
3353 u16 interp_idx
, int event
)
3356 u16 hd2_enable_reg
= 0;
3358 switch (interp_idx
) {
3360 hd2_scale_reg
= WCD934X_CDC_RX1_RX_PATH_SEC3
;
3361 hd2_enable_reg
= WCD934X_CDC_RX1_RX_PATH_CFG0
;
3364 hd2_scale_reg
= WCD934X_CDC_RX2_RX_PATH_SEC3
;
3365 hd2_enable_reg
= WCD934X_CDC_RX2_RX_PATH_CFG0
;
3371 if (SND_SOC_DAPM_EVENT_ON(event
)) {
3372 snd_soc_component_update_bits(component
, hd2_scale_reg
,
3373 WCD934X_CDC_RX_PATH_SEC_HD2_ALPHA_MASK
,
3374 WCD934X_CDC_RX_PATH_SEC_HD2_ALPHA_0P3125
);
3375 snd_soc_component_update_bits(component
, hd2_enable_reg
,
3376 WCD934X_CDC_RX_PATH_CFG_HD2_EN_MASK
,
3377 WCD934X_CDC_RX_PATH_CFG_HD2_ENABLE
);
3380 if (SND_SOC_DAPM_EVENT_OFF(event
)) {
3381 snd_soc_component_update_bits(component
, hd2_enable_reg
,
3382 WCD934X_CDC_RX_PATH_CFG_HD2_EN_MASK
,
3383 WCD934X_CDC_RX_PATH_CFG_HD2_DISABLE
);
3384 snd_soc_component_update_bits(component
, hd2_scale_reg
,
3385 WCD934X_CDC_RX_PATH_SEC_HD2_ALPHA_MASK
,
3386 WCD934X_CDC_RX_PATH_SEC_HD2_ALPHA_0P0000
);
3390 static void wcd934x_codec_hphdelay_lutbypass(struct snd_soc_component
*comp
,
3391 u16 interp_idx
, int event
)
3394 u16 hph_lut_bypass_reg
= 0;
3395 u16 hph_comp_ctrl7
= 0;
3397 switch (interp_idx
) {
3400 hph_lut_bypass_reg
= WCD934X_CDC_TOP_HPHL_COMP_LUT
;
3401 hph_comp_ctrl7
= WCD934X_CDC_COMPANDER1_CTL7
;
3405 hph_lut_bypass_reg
= WCD934X_CDC_TOP_HPHR_COMP_LUT
;
3406 hph_comp_ctrl7
= WCD934X_CDC_COMPANDER2_CTL7
;
3412 if (SND_SOC_DAPM_EVENT_ON(event
)) {
3413 snd_soc_component_update_bits(comp
, WCD934X_CDC_CLSH_TEST0
,
3415 snd_soc_component_update_bits(comp
, hph_lut_bypass_reg
,
3416 WCD934X_HPH_LUT_BYPASS_MASK
,
3417 WCD934X_HPH_LUT_BYPASS_ENABLE
);
3420 if (SND_SOC_DAPM_EVENT_OFF(event
)) {
3421 snd_soc_component_update_bits(comp
, WCD934X_CDC_CLSH_TEST0
,
3422 hph_dly_mask
, hph_dly_mask
);
3423 snd_soc_component_update_bits(comp
, hph_lut_bypass_reg
,
3424 WCD934X_HPH_LUT_BYPASS_MASK
,
3425 WCD934X_HPH_LUT_BYPASS_DISABLE
);
3429 static int wcd934x_config_compander(struct snd_soc_component
*comp
,
3430 int interp_n
, int event
)
3432 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
3434 u16 comp_ctl0_reg
, rx_path_cfg0_reg
;
3436 /* EAR does not have compander */
3440 compander
= interp_n
- 1;
3441 if (!wcd
->comp_enabled
[compander
])
3444 comp_ctl0_reg
= WCD934X_CDC_COMPANDER1_CTL0
+ (compander
* 8);
3445 rx_path_cfg0_reg
= WCD934X_CDC_RX1_RX_PATH_CFG0
+ (compander
* 20);
3448 case SND_SOC_DAPM_PRE_PMU
:
3449 /* Enable Compander Clock */
3450 snd_soc_component_update_bits(comp
, comp_ctl0_reg
,
3451 WCD934X_COMP_CLK_EN_MASK
,
3452 WCD934X_COMP_CLK_ENABLE
);
3453 snd_soc_component_update_bits(comp
, comp_ctl0_reg
,
3454 WCD934X_COMP_SOFT_RST_MASK
,
3455 WCD934X_COMP_SOFT_RST_ENABLE
);
3456 snd_soc_component_update_bits(comp
, comp_ctl0_reg
,
3457 WCD934X_COMP_SOFT_RST_MASK
,
3458 WCD934X_COMP_SOFT_RST_DISABLE
);
3459 snd_soc_component_update_bits(comp
, rx_path_cfg0_reg
,
3460 WCD934X_HPH_CMP_EN_MASK
,
3461 WCD934X_HPH_CMP_ENABLE
);
3463 case SND_SOC_DAPM_POST_PMD
:
3464 snd_soc_component_update_bits(comp
, rx_path_cfg0_reg
,
3465 WCD934X_HPH_CMP_EN_MASK
,
3466 WCD934X_HPH_CMP_DISABLE
);
3467 snd_soc_component_update_bits(comp
, comp_ctl0_reg
,
3468 WCD934X_COMP_HALT_MASK
,
3470 snd_soc_component_update_bits(comp
, comp_ctl0_reg
,
3471 WCD934X_COMP_SOFT_RST_MASK
,
3472 WCD934X_COMP_SOFT_RST_ENABLE
);
3473 snd_soc_component_update_bits(comp
, comp_ctl0_reg
,
3474 WCD934X_COMP_SOFT_RST_MASK
,
3475 WCD934X_COMP_SOFT_RST_DISABLE
);
3476 snd_soc_component_update_bits(comp
, comp_ctl0_reg
,
3477 WCD934X_COMP_CLK_EN_MASK
, 0x0);
3478 snd_soc_component_update_bits(comp
, comp_ctl0_reg
,
3479 WCD934X_COMP_SOFT_RST_MASK
, 0x0);
3486 static int wcd934x_codec_enable_interp_clk(struct snd_soc_dapm_widget
*w
,
3487 struct snd_kcontrol
*kc
, int event
)
3489 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3490 int interp_idx
= w
->shift
;
3491 u16 main_reg
= WCD934X_CDC_RX0_RX_PATH_CTL
+ (interp_idx
* 20);
3494 case SND_SOC_DAPM_PRE_PMU
:
3496 snd_soc_component_update_bits(comp
, main_reg
,
3497 WCD934X_RX_CLK_EN_MASK
,
3498 WCD934X_RX_CLK_ENABLE
);
3499 wcd934x_codec_hd2_control(comp
, interp_idx
, event
);
3500 wcd934x_codec_hphdelay_lutbypass(comp
, interp_idx
, event
);
3501 wcd934x_config_compander(comp
, interp_idx
, event
);
3503 case SND_SOC_DAPM_POST_PMD
:
3504 wcd934x_config_compander(comp
, interp_idx
, event
);
3505 wcd934x_codec_hphdelay_lutbypass(comp
, interp_idx
, event
);
3506 wcd934x_codec_hd2_control(comp
, interp_idx
, event
);
3508 snd_soc_component_update_bits(comp
, main_reg
,
3509 WCD934X_RX_CLK_EN_MASK
, 0);
3510 /* Reset enable and disable */
3511 snd_soc_component_update_bits(comp
, main_reg
,
3512 WCD934X_RX_RESET_MASK
,
3513 WCD934X_RX_RESET_ENABLE
);
3514 snd_soc_component_update_bits(comp
, main_reg
,
3515 WCD934X_RX_RESET_MASK
,
3516 WCD934X_RX_RESET_DISABLE
);
3517 /* Reset rate to 48K*/
3518 snd_soc_component_update_bits(comp
, main_reg
,
3519 WCD934X_RX_PCM_RATE_MASK
,
3520 WCD934X_RX_PCM_RATE_F_48K
);
3527 static int wcd934x_codec_enable_mix_path(struct snd_soc_dapm_widget
*w
,
3528 struct snd_kcontrol
*kc
, int event
)
3530 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3532 u16 gain_reg
, mix_reg
;
3535 gain_reg
= WCD934X_CDC_RX0_RX_VOL_MIX_CTL
+
3536 (w
->shift
* WCD934X_RX_PATH_CTL_OFFSET
);
3537 mix_reg
= WCD934X_CDC_RX0_RX_PATH_MIX_CTL
+
3538 (w
->shift
* WCD934X_RX_PATH_CTL_OFFSET
);
3541 case SND_SOC_DAPM_PRE_PMU
:
3543 snd_soc_component_update_bits(comp
, mix_reg
,
3544 WCD934X_CDC_RX_MIX_CLK_EN_MASK
,
3545 WCD934X_CDC_RX_MIX_CLK_ENABLE
);
3548 case SND_SOC_DAPM_POST_PMU
:
3549 val
= snd_soc_component_read32(comp
, gain_reg
);
3551 snd_soc_component_write(comp
, gain_reg
, val
);
3558 static int wcd934x_codec_set_iir_gain(struct snd_soc_dapm_widget
*w
,
3559 struct snd_kcontrol
*kcontrol
, int event
)
3561 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3565 case SND_SOC_DAPM_POST_PMU
:
3567 snd_soc_component_write(comp
, reg
,
3568 snd_soc_component_read32(comp
, reg
));
3571 snd_soc_component_write(comp
, reg
,
3572 snd_soc_component_read32(comp
, reg
));
3575 snd_soc_component_write(comp
, reg
,
3576 snd_soc_component_read32(comp
, reg
));
3579 snd_soc_component_write(comp
, reg
,
3580 snd_soc_component_read32(comp
, reg
));
3583 snd_soc_component_write(comp
, reg
,
3584 snd_soc_component_read32(comp
, reg
));
3592 static int wcd934x_codec_enable_main_path(struct snd_soc_dapm_widget
*w
,
3593 struct snd_kcontrol
*kcontrol
,
3596 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3599 gain_reg
= WCD934X_CDC_RX0_RX_VOL_CTL
+ (w
->shift
*
3600 WCD934X_RX_PATH_CTL_OFFSET
);
3603 case SND_SOC_DAPM_POST_PMU
:
3604 snd_soc_component_write(comp
, gain_reg
,
3605 snd_soc_component_read32(comp
, gain_reg
));
3612 static int wcd934x_codec_ear_dac_event(struct snd_soc_dapm_widget
*w
,
3613 struct snd_kcontrol
*kc
, int event
)
3615 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3616 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
3619 case SND_SOC_DAPM_PRE_PMU
:
3620 /* Disable AutoChop timer during power up */
3621 snd_soc_component_update_bits(comp
,
3622 WCD934X_HPH_NEW_INT_HPH_TIMER1
,
3623 WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK
, 0x0);
3624 wcd_clsh_ctrl_set_state(wcd
->clsh_ctrl
, WCD_CLSH_EVENT_PRE_DAC
,
3625 WCD_CLSH_STATE_EAR
, CLS_H_NORMAL
);
3628 case SND_SOC_DAPM_POST_PMD
:
3629 wcd_clsh_ctrl_set_state(wcd
->clsh_ctrl
, WCD_CLSH_EVENT_POST_PA
,
3630 WCD_CLSH_STATE_EAR
, CLS_H_NORMAL
);
3637 static int wcd934x_codec_hphl_dac_event(struct snd_soc_dapm_widget
*w
,
3638 struct snd_kcontrol
*kcontrol
,
3641 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3642 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
3643 int hph_mode
= wcd
->hph_mode
;
3647 case SND_SOC_DAPM_PRE_PMU
:
3648 /* Read DEM INP Select */
3649 dem_inp
= snd_soc_component_read32(comp
,
3650 WCD934X_CDC_RX1_RX_PATH_SEC0
) & 0x03;
3652 if (((hph_mode
== CLS_H_HIFI
) || (hph_mode
== CLS_H_LOHIFI
) ||
3653 (hph_mode
== CLS_H_LP
)) && (dem_inp
!= 0x01)) {
3656 if (hph_mode
!= CLS_H_LP
)
3657 /* Ripple freq control enable */
3658 snd_soc_component_update_bits(comp
,
3659 WCD934X_SIDO_NEW_VOUT_D_FREQ2
,
3660 WCD934X_SIDO_RIPPLE_FREQ_EN_MASK
,
3661 WCD934X_SIDO_RIPPLE_FREQ_ENABLE
);
3662 /* Disable AutoChop timer during power up */
3663 snd_soc_component_update_bits(comp
,
3664 WCD934X_HPH_NEW_INT_HPH_TIMER1
,
3665 WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK
, 0x0);
3666 wcd_clsh_ctrl_set_state(wcd
->clsh_ctrl
, WCD_CLSH_EVENT_PRE_DAC
,
3667 WCD_CLSH_STATE_HPHL
, hph_mode
);
3670 case SND_SOC_DAPM_POST_PMD
:
3671 /* 1000us required as per HW requirement */
3672 usleep_range(1000, 1100);
3673 wcd_clsh_ctrl_set_state(wcd
->clsh_ctrl
, WCD_CLSH_EVENT_POST_PA
,
3674 WCD_CLSH_STATE_HPHL
, hph_mode
);
3675 if (hph_mode
!= CLS_H_LP
)
3676 /* Ripple freq control disable */
3677 snd_soc_component_update_bits(comp
,
3678 WCD934X_SIDO_NEW_VOUT_D_FREQ2
,
3679 WCD934X_SIDO_RIPPLE_FREQ_EN_MASK
, 0x0);
3689 static int wcd934x_codec_hphr_dac_event(struct snd_soc_dapm_widget
*w
,
3690 struct snd_kcontrol
*kcontrol
,
3693 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3694 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
3695 int hph_mode
= wcd
->hph_mode
;
3699 case SND_SOC_DAPM_PRE_PMU
:
3700 dem_inp
= snd_soc_component_read32(comp
,
3701 WCD934X_CDC_RX2_RX_PATH_SEC0
) & 0x03;
3702 if (((hph_mode
== CLS_H_HIFI
) || (hph_mode
== CLS_H_LOHIFI
) ||
3703 (hph_mode
== CLS_H_LP
)) && (dem_inp
!= 0x01)) {
3706 if (hph_mode
!= CLS_H_LP
)
3707 /* Ripple freq control enable */
3708 snd_soc_component_update_bits(comp
,
3709 WCD934X_SIDO_NEW_VOUT_D_FREQ2
,
3710 WCD934X_SIDO_RIPPLE_FREQ_EN_MASK
,
3711 WCD934X_SIDO_RIPPLE_FREQ_ENABLE
);
3712 /* Disable AutoChop timer during power up */
3713 snd_soc_component_update_bits(comp
,
3714 WCD934X_HPH_NEW_INT_HPH_TIMER1
,
3715 WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK
, 0x0);
3716 wcd_clsh_ctrl_set_state(wcd
->clsh_ctrl
, WCD_CLSH_EVENT_PRE_DAC
,
3717 WCD_CLSH_STATE_HPHR
,
3720 case SND_SOC_DAPM_POST_PMD
:
3721 /* 1000us required as per HW requirement */
3722 usleep_range(1000, 1100);
3724 wcd_clsh_ctrl_set_state(wcd
->clsh_ctrl
, WCD_CLSH_EVENT_POST_PA
,
3725 WCD_CLSH_STATE_HPHR
, hph_mode
);
3726 if (hph_mode
!= CLS_H_LP
)
3727 /* Ripple freq control disable */
3728 snd_soc_component_update_bits(comp
,
3729 WCD934X_SIDO_NEW_VOUT_D_FREQ2
,
3730 WCD934X_SIDO_RIPPLE_FREQ_EN_MASK
, 0x0);
3739 static int wcd934x_codec_lineout_dac_event(struct snd_soc_dapm_widget
*w
,
3740 struct snd_kcontrol
*kc
, int event
)
3742 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3743 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
3746 case SND_SOC_DAPM_PRE_PMU
:
3747 wcd_clsh_ctrl_set_state(wcd
->clsh_ctrl
, WCD_CLSH_EVENT_PRE_DAC
,
3748 WCD_CLSH_STATE_LO
, CLS_AB
);
3750 case SND_SOC_DAPM_POST_PMD
:
3751 wcd_clsh_ctrl_set_state(wcd
->clsh_ctrl
, WCD_CLSH_EVENT_POST_PA
,
3752 WCD_CLSH_STATE_LO
, CLS_AB
);
3759 static int wcd934x_codec_enable_hphl_pa(struct snd_soc_dapm_widget
*w
,
3760 struct snd_kcontrol
*kcontrol
,
3763 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3766 case SND_SOC_DAPM_POST_PMU
:
3768 * 7ms sleep is required after PA is enabled as per
3769 * HW requirement. If compander is disabled, then
3770 * 20ms delay is needed.
3772 usleep_range(20000, 20100);
3774 snd_soc_component_update_bits(comp
, WCD934X_HPH_L_TEST
,
3775 WCD934X_HPH_OCP_DET_MASK
,
3776 WCD934X_HPH_OCP_DET_ENABLE
);
3777 /* Remove Mute on primary path */
3778 snd_soc_component_update_bits(comp
, WCD934X_CDC_RX1_RX_PATH_CTL
,
3779 WCD934X_RX_PATH_PGA_MUTE_EN_MASK
,
3781 /* Enable GM3 boost */
3782 snd_soc_component_update_bits(comp
, WCD934X_HPH_CNP_WG_CTL
,
3783 WCD934X_HPH_GM3_BOOST_EN_MASK
,
3784 WCD934X_HPH_GM3_BOOST_ENABLE
);
3785 /* Enable AutoChop timer at the end of power up */
3786 snd_soc_component_update_bits(comp
,
3787 WCD934X_HPH_NEW_INT_HPH_TIMER1
,
3788 WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK
,
3789 WCD934X_HPH_AUTOCHOP_TIMER_ENABLE
);
3790 /* Remove mix path mute */
3791 snd_soc_component_update_bits(comp
,
3792 WCD934X_CDC_RX1_RX_PATH_MIX_CTL
,
3793 WCD934X_CDC_RX_PGA_MUTE_EN_MASK
, 0x00);
3795 case SND_SOC_DAPM_PRE_PMD
:
3796 /* Enable DSD Mute before PA disable */
3797 snd_soc_component_update_bits(comp
, WCD934X_HPH_L_TEST
,
3798 WCD934X_HPH_OCP_DET_MASK
,
3799 WCD934X_HPH_OCP_DET_DISABLE
);
3800 snd_soc_component_update_bits(comp
, WCD934X_CDC_RX1_RX_PATH_CTL
,
3801 WCD934X_RX_PATH_PGA_MUTE_EN_MASK
,
3802 WCD934X_RX_PATH_PGA_MUTE_ENABLE
);
3803 snd_soc_component_update_bits(comp
,
3804 WCD934X_CDC_RX1_RX_PATH_MIX_CTL
,
3805 WCD934X_RX_PATH_PGA_MUTE_EN_MASK
,
3806 WCD934X_RX_PATH_PGA_MUTE_ENABLE
);
3808 case SND_SOC_DAPM_POST_PMD
:
3810 * 5ms sleep is required after PA disable. If compander is
3811 * disabled, then 20ms delay is needed after PA disable.
3813 usleep_range(20000, 20100);
3820 static int wcd934x_codec_enable_hphr_pa(struct snd_soc_dapm_widget
*w
,
3821 struct snd_kcontrol
*kcontrol
,
3824 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3827 case SND_SOC_DAPM_POST_PMU
:
3829 * 7ms sleep is required after PA is enabled as per
3830 * HW requirement. If compander is disabled, then
3831 * 20ms delay is needed.
3833 usleep_range(20000, 20100);
3834 snd_soc_component_update_bits(comp
, WCD934X_HPH_R_TEST
,
3835 WCD934X_HPH_OCP_DET_MASK
,
3836 WCD934X_HPH_OCP_DET_ENABLE
);
3838 snd_soc_component_update_bits(comp
, WCD934X_CDC_RX2_RX_PATH_CTL
,
3839 WCD934X_RX_PATH_PGA_MUTE_EN_MASK
,
3841 /* Enable GM3 boost */
3842 snd_soc_component_update_bits(comp
, WCD934X_HPH_CNP_WG_CTL
,
3843 WCD934X_HPH_GM3_BOOST_EN_MASK
,
3844 WCD934X_HPH_GM3_BOOST_ENABLE
);
3845 /* Enable AutoChop timer at the end of power up */
3846 snd_soc_component_update_bits(comp
,
3847 WCD934X_HPH_NEW_INT_HPH_TIMER1
,
3848 WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK
,
3849 WCD934X_HPH_AUTOCHOP_TIMER_ENABLE
);
3850 /* Remove mix path mute if it is enabled */
3851 if ((snd_soc_component_read32(comp
,
3852 WCD934X_CDC_RX2_RX_PATH_MIX_CTL
)) & 0x10)
3853 snd_soc_component_update_bits(comp
,
3854 WCD934X_CDC_RX2_RX_PATH_MIX_CTL
,
3855 WCD934X_CDC_RX_PGA_MUTE_EN_MASK
,
3856 WCD934X_CDC_RX_PGA_MUTE_DISABLE
);
3858 case SND_SOC_DAPM_PRE_PMD
:
3859 snd_soc_component_update_bits(comp
, WCD934X_HPH_R_TEST
,
3860 WCD934X_HPH_OCP_DET_MASK
,
3861 WCD934X_HPH_OCP_DET_DISABLE
);
3862 snd_soc_component_update_bits(comp
, WCD934X_CDC_RX2_RX_PATH_CTL
,
3863 WCD934X_RX_PATH_PGA_MUTE_EN_MASK
,
3864 WCD934X_RX_PATH_PGA_MUTE_ENABLE
);
3865 snd_soc_component_update_bits(comp
,
3866 WCD934X_CDC_RX2_RX_PATH_MIX_CTL
,
3867 WCD934X_CDC_RX_PGA_MUTE_EN_MASK
,
3868 WCD934X_CDC_RX_PGA_MUTE_ENABLE
);
3870 case SND_SOC_DAPM_POST_PMD
:
3872 * 5ms sleep is required after PA disable. If compander is
3873 * disabled, then 20ms delay is needed after PA disable.
3875 usleep_range(20000, 20100);
3882 static u32
wcd934x_get_dmic_sample_rate(struct snd_soc_component
*comp
,
3884 struct wcd934x_codec
*wcd
)
3887 u8 adc_mux_index
= 0, adc_mux_sel
= 0;
3888 bool dec_found
= false;
3889 u16 adc_mux_ctl_reg
, tx_fs_reg
;
3892 while (dec_found
== 0 && adc_mux_index
< WCD934X_MAX_VALID_ADC_MUX
) {
3893 if (adc_mux_index
< 4) {
3894 adc_mux_ctl_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0
+
3895 (adc_mux_index
* 2);
3896 } else if (adc_mux_index
< WCD934X_INVALID_ADC_MUX
) {
3897 adc_mux_ctl_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0
+
3899 } else if (adc_mux_index
== WCD934X_INVALID_ADC_MUX
) {
3903 adc_mux_sel
= ((snd_soc_component_read32(comp
, adc_mux_ctl_reg
)
3906 if (adc_mux_sel
== dmic
) {
3914 if (dec_found
&& adc_mux_index
<= 8) {
3915 tx_fs_reg
= WCD934X_CDC_TX0_TX_PATH_CTL
+ (16 * adc_mux_index
);
3916 tx_stream_fs
= snd_soc_component_read32(comp
, tx_fs_reg
) & 0x0F;
3917 if (tx_stream_fs
<= 4) {
3918 if (wcd
->dmic_sample_rate
<=
3919 WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ
)
3920 dmic_fs
= wcd
->dmic_sample_rate
;
3922 dmic_fs
= WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ
;
3924 dmic_fs
= WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ
;
3926 dmic_fs
= wcd
->dmic_sample_rate
;
3932 static u8
wcd934x_get_dmic_clk_val(struct snd_soc_component
*comp
,
3933 u32 mclk_rate
, u32 dmic_clk_rate
)
3938 /* Default value to return in case of error */
3939 if (mclk_rate
== WCD934X_MCLK_CLK_9P6MHZ
)
3940 dmic_ctl_val
= WCD934X_DMIC_CLK_DIV_2
;
3942 dmic_ctl_val
= WCD934X_DMIC_CLK_DIV_3
;
3944 if (dmic_clk_rate
== 0) {
3946 "%s: dmic_sample_rate cannot be 0\n",
3951 div_factor
= mclk_rate
/ dmic_clk_rate
;
3952 switch (div_factor
) {
3954 dmic_ctl_val
= WCD934X_DMIC_CLK_DIV_2
;
3957 dmic_ctl_val
= WCD934X_DMIC_CLK_DIV_3
;
3960 dmic_ctl_val
= WCD934X_DMIC_CLK_DIV_4
;
3963 dmic_ctl_val
= WCD934X_DMIC_CLK_DIV_6
;
3966 dmic_ctl_val
= WCD934X_DMIC_CLK_DIV_8
;
3969 dmic_ctl_val
= WCD934X_DMIC_CLK_DIV_16
;
3973 "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
3974 __func__
, div_factor
, mclk_rate
, dmic_clk_rate
);
3979 return dmic_ctl_val
;
3982 static int wcd934x_codec_enable_dmic(struct snd_soc_dapm_widget
*w
,
3983 struct snd_kcontrol
*kcontrol
, int event
)
3985 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
3986 struct wcd934x_codec
*wcd
= dev_get_drvdata(comp
->dev
);
3987 u8 dmic_clk_en
= 0x01;
3990 u8 dmic_rate_val
, dmic_rate_shift
= 1;
3992 u32 dmic_sample_rate
;
3996 wname
= strpbrk(w
->name
, "012345");
3998 dev_err(comp
->dev
, "%s: widget not found\n", __func__
);
4002 ret
= kstrtouint(wname
, 10, &dmic
);
4004 dev_err(comp
->dev
, "%s: Invalid DMIC line on the codec\n",
4012 dmic_clk_cnt
= &wcd
->dmic_0_1_clk_cnt
;
4013 dmic_clk_reg
= WCD934X_CPE_SS_DMIC0_CTL
;
4017 dmic_clk_cnt
= &wcd
->dmic_2_3_clk_cnt
;
4018 dmic_clk_reg
= WCD934X_CPE_SS_DMIC1_CTL
;
4022 dmic_clk_cnt
= &wcd
->dmic_4_5_clk_cnt
;
4023 dmic_clk_reg
= WCD934X_CPE_SS_DMIC2_CTL
;
4026 dev_err(comp
->dev
, "%s: Invalid DMIC Selection\n",
4032 case SND_SOC_DAPM_PRE_PMU
:
4033 dmic_sample_rate
= wcd934x_get_dmic_sample_rate(comp
, dmic
,
4035 dmic_rate_val
= wcd934x_get_dmic_clk_val(comp
, wcd
->rate
,
4038 if (*dmic_clk_cnt
== 1) {
4039 dmic_rate_val
= dmic_rate_val
<< dmic_rate_shift
;
4040 snd_soc_component_update_bits(comp
, dmic_clk_reg
,
4041 WCD934X_DMIC_RATE_MASK
,
4043 snd_soc_component_update_bits(comp
, dmic_clk_reg
,
4044 dmic_clk_en
, dmic_clk_en
);
4048 case SND_SOC_DAPM_POST_PMD
:
4050 if (*dmic_clk_cnt
== 0)
4051 snd_soc_component_update_bits(comp
, dmic_clk_reg
,
4059 static int wcd934x_codec_find_amic_input(struct snd_soc_component
*comp
,
4062 u16 mask
, shift
, adc_mux_in_reg
;
4063 u16 amic_mux_sel_reg
;
4066 if (adc_mux_n
< 0 || adc_mux_n
> WCD934X_MAX_VALID_ADC_MUX
||
4067 adc_mux_n
== WCD934X_INVALID_ADC_MUX
)
4070 if (adc_mux_n
< 3) {
4071 adc_mux_in_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1
+
4075 amic_mux_sel_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0
+
4077 } else if (adc_mux_n
< 4) {
4078 adc_mux_in_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1
;
4081 amic_mux_sel_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0
+
4083 } else if (adc_mux_n
< 7) {
4084 adc_mux_in_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1
+
4088 amic_mux_sel_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0
+
4090 } else if (adc_mux_n
< 8) {
4091 adc_mux_in_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1
;
4094 amic_mux_sel_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0
+
4096 } else if (adc_mux_n
< 12) {
4097 adc_mux_in_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1
+
4098 ((adc_mux_n
== 8) ? (adc_mux_n
- 8) :
4102 amic_mux_sel_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0
+
4104 } else if (adc_mux_n
< 13) {
4105 adc_mux_in_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1
;
4108 amic_mux_sel_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0
+
4111 adc_mux_in_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1
;
4114 amic_mux_sel_reg
= WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0
+
4118 is_amic
= (((snd_soc_component_read32(comp
, adc_mux_in_reg
)
4119 & mask
) >> shift
) == 1);
4123 return snd_soc_component_read32(comp
, amic_mux_sel_reg
) & 0x07;
4126 static u16
wcd934x_codec_get_amic_pwlvl_reg(struct snd_soc_component
*comp
,
4129 u16 pwr_level_reg
= 0;
4134 pwr_level_reg
= WCD934X_ANA_AMIC1
;
4139 pwr_level_reg
= WCD934X_ANA_AMIC3
;
4145 return pwr_level_reg
;
4148 static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget
*w
,
4149 struct snd_kcontrol
*kcontrol
, int event
)
4151 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
4152 unsigned int decimator
;
4153 char *dec_adc_mux_name
= NULL
;
4154 char *widget_name
= NULL
;
4156 int ret
= 0, amic_n
;
4157 u16 tx_vol_ctl_reg
, pwr_level_reg
= 0, dec_cfg_reg
, hpf_gate_reg
;
4158 u16 tx_gain_ctl_reg
;
4162 widget_name
= kstrndup(w
->name
, 15, GFP_KERNEL
);
4166 wname
= widget_name
;
4167 dec_adc_mux_name
= strsep(&widget_name
, " ");
4168 if (!dec_adc_mux_name
) {
4169 dev_err(comp
->dev
, "%s: Invalid decimator = %s\n",
4174 dec_adc_mux_name
= widget_name
;
4176 dec
= strpbrk(dec_adc_mux_name
, "012345678");
4178 dev_err(comp
->dev
, "%s: decimator index not found\n",
4184 ret
= kstrtouint(dec
, 10, &decimator
);
4186 dev_err(comp
->dev
, "%s: Invalid decimator = %s\n",
4192 tx_vol_ctl_reg
= WCD934X_CDC_TX0_TX_PATH_CTL
+ 16 * decimator
;
4193 hpf_gate_reg
= WCD934X_CDC_TX0_TX_PATH_SEC2
+ 16 * decimator
;
4194 dec_cfg_reg
= WCD934X_CDC_TX0_TX_PATH_CFG0
+ 16 * decimator
;
4195 tx_gain_ctl_reg
= WCD934X_CDC_TX0_TX_VOL_CTL
+ 16 * decimator
;
4198 case SND_SOC_DAPM_PRE_PMU
:
4199 amic_n
= wcd934x_codec_find_amic_input(comp
, decimator
);
4201 pwr_level_reg
= wcd934x_codec_get_amic_pwlvl_reg(comp
,
4207 switch ((snd_soc_component_read32(comp
, pwr_level_reg
) &
4208 WCD934X_AMIC_PWR_LVL_MASK
) >>
4209 WCD934X_AMIC_PWR_LVL_SHIFT
) {
4210 case WCD934X_AMIC_PWR_LEVEL_LP
:
4211 snd_soc_component_update_bits(comp
, dec_cfg_reg
,
4212 WCD934X_DEC_PWR_LVL_MASK
,
4213 WCD934X_DEC_PWR_LVL_LP
);
4215 case WCD934X_AMIC_PWR_LEVEL_HP
:
4216 snd_soc_component_update_bits(comp
, dec_cfg_reg
,
4217 WCD934X_DEC_PWR_LVL_MASK
,
4218 WCD934X_DEC_PWR_LVL_HP
);
4220 case WCD934X_AMIC_PWR_LEVEL_DEFAULT
:
4221 case WCD934X_AMIC_PWR_LEVEL_HYBRID
:
4223 snd_soc_component_update_bits(comp
, dec_cfg_reg
,
4224 WCD934X_DEC_PWR_LVL_MASK
,
4225 WCD934X_DEC_PWR_LVL_DF
);
4229 case SND_SOC_DAPM_POST_PMU
:
4230 hpf_coff_freq
= (snd_soc_component_read32(comp
, dec_cfg_reg
) &
4231 TX_HPF_CUT_OFF_FREQ_MASK
) >> 5;
4232 if (hpf_coff_freq
!= CF_MIN_3DB_150HZ
) {
4233 snd_soc_component_update_bits(comp
, dec_cfg_reg
,
4234 TX_HPF_CUT_OFF_FREQ_MASK
,
4235 CF_MIN_3DB_150HZ
<< 5);
4236 snd_soc_component_update_bits(comp
, hpf_gate_reg
,
4237 WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ_MASK
,
4238 WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ
);
4240 * Minimum 1 clk cycle delay is required as per
4243 usleep_range(1000, 1010);
4244 snd_soc_component_update_bits(comp
, hpf_gate_reg
,
4245 WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ_MASK
,
4248 /* apply gain after decimator is enabled */
4249 snd_soc_component_write(comp
, tx_gain_ctl_reg
,
4250 snd_soc_component_read32(comp
,
4253 case SND_SOC_DAPM_PRE_PMD
:
4254 hpf_coff_freq
= (snd_soc_component_read32(comp
, dec_cfg_reg
) &
4255 TX_HPF_CUT_OFF_FREQ_MASK
) >> 5;
4257 if (hpf_coff_freq
!= CF_MIN_3DB_150HZ
) {
4258 snd_soc_component_update_bits(comp
, dec_cfg_reg
,
4259 TX_HPF_CUT_OFF_FREQ_MASK
,
4260 hpf_coff_freq
<< 5);
4261 snd_soc_component_update_bits(comp
, hpf_gate_reg
,
4262 WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ_MASK
,
4263 WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ
);
4265 * Minimum 1 clk cycle delay is required as per
4268 usleep_range(1000, 1010);
4269 snd_soc_component_update_bits(comp
, hpf_gate_reg
,
4270 WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ_MASK
,
4274 case SND_SOC_DAPM_POST_PMD
:
4275 snd_soc_component_update_bits(comp
, tx_vol_ctl_reg
,
4277 snd_soc_component_update_bits(comp
, dec_cfg_reg
,
4278 WCD934X_DEC_PWR_LVL_MASK
,
4279 WCD934X_DEC_PWR_LVL_DF
);
4287 static void wcd934x_codec_set_tx_hold(struct snd_soc_component
*comp
,
4288 u16 amic_reg
, bool set
)
4293 if (amic_reg
== WCD934X_ANA_AMIC1
||
4294 amic_reg
== WCD934X_ANA_AMIC3
)
4297 val
= set
? mask
: 0x00;
4300 case WCD934X_ANA_AMIC1
:
4301 case WCD934X_ANA_AMIC2
:
4302 snd_soc_component_update_bits(comp
, WCD934X_ANA_AMIC2
,
4305 case WCD934X_ANA_AMIC3
:
4306 case WCD934X_ANA_AMIC4
:
4307 snd_soc_component_update_bits(comp
, WCD934X_ANA_AMIC4
,
4315 static int wcd934x_codec_enable_adc(struct snd_soc_dapm_widget
*w
,
4316 struct snd_kcontrol
*kcontrol
, int event
)
4318 struct snd_soc_component
*comp
= snd_soc_dapm_to_component(w
->dapm
);
4321 case SND_SOC_DAPM_PRE_PMU
:
4322 wcd934x_codec_set_tx_hold(comp
, w
->reg
, true);
4331 static const struct snd_soc_dapm_widget wcd934x_dapm_widgets
[] = {
4332 /* Analog Outputs */
4333 SND_SOC_DAPM_OUTPUT("EAR"),
4334 SND_SOC_DAPM_OUTPUT("HPHL"),
4335 SND_SOC_DAPM_OUTPUT("HPHR"),
4336 SND_SOC_DAPM_OUTPUT("LINEOUT1"),
4337 SND_SOC_DAPM_OUTPUT("LINEOUT2"),
4338 SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
4339 SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
4340 SND_SOC_DAPM_OUTPUT("ANC EAR"),
4341 SND_SOC_DAPM_OUTPUT("ANC HPHL"),
4342 SND_SOC_DAPM_OUTPUT("ANC HPHR"),
4343 SND_SOC_DAPM_OUTPUT("WDMA3_OUT"),
4344 SND_SOC_DAPM_OUTPUT("MAD_CPE_OUT1"),
4345 SND_SOC_DAPM_OUTPUT("MAD_CPE_OUT2"),
4346 SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM
,
4347 AIF1_PB
, 0, wcd934x_codec_enable_slim
,
4348 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4349 SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM
,
4350 AIF2_PB
, 0, wcd934x_codec_enable_slim
,
4351 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4352 SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM
,
4353 AIF3_PB
, 0, wcd934x_codec_enable_slim
,
4354 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4355 SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM
,
4356 AIF4_PB
, 0, wcd934x_codec_enable_slim
,
4357 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4359 SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM
, WCD934X_RX0
, 0,
4360 &slim_rx_mux
[WCD934X_RX0
]),
4361 SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM
, WCD934X_RX1
, 0,
4362 &slim_rx_mux
[WCD934X_RX1
]),
4363 SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM
, WCD934X_RX2
, 0,
4364 &slim_rx_mux
[WCD934X_RX2
]),
4365 SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM
, WCD934X_RX3
, 0,
4366 &slim_rx_mux
[WCD934X_RX3
]),
4367 SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM
, WCD934X_RX4
, 0,
4368 &slim_rx_mux
[WCD934X_RX4
]),
4369 SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM
, WCD934X_RX5
, 0,
4370 &slim_rx_mux
[WCD934X_RX5
]),
4371 SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM
, WCD934X_RX6
, 0,
4372 &slim_rx_mux
[WCD934X_RX6
]),
4373 SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM
, WCD934X_RX7
, 0,
4374 &slim_rx_mux
[WCD934X_RX7
]),
4376 SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4377 SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4378 SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4379 SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4380 SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4381 SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4382 SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4383 SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4385 SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", SND_SOC_NOPM
, INTERP_EAR
, 0,
4386 &rx_int0_2_mux
, wcd934x_codec_enable_mix_path
,
4387 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4388 SND_SOC_DAPM_POST_PMD
),
4389 SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", SND_SOC_NOPM
, INTERP_HPHL
, 0,
4390 &rx_int1_2_mux
, wcd934x_codec_enable_mix_path
,
4391 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4392 SND_SOC_DAPM_POST_PMD
),
4393 SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", SND_SOC_NOPM
, INTERP_HPHR
, 0,
4394 &rx_int2_2_mux
, wcd934x_codec_enable_mix_path
,
4395 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4396 SND_SOC_DAPM_POST_PMD
),
4397 SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", SND_SOC_NOPM
, INTERP_LO1
, 0,
4398 &rx_int3_2_mux
, wcd934x_codec_enable_mix_path
,
4399 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4400 SND_SOC_DAPM_POST_PMD
),
4401 SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", SND_SOC_NOPM
, INTERP_LO2
, 0,
4402 &rx_int4_2_mux
, wcd934x_codec_enable_mix_path
,
4403 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4404 SND_SOC_DAPM_POST_PMD
),
4405 SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", SND_SOC_NOPM
, INTERP_SPKR1
, 0,
4406 &rx_int7_2_mux
, wcd934x_codec_enable_mix_path
,
4407 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4408 SND_SOC_DAPM_POST_PMD
),
4409 SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", SND_SOC_NOPM
, INTERP_SPKR2
, 0,
4410 &rx_int8_2_mux
, wcd934x_codec_enable_mix_path
,
4411 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4412 SND_SOC_DAPM_POST_PMD
),
4414 SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM
, 0, 0,
4415 &rx_int0_1_mix_inp0_mux
),
4416 SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM
, 0, 0,
4417 &rx_int0_1_mix_inp1_mux
),
4418 SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM
, 0, 0,
4419 &rx_int0_1_mix_inp2_mux
),
4420 SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM
, 0, 0,
4421 &rx_int1_1_mix_inp0_mux
),
4422 SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM
, 0, 0,
4423 &rx_int1_1_mix_inp1_mux
),
4424 SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM
, 0, 0,
4425 &rx_int1_1_mix_inp2_mux
),
4426 SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM
, 0, 0,
4427 &rx_int2_1_mix_inp0_mux
),
4428 SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM
, 0, 0,
4429 &rx_int2_1_mix_inp1_mux
),
4430 SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM
, 0, 0,
4431 &rx_int2_1_mix_inp2_mux
),
4432 SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM
, 0, 0,
4433 &rx_int3_1_mix_inp0_mux
),
4434 SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM
, 0, 0,
4435 &rx_int3_1_mix_inp1_mux
),
4436 SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM
, 0, 0,
4437 &rx_int3_1_mix_inp2_mux
),
4438 SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM
, 0, 0,
4439 &rx_int4_1_mix_inp0_mux
),
4440 SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM
, 0, 0,
4441 &rx_int4_1_mix_inp1_mux
),
4442 SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM
, 0, 0,
4443 &rx_int4_1_mix_inp2_mux
),
4444 SND_SOC_DAPM_MUX("RX INT7_1 MIX1 INP0", SND_SOC_NOPM
, 0, 0,
4445 &rx_int7_1_mix_inp0_mux
),
4446 SND_SOC_DAPM_MUX("RX INT7_1 MIX1 INP1", SND_SOC_NOPM
, 0, 0,
4447 &rx_int7_1_mix_inp1_mux
),
4448 SND_SOC_DAPM_MUX("RX INT7_1 MIX1 INP2", SND_SOC_NOPM
, 0, 0,
4449 &rx_int7_1_mix_inp2_mux
),
4450 SND_SOC_DAPM_MUX("RX INT8_1 MIX1 INP0", SND_SOC_NOPM
, 0, 0,
4451 &rx_int8_1_mix_inp0_mux
),
4452 SND_SOC_DAPM_MUX("RX INT8_1 MIX1 INP1", SND_SOC_NOPM
, 0, 0,
4453 &rx_int8_1_mix_inp1_mux
),
4454 SND_SOC_DAPM_MUX("RX INT8_1 MIX1 INP2", SND_SOC_NOPM
, 0, 0,
4455 &rx_int8_1_mix_inp2_mux
),
4456 SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4457 SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4458 SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4459 SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM
, 0, 0,
4460 rx_int1_asrc_switch
,
4461 ARRAY_SIZE(rx_int1_asrc_switch
)),
4462 SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4463 SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM
, 0, 0,
4464 rx_int2_asrc_switch
,
4465 ARRAY_SIZE(rx_int2_asrc_switch
)),
4466 SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4467 SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM
, 0, 0,
4468 rx_int3_asrc_switch
,
4469 ARRAY_SIZE(rx_int3_asrc_switch
)),
4470 SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4471 SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM
, 0, 0,
4472 rx_int4_asrc_switch
,
4473 ARRAY_SIZE(rx_int4_asrc_switch
)),
4474 SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4475 SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4476 SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4477 SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4478 SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4479 SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4480 SND_SOC_DAPM_MIXER("RX INT1 MIX3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4481 SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4482 SND_SOC_DAPM_MIXER("RX INT2 MIX3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4483 SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4484 SND_SOC_DAPM_MIXER("RX INT3 MIX3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4485 SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4486 SND_SOC_DAPM_MIXER("RX INT4 MIX3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4488 SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4489 SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM
, 0, 0,
4491 SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM
, 0, 0,
4493 SND_SOC_DAPM_MUX_E("RX INT0 MIX2 INP", WCD934X_CDC_RX0_RX_PATH_CFG0
, 4,
4494 0, &rx_int0_mix2_inp_mux
, NULL
,
4495 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4496 SND_SOC_DAPM_MUX_E("RX INT1 MIX2 INP", WCD934X_CDC_RX1_RX_PATH_CFG0
, 4,
4497 0, &rx_int1_mix2_inp_mux
, NULL
,
4498 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4499 SND_SOC_DAPM_MUX_E("RX INT2 MIX2 INP", WCD934X_CDC_RX2_RX_PATH_CFG0
, 4,
4500 0, &rx_int2_mix2_inp_mux
, NULL
,
4501 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4502 SND_SOC_DAPM_MUX_E("RX INT3 MIX2 INP", WCD934X_CDC_RX3_RX_PATH_CFG0
, 4,
4503 0, &rx_int3_mix2_inp_mux
, NULL
,
4504 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4505 SND_SOC_DAPM_MUX_E("RX INT4 MIX2 INP", WCD934X_CDC_RX4_RX_PATH_CFG0
, 4,
4506 0, &rx_int4_mix2_inp_mux
, NULL
,
4507 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4508 SND_SOC_DAPM_MUX_E("RX INT7 MIX2 INP", WCD934X_CDC_RX7_RX_PATH_CFG0
, 4,
4509 0, &rx_int7_mix2_inp_mux
, NULL
,
4510 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4512 SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM
, 0, 0, &iir0_inp0_mux
),
4513 SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM
, 0, 0, &iir0_inp1_mux
),
4514 SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM
, 0, 0, &iir0_inp2_mux
),
4515 SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM
, 0, 0, &iir0_inp3_mux
),
4516 SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM
, 0, 0, &iir1_inp0_mux
),
4517 SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM
, 0, 0, &iir1_inp1_mux
),
4518 SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM
, 0, 0, &iir1_inp2_mux
),
4519 SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM
, 0, 0, &iir1_inp3_mux
),
4521 SND_SOC_DAPM_PGA_E("IIR0", WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL
,
4522 0, 0, NULL
, 0, wcd934x_codec_set_iir_gain
,
4523 SND_SOC_DAPM_POST_PMU
),
4524 SND_SOC_DAPM_PGA_E("IIR1", WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL
,
4525 1, 0, NULL
, 0, wcd934x_codec_set_iir_gain
,
4526 SND_SOC_DAPM_POST_PMU
),
4527 SND_SOC_DAPM_MIXER("SRC0", WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL
,
4529 SND_SOC_DAPM_MIXER("SRC1", WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL
,
4531 SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM
, 0, 0,
4532 &rx_int0_dem_inp_mux
),
4533 SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM
, 0, 0,
4534 &rx_int1_dem_inp_mux
),
4535 SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM
, 0, 0,
4536 &rx_int2_dem_inp_mux
),
4538 SND_SOC_DAPM_MUX_E("RX INT0_1 INTERP", SND_SOC_NOPM
, INTERP_EAR
, 0,
4539 &rx_int0_1_interp_mux
,
4540 wcd934x_codec_enable_main_path
,
4541 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4542 SND_SOC_DAPM_POST_PMD
),
4543 SND_SOC_DAPM_MUX_E("RX INT1_1 INTERP", SND_SOC_NOPM
, INTERP_HPHL
, 0,
4544 &rx_int1_1_interp_mux
,
4545 wcd934x_codec_enable_main_path
,
4546 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4547 SND_SOC_DAPM_POST_PMD
),
4548 SND_SOC_DAPM_MUX_E("RX INT2_1 INTERP", SND_SOC_NOPM
, INTERP_HPHR
, 0,
4549 &rx_int2_1_interp_mux
,
4550 wcd934x_codec_enable_main_path
,
4551 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4552 SND_SOC_DAPM_POST_PMD
),
4553 SND_SOC_DAPM_MUX_E("RX INT3_1 INTERP", SND_SOC_NOPM
, INTERP_LO1
, 0,
4554 &rx_int3_1_interp_mux
,
4555 wcd934x_codec_enable_main_path
,
4556 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4557 SND_SOC_DAPM_POST_PMD
),
4558 SND_SOC_DAPM_MUX_E("RX INT4_1 INTERP", SND_SOC_NOPM
, INTERP_LO2
, 0,
4559 &rx_int4_1_interp_mux
,
4560 wcd934x_codec_enable_main_path
,
4561 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4562 SND_SOC_DAPM_POST_PMD
),
4563 SND_SOC_DAPM_MUX_E("RX INT7_1 INTERP", SND_SOC_NOPM
, INTERP_SPKR1
, 0,
4564 &rx_int7_1_interp_mux
,
4565 wcd934x_codec_enable_main_path
,
4566 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4567 SND_SOC_DAPM_POST_PMD
),
4568 SND_SOC_DAPM_MUX_E("RX INT8_1 INTERP", SND_SOC_NOPM
, INTERP_SPKR2
, 0,
4569 &rx_int8_1_interp_mux
,
4570 wcd934x_codec_enable_main_path
,
4571 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4572 SND_SOC_DAPM_POST_PMD
),
4574 SND_SOC_DAPM_MUX("RX INT0_2 INTERP", SND_SOC_NOPM
, 0, 0,
4575 &rx_int0_2_interp_mux
),
4576 SND_SOC_DAPM_MUX("RX INT1_2 INTERP", SND_SOC_NOPM
, 0, 0,
4577 &rx_int1_2_interp_mux
),
4578 SND_SOC_DAPM_MUX("RX INT2_2 INTERP", SND_SOC_NOPM
, 0, 0,
4579 &rx_int2_2_interp_mux
),
4580 SND_SOC_DAPM_MUX("RX INT3_2 INTERP", SND_SOC_NOPM
, 0, 0,
4581 &rx_int3_2_interp_mux
),
4582 SND_SOC_DAPM_MUX("RX INT4_2 INTERP", SND_SOC_NOPM
, 0, 0,
4583 &rx_int4_2_interp_mux
),
4584 SND_SOC_DAPM_MUX("RX INT7_2 INTERP", SND_SOC_NOPM
, 0, 0,
4585 &rx_int7_2_interp_mux
),
4586 SND_SOC_DAPM_MUX("RX INT8_2 INTERP", SND_SOC_NOPM
, 0, 0,
4587 &rx_int8_2_interp_mux
),
4588 SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL
, SND_SOC_NOPM
,
4589 0, 0, wcd934x_codec_ear_dac_event
,
4590 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4591 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4592 SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL
, WCD934X_ANA_HPH
,
4593 5, 0, wcd934x_codec_hphl_dac_event
,
4594 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4595 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4596 SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL
, WCD934X_ANA_HPH
,
4597 4, 0, wcd934x_codec_hphr_dac_event
,
4598 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4599 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4600 SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL
, SND_SOC_NOPM
,
4601 0, 0, wcd934x_codec_lineout_dac_event
,
4602 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4603 SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL
, SND_SOC_NOPM
,
4604 0, 0, wcd934x_codec_lineout_dac_event
,
4605 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4606 SND_SOC_DAPM_PGA_E("EAR PA", WCD934X_ANA_EAR
, 7, 0, NULL
, 0, NULL
, 0),
4607 SND_SOC_DAPM_PGA_E("HPHL PA", WCD934X_ANA_HPH
, 7, 0, NULL
, 0,
4608 wcd934x_codec_enable_hphl_pa
,
4609 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4610 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4611 SND_SOC_DAPM_PGA_E("HPHR PA", WCD934X_ANA_HPH
, 6, 0, NULL
, 0,
4612 wcd934x_codec_enable_hphr_pa
,
4613 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4614 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4615 SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD934X_ANA_LO_1_2
, 7, 0, NULL
, 0,
4617 SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD934X_ANA_LO_1_2
, 6, 0, NULL
, 0,
4619 SND_SOC_DAPM_SUPPLY("RX_BIAS", WCD934X_ANA_RX_SUPPLIES
, 0, 0, NULL
,
4620 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4621 SND_SOC_DAPM_SUPPLY("SBOOST0", WCD934X_CDC_RX7_RX_PATH_CFG1
,
4623 SND_SOC_DAPM_SUPPLY("SBOOST0_CLK", WCD934X_CDC_BOOST0_BOOST_PATH_CTL
,
4625 SND_SOC_DAPM_SUPPLY("SBOOST1", WCD934X_CDC_RX8_RX_PATH_CFG1
,
4627 SND_SOC_DAPM_SUPPLY("SBOOST1_CLK", WCD934X_CDC_BOOST1_BOOST_PATH_CTL
,
4629 SND_SOC_DAPM_SUPPLY("INT0_CLK", SND_SOC_NOPM
, INTERP_EAR
, 0,
4630 wcd934x_codec_enable_interp_clk
,
4631 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4632 SND_SOC_DAPM_SUPPLY("INT1_CLK", SND_SOC_NOPM
, INTERP_HPHL
, 0,
4633 wcd934x_codec_enable_interp_clk
,
4634 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4635 SND_SOC_DAPM_SUPPLY("INT2_CLK", SND_SOC_NOPM
, INTERP_HPHR
, 0,
4636 wcd934x_codec_enable_interp_clk
,
4637 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4638 SND_SOC_DAPM_SUPPLY("INT3_CLK", SND_SOC_NOPM
, INTERP_LO1
, 0,
4639 wcd934x_codec_enable_interp_clk
,
4640 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4641 SND_SOC_DAPM_SUPPLY("INT4_CLK", SND_SOC_NOPM
, INTERP_LO2
, 0,
4642 wcd934x_codec_enable_interp_clk
,
4643 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4644 SND_SOC_DAPM_SUPPLY("INT7_CLK", SND_SOC_NOPM
, INTERP_SPKR1
, 0,
4645 wcd934x_codec_enable_interp_clk
,
4646 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4647 SND_SOC_DAPM_SUPPLY("INT8_CLK", SND_SOC_NOPM
, INTERP_SPKR2
, 0,
4648 wcd934x_codec_enable_interp_clk
,
4649 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4650 SND_SOC_DAPM_SUPPLY("DSMDEM0_CLK", WCD934X_CDC_RX0_RX_PATH_DSMDEM_CTL
,
4652 SND_SOC_DAPM_SUPPLY("DSMDEM1_CLK", WCD934X_CDC_RX1_RX_PATH_DSMDEM_CTL
,
4654 SND_SOC_DAPM_SUPPLY("DSMDEM2_CLK", WCD934X_CDC_RX2_RX_PATH_DSMDEM_CTL
,
4656 SND_SOC_DAPM_SUPPLY("DSMDEM3_CLK", WCD934X_CDC_RX3_RX_PATH_DSMDEM_CTL
,
4658 SND_SOC_DAPM_SUPPLY("DSMDEM4_CLK", WCD934X_CDC_RX4_RX_PATH_DSMDEM_CTL
,
4660 SND_SOC_DAPM_SUPPLY("DSMDEM7_CLK", WCD934X_CDC_RX7_RX_PATH_DSMDEM_CTL
,
4662 SND_SOC_DAPM_SUPPLY("DSMDEM8_CLK", WCD934X_CDC_RX8_RX_PATH_DSMDEM_CTL
,
4664 SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM
, 0, 0,
4665 wcd934x_codec_enable_mclk
,
4666 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4669 SND_SOC_DAPM_INPUT("AMIC1"),
4670 SND_SOC_DAPM_INPUT("AMIC2"),
4671 SND_SOC_DAPM_INPUT("AMIC3"),
4672 SND_SOC_DAPM_INPUT("AMIC4"),
4673 SND_SOC_DAPM_INPUT("AMIC5"),
4674 SND_SOC_DAPM_INPUT("DMIC0 Pin"),
4675 SND_SOC_DAPM_INPUT("DMIC1 Pin"),
4676 SND_SOC_DAPM_INPUT("DMIC2 Pin"),
4677 SND_SOC_DAPM_INPUT("DMIC3 Pin"),
4678 SND_SOC_DAPM_INPUT("DMIC4 Pin"),
4679 SND_SOC_DAPM_INPUT("DMIC5 Pin"),
4681 SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM
,
4682 AIF1_CAP
, 0, wcd934x_codec_enable_slim
,
4683 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4684 SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM
,
4685 AIF2_CAP
, 0, wcd934x_codec_enable_slim
,
4686 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4687 SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM
,
4688 AIF3_CAP
, 0, wcd934x_codec_enable_slim
,
4689 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4691 SND_SOC_DAPM_MIXER("SLIM TX0", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4692 SND_SOC_DAPM_MIXER("SLIM TX1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4693 SND_SOC_DAPM_MIXER("SLIM TX2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4694 SND_SOC_DAPM_MIXER("SLIM TX3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4695 SND_SOC_DAPM_MIXER("SLIM TX4", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4696 SND_SOC_DAPM_MIXER("SLIM TX5", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4697 SND_SOC_DAPM_MIXER("SLIM TX6", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4698 SND_SOC_DAPM_MIXER("SLIM TX7", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4699 SND_SOC_DAPM_MIXER("SLIM TX8", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4700 SND_SOC_DAPM_MIXER("SLIM TX9", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4701 SND_SOC_DAPM_MIXER("SLIM TX10", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4702 SND_SOC_DAPM_MIXER("SLIM TX11", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4703 SND_SOC_DAPM_MIXER("SLIM TX13", SND_SOC_NOPM
, 0, 0, NULL
, 0),
4705 /* Digital Mic Inputs */
4706 SND_SOC_DAPM_ADC_E("DMIC0", NULL
, SND_SOC_NOPM
, 0, 0,
4707 wcd934x_codec_enable_dmic
,
4708 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4709 SND_SOC_DAPM_ADC_E("DMIC1", NULL
, SND_SOC_NOPM
, 0, 0,
4710 wcd934x_codec_enable_dmic
,
4711 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4712 SND_SOC_DAPM_ADC_E("DMIC2", NULL
, SND_SOC_NOPM
, 0, 0,
4713 wcd934x_codec_enable_dmic
,
4714 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4715 SND_SOC_DAPM_ADC_E("DMIC3", NULL
, SND_SOC_NOPM
, 0, 0,
4716 wcd934x_codec_enable_dmic
,
4717 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4718 SND_SOC_DAPM_ADC_E("DMIC4", NULL
, SND_SOC_NOPM
, 0, 0,
4719 wcd934x_codec_enable_dmic
,
4720 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4721 SND_SOC_DAPM_ADC_E("DMIC5", NULL
, SND_SOC_NOPM
, 0, 0,
4722 wcd934x_codec_enable_dmic
,
4723 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
4724 SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux0
),
4725 SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux1
),
4726 SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux2
),
4727 SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux3
),
4728 SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux4
),
4729 SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux5
),
4730 SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux6
),
4731 SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux7
),
4732 SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM
, 0, 0, &tx_dmic_mux8
),
4733 SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM
, 0, 0, &tx_amic_mux0
),
4734 SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM
, 0, 0, &tx_amic_mux1
),
4735 SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM
, 0, 0, &tx_amic_mux2
),
4736 SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM
, 0, 0, &tx_amic_mux3
),
4737 SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM
, 0, 0, &tx_amic_mux4
),
4738 SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM
, 0, 0, &tx_amic_mux5
),
4739 SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM
, 0, 0, &tx_amic_mux6
),
4740 SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM
, 0, 0, &tx_amic_mux7
),
4741 SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM
, 0, 0, &tx_amic_mux8
),
4742 SND_SOC_DAPM_MUX_E("ADC MUX0", WCD934X_CDC_TX0_TX_PATH_CTL
, 5, 0,
4743 &tx_adc_mux0_mux
, wcd934x_codec_enable_dec
,
4744 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4745 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4746 SND_SOC_DAPM_MUX_E("ADC MUX1", WCD934X_CDC_TX1_TX_PATH_CTL
, 5, 0,
4747 &tx_adc_mux1_mux
, wcd934x_codec_enable_dec
,
4748 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4749 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4750 SND_SOC_DAPM_MUX_E("ADC MUX2", WCD934X_CDC_TX2_TX_PATH_CTL
, 5, 0,
4751 &tx_adc_mux2_mux
, wcd934x_codec_enable_dec
,
4752 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4753 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4754 SND_SOC_DAPM_MUX_E("ADC MUX3", WCD934X_CDC_TX3_TX_PATH_CTL
, 5, 0,
4755 &tx_adc_mux3_mux
, wcd934x_codec_enable_dec
,
4756 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4757 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4758 SND_SOC_DAPM_MUX_E("ADC MUX4", WCD934X_CDC_TX4_TX_PATH_CTL
, 5, 0,
4759 &tx_adc_mux4_mux
, wcd934x_codec_enable_dec
,
4760 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4761 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4762 SND_SOC_DAPM_MUX_E("ADC MUX5", WCD934X_CDC_TX5_TX_PATH_CTL
, 5, 0,
4763 &tx_adc_mux5_mux
, wcd934x_codec_enable_dec
,
4764 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4765 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4766 SND_SOC_DAPM_MUX_E("ADC MUX6", WCD934X_CDC_TX6_TX_PATH_CTL
, 5, 0,
4767 &tx_adc_mux6_mux
, wcd934x_codec_enable_dec
,
4768 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4769 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4770 SND_SOC_DAPM_MUX_E("ADC MUX7", WCD934X_CDC_TX7_TX_PATH_CTL
, 5, 0,
4771 &tx_adc_mux7_mux
, wcd934x_codec_enable_dec
,
4772 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4773 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4774 SND_SOC_DAPM_MUX_E("ADC MUX8", WCD934X_CDC_TX8_TX_PATH_CTL
, 5, 0,
4775 &tx_adc_mux8_mux
, wcd934x_codec_enable_dec
,
4776 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
4777 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMD
),
4778 SND_SOC_DAPM_ADC_E("ADC1", NULL
, WCD934X_ANA_AMIC1
, 7, 0,
4779 wcd934x_codec_enable_adc
, SND_SOC_DAPM_PRE_PMU
),
4780 SND_SOC_DAPM_ADC_E("ADC2", NULL
, WCD934X_ANA_AMIC2
, 7, 0,
4781 wcd934x_codec_enable_adc
, SND_SOC_DAPM_PRE_PMU
),
4782 SND_SOC_DAPM_ADC_E("ADC3", NULL
, WCD934X_ANA_AMIC3
, 7, 0,
4783 wcd934x_codec_enable_adc
, SND_SOC_DAPM_PRE_PMU
),
4784 SND_SOC_DAPM_ADC_E("ADC4", NULL
, WCD934X_ANA_AMIC4
, 7, 0,
4785 wcd934x_codec_enable_adc
, SND_SOC_DAPM_PRE_PMU
),
4786 SND_SOC_DAPM_SUPPLY("MIC BIAS1", WCD934X_ANA_MICB1
, 6, 0, NULL
,
4787 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4788 SND_SOC_DAPM_SUPPLY("MIC BIAS2", WCD934X_ANA_MICB2
, 6, 0, NULL
,
4789 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4790 SND_SOC_DAPM_SUPPLY("MIC BIAS3", WCD934X_ANA_MICB3
, 6, 0, NULL
,
4791 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4792 SND_SOC_DAPM_SUPPLY("MIC BIAS4", WCD934X_ANA_MICB4
, 6, 0, NULL
,
4793 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
4795 SND_SOC_DAPM_MUX("AMIC4_5 SEL", SND_SOC_NOPM
, 0, 0, &tx_amic4_5
),
4796 SND_SOC_DAPM_MUX("CDC_IF TX0 MUX", SND_SOC_NOPM
, WCD934X_TX0
, 0,
4798 SND_SOC_DAPM_MUX("CDC_IF TX1 MUX", SND_SOC_NOPM
, WCD934X_TX1
, 0,
4800 SND_SOC_DAPM_MUX("CDC_IF TX2 MUX", SND_SOC_NOPM
, WCD934X_TX2
, 0,
4802 SND_SOC_DAPM_MUX("CDC_IF TX3 MUX", SND_SOC_NOPM
, WCD934X_TX3
, 0,
4804 SND_SOC_DAPM_MUX("CDC_IF TX4 MUX", SND_SOC_NOPM
, WCD934X_TX4
, 0,
4806 SND_SOC_DAPM_MUX("CDC_IF TX5 MUX", SND_SOC_NOPM
, WCD934X_TX5
, 0,
4808 SND_SOC_DAPM_MUX("CDC_IF TX6 MUX", SND_SOC_NOPM
, WCD934X_TX6
, 0,
4810 SND_SOC_DAPM_MUX("CDC_IF TX7 MUX", SND_SOC_NOPM
, WCD934X_TX7
, 0,
4812 SND_SOC_DAPM_MUX("CDC_IF TX8 MUX", SND_SOC_NOPM
, WCD934X_TX8
, 0,
4814 SND_SOC_DAPM_MUX("CDC_IF TX9 MUX", SND_SOC_NOPM
, WCD934X_TX9
, 0,
4816 SND_SOC_DAPM_MUX("CDC_IF TX10 MUX", SND_SOC_NOPM
, WCD934X_TX10
, 0,
4818 SND_SOC_DAPM_MUX("CDC_IF TX11 MUX", SND_SOC_NOPM
, WCD934X_TX11
, 0,
4820 SND_SOC_DAPM_MUX("CDC_IF TX11 INP1 MUX", SND_SOC_NOPM
, WCD934X_TX11
, 0,
4821 &cdc_if_tx11_inp1_mux
),
4822 SND_SOC_DAPM_MUX("CDC_IF TX13 MUX", SND_SOC_NOPM
, WCD934X_TX13
, 0,
4824 SND_SOC_DAPM_MUX("CDC_IF TX13 INP1 MUX", SND_SOC_NOPM
, WCD934X_TX13
, 0,
4825 &cdc_if_tx13_inp1_mux
),
4826 SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM
, AIF1_CAP
, 0,
4827 aif1_slim_cap_mixer
,
4828 ARRAY_SIZE(aif1_slim_cap_mixer
)),
4829 SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM
, AIF2_CAP
, 0,
4830 aif2_slim_cap_mixer
,
4831 ARRAY_SIZE(aif2_slim_cap_mixer
)),
4832 SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM
, AIF3_CAP
, 0,
4833 aif3_slim_cap_mixer
,
4834 ARRAY_SIZE(aif3_slim_cap_mixer
)),
4837 static const struct snd_soc_dapm_route wcd934x_audio_map
[] = {
4839 WCD934X_SLIM_RX_AIF_PATH(0),
4840 WCD934X_SLIM_RX_AIF_PATH(1),
4841 WCD934X_SLIM_RX_AIF_PATH(2),
4842 WCD934X_SLIM_RX_AIF_PATH(3),
4843 WCD934X_SLIM_RX_AIF_PATH(4),
4844 WCD934X_SLIM_RX_AIF_PATH(5),
4845 WCD934X_SLIM_RX_AIF_PATH(6),
4846 WCD934X_SLIM_RX_AIF_PATH(7),
4849 WCD934X_INTERPOLATOR_PATH(0),
4850 WCD934X_INTERPOLATOR_MIX2(0),
4851 {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 MIX2"},
4852 {"RX INT0 DAC", NULL
, "RX INT0 DEM MUX"},
4853 {"RX INT0 DAC", NULL
, "RX_BIAS"},
4854 {"EAR PA", NULL
, "RX INT0 DAC"},
4855 {"EAR", NULL
, "EAR PA"},
4857 /* RX1 Headphone left */
4858 WCD934X_INTERPOLATOR_PATH(1),
4859 WCD934X_INTERPOLATOR_MIX2(1),
4860 {"RX INT1 MIX3", NULL
, "RX INT1 MIX2"},
4861 {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 MIX3"},
4862 {"RX INT1 DAC", NULL
, "RX INT1 DEM MUX"},
4863 {"RX INT1 DAC", NULL
, "RX_BIAS"},
4864 {"HPHL PA", NULL
, "RX INT1 DAC"},
4865 {"HPHL", NULL
, "HPHL PA"},
4867 /* RX2 Headphone right */
4868 WCD934X_INTERPOLATOR_PATH(2),
4869 WCD934X_INTERPOLATOR_MIX2(2),
4870 {"RX INT2 MIX3", NULL
, "RX INT2 MIX2"},
4871 {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 MIX3"},
4872 {"RX INT2 DAC", NULL
, "RX INT2 DEM MUX"},
4873 {"RX INT2 DAC", NULL
, "RX_BIAS"},
4874 {"HPHR PA", NULL
, "RX INT2 DAC"},
4875 {"HPHR", NULL
, "HPHR PA"},
4877 /* RX3 HIFi LineOut1 */
4878 WCD934X_INTERPOLATOR_PATH(3),
4879 WCD934X_INTERPOLATOR_MIX2(3),
4880 {"RX INT3 MIX3", NULL
, "RX INT3 MIX2"},
4881 {"RX INT3 DAC", NULL
, "RX INT3 MIX3"},
4882 {"RX INT3 DAC", NULL
, "RX_BIAS"},
4883 {"LINEOUT1 PA", NULL
, "RX INT3 DAC"},
4884 {"LINEOUT1", NULL
, "LINEOUT1 PA"},
4886 /* RX4 HIFi LineOut2 */
4887 WCD934X_INTERPOLATOR_PATH(4),
4888 WCD934X_INTERPOLATOR_MIX2(4),
4889 {"RX INT4 MIX3", NULL
, "RX INT4 MIX2"},
4890 {"RX INT4 DAC", NULL
, "RX INT4 MIX3"},
4891 {"RX INT4 DAC", NULL
, "RX_BIAS"},
4892 {"LINEOUT2 PA", NULL
, "RX INT4 DAC"},
4893 {"LINEOUT2", NULL
, "LINEOUT2 PA"},
4895 /* RX7 Speaker Left Out PA */
4896 WCD934X_INTERPOLATOR_PATH(7),
4897 WCD934X_INTERPOLATOR_MIX2(7),
4898 {"RX INT7 CHAIN", NULL
, "RX INT7 MIX2"},
4899 {"RX INT7 CHAIN", NULL
, "RX_BIAS"},
4900 {"RX INT7 CHAIN", NULL
, "SBOOST0"},
4901 {"RX INT7 CHAIN", NULL
, "SBOOST0_CLK"},
4902 {"SPK1 OUT", NULL
, "RX INT7 CHAIN"},
4904 /* RX8 Speaker Right Out PA */
4905 WCD934X_INTERPOLATOR_PATH(8),
4906 {"RX INT8 CHAIN", NULL
, "RX INT8 SEC MIX"},
4907 {"RX INT8 CHAIN", NULL
, "RX_BIAS"},
4908 {"RX INT8 CHAIN", NULL
, "SBOOST1"},
4909 {"RX INT8 CHAIN", NULL
, "SBOOST1_CLK"},
4910 {"SPK2 OUT", NULL
, "RX INT8 CHAIN"},
4913 {"AIF1 CAP", NULL
, "AIF1_CAP Mixer"},
4914 {"AIF2 CAP", NULL
, "AIF2_CAP Mixer"},
4915 {"AIF3 CAP", NULL
, "AIF3_CAP Mixer"},
4917 WCD934X_SLIM_TX_AIF_PATH(0),
4918 WCD934X_SLIM_TX_AIF_PATH(1),
4919 WCD934X_SLIM_TX_AIF_PATH(2),
4920 WCD934X_SLIM_TX_AIF_PATH(3),
4921 WCD934X_SLIM_TX_AIF_PATH(4),
4922 WCD934X_SLIM_TX_AIF_PATH(5),
4923 WCD934X_SLIM_TX_AIF_PATH(6),
4924 WCD934X_SLIM_TX_AIF_PATH(7),
4925 WCD934X_SLIM_TX_AIF_PATH(8),
4937 {"CDC_IF TX0 MUX", "DEC0", "ADC MUX0"},
4938 {"CDC_IF TX1 MUX", "DEC1", "ADC MUX1"},
4939 {"CDC_IF TX2 MUX", "DEC2", "ADC MUX2"},
4940 {"CDC_IF TX3 MUX", "DEC3", "ADC MUX3"},
4941 {"CDC_IF TX4 MUX", "DEC4", "ADC MUX4"},
4942 {"CDC_IF TX5 MUX", "DEC5", "ADC MUX5"},
4943 {"CDC_IF TX6 MUX", "DEC6", "ADC MUX6"},
4944 {"CDC_IF TX7 MUX", "DEC7", "ADC MUX7"},
4945 {"CDC_IF TX8 MUX", "DEC8", "ADC MUX8"},
4947 {"AMIC4_5 SEL", "AMIC4", "AMIC4"},
4948 {"AMIC4_5 SEL", "AMIC5", "AMIC5"},
4950 { "DMIC0", NULL
, "DMIC0 Pin" },
4951 { "DMIC1", NULL
, "DMIC1 Pin" },
4952 { "DMIC2", NULL
, "DMIC2 Pin" },
4953 { "DMIC3", NULL
, "DMIC3 Pin" },
4954 { "DMIC4", NULL
, "DMIC4 Pin" },
4955 { "DMIC5", NULL
, "DMIC5 Pin" },
4957 {"ADC1", NULL
, "AMIC1"},
4958 {"ADC2", NULL
, "AMIC2"},
4959 {"ADC3", NULL
, "AMIC3"},
4960 {"ADC4", NULL
, "AMIC4_5 SEL"},
4962 WCD934X_IIR_INP_MUX(0),
4963 WCD934X_IIR_INP_MUX(1),
4965 {"SRC0", NULL
, "IIR0"},
4966 {"SRC1", NULL
, "IIR1"},
4969 static const struct snd_soc_component_driver wcd934x_component_drv
= {
4970 .probe
= wcd934x_comp_probe
,
4971 .remove
= wcd934x_comp_remove
,
4972 .set_sysclk
= wcd934x_comp_set_sysclk
,
4973 .controls
= wcd934x_snd_controls
,
4974 .num_controls
= ARRAY_SIZE(wcd934x_snd_controls
),
4975 .dapm_widgets
= wcd934x_dapm_widgets
,
4976 .num_dapm_widgets
= ARRAY_SIZE(wcd934x_dapm_widgets
),
4977 .dapm_routes
= wcd934x_audio_map
,
4978 .num_dapm_routes
= ARRAY_SIZE(wcd934x_audio_map
),
4981 static int wcd934x_codec_parse_data(struct wcd934x_codec
*wcd
)
4983 struct device
*dev
= &wcd
->sdev
->dev
;
4984 struct device_node
*ifc_dev_np
;
4986 ifc_dev_np
= of_parse_phandle(dev
->of_node
, "slim-ifc-dev", 0);
4988 dev_err(dev
, "No Interface device found\n");
4992 wcd
->sidev
= of_slim_get_device(wcd
->sdev
->ctrl
, ifc_dev_np
);
4994 dev_err(dev
, "Unable to get SLIM Interface device\n");
4998 slim_get_logical_addr(wcd
->sidev
);
4999 wcd
->if_regmap
= regmap_init_slimbus(wcd
->sidev
,
5000 &wcd934x_ifc_regmap_config
);
5001 if (IS_ERR(wcd
->if_regmap
)) {
5002 dev_err(dev
, "Failed to allocate ifc register map\n");
5003 return PTR_ERR(wcd
->if_regmap
);
5006 of_property_read_u32(dev
->parent
->of_node
, "qcom,dmic-sample-rate",
5007 &wcd
->dmic_sample_rate
);
5012 static int wcd934x_codec_probe(struct platform_device
*pdev
)
5014 struct wcd934x_ddata
*data
= dev_get_drvdata(pdev
->dev
.parent
);
5015 struct wcd934x_codec
*wcd
;
5016 struct device
*dev
= &pdev
->dev
;
5019 wcd
= devm_kzalloc(&pdev
->dev
, sizeof(*wcd
), GFP_KERNEL
);
5024 wcd
->regmap
= data
->regmap
;
5025 wcd
->extclk
= data
->extclk
;
5026 wcd
->sdev
= to_slim_device(data
->dev
);
5027 mutex_init(&wcd
->sysclk_mutex
);
5029 ret
= wcd934x_codec_parse_data(wcd
);
5031 dev_err(wcd
->dev
, "Failed to get SLIM IRQ\n");
5035 /* set default rate 9P6MHz */
5036 regmap_update_bits(wcd
->regmap
, WCD934X_CODEC_RPM_CLK_MCLK_CFG
,
5037 WCD934X_CODEC_RPM_CLK_MCLK_CFG_MCLK_MASK
,
5038 WCD934X_CODEC_RPM_CLK_MCLK_CFG_9P6MHZ
);
5039 memcpy(wcd
->rx_chs
, wcd934x_rx_chs
, sizeof(wcd934x_rx_chs
));
5040 memcpy(wcd
->tx_chs
, wcd934x_tx_chs
, sizeof(wcd934x_tx_chs
));
5042 irq
= regmap_irq_get_virq(data
->irq_data
, WCD934X_IRQ_SLIMBUS
);
5044 dev_err(wcd
->dev
, "Failed to get SLIM IRQ\n");
5048 ret
= devm_request_threaded_irq(dev
, irq
, NULL
,
5049 wcd934x_slim_irq_handler
,
5050 IRQF_TRIGGER_RISING
,
5053 dev_err(dev
, "Failed to request slimbus irq\n");
5057 wcd934x_register_mclk_output(wcd
);
5058 platform_set_drvdata(pdev
, wcd
);
5060 return devm_snd_soc_register_component(dev
, &wcd934x_component_drv
,
5062 ARRAY_SIZE(wcd934x_slim_dais
));
5065 static const struct platform_device_id wcd934x_driver_id
[] = {
5067 .name
= "wcd934x-codec",
5071 MODULE_DEVICE_TABLE(platform
, wcd934x_driver_id
);
5073 static struct platform_driver wcd934x_codec_driver
= {
5074 .probe
= &wcd934x_codec_probe
,
5075 .id_table
= wcd934x_driver_id
,
5077 .name
= "wcd934x-codec",
5081 MODULE_ALIAS("platform:wcd934x-codec");
5082 module_platform_driver(wcd934x_codec_driver
);
5083 MODULE_DESCRIPTION("WCD934x codec driver");
5084 MODULE_LICENSE("GPL v2");