]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - sound/soc/codecs/cs47l24.c
Merge remote-tracking branches 'asoc/topic/inntel', 'asoc/topic/input', 'asoc/topic...
[mirror_ubuntu-bionic-kernel.git] / sound / soc / codecs / cs47l24.c
CommitLineData
6610550c
RF
1/*
2 * cs47l24.h -- ALSA SoC Audio driver for Cirrus Logic CS47L24
3 *
4 * Copyright 2015 Cirrus Logic Inc.
5 *
6 * Author: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/pm.h>
18#include <linux/pm_runtime.h>
19#include <linux/regmap.h>
20#include <linux/slab.h>
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/pcm_params.h>
24#include <sound/soc.h>
25#include <sound/jack.h>
26#include <sound/initval.h>
27#include <sound/tlv.h>
28
29#include <linux/mfd/arizona/core.h>
30#include <linux/mfd/arizona/registers.h>
31
32#include "arizona.h"
33#include "wm_adsp.h"
34#include "cs47l24.h"
35
36struct cs47l24_priv {
37 struct arizona_priv core;
38 struct arizona_fll fll[2];
39};
40
41static const struct wm_adsp_region cs47l24_dsp2_regions[] = {
42 { .type = WMFW_ADSP2_PM, .base = 0x200000 },
43 { .type = WMFW_ADSP2_ZM, .base = 0x280000 },
44 { .type = WMFW_ADSP2_XM, .base = 0x290000 },
45 { .type = WMFW_ADSP2_YM, .base = 0x2a8000 },
46};
47
48static const struct wm_adsp_region cs47l24_dsp3_regions[] = {
49 { .type = WMFW_ADSP2_PM, .base = 0x300000 },
50 { .type = WMFW_ADSP2_ZM, .base = 0x380000 },
51 { .type = WMFW_ADSP2_XM, .base = 0x390000 },
52 { .type = WMFW_ADSP2_YM, .base = 0x3a8000 },
53};
54
55static const struct wm_adsp_region *cs47l24_dsp_regions[] = {
56 cs47l24_dsp2_regions,
57 cs47l24_dsp3_regions,
58};
59
d82d767f
CK
60static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w,
61 struct snd_kcontrol *kcontrol, int event)
62{
63 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
64 struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
65 unsigned int v;
66 int ret;
67
68 ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &v);
69 if (ret != 0) {
70 dev_err(codec->dev, "Failed to read SYSCLK state: %d\n", ret);
71 return ret;
72 }
73
74 v = (v & ARIZONA_SYSCLK_FREQ_MASK) >> ARIZONA_SYSCLK_FREQ_SHIFT;
75
76 return wm_adsp2_early_event(w, kcontrol, event, v);
77}
78
6610550c
RF
79static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
80static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
81static DECLARE_TLV_DB_SCALE(noise_tlv, -13200, 600, 0);
82static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
83
84#define CS47L24_NG_SRC(name, base) \
85 SOC_SINGLE(name " NG HPOUT1L Switch", base, 0, 1, 0), \
86 SOC_SINGLE(name " NG HPOUT1R Switch", base, 1, 1, 0), \
87 SOC_SINGLE(name " NG SPKOUT Switch", base, 6, 1, 0)
88
89static const struct snd_kcontrol_new cs47l24_snd_controls[] = {
90SOC_ENUM("IN1 OSR", arizona_in_dmic_osr[0]),
91SOC_ENUM("IN2 OSR", arizona_in_dmic_osr[1]),
92
93SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum),
94
95SOC_SINGLE("IN1L HPF Switch", ARIZONA_IN1L_CONTROL,
96 ARIZONA_IN1L_HPF_SHIFT, 1, 0),
97SOC_SINGLE("IN1R HPF Switch", ARIZONA_IN1R_CONTROL,
98 ARIZONA_IN1R_HPF_SHIFT, 1, 0),
99SOC_SINGLE("IN2L HPF Switch", ARIZONA_IN2L_CONTROL,
100 ARIZONA_IN2L_HPF_SHIFT, 1, 0),
101SOC_SINGLE("IN2R HPF Switch", ARIZONA_IN2R_CONTROL,
102 ARIZONA_IN2R_HPF_SHIFT, 1, 0),
103
104SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L,
105 ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
106SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R,
107 ARIZONA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
108SOC_SINGLE_TLV("IN2L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L,
109 ARIZONA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
110SOC_SINGLE_TLV("IN2R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2R,
111 ARIZONA_IN2R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
112
113SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
114SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
115
116ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
117ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
118
119ARIZONA_EQ_CONTROL("EQ1 Coefficients", ARIZONA_EQ1_2),
120SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
121 24, 0, eq_tlv),
122SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
123 24, 0, eq_tlv),
124SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT,
125 24, 0, eq_tlv),
126SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
127 24, 0, eq_tlv),
128SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
129 24, 0, eq_tlv),
130
131ARIZONA_EQ_CONTROL("EQ2 Coefficients", ARIZONA_EQ2_2),
132SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
133 24, 0, eq_tlv),
134SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
135 24, 0, eq_tlv),
136SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT,
137 24, 0, eq_tlv),
138SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
139 24, 0, eq_tlv),
140SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
141 24, 0, eq_tlv),
142
143ARIZONA_MIXER_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE),
144ARIZONA_MIXER_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE),
145ARIZONA_MIXER_CONTROLS("DRC2L", ARIZONA_DRC2LMIX_INPUT_1_SOURCE),
146ARIZONA_MIXER_CONTROLS("DRC2R", ARIZONA_DRC2RMIX_INPUT_1_SOURCE),
147
148SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5,
149 ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA),
150SND_SOC_BYTES_MASK("DRC2", ARIZONA_DRC2_CTRL1, 5,
151 ARIZONA_DRC2R_ENA | ARIZONA_DRC2L_ENA),
152
153ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE),
154ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
155ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
156ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
157
158ARIZONA_LHPF_CONTROL("LHPF1 Coefficients", ARIZONA_HPLPF1_2),
159ARIZONA_LHPF_CONTROL("LHPF2 Coefficients", ARIZONA_HPLPF2_2),
160ARIZONA_LHPF_CONTROL("LHPF3 Coefficients", ARIZONA_HPLPF3_2),
161ARIZONA_LHPF_CONTROL("LHPF4 Coefficients", ARIZONA_HPLPF4_2),
162
163SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
164SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
165SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
166SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
167
168SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]),
169SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]),
170SOC_ENUM("ISRC3 FSL", arizona_isrc_fsl[2]),
171SOC_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]),
172SOC_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]),
173SOC_ENUM("ISRC3 FSH", arizona_isrc_fsh[2]),
174SOC_ENUM("ASRC RATE 1", arizona_asrc_rate1),
175
176ARIZONA_MIXER_CONTROLS("DSP2L", ARIZONA_DSP2LMIX_INPUT_1_SOURCE),
177ARIZONA_MIXER_CONTROLS("DSP2R", ARIZONA_DSP2RMIX_INPUT_1_SOURCE),
178ARIZONA_MIXER_CONTROLS("DSP3L", ARIZONA_DSP3LMIX_INPUT_1_SOURCE),
179ARIZONA_MIXER_CONTROLS("DSP3R", ARIZONA_DSP3RMIX_INPUT_1_SOURCE),
180
181SOC_SINGLE_TLV("Noise Generator Volume", ARIZONA_COMFORT_NOISE_GENERATOR,
182 ARIZONA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, noise_tlv),
183
184ARIZONA_MIXER_CONTROLS("HPOUT1L", ARIZONA_OUT1LMIX_INPUT_1_SOURCE),
185ARIZONA_MIXER_CONTROLS("HPOUT1R", ARIZONA_OUT1RMIX_INPUT_1_SOURCE),
186ARIZONA_MIXER_CONTROLS("SPKOUT", ARIZONA_OUT4LMIX_INPUT_1_SOURCE),
187
188SOC_SINGLE("HPOUT1 SC Protect Switch", ARIZONA_HP1_SHORT_CIRCUIT_CTRL,
189 ARIZONA_HP1_SC_ENA_SHIFT, 1, 0),
190
191SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L,
192 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1),
193SOC_SINGLE("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L,
194 ARIZONA_OUT4L_MUTE_SHIFT, 1, 1),
195
196SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L,
197 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT,
198 0xbf, 0, digital_tlv),
199SOC_SINGLE_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L,
200 ARIZONA_OUT4L_VOL_SHIFT,
201 0xbf, 0, digital_tlv),
202
203SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
204SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
205
206SOC_SINGLE("Noise Gate Switch", ARIZONA_NOISE_GATE_CONTROL,
207 ARIZONA_NGATE_ENA_SHIFT, 1, 0),
208SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL,
209 ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv),
210SOC_ENUM("Noise Gate Hold", arizona_ng_hold),
211
212CS47L24_NG_SRC("HPOUT1L", ARIZONA_NOISE_GATE_SELECT_1L),
213CS47L24_NG_SRC("HPOUT1R", ARIZONA_NOISE_GATE_SELECT_1R),
214CS47L24_NG_SRC("SPKOUT", ARIZONA_NOISE_GATE_SELECT_4L),
215
216ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
217ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
218ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
219ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
220ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
221ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
222ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE),
223ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE),
224
225ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE),
226ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE),
227ARIZONA_MIXER_CONTROLS("AIF2TX3", ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE),
228ARIZONA_MIXER_CONTROLS("AIF2TX4", ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE),
229ARIZONA_MIXER_CONTROLS("AIF2TX5", ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE),
230ARIZONA_MIXER_CONTROLS("AIF2TX6", ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE),
231
232ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE),
233ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE),
234};
235
236ARIZONA_MIXER_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE);
237ARIZONA_MIXER_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE);
238
239ARIZONA_MIXER_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE);
240ARIZONA_MIXER_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE);
241ARIZONA_MIXER_ENUMS(DRC2L, ARIZONA_DRC2LMIX_INPUT_1_SOURCE);
242ARIZONA_MIXER_ENUMS(DRC2R, ARIZONA_DRC2RMIX_INPUT_1_SOURCE);
243
244ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE);
245ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE);
246ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE);
247ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE);
248
249ARIZONA_MIXER_ENUMS(DSP2L, ARIZONA_DSP2LMIX_INPUT_1_SOURCE);
250ARIZONA_MIXER_ENUMS(DSP2R, ARIZONA_DSP2RMIX_INPUT_1_SOURCE);
251ARIZONA_DSP_AUX_ENUMS(DSP2, ARIZONA_DSP2AUX1MIX_INPUT_1_SOURCE);
252
253ARIZONA_MIXER_ENUMS(DSP3L, ARIZONA_DSP3LMIX_INPUT_1_SOURCE);
254ARIZONA_MIXER_ENUMS(DSP3R, ARIZONA_DSP3RMIX_INPUT_1_SOURCE);
255ARIZONA_DSP_AUX_ENUMS(DSP3, ARIZONA_DSP3AUX1MIX_INPUT_1_SOURCE);
256
257ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE);
258ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE);
259
260ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE);
261ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE);
262ARIZONA_MIXER_ENUMS(SPKOUT, ARIZONA_OUT4LMIX_INPUT_1_SOURCE);
263
264ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE);
265ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE);
266ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE);
267ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE);
268ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE);
269ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE);
270ARIZONA_MIXER_ENUMS(AIF1TX7, ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE);
271ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE);
272
273ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE);
274ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
275ARIZONA_MIXER_ENUMS(AIF2TX3, ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE);
276ARIZONA_MIXER_ENUMS(AIF2TX4, ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE);
277ARIZONA_MIXER_ENUMS(AIF2TX5, ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE);
278ARIZONA_MIXER_ENUMS(AIF2TX6, ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE);
279
280ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
281ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
282
283ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
284ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
285ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
286ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
287
288ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE);
289ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE);
290ARIZONA_MUX_ENUMS(ISRC1INT3, ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE);
291ARIZONA_MUX_ENUMS(ISRC1INT4, ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE);
292
293ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE);
294ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE);
295ARIZONA_MUX_ENUMS(ISRC1DEC3, ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE);
296ARIZONA_MUX_ENUMS(ISRC1DEC4, ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE);
297
298ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE);
299ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE);
300ARIZONA_MUX_ENUMS(ISRC2INT3, ARIZONA_ISRC2INT3MIX_INPUT_1_SOURCE);
301ARIZONA_MUX_ENUMS(ISRC2INT4, ARIZONA_ISRC2INT4MIX_INPUT_1_SOURCE);
302
303ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE);
304ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE);
305ARIZONA_MUX_ENUMS(ISRC2DEC3, ARIZONA_ISRC2DEC3MIX_INPUT_1_SOURCE);
306ARIZONA_MUX_ENUMS(ISRC2DEC4, ARIZONA_ISRC2DEC4MIX_INPUT_1_SOURCE);
307
308ARIZONA_MUX_ENUMS(ISRC3INT1, ARIZONA_ISRC3INT1MIX_INPUT_1_SOURCE);
309ARIZONA_MUX_ENUMS(ISRC3INT2, ARIZONA_ISRC3INT2MIX_INPUT_1_SOURCE);
310ARIZONA_MUX_ENUMS(ISRC3INT3, ARIZONA_ISRC3INT3MIX_INPUT_1_SOURCE);
311ARIZONA_MUX_ENUMS(ISRC3INT4, ARIZONA_ISRC3INT4MIX_INPUT_1_SOURCE);
312
313ARIZONA_MUX_ENUMS(ISRC3DEC1, ARIZONA_ISRC3DEC1MIX_INPUT_1_SOURCE);
314ARIZONA_MUX_ENUMS(ISRC3DEC2, ARIZONA_ISRC3DEC2MIX_INPUT_1_SOURCE);
315ARIZONA_MUX_ENUMS(ISRC3DEC3, ARIZONA_ISRC3DEC3MIX_INPUT_1_SOURCE);
316ARIZONA_MUX_ENUMS(ISRC3DEC4, ARIZONA_ISRC3DEC4MIX_INPUT_1_SOURCE);
317
318static const char * const cs47l24_aec_loopback_texts[] = {
319 "HPOUT1L", "HPOUT1R", "SPKOUT",
320};
321
322static const unsigned int cs47l24_aec_loopback_values[] = {
323 0, 1, 6,
324};
325
326static const struct soc_enum cs47l24_aec_loopback =
327 SOC_VALUE_ENUM_SINGLE(ARIZONA_DAC_AEC_CONTROL_1,
328 ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf,
329 ARRAY_SIZE(cs47l24_aec_loopback_texts),
330 cs47l24_aec_loopback_texts,
331 cs47l24_aec_loopback_values);
332
333static const struct snd_kcontrol_new cs47l24_aec_loopback_mux =
334 SOC_DAPM_ENUM("AEC Loopback", cs47l24_aec_loopback);
335
336static const struct snd_soc_dapm_widget cs47l24_dapm_widgets[] = {
337SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1,
7a4413d0
CK
338 ARIZONA_SYSCLK_ENA_SHIFT, 0, arizona_clk_ev,
339 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
6610550c 340SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
7a4413d0
CK
341 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, arizona_clk_ev,
342 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
6610550c
RF
343SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
344 ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
345SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
346 ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
347
348SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
349SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
350SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDD", 0, 0),
351
352SND_SOC_DAPM_SIGGEN("TONE"),
353SND_SOC_DAPM_SIGGEN("NOISE"),
354SND_SOC_DAPM_SIGGEN("HAPTICS"),
355
356SND_SOC_DAPM_INPUT("IN1L"),
357SND_SOC_DAPM_INPUT("IN1R"),
358SND_SOC_DAPM_INPUT("IN2L"),
359SND_SOC_DAPM_INPUT("IN2R"),
360
361SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"),
362SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"),
363
97126ce8
CK
364SND_SOC_DAPM_OUTPUT("DSP Voice Trigger"),
365
366SND_SOC_DAPM_SWITCH("DSP3 Voice Trigger", SND_SOC_NOPM, 2, 0,
367 &arizona_voice_trigger_switch[2]),
368
6610550c
RF
369SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
370 0, NULL, 0, arizona_in_ev,
371 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
372 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
373SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
374 0, NULL, 0, arizona_in_ev,
375 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
376 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
377SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
378 0, NULL, 0, arizona_in_ev,
379 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
380 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
381SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
382 0, NULL, 0, arizona_in_ev,
383 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
384 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
385
386SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
387 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
388SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
389 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
390
391SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
392 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
393
394SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
395 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
396SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1,
397 ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0),
398
399SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0),
400SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0),
401
402SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0,
403 NULL, 0),
404SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0,
405 NULL, 0),
406SND_SOC_DAPM_PGA("DRC2L", ARIZONA_DRC2_CTRL1, ARIZONA_DRC2L_ENA_SHIFT, 0,
407 NULL, 0),
408SND_SOC_DAPM_PGA("DRC2R", ARIZONA_DRC2_CTRL1, ARIZONA_DRC2R_ENA_SHIFT, 0,
409 NULL, 0),
410
411SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0,
412 NULL, 0),
413SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0,
414 NULL, 0),
415SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0,
416 NULL, 0),
417SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0,
418 NULL, 0),
419
420SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT,
421 0, NULL, 0),
422SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT,
423 0, NULL, 0),
424
425SND_SOC_DAPM_PGA("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0,
426 NULL, 0),
427SND_SOC_DAPM_PGA("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0,
428 NULL, 0),
429SND_SOC_DAPM_PGA("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0,
430 NULL, 0),
431SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0,
432 NULL, 0),
433
d82d767f
CK
434WM_ADSP2("DSP2", 1, cs47l24_adsp_power_ev),
435WM_ADSP2("DSP3", 2, cs47l24_adsp_power_ev),
6610550c
RF
436
437SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3,
438 ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0),
439SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3,
440 ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0),
441SND_SOC_DAPM_PGA("ISRC1INT3", ARIZONA_ISRC_1_CTRL_3,
442 ARIZONA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0),
443SND_SOC_DAPM_PGA("ISRC1INT4", ARIZONA_ISRC_1_CTRL_3,
444 ARIZONA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0),
445
446SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3,
447 ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0),
448SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3,
449 ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0),
450SND_SOC_DAPM_PGA("ISRC1DEC3", ARIZONA_ISRC_1_CTRL_3,
451 ARIZONA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0),
452SND_SOC_DAPM_PGA("ISRC1DEC4", ARIZONA_ISRC_1_CTRL_3,
453 ARIZONA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0),
454
455SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3,
456 ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0),
457SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3,
458 ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0),
459SND_SOC_DAPM_PGA("ISRC2INT3", ARIZONA_ISRC_2_CTRL_3,
460 ARIZONA_ISRC2_INT2_ENA_SHIFT, 0, NULL, 0),
461SND_SOC_DAPM_PGA("ISRC2INT4", ARIZONA_ISRC_2_CTRL_3,
462 ARIZONA_ISRC2_INT3_ENA_SHIFT, 0, NULL, 0),
463
464SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3,
465 ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0),
466SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3,
467 ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0),
468SND_SOC_DAPM_PGA("ISRC2DEC3", ARIZONA_ISRC_2_CTRL_3,
469 ARIZONA_ISRC2_DEC2_ENA_SHIFT, 0, NULL, 0),
470SND_SOC_DAPM_PGA("ISRC2DEC4", ARIZONA_ISRC_2_CTRL_3,
471 ARIZONA_ISRC2_DEC3_ENA_SHIFT, 0, NULL, 0),
472
473SND_SOC_DAPM_PGA("ISRC3INT1", ARIZONA_ISRC_3_CTRL_3,
474 ARIZONA_ISRC3_INT0_ENA_SHIFT, 0, NULL, 0),
475SND_SOC_DAPM_PGA("ISRC3INT2", ARIZONA_ISRC_3_CTRL_3,
476 ARIZONA_ISRC3_INT1_ENA_SHIFT, 0, NULL, 0),
477SND_SOC_DAPM_PGA("ISRC3INT3", ARIZONA_ISRC_3_CTRL_3,
478 ARIZONA_ISRC3_INT2_ENA_SHIFT, 0, NULL, 0),
479SND_SOC_DAPM_PGA("ISRC3INT4", ARIZONA_ISRC_3_CTRL_3,
480 ARIZONA_ISRC3_INT3_ENA_SHIFT, 0, NULL, 0),
481
482SND_SOC_DAPM_PGA("ISRC3DEC1", ARIZONA_ISRC_3_CTRL_3,
483 ARIZONA_ISRC3_DEC0_ENA_SHIFT, 0, NULL, 0),
484SND_SOC_DAPM_PGA("ISRC3DEC2", ARIZONA_ISRC_3_CTRL_3,
485 ARIZONA_ISRC3_DEC1_ENA_SHIFT, 0, NULL, 0),
486SND_SOC_DAPM_PGA("ISRC3DEC3", ARIZONA_ISRC_3_CTRL_3,
487 ARIZONA_ISRC3_DEC2_ENA_SHIFT, 0, NULL, 0),
488SND_SOC_DAPM_PGA("ISRC3DEC4", ARIZONA_ISRC_3_CTRL_3,
489 ARIZONA_ISRC3_DEC3_ENA_SHIFT, 0, NULL, 0),
490
491SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
492 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0,
493 &cs47l24_aec_loopback_mux),
494
495SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
496 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
497SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0,
498 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0),
499SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0,
500 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0),
501SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0,
502 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0),
503SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0,
504 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0),
505SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0,
506 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0),
507SND_SOC_DAPM_AIF_OUT("AIF1TX7", NULL, 0,
508 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX7_ENA_SHIFT, 0),
509SND_SOC_DAPM_AIF_OUT("AIF1TX8", NULL, 0,
510 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX8_ENA_SHIFT, 0),
511
512SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
513 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0),
514SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0,
515 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0),
516SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0,
517 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0),
518SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0,
519 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0),
520SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0,
521 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0),
522SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0,
523 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0),
524SND_SOC_DAPM_AIF_IN("AIF1RX7", NULL, 0,
525 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX7_ENA_SHIFT, 0),
526SND_SOC_DAPM_AIF_IN("AIF1RX8", NULL, 0,
527 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX8_ENA_SHIFT, 0),
528
529SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
530 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0),
531SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0,
532 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0),
533SND_SOC_DAPM_AIF_OUT("AIF2TX3", NULL, 0,
534 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX3_ENA_SHIFT, 0),
535SND_SOC_DAPM_AIF_OUT("AIF2TX4", NULL, 0,
536 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX4_ENA_SHIFT, 0),
537SND_SOC_DAPM_AIF_OUT("AIF2TX5", NULL, 0,
538 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX5_ENA_SHIFT, 0),
539SND_SOC_DAPM_AIF_OUT("AIF2TX6", NULL, 0,
540 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX6_ENA_SHIFT, 0),
541
542SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
543 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0),
544SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0,
545 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0),
546SND_SOC_DAPM_AIF_IN("AIF2RX3", NULL, 0,
547 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX3_ENA_SHIFT, 0),
548SND_SOC_DAPM_AIF_IN("AIF2RX4", NULL, 0,
549 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX4_ENA_SHIFT, 0),
550SND_SOC_DAPM_AIF_IN("AIF2RX5", NULL, 0,
551 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX5_ENA_SHIFT, 0),
552SND_SOC_DAPM_AIF_IN("AIF2RX6", NULL, 0,
553 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX6_ENA_SHIFT, 0),
554
555SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0,
556 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0),
557SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0,
558 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0),
559
560SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
561 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0),
562SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
563 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
564
565SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
566 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
567 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
568 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
569SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
570 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
571 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
572 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
573
574ARIZONA_MIXER_WIDGETS(EQ1, "EQ1"),
575ARIZONA_MIXER_WIDGETS(EQ2, "EQ2"),
576
577ARIZONA_MIXER_WIDGETS(DRC1L, "DRC1L"),
578ARIZONA_MIXER_WIDGETS(DRC1R, "DRC1R"),
579ARIZONA_MIXER_WIDGETS(DRC2L, "DRC2L"),
580ARIZONA_MIXER_WIDGETS(DRC2R, "DRC2R"),
581
582ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"),
583ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"),
584ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"),
585ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"),
586
587ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"),
588ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"),
589
590ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
591ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
592ARIZONA_MIXER_WIDGETS(SPKOUT, "SPKOUT"),
593
594ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
595ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
596ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
597ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
598ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
599ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
600ARIZONA_MIXER_WIDGETS(AIF1TX7, "AIF1TX7"),
601ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"),
602
603ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
604ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
605ARIZONA_MIXER_WIDGETS(AIF2TX3, "AIF2TX3"),
606ARIZONA_MIXER_WIDGETS(AIF2TX4, "AIF2TX4"),
607ARIZONA_MIXER_WIDGETS(AIF2TX5, "AIF2TX5"),
608ARIZONA_MIXER_WIDGETS(AIF2TX6, "AIF2TX6"),
609
610ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
611ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
612
613ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"),
614ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"),
615ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"),
616ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"),
617
618ARIZONA_DSP_WIDGETS(DSP2, "DSP2"),
619ARIZONA_DSP_WIDGETS(DSP3, "DSP3"),
620
621ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"),
622ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"),
623ARIZONA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"),
624ARIZONA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"),
625
626ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"),
627ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"),
628ARIZONA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"),
629ARIZONA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"),
630
631ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"),
632ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"),
633ARIZONA_MUX_WIDGETS(ISRC2DEC3, "ISRC2DEC3"),
634ARIZONA_MUX_WIDGETS(ISRC2DEC4, "ISRC2DEC4"),
635
636ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"),
637ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"),
638ARIZONA_MUX_WIDGETS(ISRC2INT3, "ISRC2INT3"),
639ARIZONA_MUX_WIDGETS(ISRC2INT4, "ISRC2INT4"),
640
641ARIZONA_MUX_WIDGETS(ISRC3DEC1, "ISRC3DEC1"),
642ARIZONA_MUX_WIDGETS(ISRC3DEC2, "ISRC3DEC2"),
643ARIZONA_MUX_WIDGETS(ISRC3DEC3, "ISRC3DEC3"),
644ARIZONA_MUX_WIDGETS(ISRC3DEC4, "ISRC3DEC4"),
645
646ARIZONA_MUX_WIDGETS(ISRC3INT1, "ISRC3INT1"),
647ARIZONA_MUX_WIDGETS(ISRC3INT2, "ISRC3INT2"),
648ARIZONA_MUX_WIDGETS(ISRC3INT3, "ISRC3INT3"),
649ARIZONA_MUX_WIDGETS(ISRC3INT4, "ISRC3INT4"),
650
651SND_SOC_DAPM_OUTPUT("HPOUT1L"),
652SND_SOC_DAPM_OUTPUT("HPOUT1R"),
653SND_SOC_DAPM_OUTPUT("SPKOUTN"),
654SND_SOC_DAPM_OUTPUT("SPKOUTP"),
655
656SND_SOC_DAPM_OUTPUT("MICSUPP"),
657};
658
659#define ARIZONA_MIXER_INPUT_ROUTES(name) \
660 { name, "Noise Generator", "Noise Generator" }, \
661 { name, "Tone Generator 1", "Tone Generator 1" }, \
662 { name, "Tone Generator 2", "Tone Generator 2" }, \
663 { name, "Haptics", "HAPTICS" }, \
664 { name, "AEC", "AEC Loopback" }, \
665 { name, "IN1L", "IN1L PGA" }, \
666 { name, "IN1R", "IN1R PGA" }, \
667 { name, "IN2L", "IN2L PGA" }, \
668 { name, "IN2R", "IN2R PGA" }, \
669 { name, "AIF1RX1", "AIF1RX1" }, \
670 { name, "AIF1RX2", "AIF1RX2" }, \
671 { name, "AIF1RX3", "AIF1RX3" }, \
672 { name, "AIF1RX4", "AIF1RX4" }, \
673 { name, "AIF1RX5", "AIF1RX5" }, \
674 { name, "AIF1RX6", "AIF1RX6" }, \
675 { name, "AIF1RX7", "AIF1RX7" }, \
676 { name, "AIF1RX8", "AIF1RX8" }, \
677 { name, "AIF2RX1", "AIF2RX1" }, \
678 { name, "AIF2RX2", "AIF2RX2" }, \
679 { name, "AIF2RX3", "AIF2RX3" }, \
680 { name, "AIF2RX4", "AIF2RX4" }, \
681 { name, "AIF2RX5", "AIF2RX5" }, \
682 { name, "AIF2RX6", "AIF2RX6" }, \
683 { name, "AIF3RX1", "AIF3RX1" }, \
684 { name, "AIF3RX2", "AIF3RX2" }, \
685 { name, "EQ1", "EQ1" }, \
686 { name, "EQ2", "EQ2" }, \
687 { name, "DRC1L", "DRC1L" }, \
688 { name, "DRC1R", "DRC1R" }, \
689 { name, "DRC2L", "DRC2L" }, \
690 { name, "DRC2R", "DRC2R" }, \
691 { name, "LHPF1", "LHPF1" }, \
692 { name, "LHPF2", "LHPF2" }, \
693 { name, "LHPF3", "LHPF3" }, \
694 { name, "LHPF4", "LHPF4" }, \
695 { name, "ASRC1L", "ASRC1L" }, \
696 { name, "ASRC1R", "ASRC1R" }, \
697 { name, "ASRC2L", "ASRC2L" }, \
698 { name, "ASRC2R", "ASRC2R" }, \
699 { name, "ISRC1DEC1", "ISRC1DEC1" }, \
700 { name, "ISRC1DEC2", "ISRC1DEC2" }, \
701 { name, "ISRC1DEC3", "ISRC1DEC3" }, \
702 { name, "ISRC1DEC4", "ISRC1DEC4" }, \
703 { name, "ISRC1INT1", "ISRC1INT1" }, \
704 { name, "ISRC1INT2", "ISRC1INT2" }, \
705 { name, "ISRC1INT3", "ISRC1INT3" }, \
706 { name, "ISRC1INT4", "ISRC1INT4" }, \
707 { name, "ISRC2DEC1", "ISRC2DEC1" }, \
708 { name, "ISRC2DEC2", "ISRC2DEC2" }, \
709 { name, "ISRC2DEC3", "ISRC2DEC3" }, \
710 { name, "ISRC2DEC4", "ISRC2DEC4" }, \
711 { name, "ISRC2INT1", "ISRC2INT1" }, \
712 { name, "ISRC2INT2", "ISRC2INT2" }, \
713 { name, "ISRC2INT3", "ISRC2INT3" }, \
714 { name, "ISRC2INT4", "ISRC2INT4" }, \
715 { name, "ISRC3DEC1", "ISRC3DEC1" }, \
716 { name, "ISRC3DEC2", "ISRC3DEC2" }, \
717 { name, "ISRC3DEC3", "ISRC3DEC3" }, \
718 { name, "ISRC3DEC4", "ISRC3DEC4" }, \
719 { name, "ISRC3INT1", "ISRC3INT1" }, \
720 { name, "ISRC3INT2", "ISRC3INT2" }, \
721 { name, "ISRC3INT3", "ISRC3INT3" }, \
722 { name, "ISRC3INT4", "ISRC3INT4" }, \
723 { name, "DSP2.1", "DSP2" }, \
724 { name, "DSP2.2", "DSP2" }, \
725 { name, "DSP2.3", "DSP2" }, \
726 { name, "DSP2.4", "DSP2" }, \
727 { name, "DSP2.5", "DSP2" }, \
728 { name, "DSP2.6", "DSP2" }, \
729 { name, "DSP3.1", "DSP3" }, \
730 { name, "DSP3.2", "DSP3" }, \
731 { name, "DSP3.3", "DSP3" }, \
732 { name, "DSP3.4", "DSP3" }, \
733 { name, "DSP3.5", "DSP3" }, \
734 { name, "DSP3.6", "DSP3" }
735
736static const struct snd_soc_dapm_route cs47l24_dapm_routes[] = {
737 { "OUT1L", NULL, "CPVDD" },
738 { "OUT1R", NULL, "CPVDD" },
739
740 { "OUT4L", NULL, "SPKVDD" },
741
742 { "OUT1L", NULL, "SYSCLK" },
743 { "OUT1R", NULL, "SYSCLK" },
744 { "OUT4L", NULL, "SYSCLK" },
745
746 { "IN1L", NULL, "SYSCLK" },
747 { "IN1R", NULL, "SYSCLK" },
748 { "IN2L", NULL, "SYSCLK" },
749 { "IN2R", NULL, "SYSCLK" },
750
19c89192
CK
751 { "ASRC1L", NULL, "SYSCLK" },
752 { "ASRC1R", NULL, "SYSCLK" },
753 { "ASRC2L", NULL, "SYSCLK" },
754 { "ASRC2R", NULL, "SYSCLK" },
755
756 { "ASRC1L", NULL, "ASYNCCLK" },
757 { "ASRC1R", NULL, "ASYNCCLK" },
758 { "ASRC2L", NULL, "ASYNCCLK" },
759 { "ASRC2R", NULL, "ASYNCCLK" },
760
6610550c
RF
761 { "MICBIAS1", NULL, "MICVDD" },
762 { "MICBIAS2", NULL, "MICVDD" },
763
764 { "Noise Generator", NULL, "SYSCLK" },
765 { "Tone Generator 1", NULL, "SYSCLK" },
766 { "Tone Generator 2", NULL, "SYSCLK" },
767
768 { "Noise Generator", NULL, "NOISE" },
769 { "Tone Generator 1", NULL, "TONE" },
770 { "Tone Generator 2", NULL, "TONE" },
771
772 { "AIF1 Capture", NULL, "AIF1TX1" },
773 { "AIF1 Capture", NULL, "AIF1TX2" },
774 { "AIF1 Capture", NULL, "AIF1TX3" },
775 { "AIF1 Capture", NULL, "AIF1TX4" },
776 { "AIF1 Capture", NULL, "AIF1TX5" },
777 { "AIF1 Capture", NULL, "AIF1TX6" },
778 { "AIF1 Capture", NULL, "AIF1TX7" },
779 { "AIF1 Capture", NULL, "AIF1TX8" },
780
781 { "AIF1RX1", NULL, "AIF1 Playback" },
782 { "AIF1RX2", NULL, "AIF1 Playback" },
783 { "AIF1RX3", NULL, "AIF1 Playback" },
784 { "AIF1RX4", NULL, "AIF1 Playback" },
785 { "AIF1RX5", NULL, "AIF1 Playback" },
786 { "AIF1RX6", NULL, "AIF1 Playback" },
787 { "AIF1RX7", NULL, "AIF1 Playback" },
788 { "AIF1RX8", NULL, "AIF1 Playback" },
789
790 { "AIF2 Capture", NULL, "AIF2TX1" },
791 { "AIF2 Capture", NULL, "AIF2TX2" },
792 { "AIF2 Capture", NULL, "AIF2TX3" },
793 { "AIF2 Capture", NULL, "AIF2TX4" },
794 { "AIF2 Capture", NULL, "AIF2TX5" },
795 { "AIF2 Capture", NULL, "AIF2TX6" },
796
797 { "AIF2RX1", NULL, "AIF2 Playback" },
798 { "AIF2RX2", NULL, "AIF2 Playback" },
799 { "AIF2RX3", NULL, "AIF2 Playback" },
800 { "AIF2RX4", NULL, "AIF2 Playback" },
801 { "AIF2RX5", NULL, "AIF2 Playback" },
802 { "AIF2RX6", NULL, "AIF2 Playback" },
803
804 { "AIF3 Capture", NULL, "AIF3TX1" },
805 { "AIF3 Capture", NULL, "AIF3TX2" },
806
807 { "AIF3RX1", NULL, "AIF3 Playback" },
808 { "AIF3RX2", NULL, "AIF3 Playback" },
809
810 { "AIF1 Playback", NULL, "SYSCLK" },
811 { "AIF2 Playback", NULL, "SYSCLK" },
812 { "AIF3 Playback", NULL, "SYSCLK" },
813
814 { "AIF1 Capture", NULL, "SYSCLK" },
815 { "AIF2 Capture", NULL, "SYSCLK" },
816 { "AIF3 Capture", NULL, "SYSCLK" },
817
7eec55d7 818 { "Voice Control DSP", NULL, "DSP3" },
7eec55d7 819
6610550c
RF
820 { "IN1L PGA", NULL, "IN1L" },
821 { "IN1R PGA", NULL, "IN1R" },
822
823 { "IN2L PGA", NULL, "IN2L" },
824 { "IN2R PGA", NULL, "IN2R" },
825
c13202f7 826 { "Audio Trace DSP", NULL, "DSP2" },
c13202f7 827
6610550c
RF
828 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
829 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
830
831 ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUT"),
832
833 ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
834 ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
835
836 ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
837 ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
838 ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
839 ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
840 ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
841 ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
842 ARIZONA_MIXER_ROUTES("AIF1TX7", "AIF1TX7"),
843 ARIZONA_MIXER_ROUTES("AIF1TX8", "AIF1TX8"),
844
845 ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
846 ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
847 ARIZONA_MIXER_ROUTES("AIF2TX3", "AIF2TX3"),
848 ARIZONA_MIXER_ROUTES("AIF2TX4", "AIF2TX4"),
849 ARIZONA_MIXER_ROUTES("AIF2TX5", "AIF2TX5"),
850 ARIZONA_MIXER_ROUTES("AIF2TX6", "AIF2TX6"),
851
852 ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
853 ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
854
855 ARIZONA_MIXER_ROUTES("EQ1", "EQ1"),
856 ARIZONA_MIXER_ROUTES("EQ2", "EQ2"),
857
858 ARIZONA_MIXER_ROUTES("DRC1L", "DRC1L"),
859 ARIZONA_MIXER_ROUTES("DRC1R", "DRC1R"),
860 ARIZONA_MIXER_ROUTES("DRC2L", "DRC2L"),
861 ARIZONA_MIXER_ROUTES("DRC2R", "DRC2R"),
862
863 ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"),
864 ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"),
865 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
866 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
867
868 ARIZONA_MUX_ROUTES("ASRC1L", "ASRC1L"),
869 ARIZONA_MUX_ROUTES("ASRC1R", "ASRC1R"),
870 ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"),
871 ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"),
872
873 ARIZONA_DSP_ROUTES("DSP2"),
874 ARIZONA_DSP_ROUTES("DSP3"),
875
876 ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"),
877 ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"),
878 ARIZONA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"),
879 ARIZONA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"),
880
881 ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"),
882 ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"),
883 ARIZONA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"),
884 ARIZONA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"),
885
886 ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"),
887 ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"),
888 ARIZONA_MUX_ROUTES("ISRC2INT3", "ISRC2INT3"),
889 ARIZONA_MUX_ROUTES("ISRC2INT4", "ISRC2INT4"),
890
891 ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"),
892 ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"),
893 ARIZONA_MUX_ROUTES("ISRC2DEC3", "ISRC2DEC3"),
894 ARIZONA_MUX_ROUTES("ISRC2DEC4", "ISRC2DEC4"),
895
896 ARIZONA_MUX_ROUTES("ISRC3INT1", "ISRC3INT1"),
897 ARIZONA_MUX_ROUTES("ISRC3INT2", "ISRC3INT2"),
898 ARIZONA_MUX_ROUTES("ISRC3INT3", "ISRC3INT3"),
899 ARIZONA_MUX_ROUTES("ISRC3INT4", "ISRC3INT4"),
900
901 ARIZONA_MUX_ROUTES("ISRC3DEC1", "ISRC3DEC1"),
902 ARIZONA_MUX_ROUTES("ISRC3DEC2", "ISRC3DEC2"),
903 ARIZONA_MUX_ROUTES("ISRC3DEC3", "ISRC3DEC3"),
904 ARIZONA_MUX_ROUTES("ISRC3DEC4", "ISRC3DEC4"),
905
906 { "AEC Loopback", "HPOUT1L", "OUT1L" },
907 { "AEC Loopback", "HPOUT1R", "OUT1R" },
908 { "HPOUT1L", NULL, "OUT1L" },
909 { "HPOUT1R", NULL, "OUT1R" },
910
911 { "AEC Loopback", "SPKOUT", "OUT4L" },
912 { "SPKOUTN", NULL, "OUT4L" },
913 { "SPKOUTP", NULL, "OUT4L" },
914
915 { "MICSUPP", NULL, "SYSCLK" },
916
9fc772ec
CK
917 { "DRC1 Signal Activity", NULL, "SYSCLK" },
918 { "DRC2 Signal Activity", NULL, "SYSCLK" },
6610550c
RF
919 { "DRC1 Signal Activity", NULL, "DRC1L" },
920 { "DRC1 Signal Activity", NULL, "DRC1R" },
921 { "DRC2 Signal Activity", NULL, "DRC2L" },
922 { "DRC2 Signal Activity", NULL, "DRC2R" },
97126ce8
CK
923
924 { "DSP Voice Trigger", NULL, "SYSCLK" },
925 { "DSP Voice Trigger", NULL, "DSP3 Voice Trigger" },
926 { "DSP3 Voice Trigger", "Switch", "DSP3" },
6610550c
RF
927};
928
929static int cs47l24_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
930 unsigned int Fref, unsigned int Fout)
931{
932 struct cs47l24_priv *cs47l24 = snd_soc_codec_get_drvdata(codec);
933
934 switch (fll_id) {
935 case CS47L24_FLL1:
936 return arizona_set_fll(&cs47l24->fll[0], source, Fref, Fout);
937 case CS47L24_FLL2:
938 return arizona_set_fll(&cs47l24->fll[1], source, Fref, Fout);
939 case CS47L24_FLL1_REFCLK:
940 return arizona_set_fll_refclk(&cs47l24->fll[0], source, Fref,
941 Fout);
942 case CS47L24_FLL2_REFCLK:
943 return arizona_set_fll_refclk(&cs47l24->fll[1], source, Fref,
944 Fout);
945 default:
946 return -EINVAL;
947 }
948}
949
d81221ff 950#define CS47L24_RATES SNDRV_PCM_RATE_KNOT
6610550c
RF
951
952#define CS47L24_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
953 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
954
955static struct snd_soc_dai_driver cs47l24_dai[] = {
956 {
957 .name = "cs47l24-aif1",
958 .id = 1,
959 .base = ARIZONA_AIF1_BCLK_CTRL,
960 .playback = {
961 .stream_name = "AIF1 Playback",
962 .channels_min = 1,
963 .channels_max = 8,
964 .rates = CS47L24_RATES,
965 .formats = CS47L24_FORMATS,
966 },
967 .capture = {
968 .stream_name = "AIF1 Capture",
969 .channels_min = 1,
970 .channels_max = 8,
971 .rates = CS47L24_RATES,
972 .formats = CS47L24_FORMATS,
973 },
974 .ops = &arizona_dai_ops,
975 .symmetric_rates = 1,
976 .symmetric_samplebits = 1,
977 },
978 {
979 .name = "cs47l24-aif2",
980 .id = 2,
981 .base = ARIZONA_AIF2_BCLK_CTRL,
982 .playback = {
983 .stream_name = "AIF2 Playback",
984 .channels_min = 1,
985 .channels_max = 6,
986 .rates = CS47L24_RATES,
987 .formats = CS47L24_FORMATS,
988 },
989 .capture = {
990 .stream_name = "AIF2 Capture",
991 .channels_min = 1,
992 .channels_max = 6,
993 .rates = CS47L24_RATES,
994 .formats = CS47L24_FORMATS,
995 },
996 .ops = &arizona_dai_ops,
997 .symmetric_rates = 1,
998 .symmetric_samplebits = 1,
999 },
1000 {
1001 .name = "cs47l24-aif3",
1002 .id = 3,
1003 .base = ARIZONA_AIF3_BCLK_CTRL,
1004 .playback = {
1005 .stream_name = "AIF3 Playback",
1006 .channels_min = 1,
1007 .channels_max = 2,
1008 .rates = CS47L24_RATES,
1009 .formats = CS47L24_FORMATS,
1010 },
1011 .capture = {
1012 .stream_name = "AIF3 Capture",
1013 .channels_min = 1,
1014 .channels_max = 2,
1015 .rates = CS47L24_RATES,
1016 .formats = CS47L24_FORMATS,
1017 },
1018 .ops = &arizona_dai_ops,
1019 .symmetric_rates = 1,
1020 .symmetric_samplebits = 1,
1021 },
7eec55d7
RF
1022 {
1023 .name = "cs47l24-cpu-voicectrl",
1024 .capture = {
1025 .stream_name = "Voice Control CPU",
1026 .channels_min = 1,
1027 .channels_max = 1,
1028 .rates = CS47L24_RATES,
1029 .formats = CS47L24_FORMATS,
1030 },
1031 .compress_new = snd_soc_new_compress,
1032 },
1033 {
1034 .name = "cs47l24-dsp-voicectrl",
1035 .capture = {
1036 .stream_name = "Voice Control DSP",
1037 .channels_min = 1,
1038 .channels_max = 1,
1039 .rates = CS47L24_RATES,
1040 .formats = CS47L24_FORMATS,
1041 },
1042 },
c13202f7
CK
1043 {
1044 .name = "cs47l24-cpu-trace",
1045 .capture = {
1046 .stream_name = "Audio Trace CPU",
1047 .channels_min = 1,
1048 .channels_max = 6,
1049 .rates = CS47L24_RATES,
1050 .formats = CS47L24_FORMATS,
1051 },
1052 .compress_new = snd_soc_new_compress,
1053 },
1054 {
1055 .name = "cs47l24-dsp-trace",
1056 .capture = {
1057 .stream_name = "Audio Trace DSP",
1058 .channels_min = 1,
1059 .channels_max = 6,
1060 .rates = CS47L24_RATES,
1061 .formats = CS47L24_FORMATS,
1062 },
1063 },
6610550c
RF
1064};
1065
7eec55d7
RF
1066static int cs47l24_open(struct snd_compr_stream *stream)
1067{
1068 struct snd_soc_pcm_runtime *rtd = stream->private_data;
1095e281 1069 struct cs47l24_priv *priv = snd_soc_platform_get_drvdata(rtd->platform);
7eec55d7
RF
1070 struct arizona *arizona = priv->core.arizona;
1071 int n_adsp;
1072
1073 if (strcmp(rtd->codec_dai->name, "cs47l24-dsp-voicectrl") == 0) {
1074 n_adsp = 2;
c13202f7
CK
1075 } else if (strcmp(rtd->codec_dai->name, "cs47l24-dsp-trace") == 0) {
1076 n_adsp = 1;
7eec55d7
RF
1077 } else {
1078 dev_err(arizona->dev,
1079 "No suitable compressed stream for DAI '%s'\n",
1080 rtd->codec_dai->name);
1081 return -EINVAL;
1082 }
1083
1084 return wm_adsp_compr_open(&priv->core.adsp[n_adsp], stream);
1085}
1086
1087static irqreturn_t cs47l24_adsp2_irq(int irq, void *data)
1088{
1089 struct cs47l24_priv *priv = data;
1090 struct arizona *arizona = priv->core.arizona;
546ad3d0 1091 struct arizona_voice_trigger_info info;
c13202f7
CK
1092 int serviced = 0;
1093 int i, ret;
7eec55d7 1094
c13202f7
CK
1095 for (i = 1; i <= 2; ++i) {
1096 ret = wm_adsp_compr_handle_irq(&priv->core.adsp[i]);
1097 if (ret != -ENODEV)
1098 serviced++;
546ad3d0
CK
1099 if (ret == WM_ADSP_COMPR_VOICE_TRIGGER) {
1100 info.core = i;
7baa7e24
CK
1101 arizona_call_notifiers(arizona,
1102 ARIZONA_NOTIFY_VOICE_TRIGGER,
546ad3d0
CK
1103 &info);
1104 }
c13202f7 1105 }
7eec55d7 1106
c13202f7 1107 if (!serviced) {
7eec55d7
RF
1108 dev_err(arizona->dev, "Spurious compressed data IRQ\n");
1109 return IRQ_NONE;
1110 }
1111
1112 return IRQ_HANDLED;
1113}
1114
6610550c
RF
1115static int cs47l24_codec_probe(struct snd_soc_codec *codec)
1116{
1117 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
35f4403e 1118 struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
6610550c
RF
1119 struct cs47l24_priv *priv = snd_soc_codec_get_drvdata(codec);
1120 int ret;
1121
1122 priv->core.arizona->dapm = dapm;
1123
1124 arizona_init_spk(codec);
1125 arizona_init_gpio(codec);
1126 arizona_init_mono(codec);
2230c49f 1127 arizona_init_notifiers(codec);
6610550c
RF
1128
1129 ret = wm_adsp2_codec_probe(&priv->core.adsp[1], codec);
1130 if (ret)
1131 goto err_adsp2_codec_probe;
1132
1133 ret = wm_adsp2_codec_probe(&priv->core.adsp[2], codec);
1134 if (ret)
1135 goto err_adsp2_codec_probe;
1136
1137 ret = snd_soc_add_codec_controls(codec,
1138 &arizona_adsp2_rate_controls[1], 2);
1139 if (ret)
1140 goto err_adsp2_codec_probe;
1141
35f4403e 1142 snd_soc_component_disable_pin(component, "HAPTICS");
6610550c
RF
1143
1144 return 0;
1145
1146err_adsp2_codec_probe:
1147 wm_adsp2_codec_remove(&priv->core.adsp[1], codec);
1148 wm_adsp2_codec_remove(&priv->core.adsp[2], codec);
1149
1150 return ret;
1151}
1152
1153static int cs47l24_codec_remove(struct snd_soc_codec *codec)
1154{
1155 struct cs47l24_priv *priv = snd_soc_codec_get_drvdata(codec);
6610550c
RF
1156
1157 wm_adsp2_codec_remove(&priv->core.adsp[1], codec);
1158 wm_adsp2_codec_remove(&priv->core.adsp[2], codec);
1159
1160 priv->core.arizona->dapm = NULL;
1161
1162 return 0;
1163}
1164
1165#define CS47L24_DIG_VU 0x0200
1166
1167static unsigned int cs47l24_digital_vu[] = {
1168 ARIZONA_DAC_DIGITAL_VOLUME_1L,
1169 ARIZONA_DAC_DIGITAL_VOLUME_1R,
1170 ARIZONA_DAC_DIGITAL_VOLUME_4L,
1171};
1172
1173static struct regmap *cs47l24_get_regmap(struct device *dev)
1174{
1175 struct cs47l24_priv *priv = dev_get_drvdata(dev);
1176
1177 return priv->core.arizona->regmap;
1178}
1179
1180static struct snd_soc_codec_driver soc_codec_dev_cs47l24 = {
1181 .probe = cs47l24_codec_probe,
1182 .remove = cs47l24_codec_remove,
1183 .get_regmap = cs47l24_get_regmap,
1184
1185 .idle_bias_off = true,
1186
1187 .set_sysclk = arizona_set_sysclk,
1188 .set_pll = cs47l24_set_fll,
1189
295f0815
KM
1190 .component_driver = {
1191 .controls = cs47l24_snd_controls,
1192 .num_controls = ARRAY_SIZE(cs47l24_snd_controls),
1193 .dapm_widgets = cs47l24_dapm_widgets,
1194 .num_dapm_widgets = ARRAY_SIZE(cs47l24_dapm_widgets),
1195 .dapm_routes = cs47l24_dapm_routes,
1196 .num_dapm_routes = ARRAY_SIZE(cs47l24_dapm_routes),
1197 },
6610550c
RF
1198};
1199
7eec55d7
RF
1200static struct snd_compr_ops cs47l24_compr_ops = {
1201 .open = cs47l24_open,
1202 .free = wm_adsp_compr_free,
1203 .set_params = wm_adsp_compr_set_params,
1204 .get_caps = wm_adsp_compr_get_caps,
1205 .trigger = wm_adsp_compr_trigger,
1206 .pointer = wm_adsp_compr_pointer,
1207 .copy = wm_adsp_compr_copy,
1208};
1209
1210static struct snd_soc_platform_driver cs47l24_compr_platform = {
1211 .compr_ops = &cs47l24_compr_ops,
1212};
9abe3dc7 1213
6610550c
RF
1214static int cs47l24_probe(struct platform_device *pdev)
1215{
1216 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
1217 struct cs47l24_priv *cs47l24;
1218 int i, ret;
1219
1220 BUILD_BUG_ON(ARRAY_SIZE(cs47l24_dai) > ARIZONA_MAX_DAI);
1221
1222 cs47l24 = devm_kzalloc(&pdev->dev, sizeof(struct cs47l24_priv),
1223 GFP_KERNEL);
1224 if (!cs47l24)
1225 return -ENOMEM;
1226
1227 platform_set_drvdata(pdev, cs47l24);
1228
1229 cs47l24->core.arizona = arizona;
1230 cs47l24->core.num_inputs = 4;
1231
1232 for (i = 1; i <= 2; i++) {
1233 cs47l24->core.adsp[i].part = "cs47l24";
1234 cs47l24->core.adsp[i].num = i + 1;
1235 cs47l24->core.adsp[i].type = WMFW_ADSP2;
1236 cs47l24->core.adsp[i].dev = arizona->dev;
1237 cs47l24->core.adsp[i].regmap = arizona->regmap;
1238
1239 cs47l24->core.adsp[i].base = ARIZONA_DSP1_CONTROL_1 +
1240 (0x100 * i);
1241 cs47l24->core.adsp[i].mem = cs47l24_dsp_regions[i - 1];
1242 cs47l24->core.adsp[i].num_mems =
1243 ARRAY_SIZE(cs47l24_dsp2_regions);
1244
1245 ret = wm_adsp2_init(&cs47l24->core.adsp[i]);
1246 if (ret != 0)
1247 return ret;
1248 }
1249
1250 for (i = 0; i < ARRAY_SIZE(cs47l24->fll); i++)
1251 cs47l24->fll[i].vco_mult = 3;
1252
1253 arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1,
1254 ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK,
1255 &cs47l24->fll[0]);
1256 arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1,
1257 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
1258 &cs47l24->fll[1]);
1259
1260 /* SR2 fixed at 8kHz, SR3 fixed at 16kHz */
1261 regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_2,
1262 ARIZONA_SAMPLE_RATE_2_MASK, 0x11);
1263 regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_3,
1264 ARIZONA_SAMPLE_RATE_3_MASK, 0x12);
1265
1266 for (i = 0; i < ARRAY_SIZE(cs47l24_dai); i++)
1267 arizona_init_dai(&cs47l24->core, i);
1268
1269 /* Latch volume update bits */
1270 for (i = 0; i < ARRAY_SIZE(cs47l24_digital_vu); i++)
1271 regmap_update_bits(arizona->regmap, cs47l24_digital_vu[i],
1272 CS47L24_DIG_VU, CS47L24_DIG_VU);
1273
1274 pm_runtime_enable(&pdev->dev);
1275 pm_runtime_idle(&pdev->dev);
1276
0809492e
CK
1277 ret = arizona_request_irq(arizona, ARIZONA_IRQ_DSP_IRQ1,
1278 "ADSP2 Compressed IRQ", cs47l24_adsp2_irq,
1279 cs47l24);
1280 if (ret != 0) {
1281 dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret);
1282 return ret;
1283 }
1284
31833ead
CK
1285 ret = arizona_init_spk_irqs(arizona);
1286 if (ret < 0)
0809492e 1287 goto err_dsp_irq;
31833ead 1288
7eec55d7
RF
1289 ret = snd_soc_register_platform(&pdev->dev, &cs47l24_compr_platform);
1290 if (ret < 0) {
1291 dev_err(&pdev->dev, "Failed to register platform: %d\n", ret);
31833ead 1292 goto err_spk_irqs;
7eec55d7 1293 }
9abe3dc7 1294
7eec55d7 1295 ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cs47l24,
6610550c 1296 cs47l24_dai, ARRAY_SIZE(cs47l24_dai));
7eec55d7
RF
1297 if (ret < 0) {
1298 dev_err(&pdev->dev, "Failed to register codec: %d\n", ret);
31833ead 1299 goto err_platform;
7eec55d7
RF
1300 }
1301
31833ead
CK
1302 return ret;
1303
1304err_platform:
1305 snd_soc_unregister_platform(&pdev->dev);
1306err_spk_irqs:
1307 arizona_free_spk_irqs(arizona);
0809492e
CK
1308err_dsp_irq:
1309 arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, cs47l24);
31833ead 1310
7eec55d7 1311 return ret;
6610550c
RF
1312}
1313
1314static int cs47l24_remove(struct platform_device *pdev)
1315{
401cf146 1316 struct cs47l24_priv *cs47l24 = platform_get_drvdata(pdev);
91495329 1317 struct arizona *arizona = cs47l24->core.arizona;
401cf146 1318
7eec55d7 1319 snd_soc_unregister_platform(&pdev->dev);
6610550c
RF
1320 snd_soc_unregister_codec(&pdev->dev);
1321 pm_runtime_disable(&pdev->dev);
1322
401cf146
RF
1323 wm_adsp2_remove(&cs47l24->core.adsp[1]);
1324 wm_adsp2_remove(&cs47l24->core.adsp[2]);
1325
31833ead
CK
1326 arizona_free_spk_irqs(arizona);
1327
0809492e
CK
1328 arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, cs47l24);
1329
6610550c
RF
1330 return 0;
1331}
1332
1333static struct platform_driver cs47l24_codec_driver = {
1334 .driver = {
1335 .name = "cs47l24-codec",
1336 },
1337 .probe = cs47l24_probe,
1338 .remove = cs47l24_remove,
1339};
1340
1341module_platform_driver(cs47l24_codec_driver);
1342
1343MODULE_DESCRIPTION("ASoC CS47L24 driver");
1344MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.wolfsonmicro.com>");
1345MODULE_LICENSE("GPL v2");
1346MODULE_ALIAS("platform:cs47l24-codec");