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