1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Intel Skylake I2S Machine Driver for NAU88L25+SSM4567
4  *
5  * Copyright (C) 2015, Intel Corporation. All rights reserved.
6  *
7  * Modified from:
8  *   Intel Skylake I2S Machine Driver for NAU88L25 and SSM4567
9  *
10  *   Copyright (C) 2015, Intel Corporation. All rights reserved.
11  */
12 
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <sound/core.h>
16 #include <sound/pcm.h>
17 #include <sound/soc.h>
18 #include <sound/soc-acpi.h>
19 #include <sound/jack.h>
20 #include <sound/pcm_params.h>
21 #include "../../codecs/nau8825.h"
22 #include "../../codecs/hdac_hdmi.h"
23 
24 #define SKL_NUVOTON_CODEC_DAI	"nau8825-hifi"
25 #define SKL_SSM_CODEC_DAI	"ssm4567-hifi"
26 #define DMIC_CH(p)     p->list[p->count-1]
27 
28 static struct snd_soc_jack skylake_headset;
29 static struct snd_soc_card skylake_audio_card;
30 static const struct snd_pcm_hw_constraint_list *dmic_constraints;
31 static struct snd_soc_jack skylake_hdmi[3];
32 
33 struct skl_hdmi_pcm {
34 	struct list_head head;
35 	struct snd_soc_dai *codec_dai;
36 	int device;
37 };
38 
39 struct skl_nau88125_private {
40 	struct list_head hdmi_pcm_list;
41 };
42 enum {
43 	SKL_DPCM_AUDIO_PB = 0,
44 	SKL_DPCM_AUDIO_CP,
45 	SKL_DPCM_AUDIO_REF_CP,
46 	SKL_DPCM_AUDIO_DMIC_CP,
47 	SKL_DPCM_AUDIO_HDMI1_PB,
48 	SKL_DPCM_AUDIO_HDMI2_PB,
49 	SKL_DPCM_AUDIO_HDMI3_PB,
50 };
51 
52 static const struct snd_kcontrol_new skylake_controls[] = {
53 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
54 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
55 	SOC_DAPM_PIN_SWITCH("Left Speaker"),
56 	SOC_DAPM_PIN_SWITCH("Right Speaker"),
57 };
58 
59 static int platform_clock_control(struct snd_soc_dapm_widget *w,
60 		struct snd_kcontrol *k, int  event)
61 {
62 	struct snd_soc_dapm_context *dapm = w->dapm;
63 	struct snd_soc_card *card = dapm->card;
64 	struct snd_soc_dai *codec_dai;
65 	int ret;
66 
67 	codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
68 	if (!codec_dai) {
69 		dev_err(card->dev, "Codec dai not found\n");
70 		return -EIO;
71 	}
72 
73 	if (SND_SOC_DAPM_EVENT_ON(event)) {
74 		ret = snd_soc_dai_set_sysclk(codec_dai,
75 				NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN);
76 		if (ret < 0) {
77 			dev_err(card->dev, "set sysclk err = %d\n", ret);
78 			return -EIO;
79 		}
80 	} else {
81 		ret = snd_soc_dai_set_sysclk(codec_dai,
82 				NAU8825_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN);
83 		if (ret < 0) {
84 			dev_err(card->dev, "set sysclk err = %d\n", ret);
85 			return -EIO;
86 		}
87 	}
88 	return ret;
89 }
90 
91 static const struct snd_soc_dapm_widget skylake_widgets[] = {
92 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
93 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
94 	SND_SOC_DAPM_SPK("Left Speaker", NULL),
95 	SND_SOC_DAPM_SPK("Right Speaker", NULL),
96 	SND_SOC_DAPM_MIC("SoC DMIC", NULL),
97 	SND_SOC_DAPM_SPK("DP1", NULL),
98 	SND_SOC_DAPM_SPK("DP2", NULL),
99 	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
100 			platform_clock_control, SND_SOC_DAPM_PRE_PMU |
101 			SND_SOC_DAPM_POST_PMD),
102 };
103 
104 static const struct snd_soc_dapm_route skylake_map[] = {
105 	/* HP jack connectors - unknown if we have jack detection */
106 	{"Headphone Jack", NULL, "HPOL"},
107 	{"Headphone Jack", NULL, "HPOR"},
108 
109 	/* speaker */
110 	{"Left Speaker", NULL, "Left OUT"},
111 	{"Right Speaker", NULL, "Right OUT"},
112 
113 	/* other jacks */
114 	{"MIC", NULL, "Headset Mic"},
115 	{"DMic", NULL, "SoC DMIC"},
116 
117 	/* CODEC BE connections */
118 	{ "Left Playback", NULL, "ssp0 Tx"},
119 	{ "Right Playback", NULL, "ssp0 Tx"},
120 	{ "ssp0 Tx", NULL, "codec0_out"},
121 
122 	/* IV feedback path */
123 	{ "codec0_lp_in", NULL, "ssp0 Rx"},
124 	{ "ssp0 Rx", NULL, "Left Capture Sense" },
125 	{ "ssp0 Rx", NULL, "Right Capture Sense" },
126 
127 	{ "Playback", NULL, "ssp1 Tx"},
128 	{ "ssp1 Tx", NULL, "codec1_out"},
129 
130 	{ "codec0_in", NULL, "ssp1 Rx" },
131 	{ "ssp1 Rx", NULL, "Capture" },
132 
133 	/* DMIC */
134 	{ "dmic01_hifi", NULL, "DMIC01 Rx" },
135 	{ "DMIC01 Rx", NULL, "DMIC AIF" },
136 
137 	{ "hifi3", NULL, "iDisp3 Tx"},
138 	{ "iDisp3 Tx", NULL, "iDisp3_out"},
139 	{ "hifi2", NULL, "iDisp2 Tx"},
140 	{ "iDisp2 Tx", NULL, "iDisp2_out"},
141 	{ "hifi1", NULL, "iDisp1 Tx"},
142 	{ "iDisp1 Tx", NULL, "iDisp1_out"},
143 
144 	{ "Headphone Jack", NULL, "Platform Clock" },
145 	{ "Headset Mic", NULL, "Platform Clock" },
146 };
147 
148 static struct snd_soc_codec_conf ssm4567_codec_conf[] = {
149 	{
150 		.dev_name = "i2c-INT343B:00",
151 		.name_prefix = "Left",
152 	},
153 	{
154 		.dev_name = "i2c-INT343B:01",
155 		.name_prefix = "Right",
156 	},
157 };
158 
159 static struct snd_soc_dai_link_component ssm4567_codec_components[] = {
160 	{ /* Left */
161 		.name = "i2c-INT343B:00",
162 		.dai_name = SKL_SSM_CODEC_DAI,
163 	},
164 	{ /* Right */
165 		.name = "i2c-INT343B:01",
166 		.dai_name = SKL_SSM_CODEC_DAI,
167 	},
168 };
169 
170 static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd)
171 {
172 	int ret;
173 
174 	/* Slot 1 for left */
175 	ret = snd_soc_dai_set_tdm_slot(rtd->codec_dais[0], 0x01, 0x01, 2, 48);
176 	if (ret < 0)
177 		return ret;
178 
179 	/* Slot 2 for right */
180 	ret = snd_soc_dai_set_tdm_slot(rtd->codec_dais[1], 0x02, 0x02, 2, 48);
181 	if (ret < 0)
182 		return ret;
183 
184 	return ret;
185 }
186 
187 static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
188 {
189 	int ret;
190 	struct snd_soc_component *component = rtd->codec_dai->component;
191 
192 	/*
193 	 * 4 buttons here map to the google Reference headset
194 	 * The use of these buttons can be decided by the user space.
195 	 */
196 	ret = snd_soc_card_jack_new(&skylake_audio_card, "Headset Jack",
197 		SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
198 		SND_JACK_BTN_2 | SND_JACK_BTN_3, &skylake_headset,
199 		NULL, 0);
200 	if (ret) {
201 		dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
202 		return ret;
203 	}
204 
205 	nau8825_enable_jack_detect(component, &skylake_headset);
206 
207 	snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
208 
209 	return ret;
210 }
211 
212 static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
213 {
214 	struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
215 	struct snd_soc_dai *dai = rtd->codec_dai;
216 	struct skl_hdmi_pcm *pcm;
217 
218 	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
219 	if (!pcm)
220 		return -ENOMEM;
221 
222 	pcm->device = SKL_DPCM_AUDIO_HDMI1_PB;
223 	pcm->codec_dai = dai;
224 
225 	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
226 
227 	return 0;
228 }
229 
230 static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
231 {
232 	struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
233 	struct snd_soc_dai *dai = rtd->codec_dai;
234 	struct skl_hdmi_pcm *pcm;
235 
236 	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
237 	if (!pcm)
238 		return -ENOMEM;
239 
240 	pcm->device = SKL_DPCM_AUDIO_HDMI2_PB;
241 	pcm->codec_dai = dai;
242 
243 	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
244 
245 	return 0;
246 }
247 
248 
249 static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
250 {
251 	struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
252 	struct snd_soc_dai *dai = rtd->codec_dai;
253 	struct skl_hdmi_pcm *pcm;
254 
255 	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
256 	if (!pcm)
257 		return -ENOMEM;
258 
259 	pcm->device = SKL_DPCM_AUDIO_HDMI3_PB;
260 	pcm->codec_dai = dai;
261 
262 	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
263 
264 	return 0;
265 }
266 
267 static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd)
268 {
269 	struct snd_soc_dapm_context *dapm;
270 	struct snd_soc_component *component = rtd->cpu_dai->component;
271 
272 	dapm = snd_soc_component_get_dapm(component);
273 	snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
274 
275 	return 0;
276 }
277 
278 static const unsigned int rates[] = {
279 	48000,
280 };
281 
282 static const struct snd_pcm_hw_constraint_list constraints_rates = {
283 	.count = ARRAY_SIZE(rates),
284 	.list  = rates,
285 	.mask = 0,
286 };
287 
288 static const unsigned int channels[] = {
289 	2,
290 };
291 
292 static const struct snd_pcm_hw_constraint_list constraints_channels = {
293 	.count = ARRAY_SIZE(channels),
294 	.list = channels,
295 	.mask = 0,
296 };
297 
298 static int skl_fe_startup(struct snd_pcm_substream *substream)
299 {
300 	struct snd_pcm_runtime *runtime = substream->runtime;
301 
302 	/*
303 	 * on this platform for PCM device we support,
304 	 *	48Khz
305 	 *	stereo
306 	 *	16 bit audio
307 	 */
308 
309 	runtime->hw.channels_max = 2;
310 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
311 					   &constraints_channels);
312 
313 	runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
314 	snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
315 
316 	snd_pcm_hw_constraint_list(runtime, 0,
317 				SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
318 
319 	return 0;
320 }
321 
322 static const struct snd_soc_ops skylake_nau8825_fe_ops = {
323 	.startup = skl_fe_startup,
324 };
325 
326 static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
327 			struct snd_pcm_hw_params *params)
328 {
329 	struct snd_interval *rate = hw_param_interval(params,
330 			SNDRV_PCM_HW_PARAM_RATE);
331 	struct snd_interval *channels = hw_param_interval(params,
332 						SNDRV_PCM_HW_PARAM_CHANNELS);
333 	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
334 
335 	/* The ADSP will covert the FE rate to 48k, stereo */
336 	rate->min = rate->max = 48000;
337 	channels->min = channels->max = 2;
338 
339 	/* set SSP0 to 24 bit */
340 	snd_mask_none(fmt);
341 	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
342 	return 0;
343 }
344 
345 static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
346 			struct snd_pcm_hw_params *params)
347 {
348 	struct snd_interval *channels = hw_param_interval(params,
349 						SNDRV_PCM_HW_PARAM_CHANNELS);
350 	if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2)
351 		channels->min = channels->max = 2;
352 	else
353 		channels->min = channels->max = 4;
354 
355 	return 0;
356 }
357 
358 static int skylake_nau8825_hw_params(struct snd_pcm_substream *substream,
359 	struct snd_pcm_hw_params *params)
360 {
361 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
362 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
363 	int ret;
364 
365 	ret = snd_soc_dai_set_sysclk(codec_dai,
366 			NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN);
367 
368 	if (ret < 0)
369 		dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
370 
371 	return ret;
372 }
373 
374 static const struct snd_soc_ops skylake_nau8825_ops = {
375 	.hw_params = skylake_nau8825_hw_params,
376 };
377 
378 static const unsigned int channels_dmic[] = {
379 	2, 4,
380 };
381 
382 static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
383 	.count = ARRAY_SIZE(channels_dmic),
384 	.list = channels_dmic,
385 	.mask = 0,
386 };
387 
388 static const unsigned int dmic_2ch[] = {
389 	2,
390 };
391 
392 static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
393 	.count = ARRAY_SIZE(dmic_2ch),
394 	.list = dmic_2ch,
395 	.mask = 0,
396 };
397 
398 static int skylake_dmic_startup(struct snd_pcm_substream *substream)
399 {
400 	struct snd_pcm_runtime *runtime = substream->runtime;
401 
402 	runtime->hw.channels_max = DMIC_CH(dmic_constraints);
403 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
404 			dmic_constraints);
405 
406 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
407 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
408 }
409 
410 static const struct snd_soc_ops skylake_dmic_ops = {
411 	.startup = skylake_dmic_startup,
412 };
413 
414 static const unsigned int rates_16000[] = {
415 	16000,
416 };
417 
418 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
419 	.count = ARRAY_SIZE(rates_16000),
420 	.list  = rates_16000,
421 };
422 
423 static const unsigned int ch_mono[] = {
424 	1,
425 };
426 
427 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
428 	.count = ARRAY_SIZE(ch_mono),
429 	.list  = ch_mono,
430 };
431 
432 static int skylake_refcap_startup(struct snd_pcm_substream *substream)
433 {
434 	substream->runtime->hw.channels_max = 1;
435 	snd_pcm_hw_constraint_list(substream->runtime, 0,
436 					SNDRV_PCM_HW_PARAM_CHANNELS,
437 					&constraints_refcap);
438 
439 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
440 			SNDRV_PCM_HW_PARAM_RATE,
441 			&constraints_16000);
442 }
443 
444 static const struct snd_soc_ops skylake_refcap_ops = {
445 	.startup = skylake_refcap_startup,
446 };
447 
448 /* skylake digital audio interface glue - connects codec <--> CPU */
449 static struct snd_soc_dai_link skylake_dais[] = {
450 	/* Front End DAI links */
451 	[SKL_DPCM_AUDIO_PB] = {
452 		.name = "Skl Audio Port",
453 		.stream_name = "Audio",
454 		.cpu_dai_name = "System Pin",
455 		.platform_name = "0000:00:1f.3",
456 		.dynamic = 1,
457 		.codec_name = "snd-soc-dummy",
458 		.codec_dai_name = "snd-soc-dummy-dai",
459 		.nonatomic = 1,
460 		.init = skylake_nau8825_fe_init,
461 		.trigger = {
462 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
463 		.dpcm_playback = 1,
464 		.ops = &skylake_nau8825_fe_ops,
465 	},
466 	[SKL_DPCM_AUDIO_CP] = {
467 		.name = "Skl Audio Capture Port",
468 		.stream_name = "Audio Record",
469 		.cpu_dai_name = "System Pin",
470 		.platform_name = "0000:00:1f.3",
471 		.dynamic = 1,
472 		.codec_name = "snd-soc-dummy",
473 		.codec_dai_name = "snd-soc-dummy-dai",
474 		.nonatomic = 1,
475 		.trigger = {
476 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
477 		.dpcm_capture = 1,
478 		.ops = &skylake_nau8825_fe_ops,
479 	},
480 	[SKL_DPCM_AUDIO_REF_CP] = {
481 		.name = "Skl Audio Reference cap",
482 		.stream_name = "Wake on Voice",
483 		.cpu_dai_name = "Reference Pin",
484 		.codec_name = "snd-soc-dummy",
485 		.codec_dai_name = "snd-soc-dummy-dai",
486 		.platform_name = "0000:00:1f.3",
487 		.init = NULL,
488 		.dpcm_capture = 1,
489 		.nonatomic = 1,
490 		.dynamic = 1,
491 		.ops = &skylake_refcap_ops,
492 	},
493 	[SKL_DPCM_AUDIO_DMIC_CP] = {
494 		.name = "Skl Audio DMIC cap",
495 		.stream_name = "dmiccap",
496 		.cpu_dai_name = "DMIC Pin",
497 		.codec_name = "snd-soc-dummy",
498 		.codec_dai_name = "snd-soc-dummy-dai",
499 		.platform_name = "0000:00:1f.3",
500 		.init = NULL,
501 		.dpcm_capture = 1,
502 		.nonatomic = 1,
503 		.dynamic = 1,
504 		.ops = &skylake_dmic_ops,
505 	},
506 	[SKL_DPCM_AUDIO_HDMI1_PB] = {
507 		.name = "Skl HDMI Port1",
508 		.stream_name = "Hdmi1",
509 		.cpu_dai_name = "HDMI1 Pin",
510 		.codec_name = "snd-soc-dummy",
511 		.codec_dai_name = "snd-soc-dummy-dai",
512 		.platform_name = "0000:00:1f.3",
513 		.dpcm_playback = 1,
514 		.init = NULL,
515 		.trigger = {
516 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
517 		.nonatomic = 1,
518 		.dynamic = 1,
519 	},
520 	[SKL_DPCM_AUDIO_HDMI2_PB] = {
521 		.name = "Skl HDMI Port2",
522 		.stream_name = "Hdmi2",
523 		.cpu_dai_name = "HDMI2 Pin",
524 		.codec_name = "snd-soc-dummy",
525 		.codec_dai_name = "snd-soc-dummy-dai",
526 		.platform_name = "0000:00:1f.3",
527 		.dpcm_playback = 1,
528 		.init = NULL,
529 		.trigger = {
530 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
531 		.nonatomic = 1,
532 		.dynamic = 1,
533 	},
534 	[SKL_DPCM_AUDIO_HDMI3_PB] = {
535 		.name = "Skl HDMI Port3",
536 		.stream_name = "Hdmi3",
537 		.cpu_dai_name = "HDMI3 Pin",
538 		.codec_name = "snd-soc-dummy",
539 		.codec_dai_name = "snd-soc-dummy-dai",
540 		.platform_name = "0000:00:1f.3",
541 		.trigger = {
542 			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
543 		.dpcm_playback = 1,
544 		.init = NULL,
545 		.nonatomic = 1,
546 		.dynamic = 1,
547 	},
548 
549 	/* Back End DAI links */
550 	{
551 		/* SSP0 - Codec */
552 		.name = "SSP0-Codec",
553 		.id = 0,
554 		.cpu_dai_name = "SSP0 Pin",
555 		.platform_name = "0000:00:1f.3",
556 		.no_pcm = 1,
557 		.codecs = ssm4567_codec_components,
558 		.num_codecs = ARRAY_SIZE(ssm4567_codec_components),
559 		.dai_fmt = SND_SOC_DAIFMT_DSP_A |
560 			SND_SOC_DAIFMT_IB_NF |
561 			SND_SOC_DAIFMT_CBS_CFS,
562 		.init = skylake_ssm4567_codec_init,
563 		.ignore_pmdown_time = 1,
564 		.be_hw_params_fixup = skylake_ssp_fixup,
565 		.dpcm_playback = 1,
566 		.dpcm_capture = 1,
567 	},
568 	{
569 		/* SSP1 - Codec */
570 		.name = "SSP1-Codec",
571 		.id = 1,
572 		.cpu_dai_name = "SSP1 Pin",
573 		.platform_name = "0000:00:1f.3",
574 		.no_pcm = 1,
575 		.codec_name = "i2c-10508825:00",
576 		.codec_dai_name = SKL_NUVOTON_CODEC_DAI,
577 		.init = skylake_nau8825_codec_init,
578 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
579 			SND_SOC_DAIFMT_CBS_CFS,
580 		.ignore_pmdown_time = 1,
581 		.be_hw_params_fixup = skylake_ssp_fixup,
582 		.ops = &skylake_nau8825_ops,
583 		.dpcm_playback = 1,
584 		.dpcm_capture = 1,
585 	},
586 	{
587 		.name = "dmic01",
588 		.id = 2,
589 		.cpu_dai_name = "DMIC01 Pin",
590 		.codec_name = "dmic-codec",
591 		.codec_dai_name = "dmic-hifi",
592 		.platform_name = "0000:00:1f.3",
593 		.ignore_suspend = 1,
594 		.be_hw_params_fixup = skylake_dmic_fixup,
595 		.dpcm_capture = 1,
596 		.no_pcm = 1,
597 	},
598 	{
599 		.name = "iDisp1",
600 		.id = 3,
601 		.cpu_dai_name = "iDisp1 Pin",
602 		.codec_name = "ehdaudio0D2",
603 		.codec_dai_name = "intel-hdmi-hifi1",
604 		.platform_name = "0000:00:1f.3",
605 		.dpcm_playback = 1,
606 		.init = skylake_hdmi1_init,
607 		.no_pcm = 1,
608 	},
609 	{
610 		.name = "iDisp2",
611 		.id = 4,
612 		.cpu_dai_name = "iDisp2 Pin",
613 		.codec_name = "ehdaudio0D2",
614 		.codec_dai_name = "intel-hdmi-hifi2",
615 		.platform_name = "0000:00:1f.3",
616 		.init = skylake_hdmi2_init,
617 		.dpcm_playback = 1,
618 		.no_pcm = 1,
619 	},
620 	{
621 		.name = "iDisp3",
622 		.id = 5,
623 		.cpu_dai_name = "iDisp3 Pin",
624 		.codec_name = "ehdaudio0D2",
625 		.codec_dai_name = "intel-hdmi-hifi3",
626 		.platform_name = "0000:00:1f.3",
627 		.init = skylake_hdmi3_init,
628 		.dpcm_playback = 1,
629 		.no_pcm = 1,
630 	},
631 };
632 
633 #define NAME_SIZE	32
634 static int skylake_card_late_probe(struct snd_soc_card *card)
635 {
636 	struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card);
637 	struct skl_hdmi_pcm *pcm;
638 	struct snd_soc_component *component = NULL;
639 	int err, i = 0;
640 	char jack_name[NAME_SIZE];
641 
642 	list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
643 		component = pcm->codec_dai->component;
644 		snprintf(jack_name, sizeof(jack_name),
645 			"HDMI/DP, pcm=%d Jack", pcm->device);
646 		err = snd_soc_card_jack_new(card, jack_name,
647 					SND_JACK_AVOUT,
648 					&skylake_hdmi[i],
649 					NULL, 0);
650 
651 		if (err)
652 			return err;
653 
654 		err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
655 						&skylake_hdmi[i]);
656 		if (err < 0)
657 			return err;
658 
659 		i++;
660 	}
661 
662 	if (!component)
663 		return -EINVAL;
664 
665 	return hdac_hdmi_jack_port_init(component, &card->dapm);
666 }
667 
668 /* skylake audio machine driver for SPT + NAU88L25 */
669 static struct snd_soc_card skylake_audio_card = {
670 	.name = "sklnau8825adi",
671 	.owner = THIS_MODULE,
672 	.dai_link = skylake_dais,
673 	.num_links = ARRAY_SIZE(skylake_dais),
674 	.controls = skylake_controls,
675 	.num_controls = ARRAY_SIZE(skylake_controls),
676 	.dapm_widgets = skylake_widgets,
677 	.num_dapm_widgets = ARRAY_SIZE(skylake_widgets),
678 	.dapm_routes = skylake_map,
679 	.num_dapm_routes = ARRAY_SIZE(skylake_map),
680 	.codec_conf = ssm4567_codec_conf,
681 	.num_configs = ARRAY_SIZE(ssm4567_codec_conf),
682 	.fully_routed = true,
683 	.late_probe = skylake_card_late_probe,
684 };
685 
686 static int skylake_audio_probe(struct platform_device *pdev)
687 {
688 	struct skl_nau88125_private *ctx;
689 	struct snd_soc_acpi_mach *mach;
690 
691 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
692 	if (!ctx)
693 		return -ENOMEM;
694 
695 	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
696 
697 	skylake_audio_card.dev = &pdev->dev;
698 	snd_soc_card_set_drvdata(&skylake_audio_card, ctx);
699 
700 	mach = (&pdev->dev)->platform_data;
701 	if (mach)
702 		dmic_constraints = mach->mach_params.dmic_num == 2 ?
703 			&constraints_dmic_2ch : &constraints_dmic_channels;
704 
705 	return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card);
706 }
707 
708 static const struct platform_device_id skl_board_ids[] = {
709 	{ .name = "skl_n88l25_s4567" },
710 	{ .name = "kbl_n88l25_s4567" },
711 	{ }
712 };
713 
714 static struct platform_driver skylake_audio = {
715 	.probe = skylake_audio_probe,
716 	.driver = {
717 		.name = "skl_n88l25_s4567",
718 		.pm = &snd_soc_pm_ops,
719 	},
720 	.id_table = skl_board_ids,
721 };
722 
723 module_platform_driver(skylake_audio)
724 
725 /* Module information */
726 MODULE_AUTHOR("Conrad Cooke  <conrad.cooke@intel.com>");
727 MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
728 MODULE_AUTHOR("Naveen M <naveen.m@intel.com>");
729 MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>");
730 MODULE_AUTHOR("Yong Zhi <yong.zhi@intel.com>");
731 MODULE_DESCRIPTION("Intel Audio Machine driver for SKL with NAU88L25 and SSM4567 in I2S Mode");
732 MODULE_LICENSE("GPL v2");
733 MODULE_ALIAS("platform:skl_n88l25_s4567");
734 MODULE_ALIAS("platform:kbl_n88l25_s4567");
735