1 // SPDX-License-Identifier: GPL-2.0-only 2 // Copyright(c) 2021 Intel Corporation. 3 // Copyright(c) 2021 Nuvoton Corporation. 4 5 /* 6 * Intel SOF Machine Driver with Nuvoton headphone codec NAU8825 7 * and speaker codec RT1019P MAX98360a or MAX98373 8 */ 9 #include <linux/i2c.h> 10 #include <linux/input.h> 11 #include <linux/module.h> 12 #include <linux/platform_device.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/soc-acpi.h> 21 #include "../../codecs/nau8825.h" 22 #include "../common/soc-intel-quirks.h" 23 #include "hda_dsp_common.h" 24 #include "sof_realtek_common.h" 25 #include "sof_maxim_common.h" 26 27 #define NAME_SIZE 32 28 29 #define SOF_NAU8825_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) 30 #define SOF_NAU8825_SSP_CODEC_MASK (GENMASK(2, 0)) 31 #define SOF_SPEAKER_AMP_PRESENT BIT(3) 32 #define SOF_NAU8825_SSP_AMP_SHIFT 4 33 #define SOF_NAU8825_SSP_AMP_MASK (GENMASK(6, 4)) 34 #define SOF_NAU8825_SSP_AMP(quirk) \ 35 (((quirk) << SOF_NAU8825_SSP_AMP_SHIFT) & SOF_NAU8825_SSP_AMP_MASK) 36 #define SOF_NAU8825_NUM_HDMIDEV_SHIFT 7 37 #define SOF_NAU8825_NUM_HDMIDEV_MASK (GENMASK(9, 7)) 38 #define SOF_NAU8825_NUM_HDMIDEV(quirk) \ 39 (((quirk) << SOF_NAU8825_NUM_HDMIDEV_SHIFT) & SOF_NAU8825_NUM_HDMIDEV_MASK) 40 41 /* BT audio offload: reserve 3 bits for future */ 42 #define SOF_BT_OFFLOAD_SSP_SHIFT 10 43 #define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(12, 10)) 44 #define SOF_BT_OFFLOAD_SSP(quirk) \ 45 (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) 46 #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(13) 47 #define SOF_RT1019P_SPEAKER_AMP_PRESENT BIT(14) 48 #define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(15) 49 #define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(16) 50 51 static unsigned long sof_nau8825_quirk = SOF_NAU8825_SSP_CODEC(0); 52 53 struct sof_hdmi_pcm { 54 struct list_head head; 55 struct snd_soc_dai *codec_dai; 56 int device; 57 }; 58 59 struct sof_card_private { 60 struct clk *mclk; 61 struct snd_soc_jack sof_headset; 62 struct list_head hdmi_pcm_list; 63 }; 64 65 static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) 66 { 67 struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 68 struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); 69 struct sof_hdmi_pcm *pcm; 70 71 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); 72 if (!pcm) 73 return -ENOMEM; 74 75 /* dai_link id is 1:1 mapped to the PCM device */ 76 pcm->device = rtd->dai_link->id; 77 pcm->codec_dai = dai; 78 79 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); 80 81 return 0; 82 } 83 84 static struct snd_soc_jack_pin jack_pins[] = { 85 { 86 .pin = "Headphone Jack", 87 .mask = SND_JACK_HEADPHONE, 88 }, 89 { 90 .pin = "Headset Mic", 91 .mask = SND_JACK_MICROPHONE, 92 }, 93 }; 94 95 static int sof_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) 96 { 97 struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 98 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 99 100 struct snd_soc_jack *jack; 101 int ret; 102 103 /* 104 * Headset buttons map to the google Reference headset. 105 * These can be configured by userspace. 106 */ 107 ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", 108 SND_JACK_HEADSET | SND_JACK_BTN_0 | 109 SND_JACK_BTN_1 | SND_JACK_BTN_2 | 110 SND_JACK_BTN_3, 111 &ctx->sof_headset, 112 jack_pins, 113 ARRAY_SIZE(jack_pins)); 114 if (ret) { 115 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); 116 return ret; 117 } 118 119 jack = &ctx->sof_headset; 120 121 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); 122 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); 123 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); 124 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); 125 ret = snd_soc_component_set_jack(component, jack, NULL); 126 127 if (ret) { 128 dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret); 129 return ret; 130 } 131 132 return ret; 133 }; 134 135 static void sof_nau8825_codec_exit(struct snd_soc_pcm_runtime *rtd) 136 { 137 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 138 139 snd_soc_component_set_jack(component, NULL, NULL); 140 } 141 142 static int sof_nau8825_hw_params(struct snd_pcm_substream *substream, 143 struct snd_pcm_hw_params *params) 144 { 145 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 146 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 147 int clk_freq, ret; 148 149 clk_freq = sof_dai_get_bclk(rtd); /* BCLK freq */ 150 151 if (clk_freq <= 0) { 152 dev_err(rtd->dev, "get bclk freq failed: %d\n", clk_freq); 153 return -EINVAL; 154 } 155 156 /* Configure clock for codec */ 157 ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_BLK, 0, 158 SND_SOC_CLOCK_IN); 159 if (ret < 0) { 160 dev_err(codec_dai->dev, "can't set BCLK clock %d\n", ret); 161 return ret; 162 } 163 164 /* Configure pll for codec */ 165 ret = snd_soc_dai_set_pll(codec_dai, 0, 0, clk_freq, 166 params_rate(params) * 256); 167 if (ret < 0) { 168 dev_err(codec_dai->dev, "can't set BCLK: %d\n", ret); 169 return ret; 170 } 171 172 return ret; 173 } 174 175 static struct snd_soc_ops sof_nau8825_ops = { 176 .hw_params = sof_nau8825_hw_params, 177 }; 178 179 static struct snd_soc_dai_link_component platform_component[] = { 180 { 181 /* name might be overridden during probe */ 182 .name = "0000:00:1f.3" 183 } 184 }; 185 186 static int sof_card_late_probe(struct snd_soc_card *card) 187 { 188 struct sof_card_private *ctx = snd_soc_card_get_drvdata(card); 189 struct snd_soc_dapm_context *dapm = &card->dapm; 190 struct sof_hdmi_pcm *pcm; 191 int err; 192 193 if (sof_nau8825_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) { 194 /* Disable Left and Right Spk pin after boot */ 195 snd_soc_dapm_disable_pin(dapm, "Left Spk"); 196 snd_soc_dapm_disable_pin(dapm, "Right Spk"); 197 err = snd_soc_dapm_sync(dapm); 198 if (err < 0) 199 return err; 200 } 201 202 if (list_empty(&ctx->hdmi_pcm_list)) 203 return -EINVAL; 204 205 pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm, head); 206 207 return hda_dsp_hdmi_build_controls(card, pcm->codec_dai->component); 208 } 209 210 static const struct snd_kcontrol_new sof_controls[] = { 211 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 212 SOC_DAPM_PIN_SWITCH("Headset Mic"), 213 SOC_DAPM_PIN_SWITCH("Left Spk"), 214 SOC_DAPM_PIN_SWITCH("Right Spk"), 215 }; 216 217 static const struct snd_kcontrol_new speaker_controls[] = { 218 SOC_DAPM_PIN_SWITCH("Spk"), 219 }; 220 221 static const struct snd_soc_dapm_widget sof_widgets[] = { 222 SND_SOC_DAPM_HP("Headphone Jack", NULL), 223 SND_SOC_DAPM_MIC("Headset Mic", NULL), 224 SND_SOC_DAPM_SPK("Left Spk", NULL), 225 SND_SOC_DAPM_SPK("Right Spk", NULL), 226 }; 227 228 static const struct snd_soc_dapm_widget speaker_widgets[] = { 229 SND_SOC_DAPM_SPK("Spk", NULL), 230 }; 231 232 static const struct snd_soc_dapm_widget dmic_widgets[] = { 233 SND_SOC_DAPM_MIC("SoC DMIC", NULL), 234 }; 235 236 static const struct snd_soc_dapm_route sof_map[] = { 237 /* HP jack connectors - unknown if we have jack detection */ 238 { "Headphone Jack", NULL, "HPOL" }, 239 { "Headphone Jack", NULL, "HPOR" }, 240 241 /* other jacks */ 242 { "MIC", NULL, "Headset Mic" }, 243 }; 244 245 static const struct snd_soc_dapm_route speaker_map[] = { 246 /* speaker */ 247 { "Spk", NULL, "Speaker" }, 248 }; 249 250 static const struct snd_soc_dapm_route dmic_map[] = { 251 /* digital mics */ 252 {"DMic", NULL, "SoC DMIC"}, 253 }; 254 255 static int speaker_codec_init(struct snd_soc_pcm_runtime *rtd) 256 { 257 struct snd_soc_card *card = rtd->card; 258 int ret; 259 260 ret = snd_soc_dapm_new_controls(&card->dapm, speaker_widgets, 261 ARRAY_SIZE(speaker_widgets)); 262 if (ret) { 263 dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret); 264 /* Don't need to add routes if widget addition failed */ 265 return ret; 266 } 267 268 ret = snd_soc_add_card_controls(card, speaker_controls, 269 ARRAY_SIZE(speaker_controls)); 270 if (ret) { 271 dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret); 272 return ret; 273 } 274 275 ret = snd_soc_dapm_add_routes(&card->dapm, speaker_map, 276 ARRAY_SIZE(speaker_map)); 277 278 if (ret) 279 dev_err(rtd->dev, "Speaker map addition failed: %d\n", ret); 280 return ret; 281 } 282 283 static int dmic_init(struct snd_soc_pcm_runtime *rtd) 284 { 285 struct snd_soc_card *card = rtd->card; 286 int ret; 287 288 ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, 289 ARRAY_SIZE(dmic_widgets)); 290 if (ret) { 291 dev_err(card->dev, "DMic widget addition failed: %d\n", ret); 292 /* Don't need to add routes if widget addition failed */ 293 return ret; 294 } 295 296 ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, 297 ARRAY_SIZE(dmic_map)); 298 299 if (ret) 300 dev_err(card->dev, "DMic map addition failed: %d\n", ret); 301 302 return ret; 303 } 304 305 /* sof audio machine driver for nau8825 codec */ 306 static struct snd_soc_card sof_audio_card_nau8825 = { 307 .name = "nau8825", /* the sof- prefix is added by the core */ 308 .owner = THIS_MODULE, 309 .controls = sof_controls, 310 .num_controls = ARRAY_SIZE(sof_controls), 311 .dapm_widgets = sof_widgets, 312 .num_dapm_widgets = ARRAY_SIZE(sof_widgets), 313 .dapm_routes = sof_map, 314 .num_dapm_routes = ARRAY_SIZE(sof_map), 315 .fully_routed = true, 316 .late_probe = sof_card_late_probe, 317 }; 318 319 static struct snd_soc_dai_link_component nau8825_component[] = { 320 { 321 .name = "i2c-10508825:00", 322 .dai_name = "nau8825-hifi", 323 } 324 }; 325 326 static struct snd_soc_dai_link_component dmic_component[] = { 327 { 328 .name = "dmic-codec", 329 .dai_name = "dmic-hifi", 330 } 331 }; 332 333 static struct snd_soc_dai_link_component rt1019p_component[] = { 334 { 335 .name = "RTL1019:00", 336 .dai_name = "HiFi", 337 } 338 }; 339 340 static struct snd_soc_dai_link_component dummy_component[] = { 341 { 342 .name = "snd-soc-dummy", 343 .dai_name = "snd-soc-dummy-dai", 344 } 345 }; 346 347 static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, 348 int ssp_codec, 349 int ssp_amp, 350 int dmic_be_num, 351 int hdmi_num) 352 { 353 struct snd_soc_dai_link_component *idisp_components; 354 struct snd_soc_dai_link_component *cpus; 355 struct snd_soc_dai_link *links; 356 int i, id = 0; 357 358 links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) * 359 sof_audio_card_nau8825.num_links, GFP_KERNEL); 360 cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component) * 361 sof_audio_card_nau8825.num_links, GFP_KERNEL); 362 if (!links || !cpus) 363 goto devm_err; 364 365 /* codec SSP */ 366 links[id].name = devm_kasprintf(dev, GFP_KERNEL, 367 "SSP%d-Codec", ssp_codec); 368 if (!links[id].name) 369 goto devm_err; 370 371 links[id].id = id; 372 links[id].codecs = nau8825_component; 373 links[id].num_codecs = ARRAY_SIZE(nau8825_component); 374 links[id].platforms = platform_component; 375 links[id].num_platforms = ARRAY_SIZE(platform_component); 376 links[id].init = sof_nau8825_codec_init; 377 links[id].exit = sof_nau8825_codec_exit; 378 links[id].ops = &sof_nau8825_ops; 379 links[id].dpcm_playback = 1; 380 links[id].dpcm_capture = 1; 381 links[id].no_pcm = 1; 382 links[id].cpus = &cpus[id]; 383 links[id].num_cpus = 1; 384 385 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 386 "SSP%d Pin", 387 ssp_codec); 388 if (!links[id].cpus->dai_name) 389 goto devm_err; 390 391 id++; 392 393 /* dmic */ 394 if (dmic_be_num > 0) { 395 /* at least we have dmic01 */ 396 links[id].name = "dmic01"; 397 links[id].cpus = &cpus[id]; 398 links[id].cpus->dai_name = "DMIC01 Pin"; 399 links[id].init = dmic_init; 400 if (dmic_be_num > 1) { 401 /* set up 2 BE links at most */ 402 links[id + 1].name = "dmic16k"; 403 links[id + 1].cpus = &cpus[id + 1]; 404 links[id + 1].cpus->dai_name = "DMIC16k Pin"; 405 dmic_be_num = 2; 406 } 407 } 408 409 for (i = 0; i < dmic_be_num; i++) { 410 links[id].id = id; 411 links[id].num_cpus = 1; 412 links[id].codecs = dmic_component; 413 links[id].num_codecs = ARRAY_SIZE(dmic_component); 414 links[id].platforms = platform_component; 415 links[id].num_platforms = ARRAY_SIZE(platform_component); 416 links[id].ignore_suspend = 1; 417 links[id].dpcm_capture = 1; 418 links[id].no_pcm = 1; 419 id++; 420 } 421 422 /* HDMI */ 423 if (hdmi_num > 0) { 424 idisp_components = devm_kzalloc(dev, 425 sizeof(struct snd_soc_dai_link_component) * 426 hdmi_num, GFP_KERNEL); 427 if (!idisp_components) 428 goto devm_err; 429 } 430 for (i = 1; i <= hdmi_num; i++) { 431 links[id].name = devm_kasprintf(dev, GFP_KERNEL, 432 "iDisp%d", i); 433 if (!links[id].name) 434 goto devm_err; 435 436 links[id].id = id; 437 links[id].cpus = &cpus[id]; 438 links[id].num_cpus = 1; 439 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 440 "iDisp%d Pin", i); 441 if (!links[id].cpus->dai_name) 442 goto devm_err; 443 444 idisp_components[i - 1].name = "ehdaudio0D2"; 445 idisp_components[i - 1].dai_name = devm_kasprintf(dev, 446 GFP_KERNEL, 447 "intel-hdmi-hifi%d", 448 i); 449 if (!idisp_components[i - 1].dai_name) 450 goto devm_err; 451 452 links[id].codecs = &idisp_components[i - 1]; 453 links[id].num_codecs = 1; 454 links[id].platforms = platform_component; 455 links[id].num_platforms = ARRAY_SIZE(platform_component); 456 links[id].init = sof_hdmi_init; 457 links[id].dpcm_playback = 1; 458 links[id].no_pcm = 1; 459 id++; 460 } 461 462 /* speaker amp */ 463 if (sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) { 464 links[id].name = devm_kasprintf(dev, GFP_KERNEL, 465 "SSP%d-Codec", ssp_amp); 466 if (!links[id].name) 467 goto devm_err; 468 469 links[id].id = id; 470 if (sof_nau8825_quirk & SOF_RT1019P_SPEAKER_AMP_PRESENT) { 471 links[id].codecs = rt1019p_component; 472 links[id].num_codecs = ARRAY_SIZE(rt1019p_component); 473 links[id].init = speaker_codec_init; 474 } else if (sof_nau8825_quirk & 475 SOF_MAX98373_SPEAKER_AMP_PRESENT) { 476 links[id].codecs = max_98373_components; 477 links[id].num_codecs = ARRAY_SIZE(max_98373_components); 478 links[id].init = max_98373_spk_codec_init; 479 links[id].ops = &max_98373_ops; 480 /* feedback stream */ 481 links[id].dpcm_capture = 1; 482 } else if (sof_nau8825_quirk & 483 SOF_MAX98360A_SPEAKER_AMP_PRESENT) { 484 max_98360a_dai_link(&links[id]); 485 } else { 486 goto devm_err; 487 } 488 489 links[id].platforms = platform_component; 490 links[id].num_platforms = ARRAY_SIZE(platform_component); 491 links[id].dpcm_playback = 1; 492 links[id].no_pcm = 1; 493 links[id].cpus = &cpus[id]; 494 links[id].num_cpus = 1; 495 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 496 "SSP%d Pin", 497 ssp_amp); 498 if (!links[id].cpus->dai_name) 499 goto devm_err; 500 id++; 501 } 502 503 /* BT audio offload */ 504 if (sof_nau8825_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) { 505 int port = (sof_nau8825_quirk & SOF_BT_OFFLOAD_SSP_MASK) >> 506 SOF_BT_OFFLOAD_SSP_SHIFT; 507 508 links[id].id = id; 509 links[id].cpus = &cpus[id]; 510 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 511 "SSP%d Pin", port); 512 if (!links[id].cpus->dai_name) 513 goto devm_err; 514 links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port); 515 if (!links[id].name) 516 goto devm_err; 517 links[id].codecs = dummy_component; 518 links[id].num_codecs = ARRAY_SIZE(dummy_component); 519 links[id].platforms = platform_component; 520 links[id].num_platforms = ARRAY_SIZE(platform_component); 521 links[id].dpcm_playback = 1; 522 links[id].dpcm_capture = 1; 523 links[id].no_pcm = 1; 524 links[id].num_cpus = 1; 525 } 526 527 return links; 528 devm_err: 529 return NULL; 530 } 531 532 static int sof_audio_probe(struct platform_device *pdev) 533 { 534 struct snd_soc_dai_link *dai_links; 535 struct snd_soc_acpi_mach *mach; 536 struct sof_card_private *ctx; 537 int dmic_be_num, hdmi_num; 538 int ret, ssp_amp, ssp_codec; 539 540 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 541 if (!ctx) 542 return -ENOMEM; 543 544 if (pdev->id_entry && pdev->id_entry->driver_data) 545 sof_nau8825_quirk = (unsigned long)pdev->id_entry->driver_data; 546 547 mach = pdev->dev.platform_data; 548 549 /* A speaker amp might not be present when the quirk claims one is. 550 * Detect this via whether the machine driver match includes quirk_data. 551 */ 552 if ((sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) && !mach->quirk_data) 553 sof_nau8825_quirk &= ~SOF_SPEAKER_AMP_PRESENT; 554 555 dev_dbg(&pdev->dev, "sof_nau8825_quirk = %lx\n", sof_nau8825_quirk); 556 557 /* default number of DMIC DAI's */ 558 dmic_be_num = 2; 559 hdmi_num = (sof_nau8825_quirk & SOF_NAU8825_NUM_HDMIDEV_MASK) >> 560 SOF_NAU8825_NUM_HDMIDEV_SHIFT; 561 /* default number of HDMI DAI's */ 562 if (!hdmi_num) 563 hdmi_num = 3; 564 565 ssp_amp = (sof_nau8825_quirk & SOF_NAU8825_SSP_AMP_MASK) >> 566 SOF_NAU8825_SSP_AMP_SHIFT; 567 568 ssp_codec = sof_nau8825_quirk & SOF_NAU8825_SSP_CODEC_MASK; 569 570 /* compute number of dai links */ 571 sof_audio_card_nau8825.num_links = 1 + dmic_be_num + hdmi_num; 572 573 if (sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) 574 sof_audio_card_nau8825.num_links++; 575 576 if (sof_nau8825_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) 577 max_98373_set_codec_conf(&sof_audio_card_nau8825); 578 579 if (sof_nau8825_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) 580 sof_audio_card_nau8825.num_links++; 581 582 dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp, 583 dmic_be_num, hdmi_num); 584 if (!dai_links) 585 return -ENOMEM; 586 587 sof_audio_card_nau8825.dai_link = dai_links; 588 589 INIT_LIST_HEAD(&ctx->hdmi_pcm_list); 590 591 sof_audio_card_nau8825.dev = &pdev->dev; 592 593 /* set platform name for each dailink */ 594 ret = snd_soc_fixup_dai_links_platform_name(&sof_audio_card_nau8825, 595 mach->mach_params.platform); 596 if (ret) 597 return ret; 598 599 snd_soc_card_set_drvdata(&sof_audio_card_nau8825, ctx); 600 601 return devm_snd_soc_register_card(&pdev->dev, 602 &sof_audio_card_nau8825); 603 } 604 605 static const struct platform_device_id board_ids[] = { 606 { 607 .name = "sof_nau8825", 608 .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | 609 SOF_NAU8825_NUM_HDMIDEV(4) | 610 SOF_BT_OFFLOAD_SSP(2) | 611 SOF_SSP_BT_OFFLOAD_PRESENT), 612 613 }, 614 { 615 .name = "adl_rt1019p_nau8825", 616 .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | 617 SOF_SPEAKER_AMP_PRESENT | 618 SOF_RT1019P_SPEAKER_AMP_PRESENT | 619 SOF_NAU8825_SSP_AMP(2) | 620 SOF_NAU8825_NUM_HDMIDEV(4)), 621 }, 622 { 623 .name = "adl_max98373_nau8825", 624 .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | 625 SOF_SPEAKER_AMP_PRESENT | 626 SOF_MAX98373_SPEAKER_AMP_PRESENT | 627 SOF_NAU8825_SSP_AMP(1) | 628 SOF_NAU8825_NUM_HDMIDEV(4) | 629 SOF_BT_OFFLOAD_SSP(2) | 630 SOF_SSP_BT_OFFLOAD_PRESENT), 631 }, 632 { 633 /* The limitation of length of char array, shorten the name */ 634 .name = "adl_mx98360a_nau8825", 635 .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | 636 SOF_SPEAKER_AMP_PRESENT | 637 SOF_MAX98360A_SPEAKER_AMP_PRESENT | 638 SOF_NAU8825_SSP_AMP(1) | 639 SOF_NAU8825_NUM_HDMIDEV(4) | 640 SOF_BT_OFFLOAD_SSP(2) | 641 SOF_SSP_BT_OFFLOAD_PRESENT), 642 643 }, 644 { } 645 }; 646 MODULE_DEVICE_TABLE(platform, board_ids); 647 648 static struct platform_driver sof_audio = { 649 .probe = sof_audio_probe, 650 .driver = { 651 .name = "sof_nau8825", 652 .pm = &snd_soc_pm_ops, 653 }, 654 .id_table = board_ids, 655 }; 656 module_platform_driver(sof_audio) 657 658 /* Module information */ 659 MODULE_DESCRIPTION("SOF Audio Machine driver for NAU8825"); 660 MODULE_AUTHOR("David Lin <ctlin0@nuvoton.com>"); 661 MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>"); 662 MODULE_LICENSE("GPL"); 663 MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); 664 MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); 665