1 // SPDX-License-Identifier: GPL-2.0 2 // Copyright(c) 2018 Intel Corporation. 3 4 /* 5 * Intel Geminilake I2S Machine Driver with MAX98357A & RT5682 Codecs 6 * 7 * Modified from: 8 * Intel Apollolake I2S Machine driver 9 */ 10 11 #include <linux/input.h> 12 #include <linux/module.h> 13 #include <linux/platform_device.h> 14 #include <sound/core.h> 15 #include <sound/jack.h> 16 #include <sound/pcm.h> 17 #include <sound/pcm_params.h> 18 #include <sound/soc.h> 19 #include <sound/soc-acpi.h> 20 #include "../../codecs/rt5682.h" 21 #include "../../codecs/hdac_hdmi.h" 22 #include "hda_dsp_common.h" 23 24 /* The platform clock outputs 19.2Mhz clock to codec as I2S MCLK */ 25 #define GLK_PLAT_CLK_FREQ 19200000 26 #define RT5682_PLL_FREQ (48000 * 512) 27 #define GLK_REALTEK_CODEC_DAI "rt5682-aif1" 28 #define GLK_MAXIM_CODEC_DAI "HiFi" 29 #define MAXIM_DEV0_NAME "MX98357A:00" 30 #define DUAL_CHANNEL 2 31 #define QUAD_CHANNEL 4 32 #define NAME_SIZE 32 33 34 static struct snd_soc_jack geminilake_hdmi[3]; 35 36 struct glk_hdmi_pcm { 37 struct list_head head; 38 struct snd_soc_dai *codec_dai; 39 int device; 40 }; 41 42 struct glk_card_private { 43 struct snd_soc_jack geminilake_headset; 44 struct list_head hdmi_pcm_list; 45 bool common_hdmi_codec_drv; 46 }; 47 48 enum { 49 GLK_DPCM_AUDIO_PB = 0, 50 GLK_DPCM_AUDIO_CP, 51 GLK_DPCM_AUDIO_HS_PB, 52 GLK_DPCM_AUDIO_ECHO_REF_CP, 53 GLK_DPCM_AUDIO_REF_CP, 54 GLK_DPCM_AUDIO_DMIC_CP, 55 GLK_DPCM_AUDIO_HDMI1_PB, 56 GLK_DPCM_AUDIO_HDMI2_PB, 57 GLK_DPCM_AUDIO_HDMI3_PB, 58 }; 59 60 static const struct snd_kcontrol_new geminilake_controls[] = { 61 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 62 SOC_DAPM_PIN_SWITCH("Headset Mic"), 63 SOC_DAPM_PIN_SWITCH("Spk"), 64 }; 65 66 static const struct snd_soc_dapm_widget geminilake_widgets[] = { 67 SND_SOC_DAPM_HP("Headphone Jack", NULL), 68 SND_SOC_DAPM_MIC("Headset Mic", NULL), 69 SND_SOC_DAPM_SPK("Spk", NULL), 70 SND_SOC_DAPM_MIC("SoC DMIC", NULL), 71 SND_SOC_DAPM_SPK("HDMI1", NULL), 72 SND_SOC_DAPM_SPK("HDMI2", NULL), 73 SND_SOC_DAPM_SPK("HDMI3", NULL), 74 }; 75 76 static const struct snd_soc_dapm_route geminilake_map[] = { 77 /* HP jack connectors - unknown if we have jack detection */ 78 { "Headphone Jack", NULL, "HPOL" }, 79 { "Headphone Jack", NULL, "HPOR" }, 80 81 /* speaker */ 82 { "Spk", NULL, "Speaker" }, 83 84 /* other jacks */ 85 { "IN1P", NULL, "Headset Mic" }, 86 87 /* digital mics */ 88 { "DMic", NULL, "SoC DMIC" }, 89 90 /* CODEC BE connections */ 91 { "HiFi Playback", NULL, "ssp1 Tx" }, 92 { "ssp1 Tx", NULL, "codec0_out" }, 93 94 { "AIF1 Playback", NULL, "ssp2 Tx" }, 95 { "ssp2 Tx", NULL, "codec1_out" }, 96 97 { "codec0_in", NULL, "ssp2 Rx" }, 98 { "ssp2 Rx", NULL, "AIF1 Capture" }, 99 100 { "HDMI1", NULL, "hif5-0 Output" }, 101 { "HDMI2", NULL, "hif6-0 Output" }, 102 { "HDMI2", NULL, "hif7-0 Output" }, 103 104 { "hifi3", NULL, "iDisp3 Tx" }, 105 { "iDisp3 Tx", NULL, "iDisp3_out" }, 106 { "hifi2", NULL, "iDisp2 Tx" }, 107 { "iDisp2 Tx", NULL, "iDisp2_out" }, 108 { "hifi1", NULL, "iDisp1 Tx" }, 109 { "iDisp1 Tx", NULL, "iDisp1_out" }, 110 111 /* DMIC */ 112 { "dmic01_hifi", NULL, "DMIC01 Rx" }, 113 { "DMIC01 Rx", NULL, "DMIC AIF" }, 114 }; 115 116 static int geminilake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, 117 struct snd_pcm_hw_params *params) 118 { 119 struct snd_interval *rate = hw_param_interval(params, 120 SNDRV_PCM_HW_PARAM_RATE); 121 struct snd_interval *channels = hw_param_interval(params, 122 SNDRV_PCM_HW_PARAM_CHANNELS); 123 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 124 125 /* The ADSP will convert the FE rate to 48k, stereo */ 126 rate->min = rate->max = 48000; 127 channels->min = channels->max = DUAL_CHANNEL; 128 129 /* set SSP to 24 bit */ 130 snd_mask_none(fmt); 131 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); 132 133 return 0; 134 } 135 136 static int geminilake_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) 137 { 138 struct glk_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 139 struct snd_soc_component *component = rtd->codec_dai->component; 140 struct snd_soc_dai *codec_dai = rtd->codec_dai; 141 struct snd_soc_jack *jack; 142 int ret; 143 144 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK, 145 GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ); 146 if (ret < 0) { 147 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); 148 return ret; 149 } 150 151 /* Configure sysclk for codec */ 152 ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL1, 153 RT5682_PLL_FREQ, SND_SOC_CLOCK_IN); 154 if (ret < 0) 155 dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); 156 157 /* 158 * Headset buttons map to the google Reference headset. 159 * These can be configured by userspace. 160 */ 161 ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", 162 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | 163 SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT, 164 &ctx->geminilake_headset, NULL, 0); 165 if (ret) { 166 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); 167 return ret; 168 } 169 170 jack = &ctx->geminilake_headset; 171 172 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); 173 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); 174 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); 175 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); 176 177 ret = snd_soc_component_set_jack(component, jack, NULL); 178 179 if (ret) { 180 dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret); 181 return ret; 182 } 183 184 return ret; 185 }; 186 187 static int geminilake_rt5682_hw_params(struct snd_pcm_substream *substream, 188 struct snd_pcm_hw_params *params) 189 { 190 struct snd_soc_pcm_runtime *rtd = substream->private_data; 191 struct snd_soc_dai *codec_dai = rtd->codec_dai; 192 int ret; 193 194 /* Set valid bitmask & configuration for I2S in 24 bit */ 195 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x0, 0x0, 2, 24); 196 if (ret < 0) { 197 dev_err(rtd->dev, "set TDM slot err:%d\n", ret); 198 return ret; 199 } 200 201 return ret; 202 } 203 204 static struct snd_soc_ops geminilake_rt5682_ops = { 205 .hw_params = geminilake_rt5682_hw_params, 206 }; 207 208 static int geminilake_hdmi_init(struct snd_soc_pcm_runtime *rtd) 209 { 210 struct glk_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 211 struct snd_soc_dai *dai = rtd->codec_dai; 212 struct glk_hdmi_pcm *pcm; 213 214 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); 215 if (!pcm) 216 return -ENOMEM; 217 218 pcm->device = GLK_DPCM_AUDIO_HDMI1_PB + dai->id; 219 pcm->codec_dai = dai; 220 221 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); 222 223 return 0; 224 } 225 226 static int geminilake_rt5682_fe_init(struct snd_soc_pcm_runtime *rtd) 227 { 228 struct snd_soc_component *component = rtd->cpu_dai->component; 229 struct snd_soc_dapm_context *dapm; 230 int ret; 231 232 dapm = snd_soc_component_get_dapm(component); 233 ret = snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); 234 if (ret) { 235 dev_err(rtd->dev, "Ref Cap ignore suspend failed %d\n", ret); 236 return ret; 237 } 238 239 return ret; 240 } 241 242 static const unsigned int rates[] = { 243 48000, 244 }; 245 246 static const struct snd_pcm_hw_constraint_list constraints_rates = { 247 .count = ARRAY_SIZE(rates), 248 .list = rates, 249 .mask = 0, 250 }; 251 252 static const unsigned int channels[] = { 253 DUAL_CHANNEL, 254 }; 255 256 static const struct snd_pcm_hw_constraint_list constraints_channels = { 257 .count = ARRAY_SIZE(channels), 258 .list = channels, 259 .mask = 0, 260 }; 261 262 static unsigned int channels_quad[] = { 263 QUAD_CHANNEL, 264 }; 265 266 static struct snd_pcm_hw_constraint_list constraints_channels_quad = { 267 .count = ARRAY_SIZE(channels_quad), 268 .list = channels_quad, 269 .mask = 0, 270 }; 271 272 static int geminilake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, 273 struct snd_pcm_hw_params *params) 274 { 275 struct snd_interval *channels = hw_param_interval(params, 276 SNDRV_PCM_HW_PARAM_CHANNELS); 277 278 /* 279 * set BE channel constraint as user FE channels 280 */ 281 channels->min = channels->max = 4; 282 283 return 0; 284 } 285 286 static int geminilake_dmic_startup(struct snd_pcm_substream *substream) 287 { 288 struct snd_pcm_runtime *runtime = substream->runtime; 289 290 runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL; 291 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 292 &constraints_channels_quad); 293 294 return snd_pcm_hw_constraint_list(substream->runtime, 0, 295 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); 296 } 297 298 static const struct snd_soc_ops geminilake_dmic_ops = { 299 .startup = geminilake_dmic_startup, 300 }; 301 302 static const unsigned int rates_16000[] = { 303 16000, 304 }; 305 306 static const struct snd_pcm_hw_constraint_list constraints_16000 = { 307 .count = ARRAY_SIZE(rates_16000), 308 .list = rates_16000, 309 }; 310 311 static int geminilake_refcap_startup(struct snd_pcm_substream *substream) 312 { 313 return snd_pcm_hw_constraint_list(substream->runtime, 0, 314 SNDRV_PCM_HW_PARAM_RATE, 315 &constraints_16000); 316 }; 317 318 static const struct snd_soc_ops geminilake_refcap_ops = { 319 .startup = geminilake_refcap_startup, 320 }; 321 322 SND_SOC_DAILINK_DEF(dummy, 323 DAILINK_COMP_ARRAY(COMP_DUMMY())); 324 325 SND_SOC_DAILINK_DEF(system, 326 DAILINK_COMP_ARRAY(COMP_CPU("System Pin"))); 327 328 SND_SOC_DAILINK_DEF(system2, 329 DAILINK_COMP_ARRAY(COMP_CPU("System Pin2"))); 330 331 SND_SOC_DAILINK_DEF(echoref, 332 DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin"))); 333 334 SND_SOC_DAILINK_DEF(reference, 335 DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin"))); 336 337 SND_SOC_DAILINK_DEF(dmic, 338 DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin"))); 339 340 SND_SOC_DAILINK_DEF(hdmi1, 341 DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin"))); 342 343 SND_SOC_DAILINK_DEF(hdmi2, 344 DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin"))); 345 346 SND_SOC_DAILINK_DEF(hdmi3, 347 DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin"))); 348 349 SND_SOC_DAILINK_DEF(ssp1_pin, 350 DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin"))); 351 SND_SOC_DAILINK_DEF(ssp1_codec, 352 DAILINK_COMP_ARRAY(COMP_CODEC(MAXIM_DEV0_NAME, 353 GLK_MAXIM_CODEC_DAI))); 354 355 SND_SOC_DAILINK_DEF(ssp2_pin, 356 DAILINK_COMP_ARRAY(COMP_CPU("SSP2 Pin"))); 357 SND_SOC_DAILINK_DEF(ssp2_codec, 358 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5682:00", 359 GLK_REALTEK_CODEC_DAI))); 360 361 SND_SOC_DAILINK_DEF(dmic_pin, 362 DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); 363 SND_SOC_DAILINK_DEF(dmic_codec, 364 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); 365 366 SND_SOC_DAILINK_DEF(idisp1_pin, 367 DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin"))); 368 SND_SOC_DAILINK_DEF(idisp1_codec, 369 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1"))); 370 371 SND_SOC_DAILINK_DEF(idisp2_pin, 372 DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin"))); 373 SND_SOC_DAILINK_DEF(idisp2_codec, 374 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2"))); 375 376 SND_SOC_DAILINK_DEF(idisp3_pin, 377 DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin"))); 378 SND_SOC_DAILINK_DEF(idisp3_codec, 379 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); 380 381 SND_SOC_DAILINK_DEF(platform, 382 DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:0e.0"))); 383 384 /* geminilake digital audio interface glue - connects codec <--> CPU */ 385 static struct snd_soc_dai_link geminilake_dais[] = { 386 /* Front End DAI links */ 387 [GLK_DPCM_AUDIO_PB] = { 388 .name = "Glk Audio Port", 389 .stream_name = "Audio", 390 .dynamic = 1, 391 .nonatomic = 1, 392 .init = geminilake_rt5682_fe_init, 393 .trigger = { 394 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 395 .dpcm_playback = 1, 396 SND_SOC_DAILINK_REG(system, dummy, platform), 397 }, 398 [GLK_DPCM_AUDIO_CP] = { 399 .name = "Glk Audio Capture Port", 400 .stream_name = "Audio Record", 401 .dynamic = 1, 402 .nonatomic = 1, 403 .trigger = { 404 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 405 .dpcm_capture = 1, 406 SND_SOC_DAILINK_REG(system, dummy, platform), 407 }, 408 [GLK_DPCM_AUDIO_HS_PB] = { 409 .name = "Glk Audio Headset Playback", 410 .stream_name = "Headset Audio", 411 .dpcm_playback = 1, 412 .nonatomic = 1, 413 .dynamic = 1, 414 SND_SOC_DAILINK_REG(system2, dummy, platform), 415 }, 416 [GLK_DPCM_AUDIO_ECHO_REF_CP] = { 417 .name = "Glk Audio Echo Reference cap", 418 .stream_name = "Echoreference Capture", 419 .init = NULL, 420 .capture_only = 1, 421 .nonatomic = 1, 422 SND_SOC_DAILINK_REG(echoref, dummy, platform), 423 }, 424 [GLK_DPCM_AUDIO_REF_CP] = { 425 .name = "Glk Audio Reference cap", 426 .stream_name = "Refcap", 427 .init = NULL, 428 .dpcm_capture = 1, 429 .nonatomic = 1, 430 .dynamic = 1, 431 .ops = &geminilake_refcap_ops, 432 SND_SOC_DAILINK_REG(reference, dummy, platform), 433 }, 434 [GLK_DPCM_AUDIO_DMIC_CP] = { 435 .name = "Glk Audio DMIC cap", 436 .stream_name = "dmiccap", 437 .init = NULL, 438 .dpcm_capture = 1, 439 .nonatomic = 1, 440 .dynamic = 1, 441 .ops = &geminilake_dmic_ops, 442 SND_SOC_DAILINK_REG(dmic, dummy, platform), 443 }, 444 [GLK_DPCM_AUDIO_HDMI1_PB] = { 445 .name = "Glk HDMI Port1", 446 .stream_name = "Hdmi1", 447 .dpcm_playback = 1, 448 .init = NULL, 449 .trigger = { 450 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 451 .nonatomic = 1, 452 .dynamic = 1, 453 SND_SOC_DAILINK_REG(hdmi1, dummy, platform), 454 }, 455 [GLK_DPCM_AUDIO_HDMI2_PB] = { 456 .name = "Glk HDMI Port2", 457 .stream_name = "Hdmi2", 458 .dpcm_playback = 1, 459 .init = NULL, 460 .trigger = { 461 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 462 .nonatomic = 1, 463 .dynamic = 1, 464 SND_SOC_DAILINK_REG(hdmi2, dummy, platform), 465 }, 466 [GLK_DPCM_AUDIO_HDMI3_PB] = { 467 .name = "Glk HDMI Port3", 468 .stream_name = "Hdmi3", 469 .trigger = { 470 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 471 .dpcm_playback = 1, 472 .init = NULL, 473 .nonatomic = 1, 474 .dynamic = 1, 475 SND_SOC_DAILINK_REG(hdmi3, dummy, platform), 476 }, 477 /* Back End DAI links */ 478 { 479 /* SSP1 - Codec */ 480 .name = "SSP1-Codec", 481 .id = 0, 482 .no_pcm = 1, 483 .dai_fmt = SND_SOC_DAIFMT_I2S | 484 SND_SOC_DAIFMT_NB_NF | 485 SND_SOC_DAIFMT_CBS_CFS, 486 .ignore_pmdown_time = 1, 487 .be_hw_params_fixup = geminilake_ssp_fixup, 488 .dpcm_playback = 1, 489 SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform), 490 }, 491 { 492 /* SSP2 - Codec */ 493 .name = "SSP2-Codec", 494 .id = 1, 495 .no_pcm = 1, 496 .init = geminilake_rt5682_codec_init, 497 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 498 SND_SOC_DAIFMT_CBS_CFS, 499 .ignore_pmdown_time = 1, 500 .be_hw_params_fixup = geminilake_ssp_fixup, 501 .ops = &geminilake_rt5682_ops, 502 .dpcm_playback = 1, 503 .dpcm_capture = 1, 504 SND_SOC_DAILINK_REG(ssp2_pin, ssp2_codec, platform), 505 }, 506 { 507 .name = "dmic01", 508 .id = 2, 509 .ignore_suspend = 1, 510 .be_hw_params_fixup = geminilake_dmic_fixup, 511 .dpcm_capture = 1, 512 .no_pcm = 1, 513 SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform), 514 }, 515 { 516 .name = "iDisp1", 517 .id = 3, 518 .init = geminilake_hdmi_init, 519 .dpcm_playback = 1, 520 .no_pcm = 1, 521 SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform), 522 }, 523 { 524 .name = "iDisp2", 525 .id = 4, 526 .init = geminilake_hdmi_init, 527 .dpcm_playback = 1, 528 .no_pcm = 1, 529 SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform), 530 }, 531 { 532 .name = "iDisp3", 533 .id = 5, 534 .init = geminilake_hdmi_init, 535 .dpcm_playback = 1, 536 .no_pcm = 1, 537 SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform), 538 }, 539 }; 540 541 static int glk_card_late_probe(struct snd_soc_card *card) 542 { 543 struct glk_card_private *ctx = snd_soc_card_get_drvdata(card); 544 struct snd_soc_component *component = NULL; 545 char jack_name[NAME_SIZE]; 546 struct glk_hdmi_pcm *pcm; 547 int err = 0; 548 int i = 0; 549 550 pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm, 551 head); 552 component = pcm->codec_dai->component; 553 554 if (ctx->common_hdmi_codec_drv) 555 return hda_dsp_hdmi_build_controls(card, component); 556 557 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { 558 component = pcm->codec_dai->component; 559 snprintf(jack_name, sizeof(jack_name), 560 "HDMI/DP, pcm=%d Jack", pcm->device); 561 err = snd_soc_card_jack_new(card, jack_name, 562 SND_JACK_AVOUT, &geminilake_hdmi[i], 563 NULL, 0); 564 565 if (err) 566 return err; 567 568 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, 569 &geminilake_hdmi[i]); 570 if (err < 0) 571 return err; 572 573 i++; 574 } 575 576 if (!component) 577 return -EINVAL; 578 579 return hdac_hdmi_jack_port_init(component, &card->dapm); 580 } 581 582 /* geminilake audio machine driver for SPT + RT5682 */ 583 static struct snd_soc_card glk_audio_card_rt5682_m98357a = { 584 .name = "glkrt5682max", 585 .owner = THIS_MODULE, 586 .dai_link = geminilake_dais, 587 .num_links = ARRAY_SIZE(geminilake_dais), 588 .controls = geminilake_controls, 589 .num_controls = ARRAY_SIZE(geminilake_controls), 590 .dapm_widgets = geminilake_widgets, 591 .num_dapm_widgets = ARRAY_SIZE(geminilake_widgets), 592 .dapm_routes = geminilake_map, 593 .num_dapm_routes = ARRAY_SIZE(geminilake_map), 594 .fully_routed = true, 595 .late_probe = glk_card_late_probe, 596 }; 597 598 static int geminilake_audio_probe(struct platform_device *pdev) 599 { 600 struct glk_card_private *ctx; 601 struct snd_soc_acpi_mach *mach; 602 const char *platform_name; 603 struct snd_soc_card *card; 604 int ret; 605 606 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 607 if (!ctx) 608 return -ENOMEM; 609 610 INIT_LIST_HEAD(&ctx->hdmi_pcm_list); 611 612 card = &glk_audio_card_rt5682_m98357a; 613 card->dev = &pdev->dev; 614 snd_soc_card_set_drvdata(card, ctx); 615 616 /* override plaform name, if required */ 617 mach = (&pdev->dev)->platform_data; 618 platform_name = mach->mach_params.platform; 619 620 ret = snd_soc_fixup_dai_links_platform_name(card, platform_name); 621 if (ret) 622 return ret; 623 624 ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv; 625 626 return devm_snd_soc_register_card(&pdev->dev, card); 627 } 628 629 static const struct platform_device_id glk_board_ids[] = { 630 { 631 .name = "glk_rt5682_max98357a", 632 .driver_data = 633 (kernel_ulong_t)&glk_audio_card_rt5682_m98357a, 634 }, 635 { } 636 }; 637 638 static struct platform_driver geminilake_audio = { 639 .probe = geminilake_audio_probe, 640 .driver = { 641 .name = "glk_rt5682_max98357a", 642 .pm = &snd_soc_pm_ops, 643 }, 644 .id_table = glk_board_ids, 645 }; 646 module_platform_driver(geminilake_audio) 647 648 /* Module information */ 649 MODULE_DESCRIPTION("Geminilake Audio Machine driver-RT5682 & MAX98357A in I2S mode"); 650 MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>"); 651 MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>"); 652 MODULE_LICENSE("GPL v2"); 653 MODULE_ALIAS("platform:glk_rt5682_max98357a"); 654