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