xref: /openbmc/linux/sound/soc/intel/boards/bxt_rt298.c (revision be709d48)
1 /*
2  * Intel Broxton-P I2S Machine Driver
3  *
4  * Copyright (C) 2014-2016, Intel Corporation. All rights reserved.
5  *
6  * Modified from:
7  *   Intel Skylake I2S Machine driver
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License version
11  * 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  */
18 
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <sound/core.h>
22 #include <sound/pcm.h>
23 #include <sound/soc.h>
24 #include <sound/soc-acpi.h>
25 #include <sound/jack.h>
26 #include <sound/pcm_params.h>
27 #include "../../codecs/hdac_hdmi.h"
28 #include "../../codecs/rt298.h"
29 
30 /* Headset jack detection DAPM pins */
31 static struct snd_soc_jack broxton_headset;
32 static struct snd_soc_jack broxton_hdmi[3];
33 
34 struct bxt_hdmi_pcm {
35 	struct list_head head;
36 	struct snd_soc_dai *codec_dai;
37 	int device;
38 };
39 
40 struct bxt_rt286_private {
41 	struct list_head hdmi_pcm_list;
42 };
43 
44 enum {
45 	BXT_DPCM_AUDIO_PB = 0,
46 	BXT_DPCM_AUDIO_CP,
47 	BXT_DPCM_AUDIO_REF_CP,
48 	BXT_DPCM_AUDIO_DMIC_CP,
49 	BXT_DPCM_AUDIO_HDMI1_PB,
50 	BXT_DPCM_AUDIO_HDMI2_PB,
51 	BXT_DPCM_AUDIO_HDMI3_PB,
52 };
53 
54 static struct snd_soc_jack_pin broxton_headset_pins[] = {
55 	{
56 		.pin = "Mic Jack",
57 		.mask = SND_JACK_MICROPHONE,
58 	},
59 	{
60 		.pin = "Headphone Jack",
61 		.mask = SND_JACK_HEADPHONE,
62 	},
63 };
64 
65 static const struct snd_kcontrol_new broxton_controls[] = {
66 	SOC_DAPM_PIN_SWITCH("Speaker"),
67 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
68 	SOC_DAPM_PIN_SWITCH("Mic Jack"),
69 };
70 
71 static const struct snd_soc_dapm_widget broxton_widgets[] = {
72 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
73 	SND_SOC_DAPM_SPK("Speaker", NULL),
74 	SND_SOC_DAPM_MIC("Mic Jack", NULL),
75 	SND_SOC_DAPM_MIC("DMIC2", NULL),
76 	SND_SOC_DAPM_MIC("SoC DMIC", NULL),
77 	SND_SOC_DAPM_SPK("HDMI1", NULL),
78 	SND_SOC_DAPM_SPK("HDMI2", NULL),
79 	SND_SOC_DAPM_SPK("HDMI3", NULL),
80 };
81 
82 static const struct snd_soc_dapm_route broxton_rt298_map[] = {
83 	/* speaker */
84 	{"Speaker", NULL, "SPOR"},
85 	{"Speaker", NULL, "SPOL"},
86 
87 	/* HP jack connectors - unknown if we have jack detect */
88 	{"Headphone Jack", NULL, "HPO Pin"},
89 
90 	/* other jacks */
91 	{"MIC1", NULL, "Mic Jack"},
92 
93 	/* digital mics */
94 	{"DMIC1 Pin", NULL, "DMIC2"},
95 	{"DMic", NULL, "SoC DMIC"},
96 
97 	{"HDMI1", NULL, "hif5-0 Output"},
98 	{"HDMI2", NULL, "hif6-0 Output"},
99 	{"HDMI2", NULL, "hif7-0 Output"},
100 
101 	/* CODEC BE connections */
102 	{ "AIF1 Playback", NULL, "ssp5 Tx"},
103 	{ "ssp5 Tx", NULL, "codec0_out"},
104 	{ "ssp5 Tx", NULL, "codec1_out"},
105 
106 	{ "codec0_in", NULL, "ssp5 Rx" },
107 	{ "ssp5 Rx", NULL, "AIF1 Capture" },
108 
109 	{ "dmic01_hifi", NULL, "DMIC01 Rx" },
110 	{ "DMIC01 Rx", NULL, "Capture" },
111 
112 	{ "hifi3", NULL, "iDisp3 Tx"},
113 	{ "iDisp3 Tx", NULL, "iDisp3_out"},
114 	{ "hifi2", NULL, "iDisp2 Tx"},
115 	{ "iDisp2 Tx", NULL, "iDisp2_out"},
116 	{ "hifi1", NULL, "iDisp1 Tx"},
117 	{ "iDisp1 Tx", NULL, "iDisp1_out"},
118 };
119 
120 static const struct snd_soc_dapm_route geminilake_rt298_map[] = {
121 	/* speaker */
122 	{"Speaker", NULL, "SPOR"},
123 	{"Speaker", NULL, "SPOL"},
124 
125 	/* HP jack connectors - unknown if we have jack detect */
126 	{"Headphone Jack", NULL, "HPO Pin"},
127 
128 	/* other jacks */
129 	{"MIC1", NULL, "Mic Jack"},
130 
131 	/* digital mics */
132 	{"DMIC1 Pin", NULL, "DMIC2"},
133 	{"DMic", NULL, "SoC DMIC"},
134 
135 	{"HDMI1", NULL, "hif5-0 Output"},
136 	{"HDMI2", NULL, "hif6-0 Output"},
137 	{"HDMI2", NULL, "hif7-0 Output"},
138 
139 	/* CODEC BE connections */
140 	{ "AIF1 Playback", NULL, "ssp2 Tx"},
141 	{ "ssp2 Tx", NULL, "codec0_out"},
142 	{ "ssp2 Tx", NULL, "codec1_out"},
143 
144 	{ "codec0_in", NULL, "ssp2 Rx" },
145 	{ "ssp2 Rx", NULL, "AIF1 Capture" },
146 
147 	{ "dmic01_hifi", NULL, "DMIC01 Rx" },
148 	{ "DMIC01 Rx", NULL, "Capture" },
149 
150 	{ "dmic_voice", NULL, "DMIC16k Rx" },
151 	{ "DMIC16k Rx", NULL, "Capture" },
152 
153 	{ "hifi3", NULL, "iDisp3 Tx"},
154 	{ "iDisp3 Tx", NULL, "iDisp3_out"},
155 	{ "hifi2", NULL, "iDisp2 Tx"},
156 	{ "iDisp2 Tx", NULL, "iDisp2_out"},
157 	{ "hifi1", NULL, "iDisp1 Tx"},
158 	{ "iDisp1 Tx", NULL, "iDisp1_out"},
159 };
160 
161 static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd)
162 {
163 	struct snd_soc_dapm_context *dapm;
164 	struct snd_soc_component *component = rtd->cpu_dai->component;
165 
166 	dapm = snd_soc_component_get_dapm(component);
167 	snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
168 
169 	return 0;
170 }
171 
172 static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd)
173 {
174 	struct snd_soc_component *component = rtd->codec_dai->component;
175 	int ret = 0;
176 
177 	ret = snd_soc_card_jack_new(rtd->card, "Headset",
178 		SND_JACK_HEADSET | SND_JACK_BTN_0,
179 		&broxton_headset,
180 		broxton_headset_pins, ARRAY_SIZE(broxton_headset_pins));
181 
182 	if (ret)
183 		return ret;
184 
185 	rt298_mic_detect(component, &broxton_headset);
186 
187 	snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
188 
189 	return 0;
190 }
191 
192 static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
193 {
194 	struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(rtd->card);
195 	struct snd_soc_dai *dai = rtd->codec_dai;
196 	struct bxt_hdmi_pcm *pcm;
197 
198 	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
199 	if (!pcm)
200 		return -ENOMEM;
201 
202 	pcm->device = BXT_DPCM_AUDIO_HDMI1_PB + dai->id;
203 	pcm->codec_dai = dai;
204 
205 	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
206 
207 	return 0;
208 }
209 
210 static int broxton_ssp5_fixup(struct snd_soc_pcm_runtime *rtd,
211 			struct snd_pcm_hw_params *params)
212 {
213 	struct snd_interval *rate = hw_param_interval(params,
214 					SNDRV_PCM_HW_PARAM_RATE);
215 	struct snd_interval *channels = hw_param_interval(params,
216 					SNDRV_PCM_HW_PARAM_CHANNELS);
217 	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
218 
219 	/* The ADSP will covert the FE rate to 48k, stereo */
220 	rate->min = rate->max = 48000;
221 	channels->min = channels->max = 2;
222 
223 	/* set SSP5 to 24 bit */
224 	snd_mask_none(fmt);
225 	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
226 
227 	return 0;
228 }
229 
230 static int broxton_rt298_hw_params(struct snd_pcm_substream *substream,
231 	struct snd_pcm_hw_params *params)
232 {
233 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
234 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
235 	int ret;
236 
237 	ret = snd_soc_dai_set_sysclk(codec_dai, RT298_SCLK_S_PLL,
238 					19200000, SND_SOC_CLOCK_IN);
239 	if (ret < 0) {
240 		dev_err(rtd->dev, "can't set codec sysclk configuration\n");
241 		return ret;
242 	}
243 
244 	return ret;
245 }
246 
247 static const struct snd_soc_ops broxton_rt298_ops = {
248 	.hw_params = broxton_rt298_hw_params,
249 };
250 
251 static const unsigned int rates[] = {
252 	48000,
253 };
254 
255 static const struct snd_pcm_hw_constraint_list constraints_rates = {
256 	.count = ARRAY_SIZE(rates),
257 	.list  = rates,
258 	.mask = 0,
259 };
260 
261 static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
262 				struct snd_pcm_hw_params *params)
263 {
264 	struct snd_interval *channels = hw_param_interval(params,
265 						SNDRV_PCM_HW_PARAM_CHANNELS);
266 	channels->min = channels->max = 4;
267 
268 	return 0;
269 }
270 
271 static const unsigned int channels_dmic[] = {
272 	1, 2, 3, 4,
273 };
274 
275 static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
276 	.count = ARRAY_SIZE(channels_dmic),
277 	.list = channels_dmic,
278 	.mask = 0,
279 };
280 
281 static int broxton_dmic_startup(struct snd_pcm_substream *substream)
282 {
283 	struct snd_pcm_runtime *runtime = substream->runtime;
284 
285 	runtime->hw.channels_max = 4;
286 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
287 					&constraints_dmic_channels);
288 
289 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
290 				SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
291 }
292 
293 static const struct snd_soc_ops broxton_dmic_ops = {
294 	.startup = broxton_dmic_startup,
295 };
296 
297 static const unsigned int channels[] = {
298 	2,
299 };
300 
301 static const struct snd_pcm_hw_constraint_list constraints_channels = {
302 	.count = ARRAY_SIZE(channels),
303 	.list = channels,
304 	.mask = 0,
305 };
306 
307 static int bxt_fe_startup(struct snd_pcm_substream *substream)
308 {
309 	struct snd_pcm_runtime *runtime = substream->runtime;
310 
311 	/*
312 	 * on this platform for PCM device we support:
313 	 *      48Khz
314 	 *      stereo
315 	 *	16-bit audio
316 	 */
317 
318 	runtime->hw.channels_max = 2;
319 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
320 				&constraints_channels);
321 
322 	runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
323 	snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
324 	snd_pcm_hw_constraint_list(runtime, 0,
325 				SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
326 
327 	return 0;
328 }
329 
330 static const struct snd_soc_ops broxton_rt286_fe_ops = {
331 	.startup = bxt_fe_startup,
332 };
333 
334 /* broxton digital audio interface glue - connects codec <--> CPU */
335 static struct snd_soc_dai_link broxton_rt298_dais[] = {
336 	/* Front End DAI links */
337 	[BXT_DPCM_AUDIO_PB] =
338 	{
339 		.name = "Bxt Audio Port",
340 		.stream_name = "Audio",
341 		.cpu_dai_name = "System Pin",
342 		.platform_name = "0000:00:0e.0",
343 		.nonatomic = 1,
344 		.dynamic = 1,
345 		.codec_name = "snd-soc-dummy",
346 		.codec_dai_name = "snd-soc-dummy-dai",
347 		.init = broxton_rt298_fe_init,
348 		.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
349 		.dpcm_playback = 1,
350 		.ops = &broxton_rt286_fe_ops,
351 	},
352 	[BXT_DPCM_AUDIO_CP] =
353 	{
354 		.name = "Bxt Audio Capture Port",
355 		.stream_name = "Audio Record",
356 		.cpu_dai_name = "System Pin",
357 		.platform_name = "0000:00:0e.0",
358 		.nonatomic = 1,
359 		.dynamic = 1,
360 		.codec_name = "snd-soc-dummy",
361 		.codec_dai_name = "snd-soc-dummy-dai",
362 		.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
363 		.dpcm_capture = 1,
364 		.ops = &broxton_rt286_fe_ops,
365 	},
366 	[BXT_DPCM_AUDIO_REF_CP] =
367 	{
368 		.name = "Bxt Audio Reference cap",
369 		.stream_name = "refcap",
370 		.cpu_dai_name = "Reference Pin",
371 		.codec_name = "snd-soc-dummy",
372 		.codec_dai_name = "snd-soc-dummy-dai",
373 		.platform_name = "0000:00:0e.0",
374 		.init = NULL,
375 		.dpcm_capture = 1,
376 		.nonatomic = 1,
377 		.dynamic = 1,
378 	},
379 	[BXT_DPCM_AUDIO_DMIC_CP] =
380 	{
381 		.name = "Bxt Audio DMIC cap",
382 		.stream_name = "dmiccap",
383 		.cpu_dai_name = "DMIC Pin",
384 		.codec_name = "snd-soc-dummy",
385 		.codec_dai_name = "snd-soc-dummy-dai",
386 		.platform_name = "0000:00:0e.0",
387 		.init = NULL,
388 		.dpcm_capture = 1,
389 		.nonatomic = 1,
390 		.dynamic = 1,
391 		.ops = &broxton_dmic_ops,
392 	},
393 	[BXT_DPCM_AUDIO_HDMI1_PB] =
394 	{
395 		.name = "Bxt HDMI Port1",
396 		.stream_name = "Hdmi1",
397 		.cpu_dai_name = "HDMI1 Pin",
398 		.codec_name = "snd-soc-dummy",
399 		.codec_dai_name = "snd-soc-dummy-dai",
400 		.platform_name = "0000:00:0e.0",
401 		.dpcm_playback = 1,
402 		.init = NULL,
403 		.nonatomic = 1,
404 		.dynamic = 1,
405 	},
406 	[BXT_DPCM_AUDIO_HDMI2_PB] =
407 	{
408 		.name = "Bxt HDMI Port2",
409 		.stream_name = "Hdmi2",
410 		.cpu_dai_name = "HDMI2 Pin",
411 		.codec_name = "snd-soc-dummy",
412 		.codec_dai_name = "snd-soc-dummy-dai",
413 		.platform_name = "0000:00:0e.0",
414 		.dpcm_playback = 1,
415 		.init = NULL,
416 		.nonatomic = 1,
417 		.dynamic = 1,
418 	},
419 	[BXT_DPCM_AUDIO_HDMI3_PB] =
420 	{
421 		.name = "Bxt HDMI Port3",
422 		.stream_name = "Hdmi3",
423 		.cpu_dai_name = "HDMI3 Pin",
424 		.codec_name = "snd-soc-dummy",
425 		.codec_dai_name = "snd-soc-dummy-dai",
426 		.platform_name = "0000:00:0e.0",
427 		.dpcm_playback = 1,
428 		.init = NULL,
429 		.nonatomic = 1,
430 		.dynamic = 1,
431 	},
432 	/* Back End DAI links */
433 	{
434 		/* SSP5 - Codec */
435 		.name = "SSP5-Codec",
436 		.id = 0,
437 		.cpu_dai_name = "SSP5 Pin",
438 		.platform_name = "0000:00:0e.0",
439 		.no_pcm = 1,
440 		.codec_name = "i2c-INT343A:00",
441 		.codec_dai_name = "rt298-aif1",
442 		.init = broxton_rt298_codec_init,
443 		.dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF |
444 						SND_SOC_DAIFMT_CBS_CFS,
445 		.ignore_pmdown_time = 1,
446 		.be_hw_params_fixup = broxton_ssp5_fixup,
447 		.ops = &broxton_rt298_ops,
448 		.dpcm_playback = 1,
449 		.dpcm_capture = 1,
450 	},
451 	{
452 		.name = "dmic01",
453 		.id = 1,
454 		.cpu_dai_name = "DMIC01 Pin",
455 		.codec_name = "dmic-codec",
456 		.codec_dai_name = "dmic-hifi",
457 		.platform_name = "0000:00:0e.0",
458 		.be_hw_params_fixup = broxton_dmic_fixup,
459 		.ignore_suspend = 1,
460 		.dpcm_capture = 1,
461 		.no_pcm = 1,
462 	},
463 	{
464 		.name = "dmic16k",
465 		.id = 2,
466 		.cpu_dai_name = "DMIC16k Pin",
467 		.codec_name = "dmic-codec",
468 		.codec_dai_name = "dmic-hifi",
469 		.platform_name = "0000:00:0e.0",
470 		.be_hw_params_fixup = broxton_dmic_fixup,
471 		.ignore_suspend = 1,
472 		.dpcm_capture = 1,
473 		.no_pcm = 1,
474 	},
475 	{
476 		.name = "iDisp1",
477 		.id = 3,
478 		.cpu_dai_name = "iDisp1 Pin",
479 		.codec_name = "ehdaudio0D2",
480 		.codec_dai_name = "intel-hdmi-hifi1",
481 		.platform_name = "0000:00:0e.0",
482 		.init = broxton_hdmi_init,
483 		.dpcm_playback = 1,
484 		.no_pcm = 1,
485 	},
486 	{
487 		.name = "iDisp2",
488 		.id = 4,
489 		.cpu_dai_name = "iDisp2 Pin",
490 		.codec_name = "ehdaudio0D2",
491 		.codec_dai_name = "intel-hdmi-hifi2",
492 		.platform_name = "0000:00:0e.0",
493 		.init = broxton_hdmi_init,
494 		.dpcm_playback = 1,
495 		.no_pcm = 1,
496 	},
497 	{
498 		.name = "iDisp3",
499 		.id = 5,
500 		.cpu_dai_name = "iDisp3 Pin",
501 		.codec_name = "ehdaudio0D2",
502 		.codec_dai_name = "intel-hdmi-hifi3",
503 		.platform_name = "0000:00:0e.0",
504 		.init = broxton_hdmi_init,
505 		.dpcm_playback = 1,
506 		.no_pcm = 1,
507 	},
508 };
509 
510 #define NAME_SIZE	32
511 static int bxt_card_late_probe(struct snd_soc_card *card)
512 {
513 	struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card);
514 	struct bxt_hdmi_pcm *pcm;
515 	struct snd_soc_component *component = NULL;
516 	int err, i = 0;
517 	char jack_name[NAME_SIZE];
518 
519 	list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
520 		component = pcm->codec_dai->component;
521 		snprintf(jack_name, sizeof(jack_name),
522 			"HDMI/DP, pcm=%d Jack", pcm->device);
523 		err = snd_soc_card_jack_new(card, jack_name,
524 					SND_JACK_AVOUT, &broxton_hdmi[i],
525 					NULL, 0);
526 
527 		if (err)
528 			return err;
529 
530 		err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
531 						&broxton_hdmi[i]);
532 		if (err < 0)
533 			return err;
534 
535 		i++;
536 	}
537 
538 	if (!component)
539 		return -EINVAL;
540 
541 	return hdac_hdmi_jack_port_init(component, &card->dapm);
542 }
543 
544 
545 /* broxton audio machine driver for SPT + RT298S */
546 static struct snd_soc_card broxton_rt298 = {
547 	.name = "broxton-rt298",
548 	.dai_link = broxton_rt298_dais,
549 	.num_links = ARRAY_SIZE(broxton_rt298_dais),
550 	.controls = broxton_controls,
551 	.num_controls = ARRAY_SIZE(broxton_controls),
552 	.dapm_widgets = broxton_widgets,
553 	.num_dapm_widgets = ARRAY_SIZE(broxton_widgets),
554 	.dapm_routes = broxton_rt298_map,
555 	.num_dapm_routes = ARRAY_SIZE(broxton_rt298_map),
556 	.fully_routed = true,
557 	.late_probe = bxt_card_late_probe,
558 
559 };
560 
561 static struct snd_soc_card geminilake_rt298 = {
562 	.name = "geminilake-rt298",
563 	.dai_link = broxton_rt298_dais,
564 	.num_links = ARRAY_SIZE(broxton_rt298_dais),
565 	.controls = broxton_controls,
566 	.num_controls = ARRAY_SIZE(broxton_controls),
567 	.dapm_widgets = broxton_widgets,
568 	.num_dapm_widgets = ARRAY_SIZE(broxton_widgets),
569 	.dapm_routes = geminilake_rt298_map,
570 	.num_dapm_routes = ARRAY_SIZE(geminilake_rt298_map),
571 	.fully_routed = true,
572 	.late_probe = bxt_card_late_probe,
573 };
574 
575 static int broxton_audio_probe(struct platform_device *pdev)
576 {
577 	struct bxt_rt286_private *ctx;
578 	struct snd_soc_card *card =
579 			(struct snd_soc_card *)pdev->id_entry->driver_data;
580 	struct snd_soc_acpi_mach *mach;
581 	const char *platform_name;
582 	int ret;
583 	int i;
584 
585 	for (i = 0; i < ARRAY_SIZE(broxton_rt298_dais); i++) {
586 		if (!strncmp(card->dai_link[i].codec_name, "i2c-INT343A:00",
587 						I2C_NAME_SIZE)) {
588 			if (!strncmp(card->name, "broxton-rt298",
589 						PLATFORM_NAME_SIZE)) {
590 				card->dai_link[i].name = "SSP5-Codec";
591 				card->dai_link[i].cpu_dai_name = "SSP5 Pin";
592 			} else if (!strncmp(card->name, "geminilake-rt298",
593 						PLATFORM_NAME_SIZE)) {
594 				card->dai_link[i].name = "SSP2-Codec";
595 				card->dai_link[i].cpu_dai_name = "SSP2 Pin";
596 			}
597 		}
598 	}
599 
600 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
601 	if (!ctx)
602 		return -ENOMEM;
603 
604 	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
605 
606 	card->dev = &pdev->dev;
607 	snd_soc_card_set_drvdata(card, ctx);
608 
609 	/* override plaform name, if required */
610 	mach = (&pdev->dev)->platform_data;
611 	platform_name = mach->mach_params.platform;
612 
613 	ret = snd_soc_fixup_dai_links_platform_name(card,
614 						    platform_name);
615 	if (ret)
616 		return ret;
617 
618 	return devm_snd_soc_register_card(&pdev->dev, card);
619 }
620 
621 static const struct platform_device_id bxt_board_ids[] = {
622 	{ .name = "bxt_alc298s_i2s", .driver_data =
623 				(unsigned long)&broxton_rt298 },
624 	{ .name = "glk_alc298s_i2s", .driver_data =
625 				(unsigned long)&geminilake_rt298 },
626 	{}
627 };
628 
629 static struct platform_driver broxton_audio = {
630 	.probe = broxton_audio_probe,
631 	.driver = {
632 		.name = "bxt_alc298s_i2s",
633 		.pm = &snd_soc_pm_ops,
634 	},
635 	.id_table = bxt_board_ids,
636 };
637 module_platform_driver(broxton_audio)
638 
639 /* Module information */
640 MODULE_AUTHOR("Ramesh Babu <Ramesh.Babu@intel.com>");
641 MODULE_AUTHOR("Senthilnathan Veppur <senthilnathanx.veppur@intel.com>");
642 MODULE_DESCRIPTION("Intel SST Audio for Broxton");
643 MODULE_LICENSE("GPL v2");
644 MODULE_ALIAS("platform:bxt_alc298s_i2s");
645 MODULE_ALIAS("platform:glk_alc298s_i2s");
646