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