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