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