1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright(c) 2018 Intel Corporation.
5 * Intel Kabylake I2S Machine Driver with MAX98927 & DA7219 Codecs
8 * Intel Kabylake I2S Machine driver supporting MAX98927 and
12 #include <linux/input.h>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <sound/core.h>
16 #include <sound/jack.h>
17 #include <sound/pcm.h>
18 #include <sound/pcm_params.h>
19 #include <sound/soc.h>
20 #include "../../codecs/da7219.h"
21 #include "../../codecs/hdac_hdmi.h"
22 #include "../skylake/skl.h"
23 #include "../../codecs/da7219-aad.h"
25 #define KBL_DIALOG_CODEC_DAI "da7219-hifi"
26 #define MAX98927_CODEC_DAI "max98927-aif1"
27 #define MAXIM_DEV0_NAME "i2c-MX98927:00"
28 #define MAXIM_DEV1_NAME "i2c-MX98927:01"
29 #define DUAL_CHANNEL 2
30 #define QUAD_CHANNEL 4
33 static struct snd_soc_card *kabylake_audio_card;
34 static struct snd_soc_jack kabylake_hdmi[3];
37 struct list_head head;
38 struct snd_soc_dai *codec_dai;
42 struct kbl_codec_private {
43 struct snd_soc_jack kabylake_headset;
44 struct list_head hdmi_pcm_list;
48 KBL_DPCM_AUDIO_PB = 0,
50 KBL_DPCM_AUDIO_ECHO_REF_CP,
51 KBL_DPCM_AUDIO_REF_CP,
52 KBL_DPCM_AUDIO_DMIC_CP,
53 KBL_DPCM_AUDIO_HDMI1_PB,
54 KBL_DPCM_AUDIO_HDMI2_PB,
55 KBL_DPCM_AUDIO_HDMI3_PB,
59 static int platform_clock_control(struct snd_soc_dapm_widget *w,
60 struct snd_kcontrol *k, int event)
62 struct snd_soc_dapm_context *dapm = w->dapm;
63 struct snd_soc_card *card = dapm->card;
64 struct snd_soc_dai *codec_dai;
67 codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI);
69 dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
73 /* Configure sysclk for codec */
74 ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000,
77 dev_err(card->dev, "can't set codec sysclk configuration\n");
81 if (SND_SOC_DAPM_EVENT_OFF(event)) {
82 ret = snd_soc_dai_set_pll(codec_dai, 0,
83 DA7219_SYSCLK_MCLK, 0, 0);
85 dev_err(card->dev, "failed to stop PLL: %d\n", ret);
86 } else if (SND_SOC_DAPM_EVENT_ON(event)) {
87 ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM,
88 0, DA7219_PLL_FREQ_OUT_98304);
90 dev_err(card->dev, "failed to start PLL: %d\n", ret);
96 static const struct snd_kcontrol_new kabylake_controls[] = {
97 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
98 SOC_DAPM_PIN_SWITCH("Headset Mic"),
99 SOC_DAPM_PIN_SWITCH("Left Spk"),
100 SOC_DAPM_PIN_SWITCH("Right Spk"),
103 static const struct snd_soc_dapm_widget kabylake_widgets[] = {
104 SND_SOC_DAPM_HP("Headphone Jack", NULL),
105 SND_SOC_DAPM_MIC("Headset Mic", NULL),
106 SND_SOC_DAPM_SPK("Left Spk", NULL),
107 SND_SOC_DAPM_SPK("Right Spk", NULL),
108 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
109 SND_SOC_DAPM_SPK("DP", NULL),
110 SND_SOC_DAPM_SPK("HDMI", NULL),
111 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
112 platform_clock_control, SND_SOC_DAPM_PRE_PMU |
113 SND_SOC_DAPM_POST_PMD),
116 static const struct snd_soc_dapm_route kabylake_map[] = {
118 { "Left Spk", NULL, "Left BE_OUT" },
119 { "Right Spk", NULL, "Right BE_OUT" },
122 { "DMic", NULL, "SoC DMIC" },
124 { "HDMI", NULL, "hif5 Output" },
125 { "DP", NULL, "hif6 Output" },
127 /* CODEC BE connections */
128 { "Left HiFi Playback", NULL, "ssp0 Tx" },
129 { "Right HiFi Playback", NULL, "ssp0 Tx" },
130 { "ssp0 Tx", NULL, "spk_out" },
132 /* IV feedback path */
133 { "codec0_fb_in", NULL, "ssp0 Rx"},
134 { "ssp0 Rx", NULL, "Left HiFi Capture" },
135 { "ssp0 Rx", NULL, "Right HiFi Capture" },
137 /* AEC capture path */
138 { "echo_ref_out", NULL, "ssp0 Rx" },
141 { "dmic01_hifi", NULL, "DMIC01 Rx" },
142 { "DMIC01 Rx", NULL, "DMIC AIF" },
144 { "hifi1", NULL, "iDisp1 Tx" },
145 { "iDisp1 Tx", NULL, "iDisp1_out" },
146 { "hifi2", NULL, "iDisp2 Tx" },
147 { "iDisp2 Tx", NULL, "iDisp2_out" },
148 { "hifi3", NULL, "iDisp3 Tx"},
149 { "iDisp3 Tx", NULL, "iDisp3_out"},
152 static const struct snd_soc_dapm_route kabylake_ssp1_map[] = {
153 { "Headphone Jack", NULL, "HPL" },
154 { "Headphone Jack", NULL, "HPR" },
157 { "MIC", NULL, "Headset Mic" },
159 /* CODEC BE connections */
160 { "Playback", NULL, "ssp1 Tx" },
161 { "ssp1 Tx", NULL, "codec1_out" },
163 { "hs_in", NULL, "ssp1 Rx" },
164 { "ssp1 Rx", NULL, "Capture" },
166 { "Headphone Jack", NULL, "Platform Clock" },
167 { "Headset Mic", NULL, "Platform Clock" },
170 static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
171 struct snd_pcm_hw_params *params)
173 struct snd_soc_pcm_runtime *runtime = substream->private_data;
176 for (j = 0; j < runtime->num_codecs; j++) {
177 struct snd_soc_dai *codec_dai = runtime->codec_dais[j];
179 if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
180 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16);
182 dev_err(runtime->dev, "DEV0 TDM slot err:%d\n", ret);
186 if (!strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) {
187 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC0, 3, 8, 16);
189 dev_err(runtime->dev, "DEV1 TDM slot err:%d\n", ret);
198 static struct snd_soc_ops kabylake_ssp0_ops = {
199 .hw_params = kabylake_ssp0_hw_params,
202 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
203 struct snd_pcm_hw_params *params)
205 struct snd_interval *rate = hw_param_interval(params,
206 SNDRV_PCM_HW_PARAM_RATE);
207 struct snd_interval *channels = hw_param_interval(params,
208 SNDRV_PCM_HW_PARAM_CHANNELS);
209 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
210 struct snd_soc_dpcm *dpcm = container_of(
211 params, struct snd_soc_dpcm, hw_params);
212 struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
213 struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
216 * The ADSP will convert the FE rate to 48k, stereo, 24 bit
218 if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
219 !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
220 !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
221 rate->min = rate->max = 48000;
222 channels->min = channels->max = 2;
224 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
228 * The speaker on the SSP0 supports S16_LE and not S24_LE.
229 * thus changing the mask here
231 if (!strcmp(be_dai_link->name, "SSP0-Codec"))
232 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
237 static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
239 struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
240 struct snd_soc_component *component = rtd->codec_dai->component;
241 struct snd_soc_jack *jack;
242 struct snd_soc_card *card = rtd->card;
246 ret = snd_soc_dapm_add_routes(&card->dapm,
248 ARRAY_SIZE(kabylake_ssp1_map));
251 * Headset buttons map to the google Reference headset.
252 * These can be configured by userspace.
254 ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack",
255 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
256 SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
257 &ctx->kabylake_headset, NULL, 0);
259 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
263 jack = &ctx->kabylake_headset;
264 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
265 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
266 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
267 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
269 da7219_aad_jack_det(component, &ctx->kabylake_headset);
271 ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
273 dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret);
278 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
280 struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
281 struct snd_soc_dai *dai = rtd->codec_dai;
282 struct kbl_hdmi_pcm *pcm;
284 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
288 pcm->device = device;
289 pcm->codec_dai = dai;
291 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
296 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
298 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
301 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
303 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
306 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
308 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
311 static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
313 struct snd_soc_dapm_context *dapm;
314 struct snd_soc_component *component = rtd->cpu_dai->component;
316 dapm = snd_soc_component_get_dapm(component);
317 snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
322 static const unsigned int rates[] = {
326 static const struct snd_pcm_hw_constraint_list constraints_rates = {
327 .count = ARRAY_SIZE(rates),
332 static const unsigned int channels[] = {
336 static const struct snd_pcm_hw_constraint_list constraints_channels = {
337 .count = ARRAY_SIZE(channels),
342 static unsigned int channels_quad[] = {
346 static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
347 .count = ARRAY_SIZE(channels_quad),
348 .list = channels_quad,
352 static int kbl_fe_startup(struct snd_pcm_substream *substream)
354 struct snd_pcm_runtime *runtime = substream->runtime;
357 * On this platform for PCM device we support,
363 runtime->hw.channels_max = DUAL_CHANNEL;
364 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
365 &constraints_channels);
367 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
368 snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
370 snd_pcm_hw_constraint_list(runtime, 0,
371 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
376 static const struct snd_soc_ops kabylake_da7219_fe_ops = {
377 .startup = kbl_fe_startup,
380 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
381 struct snd_pcm_hw_params *params)
383 struct snd_interval *channels = hw_param_interval(params,
384 SNDRV_PCM_HW_PARAM_CHANNELS);
387 * set BE channel constraint as user FE channels
390 if (params_channels(params) == 2)
391 channels->min = channels->max = 2;
393 channels->min = channels->max = 4;
398 static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
400 struct snd_pcm_runtime *runtime = substream->runtime;
402 runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
403 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
404 &constraints_channels_quad);
406 return snd_pcm_hw_constraint_list(substream->runtime, 0,
407 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
410 static struct snd_soc_ops kabylake_dmic_ops = {
411 .startup = kabylake_dmic_startup,
414 static const unsigned int rates_16000[] = {
418 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
419 .count = ARRAY_SIZE(rates_16000),
423 static const unsigned int ch_mono[] = {
426 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
427 .count = ARRAY_SIZE(ch_mono),
431 static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
433 substream->runtime->hw.channels_max = 1;
434 snd_pcm_hw_constraint_list(substream->runtime, 0,
435 SNDRV_PCM_HW_PARAM_CHANNELS,
436 &constraints_refcap);
438 return snd_pcm_hw_constraint_list(substream->runtime, 0,
439 SNDRV_PCM_HW_PARAM_RATE,
444 static struct snd_soc_ops skylake_refcap_ops = {
445 .startup = kabylake_refcap_startup,
448 static struct snd_soc_codec_conf max98927_codec_conf[] = {
451 .dev_name = MAXIM_DEV0_NAME,
452 .name_prefix = "Right",
456 .dev_name = MAXIM_DEV1_NAME,
457 .name_prefix = "Left",
461 static struct snd_soc_dai_link_component ssp0_codec_components[] = {
463 .name = MAXIM_DEV0_NAME,
464 .dai_name = MAX98927_CODEC_DAI,
468 .name = MAXIM_DEV1_NAME,
469 .dai_name = MAX98927_CODEC_DAI,
474 /* kabylake digital audio interface glue - connects codec <--> CPU */
475 static struct snd_soc_dai_link kabylake_dais[] = {
476 /* Front End DAI links */
477 [KBL_DPCM_AUDIO_PB] = {
478 .name = "Kbl Audio Port",
479 .stream_name = "Audio",
480 .cpu_dai_name = "System Pin",
481 .platform_name = "0000:00:1f.3",
483 .codec_name = "snd-soc-dummy",
484 .codec_dai_name = "snd-soc-dummy-dai",
486 .init = kabylake_da7219_fe_init,
488 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
490 .ops = &kabylake_da7219_fe_ops,
492 [KBL_DPCM_AUDIO_CP] = {
493 .name = "Kbl Audio Capture Port",
494 .stream_name = "Audio Record",
495 .cpu_dai_name = "System Pin",
496 .platform_name = "0000:00:1f.3",
498 .codec_name = "snd-soc-dummy",
499 .codec_dai_name = "snd-soc-dummy-dai",
502 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
504 .ops = &kabylake_da7219_fe_ops,
506 [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
507 .name = "Kbl Audio Echo Reference cap",
508 .stream_name = "Echoreference Capture",
509 .cpu_dai_name = "Echoref Pin",
510 .codec_name = "snd-soc-dummy",
511 .codec_dai_name = "snd-soc-dummy-dai",
512 .platform_name = "0000:00:1f.3",
517 [KBL_DPCM_AUDIO_REF_CP] = {
518 .name = "Kbl Audio Reference cap",
519 .stream_name = "Wake on Voice",
520 .cpu_dai_name = "Reference Pin",
521 .codec_name = "snd-soc-dummy",
522 .codec_dai_name = "snd-soc-dummy-dai",
523 .platform_name = "0000:00:1f.3",
528 .ops = &skylake_refcap_ops,
530 [KBL_DPCM_AUDIO_DMIC_CP] = {
531 .name = "Kbl Audio DMIC cap",
532 .stream_name = "dmiccap",
533 .cpu_dai_name = "DMIC Pin",
534 .codec_name = "snd-soc-dummy",
535 .codec_dai_name = "snd-soc-dummy-dai",
536 .platform_name = "0000:00:1f.3",
541 .ops = &kabylake_dmic_ops,
543 [KBL_DPCM_AUDIO_HDMI1_PB] = {
544 .name = "Kbl HDMI Port1",
545 .stream_name = "Hdmi1",
546 .cpu_dai_name = "HDMI1 Pin",
547 .codec_name = "snd-soc-dummy",
548 .codec_dai_name = "snd-soc-dummy-dai",
549 .platform_name = "0000:00:1f.3",
553 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
557 [KBL_DPCM_AUDIO_HDMI2_PB] = {
558 .name = "Kbl HDMI Port2",
559 .stream_name = "Hdmi2",
560 .cpu_dai_name = "HDMI2 Pin",
561 .codec_name = "snd-soc-dummy",
562 .codec_dai_name = "snd-soc-dummy-dai",
563 .platform_name = "0000:00:1f.3",
567 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
571 [KBL_DPCM_AUDIO_HDMI3_PB] = {
572 .name = "Kbl HDMI Port3",
573 .stream_name = "Hdmi3",
574 .cpu_dai_name = "HDMI3 Pin",
575 .codec_name = "snd-soc-dummy",
576 .codec_dai_name = "snd-soc-dummy-dai",
577 .platform_name = "0000:00:1f.3",
579 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
585 [KBL_DPCM_AUDIO_HS_PB] = {
586 .name = "Kbl Audio Headset Playback",
587 .stream_name = "Headset Audio",
588 .cpu_dai_name = "System Pin2",
589 .codec_name = "snd-soc-dummy",
590 .codec_dai_name = "snd-soc-dummy-dai",
591 .platform_name = "0000:00:1f.3",
595 .init = kabylake_da7219_fe_init,
597 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
598 .ops = &kabylake_da7219_fe_ops,
602 /* Back End DAI links */
605 .name = "SSP0-Codec",
607 .cpu_dai_name = "SSP0 Pin",
608 .platform_name = "0000:00:1f.3",
610 .codecs = ssp0_codec_components,
611 .num_codecs = ARRAY_SIZE(ssp0_codec_components),
612 .dai_fmt = SND_SOC_DAIFMT_DSP_B |
613 SND_SOC_DAIFMT_NB_NF |
614 SND_SOC_DAIFMT_CBS_CFS,
617 .ignore_pmdown_time = 1,
618 .be_hw_params_fixup = kabylake_ssp_fixup,
619 .ops = &kabylake_ssp0_ops,
623 .name = "SSP1-Codec",
625 .cpu_dai_name = "SSP1 Pin",
626 .platform_name = "0000:00:1f.3",
628 .codec_name = "i2c-DLGS7219:00",
629 .codec_dai_name = KBL_DIALOG_CODEC_DAI,
630 .init = kabylake_da7219_codec_init,
631 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
632 SND_SOC_DAIFMT_CBS_CFS,
633 .ignore_pmdown_time = 1,
634 .be_hw_params_fixup = kabylake_ssp_fixup,
641 .cpu_dai_name = "DMIC01 Pin",
642 .codec_name = "dmic-codec",
643 .codec_dai_name = "dmic-hifi",
644 .platform_name = "0000:00:1f.3",
645 .be_hw_params_fixup = kabylake_dmic_fixup,
653 .cpu_dai_name = "iDisp1 Pin",
654 .codec_name = "ehdaudio0D2",
655 .codec_dai_name = "intel-hdmi-hifi1",
656 .platform_name = "0000:00:1f.3",
658 .init = kabylake_hdmi1_init,
664 .cpu_dai_name = "iDisp2 Pin",
665 .codec_name = "ehdaudio0D2",
666 .codec_dai_name = "intel-hdmi-hifi2",
667 .platform_name = "0000:00:1f.3",
668 .init = kabylake_hdmi2_init,
675 .cpu_dai_name = "iDisp3 Pin",
676 .codec_name = "ehdaudio0D2",
677 .codec_dai_name = "intel-hdmi-hifi3",
678 .platform_name = "0000:00:1f.3",
679 .init = kabylake_hdmi3_init,
685 /* kabylake digital audio interface glue - connects codec <--> CPU */
686 static struct snd_soc_dai_link kabylake_max98927_dais[] = {
687 /* Front End DAI links */
688 [KBL_DPCM_AUDIO_PB] = {
689 .name = "Kbl Audio Port",
690 .stream_name = "Audio",
691 .cpu_dai_name = "System Pin",
692 .platform_name = "0000:00:1f.3",
694 .codec_name = "snd-soc-dummy",
695 .codec_dai_name = "snd-soc-dummy-dai",
697 .init = kabylake_da7219_fe_init,
699 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
701 .ops = &kabylake_da7219_fe_ops,
703 [KBL_DPCM_AUDIO_CP] = {
704 .name = "Kbl Audio Capture Port",
705 .stream_name = "Audio Record",
706 .cpu_dai_name = "System Pin",
707 .platform_name = "0000:00:1f.3",
709 .codec_name = "snd-soc-dummy",
710 .codec_dai_name = "snd-soc-dummy-dai",
713 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
715 .ops = &kabylake_da7219_fe_ops,
717 [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
718 .name = "Kbl Audio Echo Reference cap",
719 .stream_name = "Echoreference Capture",
720 .cpu_dai_name = "Echoref Pin",
721 .codec_name = "snd-soc-dummy",
722 .codec_dai_name = "snd-soc-dummy-dai",
723 .platform_name = "0000:00:1f.3",
728 [KBL_DPCM_AUDIO_REF_CP] = {
729 .name = "Kbl Audio Reference cap",
730 .stream_name = "Wake on Voice",
731 .cpu_dai_name = "Reference Pin",
732 .codec_name = "snd-soc-dummy",
733 .codec_dai_name = "snd-soc-dummy-dai",
734 .platform_name = "0000:00:1f.3",
739 .ops = &skylake_refcap_ops,
741 [KBL_DPCM_AUDIO_DMIC_CP] = {
742 .name = "Kbl Audio DMIC cap",
743 .stream_name = "dmiccap",
744 .cpu_dai_name = "DMIC Pin",
745 .codec_name = "snd-soc-dummy",
746 .codec_dai_name = "snd-soc-dummy-dai",
747 .platform_name = "0000:00:1f.3",
752 .ops = &kabylake_dmic_ops,
754 [KBL_DPCM_AUDIO_HDMI1_PB] = {
755 .name = "Kbl HDMI Port1",
756 .stream_name = "Hdmi1",
757 .cpu_dai_name = "HDMI1 Pin",
758 .codec_name = "snd-soc-dummy",
759 .codec_dai_name = "snd-soc-dummy-dai",
760 .platform_name = "0000:00:1f.3",
764 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
768 [KBL_DPCM_AUDIO_HDMI2_PB] = {
769 .name = "Kbl HDMI Port2",
770 .stream_name = "Hdmi2",
771 .cpu_dai_name = "HDMI2 Pin",
772 .codec_name = "snd-soc-dummy",
773 .codec_dai_name = "snd-soc-dummy-dai",
774 .platform_name = "0000:00:1f.3",
778 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
782 [KBL_DPCM_AUDIO_HDMI3_PB] = {
783 .name = "Kbl HDMI Port3",
784 .stream_name = "Hdmi3",
785 .cpu_dai_name = "HDMI3 Pin",
786 .codec_name = "snd-soc-dummy",
787 .codec_dai_name = "snd-soc-dummy-dai",
788 .platform_name = "0000:00:1f.3",
790 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
797 /* Back End DAI links */
800 .name = "SSP0-Codec",
802 .cpu_dai_name = "SSP0 Pin",
803 .platform_name = "0000:00:1f.3",
805 .codecs = ssp0_codec_components,
806 .num_codecs = ARRAY_SIZE(ssp0_codec_components),
807 .dai_fmt = SND_SOC_DAIFMT_DSP_B |
808 SND_SOC_DAIFMT_NB_NF |
809 SND_SOC_DAIFMT_CBS_CFS,
812 .ignore_pmdown_time = 1,
813 .be_hw_params_fixup = kabylake_ssp_fixup,
814 .ops = &kabylake_ssp0_ops,
819 .cpu_dai_name = "DMIC01 Pin",
820 .codec_name = "dmic-codec",
821 .codec_dai_name = "dmic-hifi",
822 .platform_name = "0000:00:1f.3",
823 .be_hw_params_fixup = kabylake_dmic_fixup,
831 .cpu_dai_name = "iDisp1 Pin",
832 .codec_name = "ehdaudio0D2",
833 .codec_dai_name = "intel-hdmi-hifi1",
834 .platform_name = "0000:00:1f.3",
836 .init = kabylake_hdmi1_init,
842 .cpu_dai_name = "iDisp2 Pin",
843 .codec_name = "ehdaudio0D2",
844 .codec_dai_name = "intel-hdmi-hifi2",
845 .platform_name = "0000:00:1f.3",
846 .init = kabylake_hdmi2_init,
853 .cpu_dai_name = "iDisp3 Pin",
854 .codec_name = "ehdaudio0D2",
855 .codec_dai_name = "intel-hdmi-hifi3",
856 .platform_name = "0000:00:1f.3",
857 .init = kabylake_hdmi3_init,
863 static int kabylake_card_late_probe(struct snd_soc_card *card)
865 struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
866 struct kbl_hdmi_pcm *pcm;
867 struct snd_soc_component *component = NULL;
869 char jack_name[NAME_SIZE];
871 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
872 component = pcm->codec_dai->component;
873 snprintf(jack_name, sizeof(jack_name),
874 "HDMI/DP, pcm=%d Jack", pcm->device);
875 err = snd_soc_card_jack_new(card, jack_name,
876 SND_JACK_AVOUT, &kabylake_hdmi[i],
882 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
893 return hdac_hdmi_jack_port_init(component, &card->dapm);
898 /* kabylake audio machine driver for SPT + DA7219 */
899 static struct snd_soc_card kbl_audio_card_da7219_m98927 = {
900 .name = "kblda7219m98927",
901 .owner = THIS_MODULE,
902 .dai_link = kabylake_dais,
903 .num_links = ARRAY_SIZE(kabylake_dais),
904 .controls = kabylake_controls,
905 .num_controls = ARRAY_SIZE(kabylake_controls),
906 .dapm_widgets = kabylake_widgets,
907 .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
908 .dapm_routes = kabylake_map,
909 .num_dapm_routes = ARRAY_SIZE(kabylake_map),
910 .codec_conf = max98927_codec_conf,
911 .num_configs = ARRAY_SIZE(max98927_codec_conf),
912 .fully_routed = true,
913 .late_probe = kabylake_card_late_probe,
916 /* kabylake audio machine driver for Maxim98927 */
917 static struct snd_soc_card kbl_audio_card_max98927 = {
918 .name = "kblmax98927",
919 .owner = THIS_MODULE,
920 .dai_link = kabylake_max98927_dais,
921 .num_links = ARRAY_SIZE(kabylake_max98927_dais),
922 .controls = kabylake_controls,
923 .num_controls = ARRAY_SIZE(kabylake_controls),
924 .dapm_widgets = kabylake_widgets,
925 .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
926 .dapm_routes = kabylake_map,
927 .num_dapm_routes = ARRAY_SIZE(kabylake_map),
928 .codec_conf = max98927_codec_conf,
929 .num_configs = ARRAY_SIZE(max98927_codec_conf),
930 .fully_routed = true,
931 .late_probe = kabylake_card_late_probe,
934 static int kabylake_audio_probe(struct platform_device *pdev)
936 struct kbl_codec_private *ctx;
938 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
942 INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
944 kabylake_audio_card =
945 (struct snd_soc_card *)pdev->id_entry->driver_data;
947 kabylake_audio_card->dev = &pdev->dev;
948 snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
950 return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
953 static const struct platform_device_id kbl_board_ids[] = {
955 .name = "kbl_da7219_max98927",
957 (kernel_ulong_t)&kbl_audio_card_da7219_m98927,
960 .name = "kbl_max98927",
962 (kernel_ulong_t)&kbl_audio_card_max98927,
967 static struct platform_driver kabylake_audio = {
968 .probe = kabylake_audio_probe,
970 .name = "kbl_da7219_max98927",
971 .pm = &snd_soc_pm_ops,
973 .id_table = kbl_board_ids,
976 module_platform_driver(kabylake_audio)
978 /* Module information */
979 MODULE_DESCRIPTION("Audio KabyLake Machine driver for MAX98927 & DA7219");
980 MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
981 MODULE_LICENSE("GPL v2");
982 MODULE_ALIAS("platform:kbl_da7219_max98927");
983 MODULE_ALIAS("platform:kbl_max98927");