1 /* 2 * wm8998.c -- ALSA SoC Audio driver for WM8998 codecs 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 "wm8998.h" 34 35 struct wm8998_priv { 36 struct arizona_priv core; 37 struct arizona_fll fll[2]; 38 }; 39 40 static int wm8998_asrc_ev(struct snd_soc_dapm_widget *w, 41 struct snd_kcontrol *kcontrol, 42 int event) 43 { 44 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 45 unsigned int val; 46 47 switch (event) { 48 case SND_SOC_DAPM_PRE_PMU: 49 val = snd_soc_read(codec, ARIZONA_ASRC_RATE1); 50 val &= ARIZONA_ASRC_RATE1_MASK; 51 val >>= ARIZONA_ASRC_RATE1_SHIFT; 52 53 switch (val) { 54 case 0: 55 case 1: 56 case 2: 57 val = snd_soc_read(codec, 58 ARIZONA_SAMPLE_RATE_1 + val); 59 if (val >= 0x11) { 60 dev_warn(codec->dev, 61 "Unsupported ASRC rate1 (%s)\n", 62 arizona_sample_rate_val_to_name(val)); 63 return -EINVAL; 64 } 65 break; 66 default: 67 dev_err(codec->dev, 68 "Illegal ASRC rate1 selector (0x%x)\n", 69 val); 70 return -EINVAL; 71 } 72 73 val = snd_soc_read(codec, ARIZONA_ASRC_RATE2); 74 val &= ARIZONA_ASRC_RATE2_MASK; 75 val >>= ARIZONA_ASRC_RATE2_SHIFT; 76 77 switch (val) { 78 case 8: 79 case 9: 80 val -= 0x8; 81 val = snd_soc_read(codec, 82 ARIZONA_ASYNC_SAMPLE_RATE_1 + val); 83 if (val >= 0x11) { 84 dev_warn(codec->dev, 85 "Unsupported ASRC rate2 (%s)\n", 86 arizona_sample_rate_val_to_name(val)); 87 return -EINVAL; 88 } 89 break; 90 default: 91 dev_err(codec->dev, 92 "Illegal ASRC rate2 selector (0x%x)\n", 93 val); 94 return -EINVAL; 95 } 96 break; 97 default: 98 return -EINVAL; 99 } 100 101 return 0; 102 } 103 104 static int wm8998_inmux_put(struct snd_kcontrol *kcontrol, 105 struct snd_ctl_elem_value *ucontrol) 106 { 107 struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); 108 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); 109 struct wm8998_priv *wm8998 = snd_soc_codec_get_drvdata(codec); 110 struct arizona *arizona = wm8998->core.arizona; 111 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 112 unsigned int mode_reg, mode_index; 113 unsigned int mux, inmode, src_val, mode_val; 114 115 mux = ucontrol->value.enumerated.item[0]; 116 if (mux > 1) 117 return -EINVAL; 118 119 switch (e->reg) { 120 case ARIZONA_ADC_DIGITAL_VOLUME_2L: 121 mode_reg = ARIZONA_IN2L_CONTROL; 122 mode_index = 1 + (2 * mux); 123 break; 124 default: 125 mode_reg = ARIZONA_IN1L_CONTROL; 126 mode_index = (2 * mux); 127 break; 128 } 129 130 inmode = arizona->pdata.inmode[mode_index]; 131 if (inmode & ARIZONA_INMODE_DMIC) 132 mode_val = 1 << ARIZONA_IN1_MODE_SHIFT; 133 else 134 mode_val = 0; 135 136 src_val = mux << ARIZONA_IN1L_SRC_SHIFT; 137 if (inmode & ARIZONA_INMODE_SE) 138 src_val |= 1 << ARIZONA_IN1L_SRC_SE_SHIFT; 139 140 snd_soc_update_bits(codec, mode_reg, ARIZONA_IN1_MODE_MASK, mode_val); 141 142 snd_soc_update_bits(codec, e->reg, 143 ARIZONA_IN1L_SRC_MASK | ARIZONA_IN1L_SRC_SE_MASK, 144 src_val); 145 146 return snd_soc_dapm_mux_update_power(dapm, kcontrol, 147 ucontrol->value.enumerated.item[0], 148 e, NULL); 149 } 150 151 static const char * const wm8998_inmux_texts[] = { 152 "A", 153 "B", 154 }; 155 156 static SOC_ENUM_SINGLE_DECL(wm8998_in1muxl_enum, 157 ARIZONA_ADC_DIGITAL_VOLUME_1L, 158 ARIZONA_IN1L_SRC_SHIFT, 159 wm8998_inmux_texts); 160 161 static SOC_ENUM_SINGLE_DECL(wm8998_in1muxr_enum, 162 ARIZONA_ADC_DIGITAL_VOLUME_1R, 163 ARIZONA_IN1R_SRC_SHIFT, 164 wm8998_inmux_texts); 165 166 static SOC_ENUM_SINGLE_DECL(wm8998_in2mux_enum, 167 ARIZONA_ADC_DIGITAL_VOLUME_2L, 168 ARIZONA_IN2L_SRC_SHIFT, 169 wm8998_inmux_texts); 170 171 static const struct snd_kcontrol_new wm8998_in1mux[2] = { 172 SOC_DAPM_ENUM_EXT("IN1L Mux", wm8998_in1muxl_enum, 173 snd_soc_dapm_get_enum_double, wm8998_inmux_put), 174 SOC_DAPM_ENUM_EXT("IN1R Mux", wm8998_in1muxr_enum, 175 snd_soc_dapm_get_enum_double, wm8998_inmux_put), 176 }; 177 178 static const struct snd_kcontrol_new wm8998_in2mux = 179 SOC_DAPM_ENUM_EXT("IN2 Mux", wm8998_in2mux_enum, 180 snd_soc_dapm_get_enum_double, wm8998_inmux_put); 181 182 static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0); 183 static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); 184 static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); 185 static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0); 186 187 #define WM8998_NG_SRC(name, base) \ 188 SOC_SINGLE(name " NG HPOUTL Switch", base, 0, 1, 0), \ 189 SOC_SINGLE(name " NG HPOUTR Switch", base, 1, 1, 0), \ 190 SOC_SINGLE(name " NG LINEOUTL Switch", base, 2, 1, 0), \ 191 SOC_SINGLE(name " NG LINEOUTR Switch", base, 3, 1, 0), \ 192 SOC_SINGLE(name " NG EPOUT Switch", base, 4, 1, 0), \ 193 SOC_SINGLE(name " NG SPKOUTL Switch", base, 6, 1, 0), \ 194 SOC_SINGLE(name " NG SPKOUTR Switch", base, 7, 1, 0) 195 196 static const struct snd_kcontrol_new wm8998_snd_controls[] = { 197 SOC_ENUM("IN1 OSR", arizona_in_dmic_osr[0]), 198 SOC_ENUM("IN2 OSR", arizona_in_dmic_osr[1]), 199 200 SOC_SINGLE_RANGE_TLV("IN1L Volume", ARIZONA_IN1L_CONTROL, 201 ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), 202 SOC_SINGLE_RANGE_TLV("IN1R Volume", ARIZONA_IN1R_CONTROL, 203 ARIZONA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), 204 SOC_SINGLE_RANGE_TLV("IN2 Volume", ARIZONA_IN2L_CONTROL, 205 ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), 206 207 SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum), 208 209 SOC_SINGLE("IN1L HPF Switch", ARIZONA_IN1L_CONTROL, 210 ARIZONA_IN1L_HPF_SHIFT, 1, 0), 211 SOC_SINGLE("IN1R HPF Switch", ARIZONA_IN1R_CONTROL, 212 ARIZONA_IN1R_HPF_SHIFT, 1, 0), 213 SOC_SINGLE("IN2 HPF Switch", ARIZONA_IN2L_CONTROL, 214 ARIZONA_IN2L_HPF_SHIFT, 1, 0), 215 216 SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L, 217 ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), 218 SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R, 219 ARIZONA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), 220 SOC_SINGLE_TLV("IN2 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L, 221 ARIZONA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), 222 223 SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp), 224 SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp), 225 226 ARIZONA_GAINMUX_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE), 227 ARIZONA_GAINMUX_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), 228 ARIZONA_GAINMUX_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), 229 ARIZONA_GAINMUX_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), 230 231 SND_SOC_BYTES("EQ1 Coefficients", ARIZONA_EQ1_3, 19), 232 SOC_SINGLE("EQ1 Mode Switch", ARIZONA_EQ1_2, ARIZONA_EQ1_B1_MODE_SHIFT, 1, 0), 233 SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, 234 24, 0, eq_tlv), 235 SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, 236 24, 0, eq_tlv), 237 SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT, 238 24, 0, eq_tlv), 239 SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT, 240 24, 0, eq_tlv), 241 SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT, 242 24, 0, eq_tlv), 243 244 SND_SOC_BYTES("EQ2 Coefficients", ARIZONA_EQ2_3, 19), 245 SOC_SINGLE("EQ2 Mode Switch", ARIZONA_EQ2_2, ARIZONA_EQ2_B1_MODE_SHIFT, 1, 0), 246 SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT, 247 24, 0, eq_tlv), 248 SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT, 249 24, 0, eq_tlv), 250 SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT, 251 24, 0, eq_tlv), 252 SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT, 253 24, 0, eq_tlv), 254 SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT, 255 24, 0, eq_tlv), 256 257 SND_SOC_BYTES("EQ3 Coefficients", ARIZONA_EQ3_3, 19), 258 SOC_SINGLE("EQ3 Mode Switch", ARIZONA_EQ3_2, ARIZONA_EQ3_B1_MODE_SHIFT, 1, 0), 259 SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT, 260 24, 0, eq_tlv), 261 SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT, 262 24, 0, eq_tlv), 263 SOC_SINGLE_TLV("EQ3 B3 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B3_GAIN_SHIFT, 264 24, 0, eq_tlv), 265 SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT, 266 24, 0, eq_tlv), 267 SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT, 268 24, 0, eq_tlv), 269 270 SND_SOC_BYTES("EQ4 Coefficients", ARIZONA_EQ4_3, 19), 271 SOC_SINGLE("EQ4 Mode Switch", ARIZONA_EQ4_2, ARIZONA_EQ4_B1_MODE_SHIFT, 1, 0), 272 SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT, 273 24, 0, eq_tlv), 274 SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT, 275 24, 0, eq_tlv), 276 SOC_SINGLE_TLV("EQ4 B3 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B3_GAIN_SHIFT, 277 24, 0, eq_tlv), 278 SOC_SINGLE_TLV("EQ4 B4 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B4_GAIN_SHIFT, 279 24, 0, eq_tlv), 280 SOC_SINGLE_TLV("EQ4 B5 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B5_GAIN_SHIFT, 281 24, 0, eq_tlv), 282 283 ARIZONA_GAINMUX_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE), 284 ARIZONA_GAINMUX_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE), 285 286 SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5, 287 ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA), 288 289 ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE), 290 ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE), 291 ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), 292 ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), 293 294 SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1), 295 SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1), 296 SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1), 297 SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1), 298 299 SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode), 300 SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), 301 SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), 302 SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), 303 304 SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), 305 SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), 306 SOC_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]), 307 SOC_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]), 308 SOC_ENUM("ASRC RATE 1", arizona_asrc_rate1), 309 310 ARIZONA_MIXER_CONTROLS("HPOUTL", ARIZONA_OUT1LMIX_INPUT_1_SOURCE), 311 ARIZONA_MIXER_CONTROLS("HPOUTR", ARIZONA_OUT1RMIX_INPUT_1_SOURCE), 312 ARIZONA_MIXER_CONTROLS("LINEOUTL", ARIZONA_OUT2LMIX_INPUT_1_SOURCE), 313 ARIZONA_MIXER_CONTROLS("LINEOUTR", ARIZONA_OUT2RMIX_INPUT_1_SOURCE), 314 ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE), 315 ARIZONA_MIXER_CONTROLS("SPKOUTL", ARIZONA_OUT4LMIX_INPUT_1_SOURCE), 316 ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE), 317 ARIZONA_MIXER_CONTROLS("SPKDATL", ARIZONA_OUT5LMIX_INPUT_1_SOURCE), 318 ARIZONA_MIXER_CONTROLS("SPKDATR", ARIZONA_OUT5RMIX_INPUT_1_SOURCE), 319 320 SOC_DOUBLE_R("HPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L, 321 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1), 322 SOC_DOUBLE_R("LINEOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L, 323 ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_MUTE_SHIFT, 1, 1), 324 SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L, 325 ARIZONA_OUT3L_MUTE_SHIFT, 1, 1), 326 SOC_DOUBLE_R("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L, 327 ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_MUTE_SHIFT, 1, 1), 328 SOC_DOUBLE_R("SPKDAT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L, 329 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1), 330 331 SOC_DOUBLE_R_TLV("HPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L, 332 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT, 333 0xbf, 0, digital_tlv), 334 SOC_DOUBLE_R_TLV("LINEOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_2L, 335 ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_VOL_SHIFT, 336 0xbf, 0, digital_tlv), 337 SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L, 338 ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv), 339 SOC_DOUBLE_R_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L, 340 ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_VOL_SHIFT, 341 0xbf, 0, digital_tlv), 342 SOC_DOUBLE_R_TLV("SPKDAT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L, 343 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT, 344 0xbf, 0, digital_tlv), 345 346 SOC_DOUBLE("SPKDAT Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT, 347 ARIZONA_SPK1R_MUTE_SHIFT, 1, 1), 348 349 SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), 350 SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), 351 352 SOC_SINGLE("Noise Gate Switch", ARIZONA_NOISE_GATE_CONTROL, 353 ARIZONA_NGATE_ENA_SHIFT, 1, 0), 354 SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL, 355 ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv), 356 SOC_ENUM("Noise Gate Hold", arizona_ng_hold), 357 358 WM8998_NG_SRC("HPOUTL", ARIZONA_NOISE_GATE_SELECT_1L), 359 WM8998_NG_SRC("HPOUTR", ARIZONA_NOISE_GATE_SELECT_1R), 360 WM8998_NG_SRC("LINEOUTL", ARIZONA_NOISE_GATE_SELECT_2L), 361 WM8998_NG_SRC("LINEOUTR", ARIZONA_NOISE_GATE_SELECT_2R), 362 WM8998_NG_SRC("EPOUT", ARIZONA_NOISE_GATE_SELECT_3L), 363 WM8998_NG_SRC("SPKOUTL", ARIZONA_NOISE_GATE_SELECT_4L), 364 WM8998_NG_SRC("SPKOUTR", ARIZONA_NOISE_GATE_SELECT_4R), 365 WM8998_NG_SRC("SPKDATL", ARIZONA_NOISE_GATE_SELECT_5L), 366 WM8998_NG_SRC("SPKDATR", ARIZONA_NOISE_GATE_SELECT_5R), 367 368 ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE), 369 ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE), 370 ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE), 371 ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE), 372 ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE), 373 ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE), 374 375 ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE), 376 ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE), 377 ARIZONA_MIXER_CONTROLS("AIF2TX3", ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE), 378 ARIZONA_MIXER_CONTROLS("AIF2TX4", ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE), 379 ARIZONA_MIXER_CONTROLS("AIF2TX5", ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE), 380 ARIZONA_MIXER_CONTROLS("AIF2TX6", ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE), 381 382 ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE), 383 ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE), 384 385 ARIZONA_GAINMUX_CONTROLS("SLIMTX1", ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE), 386 ARIZONA_GAINMUX_CONTROLS("SLIMTX2", ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE), 387 ARIZONA_GAINMUX_CONTROLS("SLIMTX3", ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE), 388 ARIZONA_GAINMUX_CONTROLS("SLIMTX4", ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE), 389 ARIZONA_GAINMUX_CONTROLS("SLIMTX5", ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE), 390 ARIZONA_GAINMUX_CONTROLS("SLIMTX6", ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE), 391 392 ARIZONA_GAINMUX_CONTROLS("SPDIFTX1", ARIZONA_SPDIFTX1MIX_INPUT_1_SOURCE), 393 ARIZONA_GAINMUX_CONTROLS("SPDIFTX2", ARIZONA_SPDIFTX2MIX_INPUT_1_SOURCE), 394 }; 395 396 ARIZONA_MUX_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE); 397 ARIZONA_MUX_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE); 398 ARIZONA_MUX_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE); 399 ARIZONA_MUX_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE); 400 401 ARIZONA_MUX_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE); 402 ARIZONA_MUX_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE); 403 404 ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE); 405 ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE); 406 ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE); 407 ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE); 408 409 ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE); 410 ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE); 411 412 ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE); 413 ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE); 414 ARIZONA_MIXER_ENUMS(OUT2L, ARIZONA_OUT2LMIX_INPUT_1_SOURCE); 415 ARIZONA_MIXER_ENUMS(OUT2R, ARIZONA_OUT2RMIX_INPUT_1_SOURCE); 416 ARIZONA_MIXER_ENUMS(OUT3, ARIZONA_OUT3LMIX_INPUT_1_SOURCE); 417 ARIZONA_MIXER_ENUMS(SPKOUTL, ARIZONA_OUT4LMIX_INPUT_1_SOURCE); 418 ARIZONA_MIXER_ENUMS(SPKOUTR, ARIZONA_OUT4RMIX_INPUT_1_SOURCE); 419 ARIZONA_MIXER_ENUMS(SPKDATL, ARIZONA_OUT5LMIX_INPUT_1_SOURCE); 420 ARIZONA_MIXER_ENUMS(SPKDATR, ARIZONA_OUT5RMIX_INPUT_1_SOURCE); 421 422 ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE); 423 ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE); 424 ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE); 425 ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE); 426 ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE); 427 ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE); 428 429 ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE); 430 ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE); 431 ARIZONA_MIXER_ENUMS(AIF2TX3, ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE); 432 ARIZONA_MIXER_ENUMS(AIF2TX4, ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE); 433 ARIZONA_MIXER_ENUMS(AIF2TX5, ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE); 434 ARIZONA_MIXER_ENUMS(AIF2TX6, ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE); 435 436 ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); 437 ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); 438 439 ARIZONA_MUX_ENUMS(SLIMTX1, ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE); 440 ARIZONA_MUX_ENUMS(SLIMTX2, ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE); 441 ARIZONA_MUX_ENUMS(SLIMTX3, ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE); 442 ARIZONA_MUX_ENUMS(SLIMTX4, ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE); 443 ARIZONA_MUX_ENUMS(SLIMTX5, ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE); 444 ARIZONA_MUX_ENUMS(SLIMTX6, ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE); 445 446 ARIZONA_MUX_ENUMS(SPD1TX1, ARIZONA_SPDIFTX1MIX_INPUT_1_SOURCE); 447 ARIZONA_MUX_ENUMS(SPD1TX2, ARIZONA_SPDIFTX2MIX_INPUT_1_SOURCE); 448 449 ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE); 450 ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); 451 ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); 452 ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); 453 454 ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE); 455 ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE); 456 ARIZONA_MUX_ENUMS(ISRC1INT3, ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE); 457 ARIZONA_MUX_ENUMS(ISRC1INT4, ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE); 458 459 ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE); 460 ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE); 461 ARIZONA_MUX_ENUMS(ISRC1DEC3, ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE); 462 ARIZONA_MUX_ENUMS(ISRC1DEC4, ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE); 463 464 ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE); 465 ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE); 466 467 ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE); 468 ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE); 469 470 static const char * const wm8998_aec_loopback_texts[] = { 471 "HPOUTL", "HPOUTR", "LINEOUTL", "LINEOUTR", "EPOUT", 472 "SPKOUTL", "SPKOUTR", "SPKDATL", "SPKDATR", 473 }; 474 475 static const unsigned int wm8998_aec_loopback_values[] = { 476 0, 1, 2, 3, 4, 6, 7, 8, 9, 477 }; 478 479 static SOC_VALUE_ENUM_SINGLE_DECL(wm8998_aec1_loopback, 480 ARIZONA_DAC_AEC_CONTROL_1, 481 ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf, 482 wm8998_aec_loopback_texts, 483 wm8998_aec_loopback_values); 484 485 static SOC_VALUE_ENUM_SINGLE_DECL(wm8998_aec2_loopback, 486 ARIZONA_DAC_AEC_CONTROL_2, 487 ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf, 488 wm8998_aec_loopback_texts, 489 wm8998_aec_loopback_values); 490 491 static const struct snd_kcontrol_new wm8998_aec_loopback_mux[] = { 492 SOC_DAPM_ENUM("AEC1 Loopback", wm8998_aec1_loopback), 493 SOC_DAPM_ENUM("AEC2 Loopback", wm8998_aec2_loopback), 494 }; 495 496 static const struct snd_soc_dapm_widget wm8998_dapm_widgets[] = { 497 SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, 498 ARIZONA_SYSCLK_ENA_SHIFT, 0, arizona_clk_ev, 499 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 500 SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, 501 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, arizona_clk_ev, 502 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 503 SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK, 504 ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0), 505 SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK, 506 ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0), 507 508 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0), 509 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0), 510 SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0), 511 SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS), 512 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0, 0), 513 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0), 514 515 SND_SOC_DAPM_SIGGEN("TONE"), 516 SND_SOC_DAPM_SIGGEN("HAPTICS"), 517 518 SND_SOC_DAPM_INPUT("IN1AL"), 519 SND_SOC_DAPM_INPUT("IN1AR"), 520 SND_SOC_DAPM_INPUT("IN1BL"), 521 SND_SOC_DAPM_INPUT("IN1BR"), 522 SND_SOC_DAPM_INPUT("IN2A"), 523 SND_SOC_DAPM_INPUT("IN2B"), 524 525 SND_SOC_DAPM_MUX("IN1L Mux", SND_SOC_NOPM, 0, 0, &wm8998_in1mux[0]), 526 SND_SOC_DAPM_MUX("IN1R Mux", SND_SOC_NOPM, 0, 0, &wm8998_in1mux[1]), 527 SND_SOC_DAPM_MUX("IN2 Mux", SND_SOC_NOPM, 0, 0, &wm8998_in2mux), 528 529 SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"), 530 531 SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT, 532 0, NULL, 0, arizona_in_ev, 533 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 534 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 535 SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT, 536 0, NULL, 0, arizona_in_ev, 537 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 538 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 539 SND_SOC_DAPM_PGA_E("IN2 PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT, 540 0, NULL, 0, arizona_in_ev, 541 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | 542 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 543 544 SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1, 545 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 546 SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2, 547 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 548 SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3, 549 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 550 551 SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1, 552 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0), 553 SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1, 554 ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0), 555 556 SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0), 557 SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0), 558 SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0), 559 SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0), 560 561 SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0, 562 NULL, 0), 563 SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0, 564 NULL, 0), 565 566 SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0, 567 NULL, 0), 568 SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0, 569 NULL, 0), 570 SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0, 571 NULL, 0), 572 SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0, 573 NULL, 0), 574 575 SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT, 576 0, NULL, 0), 577 SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT, 578 0, NULL, 0), 579 580 SND_SOC_DAPM_PGA_E("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0, 581 NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU), 582 SND_SOC_DAPM_PGA_E("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0, 583 NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU), 584 SND_SOC_DAPM_PGA_E("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0, 585 NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU), 586 SND_SOC_DAPM_PGA_E("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0, 587 NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU), 588 589 SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3, 590 ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0), 591 SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3, 592 ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0), 593 SND_SOC_DAPM_PGA("ISRC1INT3", ARIZONA_ISRC_1_CTRL_3, 594 ARIZONA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0), 595 SND_SOC_DAPM_PGA("ISRC1INT4", ARIZONA_ISRC_1_CTRL_3, 596 ARIZONA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0), 597 598 SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3, 599 ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0), 600 SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3, 601 ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0), 602 SND_SOC_DAPM_PGA("ISRC1DEC3", ARIZONA_ISRC_1_CTRL_3, 603 ARIZONA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0), 604 SND_SOC_DAPM_PGA("ISRC1DEC4", ARIZONA_ISRC_1_CTRL_3, 605 ARIZONA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0), 606 607 SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3, 608 ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0), 609 SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3, 610 ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0), 611 612 SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3, 613 ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0), 614 SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3, 615 ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0), 616 617 SND_SOC_DAPM_MUX("AEC1 Loopback", ARIZONA_DAC_AEC_CONTROL_1, 618 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, 619 &wm8998_aec_loopback_mux[0]), 620 621 SND_SOC_DAPM_MUX("AEC2 Loopback", ARIZONA_DAC_AEC_CONTROL_2, 622 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, 623 &wm8998_aec_loopback_mux[1]), 624 625 SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0, 626 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0), 627 SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0, 628 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0), 629 SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0, 630 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0), 631 SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0, 632 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0), 633 SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0, 634 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0), 635 SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0, 636 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0), 637 638 SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0, 639 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0), 640 SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0, 641 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0), 642 SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0, 643 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0), 644 SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0, 645 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0), 646 SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0, 647 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0), 648 SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0, 649 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0), 650 651 SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0, 652 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0), 653 SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0, 654 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0), 655 SND_SOC_DAPM_AIF_OUT("AIF2TX3", NULL, 0, 656 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX3_ENA_SHIFT, 0), 657 SND_SOC_DAPM_AIF_OUT("AIF2TX4", NULL, 0, 658 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX4_ENA_SHIFT, 0), 659 SND_SOC_DAPM_AIF_OUT("AIF2TX5", NULL, 0, 660 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX5_ENA_SHIFT, 0), 661 SND_SOC_DAPM_AIF_OUT("AIF2TX6", NULL, 0, 662 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX6_ENA_SHIFT, 0), 663 664 SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0, 665 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0), 666 SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0, 667 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0), 668 SND_SOC_DAPM_AIF_IN("AIF2RX3", NULL, 0, 669 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX3_ENA_SHIFT, 0), 670 SND_SOC_DAPM_AIF_IN("AIF2RX4", NULL, 0, 671 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX4_ENA_SHIFT, 0), 672 SND_SOC_DAPM_AIF_IN("AIF2RX5", NULL, 0, 673 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX5_ENA_SHIFT, 0), 674 SND_SOC_DAPM_AIF_IN("AIF2RX6", NULL, 0, 675 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX6_ENA_SHIFT, 0), 676 677 SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0, 678 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, 679 ARIZONA_SLIMRX1_ENA_SHIFT, 0), 680 SND_SOC_DAPM_AIF_IN("SLIMRX2", NULL, 0, 681 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, 682 ARIZONA_SLIMRX2_ENA_SHIFT, 0), 683 SND_SOC_DAPM_AIF_IN("SLIMRX3", NULL, 0, 684 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, 685 ARIZONA_SLIMRX3_ENA_SHIFT, 0), 686 SND_SOC_DAPM_AIF_IN("SLIMRX4", NULL, 0, 687 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, 688 ARIZONA_SLIMRX4_ENA_SHIFT, 0), 689 690 SND_SOC_DAPM_AIF_OUT("SLIMTX1", NULL, 0, 691 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, 692 ARIZONA_SLIMTX1_ENA_SHIFT, 0), 693 SND_SOC_DAPM_AIF_OUT("SLIMTX2", NULL, 0, 694 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, 695 ARIZONA_SLIMTX2_ENA_SHIFT, 0), 696 SND_SOC_DAPM_AIF_OUT("SLIMTX3", NULL, 0, 697 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, 698 ARIZONA_SLIMTX3_ENA_SHIFT, 0), 699 SND_SOC_DAPM_AIF_OUT("SLIMTX4", NULL, 0, 700 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, 701 ARIZONA_SLIMTX4_ENA_SHIFT, 0), 702 SND_SOC_DAPM_AIF_OUT("SLIMTX5", NULL, 0, 703 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, 704 ARIZONA_SLIMTX5_ENA_SHIFT, 0), 705 SND_SOC_DAPM_AIF_OUT("SLIMTX6", NULL, 0, 706 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, 707 ARIZONA_SLIMTX6_ENA_SHIFT, 0), 708 709 SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0, 710 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0), 711 SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0, 712 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0), 713 714 SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0, 715 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0), 716 SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, 717 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0), 718 719 SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, 720 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 721 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 722 SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, 723 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 724 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 725 SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, 726 ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 727 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 728 SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, 729 ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 730 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 731 SND_SOC_DAPM_PGA_E("OUT3", ARIZONA_OUTPUT_ENABLES_1, 732 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 733 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 734 SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, 735 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 736 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 737 SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1, 738 ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 739 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 740 741 SND_SOC_DAPM_PGA("SPD1TX1", ARIZONA_SPD1_TX_CONTROL, 742 ARIZONA_SPD1_VAL1_SHIFT, 0, NULL, 0), 743 SND_SOC_DAPM_PGA("SPD1TX2", ARIZONA_SPD1_TX_CONTROL, 744 ARIZONA_SPD1_VAL2_SHIFT, 0, NULL, 0), 745 SND_SOC_DAPM_OUT_DRV("SPD1", ARIZONA_SPD1_TX_CONTROL, 746 ARIZONA_SPD1_ENA_SHIFT, 0, NULL, 0), 747 748 ARIZONA_MUX_WIDGETS(EQ1, "EQ1"), 749 ARIZONA_MUX_WIDGETS(EQ2, "EQ2"), 750 ARIZONA_MUX_WIDGETS(EQ3, "EQ3"), 751 ARIZONA_MUX_WIDGETS(EQ4, "EQ4"), 752 753 ARIZONA_MUX_WIDGETS(DRC1L, "DRC1L"), 754 ARIZONA_MUX_WIDGETS(DRC1R, "DRC1R"), 755 756 ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"), 757 ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"), 758 ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"), 759 ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"), 760 761 ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"), 762 ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"), 763 764 ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUTL"), 765 ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUTR"), 766 ARIZONA_MIXER_WIDGETS(OUT2L, "LINEOUTL"), 767 ARIZONA_MIXER_WIDGETS(OUT2R, "LINEOUTR"), 768 ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"), 769 ARIZONA_MIXER_WIDGETS(SPKOUTL, "SPKOUTL"), 770 ARIZONA_MIXER_WIDGETS(SPKOUTR, "SPKOUTR"), 771 ARIZONA_MIXER_WIDGETS(SPKDATL, "SPKDATL"), 772 ARIZONA_MIXER_WIDGETS(SPKDATR, "SPKDATR"), 773 774 ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"), 775 ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"), 776 ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"), 777 ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"), 778 ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"), 779 ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"), 780 781 ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"), 782 ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"), 783 ARIZONA_MIXER_WIDGETS(AIF2TX3, "AIF2TX3"), 784 ARIZONA_MIXER_WIDGETS(AIF2TX4, "AIF2TX4"), 785 ARIZONA_MIXER_WIDGETS(AIF2TX5, "AIF2TX5"), 786 ARIZONA_MIXER_WIDGETS(AIF2TX6, "AIF2TX6"), 787 788 ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), 789 ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), 790 791 ARIZONA_MUX_WIDGETS(SLIMTX1, "SLIMTX1"), 792 ARIZONA_MUX_WIDGETS(SLIMTX2, "SLIMTX2"), 793 ARIZONA_MUX_WIDGETS(SLIMTX3, "SLIMTX3"), 794 ARIZONA_MUX_WIDGETS(SLIMTX4, "SLIMTX4"), 795 ARIZONA_MUX_WIDGETS(SLIMTX5, "SLIMTX5"), 796 ARIZONA_MUX_WIDGETS(SLIMTX6, "SLIMTX6"), 797 798 ARIZONA_MUX_WIDGETS(SPD1TX1, "SPDIFTX1"), 799 ARIZONA_MUX_WIDGETS(SPD1TX2, "SPDIFTX2"), 800 801 ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"), 802 ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"), 803 ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"), 804 ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"), 805 806 ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"), 807 ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"), 808 ARIZONA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"), 809 ARIZONA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"), 810 811 ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"), 812 ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"), 813 ARIZONA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"), 814 ARIZONA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"), 815 816 ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"), 817 ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"), 818 819 ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"), 820 ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"), 821 822 SND_SOC_DAPM_OUTPUT("HPOUTL"), 823 SND_SOC_DAPM_OUTPUT("HPOUTR"), 824 SND_SOC_DAPM_OUTPUT("LINEOUTL"), 825 SND_SOC_DAPM_OUTPUT("LINEOUTR"), 826 SND_SOC_DAPM_OUTPUT("EPOUT"), 827 SND_SOC_DAPM_OUTPUT("SPKOUTLN"), 828 SND_SOC_DAPM_OUTPUT("SPKOUTLP"), 829 SND_SOC_DAPM_OUTPUT("SPKOUTRN"), 830 SND_SOC_DAPM_OUTPUT("SPKOUTRP"), 831 SND_SOC_DAPM_OUTPUT("SPKDATL"), 832 SND_SOC_DAPM_OUTPUT("SPKDATR"), 833 SND_SOC_DAPM_OUTPUT("SPDIF"), 834 835 SND_SOC_DAPM_OUTPUT("MICSUPP"), 836 }; 837 838 #define ARIZONA_MIXER_INPUT_ROUTES(name) \ 839 { name, "Tone Generator 1", "Tone Generator 1" }, \ 840 { name, "Tone Generator 2", "Tone Generator 2" }, \ 841 { name, "Haptics", "HAPTICS" }, \ 842 { name, "AEC", "AEC1 Loopback" }, \ 843 { name, "AEC2", "AEC2 Loopback" }, \ 844 { name, "IN1L", "IN1L PGA" }, \ 845 { name, "IN1R", "IN1R PGA" }, \ 846 { name, "IN2L", "IN2 PGA" }, \ 847 { name, "AIF1RX1", "AIF1RX1" }, \ 848 { name, "AIF1RX2", "AIF1RX2" }, \ 849 { name, "AIF1RX3", "AIF1RX3" }, \ 850 { name, "AIF1RX4", "AIF1RX4" }, \ 851 { name, "AIF1RX5", "AIF1RX5" }, \ 852 { name, "AIF1RX6", "AIF1RX6" }, \ 853 { name, "AIF2RX1", "AIF2RX1" }, \ 854 { name, "AIF2RX2", "AIF2RX2" }, \ 855 { name, "AIF2RX3", "AIF2RX3" }, \ 856 { name, "AIF2RX4", "AIF2RX4" }, \ 857 { name, "AIF2RX5", "AIF2RX5" }, \ 858 { name, "AIF2RX6", "AIF2RX6" }, \ 859 { name, "AIF3RX1", "AIF3RX1" }, \ 860 { name, "AIF3RX2", "AIF3RX2" }, \ 861 { name, "SLIMRX1", "SLIMRX1" }, \ 862 { name, "SLIMRX2", "SLIMRX2" }, \ 863 { name, "SLIMRX3", "SLIMRX3" }, \ 864 { name, "SLIMRX4", "SLIMRX4" }, \ 865 { name, "EQ1", "EQ1" }, \ 866 { name, "EQ2", "EQ2" }, \ 867 { name, "EQ3", "EQ3" }, \ 868 { name, "EQ4", "EQ4" }, \ 869 { name, "DRC1L", "DRC1L" }, \ 870 { name, "DRC1R", "DRC1R" }, \ 871 { name, "LHPF1", "LHPF1" }, \ 872 { name, "LHPF2", "LHPF2" }, \ 873 { name, "LHPF3", "LHPF3" }, \ 874 { name, "LHPF4", "LHPF4" }, \ 875 { name, "ASRC1L", "ASRC1L" }, \ 876 { name, "ASRC1R", "ASRC1R" }, \ 877 { name, "ASRC2L", "ASRC2L" }, \ 878 { name, "ASRC2R", "ASRC2R" }, \ 879 { name, "ISRC1DEC1", "ISRC1DEC1" }, \ 880 { name, "ISRC1DEC2", "ISRC1DEC2" }, \ 881 { name, "ISRC1DEC3", "ISRC1DEC3" }, \ 882 { name, "ISRC1DEC4", "ISRC1DEC4" }, \ 883 { name, "ISRC1INT1", "ISRC1INT1" }, \ 884 { name, "ISRC1INT2", "ISRC1INT2" }, \ 885 { name, "ISRC1INT3", "ISRC1INT3" }, \ 886 { name, "ISRC1INT4", "ISRC1INT4" }, \ 887 { name, "ISRC2DEC1", "ISRC2DEC1" }, \ 888 { name, "ISRC2DEC2", "ISRC2DEC2" }, \ 889 { name, "ISRC2INT1", "ISRC2INT1" }, \ 890 { name, "ISRC2INT2", "ISRC2INT2" } 891 892 static const struct snd_soc_dapm_route wm8998_dapm_routes[] = { 893 { "AIF2 Capture", NULL, "DBVDD2" }, 894 { "AIF2 Playback", NULL, "DBVDD2" }, 895 896 { "AIF3 Capture", NULL, "DBVDD3" }, 897 { "AIF3 Playback", NULL, "DBVDD3" }, 898 899 { "OUT1L", NULL, "CPVDD" }, 900 { "OUT1R", NULL, "CPVDD" }, 901 { "OUT2L", NULL, "CPVDD" }, 902 { "OUT2R", NULL, "CPVDD" }, 903 { "OUT3", NULL, "CPVDD" }, 904 905 { "OUT4L", NULL, "SPKVDDL" }, 906 { "OUT4R", NULL, "SPKVDDR" }, 907 908 { "OUT1L", NULL, "SYSCLK" }, 909 { "OUT1R", NULL, "SYSCLK" }, 910 { "OUT2L", NULL, "SYSCLK" }, 911 { "OUT2R", NULL, "SYSCLK" }, 912 { "OUT3", NULL, "SYSCLK" }, 913 { "OUT4L", NULL, "SYSCLK" }, 914 { "OUT4R", NULL, "SYSCLK" }, 915 { "OUT5L", NULL, "SYSCLK" }, 916 { "OUT5R", NULL, "SYSCLK" }, 917 918 { "IN1AL", NULL, "SYSCLK" }, 919 { "IN1AR", NULL, "SYSCLK" }, 920 { "IN1BL", NULL, "SYSCLK" }, 921 { "IN1BR", NULL, "SYSCLK" }, 922 { "IN2A", NULL, "SYSCLK" }, 923 { "IN2B", NULL, "SYSCLK" }, 924 925 { "ASRC1L", NULL, "SYSCLK" }, 926 { "ASRC1R", NULL, "SYSCLK" }, 927 { "ASRC2L", NULL, "SYSCLK" }, 928 { "ASRC2R", NULL, "SYSCLK" }, 929 930 { "ASRC1L", NULL, "ASYNCCLK" }, 931 { "ASRC1R", NULL, "ASYNCCLK" }, 932 { "ASRC2L", NULL, "ASYNCCLK" }, 933 { "ASRC2R", NULL, "ASYNCCLK" }, 934 935 { "SPD1", NULL, "SYSCLK" }, 936 { "SPD1", NULL, "SPD1TX1" }, 937 { "SPD1", NULL, "SPD1TX2" }, 938 939 { "MICBIAS1", NULL, "MICVDD" }, 940 { "MICBIAS2", NULL, "MICVDD" }, 941 { "MICBIAS3", NULL, "MICVDD" }, 942 943 { "Tone Generator 1", NULL, "SYSCLK" }, 944 { "Tone Generator 2", NULL, "SYSCLK" }, 945 946 { "Tone Generator 1", NULL, "TONE" }, 947 { "Tone Generator 2", NULL, "TONE" }, 948 949 { "AIF1 Capture", NULL, "AIF1TX1" }, 950 { "AIF1 Capture", NULL, "AIF1TX2" }, 951 { "AIF1 Capture", NULL, "AIF1TX3" }, 952 { "AIF1 Capture", NULL, "AIF1TX4" }, 953 { "AIF1 Capture", NULL, "AIF1TX5" }, 954 { "AIF1 Capture", NULL, "AIF1TX6" }, 955 956 { "AIF1RX1", NULL, "AIF1 Playback" }, 957 { "AIF1RX2", NULL, "AIF1 Playback" }, 958 { "AIF1RX3", NULL, "AIF1 Playback" }, 959 { "AIF1RX4", NULL, "AIF1 Playback" }, 960 { "AIF1RX5", NULL, "AIF1 Playback" }, 961 { "AIF1RX6", NULL, "AIF1 Playback" }, 962 963 { "AIF2 Capture", NULL, "AIF2TX1" }, 964 { "AIF2 Capture", NULL, "AIF2TX2" }, 965 { "AIF2 Capture", NULL, "AIF2TX3" }, 966 { "AIF2 Capture", NULL, "AIF2TX4" }, 967 { "AIF2 Capture", NULL, "AIF2TX5" }, 968 { "AIF2 Capture", NULL, "AIF2TX6" }, 969 970 { "AIF2RX1", NULL, "AIF2 Playback" }, 971 { "AIF2RX2", NULL, "AIF2 Playback" }, 972 { "AIF2RX3", NULL, "AIF2 Playback" }, 973 { "AIF2RX4", NULL, "AIF2 Playback" }, 974 { "AIF2RX5", NULL, "AIF2 Playback" }, 975 { "AIF2RX6", NULL, "AIF2 Playback" }, 976 977 { "AIF3 Capture", NULL, "AIF3TX1" }, 978 { "AIF3 Capture", NULL, "AIF3TX2" }, 979 980 { "AIF3RX1", NULL, "AIF3 Playback" }, 981 { "AIF3RX2", NULL, "AIF3 Playback" }, 982 983 { "Slim1 Capture", NULL, "SLIMTX1" }, 984 { "Slim1 Capture", NULL, "SLIMTX2" }, 985 { "Slim1 Capture", NULL, "SLIMTX3" }, 986 { "Slim1 Capture", NULL, "SLIMTX4" }, 987 988 { "Slim2 Capture", NULL, "SLIMTX5" }, 989 { "Slim2 Capture", NULL, "SLIMTX6" }, 990 991 { "SLIMRX1", NULL, "Slim1 Playback" }, 992 { "SLIMRX2", NULL, "Slim1 Playback" }, 993 994 { "SLIMRX3", NULL, "Slim2 Playback" }, 995 { "SLIMRX4", NULL, "Slim2 Playback" }, 996 997 { "AIF1 Playback", NULL, "SYSCLK" }, 998 { "AIF2 Playback", NULL, "SYSCLK" }, 999 { "AIF3 Playback", NULL, "SYSCLK" }, 1000 { "Slim1 Playback", NULL, "SYSCLK" }, 1001 { "Slim2 Playback", NULL, "SYSCLK" }, 1002 1003 { "AIF1 Capture", NULL, "SYSCLK" }, 1004 { "AIF2 Capture", NULL, "SYSCLK" }, 1005 { "AIF3 Capture", NULL, "SYSCLK" }, 1006 { "Slim1 Capture", NULL, "SYSCLK" }, 1007 { "Slim2 Capture", NULL, "SYSCLK" }, 1008 1009 { "IN1L Mux", "A", "IN1AL" }, 1010 { "IN1R Mux", "A", "IN1AR" }, 1011 { "IN1L Mux", "B", "IN1BL" }, 1012 { "IN1R Mux", "B", "IN1BR" }, 1013 1014 { "IN2 Mux", "A", "IN2A" }, 1015 { "IN2 Mux", "B", "IN2B" }, 1016 1017 { "IN1L PGA", NULL, "IN1L Mux" }, 1018 { "IN1R PGA", NULL, "IN1R Mux" }, 1019 { "IN2 PGA", NULL, "IN2 Mux" }, 1020 1021 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUTL"), 1022 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUTR"), 1023 ARIZONA_MIXER_ROUTES("OUT2L", "LINEOUTL"), 1024 ARIZONA_MIXER_ROUTES("OUT2R", "LINEOUTR"), 1025 ARIZONA_MIXER_ROUTES("OUT3", "EPOUT"), 1026 1027 ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUTL"), 1028 ARIZONA_MIXER_ROUTES("OUT4R", "SPKOUTR"), 1029 ARIZONA_MIXER_ROUTES("OUT5L", "SPKDATL"), 1030 ARIZONA_MIXER_ROUTES("OUT5R", "SPKDATR"), 1031 1032 ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"), 1033 ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"), 1034 1035 ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"), 1036 ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"), 1037 ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"), 1038 ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"), 1039 ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"), 1040 ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"), 1041 1042 ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"), 1043 ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"), 1044 ARIZONA_MIXER_ROUTES("AIF2TX3", "AIF2TX3"), 1045 ARIZONA_MIXER_ROUTES("AIF2TX4", "AIF2TX4"), 1046 ARIZONA_MIXER_ROUTES("AIF2TX5", "AIF2TX5"), 1047 ARIZONA_MIXER_ROUTES("AIF2TX6", "AIF2TX6"), 1048 1049 ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"), 1050 ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"), 1051 1052 ARIZONA_MUX_ROUTES("SLIMTX1", "SLIMTX1"), 1053 ARIZONA_MUX_ROUTES("SLIMTX2", "SLIMTX2"), 1054 ARIZONA_MUX_ROUTES("SLIMTX3", "SLIMTX3"), 1055 ARIZONA_MUX_ROUTES("SLIMTX4", "SLIMTX4"), 1056 ARIZONA_MUX_ROUTES("SLIMTX5", "SLIMTX5"), 1057 ARIZONA_MUX_ROUTES("SLIMTX6", "SLIMTX6"), 1058 1059 ARIZONA_MUX_ROUTES("SPD1TX1", "SPDIFTX1"), 1060 ARIZONA_MUX_ROUTES("SPD1TX2", "SPDIFTX2"), 1061 1062 ARIZONA_MUX_ROUTES("EQ1", "EQ1"), 1063 ARIZONA_MUX_ROUTES("EQ2", "EQ2"), 1064 ARIZONA_MUX_ROUTES("EQ3", "EQ3"), 1065 ARIZONA_MUX_ROUTES("EQ4", "EQ4"), 1066 1067 ARIZONA_MUX_ROUTES("DRC1L", "DRC1L"), 1068 ARIZONA_MUX_ROUTES("DRC1R", "DRC1R"), 1069 1070 ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"), 1071 ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"), 1072 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"), 1073 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"), 1074 1075 ARIZONA_MUX_ROUTES("ASRC1L", "ASRC1L"), 1076 ARIZONA_MUX_ROUTES("ASRC1R", "ASRC1R"), 1077 ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"), 1078 ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"), 1079 1080 ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"), 1081 ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"), 1082 ARIZONA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"), 1083 ARIZONA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"), 1084 1085 ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"), 1086 ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"), 1087 ARIZONA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"), 1088 ARIZONA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"), 1089 1090 ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"), 1091 ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"), 1092 1093 ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"), 1094 ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"), 1095 1096 { "AEC1 Loopback", "HPOUTL", "OUT1L" }, 1097 { "AEC1 Loopback", "HPOUTR", "OUT1R" }, 1098 { "AEC2 Loopback", "HPOUTL", "OUT1L" }, 1099 { "AEC2 Loopback", "HPOUTR", "OUT1R" }, 1100 { "HPOUTL", NULL, "OUT1L" }, 1101 { "HPOUTR", NULL, "OUT1R" }, 1102 1103 { "AEC1 Loopback", "LINEOUTL", "OUT2L" }, 1104 { "AEC1 Loopback", "LINEOUTR", "OUT2R" }, 1105 { "AEC2 Loopback", "LINEOUTL", "OUT2L" }, 1106 { "AEC2 Loopback", "LINEOUTR", "OUT2R" }, 1107 { "LINEOUTL", NULL, "OUT2L" }, 1108 { "LINEOUTR", NULL, "OUT2R" }, 1109 1110 { "AEC1 Loopback", "EPOUT", "OUT3" }, 1111 { "AEC2 Loopback", "EPOUT", "OUT3" }, 1112 { "EPOUT", NULL, "OUT3" }, 1113 1114 { "AEC1 Loopback", "SPKOUTL", "OUT4L" }, 1115 { "AEC2 Loopback", "SPKOUTL", "OUT4L" }, 1116 { "SPKOUTLN", NULL, "OUT4L" }, 1117 { "SPKOUTLP", NULL, "OUT4L" }, 1118 1119 { "AEC1 Loopback", "SPKOUTR", "OUT4R" }, 1120 { "AEC2 Loopback", "SPKOUTR", "OUT4R" }, 1121 { "SPKOUTRN", NULL, "OUT4R" }, 1122 { "SPKOUTRP", NULL, "OUT4R" }, 1123 1124 { "SPDIF", NULL, "SPD1" }, 1125 1126 { "AEC1 Loopback", "SPKDATL", "OUT5L" }, 1127 { "AEC1 Loopback", "SPKDATR", "OUT5R" }, 1128 { "AEC2 Loopback", "SPKDATL", "OUT5L" }, 1129 { "AEC2 Loopback", "SPKDATR", "OUT5R" }, 1130 { "SPKDATL", NULL, "OUT5L" }, 1131 { "SPKDATR", NULL, "OUT5R" }, 1132 1133 { "MICSUPP", NULL, "SYSCLK" }, 1134 1135 { "DRC1 Signal Activity", NULL, "SYSCLK" }, 1136 { "DRC1 Signal Activity", NULL, "DRC1L" }, 1137 { "DRC1 Signal Activity", NULL, "DRC1R" }, 1138 }; 1139 1140 #define WM8998_RATES SNDRV_PCM_RATE_KNOT 1141 1142 #define WM8998_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 1143 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 1144 1145 static struct snd_soc_dai_driver wm8998_dai[] = { 1146 { 1147 .name = "wm8998-aif1", 1148 .id = 1, 1149 .base = ARIZONA_AIF1_BCLK_CTRL, 1150 .playback = { 1151 .stream_name = "AIF1 Playback", 1152 .channels_min = 1, 1153 .channels_max = 6, 1154 .rates = WM8998_RATES, 1155 .formats = WM8998_FORMATS, 1156 }, 1157 .capture = { 1158 .stream_name = "AIF1 Capture", 1159 .channels_min = 1, 1160 .channels_max = 6, 1161 .rates = WM8998_RATES, 1162 .formats = WM8998_FORMATS, 1163 }, 1164 .ops = &arizona_dai_ops, 1165 .symmetric_rates = 1, 1166 .symmetric_samplebits = 1, 1167 }, 1168 { 1169 .name = "wm8998-aif2", 1170 .id = 2, 1171 .base = ARIZONA_AIF2_BCLK_CTRL, 1172 .playback = { 1173 .stream_name = "AIF2 Playback", 1174 .channels_min = 1, 1175 .channels_max = 6, 1176 .rates = WM8998_RATES, 1177 .formats = WM8998_FORMATS, 1178 }, 1179 .capture = { 1180 .stream_name = "AIF2 Capture", 1181 .channels_min = 1, 1182 .channels_max = 6, 1183 .rates = WM8998_RATES, 1184 .formats = WM8998_FORMATS, 1185 }, 1186 .ops = &arizona_dai_ops, 1187 .symmetric_rates = 1, 1188 .symmetric_samplebits = 1, 1189 }, 1190 { 1191 .name = "wm8998-aif3", 1192 .id = 3, 1193 .base = ARIZONA_AIF3_BCLK_CTRL, 1194 .playback = { 1195 .stream_name = "AIF3 Playback", 1196 .channels_min = 1, 1197 .channels_max = 2, 1198 .rates = WM8998_RATES, 1199 .formats = WM8998_FORMATS, 1200 }, 1201 .capture = { 1202 .stream_name = "AIF3 Capture", 1203 .channels_min = 1, 1204 .channels_max = 2, 1205 .rates = WM8998_RATES, 1206 .formats = WM8998_FORMATS, 1207 }, 1208 .ops = &arizona_dai_ops, 1209 .symmetric_rates = 1, 1210 .symmetric_samplebits = 1, 1211 }, 1212 { 1213 .name = "wm8998-slim1", 1214 .id = 4, 1215 .playback = { 1216 .stream_name = "Slim1 Playback", 1217 .channels_min = 1, 1218 .channels_max = 2, 1219 .rates = WM8998_RATES, 1220 .formats = WM8998_FORMATS, 1221 }, 1222 .capture = { 1223 .stream_name = "Slim1 Capture", 1224 .channels_min = 1, 1225 .channels_max = 4, 1226 .rates = WM8998_RATES, 1227 .formats = WM8998_FORMATS, 1228 }, 1229 .ops = &arizona_simple_dai_ops, 1230 }, 1231 { 1232 .name = "wm8998-slim2", 1233 .id = 5, 1234 .playback = { 1235 .stream_name = "Slim2 Playback", 1236 .channels_min = 1, 1237 .channels_max = 2, 1238 .rates = WM8998_RATES, 1239 .formats = WM8998_FORMATS, 1240 }, 1241 .capture = { 1242 .stream_name = "Slim2 Capture", 1243 .channels_min = 1, 1244 .channels_max = 2, 1245 .rates = WM8998_RATES, 1246 .formats = WM8998_FORMATS, 1247 }, 1248 .ops = &arizona_simple_dai_ops, 1249 }, 1250 }; 1251 1252 static int wm8998_set_fll(struct snd_soc_codec *codec, int fll_id, int source, 1253 unsigned int Fref, unsigned int Fout) 1254 { 1255 struct wm8998_priv *wm8998 = snd_soc_codec_get_drvdata(codec); 1256 1257 switch (fll_id) { 1258 case WM8998_FLL1: 1259 return arizona_set_fll(&wm8998->fll[0], source, Fref, Fout); 1260 case WM8998_FLL2: 1261 return arizona_set_fll(&wm8998->fll[1], source, Fref, Fout); 1262 case WM8998_FLL1_REFCLK: 1263 return arizona_set_fll_refclk(&wm8998->fll[0], source, Fref, 1264 Fout); 1265 case WM8998_FLL2_REFCLK: 1266 return arizona_set_fll_refclk(&wm8998->fll[1], source, Fref, 1267 Fout); 1268 default: 1269 return -EINVAL; 1270 } 1271 } 1272 1273 static int wm8998_codec_probe(struct snd_soc_codec *codec) 1274 { 1275 struct wm8998_priv *priv = snd_soc_codec_get_drvdata(codec); 1276 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); 1277 struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); 1278 struct arizona *arizona = priv->core.arizona; 1279 int ret; 1280 1281 arizona->dapm = dapm; 1282 snd_soc_codec_init_regmap(codec, arizona->regmap); 1283 1284 ret = arizona_init_spk(codec); 1285 if (ret < 0) 1286 return ret; 1287 1288 arizona_init_gpio(codec); 1289 1290 snd_soc_component_disable_pin(component, "HAPTICS"); 1291 1292 return 0; 1293 } 1294 1295 static int wm8998_codec_remove(struct snd_soc_codec *codec) 1296 { 1297 struct wm8998_priv *priv = snd_soc_codec_get_drvdata(codec); 1298 1299 priv->core.arizona->dapm = NULL; 1300 1301 return 0; 1302 } 1303 1304 #define WM8998_DIG_VU 0x0200 1305 1306 static unsigned int wm8998_digital_vu[] = { 1307 ARIZONA_DAC_DIGITAL_VOLUME_1L, 1308 ARIZONA_DAC_DIGITAL_VOLUME_1R, 1309 ARIZONA_DAC_DIGITAL_VOLUME_2L, 1310 ARIZONA_DAC_DIGITAL_VOLUME_2R, 1311 ARIZONA_DAC_DIGITAL_VOLUME_3L, 1312 ARIZONA_DAC_DIGITAL_VOLUME_4L, 1313 ARIZONA_DAC_DIGITAL_VOLUME_4R, 1314 ARIZONA_DAC_DIGITAL_VOLUME_5L, 1315 ARIZONA_DAC_DIGITAL_VOLUME_5R, 1316 }; 1317 1318 static const struct snd_soc_codec_driver soc_codec_dev_wm8998 = { 1319 .probe = wm8998_codec_probe, 1320 .remove = wm8998_codec_remove, 1321 1322 .idle_bias_off = true, 1323 1324 .set_sysclk = arizona_set_sysclk, 1325 .set_pll = wm8998_set_fll, 1326 1327 .component_driver = { 1328 .controls = wm8998_snd_controls, 1329 .num_controls = ARRAY_SIZE(wm8998_snd_controls), 1330 .dapm_widgets = wm8998_dapm_widgets, 1331 .num_dapm_widgets = ARRAY_SIZE(wm8998_dapm_widgets), 1332 .dapm_routes = wm8998_dapm_routes, 1333 .num_dapm_routes = ARRAY_SIZE(wm8998_dapm_routes), 1334 }, 1335 }; 1336 1337 static int wm8998_probe(struct platform_device *pdev) 1338 { 1339 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 1340 struct wm8998_priv *wm8998; 1341 int i, ret; 1342 1343 wm8998 = devm_kzalloc(&pdev->dev, sizeof(struct wm8998_priv), 1344 GFP_KERNEL); 1345 if (!wm8998) 1346 return -ENOMEM; 1347 platform_set_drvdata(pdev, wm8998); 1348 1349 if (IS_ENABLED(CONFIG_OF)) { 1350 if (!dev_get_platdata(arizona->dev)) { 1351 ret = arizona_of_get_audio_pdata(arizona); 1352 if (ret < 0) 1353 return ret; 1354 } 1355 } 1356 1357 wm8998->core.arizona = arizona; 1358 wm8998->core.num_inputs = 3; /* IN1L, IN1R, IN2 */ 1359 1360 for (i = 0; i < ARRAY_SIZE(wm8998->fll); i++) 1361 wm8998->fll[i].vco_mult = 1; 1362 1363 arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1, 1364 ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK, 1365 &wm8998->fll[0]); 1366 arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1, 1367 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK, 1368 &wm8998->fll[1]); 1369 1370 for (i = 0; i < ARRAY_SIZE(wm8998_dai); i++) 1371 arizona_init_dai(&wm8998->core, i); 1372 1373 /* Latch volume update bits */ 1374 for (i = 0; i < ARRAY_SIZE(wm8998_digital_vu); i++) 1375 regmap_update_bits(arizona->regmap, wm8998_digital_vu[i], 1376 WM8998_DIG_VU, WM8998_DIG_VU); 1377 1378 pm_runtime_enable(&pdev->dev); 1379 pm_runtime_idle(&pdev->dev); 1380 1381 arizona_init_common(arizona); 1382 1383 ret = arizona_init_spk_irqs(arizona); 1384 if (ret < 0) 1385 return ret; 1386 1387 ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8998, 1388 wm8998_dai, ARRAY_SIZE(wm8998_dai)); 1389 if (ret < 0) { 1390 dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); 1391 goto err_spk_irqs; 1392 } 1393 1394 return ret; 1395 1396 err_spk_irqs: 1397 arizona_free_spk_irqs(arizona); 1398 1399 return ret; 1400 } 1401 1402 static int wm8998_remove(struct platform_device *pdev) 1403 { 1404 struct wm8998_priv *wm8998 = platform_get_drvdata(pdev); 1405 struct arizona *arizona = wm8998->core.arizona; 1406 1407 snd_soc_unregister_codec(&pdev->dev); 1408 pm_runtime_disable(&pdev->dev); 1409 1410 arizona_free_spk_irqs(arizona); 1411 1412 return 0; 1413 } 1414 1415 static struct platform_driver wm8998_codec_driver = { 1416 .driver = { 1417 .name = "wm8998-codec", 1418 }, 1419 .probe = wm8998_probe, 1420 .remove = wm8998_remove, 1421 }; 1422 1423 module_platform_driver(wm8998_codec_driver); 1424 1425 MODULE_DESCRIPTION("ASoC WM8998 driver"); 1426 MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.wolfsonmicro.com>"); 1427 MODULE_LICENSE("GPL v2"); 1428 MODULE_ALIAS("platform:wm8998-codec"); 1429