blob: 8b83f39c3ac918a660c8ca0522295f7f55112476 [file] [log] [blame]
Sylwester Nawrocki41ce2ac2019-04-19 12:21:37 +02001// SPDX-License-Identifier: GPL-2.0+
2//
3// Bells audio support
4//
5// Copyright 2012 Wolfson Microelectronics
Mark Brownb545dd92012-08-07 20:03:02 +01006
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 Brownb545dd92012-08-07 20:03:02 +010016/* 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 Brown344c5ed2012-09-25 21:24:30 +010025#define SYS_AUDIO_RATE 44100
Dimitris Papastamos208229e2012-11-15 13:56:35 +000026#define SYS_MCLK_RATE (SYS_AUDIO_RATE * 512)
Mark Brown344c5ed2012-09-25 21:24:30 +010027
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 Brownb545dd92012-08-07 20:03:02 +010032
Mark Brownb1387072012-10-02 15:47:44 +010033struct bells_drvdata {
34 int sysclk_rate;
35 int asyncclk_rate;
36};
37
Mark Brown8d47e8a2012-10-02 18:43:49 +010038static struct bells_drvdata wm2200_drvdata = {
39 .sysclk_rate = 22579200,
40};
41
Mark Brownb1387072012-10-02 15:47:44 +010042static struct bells_drvdata wm5102_drvdata = {
43 .sysclk_rate = 45158400,
44 .asyncclk_rate = 49152000,
45};
46
47static struct bells_drvdata wm5110_drvdata = {
48 .sysclk_rate = 135475200,
49 .asyncclk_rate = 147456000,
50};
51
Mark Brownb545dd92012-08-07 20:03:02 +010052static 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 Lin50159202015-11-18 02:34:01 -050056 struct snd_soc_pcm_runtime *rtd;
57 struct snd_soc_dai *codec_dai;
Kuninori Morimotof4a2be12017-12-05 04:24:28 +000058 struct snd_soc_component *component;
Mark Brownb1387072012-10-02 15:47:44 +010059 struct bells_drvdata *bells = card->drvdata;
Mark Brownb545dd92012-08-07 20:03:02 +010060 int ret;
61
Kuninori Morimoto44681892019-12-10 09:34:08 +090062 rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]);
Kuninori Morimoto7de6b6b2020-03-23 14:20:20 +090063 codec_dai = asoc_rtd_to_codec(rtd, 0);
Kuninori Morimotof4a2be12017-12-05 04:24:28 +000064 component = codec_dai->component;
Mengdong Lin50159202015-11-18 02:34:01 -050065
Mark Brownb545dd92012-08-07 20:03:02 +010066 if (dapm->dev != codec_dai->dev)
67 return 0;
68
69 switch (level) {
70 case SND_SOC_BIAS_PREPARE:
Mark Brownb1387072012-10-02 15:47:44 +010071 if (dapm->bias_level != SND_SOC_BIAS_STANDBY)
72 break;
Mark Brownb545dd92012-08-07 20:03:02 +010073
Kuninori Morimotof4a2be12017-12-05 04:24:28 +000074 ret = snd_soc_component_set_pll(component, WM5102_FLL1,
Mark Brownb1387072012-10-02 15:47:44 +010075 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 Morimotof4a2be12017-12-05 04:24:28 +000082 ret = snd_soc_component_set_pll(component, WM5102_FLL2,
Mark Brownb545dd92012-08-07 20:03:02 +010083 ARIZONA_FLL_SRC_AIF2BCLK,
84 BCLK2_RATE,
Mark Brownb1387072012-10-02 15:47:44 +010085 bells->asyncclk_rate);
Mark Brownb545dd92012-08-07 20:03:02 +010086 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
98static 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 Lin50159202015-11-18 02:34:01 -0500102 struct snd_soc_pcm_runtime *rtd;
103 struct snd_soc_dai *codec_dai;
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000104 struct snd_soc_component *component;
Mark Brownb1387072012-10-02 15:47:44 +0100105 struct bells_drvdata *bells = card->drvdata;
Mark Brownb545dd92012-08-07 20:03:02 +0100106 int ret;
107
Kuninori Morimoto44681892019-12-10 09:34:08 +0900108 rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]);
Kuninori Morimoto7de6b6b2020-03-23 14:20:20 +0900109 codec_dai = asoc_rtd_to_codec(rtd, 0);
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000110 component = codec_dai->component;
Mengdong Lin50159202015-11-18 02:34:01 -0500111
Mark Brownb545dd92012-08-07 20:03:02 +0100112 if (dapm->dev != codec_dai->dev)
113 return 0;
114
115 switch (level) {
116 case SND_SOC_BIAS_STANDBY:
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000117 ret = snd_soc_component_set_pll(component, WM5102_FLL1, 0, 0, 0);
Mark Brownb545dd92012-08-07 20:03:02 +0100118 if (ret < 0) {
119 pr_err("Failed to stop FLL: %d\n", ret);
120 return ret;
121 }
122
Mark Brownb1387072012-10-02 15:47:44 +0100123 if (bells->asyncclk_rate) {
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000124 ret = snd_soc_component_set_pll(component, WM5102_FLL2,
Mark Brownb1387072012-10-02 15:47:44 +0100125 0, 0, 0);
126 if (ret < 0) {
127 pr_err("Failed to stop FLL: %d\n", ret);
128 return ret;
129 }
Mark Brownb545dd92012-08-07 20:03:02 +0100130 }
131 break;
132
133 default:
134 break;
135 }
136
137 dapm->bias_level = level;
138
139 return 0;
140}
141
142static int bells_late_probe(struct snd_soc_card *card)
143{
Mark Brownb1387072012-10-02 15:47:44 +0100144 struct bells_drvdata *bells = card->drvdata;
Mengdong Lin50159202015-11-18 02:34:01 -0500145 struct snd_soc_pcm_runtime *rtd;
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000146 struct snd_soc_component *wm0010;
147 struct snd_soc_component *component;
Mengdong Lin50159202015-11-18 02:34:01 -0500148 struct snd_soc_dai *aif1_dai;
Mark Brownb1387072012-10-02 15:47:44 +0100149 struct snd_soc_dai *aif2_dai;
150 struct snd_soc_dai *aif3_dai;
151 struct snd_soc_dai *wm9081_dai;
Mark Brownb545dd92012-08-07 20:03:02 +0100152 int ret;
153
Kuninori Morimoto44681892019-12-10 09:34:08 +0900154 rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_AP_DSP]);
Kuninori Morimoto7de6b6b2020-03-23 14:20:20 +0900155 wm0010 = asoc_rtd_to_codec(rtd, 0)->component;
Mengdong Lin50159202015-11-18 02:34:01 -0500156
Kuninori Morimoto44681892019-12-10 09:34:08 +0900157 rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]);
Kuninori Morimoto7de6b6b2020-03-23 14:20:20 +0900158 component = asoc_rtd_to_codec(rtd, 0)->component;
159 aif1_dai = asoc_rtd_to_codec(rtd, 0);
Mengdong Lin50159202015-11-18 02:34:01 -0500160
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000161 ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_SYSCLK,
Mark Brownb1387072012-10-02 15:47:44 +0100162 ARIZONA_CLK_SRC_FLL1,
163 bells->sysclk_rate,
164 SND_SOC_CLOCK_IN);
165 if (ret != 0) {
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000166 dev_err(component->dev, "Failed to set SYSCLK: %d\n", ret);
Mark Brownb1387072012-10-02 15:47:44 +0100167 return ret;
168 }
169
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000170 ret = snd_soc_component_set_sysclk(wm0010, 0, 0, SYS_MCLK_RATE, 0);
Mark Brown344c5ed2012-09-25 21:24:30 +0100171 if (ret != 0) {
172 dev_err(wm0010->dev, "Failed to set WM0010 clock: %d\n", ret);
173 return ret;
174 }
175
Mark Brownb545dd92012-08-07 20:03:02 +0100176 ret = snd_soc_dai_set_sysclk(aif1_dai, ARIZONA_CLK_SYSCLK, 0, 0);
Mark Brownb1387072012-10-02 15:47:44 +0100177 if (ret != 0)
Mark Brownb545dd92012-08-07 20:03:02 +0100178 dev_err(aif1_dai->dev, "Failed to set AIF1 clock: %d\n", ret);
Mark Brownb1387072012-10-02 15:47:44 +0100179
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000180 ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_OPCLK, 0,
Mark Brownb1387072012-10-02 15:47:44 +0100181 SYS_MCLK_RATE, SND_SOC_CLOCK_OUT);
182 if (ret != 0)
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000183 dev_err(component->dev, "Failed to set OPCLK: %d\n", ret);
Mark Brownb1387072012-10-02 15:47:44 +0100184
185 if (card->num_rtd == DAI_CODEC_CP)
186 return 0;
187
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000188 ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_ASYNCCLK,
Mark Brownb1387072012-10-02 15:47:44 +0100189 ARIZONA_CLK_SRC_FLL2,
190 bells->asyncclk_rate,
191 SND_SOC_CLOCK_IN);
192 if (ret != 0) {
Kuninori Morimotof4a2be12017-12-05 04:24:28 +0000193 dev_err(component->dev, "Failed to set ASYNCCLK: %d\n", ret);
Mark Brownb545dd92012-08-07 20:03:02 +0100194 return ret;
195 }
196
Kuninori Morimoto44681892019-12-10 09:34:08 +0900197 rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_CP]);
Kuninori Morimoto7de6b6b2020-03-23 14:20:20 +0900198 aif2_dai = asoc_rtd_to_cpu(rtd, 0);
Mark Brownb1387072012-10-02 15:47:44 +0100199
Mark Brownb545dd92012-08-07 20:03:02 +0100200 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 Brownb1387072012-10-02 15:47:44 +0100206 if (card->num_rtd == DAI_CODEC_SUB)
207 return 0;
208
Kuninori Morimoto44681892019-12-10 09:34:08 +0900209 rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_SUB]);
Kuninori Morimoto7de6b6b2020-03-23 14:20:20 +0900210 aif3_dai = asoc_rtd_to_cpu(rtd, 0);
211 wm9081_dai = asoc_rtd_to_codec(rtd, 0);
Mark Brownb1387072012-10-02 15:47:44 +0100212
Mark Brownb545dd92012-08-07 20:03:02 +0100213 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 Morimotof4a2be12017-12-05 04:24:28 +0000219 ret = snd_soc_component_set_sysclk(wm9081_dai->component, WM9081_SYSCLK_MCLK,
Mark Brown344c5ed2012-09-25 21:24:30 +0100220 0, SYS_MCLK_RATE, 0);
Mark Brownb545dd92012-08-07 20:03:02 +0100221 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
229static 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
237static const struct snd_soc_pcm_stream sub_params = {
238 .formats = SNDRV_PCM_FMTBIT_S32_LE,
Mark Brown344c5ed2012-09-25 21:24:30 +0100239 .rate_min = SYS_AUDIO_RATE,
240 .rate_max = SYS_AUDIO_RATE,
Mark Brownb545dd92012-08-07 20:03:02 +0100241 .channels_min = 2,
242 .channels_max = 2,
243};
244
Kuninori Morimoto5af5e762019-06-06 13:08:55 +0900245SND_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
250SND_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 Brown8d47e8a2012-10-02 18:43:49 +0100254static struct snd_soc_dai_link bells_dai_wm2200[] = {
255 {
256 .name = "CPU-DSP",
257 .stream_name = "CPU-DSP",
Mark Brown8d47e8a2012-10-02 18:43:49 +0100258 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
259 | SND_SOC_DAIFMT_CBM_CFM,
Kuninori Morimoto5af5e762019-06-06 13:08:55 +0900260 SND_SOC_DAILINK_REG(wm2200_cpu_dsp),
Mark Brown8d47e8a2012-10-02 18:43:49 +0100261 },
262 {
263 .name = "DSP-CODEC",
264 .stream_name = "DSP-CODEC",
Mark Brown8d47e8a2012-10-02 18:43:49 +0100265 .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 Morimoto5af5e762019-06-06 13:08:55 +0900269 SND_SOC_DAILINK_REG(wm2200_dsp_codec),
Mark Brown8d47e8a2012-10-02 18:43:49 +0100270 },
271};
272
Kuninori Morimoto5af5e762019-06-06 13:08:55 +0900273SND_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
278SND_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
282SND_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
286SND_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 Brownb545dd92012-08-07 20:03:02 +0100290static struct snd_soc_dai_link bells_dai_wm5102[] = {
291 {
Mark Brown344c5ed2012-09-25 21:24:30 +0100292 .name = "CPU-DSP",
293 .stream_name = "CPU-DSP",
Mark Brown344c5ed2012-09-25 21:24:30 +0100294 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
295 | SND_SOC_DAIFMT_CBM_CFM,
Kuninori Morimoto5af5e762019-06-06 13:08:55 +0900296 SND_SOC_DAILINK_REG(wm5102_cpu_dsp),
Mark Brown344c5ed2012-09-25 21:24:30 +0100297 },
298 {
299 .name = "DSP-CODEC",
300 .stream_name = "DSP-CODEC",
Mark Brownb545dd92012-08-07 20:03:02 +0100301 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
302 | SND_SOC_DAIFMT_CBM_CFM,
Mark Brown344c5ed2012-09-25 21:24:30 +0100303 .params = &sub_params,
304 .ignore_suspend = 1,
Kuninori Morimoto5af5e762019-06-06 13:08:55 +0900305 SND_SOC_DAILINK_REG(wm5102_dsp_codec),
Mark Brownb545dd92012-08-07 20:03:02 +0100306 },
307 {
308 .name = "Baseband",
309 .stream_name = "Baseband",
Mark Brownb545dd92012-08-07 20:03:02 +0100310 .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 Morimoto5af5e762019-06-06 13:08:55 +0900314 SND_SOC_DAILINK_REG(wm5102_baseband),
Mark Brownb545dd92012-08-07 20:03:02 +0100315 },
316 {
317 .name = "Sub",
318 .stream_name = "Sub",
Mark Brownb545dd92012-08-07 20:03:02 +0100319 .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 Morimoto5af5e762019-06-06 13:08:55 +0900323 SND_SOC_DAILINK_REG(wm5102_sub),
Mark Brownb545dd92012-08-07 20:03:02 +0100324 },
325};
326
Kuninori Morimoto5af5e762019-06-06 13:08:55 +0900327SND_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
332SND_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
336SND_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
341SND_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 Brownb545dd92012-08-07 20:03:02 +0100345static struct snd_soc_dai_link bells_dai_wm5110[] = {
346 {
Mark Brown344c5ed2012-09-25 21:24:30 +0100347 .name = "CPU-DSP",
348 .stream_name = "CPU-DSP",
Mark Brown344c5ed2012-09-25 21:24:30 +0100349 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
350 | SND_SOC_DAIFMT_CBM_CFM,
Kuninori Morimoto5af5e762019-06-06 13:08:55 +0900351 SND_SOC_DAILINK_REG(wm5110_cpu_dsp),
Mark Brown344c5ed2012-09-25 21:24:30 +0100352 },
353 {
354 .name = "DSP-CODEC",
355 .stream_name = "DSP-CODEC",
Mark Brownb545dd92012-08-07 20:03:02 +0100356 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
357 | SND_SOC_DAIFMT_CBM_CFM,
Mark Brown344c5ed2012-09-25 21:24:30 +0100358 .params = &sub_params,
359 .ignore_suspend = 1,
Kuninori Morimoto5af5e762019-06-06 13:08:55 +0900360 SND_SOC_DAILINK_REG(wm5110_dsp_codec),
Mark Brownb545dd92012-08-07 20:03:02 +0100361 },
362 {
363 .name = "Baseband",
364 .stream_name = "Baseband",
Mark Brownb545dd92012-08-07 20:03:02 +0100365 .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 Morimoto5af5e762019-06-06 13:08:55 +0900369 SND_SOC_DAILINK_REG(wm5110_baseband),
Mark Brownb545dd92012-08-07 20:03:02 +0100370 },
371 {
372 .name = "Sub",
373 .stream_name = "Sub",
Mark Brownb545dd92012-08-07 20:03:02 +0100374 .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 Morimoto5af5e762019-06-06 13:08:55 +0900378 SND_SOC_DAILINK_REG(wm5110_sub),
Mark Brownb545dd92012-08-07 20:03:02 +0100379 },
380};
381
382static struct snd_soc_codec_conf bells_codec_conf[] = {
383 {
Kuninori Morimoto3874b212019-12-13 09:55:30 +0900384 .dlc = COMP_CODEC_CONF("wm9081.1-006c"),
Mark Brownb545dd92012-08-07 20:03:02 +0100385 .name_prefix = "Sub",
386 },
387};
388
Charles Keepax939d3c62013-05-27 09:46:53 +0100389static struct snd_soc_dapm_widget bells_widgets[] = {
390 SND_SOC_DAPM_MIC("DMIC", NULL),
391};
392
Mark Brownb545dd92012-08-07 20:03:02 +0100393static struct snd_soc_dapm_route bells_routes[] = {
394 { "Sub CLK_SYS", NULL, "OPCLK" },
Charles Keepaxb3a60062013-09-16 15:38:15 +0100395 { "CLKIN", NULL, "OPCLK" },
Charles Keepax939d3c62013-05-27 09:46:53 +0100396
397 { "DMIC", NULL, "MICBIAS2" },
398 { "IN2L", NULL, "DMIC" },
399 { "IN2R", NULL, "DMIC" },
Mark Brownb545dd92012-08-07 20:03:02 +0100400};
401
402static struct snd_soc_card bells_cards[] = {
403 {
Mark Brown8d47e8a2012-10-02 18:43:49 +0100404 .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 Keepax939d3c62013-05-27 09:46:53 +0100413 .dapm_widgets = bells_widgets,
414 .num_dapm_widgets = ARRAY_SIZE(bells_widgets),
Mark Brown8d47e8a2012-10-02 18:43:49 +0100415 .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 Brownb545dd92012-08-07 20:03:02 +0100424 .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 Keepax939d3c62013-05-27 09:46:53 +0100433 .dapm_widgets = bells_widgets,
434 .num_dapm_widgets = ARRAY_SIZE(bells_widgets),
Mark Brownb545dd92012-08-07 20:03:02 +0100435 .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 Brownb1387072012-10-02 15:47:44 +0100440
441 .drvdata = &wm5102_drvdata,
Mark Brownb545dd92012-08-07 20:03:02 +0100442 },
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 Keepax939d3c62013-05-27 09:46:53 +0100453 .dapm_widgets = bells_widgets,
454 .num_dapm_widgets = ARRAY_SIZE(bells_widgets),
Mark Brownb545dd92012-08-07 20:03:02 +0100455 .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 Brownb1387072012-10-02 15:47:44 +0100460
461 .drvdata = &wm5110_drvdata,
Mark Brownb545dd92012-08-07 20:03:02 +0100462 },
463};
464
Bill Pembertonfdca21a2012-12-07 09:26:15 -0500465static int bells_probe(struct platform_device *pdev)
Mark Brownb545dd92012-08-07 20:03:02 +0100466{
467 int ret;
468
469 bells_cards[pdev->id].dev = &pdev->dev;
470
Tushar Beherac5838832014-05-21 08:52:17 +0530471 ret = devm_snd_soc_register_card(&pdev->dev, &bells_cards[pdev->id]);
472 if (ret)
Mark Brownb545dd92012-08-07 20:03:02 +0100473 dev_err(&pdev->dev,
474 "snd_soc_register_card(%s) failed: %d\n",
475 bells_cards[pdev->id].name, ret);
Mark Brownb545dd92012-08-07 20:03:02 +0100476
Tushar Beherac5838832014-05-21 08:52:17 +0530477 return ret;
Mark Brownb545dd92012-08-07 20:03:02 +0100478}
479
480static struct platform_driver bells_driver = {
481 .driver = {
482 .name = "bells",
Mark Brownb545dd92012-08-07 20:03:02 +0100483 .pm = &snd_soc_pm_ops,
484 },
485 .probe = bells_probe,
Mark Brownb545dd92012-08-07 20:03:02 +0100486};
487
488module_platform_driver(bells_driver);
489
490MODULE_DESCRIPTION("Bells audio support");
491MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
492MODULE_LICENSE("GPL");
493MODULE_ALIAS("platform:bells");