cs47l35.c (59873B)
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 35struct cs47l35 { 36 struct madera_priv core; 37 struct madera_fll fll; 38}; 39 40static const struct cs_dsp_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 47static const struct cs_dsp_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 54static const struct cs_dsp_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 61static const struct cs_dsp_region *cs47l35_dsp_regions[] = { 62 cs47l35_dsp1_regions, 63 cs47l35_dsp2_regions, 64 cs47l35_dsp3_regions, 65}; 66 67static const int wm_adsp2_control_bases[] = { 68 MADERA_DSP1_CONFIG_1, 69 MADERA_DSP2_CONFIG_1, 70 MADERA_DSP3_CONFIG_1, 71}; 72 73static const char * const cs47l35_outdemux_texts[] = { 74 "HPOUT", 75 "EPOUT", 76}; 77 78static SOC_ENUM_SINGLE_DECL(cs47l35_outdemux_enum, SND_SOC_NOPM, 0, 79 cs47l35_outdemux_texts); 80 81static 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 85static 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 127static 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 151static 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 175static 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 200static const struct snd_kcontrol_new cs47l35_snd_controls[] = { 201SOC_ENUM("IN1 OSR", madera_in_dmic_osr[0]), 202SOC_ENUM("IN2 OSR", madera_in_dmic_osr[1]), 203 204SOC_SINGLE_RANGE_TLV("IN1L Volume", MADERA_IN1L_CONTROL, 205 MADERA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv), 206SOC_SINGLE_RANGE_TLV("IN1R Volume", MADERA_IN1R_CONTROL, 207 MADERA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv), 208SOC_SINGLE_RANGE_TLV("IN2L Volume", MADERA_IN2L_CONTROL, 209 MADERA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv), 210SOC_SINGLE_RANGE_TLV("IN2R Volume", MADERA_IN2R_CONTROL, 211 MADERA_IN2R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv), 212 213SOC_ENUM("IN HPF Cutoff Frequency", madera_in_hpf_cut_enum), 214 215SOC_SINGLE("IN1L HPF Switch", MADERA_IN1L_CONTROL, 216 MADERA_IN1L_HPF_SHIFT, 1, 0), 217SOC_SINGLE("IN1R HPF Switch", MADERA_IN1R_CONTROL, 218 MADERA_IN1R_HPF_SHIFT, 1, 0), 219SOC_SINGLE("IN2L HPF Switch", MADERA_IN2L_CONTROL, 220 MADERA_IN2L_HPF_SHIFT, 1, 0), 221SOC_SINGLE("IN2R HPF Switch", MADERA_IN2R_CONTROL, 222 MADERA_IN2R_HPF_SHIFT, 1, 0), 223 224SOC_SINGLE_TLV("IN1L Digital Volume", MADERA_ADC_DIGITAL_VOLUME_1L, 225 MADERA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 226SOC_SINGLE_TLV("IN1R Digital Volume", MADERA_ADC_DIGITAL_VOLUME_1R, 227 MADERA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 228SOC_SINGLE_TLV("IN2L Digital Volume", MADERA_ADC_DIGITAL_VOLUME_2L, 229 MADERA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 230SOC_SINGLE_TLV("IN2R Digital Volume", MADERA_ADC_DIGITAL_VOLUME_2R, 231 MADERA_IN2R_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 232 233SOC_ENUM("Input Ramp Up", madera_in_vi_ramp), 234SOC_ENUM("Input Ramp Down", madera_in_vd_ramp), 235 236MADERA_MIXER_CONTROLS("EQ1", MADERA_EQ1MIX_INPUT_1_SOURCE), 237MADERA_MIXER_CONTROLS("EQ2", MADERA_EQ2MIX_INPUT_1_SOURCE), 238MADERA_MIXER_CONTROLS("EQ3", MADERA_EQ3MIX_INPUT_1_SOURCE), 239MADERA_MIXER_CONTROLS("EQ4", MADERA_EQ4MIX_INPUT_1_SOURCE), 240 241MADERA_EQ_CONTROL("EQ1 Coefficients", MADERA_EQ1_2), 242SOC_SINGLE_TLV("EQ1 B1 Volume", MADERA_EQ1_1, MADERA_EQ1_B1_GAIN_SHIFT, 243 24, 0, madera_eq_tlv), 244SOC_SINGLE_TLV("EQ1 B2 Volume", MADERA_EQ1_1, MADERA_EQ1_B2_GAIN_SHIFT, 245 24, 0, madera_eq_tlv), 246SOC_SINGLE_TLV("EQ1 B3 Volume", MADERA_EQ1_1, MADERA_EQ1_B3_GAIN_SHIFT, 247 24, 0, madera_eq_tlv), 248SOC_SINGLE_TLV("EQ1 B4 Volume", MADERA_EQ1_2, MADERA_EQ1_B4_GAIN_SHIFT, 249 24, 0, madera_eq_tlv), 250SOC_SINGLE_TLV("EQ1 B5 Volume", MADERA_EQ1_2, MADERA_EQ1_B5_GAIN_SHIFT, 251 24, 0, madera_eq_tlv), 252 253MADERA_EQ_CONTROL("EQ2 Coefficients", MADERA_EQ2_2), 254SOC_SINGLE_TLV("EQ2 B1 Volume", MADERA_EQ2_1, MADERA_EQ2_B1_GAIN_SHIFT, 255 24, 0, madera_eq_tlv), 256SOC_SINGLE_TLV("EQ2 B2 Volume", MADERA_EQ2_1, MADERA_EQ2_B2_GAIN_SHIFT, 257 24, 0, madera_eq_tlv), 258SOC_SINGLE_TLV("EQ2 B3 Volume", MADERA_EQ2_1, MADERA_EQ2_B3_GAIN_SHIFT, 259 24, 0, madera_eq_tlv), 260SOC_SINGLE_TLV("EQ2 B4 Volume", MADERA_EQ2_2, MADERA_EQ2_B4_GAIN_SHIFT, 261 24, 0, madera_eq_tlv), 262SOC_SINGLE_TLV("EQ2 B5 Volume", MADERA_EQ2_2, MADERA_EQ2_B5_GAIN_SHIFT, 263 24, 0, madera_eq_tlv), 264 265MADERA_EQ_CONTROL("EQ3 Coefficients", MADERA_EQ3_2), 266SOC_SINGLE_TLV("EQ3 B1 Volume", MADERA_EQ3_1, MADERA_EQ3_B1_GAIN_SHIFT, 267 24, 0, madera_eq_tlv), 268SOC_SINGLE_TLV("EQ3 B2 Volume", MADERA_EQ3_1, MADERA_EQ3_B2_GAIN_SHIFT, 269 24, 0, madera_eq_tlv), 270SOC_SINGLE_TLV("EQ3 B3 Volume", MADERA_EQ3_1, MADERA_EQ3_B3_GAIN_SHIFT, 271 24, 0, madera_eq_tlv), 272SOC_SINGLE_TLV("EQ3 B4 Volume", MADERA_EQ3_2, MADERA_EQ3_B4_GAIN_SHIFT, 273 24, 0, madera_eq_tlv), 274SOC_SINGLE_TLV("EQ3 B5 Volume", MADERA_EQ3_2, MADERA_EQ3_B5_GAIN_SHIFT, 275 24, 0, madera_eq_tlv), 276 277MADERA_EQ_CONTROL("EQ4 Coefficients", MADERA_EQ4_2), 278SOC_SINGLE_TLV("EQ4 B1 Volume", MADERA_EQ4_1, MADERA_EQ4_B1_GAIN_SHIFT, 279 24, 0, madera_eq_tlv), 280SOC_SINGLE_TLV("EQ4 B2 Volume", MADERA_EQ4_1, MADERA_EQ4_B2_GAIN_SHIFT, 281 24, 0, madera_eq_tlv), 282SOC_SINGLE_TLV("EQ4 B3 Volume", MADERA_EQ4_1, MADERA_EQ4_B3_GAIN_SHIFT, 283 24, 0, madera_eq_tlv), 284SOC_SINGLE_TLV("EQ4 B4 Volume", MADERA_EQ4_2, MADERA_EQ4_B4_GAIN_SHIFT, 285 24, 0, madera_eq_tlv), 286SOC_SINGLE_TLV("EQ4 B5 Volume", MADERA_EQ4_2, MADERA_EQ4_B5_GAIN_SHIFT, 287 24, 0, madera_eq_tlv), 288 289MADERA_MIXER_CONTROLS("DRC1L", MADERA_DRC1LMIX_INPUT_1_SOURCE), 290MADERA_MIXER_CONTROLS("DRC1R", MADERA_DRC1RMIX_INPUT_1_SOURCE), 291MADERA_MIXER_CONTROLS("DRC2L", MADERA_DRC2LMIX_INPUT_1_SOURCE), 292MADERA_MIXER_CONTROLS("DRC2R", MADERA_DRC2RMIX_INPUT_1_SOURCE), 293 294SND_SOC_BYTES_MASK("DRC1", MADERA_DRC1_CTRL1, 5, 295 MADERA_DRC1R_ENA | MADERA_DRC1L_ENA), 296SND_SOC_BYTES_MASK("DRC2", MADERA_DRC2_CTRL1, 5, 297 MADERA_DRC2R_ENA | MADERA_DRC2L_ENA), 298 299MADERA_MIXER_CONTROLS("LHPF1", MADERA_HPLP1MIX_INPUT_1_SOURCE), 300MADERA_MIXER_CONTROLS("LHPF2", MADERA_HPLP2MIX_INPUT_1_SOURCE), 301MADERA_MIXER_CONTROLS("LHPF3", MADERA_HPLP3MIX_INPUT_1_SOURCE), 302MADERA_MIXER_CONTROLS("LHPF4", MADERA_HPLP4MIX_INPUT_1_SOURCE), 303 304MADERA_LHPF_CONTROL("LHPF1 Coefficients", MADERA_HPLPF1_2), 305MADERA_LHPF_CONTROL("LHPF2 Coefficients", MADERA_HPLPF2_2), 306MADERA_LHPF_CONTROL("LHPF3 Coefficients", MADERA_HPLPF3_2), 307MADERA_LHPF_CONTROL("LHPF4 Coefficients", MADERA_HPLPF4_2), 308 309SOC_ENUM("LHPF1 Mode", madera_lhpf1_mode), 310SOC_ENUM("LHPF2 Mode", madera_lhpf2_mode), 311SOC_ENUM("LHPF3 Mode", madera_lhpf3_mode), 312SOC_ENUM("LHPF4 Mode", madera_lhpf4_mode), 313 314MADERA_RATE_ENUM("ISRC1 FSL", madera_isrc_fsl[0]), 315MADERA_RATE_ENUM("ISRC2 FSL", madera_isrc_fsl[1]), 316MADERA_RATE_ENUM("ISRC1 FSH", madera_isrc_fsh[0]), 317MADERA_RATE_ENUM("ISRC2 FSH", madera_isrc_fsh[1]), 318 319WM_ADSP2_PRELOAD_SWITCH("DSP1", 1), 320WM_ADSP2_PRELOAD_SWITCH("DSP2", 2), 321WM_ADSP2_PRELOAD_SWITCH("DSP3", 3), 322 323MADERA_MIXER_CONTROLS("DSP1L", MADERA_DSP1LMIX_INPUT_1_SOURCE), 324MADERA_MIXER_CONTROLS("DSP1R", MADERA_DSP1RMIX_INPUT_1_SOURCE), 325MADERA_MIXER_CONTROLS("DSP2L", MADERA_DSP2LMIX_INPUT_1_SOURCE), 326MADERA_MIXER_CONTROLS("DSP2R", MADERA_DSP2RMIX_INPUT_1_SOURCE), 327MADERA_MIXER_CONTROLS("DSP3L", MADERA_DSP3LMIX_INPUT_1_SOURCE), 328MADERA_MIXER_CONTROLS("DSP3R", MADERA_DSP3RMIX_INPUT_1_SOURCE), 329 330SOC_SINGLE_TLV("Noise Generator Volume", MADERA_COMFORT_NOISE_GENERATOR, 331 MADERA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, madera_noise_tlv), 332 333MADERA_MIXER_CONTROLS("HPOUT1L", MADERA_OUT1LMIX_INPUT_1_SOURCE), 334MADERA_MIXER_CONTROLS("HPOUT1R", MADERA_OUT1RMIX_INPUT_1_SOURCE), 335MADERA_MIXER_CONTROLS("SPKOUT", MADERA_OUT4LMIX_INPUT_1_SOURCE), 336MADERA_MIXER_CONTROLS("SPKDAT1L", MADERA_OUT5LMIX_INPUT_1_SOURCE), 337MADERA_MIXER_CONTROLS("SPKDAT1R", MADERA_OUT5RMIX_INPUT_1_SOURCE), 338 339SOC_SINGLE("HPOUT1 SC Protect Switch", MADERA_HP1_SHORT_CIRCUIT_CTRL, 340 MADERA_HP1_SC_ENA_SHIFT, 1, 0), 341 342SOC_SINGLE("SPKDAT1 High Performance Switch", MADERA_OUTPUT_PATH_CONFIG_5L, 343 MADERA_OUT5_OSR_SHIFT, 1, 0), 344 345SOC_DOUBLE_R("HPOUT1 Digital Switch", MADERA_DAC_DIGITAL_VOLUME_1L, 346 MADERA_DAC_DIGITAL_VOLUME_1R, MADERA_OUT1L_MUTE_SHIFT, 1, 1), 347SOC_SINGLE("Speaker Digital Switch", MADERA_DAC_DIGITAL_VOLUME_4L, 348 MADERA_OUT4L_MUTE_SHIFT, 1, 1), 349SOC_DOUBLE_R("SPKDAT1 Digital Switch", MADERA_DAC_DIGITAL_VOLUME_5L, 350 MADERA_DAC_DIGITAL_VOLUME_5R, MADERA_OUT5L_MUTE_SHIFT, 1, 1), 351 352SOC_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), 355SOC_SINGLE_TLV("Speaker Digital Volume", MADERA_DAC_DIGITAL_VOLUME_4L, 356 MADERA_OUT4L_VOL_SHIFT, 0xbf, 0, madera_digital_tlv), 357SOC_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 361SOC_DOUBLE("SPKDAT1 Switch", MADERA_PDM_SPK1_CTRL_1, MADERA_SPK1L_MUTE_SHIFT, 362 MADERA_SPK1R_MUTE_SHIFT, 1, 1), 363 364SOC_ENUM("Output Ramp Up", madera_out_vi_ramp), 365SOC_ENUM("Output Ramp Down", madera_out_vd_ramp), 366 367SOC_SINGLE("Noise Gate Switch", MADERA_NOISE_GATE_CONTROL, 368 MADERA_NGATE_ENA_SHIFT, 1, 0), 369SOC_SINGLE_TLV("Noise Gate Threshold Volume", MADERA_NOISE_GATE_CONTROL, 370 MADERA_NGATE_THR_SHIFT, 7, 1, madera_ng_tlv), 371SOC_ENUM("Noise Gate Hold", madera_ng_hold), 372 373CS47L35_NG_SRC("HPOUT1L", MADERA_NOISE_GATE_SELECT_1L), 374CS47L35_NG_SRC("HPOUT1R", MADERA_NOISE_GATE_SELECT_1R), 375CS47L35_NG_SRC("SPKOUT", MADERA_NOISE_GATE_SELECT_4L), 376CS47L35_NG_SRC("SPKDAT1L", MADERA_NOISE_GATE_SELECT_5L), 377CS47L35_NG_SRC("SPKDAT1R", MADERA_NOISE_GATE_SELECT_5R), 378 379MADERA_MIXER_CONTROLS("AIF1TX1", MADERA_AIF1TX1MIX_INPUT_1_SOURCE), 380MADERA_MIXER_CONTROLS("AIF1TX2", MADERA_AIF1TX2MIX_INPUT_1_SOURCE), 381MADERA_MIXER_CONTROLS("AIF1TX3", MADERA_AIF1TX3MIX_INPUT_1_SOURCE), 382MADERA_MIXER_CONTROLS("AIF1TX4", MADERA_AIF1TX4MIX_INPUT_1_SOURCE), 383MADERA_MIXER_CONTROLS("AIF1TX5", MADERA_AIF1TX5MIX_INPUT_1_SOURCE), 384MADERA_MIXER_CONTROLS("AIF1TX6", MADERA_AIF1TX6MIX_INPUT_1_SOURCE), 385 386MADERA_MIXER_CONTROLS("AIF2TX1", MADERA_AIF2TX1MIX_INPUT_1_SOURCE), 387MADERA_MIXER_CONTROLS("AIF2TX2", MADERA_AIF2TX2MIX_INPUT_1_SOURCE), 388 389MADERA_MIXER_CONTROLS("AIF3TX1", MADERA_AIF3TX1MIX_INPUT_1_SOURCE), 390MADERA_MIXER_CONTROLS("AIF3TX2", MADERA_AIF3TX2MIX_INPUT_1_SOURCE), 391 392MADERA_MIXER_CONTROLS("SLIMTX1", MADERA_SLIMTX1MIX_INPUT_1_SOURCE), 393MADERA_MIXER_CONTROLS("SLIMTX2", MADERA_SLIMTX2MIX_INPUT_1_SOURCE), 394MADERA_MIXER_CONTROLS("SLIMTX3", MADERA_SLIMTX3MIX_INPUT_1_SOURCE), 395MADERA_MIXER_CONTROLS("SLIMTX4", MADERA_SLIMTX4MIX_INPUT_1_SOURCE), 396MADERA_MIXER_CONTROLS("SLIMTX5", MADERA_SLIMTX5MIX_INPUT_1_SOURCE), 397MADERA_MIXER_CONTROLS("SLIMTX6", MADERA_SLIMTX6MIX_INPUT_1_SOURCE), 398 399MADERA_GAINMUX_CONTROLS("SPDIF1TX1", MADERA_SPDIF1TX1MIX_INPUT_1_SOURCE), 400MADERA_GAINMUX_CONTROLS("SPDIF1TX2", MADERA_SPDIF1TX2MIX_INPUT_1_SOURCE), 401 402WM_ADSP_FW_CONTROL("DSP1", 0), 403WM_ADSP_FW_CONTROL("DSP2", 1), 404WM_ADSP_FW_CONTROL("DSP3", 2), 405}; 406 407MADERA_MIXER_ENUMS(EQ1, MADERA_EQ1MIX_INPUT_1_SOURCE); 408MADERA_MIXER_ENUMS(EQ2, MADERA_EQ2MIX_INPUT_1_SOURCE); 409MADERA_MIXER_ENUMS(EQ3, MADERA_EQ3MIX_INPUT_1_SOURCE); 410MADERA_MIXER_ENUMS(EQ4, MADERA_EQ4MIX_INPUT_1_SOURCE); 411 412MADERA_MIXER_ENUMS(DRC1L, MADERA_DRC1LMIX_INPUT_1_SOURCE); 413MADERA_MIXER_ENUMS(DRC1R, MADERA_DRC1RMIX_INPUT_1_SOURCE); 414MADERA_MIXER_ENUMS(DRC2L, MADERA_DRC2LMIX_INPUT_1_SOURCE); 415MADERA_MIXER_ENUMS(DRC2R, MADERA_DRC2RMIX_INPUT_1_SOURCE); 416 417MADERA_MIXER_ENUMS(LHPF1, MADERA_HPLP1MIX_INPUT_1_SOURCE); 418MADERA_MIXER_ENUMS(LHPF2, MADERA_HPLP2MIX_INPUT_1_SOURCE); 419MADERA_MIXER_ENUMS(LHPF3, MADERA_HPLP3MIX_INPUT_1_SOURCE); 420MADERA_MIXER_ENUMS(LHPF4, MADERA_HPLP4MIX_INPUT_1_SOURCE); 421 422MADERA_MIXER_ENUMS(DSP1L, MADERA_DSP1LMIX_INPUT_1_SOURCE); 423MADERA_MIXER_ENUMS(DSP1R, MADERA_DSP1RMIX_INPUT_1_SOURCE); 424MADERA_DSP_AUX_ENUMS(DSP1, MADERA_DSP1AUX1MIX_INPUT_1_SOURCE); 425 426MADERA_MIXER_ENUMS(DSP2L, MADERA_DSP2LMIX_INPUT_1_SOURCE); 427MADERA_MIXER_ENUMS(DSP2R, MADERA_DSP2RMIX_INPUT_1_SOURCE); 428MADERA_DSP_AUX_ENUMS(DSP2, MADERA_DSP2AUX1MIX_INPUT_1_SOURCE); 429 430MADERA_MIXER_ENUMS(DSP3L, MADERA_DSP3LMIX_INPUT_1_SOURCE); 431MADERA_MIXER_ENUMS(DSP3R, MADERA_DSP3RMIX_INPUT_1_SOURCE); 432MADERA_DSP_AUX_ENUMS(DSP3, MADERA_DSP3AUX1MIX_INPUT_1_SOURCE); 433 434MADERA_MIXER_ENUMS(PWM1, MADERA_PWM1MIX_INPUT_1_SOURCE); 435MADERA_MIXER_ENUMS(PWM2, MADERA_PWM2MIX_INPUT_1_SOURCE); 436 437MADERA_MIXER_ENUMS(OUT1L, MADERA_OUT1LMIX_INPUT_1_SOURCE); 438MADERA_MIXER_ENUMS(OUT1R, MADERA_OUT1RMIX_INPUT_1_SOURCE); 439MADERA_MIXER_ENUMS(SPKOUT, MADERA_OUT4LMIX_INPUT_1_SOURCE); 440MADERA_MIXER_ENUMS(SPKDAT1L, MADERA_OUT5LMIX_INPUT_1_SOURCE); 441MADERA_MIXER_ENUMS(SPKDAT1R, MADERA_OUT5RMIX_INPUT_1_SOURCE); 442 443MADERA_MIXER_ENUMS(AIF1TX1, MADERA_AIF1TX1MIX_INPUT_1_SOURCE); 444MADERA_MIXER_ENUMS(AIF1TX2, MADERA_AIF1TX2MIX_INPUT_1_SOURCE); 445MADERA_MIXER_ENUMS(AIF1TX3, MADERA_AIF1TX3MIX_INPUT_1_SOURCE); 446MADERA_MIXER_ENUMS(AIF1TX4, MADERA_AIF1TX4MIX_INPUT_1_SOURCE); 447MADERA_MIXER_ENUMS(AIF1TX5, MADERA_AIF1TX5MIX_INPUT_1_SOURCE); 448MADERA_MIXER_ENUMS(AIF1TX6, MADERA_AIF1TX6MIX_INPUT_1_SOURCE); 449 450MADERA_MIXER_ENUMS(AIF2TX1, MADERA_AIF2TX1MIX_INPUT_1_SOURCE); 451MADERA_MIXER_ENUMS(AIF2TX2, MADERA_AIF2TX2MIX_INPUT_1_SOURCE); 452 453MADERA_MIXER_ENUMS(AIF3TX1, MADERA_AIF3TX1MIX_INPUT_1_SOURCE); 454MADERA_MIXER_ENUMS(AIF3TX2, MADERA_AIF3TX2MIX_INPUT_1_SOURCE); 455 456MADERA_MIXER_ENUMS(SLIMTX1, MADERA_SLIMTX1MIX_INPUT_1_SOURCE); 457MADERA_MIXER_ENUMS(SLIMTX2, MADERA_SLIMTX2MIX_INPUT_1_SOURCE); 458MADERA_MIXER_ENUMS(SLIMTX3, MADERA_SLIMTX3MIX_INPUT_1_SOURCE); 459MADERA_MIXER_ENUMS(SLIMTX4, MADERA_SLIMTX4MIX_INPUT_1_SOURCE); 460MADERA_MIXER_ENUMS(SLIMTX5, MADERA_SLIMTX5MIX_INPUT_1_SOURCE); 461MADERA_MIXER_ENUMS(SLIMTX6, MADERA_SLIMTX6MIX_INPUT_1_SOURCE); 462 463MADERA_MUX_ENUMS(SPD1TX1, MADERA_SPDIF1TX1MIX_INPUT_1_SOURCE); 464MADERA_MUX_ENUMS(SPD1TX2, MADERA_SPDIF1TX2MIX_INPUT_1_SOURCE); 465 466MADERA_MUX_ENUMS(ISRC1INT1, MADERA_ISRC1INT1MIX_INPUT_1_SOURCE); 467MADERA_MUX_ENUMS(ISRC1INT2, MADERA_ISRC1INT2MIX_INPUT_1_SOURCE); 468MADERA_MUX_ENUMS(ISRC1INT3, MADERA_ISRC1INT3MIX_INPUT_1_SOURCE); 469MADERA_MUX_ENUMS(ISRC1INT4, MADERA_ISRC1INT4MIX_INPUT_1_SOURCE); 470 471MADERA_MUX_ENUMS(ISRC1DEC1, MADERA_ISRC1DEC1MIX_INPUT_1_SOURCE); 472MADERA_MUX_ENUMS(ISRC1DEC2, MADERA_ISRC1DEC2MIX_INPUT_1_SOURCE); 473MADERA_MUX_ENUMS(ISRC1DEC3, MADERA_ISRC1DEC3MIX_INPUT_1_SOURCE); 474MADERA_MUX_ENUMS(ISRC1DEC4, MADERA_ISRC1DEC4MIX_INPUT_1_SOURCE); 475 476MADERA_MUX_ENUMS(ISRC2INT1, MADERA_ISRC2INT1MIX_INPUT_1_SOURCE); 477MADERA_MUX_ENUMS(ISRC2INT2, MADERA_ISRC2INT2MIX_INPUT_1_SOURCE); 478MADERA_MUX_ENUMS(ISRC2INT3, MADERA_ISRC2INT3MIX_INPUT_1_SOURCE); 479MADERA_MUX_ENUMS(ISRC2INT4, MADERA_ISRC2INT4MIX_INPUT_1_SOURCE); 480 481MADERA_MUX_ENUMS(ISRC2DEC1, MADERA_ISRC2DEC1MIX_INPUT_1_SOURCE); 482MADERA_MUX_ENUMS(ISRC2DEC2, MADERA_ISRC2DEC2MIX_INPUT_1_SOURCE); 483MADERA_MUX_ENUMS(ISRC2DEC3, MADERA_ISRC2DEC3MIX_INPUT_1_SOURCE); 484MADERA_MUX_ENUMS(ISRC2DEC4, MADERA_ISRC2DEC4MIX_INPUT_1_SOURCE); 485 486static const char * const cs47l35_aec_loopback_texts[] = { 487 "HPOUT1L", "HPOUT1R", "SPKOUT", "SPKDAT1L", "SPKDAT1R", 488}; 489 490static const unsigned int cs47l35_aec_loopback_values[] = { 491 0, 1, 6, 8, 9, 492}; 493 494static 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 501static 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 508static 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 513static const struct snd_soc_dapm_widget cs47l35_dapm_widgets[] = { 514SND_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), 518SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK, 519 MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0), 520SND_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 524SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0), 525SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD1", 20, 0), 526SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD2", 20, 0), 527SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS), 528SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDD", 0, 0), 529 530SND_SOC_DAPM_SUPPLY("MICBIAS1", MADERA_MIC_BIAS_CTRL_1, 531 MADERA_MICB1_ENA_SHIFT, 0, NULL, 0), 532SND_SOC_DAPM_SUPPLY("MICBIAS2", MADERA_MIC_BIAS_CTRL_2, 533 MADERA_MICB1_ENA_SHIFT, 0, NULL, 0), 534 535SND_SOC_DAPM_SUPPLY("MICBIAS1A", MADERA_MIC_BIAS_CTRL_5, 536 MADERA_MICB1A_ENA_SHIFT, 0, NULL, 0), 537SND_SOC_DAPM_SUPPLY("MICBIAS1B", MADERA_MIC_BIAS_CTRL_5, 538 MADERA_MICB1B_ENA_SHIFT, 0, NULL, 0), 539SND_SOC_DAPM_SUPPLY("MICBIAS2A", MADERA_MIC_BIAS_CTRL_6, 540 MADERA_MICB2A_ENA_SHIFT, 0, NULL, 0), 541SND_SOC_DAPM_SUPPLY("MICBIAS2B", MADERA_MIC_BIAS_CTRL_6, 542 MADERA_MICB2B_ENA_SHIFT, 0, NULL, 0), 543 544SND_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), 548SND_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), 552SND_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), 556SND_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), 560SND_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), 564SND_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), 568SND_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), 572SND_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), 576SND_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), 580SND_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), 584SND_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), 588SND_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), 592SND_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 597SND_SOC_DAPM_SIGGEN("TONE"), 598SND_SOC_DAPM_SIGGEN("NOISE"), 599 600SND_SOC_DAPM_INPUT("IN1ALN"), 601SND_SOC_DAPM_INPUT("IN1ALP"), 602SND_SOC_DAPM_INPUT("IN1BLN"), 603SND_SOC_DAPM_INPUT("IN1BLP"), 604SND_SOC_DAPM_INPUT("IN1ARN"), 605SND_SOC_DAPM_INPUT("IN1ARP"), 606SND_SOC_DAPM_INPUT("IN1BRN"), 607SND_SOC_DAPM_INPUT("IN1BRP"), 608SND_SOC_DAPM_INPUT("IN2LN"), 609SND_SOC_DAPM_INPUT("IN2LP"), 610SND_SOC_DAPM_INPUT("IN2RN"), 611SND_SOC_DAPM_INPUT("IN2RP"), 612 613SND_SOC_DAPM_MUX("IN1L Analog Mux", SND_SOC_NOPM, 0, 0, &madera_inmux[0]), 614SND_SOC_DAPM_MUX("IN1R Analog Mux", SND_SOC_NOPM, 0, 0, &madera_inmux[1]), 615 616SND_SOC_DAPM_MUX("IN1L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[0]), 617SND_SOC_DAPM_MUX("IN1R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[0]), 618 619SND_SOC_DAPM_MUX("IN2L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]), 620SND_SOC_DAPM_MUX("IN2R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]), 621 622SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"), 623SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"), 624 625SND_SOC_DAPM_OUTPUT("DSP Trigger Out"), 626 627SND_SOC_DAPM_DEMUX("HPOUT1 Demux", SND_SOC_NOPM, 0, 0, &cs47l35_outdemux), 628SND_SOC_DAPM_MUX("HPOUT1 Mono Mux", SND_SOC_NOPM, 0, 0, &cs47l35_outdemux), 629 630SND_SOC_DAPM_PGA("PWM1 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM1_ENA_SHIFT, 631 0, NULL, 0), 632SND_SOC_DAPM_PGA("PWM2 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM2_ENA_SHIFT, 633 0, NULL, 0), 634 635SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0, 636 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX1_ENA_SHIFT, 0), 637SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 1, 638 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX2_ENA_SHIFT, 0), 639SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 2, 640 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX3_ENA_SHIFT, 0), 641SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 3, 642 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX4_ENA_SHIFT, 0), 643SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 4, 644 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX5_ENA_SHIFT, 0), 645SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 5, 646 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX6_ENA_SHIFT, 0), 647 648SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0, 649 MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX1_ENA_SHIFT, 0), 650SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 1, 651 MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX2_ENA_SHIFT, 0), 652 653SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0, 654 MADERA_AIF3_TX_ENABLES, MADERA_AIF3TX1_ENA_SHIFT, 0), 655SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 1, 656 MADERA_AIF3_TX_ENABLES, MADERA_AIF3TX2_ENA_SHIFT, 0), 657 658SND_SOC_DAPM_AIF_OUT("SLIMTX1", NULL, 0, 659 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 660 MADERA_SLIMTX1_ENA_SHIFT, 0), 661SND_SOC_DAPM_AIF_OUT("SLIMTX2", NULL, 1, 662 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 663 MADERA_SLIMTX2_ENA_SHIFT, 0), 664SND_SOC_DAPM_AIF_OUT("SLIMTX3", NULL, 2, 665 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 666 MADERA_SLIMTX3_ENA_SHIFT, 0), 667SND_SOC_DAPM_AIF_OUT("SLIMTX4", NULL, 3, 668 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 669 MADERA_SLIMTX4_ENA_SHIFT, 0), 670SND_SOC_DAPM_AIF_OUT("SLIMTX5", NULL, 4, 671 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 672 MADERA_SLIMTX5_ENA_SHIFT, 0), 673SND_SOC_DAPM_AIF_OUT("SLIMTX6", NULL, 5, 674 MADERA_SLIMBUS_TX_CHANNEL_ENABLE, 675 MADERA_SLIMTX6_ENA_SHIFT, 0), 676 677SND_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), 681SND_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), 685SND_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), 688SND_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), 691SND_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 695SND_SOC_DAPM_PGA("SPD1TX1", MADERA_SPD1_TX_CONTROL, 696 MADERA_SPD1_VAL1_SHIFT, 0, NULL, 0), 697SND_SOC_DAPM_PGA("SPD1TX2", MADERA_SPD1_TX_CONTROL, 698 MADERA_SPD1_VAL2_SHIFT, 0, NULL, 0), 699SND_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 */ 706SND_SOC_DAPM_PGA("Noise Generator", MADERA_COMFORT_NOISE_GENERATOR, 707 MADERA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0), 708 709SND_SOC_DAPM_PGA("Tone Generator 1", MADERA_TONE_GENERATOR_1, 710 MADERA_TONE1_ENA_SHIFT, 0, NULL, 0), 711SND_SOC_DAPM_PGA("Tone Generator 2", MADERA_TONE_GENERATOR_1, 712 MADERA_TONE2_ENA_SHIFT, 0, NULL, 0), 713 714SND_SOC_DAPM_SIGGEN("HAPTICS"), 715 716SND_SOC_DAPM_MUX("AEC1 Loopback", MADERA_DAC_AEC_CONTROL_1, 717 MADERA_AEC1_LOOPBACK_ENA_SHIFT, 0, 718 &cs47l35_aec_loopback_mux[0]), 719 720SND_SOC_DAPM_MUX("AEC2 Loopback", MADERA_DAC_AEC_CONTROL_2, 721 MADERA_AEC2_LOOPBACK_ENA_SHIFT, 0, 722 &cs47l35_aec_loopback_mux[1]), 723 724SND_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), 728SND_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 733SND_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), 737SND_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 742SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0, 743 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX1_ENA_SHIFT, 0), 744SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 1, 745 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX2_ENA_SHIFT, 0), 746SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 2, 747 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX3_ENA_SHIFT, 0), 748SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 3, 749 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX4_ENA_SHIFT, 0), 750SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 4, 751 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX5_ENA_SHIFT, 0), 752SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 5, 753 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX6_ENA_SHIFT, 0), 754 755SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0, 756 MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX1_ENA_SHIFT, 0), 757SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 1, 758 MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX2_ENA_SHIFT, 0), 759 760SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0, 761 MADERA_AIF3_RX_ENABLES, MADERA_AIF3RX1_ENA_SHIFT, 0), 762SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 1, 763 MADERA_AIF3_RX_ENABLES, MADERA_AIF3RX2_ENA_SHIFT, 0), 764 765SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0, 766 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 767 MADERA_SLIMRX1_ENA_SHIFT, 0), 768SND_SOC_DAPM_AIF_IN("SLIMRX2", NULL, 1, 769 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 770 MADERA_SLIMRX2_ENA_SHIFT, 0), 771SND_SOC_DAPM_AIF_IN("SLIMRX3", NULL, 2, 772 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 773 MADERA_SLIMRX3_ENA_SHIFT, 0), 774SND_SOC_DAPM_AIF_IN("SLIMRX4", NULL, 3, 775 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 776 MADERA_SLIMRX4_ENA_SHIFT, 0), 777SND_SOC_DAPM_AIF_IN("SLIMRX5", NULL, 4, 778 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 779 MADERA_SLIMRX5_ENA_SHIFT, 0), 780SND_SOC_DAPM_AIF_IN("SLIMRX6", NULL, 5, 781 MADERA_SLIMBUS_RX_CHANNEL_ENABLE, 782 MADERA_SLIMRX6_ENA_SHIFT, 0), 783 784SND_SOC_DAPM_PGA("EQ1", MADERA_EQ1_1, MADERA_EQ1_ENA_SHIFT, 0, NULL, 0), 785SND_SOC_DAPM_PGA("EQ2", MADERA_EQ2_1, MADERA_EQ2_ENA_SHIFT, 0, NULL, 0), 786SND_SOC_DAPM_PGA("EQ3", MADERA_EQ3_1, MADERA_EQ3_ENA_SHIFT, 0, NULL, 0), 787SND_SOC_DAPM_PGA("EQ4", MADERA_EQ4_1, MADERA_EQ4_ENA_SHIFT, 0, NULL, 0), 788 789SND_SOC_DAPM_PGA("DRC1L", MADERA_DRC1_CTRL1, MADERA_DRC1L_ENA_SHIFT, 0, 790 NULL, 0), 791SND_SOC_DAPM_PGA("DRC1R", MADERA_DRC1_CTRL1, MADERA_DRC1R_ENA_SHIFT, 0, 792 NULL, 0), 793SND_SOC_DAPM_PGA("DRC2L", MADERA_DRC2_CTRL1, MADERA_DRC2L_ENA_SHIFT, 0, 794 NULL, 0), 795SND_SOC_DAPM_PGA("DRC2R", MADERA_DRC2_CTRL1, MADERA_DRC2R_ENA_SHIFT, 0, 796 NULL, 0), 797 798SND_SOC_DAPM_PGA("LHPF1", MADERA_HPLPF1_1, MADERA_LHPF1_ENA_SHIFT, 0, 799 NULL, 0), 800SND_SOC_DAPM_PGA("LHPF2", MADERA_HPLPF2_1, MADERA_LHPF2_ENA_SHIFT, 0, 801 NULL, 0), 802SND_SOC_DAPM_PGA("LHPF3", MADERA_HPLPF3_1, MADERA_LHPF3_ENA_SHIFT, 0, 803 NULL, 0), 804SND_SOC_DAPM_PGA("LHPF4", MADERA_HPLPF4_1, MADERA_LHPF4_ENA_SHIFT, 0, 805 NULL, 0), 806 807SND_SOC_DAPM_PGA("ISRC1DEC1", MADERA_ISRC_1_CTRL_3, 808 MADERA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0), 809SND_SOC_DAPM_PGA("ISRC1DEC2", MADERA_ISRC_1_CTRL_3, 810 MADERA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0), 811SND_SOC_DAPM_PGA("ISRC1DEC3", MADERA_ISRC_1_CTRL_3, 812 MADERA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0), 813SND_SOC_DAPM_PGA("ISRC1DEC4", MADERA_ISRC_1_CTRL_3, 814 MADERA_ISRC1_DEC4_ENA_SHIFT, 0, NULL, 0), 815 816SND_SOC_DAPM_PGA("ISRC1INT1", MADERA_ISRC_1_CTRL_3, 817 MADERA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0), 818SND_SOC_DAPM_PGA("ISRC1INT2", MADERA_ISRC_1_CTRL_3, 819 MADERA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0), 820SND_SOC_DAPM_PGA("ISRC1INT3", MADERA_ISRC_1_CTRL_3, 821 MADERA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0), 822SND_SOC_DAPM_PGA("ISRC1INT4", MADERA_ISRC_1_CTRL_3, 823 MADERA_ISRC1_INT4_ENA_SHIFT, 0, NULL, 0), 824 825SND_SOC_DAPM_PGA("ISRC2DEC1", MADERA_ISRC_2_CTRL_3, 826 MADERA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0), 827SND_SOC_DAPM_PGA("ISRC2DEC2", MADERA_ISRC_2_CTRL_3, 828 MADERA_ISRC2_DEC2_ENA_SHIFT, 0, NULL, 0), 829SND_SOC_DAPM_PGA("ISRC2DEC3", MADERA_ISRC_2_CTRL_3, 830 MADERA_ISRC2_DEC3_ENA_SHIFT, 0, NULL, 0), 831SND_SOC_DAPM_PGA("ISRC2DEC4", MADERA_ISRC_2_CTRL_3, 832 MADERA_ISRC2_DEC4_ENA_SHIFT, 0, NULL, 0), 833 834SND_SOC_DAPM_PGA("ISRC2INT1", MADERA_ISRC_2_CTRL_3, 835 MADERA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0), 836SND_SOC_DAPM_PGA("ISRC2INT2", MADERA_ISRC_2_CTRL_3, 837 MADERA_ISRC2_INT2_ENA_SHIFT, 0, NULL, 0), 838SND_SOC_DAPM_PGA("ISRC2INT3", MADERA_ISRC_2_CTRL_3, 839 MADERA_ISRC2_INT3_ENA_SHIFT, 0, NULL, 0), 840SND_SOC_DAPM_PGA("ISRC2INT4", MADERA_ISRC_2_CTRL_3, 841 MADERA_ISRC2_INT4_ENA_SHIFT, 0, NULL, 0), 842 843WM_ADSP2("DSP1", 0, cs47l35_adsp_power_ev), 844WM_ADSP2("DSP2", 1, cs47l35_adsp_power_ev), 845WM_ADSP2("DSP3", 2, cs47l35_adsp_power_ev), 846 847/* End of ordered input mux widgets */ 848 849MADERA_MIXER_WIDGETS(EQ1, "EQ1"), 850MADERA_MIXER_WIDGETS(EQ2, "EQ2"), 851MADERA_MIXER_WIDGETS(EQ3, "EQ3"), 852MADERA_MIXER_WIDGETS(EQ4, "EQ4"), 853 854MADERA_MIXER_WIDGETS(DRC1L, "DRC1L"), 855MADERA_MIXER_WIDGETS(DRC1R, "DRC1R"), 856MADERA_MIXER_WIDGETS(DRC2L, "DRC2L"), 857MADERA_MIXER_WIDGETS(DRC2R, "DRC2R"), 858 859SND_SOC_DAPM_SWITCH("DRC1 Activity Output", SND_SOC_NOPM, 0, 0, 860 &madera_drc_activity_output_mux[0]), 861SND_SOC_DAPM_SWITCH("DRC2 Activity Output", SND_SOC_NOPM, 0, 0, 862 &madera_drc_activity_output_mux[1]), 863 864MADERA_MIXER_WIDGETS(LHPF1, "LHPF1"), 865MADERA_MIXER_WIDGETS(LHPF2, "LHPF2"), 866MADERA_MIXER_WIDGETS(LHPF3, "LHPF3"), 867MADERA_MIXER_WIDGETS(LHPF4, "LHPF4"), 868 869MADERA_MIXER_WIDGETS(PWM1, "PWM1"), 870MADERA_MIXER_WIDGETS(PWM2, "PWM2"), 871 872MADERA_MIXER_WIDGETS(OUT1L, "HPOUT1L"), 873MADERA_MIXER_WIDGETS(OUT1R, "HPOUT1R"), 874MADERA_MIXER_WIDGETS(SPKOUT, "SPKOUT"), 875MADERA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"), 876MADERA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"), 877 878MADERA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"), 879MADERA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"), 880MADERA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"), 881MADERA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"), 882MADERA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"), 883MADERA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"), 884 885MADERA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"), 886MADERA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"), 887 888MADERA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), 889MADERA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), 890 891MADERA_MIXER_WIDGETS(SLIMTX1, "SLIMTX1"), 892MADERA_MIXER_WIDGETS(SLIMTX2, "SLIMTX2"), 893MADERA_MIXER_WIDGETS(SLIMTX3, "SLIMTX3"), 894MADERA_MIXER_WIDGETS(SLIMTX4, "SLIMTX4"), 895MADERA_MIXER_WIDGETS(SLIMTX5, "SLIMTX5"), 896MADERA_MIXER_WIDGETS(SLIMTX6, "SLIMTX6"), 897 898MADERA_MUX_WIDGETS(SPD1TX1, "SPDIF1TX1"), 899MADERA_MUX_WIDGETS(SPD1TX2, "SPDIF1TX2"), 900 901MADERA_DSP_WIDGETS(DSP1, "DSP1"), 902MADERA_DSP_WIDGETS(DSP2, "DSP2"), 903MADERA_DSP_WIDGETS(DSP3, "DSP3"), 904 905SND_SOC_DAPM_SWITCH("DSP1 Trigger Output", SND_SOC_NOPM, 0, 0, 906 &madera_dsp_trigger_output_mux[0]), 907SND_SOC_DAPM_SWITCH("DSP2 Trigger Output", SND_SOC_NOPM, 0, 0, 908 &madera_dsp_trigger_output_mux[1]), 909SND_SOC_DAPM_SWITCH("DSP3 Trigger Output", SND_SOC_NOPM, 0, 0, 910 &madera_dsp_trigger_output_mux[2]), 911 912MADERA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"), 913MADERA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"), 914MADERA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"), 915MADERA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"), 916 917MADERA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"), 918MADERA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"), 919MADERA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"), 920MADERA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"), 921 922MADERA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"), 923MADERA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"), 924MADERA_MUX_WIDGETS(ISRC2DEC3, "ISRC2DEC3"), 925MADERA_MUX_WIDGETS(ISRC2DEC4, "ISRC2DEC4"), 926 927MADERA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"), 928MADERA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"), 929MADERA_MUX_WIDGETS(ISRC2INT3, "ISRC2INT3"), 930MADERA_MUX_WIDGETS(ISRC2INT4, "ISRC2INT4"), 931 932SND_SOC_DAPM_OUTPUT("HPOUTL"), 933SND_SOC_DAPM_OUTPUT("HPOUTR"), 934SND_SOC_DAPM_OUTPUT("EPOUTP"), 935SND_SOC_DAPM_OUTPUT("EPOUTN"), 936SND_SOC_DAPM_OUTPUT("SPKOUTN"), 937SND_SOC_DAPM_OUTPUT("SPKOUTP"), 938SND_SOC_DAPM_OUTPUT("SPKDAT1L"), 939SND_SOC_DAPM_OUTPUT("SPKDAT1R"), 940SND_SOC_DAPM_OUTPUT("SPDIF1"), 941 942SND_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 1019static 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 { "HPOUT1 Mono Mux", "EPOUT", "OUT1L" }, 1309 1310 { "HPOUTL", "HPOUT", "HPOUT1 Demux" }, 1311 { "HPOUTR", "HPOUT", "HPOUT1 Demux" }, 1312 { "EPOUTP", "EPOUT", "HPOUT1 Demux" }, 1313 { "EPOUTN", "EPOUT", "HPOUT1 Demux" }, 1314 1315 { "AEC1 Loopback", "SPKDAT1L", "OUT5L" }, 1316 { "AEC1 Loopback", "SPKDAT1R", "OUT5R" }, 1317 { "AEC2 Loopback", "SPKDAT1L", "OUT5L" }, 1318 { "AEC2 Loopback", "SPKDAT1R", "OUT5R" }, 1319 { "SPKDAT1L", NULL, "OUT5L" }, 1320 { "SPKDAT1R", NULL, "OUT5R" }, 1321 1322 { "SPDIF1", NULL, "SPD1" }, 1323 1324 { "MICSUPP", NULL, "SYSCLK" }, 1325 1326 { "DRC1 Signal Activity", NULL, "DRC1 Activity Output" }, 1327 { "DRC2 Signal Activity", NULL, "DRC2 Activity Output" }, 1328 { "DRC1 Activity Output", "Switch", "DRC1L" }, 1329 { "DRC1 Activity Output", "Switch", "DRC1R" }, 1330 { "DRC2 Activity Output", "Switch", "DRC2L" }, 1331 { "DRC2 Activity Output", "Switch", "DRC2R" }, 1332}; 1333 1334static int cs47l35_set_fll(struct snd_soc_component *component, int fll_id, 1335 int source, unsigned int fref, unsigned int fout) 1336{ 1337 struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); 1338 1339 switch (fll_id) { 1340 case MADERA_FLL1_REFCLK: 1341 return madera_set_fll_refclk(&cs47l35->fll, source, fref, 1342 fout); 1343 case MADERA_FLL1_SYNCCLK: 1344 return madera_set_fll_syncclk(&cs47l35->fll, source, fref, 1345 fout); 1346 default: 1347 return -EINVAL; 1348 } 1349} 1350 1351static struct snd_soc_dai_driver cs47l35_dai[] = { 1352 { 1353 .name = "cs47l35-aif1", 1354 .id = 1, 1355 .base = MADERA_AIF1_BCLK_CTRL, 1356 .playback = { 1357 .stream_name = "AIF1 Playback", 1358 .channels_min = 1, 1359 .channels_max = 6, 1360 .rates = MADERA_RATES, 1361 .formats = MADERA_FORMATS, 1362 }, 1363 .capture = { 1364 .stream_name = "AIF1 Capture", 1365 .channels_min = 1, 1366 .channels_max = 6, 1367 .rates = MADERA_RATES, 1368 .formats = MADERA_FORMATS, 1369 }, 1370 .ops = &madera_dai_ops, 1371 .symmetric_rate = 1, 1372 .symmetric_sample_bits = 1, 1373 }, 1374 { 1375 .name = "cs47l35-aif2", 1376 .id = 2, 1377 .base = MADERA_AIF2_BCLK_CTRL, 1378 .playback = { 1379 .stream_name = "AIF2 Playback", 1380 .channels_min = 1, 1381 .channels_max = 2, 1382 .rates = MADERA_RATES, 1383 .formats = MADERA_FORMATS, 1384 }, 1385 .capture = { 1386 .stream_name = "AIF2 Capture", 1387 .channels_min = 1, 1388 .channels_max = 2, 1389 .rates = MADERA_RATES, 1390 .formats = MADERA_FORMATS, 1391 }, 1392 .ops = &madera_dai_ops, 1393 .symmetric_rate = 1, 1394 .symmetric_sample_bits = 1, 1395 }, 1396 { 1397 .name = "cs47l35-aif3", 1398 .id = 3, 1399 .base = MADERA_AIF3_BCLK_CTRL, 1400 .playback = { 1401 .stream_name = "AIF3 Playback", 1402 .channels_min = 1, 1403 .channels_max = 2, 1404 .rates = MADERA_RATES, 1405 .formats = MADERA_FORMATS, 1406 }, 1407 .capture = { 1408 .stream_name = "AIF3 Capture", 1409 .channels_min = 1, 1410 .channels_max = 2, 1411 .rates = MADERA_RATES, 1412 .formats = MADERA_FORMATS, 1413 }, 1414 .ops = &madera_dai_ops, 1415 .symmetric_rate = 1, 1416 .symmetric_sample_bits = 1, 1417 }, 1418 { 1419 .name = "cs47l35-slim1", 1420 .id = 4, 1421 .playback = { 1422 .stream_name = "Slim1 Playback", 1423 .channels_min = 1, 1424 .channels_max = 4, 1425 .rates = MADERA_RATES, 1426 .formats = MADERA_FORMATS, 1427 }, 1428 .capture = { 1429 .stream_name = "Slim1 Capture", 1430 .channels_min = 1, 1431 .channels_max = 4, 1432 .rates = MADERA_RATES, 1433 .formats = MADERA_FORMATS, 1434 }, 1435 .ops = &madera_simple_dai_ops, 1436 }, 1437 { 1438 .name = "cs47l35-slim2", 1439 .id = 5, 1440 .playback = { 1441 .stream_name = "Slim2 Playback", 1442 .channels_min = 1, 1443 .channels_max = 2, 1444 .rates = MADERA_RATES, 1445 .formats = MADERA_FORMATS, 1446 }, 1447 .capture = { 1448 .stream_name = "Slim2 Capture", 1449 .channels_min = 1, 1450 .channels_max = 2, 1451 .rates = MADERA_RATES, 1452 .formats = MADERA_FORMATS, 1453 }, 1454 .ops = &madera_simple_dai_ops, 1455 }, 1456 { 1457 .name = "cs47l35-cpu-voicectrl", 1458 .capture = { 1459 .stream_name = "Voice Control CPU", 1460 .channels_min = 1, 1461 .channels_max = 1, 1462 .rates = MADERA_RATES, 1463 .formats = MADERA_FORMATS, 1464 }, 1465 .compress_new = &snd_soc_new_compress, 1466 }, 1467 { 1468 .name = "cs47l35-dsp-voicectrl", 1469 .capture = { 1470 .stream_name = "Voice Control DSP", 1471 .channels_min = 1, 1472 .channels_max = 1, 1473 .rates = MADERA_RATES, 1474 .formats = MADERA_FORMATS, 1475 }, 1476 }, 1477 { 1478 .name = "cs47l35-cpu-trace", 1479 .capture = { 1480 .stream_name = "Audio Trace CPU", 1481 .channels_min = 1, 1482 .channels_max = 6, 1483 .rates = MADERA_RATES, 1484 .formats = MADERA_FORMATS, 1485 }, 1486 .compress_new = &snd_soc_new_compress, 1487 }, 1488 { 1489 .name = "cs47l35-dsp-trace", 1490 .capture = { 1491 .stream_name = "Audio Trace DSP", 1492 .channels_min = 1, 1493 .channels_max = 6, 1494 .rates = MADERA_RATES, 1495 .formats = MADERA_FORMATS, 1496 }, 1497 }, 1498}; 1499 1500static int cs47l35_open(struct snd_soc_component *component, 1501 struct snd_compr_stream *stream) 1502{ 1503 struct snd_soc_pcm_runtime *rtd = stream->private_data; 1504 struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); 1505 struct madera_priv *priv = &cs47l35->core; 1506 struct madera *madera = priv->madera; 1507 int n_adsp; 1508 1509 if (strcmp(asoc_rtd_to_codec(rtd, 0)->name, "cs47l35-dsp-voicectrl") == 0) { 1510 n_adsp = 2; 1511 } else if (strcmp(asoc_rtd_to_codec(rtd, 0)->name, "cs47l35-dsp-trace") == 0) { 1512 n_adsp = 0; 1513 } else { 1514 dev_err(madera->dev, 1515 "No suitable compressed stream for DAI '%s'\n", 1516 asoc_rtd_to_codec(rtd, 0)->name); 1517 return -EINVAL; 1518 } 1519 1520 return wm_adsp_compr_open(&priv->adsp[n_adsp], stream); 1521} 1522 1523static irqreturn_t cs47l35_adsp2_irq(int irq, void *data) 1524{ 1525 struct cs47l35 *cs47l35 = data; 1526 struct madera_priv *priv = &cs47l35->core; 1527 struct madera *madera = priv->madera; 1528 struct madera_voice_trigger_info trig_info; 1529 int serviced = 0; 1530 int i, ret; 1531 1532 for (i = 0; i < CS47L35_NUM_ADSP; ++i) { 1533 ret = wm_adsp_compr_handle_irq(&priv->adsp[i]); 1534 if (ret != -ENODEV) 1535 serviced++; 1536 if (ret == WM_ADSP_COMPR_VOICE_TRIGGER) { 1537 trig_info.core_num = i + 1; 1538 blocking_notifier_call_chain(&madera->notifier, 1539 MADERA_NOTIFY_VOICE_TRIGGER, 1540 &trig_info); 1541 } 1542 } 1543 1544 if (!serviced) { 1545 dev_err(madera->dev, "Spurious compressed data IRQ\n"); 1546 return IRQ_NONE; 1547 } 1548 1549 return IRQ_HANDLED; 1550} 1551 1552static const struct snd_soc_dapm_route cs47l35_mono_routes[] = { 1553 { "HPOUT1 Mono Mux", "HPOUT", "OUT1L" }, 1554}; 1555 1556static 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 1592static 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 1608static 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 1616static 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 1626static 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 1644static 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].cs_dsp.num = i + 1; 1690 cs47l35->core.adsp[i].cs_dsp.type = WMFW_ADSP2; 1691 cs47l35->core.adsp[i].cs_dsp.rev = 1; 1692 cs47l35->core.adsp[i].cs_dsp.dev = madera->dev; 1693 cs47l35->core.adsp[i].cs_dsp.regmap = madera->regmap_32bit; 1694 1695 cs47l35->core.adsp[i].cs_dsp.base = wm_adsp2_control_bases[i]; 1696 cs47l35->core.adsp[i].cs_dsp.mem = cs47l35_dsp_regions[i]; 1697 cs47l35->core.adsp[i].cs_dsp.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 1732error_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]); 1737error_dsp_irq: 1738 madera_set_irq_wake(madera, MADERA_IRQ_DSP_IRQ1, 0); 1739 madera_free_irq(madera, MADERA_IRQ_DSP_IRQ1, cs47l35); 1740error_overheat: 1741 madera_free_overheat(&cs47l35->core); 1742error_core: 1743 madera_core_free(&cs47l35->core); 1744 1745 return ret; 1746} 1747 1748static 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 1766static struct platform_driver cs47l35_codec_driver = { 1767 .driver = { 1768 .name = "cs47l35-codec", 1769 }, 1770 .probe = &cs47l35_probe, 1771 .remove = &cs47l35_remove, 1772}; 1773 1774module_platform_driver(cs47l35_codec_driver); 1775 1776MODULE_SOFTDEP("pre: madera irq-madera arizona-micsupp"); 1777MODULE_DESCRIPTION("ASoC CS47L35 driver"); 1778MODULE_AUTHOR("Piotr Stankiewicz <piotrs@opensource.cirrus.com>"); 1779MODULE_LICENSE("GPL v2"); 1780MODULE_ALIAS("platform:cs47l35-codec");