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