1 // SPDX-License-Identifier: GPL-2.0-only 2 // Copyright(c) 2019-2020 Intel Corporation. 3 4 /* 5 * Intel SOF Machine Driver with Realtek rt5682 Codec 6 * and speaker codec MAX98357A or RT1015. 7 */ 8 #include <linux/i2c.h> 9 #include <linux/input.h> 10 #include <linux/module.h> 11 #include <linux/platform_device.h> 12 #include <linux/clk.h> 13 #include <linux/dmi.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/sof.h> 20 #include <sound/rt5682.h> 21 #include <sound/rt5682s.h> 22 #include <sound/soc-acpi.h> 23 #include "../../codecs/rt5682.h" 24 #include "../../codecs/rt5682s.h" 25 #include "../../codecs/hdac_hdmi.h" 26 #include "../common/soc-intel-quirks.h" 27 #include "hda_dsp_common.h" 28 #include "sof_maxim_common.h" 29 #include "sof_realtek_common.h" 30 31 #define NAME_SIZE 32 32 33 #define SOF_RT5682_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) 34 #define SOF_RT5682_SSP_CODEC_MASK (GENMASK(2, 0)) 35 #define SOF_RT5682_MCLK_EN BIT(3) 36 #define SOF_RT5682_MCLK_24MHZ BIT(4) 37 #define SOF_SPEAKER_AMP_PRESENT BIT(5) 38 #define SOF_RT5682_SSP_AMP_SHIFT 6 39 #define SOF_RT5682_SSP_AMP_MASK (GENMASK(8, 6)) 40 #define SOF_RT5682_SSP_AMP(quirk) \ 41 (((quirk) << SOF_RT5682_SSP_AMP_SHIFT) & SOF_RT5682_SSP_AMP_MASK) 42 #define SOF_RT5682_MCLK_BYTCHT_EN BIT(9) 43 #define SOF_RT5682_NUM_HDMIDEV_SHIFT 10 44 #define SOF_RT5682_NUM_HDMIDEV_MASK (GENMASK(12, 10)) 45 #define SOF_RT5682_NUM_HDMIDEV(quirk) \ 46 ((quirk << SOF_RT5682_NUM_HDMIDEV_SHIFT) & SOF_RT5682_NUM_HDMIDEV_MASK) 47 #define SOF_RT1011_SPEAKER_AMP_PRESENT BIT(13) 48 #define SOF_RT1015_SPEAKER_AMP_PRESENT BIT(14) 49 #define SOF_RT1015_SPEAKER_AMP_100FS BIT(15) 50 #define SOF_RT1015P_SPEAKER_AMP_PRESENT BIT(16) 51 #define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(17) 52 #define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(18) 53 54 /* BT audio offload: reserve 3 bits for future */ 55 #define SOF_BT_OFFLOAD_SSP_SHIFT 19 56 #define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(21, 19)) 57 #define SOF_BT_OFFLOAD_SSP(quirk) \ 58 (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) 59 #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(22) 60 #define SOF_RT5682S_HEADPHONE_CODEC_PRESENT BIT(23) 61 #define SOF_MAX98390_SPEAKER_AMP_PRESENT BIT(24) 62 #define SOF_MAX98390_TWEETER_SPEAKER_PRESENT BIT(25) 63 #define SOF_RT1019_SPEAKER_AMP_PRESENT BIT(26) 64 65 66 /* Default: MCLK on, MCLK 19.2M, SSP0 */ 67 static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN | 68 SOF_RT5682_SSP_CODEC(0); 69 70 static int is_legacy_cpu; 71 72 struct sof_hdmi_pcm { 73 struct list_head head; 74 struct snd_soc_dai *codec_dai; 75 struct snd_soc_jack hdmi_jack; 76 int device; 77 }; 78 79 struct sof_card_private { 80 struct clk *mclk; 81 struct snd_soc_jack sof_headset; 82 struct list_head hdmi_pcm_list; 83 bool common_hdmi_codec_drv; 84 bool idisp_codec; 85 }; 86 87 static int sof_rt5682_quirk_cb(const struct dmi_system_id *id) 88 { 89 sof_rt5682_quirk = (unsigned long)id->driver_data; 90 return 1; 91 } 92 93 static const struct dmi_system_id sof_rt5682_quirk_table[] = { 94 { 95 .callback = sof_rt5682_quirk_cb, 96 .matches = { 97 DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), 98 DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max"), 99 }, 100 .driver_data = (void *)(SOF_RT5682_SSP_CODEC(2)), 101 }, 102 { 103 .callback = sof_rt5682_quirk_cb, 104 .matches = { 105 DMI_MATCH(DMI_SYS_VENDOR, "AAEON"), 106 DMI_MATCH(DMI_PRODUCT_NAME, "UP-CHT01"), 107 }, 108 .driver_data = (void *)(SOF_RT5682_SSP_CODEC(2)), 109 }, 110 { 111 .callback = sof_rt5682_quirk_cb, 112 .matches = { 113 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), 114 DMI_MATCH(DMI_PRODUCT_NAME, "WhiskeyLake Client"), 115 }, 116 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 117 SOF_RT5682_MCLK_24MHZ | 118 SOF_RT5682_SSP_CODEC(1)), 119 }, 120 { 121 /* 122 * Dooly is hatch family but using rt1015 amp so it 123 * requires a quirk before "Google_Hatch". 124 */ 125 .callback = sof_rt5682_quirk_cb, 126 .matches = { 127 DMI_MATCH(DMI_SYS_VENDOR, "HP"), 128 DMI_MATCH(DMI_PRODUCT_NAME, "Dooly"), 129 }, 130 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 131 SOF_RT5682_MCLK_24MHZ | 132 SOF_RT5682_SSP_CODEC(0) | 133 SOF_SPEAKER_AMP_PRESENT | 134 SOF_RT1015_SPEAKER_AMP_PRESENT | 135 SOF_RT1015_SPEAKER_AMP_100FS | 136 SOF_RT5682_SSP_AMP(1)), 137 }, 138 { 139 .callback = sof_rt5682_quirk_cb, 140 .matches = { 141 DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Hatch"), 142 }, 143 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 144 SOF_RT5682_MCLK_24MHZ | 145 SOF_RT5682_SSP_CODEC(0) | 146 SOF_SPEAKER_AMP_PRESENT | 147 SOF_RT5682_SSP_AMP(1)), 148 }, 149 { 150 .callback = sof_rt5682_quirk_cb, 151 .matches = { 152 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), 153 DMI_MATCH(DMI_PRODUCT_NAME, "Ice Lake Client"), 154 }, 155 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 156 SOF_RT5682_SSP_CODEC(0)), 157 }, 158 { 159 .callback = sof_rt5682_quirk_cb, 160 .matches = { 161 DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Volteer"), 162 DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98373_ALC5682I_I2S_UP4"), 163 }, 164 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 165 SOF_RT5682_SSP_CODEC(0) | 166 SOF_SPEAKER_AMP_PRESENT | 167 SOF_MAX98373_SPEAKER_AMP_PRESENT | 168 SOF_RT5682_SSP_AMP(2) | 169 SOF_RT5682_NUM_HDMIDEV(4)), 170 }, 171 { 172 .callback = sof_rt5682_quirk_cb, 173 .matches = { 174 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), 175 DMI_MATCH(DMI_PRODUCT_NAME, "Alder Lake Client Platform"), 176 DMI_MATCH(DMI_OEM_STRING, "AUDIO-ADL_MAX98373_ALC5682I_I2S"), 177 }, 178 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 179 SOF_RT5682_SSP_CODEC(0) | 180 SOF_SPEAKER_AMP_PRESENT | 181 SOF_MAX98373_SPEAKER_AMP_PRESENT | 182 SOF_RT5682_SSP_AMP(2) | 183 SOF_RT5682_NUM_HDMIDEV(4)), 184 }, 185 { 186 .callback = sof_rt5682_quirk_cb, 187 .matches = { 188 DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"), 189 DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S"), 190 }, 191 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 192 SOF_RT5682_SSP_CODEC(0) | 193 SOF_SPEAKER_AMP_PRESENT | 194 SOF_MAX98390_SPEAKER_AMP_PRESENT | 195 SOF_RT5682_SSP_AMP(2) | 196 SOF_RT5682_NUM_HDMIDEV(4)), 197 }, 198 { 199 .callback = sof_rt5682_quirk_cb, 200 .matches = { 201 DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"), 202 DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S_4SPK"), 203 }, 204 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 205 SOF_RT5682_SSP_CODEC(0) | 206 SOF_SPEAKER_AMP_PRESENT | 207 SOF_MAX98390_SPEAKER_AMP_PRESENT | 208 SOF_MAX98390_TWEETER_SPEAKER_PRESENT | 209 SOF_RT5682_SSP_AMP(1) | 210 SOF_RT5682_NUM_HDMIDEV(4) | 211 SOF_BT_OFFLOAD_SSP(2) | 212 SOF_SSP_BT_OFFLOAD_PRESENT), 213 214 }, 215 { 216 .callback = sof_rt5682_quirk_cb, 217 .matches = { 218 DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"), 219 DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98360_ALC5682I_I2S_AMP_SSP2"), 220 }, 221 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 222 SOF_RT5682_SSP_CODEC(0) | 223 SOF_SPEAKER_AMP_PRESENT | 224 SOF_MAX98360A_SPEAKER_AMP_PRESENT | 225 SOF_RT5682_SSP_AMP(2) | 226 SOF_RT5682_NUM_HDMIDEV(4)), 227 }, 228 {} 229 }; 230 231 static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) 232 { 233 struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 234 struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); 235 struct sof_hdmi_pcm *pcm; 236 237 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); 238 if (!pcm) 239 return -ENOMEM; 240 241 /* dai_link id is 1:1 mapped to the PCM device */ 242 pcm->device = rtd->dai_link->id; 243 pcm->codec_dai = dai; 244 245 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); 246 247 return 0; 248 } 249 250 static struct snd_soc_jack_pin jack_pins[] = { 251 { 252 .pin = "Headphone Jack", 253 .mask = SND_JACK_HEADPHONE, 254 }, 255 { 256 .pin = "Headset Mic", 257 .mask = SND_JACK_MICROPHONE, 258 }, 259 }; 260 261 static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) 262 { 263 struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 264 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 265 struct snd_soc_jack *jack; 266 int ret; 267 268 /* need to enable ASRC function for 24MHz mclk rate */ 269 if ((sof_rt5682_quirk & SOF_RT5682_MCLK_EN) && 270 (sof_rt5682_quirk & SOF_RT5682_MCLK_24MHZ)) { 271 if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) 272 rt5682s_sel_asrc_clk_src(component, 273 RT5682S_DA_STEREO1_FILTER | 274 RT5682S_AD_STEREO1_FILTER, 275 RT5682S_CLK_SEL_I2S1_ASRC); 276 else 277 rt5682_sel_asrc_clk_src(component, 278 RT5682_DA_STEREO1_FILTER | 279 RT5682_AD_STEREO1_FILTER, 280 RT5682_CLK_SEL_I2S1_ASRC); 281 } 282 283 if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) { 284 /* 285 * The firmware might enable the clock at 286 * boot (this information may or may not 287 * be reflected in the enable clock register). 288 * To change the rate we must disable the clock 289 * first to cover these cases. Due to common 290 * clock framework restrictions that do not allow 291 * to disable a clock that has not been enabled, 292 * we need to enable the clock first. 293 */ 294 ret = clk_prepare_enable(ctx->mclk); 295 if (!ret) 296 clk_disable_unprepare(ctx->mclk); 297 298 ret = clk_set_rate(ctx->mclk, 19200000); 299 300 if (ret) 301 dev_err(rtd->dev, "unable to set MCLK rate\n"); 302 } 303 304 /* 305 * Headset buttons map to the google Reference headset. 306 * These can be configured by userspace. 307 */ 308 ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", 309 SND_JACK_HEADSET | SND_JACK_BTN_0 | 310 SND_JACK_BTN_1 | SND_JACK_BTN_2 | 311 SND_JACK_BTN_3, 312 &ctx->sof_headset, 313 jack_pins, 314 ARRAY_SIZE(jack_pins)); 315 if (ret) { 316 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); 317 return ret; 318 } 319 320 jack = &ctx->sof_headset; 321 322 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); 323 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); 324 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); 325 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); 326 ret = snd_soc_component_set_jack(component, jack, NULL); 327 328 if (ret) { 329 dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret); 330 return ret; 331 } 332 333 return ret; 334 }; 335 336 static void sof_rt5682_codec_exit(struct snd_soc_pcm_runtime *rtd) 337 { 338 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 339 340 snd_soc_component_set_jack(component, NULL, NULL); 341 } 342 343 static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, 344 struct snd_pcm_hw_params *params) 345 { 346 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 347 struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 348 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 349 int pll_id, pll_source, pll_in, pll_out, clk_id, ret; 350 351 if (sof_rt5682_quirk & SOF_RT5682_MCLK_EN) { 352 if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) { 353 ret = clk_prepare_enable(ctx->mclk); 354 if (ret < 0) { 355 dev_err(rtd->dev, 356 "could not configure MCLK state"); 357 return ret; 358 } 359 } 360 361 if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) 362 pll_source = RT5682S_PLL_S_MCLK; 363 else 364 pll_source = RT5682_PLL1_S_MCLK; 365 366 /* get the tplg configured mclk. */ 367 pll_in = sof_dai_get_mclk(rtd); 368 369 /* mclk from the quirk is the first choice */ 370 if (sof_rt5682_quirk & SOF_RT5682_MCLK_24MHZ) { 371 if (pll_in != 24000000) 372 dev_warn(rtd->dev, "configure wrong mclk in tplg, please use 24MHz.\n"); 373 pll_in = 24000000; 374 } else if (pll_in == 0) { 375 /* use default mclk if not specified correct in topology */ 376 pll_in = 19200000; 377 } else if (pll_in < 0) { 378 return pll_in; 379 } 380 } else { 381 if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) 382 pll_source = RT5682S_PLL_S_BCLK1; 383 else 384 pll_source = RT5682_PLL1_S_BCLK1; 385 386 pll_in = params_rate(params) * 50; 387 } 388 389 if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) { 390 pll_id = RT5682S_PLL2; 391 clk_id = RT5682S_SCLK_S_PLL2; 392 } else { 393 pll_id = RT5682_PLL1; 394 clk_id = RT5682_SCLK_S_PLL1; 395 } 396 397 pll_out = params_rate(params) * 512; 398 399 /* when MCLK is 512FS, no need to set PLL configuration additionally. */ 400 if (pll_in == pll_out) 401 clk_id = RT5682S_SCLK_S_MCLK; 402 else { 403 /* Configure pll for codec */ 404 ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, pll_in, 405 pll_out); 406 if (ret < 0) 407 dev_err(rtd->dev, "snd_soc_dai_set_pll err = %d\n", ret); 408 } 409 410 /* Configure sysclk for codec */ 411 ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, 412 pll_out, SND_SOC_CLOCK_IN); 413 if (ret < 0) 414 dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); 415 416 /* 417 * slot_width should equal or large than data length, set them 418 * be the same 419 */ 420 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x0, 0x0, 2, 421 params_width(params)); 422 if (ret < 0) { 423 dev_err(rtd->dev, "set TDM slot err:%d\n", ret); 424 return ret; 425 } 426 427 return ret; 428 } 429 430 static struct snd_soc_ops sof_rt5682_ops = { 431 .hw_params = sof_rt5682_hw_params, 432 }; 433 434 static struct snd_soc_dai_link_component platform_component[] = { 435 { 436 /* name might be overridden during probe */ 437 .name = "0000:00:1f.3" 438 } 439 }; 440 441 static int sof_card_late_probe(struct snd_soc_card *card) 442 { 443 struct sof_card_private *ctx = snd_soc_card_get_drvdata(card); 444 struct snd_soc_component *component = NULL; 445 struct snd_soc_dapm_context *dapm = &card->dapm; 446 char jack_name[NAME_SIZE]; 447 struct sof_hdmi_pcm *pcm; 448 int err; 449 450 if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) { 451 /* Disable Left and Right Spk pin after boot */ 452 snd_soc_dapm_disable_pin(dapm, "Left Spk"); 453 snd_soc_dapm_disable_pin(dapm, "Right Spk"); 454 err = snd_soc_dapm_sync(dapm); 455 if (err < 0) 456 return err; 457 } 458 459 /* HDMI is not supported by SOF on Baytrail/CherryTrail */ 460 if (is_legacy_cpu || !ctx->idisp_codec) 461 return 0; 462 463 if (list_empty(&ctx->hdmi_pcm_list)) 464 return -EINVAL; 465 466 if (ctx->common_hdmi_codec_drv) { 467 pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm, 468 head); 469 component = pcm->codec_dai->component; 470 return hda_dsp_hdmi_build_controls(card, component); 471 } 472 473 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { 474 component = pcm->codec_dai->component; 475 snprintf(jack_name, sizeof(jack_name), 476 "HDMI/DP, pcm=%d Jack", pcm->device); 477 err = snd_soc_card_jack_new(card, jack_name, 478 SND_JACK_AVOUT, &pcm->hdmi_jack); 479 480 if (err) 481 return err; 482 483 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, 484 &pcm->hdmi_jack); 485 if (err < 0) 486 return err; 487 } 488 489 return hdac_hdmi_jack_port_init(component, &card->dapm); 490 } 491 492 static const struct snd_kcontrol_new sof_controls[] = { 493 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 494 SOC_DAPM_PIN_SWITCH("Headset Mic"), 495 SOC_DAPM_PIN_SWITCH("Left Spk"), 496 SOC_DAPM_PIN_SWITCH("Right Spk"), 497 498 }; 499 500 static const struct snd_soc_dapm_widget sof_widgets[] = { 501 SND_SOC_DAPM_HP("Headphone Jack", NULL), 502 SND_SOC_DAPM_MIC("Headset Mic", NULL), 503 SND_SOC_DAPM_SPK("Left Spk", NULL), 504 SND_SOC_DAPM_SPK("Right Spk", NULL), 505 }; 506 507 static const struct snd_soc_dapm_widget dmic_widgets[] = { 508 SND_SOC_DAPM_MIC("SoC DMIC", NULL), 509 }; 510 511 static const struct snd_soc_dapm_route sof_map[] = { 512 /* HP jack connectors - unknown if we have jack detection */ 513 { "Headphone Jack", NULL, "HPOL" }, 514 { "Headphone Jack", NULL, "HPOR" }, 515 516 /* other jacks */ 517 { "IN1P", NULL, "Headset Mic" }, 518 }; 519 520 static const struct snd_soc_dapm_route dmic_map[] = { 521 /* digital mics */ 522 {"DMic", NULL, "SoC DMIC"}, 523 }; 524 525 static int dmic_init(struct snd_soc_pcm_runtime *rtd) 526 { 527 struct snd_soc_card *card = rtd->card; 528 int ret; 529 530 ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, 531 ARRAY_SIZE(dmic_widgets)); 532 if (ret) { 533 dev_err(card->dev, "DMic widget addition failed: %d\n", ret); 534 /* Don't need to add routes if widget addition failed */ 535 return ret; 536 } 537 538 ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, 539 ARRAY_SIZE(dmic_map)); 540 541 if (ret) 542 dev_err(card->dev, "DMic map addition failed: %d\n", ret); 543 544 return ret; 545 } 546 547 /* sof audio machine driver for rt5682 codec */ 548 static struct snd_soc_card sof_audio_card_rt5682 = { 549 .name = "rt5682", /* the sof- prefix is added by the core */ 550 .owner = THIS_MODULE, 551 .controls = sof_controls, 552 .num_controls = ARRAY_SIZE(sof_controls), 553 .dapm_widgets = sof_widgets, 554 .num_dapm_widgets = ARRAY_SIZE(sof_widgets), 555 .dapm_routes = sof_map, 556 .num_dapm_routes = ARRAY_SIZE(sof_map), 557 .fully_routed = true, 558 .late_probe = sof_card_late_probe, 559 }; 560 561 static struct snd_soc_dai_link_component rt5682_component[] = { 562 { 563 .name = "i2c-10EC5682:00", 564 .dai_name = "rt5682-aif1", 565 } 566 }; 567 568 static struct snd_soc_dai_link_component rt5682s_component[] = { 569 { 570 .name = "i2c-RTL5682:00", 571 .dai_name = "rt5682s-aif1", 572 } 573 }; 574 575 static struct snd_soc_dai_link_component dmic_component[] = { 576 { 577 .name = "dmic-codec", 578 .dai_name = "dmic-hifi", 579 } 580 }; 581 582 static struct snd_soc_dai_link_component dummy_component[] = { 583 { 584 .name = "snd-soc-dummy", 585 .dai_name = "snd-soc-dummy-dai", 586 } 587 }; 588 589 #define IDISP_CODEC_MASK 0x4 590 591 static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, 592 int ssp_codec, 593 int ssp_amp, 594 int dmic_be_num, 595 int hdmi_num, 596 bool idisp_codec) 597 { 598 struct snd_soc_dai_link_component *idisp_components; 599 struct snd_soc_dai_link_component *cpus; 600 struct snd_soc_dai_link *links; 601 int i, id = 0; 602 603 links = devm_kcalloc(dev, sof_audio_card_rt5682.num_links, 604 sizeof(struct snd_soc_dai_link), GFP_KERNEL); 605 cpus = devm_kcalloc(dev, sof_audio_card_rt5682.num_links, 606 sizeof(struct snd_soc_dai_link_component), GFP_KERNEL); 607 if (!links || !cpus) 608 goto devm_err; 609 610 /* codec SSP */ 611 links[id].name = devm_kasprintf(dev, GFP_KERNEL, 612 "SSP%d-Codec", ssp_codec); 613 if (!links[id].name) 614 goto devm_err; 615 616 links[id].id = id; 617 if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) { 618 links[id].codecs = rt5682s_component; 619 links[id].num_codecs = ARRAY_SIZE(rt5682s_component); 620 } else { 621 links[id].codecs = rt5682_component; 622 links[id].num_codecs = ARRAY_SIZE(rt5682_component); 623 } 624 links[id].platforms = platform_component; 625 links[id].num_platforms = ARRAY_SIZE(platform_component); 626 links[id].init = sof_rt5682_codec_init; 627 links[id].exit = sof_rt5682_codec_exit; 628 links[id].ops = &sof_rt5682_ops; 629 links[id].dpcm_playback = 1; 630 links[id].dpcm_capture = 1; 631 links[id].no_pcm = 1; 632 links[id].cpus = &cpus[id]; 633 links[id].num_cpus = 1; 634 if (is_legacy_cpu) { 635 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 636 "ssp%d-port", 637 ssp_codec); 638 if (!links[id].cpus->dai_name) 639 goto devm_err; 640 } else { 641 /* 642 * Currently, On SKL+ platforms MCLK will be turned off in sof 643 * runtime suspended, and it will go into runtime suspended 644 * right after playback is stop. However, rt5682 will output 645 * static noise if sysclk turns off during playback. Set 646 * ignore_pmdown_time to power down rt5682 immediately and 647 * avoid the noise. 648 * It can be removed once we can control MCLK by driver. 649 */ 650 links[id].ignore_pmdown_time = 1; 651 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 652 "SSP%d Pin", 653 ssp_codec); 654 if (!links[id].cpus->dai_name) 655 goto devm_err; 656 } 657 id++; 658 659 /* dmic */ 660 if (dmic_be_num > 0) { 661 /* at least we have dmic01 */ 662 links[id].name = "dmic01"; 663 links[id].cpus = &cpus[id]; 664 links[id].cpus->dai_name = "DMIC01 Pin"; 665 links[id].init = dmic_init; 666 if (dmic_be_num > 1) { 667 /* set up 2 BE links at most */ 668 links[id + 1].name = "dmic16k"; 669 links[id + 1].cpus = &cpus[id + 1]; 670 links[id + 1].cpus->dai_name = "DMIC16k Pin"; 671 dmic_be_num = 2; 672 } 673 } 674 675 for (i = 0; i < dmic_be_num; i++) { 676 links[id].id = id; 677 links[id].num_cpus = 1; 678 links[id].codecs = dmic_component; 679 links[id].num_codecs = ARRAY_SIZE(dmic_component); 680 links[id].platforms = platform_component; 681 links[id].num_platforms = ARRAY_SIZE(platform_component); 682 links[id].ignore_suspend = 1; 683 links[id].dpcm_capture = 1; 684 links[id].no_pcm = 1; 685 id++; 686 } 687 688 /* HDMI */ 689 if (hdmi_num > 0) { 690 idisp_components = devm_kcalloc(dev, 691 hdmi_num, 692 sizeof(struct snd_soc_dai_link_component), 693 GFP_KERNEL); 694 if (!idisp_components) 695 goto devm_err; 696 } 697 for (i = 1; i <= hdmi_num; i++) { 698 links[id].name = devm_kasprintf(dev, GFP_KERNEL, 699 "iDisp%d", i); 700 if (!links[id].name) 701 goto devm_err; 702 703 links[id].id = id; 704 links[id].cpus = &cpus[id]; 705 links[id].num_cpus = 1; 706 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 707 "iDisp%d Pin", i); 708 if (!links[id].cpus->dai_name) 709 goto devm_err; 710 711 if (idisp_codec) { 712 idisp_components[i - 1].name = "ehdaudio0D2"; 713 idisp_components[i - 1].dai_name = devm_kasprintf(dev, 714 GFP_KERNEL, 715 "intel-hdmi-hifi%d", 716 i); 717 if (!idisp_components[i - 1].dai_name) 718 goto devm_err; 719 } else { 720 idisp_components[i - 1].name = "snd-soc-dummy"; 721 idisp_components[i - 1].dai_name = "snd-soc-dummy-dai"; 722 } 723 724 links[id].codecs = &idisp_components[i - 1]; 725 links[id].num_codecs = 1; 726 links[id].platforms = platform_component; 727 links[id].num_platforms = ARRAY_SIZE(platform_component); 728 links[id].init = sof_hdmi_init; 729 links[id].dpcm_playback = 1; 730 links[id].no_pcm = 1; 731 id++; 732 } 733 734 /* speaker amp */ 735 if (sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) { 736 links[id].name = devm_kasprintf(dev, GFP_KERNEL, 737 "SSP%d-Codec", ssp_amp); 738 if (!links[id].name) 739 goto devm_err; 740 741 links[id].id = id; 742 if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT) { 743 sof_rt1015_dai_link(&links[id], (sof_rt5682_quirk & 744 SOF_RT1015_SPEAKER_AMP_100FS) ? 100 : 64); 745 } else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) { 746 sof_rt1015p_dai_link(&links[id]); 747 } else if (sof_rt5682_quirk & SOF_RT1019_SPEAKER_AMP_PRESENT) { 748 sof_rt1019p_dai_link(&links[id]); 749 } else if (sof_rt5682_quirk & 750 SOF_MAX98373_SPEAKER_AMP_PRESENT) { 751 links[id].codecs = max_98373_components; 752 links[id].num_codecs = ARRAY_SIZE(max_98373_components); 753 links[id].init = max_98373_spk_codec_init; 754 links[id].ops = &max_98373_ops; 755 /* feedback stream */ 756 links[id].dpcm_capture = 1; 757 } else if (sof_rt5682_quirk & 758 SOF_MAX98360A_SPEAKER_AMP_PRESENT) { 759 max_98360a_dai_link(&links[id]); 760 } else if (sof_rt5682_quirk & 761 SOF_RT1011_SPEAKER_AMP_PRESENT) { 762 sof_rt1011_dai_link(&links[id]); 763 } else if (sof_rt5682_quirk & 764 SOF_MAX98390_SPEAKER_AMP_PRESENT) { 765 if (sof_rt5682_quirk & 766 SOF_MAX98390_TWEETER_SPEAKER_PRESENT) { 767 links[id].codecs = max_98390_4spk_components; 768 links[id].num_codecs = ARRAY_SIZE(max_98390_4spk_components); 769 } else { 770 links[id].codecs = max_98390_components; 771 links[id].num_codecs = ARRAY_SIZE(max_98390_components); 772 } 773 links[id].init = max_98390_spk_codec_init; 774 links[id].ops = &max_98390_ops; 775 links[id].dpcm_capture = 1; 776 777 } else { 778 max_98357a_dai_link(&links[id]); 779 } 780 links[id].platforms = platform_component; 781 links[id].num_platforms = ARRAY_SIZE(platform_component); 782 links[id].dpcm_playback = 1; 783 links[id].no_pcm = 1; 784 links[id].cpus = &cpus[id]; 785 links[id].num_cpus = 1; 786 if (is_legacy_cpu) { 787 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 788 "ssp%d-port", 789 ssp_amp); 790 if (!links[id].cpus->dai_name) 791 goto devm_err; 792 793 } else { 794 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 795 "SSP%d Pin", 796 ssp_amp); 797 if (!links[id].cpus->dai_name) 798 goto devm_err; 799 } 800 id++; 801 } 802 803 /* BT audio offload */ 804 if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) { 805 int port = (sof_rt5682_quirk & SOF_BT_OFFLOAD_SSP_MASK) >> 806 SOF_BT_OFFLOAD_SSP_SHIFT; 807 808 links[id].id = id; 809 links[id].cpus = &cpus[id]; 810 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 811 "SSP%d Pin", port); 812 if (!links[id].cpus->dai_name) 813 goto devm_err; 814 links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port); 815 if (!links[id].name) 816 goto devm_err; 817 links[id].codecs = dummy_component; 818 links[id].num_codecs = ARRAY_SIZE(dummy_component); 819 links[id].platforms = platform_component; 820 links[id].num_platforms = ARRAY_SIZE(platform_component); 821 links[id].dpcm_playback = 1; 822 links[id].dpcm_capture = 1; 823 links[id].no_pcm = 1; 824 links[id].num_cpus = 1; 825 } 826 827 return links; 828 devm_err: 829 return NULL; 830 } 831 832 static int sof_audio_probe(struct platform_device *pdev) 833 { 834 struct snd_soc_dai_link *dai_links; 835 struct snd_soc_acpi_mach *mach; 836 struct sof_card_private *ctx; 837 int dmic_be_num, hdmi_num; 838 int ret, ssp_amp, ssp_codec; 839 840 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 841 if (!ctx) 842 return -ENOMEM; 843 844 if (pdev->id_entry && pdev->id_entry->driver_data) 845 sof_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data; 846 847 dmi_check_system(sof_rt5682_quirk_table); 848 849 mach = pdev->dev.platform_data; 850 851 /* A speaker amp might not be present when the quirk claims one is. 852 * Detect this via whether the machine driver match includes quirk_data. 853 */ 854 if ((sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) && !mach->quirk_data) 855 sof_rt5682_quirk &= ~SOF_SPEAKER_AMP_PRESENT; 856 857 /* Detect the headset codec variant */ 858 if (acpi_dev_present("RTL5682", NULL, -1)) 859 sof_rt5682_quirk |= SOF_RT5682S_HEADPHONE_CODEC_PRESENT; 860 861 /* Detect the headset codec variant to support machines in DMI quirk */ 862 if (acpi_dev_present("RTL5682", NULL, -1)) 863 sof_rt5682_quirk |= SOF_RT5682S_HEADPHONE_CODEC_PRESENT; 864 865 if (soc_intel_is_byt() || soc_intel_is_cht()) { 866 is_legacy_cpu = 1; 867 dmic_be_num = 0; 868 hdmi_num = 0; 869 /* default quirk for legacy cpu */ 870 sof_rt5682_quirk = SOF_RT5682_MCLK_EN | 871 SOF_RT5682_MCLK_BYTCHT_EN | 872 SOF_RT5682_SSP_CODEC(2); 873 } else { 874 dmic_be_num = 2; 875 hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >> 876 SOF_RT5682_NUM_HDMIDEV_SHIFT; 877 /* default number of HDMI DAI's */ 878 if (!hdmi_num) 879 hdmi_num = 3; 880 881 if (mach->mach_params.codec_mask & IDISP_CODEC_MASK) 882 ctx->idisp_codec = true; 883 } 884 885 /* need to get main clock from pmc */ 886 if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) { 887 ctx->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); 888 if (IS_ERR(ctx->mclk)) { 889 ret = PTR_ERR(ctx->mclk); 890 891 dev_err(&pdev->dev, 892 "Failed to get MCLK from pmc_plt_clk_3: %d\n", 893 ret); 894 return ret; 895 } 896 897 ret = clk_prepare_enable(ctx->mclk); 898 if (ret < 0) { 899 dev_err(&pdev->dev, 900 "could not configure MCLK state"); 901 return ret; 902 } 903 } 904 905 dev_dbg(&pdev->dev, "sof_rt5682_quirk = %lx\n", sof_rt5682_quirk); 906 907 ssp_amp = (sof_rt5682_quirk & SOF_RT5682_SSP_AMP_MASK) >> 908 SOF_RT5682_SSP_AMP_SHIFT; 909 910 ssp_codec = sof_rt5682_quirk & SOF_RT5682_SSP_CODEC_MASK; 911 912 /* compute number of dai links */ 913 sof_audio_card_rt5682.num_links = 1 + dmic_be_num + hdmi_num; 914 915 if (sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) 916 sof_audio_card_rt5682.num_links++; 917 918 if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) 919 max_98373_set_codec_conf(&sof_audio_card_rt5682); 920 else if (sof_rt5682_quirk & SOF_RT1011_SPEAKER_AMP_PRESENT) 921 sof_rt1011_codec_conf(&sof_audio_card_rt5682); 922 else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) 923 sof_rt1015p_codec_conf(&sof_audio_card_rt5682); 924 else if (sof_rt5682_quirk & SOF_MAX98390_SPEAKER_AMP_PRESENT) { 925 if (sof_rt5682_quirk & SOF_MAX98390_TWEETER_SPEAKER_PRESENT) 926 max_98390_set_codec_conf(&sof_audio_card_rt5682, 927 ARRAY_SIZE(max_98390_4spk_components)); 928 else 929 max_98390_set_codec_conf(&sof_audio_card_rt5682, 930 ARRAY_SIZE(max_98390_components)); 931 } 932 933 if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) 934 sof_audio_card_rt5682.num_links++; 935 936 dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp, 937 dmic_be_num, hdmi_num, ctx->idisp_codec); 938 if (!dai_links) 939 return -ENOMEM; 940 941 sof_audio_card_rt5682.dai_link = dai_links; 942 943 if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT) 944 sof_rt1015_codec_conf(&sof_audio_card_rt5682); 945 946 INIT_LIST_HEAD(&ctx->hdmi_pcm_list); 947 948 sof_audio_card_rt5682.dev = &pdev->dev; 949 950 /* set platform name for each dailink */ 951 ret = snd_soc_fixup_dai_links_platform_name(&sof_audio_card_rt5682, 952 mach->mach_params.platform); 953 if (ret) 954 return ret; 955 956 ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv; 957 958 snd_soc_card_set_drvdata(&sof_audio_card_rt5682, ctx); 959 960 return devm_snd_soc_register_card(&pdev->dev, 961 &sof_audio_card_rt5682); 962 } 963 964 static const struct platform_device_id board_ids[] = { 965 { 966 .name = "sof_rt5682", 967 }, 968 { 969 .name = "tgl_mx98357_rt5682", 970 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 971 SOF_RT5682_SSP_CODEC(0) | 972 SOF_SPEAKER_AMP_PRESENT | 973 SOF_RT5682_SSP_AMP(1) | 974 SOF_RT5682_NUM_HDMIDEV(4) | 975 SOF_BT_OFFLOAD_SSP(2) | 976 SOF_SSP_BT_OFFLOAD_PRESENT), 977 }, 978 { 979 .name = "jsl_rt5682_rt1015", 980 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 981 SOF_RT5682_MCLK_24MHZ | 982 SOF_RT5682_SSP_CODEC(0) | 983 SOF_SPEAKER_AMP_PRESENT | 984 SOF_RT1015_SPEAKER_AMP_PRESENT | 985 SOF_RT5682_SSP_AMP(1)), 986 }, 987 { 988 .name = "tgl_mx98373_rt5682", 989 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 990 SOF_RT5682_SSP_CODEC(0) | 991 SOF_SPEAKER_AMP_PRESENT | 992 SOF_MAX98373_SPEAKER_AMP_PRESENT | 993 SOF_RT5682_SSP_AMP(1) | 994 SOF_RT5682_NUM_HDMIDEV(4) | 995 SOF_BT_OFFLOAD_SSP(2) | 996 SOF_SSP_BT_OFFLOAD_PRESENT), 997 }, 998 { 999 .name = "jsl_rt5682_mx98360", 1000 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1001 SOF_RT5682_MCLK_24MHZ | 1002 SOF_RT5682_SSP_CODEC(0) | 1003 SOF_SPEAKER_AMP_PRESENT | 1004 SOF_MAX98360A_SPEAKER_AMP_PRESENT | 1005 SOF_RT5682_SSP_AMP(1)), 1006 }, 1007 { 1008 .name = "cml_rt1015_rt5682", 1009 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1010 SOF_RT5682_MCLK_24MHZ | 1011 SOF_RT5682_SSP_CODEC(0) | 1012 SOF_SPEAKER_AMP_PRESENT | 1013 SOF_RT1015_SPEAKER_AMP_PRESENT | 1014 SOF_RT1015_SPEAKER_AMP_100FS | 1015 SOF_RT5682_SSP_AMP(1)), 1016 }, 1017 { 1018 .name = "tgl_rt1011_rt5682", 1019 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1020 SOF_RT5682_SSP_CODEC(0) | 1021 SOF_SPEAKER_AMP_PRESENT | 1022 SOF_RT1011_SPEAKER_AMP_PRESENT | 1023 SOF_RT5682_SSP_AMP(1) | 1024 SOF_RT5682_NUM_HDMIDEV(4) | 1025 SOF_BT_OFFLOAD_SSP(2) | 1026 SOF_SSP_BT_OFFLOAD_PRESENT), 1027 }, 1028 { 1029 .name = "jsl_rt5682_rt1015p", 1030 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1031 SOF_RT5682_MCLK_24MHZ | 1032 SOF_RT5682_SSP_CODEC(0) | 1033 SOF_SPEAKER_AMP_PRESENT | 1034 SOF_RT1015P_SPEAKER_AMP_PRESENT | 1035 SOF_RT5682_SSP_AMP(1)), 1036 }, 1037 { 1038 .name = "adl_mx98373_rt5682", 1039 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1040 SOF_RT5682_SSP_CODEC(0) | 1041 SOF_SPEAKER_AMP_PRESENT | 1042 SOF_MAX98373_SPEAKER_AMP_PRESENT | 1043 SOF_RT5682_SSP_AMP(1) | 1044 SOF_RT5682_NUM_HDMIDEV(4) | 1045 SOF_BT_OFFLOAD_SSP(2) | 1046 SOF_SSP_BT_OFFLOAD_PRESENT), 1047 }, 1048 { 1049 .name = "adl_mx98357_rt5682", 1050 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1051 SOF_RT5682_SSP_CODEC(0) | 1052 SOF_SPEAKER_AMP_PRESENT | 1053 SOF_RT5682_SSP_AMP(2) | 1054 SOF_RT5682_NUM_HDMIDEV(4)), 1055 }, 1056 { 1057 .name = "adl_max98390_rt5682", 1058 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1059 SOF_RT5682_SSP_CODEC(0) | 1060 SOF_SPEAKER_AMP_PRESENT | 1061 SOF_MAX98390_SPEAKER_AMP_PRESENT | 1062 SOF_RT5682_SSP_AMP(1) | 1063 SOF_RT5682_NUM_HDMIDEV(4) | 1064 SOF_BT_OFFLOAD_SSP(2) | 1065 SOF_SSP_BT_OFFLOAD_PRESENT), 1066 }, 1067 { 1068 .name = "adl_mx98360_rt5682", 1069 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1070 SOF_RT5682_SSP_CODEC(0) | 1071 SOF_SPEAKER_AMP_PRESENT | 1072 SOF_MAX98360A_SPEAKER_AMP_PRESENT | 1073 SOF_RT5682_SSP_AMP(1) | 1074 SOF_RT5682_NUM_HDMIDEV(4) | 1075 SOF_BT_OFFLOAD_SSP(2) | 1076 SOF_SSP_BT_OFFLOAD_PRESENT), 1077 }, 1078 { 1079 .name = "adl_rt5682", 1080 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1081 SOF_RT5682_SSP_CODEC(0) | 1082 SOF_RT5682_NUM_HDMIDEV(4) | 1083 SOF_BT_OFFLOAD_SSP(2) | 1084 SOF_SSP_BT_OFFLOAD_PRESENT), 1085 }, 1086 { 1087 .name = "adl_rt1019_rt5682s", 1088 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1089 SOF_RT5682_SSP_CODEC(0) | 1090 SOF_RT5682S_HEADPHONE_CODEC_PRESENT | 1091 SOF_SPEAKER_AMP_PRESENT | 1092 SOF_RT1019_SPEAKER_AMP_PRESENT | 1093 SOF_RT5682_SSP_AMP(1) | 1094 SOF_RT5682_NUM_HDMIDEV(4)), 1095 }, 1096 { 1097 .name = "mtl_mx98357_rt5682", 1098 .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | 1099 SOF_RT5682_SSP_CODEC(0) | 1100 SOF_SPEAKER_AMP_PRESENT | 1101 SOF_RT5682_SSP_AMP(1) | 1102 SOF_RT5682_NUM_HDMIDEV(4)), 1103 }, 1104 { } 1105 }; 1106 MODULE_DEVICE_TABLE(platform, board_ids); 1107 1108 static struct platform_driver sof_audio = { 1109 .probe = sof_audio_probe, 1110 .driver = { 1111 .name = "sof_rt5682", 1112 .pm = &snd_soc_pm_ops, 1113 }, 1114 .id_table = board_ids, 1115 }; 1116 module_platform_driver(sof_audio) 1117 1118 /* Module information */ 1119 MODULE_DESCRIPTION("SOF Audio Machine driver"); 1120 MODULE_AUTHOR("Bard Liao <bard.liao@intel.com>"); 1121 MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>"); 1122 MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>"); 1123 MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>"); 1124 MODULE_LICENSE("GPL v2"); 1125 MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); 1126 MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); 1127 MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); 1128