1 // SPDX-License-Identifier: GPL-2.0-only 2 // 3 // ALSA SoC Audio driver for CS47L35 codec 4 // 5 // Copyright (C) 2015-2019 Cirrus Logic, Inc. and 6 // Cirrus Logic International Semiconductor Ltd. 7 // 8 9 #include <linux/delay.h> 10 #include <linux/device.h> 11 #include <linux/init.h> 12 #include <linux/module.h> 13 #include <linux/moduleparam.h> 14 #include <linux/pm.h> 15 #include <linux/pm_runtime.h> 16 #include <linux/regmap.h> 17 #include <sound/core.h> 18 #include <sound/pcm.h> 19 #include <sound/pcm_params.h> 20 #include <sound/soc.h> 21 #include <sound/tlv.h> 22 23 #include <linux/irqchip/irq-madera.h> 24 #include <linux/mfd/madera/core.h> 25 #include <linux/mfd/madera/registers.h> 26 27 #include "madera.h" 28 #include "wm_adsp.h" 29 30 #define CS47L35_NUM_ADSP 3 31 #define CS47L35_MONO_OUTPUTS 1 32 33 #define DRV_NAME "cs47l35-codec" 34 35 struct cs47l35 { 36 struct madera_priv core; 37 struct madera_fll fll; 38 }; 39 40 static const struct wm_adsp_region cs47l35_dsp1_regions[] = { 41 { .type = WMFW_ADSP2_PM, .base = 0x080000 }, 42 { .type = WMFW_ADSP2_ZM, .base = 0x0e0000 }, 43 { .type = WMFW_ADSP2_XM, .base = 0x0a0000 }, 44 { .type = WMFW_ADSP2_YM, .base = 0x0c0000 }, 45 }; 46 47 static const struct wm_adsp_region cs47l35_dsp2_regions[] = { 48 { .type = WMFW_ADSP2_PM, .base = 0x100000 }, 49 { .type = WMFW_ADSP2_ZM, .base = 0x160000 }, 50 { .type = WMFW_ADSP2_XM, .base = 0x120000 }, 51 { .type = WMFW_ADSP2_YM, .base = 0x140000 }, 52 }; 53 54 static const struct wm_adsp_region cs47l35_dsp3_regions[] = { 55 { .type = WMFW_ADSP2_PM, .base = 0x180000 }, 56 { .type = WMFW_ADSP2_ZM, .base = 0x1e0000 }, 57 { .type = WMFW_ADSP2_XM, .base = 0x1a0000 }, 58 { .type = WMFW_ADSP2_YM, .base = 0x1c0000 }, 59 }; 60 61 static const struct wm_adsp_region *cs47l35_dsp_regions[] = { 62 cs47l35_dsp1_regions, 63 cs47l35_dsp2_regions, 64 cs47l35_dsp3_regions, 65 }; 66 67 static const int wm_adsp2_control_bases[] = { 68 MADERA_DSP1_CONFIG_1, 69 MADERA_DSP2_CONFIG_1, 70 MADERA_DSP3_CONFIG_1, 71 }; 72 73 static const char * const cs47l35_outdemux_texts[] = { 74 "HPOUT", 75 "EPOUT", 76 }; 77 78 static SOC_ENUM_SINGLE_DECL(cs47l35_outdemux_enum, SND_SOC_NOPM, 0, 79 cs47l35_outdemux_texts); 80 81 static const struct snd_kcontrol_new cs47l35_outdemux = 82 SOC_DAPM_ENUM_EXT("HPOUT1 Demux", cs47l35_outdemux_enum, 83 madera_out1_demux_get, madera_out1_demux_put); 84 85 static int cs47l35_adsp_power_ev(struct snd_soc_dapm_widget *w, 86 struct snd_kcontrol *kcontrol, 87 int event) 88 { 89 struct snd_soc_component *component = 90 snd_soc_dapm_to_component(w->dapm); 91 struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); 92 struct madera_priv *priv = &cs47l35->core; 93 struct madera *madera = priv->madera; 94 unsigned int freq; 95 int ret; 96 97 ret = regmap_read(madera->regmap, MADERA_DSP_CLOCK_1, &freq); 98 if (ret != 0) { 99 dev_err(madera->dev, 100 "Failed to read MADERA_DSP_CLOCK_1: %d\n", ret); 101 return ret; 102 } 103 104 freq &= MADERA_DSP_CLK_FREQ_LEGACY_MASK; 105 freq >>= MADERA_DSP_CLK_FREQ_LEGACY_SHIFT; 106 107 switch (event) { 108 case SND_SOC_DAPM_PRE_PMU: 109 ret = madera_set_adsp_clk(&cs47l35->core, w->shift, freq); 110 if (ret) 111 return ret; 112 break; 113 default: 114 break; 115 } 116 117 return wm_adsp_early_event(w, kcontrol, event); 118 } 119 120 #define CS47L35_NG_SRC(name, base) \ 121 SOC_SINGLE(name " NG HPOUT1L Switch", base, 0, 1, 0), \ 122 SOC_SINGLE(name " NG HPOUT1R Switch", base, 1, 1, 0), \ 123 SOC_SINGLE(name " NG SPKOUT Switch", base, 6, 1, 0), \ 124 SOC_SINGLE(name " NG SPKDAT1L Switch", base, 8, 1, 0), \ 125 SOC_SINGLE(name " NG SPKDAT1R Switch", base, 9, 1, 0) 126 127 static void cs47l35_hp_post_enable(struct snd_soc_dapm_widget *w) 128 { 129 struct snd_soc_component *component = 130 snd_soc_dapm_to_component(w->dapm); 131 unsigned int val; 132 133 switch (w->shift) { 134 case MADERA_OUT1L_ENA_SHIFT: 135 case MADERA_OUT1R_ENA_SHIFT: 136 val = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1); 137 val &= (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA); 138 139 if (val != (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA)) 140 break; 141 142 snd_soc_component_update_bits(component, 143 MADERA_EDRE_HP_STEREO_CONTROL, 144 0x0001, 1); 145 break; 146 default: 147 break; 148 } 149 } 150 151 static void cs47l35_hp_post_disable(struct snd_soc_dapm_widget *w) 152 { 153 struct snd_soc_component *component = 154 snd_soc_dapm_to_component(w->dapm); 155 156 switch (w->shift) { 157 case MADERA_OUT1L_ENA_SHIFT: 158 snd_soc_component_write(component, MADERA_DCS_HP1L_CONTROL, 159 0x2006); 160 break; 161 case MADERA_OUT1R_ENA_SHIFT: 162 snd_soc_component_write(component, MADERA_DCS_HP1R_CONTROL, 163 0x2006); 164 break; 165 default: 166 return; 167 } 168 169 /* Only get to here for OUT1L and OUT1R */ 170 snd_soc_component_update_bits(component, 171 MADERA_EDRE_HP_STEREO_CONTROL, 172 0x0001, 0); 173 } 174 175 static int cs47l35_hp_ev(struct snd_soc_dapm_widget *w, 176 struct snd_kcontrol *kcontrol, int event) 177 { 178 int ret; 179 180 switch (event) { 181 case SND_SOC_DAPM_PRE_PMU: 182 case SND_SOC_DAPM_PRE_PMD: 183 return madera_hp_ev(w, kcontrol, event); 184 case SND_SOC_DAPM_POST_PMU: 185 ret = madera_hp_ev(w, kcontrol, event); 186 if (ret < 0) 187 return ret; 188 189 cs47l35_hp_post_enable(w); 190 return 0; 191 case SND_SOC_DAPM_POST_PMD: 192 ret = madera_hp_ev(w, kcontrol, event); 193 cs47l35_hp_post_disable(w); 194 return ret; 195 default: 196 return -EINVAL; 197 } 198 } 199 200 static const struct snd_kcontrol_new cs47l35_snd_controls[] = { 201 SOC_ENUM("IN1 OSR", madera_in_dmic_osr[0]), 202 SOC_ENUM("IN2 OSR", madera_in_dmic_osr[1]), 203 204 SOC_SINGLE_RANGE_TLV("IN1L Volume", MADERA_IN1L_CONTROL, 205 MADERA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv), 206 SOC_SINGLE_RANGE_TLV("IN1R Volume", MADERA_IN1R_CONTROL, 207 MADERA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv), 208 SOC_SINGLE_RANGE_TLV("IN2L Volume", MADERA_IN2L_CONTROL, 209 MADERA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv), 210 SOC_SINGLE_RANGE_TLV("IN2R Volume", MADERA_IN2R_CONTROL, 211 MADERA_IN2R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv), 212 213 SOC_ENUM("IN HPF Cutoff Frequency", madera_in_hpf_cut_enum), 214 215 SOC_SINGLE("IN1L HPF Switch", MADERA_IN1L_CONTROL, 216 MADERA_IN1L_HPF_SHIFT, 1, 0), 217 SOC_SINGLE("IN1R HPF Switch", MADERA_IN1R_CONTROL, 218 MADERA_IN1R_HPF_SHIFT, 1, 0), 219 SOC_SINGLE("IN2L HPF Switch", MADERA_IN2L_CONTROL, 220 MADERA_IN2L_HPF_SHIFT, 1, 0), 221 SOC_SINGLE("IN2R HPF Switch", MADERA_IN2R_CONTROL, 222 MADERA_IN2R_HPF_SHIFT, 1, 0), 223 224 SOC_SINGLE_TLV("IN1L Digital Volume", MADERA_ADC_DIGITAL_VOLUME_1L, 225 MADERA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 226 SOC_SINGLE_TLV("IN1R Digital Volume", MADERA_ADC_DIGITAL_VOLUME_1R, 227 MADERA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 228 SOC_SINGLE_TLV("IN2L Digital Volume", MADERA_ADC_DIGITAL_VOLUME_2L, 229 MADERA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 230 SOC_SINGLE_TLV("IN2R Digital Volume", MADERA_ADC_DIGITAL_VOLUME_2R, 231 MADERA_IN2R_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 232 233 SOC_ENUM("Input Ramp Up", madera_in_vi_ramp), 234 SOC_ENUM("Input Ramp Down", madera_in_vd_ramp), 235 236 MADERA_MIXER_CONTROLS("EQ1", MADERA_EQ1MIX_INPUT_1_SOURCE), 237 MADERA_MIXER_CONTROLS("EQ2", MADERA_EQ2MIX_INPUT_1_SOURCE), 238 MADERA_MIXER_CONTROLS("EQ3", MADERA_EQ3MIX_INPUT_1_SOURCE), 239 MADERA_MIXER_CONTROLS("EQ4", MADERA_EQ4MIX_INPUT_1_SOURCE), 240 241 MADERA_EQ_CONTROL("EQ1 Coefficients", MADERA_EQ1_2), 242 SOC_SINGLE_TLV("EQ1 B1 Volume", MADERA_EQ1_1, MADERA_EQ1_B1_GAIN_SHIFT, 243 24, 0, madera_eq_tlv), 244 SOC_SINGLE_TLV("EQ1 B2 Volume", MADERA_EQ1_1, MADERA_EQ1_B2_GAIN_SHIFT, 245 24, 0, madera_eq_tlv), 246 SOC_SINGLE_TLV("EQ1 B3 Volume", MADERA_EQ1_1, MADERA_EQ1_B3_GAIN_SHIFT, 247 24, 0, madera_eq_tlv), 248 SOC_SINGLE_TLV("EQ1 B4 Volume", MADERA_EQ1_2, MADERA_EQ1_B4_GAIN_SHIFT, 249 24, 0, madera_eq_tlv), 250 SOC_SINGLE_TLV("EQ1 B5 Volume", MADERA_EQ1_2, MADERA_EQ1_B5_GAIN_SHIFT, 251 24, 0, madera_eq_tlv), 252 253 MADERA_EQ_CONTROL("EQ2 Coefficients", MADERA_EQ2_2), 254 SOC_SINGLE_TLV("EQ2 B1 Volume", MADERA_EQ2_1, MADERA_EQ2_B1_GAIN_SHIFT, 255 24, 0, madera_eq_tlv), 256 SOC_SINGLE_TLV("EQ2 B2 Volume", MADERA_EQ2_1, MADERA_EQ2_B2_GAIN_SHIFT, 257 24, 0, madera_eq_tlv), 258 SOC_SINGLE_TLV("EQ2 B3 Volume", MADERA_EQ2_1, MADERA_EQ2_B3_GAIN_SHIFT, 259 24, 0, madera_eq_tlv), 260 SOC_SINGLE_TLV("EQ2 B4 Volume", MADERA_EQ2_2, MADERA_EQ2_B4_GAIN_SHIFT, 261 24, 0, madera_eq_tlv), 262 SOC_SINGLE_TLV("EQ2 B5 Volume", MADERA_EQ2_2, MADERA_EQ2_B5_GAIN_SHIFT, 263 24, 0, madera_eq_tlv), 264 265 MADERA_EQ_CONTROL("EQ3 Coefficients", MADERA_EQ3_2), 266 SOC_SINGLE_TLV("EQ3 B1 Volume", MADERA_EQ3_1, MADERA_EQ3_B1_GAIN_SHIFT, 267 24, 0, madera_eq_tlv), 268 SOC_SINGLE_TLV("EQ3 B2 Volume", MADERA_EQ3_1, MADERA_EQ3_B2_GAIN_SHIFT, 269 24, 0, madera_eq_tlv), 270 SOC_SINGLE_TLV("EQ3 B3 Volume", MADERA_EQ3_1, MADERA_EQ3_B3_GAIN_SHIFT, 271 24, 0, madera_eq_tlv), 272 SOC_SINGLE_TLV("EQ3 B4 Volume", MADERA_EQ3_2, MADERA_EQ3_B4_GAIN_SHIFT, 273 24, 0, madera_eq_tlv), 274 SOC_SINGLE_TLV("EQ3 B5 Volume", MADERA_EQ3_2, MADERA_EQ3_B5_GAIN_SHIFT, 275 24, 0, madera_eq_tlv), 276 277 MADERA_EQ_CONTROL("EQ4 Coefficients", MADERA_EQ4_2), 278 SOC_SINGLE_TLV("EQ4 B1 Volume", MADERA_EQ4_1, MADERA_EQ4_B1_GAIN_SHIFT, 279 24, 0, madera_eq_tlv), 280 SOC_SINGLE_TLV("EQ4 B2 Volume", MADERA_EQ4_1, MADERA_EQ4_B2_GAIN_SHIFT, 281 24, 0, madera_eq_tlv), 282 SOC_SINGLE_TLV("EQ4 B3 Volume", MADERA_EQ4_1, MADERA_EQ4_B3_GAIN_SHIFT, 283 24, 0, madera_eq_tlv), 284 SOC_SINGLE_TLV("EQ4 B4 Volume", MADERA_EQ4_2, MADERA_EQ4_B4_GAIN_SHIFT, 285 24, 0, madera_eq_tlv), 286 SOC_SINGLE_TLV("EQ4 B5 Volume", MADERA_EQ4_2, MADERA_EQ4_B5_GAIN_SHIFT, 287 24, 0, madera_eq_tlv), 288 289 MADERA_MIXER_CONTROLS("DRC1L", MADERA_DRC1LMIX_INPUT_1_SOURCE), 290 MADERA_MIXER_CONTROLS("DRC1R", MADERA_DRC1RMIX_INPUT_1_SOURCE), 291 MADERA_MIXER_CONTROLS("DRC2L", MADERA_DRC2LMIX_INPUT_1_SOURCE), 292 MADERA_MIXER_CONTROLS("DRC2R", MADERA_DRC2RMIX_INPUT_1_SOURCE), 293 294 SND_SOC_BYTES_MASK("DRC1", MADERA_DRC1_CTRL1, 5, 295 MADERA_DRC1R_ENA | MADERA_DRC1L_ENA), 296 SND_SOC_BYTES_MASK("DRC2", MADERA_DRC2_CTRL1, 5, 297 MADERA_DRC2R_ENA | MADERA_DRC2L_ENA), 298 299 MADERA_MIXER_CONTROLS("LHPF1", MADERA_HPLP1MIX_INPUT_1_SOURCE), 300 MADERA_MIXER_CONTROLS("LHPF2", MADERA_HPLP2MIX_INPUT_1_SOURCE), 301 MADERA_MIXER_CONTROLS("LHPF3", MADERA_HPLP3MIX_INPUT_1_SOURCE), 302 MADERA_MIXER_CONTROLS("LHPF4", MADERA_HPLP4MIX_INPUT_1_SOURCE), 303 304 MADERA_LHPF_CONTROL("LHPF1 Coefficients", MADERA_HPLPF1_2), 305 MADERA_LHPF_CONTROL("LHPF2 Coefficients", MADERA_HPLPF2_2), 306 MADERA_LHPF_CONTROL("LHPF3 Coefficients", MADERA_HPLPF3_2), 307 MADERA_LHPF_CONTROL("LHPF4 Coefficients", MADERA_HPLPF4_2), 308 309 SOC_ENUM("LHPF1 Mode", madera_lhpf1_mode), 310 SOC_ENUM("LHPF2 Mode", madera_lhpf2_mode), 311 SOC_ENUM("LHPF3 Mode", madera_lhpf3_mode), 312 SOC_ENUM("LHPF4 Mode", madera_lhpf4_mode), 313 314 MADERA_RATE_ENUM("ISRC1 FSL", madera_isrc_fsl[0]), 315 MADERA_RATE_ENUM("ISRC2 FSL", madera_isrc_fsl[1]), 316 MADERA_RATE_ENUM("ISRC1 FSH", madera_isrc_fsh[0]), 317 MADERA_RATE_ENUM("ISRC2 FSH", madera_isrc_fsh[1]), 318 319 WM_ADSP2_PRELOAD_SWITCH("DSP1", 1), 320 WM_ADSP2_PRELOAD_SWITCH("DSP2", 2), 321 WM_ADSP2_PRELOAD_SWITCH("DSP3", 3), 322 323 MADERA_MIXER_CONTROLS("DSP1L", MADERA_DSP1LMIX_INPUT_1_SOURCE), 324 MADERA_MIXER_CONTROLS("DSP1R", MADERA_DSP1RMIX_INPUT_1_SOURCE), 325 MADERA_MIXER_CONTROLS("DSP2L", MADERA_DSP2LMIX_INPUT_1_SOURCE), 326 MADERA_MIXER_CONTROLS("DSP2R", MADERA_DSP2RMIX_INPUT_1_SOURCE), 327 MADERA_MIXER_CONTROLS("DSP3L", MADERA_DSP3LMIX_INPUT_1_SOURCE), 328 MADERA_MIXER_CONTROLS("DSP3R", MADERA_DSP3RMIX_INPUT_1_SOURCE), 329 330 SOC_SINGLE_TLV("Noise Generator Volume", MADERA_COMFORT_NOISE_GENERATOR, 331 MADERA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, madera_noise_tlv), 332 333 MADERA_MIXER_CONTROLS("HPOUT1L", MADERA_OUT1LMIX_INPUT_1_SOURCE), 334 MADERA_MIXER_CONTROLS("HPOUT1R", MADERA_OUT1RMIX_INPUT_1_SOURCE), 335 MADERA_MIXER_CONTROLS("SPKOUT", MADERA_OUT4LMIX_INPUT_1_SOURCE), 336 MADERA_MIXER_CONTROLS("SPKDAT1L", MADERA_OUT5LMIX_INPUT_1_SOURCE), 337 MADERA_MIXER_CONTROLS("SPKDAT1R", MADERA_OUT5RMIX_INPUT_1_SOURCE), 338 339 SOC_SINGLE("HPOUT1 SC Protect Switch", MADERA_HP1_SHORT_CIRCUIT_CTRL, 340 MADERA_HP1_SC_ENA_SHIFT, 1, 0), 341 342 SOC_SINGLE("SPKDAT1 High Performance Switch", MADERA_OUTPUT_PATH_CONFIG_5L, 343 MADERA_OUT5_OSR_SHIFT, 1, 0), 344 345 SOC_DOUBLE_R("HPOUT1 Digital Switch", MADERA_DAC_DIGITAL_VOLUME_1L, 346 MADERA_DAC_DIGITAL_VOLUME_1R, MADERA_OUT1L_MUTE_SHIFT, 1, 1), 347 SOC_SINGLE("Speaker Digital Switch", MADERA_DAC_DIGITAL_VOLUME_4L, 348 MADERA_OUT4L_MUTE_SHIFT, 1, 1), 349 SOC_DOUBLE_R("SPKDAT1 Digital Switch", MADERA_DAC_DIGITAL_VOLUME_5L, 350 MADERA_DAC_DIGITAL_VOLUME_5R, MADERA_OUT5L_MUTE_SHIFT, 1, 1), 351 352 SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", MADERA_DAC_DIGITAL_VOLUME_1L, 353 MADERA_DAC_DIGITAL_VOLUME_1R, MADERA_OUT1L_VOL_SHIFT, 354 0xbf, 0, madera_digital_tlv), 355 SOC_SINGLE_TLV("Speaker Digital Volume", MADERA_DAC_DIGITAL_VOLUME_4L, 356 MADERA_OUT4L_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 357 SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", MADERA_DAC_DIGITAL_VOLUME_5L, 358 MADERA_DAC_DIGITAL_VOLUME_5R, MADERA_OUT5L_VOL_SHIFT, 359 0xbf, 0, madera_digital_tlv), 360 361 SOC_DOUBLE("SPKDAT1 Switch", MADERA_PDM_SPK1_CTRL_1, MADERA_SPK1L_MUTE_SHIFT, 362 MADERA_SPK1R_MUTE_SHIFT, 1, 1), 363 364 SOC_ENUM("Output Ramp Up", madera_out_vi_ramp), 365 SOC_ENUM("Output Ramp Down", madera_out_vd_ramp), 366 367 SOC_SINGLE("Noise Gate Switch", MADERA_NOISE_GATE_CONTROL, 368 MADERA_NGATE_ENA_SHIFT, 1, 0), 369 SOC_SINGLE_TLV("Noise Gate Threshold Volume", MADERA_NOISE_GATE_CONTROL, 370 MADERA_NGATE_THR_SHIFT, 7, 1, madera_ng_tlv), 371 SOC_ENUM("Noise Gate Hold", madera_ng_hold), 372 373 CS47L35_NG_SRC("HPOUT1L", MADERA_NOISE_GATE_SELECT_1L), 374 CS47L35_NG_SRC("HPOUT1R", MADERA_NOISE_GATE_SELECT_1R), 375 CS47L35_NG_SRC("SPKOUT", MADERA_NOISE_GATE_SELECT_4L), 376 CS47L35_NG_SRC("SPKDAT1L", MADERA_NOISE_GATE_SELECT_5L), 377 CS47L35_NG_SRC("SPKDAT1R", MADERA_NOISE_GATE_SELECT_5R), 378 379 MADERA_MIXER_CONTROLS("AIF1TX1", MADERA_AIF1TX1MIX_INPUT_1_SOURCE), 380 MADERA_MIXER_CONTROLS("AIF1TX2", MADERA_AIF1TX2MIX_INPUT_1_SOURCE), 381 MADERA_MIXER_CONTROLS("AIF1TX3", MADERA_AIF1TX3MIX_INPUT_1_SOURCE), 382 MADERA_MIXER_CONTROLS("AIF1TX4", MADERA_AIF1TX4MIX_INPUT_1_SOURCE), 383 MADERA_MIXER_CONTROLS("AIF1TX5", MADERA_AIF1TX5MIX_INPUT_1_SOURCE), 384 MADERA_MIXER_CONTROLS("AIF1TX6", MADERA_AIF1TX6MIX_INPUT_1_SOURCE), 385 386 MADERA_MIXER_CONTROLS("AIF2TX1", MADERA_AIF2TX1MIX_INPUT_1_SOURCE), 387 MADERA_MIXER_CONTROLS("AIF2TX2", MADERA_AIF2TX2MIX_INPUT_1_SOURCE), 388 389 MADERA_MIXER_CONTROLS("AIF3TX1", MADERA_AIF3TX1MIX_INPUT_1_SOURCE), 390 MADERA_MIXER_CONTROLS("AIF3TX2", MADERA_AIF3TX2MIX_INPUT_1_SOURCE), 391 392 MADERA_MIXER_CONTROLS("SLIMTX1", MADERA_SLIMTX1MIX_INPUT_1_SOURCE), 393 MADERA_MIXER_CONTROLS("SLIMTX2", MADERA_SLIMTX2MIX_INPUT_1_SOURCE), 394 MADERA_MIXER_CONTROLS("SLIMTX3", MADERA_SLIMTX3MIX_INPUT_1_SOURCE), 395 MADERA_MIXER_CONTROLS("SLIMTX4", MADERA_SLIMTX4MIX_INPUT_1_SOURCE), 396 MADERA_MIXER_CONTROLS("SLIMTX5", MADERA_SLIMTX5MIX_INPUT_1_SOURCE), 397 MADERA_MIXER_CONTROLS("SLIMTX6", MADERA_SLIMTX6MIX_INPUT_1_SOURCE), 398 399 MADERA_GAINMUX_CONTROLS("SPDIF1TX1", MADERA_SPDIF1TX1MIX_INPUT_1_SOURCE), 400 MADERA_GAINMUX_CONTROLS("SPDIF1TX2", MADERA_SPDIF1TX2MIX_INPUT_1_SOURCE), 401 402 WM_ADSP_FW_CONTROL("DSP1", 0), 403 WM_ADSP_FW_CONTROL("DSP2", 1), 404 WM_ADSP_FW_CONTROL("DSP3", 2), 405 }; 406 407 MADERA_MIXER_ENUMS(EQ1, MADERA_EQ1MIX_INPUT_1_SOURCE); 408 MADERA_MIXER_ENUMS(EQ2, MADERA_EQ2MIX_INPUT_1_SOURCE); 409 MADERA_MIXER_ENUMS(EQ3, MADERA_EQ3MIX_INPUT_1_SOURCE); 410 MADERA_MIXER_ENUMS(EQ4, MADERA_EQ4MIX_INPUT_1_SOURCE); 411 412 MADERA_MIXER_ENUMS(DRC1L, MADERA_DRC1LMIX_INPUT_1_SOURCE); 413 MADERA_MIXER_ENUMS(DRC1R, MADERA_DRC1RMIX_INPUT_1_SOURCE); 414 MADERA_MIXER_ENUMS(DRC2L, MADERA_DRC2LMIX_INPUT_1_SOURCE); 415 MADERA_MIXER_ENUMS(DRC2R, MADERA_DRC2RMIX_INPUT_1_SOURCE); 416 417 MADERA_MIXER_ENUMS(LHPF1, MADERA_HPLP1MIX_INPUT_1_SOURCE); 418 MADERA_MIXER_ENUMS(LHPF2, MADERA_HPLP2MIX_INPUT_1_SOURCE); 419 MADERA_MIXER_ENUMS(LHPF3, MADERA_HPLP3MIX_INPUT_1_SOURCE); 420 MADERA_MIXER_ENUMS(LHPF4, MADERA_HPLP4MIX_INPUT_1_SOURCE); 421 422 MADERA_MIXER_ENUMS(DSP1L, MADERA_DSP1LMIX_INPUT_1_SOURCE); 423 MADERA_MIXER_ENUMS(DSP1R, MADERA_DSP1RMIX_INPUT_1_SOURCE); 424 MADERA_DSP_AUX_ENUMS(DSP1, MADERA_DSP1AUX1MIX_INPUT_1_SOURCE); 425 426 MADERA_MIXER_ENUMS(DSP2L, MADERA_DSP2LMIX_INPUT_1_SOURCE); 427 MADERA_MIXER_ENUMS(DSP2R, MADERA_DSP2RMIX_INPUT_1_SOURCE); 428 MADERA_DSP_AUX_ENUMS(DSP2, MADERA_DSP2AUX1MIX_INPUT_1_SOURCE); 429 430 MADERA_MIXER_ENUMS(DSP3L, MADERA_DSP3LMIX_INPUT_1_SOURCE); 431 MADERA_MIXER_ENUMS(DSP3R, MADERA_DSP3RMIX_INPUT_1_SOURCE); 432 MADERA_DSP_AUX_ENUMS(DSP3, MADERA_DSP3AUX1MIX_INPUT_1_SOURCE); 433 434 MADERA_MIXER_ENUMS(PWM1, MADERA_PWM1MIX_INPUT_1_SOURCE); 435 MADERA_MIXER_ENUMS(PWM2, MADERA_PWM2MIX_INPUT_1_SOURCE); 436 437 MADERA_MIXER_ENUMS(OUT1L, MADERA_OUT1LMIX_INPUT_1_SOURCE); 438 MADERA_MIXER_ENUMS(OUT1R, MADERA_OUT1RMIX_INPUT_1_SOURCE); 439 MADERA_MIXER_ENUMS(SPKOUT, MADERA_OUT4LMIX_INPUT_1_SOURCE); 440 MADERA_MIXER_ENUMS(SPKDAT1L, MADERA_OUT5LMIX_INPUT_1_SOURCE); 441 MADERA_MIXER_ENUMS(SPKDAT1R, MADERA_OUT5RMIX_INPUT_1_SOURCE); 442 443 MADERA_MIXER_ENUMS(AIF1TX1, MADERA_AIF1TX1MIX_INPUT_1_SOURCE); 444 MADERA_MIXER_ENUMS(AIF1TX2, MADERA_AIF1TX2MIX_INPUT_1_SOURCE); 445 MADERA_MIXER_ENUMS(AIF1TX3, MADERA_AIF1TX3MIX_INPUT_1_SOURCE); 446 MADERA_MIXER_ENUMS(AIF1TX4, MADERA_AIF1TX4MIX_INPUT_1_SOURCE); 447 MADERA_MIXER_ENUMS(AIF1TX5, MADERA_AIF1TX5MIX_INPUT_1_SOURCE); 448 MADERA_MIXER_ENUMS(AIF1TX6, MADERA_AIF1TX6MIX_INPUT_1_SOURCE); 449 450 MADERA_MIXER_ENUMS(AIF2TX1, MADERA_AIF2TX1MIX_INPUT_1_SOURCE); 451 MADERA_MIXER_ENUMS(AIF2TX2, MADERA_AIF2TX2MIX_INPUT_1_SOURCE); 452 453 MADERA_MIXER_ENUMS(AIF3TX1, MADERA_AIF3TX1MIX_INPUT_1_SOURCE); 454 MADERA_MIXER_ENUMS(AIF3TX2, MADERA_AIF3TX2MIX_INPUT_1_SOURCE); 455 456 MADERA_MIXER_ENUMS(SLIMTX1, MADERA_SLIMTX1MIX_INPUT_1_SOURCE); 457 MADERA_MIXER_ENUMS(SLIMTX2, MADERA_SLIMTX2MIX_INPUT_1_SOURCE); 458 MADERA_MIXER_ENUMS(SLIMTX3, MADERA_SLIMTX3MIX_INPUT_1_SOURCE); 459 MADERA_MIXER_ENUMS(SLIMTX4, MADERA_SLIMTX4MIX_INPUT_1_SOURCE); 460 MADERA_MIXER_ENUMS(SLIMTX5, MADERA_SLIMTX5MIX_INPUT_1_SOURCE); 461 MADERA_MIXER_ENUMS(SLIMTX6, MADERA_SLIMTX6MIX_INPUT_1_SOURCE); 462 463 MADERA_MUX_ENUMS(SPD1TX1, MADERA_SPDIF1TX1MIX_INPUT_1_SOURCE); 464 MADERA_MUX_ENUMS(SPD1TX2, MADERA_SPDIF1TX2MIX_INPUT_1_SOURCE); 465 466 MADERA_MUX_ENUMS(ISRC1INT1, MADERA_ISRC1INT1MIX_INPUT_1_SOURCE); 467 MADERA_MUX_ENUMS(ISRC1INT2, MADERA_ISRC1INT2MIX_INPUT_1_SOURCE); 468 MADERA_MUX_ENUMS(ISRC1INT3, MADERA_ISRC1INT3MIX_INPUT_1_SOURCE); 469 MADERA_MUX_ENUMS(ISRC1INT4, MADERA_ISRC1INT4MIX_INPUT_1_SOURCE); 470 471 MADERA_MUX_ENUMS(ISRC1DEC1, MADERA_ISRC1DEC1MIX_INPUT_1_SOURCE); 472 MADERA_MUX_ENUMS(ISRC1DEC2, MADERA_ISRC1DEC2MIX_INPUT_1_SOURCE); 473 MADERA_MUX_ENUMS(ISRC1DEC3, MADERA_ISRC1DEC3MIX_INPUT_1_SOURCE); 474 MADERA_MUX_ENUMS(ISRC1DEC4, MADERA_ISRC1DEC4MIX_INPUT_1_SOURCE); 475 476 MADERA_MUX_ENUMS(ISRC2INT1, MADERA_ISRC2INT1MIX_INPUT_1_SOURCE); 477 MADERA_MUX_ENUMS(ISRC2INT2, MADERA_ISRC2INT2MIX_INPUT_1_SOURCE); 478 MADERA_MUX_ENUMS(ISRC2INT3, MADERA_ISRC2INT3MIX_INPUT_1_SOURCE); 479 MADERA_MUX_ENUMS(ISRC2INT4, MADERA_ISRC2INT4MIX_INPUT_1_SOURCE); 480 481 MADERA_MUX_ENUMS(ISRC2DEC1, MADERA_ISRC2DEC1MIX_INPUT_1_SOURCE); 482 MADERA_MUX_ENUMS(ISRC2DEC2, MADERA_ISRC2DEC2MIX_INPUT_1_SOURCE); 483 MADERA_MUX_ENUMS(ISRC2DEC3, MADERA_ISRC2DEC3MIX_INPUT_1_SOURCE); 484 MADERA_MUX_ENUMS(ISRC2DEC4, MADERA_ISRC2DEC4MIX_INPUT_1_SOURCE); 485 486 static const char * const cs47l35_aec_loopback_texts[] = { 487 "HPOUT1L", "HPOUT1R", "SPKOUT", "SPKDAT1L", "SPKDAT1R", 488 }; 489 490 static const unsigned int cs47l35_aec_loopback_values[] = { 491 0, 1, 6, 8, 9, 492 }; 493 494 static const struct soc_enum cs47l35_aec1_loopback = 495 SOC_VALUE_ENUM_SINGLE(MADERA_DAC_AEC_CONTROL_1, 496 MADERA_AEC1_LOOPBACK_SRC_SHIFT, 0xf, 497 ARRAY_SIZE(cs47l35_aec_loopback_texts), 498 cs47l35_aec_loopback_texts, 499 cs47l35_aec_loopback_values); 500 501 static const struct soc_enum cs47l35_aec2_loopback = 502 SOC_VALUE_ENUM_SINGLE(MADERA_DAC_AEC_CONTROL_2, 503 MADERA_AEC2_LOOPBACK_SRC_SHIFT, 0xf, 504 ARRAY_SIZE(cs47l35_aec_loopback_texts), 505 cs47l35_aec_loopback_texts, 506 cs47l35_aec_loopback_values); 507 508 static const struct snd_kcontrol_new cs47l35_aec_loopback_mux[] = { 509 SOC_DAPM_ENUM("AEC1 Loopback", cs47l35_aec1_loopback), 510 SOC_DAPM_ENUM("AEC2 Loopback", cs47l35_aec2_loopback), 511 }; 512 513 static const struct snd_soc_dapm_widget cs47l35_dapm_widgets[] = { 514 SND_SOC_DAPM_SUPPLY("SYSCLK", MADERA_SYSTEM_CLOCK_1, MADERA_SYSCLK_ENA_SHIFT, 515 0, madera_sysclk_ev, 516 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 517 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 518 SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK, 519 MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0), 520 SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, MADERA_DSP_CLK_ENA_SHIFT, 521 0, madera_clk_ev, 522 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 523 524 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0), 525 SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD1", 20, 0), 526 SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD2", 20, 0), 527 SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS), 528 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDD", 0, 0), 529 530 SND_SOC_DAPM_SUPPLY("MICBIAS1", MADERA_MIC_BIAS_CTRL_1, 531 MADERA_MICB1_ENA_SHIFT, 0, NULL, 0), 532 SND_SOC_DAPM_SUPPLY("MICBIAS2", MADERA_MIC_BIAS_CTRL_2, 533 MADERA_MICB1_ENA_SHIFT, 0, NULL, 0), 534 535 SND_SOC_DAPM_SUPPLY("MICBIAS1A", MADERA_MIC_BIAS_CTRL_5, 536 MADERA_MICB1A_ENA_SHIFT, 0, NULL, 0), 537 SND_SOC_DAPM_SUPPLY("MICBIAS1B", MADERA_MIC_BIAS_CTRL_5, 538 MADERA_MICB1B_ENA_SHIFT, 0, NULL, 0), 539 SND_SOC_DAPM_SUPPLY("MICBIAS2A", MADERA_MIC_BIAS_CTRL_6, 540 MADERA_MICB2A_ENA_SHIFT, 0, NULL, 0), 541 SND_SOC_DAPM_SUPPLY("MICBIAS2B", MADERA_MIC_BIAS_CTRL_6, 542 MADERA_MICB2B_ENA_SHIFT, 0, NULL, 0), 543 544 SND_SOC_DAPM_SUPPLY("FXCLK", SND_SOC_NOPM, 545 MADERA_DOM_GRP_FX, 0, 546 madera_domain_clk_ev, 547 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 548 SND_SOC_DAPM_SUPPLY("ISRC1CLK", SND_SOC_NOPM, 549 MADERA_DOM_GRP_ISRC1, 0, 550 madera_domain_clk_ev, 551 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 552 SND_SOC_DAPM_SUPPLY("ISRC2CLK", SND_SOC_NOPM, 553 MADERA_DOM_GRP_ISRC2, 0, 554 madera_domain_clk_ev, 555 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 556 SND_SOC_DAPM_SUPPLY("OUTCLK", SND_SOC_NOPM, 557 MADERA_DOM_GRP_OUT, 0, 558 madera_domain_clk_ev, 559 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 560 SND_SOC_DAPM_SUPPLY("SPDCLK", SND_SOC_NOPM, 561 MADERA_DOM_GRP_SPD, 0, 562 madera_domain_clk_ev, 563 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 564 SND_SOC_DAPM_SUPPLY("DSP1CLK", SND_SOC_NOPM, 565 MADERA_DOM_GRP_DSP1, 0, 566 madera_domain_clk_ev, 567 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 568 SND_SOC_DAPM_SUPPLY("DSP2CLK", SND_SOC_NOPM, 569 MADERA_DOM_GRP_DSP2, 0, 570 madera_domain_clk_ev, 571 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 572 SND_SOC_DAPM_SUPPLY("DSP3CLK", SND_SOC_NOPM, 573 MADERA_DOM_GRP_DSP3, 0, 574 madera_domain_clk_ev, 575 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 576 SND_SOC_DAPM_SUPPLY("AIF1TXCLK", SND_SOC_NOPM, 577 MADERA_DOM_GRP_AIF1, 0, 578 madera_domain_clk_ev, 579 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 580 SND_SOC_DAPM_SUPPLY("AIF2TXCLK", SND_SOC_NOPM, 581 MADERA_DOM_GRP_AIF2, 0, 582 madera_domain_clk_ev, 583 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 584 SND_SOC_DAPM_SUPPLY("AIF3TXCLK", SND_SOC_NOPM, 585 MADERA_DOM_GRP_AIF3, 0, 586 madera_domain_clk_ev, 587 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 588 SND_SOC_DAPM_SUPPLY("SLIMBUSCLK", SND_SOC_NOPM, 589 MADERA_DOM_GRP_SLIMBUS, 0, 590 madera_domain_clk_ev, 591 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 592 SND_SOC_DAPM_SUPPLY("PWMCLK", SND_SOC_NOPM, 593 MADERA_DOM_GRP_PWM, 0, 594 madera_domain_clk_ev, 595 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 596 597 SND_SOC_DAPM_SIGGEN("TONE"), 598 SND_SOC_DAPM_SIGGEN("NOISE"), 599 600 SND_SOC_DAPM_INPUT("IN1ALN"), 601 SND_SOC_DAPM_INPUT("IN1ALP"), 602 SND_SOC_DAPM_INPUT("IN1BLN"), 603 SND_SOC_DAPM_INPUT("IN1BLP"), 604 SND_SOC_DAPM_INPUT("IN1ARN"), 605 SND_SOC_DAPM_INPUT("IN1ARP"), 606 SND_SOC_DAPM_INPUT("IN1BRN"), 607 SND_SOC_DAPM_INPUT("IN1BRP"), 608 SND_SOC_DAPM_INPUT("IN2LN"), 609 SND_SOC_DAPM_INPUT("IN2LP"), 610 SND_SOC_DAPM_INPUT("IN2RN"), 611 SND_SOC_DAPM_INPUT("IN2RP"), 612 613 SND_SOC_DAPM_MUX("IN1L Analog Mux", SND_SOC_NOPM, 0, 0, &madera_inmux[0]), 614 SND_SOC_DAPM_MUX("IN1R Analog Mux", SND_SOC_NOPM, 0, 0, &madera_inmux[1]), 615 616 SND_SOC_DAPM_MUX("IN1L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[0]), 617 SND_SOC_DAPM_MUX("IN1R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[0]), 618 619 SND_SOC_DAPM_MUX("IN2L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]), 620 SND_SOC_DAPM_MUX("IN2R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]), 621 622 SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"), 623 SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"), 624 625 SND_SOC_DAPM_OUTPUT("DSP Trigger Out"), 626 627 SND_SOC_DAPM_DEMUX("HPOUT1 Demux", SND_SOC_NOPM, 0, 0, &cs47l35_outdemux), 628 SND_SOC_DAPM_MUX("HPOUT1 Mono Mux", SND_SOC_NOPM, 0, 0, &cs47l35_outdemux), 629 630 SND_SOC_DAPM_PGA("PWM1 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM1_ENA_SHIFT, 631 0, NULL, 0), 632 SND_SOC_DAPM_PGA("PWM2 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM2_ENA_SHIFT, 633 0, NULL, 0), 634 635 SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0, 636 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX1_ENA_SHIFT, 0), 637 SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 1, 638 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX2_ENA_SHIFT, 0), 639 SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 2, 640 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX3_ENA_SHIFT, 0), 641 SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 3, 642 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX4_ENA_SHIFT, 0), 643 SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 4, 644 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX5_ENA_SHIFT, 0), 645 SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 5, 646 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX6_ENA_SHIFT, 0), 647 648 SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0, 649 MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX1_ENA_SHIFT, 0), 650 SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 1, 651 MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX2_ENA_SHIFT, 0), 652 653 SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0, 654 MADERA_AIF3_TX_ENABLES, MADERA_AIF3TX1_ENA_SHIFT, 0), 655 SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 1, 656 MADERA_AIF3_TX_ENABLES, MADERA_AIF3TX2_ENA_SHIFT, 0), 657 658 SND_SOC_DAPM_AIF_OUT("SLIMTX1", NULL, 0, 659 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 660 MADERA_SLIMTX1_ENA_SHIFT, 0), 661 SND_SOC_DAPM_AIF_OUT("SLIMTX2", NULL, 1, 662 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 663 MADERA_SLIMTX2_ENA_SHIFT, 0), 664 SND_SOC_DAPM_AIF_OUT("SLIMTX3", NULL, 2, 665 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 666 MADERA_SLIMTX3_ENA_SHIFT, 0), 667 SND_SOC_DAPM_AIF_OUT("SLIMTX4", NULL, 3, 668 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 669 MADERA_SLIMTX4_ENA_SHIFT, 0), 670 SND_SOC_DAPM_AIF_OUT("SLIMTX5", NULL, 4, 671 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 672 MADERA_SLIMTX5_ENA_SHIFT, 0), 673 SND_SOC_DAPM_AIF_OUT("SLIMTX6", NULL, 5, 674 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 675 MADERA_SLIMTX6_ENA_SHIFT, 0), 676 677 SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, 678 MADERA_OUT1L_ENA_SHIFT, 0, NULL, 0, cs47l35_hp_ev, 679 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 680 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 681 SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, 682 MADERA_OUT1R_ENA_SHIFT, 0, NULL, 0, cs47l35_hp_ev, 683 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 684 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 685 SND_SOC_DAPM_PGA_E("OUT4L", SND_SOC_NOPM, 686 MADERA_OUT4L_ENA_SHIFT, 0, NULL, 0, madera_spk_ev, 687 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 688 SND_SOC_DAPM_PGA_E("OUT5L", MADERA_OUTPUT_ENABLES_1, 689 MADERA_OUT5L_ENA_SHIFT, 0, NULL, 0, madera_out_ev, 690 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 691 SND_SOC_DAPM_PGA_E("OUT5R", MADERA_OUTPUT_ENABLES_1, 692 MADERA_OUT5R_ENA_SHIFT, 0, NULL, 0, madera_out_ev, 693 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 694 695 SND_SOC_DAPM_PGA("SPD1TX1", MADERA_SPD1_TX_CONTROL, 696 MADERA_SPD1_VAL1_SHIFT, 0, NULL, 0), 697 SND_SOC_DAPM_PGA("SPD1TX2", MADERA_SPD1_TX_CONTROL, 698 MADERA_SPD1_VAL2_SHIFT, 0, NULL, 0), 699 SND_SOC_DAPM_OUT_DRV("SPD1", MADERA_SPD1_TX_CONTROL, 700 MADERA_SPD1_ENA_SHIFT, 0, NULL, 0), 701 702 /* 703 * Input mux widgets arranged in order of sources in MADERA_MIXER_INPUT_ROUTES 704 * to take advantage of cache lookup in DAPM 705 */ 706 SND_SOC_DAPM_PGA("Noise Generator", MADERA_COMFORT_NOISE_GENERATOR, 707 MADERA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0), 708 709 SND_SOC_DAPM_PGA("Tone Generator 1", MADERA_TONE_GENERATOR_1, 710 MADERA_TONE1_ENA_SHIFT, 0, NULL, 0), 711 SND_SOC_DAPM_PGA("Tone Generator 2", MADERA_TONE_GENERATOR_1, 712 MADERA_TONE2_ENA_SHIFT, 0, NULL, 0), 713 714 SND_SOC_DAPM_SIGGEN("HAPTICS"), 715 716 SND_SOC_DAPM_MUX("AEC1 Loopback", MADERA_DAC_AEC_CONTROL_1, 717 MADERA_AEC1_LOOPBACK_ENA_SHIFT, 0, 718 &cs47l35_aec_loopback_mux[0]), 719 720 SND_SOC_DAPM_MUX("AEC2 Loopback", MADERA_DAC_AEC_CONTROL_2, 721 MADERA_AEC2_LOOPBACK_ENA_SHIFT, 0, 722 &cs47l35_aec_loopback_mux[1]), 723 724 SND_SOC_DAPM_PGA_E("IN1L", MADERA_INPUT_ENABLES, MADERA_IN1L_ENA_SHIFT, 725 0, NULL, 0, madera_in_ev, 726 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 727 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 728 SND_SOC_DAPM_PGA_E("IN1R", MADERA_INPUT_ENABLES, MADERA_IN1R_ENA_SHIFT, 729 0, NULL, 0, madera_in_ev, 730 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 731 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 732 733 SND_SOC_DAPM_PGA_E("IN2L", MADERA_INPUT_ENABLES, MADERA_IN2L_ENA_SHIFT, 734 0, NULL, 0, madera_in_ev, 735 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 736 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 737 SND_SOC_DAPM_PGA_E("IN2R", MADERA_INPUT_ENABLES, MADERA_IN2R_ENA_SHIFT, 738 0, NULL, 0, madera_in_ev, 739 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 740 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 741 742 SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0, 743 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX1_ENA_SHIFT, 0), 744 SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 1, 745 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX2_ENA_SHIFT, 0), 746 SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 2, 747 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX3_ENA_SHIFT, 0), 748 SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 3, 749 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX4_ENA_SHIFT, 0), 750 SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 4, 751 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX5_ENA_SHIFT, 0), 752 SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 5, 753 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX6_ENA_SHIFT, 0), 754 755 SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0, 756 MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX1_ENA_SHIFT, 0), 757 SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 1, 758 MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX2_ENA_SHIFT, 0), 759 760 SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0, 761 MADERA_AIF3_RX_ENABLES, MADERA_AIF3RX1_ENA_SHIFT, 0), 762 SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 1, 763 MADERA_AIF3_RX_ENABLES, MADERA_AIF3RX2_ENA_SHIFT, 0), 764 765 SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0, 766 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 767 MADERA_SLIMRX1_ENA_SHIFT, 0), 768 SND_SOC_DAPM_AIF_IN("SLIMRX2", NULL, 1, 769 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 770 MADERA_SLIMRX2_ENA_SHIFT, 0), 771 SND_SOC_DAPM_AIF_IN("SLIMRX3", NULL, 2, 772 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 773 MADERA_SLIMRX3_ENA_SHIFT, 0), 774 SND_SOC_DAPM_AIF_IN("SLIMRX4", NULL, 3, 775 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 776 MADERA_SLIMRX4_ENA_SHIFT, 0), 777 SND_SOC_DAPM_AIF_IN("SLIMRX5", NULL, 4, 778 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 779 MADERA_SLIMRX5_ENA_SHIFT, 0), 780 SND_SOC_DAPM_AIF_IN("SLIMRX6", NULL, 5, 781 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 782 MADERA_SLIMRX6_ENA_SHIFT, 0), 783 784 SND_SOC_DAPM_PGA("EQ1", MADERA_EQ1_1, MADERA_EQ1_ENA_SHIFT, 0, NULL, 0), 785 SND_SOC_DAPM_PGA("EQ2", MADERA_EQ2_1, MADERA_EQ2_ENA_SHIFT, 0, NULL, 0), 786 SND_SOC_DAPM_PGA("EQ3", MADERA_EQ3_1, MADERA_EQ3_ENA_SHIFT, 0, NULL, 0), 787 SND_SOC_DAPM_PGA("EQ4", MADERA_EQ4_1, MADERA_EQ4_ENA_SHIFT, 0, NULL, 0), 788 789 SND_SOC_DAPM_PGA("DRC1L", MADERA_DRC1_CTRL1, MADERA_DRC1L_ENA_SHIFT, 0, 790 NULL, 0), 791 SND_SOC_DAPM_PGA("DRC1R", MADERA_DRC1_CTRL1, MADERA_DRC1R_ENA_SHIFT, 0, 792 NULL, 0), 793 SND_SOC_DAPM_PGA("DRC2L", MADERA_DRC2_CTRL1, MADERA_DRC2L_ENA_SHIFT, 0, 794 NULL, 0), 795 SND_SOC_DAPM_PGA("DRC2R", MADERA_DRC2_CTRL1, MADERA_DRC2R_ENA_SHIFT, 0, 796 NULL, 0), 797 798 SND_SOC_DAPM_PGA("LHPF1", MADERA_HPLPF1_1, MADERA_LHPF1_ENA_SHIFT, 0, 799 NULL, 0), 800 SND_SOC_DAPM_PGA("LHPF2", MADERA_HPLPF2_1, MADERA_LHPF2_ENA_SHIFT, 0, 801 NULL, 0), 802 SND_SOC_DAPM_PGA("LHPF3", MADERA_HPLPF3_1, MADERA_LHPF3_ENA_SHIFT, 0, 803 NULL, 0), 804 SND_SOC_DAPM_PGA("LHPF4", MADERA_HPLPF4_1, MADERA_LHPF4_ENA_SHIFT, 0, 805 NULL, 0), 806 807 SND_SOC_DAPM_PGA("ISRC1DEC1", MADERA_ISRC_1_CTRL_3, 808 MADERA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0), 809 SND_SOC_DAPM_PGA("ISRC1DEC2", MADERA_ISRC_1_CTRL_3, 810 MADERA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0), 811 SND_SOC_DAPM_PGA("ISRC1DEC3", MADERA_ISRC_1_CTRL_3, 812 MADERA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0), 813 SND_SOC_DAPM_PGA("ISRC1DEC4", MADERA_ISRC_1_CTRL_3, 814 MADERA_ISRC1_DEC4_ENA_SHIFT, 0, NULL, 0), 815 816 SND_SOC_DAPM_PGA("ISRC1INT1", MADERA_ISRC_1_CTRL_3, 817 MADERA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0), 818 SND_SOC_DAPM_PGA("ISRC1INT2", MADERA_ISRC_1_CTRL_3, 819 MADERA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0), 820 SND_SOC_DAPM_PGA("ISRC1INT3", MADERA_ISRC_1_CTRL_3, 821 MADERA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0), 822 SND_SOC_DAPM_PGA("ISRC1INT4", MADERA_ISRC_1_CTRL_3, 823 MADERA_ISRC1_INT4_ENA_SHIFT, 0, NULL, 0), 824 825 SND_SOC_DAPM_PGA("ISRC2DEC1", MADERA_ISRC_2_CTRL_3, 826 MADERA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0), 827 SND_SOC_DAPM_PGA("ISRC2DEC2", MADERA_ISRC_2_CTRL_3, 828 MADERA_ISRC2_DEC2_ENA_SHIFT, 0, NULL, 0), 829 SND_SOC_DAPM_PGA("ISRC2DEC3", MADERA_ISRC_2_CTRL_3, 830 MADERA_ISRC2_DEC3_ENA_SHIFT, 0, NULL, 0), 831 SND_SOC_DAPM_PGA("ISRC2DEC4", MADERA_ISRC_2_CTRL_3, 832 MADERA_ISRC2_DEC4_ENA_SHIFT, 0, NULL, 0), 833 834 SND_SOC_DAPM_PGA("ISRC2INT1", MADERA_ISRC_2_CTRL_3, 835 MADERA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0), 836 SND_SOC_DAPM_PGA("ISRC2INT2", MADERA_ISRC_2_CTRL_3, 837 MADERA_ISRC2_INT2_ENA_SHIFT, 0, NULL, 0), 838 SND_SOC_DAPM_PGA("ISRC2INT3", MADERA_ISRC_2_CTRL_3, 839 MADERA_ISRC2_INT3_ENA_SHIFT, 0, NULL, 0), 840 SND_SOC_DAPM_PGA("ISRC2INT4", MADERA_ISRC_2_CTRL_3, 841 MADERA_ISRC2_INT4_ENA_SHIFT, 0, NULL, 0), 842 843 WM_ADSP2("DSP1", 0, cs47l35_adsp_power_ev), 844 WM_ADSP2("DSP2", 1, cs47l35_adsp_power_ev), 845 WM_ADSP2("DSP3", 2, cs47l35_adsp_power_ev), 846 847 /* End of ordered input mux widgets */ 848 849 MADERA_MIXER_WIDGETS(EQ1, "EQ1"), 850 MADERA_MIXER_WIDGETS(EQ2, "EQ2"), 851 MADERA_MIXER_WIDGETS(EQ3, "EQ3"), 852 MADERA_MIXER_WIDGETS(EQ4, "EQ4"), 853 854 MADERA_MIXER_WIDGETS(DRC1L, "DRC1L"), 855 MADERA_MIXER_WIDGETS(DRC1R, "DRC1R"), 856 MADERA_MIXER_WIDGETS(DRC2L, "DRC2L"), 857 MADERA_MIXER_WIDGETS(DRC2R, "DRC2R"), 858 859 SND_SOC_DAPM_SWITCH("DRC1 Activity Output", SND_SOC_NOPM, 0, 0, 860 &madera_drc_activity_output_mux[0]), 861 SND_SOC_DAPM_SWITCH("DRC2 Activity Output", SND_SOC_NOPM, 0, 0, 862 &madera_drc_activity_output_mux[1]), 863 864 MADERA_MIXER_WIDGETS(LHPF1, "LHPF1"), 865 MADERA_MIXER_WIDGETS(LHPF2, "LHPF2"), 866 MADERA_MIXER_WIDGETS(LHPF3, "LHPF3"), 867 MADERA_MIXER_WIDGETS(LHPF4, "LHPF4"), 868 869 MADERA_MIXER_WIDGETS(PWM1, "PWM1"), 870 MADERA_MIXER_WIDGETS(PWM2, "PWM2"), 871 872 MADERA_MIXER_WIDGETS(OUT1L, "HPOUT1L"), 873 MADERA_MIXER_WIDGETS(OUT1R, "HPOUT1R"), 874 MADERA_MIXER_WIDGETS(SPKOUT, "SPKOUT"), 875 MADERA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"), 876 MADERA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"), 877 878 MADERA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"), 879 MADERA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"), 880 MADERA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"), 881 MADERA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"), 882 MADERA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"), 883 MADERA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"), 884 885 MADERA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"), 886 MADERA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"), 887 888 MADERA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), 889 MADERA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), 890 891 MADERA_MIXER_WIDGETS(SLIMTX1, "SLIMTX1"), 892 MADERA_MIXER_WIDGETS(SLIMTX2, "SLIMTX2"), 893 MADERA_MIXER_WIDGETS(SLIMTX3, "SLIMTX3"), 894 MADERA_MIXER_WIDGETS(SLIMTX4, "SLIMTX4"), 895 MADERA_MIXER_WIDGETS(SLIMTX5, "SLIMTX5"), 896 MADERA_MIXER_WIDGETS(SLIMTX6, "SLIMTX6"), 897 898 MADERA_MUX_WIDGETS(SPD1TX1, "SPDIF1TX1"), 899 MADERA_MUX_WIDGETS(SPD1TX2, "SPDIF1TX2"), 900 901 MADERA_DSP_WIDGETS(DSP1, "DSP1"), 902 MADERA_DSP_WIDGETS(DSP2, "DSP2"), 903 MADERA_DSP_WIDGETS(DSP3, "DSP3"), 904 905 SND_SOC_DAPM_SWITCH("DSP1 Trigger Output", SND_SOC_NOPM, 0, 0, 906 &madera_dsp_trigger_output_mux[0]), 907 SND_SOC_DAPM_SWITCH("DSP2 Trigger Output", SND_SOC_NOPM, 0, 0, 908 &madera_dsp_trigger_output_mux[1]), 909 SND_SOC_DAPM_SWITCH("DSP3 Trigger Output", SND_SOC_NOPM, 0, 0, 910 &madera_dsp_trigger_output_mux[2]), 911 912 MADERA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"), 913 MADERA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"), 914 MADERA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"), 915 MADERA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"), 916 917 MADERA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"), 918 MADERA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"), 919 MADERA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"), 920 MADERA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"), 921 922 MADERA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"), 923 MADERA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"), 924 MADERA_MUX_WIDGETS(ISRC2DEC3, "ISRC2DEC3"), 925 MADERA_MUX_WIDGETS(ISRC2DEC4, "ISRC2DEC4"), 926 927 MADERA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"), 928 MADERA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"), 929 MADERA_MUX_WIDGETS(ISRC2INT3, "ISRC2INT3"), 930 MADERA_MUX_WIDGETS(ISRC2INT4, "ISRC2INT4"), 931 932 SND_SOC_DAPM_OUTPUT("HPOUTL"), 933 SND_SOC_DAPM_OUTPUT("HPOUTR"), 934 SND_SOC_DAPM_OUTPUT("EPOUTP"), 935 SND_SOC_DAPM_OUTPUT("EPOUTN"), 936 SND_SOC_DAPM_OUTPUT("SPKOUTN"), 937 SND_SOC_DAPM_OUTPUT("SPKOUTP"), 938 SND_SOC_DAPM_OUTPUT("SPKDAT1L"), 939 SND_SOC_DAPM_OUTPUT("SPKDAT1R"), 940 SND_SOC_DAPM_OUTPUT("SPDIF1"), 941 942 SND_SOC_DAPM_OUTPUT("MICSUPP"), 943 }; 944 945 #define MADERA_MIXER_INPUT_ROUTES(name) \ 946 { name, "Noise Generator", "Noise Generator" }, \ 947 { name, "Tone Generator 1", "Tone Generator 1" }, \ 948 { name, "Tone Generator 2", "Tone Generator 2" }, \ 949 { name, "Haptics", "HAPTICS" }, \ 950 { name, "AEC1", "AEC1 Loopback" }, \ 951 { name, "AEC2", "AEC2 Loopback" }, \ 952 { name, "IN1L", "IN1L" }, \ 953 { name, "IN1R", "IN1R" }, \ 954 { name, "IN2L", "IN2L" }, \ 955 { name, "IN2R", "IN2R" }, \ 956 { name, "AIF1RX1", "AIF1RX1" }, \ 957 { name, "AIF1RX2", "AIF1RX2" }, \ 958 { name, "AIF1RX3", "AIF1RX3" }, \ 959 { name, "AIF1RX4", "AIF1RX4" }, \ 960 { name, "AIF1RX5", "AIF1RX5" }, \ 961 { name, "AIF1RX6", "AIF1RX6" }, \ 962 { name, "AIF2RX1", "AIF2RX1" }, \ 963 { name, "AIF2RX2", "AIF2RX2" }, \ 964 { name, "AIF3RX1", "AIF3RX1" }, \ 965 { name, "AIF3RX2", "AIF3RX2" }, \ 966 { name, "SLIMRX1", "SLIMRX1" }, \ 967 { name, "SLIMRX2", "SLIMRX2" }, \ 968 { name, "SLIMRX3", "SLIMRX3" }, \ 969 { name, "SLIMRX4", "SLIMRX4" }, \ 970 { name, "SLIMRX5", "SLIMRX5" }, \ 971 { name, "SLIMRX6", "SLIMRX6" }, \ 972 { name, "EQ1", "EQ1" }, \ 973 { name, "EQ2", "EQ2" }, \ 974 { name, "EQ3", "EQ3" }, \ 975 { name, "EQ4", "EQ4" }, \ 976 { name, "DRC1L", "DRC1L" }, \ 977 { name, "DRC1R", "DRC1R" }, \ 978 { name, "DRC2L", "DRC2L" }, \ 979 { name, "DRC2R", "DRC2R" }, \ 980 { name, "LHPF1", "LHPF1" }, \ 981 { name, "LHPF2", "LHPF2" }, \ 982 { name, "LHPF3", "LHPF3" }, \ 983 { name, "LHPF4", "LHPF4" }, \ 984 { name, "ISRC1DEC1", "ISRC1DEC1" }, \ 985 { name, "ISRC1DEC2", "ISRC1DEC2" }, \ 986 { name, "ISRC1DEC3", "ISRC1DEC3" }, \ 987 { name, "ISRC1DEC4", "ISRC1DEC4" }, \ 988 { name, "ISRC1INT1", "ISRC1INT1" }, \ 989 { name, "ISRC1INT2", "ISRC1INT2" }, \ 990 { name, "ISRC1INT3", "ISRC1INT3" }, \ 991 { name, "ISRC1INT4", "ISRC1INT4" }, \ 992 { name, "ISRC2DEC1", "ISRC2DEC1" }, \ 993 { name, "ISRC2DEC2", "ISRC2DEC2" }, \ 994 { name, "ISRC2DEC3", "ISRC2DEC3" }, \ 995 { name, "ISRC2DEC4", "ISRC2DEC4" }, \ 996 { name, "ISRC2INT1", "ISRC2INT1" }, \ 997 { name, "ISRC2INT2", "ISRC2INT2" }, \ 998 { name, "ISRC2INT3", "ISRC2INT3" }, \ 999 { name, "ISRC2INT4", "ISRC2INT4" }, \ 1000 { name, "DSP1.1", "DSP1" }, \ 1001 { name, "DSP1.2", "DSP1" }, \ 1002 { name, "DSP1.3", "DSP1" }, \ 1003 { name, "DSP1.4", "DSP1" }, \ 1004 { name, "DSP1.5", "DSP1" }, \ 1005 { name, "DSP1.6", "DSP1" }, \ 1006 { name, "DSP2.1", "DSP2" }, \ 1007 { name, "DSP2.2", "DSP2" }, \ 1008 { name, "DSP2.3", "DSP2" }, \ 1009 { name, "DSP2.4", "DSP2" }, \ 1010 { name, "DSP2.5", "DSP2" }, \ 1011 { name, "DSP2.6", "DSP2" }, \ 1012 { name, "DSP3.1", "DSP3" }, \ 1013 { name, "DSP3.2", "DSP3" }, \ 1014 { name, "DSP3.3", "DSP3" }, \ 1015 { name, "DSP3.4", "DSP3" }, \ 1016 { name, "DSP3.5", "DSP3" }, \ 1017 { name, "DSP3.6", "DSP3" } 1018 1019 static const struct snd_soc_dapm_route cs47l35_dapm_routes[] = { 1020 /* Internal clock domains */ 1021 { "EQ1", NULL, "FXCLK" }, 1022 { "EQ2", NULL, "FXCLK" }, 1023 { "EQ3", NULL, "FXCLK" }, 1024 { "EQ4", NULL, "FXCLK" }, 1025 { "DRC1L", NULL, "FXCLK" }, 1026 { "DRC1R", NULL, "FXCLK" }, 1027 { "DRC2L", NULL, "FXCLK" }, 1028 { "DRC2R", NULL, "FXCLK" }, 1029 { "LHPF1", NULL, "FXCLK" }, 1030 { "LHPF2", NULL, "FXCLK" }, 1031 { "LHPF3", NULL, "FXCLK" }, 1032 { "LHPF4", NULL, "FXCLK" }, 1033 { "PWM1 Mixer", NULL, "PWMCLK" }, 1034 { "PWM2 Mixer", NULL, "PWMCLK" }, 1035 { "OUT1L", NULL, "OUTCLK" }, 1036 { "OUT1R", NULL, "OUTCLK" }, 1037 { "OUT4L", NULL, "OUTCLK" }, 1038 { "OUT5L", NULL, "OUTCLK" }, 1039 { "OUT5R", NULL, "OUTCLK" }, 1040 { "AIF1TX1", NULL, "AIF1TXCLK" }, 1041 { "AIF1TX2", NULL, "AIF1TXCLK" }, 1042 { "AIF1TX3", NULL, "AIF1TXCLK" }, 1043 { "AIF1TX4", NULL, "AIF1TXCLK" }, 1044 { "AIF1TX5", NULL, "AIF1TXCLK" }, 1045 { "AIF1TX6", NULL, "AIF1TXCLK" }, 1046 { "AIF2TX1", NULL, "AIF2TXCLK" }, 1047 { "AIF2TX2", NULL, "AIF2TXCLK" }, 1048 { "AIF3TX1", NULL, "AIF3TXCLK" }, 1049 { "AIF3TX2", NULL, "AIF3TXCLK" }, 1050 { "SLIMTX1", NULL, "SLIMBUSCLK" }, 1051 { "SLIMTX2", NULL, "SLIMBUSCLK" }, 1052 { "SLIMTX3", NULL, "SLIMBUSCLK" }, 1053 { "SLIMTX4", NULL, "SLIMBUSCLK" }, 1054 { "SLIMTX5", NULL, "SLIMBUSCLK" }, 1055 { "SLIMTX6", NULL, "SLIMBUSCLK" }, 1056 { "SPD1TX1", NULL, "SPDCLK" }, 1057 { "SPD1TX2", NULL, "SPDCLK" }, 1058 { "DSP1", NULL, "DSP1CLK" }, 1059 { "DSP2", NULL, "DSP2CLK" }, 1060 { "DSP3", NULL, "DSP3CLK" }, 1061 { "ISRC1DEC1", NULL, "ISRC1CLK" }, 1062 { "ISRC1DEC2", NULL, "ISRC1CLK" }, 1063 { "ISRC1DEC3", NULL, "ISRC1CLK" }, 1064 { "ISRC1DEC4", NULL, "ISRC1CLK" }, 1065 { "ISRC1INT1", NULL, "ISRC1CLK" }, 1066 { "ISRC1INT2", NULL, "ISRC1CLK" }, 1067 { "ISRC1INT3", NULL, "ISRC1CLK" }, 1068 { "ISRC1INT4", NULL, "ISRC1CLK" }, 1069 { "ISRC2DEC1", NULL, "ISRC2CLK" }, 1070 { "ISRC2DEC2", NULL, "ISRC2CLK" }, 1071 { "ISRC2DEC3", NULL, "ISRC2CLK" }, 1072 { "ISRC2DEC4", NULL, "ISRC2CLK" }, 1073 { "ISRC2INT1", NULL, "ISRC2CLK" }, 1074 { "ISRC2INT2", NULL, "ISRC2CLK" }, 1075 { "ISRC2INT3", NULL, "ISRC2CLK" }, 1076 { "ISRC2INT4", NULL, "ISRC2CLK" }, 1077 1078 { "AIF2 Capture", NULL, "DBVDD2" }, 1079 { "AIF2 Playback", NULL, "DBVDD2" }, 1080 1081 { "AIF3 Capture", NULL, "DBVDD2" }, 1082 { "AIF3 Playback", NULL, "DBVDD2" }, 1083 1084 { "OUT1L", NULL, "CPVDD1" }, 1085 { "OUT1R", NULL, "CPVDD1" }, 1086 { "OUT1L", NULL, "CPVDD2" }, 1087 { "OUT1R", NULL, "CPVDD2" }, 1088 1089 { "OUT4L", NULL, "SPKVDD" }, 1090 1091 { "OUT1L", NULL, "SYSCLK" }, 1092 { "OUT1R", NULL, "SYSCLK" }, 1093 { "OUT4L", NULL, "SYSCLK" }, 1094 { "OUT5L", NULL, "SYSCLK" }, 1095 { "OUT5R", NULL, "SYSCLK" }, 1096 1097 { "SPD1", NULL, "SYSCLK" }, 1098 { "SPD1", NULL, "SPD1TX1" }, 1099 { "SPD1", NULL, "SPD1TX2" }, 1100 1101 { "IN1L", NULL, "SYSCLK" }, 1102 { "IN1R", NULL, "SYSCLK" }, 1103 { "IN2L", NULL, "SYSCLK" }, 1104 { "IN2R", NULL, "SYSCLK" }, 1105 1106 { "MICBIAS1", NULL, "MICVDD" }, 1107 { "MICBIAS2", NULL, "MICVDD" }, 1108 1109 { "MICBIAS1A", NULL, "MICBIAS1" }, 1110 { "MICBIAS1B", NULL, "MICBIAS1" }, 1111 { "MICBIAS2A", NULL, "MICBIAS2" }, 1112 { "MICBIAS2B", NULL, "MICBIAS2" }, 1113 1114 { "Noise Generator", NULL, "SYSCLK" }, 1115 { "Tone Generator 1", NULL, "SYSCLK" }, 1116 { "Tone Generator 2", NULL, "SYSCLK" }, 1117 1118 { "Noise Generator", NULL, "NOISE" }, 1119 { "Tone Generator 1", NULL, "TONE" }, 1120 { "Tone Generator 2", NULL, "TONE" }, 1121 1122 { "AIF1 Capture", NULL, "AIF1TX1" }, 1123 { "AIF1 Capture", NULL, "AIF1TX2" }, 1124 { "AIF1 Capture", NULL, "AIF1TX3" }, 1125 { "AIF1 Capture", NULL, "AIF1TX4" }, 1126 { "AIF1 Capture", NULL, "AIF1TX5" }, 1127 { "AIF1 Capture", NULL, "AIF1TX6" }, 1128 1129 { "AIF1RX1", NULL, "AIF1 Playback" }, 1130 { "AIF1RX2", NULL, "AIF1 Playback" }, 1131 { "AIF1RX3", NULL, "AIF1 Playback" }, 1132 { "AIF1RX4", NULL, "AIF1 Playback" }, 1133 { "AIF1RX5", NULL, "AIF1 Playback" }, 1134 { "AIF1RX6", NULL, "AIF1 Playback" }, 1135 1136 { "AIF2 Capture", NULL, "AIF2TX1" }, 1137 { "AIF2 Capture", NULL, "AIF2TX2" }, 1138 1139 { "AIF2RX1", NULL, "AIF2 Playback" }, 1140 { "AIF2RX2", NULL, "AIF2 Playback" }, 1141 1142 { "AIF3 Capture", NULL, "AIF3TX1" }, 1143 { "AIF3 Capture", NULL, "AIF3TX2" }, 1144 1145 { "AIF3RX1", NULL, "AIF3 Playback" }, 1146 { "AIF3RX2", NULL, "AIF3 Playback" }, 1147 1148 { "Slim1 Capture", NULL, "SLIMTX1" }, 1149 { "Slim1 Capture", NULL, "SLIMTX2" }, 1150 { "Slim1 Capture", NULL, "SLIMTX3" }, 1151 { "Slim1 Capture", NULL, "SLIMTX4" }, 1152 1153 { "SLIMRX1", NULL, "Slim1 Playback" }, 1154 { "SLIMRX2", NULL, "Slim1 Playback" }, 1155 { "SLIMRX3", NULL, "Slim1 Playback" }, 1156 { "SLIMRX4", NULL, "Slim1 Playback" }, 1157 1158 { "Slim2 Capture", NULL, "SLIMTX5" }, 1159 { "Slim2 Capture", NULL, "SLIMTX6" }, 1160 1161 { "SLIMRX5", NULL, "Slim2 Playback" }, 1162 { "SLIMRX6", NULL, "Slim2 Playback" }, 1163 1164 { "AIF1 Playback", NULL, "SYSCLK" }, 1165 { "AIF2 Playback", NULL, "SYSCLK" }, 1166 { "AIF3 Playback", NULL, "SYSCLK" }, 1167 { "Slim1 Playback", NULL, "SYSCLK" }, 1168 { "Slim2 Playback", NULL, "SYSCLK" }, 1169 1170 { "AIF1 Capture", NULL, "SYSCLK" }, 1171 { "AIF2 Capture", NULL, "SYSCLK" }, 1172 { "AIF3 Capture", NULL, "SYSCLK" }, 1173 { "Slim1 Capture", NULL, "SYSCLK" }, 1174 { "Slim2 Capture", NULL, "SYSCLK" }, 1175 1176 { "Voice Control DSP", NULL, "DSP3" }, 1177 1178 { "Audio Trace DSP", NULL, "DSP1" }, 1179 1180 { "IN1L Analog Mux", "A", "IN1ALN" }, 1181 { "IN1L Analog Mux", "A", "IN1ALP" }, 1182 { "IN1L Analog Mux", "B", "IN1BLN" }, 1183 { "IN1L Analog Mux", "B", "IN1BLP" }, 1184 1185 { "IN1R Analog Mux", "A", "IN1ARN" }, 1186 { "IN1R Analog Mux", "A", "IN1ARP" }, 1187 { "IN1R Analog Mux", "B", "IN1BRN" }, 1188 { "IN1R Analog Mux", "B", "IN1BRP" }, 1189 1190 { "IN1L Mode", "Analog", "IN1L Analog Mux" }, 1191 { "IN1R Mode", "Analog", "IN1R Analog Mux" }, 1192 1193 { "IN1L Mode", "Digital", "IN1ALN" }, 1194 { "IN1L Mode", "Digital", "IN1ARN" }, 1195 { "IN1R Mode", "Digital", "IN1ALN" }, 1196 { "IN1R Mode", "Digital", "IN1ARN" }, 1197 1198 { "IN1L", NULL, "IN1L Mode" }, 1199 { "IN1R", NULL, "IN1R Mode" }, 1200 1201 { "IN2L Mode", "Analog", "IN2LN" }, 1202 { "IN2L Mode", "Analog", "IN2LP" }, 1203 { "IN2R Mode", "Analog", "IN2RN" }, 1204 { "IN2R Mode", "Analog", "IN2RP" }, 1205 1206 { "IN2L Mode", "Digital", "IN2LN" }, 1207 { "IN2L Mode", "Digital", "IN2RN" }, 1208 { "IN2R Mode", "Digital", "IN2LN" }, 1209 { "IN2R Mode", "Digital", "IN2RN" }, 1210 1211 { "IN2L", NULL, "IN2L Mode" }, 1212 { "IN2R", NULL, "IN2R Mode" }, 1213 1214 MADERA_MIXER_ROUTES("OUT1L", "HPOUT1L"), 1215 MADERA_MIXER_ROUTES("OUT1R", "HPOUT1R"), 1216 1217 MADERA_MIXER_ROUTES("OUT4L", "SPKOUT"), 1218 1219 MADERA_MIXER_ROUTES("OUT5L", "SPKDAT1L"), 1220 MADERA_MIXER_ROUTES("OUT5R", "SPKDAT1R"), 1221 1222 MADERA_MIXER_ROUTES("PWM1 Driver", "PWM1"), 1223 MADERA_MIXER_ROUTES("PWM2 Driver", "PWM2"), 1224 1225 MADERA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"), 1226 MADERA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"), 1227 MADERA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"), 1228 MADERA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"), 1229 MADERA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"), 1230 MADERA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"), 1231 1232 MADERA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"), 1233 MADERA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"), 1234 1235 MADERA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"), 1236 MADERA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"), 1237 1238 MADERA_MIXER_ROUTES("SLIMTX1", "SLIMTX1"), 1239 MADERA_MIXER_ROUTES("SLIMTX2", "SLIMTX2"), 1240 MADERA_MIXER_ROUTES("SLIMTX3", "SLIMTX3"), 1241 MADERA_MIXER_ROUTES("SLIMTX4", "SLIMTX4"), 1242 MADERA_MIXER_ROUTES("SLIMTX5", "SLIMTX5"), 1243 MADERA_MIXER_ROUTES("SLIMTX6", "SLIMTX6"), 1244 1245 MADERA_MUX_ROUTES("SPD1TX1", "SPDIF1TX1"), 1246 MADERA_MUX_ROUTES("SPD1TX2", "SPDIF1TX2"), 1247 1248 MADERA_MIXER_ROUTES("EQ1", "EQ1"), 1249 MADERA_MIXER_ROUTES("EQ2", "EQ2"), 1250 MADERA_MIXER_ROUTES("EQ3", "EQ3"), 1251 MADERA_MIXER_ROUTES("EQ4", "EQ4"), 1252 1253 MADERA_MIXER_ROUTES("DRC1L", "DRC1L"), 1254 MADERA_MIXER_ROUTES("DRC1R", "DRC1R"), 1255 MADERA_MIXER_ROUTES("DRC2L", "DRC2L"), 1256 MADERA_MIXER_ROUTES("DRC2R", "DRC2R"), 1257 1258 MADERA_MIXER_ROUTES("LHPF1", "LHPF1"), 1259 MADERA_MIXER_ROUTES("LHPF2", "LHPF2"), 1260 MADERA_MIXER_ROUTES("LHPF3", "LHPF3"), 1261 MADERA_MIXER_ROUTES("LHPF4", "LHPF4"), 1262 1263 MADERA_DSP_ROUTES("DSP1"), 1264 MADERA_DSP_ROUTES("DSP2"), 1265 MADERA_DSP_ROUTES("DSP3"), 1266 1267 { "DSP Trigger Out", NULL, "DSP1 Trigger Output" }, 1268 { "DSP Trigger Out", NULL, "DSP2 Trigger Output" }, 1269 { "DSP Trigger Out", NULL, "DSP3 Trigger Output" }, 1270 1271 { "DSP1 Trigger Output", "Switch", "DSP1" }, 1272 { "DSP2 Trigger Output", "Switch", "DSP2" }, 1273 { "DSP3 Trigger Output", "Switch", "DSP3" }, 1274 1275 MADERA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"), 1276 MADERA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"), 1277 MADERA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"), 1278 MADERA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"), 1279 1280 MADERA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"), 1281 MADERA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"), 1282 MADERA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"), 1283 MADERA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"), 1284 1285 MADERA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"), 1286 MADERA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"), 1287 MADERA_MUX_ROUTES("ISRC2INT3", "ISRC2INT3"), 1288 MADERA_MUX_ROUTES("ISRC2INT4", "ISRC2INT4"), 1289 1290 MADERA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"), 1291 MADERA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"), 1292 MADERA_MUX_ROUTES("ISRC2DEC3", "ISRC2DEC3"), 1293 MADERA_MUX_ROUTES("ISRC2DEC4", "ISRC2DEC4"), 1294 1295 { "AEC1 Loopback", "HPOUT1L", "OUT1L" }, 1296 { "AEC1 Loopback", "HPOUT1R", "OUT1R" }, 1297 { "AEC2 Loopback", "HPOUT1L", "OUT1L" }, 1298 { "AEC2 Loopback", "HPOUT1R", "OUT1R" }, 1299 { "HPOUT1 Demux", NULL, "OUT1L" }, 1300 { "HPOUT1 Demux", NULL, "OUT1R" }, 1301 1302 { "AEC1 Loopback", "SPKOUT", "OUT4L" }, 1303 { "AEC2 Loopback", "SPKOUT", "OUT4L" }, 1304 { "SPKOUTN", NULL, "OUT4L" }, 1305 { "SPKOUTP", NULL, "OUT4L" }, 1306 1307 { "OUT1R", NULL, "HPOUT1 Mono Mux" }, 1308 1309 { "HPOUTL", "HPOUT", "HPOUT1 Demux" }, 1310 { "HPOUTR", "HPOUT", "HPOUT1 Demux" }, 1311 { "EPOUTP", "EPOUT", "HPOUT1 Demux" }, 1312 { "EPOUTN", "EPOUT", "HPOUT1 Demux" }, 1313 1314 { "AEC1 Loopback", "SPKDAT1L", "OUT5L" }, 1315 { "AEC1 Loopback", "SPKDAT1R", "OUT5R" }, 1316 { "AEC2 Loopback", "SPKDAT1L", "OUT5L" }, 1317 { "AEC2 Loopback", "SPKDAT1R", "OUT5R" }, 1318 { "SPKDAT1L", NULL, "OUT5L" }, 1319 { "SPKDAT1R", NULL, "OUT5R" }, 1320 1321 { "SPDIF1", NULL, "SPD1" }, 1322 1323 { "MICSUPP", NULL, "SYSCLK" }, 1324 1325 { "DRC1 Signal Activity", NULL, "DRC1 Activity Output" }, 1326 { "DRC2 Signal Activity", NULL, "DRC2 Activity Output" }, 1327 { "DRC1 Activity Output", "Switch", "DRC1L" }, 1328 { "DRC1 Activity Output", "Switch", "DRC1R" }, 1329 { "DRC2 Activity Output", "Switch", "DRC2L" }, 1330 { "DRC2 Activity Output", "Switch", "DRC2R" }, 1331 }; 1332 1333 static int cs47l35_set_fll(struct snd_soc_component *component, int fll_id, 1334 int source, unsigned int fref, unsigned int fout) 1335 { 1336 struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); 1337 1338 switch (fll_id) { 1339 case MADERA_FLL1_REFCLK: 1340 return madera_set_fll_refclk(&cs47l35->fll, source, fref, 1341 fout); 1342 case MADERA_FLL1_SYNCCLK: 1343 return madera_set_fll_syncclk(&cs47l35->fll, source, fref, 1344 fout); 1345 default: 1346 return -EINVAL; 1347 } 1348 } 1349 1350 static struct snd_soc_dai_driver cs47l35_dai[] = { 1351 { 1352 .name = "cs47l35-aif1", 1353 .id = 1, 1354 .base = MADERA_AIF1_BCLK_CTRL, 1355 .playback = { 1356 .stream_name = "AIF1 Playback", 1357 .channels_min = 1, 1358 .channels_max = 6, 1359 .rates = MADERA_RATES, 1360 .formats = MADERA_FORMATS, 1361 }, 1362 .capture = { 1363 .stream_name = "AIF1 Capture", 1364 .channels_min = 1, 1365 .channels_max = 6, 1366 .rates = MADERA_RATES, 1367 .formats = MADERA_FORMATS, 1368 }, 1369 .ops = &madera_dai_ops, 1370 .symmetric_rates = 1, 1371 .symmetric_samplebits = 1, 1372 }, 1373 { 1374 .name = "cs47l35-aif2", 1375 .id = 2, 1376 .base = MADERA_AIF2_BCLK_CTRL, 1377 .playback = { 1378 .stream_name = "AIF2 Playback", 1379 .channels_min = 1, 1380 .channels_max = 2, 1381 .rates = MADERA_RATES, 1382 .formats = MADERA_FORMATS, 1383 }, 1384 .capture = { 1385 .stream_name = "AIF2 Capture", 1386 .channels_min = 1, 1387 .channels_max = 2, 1388 .rates = MADERA_RATES, 1389 .formats = MADERA_FORMATS, 1390 }, 1391 .ops = &madera_dai_ops, 1392 .symmetric_rates = 1, 1393 .symmetric_samplebits = 1, 1394 }, 1395 { 1396 .name = "cs47l35-aif3", 1397 .id = 3, 1398 .base = MADERA_AIF3_BCLK_CTRL, 1399 .playback = { 1400 .stream_name = "AIF3 Playback", 1401 .channels_min = 1, 1402 .channels_max = 2, 1403 .rates = MADERA_RATES, 1404 .formats = MADERA_FORMATS, 1405 }, 1406 .capture = { 1407 .stream_name = "AIF3 Capture", 1408 .channels_min = 1, 1409 .channels_max = 2, 1410 .rates = MADERA_RATES, 1411 .formats = MADERA_FORMATS, 1412 }, 1413 .ops = &madera_dai_ops, 1414 .symmetric_rates = 1, 1415 .symmetric_samplebits = 1, 1416 }, 1417 { 1418 .name = "cs47l35-slim1", 1419 .id = 4, 1420 .playback = { 1421 .stream_name = "Slim1 Playback", 1422 .channels_min = 1, 1423 .channels_max = 4, 1424 .rates = MADERA_RATES, 1425 .formats = MADERA_FORMATS, 1426 }, 1427 .capture = { 1428 .stream_name = "Slim1 Capture", 1429 .channels_min = 1, 1430 .channels_max = 4, 1431 .rates = MADERA_RATES, 1432 .formats = MADERA_FORMATS, 1433 }, 1434 .ops = &madera_simple_dai_ops, 1435 }, 1436 { 1437 .name = "cs47l35-slim2", 1438 .id = 5, 1439 .playback = { 1440 .stream_name = "Slim2 Playback", 1441 .channels_min = 1, 1442 .channels_max = 2, 1443 .rates = MADERA_RATES, 1444 .formats = MADERA_FORMATS, 1445 }, 1446 .capture = { 1447 .stream_name = "Slim2 Capture", 1448 .channels_min = 1, 1449 .channels_max = 2, 1450 .rates = MADERA_RATES, 1451 .formats = MADERA_FORMATS, 1452 }, 1453 .ops = &madera_simple_dai_ops, 1454 }, 1455 { 1456 .name = "cs47l35-cpu-voicectrl", 1457 .capture = { 1458 .stream_name = "Voice Control CPU", 1459 .channels_min = 1, 1460 .channels_max = 1, 1461 .rates = MADERA_RATES, 1462 .formats = MADERA_FORMATS, 1463 }, 1464 .compress_new = &snd_soc_new_compress, 1465 }, 1466 { 1467 .name = "cs47l35-dsp-voicectrl", 1468 .capture = { 1469 .stream_name = "Voice Control DSP", 1470 .channels_min = 1, 1471 .channels_max = 1, 1472 .rates = MADERA_RATES, 1473 .formats = MADERA_FORMATS, 1474 }, 1475 }, 1476 { 1477 .name = "cs47l35-cpu-trace", 1478 .capture = { 1479 .stream_name = "Audio Trace CPU", 1480 .channels_min = 1, 1481 .channels_max = 6, 1482 .rates = MADERA_RATES, 1483 .formats = MADERA_FORMATS, 1484 }, 1485 .compress_new = &snd_soc_new_compress, 1486 }, 1487 { 1488 .name = "cs47l35-dsp-trace", 1489 .capture = { 1490 .stream_name = "Audio Trace DSP", 1491 .channels_min = 1, 1492 .channels_max = 6, 1493 .rates = MADERA_RATES, 1494 .formats = MADERA_FORMATS, 1495 }, 1496 }, 1497 }; 1498 1499 static int cs47l35_open(struct snd_soc_component *component, 1500 struct snd_compr_stream *stream) 1501 { 1502 struct snd_soc_pcm_runtime *rtd = stream->private_data; 1503 struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); 1504 struct madera_priv *priv = &cs47l35->core; 1505 struct madera *madera = priv->madera; 1506 int n_adsp; 1507 1508 if (strcmp(asoc_rtd_to_codec(rtd, 0)->name, "cs47l35-dsp-voicectrl") == 0) { 1509 n_adsp = 2; 1510 } else if (strcmp(asoc_rtd_to_codec(rtd, 0)->name, "cs47l35-dsp-trace") == 0) { 1511 n_adsp = 0; 1512 } else { 1513 dev_err(madera->dev, 1514 "No suitable compressed stream for DAI '%s'\n", 1515 asoc_rtd_to_codec(rtd, 0)->name); 1516 return -EINVAL; 1517 } 1518 1519 return wm_adsp_compr_open(&priv->adsp[n_adsp], stream); 1520 } 1521 1522 static irqreturn_t cs47l35_adsp2_irq(int irq, void *data) 1523 { 1524 struct cs47l35 *cs47l35 = data; 1525 struct madera_priv *priv = &cs47l35->core; 1526 struct madera *madera = priv->madera; 1527 struct madera_voice_trigger_info trig_info; 1528 int serviced = 0; 1529 int i, ret; 1530 1531 for (i = 0; i < CS47L35_NUM_ADSP; ++i) { 1532 ret = wm_adsp_compr_handle_irq(&priv->adsp[i]); 1533 if (ret != -ENODEV) 1534 serviced++; 1535 if (ret == WM_ADSP_COMPR_VOICE_TRIGGER) { 1536 trig_info.core_num = i + 1; 1537 blocking_notifier_call_chain(&madera->notifier, 1538 MADERA_NOTIFY_VOICE_TRIGGER, 1539 &trig_info); 1540 } 1541 } 1542 1543 if (!serviced) { 1544 dev_err(madera->dev, "Spurious compressed data IRQ\n"); 1545 return IRQ_NONE; 1546 } 1547 1548 return IRQ_HANDLED; 1549 } 1550 1551 static const struct snd_soc_dapm_route cs47l35_mono_routes[] = { 1552 { "HPOUT1 Mono Mux", "HPOUT", "OUT1L" }, 1553 { "HPOUT1 Mono Mux", "EPOUT", "OUT1L" }, 1554 }; 1555 1556 static int cs47l35_component_probe(struct snd_soc_component *component) 1557 { 1558 struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); 1559 struct madera *madera = cs47l35->core.madera; 1560 int i, ret; 1561 1562 snd_soc_component_init_regmap(component, madera->regmap); 1563 1564 mutex_lock(&madera->dapm_ptr_lock); 1565 madera->dapm = snd_soc_component_get_dapm(component); 1566 mutex_unlock(&madera->dapm_ptr_lock); 1567 1568 ret = madera_init_inputs(component); 1569 if (ret) 1570 return ret; 1571 1572 ret = madera_init_outputs(component, cs47l35_mono_routes, 1573 ARRAY_SIZE(cs47l35_mono_routes), 1574 CS47L35_MONO_OUTPUTS); 1575 if (ret) 1576 return ret; 1577 1578 snd_soc_component_disable_pin(component, "HAPTICS"); 1579 1580 ret = snd_soc_add_component_controls(component, 1581 madera_adsp_rate_controls, 1582 CS47L35_NUM_ADSP); 1583 if (ret) 1584 return ret; 1585 1586 for (i = 0; i < CS47L35_NUM_ADSP; i++) 1587 wm_adsp2_component_probe(&cs47l35->core.adsp[i], component); 1588 1589 return 0; 1590 } 1591 1592 static void cs47l35_component_remove(struct snd_soc_component *component) 1593 { 1594 struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); 1595 struct madera *madera = cs47l35->core.madera; 1596 int i; 1597 1598 mutex_lock(&madera->dapm_ptr_lock); 1599 madera->dapm = NULL; 1600 mutex_unlock(&madera->dapm_ptr_lock); 1601 1602 for (i = 0; i < CS47L35_NUM_ADSP; i++) 1603 wm_adsp2_component_remove(&cs47l35->core.adsp[i], component); 1604 } 1605 1606 #define CS47L35_DIG_VU 0x0200 1607 1608 static unsigned int cs47l35_digital_vu[] = { 1609 MADERA_DAC_DIGITAL_VOLUME_1L, 1610 MADERA_DAC_DIGITAL_VOLUME_1R, 1611 MADERA_DAC_DIGITAL_VOLUME_4L, 1612 MADERA_DAC_DIGITAL_VOLUME_5L, 1613 MADERA_DAC_DIGITAL_VOLUME_5R, 1614 }; 1615 1616 static const struct snd_compress_ops cs47l35_compress_ops = { 1617 .open = &cs47l35_open, 1618 .free = &wm_adsp_compr_free, 1619 .set_params = &wm_adsp_compr_set_params, 1620 .get_caps = &wm_adsp_compr_get_caps, 1621 .trigger = &wm_adsp_compr_trigger, 1622 .pointer = &wm_adsp_compr_pointer, 1623 .copy = &wm_adsp_compr_copy, 1624 }; 1625 1626 static const struct snd_soc_component_driver soc_component_dev_cs47l35 = { 1627 .probe = &cs47l35_component_probe, 1628 .remove = &cs47l35_component_remove, 1629 .set_sysclk = &madera_set_sysclk, 1630 .set_pll = &cs47l35_set_fll, 1631 .name = DRV_NAME, 1632 .compress_ops = &cs47l35_compress_ops, 1633 .controls = cs47l35_snd_controls, 1634 .num_controls = ARRAY_SIZE(cs47l35_snd_controls), 1635 .dapm_widgets = cs47l35_dapm_widgets, 1636 .num_dapm_widgets = ARRAY_SIZE(cs47l35_dapm_widgets), 1637 .dapm_routes = cs47l35_dapm_routes, 1638 .num_dapm_routes = ARRAY_SIZE(cs47l35_dapm_routes), 1639 .use_pmdown_time = 1, 1640 .endianness = 1, 1641 .non_legacy_dai_naming = 1, 1642 }; 1643 1644 static int cs47l35_probe(struct platform_device *pdev) 1645 { 1646 struct madera *madera = dev_get_drvdata(pdev->dev.parent); 1647 struct cs47l35 *cs47l35; 1648 int i, ret; 1649 1650 BUILD_BUG_ON(ARRAY_SIZE(cs47l35_dai) > MADERA_MAX_DAI); 1651 1652 /* quick exit if Madera irqchip driver hasn't completed probe */ 1653 if (!madera->irq_dev) { 1654 dev_dbg(&pdev->dev, "irqchip driver not ready\n"); 1655 return -EPROBE_DEFER; 1656 } 1657 1658 cs47l35 = devm_kzalloc(&pdev->dev, sizeof(struct cs47l35), GFP_KERNEL); 1659 if (!cs47l35) 1660 return -ENOMEM; 1661 platform_set_drvdata(pdev, cs47l35); 1662 1663 cs47l35->core.madera = madera; 1664 cs47l35->core.dev = &pdev->dev; 1665 cs47l35->core.num_inputs = 4; 1666 1667 ret = madera_core_init(&cs47l35->core); 1668 if (ret) 1669 return ret; 1670 1671 ret = madera_init_overheat(&cs47l35->core); 1672 if (ret) 1673 goto error_core; 1674 1675 ret = madera_request_irq(madera, MADERA_IRQ_DSP_IRQ1, 1676 "ADSP2 Compressed IRQ", cs47l35_adsp2_irq, 1677 cs47l35); 1678 if (ret) { 1679 dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret); 1680 goto error_overheat; 1681 } 1682 1683 ret = madera_set_irq_wake(madera, MADERA_IRQ_DSP_IRQ1, 1); 1684 if (ret) 1685 dev_warn(&pdev->dev, "Failed to set DSP IRQ wake: %d\n", ret); 1686 1687 for (i = 0; i < CS47L35_NUM_ADSP; i++) { 1688 cs47l35->core.adsp[i].part = "cs47l35"; 1689 cs47l35->core.adsp[i].num = i + 1; 1690 cs47l35->core.adsp[i].type = WMFW_ADSP2; 1691 cs47l35->core.adsp[i].rev = 1; 1692 cs47l35->core.adsp[i].dev = madera->dev; 1693 cs47l35->core.adsp[i].regmap = madera->regmap_32bit; 1694 1695 cs47l35->core.adsp[i].base = wm_adsp2_control_bases[i]; 1696 cs47l35->core.adsp[i].mem = cs47l35_dsp_regions[i]; 1697 cs47l35->core.adsp[i].num_mems = 1698 ARRAY_SIZE(cs47l35_dsp1_regions); 1699 1700 ret = wm_adsp2_init(&cs47l35->core.adsp[i]); 1701 if (ret) { 1702 for (--i; i >= 0; --i) 1703 wm_adsp2_remove(&cs47l35->core.adsp[i]); 1704 goto error_dsp_irq; 1705 } 1706 } 1707 1708 madera_init_fll(madera, 1, MADERA_FLL1_CONTROL_1 - 1, &cs47l35->fll); 1709 1710 for (i = 0; i < ARRAY_SIZE(cs47l35_dai); i++) 1711 madera_init_dai(&cs47l35->core, i); 1712 1713 /* Latch volume update bits */ 1714 for (i = 0; i < ARRAY_SIZE(cs47l35_digital_vu); i++) 1715 regmap_update_bits(madera->regmap, cs47l35_digital_vu[i], 1716 CS47L35_DIG_VU, CS47L35_DIG_VU); 1717 1718 pm_runtime_enable(&pdev->dev); 1719 pm_runtime_idle(&pdev->dev); 1720 1721 ret = devm_snd_soc_register_component(&pdev->dev, 1722 &soc_component_dev_cs47l35, 1723 cs47l35_dai, 1724 ARRAY_SIZE(cs47l35_dai)); 1725 if (ret < 0) { 1726 dev_err(&pdev->dev, "Failed to register component: %d\n", ret); 1727 goto error_pm_runtime; 1728 } 1729 1730 return ret; 1731 1732 error_pm_runtime: 1733 pm_runtime_disable(&pdev->dev); 1734 1735 for (i = 0; i < CS47L35_NUM_ADSP; i++) 1736 wm_adsp2_remove(&cs47l35->core.adsp[i]); 1737 error_dsp_irq: 1738 madera_set_irq_wake(madera, MADERA_IRQ_DSP_IRQ1, 0); 1739 madera_free_irq(madera, MADERA_IRQ_DSP_IRQ1, cs47l35); 1740 error_overheat: 1741 madera_free_overheat(&cs47l35->core); 1742 error_core: 1743 madera_core_free(&cs47l35->core); 1744 1745 return ret; 1746 } 1747 1748 static int cs47l35_remove(struct platform_device *pdev) 1749 { 1750 struct cs47l35 *cs47l35 = platform_get_drvdata(pdev); 1751 int i; 1752 1753 pm_runtime_disable(&pdev->dev); 1754 1755 for (i = 0; i < CS47L35_NUM_ADSP; i++) 1756 wm_adsp2_remove(&cs47l35->core.adsp[i]); 1757 1758 madera_set_irq_wake(cs47l35->core.madera, MADERA_IRQ_DSP_IRQ1, 0); 1759 madera_free_irq(cs47l35->core.madera, MADERA_IRQ_DSP_IRQ1, cs47l35); 1760 madera_free_overheat(&cs47l35->core); 1761 madera_core_free(&cs47l35->core); 1762 1763 return 0; 1764 } 1765 1766 static struct platform_driver cs47l35_codec_driver = { 1767 .driver = { 1768 .name = "cs47l35-codec", 1769 }, 1770 .probe = &cs47l35_probe, 1771 .remove = &cs47l35_remove, 1772 }; 1773 1774 module_platform_driver(cs47l35_codec_driver); 1775 1776 MODULE_SOFTDEP("pre: madera irq-madera arizona-micsupp"); 1777 MODULE_DESCRIPTION("ASoC CS47L35 driver"); 1778 MODULE_AUTHOR("Piotr Stankiewicz <piotrs@opensource.cirrus.com>"); 1779 MODULE_LICENSE("GPL v2"); 1780 MODULE_ALIAS("platform:cs47l35-codec"); 1781