Sylwester Nawrocki | 3f8b21f | 2019-04-19 12:22:00 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | // |
| 3 | // Speyside audio support |
| 4 | // |
| 5 | // Copyright 2011 Wolfson Microelectronics |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 6 | |
| 7 | #include <sound/soc.h> |
| 8 | #include <sound/soc-dapm.h> |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 9 | #include <sound/jack.h> |
| 10 | #include <linux/gpio.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 11 | #include <linux/module.h> |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 12 | |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 13 | #include "../codecs/wm8996.h" |
Mark Brown | ea3e98e | 2011-04-11 23:42:25 -0700 | [diff] [blame] | 14 | #include "../codecs/wm9081.h" |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 15 | |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 16 | #define WM8996_HPSEL_GPIO 214 |
Mark Brown | 3628137 | 2011-12-11 11:31:22 +0800 | [diff] [blame] | 17 | #define MCLK_AUDIO_RATE (512 * 48000) |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 18 | |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 19 | static int speyside_set_bias_level(struct snd_soc_card *card, |
Mark Brown | d4c6005 | 2011-06-06 19:13:23 +0100 | [diff] [blame] | 20 | struct snd_soc_dapm_context *dapm, |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 21 | enum snd_soc_bias_level level) |
| 22 | { |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 23 | struct snd_soc_pcm_runtime *rtd; |
| 24 | struct snd_soc_dai *codec_dai; |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 25 | int ret; |
| 26 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 27 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 28 | codec_dai = asoc_rtd_to_codec(rtd, 0); |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 29 | |
Mark Brown | d4c6005 | 2011-06-06 19:13:23 +0100 | [diff] [blame] | 30 | if (dapm->dev != codec_dai->dev) |
| 31 | return 0; |
| 32 | |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 33 | switch (level) { |
| 34 | case SND_SOC_BIAS_STANDBY: |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 35 | ret = snd_soc_dai_set_sysclk(codec_dai, WM8996_SYSCLK_MCLK2, |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 36 | 32768, SND_SOC_CLOCK_IN); |
| 37 | if (ret < 0) |
| 38 | return ret; |
| 39 | |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 40 | ret = snd_soc_dai_set_pll(codec_dai, WM8996_FLL_MCLK2, |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 41 | 0, 0, 0); |
| 42 | if (ret < 0) { |
| 43 | pr_err("Failed to stop FLL\n"); |
| 44 | return ret; |
| 45 | } |
Mark Brown | 85e9e76 | 2011-06-06 19:12:44 +0100 | [diff] [blame] | 46 | break; |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 47 | |
| 48 | default: |
| 49 | break; |
| 50 | } |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |
Mark Brown | 85e9e76 | 2011-06-06 19:12:44 +0100 | [diff] [blame] | 55 | static int speyside_set_bias_level_post(struct snd_soc_card *card, |
| 56 | struct snd_soc_dapm_context *dapm, |
| 57 | enum snd_soc_bias_level level) |
| 58 | { |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 59 | struct snd_soc_pcm_runtime *rtd; |
| 60 | struct snd_soc_dai *codec_dai; |
Mark Brown | 85e9e76 | 2011-06-06 19:12:44 +0100 | [diff] [blame] | 61 | int ret; |
| 62 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 63 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 64 | codec_dai = asoc_rtd_to_codec(rtd, 0); |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 65 | |
Mark Brown | 85e9e76 | 2011-06-06 19:12:44 +0100 | [diff] [blame] | 66 | if (dapm->dev != codec_dai->dev) |
| 67 | return 0; |
| 68 | |
| 69 | switch (level) { |
| 70 | case SND_SOC_BIAS_PREPARE: |
| 71 | if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) { |
| 72 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 73 | WM8996_FLL_MCLK2, |
Mark Brown | 3628137 | 2011-12-11 11:31:22 +0800 | [diff] [blame] | 74 | 32768, MCLK_AUDIO_RATE); |
Mark Brown | 85e9e76 | 2011-06-06 19:12:44 +0100 | [diff] [blame] | 75 | if (ret < 0) { |
| 76 | pr_err("Failed to start FLL\n"); |
| 77 | return ret; |
| 78 | } |
| 79 | |
| 80 | ret = snd_soc_dai_set_sysclk(codec_dai, |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 81 | WM8996_SYSCLK_FLL, |
Mark Brown | 3628137 | 2011-12-11 11:31:22 +0800 | [diff] [blame] | 82 | MCLK_AUDIO_RATE, |
Mark Brown | 85e9e76 | 2011-06-06 19:12:44 +0100 | [diff] [blame] | 83 | SND_SOC_CLOCK_IN); |
| 84 | if (ret < 0) |
| 85 | return ret; |
| 86 | } |
| 87 | break; |
| 88 | |
| 89 | default: |
| 90 | break; |
| 91 | } |
| 92 | |
| 93 | card->dapm.bias_level = level; |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 98 | static struct snd_soc_jack speyside_headset; |
| 99 | |
| 100 | /* Headset jack detection DAPM pins */ |
| 101 | static struct snd_soc_jack_pin speyside_headset_pins[] = { |
| 102 | { |
| 103 | .pin = "Headset Mic", |
| 104 | .mask = SND_JACK_MICROPHONE, |
| 105 | }, |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | /* Default the headphone selection to active high */ |
| 109 | static int speyside_jack_polarity; |
| 110 | |
| 111 | static int speyside_get_micbias(struct snd_soc_dapm_widget *source, |
| 112 | struct snd_soc_dapm_widget *sink) |
| 113 | { |
| 114 | if (speyside_jack_polarity && (strcmp(source->name, "MICB1") == 0)) |
| 115 | return 1; |
| 116 | if (!speyside_jack_polarity && (strcmp(source->name, "MICB2") == 0)) |
| 117 | return 1; |
| 118 | |
| 119 | return 0; |
| 120 | } |
| 121 | |
Kuninori Morimoto | 5d61ef8 | 2018-01-29 03:08:15 +0000 | [diff] [blame] | 122 | static void speyside_set_polarity(struct snd_soc_component *component, |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 123 | int polarity) |
| 124 | { |
| 125 | speyside_jack_polarity = !polarity; |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 126 | gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity); |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 127 | |
| 128 | /* Re-run DAPM to make sure we're using the correct mic bias */ |
Kuninori Morimoto | 5d61ef8 | 2018-01-29 03:08:15 +0000 | [diff] [blame] | 129 | snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Mark Brown | f9372c9 | 2012-08-23 17:05:48 +0100 | [diff] [blame] | 132 | static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd) |
| 133 | { |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 134 | struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); |
Mark Brown | f9372c9 | 2012-08-23 17:05:48 +0100 | [diff] [blame] | 135 | int ret; |
| 136 | |
| 137 | ret = snd_soc_dai_set_sysclk(dai, 0, MCLK_AUDIO_RATE, 0); |
| 138 | if (ret < 0) |
| 139 | return ret; |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 144 | static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd) |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 145 | { |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 146 | struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); |
Kuninori Morimoto | 5d61ef8 | 2018-01-29 03:08:15 +0000 | [diff] [blame] | 147 | struct snd_soc_component *component = dai->component; |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 148 | int ret; |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 149 | |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 150 | ret = snd_soc_dai_set_sysclk(dai, WM8996_SYSCLK_MCLK2, 32768, 0); |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 151 | if (ret < 0) |
| 152 | return ret; |
| 153 | |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 154 | ret = gpio_request(WM8996_HPSEL_GPIO, "HP_SEL"); |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 155 | if (ret != 0) |
| 156 | pr_err("Failed to request HP_SEL GPIO: %d\n", ret); |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 157 | gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity); |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 158 | |
Lars-Peter Clausen | 663976a | 2015-03-04 10:33:38 +0100 | [diff] [blame] | 159 | ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT | |
| 160 | SND_JACK_HEADSET | SND_JACK_BTN_0, |
| 161 | &speyside_headset, speyside_headset_pins, |
| 162 | ARRAY_SIZE(speyside_headset_pins)); |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 163 | if (ret) |
| 164 | return ret; |
| 165 | |
Kuninori Morimoto | 5d61ef8 | 2018-01-29 03:08:15 +0000 | [diff] [blame] | 166 | wm8996_detect(component, &speyside_headset, speyside_set_polarity); |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 167 | |
| 168 | return 0; |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Mark Brown | b7a5d14 | 2011-04-12 17:37:52 -0700 | [diff] [blame] | 171 | static int speyside_late_probe(struct snd_soc_card *card) |
| 172 | { |
| 173 | snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone"); |
| 174 | snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Mic"); |
| 175 | snd_soc_dapm_ignore_suspend(&card->dapm, "Main AMIC"); |
| 176 | snd_soc_dapm_ignore_suspend(&card->dapm, "Main DMIC"); |
Mark Brown | 5b895ee | 2011-11-27 15:54:49 +0000 | [diff] [blame] | 177 | snd_soc_dapm_ignore_suspend(&card->dapm, "Main Speaker"); |
Mark Brown | b7a5d14 | 2011-04-12 17:37:52 -0700 | [diff] [blame] | 178 | snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Output"); |
| 179 | snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Input"); |
| 180 | |
| 181 | return 0; |
| 182 | } |
| 183 | |
Mark Brown | f9372c9 | 2012-08-23 17:05:48 +0100 | [diff] [blame] | 184 | static const struct snd_soc_pcm_stream dsp_codec_params = { |
| 185 | .formats = SNDRV_PCM_FMTBIT_S32_LE, |
| 186 | .rate_min = 48000, |
| 187 | .rate_max = 48000, |
| 188 | .channels_min = 2, |
| 189 | .channels_max = 2, |
| 190 | }; |
| 191 | |
Kuninori Morimoto | 3f60911 | 2019-06-06 13:09:50 +0900 | [diff] [blame] | 192 | SND_SOC_DAILINK_DEFS(cpu_dsp, |
| 193 | DAILINK_COMP_ARRAY(COMP_CPU("samsung-i2s.0")), |
| 194 | DAILINK_COMP_ARRAY(COMP_CODEC("spi0.0", "wm0010-sdi1")), |
| 195 | DAILINK_COMP_ARRAY(COMP_PLATFORM("samsung-i2s.0"))); |
| 196 | |
| 197 | SND_SOC_DAILINK_DEFS(dsp_codec, |
| 198 | DAILINK_COMP_ARRAY(COMP_CPU("wm0010-sdi2")), |
| 199 | DAILINK_COMP_ARRAY(COMP_CODEC("wm8996.1-001a", "wm8996-aif1"))); |
| 200 | |
| 201 | SND_SOC_DAILINK_DEFS(baseband, |
| 202 | DAILINK_COMP_ARRAY(COMP_CPU("wm8996-aif2")), |
| 203 | DAILINK_COMP_ARRAY(COMP_CODEC("wm1250-ev1.1-0027", "wm1250-ev1"))); |
| 204 | |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 205 | static struct snd_soc_dai_link speyside_dai[] = { |
| 206 | { |
Mark Brown | f9372c9 | 2012-08-23 17:05:48 +0100 | [diff] [blame] | 207 | .name = "CPU-DSP", |
| 208 | .stream_name = "CPU-DSP", |
Mark Brown | f9372c9 | 2012-08-23 17:05:48 +0100 | [diff] [blame] | 209 | .init = speyside_wm0010_init, |
| 210 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 211 | | SND_SOC_DAIFMT_CBM_CFM, |
Kuninori Morimoto | 3f60911 | 2019-06-06 13:09:50 +0900 | [diff] [blame] | 212 | SND_SOC_DAILINK_REG(cpu_dsp), |
Mark Brown | f9372c9 | 2012-08-23 17:05:48 +0100 | [diff] [blame] | 213 | }, |
| 214 | { |
| 215 | .name = "DSP-CODEC", |
| 216 | .stream_name = "DSP-CODEC", |
Mark Brown | a9ba615 | 2011-06-24 12:10:44 +0100 | [diff] [blame] | 217 | .init = speyside_wm8996_init, |
Mark Brown | 26e6781 | 2011-09-27 16:48:49 +0100 | [diff] [blame] | 218 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 219 | | SND_SOC_DAIFMT_CBM_CFM, |
Mark Brown | f9372c9 | 2012-08-23 17:05:48 +0100 | [diff] [blame] | 220 | .params = &dsp_codec_params, |
| 221 | .ignore_suspend = 1, |
Kuninori Morimoto | 3f60911 | 2019-06-06 13:09:50 +0900 | [diff] [blame] | 222 | SND_SOC_DAILINK_REG(dsp_codec), |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 223 | }, |
Mark Brown | 556e4fb | 2011-04-12 14:15:10 -0700 | [diff] [blame] | 224 | { |
| 225 | .name = "Baseband", |
| 226 | .stream_name = "Baseband", |
Mark Brown | 26e6781 | 2011-09-27 16:48:49 +0100 | [diff] [blame] | 227 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 228 | | SND_SOC_DAIFMT_CBM_CFM, |
Mark Brown | b7a5d14 | 2011-04-12 17:37:52 -0700 | [diff] [blame] | 229 | .ignore_suspend = 1, |
Kuninori Morimoto | 3f60911 | 2019-06-06 13:09:50 +0900 | [diff] [blame] | 230 | SND_SOC_DAILINK_REG(baseband), |
Mark Brown | 556e4fb | 2011-04-12 14:15:10 -0700 | [diff] [blame] | 231 | }, |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 232 | }; |
| 233 | |
Lars-Peter Clausen | 57bf772 | 2014-08-19 15:51:23 +0200 | [diff] [blame] | 234 | static int speyside_wm9081_init(struct snd_soc_component *component) |
Mark Brown | ea3e98e | 2011-04-11 23:42:25 -0700 | [diff] [blame] | 235 | { |
Mark Brown | ea3e98e | 2011-04-11 23:42:25 -0700 | [diff] [blame] | 236 | /* At any time the WM9081 is active it will have this clock */ |
Kuninori Morimoto | 5d61ef8 | 2018-01-29 03:08:15 +0000 | [diff] [blame] | 237 | return snd_soc_component_set_sysclk(component, WM9081_SYSCLK_MCLK, 0, |
Mark Brown | 3628137 | 2011-12-11 11:31:22 +0800 | [diff] [blame] | 238 | MCLK_AUDIO_RATE, 0); |
Mark Brown | ea3e98e | 2011-04-11 23:42:25 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static struct snd_soc_aux_dev speyside_aux_dev[] = { |
| 242 | { |
Kuninori Morimoto | 2d946aa | 2019-08-08 14:54:15 +0900 | [diff] [blame] | 243 | .dlc = COMP_AUX("wm9081.1-006c"), |
Mark Brown | ea3e98e | 2011-04-11 23:42:25 -0700 | [diff] [blame] | 244 | .init = speyside_wm9081_init, |
| 245 | }, |
| 246 | }; |
| 247 | |
| 248 | static struct snd_soc_codec_conf speyside_codec_conf[] = { |
| 249 | { |
Kuninori Morimoto | b9fc100 | 2019-12-13 09:55:44 +0900 | [diff] [blame] | 250 | .dlc = COMP_CODEC_CONF("wm9081.1-006c"), |
Mark Brown | ea3e98e | 2011-04-11 23:42:25 -0700 | [diff] [blame] | 251 | .name_prefix = "Sub", |
| 252 | }, |
| 253 | }; |
| 254 | |
Mark Brown | ea0e60d | 2011-04-12 00:09:53 -0700 | [diff] [blame] | 255 | static const struct snd_kcontrol_new controls[] = { |
| 256 | SOC_DAPM_PIN_SWITCH("Main Speaker"), |
| 257 | SOC_DAPM_PIN_SWITCH("Main DMIC"), |
| 258 | SOC_DAPM_PIN_SWITCH("Main AMIC"), |
Mark Brown | 556e4fb | 2011-04-12 14:15:10 -0700 | [diff] [blame] | 259 | SOC_DAPM_PIN_SWITCH("WM1250 Input"), |
| 260 | SOC_DAPM_PIN_SWITCH("WM1250 Output"), |
Mark Brown | 68d5a59 | 2011-08-04 18:13:45 +0900 | [diff] [blame] | 261 | SOC_DAPM_PIN_SWITCH("Headphone"), |
Mark Brown | ea0e60d | 2011-04-12 00:09:53 -0700 | [diff] [blame] | 262 | }; |
| 263 | |
Mark Brown | ecfb1ad | 2011-04-11 23:09:15 -0700 | [diff] [blame] | 264 | static struct snd_soc_dapm_widget widgets[] = { |
| 265 | SND_SOC_DAPM_HP("Headphone", NULL), |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 266 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
Mark Brown | ecfb1ad | 2011-04-11 23:09:15 -0700 | [diff] [blame] | 267 | |
| 268 | SND_SOC_DAPM_SPK("Main Speaker", NULL), |
| 269 | |
| 270 | SND_SOC_DAPM_MIC("Main AMIC", NULL), |
| 271 | SND_SOC_DAPM_MIC("Main DMIC", NULL), |
| 272 | }; |
| 273 | |
| 274 | static struct snd_soc_dapm_route audio_paths[] = { |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 275 | { "IN1RN", NULL, "MICB1" }, |
| 276 | { "IN1RP", NULL, "MICB1" }, |
| 277 | { "IN1RN", NULL, "MICB2" }, |
| 278 | { "IN1RP", NULL, "MICB2" }, |
| 279 | { "MICB1", NULL, "Headset Mic", speyside_get_micbias }, |
| 280 | { "MICB2", NULL, "Headset Mic", speyside_get_micbias }, |
| 281 | |
Mark Brown | ecfb1ad | 2011-04-11 23:09:15 -0700 | [diff] [blame] | 282 | { "IN1LP", NULL, "MICB2" }, |
Mark Brown | 68688e7 | 2011-04-12 00:00:36 -0700 | [diff] [blame] | 283 | { "IN1RN", NULL, "MICB1" }, |
Mark Brown | ecfb1ad | 2011-04-11 23:09:15 -0700 | [diff] [blame] | 284 | { "MICB2", NULL, "Main AMIC" }, |
| 285 | |
| 286 | { "DMIC1DAT", NULL, "MICB1" }, |
| 287 | { "DMIC2DAT", NULL, "MICB1" }, |
| 288 | { "MICB1", NULL, "Main DMIC" }, |
| 289 | |
| 290 | { "Headphone", NULL, "HPOUT1L" }, |
| 291 | { "Headphone", NULL, "HPOUT1R" }, |
| 292 | |
Mark Brown | ea3e98e | 2011-04-11 23:42:25 -0700 | [diff] [blame] | 293 | { "Sub IN1", NULL, "HPOUT2L" }, |
| 294 | { "Sub IN2", NULL, "HPOUT2R" }, |
| 295 | |
| 296 | { "Main Speaker", NULL, "Sub SPKN" }, |
| 297 | { "Main Speaker", NULL, "Sub SPKP" }, |
Mark Brown | ecfb1ad | 2011-04-11 23:09:15 -0700 | [diff] [blame] | 298 | { "Main Speaker", NULL, "SPKDAT" }, |
| 299 | }; |
| 300 | |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 301 | static struct snd_soc_card speyside = { |
| 302 | .name = "Speyside", |
Axel Lin | 095d79d | 2011-12-22 10:53:15 +0800 | [diff] [blame] | 303 | .owner = THIS_MODULE, |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 304 | .dai_link = speyside_dai, |
| 305 | .num_links = ARRAY_SIZE(speyside_dai), |
Mark Brown | ea3e98e | 2011-04-11 23:42:25 -0700 | [diff] [blame] | 306 | .aux_dev = speyside_aux_dev, |
| 307 | .num_aux_devs = ARRAY_SIZE(speyside_aux_dev), |
| 308 | .codec_conf = speyside_codec_conf, |
| 309 | .num_configs = ARRAY_SIZE(speyside_codec_conf), |
Mark Brown | ecfb1ad | 2011-04-11 23:09:15 -0700 | [diff] [blame] | 310 | |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 311 | .set_bias_level = speyside_set_bias_level, |
Mark Brown | 995e54f | 2011-06-08 16:11:18 +0100 | [diff] [blame] | 312 | .set_bias_level_post = speyside_set_bias_level_post, |
Mark Brown | ea0a591 | 2011-04-11 23:32:03 -0700 | [diff] [blame] | 313 | |
Mark Brown | ea0e60d | 2011-04-12 00:09:53 -0700 | [diff] [blame] | 314 | .controls = controls, |
| 315 | .num_controls = ARRAY_SIZE(controls), |
Mark Brown | ecfb1ad | 2011-04-11 23:09:15 -0700 | [diff] [blame] | 316 | .dapm_widgets = widgets, |
| 317 | .num_dapm_widgets = ARRAY_SIZE(widgets), |
| 318 | .dapm_routes = audio_paths, |
| 319 | .num_dapm_routes = ARRAY_SIZE(audio_paths), |
Mark Brown | 39afd66 | 2011-11-23 21:33:07 +0000 | [diff] [blame] | 320 | .fully_routed = true, |
Mark Brown | b7a5d14 | 2011-04-12 17:37:52 -0700 | [diff] [blame] | 321 | |
| 322 | .late_probe = speyside_late_probe, |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 323 | }; |
| 324 | |
Bill Pemberton | fdca21a | 2012-12-07 09:26:15 -0500 | [diff] [blame] | 325 | static int speyside_probe(struct platform_device *pdev) |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 326 | { |
| 327 | struct snd_soc_card *card = &speyside; |
| 328 | int ret; |
| 329 | |
| 330 | card->dev = &pdev->dev; |
| 331 | |
Tushar Behera | c583883 | 2014-05-21 08:52:17 +0530 | [diff] [blame] | 332 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
Marek Szyprowski | 1a1b374 | 2020-02-28 11:11:20 +0100 | [diff] [blame] | 333 | if (ret && ret != -EPROBE_DEFER) |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 334 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |
| 335 | ret); |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 336 | |
Tushar Behera | c583883 | 2014-05-21 08:52:17 +0530 | [diff] [blame] | 337 | return ret; |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | static struct platform_driver speyside_driver = { |
| 341 | .driver = { |
| 342 | .name = "speyside", |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 343 | .pm = &snd_soc_pm_ops, |
| 344 | }, |
| 345 | .probe = speyside_probe, |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 346 | }; |
| 347 | |
Mark Brown | e00c3f5 | 2011-11-23 15:20:13 +0000 | [diff] [blame] | 348 | module_platform_driver(speyside_driver); |
Mark Brown | 9b8dc66 | 2011-04-12 17:24:39 -0700 | [diff] [blame] | 349 | |
| 350 | MODULE_DESCRIPTION("Speyside audio support"); |
| 351 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |
| 352 | MODULE_LICENSE("GPL"); |
| 353 | MODULE_ALIAS("platform:speyside"); |