1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Intel Skylake I2S Machine Driver for NAU88L25+SSM4567 4 * 5 * Copyright (C) 2015, Intel Corporation. All rights reserved. 6 * 7 * Modified from: 8 * Intel Skylake I2S Machine Driver for NAU88L25 and SSM4567 9 * 10 * Copyright (C) 2015, Intel Corporation. All rights reserved. 11 */ 12 13 #include <linux/module.h> 14 #include <linux/platform_device.h> 15 #include <sound/core.h> 16 #include <sound/pcm.h> 17 #include <sound/soc.h> 18 #include <sound/soc-acpi.h> 19 #include <sound/jack.h> 20 #include <sound/pcm_params.h> 21 #include "../../codecs/nau8825.h" 22 #include "../../codecs/hdac_hdmi.h" 23 24 #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi" 25 #define SKL_SSM_CODEC_DAI "ssm4567-hifi" 26 #define DMIC_CH(p) p->list[p->count-1] 27 28 static struct snd_soc_jack skylake_headset; 29 static struct snd_soc_card skylake_audio_card; 30 static const struct snd_pcm_hw_constraint_list *dmic_constraints; 31 static struct snd_soc_jack skylake_hdmi[3]; 32 33 struct skl_hdmi_pcm { 34 struct list_head head; 35 struct snd_soc_dai *codec_dai; 36 int device; 37 }; 38 39 struct skl_nau88125_private { 40 struct list_head hdmi_pcm_list; 41 }; 42 enum { 43 SKL_DPCM_AUDIO_PB = 0, 44 SKL_DPCM_AUDIO_CP, 45 SKL_DPCM_AUDIO_REF_CP, 46 SKL_DPCM_AUDIO_DMIC_CP, 47 SKL_DPCM_AUDIO_HDMI1_PB, 48 SKL_DPCM_AUDIO_HDMI2_PB, 49 SKL_DPCM_AUDIO_HDMI3_PB, 50 }; 51 52 static const struct snd_kcontrol_new skylake_controls[] = { 53 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 54 SOC_DAPM_PIN_SWITCH("Headset Mic"), 55 SOC_DAPM_PIN_SWITCH("Left Speaker"), 56 SOC_DAPM_PIN_SWITCH("Right Speaker"), 57 }; 58 59 static int platform_clock_control(struct snd_soc_dapm_widget *w, 60 struct snd_kcontrol *k, int event) 61 { 62 struct snd_soc_dapm_context *dapm = w->dapm; 63 struct snd_soc_card *card = dapm->card; 64 struct snd_soc_dai *codec_dai; 65 int ret; 66 67 codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI); 68 if (!codec_dai) { 69 dev_err(card->dev, "Codec dai not found\n"); 70 return -EIO; 71 } 72 73 if (SND_SOC_DAPM_EVENT_ON(event)) { 74 ret = snd_soc_dai_set_sysclk(codec_dai, 75 NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN); 76 if (ret < 0) { 77 dev_err(card->dev, "set sysclk err = %d\n", ret); 78 return -EIO; 79 } 80 } else { 81 ret = snd_soc_dai_set_sysclk(codec_dai, 82 NAU8825_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN); 83 if (ret < 0) { 84 dev_err(card->dev, "set sysclk err = %d\n", ret); 85 return -EIO; 86 } 87 } 88 return ret; 89 } 90 91 static const struct snd_soc_dapm_widget skylake_widgets[] = { 92 SND_SOC_DAPM_HP("Headphone Jack", NULL), 93 SND_SOC_DAPM_MIC("Headset Mic", NULL), 94 SND_SOC_DAPM_SPK("Left Speaker", NULL), 95 SND_SOC_DAPM_SPK("Right Speaker", NULL), 96 SND_SOC_DAPM_MIC("SoC DMIC", NULL), 97 SND_SOC_DAPM_SPK("DP1", NULL), 98 SND_SOC_DAPM_SPK("DP2", NULL), 99 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, 100 platform_clock_control, SND_SOC_DAPM_PRE_PMU | 101 SND_SOC_DAPM_POST_PMD), 102 }; 103 104 static struct snd_soc_jack_pin jack_pins[] = { 105 { 106 .pin = "Headphone Jack", 107 .mask = SND_JACK_HEADPHONE, 108 }, 109 { 110 .pin = "Headset Mic", 111 .mask = SND_JACK_MICROPHONE, 112 }, 113 }; 114 115 static const struct snd_soc_dapm_route skylake_map[] = { 116 /* HP jack connectors - unknown if we have jack detection */ 117 {"Headphone Jack", NULL, "HPOL"}, 118 {"Headphone Jack", NULL, "HPOR"}, 119 120 /* speaker */ 121 {"Left Speaker", NULL, "Left OUT"}, 122 {"Right Speaker", NULL, "Right OUT"}, 123 124 /* other jacks */ 125 {"MIC", NULL, "Headset Mic"}, 126 {"DMic", NULL, "SoC DMIC"}, 127 128 /* CODEC BE connections */ 129 { "Left Playback", NULL, "ssp0 Tx"}, 130 { "Right Playback", NULL, "ssp0 Tx"}, 131 { "ssp0 Tx", NULL, "codec0_out"}, 132 133 /* IV feedback path */ 134 { "codec0_lp_in", NULL, "ssp0 Rx"}, 135 { "ssp0 Rx", NULL, "Left Capture Sense" }, 136 { "ssp0 Rx", NULL, "Right Capture Sense" }, 137 138 { "Playback", NULL, "ssp1 Tx"}, 139 { "ssp1 Tx", NULL, "codec1_out"}, 140 141 { "codec0_in", NULL, "ssp1 Rx" }, 142 { "ssp1 Rx", NULL, "Capture" }, 143 144 /* DMIC */ 145 { "dmic01_hifi", NULL, "DMIC01 Rx" }, 146 { "DMIC01 Rx", NULL, "DMIC AIF" }, 147 148 { "hifi3", NULL, "iDisp3 Tx"}, 149 { "iDisp3 Tx", NULL, "iDisp3_out"}, 150 { "hifi2", NULL, "iDisp2 Tx"}, 151 { "iDisp2 Tx", NULL, "iDisp2_out"}, 152 { "hifi1", NULL, "iDisp1 Tx"}, 153 { "iDisp1 Tx", NULL, "iDisp1_out"}, 154 155 { "Headphone Jack", NULL, "Platform Clock" }, 156 { "Headset Mic", NULL, "Platform Clock" }, 157 }; 158 159 static struct snd_soc_codec_conf ssm4567_codec_conf[] = { 160 { 161 .dlc = COMP_CODEC_CONF("i2c-INT343B:00"), 162 .name_prefix = "Left", 163 }, 164 { 165 .dlc = COMP_CODEC_CONF("i2c-INT343B:01"), 166 .name_prefix = "Right", 167 }, 168 }; 169 170 static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd) 171 { 172 int ret; 173 174 /* Slot 1 for left */ 175 ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_codec(rtd, 0), 0x01, 0x01, 2, 48); 176 if (ret < 0) 177 return ret; 178 179 /* Slot 2 for right */ 180 ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_codec(rtd, 1), 0x02, 0x02, 2, 48); 181 if (ret < 0) 182 return ret; 183 184 return ret; 185 } 186 187 static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) 188 { 189 int ret; 190 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 191 192 /* 193 * 4 buttons here map to the google Reference headset 194 * The use of these buttons can be decided by the user space. 195 */ 196 ret = snd_soc_card_jack_new_pins(&skylake_audio_card, "Headset Jack", 197 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | 198 SND_JACK_BTN_2 | SND_JACK_BTN_3, &skylake_headset, 199 jack_pins, 200 ARRAY_SIZE(jack_pins)); 201 if (ret) { 202 dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret); 203 return ret; 204 } 205 206 nau8825_enable_jack_detect(component, &skylake_headset); 207 208 snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); 209 210 return ret; 211 } 212 213 static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) 214 { 215 struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card); 216 struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); 217 struct skl_hdmi_pcm *pcm; 218 219 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); 220 if (!pcm) 221 return -ENOMEM; 222 223 pcm->device = SKL_DPCM_AUDIO_HDMI1_PB; 224 pcm->codec_dai = dai; 225 226 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); 227 228 return 0; 229 } 230 231 static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) 232 { 233 struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card); 234 struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); 235 struct skl_hdmi_pcm *pcm; 236 237 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); 238 if (!pcm) 239 return -ENOMEM; 240 241 pcm->device = SKL_DPCM_AUDIO_HDMI2_PB; 242 pcm->codec_dai = dai; 243 244 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); 245 246 return 0; 247 } 248 249 250 static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) 251 { 252 struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card); 253 struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); 254 struct skl_hdmi_pcm *pcm; 255 256 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); 257 if (!pcm) 258 return -ENOMEM; 259 260 pcm->device = SKL_DPCM_AUDIO_HDMI3_PB; 261 pcm->codec_dai = dai; 262 263 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); 264 265 return 0; 266 } 267 268 static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd) 269 { 270 struct snd_soc_dapm_context *dapm; 271 struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component; 272 273 dapm = snd_soc_component_get_dapm(component); 274 snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); 275 276 return 0; 277 } 278 279 static const unsigned int rates[] = { 280 48000, 281 }; 282 283 static const struct snd_pcm_hw_constraint_list constraints_rates = { 284 .count = ARRAY_SIZE(rates), 285 .list = rates, 286 .mask = 0, 287 }; 288 289 static const unsigned int channels[] = { 290 2, 291 }; 292 293 static const struct snd_pcm_hw_constraint_list constraints_channels = { 294 .count = ARRAY_SIZE(channels), 295 .list = channels, 296 .mask = 0, 297 }; 298 299 static int skl_fe_startup(struct snd_pcm_substream *substream) 300 { 301 struct snd_pcm_runtime *runtime = substream->runtime; 302 303 /* 304 * on this platform for PCM device we support, 305 * 48Khz 306 * stereo 307 * 16 bit audio 308 */ 309 310 runtime->hw.channels_max = 2; 311 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 312 &constraints_channels); 313 314 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; 315 snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); 316 317 snd_pcm_hw_constraint_list(runtime, 0, 318 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); 319 320 return 0; 321 } 322 323 static const struct snd_soc_ops skylake_nau8825_fe_ops = { 324 .startup = skl_fe_startup, 325 }; 326 327 static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, 328 struct snd_pcm_hw_params *params) 329 { 330 struct snd_interval *rate = hw_param_interval(params, 331 SNDRV_PCM_HW_PARAM_RATE); 332 struct snd_interval *chan = hw_param_interval(params, 333 SNDRV_PCM_HW_PARAM_CHANNELS); 334 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 335 336 /* The ADSP will covert the FE rate to 48k, stereo */ 337 rate->min = rate->max = 48000; 338 chan->min = chan->max = 2; 339 340 /* set SSP0 to 24 bit */ 341 snd_mask_none(fmt); 342 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); 343 return 0; 344 } 345 346 static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, 347 struct snd_pcm_hw_params *params) 348 { 349 struct snd_interval *chan = hw_param_interval(params, 350 SNDRV_PCM_HW_PARAM_CHANNELS); 351 if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) 352 chan->min = chan->max = 2; 353 else 354 chan->min = chan->max = 4; 355 356 return 0; 357 } 358 359 static int skylake_nau8825_hw_params(struct snd_pcm_substream *substream, 360 struct snd_pcm_hw_params *params) 361 { 362 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 363 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 364 int ret; 365 366 ret = snd_soc_dai_set_sysclk(codec_dai, 367 NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN); 368 369 if (ret < 0) 370 dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); 371 372 return ret; 373 } 374 375 static const struct snd_soc_ops skylake_nau8825_ops = { 376 .hw_params = skylake_nau8825_hw_params, 377 }; 378 379 static const unsigned int channels_dmic[] = { 380 2, 4, 381 }; 382 383 static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = { 384 .count = ARRAY_SIZE(channels_dmic), 385 .list = channels_dmic, 386 .mask = 0, 387 }; 388 389 static const unsigned int dmic_2ch[] = { 390 2, 391 }; 392 393 static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = { 394 .count = ARRAY_SIZE(dmic_2ch), 395 .list = dmic_2ch, 396 .mask = 0, 397 }; 398 399 static int skylake_dmic_startup(struct snd_pcm_substream *substream) 400 { 401 struct snd_pcm_runtime *runtime = substream->runtime; 402 403 runtime->hw.channels_max = DMIC_CH(dmic_constraints); 404 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 405 dmic_constraints); 406 407 return snd_pcm_hw_constraint_list(substream->runtime, 0, 408 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); 409 } 410 411 static const struct snd_soc_ops skylake_dmic_ops = { 412 .startup = skylake_dmic_startup, 413 }; 414 415 static const unsigned int rates_16000[] = { 416 16000, 417 }; 418 419 static const struct snd_pcm_hw_constraint_list constraints_16000 = { 420 .count = ARRAY_SIZE(rates_16000), 421 .list = rates_16000, 422 }; 423 424 static const unsigned int ch_mono[] = { 425 1, 426 }; 427 428 static const struct snd_pcm_hw_constraint_list constraints_refcap = { 429 .count = ARRAY_SIZE(ch_mono), 430 .list = ch_mono, 431 }; 432 433 static int skylake_refcap_startup(struct snd_pcm_substream *substream) 434 { 435 substream->runtime->hw.channels_max = 1; 436 snd_pcm_hw_constraint_list(substream->runtime, 0, 437 SNDRV_PCM_HW_PARAM_CHANNELS, 438 &constraints_refcap); 439 440 return snd_pcm_hw_constraint_list(substream->runtime, 0, 441 SNDRV_PCM_HW_PARAM_RATE, 442 &constraints_16000); 443 } 444 445 static const struct snd_soc_ops skylake_refcap_ops = { 446 .startup = skylake_refcap_startup, 447 }; 448 449 SND_SOC_DAILINK_DEF(dummy, 450 DAILINK_COMP_ARRAY(COMP_DUMMY())); 451 452 SND_SOC_DAILINK_DEF(system, 453 DAILINK_COMP_ARRAY(COMP_CPU("System Pin"))); 454 455 SND_SOC_DAILINK_DEF(reference, 456 DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin"))); 457 458 SND_SOC_DAILINK_DEF(dmic, 459 DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin"))); 460 461 SND_SOC_DAILINK_DEF(hdmi1, 462 DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin"))); 463 464 SND_SOC_DAILINK_DEF(hdmi2, 465 DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin"))); 466 467 SND_SOC_DAILINK_DEF(hdmi3, 468 DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin"))); 469 470 SND_SOC_DAILINK_DEF(ssp0_pin, 471 DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin"))); 472 SND_SOC_DAILINK_DEF(ssp0_codec, 473 DAILINK_COMP_ARRAY( 474 /* Left */ COMP_CODEC("i2c-INT343B:00", SKL_SSM_CODEC_DAI), 475 /* Right */ COMP_CODEC("i2c-INT343B:01", SKL_SSM_CODEC_DAI))); 476 477 SND_SOC_DAILINK_DEF(ssp1_pin, 478 DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin"))); 479 SND_SOC_DAILINK_DEF(ssp1_codec, 480 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10508825:00", SKL_NUVOTON_CODEC_DAI))); 481 482 SND_SOC_DAILINK_DEF(dmic01_pin, 483 DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); 484 SND_SOC_DAILINK_DEF(dmic_codec, 485 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); 486 487 SND_SOC_DAILINK_DEF(idisp1_pin, 488 DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin"))); 489 SND_SOC_DAILINK_DEF(idisp1_codec, 490 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1"))); 491 492 SND_SOC_DAILINK_DEF(idisp2_pin, 493 DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin"))); 494 SND_SOC_DAILINK_DEF(idisp2_codec, 495 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2"))); 496 497 SND_SOC_DAILINK_DEF(idisp3_pin, 498 DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin"))); 499 SND_SOC_DAILINK_DEF(idisp3_codec, 500 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); 501 502 SND_SOC_DAILINK_DEF(platform, 503 DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3"))); 504 505 /* skylake digital audio interface glue - connects codec <--> CPU */ 506 static struct snd_soc_dai_link skylake_dais[] = { 507 /* Front End DAI links */ 508 [SKL_DPCM_AUDIO_PB] = { 509 .name = "Skl Audio Port", 510 .stream_name = "Audio", 511 .dynamic = 1, 512 .nonatomic = 1, 513 .init = skylake_nau8825_fe_init, 514 .trigger = { 515 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 516 .dpcm_playback = 1, 517 .ops = &skylake_nau8825_fe_ops, 518 SND_SOC_DAILINK_REG(system, dummy, platform), 519 }, 520 [SKL_DPCM_AUDIO_CP] = { 521 .name = "Skl Audio Capture Port", 522 .stream_name = "Audio Record", 523 .dynamic = 1, 524 .nonatomic = 1, 525 .trigger = { 526 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 527 .dpcm_capture = 1, 528 .ops = &skylake_nau8825_fe_ops, 529 SND_SOC_DAILINK_REG(system, dummy, platform), 530 }, 531 [SKL_DPCM_AUDIO_REF_CP] = { 532 .name = "Skl Audio Reference cap", 533 .stream_name = "Wake on Voice", 534 .init = NULL, 535 .dpcm_capture = 1, 536 .nonatomic = 1, 537 .dynamic = 1, 538 .ops = &skylake_refcap_ops, 539 SND_SOC_DAILINK_REG(reference, dummy, platform), 540 }, 541 [SKL_DPCM_AUDIO_DMIC_CP] = { 542 .name = "Skl Audio DMIC cap", 543 .stream_name = "dmiccap", 544 .init = NULL, 545 .dpcm_capture = 1, 546 .nonatomic = 1, 547 .dynamic = 1, 548 .ops = &skylake_dmic_ops, 549 SND_SOC_DAILINK_REG(dmic, dummy, platform), 550 }, 551 [SKL_DPCM_AUDIO_HDMI1_PB] = { 552 .name = "Skl HDMI Port1", 553 .stream_name = "Hdmi1", 554 .dpcm_playback = 1, 555 .init = NULL, 556 .trigger = { 557 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 558 .nonatomic = 1, 559 .dynamic = 1, 560 SND_SOC_DAILINK_REG(hdmi1, dummy, platform), 561 }, 562 [SKL_DPCM_AUDIO_HDMI2_PB] = { 563 .name = "Skl HDMI Port2", 564 .stream_name = "Hdmi2", 565 .dpcm_playback = 1, 566 .init = NULL, 567 .trigger = { 568 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 569 .nonatomic = 1, 570 .dynamic = 1, 571 SND_SOC_DAILINK_REG(hdmi2, dummy, platform), 572 }, 573 [SKL_DPCM_AUDIO_HDMI3_PB] = { 574 .name = "Skl HDMI Port3", 575 .stream_name = "Hdmi3", 576 .trigger = { 577 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 578 .dpcm_playback = 1, 579 .init = NULL, 580 .nonatomic = 1, 581 .dynamic = 1, 582 SND_SOC_DAILINK_REG(hdmi3, dummy, platform), 583 }, 584 585 /* Back End DAI links */ 586 { 587 /* SSP0 - Codec */ 588 .name = "SSP0-Codec", 589 .id = 0, 590 .no_pcm = 1, 591 .dai_fmt = SND_SOC_DAIFMT_DSP_A | 592 SND_SOC_DAIFMT_IB_NF | 593 SND_SOC_DAIFMT_CBC_CFC, 594 .init = skylake_ssm4567_codec_init, 595 .ignore_pmdown_time = 1, 596 .be_hw_params_fixup = skylake_ssp_fixup, 597 .dpcm_playback = 1, 598 .dpcm_capture = 1, 599 SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform), 600 }, 601 { 602 /* SSP1 - Codec */ 603 .name = "SSP1-Codec", 604 .id = 1, 605 .no_pcm = 1, 606 .init = skylake_nau8825_codec_init, 607 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 608 SND_SOC_DAIFMT_CBC_CFC, 609 .ignore_pmdown_time = 1, 610 .be_hw_params_fixup = skylake_ssp_fixup, 611 .ops = &skylake_nau8825_ops, 612 .dpcm_playback = 1, 613 .dpcm_capture = 1, 614 SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform), 615 }, 616 { 617 .name = "dmic01", 618 .id = 2, 619 .ignore_suspend = 1, 620 .be_hw_params_fixup = skylake_dmic_fixup, 621 .dpcm_capture = 1, 622 .no_pcm = 1, 623 SND_SOC_DAILINK_REG(dmic01_pin, dmic_codec, platform), 624 }, 625 { 626 .name = "iDisp1", 627 .id = 3, 628 .dpcm_playback = 1, 629 .init = skylake_hdmi1_init, 630 .no_pcm = 1, 631 SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform), 632 }, 633 { 634 .name = "iDisp2", 635 .id = 4, 636 .init = skylake_hdmi2_init, 637 .dpcm_playback = 1, 638 .no_pcm = 1, 639 SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform), 640 }, 641 { 642 .name = "iDisp3", 643 .id = 5, 644 .init = skylake_hdmi3_init, 645 .dpcm_playback = 1, 646 .no_pcm = 1, 647 SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform), 648 }, 649 }; 650 651 #define NAME_SIZE 32 652 static int skylake_card_late_probe(struct snd_soc_card *card) 653 { 654 struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card); 655 struct skl_hdmi_pcm *pcm; 656 struct snd_soc_component *component = NULL; 657 int err, i = 0; 658 char jack_name[NAME_SIZE]; 659 660 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { 661 component = pcm->codec_dai->component; 662 snprintf(jack_name, sizeof(jack_name), 663 "HDMI/DP, pcm=%d Jack", pcm->device); 664 err = snd_soc_card_jack_new(card, jack_name, 665 SND_JACK_AVOUT, 666 &skylake_hdmi[i]); 667 668 if (err) 669 return err; 670 671 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, 672 &skylake_hdmi[i]); 673 if (err < 0) 674 return err; 675 676 i++; 677 } 678 679 if (!component) 680 return -EINVAL; 681 682 return hdac_hdmi_jack_port_init(component, &card->dapm); 683 } 684 685 /* skylake audio machine driver for SPT + NAU88L25 */ 686 static struct snd_soc_card skylake_audio_card = { 687 .name = "sklnau8825adi", 688 .owner = THIS_MODULE, 689 .dai_link = skylake_dais, 690 .num_links = ARRAY_SIZE(skylake_dais), 691 .controls = skylake_controls, 692 .num_controls = ARRAY_SIZE(skylake_controls), 693 .dapm_widgets = skylake_widgets, 694 .num_dapm_widgets = ARRAY_SIZE(skylake_widgets), 695 .dapm_routes = skylake_map, 696 .num_dapm_routes = ARRAY_SIZE(skylake_map), 697 .codec_conf = ssm4567_codec_conf, 698 .num_configs = ARRAY_SIZE(ssm4567_codec_conf), 699 .fully_routed = true, 700 .disable_route_checks = true, 701 .late_probe = skylake_card_late_probe, 702 }; 703 704 static int skylake_audio_probe(struct platform_device *pdev) 705 { 706 struct skl_nau88125_private *ctx; 707 struct snd_soc_acpi_mach *mach; 708 709 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 710 if (!ctx) 711 return -ENOMEM; 712 713 INIT_LIST_HEAD(&ctx->hdmi_pcm_list); 714 715 skylake_audio_card.dev = &pdev->dev; 716 snd_soc_card_set_drvdata(&skylake_audio_card, ctx); 717 718 mach = pdev->dev.platform_data; 719 if (mach) 720 dmic_constraints = mach->mach_params.dmic_num == 2 ? 721 &constraints_dmic_2ch : &constraints_dmic_channels; 722 723 return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card); 724 } 725 726 static const struct platform_device_id skl_board_ids[] = { 727 { .name = "skl_n88l25_s4567" }, 728 { .name = "kbl_n88l25_s4567" }, 729 { } 730 }; 731 MODULE_DEVICE_TABLE(platform, skl_board_ids); 732 733 static struct platform_driver skylake_audio = { 734 .probe = skylake_audio_probe, 735 .driver = { 736 .name = "skl_n88l25_s4567", 737 .pm = &snd_soc_pm_ops, 738 }, 739 .id_table = skl_board_ids, 740 }; 741 742 module_platform_driver(skylake_audio) 743 744 /* Module information */ 745 MODULE_AUTHOR("Conrad Cooke <conrad.cooke@intel.com>"); 746 MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>"); 747 MODULE_AUTHOR("Naveen M <naveen.m@intel.com>"); 748 MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>"); 749 MODULE_AUTHOR("Yong Zhi <yong.zhi@intel.com>"); 750 MODULE_DESCRIPTION("Intel Audio Machine driver for SKL with NAU88L25 and SSM4567 in I2S Mode"); 751 MODULE_LICENSE("GPL v2"); 752