1 // SPDX-License-Identifier: GPL-2.0-only
3 * byt_cr_dpcm_rt5640.c - ASoc Machine driver for Intel Byt CR platform
5 * Copyright (C) 2014 Intel Corp
6 * Author: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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/gpio/consumer.h>
22 #include <linux/gpio/machine.h>
23 #include <linux/input.h>
24 #include <linux/slab.h>
25 #include <sound/pcm.h>
26 #include <sound/pcm_params.h>
27 #include <sound/soc.h>
28 #include <sound/jack.h>
29 #include <sound/soc-acpi.h>
30 #include <dt-bindings/sound/rt5640.h>
31 #include "../../codecs/rt5640.h"
32 #include "../atom/sst-atom-controls.h"
33 #include "../common/soc-intel-quirks.h"
40 BYT_RT5640_NO_INTERNAL_MIC_MAP,
44 BYT_RT5640_JD_SRC_GPIO1 = (RT5640_JD_SRC_GPIO1 << 4),
45 BYT_RT5640_JD_SRC_JD1_IN4P = (RT5640_JD_SRC_JD1_IN4P << 4),
46 BYT_RT5640_JD_SRC_JD2_IN4N = (RT5640_JD_SRC_JD2_IN4N << 4),
47 BYT_RT5640_JD_SRC_GPIO2 = (RT5640_JD_SRC_GPIO2 << 4),
48 BYT_RT5640_JD_SRC_GPIO3 = (RT5640_JD_SRC_GPIO3 << 4),
49 BYT_RT5640_JD_SRC_GPIO4 = (RT5640_JD_SRC_GPIO4 << 4),
53 BYT_RT5640_OVCD_TH_600UA = (6 << 8),
54 BYT_RT5640_OVCD_TH_1500UA = (15 << 8),
55 BYT_RT5640_OVCD_TH_2000UA = (20 << 8),
59 BYT_RT5640_OVCD_SF_0P5 = (RT5640_OVCD_SF_0P5 << 13),
60 BYT_RT5640_OVCD_SF_0P75 = (RT5640_OVCD_SF_0P75 << 13),
61 BYT_RT5640_OVCD_SF_1P0 = (RT5640_OVCD_SF_1P0 << 13),
62 BYT_RT5640_OVCD_SF_1P5 = (RT5640_OVCD_SF_1P5 << 13),
65 #define BYT_RT5640_MAP(quirk) ((quirk) & GENMASK(3, 0))
66 #define BYT_RT5640_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4)
67 #define BYT_RT5640_OVCD_TH(quirk) (((quirk) & GENMASK(12, 8)) >> 8)
68 #define BYT_RT5640_OVCD_SF(quirk) (((quirk) & GENMASK(14, 13)) >> 13)
69 #define BYT_RT5640_JD_NOT_INV BIT(16)
70 #define BYT_RT5640_MONO_SPEAKER BIT(17)
71 #define BYT_RT5640_DIFF_MIC BIT(18) /* default is single-ended */
72 #define BYT_RT5640_SSP2_AIF2 BIT(19) /* default is using AIF1 */
73 #define BYT_RT5640_SSP0_AIF1 BIT(20)
74 #define BYT_RT5640_SSP0_AIF2 BIT(21)
75 #define BYT_RT5640_MCLK_EN BIT(22)
76 #define BYT_RT5640_MCLK_25MHZ BIT(23)
77 #define BYT_RT5640_NO_SPEAKERS BIT(24)
78 #define BYT_RT5640_LINEOUT BIT(25)
79 #define BYT_RT5640_LINEOUT_AS_HP2 BIT(26)
80 #define BYT_RT5640_HSMIC2_ON_IN1 BIT(27)
81 #define BYT_RT5640_JD_HP_ELITEP_1000G2 BIT(28)
83 #define BYTCR_INPUT_DEFAULTS \
84 (BYT_RT5640_IN3_MAP | \
85 BYT_RT5640_JD_SRC_JD1_IN4P | \
86 BYT_RT5640_OVCD_TH_2000UA | \
87 BYT_RT5640_OVCD_SF_0P75 | \
90 /* in-diff or dmic-pin + jdsrc + ovcd-th + -sf + jd-inv + terminating entry */
91 #define MAX_NO_PROPS 6
93 struct byt_rt5640_private {
94 struct snd_soc_jack jack;
95 struct snd_soc_jack jack2;
96 struct gpio_desc *hsmic_detect;
98 struct device *codec_dev;
100 static bool is_bytcr;
102 static unsigned long byt_rt5640_quirk = BYT_RT5640_MCLK_EN;
103 static int quirk_override = -1;
104 module_param_named(quirk, quirk_override, int, 0444);
105 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
107 static void log_quirks(struct device *dev)
110 bool has_mclk = false;
111 bool has_ssp0 = false;
112 bool has_ssp0_aif1 = false;
113 bool has_ssp0_aif2 = false;
114 bool has_ssp2_aif2 = false;
116 map = BYT_RT5640_MAP(byt_rt5640_quirk);
118 case BYT_RT5640_DMIC1_MAP:
119 dev_info(dev, "quirk DMIC1_MAP enabled\n");
121 case BYT_RT5640_DMIC2_MAP:
122 dev_info(dev, "quirk DMIC2_MAP enabled\n");
124 case BYT_RT5640_IN1_MAP:
125 dev_info(dev, "quirk IN1_MAP enabled\n");
127 case BYT_RT5640_IN3_MAP:
128 dev_info(dev, "quirk IN3_MAP enabled\n");
130 case BYT_RT5640_NO_INTERNAL_MIC_MAP:
131 dev_info(dev, "quirk NO_INTERNAL_MIC_MAP enabled\n");
134 dev_err(dev, "quirk map 0x%x is not supported, microphone input will not work\n", map);
137 if (byt_rt5640_quirk & BYT_RT5640_HSMIC2_ON_IN1)
138 dev_info(dev, "quirk HSMIC2_ON_IN1 enabled\n");
139 if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) {
140 dev_info(dev, "quirk realtek,jack-detect-source %ld\n",
141 BYT_RT5640_JDSRC(byt_rt5640_quirk));
142 dev_info(dev, "quirk realtek,over-current-threshold-microamp %ld\n",
143 BYT_RT5640_OVCD_TH(byt_rt5640_quirk) * 100);
144 dev_info(dev, "quirk realtek,over-current-scale-factor %ld\n",
145 BYT_RT5640_OVCD_SF(byt_rt5640_quirk));
147 if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV)
148 dev_info(dev, "quirk JD_NOT_INV enabled\n");
149 if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2)
150 dev_info(dev, "quirk JD_HP_ELITEPAD_1000G2 enabled\n");
151 if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER)
152 dev_info(dev, "quirk MONO_SPEAKER enabled\n");
153 if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS)
154 dev_info(dev, "quirk NO_SPEAKERS enabled\n");
155 if (byt_rt5640_quirk & BYT_RT5640_LINEOUT)
156 dev_info(dev, "quirk LINEOUT enabled\n");
157 if (byt_rt5640_quirk & BYT_RT5640_LINEOUT_AS_HP2)
158 dev_info(dev, "quirk LINEOUT_AS_HP2 enabled\n");
159 if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC)
160 dev_info(dev, "quirk DIFF_MIC enabled\n");
161 if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) {
162 dev_info(dev, "quirk SSP0_AIF1 enabled\n");
164 has_ssp0_aif1 = true;
166 if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) {
167 dev_info(dev, "quirk SSP0_AIF2 enabled\n");
169 has_ssp0_aif2 = true;
171 if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) {
172 dev_info(dev, "quirk SSP2_AIF2 enabled\n");
173 has_ssp2_aif2 = true;
175 if (is_bytcr && !has_ssp0)
176 dev_err(dev, "Invalid routing, bytcr detected but no SSP0-based quirk, audio cannot work with SSP2 on bytcr\n");
177 if (has_ssp0_aif1 && has_ssp0_aif2)
178 dev_err(dev, "Invalid routing, SSP0 cannot be connected to both AIF1 and AIF2\n");
179 if (has_ssp0 && has_ssp2_aif2)
180 dev_err(dev, "Invalid routing, cannot have both SSP0 and SSP2 connected to codec\n");
182 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
183 dev_info(dev, "quirk MCLK_EN enabled\n");
186 if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) {
188 dev_info(dev, "quirk MCLK_25MHZ enabled\n");
190 dev_err(dev, "quirk MCLK_25MHZ enabled but quirk MCLK not selected, will be ignored\n");
194 static int byt_rt5640_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai,
199 /* Configure the PLL before selecting it */
200 if (!(byt_rt5640_quirk & BYT_RT5640_MCLK_EN)) {
201 /* use bitclock as PLL input */
202 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
203 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
204 /* 2x16 bit slots on SSP0 */
205 ret = snd_soc_dai_set_pll(codec_dai, 0,
207 rate * 32, rate * 512);
209 /* 2x15 bit slots on SSP2 */
210 ret = snd_soc_dai_set_pll(codec_dai, 0,
212 rate * 50, rate * 512);
215 if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) {
216 ret = snd_soc_dai_set_pll(codec_dai, 0,
218 25000000, rate * 512);
220 ret = snd_soc_dai_set_pll(codec_dai, 0,
222 19200000, rate * 512);
227 dev_err(codec_dai->component->dev, "can't set pll: %d\n", ret);
231 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1,
232 rate * 512, SND_SOC_CLOCK_IN);
234 dev_err(codec_dai->component->dev, "can't set clock %d\n", ret);
241 #define BYT_CODEC_DAI1 "rt5640-aif1"
242 #define BYT_CODEC_DAI2 "rt5640-aif2"
244 static struct snd_soc_dai *byt_rt5640_get_codec_dai(struct snd_soc_dapm_context *dapm)
246 struct snd_soc_card *card = dapm->card;
247 struct snd_soc_dai *codec_dai;
249 codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1);
251 codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2);
253 dev_err(card->dev, "Error codec dai not found\n");
258 static int platform_clock_control(struct snd_soc_dapm_widget *w,
259 struct snd_kcontrol *k, int event)
261 struct snd_soc_dapm_context *dapm = w->dapm;
262 struct snd_soc_card *card = dapm->card;
263 struct snd_soc_dai *codec_dai;
264 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
267 codec_dai = byt_rt5640_get_codec_dai(dapm);
271 if (SND_SOC_DAPM_EVENT_ON(event)) {
272 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
273 ret = clk_prepare_enable(priv->mclk);
276 "could not configure MCLK state\n");
280 ret = byt_rt5640_prepare_and_enable_pll1(codec_dai, 48000);
283 * Set codec clock source to internal clock before
284 * turning off the platform clock. Codec needs clock
285 * for Jack detection and button press
287 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_RCCLK,
291 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN)
292 clk_disable_unprepare(priv->mclk);
297 dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
304 static int byt_rt5640_event_lineout(struct snd_soc_dapm_widget *w,
305 struct snd_kcontrol *k, int event)
307 unsigned int gpio_ctrl3_val = RT5640_GP1_PF_OUT;
308 struct snd_soc_dai *codec_dai;
310 if (!(byt_rt5640_quirk & BYT_RT5640_LINEOUT_AS_HP2))
314 * On devices which use line-out as a second headphones output,
315 * the codec's GPIO1 pin is used to enable an external HP-amp.
318 codec_dai = byt_rt5640_get_codec_dai(w->dapm);
322 if (SND_SOC_DAPM_EVENT_ON(event))
323 gpio_ctrl3_val |= RT5640_GP1_OUT_HI;
325 snd_soc_component_update_bits(codec_dai->component, RT5640_GPIO_CTRL3,
326 RT5640_GP1_PF_MASK | RT5640_GP1_OUT_MASK, gpio_ctrl3_val);
331 static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = {
332 SND_SOC_DAPM_HP("Headphone", NULL),
333 SND_SOC_DAPM_MIC("Headset Mic", NULL),
334 SND_SOC_DAPM_MIC("Headset Mic 2", NULL),
335 SND_SOC_DAPM_MIC("Internal Mic", NULL),
336 SND_SOC_DAPM_SPK("Speaker", NULL),
337 SND_SOC_DAPM_LINE("Line Out", byt_rt5640_event_lineout),
338 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
339 platform_clock_control, SND_SOC_DAPM_PRE_PMU |
340 SND_SOC_DAPM_POST_PMD),
343 static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = {
344 {"Headphone", NULL, "Platform Clock"},
345 {"Headset Mic", NULL, "Platform Clock"},
346 {"Headset Mic", NULL, "MICBIAS1"},
347 {"IN2P", NULL, "Headset Mic"},
348 {"Headphone", NULL, "HPOL"},
349 {"Headphone", NULL, "HPOR"},
352 static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = {
353 {"Internal Mic", NULL, "Platform Clock"},
354 {"DMIC1", NULL, "Internal Mic"},
357 static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic2_map[] = {
358 {"Internal Mic", NULL, "Platform Clock"},
359 {"DMIC2", NULL, "Internal Mic"},
362 static const struct snd_soc_dapm_route byt_rt5640_intmic_in1_map[] = {
363 {"Internal Mic", NULL, "Platform Clock"},
364 {"Internal Mic", NULL, "MICBIAS1"},
365 {"IN1P", NULL, "Internal Mic"},
368 static const struct snd_soc_dapm_route byt_rt5640_intmic_in3_map[] = {
369 {"Internal Mic", NULL, "Platform Clock"},
370 {"Internal Mic", NULL, "MICBIAS1"},
371 {"IN3P", NULL, "Internal Mic"},
374 static const struct snd_soc_dapm_route byt_rt5640_hsmic2_in1_map[] = {
375 {"Headset Mic 2", NULL, "Platform Clock"},
376 {"Headset Mic 2", NULL, "MICBIAS1"},
377 {"IN1P", NULL, "Headset Mic 2"},
380 static const struct snd_soc_dapm_route byt_rt5640_ssp2_aif1_map[] = {
381 {"ssp2 Tx", NULL, "codec_out0"},
382 {"ssp2 Tx", NULL, "codec_out1"},
383 {"codec_in0", NULL, "ssp2 Rx"},
384 {"codec_in1", NULL, "ssp2 Rx"},
386 {"AIF1 Playback", NULL, "ssp2 Tx"},
387 {"ssp2 Rx", NULL, "AIF1 Capture"},
390 static const struct snd_soc_dapm_route byt_rt5640_ssp2_aif2_map[] = {
391 {"ssp2 Tx", NULL, "codec_out0"},
392 {"ssp2 Tx", NULL, "codec_out1"},
393 {"codec_in0", NULL, "ssp2 Rx"},
394 {"codec_in1", NULL, "ssp2 Rx"},
396 {"AIF2 Playback", NULL, "ssp2 Tx"},
397 {"ssp2 Rx", NULL, "AIF2 Capture"},
400 static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif1_map[] = {
401 {"ssp0 Tx", NULL, "modem_out"},
402 {"modem_in", NULL, "ssp0 Rx"},
404 {"AIF1 Playback", NULL, "ssp0 Tx"},
405 {"ssp0 Rx", NULL, "AIF1 Capture"},
408 static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif2_map[] = {
409 {"ssp0 Tx", NULL, "modem_out"},
410 {"modem_in", NULL, "ssp0 Rx"},
412 {"AIF2 Playback", NULL, "ssp0 Tx"},
413 {"ssp0 Rx", NULL, "AIF2 Capture"},
416 static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = {
417 {"Speaker", NULL, "Platform Clock"},
418 {"Speaker", NULL, "SPOLP"},
419 {"Speaker", NULL, "SPOLN"},
420 {"Speaker", NULL, "SPORP"},
421 {"Speaker", NULL, "SPORN"},
424 static const struct snd_soc_dapm_route byt_rt5640_mono_spk_map[] = {
425 {"Speaker", NULL, "Platform Clock"},
426 {"Speaker", NULL, "SPOLP"},
427 {"Speaker", NULL, "SPOLN"},
430 static const struct snd_soc_dapm_route byt_rt5640_lineout_map[] = {
431 {"Line Out", NULL, "Platform Clock"},
432 {"Line Out", NULL, "LOUTR"},
433 {"Line Out", NULL, "LOUTL"},
436 static const struct snd_kcontrol_new byt_rt5640_controls[] = {
437 SOC_DAPM_PIN_SWITCH("Headphone"),
438 SOC_DAPM_PIN_SWITCH("Headset Mic"),
439 SOC_DAPM_PIN_SWITCH("Headset Mic 2"),
440 SOC_DAPM_PIN_SWITCH("Internal Mic"),
441 SOC_DAPM_PIN_SWITCH("Speaker"),
442 SOC_DAPM_PIN_SWITCH("Line Out"),
445 static struct snd_soc_jack_pin rt5640_pins[] = {
448 .mask = SND_JACK_HEADPHONE,
451 .pin = "Headset Mic",
452 .mask = SND_JACK_MICROPHONE,
456 static struct snd_soc_jack_pin rt5640_pins2[] = {
458 /* The 2nd headset jack uses lineout with an external HP-amp */
460 .mask = SND_JACK_HEADPHONE,
463 .pin = "Headset Mic 2",
464 .mask = SND_JACK_MICROPHONE,
468 static struct snd_soc_jack_gpio rt5640_jack_gpio = {
470 .report = SND_JACK_HEADSET,
472 .debounce_time = 200,
475 static struct snd_soc_jack_gpio rt5640_jack2_gpio = {
476 .name = "hp2-detect",
477 .report = SND_JACK_HEADSET,
479 .debounce_time = 200,
482 static const struct acpi_gpio_params acpi_gpio0 = { 0, 0, false };
483 static const struct acpi_gpio_params acpi_gpio1 = { 1, 0, false };
484 static const struct acpi_gpio_params acpi_gpio2 = { 2, 0, false };
486 static const struct acpi_gpio_mapping byt_rt5640_hp_elitepad_1000g2_gpios[] = {
487 { "hp-detect-gpios", &acpi_gpio0, 1, },
488 { "headset-mic-detect-gpios", &acpi_gpio1, 1, },
489 { "hp2-detect-gpios", &acpi_gpio2, 1, },
493 static int byt_rt5640_hp_elitepad_1000g2_jack1_check(void *data)
495 struct byt_rt5640_private *priv = data;
496 int jack_status, mic_status;
498 jack_status = gpiod_get_value_cansleep(rt5640_jack_gpio.desc);
502 mic_status = gpiod_get_value_cansleep(priv->hsmic_detect);
504 return SND_JACK_HEADPHONE;
506 return SND_JACK_HEADSET;
509 static int byt_rt5640_hp_elitepad_1000g2_jack2_check(void *data)
511 struct snd_soc_component *component = data;
512 int jack_status, report;
514 jack_status = gpiod_get_value_cansleep(rt5640_jack2_gpio.desc);
518 rt5640_enable_micbias1_for_ovcd(component);
519 report = rt5640_detect_headset(component, rt5640_jack2_gpio.desc);
520 rt5640_disable_micbias1_for_ovcd(component);
525 static int byt_rt5640_aif1_hw_params(struct snd_pcm_substream *substream,
526 struct snd_pcm_hw_params *params)
528 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
529 struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
531 return byt_rt5640_prepare_and_enable_pll1(dai, params_rate(params));
534 /* Please keep this list alphabetically sorted */
535 static const struct dmi_system_id byt_rt5640_quirk_table[] = {
536 { /* Acer Iconia Tab 8 W1-810 */
538 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Acer"),
539 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Iconia W1-810"),
541 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
542 BYT_RT5640_JD_SRC_JD1_IN4P |
543 BYT_RT5640_OVCD_TH_1500UA |
544 BYT_RT5640_OVCD_SF_0P75 |
545 BYT_RT5640_SSP0_AIF1 |
548 { /* Acer One 10 S1002 */
550 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
551 DMI_MATCH(DMI_PRODUCT_NAME, "One S1002"),
553 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
554 BYT_RT5640_JD_SRC_JD2_IN4N |
555 BYT_RT5640_OVCD_TH_2000UA |
556 BYT_RT5640_OVCD_SF_0P75 |
557 BYT_RT5640_DIFF_MIC |
558 BYT_RT5640_SSP0_AIF2 |
563 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
564 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
566 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
567 BYT_RT5640_JD_SRC_JD2_IN4N |
568 BYT_RT5640_OVCD_TH_2000UA |
569 BYT_RT5640_OVCD_SF_0P75 |
570 BYT_RT5640_SSP0_AIF1 |
574 /* Advantech MICA-071 */
576 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Advantech"),
577 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MICA-071"),
579 /* OVCD Th = 1500uA to reliable detect head-phones vs -set */
580 .driver_data = (void *)(BYT_RT5640_IN3_MAP |
581 BYT_RT5640_JD_SRC_JD2_IN4N |
582 BYT_RT5640_OVCD_TH_1500UA |
583 BYT_RT5640_OVCD_SF_0P75 |
584 BYT_RT5640_MONO_SPEAKER |
585 BYT_RT5640_DIFF_MIC |
590 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
591 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 80 Cesium"),
593 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
594 BYT_RT5640_MONO_SPEAKER |
595 BYT_RT5640_SSP0_AIF1 |
600 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
601 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 140 CESIUM"),
603 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
604 BYT_RT5640_JD_SRC_JD2_IN4N |
605 BYT_RT5640_OVCD_TH_2000UA |
606 BYT_RT5640_OVCD_SF_0P75 |
607 BYT_RT5640_SSP0_AIF1 |
612 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
613 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"),
615 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
616 BYT_RT5640_JD_SRC_JD2_IN4N |
617 BYT_RT5640_OVCD_TH_2000UA |
618 BYT_RT5640_OVCD_SF_0P75 |
619 BYT_RT5640_SSP0_AIF1 |
624 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
625 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"),
627 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
628 BYT_RT5640_JD_SRC_JD2_IN4N |
629 BYT_RT5640_OVCD_TH_2000UA |
630 BYT_RT5640_OVCD_SF_0P75 |
635 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
636 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TAF"),
638 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
639 BYT_RT5640_JD_SRC_JD2_IN4N |
640 BYT_RT5640_OVCD_TH_2000UA |
641 BYT_RT5640_OVCD_SF_0P75 |
642 BYT_RT5640_MONO_SPEAKER |
643 BYT_RT5640_DIFF_MIC |
644 BYT_RT5640_SSP0_AIF2 |
647 { /* Chuwi Vi8 (CWI506) */
649 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"),
650 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "i86"),
651 /* The above are too generic, also match BIOS info */
652 DMI_MATCH(DMI_BIOS_VERSION, "CHUWI.D86JLBNR"),
654 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
655 BYT_RT5640_MONO_SPEAKER |
656 BYT_RT5640_SSP0_AIF1 |
660 /* Chuwi Vi10 (CWI505) */
662 DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
663 DMI_MATCH(DMI_BOARD_NAME, "BYT-PF02"),
664 DMI_MATCH(DMI_SYS_VENDOR, "ilife"),
665 DMI_MATCH(DMI_PRODUCT_NAME, "S165"),
667 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
668 BYT_RT5640_JD_SRC_JD2_IN4N |
669 BYT_RT5640_OVCD_TH_2000UA |
670 BYT_RT5640_OVCD_SF_0P75 |
671 BYT_RT5640_DIFF_MIC |
672 BYT_RT5640_SSP0_AIF1 |
676 /* Chuwi Hi8 (CWI509) */
678 DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
679 DMI_MATCH(DMI_BOARD_NAME, "BYT-PA03C"),
680 DMI_MATCH(DMI_SYS_VENDOR, "ilife"),
681 DMI_MATCH(DMI_PRODUCT_NAME, "S806"),
683 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
684 BYT_RT5640_JD_SRC_JD2_IN4N |
685 BYT_RT5640_OVCD_TH_2000UA |
686 BYT_RT5640_OVCD_SF_0P75 |
687 BYT_RT5640_MONO_SPEAKER |
688 BYT_RT5640_DIFF_MIC |
689 BYT_RT5640_SSP0_AIF1 |
694 DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"),
695 DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"),
697 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP),
699 { /* Connect Tablet 9 */
701 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Connect"),
702 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Tablet 9"),
704 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
705 BYT_RT5640_MONO_SPEAKER |
706 BYT_RT5640_SSP0_AIF1 |
711 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
712 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Venue 8 Pro 5830"),
714 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
715 BYT_RT5640_JD_SRC_JD2_IN4N |
716 BYT_RT5640_OVCD_TH_2000UA |
717 BYT_RT5640_OVCD_SF_0P75 |
718 BYT_RT5640_MONO_SPEAKER |
721 { /* Estar Beauty HD MID 7316R */
723 DMI_MATCH(DMI_SYS_VENDOR, "Estar"),
724 DMI_MATCH(DMI_PRODUCT_NAME, "eSTAR BEAUTY HD Intel Quad core"),
726 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
727 BYT_RT5640_MONO_SPEAKER |
728 BYT_RT5640_SSP0_AIF1 |
731 { /* Glavey TM800A550L */
733 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
734 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
735 /* Above strings are too generic, also match on BIOS version */
736 DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"),
738 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
739 BYT_RT5640_SSP0_AIF1 |
744 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
745 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP ElitePad 1000 G2"),
747 .driver_data = (void *)(BYT_RT5640_DMIC2_MAP |
750 BYT_RT5640_LINEOUT_AS_HP2 |
751 BYT_RT5640_HSMIC2_ON_IN1 |
752 BYT_RT5640_JD_HP_ELITEP_1000G2),
754 { /* HP Pavilion x2 10-k0XX, 10-n0XX */
756 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
757 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"),
759 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
760 BYT_RT5640_JD_SRC_JD2_IN4N |
761 BYT_RT5640_OVCD_TH_1500UA |
762 BYT_RT5640_OVCD_SF_0P75 |
763 BYT_RT5640_SSP0_AIF1 |
766 { /* HP Pavilion x2 10-p0XX */
768 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
769 DMI_MATCH(DMI_PRODUCT_NAME, "HP x2 Detachable 10-p0XX"),
771 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
772 BYT_RT5640_JD_SRC_JD1_IN4P |
773 BYT_RT5640_OVCD_TH_2000UA |
774 BYT_RT5640_OVCD_SF_0P75 |
777 { /* HP Pro Tablet 408 */
779 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
780 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pro Tablet 408"),
782 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
783 BYT_RT5640_JD_SRC_JD2_IN4N |
784 BYT_RT5640_OVCD_TH_1500UA |
785 BYT_RT5640_OVCD_SF_0P75 |
786 BYT_RT5640_SSP0_AIF1 |
791 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
792 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP Stream 7 Tablet"),
794 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
795 BYT_RT5640_MONO_SPEAKER |
796 BYT_RT5640_JD_NOT_INV |
797 BYT_RT5640_SSP0_AIF1 |
800 { /* I.T.Works TW891 */
802 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."),
803 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TW891"),
804 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."),
805 DMI_EXACT_MATCH(DMI_BOARD_NAME, "TW891"),
807 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
808 BYT_RT5640_MONO_SPEAKER |
809 BYT_RT5640_SSP0_AIF1 |
812 { /* Lamina I8270 / T701BR.SE */
814 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Lamina"),
815 DMI_EXACT_MATCH(DMI_BOARD_NAME, "T701BR.SE"),
817 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
818 BYT_RT5640_MONO_SPEAKER |
819 BYT_RT5640_JD_NOT_INV |
820 BYT_RT5640_SSP0_AIF1 |
823 { /* Lenovo Miix 2 8 */
825 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
826 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "20326"),
827 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Hiking"),
829 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
830 BYT_RT5640_JD_SRC_JD2_IN4N |
831 BYT_RT5640_OVCD_TH_2000UA |
832 BYT_RT5640_OVCD_SF_0P75 |
833 BYT_RT5640_MONO_SPEAKER |
836 { /* Lenovo Miix 3-830 */
838 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
839 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 3-830"),
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_MONO_SPEAKER |
846 BYT_RT5640_DIFF_MIC |
847 BYT_RT5640_SSP0_AIF1 |
850 { /* Linx Linx7 tablet */
852 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LINX"),
853 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "LINX7"),
855 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
856 BYT_RT5640_MONO_SPEAKER |
857 BYT_RT5640_JD_NOT_INV |
858 BYT_RT5640_SSP0_AIF1 |
861 { /* Mele PCG03 Mini PC */
863 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"),
864 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Mini PC"),
866 .driver_data = (void *)(BYT_RT5640_NO_INTERNAL_MIC_MAP |
867 BYT_RT5640_NO_SPEAKERS |
868 BYT_RT5640_SSP0_AIF1),
870 { /* MPMAN Converter 9, similar hw as the I.T.Works TW891 2-in-1 */
872 DMI_MATCH(DMI_SYS_VENDOR, "MPMAN"),
873 DMI_MATCH(DMI_PRODUCT_NAME, "Converter9"),
875 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
876 BYT_RT5640_MONO_SPEAKER |
877 BYT_RT5640_SSP0_AIF1 |
881 /* MPMAN MPWIN895CL */
883 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MPMAN"),
884 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MPWIN8900CL"),
886 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
887 BYT_RT5640_MONO_SPEAKER |
888 BYT_RT5640_SSP0_AIF1 |
891 { /* MSI S100 tablet */
893 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Micro-Star International Co., Ltd."),
894 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "S100"),
896 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
897 BYT_RT5640_JD_SRC_JD2_IN4N |
898 BYT_RT5640_OVCD_TH_2000UA |
899 BYT_RT5640_OVCD_SF_0P75 |
900 BYT_RT5640_MONO_SPEAKER |
901 BYT_RT5640_DIFF_MIC |
904 { /* Nuvison/TMax TM800W560 */
906 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TMAX"),
907 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TM800W560L"),
909 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
910 BYT_RT5640_JD_SRC_JD2_IN4N |
911 BYT_RT5640_OVCD_TH_2000UA |
912 BYT_RT5640_OVCD_SF_0P75 |
913 BYT_RT5640_JD_NOT_INV |
914 BYT_RT5640_DIFF_MIC |
915 BYT_RT5640_SSP0_AIF1 |
920 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
921 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
922 /* The above are too generic, also match BIOS info */
923 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "5.6.5"),
924 DMI_EXACT_MATCH(DMI_BIOS_DATE, "07/25/2014"),
926 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
927 BYT_RT5640_JD_SRC_JD2_IN4N |
928 BYT_RT5640_OVCD_TH_2000UA |
929 BYT_RT5640_OVCD_SF_0P75 |
930 BYT_RT5640_DIFF_MIC |
935 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
936 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
937 /* The above are too generic, also match BIOS info */
938 DMI_MATCH(DMI_BIOS_VERSION, "V8L_WIN32_CHIPHD"),
940 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
941 BYT_RT5640_MONO_SPEAKER |
942 BYT_RT5640_SSP0_AIF1 |
945 { /* Point of View Mobii TAB-P800W (V2.0) */
947 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
948 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
949 /* The above are too generic, also match BIOS info */
950 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "3BAIR1014"),
951 DMI_EXACT_MATCH(DMI_BIOS_DATE, "10/24/2014"),
953 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
954 BYT_RT5640_JD_SRC_JD2_IN4N |
955 BYT_RT5640_OVCD_TH_2000UA |
956 BYT_RT5640_OVCD_SF_0P75 |
957 BYT_RT5640_MONO_SPEAKER |
958 BYT_RT5640_DIFF_MIC |
959 BYT_RT5640_SSP0_AIF2 |
962 { /* Point of View Mobii TAB-P800W (V2.1) */
964 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
965 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
966 /* The above are too generic, also match BIOS info */
967 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "3BAIR1013"),
968 DMI_EXACT_MATCH(DMI_BIOS_DATE, "08/22/2014"),
970 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
971 BYT_RT5640_JD_SRC_JD2_IN4N |
972 BYT_RT5640_OVCD_TH_2000UA |
973 BYT_RT5640_OVCD_SF_0P75 |
974 BYT_RT5640_MONO_SPEAKER |
975 BYT_RT5640_DIFF_MIC |
976 BYT_RT5640_SSP0_AIF2 |
979 { /* Point of View Mobii TAB-P1005W-232 (V2.0) */
981 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "POV"),
982 DMI_EXACT_MATCH(DMI_BOARD_NAME, "I102A"),
984 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
985 BYT_RT5640_JD_SRC_JD2_IN4N |
986 BYT_RT5640_OVCD_TH_2000UA |
987 BYT_RT5640_OVCD_SF_0P75 |
988 BYT_RT5640_DIFF_MIC |
989 BYT_RT5640_SSP0_AIF1 |
995 DMI_MATCH(DMI_SYS_VENDOR, "Prowise"),
996 DMI_MATCH(DMI_PRODUCT_NAME, "PT301"),
998 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
999 BYT_RT5640_JD_SRC_JD2_IN4N |
1000 BYT_RT5640_OVCD_TH_2000UA |
1001 BYT_RT5640_OVCD_SF_0P75 |
1002 BYT_RT5640_DIFF_MIC |
1003 BYT_RT5640_SSP0_AIF1 |
1004 BYT_RT5640_MCLK_EN),
1009 DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"),
1010 DMI_MATCH(DMI_BOARD_NAME, "tPAD"),
1012 .driver_data = (void *)(BYT_RT5640_IN3_MAP |
1013 BYT_RT5640_JD_SRC_JD1_IN4P |
1014 BYT_RT5640_OVCD_TH_2000UA |
1015 BYT_RT5640_OVCD_SF_1P0 |
1016 BYT_RT5640_SSP0_AIF1 |
1017 BYT_RT5640_MCLK_EN),
1019 { /* Toshiba Satellite Click Mini L9W-B */
1021 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1022 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SATELLITE Click Mini L9W-B"),
1024 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
1025 BYT_RT5640_JD_SRC_JD2_IN4N |
1026 BYT_RT5640_OVCD_TH_1500UA |
1027 BYT_RT5640_OVCD_SF_0P75 |
1028 BYT_RT5640_SSP0_AIF1 |
1029 BYT_RT5640_MCLK_EN),
1031 { /* Toshiba Encore WT8-A */
1033 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1034 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT8-A"),
1036 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
1037 BYT_RT5640_JD_SRC_JD2_IN4N |
1038 BYT_RT5640_OVCD_TH_2000UA |
1039 BYT_RT5640_OVCD_SF_0P75 |
1040 BYT_RT5640_JD_NOT_INV |
1041 BYT_RT5640_MCLK_EN),
1043 { /* Toshiba Encore WT10-A */
1045 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1046 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT10-A-103"),
1048 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
1049 BYT_RT5640_JD_SRC_JD1_IN4P |
1050 BYT_RT5640_OVCD_TH_2000UA |
1051 BYT_RT5640_OVCD_SF_0P75 |
1052 BYT_RT5640_SSP0_AIF2 |
1053 BYT_RT5640_MCLK_EN),
1055 { /* Voyo Winpad A15 */
1057 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
1058 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
1059 /* Above strings are too generic, also match on BIOS date */
1060 DMI_MATCH(DMI_BIOS_DATE, "11/20/2014"),
1062 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
1063 BYT_RT5640_JD_SRC_JD2_IN4N |
1064 BYT_RT5640_OVCD_TH_2000UA |
1065 BYT_RT5640_OVCD_SF_0P75 |
1066 BYT_RT5640_DIFF_MIC |
1067 BYT_RT5640_MCLK_EN),
1069 { /* Catch-all for generic Insyde tablets, must be last */
1071 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
1073 .driver_data = (void *)(BYTCR_INPUT_DEFAULTS |
1074 BYT_RT5640_MCLK_EN |
1075 BYT_RT5640_SSP0_AIF1),
1082 * Note this MUST be called before snd_soc_register_card(), so that the props
1083 * are in place before the codec component driver's probe function parses them.
1085 static int byt_rt5640_add_codec_device_props(struct device *i2c_dev,
1086 struct byt_rt5640_private *priv)
1088 struct property_entry props[MAX_NO_PROPS] = {};
1089 struct fwnode_handle *fwnode;
1093 switch (BYT_RT5640_MAP(byt_rt5640_quirk)) {
1094 case BYT_RT5640_DMIC1_MAP:
1095 props[cnt++] = PROPERTY_ENTRY_U32("realtek,dmic1-data-pin",
1096 RT5640_DMIC1_DATA_PIN_IN1P);
1098 case BYT_RT5640_DMIC2_MAP:
1099 props[cnt++] = PROPERTY_ENTRY_U32("realtek,dmic2-data-pin",
1100 RT5640_DMIC2_DATA_PIN_IN1N);
1102 case BYT_RT5640_IN1_MAP:
1103 if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC)
1105 PROPERTY_ENTRY_BOOL("realtek,in1-differential");
1107 case BYT_RT5640_IN3_MAP:
1108 if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC)
1110 PROPERTY_ENTRY_BOOL("realtek,in3-differential");
1114 if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) {
1115 props[cnt++] = PROPERTY_ENTRY_U32(
1116 "realtek,jack-detect-source",
1117 BYT_RT5640_JDSRC(byt_rt5640_quirk));
1119 props[cnt++] = PROPERTY_ENTRY_U32(
1120 "realtek,over-current-threshold-microamp",
1121 BYT_RT5640_OVCD_TH(byt_rt5640_quirk) * 100);
1123 props[cnt++] = PROPERTY_ENTRY_U32(
1124 "realtek,over-current-scale-factor",
1125 BYT_RT5640_OVCD_SF(byt_rt5640_quirk));
1128 if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV)
1129 props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted");
1131 fwnode = fwnode_create_software_node(props, NULL);
1132 if (IS_ERR(fwnode)) {
1133 /* put_device() is handled in caller */
1134 return PTR_ERR(fwnode);
1137 ret = device_add_software_node(i2c_dev, to_software_node(fwnode));
1139 fwnode_handle_put(fwnode);
1144 static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
1146 struct snd_soc_card *card = runtime->card;
1147 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
1148 struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
1149 const struct snd_soc_dapm_route *custom_map = NULL;
1153 card->dapm.idle_bias_off = true;
1155 /* Start with RC clk for jack-detect (we disable MCLK below) */
1156 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN)
1157 snd_soc_component_update_bits(component, RT5640_GLB_CLK,
1158 RT5640_SCLK_SRC_MASK, RT5640_SCLK_SRC_RCCLK);
1160 rt5640_sel_asrc_clk_src(component,
1161 RT5640_DA_STEREO_FILTER |
1162 RT5640_DA_MONO_L_FILTER |
1163 RT5640_DA_MONO_R_FILTER |
1164 RT5640_AD_STEREO_FILTER |
1165 RT5640_AD_MONO_L_FILTER |
1166 RT5640_AD_MONO_R_FILTER,
1167 RT5640_CLK_SEL_ASRC);
1169 ret = snd_soc_add_card_controls(card, byt_rt5640_controls,
1170 ARRAY_SIZE(byt_rt5640_controls));
1172 dev_err(card->dev, "unable to add card controls\n");
1176 switch (BYT_RT5640_MAP(byt_rt5640_quirk)) {
1177 case BYT_RT5640_IN1_MAP:
1178 custom_map = byt_rt5640_intmic_in1_map;
1179 num_routes = ARRAY_SIZE(byt_rt5640_intmic_in1_map);
1181 case BYT_RT5640_IN3_MAP:
1182 custom_map = byt_rt5640_intmic_in3_map;
1183 num_routes = ARRAY_SIZE(byt_rt5640_intmic_in3_map);
1185 case BYT_RT5640_DMIC1_MAP:
1186 custom_map = byt_rt5640_intmic_dmic1_map;
1187 num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map);
1189 case BYT_RT5640_DMIC2_MAP:
1190 custom_map = byt_rt5640_intmic_dmic2_map;
1191 num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic2_map);
1195 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes);
1199 if (byt_rt5640_quirk & BYT_RT5640_HSMIC2_ON_IN1) {
1200 ret = snd_soc_dapm_add_routes(&card->dapm,
1201 byt_rt5640_hsmic2_in1_map,
1202 ARRAY_SIZE(byt_rt5640_hsmic2_in1_map));
1207 if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) {
1208 ret = snd_soc_dapm_add_routes(&card->dapm,
1209 byt_rt5640_ssp2_aif2_map,
1210 ARRAY_SIZE(byt_rt5640_ssp2_aif2_map));
1211 } else if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) {
1212 ret = snd_soc_dapm_add_routes(&card->dapm,
1213 byt_rt5640_ssp0_aif1_map,
1214 ARRAY_SIZE(byt_rt5640_ssp0_aif1_map));
1215 } else if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) {
1216 ret = snd_soc_dapm_add_routes(&card->dapm,
1217 byt_rt5640_ssp0_aif2_map,
1218 ARRAY_SIZE(byt_rt5640_ssp0_aif2_map));
1220 ret = snd_soc_dapm_add_routes(&card->dapm,
1221 byt_rt5640_ssp2_aif1_map,
1222 ARRAY_SIZE(byt_rt5640_ssp2_aif1_map));
1227 if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) {
1228 ret = snd_soc_dapm_add_routes(&card->dapm,
1229 byt_rt5640_mono_spk_map,
1230 ARRAY_SIZE(byt_rt5640_mono_spk_map));
1231 } else if (!(byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS)) {
1232 ret = snd_soc_dapm_add_routes(&card->dapm,
1233 byt_rt5640_stereo_spk_map,
1234 ARRAY_SIZE(byt_rt5640_stereo_spk_map));
1239 if (byt_rt5640_quirk & BYT_RT5640_LINEOUT) {
1240 ret = snd_soc_dapm_add_routes(&card->dapm,
1241 byt_rt5640_lineout_map,
1242 ARRAY_SIZE(byt_rt5640_lineout_map));
1247 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
1249 * The firmware might enable the clock at
1250 * boot (this information may or may not
1251 * be reflected in the enable clock register).
1252 * To change the rate we must disable the clock
1253 * first to cover these cases. Due to common
1254 * clock framework restrictions that do not allow
1255 * to disable a clock that has not been enabled,
1256 * we need to enable the clock first.
1258 ret = clk_prepare_enable(priv->mclk);
1260 clk_disable_unprepare(priv->mclk);
1262 if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ)
1263 ret = clk_set_rate(priv->mclk, 25000000);
1265 ret = clk_set_rate(priv->mclk, 19200000);
1268 dev_err(card->dev, "unable to set MCLK rate\n");
1273 if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) {
1274 ret = snd_soc_card_jack_new(card, "Headset",
1275 SND_JACK_HEADSET | SND_JACK_BTN_0,
1276 &priv->jack, rt5640_pins,
1277 ARRAY_SIZE(rt5640_pins));
1279 dev_err(card->dev, "Jack creation failed %d\n", ret);
1282 snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0,
1284 snd_soc_component_set_jack(component, &priv->jack, NULL);
1287 if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2) {
1288 ret = snd_soc_card_jack_new(card, "Headset",
1290 &priv->jack, rt5640_pins,
1291 ARRAY_SIZE(rt5640_pins));
1295 ret = snd_soc_card_jack_new(card, "Headset 2",
1297 &priv->jack2, rt5640_pins2,
1298 ARRAY_SIZE(rt5640_pins2));
1302 rt5640_jack_gpio.data = priv;
1303 rt5640_jack_gpio.gpiod_dev = priv->codec_dev;
1304 rt5640_jack_gpio.jack_status_check = byt_rt5640_hp_elitepad_1000g2_jack1_check;
1305 ret = snd_soc_jack_add_gpios(&priv->jack, 1, &rt5640_jack_gpio);
1309 rt5640_set_ovcd_params(component);
1310 rt5640_jack2_gpio.data = component;
1311 rt5640_jack2_gpio.gpiod_dev = priv->codec_dev;
1312 rt5640_jack2_gpio.jack_status_check = byt_rt5640_hp_elitepad_1000g2_jack2_check;
1313 ret = snd_soc_jack_add_gpios(&priv->jack2, 1, &rt5640_jack2_gpio);
1315 snd_soc_jack_free_gpios(&priv->jack, 1, &rt5640_jack_gpio);
1323 static void byt_rt5640_exit(struct snd_soc_pcm_runtime *runtime)
1325 struct snd_soc_card *card = runtime->card;
1326 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
1328 if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2) {
1329 snd_soc_jack_free_gpios(&priv->jack2, 1, &rt5640_jack2_gpio);
1330 snd_soc_jack_free_gpios(&priv->jack, 1, &rt5640_jack_gpio);
1334 static int byt_rt5640_codec_fixup(struct snd_soc_pcm_runtime *rtd,
1335 struct snd_pcm_hw_params *params)
1337 struct snd_interval *rate = hw_param_interval(params,
1338 SNDRV_PCM_HW_PARAM_RATE);
1339 struct snd_interval *channels = hw_param_interval(params,
1340 SNDRV_PCM_HW_PARAM_CHANNELS);
1343 /* The DSP will covert the FE rate to 48k, stereo */
1344 rate->min = rate->max = 48000;
1345 channels->min = channels->max = 2;
1347 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
1348 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1349 /* set SSP0 to 16-bit */
1350 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
1353 /* set SSP2 to 24-bit */
1354 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
1359 * Default mode for SSP configuration is TDM 4 slot, override config
1360 * with explicit setting to I2S 2ch. The word length is set with
1361 * dai_set_tdm_slot() since there is no other API exposed
1363 ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0),
1364 SND_SOC_DAIFMT_I2S |
1365 SND_SOC_DAIFMT_NB_NF |
1366 SND_SOC_DAIFMT_CBS_CFS);
1368 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
1372 ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), 0x3, 0x3, 2, bits);
1374 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
1381 static int byt_rt5640_aif1_startup(struct snd_pcm_substream *substream)
1383 return snd_pcm_hw_constraint_single(substream->runtime,
1384 SNDRV_PCM_HW_PARAM_RATE, 48000);
1387 static const struct snd_soc_ops byt_rt5640_aif1_ops = {
1388 .startup = byt_rt5640_aif1_startup,
1391 static const struct snd_soc_ops byt_rt5640_be_ssp2_ops = {
1392 .hw_params = byt_rt5640_aif1_hw_params,
1395 SND_SOC_DAILINK_DEF(dummy,
1396 DAILINK_COMP_ARRAY(COMP_DUMMY()));
1398 SND_SOC_DAILINK_DEF(media,
1399 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
1401 SND_SOC_DAILINK_DEF(deepbuffer,
1402 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
1404 SND_SOC_DAILINK_DEF(ssp2_port,
1405 /* overwritten for ssp0 routing */
1406 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
1407 SND_SOC_DAILINK_DEF(ssp2_codec,
1408 DAILINK_COMP_ARRAY(COMP_CODEC(
1409 /* overwritten with HID */ "i2c-10EC5640:00",
1410 /* changed w/ quirk */ "rt5640-aif1")));
1412 SND_SOC_DAILINK_DEF(platform,
1413 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
1415 static struct snd_soc_dai_link byt_rt5640_dais[] = {
1416 [MERR_DPCM_AUDIO] = {
1417 .name = "Baytrail Audio Port",
1418 .stream_name = "Baytrail Audio",
1423 .ops = &byt_rt5640_aif1_ops,
1424 SND_SOC_DAILINK_REG(media, dummy, platform),
1426 [MERR_DPCM_DEEP_BUFFER] = {
1427 .name = "Deep-Buffer Audio Port",
1428 .stream_name = "Deep-Buffer Audio",
1432 .ops = &byt_rt5640_aif1_ops,
1433 SND_SOC_DAILINK_REG(deepbuffer, dummy, platform),
1437 .name = "SSP2-Codec",
1440 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
1441 | SND_SOC_DAIFMT_CBS_CFS,
1442 .be_hw_params_fixup = byt_rt5640_codec_fixup,
1445 .init = byt_rt5640_init,
1446 .exit = byt_rt5640_exit,
1447 .ops = &byt_rt5640_be_ssp2_ops,
1448 SND_SOC_DAILINK_REG(ssp2_port, ssp2_codec, platform),
1453 static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN];
1454 #if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
1455 static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */
1457 static char byt_rt5640_components[64]; /* = "cfg-spk:* cfg-mic:* ..." */
1459 static int byt_rt5640_suspend(struct snd_soc_card *card)
1461 struct snd_soc_component *component;
1463 if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
1466 for_each_card_components(card, component) {
1467 if (!strcmp(component->name, byt_rt5640_codec_name)) {
1468 dev_dbg(component->dev, "disabling jack detect before suspend\n");
1469 snd_soc_component_set_jack(component, NULL, NULL);
1477 static int byt_rt5640_resume(struct snd_soc_card *card)
1479 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
1480 struct snd_soc_component *component;
1482 if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
1485 for_each_card_components(card, component) {
1486 if (!strcmp(component->name, byt_rt5640_codec_name)) {
1487 dev_dbg(component->dev, "re-enabling jack detect after resume\n");
1488 snd_soc_component_set_jack(component, &priv->jack, NULL);
1496 /* use space before codec name to simplify card ID, and simplify driver name */
1497 #define SOF_CARD_NAME "bytcht rt5640" /* card name will be 'sof-bytcht rt5640' */
1498 #define SOF_DRIVER_NAME "SOF"
1500 #define CARD_NAME "bytcr-rt5640"
1501 #define DRIVER_NAME NULL /* card name will be used for driver name */
1503 static struct snd_soc_card byt_rt5640_card = {
1504 .owner = THIS_MODULE,
1505 .dai_link = byt_rt5640_dais,
1506 .num_links = ARRAY_SIZE(byt_rt5640_dais),
1507 .dapm_widgets = byt_rt5640_widgets,
1508 .num_dapm_widgets = ARRAY_SIZE(byt_rt5640_widgets),
1509 .dapm_routes = byt_rt5640_audio_map,
1510 .num_dapm_routes = ARRAY_SIZE(byt_rt5640_audio_map),
1511 .fully_routed = true,
1512 .suspend_pre = byt_rt5640_suspend,
1513 .resume_post = byt_rt5640_resume,
1516 struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
1517 u64 aif_value; /* 1: AIF1, 2: AIF2 */
1518 u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */
1521 static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
1523 struct device *dev = &pdev->dev;
1524 static const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3", "none" };
1525 __maybe_unused const char *spk_type;
1526 const struct dmi_system_id *dmi_id;
1527 const char *headset2_string = "";
1528 const char *lineout_string = "";
1529 struct byt_rt5640_private *priv;
1530 struct snd_soc_acpi_mach *mach;
1531 const char *platform_name;
1532 struct acpi_device *adev;
1533 struct device *codec_dev;
1541 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
1545 /* register the soc card */
1546 byt_rt5640_card.dev = &pdev->dev;
1547 mach = byt_rt5640_card.dev->platform_data;
1548 snd_soc_card_set_drvdata(&byt_rt5640_card, priv);
1550 /* fix index of codec dai */
1551 for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) {
1552 if (!strcmp(byt_rt5640_dais[i].codecs->name,
1553 "i2c-10EC5640:00")) {
1559 /* fixup codec name based on HID */
1560 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
1562 snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name),
1563 "i2c-%s", acpi_dev_name(adev));
1564 put_device(&adev->dev);
1565 byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name;
1567 dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
1572 * swap SSP0 if bytcr is detected
1573 * (will be overridden if DMI quirk is detected)
1575 if (soc_intel_is_byt()) {
1576 if (mach->mach_params.acpi_ipc_irq_index == 0)
1582 * Baytrail CR platforms may have CHAN package in BIOS, try
1583 * to find relevant routing quirk based as done on Windows
1584 * platforms. We have to read the information directly from the
1585 * BIOS, at this stage the card is not created and the links
1586 * with the codec driver/pdata are non-existent
1589 struct acpi_chan_package chan_package;
1591 /* format specified: 2 64-bit integers */
1592 struct acpi_buffer format = {sizeof("NN"), "NN"};
1593 struct acpi_buffer state = {0, NULL};
1594 struct snd_soc_acpi_package_context pkg_ctx;
1595 bool pkg_found = false;
1597 state.length = sizeof(chan_package);
1598 state.pointer = &chan_package;
1600 pkg_ctx.name = "CHAN";
1602 pkg_ctx.format = &format;
1603 pkg_ctx.state = &state;
1604 pkg_ctx.data_valid = false;
1606 pkg_found = snd_soc_acpi_find_package_from_hid(mach->id,
1609 if (chan_package.aif_value == 1) {
1610 dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n");
1611 byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF1;
1612 } else if (chan_package.aif_value == 2) {
1613 dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n");
1614 byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF2;
1616 dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n");
1622 /* no BIOS indications, assume SSP0-AIF2 connection */
1623 byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF2;
1626 /* change defaults for Baytrail-CR capture */
1627 byt_rt5640_quirk |= BYTCR_INPUT_DEFAULTS;
1629 byt_rt5640_quirk |= BYT_RT5640_DMIC1_MAP |
1630 BYT_RT5640_JD_SRC_JD2_IN4N |
1631 BYT_RT5640_OVCD_TH_2000UA |
1632 BYT_RT5640_OVCD_SF_0P75;
1635 /* check quirks before creating card */
1636 dmi_id = dmi_first_match(byt_rt5640_quirk_table);
1638 byt_rt5640_quirk = (unsigned long)dmi_id->driver_data;
1639 if (quirk_override != -1) {
1640 dev_info(&pdev->dev, "Overriding quirk 0x%lx => 0x%x\n",
1641 byt_rt5640_quirk, quirk_override);
1642 byt_rt5640_quirk = quirk_override;
1645 codec_dev = acpi_get_first_physical_node(adev);
1647 return -EPROBE_DEFER;
1648 priv->codec_dev = get_device(codec_dev);
1650 if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2) {
1651 acpi_dev_add_driver_gpios(ACPI_COMPANION(priv->codec_dev),
1652 byt_rt5640_hp_elitepad_1000g2_gpios);
1654 priv->hsmic_detect = devm_fwnode_gpiod_get(&pdev->dev, codec_dev->fwnode,
1655 "headset-mic-detect", GPIOD_IN,
1656 "headset-mic-detect");
1657 if (IS_ERR(priv->hsmic_detect)) {
1658 ret_val = PTR_ERR(priv->hsmic_detect);
1659 dev_err_probe(&pdev->dev, ret_val, "getting hsmic-detect GPIO\n");
1664 /* Must be called before register_card, also see declaration comment. */
1665 ret_val = byt_rt5640_add_codec_device_props(codec_dev, priv);
1667 goto err_remove_gpios;
1669 log_quirks(&pdev->dev);
1671 if ((byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) ||
1672 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
1673 byt_rt5640_dais[dai_index].codecs->dai_name = "rt5640-aif2";
1679 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
1680 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2))
1681 byt_rt5640_dais[dai_index].cpus->dai_name = "ssp0-port";
1683 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
1684 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
1685 if (IS_ERR(priv->mclk)) {
1686 ret_val = PTR_ERR(priv->mclk);
1689 "Failed to get MCLK from pmc_plt_clk_3: %d\n",
1693 * Fall back to bit clock usage for -ENOENT (clock not
1694 * available likely due to missing dependencies), bail
1695 * for all other errors, including -EPROBE_DEFER
1697 if (ret_val != -ENOENT)
1699 byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN;
1703 if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS) {
1706 } else if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) {
1711 spk_type = "stereo";
1714 if (byt_rt5640_quirk & BYT_RT5640_LINEOUT) {
1715 if (byt_rt5640_quirk & BYT_RT5640_LINEOUT_AS_HP2)
1716 lineout_string = " cfg-hp2:lineout";
1718 lineout_string = " cfg-lineout:2";
1721 if (byt_rt5640_quirk & BYT_RT5640_HSMIC2_ON_IN1)
1722 headset2_string = " cfg-hs2:in1";
1724 snprintf(byt_rt5640_components, sizeof(byt_rt5640_components),
1725 "cfg-spk:%d cfg-mic:%s aif:%d%s%s", cfg_spk,
1726 map_name[BYT_RT5640_MAP(byt_rt5640_quirk)], aif,
1727 lineout_string, headset2_string);
1728 byt_rt5640_card.components = byt_rt5640_components;
1729 #if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
1730 snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name),
1731 "bytcr-rt5640-%s-spk-%s-mic", spk_type,
1732 map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
1733 byt_rt5640_card.long_name = byt_rt5640_long_name;
1736 /* override plaform name, if required */
1737 platform_name = mach->mach_params.platform;
1739 ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5640_card,
1744 sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
1746 /* set card and driver name */
1748 byt_rt5640_card.name = SOF_CARD_NAME;
1749 byt_rt5640_card.driver_name = SOF_DRIVER_NAME;
1751 byt_rt5640_card.name = CARD_NAME;
1752 byt_rt5640_card.driver_name = DRIVER_NAME;
1757 dev->driver->pm = &snd_soc_pm_ops;
1759 ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5640_card);
1762 dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n",
1766 platform_set_drvdata(pdev, &byt_rt5640_card);
1770 device_remove_software_node(priv->codec_dev);
1772 if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2)
1773 acpi_dev_remove_driver_gpios(ACPI_COMPANION(priv->codec_dev));
1775 put_device(priv->codec_dev);
1779 static int snd_byt_rt5640_mc_remove(struct platform_device *pdev)
1781 struct snd_soc_card *card = platform_get_drvdata(pdev);
1782 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
1784 if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2)
1785 acpi_dev_remove_driver_gpios(ACPI_COMPANION(priv->codec_dev));
1787 device_remove_software_node(priv->codec_dev);
1788 put_device(priv->codec_dev);
1792 static struct platform_driver snd_byt_rt5640_mc_driver = {
1794 .name = "bytcr_rt5640",
1796 .probe = snd_byt_rt5640_mc_probe,
1797 .remove = snd_byt_rt5640_mc_remove,
1800 module_platform_driver(snd_byt_rt5640_mc_driver);
1802 MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver");
1803 MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>");
1804 MODULE_LICENSE("GPL v2");
1805 MODULE_ALIAS("platform:bytcr_rt5640");