Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * wm5102.c -- WM5102 ALSA SoC Audio driver |
| 3 | * |
| 4 | * Copyright 2012 Wolfson Microelectronics plc |
| 5 | * |
| 6 | * Author: Mark Brown <broonie@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> |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 28 | |
| 29 | #include <linux/mfd/arizona/core.h> |
| 30 | #include <linux/mfd/arizona/registers.h> |
| 31 | |
| 32 | #include "arizona.h" |
| 33 | #include "wm5102.h" |
| 34 | |
| 35 | struct wm5102_priv { |
| 36 | struct arizona_priv core; |
| 37 | struct arizona_fll fll[2]; |
| 38 | }; |
| 39 | |
| 40 | static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0); |
| 41 | static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); |
| 42 | static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); |
| 43 | static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0); |
| 44 | |
| 45 | static const struct snd_kcontrol_new wm5102_snd_controls[] = { |
| 46 | SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL, |
| 47 | ARIZONA_IN1_OSR_SHIFT, 1, 0), |
| 48 | SOC_SINGLE("IN2 High Performance Switch", ARIZONA_IN2L_CONTROL, |
| 49 | ARIZONA_IN2_OSR_SHIFT, 1, 0), |
| 50 | SOC_SINGLE("IN3 High Performance Switch", ARIZONA_IN3L_CONTROL, |
| 51 | ARIZONA_IN3_OSR_SHIFT, 1, 0), |
| 52 | |
| 53 | SOC_DOUBLE_R_RANGE_TLV("IN1 Volume", ARIZONA_IN1L_CONTROL, |
| 54 | ARIZONA_IN1R_CONTROL, |
| 55 | ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), |
| 56 | SOC_DOUBLE_R_RANGE_TLV("IN2 Volume", ARIZONA_IN2L_CONTROL, |
| 57 | ARIZONA_IN2R_CONTROL, |
| 58 | ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), |
| 59 | SOC_DOUBLE_R_RANGE_TLV("IN3 Volume", ARIZONA_IN3L_CONTROL, |
| 60 | ARIZONA_IN3R_CONTROL, |
| 61 | ARIZONA_IN3L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), |
| 62 | |
| 63 | SOC_DOUBLE_R("IN1 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_1L, |
| 64 | ARIZONA_ADC_DIGITAL_VOLUME_1R, ARIZONA_IN1L_MUTE_SHIFT, 1, 1), |
| 65 | SOC_DOUBLE_R("IN2 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_2L, |
| 66 | ARIZONA_ADC_DIGITAL_VOLUME_2R, ARIZONA_IN2L_MUTE_SHIFT, 1, 1), |
| 67 | SOC_DOUBLE_R("IN3 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_3L, |
| 68 | ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_MUTE_SHIFT, 1, 1), |
| 69 | |
| 70 | SOC_DOUBLE_R_TLV("IN1 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L, |
Mark Brown | bc9dce5 | 2012-07-09 19:08:23 +0100 | [diff] [blame] | 71 | ARIZONA_ADC_DIGITAL_VOLUME_1R, ARIZONA_IN1L_DIG_VOL_SHIFT, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 72 | 0xbf, 0, digital_tlv), |
| 73 | SOC_DOUBLE_R_TLV("IN2 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L, |
Mark Brown | bc9dce5 | 2012-07-09 19:08:23 +0100 | [diff] [blame] | 74 | ARIZONA_ADC_DIGITAL_VOLUME_2R, ARIZONA_IN2L_DIG_VOL_SHIFT, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 75 | 0xbf, 0, digital_tlv), |
| 76 | SOC_DOUBLE_R_TLV("IN3 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_3L, |
Mark Brown | bc9dce5 | 2012-07-09 19:08:23 +0100 | [diff] [blame] | 77 | ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_DIG_VOL_SHIFT, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 78 | 0xbf, 0, digital_tlv), |
| 79 | |
| 80 | ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE), |
| 81 | ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), |
| 82 | ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), |
| 83 | ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), |
| 84 | |
| 85 | SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, |
| 86 | 24, 0, eq_tlv), |
| 87 | SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, |
| 88 | 24, 0, eq_tlv), |
| 89 | SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT, |
| 90 | 24, 0, eq_tlv), |
| 91 | SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT, |
| 92 | 24, 0, eq_tlv), |
| 93 | SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT, |
| 94 | 24, 0, eq_tlv), |
| 95 | |
| 96 | SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT, |
| 97 | 24, 0, eq_tlv), |
| 98 | SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT, |
| 99 | 24, 0, eq_tlv), |
| 100 | SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT, |
| 101 | 24, 0, eq_tlv), |
| 102 | SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT, |
| 103 | 24, 0, eq_tlv), |
| 104 | SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT, |
| 105 | 24, 0, eq_tlv), |
| 106 | |
| 107 | SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT, |
| 108 | 24, 0, eq_tlv), |
| 109 | SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT, |
| 110 | 24, 0, eq_tlv), |
| 111 | SOC_SINGLE_TLV("EQ3 B3 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B3_GAIN_SHIFT, |
| 112 | 24, 0, eq_tlv), |
| 113 | SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT, |
| 114 | 24, 0, eq_tlv), |
| 115 | SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT, |
| 116 | 24, 0, eq_tlv), |
| 117 | |
| 118 | SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT, |
| 119 | 24, 0, eq_tlv), |
| 120 | SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT, |
| 121 | 24, 0, eq_tlv), |
| 122 | SOC_SINGLE_TLV("EQ4 B3 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B3_GAIN_SHIFT, |
| 123 | 24, 0, eq_tlv), |
| 124 | SOC_SINGLE_TLV("EQ4 B4 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B4_GAIN_SHIFT, |
| 125 | 24, 0, eq_tlv), |
| 126 | SOC_SINGLE_TLV("EQ4 B5 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B5_GAIN_SHIFT, |
| 127 | 24, 0, eq_tlv), |
| 128 | |
| 129 | ARIZONA_MIXER_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE), |
| 130 | ARIZONA_MIXER_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE), |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 131 | |
| 132 | SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5, |
| 133 | ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA), |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 134 | |
| 135 | ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE), |
| 136 | ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE), |
| 137 | ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), |
| 138 | ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), |
| 139 | |
| 140 | SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode), |
| 141 | SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), |
| 142 | SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), |
| 143 | SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), |
| 144 | |
| 145 | ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE), |
| 146 | ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE), |
| 147 | |
| 148 | SOC_SINGLE_TLV("Noise Generator Volume", ARIZONA_COMFORT_NOISE_GENERATOR, |
| 149 | ARIZONA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, noise_tlv), |
| 150 | |
| 151 | ARIZONA_MIXER_CONTROLS("HPOUT1L", ARIZONA_OUT1LMIX_INPUT_1_SOURCE), |
| 152 | ARIZONA_MIXER_CONTROLS("HPOUT1R", ARIZONA_OUT1RMIX_INPUT_1_SOURCE), |
| 153 | ARIZONA_MIXER_CONTROLS("HPOUT2L", ARIZONA_OUT2LMIX_INPUT_1_SOURCE), |
| 154 | ARIZONA_MIXER_CONTROLS("HPOUT2R", ARIZONA_OUT2RMIX_INPUT_1_SOURCE), |
| 155 | ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE), |
| 156 | ARIZONA_MIXER_CONTROLS("SPKOUTL", ARIZONA_OUT4LMIX_INPUT_1_SOURCE), |
| 157 | ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE), |
| 158 | ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE), |
| 159 | ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE), |
| 160 | |
| 161 | SOC_SINGLE("HPOUT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_1L, |
| 162 | ARIZONA_OUT1_OSR_SHIFT, 1, 0), |
| 163 | SOC_SINGLE("OUT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_2L, |
| 164 | ARIZONA_OUT2_OSR_SHIFT, 1, 0), |
| 165 | SOC_SINGLE("EPOUT High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_3L, |
| 166 | ARIZONA_OUT3_OSR_SHIFT, 1, 0), |
| 167 | SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L, |
| 168 | ARIZONA_OUT4_OSR_SHIFT, 1, 0), |
| 169 | SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L, |
| 170 | ARIZONA_OUT5_OSR_SHIFT, 1, 0), |
| 171 | |
| 172 | SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L, |
| 173 | ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1), |
| 174 | SOC_DOUBLE_R("OUT2 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L, |
| 175 | ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_MUTE_SHIFT, 1, 1), |
| 176 | SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L, |
| 177 | ARIZONA_OUT3L_MUTE_SHIFT, 1, 1), |
| 178 | SOC_DOUBLE_R("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L, |
| 179 | ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_MUTE_SHIFT, 1, 1), |
| 180 | SOC_DOUBLE_R("SPKDAT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L, |
| 181 | ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1), |
| 182 | |
| 183 | SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L, |
| 184 | ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT, |
| 185 | 0xbf, 0, digital_tlv), |
| 186 | SOC_DOUBLE_R_TLV("OUT2 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_2L, |
| 187 | ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_VOL_SHIFT, |
| 188 | 0xbf, 0, digital_tlv), |
| 189 | SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L, |
| 190 | ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv), |
| 191 | SOC_DOUBLE_R_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L, |
| 192 | ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_VOL_SHIFT, |
| 193 | 0xbf, 0, digital_tlv), |
| 194 | SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L, |
| 195 | ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT, |
| 196 | 0xbf, 0, digital_tlv), |
| 197 | |
| 198 | SOC_DOUBLE_R_RANGE_TLV("HPOUT1 Volume", ARIZONA_OUTPUT_PATH_CONFIG_1L, |
| 199 | ARIZONA_OUTPUT_PATH_CONFIG_1R, |
| 200 | ARIZONA_OUT1L_PGA_VOL_SHIFT, |
| 201 | 0x34, 0x40, 0, ana_tlv), |
| 202 | SOC_DOUBLE_R_RANGE_TLV("OUT2 Volume", ARIZONA_OUTPUT_PATH_CONFIG_2L, |
| 203 | ARIZONA_OUTPUT_PATH_CONFIG_2R, |
| 204 | ARIZONA_OUT2L_PGA_VOL_SHIFT, |
| 205 | 0x34, 0x40, 0, ana_tlv), |
| 206 | SOC_SINGLE_RANGE_TLV("EPOUT Volume", ARIZONA_OUTPUT_PATH_CONFIG_3L, |
| 207 | ARIZONA_OUT3L_PGA_VOL_SHIFT, 0x34, 0x40, 0, ana_tlv), |
| 208 | |
| 209 | SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT, |
| 210 | ARIZONA_SPK1R_MUTE_SHIFT, 1, 1), |
| 211 | |
| 212 | ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE), |
| 213 | ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE), |
| 214 | ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE), |
| 215 | ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE), |
| 216 | ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE), |
| 217 | ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE), |
| 218 | ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE), |
| 219 | ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE), |
| 220 | |
| 221 | ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE), |
| 222 | ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE), |
| 223 | |
| 224 | ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE), |
| 225 | ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE), |
| 226 | }; |
| 227 | |
| 228 | ARIZONA_MIXER_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE); |
| 229 | ARIZONA_MIXER_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE); |
| 230 | ARIZONA_MIXER_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE); |
| 231 | ARIZONA_MIXER_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE); |
| 232 | |
| 233 | ARIZONA_MIXER_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE); |
| 234 | ARIZONA_MIXER_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE); |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 235 | |
| 236 | ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE); |
| 237 | ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE); |
| 238 | ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE); |
| 239 | ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE); |
| 240 | |
| 241 | ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE); |
| 242 | ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE); |
| 243 | |
| 244 | ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE); |
| 245 | ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE); |
| 246 | |
| 247 | ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE); |
| 248 | ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE); |
| 249 | ARIZONA_MIXER_ENUMS(OUT2L, ARIZONA_OUT2LMIX_INPUT_1_SOURCE); |
| 250 | ARIZONA_MIXER_ENUMS(OUT2R, ARIZONA_OUT2RMIX_INPUT_1_SOURCE); |
| 251 | ARIZONA_MIXER_ENUMS(OUT3, ARIZONA_OUT3LMIX_INPUT_1_SOURCE); |
| 252 | ARIZONA_MIXER_ENUMS(SPKOUTL, ARIZONA_OUT4LMIX_INPUT_1_SOURCE); |
| 253 | ARIZONA_MIXER_ENUMS(SPKOUTR, ARIZONA_OUT4RMIX_INPUT_1_SOURCE); |
| 254 | ARIZONA_MIXER_ENUMS(SPKDAT1L, ARIZONA_OUT5LMIX_INPUT_1_SOURCE); |
| 255 | ARIZONA_MIXER_ENUMS(SPKDAT1R, ARIZONA_OUT5RMIX_INPUT_1_SOURCE); |
| 256 | |
| 257 | ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE); |
| 258 | ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE); |
| 259 | ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE); |
| 260 | ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE); |
| 261 | ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE); |
| 262 | ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE); |
| 263 | ARIZONA_MIXER_ENUMS(AIF1TX7, ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE); |
| 264 | ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE); |
| 265 | |
| 266 | ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE); |
| 267 | ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE); |
| 268 | |
| 269 | ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); |
| 270 | ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); |
| 271 | |
Mark Brown | 9498822 | 2012-07-04 20:07:03 +0100 | [diff] [blame] | 272 | ARIZONA_MIXER_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE); |
| 273 | ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); |
| 274 | ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); |
| 275 | ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); |
| 276 | |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 277 | |
| 278 | static const char *wm5102_aec_loopback_texts[] = { |
| 279 | "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT", |
| 280 | "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R", |
| 281 | }; |
| 282 | |
| 283 | static const unsigned int wm5102_aec_loopback_values[] = { |
| 284 | 0, 1, 2, 3, 4, 6, 7, 8, 9, |
| 285 | }; |
| 286 | |
| 287 | static const struct soc_enum wm5102_aec_loopback = |
| 288 | SOC_VALUE_ENUM_SINGLE(ARIZONA_DAC_AEC_CONTROL_1, |
| 289 | ARIZONA_AEC_LOOPBACK_SRC_SHIFT, |
| 290 | ARIZONA_AEC_LOOPBACK_SRC_MASK, |
| 291 | ARRAY_SIZE(wm5102_aec_loopback_texts), |
| 292 | wm5102_aec_loopback_texts, |
| 293 | wm5102_aec_loopback_values); |
| 294 | |
| 295 | static const struct snd_kcontrol_new wm5102_aec_loopback_mux = |
| 296 | SOC_DAPM_VALUE_ENUM("AEC Loopback", wm5102_aec_loopback); |
| 297 | |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 298 | static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = { |
| 299 | SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, |
| 300 | 0, NULL, 0), |
| 301 | SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, |
| 302 | ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), |
Mark Brown | c665d1a | 2012-08-08 17:53:01 +0100 | [diff] [blame] | 303 | SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK, |
| 304 | ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0), |
| 305 | SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK, |
| 306 | ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0), |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 307 | |
Mark Brown | 822b4b8 | 2012-09-07 10:54:32 +0800 | [diff] [blame] | 308 | SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0), |
| 309 | SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0), |
| 310 | SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0), |
Mark Brown | bb09d97 | 2012-09-07 12:58:43 +0800 | [diff] [blame] | 311 | SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS), |
Mark Brown | 822b4b8 | 2012-09-07 10:54:32 +0800 | [diff] [blame] | 312 | SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0, 0), |
| 313 | SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0), |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 314 | |
| 315 | SND_SOC_DAPM_SIGGEN("TONE"), |
| 316 | SND_SOC_DAPM_SIGGEN("NOISE"), |
| 317 | |
| 318 | SND_SOC_DAPM_INPUT("IN1L"), |
| 319 | SND_SOC_DAPM_INPUT("IN1R"), |
| 320 | SND_SOC_DAPM_INPUT("IN2L"), |
| 321 | SND_SOC_DAPM_INPUT("IN2R"), |
| 322 | SND_SOC_DAPM_INPUT("IN3L"), |
| 323 | SND_SOC_DAPM_INPUT("IN3R"), |
| 324 | |
| 325 | SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT, |
| 326 | 0, NULL, 0, arizona_in_ev, |
| 327 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 328 | SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT, |
| 329 | 0, NULL, 0, arizona_in_ev, |
| 330 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 331 | SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT, |
| 332 | 0, NULL, 0, arizona_in_ev, |
| 333 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 334 | SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT, |
| 335 | 0, NULL, 0, arizona_in_ev, |
| 336 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 337 | SND_SOC_DAPM_PGA_E("IN3L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3L_ENA_SHIFT, |
| 338 | 0, NULL, 0, arizona_in_ev, |
| 339 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 340 | SND_SOC_DAPM_PGA_E("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT, |
| 341 | 0, NULL, 0, arizona_in_ev, |
| 342 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 343 | |
| 344 | SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1, |
| 345 | ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), |
| 346 | SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2, |
| 347 | ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), |
| 348 | SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3, |
| 349 | ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), |
| 350 | |
| 351 | SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR, |
| 352 | ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0), |
| 353 | |
| 354 | SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1, |
| 355 | ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0), |
| 356 | SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1, |
| 357 | ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0), |
| 358 | |
| 359 | SND_SOC_DAPM_PGA("Mic Mute Mixer", ARIZONA_MIC_NOISE_MIX_CONTROL_1, |
| 360 | ARIZONA_MICMUTE_MIX_ENA_SHIFT, 0, NULL, 0), |
| 361 | |
| 362 | SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0), |
| 363 | SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0), |
| 364 | SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0), |
| 365 | SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0), |
| 366 | |
| 367 | SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0, |
| 368 | NULL, 0), |
| 369 | SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0, |
| 370 | NULL, 0), |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 371 | |
| 372 | SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0, |
| 373 | NULL, 0), |
| 374 | SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0, |
| 375 | NULL, 0), |
| 376 | SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0, |
| 377 | NULL, 0), |
| 378 | SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0, |
| 379 | NULL, 0), |
| 380 | |
| 381 | SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT, |
| 382 | 0, NULL, 0), |
| 383 | SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT, |
| 384 | 0, NULL, 0), |
| 385 | |
Mark Brown | 9498822 | 2012-07-04 20:07:03 +0100 | [diff] [blame] | 386 | SND_SOC_DAPM_PGA("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0, |
| 387 | NULL, 0), |
| 388 | SND_SOC_DAPM_PGA("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0, |
| 389 | NULL, 0), |
| 390 | SND_SOC_DAPM_PGA("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0, |
| 391 | NULL, 0), |
| 392 | SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0, |
| 393 | NULL, 0), |
| 394 | |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 395 | SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0, |
| 396 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0), |
| 397 | SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0, |
| 398 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0), |
| 399 | SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0, |
| 400 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0), |
| 401 | SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0, |
| 402 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0), |
| 403 | SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0, |
| 404 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0), |
| 405 | SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0, |
| 406 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0), |
| 407 | SND_SOC_DAPM_AIF_OUT("AIF1TX7", NULL, 0, |
| 408 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX7_ENA_SHIFT, 0), |
| 409 | SND_SOC_DAPM_AIF_OUT("AIF1TX8", NULL, 0, |
| 410 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX8_ENA_SHIFT, 0), |
| 411 | |
| 412 | SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0, |
| 413 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0), |
| 414 | SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0, |
| 415 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0), |
| 416 | SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0, |
| 417 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0), |
| 418 | SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0, |
| 419 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0), |
| 420 | SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0, |
| 421 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0), |
| 422 | SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0, |
| 423 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0), |
| 424 | SND_SOC_DAPM_AIF_IN("AIF1RX7", NULL, 0, |
| 425 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX7_ENA_SHIFT, 0), |
| 426 | SND_SOC_DAPM_AIF_IN("AIF1RX8", NULL, 0, |
| 427 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX8_ENA_SHIFT, 0), |
| 428 | |
| 429 | SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0, |
| 430 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0), |
| 431 | SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0, |
| 432 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0), |
| 433 | |
| 434 | SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0, |
| 435 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0), |
| 436 | SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0, |
| 437 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0), |
| 438 | |
| 439 | SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0, |
| 440 | ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0), |
| 441 | SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0, |
| 442 | ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0), |
| 443 | |
| 444 | SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0, |
| 445 | ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0), |
| 446 | SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, |
| 447 | ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0), |
| 448 | |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 449 | SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, |
| 450 | ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux), |
| 451 | |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 452 | SND_SOC_DAPM_PGA_E("OUT1L", ARIZONA_OUTPUT_ENABLES_1, |
| 453 | ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 454 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 455 | SND_SOC_DAPM_PGA_E("OUT1R", ARIZONA_OUTPUT_ENABLES_1, |
| 456 | ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 457 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 458 | SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, |
| 459 | ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 460 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 461 | SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, |
| 462 | ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 463 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 464 | SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, |
| 465 | ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 466 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 467 | SND_SOC_DAPM_PGA_E("OUT4L", ARIZONA_OUTPUT_ENABLES_1, |
| 468 | ARIZONA_OUT4L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 469 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 470 | SND_SOC_DAPM_PGA_E("OUT4R", ARIZONA_OUTPUT_ENABLES_1, |
| 471 | ARIZONA_OUT4R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 472 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 473 | SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, |
| 474 | ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 475 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 476 | SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1, |
| 477 | ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
| 478 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
| 479 | |
| 480 | ARIZONA_MIXER_WIDGETS(EQ1, "EQ1"), |
| 481 | ARIZONA_MIXER_WIDGETS(EQ2, "EQ2"), |
| 482 | ARIZONA_MIXER_WIDGETS(EQ3, "EQ3"), |
| 483 | ARIZONA_MIXER_WIDGETS(EQ4, "EQ4"), |
| 484 | |
| 485 | ARIZONA_MIXER_WIDGETS(DRC1L, "DRC1L"), |
| 486 | ARIZONA_MIXER_WIDGETS(DRC1R, "DRC1R"), |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 487 | |
| 488 | ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"), |
| 489 | ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"), |
| 490 | ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"), |
| 491 | ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"), |
| 492 | |
| 493 | ARIZONA_MIXER_WIDGETS(Mic, "Mic"), |
| 494 | ARIZONA_MIXER_WIDGETS(Noise, "Noise"), |
| 495 | |
| 496 | ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"), |
| 497 | ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"), |
| 498 | |
| 499 | ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUT1L"), |
| 500 | ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUT1R"), |
| 501 | ARIZONA_MIXER_WIDGETS(OUT2L, "HPOUT2L"), |
| 502 | ARIZONA_MIXER_WIDGETS(OUT2R, "HPOUT2R"), |
| 503 | ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"), |
| 504 | ARIZONA_MIXER_WIDGETS(SPKOUTL, "SPKOUTL"), |
| 505 | ARIZONA_MIXER_WIDGETS(SPKOUTR, "SPKOUTR"), |
| 506 | ARIZONA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"), |
| 507 | ARIZONA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"), |
| 508 | |
| 509 | ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"), |
| 510 | ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"), |
| 511 | ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"), |
| 512 | ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"), |
| 513 | ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"), |
| 514 | ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"), |
| 515 | ARIZONA_MIXER_WIDGETS(AIF1TX7, "AIF1TX7"), |
| 516 | ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"), |
| 517 | |
| 518 | ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"), |
| 519 | ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"), |
| 520 | |
| 521 | ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), |
| 522 | ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), |
| 523 | |
Mark Brown | 9498822 | 2012-07-04 20:07:03 +0100 | [diff] [blame] | 524 | ARIZONA_MIXER_WIDGETS(ASRC1L, "ASRC1L"), |
| 525 | ARIZONA_MIXER_WIDGETS(ASRC1R, "ASRC1R"), |
| 526 | ARIZONA_MIXER_WIDGETS(ASRC2L, "ASRC2L"), |
| 527 | ARIZONA_MIXER_WIDGETS(ASRC2R, "ASRC2R"), |
| 528 | |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 529 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), |
| 530 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), |
| 531 | SND_SOC_DAPM_OUTPUT("HPOUT2L"), |
| 532 | SND_SOC_DAPM_OUTPUT("HPOUT2R"), |
| 533 | SND_SOC_DAPM_OUTPUT("EPOUTN"), |
| 534 | SND_SOC_DAPM_OUTPUT("EPOUTP"), |
| 535 | SND_SOC_DAPM_OUTPUT("SPKOUTLN"), |
| 536 | SND_SOC_DAPM_OUTPUT("SPKOUTLP"), |
| 537 | SND_SOC_DAPM_OUTPUT("SPKOUTRN"), |
| 538 | SND_SOC_DAPM_OUTPUT("SPKOUTRP"), |
| 539 | SND_SOC_DAPM_OUTPUT("SPKDAT1L"), |
| 540 | SND_SOC_DAPM_OUTPUT("SPKDAT1R"), |
| 541 | }; |
| 542 | |
| 543 | #define ARIZONA_MIXER_INPUT_ROUTES(name) \ |
| 544 | { name, "Noise Generator", "Noise Generator" }, \ |
| 545 | { name, "Tone Generator 1", "Tone Generator 1" }, \ |
| 546 | { name, "Tone Generator 2", "Tone Generator 2" }, \ |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 547 | { name, "AEC", "AEC Loopback" }, \ |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 548 | { name, "IN1L", "IN1L PGA" }, \ |
| 549 | { name, "IN1R", "IN1R PGA" }, \ |
| 550 | { name, "IN2L", "IN2L PGA" }, \ |
| 551 | { name, "IN2R", "IN2R PGA" }, \ |
| 552 | { name, "IN3L", "IN3L PGA" }, \ |
| 553 | { name, "IN3R", "IN3R PGA" }, \ |
| 554 | { name, "Mic Mute Mixer", "Mic Mute Mixer" }, \ |
| 555 | { name, "AIF1RX1", "AIF1RX1" }, \ |
| 556 | { name, "AIF1RX2", "AIF1RX2" }, \ |
| 557 | { name, "AIF1RX3", "AIF1RX3" }, \ |
| 558 | { name, "AIF1RX4", "AIF1RX4" }, \ |
| 559 | { name, "AIF1RX5", "AIF1RX5" }, \ |
| 560 | { name, "AIF1RX6", "AIF1RX6" }, \ |
| 561 | { name, "AIF1RX7", "AIF1RX7" }, \ |
| 562 | { name, "AIF1RX8", "AIF1RX8" }, \ |
| 563 | { name, "AIF2RX1", "AIF2RX1" }, \ |
| 564 | { name, "AIF2RX2", "AIF2RX2" }, \ |
| 565 | { name, "AIF3RX1", "AIF3RX1" }, \ |
| 566 | { name, "AIF3RX2", "AIF3RX2" }, \ |
| 567 | { name, "EQ1", "EQ1" }, \ |
| 568 | { name, "EQ2", "EQ2" }, \ |
| 569 | { name, "EQ3", "EQ3" }, \ |
| 570 | { name, "EQ4", "EQ4" }, \ |
| 571 | { name, "DRC1L", "DRC1L" }, \ |
| 572 | { name, "DRC1R", "DRC1R" }, \ |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 573 | { name, "LHPF1", "LHPF1" }, \ |
| 574 | { name, "LHPF2", "LHPF2" }, \ |
| 575 | { name, "LHPF3", "LHPF3" }, \ |
Mark Brown | 9498822 | 2012-07-04 20:07:03 +0100 | [diff] [blame] | 576 | { name, "LHPF4", "LHPF4" }, \ |
| 577 | { name, "ASRC1L", "ASRC1L" }, \ |
| 578 | { name, "ASRC1R", "ASRC1R" }, \ |
| 579 | { name, "ASRC2L", "ASRC2L" }, \ |
| 580 | { name, "ASRC2R", "ASRC2R" } |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 581 | |
| 582 | static const struct snd_soc_dapm_route wm5102_dapm_routes[] = { |
| 583 | { "AIF2 Capture", NULL, "DBVDD2" }, |
| 584 | { "AIF2 Playback", NULL, "DBVDD2" }, |
| 585 | |
| 586 | { "AIF3 Capture", NULL, "DBVDD3" }, |
| 587 | { "AIF3 Playback", NULL, "DBVDD3" }, |
| 588 | |
| 589 | { "OUT1L", NULL, "CPVDD" }, |
| 590 | { "OUT1R", NULL, "CPVDD" }, |
| 591 | { "OUT2L", NULL, "CPVDD" }, |
| 592 | { "OUT2R", NULL, "CPVDD" }, |
| 593 | { "OUT3L", NULL, "CPVDD" }, |
| 594 | |
| 595 | { "OUT4L", NULL, "SPKVDDL" }, |
| 596 | { "OUT4R", NULL, "SPKVDDR" }, |
| 597 | |
| 598 | { "OUT1L", NULL, "SYSCLK" }, |
| 599 | { "OUT1R", NULL, "SYSCLK" }, |
| 600 | { "OUT2L", NULL, "SYSCLK" }, |
| 601 | { "OUT2R", NULL, "SYSCLK" }, |
| 602 | { "OUT3L", NULL, "SYSCLK" }, |
| 603 | { "OUT4L", NULL, "SYSCLK" }, |
| 604 | { "OUT4R", NULL, "SYSCLK" }, |
| 605 | { "OUT5L", NULL, "SYSCLK" }, |
| 606 | { "OUT5R", NULL, "SYSCLK" }, |
| 607 | |
| 608 | { "MICBIAS1", NULL, "MICVDD" }, |
| 609 | { "MICBIAS2", NULL, "MICVDD" }, |
| 610 | { "MICBIAS3", NULL, "MICVDD" }, |
| 611 | |
| 612 | { "Noise Generator", NULL, "NOISE" }, |
| 613 | { "Tone Generator 1", NULL, "TONE" }, |
| 614 | { "Tone Generator 2", NULL, "TONE" }, |
| 615 | |
| 616 | { "Mic Mute Mixer", NULL, "Noise Mixer" }, |
| 617 | { "Mic Mute Mixer", NULL, "Mic Mixer" }, |
| 618 | |
| 619 | { "AIF1 Capture", NULL, "AIF1TX1" }, |
| 620 | { "AIF1 Capture", NULL, "AIF1TX2" }, |
| 621 | { "AIF1 Capture", NULL, "AIF1TX3" }, |
| 622 | { "AIF1 Capture", NULL, "AIF1TX4" }, |
| 623 | { "AIF1 Capture", NULL, "AIF1TX5" }, |
| 624 | { "AIF1 Capture", NULL, "AIF1TX6" }, |
| 625 | { "AIF1 Capture", NULL, "AIF1TX7" }, |
| 626 | { "AIF1 Capture", NULL, "AIF1TX8" }, |
| 627 | |
| 628 | { "AIF1RX1", NULL, "AIF1 Playback" }, |
| 629 | { "AIF1RX2", NULL, "AIF1 Playback" }, |
| 630 | { "AIF1RX3", NULL, "AIF1 Playback" }, |
| 631 | { "AIF1RX4", NULL, "AIF1 Playback" }, |
| 632 | { "AIF1RX5", NULL, "AIF1 Playback" }, |
| 633 | { "AIF1RX6", NULL, "AIF1 Playback" }, |
| 634 | { "AIF1RX7", NULL, "AIF1 Playback" }, |
| 635 | { "AIF1RX8", NULL, "AIF1 Playback" }, |
| 636 | |
| 637 | { "AIF2 Capture", NULL, "AIF2TX1" }, |
| 638 | { "AIF2 Capture", NULL, "AIF2TX2" }, |
| 639 | |
| 640 | { "AIF2RX1", NULL, "AIF2 Playback" }, |
| 641 | { "AIF2RX2", NULL, "AIF2 Playback" }, |
| 642 | |
| 643 | { "AIF3 Capture", NULL, "AIF3TX1" }, |
| 644 | { "AIF3 Capture", NULL, "AIF3TX2" }, |
| 645 | |
| 646 | { "AIF3RX1", NULL, "AIF3 Playback" }, |
| 647 | { "AIF3RX2", NULL, "AIF3 Playback" }, |
| 648 | |
| 649 | { "AIF1 Playback", NULL, "SYSCLK" }, |
| 650 | { "AIF2 Playback", NULL, "SYSCLK" }, |
| 651 | { "AIF3 Playback", NULL, "SYSCLK" }, |
| 652 | |
| 653 | { "AIF1 Capture", NULL, "SYSCLK" }, |
| 654 | { "AIF2 Capture", NULL, "SYSCLK" }, |
| 655 | { "AIF3 Capture", NULL, "SYSCLK" }, |
| 656 | |
Mark Brown | 14ebd8a | 2012-08-10 15:40:12 +0100 | [diff] [blame] | 657 | { "IN1L PGA", NULL, "IN1L" }, |
| 658 | { "IN1R PGA", NULL, "IN1R" }, |
| 659 | |
| 660 | { "IN2L PGA", NULL, "IN2L" }, |
| 661 | { "IN2R PGA", NULL, "IN2R" }, |
| 662 | |
| 663 | { "IN3L PGA", NULL, "IN3L" }, |
| 664 | { "IN3R PGA", NULL, "IN3R" }, |
| 665 | |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 666 | ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"), |
| 667 | ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"), |
| 668 | ARIZONA_MIXER_ROUTES("OUT2L", "HPOUT2L"), |
| 669 | ARIZONA_MIXER_ROUTES("OUT2R", "HPOUT2R"), |
| 670 | ARIZONA_MIXER_ROUTES("OUT3L", "EPOUT"), |
| 671 | |
| 672 | ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUTL"), |
| 673 | ARIZONA_MIXER_ROUTES("OUT4R", "SPKOUTR"), |
| 674 | ARIZONA_MIXER_ROUTES("OUT5L", "SPKDAT1L"), |
| 675 | ARIZONA_MIXER_ROUTES("OUT5R", "SPKDAT1R"), |
| 676 | |
| 677 | ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"), |
| 678 | ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"), |
| 679 | |
| 680 | ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"), |
| 681 | ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"), |
| 682 | ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"), |
| 683 | ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"), |
| 684 | ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"), |
| 685 | ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"), |
| 686 | ARIZONA_MIXER_ROUTES("AIF1TX7", "AIF1TX7"), |
| 687 | ARIZONA_MIXER_ROUTES("AIF1TX8", "AIF1TX8"), |
| 688 | |
| 689 | ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"), |
| 690 | ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"), |
| 691 | |
| 692 | ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"), |
| 693 | ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"), |
| 694 | |
| 695 | ARIZONA_MIXER_ROUTES("EQ1", "EQ1"), |
| 696 | ARIZONA_MIXER_ROUTES("EQ2", "EQ2"), |
| 697 | ARIZONA_MIXER_ROUTES("EQ3", "EQ3"), |
| 698 | ARIZONA_MIXER_ROUTES("EQ4", "EQ4"), |
| 699 | |
| 700 | ARIZONA_MIXER_ROUTES("DRC1L", "DRC1L"), |
| 701 | ARIZONA_MIXER_ROUTES("DRC1R", "DRC1R"), |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 702 | |
| 703 | ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"), |
| 704 | ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"), |
| 705 | ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"), |
| 706 | ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"), |
| 707 | |
Mark Brown | 9498822 | 2012-07-04 20:07:03 +0100 | [diff] [blame] | 708 | ARIZONA_MIXER_ROUTES("ASRC1L", "ASRC1L"), |
| 709 | ARIZONA_MIXER_ROUTES("ASRC1R", "ASRC1R"), |
| 710 | ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"), |
| 711 | ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"), |
| 712 | |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 713 | { "AEC Loopback", "HPOUT1L", "OUT1L" }, |
| 714 | { "AEC Loopback", "HPOUT1R", "OUT1R" }, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 715 | { "HPOUT1L", NULL, "OUT1L" }, |
| 716 | { "HPOUT1R", NULL, "OUT1R" }, |
| 717 | |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 718 | { "AEC Loopback", "HPOUT2L", "OUT2L" }, |
| 719 | { "AEC Loopback", "HPOUT2R", "OUT2R" }, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 720 | { "HPOUT2L", NULL, "OUT2L" }, |
| 721 | { "HPOUT2R", NULL, "OUT2R" }, |
| 722 | |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 723 | { "AEC Loopback", "EPOUT", "OUT3L" }, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 724 | { "EPOUTN", NULL, "OUT3L" }, |
| 725 | { "EPOUTP", NULL, "OUT3L" }, |
| 726 | |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 727 | { "AEC Loopback", "SPKOUTL", "OUT4L" }, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 728 | { "SPKOUTLN", NULL, "OUT4L" }, |
| 729 | { "SPKOUTLP", NULL, "OUT4L" }, |
| 730 | |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 731 | { "AEC Loopback", "SPKOUTR", "OUT4R" }, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 732 | { "SPKOUTRN", NULL, "OUT4R" }, |
| 733 | { "SPKOUTRP", NULL, "OUT4R" }, |
| 734 | |
Mark Brown | a3150f0 | 2012-08-16 20:28:18 +0100 | [diff] [blame] | 735 | { "AEC Loopback", "SPKDAT1L", "OUT5L" }, |
| 736 | { "AEC Loopback", "SPKDAT1R", "OUT5R" }, |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 737 | { "SPKDAT1L", NULL, "OUT5L" }, |
| 738 | { "SPKDAT1R", NULL, "OUT5R" }, |
| 739 | }; |
| 740 | |
| 741 | static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source, |
| 742 | unsigned int Fref, unsigned int Fout) |
| 743 | { |
| 744 | struct wm5102_priv *wm5102 = snd_soc_codec_get_drvdata(codec); |
| 745 | |
| 746 | switch (fll_id) { |
| 747 | case WM5102_FLL1: |
| 748 | return arizona_set_fll(&wm5102->fll[0], source, Fref, Fout); |
| 749 | case WM5102_FLL2: |
| 750 | return arizona_set_fll(&wm5102->fll[1], source, Fref, Fout); |
| 751 | default: |
| 752 | return -EINVAL; |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | #define WM5102_RATES SNDRV_PCM_RATE_8000_192000 |
| 757 | |
| 758 | #define WM5102_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
| 759 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) |
| 760 | |
| 761 | static struct snd_soc_dai_driver wm5102_dai[] = { |
| 762 | { |
| 763 | .name = "wm5102-aif1", |
| 764 | .id = 1, |
| 765 | .base = ARIZONA_AIF1_BCLK_CTRL, |
| 766 | .playback = { |
| 767 | .stream_name = "AIF1 Playback", |
| 768 | .channels_min = 1, |
| 769 | .channels_max = 8, |
| 770 | .rates = WM5102_RATES, |
| 771 | .formats = WM5102_FORMATS, |
| 772 | }, |
| 773 | .capture = { |
| 774 | .stream_name = "AIF1 Capture", |
| 775 | .channels_min = 1, |
| 776 | .channels_max = 8, |
| 777 | .rates = WM5102_RATES, |
| 778 | .formats = WM5102_FORMATS, |
| 779 | }, |
| 780 | .ops = &arizona_dai_ops, |
| 781 | .symmetric_rates = 1, |
| 782 | }, |
| 783 | { |
| 784 | .name = "wm5102-aif2", |
| 785 | .id = 2, |
| 786 | .base = ARIZONA_AIF2_BCLK_CTRL, |
| 787 | .playback = { |
| 788 | .stream_name = "AIF2 Playback", |
| 789 | .channels_min = 1, |
| 790 | .channels_max = 2, |
| 791 | .rates = WM5102_RATES, |
| 792 | .formats = WM5102_FORMATS, |
| 793 | }, |
| 794 | .capture = { |
| 795 | .stream_name = "AIF2 Capture", |
| 796 | .channels_min = 1, |
| 797 | .channels_max = 2, |
| 798 | .rates = WM5102_RATES, |
| 799 | .formats = WM5102_FORMATS, |
| 800 | }, |
| 801 | .ops = &arizona_dai_ops, |
| 802 | .symmetric_rates = 1, |
| 803 | }, |
| 804 | { |
| 805 | .name = "wm5102-aif3", |
| 806 | .id = 3, |
| 807 | .base = ARIZONA_AIF3_BCLK_CTRL, |
| 808 | .playback = { |
| 809 | .stream_name = "AIF3 Playback", |
| 810 | .channels_min = 1, |
| 811 | .channels_max = 2, |
| 812 | .rates = WM5102_RATES, |
| 813 | .formats = WM5102_FORMATS, |
| 814 | }, |
| 815 | .capture = { |
| 816 | .stream_name = "AIF3 Capture", |
| 817 | .channels_min = 1, |
| 818 | .channels_max = 2, |
| 819 | .rates = WM5102_RATES, |
| 820 | .formats = WM5102_FORMATS, |
| 821 | }, |
| 822 | .ops = &arizona_dai_ops, |
| 823 | .symmetric_rates = 1, |
| 824 | }, |
| 825 | }; |
| 826 | |
| 827 | static int wm5102_codec_probe(struct snd_soc_codec *codec) |
| 828 | { |
| 829 | struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); |
| 830 | |
| 831 | codec->control_data = priv->core.arizona->regmap; |
| 832 | return snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP); |
| 833 | } |
| 834 | |
| 835 | #define WM5102_DIG_VU 0x0200 |
| 836 | |
| 837 | static unsigned int wm5102_digital_vu[] = { |
| 838 | ARIZONA_ADC_DIGITAL_VOLUME_1L, |
| 839 | ARIZONA_ADC_DIGITAL_VOLUME_1R, |
| 840 | ARIZONA_ADC_DIGITAL_VOLUME_2L, |
| 841 | ARIZONA_ADC_DIGITAL_VOLUME_2R, |
| 842 | ARIZONA_ADC_DIGITAL_VOLUME_3L, |
| 843 | ARIZONA_ADC_DIGITAL_VOLUME_3R, |
| 844 | |
| 845 | ARIZONA_DAC_DIGITAL_VOLUME_1L, |
| 846 | ARIZONA_DAC_DIGITAL_VOLUME_1R, |
| 847 | ARIZONA_DAC_DIGITAL_VOLUME_2L, |
| 848 | ARIZONA_DAC_DIGITAL_VOLUME_2R, |
| 849 | ARIZONA_DAC_DIGITAL_VOLUME_3L, |
| 850 | ARIZONA_DAC_DIGITAL_VOLUME_3R, |
| 851 | ARIZONA_DAC_DIGITAL_VOLUME_4L, |
| 852 | ARIZONA_DAC_DIGITAL_VOLUME_4R, |
| 853 | ARIZONA_DAC_DIGITAL_VOLUME_5L, |
| 854 | ARIZONA_DAC_DIGITAL_VOLUME_5R, |
| 855 | }; |
| 856 | |
| 857 | static struct snd_soc_codec_driver soc_codec_dev_wm5102 = { |
| 858 | .probe = wm5102_codec_probe, |
| 859 | |
| 860 | .idle_bias_off = true, |
| 861 | |
| 862 | .set_sysclk = arizona_set_sysclk, |
| 863 | .set_pll = wm5102_set_fll, |
| 864 | |
| 865 | .controls = wm5102_snd_controls, |
| 866 | .num_controls = ARRAY_SIZE(wm5102_snd_controls), |
| 867 | .dapm_widgets = wm5102_dapm_widgets, |
| 868 | .num_dapm_widgets = ARRAY_SIZE(wm5102_dapm_widgets), |
| 869 | .dapm_routes = wm5102_dapm_routes, |
| 870 | .num_dapm_routes = ARRAY_SIZE(wm5102_dapm_routes), |
| 871 | }; |
| 872 | |
| 873 | static int __devinit wm5102_probe(struct platform_device *pdev) |
| 874 | { |
| 875 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); |
| 876 | struct wm5102_priv *wm5102; |
| 877 | int i; |
| 878 | |
| 879 | wm5102 = devm_kzalloc(&pdev->dev, sizeof(struct wm5102_priv), |
| 880 | GFP_KERNEL); |
| 881 | if (wm5102 == NULL) |
| 882 | return -ENOMEM; |
| 883 | platform_set_drvdata(pdev, wm5102); |
| 884 | |
| 885 | wm5102->core.arizona = arizona; |
| 886 | |
Mark Brown | 2b4d39f | 2012-07-10 17:03:46 +0100 | [diff] [blame] | 887 | for (i = 0; i < ARRAY_SIZE(wm5102->fll); i++) |
| 888 | wm5102->fll[i].vco_mult = 1; |
| 889 | |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 890 | arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1, |
| 891 | ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK, |
| 892 | &wm5102->fll[0]); |
| 893 | arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1, |
| 894 | ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK, |
| 895 | &wm5102->fll[1]); |
| 896 | |
Mark Brown | 5b2eec3 | 2012-07-04 17:32:05 +0100 | [diff] [blame] | 897 | for (i = 0; i < ARRAY_SIZE(wm5102_dai); i++) |
| 898 | arizona_init_dai(&wm5102->core, i); |
| 899 | |
Mark Brown | 93e8791 | 2012-06-19 16:38:15 +0100 | [diff] [blame] | 900 | /* Latch volume update bits */ |
| 901 | for (i = 0; i < ARRAY_SIZE(wm5102_digital_vu); i++) |
| 902 | regmap_update_bits(arizona->regmap, wm5102_digital_vu[i], |
| 903 | WM5102_DIG_VU, WM5102_DIG_VU); |
| 904 | |
| 905 | pm_runtime_enable(&pdev->dev); |
| 906 | pm_runtime_idle(&pdev->dev); |
| 907 | |
| 908 | return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102, |
| 909 | wm5102_dai, ARRAY_SIZE(wm5102_dai)); |
| 910 | } |
| 911 | |
| 912 | static int __devexit wm5102_remove(struct platform_device *pdev) |
| 913 | { |
| 914 | snd_soc_unregister_codec(&pdev->dev); |
| 915 | pm_runtime_disable(&pdev->dev); |
| 916 | |
| 917 | return 0; |
| 918 | } |
| 919 | |
| 920 | static struct platform_driver wm5102_codec_driver = { |
| 921 | .driver = { |
| 922 | .name = "wm5102-codec", |
| 923 | .owner = THIS_MODULE, |
| 924 | }, |
| 925 | .probe = wm5102_probe, |
| 926 | .remove = __devexit_p(wm5102_remove), |
| 927 | }; |
| 928 | |
| 929 | module_platform_driver(wm5102_codec_driver); |
| 930 | |
| 931 | MODULE_DESCRIPTION("ASoC WM5102 driver"); |
| 932 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |
| 933 | MODULE_LICENSE("GPL"); |
| 934 | MODULE_ALIAS("platform:wm5102-codec"); |