Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Intel Broxton-P I2S Machine Driver
0004  *
0005  * Copyright (C) 2014-2016, Intel Corporation. All rights reserved.
0006  *
0007  * Modified from:
0008  *   Intel Skylake I2S Machine driver
0009  */
0010 
0011 #include <linux/module.h>
0012 #include <linux/platform_device.h>
0013 #include <sound/core.h>
0014 #include <sound/pcm.h>
0015 #include <sound/soc.h>
0016 #include <sound/soc-acpi.h>
0017 #include <sound/jack.h>
0018 #include <sound/pcm_params.h>
0019 #include "../../codecs/hdac_hdmi.h"
0020 #include "../../codecs/rt298.h"
0021 #include "hda_dsp_common.h"
0022 
0023 /* Headset jack detection DAPM pins */
0024 static struct snd_soc_jack broxton_headset;
0025 static struct snd_soc_jack broxton_hdmi[3];
0026 
0027 struct bxt_hdmi_pcm {
0028     struct list_head head;
0029     struct snd_soc_dai *codec_dai;
0030     int device;
0031 };
0032 
0033 struct bxt_rt286_private {
0034     struct list_head hdmi_pcm_list;
0035     bool common_hdmi_codec_drv;
0036 };
0037 
0038 enum {
0039     BXT_DPCM_AUDIO_PB = 0,
0040     BXT_DPCM_AUDIO_CP,
0041     BXT_DPCM_AUDIO_REF_CP,
0042     BXT_DPCM_AUDIO_DMIC_CP,
0043     BXT_DPCM_AUDIO_HDMI1_PB,
0044     BXT_DPCM_AUDIO_HDMI2_PB,
0045     BXT_DPCM_AUDIO_HDMI3_PB,
0046 };
0047 
0048 static struct snd_soc_jack_pin broxton_headset_pins[] = {
0049     {
0050         .pin = "Mic Jack",
0051         .mask = SND_JACK_MICROPHONE,
0052     },
0053     {
0054         .pin = "Headphone Jack",
0055         .mask = SND_JACK_HEADPHONE,
0056     },
0057 };
0058 
0059 static const struct snd_kcontrol_new broxton_controls[] = {
0060     SOC_DAPM_PIN_SWITCH("Speaker"),
0061     SOC_DAPM_PIN_SWITCH("Headphone Jack"),
0062     SOC_DAPM_PIN_SWITCH("Mic Jack"),
0063 };
0064 
0065 static const struct snd_soc_dapm_widget broxton_widgets[] = {
0066     SND_SOC_DAPM_HP("Headphone Jack", NULL),
0067     SND_SOC_DAPM_SPK("Speaker", NULL),
0068     SND_SOC_DAPM_MIC("Mic Jack", NULL),
0069     SND_SOC_DAPM_MIC("DMIC2", NULL),
0070     SND_SOC_DAPM_MIC("SoC DMIC", NULL),
0071     SND_SOC_DAPM_SPK("HDMI1", NULL),
0072     SND_SOC_DAPM_SPK("HDMI2", NULL),
0073     SND_SOC_DAPM_SPK("HDMI3", NULL),
0074 };
0075 
0076 static const struct snd_soc_dapm_route broxton_rt298_map[] = {
0077     /* speaker */
0078     {"Speaker", NULL, "SPOR"},
0079     {"Speaker", NULL, "SPOL"},
0080 
0081     /* HP jack connectors - unknown if we have jack detect */
0082     {"Headphone Jack", NULL, "HPO Pin"},
0083 
0084     /* other jacks */
0085     {"MIC1", NULL, "Mic Jack"},
0086 
0087     /* digital mics */
0088     {"DMIC1 Pin", NULL, "DMIC2"},
0089     {"DMic", NULL, "SoC DMIC"},
0090 
0091     {"HDMI1", NULL, "hif5-0 Output"},
0092     {"HDMI2", NULL, "hif6-0 Output"},
0093     {"HDMI2", NULL, "hif7-0 Output"},
0094 
0095     /* CODEC BE connections */
0096     { "AIF1 Playback", NULL, "ssp5 Tx"},
0097     { "ssp5 Tx", NULL, "codec0_out"},
0098     { "ssp5 Tx", NULL, "codec1_out"},
0099 
0100     { "codec0_in", NULL, "ssp5 Rx" },
0101     { "ssp5 Rx", NULL, "AIF1 Capture" },
0102 
0103     { "dmic01_hifi", NULL, "DMIC01 Rx" },
0104     { "DMIC01 Rx", NULL, "Capture" },
0105 
0106     { "hifi3", NULL, "iDisp3 Tx"},
0107     { "iDisp3 Tx", NULL, "iDisp3_out"},
0108     { "hifi2", NULL, "iDisp2 Tx"},
0109     { "iDisp2 Tx", NULL, "iDisp2_out"},
0110     { "hifi1", NULL, "iDisp1 Tx"},
0111     { "iDisp1 Tx", NULL, "iDisp1_out"},
0112 };
0113 
0114 static const struct snd_soc_dapm_route geminilake_rt298_map[] = {
0115     /* speaker */
0116     {"Speaker", NULL, "SPOR"},
0117     {"Speaker", NULL, "SPOL"},
0118 
0119     /* HP jack connectors - unknown if we have jack detect */
0120     {"Headphone Jack", NULL, "HPO Pin"},
0121 
0122     /* other jacks */
0123     {"MIC1", NULL, "Mic Jack"},
0124 
0125     /* digital mics */
0126     {"DMIC1 Pin", NULL, "DMIC2"},
0127     {"DMic", NULL, "SoC DMIC"},
0128 
0129     {"HDMI1", NULL, "hif5-0 Output"},
0130     {"HDMI2", NULL, "hif6-0 Output"},
0131     {"HDMI2", NULL, "hif7-0 Output"},
0132 
0133     /* CODEC BE connections */
0134     { "AIF1 Playback", NULL, "ssp2 Tx"},
0135     { "ssp2 Tx", NULL, "codec0_out"},
0136     { "ssp2 Tx", NULL, "codec1_out"},
0137 
0138     { "codec0_in", NULL, "ssp2 Rx" },
0139     { "ssp2 Rx", NULL, "AIF1 Capture" },
0140 
0141     { "dmic01_hifi", NULL, "DMIC01 Rx" },
0142     { "DMIC01 Rx", NULL, "Capture" },
0143 
0144     { "dmic_voice", NULL, "DMIC16k Rx" },
0145     { "DMIC16k Rx", NULL, "Capture" },
0146 
0147     { "hifi3", NULL, "iDisp3 Tx"},
0148     { "iDisp3 Tx", NULL, "iDisp3_out"},
0149     { "hifi2", NULL, "iDisp2 Tx"},
0150     { "iDisp2 Tx", NULL, "iDisp2_out"},
0151     { "hifi1", NULL, "iDisp1 Tx"},
0152     { "iDisp1 Tx", NULL, "iDisp1_out"},
0153 };
0154 
0155 static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd)
0156 {
0157     struct snd_soc_dapm_context *dapm;
0158     struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
0159 
0160     dapm = snd_soc_component_get_dapm(component);
0161     snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
0162 
0163     return 0;
0164 }
0165 
0166 static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd)
0167 {
0168     struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
0169     int ret = 0;
0170 
0171     ret = snd_soc_card_jack_new_pins(rtd->card, "Headset",
0172         SND_JACK_HEADSET | SND_JACK_BTN_0,
0173         &broxton_headset,
0174         broxton_headset_pins, ARRAY_SIZE(broxton_headset_pins));
0175 
0176     if (ret)
0177         return ret;
0178 
0179     snd_soc_component_set_jack(component, &broxton_headset, NULL);
0180 
0181     snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
0182 
0183     return 0;
0184 }
0185 
0186 static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
0187 {
0188     struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(rtd->card);
0189     struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
0190     struct bxt_hdmi_pcm *pcm;
0191 
0192     pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
0193     if (!pcm)
0194         return -ENOMEM;
0195 
0196     pcm->device = BXT_DPCM_AUDIO_HDMI1_PB + dai->id;
0197     pcm->codec_dai = dai;
0198 
0199     list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
0200 
0201     return 0;
0202 }
0203 
0204 static int broxton_ssp5_fixup(struct snd_soc_pcm_runtime *rtd,
0205             struct snd_pcm_hw_params *params)
0206 {
0207     struct snd_interval *rate = hw_param_interval(params,
0208                     SNDRV_PCM_HW_PARAM_RATE);
0209     struct snd_interval *chan = hw_param_interval(params,
0210                     SNDRV_PCM_HW_PARAM_CHANNELS);
0211     struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
0212 
0213     /* The ADSP will covert the FE rate to 48k, stereo */
0214     rate->min = rate->max = 48000;
0215     chan->min = chan->max = 2;
0216 
0217     /* set SSP5 to 24 bit */
0218     snd_mask_none(fmt);
0219     snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
0220 
0221     return 0;
0222 }
0223 
0224 static int broxton_rt298_hw_params(struct snd_pcm_substream *substream,
0225     struct snd_pcm_hw_params *params)
0226 {
0227     struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
0228     struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
0229     int ret;
0230 
0231     ret = snd_soc_dai_set_sysclk(codec_dai, RT298_SCLK_S_PLL,
0232                     19200000, SND_SOC_CLOCK_IN);
0233     if (ret < 0) {
0234         dev_err(rtd->dev, "can't set codec sysclk configuration\n");
0235         return ret;
0236     }
0237 
0238     return ret;
0239 }
0240 
0241 static const struct snd_soc_ops broxton_rt298_ops = {
0242     .hw_params = broxton_rt298_hw_params,
0243 };
0244 
0245 static const unsigned int rates[] = {
0246     48000,
0247 };
0248 
0249 static const struct snd_pcm_hw_constraint_list constraints_rates = {
0250     .count = ARRAY_SIZE(rates),
0251     .list  = rates,
0252     .mask = 0,
0253 };
0254 
0255 static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
0256                 struct snd_pcm_hw_params *params)
0257 {
0258     struct snd_interval *chan = hw_param_interval(params,
0259                         SNDRV_PCM_HW_PARAM_CHANNELS);
0260     chan->min = chan->max = 4;
0261 
0262     return 0;
0263 }
0264 
0265 static const unsigned int channels_dmic[] = {
0266     1, 2, 3, 4,
0267 };
0268 
0269 static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
0270     .count = ARRAY_SIZE(channels_dmic),
0271     .list = channels_dmic,
0272     .mask = 0,
0273 };
0274 
0275 static int broxton_dmic_startup(struct snd_pcm_substream *substream)
0276 {
0277     struct snd_pcm_runtime *runtime = substream->runtime;
0278 
0279     runtime->hw.channels_max = 4;
0280     snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
0281                     &constraints_dmic_channels);
0282 
0283     return snd_pcm_hw_constraint_list(substream->runtime, 0,
0284                 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
0285 }
0286 
0287 static const struct snd_soc_ops broxton_dmic_ops = {
0288     .startup = broxton_dmic_startup,
0289 };
0290 
0291 static const unsigned int channels[] = {
0292     2,
0293 };
0294 
0295 static const struct snd_pcm_hw_constraint_list constraints_channels = {
0296     .count = ARRAY_SIZE(channels),
0297     .list = channels,
0298     .mask = 0,
0299 };
0300 
0301 static int bxt_fe_startup(struct snd_pcm_substream *substream)
0302 {
0303     struct snd_pcm_runtime *runtime = substream->runtime;
0304 
0305     /*
0306      * on this platform for PCM device we support:
0307      *      48Khz
0308      *      stereo
0309      *  16-bit audio
0310      */
0311 
0312     runtime->hw.channels_max = 2;
0313     snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
0314                 &constraints_channels);
0315 
0316     runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
0317     snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
0318     snd_pcm_hw_constraint_list(runtime, 0,
0319                 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
0320 
0321     return 0;
0322 }
0323 
0324 static const struct snd_soc_ops broxton_rt286_fe_ops = {
0325     .startup = bxt_fe_startup,
0326 };
0327 
0328 SND_SOC_DAILINK_DEF(dummy,
0329     DAILINK_COMP_ARRAY(COMP_DUMMY()));
0330 
0331 SND_SOC_DAILINK_DEF(system,
0332     DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
0333 
0334 SND_SOC_DAILINK_DEF(reference,
0335     DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
0336 
0337 SND_SOC_DAILINK_DEF(dmic,
0338     DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
0339 
0340 SND_SOC_DAILINK_DEF(hdmi1,
0341     DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
0342 
0343 SND_SOC_DAILINK_DEF(hdmi2,
0344     DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
0345 
0346 SND_SOC_DAILINK_DEF(hdmi3,
0347     DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
0348 
0349 SND_SOC_DAILINK_DEF(ssp5_pin,
0350     DAILINK_COMP_ARRAY(COMP_CPU("SSP5 Pin")));
0351 SND_SOC_DAILINK_DEF(ssp5_codec,
0352     DAILINK_COMP_ARRAY(COMP_CODEC("i2c-INT343A:00",
0353                       "rt298-aif1")));
0354 
0355 SND_SOC_DAILINK_DEF(dmic_pin,
0356     DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
0357 
0358 SND_SOC_DAILINK_DEF(dmic_codec,
0359     DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec",
0360                       "dmic-hifi")));
0361 
0362 SND_SOC_DAILINK_DEF(dmic16k,
0363     DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));
0364 
0365 SND_SOC_DAILINK_DEF(idisp1_pin,
0366     DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
0367 SND_SOC_DAILINK_DEF(idisp1_codec,
0368     DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
0369                       "intel-hdmi-hifi1")));
0370 
0371 SND_SOC_DAILINK_DEF(idisp2_pin,
0372     DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
0373 SND_SOC_DAILINK_DEF(idisp2_codec,
0374     DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
0375                       "intel-hdmi-hifi2")));
0376 
0377 SND_SOC_DAILINK_DEF(idisp3_pin,
0378     DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
0379 SND_SOC_DAILINK_DEF(idisp3_codec,
0380     DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
0381                       "intel-hdmi-hifi3")));
0382 
0383 SND_SOC_DAILINK_DEF(platform,
0384     DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:0e.0")));
0385 
0386 /* broxton digital audio interface glue - connects codec <--> CPU */
0387 static struct snd_soc_dai_link broxton_rt298_dais[] = {
0388     /* Front End DAI links */
0389     [BXT_DPCM_AUDIO_PB] =
0390     {
0391         .name = "Bxt Audio Port",
0392         .stream_name = "Audio",
0393         .nonatomic = 1,
0394         .dynamic = 1,
0395         .init = broxton_rt298_fe_init,
0396         .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
0397         .dpcm_playback = 1,
0398         .ops = &broxton_rt286_fe_ops,
0399         SND_SOC_DAILINK_REG(system, dummy, platform),
0400     },
0401     [BXT_DPCM_AUDIO_CP] =
0402     {
0403         .name = "Bxt Audio Capture Port",
0404         .stream_name = "Audio Record",
0405         .nonatomic = 1,
0406         .dynamic = 1,
0407         .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
0408         .dpcm_capture = 1,
0409         .ops = &broxton_rt286_fe_ops,
0410         SND_SOC_DAILINK_REG(system, dummy, platform),
0411     },
0412     [BXT_DPCM_AUDIO_REF_CP] =
0413     {
0414         .name = "Bxt Audio Reference cap",
0415         .stream_name = "refcap",
0416         .init = NULL,
0417         .dpcm_capture = 1,
0418         .nonatomic = 1,
0419         .dynamic = 1,
0420         SND_SOC_DAILINK_REG(reference, dummy, platform),
0421     },
0422     [BXT_DPCM_AUDIO_DMIC_CP] =
0423     {
0424         .name = "Bxt Audio DMIC cap",
0425         .stream_name = "dmiccap",
0426         .init = NULL,
0427         .dpcm_capture = 1,
0428         .nonatomic = 1,
0429         .dynamic = 1,
0430         .ops = &broxton_dmic_ops,
0431         SND_SOC_DAILINK_REG(dmic, dummy, platform),
0432     },
0433     [BXT_DPCM_AUDIO_HDMI1_PB] =
0434     {
0435         .name = "Bxt HDMI Port1",
0436         .stream_name = "Hdmi1",
0437         .dpcm_playback = 1,
0438         .init = NULL,
0439         .nonatomic = 1,
0440         .dynamic = 1,
0441         SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
0442     },
0443     [BXT_DPCM_AUDIO_HDMI2_PB] =
0444     {
0445         .name = "Bxt HDMI Port2",
0446         .stream_name = "Hdmi2",
0447         .dpcm_playback = 1,
0448         .init = NULL,
0449         .nonatomic = 1,
0450         .dynamic = 1,
0451         SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
0452     },
0453     [BXT_DPCM_AUDIO_HDMI3_PB] =
0454     {
0455         .name = "Bxt HDMI Port3",
0456         .stream_name = "Hdmi3",
0457         .dpcm_playback = 1,
0458         .init = NULL,
0459         .nonatomic = 1,
0460         .dynamic = 1,
0461         SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
0462     },
0463     /* Back End DAI links */
0464     {
0465         /* SSP5 - Codec */
0466         .name = "SSP5-Codec",
0467         .id = 0,
0468         .no_pcm = 1,
0469         .init = broxton_rt298_codec_init,
0470         .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF |
0471                         SND_SOC_DAIFMT_CBC_CFC,
0472         .ignore_pmdown_time = 1,
0473         .be_hw_params_fixup = broxton_ssp5_fixup,
0474         .ops = &broxton_rt298_ops,
0475         .dpcm_playback = 1,
0476         .dpcm_capture = 1,
0477         SND_SOC_DAILINK_REG(ssp5_pin, ssp5_codec, platform),
0478     },
0479     {
0480         .name = "dmic01",
0481         .id = 1,
0482         .be_hw_params_fixup = broxton_dmic_fixup,
0483         .ignore_suspend = 1,
0484         .dpcm_capture = 1,
0485         .no_pcm = 1,
0486         SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
0487     },
0488     {
0489         .name = "dmic16k",
0490         .id = 2,
0491         .be_hw_params_fixup = broxton_dmic_fixup,
0492         .ignore_suspend = 1,
0493         .dpcm_capture = 1,
0494         .no_pcm = 1,
0495         SND_SOC_DAILINK_REG(dmic16k, dmic_codec, platform),
0496     },
0497     {
0498         .name = "iDisp1",
0499         .id = 3,
0500         .init = broxton_hdmi_init,
0501         .dpcm_playback = 1,
0502         .no_pcm = 1,
0503         SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
0504     },
0505     {
0506         .name = "iDisp2",
0507         .id = 4,
0508         .init = broxton_hdmi_init,
0509         .dpcm_playback = 1,
0510         .no_pcm = 1,
0511         SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
0512     },
0513     {
0514         .name = "iDisp3",
0515         .id = 5,
0516         .init = broxton_hdmi_init,
0517         .dpcm_playback = 1,
0518         .no_pcm = 1,
0519         SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
0520     },
0521 };
0522 
0523 #define NAME_SIZE   32
0524 static int bxt_card_late_probe(struct snd_soc_card *card)
0525 {
0526     struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card);
0527     struct bxt_hdmi_pcm *pcm;
0528     struct snd_soc_component *component = NULL;
0529     int err, i = 0;
0530     char jack_name[NAME_SIZE];
0531 
0532     if (list_empty(&ctx->hdmi_pcm_list))
0533         return -EINVAL;
0534 
0535     if (ctx->common_hdmi_codec_drv) {
0536         pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
0537                        head);
0538         component = pcm->codec_dai->component;
0539         return hda_dsp_hdmi_build_controls(card, component);
0540     }
0541 
0542     list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
0543         component = pcm->codec_dai->component;
0544         snprintf(jack_name, sizeof(jack_name),
0545             "HDMI/DP, pcm=%d Jack", pcm->device);
0546         err = snd_soc_card_jack_new(card, jack_name,
0547                     SND_JACK_AVOUT, &broxton_hdmi[i]);
0548 
0549         if (err)
0550             return err;
0551 
0552         err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
0553                         &broxton_hdmi[i]);
0554         if (err < 0)
0555             return err;
0556 
0557         i++;
0558     }
0559 
0560     return hdac_hdmi_jack_port_init(component, &card->dapm);
0561 }
0562 
0563 
0564 /* broxton audio machine driver for SPT + RT298S */
0565 static struct snd_soc_card broxton_rt298 = {
0566     .name = "broxton-rt298",
0567     .owner = THIS_MODULE,
0568     .dai_link = broxton_rt298_dais,
0569     .num_links = ARRAY_SIZE(broxton_rt298_dais),
0570     .controls = broxton_controls,
0571     .num_controls = ARRAY_SIZE(broxton_controls),
0572     .dapm_widgets = broxton_widgets,
0573     .num_dapm_widgets = ARRAY_SIZE(broxton_widgets),
0574     .dapm_routes = broxton_rt298_map,
0575     .num_dapm_routes = ARRAY_SIZE(broxton_rt298_map),
0576     .fully_routed = true,
0577     .late_probe = bxt_card_late_probe,
0578 
0579 };
0580 
0581 static struct snd_soc_card geminilake_rt298 = {
0582     .name = "geminilake-rt298",
0583     .owner = THIS_MODULE,
0584     .dai_link = broxton_rt298_dais,
0585     .num_links = ARRAY_SIZE(broxton_rt298_dais),
0586     .controls = broxton_controls,
0587     .num_controls = ARRAY_SIZE(broxton_controls),
0588     .dapm_widgets = broxton_widgets,
0589     .num_dapm_widgets = ARRAY_SIZE(broxton_widgets),
0590     .dapm_routes = geminilake_rt298_map,
0591     .num_dapm_routes = ARRAY_SIZE(geminilake_rt298_map),
0592     .fully_routed = true,
0593     .late_probe = bxt_card_late_probe,
0594 };
0595 
0596 static int broxton_audio_probe(struct platform_device *pdev)
0597 {
0598     struct bxt_rt286_private *ctx;
0599     struct snd_soc_card *card =
0600             (struct snd_soc_card *)pdev->id_entry->driver_data;
0601     struct snd_soc_acpi_mach *mach;
0602     const char *platform_name;
0603     int ret;
0604     int i;
0605 
0606     for (i = 0; i < ARRAY_SIZE(broxton_rt298_dais); i++) {
0607         if (!strncmp(card->dai_link[i].codecs->name, "i2c-INT343A:00",
0608                  I2C_NAME_SIZE)) {
0609             if (!strncmp(card->name, "broxton-rt298",
0610                      PLATFORM_NAME_SIZE)) {
0611                 card->dai_link[i].name = "SSP5-Codec";
0612                 card->dai_link[i].cpus->dai_name = "SSP5 Pin";
0613             } else if (!strncmp(card->name, "geminilake-rt298",
0614                         PLATFORM_NAME_SIZE)) {
0615                 card->dai_link[i].name = "SSP2-Codec";
0616                 card->dai_link[i].cpus->dai_name = "SSP2 Pin";
0617             }
0618         }
0619     }
0620 
0621     ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
0622     if (!ctx)
0623         return -ENOMEM;
0624 
0625     INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
0626 
0627     card->dev = &pdev->dev;
0628     snd_soc_card_set_drvdata(card, ctx);
0629 
0630     /* override platform name, if required */
0631     mach = pdev->dev.platform_data;
0632     platform_name = mach->mach_params.platform;
0633 
0634     ret = snd_soc_fixup_dai_links_platform_name(card,
0635                             platform_name);
0636     if (ret)
0637         return ret;
0638 
0639     ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
0640 
0641     return devm_snd_soc_register_card(&pdev->dev, card);
0642 }
0643 
0644 static const struct platform_device_id bxt_board_ids[] = {
0645     { .name = "bxt_alc298s_i2s", .driver_data =
0646                 (unsigned long)&broxton_rt298 },
0647     { .name = "glk_alc298s_i2s", .driver_data =
0648                 (unsigned long)&geminilake_rt298 },
0649     {}
0650 };
0651 MODULE_DEVICE_TABLE(platform, bxt_board_ids);
0652 
0653 static struct platform_driver broxton_audio = {
0654     .probe = broxton_audio_probe,
0655     .driver = {
0656         .name = "bxt_alc298s_i2s",
0657         .pm = &snd_soc_pm_ops,
0658     },
0659     .id_table = bxt_board_ids,
0660 };
0661 module_platform_driver(broxton_audio)
0662 
0663 /* Module information */
0664 MODULE_AUTHOR("Ramesh Babu <Ramesh.Babu@intel.com>");
0665 MODULE_AUTHOR("Senthilnathan Veppur <senthilnathanx.veppur@intel.com>");
0666 MODULE_DESCRIPTION("Intel SST Audio for Broxton");
0667 MODULE_LICENSE("GPL v2");
0668 MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);