Sylwester Nawrocki | 41ce2ac | 2019-04-19 12:21:37 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | // |
| 3 | // Bells audio support |
| 4 | // |
| 5 | // Copyright 2012 Wolfson Microelectronics |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 6 | |
| 7 | #include <sound/soc.h> |
| 8 | #include <sound/soc-dapm.h> |
| 9 | #include <sound/jack.h> |
| 10 | #include <linux/gpio.h> |
| 11 | #include <linux/module.h> |
| 12 | |
| 13 | #include "../codecs/wm5102.h" |
| 14 | #include "../codecs/wm9081.h" |
| 15 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 16 | /* BCLK2 is fixed at this currently */ |
| 17 | #define BCLK2_RATE (64 * 8000) |
| 18 | |
| 19 | /* |
| 20 | * Expect a 24.576MHz crystal if one is fitted (the driver will function |
| 21 | * if this is not fitted). |
| 22 | */ |
| 23 | #define MCLK_RATE 24576000 |
| 24 | |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 25 | #define SYS_AUDIO_RATE 44100 |
Dimitris Papastamos | 208229e | 2012-11-15 13:56:35 +0000 | [diff] [blame] | 26 | #define SYS_MCLK_RATE (SYS_AUDIO_RATE * 512) |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 27 | |
| 28 | #define DAI_AP_DSP 0 |
| 29 | #define DAI_DSP_CODEC 1 |
| 30 | #define DAI_CODEC_CP 2 |
| 31 | #define DAI_CODEC_SUB 3 |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 32 | |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 33 | struct bells_drvdata { |
| 34 | int sysclk_rate; |
| 35 | int asyncclk_rate; |
| 36 | }; |
| 37 | |
Mark Brown | 8d47e8a | 2012-10-02 18:43:49 +0100 | [diff] [blame] | 38 | static struct bells_drvdata wm2200_drvdata = { |
| 39 | .sysclk_rate = 22579200, |
| 40 | }; |
| 41 | |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 42 | static struct bells_drvdata wm5102_drvdata = { |
| 43 | .sysclk_rate = 45158400, |
| 44 | .asyncclk_rate = 49152000, |
| 45 | }; |
| 46 | |
| 47 | static struct bells_drvdata wm5110_drvdata = { |
| 48 | .sysclk_rate = 135475200, |
| 49 | .asyncclk_rate = 147456000, |
| 50 | }; |
| 51 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 52 | static int bells_set_bias_level(struct snd_soc_card *card, |
| 53 | struct snd_soc_dapm_context *dapm, |
| 54 | enum snd_soc_bias_level level) |
| 55 | { |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 56 | struct snd_soc_pcm_runtime *rtd; |
| 57 | struct snd_soc_dai *codec_dai; |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 58 | struct snd_soc_component *component; |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 59 | struct bells_drvdata *bells = card->drvdata; |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 60 | int ret; |
| 61 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 62 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 63 | codec_dai = asoc_rtd_to_codec(rtd, 0); |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 64 | component = codec_dai->component; |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 65 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 66 | if (dapm->dev != codec_dai->dev) |
| 67 | return 0; |
| 68 | |
| 69 | switch (level) { |
| 70 | case SND_SOC_BIAS_PREPARE: |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 71 | if (dapm->bias_level != SND_SOC_BIAS_STANDBY) |
| 72 | break; |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 73 | |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 74 | ret = snd_soc_component_set_pll(component, WM5102_FLL1, |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 75 | ARIZONA_FLL_SRC_MCLK1, |
| 76 | MCLK_RATE, |
| 77 | bells->sysclk_rate); |
| 78 | if (ret < 0) |
| 79 | pr_err("Failed to start FLL: %d\n", ret); |
| 80 | |
| 81 | if (bells->asyncclk_rate) { |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 82 | ret = snd_soc_component_set_pll(component, WM5102_FLL2, |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 83 | ARIZONA_FLL_SRC_AIF2BCLK, |
| 84 | BCLK2_RATE, |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 85 | bells->asyncclk_rate); |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 86 | if (ret < 0) |
| 87 | pr_err("Failed to start FLL: %d\n", ret); |
| 88 | } |
| 89 | break; |
| 90 | |
| 91 | default: |
| 92 | break; |
| 93 | } |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | static int bells_set_bias_level_post(struct snd_soc_card *card, |
| 99 | struct snd_soc_dapm_context *dapm, |
| 100 | enum snd_soc_bias_level level) |
| 101 | { |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 102 | struct snd_soc_pcm_runtime *rtd; |
| 103 | struct snd_soc_dai *codec_dai; |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 104 | struct snd_soc_component *component; |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 105 | struct bells_drvdata *bells = card->drvdata; |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 106 | int ret; |
| 107 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 108 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 109 | codec_dai = asoc_rtd_to_codec(rtd, 0); |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 110 | component = codec_dai->component; |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 111 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 112 | if (dapm->dev != codec_dai->dev) |
| 113 | return 0; |
| 114 | |
| 115 | switch (level) { |
| 116 | case SND_SOC_BIAS_STANDBY: |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 117 | ret = snd_soc_component_set_pll(component, WM5102_FLL1, 0, 0, 0); |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 118 | if (ret < 0) { |
| 119 | pr_err("Failed to stop FLL: %d\n", ret); |
| 120 | return ret; |
| 121 | } |
| 122 | |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 123 | if (bells->asyncclk_rate) { |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 124 | ret = snd_soc_component_set_pll(component, WM5102_FLL2, |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 125 | 0, 0, 0); |
| 126 | if (ret < 0) { |
| 127 | pr_err("Failed to stop FLL: %d\n", ret); |
| 128 | return ret; |
| 129 | } |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 130 | } |
| 131 | break; |
| 132 | |
| 133 | default: |
| 134 | break; |
| 135 | } |
| 136 | |
| 137 | dapm->bias_level = level; |
| 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | static int bells_late_probe(struct snd_soc_card *card) |
| 143 | { |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 144 | struct bells_drvdata *bells = card->drvdata; |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 145 | struct snd_soc_pcm_runtime *rtd; |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 146 | struct snd_soc_component *wm0010; |
| 147 | struct snd_soc_component *component; |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 148 | struct snd_soc_dai *aif1_dai; |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 149 | struct snd_soc_dai *aif2_dai; |
| 150 | struct snd_soc_dai *aif3_dai; |
| 151 | struct snd_soc_dai *wm9081_dai; |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 152 | int ret; |
| 153 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 154 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_AP_DSP]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 155 | wm0010 = asoc_rtd_to_codec(rtd, 0)->component; |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 156 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 157 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 158 | component = asoc_rtd_to_codec(rtd, 0)->component; |
| 159 | aif1_dai = asoc_rtd_to_codec(rtd, 0); |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 160 | |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 161 | ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_SYSCLK, |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 162 | ARIZONA_CLK_SRC_FLL1, |
| 163 | bells->sysclk_rate, |
| 164 | SND_SOC_CLOCK_IN); |
| 165 | if (ret != 0) { |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 166 | dev_err(component->dev, "Failed to set SYSCLK: %d\n", ret); |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 167 | return ret; |
| 168 | } |
| 169 | |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 170 | ret = snd_soc_component_set_sysclk(wm0010, 0, 0, SYS_MCLK_RATE, 0); |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 171 | if (ret != 0) { |
| 172 | dev_err(wm0010->dev, "Failed to set WM0010 clock: %d\n", ret); |
| 173 | return ret; |
| 174 | } |
| 175 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 176 | ret = snd_soc_dai_set_sysclk(aif1_dai, ARIZONA_CLK_SYSCLK, 0, 0); |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 177 | if (ret != 0) |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 178 | dev_err(aif1_dai->dev, "Failed to set AIF1 clock: %d\n", ret); |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 179 | |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 180 | ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_OPCLK, 0, |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 181 | SYS_MCLK_RATE, SND_SOC_CLOCK_OUT); |
| 182 | if (ret != 0) |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 183 | dev_err(component->dev, "Failed to set OPCLK: %d\n", ret); |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 184 | |
| 185 | if (card->num_rtd == DAI_CODEC_CP) |
| 186 | return 0; |
| 187 | |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 188 | ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_ASYNCCLK, |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 189 | ARIZONA_CLK_SRC_FLL2, |
| 190 | bells->asyncclk_rate, |
| 191 | SND_SOC_CLOCK_IN); |
| 192 | if (ret != 0) { |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 193 | dev_err(component->dev, "Failed to set ASYNCCLK: %d\n", ret); |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 194 | return ret; |
| 195 | } |
| 196 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 197 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_CP]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 198 | aif2_dai = asoc_rtd_to_cpu(rtd, 0); |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 199 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 200 | ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0); |
| 201 | if (ret != 0) { |
| 202 | dev_err(aif2_dai->dev, "Failed to set AIF2 clock: %d\n", ret); |
| 203 | return ret; |
| 204 | } |
| 205 | |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 206 | if (card->num_rtd == DAI_CODEC_SUB) |
| 207 | return 0; |
| 208 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 209 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_SUB]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 210 | aif3_dai = asoc_rtd_to_cpu(rtd, 0); |
| 211 | wm9081_dai = asoc_rtd_to_codec(rtd, 0); |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 212 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 213 | ret = snd_soc_dai_set_sysclk(aif3_dai, ARIZONA_CLK_SYSCLK, 0, 0); |
| 214 | if (ret != 0) { |
| 215 | dev_err(aif1_dai->dev, "Failed to set AIF1 clock: %d\n", ret); |
| 216 | return ret; |
| 217 | } |
| 218 | |
Kuninori Morimoto | f4a2be1 | 2017-12-05 04:24:28 +0000 | [diff] [blame] | 219 | ret = snd_soc_component_set_sysclk(wm9081_dai->component, WM9081_SYSCLK_MCLK, |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 220 | 0, SYS_MCLK_RATE, 0); |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 221 | if (ret != 0) { |
| 222 | dev_err(wm9081_dai->dev, "Failed to set MCLK: %d\n", ret); |
| 223 | return ret; |
| 224 | } |
| 225 | |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | static const struct snd_soc_pcm_stream baseband_params = { |
| 230 | .formats = SNDRV_PCM_FMTBIT_S32_LE, |
| 231 | .rate_min = 8000, |
| 232 | .rate_max = 8000, |
| 233 | .channels_min = 2, |
| 234 | .channels_max = 2, |
| 235 | }; |
| 236 | |
| 237 | static const struct snd_soc_pcm_stream sub_params = { |
| 238 | .formats = SNDRV_PCM_FMTBIT_S32_LE, |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 239 | .rate_min = SYS_AUDIO_RATE, |
| 240 | .rate_max = SYS_AUDIO_RATE, |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 241 | .channels_min = 2, |
| 242 | .channels_max = 2, |
| 243 | }; |
| 244 | |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 245 | SND_SOC_DAILINK_DEFS(wm2200_cpu_dsp, |
| 246 | DAILINK_COMP_ARRAY(COMP_CPU("samsung-i2s.0")), |
| 247 | DAILINK_COMP_ARRAY(COMP_CODEC("spi0.0", "wm0010-sdi1")), |
| 248 | DAILINK_COMP_ARRAY(COMP_PLATFORM("samsung-i2s.0"))); |
| 249 | |
| 250 | SND_SOC_DAILINK_DEFS(wm2200_dsp_codec, |
| 251 | DAILINK_COMP_ARRAY(COMP_CPU("wm0010-sdi2")), |
| 252 | DAILINK_COMP_ARRAY(COMP_CODEC("wm2200.1-003a", "wm2200"))); |
| 253 | |
Mark Brown | 8d47e8a | 2012-10-02 18:43:49 +0100 | [diff] [blame] | 254 | static struct snd_soc_dai_link bells_dai_wm2200[] = { |
| 255 | { |
| 256 | .name = "CPU-DSP", |
| 257 | .stream_name = "CPU-DSP", |
Mark Brown | 8d47e8a | 2012-10-02 18:43:49 +0100 | [diff] [blame] | 258 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 259 | | SND_SOC_DAIFMT_CBM_CFM, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 260 | SND_SOC_DAILINK_REG(wm2200_cpu_dsp), |
Mark Brown | 8d47e8a | 2012-10-02 18:43:49 +0100 | [diff] [blame] | 261 | }, |
| 262 | { |
| 263 | .name = "DSP-CODEC", |
| 264 | .stream_name = "DSP-CODEC", |
Mark Brown | 8d47e8a | 2012-10-02 18:43:49 +0100 | [diff] [blame] | 265 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 266 | | SND_SOC_DAIFMT_CBM_CFM, |
| 267 | .params = &sub_params, |
| 268 | .ignore_suspend = 1, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 269 | SND_SOC_DAILINK_REG(wm2200_dsp_codec), |
Mark Brown | 8d47e8a | 2012-10-02 18:43:49 +0100 | [diff] [blame] | 270 | }, |
| 271 | }; |
| 272 | |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 273 | SND_SOC_DAILINK_DEFS(wm5102_cpu_dsp, |
| 274 | DAILINK_COMP_ARRAY(COMP_CPU("samsung-i2s.0")), |
| 275 | DAILINK_COMP_ARRAY(COMP_CODEC("spi0.0", "wm0010-sdi1")), |
| 276 | DAILINK_COMP_ARRAY(COMP_PLATFORM("samsung-i2s.0"))); |
| 277 | |
| 278 | SND_SOC_DAILINK_DEFS(wm5102_dsp_codec, |
| 279 | DAILINK_COMP_ARRAY(COMP_CPU("wm0010-sdi2")), |
| 280 | DAILINK_COMP_ARRAY(COMP_CODEC("wm5102-codec", "wm5102-aif1"))); |
| 281 | |
| 282 | SND_SOC_DAILINK_DEFS(wm5102_baseband, |
| 283 | DAILINK_COMP_ARRAY(COMP_CPU("wm5102-aif2")), |
| 284 | DAILINK_COMP_ARRAY(COMP_CODEC("wm1250-ev1.1-0027", "wm1250-ev1"))); |
| 285 | |
| 286 | SND_SOC_DAILINK_DEFS(wm5102_sub, |
| 287 | DAILINK_COMP_ARRAY(COMP_CPU("wm5102-aif3")), |
| 288 | DAILINK_COMP_ARRAY(COMP_CODEC("wm9081.1-006c", "wm9081-hifi"))); |
| 289 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 290 | static struct snd_soc_dai_link bells_dai_wm5102[] = { |
| 291 | { |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 292 | .name = "CPU-DSP", |
| 293 | .stream_name = "CPU-DSP", |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 294 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 295 | | SND_SOC_DAIFMT_CBM_CFM, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 296 | SND_SOC_DAILINK_REG(wm5102_cpu_dsp), |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 297 | }, |
| 298 | { |
| 299 | .name = "DSP-CODEC", |
| 300 | .stream_name = "DSP-CODEC", |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 301 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 302 | | SND_SOC_DAIFMT_CBM_CFM, |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 303 | .params = &sub_params, |
| 304 | .ignore_suspend = 1, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 305 | SND_SOC_DAILINK_REG(wm5102_dsp_codec), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 306 | }, |
| 307 | { |
| 308 | .name = "Baseband", |
| 309 | .stream_name = "Baseband", |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 310 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 311 | | SND_SOC_DAIFMT_CBM_CFM, |
| 312 | .ignore_suspend = 1, |
| 313 | .params = &baseband_params, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 314 | SND_SOC_DAILINK_REG(wm5102_baseband), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 315 | }, |
| 316 | { |
| 317 | .name = "Sub", |
| 318 | .stream_name = "Sub", |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 319 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 320 | | SND_SOC_DAIFMT_CBS_CFS, |
| 321 | .ignore_suspend = 1, |
| 322 | .params = &sub_params, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 323 | SND_SOC_DAILINK_REG(wm5102_sub), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 324 | }, |
| 325 | }; |
| 326 | |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 327 | SND_SOC_DAILINK_DEFS(wm5110_cpu_dsp, |
| 328 | DAILINK_COMP_ARRAY(COMP_CPU("samsung-i2s.0")), |
| 329 | DAILINK_COMP_ARRAY(COMP_CODEC("spi0.0", "wm0010-sdi1")), |
| 330 | DAILINK_COMP_ARRAY(COMP_PLATFORM("samsung-i2s.0"))); |
| 331 | |
| 332 | SND_SOC_DAILINK_DEFS(wm5110_dsp_codec, |
| 333 | DAILINK_COMP_ARRAY(COMP_CPU("wm0010-sdi2")), |
| 334 | DAILINK_COMP_ARRAY(COMP_CODEC("wm5110-codec", "wm5110-aif1"))); |
| 335 | |
| 336 | SND_SOC_DAILINK_DEFS(wm5110_baseband, |
| 337 | DAILINK_COMP_ARRAY(COMP_CPU("wm5110-aif2")), |
| 338 | DAILINK_COMP_ARRAY(COMP_CODEC("wm1250-ev1.1-0027", "wm1250-ev1"))); |
| 339 | |
| 340 | |
| 341 | SND_SOC_DAILINK_DEFS(wm5110_sub, |
| 342 | DAILINK_COMP_ARRAY(COMP_CPU("wm5110-aif3")), |
| 343 | DAILINK_COMP_ARRAY(COMP_CODEC("wm9081.1-006c", "wm9081-hifi"))); |
| 344 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 345 | static struct snd_soc_dai_link bells_dai_wm5110[] = { |
| 346 | { |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 347 | .name = "CPU-DSP", |
| 348 | .stream_name = "CPU-DSP", |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 349 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 350 | | SND_SOC_DAIFMT_CBM_CFM, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 351 | SND_SOC_DAILINK_REG(wm5110_cpu_dsp), |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 352 | }, |
| 353 | { |
| 354 | .name = "DSP-CODEC", |
| 355 | .stream_name = "DSP-CODEC", |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 356 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 357 | | SND_SOC_DAIFMT_CBM_CFM, |
Mark Brown | 344c5ed | 2012-09-25 21:24:30 +0100 | [diff] [blame] | 358 | .params = &sub_params, |
| 359 | .ignore_suspend = 1, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 360 | SND_SOC_DAILINK_REG(wm5110_dsp_codec), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 361 | }, |
| 362 | { |
| 363 | .name = "Baseband", |
| 364 | .stream_name = "Baseband", |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 365 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 366 | | SND_SOC_DAIFMT_CBM_CFM, |
| 367 | .ignore_suspend = 1, |
| 368 | .params = &baseband_params, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 369 | SND_SOC_DAILINK_REG(wm5110_baseband), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 370 | }, |
| 371 | { |
| 372 | .name = "Sub", |
| 373 | .stream_name = "Sub", |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 374 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 375 | | SND_SOC_DAIFMT_CBS_CFS, |
| 376 | .ignore_suspend = 1, |
| 377 | .params = &sub_params, |
Kuninori Morimoto | 5af5e76 | 2019-06-06 13:08:55 +0900 | [diff] [blame] | 378 | SND_SOC_DAILINK_REG(wm5110_sub), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 379 | }, |
| 380 | }; |
| 381 | |
| 382 | static struct snd_soc_codec_conf bells_codec_conf[] = { |
| 383 | { |
Kuninori Morimoto | 3874b21 | 2019-12-13 09:55:30 +0900 | [diff] [blame] | 384 | .dlc = COMP_CODEC_CONF("wm9081.1-006c"), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 385 | .name_prefix = "Sub", |
| 386 | }, |
| 387 | }; |
| 388 | |
Charles Keepax | 939d3c6 | 2013-05-27 09:46:53 +0100 | [diff] [blame] | 389 | static struct snd_soc_dapm_widget bells_widgets[] = { |
| 390 | SND_SOC_DAPM_MIC("DMIC", NULL), |
| 391 | }; |
| 392 | |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 393 | static struct snd_soc_dapm_route bells_routes[] = { |
| 394 | { "Sub CLK_SYS", NULL, "OPCLK" }, |
Charles Keepax | b3a6006 | 2013-09-16 15:38:15 +0100 | [diff] [blame] | 395 | { "CLKIN", NULL, "OPCLK" }, |
Charles Keepax | 939d3c6 | 2013-05-27 09:46:53 +0100 | [diff] [blame] | 396 | |
| 397 | { "DMIC", NULL, "MICBIAS2" }, |
| 398 | { "IN2L", NULL, "DMIC" }, |
| 399 | { "IN2R", NULL, "DMIC" }, |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 400 | }; |
| 401 | |
| 402 | static struct snd_soc_card bells_cards[] = { |
| 403 | { |
Mark Brown | 8d47e8a | 2012-10-02 18:43:49 +0100 | [diff] [blame] | 404 | .name = "Bells WM2200", |
| 405 | .owner = THIS_MODULE, |
| 406 | .dai_link = bells_dai_wm2200, |
| 407 | .num_links = ARRAY_SIZE(bells_dai_wm2200), |
| 408 | .codec_conf = bells_codec_conf, |
| 409 | .num_configs = ARRAY_SIZE(bells_codec_conf), |
| 410 | |
| 411 | .late_probe = bells_late_probe, |
| 412 | |
Charles Keepax | 939d3c6 | 2013-05-27 09:46:53 +0100 | [diff] [blame] | 413 | .dapm_widgets = bells_widgets, |
| 414 | .num_dapm_widgets = ARRAY_SIZE(bells_widgets), |
Mark Brown | 8d47e8a | 2012-10-02 18:43:49 +0100 | [diff] [blame] | 415 | .dapm_routes = bells_routes, |
| 416 | .num_dapm_routes = ARRAY_SIZE(bells_routes), |
| 417 | |
| 418 | .set_bias_level = bells_set_bias_level, |
| 419 | .set_bias_level_post = bells_set_bias_level_post, |
| 420 | |
| 421 | .drvdata = &wm2200_drvdata, |
| 422 | }, |
| 423 | { |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 424 | .name = "Bells WM5102", |
| 425 | .owner = THIS_MODULE, |
| 426 | .dai_link = bells_dai_wm5102, |
| 427 | .num_links = ARRAY_SIZE(bells_dai_wm5102), |
| 428 | .codec_conf = bells_codec_conf, |
| 429 | .num_configs = ARRAY_SIZE(bells_codec_conf), |
| 430 | |
| 431 | .late_probe = bells_late_probe, |
| 432 | |
Charles Keepax | 939d3c6 | 2013-05-27 09:46:53 +0100 | [diff] [blame] | 433 | .dapm_widgets = bells_widgets, |
| 434 | .num_dapm_widgets = ARRAY_SIZE(bells_widgets), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 435 | .dapm_routes = bells_routes, |
| 436 | .num_dapm_routes = ARRAY_SIZE(bells_routes), |
| 437 | |
| 438 | .set_bias_level = bells_set_bias_level, |
| 439 | .set_bias_level_post = bells_set_bias_level_post, |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 440 | |
| 441 | .drvdata = &wm5102_drvdata, |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 442 | }, |
| 443 | { |
| 444 | .name = "Bells WM5110", |
| 445 | .owner = THIS_MODULE, |
| 446 | .dai_link = bells_dai_wm5110, |
| 447 | .num_links = ARRAY_SIZE(bells_dai_wm5110), |
| 448 | .codec_conf = bells_codec_conf, |
| 449 | .num_configs = ARRAY_SIZE(bells_codec_conf), |
| 450 | |
| 451 | .late_probe = bells_late_probe, |
| 452 | |
Charles Keepax | 939d3c6 | 2013-05-27 09:46:53 +0100 | [diff] [blame] | 453 | .dapm_widgets = bells_widgets, |
| 454 | .num_dapm_widgets = ARRAY_SIZE(bells_widgets), |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 455 | .dapm_routes = bells_routes, |
| 456 | .num_dapm_routes = ARRAY_SIZE(bells_routes), |
| 457 | |
| 458 | .set_bias_level = bells_set_bias_level, |
| 459 | .set_bias_level_post = bells_set_bias_level_post, |
Mark Brown | b138707 | 2012-10-02 15:47:44 +0100 | [diff] [blame] | 460 | |
| 461 | .drvdata = &wm5110_drvdata, |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 462 | }, |
| 463 | }; |
| 464 | |
Bill Pemberton | fdca21a | 2012-12-07 09:26:15 -0500 | [diff] [blame] | 465 | static int bells_probe(struct platform_device *pdev) |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 466 | { |
| 467 | int ret; |
| 468 | |
| 469 | bells_cards[pdev->id].dev = &pdev->dev; |
| 470 | |
Tushar Behera | c583883 | 2014-05-21 08:52:17 +0530 | [diff] [blame] | 471 | ret = devm_snd_soc_register_card(&pdev->dev, &bells_cards[pdev->id]); |
| 472 | if (ret) |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 473 | dev_err(&pdev->dev, |
| 474 | "snd_soc_register_card(%s) failed: %d\n", |
| 475 | bells_cards[pdev->id].name, ret); |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 476 | |
Tushar Behera | c583883 | 2014-05-21 08:52:17 +0530 | [diff] [blame] | 477 | return ret; |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | static struct platform_driver bells_driver = { |
| 481 | .driver = { |
| 482 | .name = "bells", |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 483 | .pm = &snd_soc_pm_ops, |
| 484 | }, |
| 485 | .probe = bells_probe, |
Mark Brown | b545dd9 | 2012-08-07 20:03:02 +0100 | [diff] [blame] | 486 | }; |
| 487 | |
| 488 | module_platform_driver(bells_driver); |
| 489 | |
| 490 | MODULE_DESCRIPTION("Bells audio support"); |
| 491 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |
| 492 | MODULE_LICENSE("GPL"); |
| 493 | MODULE_ALIAS("platform:bells"); |