blob: 53a15be38b56f872b8cec592236c3ddcbebe2535 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * byt_cr_dpcm_rt5640.c - ASoc Machine driver for Intel Byt CR platform
4 *
5 * Copyright (C) 2014 Intel Corp
6 * Author: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 */
11
12#include <linux/i2c.h>
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/platform_device.h>
17#include <linux/acpi.h>
18#include <linux/clk.h>
19#include <linux/device.h>
20#include <linux/dmi.h>
21#include <linux/input.h>
22#include <linux/slab.h>
23#include <sound/pcm.h>
24#include <sound/pcm_params.h>
25#include <sound/soc.h>
26#include <sound/jack.h>
27#include <sound/soc-acpi.h>
28#include <dt-bindings/sound/rt5640.h>
29#include "../../codecs/rt5640.h"
30#include "../atom/sst-atom-controls.h"
31#include "../common/sst-dsp.h"
32#include "../common/soc-intel-quirks.h"
33
34enum {
35 BYT_RT5640_DMIC1_MAP,
36 BYT_RT5640_DMIC2_MAP,
37 BYT_RT5640_IN1_MAP,
38 BYT_RT5640_IN3_MAP,
39};
40
41enum {
42 BYT_RT5640_JD_SRC_GPIO1 = (RT5640_JD_SRC_GPIO1 << 4),
43 BYT_RT5640_JD_SRC_JD1_IN4P = (RT5640_JD_SRC_JD1_IN4P << 4),
44 BYT_RT5640_JD_SRC_JD2_IN4N = (RT5640_JD_SRC_JD2_IN4N << 4),
45 BYT_RT5640_JD_SRC_GPIO2 = (RT5640_JD_SRC_GPIO2 << 4),
46 BYT_RT5640_JD_SRC_GPIO3 = (RT5640_JD_SRC_GPIO3 << 4),
47 BYT_RT5640_JD_SRC_GPIO4 = (RT5640_JD_SRC_GPIO4 << 4),
48};
49
50enum {
51 BYT_RT5640_OVCD_TH_600UA = (6 << 8),
52 BYT_RT5640_OVCD_TH_1500UA = (15 << 8),
53 BYT_RT5640_OVCD_TH_2000UA = (20 << 8),
54};
55
56enum {
57 BYT_RT5640_OVCD_SF_0P5 = (RT5640_OVCD_SF_0P5 << 13),
58 BYT_RT5640_OVCD_SF_0P75 = (RT5640_OVCD_SF_0P75 << 13),
59 BYT_RT5640_OVCD_SF_1P0 = (RT5640_OVCD_SF_1P0 << 13),
60 BYT_RT5640_OVCD_SF_1P5 = (RT5640_OVCD_SF_1P5 << 13),
61};
62
63#define BYT_RT5640_MAP(quirk) ((quirk) & GENMASK(3, 0))
64#define BYT_RT5640_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4)
65#define BYT_RT5640_OVCD_TH(quirk) (((quirk) & GENMASK(12, 8)) >> 8)
66#define BYT_RT5640_OVCD_SF(quirk) (((quirk) & GENMASK(14, 13)) >> 13)
67#define BYT_RT5640_JD_NOT_INV BIT(16)
68#define BYT_RT5640_MONO_SPEAKER BIT(17)
69#define BYT_RT5640_DIFF_MIC BIT(18) /* default is single-ended */
70#define BYT_RT5640_SSP2_AIF2 BIT(19) /* default is using AIF1 */
71#define BYT_RT5640_SSP0_AIF1 BIT(20)
72#define BYT_RT5640_SSP0_AIF2 BIT(21)
73#define BYT_RT5640_MCLK_EN BIT(22)
74#define BYT_RT5640_MCLK_25MHZ BIT(23)
75
76#define BYTCR_INPUT_DEFAULTS \
77 (BYT_RT5640_IN3_MAP | \
78 BYT_RT5640_JD_SRC_JD1_IN4P | \
79 BYT_RT5640_OVCD_TH_2000UA | \
80 BYT_RT5640_OVCD_SF_0P75 | \
81 BYT_RT5640_DIFF_MIC)
82
83/* in-diff or dmic-pin + jdsrc + ovcd-th + -sf + jd-inv + terminating entry */
84#define MAX_NO_PROPS 6
85
86struct byt_rt5640_private {
87 struct snd_soc_jack jack;
88 struct clk *mclk;
89};
90static bool is_bytcr;
91
92static unsigned long byt_rt5640_quirk = BYT_RT5640_MCLK_EN;
93static int quirk_override = -1;
94module_param_named(quirk, quirk_override, int, 0444);
95MODULE_PARM_DESC(quirk, "Board-specific quirk override");
96
97static void log_quirks(struct device *dev)
98{
99 int map;
100 bool has_mclk = false;
101 bool has_ssp0 = false;
102 bool has_ssp0_aif1 = false;
103 bool has_ssp0_aif2 = false;
104 bool has_ssp2_aif2 = false;
105
106 map = BYT_RT5640_MAP(byt_rt5640_quirk);
107 switch (map) {
108 case BYT_RT5640_DMIC1_MAP:
109 dev_info(dev, "quirk DMIC1_MAP enabled\n");
110 break;
111 case BYT_RT5640_DMIC2_MAP:
112 dev_info(dev, "quirk DMIC2_MAP enabled\n");
113 break;
114 case BYT_RT5640_IN1_MAP:
115 dev_info(dev, "quirk IN1_MAP enabled\n");
116 break;
117 case BYT_RT5640_IN3_MAP:
118 dev_info(dev, "quirk IN3_MAP enabled\n");
119 break;
120 default:
121 dev_err(dev, "quirk map 0x%x is not supported, microphone input will not work\n", map);
122 break;
123 }
124 if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) {
125 dev_info(dev, "quirk realtek,jack-detect-source %ld\n",
126 BYT_RT5640_JDSRC(byt_rt5640_quirk));
127 dev_info(dev, "quirk realtek,over-current-threshold-microamp %ld\n",
128 BYT_RT5640_OVCD_TH(byt_rt5640_quirk) * 100);
129 dev_info(dev, "quirk realtek,over-current-scale-factor %ld\n",
130 BYT_RT5640_OVCD_SF(byt_rt5640_quirk));
131 }
132 if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV)
133 dev_info(dev, "quirk JD_NOT_INV enabled\n");
134 if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER)
135 dev_info(dev, "quirk MONO_SPEAKER enabled\n");
136 if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC)
137 dev_info(dev, "quirk DIFF_MIC enabled\n");
138 if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) {
139 dev_info(dev, "quirk SSP0_AIF1 enabled\n");
140 has_ssp0 = true;
141 has_ssp0_aif1 = true;
142 }
143 if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) {
144 dev_info(dev, "quirk SSP0_AIF2 enabled\n");
145 has_ssp0 = true;
146 has_ssp0_aif2 = true;
147 }
148 if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) {
149 dev_info(dev, "quirk SSP2_AIF2 enabled\n");
150 has_ssp2_aif2 = true;
151 }
152 if (is_bytcr && !has_ssp0)
153 dev_err(dev, "Invalid routing, bytcr detected but no SSP0-based quirk, audio cannot work with SSP2 on bytcr\n");
154 if (has_ssp0_aif1 && has_ssp0_aif2)
155 dev_err(dev, "Invalid routing, SSP0 cannot be connected to both AIF1 and AIF2\n");
156 if (has_ssp0 && has_ssp2_aif2)
157 dev_err(dev, "Invalid routing, cannot have both SSP0 and SSP2 connected to codec\n");
158
159 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
160 dev_info(dev, "quirk MCLK_EN enabled\n");
161 has_mclk = true;
162 }
163 if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) {
164 if (has_mclk)
165 dev_info(dev, "quirk MCLK_25MHZ enabled\n");
166 else
167 dev_err(dev, "quirk MCLK_25MHZ enabled but quirk MCLK not selected, will be ignored\n");
168 }
169}
170
171static int byt_rt5640_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai,
172 int rate)
173{
174 int ret;
175
176 /* Configure the PLL before selecting it */
177 if (!(byt_rt5640_quirk & BYT_RT5640_MCLK_EN)) {
178 /* use bitclock as PLL input */
179 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
180 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
181 /* 2x16 bit slots on SSP0 */
182 ret = snd_soc_dai_set_pll(codec_dai, 0,
183 RT5640_PLL1_S_BCLK1,
184 rate * 32, rate * 512);
185 } else {
186 /* 2x15 bit slots on SSP2 */
187 ret = snd_soc_dai_set_pll(codec_dai, 0,
188 RT5640_PLL1_S_BCLK1,
189 rate * 50, rate * 512);
190 }
191 } else {
192 if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) {
193 ret = snd_soc_dai_set_pll(codec_dai, 0,
194 RT5640_PLL1_S_MCLK,
195 25000000, rate * 512);
196 } else {
197 ret = snd_soc_dai_set_pll(codec_dai, 0,
198 RT5640_PLL1_S_MCLK,
199 19200000, rate * 512);
200 }
201 }
202
203 if (ret < 0) {
204 dev_err(codec_dai->component->dev, "can't set pll: %d\n", ret);
205 return ret;
206 }
207
208 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1,
209 rate * 512, SND_SOC_CLOCK_IN);
210 if (ret < 0) {
211 dev_err(codec_dai->component->dev, "can't set clock %d\n", ret);
212 return ret;
213 }
214
215 return 0;
216}
217
218#define BYT_CODEC_DAI1 "rt5640-aif1"
219#define BYT_CODEC_DAI2 "rt5640-aif2"
220
221static int platform_clock_control(struct snd_soc_dapm_widget *w,
222 struct snd_kcontrol *k, int event)
223{
224 struct snd_soc_dapm_context *dapm = w->dapm;
225 struct snd_soc_card *card = dapm->card;
226 struct snd_soc_dai *codec_dai;
227 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
228 int ret;
229
230 codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1);
231 if (!codec_dai)
232 codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2);
233
234 if (!codec_dai) {
235 dev_err(card->dev,
236 "Codec dai not found; Unable to set platform clock\n");
237 return -EIO;
238 }
239
240 if (SND_SOC_DAPM_EVENT_ON(event)) {
241 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
242 ret = clk_prepare_enable(priv->mclk);
243 if (ret < 0) {
244 dev_err(card->dev,
245 "could not configure MCLK state\n");
246 return ret;
247 }
248 }
249 ret = byt_rt5640_prepare_and_enable_pll1(codec_dai, 48000);
250 } else {
251 /*
252 * Set codec clock source to internal clock before
253 * turning off the platform clock. Codec needs clock
254 * for Jack detection and button press
255 */
256 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_RCCLK,
257 48000 * 512,
258 SND_SOC_CLOCK_IN);
259 if (!ret) {
260 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN)
261 clk_disable_unprepare(priv->mclk);
262 }
263 }
264
265 if (ret < 0) {
266 dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
267 return ret;
268 }
269
270 return 0;
271}
272
273static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = {
274 SND_SOC_DAPM_HP("Headphone", NULL),
275 SND_SOC_DAPM_MIC("Headset Mic", NULL),
276 SND_SOC_DAPM_MIC("Internal Mic", NULL),
277 SND_SOC_DAPM_SPK("Speaker", NULL),
278 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
279 platform_clock_control, SND_SOC_DAPM_PRE_PMU |
280 SND_SOC_DAPM_POST_PMD),
281
282};
283
284static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = {
285 {"Headphone", NULL, "Platform Clock"},
286 {"Headset Mic", NULL, "Platform Clock"},
287 {"Headset Mic", NULL, "MICBIAS1"},
288 {"IN2P", NULL, "Headset Mic"},
289 {"Headphone", NULL, "HPOL"},
290 {"Headphone", NULL, "HPOR"},
291};
292
293static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = {
294 {"Internal Mic", NULL, "Platform Clock"},
295 {"DMIC1", NULL, "Internal Mic"},
296};
297
298static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic2_map[] = {
299 {"Internal Mic", NULL, "Platform Clock"},
300 {"DMIC2", NULL, "Internal Mic"},
301};
302
303static const struct snd_soc_dapm_route byt_rt5640_intmic_in1_map[] = {
304 {"Internal Mic", NULL, "Platform Clock"},
305 {"Internal Mic", NULL, "MICBIAS1"},
306 {"IN1P", NULL, "Internal Mic"},
307};
308
309static const struct snd_soc_dapm_route byt_rt5640_intmic_in3_map[] = {
310 {"Internal Mic", NULL, "Platform Clock"},
311 {"Internal Mic", NULL, "MICBIAS1"},
312 {"IN3P", NULL, "Internal Mic"},
313};
314
315static const struct snd_soc_dapm_route byt_rt5640_ssp2_aif1_map[] = {
316 {"ssp2 Tx", NULL, "codec_out0"},
317 {"ssp2 Tx", NULL, "codec_out1"},
318 {"codec_in0", NULL, "ssp2 Rx"},
319 {"codec_in1", NULL, "ssp2 Rx"},
320
321 {"AIF1 Playback", NULL, "ssp2 Tx"},
322 {"ssp2 Rx", NULL, "AIF1 Capture"},
323};
324
325static const struct snd_soc_dapm_route byt_rt5640_ssp2_aif2_map[] = {
326 {"ssp2 Tx", NULL, "codec_out0"},
327 {"ssp2 Tx", NULL, "codec_out1"},
328 {"codec_in0", NULL, "ssp2 Rx"},
329 {"codec_in1", NULL, "ssp2 Rx"},
330
331 {"AIF2 Playback", NULL, "ssp2 Tx"},
332 {"ssp2 Rx", NULL, "AIF2 Capture"},
333};
334
335static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif1_map[] = {
336 {"ssp0 Tx", NULL, "modem_out"},
337 {"modem_in", NULL, "ssp0 Rx"},
338
339 {"AIF1 Playback", NULL, "ssp0 Tx"},
340 {"ssp0 Rx", NULL, "AIF1 Capture"},
341};
342
343static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif2_map[] = {
344 {"ssp0 Tx", NULL, "modem_out"},
345 {"modem_in", NULL, "ssp0 Rx"},
346
347 {"AIF2 Playback", NULL, "ssp0 Tx"},
348 {"ssp0 Rx", NULL, "AIF2 Capture"},
349};
350
351static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = {
352 {"Speaker", NULL, "Platform Clock"},
353 {"Speaker", NULL, "SPOLP"},
354 {"Speaker", NULL, "SPOLN"},
355 {"Speaker", NULL, "SPORP"},
356 {"Speaker", NULL, "SPORN"},
357};
358
359static const struct snd_soc_dapm_route byt_rt5640_mono_spk_map[] = {
360 {"Speaker", NULL, "Platform Clock"},
361 {"Speaker", NULL, "SPOLP"},
362 {"Speaker", NULL, "SPOLN"},
363};
364
365static const struct snd_kcontrol_new byt_rt5640_controls[] = {
366 SOC_DAPM_PIN_SWITCH("Headphone"),
367 SOC_DAPM_PIN_SWITCH("Headset Mic"),
368 SOC_DAPM_PIN_SWITCH("Internal Mic"),
369 SOC_DAPM_PIN_SWITCH("Speaker"),
370};
371
372static struct snd_soc_jack_pin rt5640_pins[] = {
373 {
374 .pin = "Headphone",
375 .mask = SND_JACK_HEADPHONE,
376 },
377 {
378 .pin = "Headset Mic",
379 .mask = SND_JACK_MICROPHONE,
380 },
381};
382
383static int byt_rt5640_aif1_hw_params(struct snd_pcm_substream *substream,
384 struct snd_pcm_hw_params *params)
385{
386 struct snd_soc_pcm_runtime *rtd = substream->private_data;
387 struct snd_soc_dai *dai = rtd->codec_dai;
388
389 return byt_rt5640_prepare_and_enable_pll1(dai, params_rate(params));
390}
391
392/* Please keep this list alphabetically sorted */
393static const struct dmi_system_id byt_rt5640_quirk_table[] = {
394 { /* Acer Iconia One 7 B1-750 */
395 .matches = {
396 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"),
397 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "VESPA2"),
398 },
399 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
400 BYT_RT5640_JD_SRC_JD1_IN4P |
401 BYT_RT5640_OVCD_TH_1500UA |
402 BYT_RT5640_OVCD_SF_0P75 |
403 BYT_RT5640_SSP0_AIF1 |
404 BYT_RT5640_MCLK_EN),
405 },
406 { /* Acer Iconia Tab 8 W1-810 */
407 .matches = {
408 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Acer"),
409 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Iconia W1-810"),
410 },
411 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
412 BYT_RT5640_JD_SRC_JD1_IN4P |
413 BYT_RT5640_OVCD_TH_1500UA |
414 BYT_RT5640_OVCD_SF_0P75 |
415 BYT_RT5640_SSP0_AIF1 |
416 BYT_RT5640_MCLK_EN),
417 },
418 { /* Acer One 10 S1002 */
419 .matches = {
420 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
421 DMI_MATCH(DMI_PRODUCT_NAME, "One S1002"),
422 },
423 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
424 BYT_RT5640_JD_SRC_JD2_IN4N |
425 BYT_RT5640_OVCD_TH_2000UA |
426 BYT_RT5640_OVCD_SF_0P75 |
427 BYT_RT5640_DIFF_MIC |
428 BYT_RT5640_SSP0_AIF2 |
429 BYT_RT5640_MCLK_EN),
430 },
431 {
432 .matches = {
433 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
434 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
435 },
436 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
437 BYT_RT5640_JD_SRC_JD2_IN4N |
438 BYT_RT5640_OVCD_TH_2000UA |
439 BYT_RT5640_OVCD_SF_0P75 |
440 BYT_RT5640_SSP0_AIF1 |
441 BYT_RT5640_MCLK_EN),
442 },
443 {
444 /* Advantech MICA-071 */
445 .matches = {
446 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Advantech"),
447 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MICA-071"),
448 },
449 /* OVCD Th = 1500uA to reliable detect head-phones vs -set */
450 .driver_data = (void *)(BYT_RT5640_IN3_MAP |
451 BYT_RT5640_JD_SRC_JD2_IN4N |
452 BYT_RT5640_OVCD_TH_1500UA |
453 BYT_RT5640_OVCD_SF_0P75 |
454 BYT_RT5640_MONO_SPEAKER |
455 BYT_RT5640_DIFF_MIC |
456 BYT_RT5640_MCLK_EN),
457 },
458 {
459 .matches = {
460 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
461 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 80 Cesium"),
462 },
463 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
464 BYT_RT5640_MONO_SPEAKER |
465 BYT_RT5640_SSP0_AIF1 |
466 BYT_RT5640_MCLK_EN),
467 },
468 {
469 .matches = {
470 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
471 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 101 CESIUM"),
472 },
473 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
474 BYT_RT5640_JD_NOT_INV |
475 BYT_RT5640_DIFF_MIC |
476 BYT_RT5640_SSP0_AIF1 |
477 BYT_RT5640_MCLK_EN),
478 },
479 {
480 .matches = {
481 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
482 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 140 CESIUM"),
483 },
484 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
485 BYT_RT5640_JD_SRC_JD2_IN4N |
486 BYT_RT5640_OVCD_TH_2000UA |
487 BYT_RT5640_OVCD_SF_0P75 |
488 BYT_RT5640_SSP0_AIF1 |
489 BYT_RT5640_MCLK_EN),
490 },
491 {
492 .matches = {
493 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
494 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"),
495 },
496 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
497 BYT_RT5640_JD_SRC_JD2_IN4N |
498 BYT_RT5640_OVCD_TH_2000UA |
499 BYT_RT5640_OVCD_SF_0P75 |
500 BYT_RT5640_SSP0_AIF1 |
501 BYT_RT5640_MCLK_EN),
502 },
503 {
504 .matches = {
505 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
506 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"),
507 },
508 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
509 BYT_RT5640_JD_SRC_JD2_IN4N |
510 BYT_RT5640_OVCD_TH_2000UA |
511 BYT_RT5640_OVCD_SF_0P75 |
512 BYT_RT5640_MCLK_EN),
513 },
514 {
515 .matches = {
516 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
517 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TAF"),
518 },
519 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
520 BYT_RT5640_JD_SRC_JD2_IN4N |
521 BYT_RT5640_OVCD_TH_2000UA |
522 BYT_RT5640_OVCD_SF_0P75 |
523 BYT_RT5640_MONO_SPEAKER |
524 BYT_RT5640_DIFF_MIC |
525 BYT_RT5640_SSP0_AIF2 |
526 BYT_RT5640_MCLK_EN),
527 },
528 { /* Chuwi Vi8 (CWI506) */
529 .matches = {
530 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"),
531 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "i86"),
532 /* The above are too generic, also match BIOS info */
533 DMI_MATCH(DMI_BIOS_VERSION, "CHUWI.D86JLBNR"),
534 },
535 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
536 BYT_RT5640_MONO_SPEAKER |
537 BYT_RT5640_SSP0_AIF1 |
538 BYT_RT5640_MCLK_EN),
539 },
540 { /* Chuwi Vi8 dual-boot (CWI506) */
541 .matches = {
542 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"),
543 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "i86"),
544 /* The above are too generic, also match BIOS info */
545 DMI_MATCH(DMI_BIOS_VERSION, "CHUWI2.D86JHBNR02"),
546 },
547 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
548 BYT_RT5640_MONO_SPEAKER |
549 BYT_RT5640_SSP0_AIF1 |
550 BYT_RT5640_MCLK_EN),
551 },
552 {
553 /* Chuwi Vi10 (CWI505) */
554 .matches = {
555 DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
556 DMI_MATCH(DMI_BOARD_NAME, "BYT-PF02"),
557 DMI_MATCH(DMI_SYS_VENDOR, "ilife"),
558 DMI_MATCH(DMI_PRODUCT_NAME, "S165"),
559 },
560 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
561 BYT_RT5640_JD_SRC_JD2_IN4N |
562 BYT_RT5640_OVCD_TH_2000UA |
563 BYT_RT5640_OVCD_SF_0P75 |
564 BYT_RT5640_DIFF_MIC |
565 BYT_RT5640_SSP0_AIF1 |
566 BYT_RT5640_MCLK_EN),
567 },
568 {
569 /* Chuwi Hi8 (CWI509) */
570 .matches = {
571 DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
572 DMI_MATCH(DMI_BOARD_NAME, "BYT-PA03C"),
573 DMI_MATCH(DMI_SYS_VENDOR, "ilife"),
574 DMI_MATCH(DMI_PRODUCT_NAME, "S806"),
575 },
576 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
577 BYT_RT5640_JD_SRC_JD2_IN4N |
578 BYT_RT5640_OVCD_TH_2000UA |
579 BYT_RT5640_OVCD_SF_0P75 |
580 BYT_RT5640_MONO_SPEAKER |
581 BYT_RT5640_DIFF_MIC |
582 BYT_RT5640_SSP0_AIF1 |
583 BYT_RT5640_MCLK_EN),
584 },
585 {
586 .matches = {
587 DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"),
588 DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"),
589 },
590 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP),
591 },
592 { /* Connect Tablet 9 */
593 .matches = {
594 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Connect"),
595 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Tablet 9"),
596 },
597 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
598 BYT_RT5640_MONO_SPEAKER |
599 BYT_RT5640_SSP0_AIF1 |
600 BYT_RT5640_MCLK_EN),
601 },
602 {
603 .matches = {
604 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
605 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Venue 8 Pro 5830"),
606 },
607 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
608 BYT_RT5640_JD_SRC_JD2_IN4N |
609 BYT_RT5640_OVCD_TH_2000UA |
610 BYT_RT5640_OVCD_SF_0P75 |
611 BYT_RT5640_MONO_SPEAKER |
612 BYT_RT5640_MCLK_EN),
613 },
614 { /* Estar Beauty HD MID 7316R */
615 .matches = {
616 DMI_MATCH(DMI_SYS_VENDOR, "Estar"),
617 DMI_MATCH(DMI_PRODUCT_NAME, "eSTAR BEAUTY HD Intel Quad core"),
618 },
619 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
620 BYT_RT5640_MONO_SPEAKER |
621 BYT_RT5640_SSP0_AIF1 |
622 BYT_RT5640_MCLK_EN),
623 },
624 { /* Glavey TM800A550L */
625 .matches = {
626 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
627 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
628 /* Above strings are too generic, also match on BIOS version */
629 DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"),
630 },
631 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
632 BYT_RT5640_SSP0_AIF1 |
633 BYT_RT5640_MCLK_EN),
634 },
635 {
636 .matches = {
637 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
638 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP ElitePad 1000 G2"),
639 },
640 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
641 BYT_RT5640_MCLK_EN),
642 },
643 { /* HP Pavilion x2 10-n000nd */
644 .matches = {
645 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
646 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"),
647 },
648 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
649 BYT_RT5640_JD_SRC_JD2_IN4N |
650 BYT_RT5640_OVCD_TH_1500UA |
651 BYT_RT5640_OVCD_SF_0P75 |
652 BYT_RT5640_SSP0_AIF1 |
653 BYT_RT5640_MCLK_EN),
654 },
655 { /* HP Stream 7 */
656 .matches = {
657 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
658 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP Stream 7 Tablet"),
659 },
660 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
661 BYT_RT5640_MONO_SPEAKER |
662 BYT_RT5640_JD_NOT_INV |
663 BYT_RT5640_SSP0_AIF1 |
664 BYT_RT5640_MCLK_EN),
665 },
666 { /* I.T.Works TW891 */
667 .matches = {
668 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."),
669 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TW891"),
670 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."),
671 DMI_EXACT_MATCH(DMI_BOARD_NAME, "TW891"),
672 },
673 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
674 BYT_RT5640_MONO_SPEAKER |
675 BYT_RT5640_SSP0_AIF1 |
676 BYT_RT5640_MCLK_EN),
677 },
678 { /* Lamina I8270 / T701BR.SE */
679 .matches = {
680 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Lamina"),
681 DMI_EXACT_MATCH(DMI_BOARD_NAME, "T701BR.SE"),
682 },
683 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
684 BYT_RT5640_MONO_SPEAKER |
685 BYT_RT5640_JD_NOT_INV |
686 BYT_RT5640_SSP0_AIF1 |
687 BYT_RT5640_MCLK_EN),
688 },
689 { /* Lenovo Miix 2 8 */
690 .matches = {
691 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
692 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "20326"),
693 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Hiking"),
694 },
695 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
696 BYT_RT5640_JD_SRC_JD2_IN4N |
697 BYT_RT5640_OVCD_TH_2000UA |
698 BYT_RT5640_OVCD_SF_0P75 |
699 BYT_RT5640_MONO_SPEAKER |
700 BYT_RT5640_MCLK_EN),
701 },
702 { /* Lenovo Miix 3-830 */
703 .matches = {
704 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
705 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 3-830"),
706 },
707 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
708 BYT_RT5640_JD_SRC_JD2_IN4N |
709 BYT_RT5640_OVCD_TH_2000UA |
710 BYT_RT5640_OVCD_SF_0P75 |
711 BYT_RT5640_MONO_SPEAKER |
712 BYT_RT5640_DIFF_MIC |
713 BYT_RT5640_SSP0_AIF1 |
714 BYT_RT5640_MCLK_EN),
715 },
716 { /* Linx Linx7 tablet */
717 .matches = {
718 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LINX"),
719 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "LINX7"),
720 },
721 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
722 BYT_RT5640_MONO_SPEAKER |
723 BYT_RT5640_JD_NOT_INV |
724 BYT_RT5640_SSP0_AIF1 |
725 BYT_RT5640_MCLK_EN),
726 },
727 { /* MPMAN Converter 9, similar hw as the I.T.Works TW891 2-in-1 */
728 .matches = {
729 DMI_MATCH(DMI_SYS_VENDOR, "MPMAN"),
730 DMI_MATCH(DMI_PRODUCT_NAME, "Converter9"),
731 },
732 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
733 BYT_RT5640_MONO_SPEAKER |
734 BYT_RT5640_SSP0_AIF1 |
735 BYT_RT5640_MCLK_EN),
736 },
737 {
738 /* MPMAN MPWIN895CL */
739 .matches = {
740 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MPMAN"),
741 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MPWIN8900CL"),
742 },
743 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
744 BYT_RT5640_MONO_SPEAKER |
745 BYT_RT5640_SSP0_AIF1 |
746 BYT_RT5640_MCLK_EN),
747 },
748 { /* MSI S100 tablet */
749 .matches = {
750 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Micro-Star International Co., Ltd."),
751 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "S100"),
752 },
753 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
754 BYT_RT5640_JD_SRC_JD2_IN4N |
755 BYT_RT5640_OVCD_TH_2000UA |
756 BYT_RT5640_OVCD_SF_0P75 |
757 BYT_RT5640_MONO_SPEAKER |
758 BYT_RT5640_DIFF_MIC |
759 BYT_RT5640_MCLK_EN),
760 },
761 { /* Nuvison/TMax TM800W560 */
762 .matches = {
763 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TMAX"),
764 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TM800W560L"),
765 },
766 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
767 BYT_RT5640_JD_SRC_JD2_IN4N |
768 BYT_RT5640_OVCD_TH_2000UA |
769 BYT_RT5640_OVCD_SF_0P75 |
770 BYT_RT5640_JD_NOT_INV |
771 BYT_RT5640_DIFF_MIC |
772 BYT_RT5640_SSP0_AIF1 |
773 BYT_RT5640_MCLK_EN),
774 },
775 { /* Onda v975w */
776 .matches = {
777 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
778 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
779 /* The above are too generic, also match BIOS info */
780 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "5.6.5"),
781 DMI_EXACT_MATCH(DMI_BIOS_DATE, "07/25/2014"),
782 },
783 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
784 BYT_RT5640_JD_SRC_JD2_IN4N |
785 BYT_RT5640_OVCD_TH_2000UA |
786 BYT_RT5640_OVCD_SF_0P75 |
787 BYT_RT5640_DIFF_MIC |
788 BYT_RT5640_MCLK_EN),
789 },
790 { /* Pipo W4 */
791 .matches = {
792 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
793 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
794 /* The above are too generic, also match BIOS info */
795 DMI_MATCH(DMI_BIOS_VERSION, "V8L_WIN32_CHIPHD"),
796 },
797 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
798 BYT_RT5640_MONO_SPEAKER |
799 BYT_RT5640_SSP0_AIF1 |
800 BYT_RT5640_MCLK_EN),
801 },
802 { /* Point of View Mobii TAB-P800W (V2.0) */
803 .matches = {
804 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
805 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
806 /* The above are too generic, also match BIOS info */
807 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "3BAIR1014"),
808 DMI_EXACT_MATCH(DMI_BIOS_DATE, "10/24/2014"),
809 },
810 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
811 BYT_RT5640_JD_SRC_JD2_IN4N |
812 BYT_RT5640_OVCD_TH_2000UA |
813 BYT_RT5640_OVCD_SF_0P75 |
814 BYT_RT5640_MONO_SPEAKER |
815 BYT_RT5640_DIFF_MIC |
816 BYT_RT5640_SSP0_AIF2 |
817 BYT_RT5640_MCLK_EN),
818 },
819 { /* Point of View Mobii TAB-P800W (V2.1) */
820 .matches = {
821 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
822 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
823 /* The above are too generic, also match BIOS info */
824 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "3BAIR1013"),
825 DMI_EXACT_MATCH(DMI_BIOS_DATE, "08/22/2014"),
826 },
827 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
828 BYT_RT5640_JD_SRC_JD2_IN4N |
829 BYT_RT5640_OVCD_TH_2000UA |
830 BYT_RT5640_OVCD_SF_0P75 |
831 BYT_RT5640_MONO_SPEAKER |
832 BYT_RT5640_DIFF_MIC |
833 BYT_RT5640_SSP0_AIF2 |
834 BYT_RT5640_MCLK_EN),
835 },
836 { /* Point of View Mobii TAB-P1005W-232 (V2.0) */
837 .matches = {
838 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "POV"),
839 DMI_EXACT_MATCH(DMI_BOARD_NAME, "I102A"),
840 },
841 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
842 BYT_RT5640_JD_SRC_JD2_IN4N |
843 BYT_RT5640_OVCD_TH_2000UA |
844 BYT_RT5640_OVCD_SF_0P75 |
845 BYT_RT5640_DIFF_MIC |
846 BYT_RT5640_SSP0_AIF1 |
847 BYT_RT5640_MCLK_EN),
848 },
849 {
850 /* Prowise PT301 */
851 .matches = {
852 DMI_MATCH(DMI_SYS_VENDOR, "Prowise"),
853 DMI_MATCH(DMI_PRODUCT_NAME, "PT301"),
854 },
855 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
856 BYT_RT5640_JD_SRC_JD2_IN4N |
857 BYT_RT5640_OVCD_TH_2000UA |
858 BYT_RT5640_OVCD_SF_0P75 |
859 BYT_RT5640_DIFF_MIC |
860 BYT_RT5640_SSP0_AIF1 |
861 BYT_RT5640_MCLK_EN),
862 },
863 {
864 /* Teclast X89 */
865 .matches = {
866 DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"),
867 DMI_MATCH(DMI_BOARD_NAME, "tPAD"),
868 },
869 .driver_data = (void *)(BYT_RT5640_IN3_MAP |
870 BYT_RT5640_JD_SRC_JD1_IN4P |
871 BYT_RT5640_OVCD_TH_2000UA |
872 BYT_RT5640_OVCD_SF_1P0 |
873 BYT_RT5640_SSP0_AIF1 |
874 BYT_RT5640_MCLK_EN),
875 },
876 { /* Toshiba Satellite Click Mini L9W-B */
877 .matches = {
878 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
879 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SATELLITE Click Mini L9W-B"),
880 },
881 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
882 BYT_RT5640_JD_SRC_JD2_IN4N |
883 BYT_RT5640_OVCD_TH_1500UA |
884 BYT_RT5640_OVCD_SF_0P75 |
885 BYT_RT5640_SSP0_AIF1 |
886 BYT_RT5640_MCLK_EN),
887 },
888 { /* Toshiba Encore WT8-A */
889 .matches = {
890 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
891 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT8-A"),
892 },
893 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
894 BYT_RT5640_JD_SRC_JD2_IN4N |
895 BYT_RT5640_OVCD_TH_2000UA |
896 BYT_RT5640_OVCD_SF_0P75 |
897 BYT_RT5640_JD_NOT_INV |
898 BYT_RT5640_MCLK_EN),
899 },
900 { /* Toshiba Encore WT10-A */
901 .matches = {
902 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
903 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT10-A-103"),
904 },
905 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
906 BYT_RT5640_JD_SRC_JD1_IN4P |
907 BYT_RT5640_OVCD_TH_2000UA |
908 BYT_RT5640_OVCD_SF_0P75 |
909 BYT_RT5640_SSP0_AIF2 |
910 BYT_RT5640_MCLK_EN),
911 },
912 { /* Vexia Edu Atla 10 tablet */
913 .matches = {
914 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
915 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
916 /* Above strings are too generic, also match on BIOS date */
917 DMI_MATCH(DMI_BIOS_DATE, "08/25/2014"),
918 },
919 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
920 BYT_RT5640_JD_SRC_JD2_IN4N |
921 BYT_RT5640_OVCD_TH_2000UA |
922 BYT_RT5640_OVCD_SF_0P75 |
923 BYT_RT5640_DIFF_MIC |
924 BYT_RT5640_SSP0_AIF2 |
925 BYT_RT5640_MCLK_EN),
926 },
927 { /* Voyo Winpad A15 */
928 .matches = {
929 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
930 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
931 /* Above strings are too generic, also match on BIOS date */
932 DMI_MATCH(DMI_BIOS_DATE, "11/20/2014"),
933 },
934 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
935 BYT_RT5640_JD_SRC_JD2_IN4N |
936 BYT_RT5640_OVCD_TH_2000UA |
937 BYT_RT5640_OVCD_SF_0P75 |
938 BYT_RT5640_DIFF_MIC |
939 BYT_RT5640_MCLK_EN),
940 },
941 { /* Catch-all for generic Insyde tablets, must be last */
942 .matches = {
943 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
944 },
945 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
946 BYT_RT5640_MCLK_EN |
947 BYT_RT5640_SSP0_AIF1),
948
949 },
950 {}
951};
952
953/*
954 * Note this MUST be called before snd_soc_register_card(), so that the props
955 * are in place before the codec component driver's probe function parses them.
956 */
957static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name)
958{
959 struct property_entry props[MAX_NO_PROPS] = {};
960 struct device *i2c_dev;
961 int ret, cnt = 0;
962
963 i2c_dev = bus_find_device_by_name(&i2c_bus_type, NULL, i2c_dev_name);
964 if (!i2c_dev)
965 return -EPROBE_DEFER;
966
967 switch (BYT_RT5640_MAP(byt_rt5640_quirk)) {
968 case BYT_RT5640_DMIC1_MAP:
969 props[cnt++] = PROPERTY_ENTRY_U32("realtek,dmic1-data-pin",
970 RT5640_DMIC1_DATA_PIN_IN1P);
971 break;
972 case BYT_RT5640_DMIC2_MAP:
973 props[cnt++] = PROPERTY_ENTRY_U32("realtek,dmic2-data-pin",
974 RT5640_DMIC2_DATA_PIN_IN1N);
975 break;
976 case BYT_RT5640_IN1_MAP:
977 if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC)
978 props[cnt++] =
979 PROPERTY_ENTRY_BOOL("realtek,in1-differential");
980 break;
981 case BYT_RT5640_IN3_MAP:
982 if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC)
983 props[cnt++] =
984 PROPERTY_ENTRY_BOOL("realtek,in3-differential");
985 break;
986 }
987
988 if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) {
989 props[cnt++] = PROPERTY_ENTRY_U32(
990 "realtek,jack-detect-source",
991 BYT_RT5640_JDSRC(byt_rt5640_quirk));
992
993 props[cnt++] = PROPERTY_ENTRY_U32(
994 "realtek,over-current-threshold-microamp",
995 BYT_RT5640_OVCD_TH(byt_rt5640_quirk) * 100);
996
997 props[cnt++] = PROPERTY_ENTRY_U32(
998 "realtek,over-current-scale-factor",
999 BYT_RT5640_OVCD_SF(byt_rt5640_quirk));
1000 }
1001
1002 if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV)
1003 props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted");
1004
1005 ret = device_add_properties(i2c_dev, props);
1006 put_device(i2c_dev);
1007
1008 return ret;
1009}
1010
1011static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
1012{
1013 struct snd_soc_card *card = runtime->card;
1014 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
1015 struct snd_soc_component *component = runtime->codec_dai->component;
1016 const struct snd_soc_dapm_route *custom_map;
1017 int num_routes;
1018 int ret;
1019
1020 card->dapm.idle_bias_off = true;
1021
1022 /* Start with RC clk for jack-detect (we disable MCLK below) */
1023 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN)
1024 snd_soc_component_update_bits(component, RT5640_GLB_CLK,
1025 RT5640_SCLK_SRC_MASK, RT5640_SCLK_SRC_RCCLK);
1026
1027 rt5640_sel_asrc_clk_src(component,
1028 RT5640_DA_STEREO_FILTER |
1029 RT5640_DA_MONO_L_FILTER |
1030 RT5640_DA_MONO_R_FILTER |
1031 RT5640_AD_STEREO_FILTER |
1032 RT5640_AD_MONO_L_FILTER |
1033 RT5640_AD_MONO_R_FILTER,
1034 RT5640_CLK_SEL_ASRC);
1035
1036 ret = snd_soc_add_card_controls(card, byt_rt5640_controls,
1037 ARRAY_SIZE(byt_rt5640_controls));
1038 if (ret) {
1039 dev_err(card->dev, "unable to add card controls\n");
1040 return ret;
1041 }
1042
1043 switch (BYT_RT5640_MAP(byt_rt5640_quirk)) {
1044 case BYT_RT5640_IN1_MAP:
1045 custom_map = byt_rt5640_intmic_in1_map;
1046 num_routes = ARRAY_SIZE(byt_rt5640_intmic_in1_map);
1047 break;
1048 case BYT_RT5640_IN3_MAP:
1049 custom_map = byt_rt5640_intmic_in3_map;
1050 num_routes = ARRAY_SIZE(byt_rt5640_intmic_in3_map);
1051 break;
1052 case BYT_RT5640_DMIC2_MAP:
1053 custom_map = byt_rt5640_intmic_dmic2_map;
1054 num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic2_map);
1055 break;
1056 default:
1057 custom_map = byt_rt5640_intmic_dmic1_map;
1058 num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map);
1059 }
1060
1061 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes);
1062 if (ret)
1063 return ret;
1064
1065 if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) {
1066 ret = snd_soc_dapm_add_routes(&card->dapm,
1067 byt_rt5640_ssp2_aif2_map,
1068 ARRAY_SIZE(byt_rt5640_ssp2_aif2_map));
1069 } else if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) {
1070 ret = snd_soc_dapm_add_routes(&card->dapm,
1071 byt_rt5640_ssp0_aif1_map,
1072 ARRAY_SIZE(byt_rt5640_ssp0_aif1_map));
1073 } else if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) {
1074 ret = snd_soc_dapm_add_routes(&card->dapm,
1075 byt_rt5640_ssp0_aif2_map,
1076 ARRAY_SIZE(byt_rt5640_ssp0_aif2_map));
1077 } else {
1078 ret = snd_soc_dapm_add_routes(&card->dapm,
1079 byt_rt5640_ssp2_aif1_map,
1080 ARRAY_SIZE(byt_rt5640_ssp2_aif1_map));
1081 }
1082 if (ret)
1083 return ret;
1084
1085 if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) {
1086 ret = snd_soc_dapm_add_routes(&card->dapm,
1087 byt_rt5640_mono_spk_map,
1088 ARRAY_SIZE(byt_rt5640_mono_spk_map));
1089 } else {
1090 ret = snd_soc_dapm_add_routes(&card->dapm,
1091 byt_rt5640_stereo_spk_map,
1092 ARRAY_SIZE(byt_rt5640_stereo_spk_map));
1093 }
1094 if (ret)
1095 return ret;
1096
1097 snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone");
1098 snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker");
1099
1100 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
1101 /*
1102 * The firmware might enable the clock at
1103 * boot (this information may or may not
1104 * be reflected in the enable clock register).
1105 * To change the rate we must disable the clock
1106 * first to cover these cases. Due to common
1107 * clock framework restrictions that do not allow
1108 * to disable a clock that has not been enabled,
1109 * we need to enable the clock first.
1110 */
1111 ret = clk_prepare_enable(priv->mclk);
1112 if (!ret)
1113 clk_disable_unprepare(priv->mclk);
1114
1115 if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ)
1116 ret = clk_set_rate(priv->mclk, 25000000);
1117 else
1118 ret = clk_set_rate(priv->mclk, 19200000);
1119
1120 if (ret) {
1121 dev_err(card->dev, "unable to set MCLK rate\n");
1122 return ret;
1123 }
1124 }
1125
1126 if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) {
1127 ret = snd_soc_card_jack_new(card, "Headset",
1128 SND_JACK_HEADSET | SND_JACK_BTN_0,
1129 &priv->jack, rt5640_pins,
1130 ARRAY_SIZE(rt5640_pins));
1131 if (ret) {
1132 dev_err(card->dev, "Jack creation failed %d\n", ret);
1133 return ret;
1134 }
1135 snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0,
1136 KEY_PLAYPAUSE);
1137 snd_soc_component_set_jack(component, &priv->jack, NULL);
1138 }
1139
1140 return 0;
1141}
1142
1143static const struct snd_soc_pcm_stream byt_rt5640_dai_params = {
1144 .formats = SNDRV_PCM_FMTBIT_S24_LE,
1145 .rate_min = 48000,
1146 .rate_max = 48000,
1147 .channels_min = 2,
1148 .channels_max = 2,
1149};
1150
1151static int byt_rt5640_codec_fixup(struct snd_soc_pcm_runtime *rtd,
1152 struct snd_pcm_hw_params *params)
1153{
1154 struct snd_interval *rate = hw_param_interval(params,
1155 SNDRV_PCM_HW_PARAM_RATE);
1156 struct snd_interval *channels = hw_param_interval(params,
1157 SNDRV_PCM_HW_PARAM_CHANNELS);
1158 int ret;
1159
1160 /* The DSP will covert the FE rate to 48k, stereo */
1161 rate->min = rate->max = 48000;
1162 channels->min = channels->max = 2;
1163
1164 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
1165 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1166
1167 /* set SSP0 to 16-bit */
1168 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
1169
1170 /*
1171 * Default mode for SSP configuration is TDM 4 slot, override config
1172 * with explicit setting to I2S 2ch 16-bit. The word length is set with
1173 * dai_set_tdm_slot() since there is no other API exposed
1174 */
1175 ret = snd_soc_dai_set_fmt(rtd->cpu_dai,
1176 SND_SOC_DAIFMT_I2S |
1177 SND_SOC_DAIFMT_NB_NF |
1178 SND_SOC_DAIFMT_CBS_CFS
1179 );
1180 if (ret < 0) {
1181 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
1182 return ret;
1183 }
1184
1185 ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 16);
1186 if (ret < 0) {
1187 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
1188 return ret;
1189 }
1190
1191 } else {
1192
1193 /* set SSP2 to 24-bit */
1194 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
1195
1196 /*
1197 * Default mode for SSP configuration is TDM 4 slot, override config
1198 * with explicit setting to I2S 2ch 24-bit. The word length is set with
1199 * dai_set_tdm_slot() since there is no other API exposed
1200 */
1201 ret = snd_soc_dai_set_fmt(rtd->cpu_dai,
1202 SND_SOC_DAIFMT_I2S |
1203 SND_SOC_DAIFMT_NB_NF |
1204 SND_SOC_DAIFMT_CBS_CFS
1205 );
1206 if (ret < 0) {
1207 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
1208 return ret;
1209 }
1210
1211 ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24);
1212 if (ret < 0) {
1213 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
1214 return ret;
1215 }
1216 }
1217 return 0;
1218}
1219
1220static int byt_rt5640_aif1_startup(struct snd_pcm_substream *substream)
1221{
1222 return snd_pcm_hw_constraint_single(substream->runtime,
1223 SNDRV_PCM_HW_PARAM_RATE, 48000);
1224}
1225
1226static const struct snd_soc_ops byt_rt5640_aif1_ops = {
1227 .startup = byt_rt5640_aif1_startup,
1228};
1229
1230static const struct snd_soc_ops byt_rt5640_be_ssp2_ops = {
1231 .hw_params = byt_rt5640_aif1_hw_params,
1232};
1233
1234SND_SOC_DAILINK_DEF(dummy,
1235 DAILINK_COMP_ARRAY(COMP_DUMMY()));
1236
1237SND_SOC_DAILINK_DEF(media,
1238 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
1239
1240SND_SOC_DAILINK_DEF(deepbuffer,
1241 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
1242
1243SND_SOC_DAILINK_DEF(ssp2_port,
1244 /* overwritten for ssp0 routing */
1245 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
1246SND_SOC_DAILINK_DEF(ssp2_codec,
1247 DAILINK_COMP_ARRAY(COMP_CODEC(
1248 /* overwritten with HID */ "i2c-10EC5640:00",
1249 /* changed w/ quirk */ "rt5640-aif1")));
1250
1251SND_SOC_DAILINK_DEF(platform,
1252 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
1253
1254static struct snd_soc_dai_link byt_rt5640_dais[] = {
1255 [MERR_DPCM_AUDIO] = {
1256 .name = "Baytrail Audio Port",
1257 .stream_name = "Baytrail Audio",
1258 .nonatomic = true,
1259 .dynamic = 1,
1260 .dpcm_playback = 1,
1261 .dpcm_capture = 1,
1262 .ops = &byt_rt5640_aif1_ops,
1263 SND_SOC_DAILINK_REG(media, dummy, platform),
1264 },
1265 [MERR_DPCM_DEEP_BUFFER] = {
1266 .name = "Deep-Buffer Audio Port",
1267 .stream_name = "Deep-Buffer Audio",
1268 .nonatomic = true,
1269 .dynamic = 1,
1270 .dpcm_playback = 1,
1271 .ops = &byt_rt5640_aif1_ops,
1272 SND_SOC_DAILINK_REG(deepbuffer, dummy, platform),
1273 },
1274 /* back ends */
1275 {
1276 .name = "SSP2-Codec",
1277 .id = 0,
1278 .no_pcm = 1,
1279 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
1280 | SND_SOC_DAIFMT_CBS_CFS,
1281 .be_hw_params_fixup = byt_rt5640_codec_fixup,
1282 .ignore_suspend = 1,
1283 .nonatomic = true,
1284 .dpcm_playback = 1,
1285 .dpcm_capture = 1,
1286 .init = byt_rt5640_init,
1287 .ops = &byt_rt5640_be_ssp2_ops,
1288 SND_SOC_DAILINK_REG(ssp2_port, ssp2_codec, platform),
1289 },
1290};
1291
1292/* SoC card */
1293static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN];
1294static char byt_rt5640_codec_aif_name[12]; /* = "rt5640-aif[1|2]" */
1295static char byt_rt5640_cpu_dai_name[10]; /* = "ssp[0|2]-port" */
1296static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */
1297
1298static int byt_rt5640_suspend(struct snd_soc_card *card)
1299{
1300 struct snd_soc_component *component;
1301
1302 if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
1303 return 0;
1304
1305 for_each_card_components(card, component) {
1306 if (!strcmp(component->name, byt_rt5640_codec_name)) {
1307 dev_dbg(component->dev, "disabling jack detect before suspend\n");
1308 snd_soc_component_set_jack(component, NULL, NULL);
1309 break;
1310 }
1311 }
1312
1313 return 0;
1314}
1315
1316static int byt_rt5640_resume(struct snd_soc_card *card)
1317{
1318 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
1319 struct snd_soc_component *component;
1320
1321 if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
1322 return 0;
1323
1324 for_each_card_components(card, component) {
1325 if (!strcmp(component->name, byt_rt5640_codec_name)) {
1326 dev_dbg(component->dev, "re-enabling jack detect after resume\n");
1327 snd_soc_component_set_jack(component, &priv->jack, NULL);
1328 break;
1329 }
1330 }
1331
1332 return 0;
1333}
1334
1335static struct snd_soc_card byt_rt5640_card = {
1336 .name = "bytcr-rt5640",
1337 .owner = THIS_MODULE,
1338 .dai_link = byt_rt5640_dais,
1339 .num_links = ARRAY_SIZE(byt_rt5640_dais),
1340 .dapm_widgets = byt_rt5640_widgets,
1341 .num_dapm_widgets = ARRAY_SIZE(byt_rt5640_widgets),
1342 .dapm_routes = byt_rt5640_audio_map,
1343 .num_dapm_routes = ARRAY_SIZE(byt_rt5640_audio_map),
1344 .fully_routed = true,
1345 .suspend_pre = byt_rt5640_suspend,
1346 .resume_post = byt_rt5640_resume,
1347};
1348
1349struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
1350 u64 aif_value; /* 1: AIF1, 2: AIF2 */
1351 u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */
1352};
1353
1354static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
1355{
1356 static const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3" };
1357 const struct dmi_system_id *dmi_id;
1358 struct byt_rt5640_private *priv;
1359 struct snd_soc_acpi_mach *mach;
1360 const char *platform_name;
1361 struct acpi_device *adev;
1362 int ret_val = 0;
1363 int dai_index = 0;
1364 int i;
1365
1366 is_bytcr = false;
1367 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
1368 if (!priv)
1369 return -ENOMEM;
1370
1371 /* register the soc card */
1372 byt_rt5640_card.dev = &pdev->dev;
1373 mach = byt_rt5640_card.dev->platform_data;
1374 snd_soc_card_set_drvdata(&byt_rt5640_card, priv);
1375
1376 /* fix index of codec dai */
1377 for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) {
1378 if (!strcmp(byt_rt5640_dais[i].codecs->name,
1379 "i2c-10EC5640:00")) {
1380 dai_index = i;
1381 break;
1382 }
1383 }
1384
1385 /* fixup codec name based on HID */
1386 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
1387 if (adev) {
1388 snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name),
1389 "i2c-%s", acpi_dev_name(adev));
1390 put_device(&adev->dev);
1391 byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name;
1392 }
1393
1394 /*
1395 * swap SSP0 if bytcr is detected
1396 * (will be overridden if DMI quirk is detected)
1397 */
1398 if (soc_intel_is_byt()) {
1399 if (mach->mach_params.acpi_ipc_irq_index == 0)
1400 is_bytcr = true;
1401 }
1402
1403 if (is_bytcr) {
1404 /*
1405 * Baytrail CR platforms may have CHAN package in BIOS, try
1406 * to find relevant routing quirk based as done on Windows
1407 * platforms. We have to read the information directly from the
1408 * BIOS, at this stage the card is not created and the links
1409 * with the codec driver/pdata are non-existent
1410 */
1411
1412 struct acpi_chan_package chan_package;
1413
1414 /* format specified: 2 64-bit integers */
1415 struct acpi_buffer format = {sizeof("NN"), "NN"};
1416 struct acpi_buffer state = {0, NULL};
1417 struct snd_soc_acpi_package_context pkg_ctx;
1418 bool pkg_found = false;
1419
1420 state.length = sizeof(chan_package);
1421 state.pointer = &chan_package;
1422
1423 pkg_ctx.name = "CHAN";
1424 pkg_ctx.length = 2;
1425 pkg_ctx.format = &format;
1426 pkg_ctx.state = &state;
1427 pkg_ctx.data_valid = false;
1428
1429 pkg_found = snd_soc_acpi_find_package_from_hid(mach->id,
1430 &pkg_ctx);
1431 if (pkg_found) {
1432 if (chan_package.aif_value == 1) {
1433 dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n");
1434 byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF1;
1435 } else if (chan_package.aif_value == 2) {
1436 dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n");
1437 byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF2;
1438 } else {
1439 dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n");
1440 pkg_found = false;
1441 }
1442 }
1443
1444 if (!pkg_found) {
1445 /* no BIOS indications, assume SSP0-AIF2 connection */
1446 byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF2;
1447 }
1448
1449 /* change defaults for Baytrail-CR capture */
1450 byt_rt5640_quirk |= BYTCR_INPUT_DEFAULTS;
1451 } else {
1452 byt_rt5640_quirk |= BYT_RT5640_DMIC1_MAP |
1453 BYT_RT5640_JD_SRC_JD2_IN4N |
1454 BYT_RT5640_OVCD_TH_2000UA |
1455 BYT_RT5640_OVCD_SF_0P75;
1456 }
1457
1458 /* check quirks before creating card */
1459 dmi_id = dmi_first_match(byt_rt5640_quirk_table);
1460 if (dmi_id)
1461 byt_rt5640_quirk = (unsigned long)dmi_id->driver_data;
1462 if (quirk_override != -1) {
1463 dev_info(&pdev->dev, "Overriding quirk 0x%x => 0x%x\n",
1464 (unsigned int)byt_rt5640_quirk, quirk_override);
1465 byt_rt5640_quirk = quirk_override;
1466 }
1467
1468 /* Must be called before register_card, also see declaration comment. */
1469 ret_val = byt_rt5640_add_codec_device_props(byt_rt5640_codec_name);
1470 if (ret_val)
1471 return ret_val;
1472
1473 log_quirks(&pdev->dev);
1474
1475 if ((byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) ||
1476 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1477
1478 /* fixup codec aif name */
1479 snprintf(byt_rt5640_codec_aif_name,
1480 sizeof(byt_rt5640_codec_aif_name),
1481 "%s", "rt5640-aif2");
1482
1483 byt_rt5640_dais[dai_index].codecs->dai_name =
1484 byt_rt5640_codec_aif_name;
1485 }
1486
1487 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
1488 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1489
1490 /* fixup cpu dai name name */
1491 snprintf(byt_rt5640_cpu_dai_name,
1492 sizeof(byt_rt5640_cpu_dai_name),
1493 "%s", "ssp0-port");
1494
1495 byt_rt5640_dais[dai_index].cpus->dai_name =
1496 byt_rt5640_cpu_dai_name;
1497 }
1498
1499 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
1500 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
1501 if (IS_ERR(priv->mclk)) {
1502 ret_val = PTR_ERR(priv->mclk);
1503
1504 dev_err(&pdev->dev,
1505 "Failed to get MCLK from pmc_plt_clk_3: %d\n",
1506 ret_val);
1507
1508 /*
1509 * Fall back to bit clock usage for -ENOENT (clock not
1510 * available likely due to missing dependencies), bail
1511 * for all other errors, including -EPROBE_DEFER
1512 */
1513 if (ret_val != -ENOENT)
1514 return ret_val;
1515 byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN;
1516 }
1517 }
1518
1519 snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name),
1520 "bytcr-rt5640-%s-spk-%s-mic",
1521 (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ?
1522 "mono" : "stereo",
1523 map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
1524 byt_rt5640_card.long_name = byt_rt5640_long_name;
1525
1526 /* override plaform name, if required */
1527 platform_name = mach->mach_params.platform;
1528
1529 ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5640_card,
1530 platform_name);
1531 if (ret_val)
1532 return ret_val;
1533
1534 ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5640_card);
1535
1536 if (ret_val) {
1537 dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n",
1538 ret_val);
1539 return ret_val;
1540 }
1541 platform_set_drvdata(pdev, &byt_rt5640_card);
1542 return ret_val;
1543}
1544
1545static struct platform_driver snd_byt_rt5640_mc_driver = {
1546 .driver = {
1547 .name = "bytcr_rt5640",
1548 },
1549 .probe = snd_byt_rt5640_mc_probe,
1550};
1551
1552module_platform_driver(snd_byt_rt5640_mc_driver);
1553
1554MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver");
1555MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>");
1556MODULE_LICENSE("GPL v2");
1557MODULE_ALIAS("platform:bytcr_rt5640");