11802d0beSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
276016322SRamesh Babu /*
376016322SRamesh Babu * Intel Broxton-P I2S Machine Driver
476016322SRamesh Babu *
576016322SRamesh Babu * Copyright (C) 2014-2016, Intel Corporation. All rights reserved.
676016322SRamesh Babu *
776016322SRamesh Babu * Modified from:
876016322SRamesh Babu * Intel Skylake I2S Machine driver
976016322SRamesh Babu */
1076016322SRamesh Babu
1176016322SRamesh Babu #include <linux/module.h>
1276016322SRamesh Babu #include <linux/platform_device.h>
1376016322SRamesh Babu #include <sound/core.h>
1476016322SRamesh Babu #include <sound/pcm.h>
1576016322SRamesh Babu #include <sound/soc.h>
16fbe2c273SPierre-Louis Bossart #include <sound/soc-acpi.h>
1776016322SRamesh Babu #include <sound/jack.h>
1876016322SRamesh Babu #include <sound/pcm_params.h>
1976016322SRamesh Babu #include "../../codecs/hdac_hdmi.h"
2076016322SRamesh Babu #include "../../codecs/rt298.h"
217d2ae583SKai Vehmanen #include "hda_dsp_common.h"
2276016322SRamesh Babu
2376016322SRamesh Babu /* Headset jack detection DAPM pins */
2451e0f3c8SJeeja KP static struct snd_soc_jack broxton_headset;
257932b8acSJeeja KP static struct snd_soc_jack broxton_hdmi[3];
2651e0f3c8SJeeja KP
2751e0f3c8SJeeja KP struct bxt_hdmi_pcm {
2851e0f3c8SJeeja KP struct list_head head;
2951e0f3c8SJeeja KP struct snd_soc_dai *codec_dai;
3051e0f3c8SJeeja KP int device;
3151e0f3c8SJeeja KP };
3251e0f3c8SJeeja KP
3351e0f3c8SJeeja KP struct bxt_rt286_private {
3451e0f3c8SJeeja KP struct list_head hdmi_pcm_list;
357d2ae583SKai Vehmanen bool common_hdmi_codec_drv;
3651e0f3c8SJeeja KP };
3776016322SRamesh Babu
3876016322SRamesh Babu enum {
3976016322SRamesh Babu BXT_DPCM_AUDIO_PB = 0,
4076016322SRamesh Babu BXT_DPCM_AUDIO_CP,
4176016322SRamesh Babu BXT_DPCM_AUDIO_REF_CP,
42bfcdc6d1SSenthilnathan Veppur BXT_DPCM_AUDIO_DMIC_CP,
4376016322SRamesh Babu BXT_DPCM_AUDIO_HDMI1_PB,
4476016322SRamesh Babu BXT_DPCM_AUDIO_HDMI2_PB,
4576016322SRamesh Babu BXT_DPCM_AUDIO_HDMI3_PB,
4676016322SRamesh Babu };
4776016322SRamesh Babu
4876016322SRamesh Babu static struct snd_soc_jack_pin broxton_headset_pins[] = {
4976016322SRamesh Babu {
5076016322SRamesh Babu .pin = "Mic Jack",
5176016322SRamesh Babu .mask = SND_JACK_MICROPHONE,
5276016322SRamesh Babu },
5376016322SRamesh Babu {
5476016322SRamesh Babu .pin = "Headphone Jack",
5576016322SRamesh Babu .mask = SND_JACK_HEADPHONE,
5676016322SRamesh Babu },
5776016322SRamesh Babu };
5876016322SRamesh Babu
5976016322SRamesh Babu static const struct snd_kcontrol_new broxton_controls[] = {
6076016322SRamesh Babu SOC_DAPM_PIN_SWITCH("Speaker"),
6176016322SRamesh Babu SOC_DAPM_PIN_SWITCH("Headphone Jack"),
6276016322SRamesh Babu SOC_DAPM_PIN_SWITCH("Mic Jack"),
6376016322SRamesh Babu };
6476016322SRamesh Babu
6576016322SRamesh Babu static const struct snd_soc_dapm_widget broxton_widgets[] = {
6676016322SRamesh Babu SND_SOC_DAPM_HP("Headphone Jack", NULL),
6776016322SRamesh Babu SND_SOC_DAPM_SPK("Speaker", NULL),
6876016322SRamesh Babu SND_SOC_DAPM_MIC("Mic Jack", NULL),
6976016322SRamesh Babu SND_SOC_DAPM_MIC("DMIC2", NULL),
7076016322SRamesh Babu SND_SOC_DAPM_MIC("SoC DMIC", NULL),
7176016322SRamesh Babu SND_SOC_DAPM_SPK("HDMI1", NULL),
7276016322SRamesh Babu SND_SOC_DAPM_SPK("HDMI2", NULL),
7376016322SRamesh Babu SND_SOC_DAPM_SPK("HDMI3", NULL),
7476016322SRamesh Babu };
7576016322SRamesh Babu
7676016322SRamesh Babu static const struct snd_soc_dapm_route broxton_rt298_map[] = {
7776016322SRamesh Babu /* speaker */
7876016322SRamesh Babu {"Speaker", NULL, "SPOR"},
7976016322SRamesh Babu {"Speaker", NULL, "SPOL"},
8076016322SRamesh Babu
8176016322SRamesh Babu /* HP jack connectors - unknown if we have jack detect */
8276016322SRamesh Babu {"Headphone Jack", NULL, "HPO Pin"},
8376016322SRamesh Babu
8476016322SRamesh Babu /* other jacks */
8576016322SRamesh Babu {"MIC1", NULL, "Mic Jack"},
8676016322SRamesh Babu
8776016322SRamesh Babu /* digital mics */
8876016322SRamesh Babu {"DMIC1 Pin", NULL, "DMIC2"},
8976016322SRamesh Babu {"DMic", NULL, "SoC DMIC"},
9076016322SRamesh Babu
91eaba3103SJeeja KP {"HDMI1", NULL, "hif5-0 Output"},
92eaba3103SJeeja KP {"HDMI2", NULL, "hif6-0 Output"},
93eaba3103SJeeja KP {"HDMI2", NULL, "hif7-0 Output"},
9476016322SRamesh Babu
9576016322SRamesh Babu /* CODEC BE connections */
9676016322SRamesh Babu { "AIF1 Playback", NULL, "ssp5 Tx"},
9776016322SRamesh Babu { "ssp5 Tx", NULL, "codec0_out"},
98bfcdc6d1SSenthilnathan Veppur { "ssp5 Tx", NULL, "codec1_out"},
9976016322SRamesh Babu
10076016322SRamesh Babu { "codec0_in", NULL, "ssp5 Rx" },
10176016322SRamesh Babu { "ssp5 Rx", NULL, "AIF1 Capture" },
10276016322SRamesh Babu
10376016322SRamesh Babu { "dmic01_hifi", NULL, "DMIC01 Rx" },
10476016322SRamesh Babu { "DMIC01 Rx", NULL, "Capture" },
10576016322SRamesh Babu
10676016322SRamesh Babu { "hifi3", NULL, "iDisp3 Tx"},
10776016322SRamesh Babu { "iDisp3 Tx", NULL, "iDisp3_out"},
10876016322SRamesh Babu { "hifi2", NULL, "iDisp2 Tx"},
10976016322SRamesh Babu { "iDisp2 Tx", NULL, "iDisp2_out"},
11076016322SRamesh Babu { "hifi1", NULL, "iDisp1 Tx"},
11176016322SRamesh Babu { "iDisp1 Tx", NULL, "iDisp1_out"},
112669eb871SPradeep Tewani };
11376016322SRamesh Babu
114669eb871SPradeep Tewani static const struct snd_soc_dapm_route geminilake_rt298_map[] = {
115669eb871SPradeep Tewani /* speaker */
116669eb871SPradeep Tewani {"Speaker", NULL, "SPOR"},
117669eb871SPradeep Tewani {"Speaker", NULL, "SPOL"},
118669eb871SPradeep Tewani
119669eb871SPradeep Tewani /* HP jack connectors - unknown if we have jack detect */
120669eb871SPradeep Tewani {"Headphone Jack", NULL, "HPO Pin"},
121669eb871SPradeep Tewani
122669eb871SPradeep Tewani /* other jacks */
123669eb871SPradeep Tewani {"MIC1", NULL, "Mic Jack"},
124669eb871SPradeep Tewani
125669eb871SPradeep Tewani /* digital mics */
126669eb871SPradeep Tewani {"DMIC1 Pin", NULL, "DMIC2"},
127669eb871SPradeep Tewani {"DMic", NULL, "SoC DMIC"},
128669eb871SPradeep Tewani
129669eb871SPradeep Tewani {"HDMI1", NULL, "hif5-0 Output"},
130669eb871SPradeep Tewani {"HDMI2", NULL, "hif6-0 Output"},
131669eb871SPradeep Tewani {"HDMI2", NULL, "hif7-0 Output"},
132669eb871SPradeep Tewani
133669eb871SPradeep Tewani /* CODEC BE connections */
134669eb871SPradeep Tewani { "AIF1 Playback", NULL, "ssp2 Tx"},
135669eb871SPradeep Tewani { "ssp2 Tx", NULL, "codec0_out"},
136669eb871SPradeep Tewani { "ssp2 Tx", NULL, "codec1_out"},
137669eb871SPradeep Tewani
138669eb871SPradeep Tewani { "codec0_in", NULL, "ssp2 Rx" },
139669eb871SPradeep Tewani { "ssp2 Rx", NULL, "AIF1 Capture" },
140669eb871SPradeep Tewani
141669eb871SPradeep Tewani { "dmic01_hifi", NULL, "DMIC01 Rx" },
142669eb871SPradeep Tewani { "DMIC01 Rx", NULL, "Capture" },
143669eb871SPradeep Tewani
1448913f97dSPawse, GuruprasadX { "dmic_voice", NULL, "DMIC16k Rx" },
1458913f97dSPawse, GuruprasadX { "DMIC16k Rx", NULL, "Capture" },
1468913f97dSPawse, GuruprasadX
147669eb871SPradeep Tewani { "hifi3", NULL, "iDisp3 Tx"},
148669eb871SPradeep Tewani { "iDisp3 Tx", NULL, "iDisp3_out"},
149669eb871SPradeep Tewani { "hifi2", NULL, "iDisp2 Tx"},
150669eb871SPradeep Tewani { "iDisp2 Tx", NULL, "iDisp2_out"},
151669eb871SPradeep Tewani { "hifi1", NULL, "iDisp1 Tx"},
152669eb871SPradeep Tewani { "iDisp1 Tx", NULL, "iDisp1_out"},
15376016322SRamesh Babu };
15476016322SRamesh Babu
broxton_rt298_fe_init(struct snd_soc_pcm_runtime * rtd)155316f135aSSenthilnathan Veppur static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd)
156316f135aSSenthilnathan Veppur {
157316f135aSSenthilnathan Veppur struct snd_soc_dapm_context *dapm;
1580d1571c1SKuninori Morimoto struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
159316f135aSSenthilnathan Veppur
160316f135aSSenthilnathan Veppur dapm = snd_soc_component_get_dapm(component);
161316f135aSSenthilnathan Veppur snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
162316f135aSSenthilnathan Veppur
163316f135aSSenthilnathan Veppur return 0;
164316f135aSSenthilnathan Veppur }
165316f135aSSenthilnathan Veppur
broxton_rt298_codec_init(struct snd_soc_pcm_runtime * rtd)16676016322SRamesh Babu static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd)
16776016322SRamesh Babu {
1680d1571c1SKuninori Morimoto struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
16976016322SRamesh Babu int ret = 0;
17076016322SRamesh Babu
17119aed2d6SAkihiko Odaki ret = snd_soc_card_jack_new_pins(rtd->card, "Headset",
17276016322SRamesh Babu SND_JACK_HEADSET | SND_JACK_BTN_0,
17376016322SRamesh Babu &broxton_headset,
17476016322SRamesh Babu broxton_headset_pins, ARRAY_SIZE(broxton_headset_pins));
17576016322SRamesh Babu
17676016322SRamesh Babu if (ret)
17776016322SRamesh Babu return ret;
17876016322SRamesh Babu
1791eb73102SCezary Rojewski snd_soc_component_set_jack(component, &broxton_headset, NULL);
180316f135aSSenthilnathan Veppur
181316f135aSSenthilnathan Veppur snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
182316f135aSSenthilnathan Veppur
18376016322SRamesh Babu return 0;
18476016322SRamesh Babu }
18576016322SRamesh Babu
broxton_hdmi_init(struct snd_soc_pcm_runtime * rtd)18676016322SRamesh Babu static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
18776016322SRamesh Babu {
18851e0f3c8SJeeja KP struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(rtd->card);
1890d1571c1SKuninori Morimoto struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
19051e0f3c8SJeeja KP struct bxt_hdmi_pcm *pcm;
19176016322SRamesh Babu
19251e0f3c8SJeeja KP pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
19351e0f3c8SJeeja KP if (!pcm)
19451e0f3c8SJeeja KP return -ENOMEM;
19551e0f3c8SJeeja KP
19651e0f3c8SJeeja KP pcm->device = BXT_DPCM_AUDIO_HDMI1_PB + dai->id;
19751e0f3c8SJeeja KP pcm->codec_dai = dai;
19851e0f3c8SJeeja KP
19951e0f3c8SJeeja KP list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
20051e0f3c8SJeeja KP
20151e0f3c8SJeeja KP return 0;
20276016322SRamesh Babu }
20376016322SRamesh Babu
broxton_ssp5_fixup(struct snd_soc_pcm_runtime * rtd,struct snd_pcm_hw_params * params)20476016322SRamesh Babu static int broxton_ssp5_fixup(struct snd_soc_pcm_runtime *rtd,
20576016322SRamesh Babu struct snd_pcm_hw_params *params)
20676016322SRamesh Babu {
20776016322SRamesh Babu struct snd_interval *rate = hw_param_interval(params,
20876016322SRamesh Babu SNDRV_PCM_HW_PARAM_RATE);
209c1b76536SPierre-Louis Bossart struct snd_interval *chan = hw_param_interval(params,
21076016322SRamesh Babu SNDRV_PCM_HW_PARAM_CHANNELS);
21176016322SRamesh Babu struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
21276016322SRamesh Babu
2134088355aSAmadeusz Sławiński /* The ADSP will convert the FE rate to 48k, stereo */
21476016322SRamesh Babu rate->min = rate->max = 48000;
215c1b76536SPierre-Louis Bossart chan->min = chan->max = 2;
21676016322SRamesh Babu
21776016322SRamesh Babu /* set SSP5 to 24 bit */
21876016322SRamesh Babu snd_mask_none(fmt);
219b5453e8cSTakashi Iwai snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
22076016322SRamesh Babu
22176016322SRamesh Babu return 0;
22276016322SRamesh Babu }
22376016322SRamesh Babu
broxton_rt298_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params)22476016322SRamesh Babu static int broxton_rt298_hw_params(struct snd_pcm_substream *substream,
22576016322SRamesh Babu struct snd_pcm_hw_params *params)
22676016322SRamesh Babu {
2272207b93bSKuninori Morimoto struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
2280d1571c1SKuninori Morimoto struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
22976016322SRamesh Babu int ret;
23076016322SRamesh Babu
23176016322SRamesh Babu ret = snd_soc_dai_set_sysclk(codec_dai, RT298_SCLK_S_PLL,
23276016322SRamesh Babu 19200000, SND_SOC_CLOCK_IN);
23376016322SRamesh Babu if (ret < 0) {
23476016322SRamesh Babu dev_err(rtd->dev, "can't set codec sysclk configuration\n");
23576016322SRamesh Babu return ret;
23676016322SRamesh Babu }
23776016322SRamesh Babu
23876016322SRamesh Babu return ret;
23976016322SRamesh Babu }
24076016322SRamesh Babu
2419b6fdef6SJulia Lawall static const struct snd_soc_ops broxton_rt298_ops = {
24276016322SRamesh Babu .hw_params = broxton_rt298_hw_params,
24376016322SRamesh Babu };
24476016322SRamesh Babu
24521031d53STakashi Iwai static const unsigned int rates[] = {
246bfcdc6d1SSenthilnathan Veppur 48000,
247bfcdc6d1SSenthilnathan Veppur };
248bfcdc6d1SSenthilnathan Veppur
24921031d53STakashi Iwai static const struct snd_pcm_hw_constraint_list constraints_rates = {
250bfcdc6d1SSenthilnathan Veppur .count = ARRAY_SIZE(rates),
251bfcdc6d1SSenthilnathan Veppur .list = rates,
252bfcdc6d1SSenthilnathan Veppur .mask = 0,
253bfcdc6d1SSenthilnathan Veppur };
254bfcdc6d1SSenthilnathan Veppur
broxton_dmic_fixup(struct snd_soc_pcm_runtime * rtd,struct snd_pcm_hw_params * params)255bfcdc6d1SSenthilnathan Veppur static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
256bfcdc6d1SSenthilnathan Veppur struct snd_pcm_hw_params *params)
257bfcdc6d1SSenthilnathan Veppur {
258c1b76536SPierre-Louis Bossart struct snd_interval *chan = hw_param_interval(params,
259bfcdc6d1SSenthilnathan Veppur SNDRV_PCM_HW_PARAM_CHANNELS);
260c1b76536SPierre-Louis Bossart chan->min = chan->max = 4;
261bfcdc6d1SSenthilnathan Veppur
262bfcdc6d1SSenthilnathan Veppur return 0;
263bfcdc6d1SSenthilnathan Veppur }
264bfcdc6d1SSenthilnathan Veppur
26521031d53STakashi Iwai static const unsigned int channels_dmic[] = {
266e8883cb6SDharageswari R 1, 2, 3, 4,
267bfcdc6d1SSenthilnathan Veppur };
268bfcdc6d1SSenthilnathan Veppur
26921031d53STakashi Iwai static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
270bfcdc6d1SSenthilnathan Veppur .count = ARRAY_SIZE(channels_dmic),
271bfcdc6d1SSenthilnathan Veppur .list = channels_dmic,
272bfcdc6d1SSenthilnathan Veppur .mask = 0,
273bfcdc6d1SSenthilnathan Veppur };
274bfcdc6d1SSenthilnathan Veppur
broxton_dmic_startup(struct snd_pcm_substream * substream)275bfcdc6d1SSenthilnathan Veppur static int broxton_dmic_startup(struct snd_pcm_substream *substream)
276bfcdc6d1SSenthilnathan Veppur {
277bfcdc6d1SSenthilnathan Veppur struct snd_pcm_runtime *runtime = substream->runtime;
278bfcdc6d1SSenthilnathan Veppur
279bfcdc6d1SSenthilnathan Veppur runtime->hw.channels_max = 4;
280bfcdc6d1SSenthilnathan Veppur snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
281bfcdc6d1SSenthilnathan Veppur &constraints_dmic_channels);
282bfcdc6d1SSenthilnathan Veppur
283bfcdc6d1SSenthilnathan Veppur return snd_pcm_hw_constraint_list(substream->runtime, 0,
284bfcdc6d1SSenthilnathan Veppur SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
285bfcdc6d1SSenthilnathan Veppur }
286bfcdc6d1SSenthilnathan Veppur
2879b6fdef6SJulia Lawall static const struct snd_soc_ops broxton_dmic_ops = {
288bfcdc6d1SSenthilnathan Veppur .startup = broxton_dmic_startup,
289bfcdc6d1SSenthilnathan Veppur };
290bfcdc6d1SSenthilnathan Veppur
29121031d53STakashi Iwai static const unsigned int channels[] = {
2924cdf33feSSenthilnathan Veppur 2,
2934cdf33feSSenthilnathan Veppur };
2944cdf33feSSenthilnathan Veppur
29521031d53STakashi Iwai static const struct snd_pcm_hw_constraint_list constraints_channels = {
2964cdf33feSSenthilnathan Veppur .count = ARRAY_SIZE(channels),
2974cdf33feSSenthilnathan Veppur .list = channels,
2984cdf33feSSenthilnathan Veppur .mask = 0,
2994cdf33feSSenthilnathan Veppur };
3004cdf33feSSenthilnathan Veppur
bxt_fe_startup(struct snd_pcm_substream * substream)3014cdf33feSSenthilnathan Veppur static int bxt_fe_startup(struct snd_pcm_substream *substream)
3024cdf33feSSenthilnathan Veppur {
3034cdf33feSSenthilnathan Veppur struct snd_pcm_runtime *runtime = substream->runtime;
3044cdf33feSSenthilnathan Veppur
3054cdf33feSSenthilnathan Veppur /*
3064cdf33feSSenthilnathan Veppur * on this platform for PCM device we support:
3074cdf33feSSenthilnathan Veppur * 48Khz
3084cdf33feSSenthilnathan Veppur * stereo
309e59ed087SG Kranthi * 16-bit audio
3104cdf33feSSenthilnathan Veppur */
3114cdf33feSSenthilnathan Veppur
3124cdf33feSSenthilnathan Veppur runtime->hw.channels_max = 2;
3134cdf33feSSenthilnathan Veppur snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
3144cdf33feSSenthilnathan Veppur &constraints_channels);
3154cdf33feSSenthilnathan Veppur
316e59ed087SG Kranthi runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
317e59ed087SG Kranthi snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
3184cdf33feSSenthilnathan Veppur snd_pcm_hw_constraint_list(runtime, 0,
3194cdf33feSSenthilnathan Veppur SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
3204cdf33feSSenthilnathan Veppur
3214cdf33feSSenthilnathan Veppur return 0;
3224cdf33feSSenthilnathan Veppur }
3234cdf33feSSenthilnathan Veppur
3244cdf33feSSenthilnathan Veppur static const struct snd_soc_ops broxton_rt286_fe_ops = {
3254cdf33feSSenthilnathan Veppur .startup = bxt_fe_startup,
3264cdf33feSSenthilnathan Veppur };
3274cdf33feSSenthilnathan Veppur
3285895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(dummy,
3295895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_DUMMY()));
3305895eb75SKuninori Morimoto
3315895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(system,
3325895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
3335895eb75SKuninori Morimoto
3345895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(reference,
3355895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
3365895eb75SKuninori Morimoto
3375895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(dmic,
3385895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
3395895eb75SKuninori Morimoto
3405895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(hdmi1,
3415895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
3425895eb75SKuninori Morimoto
3435895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(hdmi2,
3445895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
3455895eb75SKuninori Morimoto
3465895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(hdmi3,
3475895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
3485895eb75SKuninori Morimoto
3495895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(ssp5_pin,
3505895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("SSP5 Pin")));
3515895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(ssp5_codec,
3525895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CODEC("i2c-INT343A:00",
3535895eb75SKuninori Morimoto "rt298-aif1")));
3545895eb75SKuninori Morimoto
3555895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(dmic_pin,
3565895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
3575895eb75SKuninori Morimoto
3585895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(dmic_codec,
3595895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec",
3605895eb75SKuninori Morimoto "dmic-hifi")));
3615895eb75SKuninori Morimoto
3625895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(dmic16k,
3635895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));
3645895eb75SKuninori Morimoto
3655895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(idisp1_pin,
3665895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
3675895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(idisp1_codec,
3685895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
3695895eb75SKuninori Morimoto "intel-hdmi-hifi1")));
3705895eb75SKuninori Morimoto
3715895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(idisp2_pin,
3725895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
3735895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(idisp2_codec,
3745895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
3755895eb75SKuninori Morimoto "intel-hdmi-hifi2")));
3765895eb75SKuninori Morimoto
3775895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(idisp3_pin,
3785895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
3795895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(idisp3_codec,
3805895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
3815895eb75SKuninori Morimoto "intel-hdmi-hifi3")));
3825895eb75SKuninori Morimoto
3835895eb75SKuninori Morimoto SND_SOC_DAILINK_DEF(platform,
3845895eb75SKuninori Morimoto DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:0e.0")));
3855895eb75SKuninori Morimoto
38676016322SRamesh Babu /* broxton digital audio interface glue - connects codec <--> CPU */
38776016322SRamesh Babu static struct snd_soc_dai_link broxton_rt298_dais[] = {
38876016322SRamesh Babu /* Front End DAI links */
3895919a389STakashi Sakamoto [BXT_DPCM_AUDIO_PB] =
39076016322SRamesh Babu {
39176016322SRamesh Babu .name = "Bxt Audio Port",
39276016322SRamesh Babu .stream_name = "Audio",
39376016322SRamesh Babu .nonatomic = 1,
39476016322SRamesh Babu .dynamic = 1,
395316f135aSSenthilnathan Veppur .init = broxton_rt298_fe_init,
39676016322SRamesh Babu .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
39776016322SRamesh Babu .dpcm_playback = 1,
3984cdf33feSSenthilnathan Veppur .ops = &broxton_rt286_fe_ops,
3995895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(system, dummy, platform),
40076016322SRamesh Babu },
4015919a389STakashi Sakamoto [BXT_DPCM_AUDIO_CP] =
40276016322SRamesh Babu {
40376016322SRamesh Babu .name = "Bxt Audio Capture Port",
40476016322SRamesh Babu .stream_name = "Audio Record",
40576016322SRamesh Babu .nonatomic = 1,
40676016322SRamesh Babu .dynamic = 1,
40776016322SRamesh Babu .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
40876016322SRamesh Babu .dpcm_capture = 1,
4094cdf33feSSenthilnathan Veppur .ops = &broxton_rt286_fe_ops,
4105895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(system, dummy, platform),
41176016322SRamesh Babu },
4125919a389STakashi Sakamoto [BXT_DPCM_AUDIO_REF_CP] =
41376016322SRamesh Babu {
41476016322SRamesh Babu .name = "Bxt Audio Reference cap",
41576016322SRamesh Babu .stream_name = "refcap",
41676016322SRamesh Babu .init = NULL,
41776016322SRamesh Babu .dpcm_capture = 1,
41876016322SRamesh Babu .nonatomic = 1,
41976016322SRamesh Babu .dynamic = 1,
4205895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(reference, dummy, platform),
42176016322SRamesh Babu },
4225919a389STakashi Sakamoto [BXT_DPCM_AUDIO_DMIC_CP] =
423bfcdc6d1SSenthilnathan Veppur {
424bfcdc6d1SSenthilnathan Veppur .name = "Bxt Audio DMIC cap",
425bfcdc6d1SSenthilnathan Veppur .stream_name = "dmiccap",
426bfcdc6d1SSenthilnathan Veppur .init = NULL,
427bfcdc6d1SSenthilnathan Veppur .dpcm_capture = 1,
428bfcdc6d1SSenthilnathan Veppur .nonatomic = 1,
429bfcdc6d1SSenthilnathan Veppur .dynamic = 1,
430bfcdc6d1SSenthilnathan Veppur .ops = &broxton_dmic_ops,
4315895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(dmic, dummy, platform),
432bfcdc6d1SSenthilnathan Veppur },
4335919a389STakashi Sakamoto [BXT_DPCM_AUDIO_HDMI1_PB] =
43476016322SRamesh Babu {
43576016322SRamesh Babu .name = "Bxt HDMI Port1",
43676016322SRamesh Babu .stream_name = "Hdmi1",
43776016322SRamesh Babu .dpcm_playback = 1,
43876016322SRamesh Babu .init = NULL,
43976016322SRamesh Babu .nonatomic = 1,
44076016322SRamesh Babu .dynamic = 1,
4415895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
44276016322SRamesh Babu },
4435919a389STakashi Sakamoto [BXT_DPCM_AUDIO_HDMI2_PB] =
44476016322SRamesh Babu {
44576016322SRamesh Babu .name = "Bxt HDMI Port2",
44676016322SRamesh Babu .stream_name = "Hdmi2",
44776016322SRamesh Babu .dpcm_playback = 1,
44876016322SRamesh Babu .init = NULL,
44976016322SRamesh Babu .nonatomic = 1,
45076016322SRamesh Babu .dynamic = 1,
4515895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
45276016322SRamesh Babu },
4535919a389STakashi Sakamoto [BXT_DPCM_AUDIO_HDMI3_PB] =
45476016322SRamesh Babu {
45576016322SRamesh Babu .name = "Bxt HDMI Port3",
45676016322SRamesh Babu .stream_name = "Hdmi3",
45776016322SRamesh Babu .dpcm_playback = 1,
45876016322SRamesh Babu .init = NULL,
45976016322SRamesh Babu .nonatomic = 1,
46076016322SRamesh Babu .dynamic = 1,
4615895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
46276016322SRamesh Babu },
46376016322SRamesh Babu /* Back End DAI links */
46476016322SRamesh Babu {
46576016322SRamesh Babu /* SSP5 - Codec */
46676016322SRamesh Babu .name = "SSP5-Codec",
467bfb7802aSStephen Rothwell .id = 0,
46876016322SRamesh Babu .no_pcm = 1,
46976016322SRamesh Babu .init = broxton_rt298_codec_init,
47076016322SRamesh Babu .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF |
4715374b921SPeter Ujfalusi SND_SOC_DAIFMT_CBC_CFC,
47276016322SRamesh Babu .ignore_pmdown_time = 1,
47376016322SRamesh Babu .be_hw_params_fixup = broxton_ssp5_fixup,
47476016322SRamesh Babu .ops = &broxton_rt298_ops,
47576016322SRamesh Babu .dpcm_playback = 1,
47676016322SRamesh Babu .dpcm_capture = 1,
4775895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(ssp5_pin, ssp5_codec, platform),
47876016322SRamesh Babu },
47976016322SRamesh Babu {
48076016322SRamesh Babu .name = "dmic01",
481bfb7802aSStephen Rothwell .id = 1,
482bfcdc6d1SSenthilnathan Veppur .be_hw_params_fixup = broxton_dmic_fixup,
48376016322SRamesh Babu .ignore_suspend = 1,
48476016322SRamesh Babu .dpcm_capture = 1,
48576016322SRamesh Babu .no_pcm = 1,
4865895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
48776016322SRamesh Babu },
48876016322SRamesh Babu {
4898913f97dSPawse, GuruprasadX .name = "dmic16k",
4908913f97dSPawse, GuruprasadX .id = 2,
4918913f97dSPawse, GuruprasadX .be_hw_params_fixup = broxton_dmic_fixup,
4928913f97dSPawse, GuruprasadX .ignore_suspend = 1,
4938913f97dSPawse, GuruprasadX .dpcm_capture = 1,
4948913f97dSPawse, GuruprasadX .no_pcm = 1,
4955895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(dmic16k, dmic_codec, platform),
4968913f97dSPawse, GuruprasadX },
4978913f97dSPawse, GuruprasadX {
49876016322SRamesh Babu .name = "iDisp1",
499bfb7802aSStephen Rothwell .id = 3,
50076016322SRamesh Babu .init = broxton_hdmi_init,
50176016322SRamesh Babu .dpcm_playback = 1,
50276016322SRamesh Babu .no_pcm = 1,
5035895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
50476016322SRamesh Babu },
50576016322SRamesh Babu {
50676016322SRamesh Babu .name = "iDisp2",
507bfb7802aSStephen Rothwell .id = 4,
50876016322SRamesh Babu .init = broxton_hdmi_init,
50976016322SRamesh Babu .dpcm_playback = 1,
51076016322SRamesh Babu .no_pcm = 1,
5115895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
51276016322SRamesh Babu },
51376016322SRamesh Babu {
51476016322SRamesh Babu .name = "iDisp3",
515bfb7802aSStephen Rothwell .id = 5,
51676016322SRamesh Babu .init = broxton_hdmi_init,
51776016322SRamesh Babu .dpcm_playback = 1,
51876016322SRamesh Babu .no_pcm = 1,
5195895eb75SKuninori Morimoto SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
52076016322SRamesh Babu },
52176016322SRamesh Babu };
52276016322SRamesh Babu
5237932b8acSJeeja KP #define NAME_SIZE 32
bxt_card_late_probe(struct snd_soc_card * card)52451e0f3c8SJeeja KP static int bxt_card_late_probe(struct snd_soc_card *card)
52551e0f3c8SJeeja KP {
52651e0f3c8SJeeja KP struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card);
52751e0f3c8SJeeja KP struct bxt_hdmi_pcm *pcm;
52845101122SKuninori Morimoto struct snd_soc_component *component = NULL;
5297932b8acSJeeja KP int err, i = 0;
5307932b8acSJeeja KP char jack_name[NAME_SIZE];
53151e0f3c8SJeeja KP
53298ff5c26SGuennadi Liakhovetski if (list_empty(&ctx->hdmi_pcm_list))
53398ff5c26SGuennadi Liakhovetski return -EINVAL;
53498ff5c26SGuennadi Liakhovetski
53598ff5c26SGuennadi Liakhovetski if (ctx->common_hdmi_codec_drv) {
5367d2ae583SKai Vehmanen pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
5377d2ae583SKai Vehmanen head);
5387d2ae583SKai Vehmanen component = pcm->codec_dai->component;
5397d2ae583SKai Vehmanen return hda_dsp_hdmi_build_controls(card, component);
54098ff5c26SGuennadi Liakhovetski }
5417d2ae583SKai Vehmanen
54251e0f3c8SJeeja KP list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
54345101122SKuninori Morimoto component = pcm->codec_dai->component;
5447932b8acSJeeja KP snprintf(jack_name, sizeof(jack_name),
5457932b8acSJeeja KP "HDMI/DP, pcm=%d Jack", pcm->device);
5467932b8acSJeeja KP err = snd_soc_card_jack_new(card, jack_name,
54719aed2d6SAkihiko Odaki SND_JACK_AVOUT, &broxton_hdmi[i]);
5487932b8acSJeeja KP
5497932b8acSJeeja KP if (err)
5507932b8acSJeeja KP return err;
5517932b8acSJeeja KP
5527932b8acSJeeja KP err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
5537932b8acSJeeja KP &broxton_hdmi[i]);
55451e0f3c8SJeeja KP if (err < 0)
55551e0f3c8SJeeja KP return err;
5567932b8acSJeeja KP
5577932b8acSJeeja KP i++;
55851e0f3c8SJeeja KP }
55951e0f3c8SJeeja KP
56045101122SKuninori Morimoto return hdac_hdmi_jack_port_init(component, &card->dapm);
56151e0f3c8SJeeja KP }
56251e0f3c8SJeeja KP
56351e0f3c8SJeeja KP
56476016322SRamesh Babu /* broxton audio machine driver for SPT + RT298S */
56576016322SRamesh Babu static struct snd_soc_card broxton_rt298 = {
56676016322SRamesh Babu .name = "broxton-rt298",
56788cee34bSPierre-Louis Bossart .owner = THIS_MODULE,
56876016322SRamesh Babu .dai_link = broxton_rt298_dais,
56976016322SRamesh Babu .num_links = ARRAY_SIZE(broxton_rt298_dais),
57076016322SRamesh Babu .controls = broxton_controls,
57176016322SRamesh Babu .num_controls = ARRAY_SIZE(broxton_controls),
57276016322SRamesh Babu .dapm_widgets = broxton_widgets,
57376016322SRamesh Babu .num_dapm_widgets = ARRAY_SIZE(broxton_widgets),
57476016322SRamesh Babu .dapm_routes = broxton_rt298_map,
57576016322SRamesh Babu .num_dapm_routes = ARRAY_SIZE(broxton_rt298_map),
57676016322SRamesh Babu .fully_routed = true,
577*48f3fe13SCezary Rojewski .disable_route_checks = true,
57851e0f3c8SJeeja KP .late_probe = bxt_card_late_probe,
57951e0f3c8SJeeja KP
58076016322SRamesh Babu };
58176016322SRamesh Babu
582669eb871SPradeep Tewani static struct snd_soc_card geminilake_rt298 = {
583669eb871SPradeep Tewani .name = "geminilake-rt298",
58488cee34bSPierre-Louis Bossart .owner = THIS_MODULE,
585669eb871SPradeep Tewani .dai_link = broxton_rt298_dais,
586669eb871SPradeep Tewani .num_links = ARRAY_SIZE(broxton_rt298_dais),
587669eb871SPradeep Tewani .controls = broxton_controls,
588669eb871SPradeep Tewani .num_controls = ARRAY_SIZE(broxton_controls),
589669eb871SPradeep Tewani .dapm_widgets = broxton_widgets,
590669eb871SPradeep Tewani .num_dapm_widgets = ARRAY_SIZE(broxton_widgets),
591669eb871SPradeep Tewani .dapm_routes = geminilake_rt298_map,
592669eb871SPradeep Tewani .num_dapm_routes = ARRAY_SIZE(geminilake_rt298_map),
593669eb871SPradeep Tewani .fully_routed = true,
594669eb871SPradeep Tewani .late_probe = bxt_card_late_probe,
595669eb871SPradeep Tewani };
596669eb871SPradeep Tewani
broxton_audio_probe(struct platform_device * pdev)59776016322SRamesh Babu static int broxton_audio_probe(struct platform_device *pdev)
59876016322SRamesh Babu {
59951e0f3c8SJeeja KP struct bxt_rt286_private *ctx;
600669eb871SPradeep Tewani struct snd_soc_card *card =
601669eb871SPradeep Tewani (struct snd_soc_card *)pdev->id_entry->driver_data;
602fbe2c273SPierre-Louis Bossart struct snd_soc_acpi_mach *mach;
603fbe2c273SPierre-Louis Bossart const char *platform_name;
604fbe2c273SPierre-Louis Bossart int ret;
605669eb871SPradeep Tewani int i;
606669eb871SPradeep Tewani
607669eb871SPradeep Tewani for (i = 0; i < ARRAY_SIZE(broxton_rt298_dais); i++) {
6085895eb75SKuninori Morimoto if (!strncmp(card->dai_link[i].codecs->name, "i2c-INT343A:00",
609669eb871SPradeep Tewani I2C_NAME_SIZE)) {
610669eb871SPradeep Tewani if (!strncmp(card->name, "broxton-rt298",
611669eb871SPradeep Tewani PLATFORM_NAME_SIZE)) {
612669eb871SPradeep Tewani card->dai_link[i].name = "SSP5-Codec";
6135895eb75SKuninori Morimoto card->dai_link[i].cpus->dai_name = "SSP5 Pin";
614669eb871SPradeep Tewani } else if (!strncmp(card->name, "geminilake-rt298",
615669eb871SPradeep Tewani PLATFORM_NAME_SIZE)) {
616669eb871SPradeep Tewani card->dai_link[i].name = "SSP2-Codec";
6175895eb75SKuninori Morimoto card->dai_link[i].cpus->dai_name = "SSP2 Pin";
618669eb871SPradeep Tewani }
619669eb871SPradeep Tewani }
620669eb871SPradeep Tewani }
62151e0f3c8SJeeja KP
622270e1ad6SJia-Ju Bai ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
62351e0f3c8SJeeja KP if (!ctx)
62451e0f3c8SJeeja KP return -ENOMEM;
62551e0f3c8SJeeja KP
62651e0f3c8SJeeja KP INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
62751e0f3c8SJeeja KP
628669eb871SPradeep Tewani card->dev = &pdev->dev;
629669eb871SPradeep Tewani snd_soc_card_set_drvdata(card, ctx);
63076016322SRamesh Babu
631f1eebb3bSPierre-Louis Bossart /* override platform name, if required */
63242432196SGuennadi Liakhovetski mach = pdev->dev.platform_data;
633fbe2c273SPierre-Louis Bossart platform_name = mach->mach_params.platform;
634fbe2c273SPierre-Louis Bossart
635fbe2c273SPierre-Louis Bossart ret = snd_soc_fixup_dai_links_platform_name(card,
636fbe2c273SPierre-Louis Bossart platform_name);
637fbe2c273SPierre-Louis Bossart if (ret)
638fbe2c273SPierre-Louis Bossart return ret;
639fbe2c273SPierre-Louis Bossart
6407d2ae583SKai Vehmanen ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
6417d2ae583SKai Vehmanen
642669eb871SPradeep Tewani return devm_snd_soc_register_card(&pdev->dev, card);
64376016322SRamesh Babu }
64476016322SRamesh Babu
645669eb871SPradeep Tewani static const struct platform_device_id bxt_board_ids[] = {
646669eb871SPradeep Tewani { .name = "bxt_alc298s_i2s", .driver_data =
647669eb871SPradeep Tewani (unsigned long)&broxton_rt298 },
648669eb871SPradeep Tewani { .name = "glk_alc298s_i2s", .driver_data =
649669eb871SPradeep Tewani (unsigned long)&geminilake_rt298 },
65082444cdbSPradeep Tewani {}
651669eb871SPradeep Tewani };
65253b98536SPierre-Louis Bossart MODULE_DEVICE_TABLE(platform, bxt_board_ids);
653669eb871SPradeep Tewani
65476016322SRamesh Babu static struct platform_driver broxton_audio = {
65576016322SRamesh Babu .probe = broxton_audio_probe,
65676016322SRamesh Babu .driver = {
65776016322SRamesh Babu .name = "bxt_alc298s_i2s",
658f749a78aSVinod Koul .pm = &snd_soc_pm_ops,
65976016322SRamesh Babu },
660669eb871SPradeep Tewani .id_table = bxt_board_ids,
66176016322SRamesh Babu };
66276016322SRamesh Babu module_platform_driver(broxton_audio)
66376016322SRamesh Babu
66476016322SRamesh Babu /* Module information */
66576016322SRamesh Babu MODULE_AUTHOR("Ramesh Babu <Ramesh.Babu@intel.com>");
66676016322SRamesh Babu MODULE_AUTHOR("Senthilnathan Veppur <senthilnathanx.veppur@intel.com>");
66776016322SRamesh Babu MODULE_DESCRIPTION("Intel SST Audio for Broxton");
66876016322SRamesh Babu MODULE_LICENSE("GPL v2");
669f6081af6SPierre-Louis Bossart MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
670