1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright(c) 2017-18 Intel Corporation.
3 
4 /*
5  * Intel Kabylake I2S Machine Driver with MAX98357A & DA7219 Codecs
6  *
7  * Modified from:
8  *   Intel Kabylake I2S Machine driver supporting MAXIM98927 and
9  *   RT5663 codecs
10  */
11 
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 
23 #define KBL_DIALOG_CODEC_DAI "da7219-hifi"
24 #define KBL_MAXIM_CODEC_DAI "HiFi"
25 #define MAXIM_DEV0_NAME "MX98357A:00"
26 #define DUAL_CHANNEL 2
27 #define QUAD_CHANNEL 4
28 
29 static struct snd_soc_card *kabylake_audio_card;
30 static struct snd_soc_jack skylake_hdmi[3];
31 
32 struct kbl_hdmi_pcm {
33 	struct list_head head;
34 	struct snd_soc_dai *codec_dai;
35 	int device;
36 };
37 
38 struct kbl_codec_private {
39 	struct snd_soc_jack kabylake_headset;
40 	struct list_head hdmi_pcm_list;
41 };
42 
43 enum {
44 	KBL_DPCM_AUDIO_PB = 0,
45 	KBL_DPCM_AUDIO_CP,
46 	KBL_DPCM_AUDIO_REF_CP,
47 	KBL_DPCM_AUDIO_DMIC_CP,
48 	KBL_DPCM_AUDIO_HDMI1_PB,
49 	KBL_DPCM_AUDIO_HDMI2_PB,
50 	KBL_DPCM_AUDIO_HDMI3_PB,
51 };
52 
53 static int platform_clock_control(struct snd_soc_dapm_widget *w,
54 					struct snd_kcontrol *k, int  event)
55 {
56 	struct snd_soc_dapm_context *dapm = w->dapm;
57 	struct snd_soc_card *card = dapm->card;
58 	struct snd_soc_dai *codec_dai;
59 	int ret = 0;
60 
61 	codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI);
62 	if (!codec_dai) {
63 		dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
64 		return -EIO;
65 	}
66 
67 	if (SND_SOC_DAPM_EVENT_OFF(event)) {
68 		ret = snd_soc_dai_set_pll(codec_dai, 0,
69 				     DA7219_SYSCLK_MCLK, 0, 0);
70 		if (ret)
71 			dev_err(card->dev, "failed to stop PLL: %d\n", ret);
72 	} else if (SND_SOC_DAPM_EVENT_ON(event)) {
73 		ret = snd_soc_dai_set_pll(codec_dai, 0,	DA7219_SYSCLK_PLL_SRM,
74 				     0, DA7219_PLL_FREQ_OUT_98304);
75 		if (ret)
76 			dev_err(card->dev, "failed to start PLL: %d\n", ret);
77 	}
78 
79 	return ret;
80 }
81 
82 static const struct snd_kcontrol_new kabylake_controls[] = {
83 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
84 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
85 	SOC_DAPM_PIN_SWITCH("Spk"),
86 };
87 
88 static const struct snd_soc_dapm_widget kabylake_widgets[] = {
89 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
90 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
91 	SND_SOC_DAPM_SPK("Spk", NULL),
92 	SND_SOC_DAPM_MIC("SoC DMIC", NULL),
93 	SND_SOC_DAPM_SPK("HDMI1", NULL),
94 	SND_SOC_DAPM_SPK("HDMI2", NULL),
95 	SND_SOC_DAPM_SPK("HDMI3", NULL),
96 	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
97 			platform_clock_control, SND_SOC_DAPM_PRE_PMU |
98 			SND_SOC_DAPM_POST_PMD),
99 };
100 
101 static struct snd_soc_jack_pin jack_pins[] = {
102 	{
103 		.pin    = "Headphone Jack",
104 		.mask   = SND_JACK_HEADPHONE,
105 	},
106 	{
107 		.pin    = "Headset Mic",
108 		.mask   = SND_JACK_MICROPHONE,
109 	},
110 };
111 
112 static const struct snd_soc_dapm_route kabylake_map[] = {
113 	{ "Headphone Jack", NULL, "HPL" },
114 	{ "Headphone Jack", NULL, "HPR" },
115 
116 	/* speaker */
117 	{ "Spk", NULL, "Speaker" },
118 
119 	/* other jacks */
120 	{ "MIC", NULL, "Headset Mic" },
121 	{ "DMic", NULL, "SoC DMIC" },
122 
123 	{"HDMI1", NULL, "hif5-0 Output"},
124 	{"HDMI2", NULL, "hif6-0 Output"},
125 	{"HDMI3", NULL, "hif7-0 Output"},
126 
127 	/* CODEC BE connections */
128 	{ "HiFi Playback", NULL, "ssp0 Tx" },
129 	{ "ssp0 Tx", NULL, "codec0_out" },
130 
131 	{ "Playback", NULL, "ssp1 Tx" },
132 	{ "ssp1 Tx", NULL, "codec1_out" },
133 
134 	{ "codec0_in", NULL, "ssp1 Rx" },
135 	{ "ssp1 Rx", NULL, "Capture" },
136 
137 	/* DMIC */
138 	{ "dmic01_hifi", NULL, "DMIC01 Rx" },
139 	{ "DMIC01 Rx", NULL, "DMIC AIF" },
140 
141 	{ "hifi1", NULL, "iDisp1 Tx" },
142 	{ "iDisp1 Tx", NULL, "iDisp1_out" },
143 	{ "hifi2", NULL, "iDisp2 Tx" },
144 	{ "iDisp2 Tx", NULL, "iDisp2_out" },
145 	{ "hifi3", NULL, "iDisp3 Tx"},
146 	{ "iDisp3 Tx", NULL, "iDisp3_out"},
147 
148 	{ "Headphone Jack", NULL, "Platform Clock" },
149 	{ "Headset Mic", NULL, "Platform Clock" },
150 };
151 
152 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
153 			struct snd_pcm_hw_params *params)
154 {
155 	struct snd_interval *rate = hw_param_interval(params,
156 			SNDRV_PCM_HW_PARAM_RATE);
157 	struct snd_interval *chan = hw_param_interval(params,
158 			SNDRV_PCM_HW_PARAM_CHANNELS);
159 	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
160 
161 	/* The ADSP will convert the FE rate to 48k, stereo */
162 	rate->min = rate->max = 48000;
163 	chan->min = chan->max = DUAL_CHANNEL;
164 
165 	/* set SSP to 24 bit */
166 	snd_mask_none(fmt);
167 	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
168 
169 	return 0;
170 }
171 
172 static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
173 {
174 	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
175 	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
176 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
177 	struct snd_soc_jack *jack;
178 	int ret;
179 
180 	/* Configure sysclk for codec */
181 	ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000,
182 						SND_SOC_CLOCK_IN);
183 	if (ret) {
184 		dev_err(rtd->dev, "can't set codec sysclk configuration\n");
185 		return ret;
186 	}
187 
188 	/*
189 	 * Headset buttons map to the google Reference headset.
190 	 * These can be configured by userspace.
191 	 */
192 	ret = snd_soc_card_jack_new_pins(kabylake_audio_card, "Headset Jack",
193 					 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
194 					 SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
195 					 &ctx->kabylake_headset,
196 					 jack_pins,
197 					 ARRAY_SIZE(jack_pins));
198 	if (ret) {
199 		dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
200 		return ret;
201 	}
202 
203 	jack = &ctx->kabylake_headset;
204 
205 	snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
206 	snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
207 	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
208 	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
209 	snd_soc_component_set_jack(component, &ctx->kabylake_headset, NULL);
210 
211 	ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
212 	if (ret)
213 		dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret);
214 
215 	return ret;
216 }
217 
218 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
219 {
220 	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
221 	struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
222 	struct kbl_hdmi_pcm *pcm;
223 
224 	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
225 	if (!pcm)
226 		return -ENOMEM;
227 
228 	pcm->device = device;
229 	pcm->codec_dai = dai;
230 
231 	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
232 
233 	return 0;
234 }
235 
236 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
237 {
238 	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
239 }
240 
241 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
242 {
243 	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
244 }
245 
246 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
247 {
248 	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
249 }
250 
251 static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
252 {
253 	struct snd_soc_dapm_context *dapm;
254 	struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
255 
256 	dapm = snd_soc_component_get_dapm(component);
257 	snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
258 
259 	return 0;
260 }
261 
262 static const unsigned int rates[] = {
263 	48000,
264 };
265 
266 static const struct snd_pcm_hw_constraint_list constraints_rates = {
267 	.count = ARRAY_SIZE(rates),
268 	.list  = rates,
269 	.mask = 0,
270 };
271 
272 static const unsigned int channels[] = {
273 	DUAL_CHANNEL,
274 };
275 
276 static const struct snd_pcm_hw_constraint_list constraints_channels = {
277 	.count = ARRAY_SIZE(channels),
278 	.list = channels,
279 	.mask = 0,
280 };
281 
282 static unsigned int channels_quad[] = {
283 	QUAD_CHANNEL,
284 };
285 
286 static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
287 	.count = ARRAY_SIZE(channels_quad),
288 	.list = channels_quad,
289 	.mask = 0,
290 };
291 
292 static int kbl_fe_startup(struct snd_pcm_substream *substream)
293 {
294 	struct snd_pcm_runtime *runtime = substream->runtime;
295 
296 	/*
297 	 * On this platform for PCM device we support,
298 	 * 48Khz
299 	 * stereo
300 	 * 16 bit audio
301 	 */
302 
303 	runtime->hw.channels_max = DUAL_CHANNEL;
304 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
305 					   &constraints_channels);
306 
307 	runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
308 	snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
309 
310 	snd_pcm_hw_constraint_list(runtime, 0,
311 				SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
312 
313 	return 0;
314 }
315 
316 static const struct snd_soc_ops kabylake_da7219_fe_ops = {
317 	.startup = kbl_fe_startup,
318 };
319 
320 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
321 		struct snd_pcm_hw_params *params)
322 {
323 	struct snd_interval *chan = hw_param_interval(params,
324 				SNDRV_PCM_HW_PARAM_CHANNELS);
325 
326 	/*
327 	 * set BE channel constraint as user FE channels
328 	 */
329 
330 	if (params_channels(params) == 2)
331 		chan->min = chan->max = 2;
332 	else
333 		chan->min = chan->max = 4;
334 
335 	return 0;
336 }
337 
338 static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
339 {
340 	struct snd_pcm_runtime *runtime = substream->runtime;
341 
342 	runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
343 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
344 			&constraints_channels_quad);
345 
346 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
347 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
348 }
349 
350 static struct snd_soc_ops kabylake_dmic_ops = {
351 	.startup = kabylake_dmic_startup,
352 };
353 
354 static unsigned int rates_16000[] = {
355         16000,
356 };
357 
358 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
359         .count = ARRAY_SIZE(rates_16000),
360         .list  = rates_16000,
361 };
362 
363 static const unsigned int ch_mono[] = {
364 	1,
365 };
366 
367 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
368 	.count = ARRAY_SIZE(ch_mono),
369 	.list  = ch_mono,
370 };
371 
372 static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
373 {
374 	substream->runtime->hw.channels_max = 1;
375 	snd_pcm_hw_constraint_list(substream->runtime, 0,
376 					SNDRV_PCM_HW_PARAM_CHANNELS,
377 					&constraints_refcap);
378 
379 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
380 					SNDRV_PCM_HW_PARAM_RATE,
381 					&constraints_16000);
382 }
383 
384 static struct snd_soc_ops skylake_refcap_ops = {
385 	.startup = kabylake_refcap_startup,
386 };
387 
388 SND_SOC_DAILINK_DEF(dummy,
389 	DAILINK_COMP_ARRAY(COMP_DUMMY()));
390 
391 SND_SOC_DAILINK_DEF(system,
392 	DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
393 
394 SND_SOC_DAILINK_DEF(reference,
395 	DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
396 
397 SND_SOC_DAILINK_DEF(dmic,
398 	DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
399 
400 SND_SOC_DAILINK_DEF(hdmi1,
401 	DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
402 
403 SND_SOC_DAILINK_DEF(hdmi2,
404 	DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
405 
406 SND_SOC_DAILINK_DEF(hdmi3,
407 	DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
408 
409 SND_SOC_DAILINK_DEF(ssp0_pin,
410 	DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
411 SND_SOC_DAILINK_DEF(ssp0_codec,
412 	DAILINK_COMP_ARRAY(COMP_CODEC(MAXIM_DEV0_NAME,
413 				      KBL_MAXIM_CODEC_DAI)));
414 
415 SND_SOC_DAILINK_DEF(ssp1_pin,
416 	DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
417 SND_SOC_DAILINK_DEF(ssp1_codec,
418 	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
419 				      KBL_DIALOG_CODEC_DAI)));
420 
421 SND_SOC_DAILINK_DEF(dmic_pin,
422 	DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
423 SND_SOC_DAILINK_DEF(dmic_codec,
424 	DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
425 
426 SND_SOC_DAILINK_DEF(idisp1_pin,
427 	DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
428 SND_SOC_DAILINK_DEF(idisp1_codec,
429 	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
430 				      "intel-hdmi-hifi1")));
431 
432 SND_SOC_DAILINK_DEF(idisp2_pin,
433 	DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
434 SND_SOC_DAILINK_DEF(idisp2_codec,
435 	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
436 
437 SND_SOC_DAILINK_DEF(idisp3_pin,
438 	DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
439 SND_SOC_DAILINK_DEF(idisp3_codec,
440 	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
441 
442 SND_SOC_DAILINK_DEF(platform,
443 	DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
444 
445 /* kabylake digital audio interface glue - connects codec <--> CPU */
446 static struct snd_soc_dai_link kabylake_dais[] = {
447 	/* Front End DAI links */
448 	[KBL_DPCM_AUDIO_PB] = {
449 		.name = "Kbl Audio Port",
450 		.stream_name = "Audio",
451 		.dynamic = 1,
452 		.nonatomic = 1,
453 		.init = kabylake_da7219_fe_init,
454 		.trigger = {
455 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
456 		.dpcm_playback = 1,
457 		.ops = &kabylake_da7219_fe_ops,
458 		SND_SOC_DAILINK_REG(system, dummy, platform),
459 	},
460 	[KBL_DPCM_AUDIO_CP] = {
461 		.name = "Kbl Audio Capture Port",
462 		.stream_name = "Audio Record",
463 		.dynamic = 1,
464 		.nonatomic = 1,
465 		.trigger = {
466 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
467 		.dpcm_capture = 1,
468 		.ops = &kabylake_da7219_fe_ops,
469 		SND_SOC_DAILINK_REG(system, dummy, platform),
470 	},
471 	[KBL_DPCM_AUDIO_REF_CP] = {
472 		.name = "Kbl Audio Reference cap",
473 		.stream_name = "Wake on Voice",
474 		.init = NULL,
475 		.dpcm_capture = 1,
476 		.nonatomic = 1,
477 		.dynamic = 1,
478 		.ops = &skylake_refcap_ops,
479 		SND_SOC_DAILINK_REG(reference, dummy, platform),
480 	},
481 	[KBL_DPCM_AUDIO_DMIC_CP] = {
482 		.name = "Kbl Audio DMIC cap",
483 		.stream_name = "dmiccap",
484 		.init = NULL,
485 		.dpcm_capture = 1,
486 		.nonatomic = 1,
487 		.dynamic = 1,
488 		.ops = &kabylake_dmic_ops,
489 		SND_SOC_DAILINK_REG(dmic, dummy, platform),
490 	},
491 	[KBL_DPCM_AUDIO_HDMI1_PB] = {
492 		.name = "Kbl HDMI Port1",
493 		.stream_name = "Hdmi1",
494 		.dpcm_playback = 1,
495 		.init = NULL,
496 		.trigger = {
497 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
498 		.nonatomic = 1,
499 		.dynamic = 1,
500 		SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
501 	},
502 	[KBL_DPCM_AUDIO_HDMI2_PB] = {
503 		.name = "Kbl HDMI Port2",
504 		.stream_name = "Hdmi2",
505 		.dpcm_playback = 1,
506 		.init = NULL,
507 		.trigger = {
508 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
509 		.nonatomic = 1,
510 		.dynamic = 1,
511 		SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
512 	},
513 	[KBL_DPCM_AUDIO_HDMI3_PB] = {
514 		.name = "Kbl HDMI Port3",
515 		.stream_name = "Hdmi3",
516 		.trigger = {
517 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
518 		.dpcm_playback = 1,
519 		.init = NULL,
520 		.nonatomic = 1,
521 		.dynamic = 1,
522 		SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
523 	},
524 
525 	/* Back End DAI links */
526 	{
527 		/* SSP0 - Codec */
528 		.name = "SSP0-Codec",
529 		.id = 0,
530 		.no_pcm = 1,
531 		.dai_fmt = SND_SOC_DAIFMT_I2S |
532 			SND_SOC_DAIFMT_NB_NF |
533 			SND_SOC_DAIFMT_CBC_CFC,
534 		.ignore_pmdown_time = 1,
535 		.be_hw_params_fixup = kabylake_ssp_fixup,
536 		.dpcm_playback = 1,
537 		SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
538 	},
539 	{
540 		/* SSP1 - Codec */
541 		.name = "SSP1-Codec",
542 		.id = 1,
543 		.no_pcm = 1,
544 		.init = kabylake_da7219_codec_init,
545 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
546 			SND_SOC_DAIFMT_CBC_CFC,
547 		.ignore_pmdown_time = 1,
548 		.be_hw_params_fixup = kabylake_ssp_fixup,
549 		.dpcm_playback = 1,
550 		.dpcm_capture = 1,
551 		SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
552 	},
553 	{
554 		.name = "dmic01",
555 		.id = 2,
556 		.be_hw_params_fixup = kabylake_dmic_fixup,
557 		.ignore_suspend = 1,
558 		.dpcm_capture = 1,
559 		.no_pcm = 1,
560 		SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
561 	},
562 	{
563 		.name = "iDisp1",
564 		.id = 3,
565 		.dpcm_playback = 1,
566 		.init = kabylake_hdmi1_init,
567 		.no_pcm = 1,
568 		SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
569 	},
570 	{
571 		.name = "iDisp2",
572 		.id = 4,
573 		.init = kabylake_hdmi2_init,
574 		.dpcm_playback = 1,
575 		.no_pcm = 1,
576 		SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
577 	},
578 	{
579 		.name = "iDisp3",
580 		.id = 5,
581 		.init = kabylake_hdmi3_init,
582 		.dpcm_playback = 1,
583 		.no_pcm = 1,
584 		SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
585 	},
586 };
587 
588 #define NAME_SIZE	32
589 static int kabylake_card_late_probe(struct snd_soc_card *card)
590 {
591 	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
592 	struct kbl_hdmi_pcm *pcm;
593 	struct snd_soc_component *component = NULL;
594 	int err, i = 0;
595 	char jack_name[NAME_SIZE];
596 
597 	list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
598 		component = pcm->codec_dai->component;
599 		snprintf(jack_name, sizeof(jack_name),
600 			"HDMI/DP, pcm=%d Jack", pcm->device);
601 		err = snd_soc_card_jack_new(card, jack_name,
602 					SND_JACK_AVOUT, &skylake_hdmi[i]);
603 
604 		if (err)
605 			return err;
606 
607 		err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
608 				&skylake_hdmi[i]);
609 		if (err < 0)
610 			return err;
611 
612 		i++;
613 
614 	}
615 
616 	if (!component)
617 		return -EINVAL;
618 
619 	return hdac_hdmi_jack_port_init(component, &card->dapm);
620 }
621 
622 /* kabylake audio machine driver for SPT + DA7219 */
623 static struct snd_soc_card kabylake_audio_card_da7219_m98357a = {
624 	.name = "kblda7219max",
625 	.owner = THIS_MODULE,
626 	.dai_link = kabylake_dais,
627 	.num_links = ARRAY_SIZE(kabylake_dais),
628 	.controls = kabylake_controls,
629 	.num_controls = ARRAY_SIZE(kabylake_controls),
630 	.dapm_widgets = kabylake_widgets,
631 	.num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
632 	.dapm_routes = kabylake_map,
633 	.num_dapm_routes = ARRAY_SIZE(kabylake_map),
634 	.fully_routed = true,
635 	.late_probe = kabylake_card_late_probe,
636 };
637 
638 static int kabylake_audio_probe(struct platform_device *pdev)
639 {
640 	struct kbl_codec_private *ctx;
641 
642 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
643 	if (!ctx)
644 		return -ENOMEM;
645 
646 	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
647 
648 	kabylake_audio_card =
649 		(struct snd_soc_card *)pdev->id_entry->driver_data;
650 
651 	kabylake_audio_card->dev = &pdev->dev;
652 	snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
653 	return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
654 }
655 
656 static const struct platform_device_id kbl_board_ids[] = {
657 	{
658 		.name = "kbl_da7219_mx98357a",
659 		.driver_data =
660 			(kernel_ulong_t)&kabylake_audio_card_da7219_m98357a,
661 	},
662 	{ }
663 };
664 MODULE_DEVICE_TABLE(platform, kbl_board_ids);
665 
666 static struct platform_driver kabylake_audio = {
667 	.probe = kabylake_audio_probe,
668 	.driver = {
669 		.name = "kbl_da7219_max98357a",
670 		.pm = &snd_soc_pm_ops,
671 	},
672 	.id_table = kbl_board_ids,
673 };
674 
675 module_platform_driver(kabylake_audio)
676 
677 /* Module information */
678 MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode");
679 MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
680 MODULE_LICENSE("GPL v2");
681