2 * Intel Kabylake I2S Machine Driver with MAXIM98927
5 * Copyright (C) 2017, Intel Corporation. All rights reserved.
8 * Intel Skylake I2S Machine driver
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License version
12 * 2 as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #include <linux/module.h>
21 #include <linux/platform_device.h>
22 #include <sound/core.h>
23 #include <sound/jack.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/soc.h>
27 #include "../../codecs/rt5663.h"
28 #include "../../codecs/hdac_hdmi.h"
29 #include "../skylake/skl.h"
31 #define KBL_REALTEK_CODEC_DAI "rt5663-aif"
32 #define KBL_MAXIM_CODEC_DAI "max98927-aif1"
33 #define DMIC_CH(p) p->list[p->count-1]
34 #define MAXIM_DEV0_NAME "i2c-MX98927:00"
35 #define MAXIM_DEV1_NAME "i2c-MX98927:01"
37 static struct snd_soc_card *kabylake_audio_card;
38 static const struct snd_pcm_hw_constraint_list *dmic_constraints;
39 static struct snd_soc_jack skylake_hdmi[3];
42 struct list_head head;
43 struct snd_soc_dai *codec_dai;
47 struct kbl_rt5663_private {
48 struct snd_soc_jack kabylake_headset;
49 struct list_head hdmi_pcm_list;
53 KBL_DPCM_AUDIO_PB = 0,
56 KBL_DPCM_AUDIO_ECHO_REF_CP,
57 KBL_DPCM_AUDIO_REF_CP,
58 KBL_DPCM_AUDIO_DMIC_CP,
59 KBL_DPCM_AUDIO_HDMI1_PB,
60 KBL_DPCM_AUDIO_HDMI2_PB,
61 KBL_DPCM_AUDIO_HDMI3_PB,
64 static const struct snd_kcontrol_new kabylake_controls[] = {
65 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
66 SOC_DAPM_PIN_SWITCH("Headset Mic"),
67 SOC_DAPM_PIN_SWITCH("Left Spk"),
68 SOC_DAPM_PIN_SWITCH("Right Spk"),
71 static const struct snd_soc_dapm_widget kabylake_widgets[] = {
72 SND_SOC_DAPM_HP("Headphone Jack", NULL),
73 SND_SOC_DAPM_MIC("Headset Mic", NULL),
74 SND_SOC_DAPM_SPK("Left Spk", NULL),
75 SND_SOC_DAPM_SPK("Right Spk", NULL),
76 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
77 SND_SOC_DAPM_SPK("HDMI1", NULL),
78 SND_SOC_DAPM_SPK("HDMI2", NULL),
79 SND_SOC_DAPM_SPK("HDMI3", NULL),
83 static const struct snd_soc_dapm_route kabylake_map[] = {
84 /* HP jack connectors - unknown if we have jack detection */
85 { "Headphone Jack", NULL, "HPOL" },
86 { "Headphone Jack", NULL, "HPOR" },
89 { "Left Spk", NULL, "Left BE_OUT" },
90 { "Right Spk", NULL, "Right BE_OUT" },
93 { "IN1P", NULL, "Headset Mic" },
94 { "IN1N", NULL, "Headset Mic" },
95 { "DMic", NULL, "SoC DMIC" },
97 /* CODEC BE connections */
98 { "Left HiFi Playback", NULL, "ssp0 Tx" },
99 { "Right HiFi Playback", NULL, "ssp0 Tx" },
100 { "ssp0 Tx", NULL, "spk_out" },
102 { "AIF Playback", NULL, "ssp1 Tx" },
103 { "ssp1 Tx", NULL, "hs_out" },
105 { "hs_in", NULL, "ssp1 Rx" },
106 { "ssp1 Rx", NULL, "AIF Capture" },
108 /* IV feedback path */
109 { "codec0_fb_in", NULL, "ssp0 Rx"},
110 { "ssp0 Rx", NULL, "Left HiFi Capture" },
111 { "ssp0 Rx", NULL, "Right HiFi Capture" },
114 { "dmic01_hifi", NULL, "DMIC01 Rx" },
115 { "DMIC01 Rx", NULL, "DMIC AIF" },
117 { "hifi3", NULL, "iDisp3 Tx"},
118 { "iDisp3 Tx", NULL, "iDisp3_out"},
119 { "hifi2", NULL, "iDisp2 Tx"},
120 { "iDisp2 Tx", NULL, "iDisp2_out"},
121 { "hifi1", NULL, "iDisp1 Tx"},
122 { "iDisp1 Tx", NULL, "iDisp1_out"},
126 KBL_DPCM_AUDIO_5663_PB = 0,
127 KBL_DPCM_AUDIO_5663_CP,
128 KBL_DPCM_AUDIO_5663_HDMI1_PB,
129 KBL_DPCM_AUDIO_5663_HDMI2_PB,
132 static const struct snd_kcontrol_new kabylake_5663_controls[] = {
133 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
134 SOC_DAPM_PIN_SWITCH("Headset Mic"),
137 static const struct snd_soc_dapm_widget kabylake_5663_widgets[] = {
138 SND_SOC_DAPM_HP("Headphone Jack", NULL),
139 SND_SOC_DAPM_MIC("Headset Mic", NULL),
140 SND_SOC_DAPM_SPK("DP", NULL),
141 SND_SOC_DAPM_SPK("HDMI", NULL),
144 static const struct snd_soc_dapm_route kabylake_5663_map[] = {
145 { "Headphone Jack", NULL, "HPOL" },
146 { "Headphone Jack", NULL, "HPOR" },
149 { "IN1P", NULL, "Headset Mic" },
150 { "IN1N", NULL, "Headset Mic" },
152 { "HDMI", NULL, "hif5 Output" },
153 { "DP", NULL, "hif6 Output" },
155 /* CODEC BE connections */
156 { "AIF Playback", NULL, "ssp1 Tx" },
157 { "ssp1 Tx", NULL, "codec1_out" },
159 { "codec0_in", NULL, "ssp1 Rx" },
160 { "ssp1 Rx", NULL, "AIF Capture" },
162 { "hifi2", NULL, "iDisp2 Tx"},
163 { "iDisp2 Tx", NULL, "iDisp2_out"},
164 { "hifi1", NULL, "iDisp1 Tx"},
165 { "iDisp1 Tx", NULL, "iDisp1_out"},
168 static struct snd_soc_codec_conf max98927_codec_conf[] = {
170 .dev_name = MAXIM_DEV0_NAME,
171 .name_prefix = "Right",
174 .dev_name = MAXIM_DEV1_NAME,
175 .name_prefix = "Left",
179 static struct snd_soc_dai_link_component max98927_codec_components[] = {
181 .name = MAXIM_DEV0_NAME,
182 .dai_name = KBL_MAXIM_CODEC_DAI,
185 .name = MAXIM_DEV1_NAME,
186 .dai_name = KBL_MAXIM_CODEC_DAI,
190 static int kabylake_rt5663_fe_init(struct snd_soc_pcm_runtime *rtd)
193 struct snd_soc_dapm_context *dapm;
194 struct snd_soc_component *component = rtd->cpu_dai->component;
196 dapm = snd_soc_component_get_dapm(component);
197 ret = snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
199 dev_err(rtd->dev, "Ref Cap ignore suspend failed %d\n", ret);
206 static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
209 struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card);
210 struct snd_soc_codec *codec = rtd->codec;
213 * Headset buttons map to the google Reference headset.
214 * These can be configured by userspace.
216 ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack",
217 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
218 SND_JACK_BTN_2 | SND_JACK_BTN_3, &ctx->kabylake_headset,
221 dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
224 rt5663_set_jack_detect(codec, &ctx->kabylake_headset);
228 static int kabylake_rt5663_max98927_codec_init(struct snd_soc_pcm_runtime *rtd)
232 ret = kabylake_rt5663_codec_init(rtd);
236 ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
238 dev_err(rtd->dev, "SoC DMIC ignore suspend failed %d\n", ret);
245 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
247 struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card);
248 struct snd_soc_dai *dai = rtd->codec_dai;
249 struct kbl_hdmi_pcm *pcm;
251 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
255 pcm->device = device;
256 pcm->codec_dai = dai;
258 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
263 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
265 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
268 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
270 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
273 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
275 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
278 static int kabylake_5663_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
280 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5663_HDMI1_PB);
283 static int kabylake_5663_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
285 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5663_HDMI2_PB);
288 static unsigned int rates[] = {
292 static const struct snd_pcm_hw_constraint_list constraints_rates = {
293 .count = ARRAY_SIZE(rates),
298 static unsigned int channels[] = {
302 static const struct snd_pcm_hw_constraint_list constraints_channels = {
303 .count = ARRAY_SIZE(channels),
308 static int kbl_fe_startup(struct snd_pcm_substream *substream)
310 struct snd_pcm_runtime *runtime = substream->runtime;
313 * On this platform for PCM device we support,
319 runtime->hw.channels_max = 2;
320 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
321 &constraints_channels);
323 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
324 snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
326 snd_pcm_hw_constraint_list(runtime, 0,
327 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
332 static const struct snd_soc_ops kabylake_rt5663_fe_ops = {
333 .startup = kbl_fe_startup,
336 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
337 struct snd_pcm_hw_params *params)
339 struct snd_interval *rate = hw_param_interval(params,
340 SNDRV_PCM_HW_PARAM_RATE);
341 struct snd_interval *channels = hw_param_interval(params,
342 SNDRV_PCM_HW_PARAM_CHANNELS);
343 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
345 /* The ADSP will convert the FE rate to 48k, stereo */
346 rate->min = rate->max = 48000;
347 channels->min = channels->max = 2;
348 /* set SSP1 to 24 bit */
350 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
355 static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
356 struct snd_pcm_hw_params *params)
358 struct snd_soc_pcm_runtime *rtd = substream->private_data;
359 struct snd_soc_dai *codec_dai = rtd->codec_dai;
362 /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */
363 rt5663_sel_asrc_clk_src(codec_dai->codec,
364 RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER,
365 RT5663_CLK_SEL_I2S1_ASRC);
367 ret = snd_soc_dai_set_sysclk(codec_dai,
368 RT5663_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN);
370 dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
375 static struct snd_soc_ops kabylake_rt5663_ops = {
376 .hw_params = kabylake_rt5663_hw_params,
379 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
380 struct snd_pcm_hw_params *params)
382 struct snd_interval *channels = hw_param_interval(params,
383 SNDRV_PCM_HW_PARAM_CHANNELS);
385 if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2)
386 channels->min = channels->max = 2;
388 channels->min = channels->max = 4;
393 static unsigned int channels_dmic[] = {
397 static struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
398 .count = ARRAY_SIZE(channels_dmic),
399 .list = channels_dmic,
403 static const unsigned int dmic_2ch[] = {
407 static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
408 .count = ARRAY_SIZE(dmic_2ch),
413 static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
415 struct snd_pcm_runtime *runtime = substream->runtime;
417 runtime->hw.channels_max = DMIC_CH(dmic_constraints);
418 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
421 return snd_pcm_hw_constraint_list(substream->runtime, 0,
422 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
425 static struct snd_soc_ops kabylake_dmic_ops = {
426 .startup = kabylake_dmic_startup,
429 static unsigned int rates_16000[] = {
433 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
434 .count = ARRAY_SIZE(rates_16000),
438 static const unsigned int ch_mono[] = {
442 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
443 .count = ARRAY_SIZE(ch_mono),
447 static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
449 substream->runtime->hw.channels_max = 1;
450 snd_pcm_hw_constraint_list(substream->runtime, 0,
451 SNDRV_PCM_HW_PARAM_CHANNELS,
452 &constraints_refcap);
454 return snd_pcm_hw_constraint_list(substream->runtime, 0,
455 SNDRV_PCM_HW_PARAM_RATE,
459 static struct snd_soc_ops skylaye_refcap_ops = {
460 .startup = kabylake_refcap_startup,
463 /* kabylake digital audio interface glue - connects codec <--> CPU */
464 static struct snd_soc_dai_link kabylake_dais[] = {
465 /* Front End DAI links */
466 [KBL_DPCM_AUDIO_PB] = {
467 .name = "Kbl Audio Port",
468 .stream_name = "Audio",
469 .cpu_dai_name = "System Pin",
470 .platform_name = "0000:00:1f.3",
472 .codec_name = "snd-soc-dummy",
473 .codec_dai_name = "snd-soc-dummy-dai",
475 .init = kabylake_rt5663_fe_init,
477 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
479 .ops = &kabylake_rt5663_fe_ops,
481 [KBL_DPCM_AUDIO_CP] = {
482 .name = "Kbl Audio Capture Port",
483 .stream_name = "Audio Record",
484 .cpu_dai_name = "System Pin",
485 .platform_name = "0000:00:1f.3",
487 .codec_name = "snd-soc-dummy",
488 .codec_dai_name = "snd-soc-dummy-dai",
491 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
493 .ops = &kabylake_rt5663_fe_ops,
495 [KBL_DPCM_AUDIO_HS_PB] = {
496 .name = "Kbl Audio Headset Playback",
497 .stream_name = "Headset Audio",
498 .cpu_dai_name = "System Pin2",
499 .codec_name = "snd-soc-dummy",
500 .codec_dai_name = "snd-soc-dummy-dai",
501 .platform_name = "0000:00:1f.3",
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 = &skylaye_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},
586 /* Back End DAI links */
589 .name = "SSP0-Codec",
591 .cpu_dai_name = "SSP0 Pin",
592 .platform_name = "0000:00:1f.3",
594 .codecs = max98927_codec_components,
595 .num_codecs = ARRAY_SIZE(max98927_codec_components),
596 .dai_fmt = SND_SOC_DAIFMT_I2S |
597 SND_SOC_DAIFMT_NB_NF |
598 SND_SOC_DAIFMT_CBS_CFS,
599 .ignore_pmdown_time = 1,
600 .be_hw_params_fixup = kabylake_ssp_fixup,
605 .name = "SSP1-Codec",
607 .cpu_dai_name = "SSP1 Pin",
608 .platform_name = "0000:00:1f.3",
610 .codec_name = "i2c-10EC5663:00",
611 .codec_dai_name = KBL_REALTEK_CODEC_DAI,
612 .init = kabylake_rt5663_max98927_codec_init,
613 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
614 SND_SOC_DAIFMT_CBS_CFS,
615 .ignore_pmdown_time = 1,
616 .be_hw_params_fixup = kabylake_ssp_fixup,
617 .ops = &kabylake_rt5663_ops,
624 .cpu_dai_name = "DMIC01 Pin",
625 .codec_name = "dmic-codec",
626 .codec_dai_name = "dmic-hifi",
627 .platform_name = "0000:00:1f.3",
628 .be_hw_params_fixup = kabylake_dmic_fixup,
636 .cpu_dai_name = "iDisp1 Pin",
637 .codec_name = "ehdaudio0D2",
638 .codec_dai_name = "intel-hdmi-hifi1",
639 .platform_name = "0000:00:1f.3",
641 .init = kabylake_hdmi1_init,
647 .cpu_dai_name = "iDisp2 Pin",
648 .codec_name = "ehdaudio0D2",
649 .codec_dai_name = "intel-hdmi-hifi2",
650 .platform_name = "0000:00:1f.3",
651 .init = kabylake_hdmi2_init,
658 .cpu_dai_name = "iDisp3 Pin",
659 .codec_name = "ehdaudio0D2",
660 .codec_dai_name = "intel-hdmi-hifi3",
661 .platform_name = "0000:00:1f.3",
662 .init = kabylake_hdmi3_init,
668 static struct snd_soc_dai_link kabylake_5663_dais[] = {
669 /* Front End DAI links */
670 [KBL_DPCM_AUDIO_5663_PB] = {
671 .name = "Kbl Audio Port",
672 .stream_name = "Audio",
673 .cpu_dai_name = "System Pin",
674 .platform_name = "0000:00:1f.3",
676 .codec_name = "snd-soc-dummy",
677 .codec_dai_name = "snd-soc-dummy-dai",
680 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
682 .ops = &kabylake_rt5663_fe_ops,
684 [KBL_DPCM_AUDIO_5663_CP] = {
685 .name = "Kbl Audio Capture Port",
686 .stream_name = "Audio Record",
687 .cpu_dai_name = "System Pin",
688 .platform_name = "0000:00:1f.3",
690 .codec_name = "snd-soc-dummy",
691 .codec_dai_name = "snd-soc-dummy-dai",
694 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
696 .ops = &kabylake_rt5663_fe_ops,
698 [KBL_DPCM_AUDIO_5663_HDMI1_PB] = {
699 .name = "Kbl HDMI Port1",
700 .stream_name = "Hdmi1",
701 .cpu_dai_name = "HDMI1 Pin",
702 .codec_name = "snd-soc-dummy",
703 .codec_dai_name = "snd-soc-dummy-dai",
704 .platform_name = "0000:00:1f.3",
708 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
712 [KBL_DPCM_AUDIO_5663_HDMI2_PB] = {
713 .name = "Kbl HDMI Port2",
714 .stream_name = "Hdmi2",
715 .cpu_dai_name = "HDMI2 Pin",
716 .codec_name = "snd-soc-dummy",
717 .codec_dai_name = "snd-soc-dummy-dai",
718 .platform_name = "0000:00:1f.3",
722 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
727 /* Back End DAI links */
730 .name = "SSP1-Codec",
732 .cpu_dai_name = "SSP1 Pin",
733 .platform_name = "0000:00:1f.3",
735 .codec_name = "i2c-10EC5663:00",
736 .codec_dai_name = KBL_REALTEK_CODEC_DAI,
737 .init = kabylake_rt5663_codec_init,
738 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
739 SND_SOC_DAIFMT_CBS_CFS,
740 .ignore_pmdown_time = 1,
741 .be_hw_params_fixup = kabylake_ssp_fixup,
742 .ops = &kabylake_rt5663_ops,
749 .cpu_dai_name = "iDisp1 Pin",
750 .codec_name = "ehdaudio0D2",
751 .codec_dai_name = "intel-hdmi-hifi1",
752 .platform_name = "0000:00:1f.3",
754 .init = kabylake_5663_hdmi1_init,
760 .cpu_dai_name = "iDisp2 Pin",
761 .codec_name = "ehdaudio0D2",
762 .codec_dai_name = "intel-hdmi-hifi2",
763 .platform_name = "0000:00:1f.3",
764 .init = kabylake_5663_hdmi2_init,
771 static int kabylake_card_late_probe(struct snd_soc_card *card)
773 struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card);
774 struct kbl_hdmi_pcm *pcm;
775 struct snd_soc_codec *codec = NULL;
777 char jack_name[NAME_SIZE];
779 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
780 codec = pcm->codec_dai->codec;
781 snprintf(jack_name, sizeof(jack_name),
782 "HDMI/DP, pcm=%d Jack", pcm->device);
783 err = snd_soc_card_jack_new(card, jack_name,
784 SND_JACK_AVOUT, &skylake_hdmi[i],
790 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
801 return hdac_hdmi_jack_port_init(codec, &card->dapm);
804 /* kabylake audio machine driver for SPT + RT5663 */
805 static struct snd_soc_card kabylake_audio_card_rt5663_m98927 = {
806 .name = "kblrt5663max",
807 .owner = THIS_MODULE,
808 .dai_link = kabylake_dais,
809 .num_links = ARRAY_SIZE(kabylake_dais),
810 .controls = kabylake_controls,
811 .num_controls = ARRAY_SIZE(kabylake_controls),
812 .dapm_widgets = kabylake_widgets,
813 .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
814 .dapm_routes = kabylake_map,
815 .num_dapm_routes = ARRAY_SIZE(kabylake_map),
816 .codec_conf = max98927_codec_conf,
817 .num_configs = ARRAY_SIZE(max98927_codec_conf),
818 .fully_routed = true,
819 .late_probe = kabylake_card_late_probe,
822 /* kabylake audio machine driver for RT5663 */
823 static struct snd_soc_card kabylake_audio_card_rt5663 = {
825 .owner = THIS_MODULE,
826 .dai_link = kabylake_5663_dais,
827 .num_links = ARRAY_SIZE(kabylake_5663_dais),
828 .controls = kabylake_5663_controls,
829 .num_controls = ARRAY_SIZE(kabylake_5663_controls),
830 .dapm_widgets = kabylake_5663_widgets,
831 .num_dapm_widgets = ARRAY_SIZE(kabylake_5663_widgets),
832 .dapm_routes = kabylake_5663_map,
833 .num_dapm_routes = ARRAY_SIZE(kabylake_5663_map),
834 .fully_routed = true,
835 .late_probe = kabylake_card_late_probe,
838 static int kabylake_audio_probe(struct platform_device *pdev)
840 struct kbl_rt5663_private *ctx;
841 struct skl_machine_pdata *pdata;
843 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
847 INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
849 kabylake_audio_card =
850 (struct snd_soc_card *)pdev->id_entry->driver_data;
852 kabylake_audio_card->dev = &pdev->dev;
853 snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
855 pdata = dev_get_drvdata(&pdev->dev);
857 dmic_constraints = pdata->dmic_num == 2 ?
858 &constraints_dmic_2ch : &constraints_dmic_channels;
860 return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
863 static const struct platform_device_id kbl_board_ids[] = {
865 .name = "kbl_rt5663",
866 .driver_data = (kernel_ulong_t)&kabylake_audio_card_rt5663,
869 .name = "kbl_rt5663_m98927",
871 (kernel_ulong_t)&kabylake_audio_card_rt5663_m98927,
876 static struct platform_driver kabylake_audio = {
877 .probe = kabylake_audio_probe,
879 .name = "kbl_rt5663_m98927",
880 .pm = &snd_soc_pm_ops,
882 .id_table = kbl_board_ids,
885 module_platform_driver(kabylake_audio)
887 /* Module information */
888 MODULE_DESCRIPTION("Audio Machine driver-RT5663 & MAX98927 in I2S mode");
889 MODULE_AUTHOR("Naveen M <naveen.m@intel.com>");
890 MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
891 MODULE_LICENSE("GPL v2");
892 MODULE_ALIAS("platform:kbl_rt5663");
893 MODULE_ALIAS("platform:kbl_rt5663_m98927");