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