1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright(c) 2018 Intel Corporation.
3 
4 /*
5  * Intel Kabylake I2S Machine Driver with MAX98927, MAX98373 & DA7219 Codecs
6  *
7  * Modified from:
8  *   Intel Kabylake I2S Machine driver supporting MAX98927 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 MAX98927_CODEC_DAI	"max98927-aif1"
25 #define MAX98927_DEV0_NAME	"i2c-MX98927:00"
26 #define MAX98927_DEV1_NAME	"i2c-MX98927:01"
27 
28 #define MAX98373_CODEC_DAI	"max98373-aif1"
29 #define MAX98373_DEV0_NAME	"i2c-MX98373:00"
30 #define MAX98373_DEV1_NAME	"i2c-MX98373:01"
31 
32 
33 #define DUAL_CHANNEL	2
34 #define QUAD_CHANNEL	4
35 #define NAME_SIZE	32
36 
37 static struct snd_soc_card *kabylake_audio_card;
38 static struct snd_soc_jack kabylake_hdmi[3];
39 
40 struct kbl_hdmi_pcm {
41 	struct list_head head;
42 	struct snd_soc_dai *codec_dai;
43 	int device;
44 };
45 
46 struct kbl_codec_private {
47 	struct snd_soc_jack kabylake_headset;
48 	struct list_head hdmi_pcm_list;
49 };
50 
51 enum {
52 	KBL_DPCM_AUDIO_PB = 0,
53 	KBL_DPCM_AUDIO_ECHO_REF_CP,
54 	KBL_DPCM_AUDIO_REF_CP,
55 	KBL_DPCM_AUDIO_DMIC_CP,
56 	KBL_DPCM_AUDIO_HDMI1_PB,
57 	KBL_DPCM_AUDIO_HDMI2_PB,
58 	KBL_DPCM_AUDIO_HDMI3_PB,
59 	KBL_DPCM_AUDIO_HS_PB,
60 	KBL_DPCM_AUDIO_CP,
61 };
62 
63 static int platform_clock_control(struct snd_soc_dapm_widget *w,
64 					struct snd_kcontrol *k, int  event)
65 {
66 	struct snd_soc_dapm_context *dapm = w->dapm;
67 	struct snd_soc_card *card = dapm->card;
68 	struct snd_soc_dai *codec_dai;
69 	int ret = 0;
70 
71 	codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI);
72 	if (!codec_dai) {
73 		dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
74 		return -EIO;
75 	}
76 
77 	/* Configure sysclk for codec */
78 	ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000,
79 				     SND_SOC_CLOCK_IN);
80 	if (ret) {
81 		dev_err(card->dev, "can't set codec sysclk configuration\n");
82 		return ret;
83 	}
84 
85 	if (SND_SOC_DAPM_EVENT_OFF(event)) {
86 		ret = snd_soc_dai_set_pll(codec_dai, 0,
87 				     DA7219_SYSCLK_MCLK, 0, 0);
88 		if (ret)
89 			dev_err(card->dev, "failed to stop PLL: %d\n", ret);
90 	} else if (SND_SOC_DAPM_EVENT_ON(event)) {
91 		ret = snd_soc_dai_set_pll(codec_dai, 0,	DA7219_SYSCLK_PLL_SRM,
92 				     0, DA7219_PLL_FREQ_OUT_98304);
93 		if (ret)
94 			dev_err(card->dev, "failed to start PLL: %d\n", ret);
95 	}
96 
97 	return ret;
98 }
99 
100 static const struct snd_kcontrol_new kabylake_controls[] = {
101 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
102 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
103 	SOC_DAPM_PIN_SWITCH("Left Spk"),
104 	SOC_DAPM_PIN_SWITCH("Right Spk"),
105 	SOC_DAPM_PIN_SWITCH("Line Out"),
106 };
107 
108 static const struct snd_soc_dapm_widget kabylake_widgets[] = {
109 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
110 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
111 	SND_SOC_DAPM_SPK("Left Spk", NULL),
112 	SND_SOC_DAPM_SPK("Right Spk", NULL),
113 	SND_SOC_DAPM_LINE("Line Out", NULL),
114 	SND_SOC_DAPM_MIC("SoC DMIC", NULL),
115 	SND_SOC_DAPM_SPK("HDMI1", NULL),
116 	SND_SOC_DAPM_SPK("HDMI2", NULL),
117 	SND_SOC_DAPM_SPK("HDMI3", NULL),
118 	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
119 			platform_clock_control, SND_SOC_DAPM_PRE_PMU |
120 			SND_SOC_DAPM_POST_PMD),
121 };
122 
123 static struct snd_soc_jack_pin jack_pins[] = {
124 	{
125 		.pin    = "Headphone Jack",
126 		.mask   = SND_JACK_HEADPHONE,
127 	},
128 	{
129 		.pin    = "Headset Mic",
130 		.mask   = SND_JACK_MICROPHONE,
131 	},
132 	{
133 		.pin    = "Line Out",
134 		.mask   = SND_JACK_MICROPHONE,
135 	},
136 };
137 
138 static const struct snd_soc_dapm_route kabylake_map[] = {
139 	/* speaker */
140 	{ "Left Spk", NULL, "Left BE_OUT" },
141 	{ "Right Spk", NULL, "Right BE_OUT" },
142 
143 	/* other jacks */
144 	{ "DMic", NULL, "SoC DMIC" },
145 
146 	{"HDMI1", NULL, "hif5-0 Output"},
147 	{"HDMI2", NULL, "hif6-0 Output"},
148 	{"HDMI3", NULL, "hif7-0 Output"},
149 
150 	/* CODEC BE connections */
151 	{ "Left HiFi Playback", NULL, "ssp0 Tx" },
152 	{ "Right HiFi Playback", NULL, "ssp0 Tx" },
153 	{ "ssp0 Tx", NULL, "spk_out" },
154 
155 	/* IV feedback path */
156 	{ "codec0_fb_in", NULL, "ssp0 Rx"},
157 	{ "ssp0 Rx", NULL, "Left HiFi Capture" },
158 	{ "ssp0 Rx", NULL, "Right HiFi Capture" },
159 
160 	/* AEC capture path */
161 	{ "echo_ref_out", NULL, "ssp0 Rx" },
162 
163 	/* DMIC */
164 	{ "dmic01_hifi", NULL, "DMIC01 Rx" },
165 	{ "DMIC01 Rx", NULL, "DMIC AIF" },
166 
167 	{ "hifi1", NULL, "iDisp1 Tx" },
168 	{ "iDisp1 Tx", NULL, "iDisp1_out" },
169 	{ "hifi2", NULL, "iDisp2 Tx" },
170 	{ "iDisp2 Tx", NULL, "iDisp2_out" },
171 	{ "hifi3", NULL, "iDisp3 Tx"},
172 	{ "iDisp3 Tx", NULL, "iDisp3_out"},
173 };
174 
175 static const struct snd_soc_dapm_route kabylake_ssp1_map[] = {
176 	{ "Headphone Jack", NULL, "HPL" },
177 	{ "Headphone Jack", NULL, "HPR" },
178 
179 	/* other jacks */
180 	{ "MIC", NULL, "Headset Mic" },
181 
182 	/* CODEC BE connections */
183 	{ "Playback", NULL, "ssp1 Tx" },
184 	{ "ssp1 Tx", NULL, "codec1_out" },
185 
186 	{ "hs_in", NULL, "ssp1 Rx" },
187 	{ "ssp1 Rx", NULL, "Capture" },
188 
189 	{ "Headphone Jack", NULL, "Platform Clock" },
190 	{ "Headset Mic", NULL, "Platform Clock" },
191 	{ "Line Out", NULL, "Platform Clock" },
192 };
193 
194 static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
195 	struct snd_pcm_hw_params *params)
196 {
197 	struct snd_soc_pcm_runtime *runtime = asoc_substream_to_rtd(substream);
198 	struct snd_soc_dai *codec_dai;
199 	int ret, j;
200 
201 	for_each_rtd_codec_dais(runtime, j, codec_dai) {
202 
203 		if (!strcmp(codec_dai->component->name, MAX98927_DEV0_NAME)) {
204 			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16);
205 			if (ret < 0) {
206 				dev_err(runtime->dev, "DEV0 TDM slot err:%d\n", ret);
207 				return ret;
208 			}
209 		}
210 		if (!strcmp(codec_dai->component->name, MAX98927_DEV1_NAME)) {
211 			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC0, 3, 8, 16);
212 			if (ret < 0) {
213 				dev_err(runtime->dev, "DEV1 TDM slot err:%d\n", ret);
214 				return ret;
215 			}
216 		}
217 		if (!strcmp(codec_dai->component->name, MAX98373_DEV0_NAME)) {
218 			ret = snd_soc_dai_set_tdm_slot(codec_dai,
219 							0x30, 3, 8, 16);
220 			if (ret < 0) {
221 				dev_err(runtime->dev,
222 						"DEV0 TDM slot err:%d\n", ret);
223 				return ret;
224 			}
225 		}
226 		if (!strcmp(codec_dai->component->name, MAX98373_DEV1_NAME)) {
227 			ret = snd_soc_dai_set_tdm_slot(codec_dai,
228 							0xC0, 3, 8, 16);
229 			if (ret < 0) {
230 				dev_err(runtime->dev,
231 						"DEV1 TDM slot err:%d\n", ret);
232 				return ret;
233 			}
234 		}
235 	}
236 
237 	return 0;
238 }
239 
240 static int kabylake_ssp0_trigger(struct snd_pcm_substream *substream, int cmd)
241 {
242 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
243 	struct snd_soc_dai *codec_dai;
244 	int j, ret;
245 
246 	for_each_rtd_codec_dais(rtd, j, codec_dai) {
247 		const char *name = codec_dai->component->name;
248 		struct snd_soc_component *component = codec_dai->component;
249 		struct snd_soc_dapm_context *dapm =
250 				snd_soc_component_get_dapm(component);
251 		char pin_name[20];
252 
253 		if (strcmp(name, MAX98927_DEV0_NAME) &&
254 			strcmp(name, MAX98927_DEV1_NAME) &&
255 			strcmp(name, MAX98373_DEV0_NAME) &&
256 			strcmp(name, MAX98373_DEV1_NAME))
257 			continue;
258 
259 		snprintf(pin_name, ARRAY_SIZE(pin_name), "%s Spk",
260 			codec_dai->component->name_prefix);
261 
262 		switch (cmd) {
263 		case SNDRV_PCM_TRIGGER_START:
264 		case SNDRV_PCM_TRIGGER_RESUME:
265 		case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
266 			ret = snd_soc_dapm_enable_pin(dapm, pin_name);
267 			if (ret) {
268 				dev_err(rtd->dev, "failed to enable %s: %d\n",
269 				pin_name, ret);
270 				return ret;
271 			}
272 			snd_soc_dapm_sync(dapm);
273 			break;
274 		case SNDRV_PCM_TRIGGER_STOP:
275 		case SNDRV_PCM_TRIGGER_SUSPEND:
276 		case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
277 			ret = snd_soc_dapm_disable_pin(dapm, pin_name);
278 			if (ret) {
279 				dev_err(rtd->dev, "failed to disable %s: %d\n",
280 				pin_name, ret);
281 				return ret;
282 			}
283 			snd_soc_dapm_sync(dapm);
284 			break;
285 		}
286 	}
287 
288 	return 0;
289 }
290 
291 static struct snd_soc_ops kabylake_ssp0_ops = {
292 	.hw_params = kabylake_ssp0_hw_params,
293 	.trigger = kabylake_ssp0_trigger,
294 };
295 
296 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
297 			struct snd_pcm_hw_params *params)
298 {
299 	struct snd_interval *rate = hw_param_interval(params,
300 			SNDRV_PCM_HW_PARAM_RATE);
301 	struct snd_interval *chan = hw_param_interval(params,
302 			SNDRV_PCM_HW_PARAM_CHANNELS);
303 	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
304 	struct snd_soc_dpcm *dpcm, *rtd_dpcm = NULL;
305 
306 	/*
307 	 * The following loop will be called only for playback stream
308 	 * In this platform, there is only one playback device on every SSP
309 	 */
310 	for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) {
311 		rtd_dpcm = dpcm;
312 		break;
313 	}
314 
315 	/*
316 	 * This following loop will be called only for capture stream
317 	 * In this platform, there is only one capture device on every SSP
318 	 */
319 	for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) {
320 		rtd_dpcm = dpcm;
321 		break;
322 	}
323 
324 	if (!rtd_dpcm)
325 		return -EINVAL;
326 
327 	/*
328 	 * The above 2 loops are mutually exclusive based on the stream direction,
329 	 * thus rtd_dpcm variable will never be overwritten
330 	 */
331 
332 	/*
333 	 * The ADSP will convert the FE rate to 48k, stereo, 24 bit
334 	 */
335 	if (!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Port") ||
336 	    !strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Headset Playback") ||
337 	    !strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Capture Port")) {
338 		rate->min = rate->max = 48000;
339 		chan->min = chan->max = 2;
340 		snd_mask_none(fmt);
341 		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
342 	}
343 
344 	/*
345 	 * The speaker on the SSP0 supports S16_LE and not S24_LE.
346 	 * thus changing the mask here
347 	 */
348 	if (!strcmp(rtd_dpcm->be->dai_link->name, "SSP0-Codec"))
349 		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
350 
351 	return 0;
352 }
353 
354 static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
355 {
356 	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
357 	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
358 	struct snd_soc_jack *jack;
359 	struct snd_soc_card *card = rtd->card;
360 	int ret;
361 
362 
363 	ret = snd_soc_dapm_add_routes(&card->dapm,
364 			kabylake_ssp1_map,
365 			ARRAY_SIZE(kabylake_ssp1_map));
366 
367 	if (ret)
368 		return ret;
369 
370 	/*
371 	 * Headset buttons map to the google Reference headset.
372 	 * These can be configured by userspace.
373 	 */
374 	ret = snd_soc_card_jack_new_pins(kabylake_audio_card, "Headset Jack",
375 					 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
376 					 SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
377 					 &ctx->kabylake_headset,
378 					 jack_pins,
379 					 ARRAY_SIZE(jack_pins));
380 	if (ret) {
381 		dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
382 		return ret;
383 	}
384 
385 	jack = &ctx->kabylake_headset;
386 	snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
387 	snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
388 	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
389 	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
390 
391 	snd_soc_component_set_jack(component, &ctx->kabylake_headset, NULL);
392 
393 	return 0;
394 }
395 
396 static int kabylake_dmic_init(struct snd_soc_pcm_runtime *rtd)
397 {
398 	int ret;
399 	ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
400 	if (ret)
401 		dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret);
402 
403 	return ret;
404 }
405 
406 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
407 {
408 	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
409 	struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
410 	struct kbl_hdmi_pcm *pcm;
411 
412 	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
413 	if (!pcm)
414 		return -ENOMEM;
415 
416 	pcm->device = device;
417 	pcm->codec_dai = dai;
418 
419 	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
420 
421 	return 0;
422 }
423 
424 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
425 {
426 	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
427 }
428 
429 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
430 {
431 	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
432 }
433 
434 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
435 {
436 	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
437 }
438 
439 static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
440 {
441 	struct snd_soc_dapm_context *dapm;
442 	struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
443 
444 	dapm = snd_soc_component_get_dapm(component);
445 	snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
446 
447 	return 0;
448 }
449 
450 static const unsigned int rates[] = {
451 	48000,
452 };
453 
454 static const struct snd_pcm_hw_constraint_list constraints_rates = {
455 	.count = ARRAY_SIZE(rates),
456 	.list  = rates,
457 	.mask = 0,
458 };
459 
460 static const unsigned int channels[] = {
461 	DUAL_CHANNEL,
462 };
463 
464 static const struct snd_pcm_hw_constraint_list constraints_channels = {
465 	.count = ARRAY_SIZE(channels),
466 	.list = channels,
467 	.mask = 0,
468 };
469 
470 static unsigned int channels_quad[] = {
471 	QUAD_CHANNEL,
472 };
473 
474 static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
475 	.count = ARRAY_SIZE(channels_quad),
476 	.list = channels_quad,
477 	.mask = 0,
478 };
479 
480 static int kbl_fe_startup(struct snd_pcm_substream *substream)
481 {
482 	struct snd_pcm_runtime *runtime = substream->runtime;
483 
484 	/*
485 	 * On this platform for PCM device we support,
486 	 * 48Khz
487 	 * stereo
488 	 * 16 bit audio
489 	 */
490 
491 	runtime->hw.channels_max = DUAL_CHANNEL;
492 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
493 					   &constraints_channels);
494 
495 	runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
496 	snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
497 
498 	snd_pcm_hw_constraint_list(runtime, 0,
499 				SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
500 
501 	return 0;
502 }
503 
504 static const struct snd_soc_ops kabylake_da7219_fe_ops = {
505 	.startup = kbl_fe_startup,
506 };
507 
508 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
509 		struct snd_pcm_hw_params *params)
510 {
511 	struct snd_interval *chan = hw_param_interval(params,
512 				SNDRV_PCM_HW_PARAM_CHANNELS);
513 
514 	/*
515 	 * set BE channel constraint as user FE channels
516 	 */
517 
518 	if (params_channels(params) == 2)
519 		chan->min = chan->max = 2;
520 	else
521 		chan->min = chan->max = 4;
522 
523 	return 0;
524 }
525 
526 static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
527 {
528 	struct snd_pcm_runtime *runtime = substream->runtime;
529 
530 	runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
531 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
532 			&constraints_channels_quad);
533 
534 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
535 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
536 }
537 
538 static struct snd_soc_ops kabylake_dmic_ops = {
539 	.startup = kabylake_dmic_startup,
540 };
541 
542 static const unsigned int rates_16000[] = {
543 	16000,
544 };
545 
546 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
547 	.count = ARRAY_SIZE(rates_16000),
548 	.list  = rates_16000,
549 };
550 
551 static const unsigned int ch_mono[] = {
552 	1,
553 };
554 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
555 	.count = ARRAY_SIZE(ch_mono),
556 	.list  = ch_mono,
557 };
558 
559 static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
560 {
561 	substream->runtime->hw.channels_max = 1;
562 	snd_pcm_hw_constraint_list(substream->runtime, 0,
563 					SNDRV_PCM_HW_PARAM_CHANNELS,
564 					&constraints_refcap);
565 
566 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
567 				SNDRV_PCM_HW_PARAM_RATE,
568 				&constraints_16000);
569 }
570 
571 
572 static struct snd_soc_ops skylake_refcap_ops = {
573 	.startup = kabylake_refcap_startup,
574 };
575 
576 static struct snd_soc_codec_conf max98927_codec_conf[] = {
577 
578 	{
579 		.dlc = COMP_CODEC_CONF(MAX98927_DEV0_NAME),
580 		.name_prefix = "Right",
581 	},
582 
583 	{
584 		.dlc = COMP_CODEC_CONF(MAX98927_DEV1_NAME),
585 		.name_prefix = "Left",
586 	},
587 };
588 
589 static struct snd_soc_codec_conf max98373_codec_conf[] = {
590 
591 	{
592 		.dlc = COMP_CODEC_CONF(MAX98373_DEV0_NAME),
593 		.name_prefix = "Right",
594 	},
595 
596 	{
597 		.dlc = COMP_CODEC_CONF(MAX98373_DEV1_NAME),
598 		.name_prefix = "Left",
599 	},
600 };
601 
602 static struct snd_soc_dai_link_component max98373_ssp0_codec_components[] = {
603 	{ /* Left */
604 		.name = MAX98373_DEV0_NAME,
605 		.dai_name = MAX98373_CODEC_DAI,
606 	},
607 
608 	{  /* For Right */
609 		.name = MAX98373_DEV1_NAME,
610 		.dai_name = MAX98373_CODEC_DAI,
611 	},
612 
613 };
614 
615 SND_SOC_DAILINK_DEF(dummy,
616 	DAILINK_COMP_ARRAY(COMP_DUMMY()));
617 
618 SND_SOC_DAILINK_DEF(system,
619 	DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
620 
621 SND_SOC_DAILINK_DEF(echoref,
622 	DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin")));
623 
624 SND_SOC_DAILINK_DEF(reference,
625 	DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
626 
627 SND_SOC_DAILINK_DEF(dmic,
628 	DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
629 
630 SND_SOC_DAILINK_DEF(hdmi1,
631 	DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
632 
633 SND_SOC_DAILINK_DEF(hdmi2,
634 	DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
635 
636 SND_SOC_DAILINK_DEF(hdmi3,
637 	DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
638 
639 SND_SOC_DAILINK_DEF(system2,
640 	DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
641 
642 SND_SOC_DAILINK_DEF(ssp0_pin,
643 	DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
644 SND_SOC_DAILINK_DEF(ssp0_codec,
645 	DAILINK_COMP_ARRAY(
646 	/* Left */	COMP_CODEC(MAX98927_DEV0_NAME, MAX98927_CODEC_DAI),
647 	/* For Right */	COMP_CODEC(MAX98927_DEV1_NAME, MAX98927_CODEC_DAI)));
648 
649 SND_SOC_DAILINK_DEF(ssp1_pin,
650 	DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
651 SND_SOC_DAILINK_DEF(ssp1_codec,
652 	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
653 				      KBL_DIALOG_CODEC_DAI)));
654 
655 SND_SOC_DAILINK_DEF(dmic_pin,
656 	DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
657 SND_SOC_DAILINK_DEF(dmic_codec,
658 	DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
659 
660 SND_SOC_DAILINK_DEF(idisp1_pin,
661 	DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
662 SND_SOC_DAILINK_DEF(idisp1_codec,
663 	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
664 
665 SND_SOC_DAILINK_DEF(idisp2_pin,
666 	DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
667 SND_SOC_DAILINK_DEF(idisp2_codec,
668 	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
669 
670 SND_SOC_DAILINK_DEF(idisp3_pin,
671 	DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
672 SND_SOC_DAILINK_DEF(idisp3_codec,
673 	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
674 
675 SND_SOC_DAILINK_DEF(platform,
676 	DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
677 
678 /* kabylake digital audio interface glue - connects codec <--> CPU */
679 static struct snd_soc_dai_link kabylake_dais[] = {
680 	/* Front End DAI links */
681 	[KBL_DPCM_AUDIO_PB] = {
682 		.name = "Kbl Audio Port",
683 		.stream_name = "Audio",
684 		.dynamic = 1,
685 		.nonatomic = 1,
686 		.init = kabylake_da7219_fe_init,
687 		.trigger = {
688 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
689 		.dpcm_playback = 1,
690 		.ops = &kabylake_da7219_fe_ops,
691 		SND_SOC_DAILINK_REG(system, dummy, platform),
692 	},
693 	[KBL_DPCM_AUDIO_ECHO_REF_CP] = {
694 		.name = "Kbl Audio Echo Reference cap",
695 		.stream_name = "Echoreference Capture",
696 		.init = NULL,
697 		.dpcm_capture = 1,
698 		.nonatomic = 1,
699 		SND_SOC_DAILINK_REG(echoref, dummy, platform),
700 	},
701 	[KBL_DPCM_AUDIO_REF_CP] = {
702 		.name = "Kbl Audio Reference cap",
703 		.stream_name = "Wake on Voice",
704 		.init = NULL,
705 		.dpcm_capture = 1,
706 		.nonatomic = 1,
707 		.dynamic = 1,
708 		.ops = &skylake_refcap_ops,
709 		SND_SOC_DAILINK_REG(reference, dummy, platform),
710 	},
711 	[KBL_DPCM_AUDIO_DMIC_CP] = {
712 		.name = "Kbl Audio DMIC cap",
713 		.stream_name = "dmiccap",
714 		.init = NULL,
715 		.dpcm_capture = 1,
716 		.nonatomic = 1,
717 		.dynamic = 1,
718 		.ops = &kabylake_dmic_ops,
719 		SND_SOC_DAILINK_REG(dmic, dummy, platform),
720 	},
721 	[KBL_DPCM_AUDIO_HDMI1_PB] = {
722 		.name = "Kbl HDMI Port1",
723 		.stream_name = "Hdmi1",
724 		.dpcm_playback = 1,
725 		.init = NULL,
726 		.trigger = {
727 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
728 		.nonatomic = 1,
729 		.dynamic = 1,
730 		SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
731 	},
732 	[KBL_DPCM_AUDIO_HDMI2_PB] = {
733 		.name = "Kbl HDMI Port2",
734 		.stream_name = "Hdmi2",
735 		.dpcm_playback = 1,
736 		.init = NULL,
737 		.trigger = {
738 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
739 		.nonatomic = 1,
740 		.dynamic = 1,
741 		SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
742 	},
743 	[KBL_DPCM_AUDIO_HDMI3_PB] = {
744 		.name = "Kbl HDMI Port3",
745 		.stream_name = "Hdmi3",
746 		.trigger = {
747 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
748 		.dpcm_playback = 1,
749 		.init = NULL,
750 		.nonatomic = 1,
751 		.dynamic = 1,
752 		SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
753 	},
754 	[KBL_DPCM_AUDIO_HS_PB] = {
755 		.name = "Kbl Audio Headset Playback",
756 		.stream_name = "Headset Audio",
757 		.dpcm_playback = 1,
758 		.nonatomic = 1,
759 		.dynamic = 1,
760 		.init = kabylake_da7219_fe_init,
761 		.trigger = {
762 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
763 		.ops = &kabylake_da7219_fe_ops,
764 		SND_SOC_DAILINK_REG(system2, dummy, platform),
765 	},
766 	[KBL_DPCM_AUDIO_CP] = {
767 		.name = "Kbl Audio Capture Port",
768 		.stream_name = "Audio Record",
769 		.dynamic = 1,
770 		.nonatomic = 1,
771 		.trigger = {
772 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
773 		.dpcm_capture = 1,
774 		.ops = &kabylake_da7219_fe_ops,
775 		SND_SOC_DAILINK_REG(system, dummy, platform),
776 	},
777 
778 	/* Back End DAI links */
779 	{
780 		/* SSP0 - Codec */
781 		.name = "SSP0-Codec",
782 		.id = 0,
783 		.no_pcm = 1,
784 		.dai_fmt = SND_SOC_DAIFMT_DSP_B |
785 			SND_SOC_DAIFMT_NB_NF |
786 			SND_SOC_DAIFMT_CBC_CFC,
787 		.dpcm_playback = 1,
788 		.dpcm_capture = 1,
789 		.ignore_pmdown_time = 1,
790 		.be_hw_params_fixup = kabylake_ssp_fixup,
791 		.ops = &kabylake_ssp0_ops,
792 		SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
793 	},
794 	{
795 		/* SSP1 - Codec */
796 		.name = "SSP1-Codec",
797 		.id = 1,
798 		.no_pcm = 1,
799 		.init = kabylake_da7219_codec_init,
800 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
801 			SND_SOC_DAIFMT_CBC_CFC,
802 		.ignore_pmdown_time = 1,
803 		.be_hw_params_fixup = kabylake_ssp_fixup,
804 		.dpcm_playback = 1,
805 		.dpcm_capture = 1,
806 		SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
807 	},
808 	{
809 		.name = "dmic01",
810 		.id = 2,
811 		.init = kabylake_dmic_init,
812 		.be_hw_params_fixup = kabylake_dmic_fixup,
813 		.ignore_suspend = 1,
814 		.dpcm_capture = 1,
815 		.no_pcm = 1,
816 		SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
817 	},
818 	{
819 		.name = "iDisp1",
820 		.id = 3,
821 		.dpcm_playback = 1,
822 		.init = kabylake_hdmi1_init,
823 		.no_pcm = 1,
824 		SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
825 	},
826 	{
827 		.name = "iDisp2",
828 		.id = 4,
829 		.init = kabylake_hdmi2_init,
830 		.dpcm_playback = 1,
831 		.no_pcm = 1,
832 		SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
833 	},
834 	{
835 		.name = "iDisp3",
836 		.id = 5,
837 		.init = kabylake_hdmi3_init,
838 		.dpcm_playback = 1,
839 		.no_pcm = 1,
840 		SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
841 	},
842 };
843 
844 /* kabylake digital audio interface glue - connects codec <--> CPU */
845 static struct snd_soc_dai_link kabylake_max98_927_373_dais[] = {
846 	/* Front End DAI links */
847 	[KBL_DPCM_AUDIO_PB] = {
848 		.name = "Kbl Audio Port",
849 		.stream_name = "Audio",
850 		.dynamic = 1,
851 		.nonatomic = 1,
852 		.init = kabylake_da7219_fe_init,
853 		.trigger = {
854 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
855 		.dpcm_playback = 1,
856 		.ops = &kabylake_da7219_fe_ops,
857 		SND_SOC_DAILINK_REG(system, dummy, platform),
858 	},
859 	[KBL_DPCM_AUDIO_ECHO_REF_CP] = {
860 		.name = "Kbl Audio Echo Reference cap",
861 		.stream_name = "Echoreference Capture",
862 		.init = NULL,
863 		.dpcm_capture = 1,
864 		.nonatomic = 1,
865 		SND_SOC_DAILINK_REG(echoref, dummy, platform),
866 	},
867 	[KBL_DPCM_AUDIO_REF_CP] = {
868 		.name = "Kbl Audio Reference cap",
869 		.stream_name = "Wake on Voice",
870 		.init = NULL,
871 		.dpcm_capture = 1,
872 		.nonatomic = 1,
873 		.dynamic = 1,
874 		.ops = &skylake_refcap_ops,
875 		SND_SOC_DAILINK_REG(reference, dummy, platform),
876 	},
877 	[KBL_DPCM_AUDIO_DMIC_CP] = {
878 		.name = "Kbl Audio DMIC cap",
879 		.stream_name = "dmiccap",
880 		.init = NULL,
881 		.dpcm_capture = 1,
882 		.nonatomic = 1,
883 		.dynamic = 1,
884 		.ops = &kabylake_dmic_ops,
885 		SND_SOC_DAILINK_REG(dmic, dummy, platform),
886 	},
887 	[KBL_DPCM_AUDIO_HDMI1_PB] = {
888 		.name = "Kbl HDMI Port1",
889 		.stream_name = "Hdmi1",
890 		.dpcm_playback = 1,
891 		.init = NULL,
892 		.trigger = {
893 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
894 		.nonatomic = 1,
895 		.dynamic = 1,
896 		SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
897 	},
898 	[KBL_DPCM_AUDIO_HDMI2_PB] = {
899 		.name = "Kbl HDMI Port2",
900 		.stream_name = "Hdmi2",
901 		.dpcm_playback = 1,
902 		.init = NULL,
903 		.trigger = {
904 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
905 		.nonatomic = 1,
906 		.dynamic = 1,
907 		SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
908 	},
909 	[KBL_DPCM_AUDIO_HDMI3_PB] = {
910 		.name = "Kbl HDMI Port3",
911 		.stream_name = "Hdmi3",
912 		.trigger = {
913 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
914 		.dpcm_playback = 1,
915 		.init = NULL,
916 		.nonatomic = 1,
917 		.dynamic = 1,
918 		SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
919 	},
920 
921 	/* Back End DAI links */
922 	{
923 		/* SSP0 - Codec */
924 		.name = "SSP0-Codec",
925 		.id = 0,
926 		.no_pcm = 1,
927 		.dai_fmt = SND_SOC_DAIFMT_DSP_B |
928 			SND_SOC_DAIFMT_NB_NF |
929 			SND_SOC_DAIFMT_CBC_CFC,
930 		.dpcm_playback = 1,
931 		.dpcm_capture = 1,
932 		.ignore_pmdown_time = 1,
933 		.be_hw_params_fixup = kabylake_ssp_fixup,
934 		.ops = &kabylake_ssp0_ops,
935 		SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec),
936 	},
937 	{
938 		.name = "dmic01",
939 		.id = 1,
940 		.init = kabylake_dmic_init,
941 		.be_hw_params_fixup = kabylake_dmic_fixup,
942 		.ignore_suspend = 1,
943 		.dpcm_capture = 1,
944 		.no_pcm = 1,
945 		SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
946 	},
947 	{
948 		.name = "iDisp1",
949 		.id = 2,
950 		.dpcm_playback = 1,
951 		.init = kabylake_hdmi1_init,
952 		.no_pcm = 1,
953 		SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
954 	},
955 	{
956 		.name = "iDisp2",
957 		.id = 3,
958 		.init = kabylake_hdmi2_init,
959 		.dpcm_playback = 1,
960 		.no_pcm = 1,
961 		SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
962 	},
963 	{
964 		.name = "iDisp3",
965 		.id = 4,
966 		.init = kabylake_hdmi3_init,
967 		.dpcm_playback = 1,
968 		.no_pcm = 1,
969 		SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
970 	},
971 };
972 
973 static int kabylake_card_late_probe(struct snd_soc_card *card)
974 {
975 	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
976 	struct kbl_hdmi_pcm *pcm;
977 	struct snd_soc_dapm_context *dapm = &card->dapm;
978 	struct snd_soc_component *component = NULL;
979 	int err, i = 0;
980 	char jack_name[NAME_SIZE];
981 
982 	list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
983 		component = pcm->codec_dai->component;
984 		snprintf(jack_name, sizeof(jack_name),
985 			"HDMI/DP, pcm=%d Jack", pcm->device);
986 		err = snd_soc_card_jack_new(card, jack_name,
987 					SND_JACK_AVOUT, &kabylake_hdmi[i]);
988 
989 		if (err)
990 			return err;
991 
992 		err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
993 						&kabylake_hdmi[i]);
994 		if (err < 0)
995 			return err;
996 
997 		i++;
998 	}
999 
1000 	if (!component)
1001 		return -EINVAL;
1002 
1003 
1004 	err = hdac_hdmi_jack_port_init(component, &card->dapm);
1005 
1006 	if (err < 0)
1007 		return err;
1008 
1009 	err = snd_soc_dapm_disable_pin(dapm, "Left Spk");
1010 	if (err) {
1011 		dev_err(card->dev, "failed to disable Left Spk: %d\n", err);
1012 		return err;
1013 	}
1014 
1015 	err = snd_soc_dapm_disable_pin(dapm, "Right Spk");
1016 	if (err) {
1017 		dev_err(card->dev, "failed to disable Right Spk: %d\n", err);
1018 		return err;
1019 	}
1020 
1021 	return snd_soc_dapm_sync(dapm);
1022 }
1023 
1024 /* kabylake audio machine driver for SPT + DA7219 */
1025 static struct snd_soc_card kbl_audio_card_da7219_m98927 = {
1026 	.name = "kblda7219m98927",
1027 	.owner = THIS_MODULE,
1028 	.dai_link = kabylake_dais,
1029 	.num_links = ARRAY_SIZE(kabylake_dais),
1030 	.controls = kabylake_controls,
1031 	.num_controls = ARRAY_SIZE(kabylake_controls),
1032 	.dapm_widgets = kabylake_widgets,
1033 	.num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1034 	.dapm_routes = kabylake_map,
1035 	.num_dapm_routes = ARRAY_SIZE(kabylake_map),
1036 	.codec_conf = max98927_codec_conf,
1037 	.num_configs = ARRAY_SIZE(max98927_codec_conf),
1038 	.fully_routed = true,
1039 	.disable_route_checks = true,
1040 	.late_probe = kabylake_card_late_probe,
1041 };
1042 
1043 /* kabylake audio machine driver for Maxim98927 */
1044 static struct snd_soc_card kbl_audio_card_max98927 = {
1045 	.name = "kblmax98927",
1046 	.owner = THIS_MODULE,
1047 	.dai_link = kabylake_max98_927_373_dais,
1048 	.num_links = ARRAY_SIZE(kabylake_max98_927_373_dais),
1049 	.controls = kabylake_controls,
1050 	.num_controls = ARRAY_SIZE(kabylake_controls),
1051 	.dapm_widgets = kabylake_widgets,
1052 	.num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1053 	.dapm_routes = kabylake_map,
1054 	.num_dapm_routes = ARRAY_SIZE(kabylake_map),
1055 	.codec_conf = max98927_codec_conf,
1056 	.num_configs = ARRAY_SIZE(max98927_codec_conf),
1057 	.fully_routed = true,
1058 	.disable_route_checks = true,
1059 	.late_probe = kabylake_card_late_probe,
1060 };
1061 
1062 static struct snd_soc_card kbl_audio_card_da7219_m98373 = {
1063 	.name = "kblda7219m98373",
1064 	.owner = THIS_MODULE,
1065 	.dai_link = kabylake_dais,
1066 	.num_links = ARRAY_SIZE(kabylake_dais),
1067 	.controls = kabylake_controls,
1068 	.num_controls = ARRAY_SIZE(kabylake_controls),
1069 	.dapm_widgets = kabylake_widgets,
1070 	.num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1071 	.dapm_routes = kabylake_map,
1072 	.num_dapm_routes = ARRAY_SIZE(kabylake_map),
1073 	.codec_conf = max98373_codec_conf,
1074 	.num_configs = ARRAY_SIZE(max98373_codec_conf),
1075 	.fully_routed = true,
1076 	.disable_route_checks = true,
1077 	.late_probe = kabylake_card_late_probe,
1078 };
1079 
1080 static struct snd_soc_card kbl_audio_card_max98373 = {
1081 	.name = "kblmax98373",
1082 	.owner = THIS_MODULE,
1083 	.dai_link = kabylake_max98_927_373_dais,
1084 	.num_links = ARRAY_SIZE(kabylake_max98_927_373_dais),
1085 	.controls = kabylake_controls,
1086 	.num_controls = ARRAY_SIZE(kabylake_controls),
1087 	.dapm_widgets = kabylake_widgets,
1088 	.num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1089 	.dapm_routes = kabylake_map,
1090 	.num_dapm_routes = ARRAY_SIZE(kabylake_map),
1091 	.codec_conf = max98373_codec_conf,
1092 	.num_configs = ARRAY_SIZE(max98373_codec_conf),
1093 	.fully_routed = true,
1094 	.disable_route_checks = true,
1095 	.late_probe = kabylake_card_late_probe,
1096 };
1097 
1098 static int kabylake_audio_probe(struct platform_device *pdev)
1099 {
1100 	struct kbl_codec_private *ctx;
1101 	struct snd_soc_dai_link *kbl_dai_link;
1102 	struct snd_soc_dai_link_component **codecs;
1103 	int i;
1104 
1105 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
1106 	if (!ctx)
1107 		return -ENOMEM;
1108 
1109 	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
1110 
1111 	kabylake_audio_card =
1112 		(struct snd_soc_card *)pdev->id_entry->driver_data;
1113 
1114 	kbl_dai_link = kabylake_audio_card->dai_link;
1115 
1116 	/* Update codecs for SSP0 with max98373 codec info */
1117 	if (!strcmp(pdev->name, "kbl_da7219_max98373") ||
1118 		(!strcmp(pdev->name, "kbl_max98373"))) {
1119 		for (i = 0; i < kabylake_audio_card->num_links; ++i) {
1120 			if (strcmp(kbl_dai_link[i].name, "SSP0-Codec"))
1121 				continue;
1122 
1123 			codecs = &(kbl_dai_link[i].codecs);
1124 			*codecs = max98373_ssp0_codec_components;
1125 			kbl_dai_link[i].num_codecs =
1126 				ARRAY_SIZE(max98373_ssp0_codec_components);
1127 			break;
1128 		}
1129 	}
1130 	kabylake_audio_card->dev = &pdev->dev;
1131 	snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
1132 
1133 	return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
1134 }
1135 
1136 static const struct platform_device_id kbl_board_ids[] = {
1137 	{
1138 		.name = "kbl_da7219_max98927",
1139 		.driver_data =
1140 			(kernel_ulong_t)&kbl_audio_card_da7219_m98927,
1141 	},
1142 	{
1143 		.name = "kbl_max98927",
1144 		.driver_data =
1145 			(kernel_ulong_t)&kbl_audio_card_max98927,
1146 	},
1147 	{
1148 		.name = "kbl_da7219_max98373",
1149 		.driver_data =
1150 			(kernel_ulong_t)&kbl_audio_card_da7219_m98373,
1151 	},
1152 	{
1153 		.name = "kbl_max98373",
1154 		.driver_data =
1155 			(kernel_ulong_t)&kbl_audio_card_max98373,
1156 	},
1157 	{ }
1158 };
1159 MODULE_DEVICE_TABLE(platform, kbl_board_ids);
1160 
1161 static struct platform_driver kabylake_audio = {
1162 	.probe = kabylake_audio_probe,
1163 	.driver = {
1164 		.name = "kbl_da7219_max98_927_373",
1165 		.pm = &snd_soc_pm_ops,
1166 	},
1167 	.id_table = kbl_board_ids,
1168 };
1169 
1170 module_platform_driver(kabylake_audio)
1171 
1172 /* Module information */
1173 MODULE_DESCRIPTION("Audio KabyLake Machine driver for MAX98927/MAX98373 & DA7219");
1174 MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
1175 MODULE_LICENSE("GPL v2");
1176