18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Intel Kabylake I2S Machine Driver with MAXIM98927
48c2ecf20Sopenharmony_ci * and RT5663 Codecs
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 2017, Intel Corporation. All rights reserved.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Modified from:
98c2ecf20Sopenharmony_ci *   Intel Skylake I2S Machine driver
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/input.h>
138c2ecf20Sopenharmony_ci#include <linux/module.h>
148c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
158c2ecf20Sopenharmony_ci#include <sound/core.h>
168c2ecf20Sopenharmony_ci#include <sound/jack.h>
178c2ecf20Sopenharmony_ci#include <sound/pcm.h>
188c2ecf20Sopenharmony_ci#include <sound/pcm_params.h>
198c2ecf20Sopenharmony_ci#include <sound/soc.h>
208c2ecf20Sopenharmony_ci#include <sound/soc-acpi.h>
218c2ecf20Sopenharmony_ci#include "../../codecs/rt5663.h"
228c2ecf20Sopenharmony_ci#include "../../codecs/hdac_hdmi.h"
238c2ecf20Sopenharmony_ci#include <linux/clk.h>
248c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
258c2ecf20Sopenharmony_ci#include <linux/clkdev.h>
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define KBL_REALTEK_CODEC_DAI "rt5663-aif"
288c2ecf20Sopenharmony_ci#define KBL_MAXIM_CODEC_DAI "max98927-aif1"
298c2ecf20Sopenharmony_ci#define DMIC_CH(p) p->list[p->count-1]
308c2ecf20Sopenharmony_ci#define MAXIM_DEV0_NAME "i2c-MX98927:00"
318c2ecf20Sopenharmony_ci#define MAXIM_DEV1_NAME "i2c-MX98927:01"
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistatic struct snd_soc_card *kabylake_audio_card;
348c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list *dmic_constraints;
358c2ecf20Sopenharmony_cistatic struct snd_soc_jack skylake_hdmi[3];
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cistruct kbl_hdmi_pcm {
388c2ecf20Sopenharmony_ci	struct list_head head;
398c2ecf20Sopenharmony_ci	struct snd_soc_dai *codec_dai;
408c2ecf20Sopenharmony_ci	int device;
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cistruct kbl_rt5663_private {
448c2ecf20Sopenharmony_ci	struct snd_soc_jack kabylake_headset;
458c2ecf20Sopenharmony_ci	struct list_head hdmi_pcm_list;
468c2ecf20Sopenharmony_ci	struct clk *mclk;
478c2ecf20Sopenharmony_ci	struct clk *sclk;
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cienum {
518c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_PB = 0,
528c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_CP,
538c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_HS_PB,
548c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_ECHO_REF_CP,
558c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_REF_CP,
568c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_DMIC_CP,
578c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_HDMI1_PB,
588c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_HDMI2_PB,
598c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_HDMI3_PB,
608c2ecf20Sopenharmony_ci};
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new kabylake_controls[] = {
638c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
648c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Headset Mic"),
658c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Left Spk"),
668c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Right Spk"),
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic int platform_clock_control(struct snd_soc_dapm_widget *w,
708c2ecf20Sopenharmony_ci			struct snd_kcontrol *k, int  event)
718c2ecf20Sopenharmony_ci{
728c2ecf20Sopenharmony_ci	struct snd_soc_dapm_context *dapm = w->dapm;
738c2ecf20Sopenharmony_ci	struct snd_soc_card *card = dapm->card;
748c2ecf20Sopenharmony_ci	struct kbl_rt5663_private *priv = snd_soc_card_get_drvdata(card);
758c2ecf20Sopenharmony_ci	int ret = 0;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	/*
788c2ecf20Sopenharmony_ci	 * MCLK/SCLK need to be ON early for a successful synchronization of
798c2ecf20Sopenharmony_ci	 * codec internal clock. And the clocks are turned off during
808c2ecf20Sopenharmony_ci	 * POST_PMD after the stream is stopped.
818c2ecf20Sopenharmony_ci	 */
828c2ecf20Sopenharmony_ci	switch (event) {
838c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_PRE_PMU:
848c2ecf20Sopenharmony_ci		/* Enable MCLK */
858c2ecf20Sopenharmony_ci		ret = clk_set_rate(priv->mclk, 24000000);
868c2ecf20Sopenharmony_ci		if (ret < 0) {
878c2ecf20Sopenharmony_ci			dev_err(card->dev, "Can't set rate for mclk, err: %d\n",
888c2ecf20Sopenharmony_ci				ret);
898c2ecf20Sopenharmony_ci			return ret;
908c2ecf20Sopenharmony_ci		}
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci		ret = clk_prepare_enable(priv->mclk);
938c2ecf20Sopenharmony_ci		if (ret < 0) {
948c2ecf20Sopenharmony_ci			dev_err(card->dev, "Can't enable mclk, err: %d\n", ret);
958c2ecf20Sopenharmony_ci			return ret;
968c2ecf20Sopenharmony_ci		}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci		/* Enable SCLK */
998c2ecf20Sopenharmony_ci		ret = clk_set_rate(priv->sclk, 3072000);
1008c2ecf20Sopenharmony_ci		if (ret < 0) {
1018c2ecf20Sopenharmony_ci			dev_err(card->dev, "Can't set rate for sclk, err: %d\n",
1028c2ecf20Sopenharmony_ci				ret);
1038c2ecf20Sopenharmony_ci			clk_disable_unprepare(priv->mclk);
1048c2ecf20Sopenharmony_ci			return ret;
1058c2ecf20Sopenharmony_ci		}
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci		ret = clk_prepare_enable(priv->sclk);
1088c2ecf20Sopenharmony_ci		if (ret < 0) {
1098c2ecf20Sopenharmony_ci			dev_err(card->dev, "Can't enable sclk, err: %d\n", ret);
1108c2ecf20Sopenharmony_ci			clk_disable_unprepare(priv->mclk);
1118c2ecf20Sopenharmony_ci		}
1128c2ecf20Sopenharmony_ci		break;
1138c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMD:
1148c2ecf20Sopenharmony_ci		clk_disable_unprepare(priv->mclk);
1158c2ecf20Sopenharmony_ci		clk_disable_unprepare(priv->sclk);
1168c2ecf20Sopenharmony_ci		break;
1178c2ecf20Sopenharmony_ci	default:
1188c2ecf20Sopenharmony_ci		return 0;
1198c2ecf20Sopenharmony_ci	}
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci	return 0;
1228c2ecf20Sopenharmony_ci}
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget kabylake_widgets[] = {
1258c2ecf20Sopenharmony_ci	SND_SOC_DAPM_HP("Headphone Jack", NULL),
1268c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIC("Headset Mic", NULL),
1278c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SPK("Left Spk", NULL),
1288c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SPK("Right Spk", NULL),
1298c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIC("SoC DMIC", NULL),
1308c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SPK("HDMI1", NULL),
1318c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SPK("HDMI2", NULL),
1328c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SPK("HDMI3", NULL),
1338c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
1348c2ecf20Sopenharmony_ci			platform_clock_control, SND_SOC_DAPM_PRE_PMU |
1358c2ecf20Sopenharmony_ci			SND_SOC_DAPM_POST_PMD),
1368c2ecf20Sopenharmony_ci};
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route kabylake_map[] = {
1398c2ecf20Sopenharmony_ci	/* HP jack connectors - unknown if we have jack detection */
1408c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "Platform Clock" },
1418c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "HPOL" },
1428c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "HPOR" },
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	/* speaker */
1458c2ecf20Sopenharmony_ci	{ "Left Spk", NULL, "Left BE_OUT" },
1468c2ecf20Sopenharmony_ci	{ "Right Spk", NULL, "Right BE_OUT" },
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	/* other jacks */
1498c2ecf20Sopenharmony_ci	{ "Headset Mic", NULL, "Platform Clock" },
1508c2ecf20Sopenharmony_ci	{ "IN1P", NULL, "Headset Mic" },
1518c2ecf20Sopenharmony_ci	{ "IN1N", NULL, "Headset Mic" },
1528c2ecf20Sopenharmony_ci	{ "DMic", NULL, "SoC DMIC" },
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	/* CODEC BE connections */
1558c2ecf20Sopenharmony_ci	{ "Left HiFi Playback", NULL, "ssp0 Tx" },
1568c2ecf20Sopenharmony_ci	{ "Right HiFi Playback", NULL, "ssp0 Tx" },
1578c2ecf20Sopenharmony_ci	{ "ssp0 Tx", NULL, "spk_out" },
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci	{ "AIF Playback", NULL, "ssp1 Tx" },
1608c2ecf20Sopenharmony_ci	{ "ssp1 Tx", NULL, "codec1_out" },
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	{ "hs_in", NULL, "ssp1 Rx" },
1638c2ecf20Sopenharmony_ci	{ "ssp1 Rx", NULL, "AIF Capture" },
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	/* IV feedback path */
1668c2ecf20Sopenharmony_ci	{ "codec0_fb_in", NULL, "ssp0 Rx"},
1678c2ecf20Sopenharmony_ci	{ "ssp0 Rx", NULL, "Left HiFi Capture" },
1688c2ecf20Sopenharmony_ci	{ "ssp0 Rx", NULL, "Right HiFi Capture" },
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	/* DMIC */
1718c2ecf20Sopenharmony_ci	{ "dmic01_hifi", NULL, "DMIC01 Rx" },
1728c2ecf20Sopenharmony_ci	{ "DMIC01 Rx", NULL, "DMIC AIF" },
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	{ "hifi3", NULL, "iDisp3 Tx"},
1758c2ecf20Sopenharmony_ci	{ "iDisp3 Tx", NULL, "iDisp3_out"},
1768c2ecf20Sopenharmony_ci	{ "hifi2", NULL, "iDisp2 Tx"},
1778c2ecf20Sopenharmony_ci	{ "iDisp2 Tx", NULL, "iDisp2_out"},
1788c2ecf20Sopenharmony_ci	{ "hifi1", NULL, "iDisp1 Tx"},
1798c2ecf20Sopenharmony_ci	{ "iDisp1 Tx", NULL, "iDisp1_out"},
1808c2ecf20Sopenharmony_ci};
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_cienum {
1838c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_5663_PB = 0,
1848c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_5663_CP,
1858c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_5663_HDMI1_PB,
1868c2ecf20Sopenharmony_ci	KBL_DPCM_AUDIO_5663_HDMI2_PB,
1878c2ecf20Sopenharmony_ci};
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new kabylake_5663_controls[] = {
1908c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
1918c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Headset Mic"),
1928c2ecf20Sopenharmony_ci};
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget kabylake_5663_widgets[] = {
1958c2ecf20Sopenharmony_ci	SND_SOC_DAPM_HP("Headphone Jack", NULL),
1968c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIC("Headset Mic", NULL),
1978c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SPK("DP", NULL),
1988c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SPK("HDMI", NULL),
1998c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
2008c2ecf20Sopenharmony_ci			platform_clock_control, SND_SOC_DAPM_PRE_PMU |
2018c2ecf20Sopenharmony_ci			SND_SOC_DAPM_POST_PMD),
2028c2ecf20Sopenharmony_ci};
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route kabylake_5663_map[] = {
2058c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "Platform Clock" },
2068c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "HPOL" },
2078c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "HPOR" },
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	/* other jacks */
2108c2ecf20Sopenharmony_ci	{ "Headset Mic", NULL, "Platform Clock" },
2118c2ecf20Sopenharmony_ci	{ "IN1P", NULL, "Headset Mic" },
2128c2ecf20Sopenharmony_ci	{ "IN1N", NULL, "Headset Mic" },
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	{ "HDMI", NULL, "hif5 Output" },
2158c2ecf20Sopenharmony_ci	{ "DP", NULL, "hif6 Output" },
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci	/* CODEC BE connections */
2188c2ecf20Sopenharmony_ci	{ "AIF Playback", NULL, "ssp1 Tx" },
2198c2ecf20Sopenharmony_ci	{ "ssp1 Tx", NULL, "codec1_out" },
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci	{ "codec0_in", NULL, "ssp1 Rx" },
2228c2ecf20Sopenharmony_ci	{ "ssp1 Rx", NULL, "AIF Capture" },
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	{ "hifi2", NULL, "iDisp2 Tx"},
2258c2ecf20Sopenharmony_ci	{ "iDisp2 Tx", NULL, "iDisp2_out"},
2268c2ecf20Sopenharmony_ci	{ "hifi1", NULL, "iDisp1 Tx"},
2278c2ecf20Sopenharmony_ci	{ "iDisp1 Tx", NULL, "iDisp1_out"},
2288c2ecf20Sopenharmony_ci};
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistatic struct snd_soc_codec_conf max98927_codec_conf[] = {
2318c2ecf20Sopenharmony_ci	{
2328c2ecf20Sopenharmony_ci		.dlc = COMP_CODEC_CONF(MAXIM_DEV0_NAME),
2338c2ecf20Sopenharmony_ci		.name_prefix = "Right",
2348c2ecf20Sopenharmony_ci	},
2358c2ecf20Sopenharmony_ci	{
2368c2ecf20Sopenharmony_ci		.dlc = COMP_CODEC_CONF(MAXIM_DEV1_NAME),
2378c2ecf20Sopenharmony_ci		.name_prefix = "Left",
2388c2ecf20Sopenharmony_ci	},
2398c2ecf20Sopenharmony_ci};
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_cistatic int kabylake_rt5663_fe_init(struct snd_soc_pcm_runtime *rtd)
2428c2ecf20Sopenharmony_ci{
2438c2ecf20Sopenharmony_ci	int ret;
2448c2ecf20Sopenharmony_ci	struct snd_soc_dapm_context *dapm;
2458c2ecf20Sopenharmony_ci	struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	dapm = snd_soc_component_get_dapm(component);
2488c2ecf20Sopenharmony_ci	ret = snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
2498c2ecf20Sopenharmony_ci	if (ret) {
2508c2ecf20Sopenharmony_ci		dev_err(rtd->dev, "Ref Cap ignore suspend failed %d\n", ret);
2518c2ecf20Sopenharmony_ci		return ret;
2528c2ecf20Sopenharmony_ci	}
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	return ret;
2558c2ecf20Sopenharmony_ci}
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_cistatic int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
2588c2ecf20Sopenharmony_ci{
2598c2ecf20Sopenharmony_ci	int ret;
2608c2ecf20Sopenharmony_ci	struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card);
2618c2ecf20Sopenharmony_ci	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
2628c2ecf20Sopenharmony_ci	struct snd_soc_jack *jack;
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	/*
2658c2ecf20Sopenharmony_ci	 * Headset buttons map to the google Reference headset.
2668c2ecf20Sopenharmony_ci	 * These can be configured by userspace.
2678c2ecf20Sopenharmony_ci	 */
2688c2ecf20Sopenharmony_ci	ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack",
2698c2ecf20Sopenharmony_ci			SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
2708c2ecf20Sopenharmony_ci			SND_JACK_BTN_2 | SND_JACK_BTN_3, &ctx->kabylake_headset,
2718c2ecf20Sopenharmony_ci			NULL, 0);
2728c2ecf20Sopenharmony_ci	if (ret) {
2738c2ecf20Sopenharmony_ci		dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
2748c2ecf20Sopenharmony_ci		return ret;
2758c2ecf20Sopenharmony_ci	}
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci	jack = &ctx->kabylake_headset;
2788c2ecf20Sopenharmony_ci	snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
2798c2ecf20Sopenharmony_ci	snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
2808c2ecf20Sopenharmony_ci	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
2818c2ecf20Sopenharmony_ci	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	snd_soc_component_set_jack(component, &ctx->kabylake_headset, NULL);
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	return ret;
2868c2ecf20Sopenharmony_ci}
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_cistatic int kabylake_rt5663_max98927_codec_init(struct snd_soc_pcm_runtime *rtd)
2898c2ecf20Sopenharmony_ci{
2908c2ecf20Sopenharmony_ci	int ret;
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	ret = kabylake_rt5663_codec_init(rtd);
2938c2ecf20Sopenharmony_ci	if (ret)
2948c2ecf20Sopenharmony_ci		return ret;
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci	ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
2978c2ecf20Sopenharmony_ci	if (ret) {
2988c2ecf20Sopenharmony_ci		dev_err(rtd->dev, "SoC DMIC ignore suspend failed %d\n", ret);
2998c2ecf20Sopenharmony_ci		return ret;
3008c2ecf20Sopenharmony_ci	}
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	return ret;
3038c2ecf20Sopenharmony_ci}
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_cistatic int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
3068c2ecf20Sopenharmony_ci{
3078c2ecf20Sopenharmony_ci	struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card);
3088c2ecf20Sopenharmony_ci	struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
3098c2ecf20Sopenharmony_ci	struct kbl_hdmi_pcm *pcm;
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
3128c2ecf20Sopenharmony_ci	if (!pcm)
3138c2ecf20Sopenharmony_ci		return -ENOMEM;
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	pcm->device = device;
3168c2ecf20Sopenharmony_ci	pcm->codec_dai = dai;
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci	return 0;
3218c2ecf20Sopenharmony_ci}
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_cistatic int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
3248c2ecf20Sopenharmony_ci{
3258c2ecf20Sopenharmony_ci	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
3268c2ecf20Sopenharmony_ci}
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistatic int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
3298c2ecf20Sopenharmony_ci{
3308c2ecf20Sopenharmony_ci	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
3318c2ecf20Sopenharmony_ci}
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistatic int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
3348c2ecf20Sopenharmony_ci{
3358c2ecf20Sopenharmony_ci	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
3368c2ecf20Sopenharmony_ci}
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_cistatic int kabylake_5663_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
3398c2ecf20Sopenharmony_ci{
3408c2ecf20Sopenharmony_ci	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5663_HDMI1_PB);
3418c2ecf20Sopenharmony_ci}
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_cistatic int kabylake_5663_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
3448c2ecf20Sopenharmony_ci{
3458c2ecf20Sopenharmony_ci	return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5663_HDMI2_PB);
3468c2ecf20Sopenharmony_ci}
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_cistatic unsigned int rates[] = {
3498c2ecf20Sopenharmony_ci	48000,
3508c2ecf20Sopenharmony_ci};
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list constraints_rates = {
3538c2ecf20Sopenharmony_ci	.count = ARRAY_SIZE(rates),
3548c2ecf20Sopenharmony_ci	.list  = rates,
3558c2ecf20Sopenharmony_ci	.mask = 0,
3568c2ecf20Sopenharmony_ci};
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_cistatic unsigned int channels[] = {
3598c2ecf20Sopenharmony_ci	2,
3608c2ecf20Sopenharmony_ci};
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list constraints_channels = {
3638c2ecf20Sopenharmony_ci	.count = ARRAY_SIZE(channels),
3648c2ecf20Sopenharmony_ci	.list = channels,
3658c2ecf20Sopenharmony_ci	.mask = 0,
3668c2ecf20Sopenharmony_ci};
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_cistatic int kbl_fe_startup(struct snd_pcm_substream *substream)
3698c2ecf20Sopenharmony_ci{
3708c2ecf20Sopenharmony_ci	struct snd_pcm_runtime *runtime = substream->runtime;
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	/*
3738c2ecf20Sopenharmony_ci	 * On this platform for PCM device we support,
3748c2ecf20Sopenharmony_ci	 * 48Khz
3758c2ecf20Sopenharmony_ci	 * stereo
3768c2ecf20Sopenharmony_ci	 * 16 bit audio
3778c2ecf20Sopenharmony_ci	 */
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	runtime->hw.channels_max = 2;
3808c2ecf20Sopenharmony_ci	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
3818c2ecf20Sopenharmony_ci					   &constraints_channels);
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
3848c2ecf20Sopenharmony_ci	snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci	snd_pcm_hw_constraint_list(runtime, 0,
3878c2ecf20Sopenharmony_ci				SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci	return 0;
3908c2ecf20Sopenharmony_ci}
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistatic const struct snd_soc_ops kabylake_rt5663_fe_ops = {
3938c2ecf20Sopenharmony_ci	.startup = kbl_fe_startup,
3948c2ecf20Sopenharmony_ci};
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_cistatic int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
3978c2ecf20Sopenharmony_ci	struct snd_pcm_hw_params *params)
3988c2ecf20Sopenharmony_ci{
3998c2ecf20Sopenharmony_ci	struct snd_interval *rate = hw_param_interval(params,
4008c2ecf20Sopenharmony_ci			SNDRV_PCM_HW_PARAM_RATE);
4018c2ecf20Sopenharmony_ci	struct snd_interval *chan = hw_param_interval(params,
4028c2ecf20Sopenharmony_ci			SNDRV_PCM_HW_PARAM_CHANNELS);
4038c2ecf20Sopenharmony_ci	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
4048c2ecf20Sopenharmony_ci	struct snd_soc_dpcm *dpcm, *rtd_dpcm = NULL;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci	/*
4078c2ecf20Sopenharmony_ci	 * The following loop will be called only for playback stream
4088c2ecf20Sopenharmony_ci	 * In this platform, there is only one playback device on every SSP
4098c2ecf20Sopenharmony_ci	 */
4108c2ecf20Sopenharmony_ci	for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) {
4118c2ecf20Sopenharmony_ci		rtd_dpcm = dpcm;
4128c2ecf20Sopenharmony_ci		break;
4138c2ecf20Sopenharmony_ci	}
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci	/*
4168c2ecf20Sopenharmony_ci	 * This following loop will be called only for capture stream
4178c2ecf20Sopenharmony_ci	 * In this platform, there is only one capture device on every SSP
4188c2ecf20Sopenharmony_ci	 */
4198c2ecf20Sopenharmony_ci	for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) {
4208c2ecf20Sopenharmony_ci		rtd_dpcm = dpcm;
4218c2ecf20Sopenharmony_ci		break;
4228c2ecf20Sopenharmony_ci	}
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci	if (!rtd_dpcm)
4258c2ecf20Sopenharmony_ci		return -EINVAL;
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci	/*
4288c2ecf20Sopenharmony_ci	 * The above 2 loops are mutually exclusive based on the stream direction,
4298c2ecf20Sopenharmony_ci	 * thus rtd_dpcm variable will never be overwritten
4308c2ecf20Sopenharmony_ci	 */
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci	/*
4338c2ecf20Sopenharmony_ci	 * The ADSP will convert the FE rate to 48k, stereo, 24 bit
4348c2ecf20Sopenharmony_ci	 */
4358c2ecf20Sopenharmony_ci	if (!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Port") ||
4368c2ecf20Sopenharmony_ci	    !strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Headset Playback") ||
4378c2ecf20Sopenharmony_ci	    !strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Capture Port")) {
4388c2ecf20Sopenharmony_ci		rate->min = rate->max = 48000;
4398c2ecf20Sopenharmony_ci		chan->min = chan->max = 2;
4408c2ecf20Sopenharmony_ci		snd_mask_none(fmt);
4418c2ecf20Sopenharmony_ci		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
4428c2ecf20Sopenharmony_ci	}
4438c2ecf20Sopenharmony_ci	/*
4448c2ecf20Sopenharmony_ci	 * The speaker on the SSP0 supports S16_LE and not S24_LE.
4458c2ecf20Sopenharmony_ci	 * thus changing the mask here
4468c2ecf20Sopenharmony_ci	 */
4478c2ecf20Sopenharmony_ci	if (!strcmp(rtd_dpcm->be->dai_link->name, "SSP0-Codec"))
4488c2ecf20Sopenharmony_ci		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_ci	return 0;
4518c2ecf20Sopenharmony_ci}
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_cistatic int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
4548c2ecf20Sopenharmony_ci	struct snd_pcm_hw_params *params)
4558c2ecf20Sopenharmony_ci{
4568c2ecf20Sopenharmony_ci	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
4578c2ecf20Sopenharmony_ci	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
4588c2ecf20Sopenharmony_ci	int ret;
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci	/* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */
4618c2ecf20Sopenharmony_ci	rt5663_sel_asrc_clk_src(codec_dai->component,
4628c2ecf20Sopenharmony_ci			RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER,
4638c2ecf20Sopenharmony_ci			RT5663_CLK_SEL_I2S1_ASRC);
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ci	ret = snd_soc_dai_set_sysclk(codec_dai,
4668c2ecf20Sopenharmony_ci			RT5663_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN);
4678c2ecf20Sopenharmony_ci	if (ret < 0)
4688c2ecf20Sopenharmony_ci		dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci	return ret;
4718c2ecf20Sopenharmony_ci}
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_cistatic struct snd_soc_ops kabylake_rt5663_ops = {
4748c2ecf20Sopenharmony_ci	.hw_params = kabylake_rt5663_hw_params,
4758c2ecf20Sopenharmony_ci};
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_cistatic int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
4788c2ecf20Sopenharmony_ci		struct snd_pcm_hw_params *params)
4798c2ecf20Sopenharmony_ci{
4808c2ecf20Sopenharmony_ci	struct snd_interval *chan = hw_param_interval(params,
4818c2ecf20Sopenharmony_ci				SNDRV_PCM_HW_PARAM_CHANNELS);
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci	if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2)
4848c2ecf20Sopenharmony_ci		chan->min = chan->max = 2;
4858c2ecf20Sopenharmony_ci	else
4868c2ecf20Sopenharmony_ci		chan->min = chan->max = 4;
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci	return 0;
4898c2ecf20Sopenharmony_ci}
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_cistatic int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
4928c2ecf20Sopenharmony_ci					struct snd_pcm_hw_params *params)
4938c2ecf20Sopenharmony_ci{
4948c2ecf20Sopenharmony_ci	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
4958c2ecf20Sopenharmony_ci	struct snd_soc_dai *codec_dai;
4968c2ecf20Sopenharmony_ci	int ret = 0, j;
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_ci	for_each_rtd_codec_dais(rtd, j, codec_dai) {
4998c2ecf20Sopenharmony_ci		if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
5008c2ecf20Sopenharmony_ci			/*
5018c2ecf20Sopenharmony_ci			 * Use channel 4 and 5 for the first amp
5028c2ecf20Sopenharmony_ci			 */
5038c2ecf20Sopenharmony_ci			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16);
5048c2ecf20Sopenharmony_ci			if (ret < 0) {
5058c2ecf20Sopenharmony_ci				dev_err(rtd->dev, "set TDM slot err:%d\n", ret);
5068c2ecf20Sopenharmony_ci				return ret;
5078c2ecf20Sopenharmony_ci			}
5088c2ecf20Sopenharmony_ci		}
5098c2ecf20Sopenharmony_ci		if (!strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) {
5108c2ecf20Sopenharmony_ci			/*
5118c2ecf20Sopenharmony_ci			 * Use channel 6 and 7 for the second amp
5128c2ecf20Sopenharmony_ci			 */
5138c2ecf20Sopenharmony_ci			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC0, 3, 8, 16);
5148c2ecf20Sopenharmony_ci			if (ret < 0) {
5158c2ecf20Sopenharmony_ci				dev_err(rtd->dev, "set TDM slot err:%d\n", ret);
5168c2ecf20Sopenharmony_ci				return ret;
5178c2ecf20Sopenharmony_ci			}
5188c2ecf20Sopenharmony_ci		}
5198c2ecf20Sopenharmony_ci	}
5208c2ecf20Sopenharmony_ci	return ret;
5218c2ecf20Sopenharmony_ci}
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_cistatic struct snd_soc_ops kabylake_ssp0_ops = {
5248c2ecf20Sopenharmony_ci	.hw_params = kabylake_ssp0_hw_params,
5258c2ecf20Sopenharmony_ci};
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_cistatic unsigned int channels_dmic[] = {
5288c2ecf20Sopenharmony_ci	2, 4,
5298c2ecf20Sopenharmony_ci};
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_cistatic struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
5328c2ecf20Sopenharmony_ci	.count = ARRAY_SIZE(channels_dmic),
5338c2ecf20Sopenharmony_ci	.list = channels_dmic,
5348c2ecf20Sopenharmony_ci	.mask = 0,
5358c2ecf20Sopenharmony_ci};
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_cistatic const unsigned int dmic_2ch[] = {
5388c2ecf20Sopenharmony_ci	2,
5398c2ecf20Sopenharmony_ci};
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
5428c2ecf20Sopenharmony_ci	.count = ARRAY_SIZE(dmic_2ch),
5438c2ecf20Sopenharmony_ci	.list = dmic_2ch,
5448c2ecf20Sopenharmony_ci	.mask = 0,
5458c2ecf20Sopenharmony_ci};
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_cistatic int kabylake_dmic_startup(struct snd_pcm_substream *substream)
5488c2ecf20Sopenharmony_ci{
5498c2ecf20Sopenharmony_ci	struct snd_pcm_runtime *runtime = substream->runtime;
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ci	runtime->hw.channels_max = DMIC_CH(dmic_constraints);
5528c2ecf20Sopenharmony_ci	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
5538c2ecf20Sopenharmony_ci			dmic_constraints);
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci	return snd_pcm_hw_constraint_list(substream->runtime, 0,
5568c2ecf20Sopenharmony_ci			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
5578c2ecf20Sopenharmony_ci}
5588c2ecf20Sopenharmony_ci
5598c2ecf20Sopenharmony_cistatic struct snd_soc_ops kabylake_dmic_ops = {
5608c2ecf20Sopenharmony_ci	.startup = kabylake_dmic_startup,
5618c2ecf20Sopenharmony_ci};
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_cistatic unsigned int rates_16000[] = {
5648c2ecf20Sopenharmony_ci	16000,
5658c2ecf20Sopenharmony_ci};
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list constraints_16000 = {
5688c2ecf20Sopenharmony_ci	.count = ARRAY_SIZE(rates_16000),
5698c2ecf20Sopenharmony_ci	.list  = rates_16000,
5708c2ecf20Sopenharmony_ci};
5718c2ecf20Sopenharmony_ci
5728c2ecf20Sopenharmony_cistatic const unsigned int ch_mono[] = {
5738c2ecf20Sopenharmony_ci	1,
5748c2ecf20Sopenharmony_ci};
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list constraints_refcap = {
5778c2ecf20Sopenharmony_ci	.count = ARRAY_SIZE(ch_mono),
5788c2ecf20Sopenharmony_ci	.list  = ch_mono,
5798c2ecf20Sopenharmony_ci};
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_cistatic int kabylake_refcap_startup(struct snd_pcm_substream *substream)
5828c2ecf20Sopenharmony_ci{
5838c2ecf20Sopenharmony_ci	substream->runtime->hw.channels_max = 1;
5848c2ecf20Sopenharmony_ci	snd_pcm_hw_constraint_list(substream->runtime, 0,
5858c2ecf20Sopenharmony_ci					SNDRV_PCM_HW_PARAM_CHANNELS,
5868c2ecf20Sopenharmony_ci					&constraints_refcap);
5878c2ecf20Sopenharmony_ci
5888c2ecf20Sopenharmony_ci	return snd_pcm_hw_constraint_list(substream->runtime, 0,
5898c2ecf20Sopenharmony_ci				SNDRV_PCM_HW_PARAM_RATE,
5908c2ecf20Sopenharmony_ci				&constraints_16000);
5918c2ecf20Sopenharmony_ci}
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_cistatic struct snd_soc_ops skylake_refcap_ops = {
5948c2ecf20Sopenharmony_ci	.startup = kabylake_refcap_startup,
5958c2ecf20Sopenharmony_ci};
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dummy,
5988c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_DUMMY()));
5998c2ecf20Sopenharmony_ci
6008c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(system,
6018c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(system2,
6048c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
6058c2ecf20Sopenharmony_ci
6068c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(echoref,
6078c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin")));
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(reference,
6108c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
6118c2ecf20Sopenharmony_ci
6128c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dmic,
6138c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(hdmi1,
6168c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(hdmi2,
6198c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(hdmi3,
6228c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp0_pin,
6258c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
6268c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp0_codec,
6278c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(
6288c2ecf20Sopenharmony_ci	/* Left */	COMP_CODEC(MAXIM_DEV0_NAME, KBL_MAXIM_CODEC_DAI),
6298c2ecf20Sopenharmony_ci	/* Right */	COMP_CODEC(MAXIM_DEV1_NAME, KBL_MAXIM_CODEC_DAI)));
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp1_pin,
6328c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
6338c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp1_codec,
6348c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5663:00",
6358c2ecf20Sopenharmony_ci				      KBL_REALTEK_CODEC_DAI)));
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dmic01_pin,
6388c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
6398c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dmic_codec,
6408c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp1_pin,
6438c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
6448c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp1_codec,
6458c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp2_pin,
6488c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
6498c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp2_codec,
6508c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp3_pin,
6538c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
6548c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp3_codec,
6558c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
6568c2ecf20Sopenharmony_ci
6578c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(platform,
6588c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci/* kabylake digital audio interface glue - connects codec <--> CPU */
6618c2ecf20Sopenharmony_cistatic struct snd_soc_dai_link kabylake_dais[] = {
6628c2ecf20Sopenharmony_ci	/* Front End DAI links */
6638c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_PB] = {
6648c2ecf20Sopenharmony_ci		.name = "Kbl Audio Port",
6658c2ecf20Sopenharmony_ci		.stream_name = "Audio",
6668c2ecf20Sopenharmony_ci		.dynamic = 1,
6678c2ecf20Sopenharmony_ci		.nonatomic = 1,
6688c2ecf20Sopenharmony_ci		.init = kabylake_rt5663_fe_init,
6698c2ecf20Sopenharmony_ci		.trigger = {
6708c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
6718c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
6728c2ecf20Sopenharmony_ci		.ops = &kabylake_rt5663_fe_ops,
6738c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(system, dummy, platform),
6748c2ecf20Sopenharmony_ci	},
6758c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_CP] = {
6768c2ecf20Sopenharmony_ci		.name = "Kbl Audio Capture Port",
6778c2ecf20Sopenharmony_ci		.stream_name = "Audio Record",
6788c2ecf20Sopenharmony_ci		.dynamic = 1,
6798c2ecf20Sopenharmony_ci		.nonatomic = 1,
6808c2ecf20Sopenharmony_ci		.trigger = {
6818c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
6828c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
6838c2ecf20Sopenharmony_ci		.ops = &kabylake_rt5663_fe_ops,
6848c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(system, dummy, platform),
6858c2ecf20Sopenharmony_ci	},
6868c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_HS_PB] = {
6878c2ecf20Sopenharmony_ci		.name = "Kbl Audio Headset Playback",
6888c2ecf20Sopenharmony_ci		.stream_name = "Headset Audio",
6898c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
6908c2ecf20Sopenharmony_ci		.nonatomic = 1,
6918c2ecf20Sopenharmony_ci		.dynamic = 1,
6928c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(system2, dummy, platform),
6938c2ecf20Sopenharmony_ci	},
6948c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_ECHO_REF_CP] = {
6958c2ecf20Sopenharmony_ci		.name = "Kbl Audio Echo Reference cap",
6968c2ecf20Sopenharmony_ci		.stream_name = "Echoreference Capture",
6978c2ecf20Sopenharmony_ci		.init = NULL,
6988c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
6998c2ecf20Sopenharmony_ci		.nonatomic = 1,
7008c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(echoref, dummy, platform),
7018c2ecf20Sopenharmony_ci	},
7028c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_REF_CP] = {
7038c2ecf20Sopenharmony_ci		.name = "Kbl Audio Reference cap",
7048c2ecf20Sopenharmony_ci		.stream_name = "Wake on Voice",
7058c2ecf20Sopenharmony_ci		.init = NULL,
7068c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
7078c2ecf20Sopenharmony_ci		.nonatomic = 1,
7088c2ecf20Sopenharmony_ci		.dynamic = 1,
7098c2ecf20Sopenharmony_ci		.ops = &skylake_refcap_ops,
7108c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(reference, dummy, platform),
7118c2ecf20Sopenharmony_ci	},
7128c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_DMIC_CP] = {
7138c2ecf20Sopenharmony_ci		.name = "Kbl Audio DMIC cap",
7148c2ecf20Sopenharmony_ci		.stream_name = "dmiccap",
7158c2ecf20Sopenharmony_ci		.init = NULL,
7168c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
7178c2ecf20Sopenharmony_ci		.nonatomic = 1,
7188c2ecf20Sopenharmony_ci		.dynamic = 1,
7198c2ecf20Sopenharmony_ci		.ops = &kabylake_dmic_ops,
7208c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(dmic, dummy, platform),
7218c2ecf20Sopenharmony_ci	},
7228c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_HDMI1_PB] = {
7238c2ecf20Sopenharmony_ci		.name = "Kbl HDMI Port1",
7248c2ecf20Sopenharmony_ci		.stream_name = "Hdmi1",
7258c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
7268c2ecf20Sopenharmony_ci		.init = NULL,
7278c2ecf20Sopenharmony_ci		.trigger = {
7288c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
7298c2ecf20Sopenharmony_ci		.nonatomic = 1,
7308c2ecf20Sopenharmony_ci		.dynamic = 1,
7318c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
7328c2ecf20Sopenharmony_ci	},
7338c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_HDMI2_PB] = {
7348c2ecf20Sopenharmony_ci		.name = "Kbl HDMI Port2",
7358c2ecf20Sopenharmony_ci		.stream_name = "Hdmi2",
7368c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
7378c2ecf20Sopenharmony_ci		.init = NULL,
7388c2ecf20Sopenharmony_ci		.trigger = {
7398c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
7408c2ecf20Sopenharmony_ci		.nonatomic = 1,
7418c2ecf20Sopenharmony_ci		.dynamic = 1,
7428c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
7438c2ecf20Sopenharmony_ci	},
7448c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_HDMI3_PB] = {
7458c2ecf20Sopenharmony_ci		.name = "Kbl HDMI Port3",
7468c2ecf20Sopenharmony_ci		.stream_name = "Hdmi3",
7478c2ecf20Sopenharmony_ci		.trigger = {
7488c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
7498c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
7508c2ecf20Sopenharmony_ci		.init = NULL,
7518c2ecf20Sopenharmony_ci		.nonatomic = 1,
7528c2ecf20Sopenharmony_ci		.dynamic = 1,
7538c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
7548c2ecf20Sopenharmony_ci	},
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci	/* Back End DAI links */
7578c2ecf20Sopenharmony_ci	{
7588c2ecf20Sopenharmony_ci		/* SSP0 - Codec */
7598c2ecf20Sopenharmony_ci		.name = "SSP0-Codec",
7608c2ecf20Sopenharmony_ci		.id = 0,
7618c2ecf20Sopenharmony_ci		.no_pcm = 1,
7628c2ecf20Sopenharmony_ci		.dai_fmt = SND_SOC_DAIFMT_DSP_B |
7638c2ecf20Sopenharmony_ci			SND_SOC_DAIFMT_NB_NF |
7648c2ecf20Sopenharmony_ci			SND_SOC_DAIFMT_CBS_CFS,
7658c2ecf20Sopenharmony_ci		.ignore_pmdown_time = 1,
7668c2ecf20Sopenharmony_ci		.be_hw_params_fixup = kabylake_ssp_fixup,
7678c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
7688c2ecf20Sopenharmony_ci		.ops = &kabylake_ssp0_ops,
7698c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
7708c2ecf20Sopenharmony_ci	},
7718c2ecf20Sopenharmony_ci	{
7728c2ecf20Sopenharmony_ci		/* SSP1 - Codec */
7738c2ecf20Sopenharmony_ci		.name = "SSP1-Codec",
7748c2ecf20Sopenharmony_ci		.id = 1,
7758c2ecf20Sopenharmony_ci		.no_pcm = 1,
7768c2ecf20Sopenharmony_ci		.init = kabylake_rt5663_max98927_codec_init,
7778c2ecf20Sopenharmony_ci		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
7788c2ecf20Sopenharmony_ci			SND_SOC_DAIFMT_CBS_CFS,
7798c2ecf20Sopenharmony_ci		.ignore_pmdown_time = 1,
7808c2ecf20Sopenharmony_ci		.be_hw_params_fixup = kabylake_ssp_fixup,
7818c2ecf20Sopenharmony_ci		.ops = &kabylake_rt5663_ops,
7828c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
7838c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
7848c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
7858c2ecf20Sopenharmony_ci	},
7868c2ecf20Sopenharmony_ci	{
7878c2ecf20Sopenharmony_ci		.name = "dmic01",
7888c2ecf20Sopenharmony_ci		.id = 2,
7898c2ecf20Sopenharmony_ci		.be_hw_params_fixup = kabylake_dmic_fixup,
7908c2ecf20Sopenharmony_ci		.ignore_suspend = 1,
7918c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
7928c2ecf20Sopenharmony_ci		.no_pcm = 1,
7938c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(dmic01_pin, dmic_codec, platform),
7948c2ecf20Sopenharmony_ci	},
7958c2ecf20Sopenharmony_ci	{
7968c2ecf20Sopenharmony_ci		.name = "iDisp1",
7978c2ecf20Sopenharmony_ci		.id = 3,
7988c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
7998c2ecf20Sopenharmony_ci		.init = kabylake_hdmi1_init,
8008c2ecf20Sopenharmony_ci		.no_pcm = 1,
8018c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
8028c2ecf20Sopenharmony_ci	},
8038c2ecf20Sopenharmony_ci	{
8048c2ecf20Sopenharmony_ci		.name = "iDisp2",
8058c2ecf20Sopenharmony_ci		.id = 4,
8068c2ecf20Sopenharmony_ci		.init = kabylake_hdmi2_init,
8078c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
8088c2ecf20Sopenharmony_ci		.no_pcm = 1,
8098c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
8108c2ecf20Sopenharmony_ci	},
8118c2ecf20Sopenharmony_ci	{
8128c2ecf20Sopenharmony_ci		.name = "iDisp3",
8138c2ecf20Sopenharmony_ci		.id = 5,
8148c2ecf20Sopenharmony_ci		.init = kabylake_hdmi3_init,
8158c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
8168c2ecf20Sopenharmony_ci		.no_pcm = 1,
8178c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
8188c2ecf20Sopenharmony_ci	},
8198c2ecf20Sopenharmony_ci};
8208c2ecf20Sopenharmony_ci
8218c2ecf20Sopenharmony_cistatic struct snd_soc_dai_link kabylake_5663_dais[] = {
8228c2ecf20Sopenharmony_ci	/* Front End DAI links */
8238c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_5663_PB] = {
8248c2ecf20Sopenharmony_ci		.name = "Kbl Audio Port",
8258c2ecf20Sopenharmony_ci		.stream_name = "Audio",
8268c2ecf20Sopenharmony_ci		.dynamic = 1,
8278c2ecf20Sopenharmony_ci		.nonatomic = 1,
8288c2ecf20Sopenharmony_ci		.trigger = {
8298c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
8308c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
8318c2ecf20Sopenharmony_ci		.ops = &kabylake_rt5663_fe_ops,
8328c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(system, dummy, platform),
8338c2ecf20Sopenharmony_ci	},
8348c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_5663_CP] = {
8358c2ecf20Sopenharmony_ci		.name = "Kbl Audio Capture Port",
8368c2ecf20Sopenharmony_ci		.stream_name = "Audio Record",
8378c2ecf20Sopenharmony_ci		.dynamic = 1,
8388c2ecf20Sopenharmony_ci		.nonatomic = 1,
8398c2ecf20Sopenharmony_ci		.trigger = {
8408c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
8418c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
8428c2ecf20Sopenharmony_ci		.ops = &kabylake_rt5663_fe_ops,
8438c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(system, dummy, platform),
8448c2ecf20Sopenharmony_ci	},
8458c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_5663_HDMI1_PB] = {
8468c2ecf20Sopenharmony_ci		.name = "Kbl HDMI Port1",
8478c2ecf20Sopenharmony_ci		.stream_name = "Hdmi1",
8488c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
8498c2ecf20Sopenharmony_ci		.init = NULL,
8508c2ecf20Sopenharmony_ci		.trigger = {
8518c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
8528c2ecf20Sopenharmony_ci		.nonatomic = 1,
8538c2ecf20Sopenharmony_ci		.dynamic = 1,
8548c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
8558c2ecf20Sopenharmony_ci	},
8568c2ecf20Sopenharmony_ci	[KBL_DPCM_AUDIO_5663_HDMI2_PB] = {
8578c2ecf20Sopenharmony_ci		.name = "Kbl HDMI Port2",
8588c2ecf20Sopenharmony_ci		.stream_name = "Hdmi2",
8598c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
8608c2ecf20Sopenharmony_ci		.init = NULL,
8618c2ecf20Sopenharmony_ci		.trigger = {
8628c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
8638c2ecf20Sopenharmony_ci		.nonatomic = 1,
8648c2ecf20Sopenharmony_ci		.dynamic = 1,
8658c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
8668c2ecf20Sopenharmony_ci	},
8678c2ecf20Sopenharmony_ci
8688c2ecf20Sopenharmony_ci	/* Back End DAI links */
8698c2ecf20Sopenharmony_ci	{
8708c2ecf20Sopenharmony_ci		/* SSP1 - Codec */
8718c2ecf20Sopenharmony_ci		.name = "SSP1-Codec",
8728c2ecf20Sopenharmony_ci		.id = 0,
8738c2ecf20Sopenharmony_ci		.no_pcm = 1,
8748c2ecf20Sopenharmony_ci		.init = kabylake_rt5663_codec_init,
8758c2ecf20Sopenharmony_ci		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
8768c2ecf20Sopenharmony_ci			SND_SOC_DAIFMT_CBS_CFS,
8778c2ecf20Sopenharmony_ci		.ignore_pmdown_time = 1,
8788c2ecf20Sopenharmony_ci		.be_hw_params_fixup = kabylake_ssp_fixup,
8798c2ecf20Sopenharmony_ci		.ops = &kabylake_rt5663_ops,
8808c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
8818c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
8828c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
8838c2ecf20Sopenharmony_ci	},
8848c2ecf20Sopenharmony_ci	{
8858c2ecf20Sopenharmony_ci		.name = "iDisp1",
8868c2ecf20Sopenharmony_ci		.id = 1,
8878c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
8888c2ecf20Sopenharmony_ci		.init = kabylake_5663_hdmi1_init,
8898c2ecf20Sopenharmony_ci		.no_pcm = 1,
8908c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
8918c2ecf20Sopenharmony_ci	},
8928c2ecf20Sopenharmony_ci	{
8938c2ecf20Sopenharmony_ci		.name = "iDisp2",
8948c2ecf20Sopenharmony_ci		.id = 2,
8958c2ecf20Sopenharmony_ci		.init = kabylake_5663_hdmi2_init,
8968c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
8978c2ecf20Sopenharmony_ci		.no_pcm = 1,
8988c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
8998c2ecf20Sopenharmony_ci	},
9008c2ecf20Sopenharmony_ci};
9018c2ecf20Sopenharmony_ci
9028c2ecf20Sopenharmony_ci#define NAME_SIZE	32
9038c2ecf20Sopenharmony_cistatic int kabylake_card_late_probe(struct snd_soc_card *card)
9048c2ecf20Sopenharmony_ci{
9058c2ecf20Sopenharmony_ci	struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card);
9068c2ecf20Sopenharmony_ci	struct kbl_hdmi_pcm *pcm;
9078c2ecf20Sopenharmony_ci	struct snd_soc_component *component = NULL;
9088c2ecf20Sopenharmony_ci	int err, i = 0;
9098c2ecf20Sopenharmony_ci	char jack_name[NAME_SIZE];
9108c2ecf20Sopenharmony_ci
9118c2ecf20Sopenharmony_ci	list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
9128c2ecf20Sopenharmony_ci		component = pcm->codec_dai->component;
9138c2ecf20Sopenharmony_ci		snprintf(jack_name, sizeof(jack_name),
9148c2ecf20Sopenharmony_ci			"HDMI/DP, pcm=%d Jack", pcm->device);
9158c2ecf20Sopenharmony_ci		err = snd_soc_card_jack_new(card, jack_name,
9168c2ecf20Sopenharmony_ci					SND_JACK_AVOUT, &skylake_hdmi[i],
9178c2ecf20Sopenharmony_ci					NULL, 0);
9188c2ecf20Sopenharmony_ci
9198c2ecf20Sopenharmony_ci		if (err)
9208c2ecf20Sopenharmony_ci			return err;
9218c2ecf20Sopenharmony_ci
9228c2ecf20Sopenharmony_ci		err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
9238c2ecf20Sopenharmony_ci						&skylake_hdmi[i]);
9248c2ecf20Sopenharmony_ci		if (err < 0)
9258c2ecf20Sopenharmony_ci			return err;
9268c2ecf20Sopenharmony_ci
9278c2ecf20Sopenharmony_ci		i++;
9288c2ecf20Sopenharmony_ci	}
9298c2ecf20Sopenharmony_ci
9308c2ecf20Sopenharmony_ci	if (!component)
9318c2ecf20Sopenharmony_ci		return -EINVAL;
9328c2ecf20Sopenharmony_ci
9338c2ecf20Sopenharmony_ci	return hdac_hdmi_jack_port_init(component, &card->dapm);
9348c2ecf20Sopenharmony_ci}
9358c2ecf20Sopenharmony_ci
9368c2ecf20Sopenharmony_ci/* kabylake audio machine driver for SPT + RT5663 */
9378c2ecf20Sopenharmony_cistatic struct snd_soc_card kabylake_audio_card_rt5663_m98927 = {
9388c2ecf20Sopenharmony_ci	.name = "kblrt5663max",
9398c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
9408c2ecf20Sopenharmony_ci	.dai_link = kabylake_dais,
9418c2ecf20Sopenharmony_ci	.num_links = ARRAY_SIZE(kabylake_dais),
9428c2ecf20Sopenharmony_ci	.controls = kabylake_controls,
9438c2ecf20Sopenharmony_ci	.num_controls = ARRAY_SIZE(kabylake_controls),
9448c2ecf20Sopenharmony_ci	.dapm_widgets = kabylake_widgets,
9458c2ecf20Sopenharmony_ci	.num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
9468c2ecf20Sopenharmony_ci	.dapm_routes = kabylake_map,
9478c2ecf20Sopenharmony_ci	.num_dapm_routes = ARRAY_SIZE(kabylake_map),
9488c2ecf20Sopenharmony_ci	.codec_conf = max98927_codec_conf,
9498c2ecf20Sopenharmony_ci	.num_configs = ARRAY_SIZE(max98927_codec_conf),
9508c2ecf20Sopenharmony_ci	.fully_routed = true,
9518c2ecf20Sopenharmony_ci	.late_probe = kabylake_card_late_probe,
9528c2ecf20Sopenharmony_ci};
9538c2ecf20Sopenharmony_ci
9548c2ecf20Sopenharmony_ci/* kabylake audio machine driver for RT5663 */
9558c2ecf20Sopenharmony_cistatic struct snd_soc_card kabylake_audio_card_rt5663 = {
9568c2ecf20Sopenharmony_ci	.name = "kblrt5663",
9578c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
9588c2ecf20Sopenharmony_ci	.dai_link = kabylake_5663_dais,
9598c2ecf20Sopenharmony_ci	.num_links = ARRAY_SIZE(kabylake_5663_dais),
9608c2ecf20Sopenharmony_ci	.controls = kabylake_5663_controls,
9618c2ecf20Sopenharmony_ci	.num_controls = ARRAY_SIZE(kabylake_5663_controls),
9628c2ecf20Sopenharmony_ci	.dapm_widgets = kabylake_5663_widgets,
9638c2ecf20Sopenharmony_ci	.num_dapm_widgets = ARRAY_SIZE(kabylake_5663_widgets),
9648c2ecf20Sopenharmony_ci	.dapm_routes = kabylake_5663_map,
9658c2ecf20Sopenharmony_ci	.num_dapm_routes = ARRAY_SIZE(kabylake_5663_map),
9668c2ecf20Sopenharmony_ci	.fully_routed = true,
9678c2ecf20Sopenharmony_ci	.late_probe = kabylake_card_late_probe,
9688c2ecf20Sopenharmony_ci};
9698c2ecf20Sopenharmony_ci
9708c2ecf20Sopenharmony_cistatic int kabylake_audio_probe(struct platform_device *pdev)
9718c2ecf20Sopenharmony_ci{
9728c2ecf20Sopenharmony_ci	struct kbl_rt5663_private *ctx;
9738c2ecf20Sopenharmony_ci	struct snd_soc_acpi_mach *mach;
9748c2ecf20Sopenharmony_ci	int ret;
9758c2ecf20Sopenharmony_ci
9768c2ecf20Sopenharmony_ci	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
9778c2ecf20Sopenharmony_ci	if (!ctx)
9788c2ecf20Sopenharmony_ci		return -ENOMEM;
9798c2ecf20Sopenharmony_ci
9808c2ecf20Sopenharmony_ci	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
9818c2ecf20Sopenharmony_ci
9828c2ecf20Sopenharmony_ci	kabylake_audio_card =
9838c2ecf20Sopenharmony_ci		(struct snd_soc_card *)pdev->id_entry->driver_data;
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_ci	kabylake_audio_card->dev = &pdev->dev;
9868c2ecf20Sopenharmony_ci	snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
9878c2ecf20Sopenharmony_ci
9888c2ecf20Sopenharmony_ci	mach = pdev->dev.platform_data;
9898c2ecf20Sopenharmony_ci	if (mach)
9908c2ecf20Sopenharmony_ci		dmic_constraints = mach->mach_params.dmic_num == 2 ?
9918c2ecf20Sopenharmony_ci			&constraints_dmic_2ch : &constraints_dmic_channels;
9928c2ecf20Sopenharmony_ci
9938c2ecf20Sopenharmony_ci	ctx->mclk = devm_clk_get(&pdev->dev, "ssp1_mclk");
9948c2ecf20Sopenharmony_ci	if (IS_ERR(ctx->mclk)) {
9958c2ecf20Sopenharmony_ci		ret = PTR_ERR(ctx->mclk);
9968c2ecf20Sopenharmony_ci		if (ret == -ENOENT) {
9978c2ecf20Sopenharmony_ci			dev_info(&pdev->dev,
9988c2ecf20Sopenharmony_ci				"Failed to get ssp1_sclk, defer probe\n");
9998c2ecf20Sopenharmony_ci			return -EPROBE_DEFER;
10008c2ecf20Sopenharmony_ci		}
10018c2ecf20Sopenharmony_ci
10028c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Failed to get ssp1_mclk with err:%d\n",
10038c2ecf20Sopenharmony_ci								ret);
10048c2ecf20Sopenharmony_ci		return ret;
10058c2ecf20Sopenharmony_ci	}
10068c2ecf20Sopenharmony_ci
10078c2ecf20Sopenharmony_ci	ctx->sclk = devm_clk_get(&pdev->dev, "ssp1_sclk");
10088c2ecf20Sopenharmony_ci	if (IS_ERR(ctx->sclk)) {
10098c2ecf20Sopenharmony_ci		ret = PTR_ERR(ctx->sclk);
10108c2ecf20Sopenharmony_ci		if (ret == -ENOENT) {
10118c2ecf20Sopenharmony_ci			dev_info(&pdev->dev,
10128c2ecf20Sopenharmony_ci				"Failed to get ssp1_sclk, defer probe\n");
10138c2ecf20Sopenharmony_ci			return -EPROBE_DEFER;
10148c2ecf20Sopenharmony_ci		}
10158c2ecf20Sopenharmony_ci
10168c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Failed to get ssp1_sclk with err:%d\n",
10178c2ecf20Sopenharmony_ci								ret);
10188c2ecf20Sopenharmony_ci		return ret;
10198c2ecf20Sopenharmony_ci	}
10208c2ecf20Sopenharmony_ci
10218c2ecf20Sopenharmony_ci	return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
10228c2ecf20Sopenharmony_ci}
10238c2ecf20Sopenharmony_ci
10248c2ecf20Sopenharmony_cistatic const struct platform_device_id kbl_board_ids[] = {
10258c2ecf20Sopenharmony_ci	{
10268c2ecf20Sopenharmony_ci		.name = "kbl_rt5663",
10278c2ecf20Sopenharmony_ci		.driver_data = (kernel_ulong_t)&kabylake_audio_card_rt5663,
10288c2ecf20Sopenharmony_ci	},
10298c2ecf20Sopenharmony_ci	{
10308c2ecf20Sopenharmony_ci		.name = "kbl_rt5663_m98927",
10318c2ecf20Sopenharmony_ci		.driver_data =
10328c2ecf20Sopenharmony_ci			(kernel_ulong_t)&kabylake_audio_card_rt5663_m98927,
10338c2ecf20Sopenharmony_ci	},
10348c2ecf20Sopenharmony_ci	{ }
10358c2ecf20Sopenharmony_ci};
10368c2ecf20Sopenharmony_ci
10378c2ecf20Sopenharmony_cistatic struct platform_driver kabylake_audio = {
10388c2ecf20Sopenharmony_ci	.probe = kabylake_audio_probe,
10398c2ecf20Sopenharmony_ci	.driver = {
10408c2ecf20Sopenharmony_ci		.name = "kbl_rt5663_m98927",
10418c2ecf20Sopenharmony_ci		.pm = &snd_soc_pm_ops,
10428c2ecf20Sopenharmony_ci	},
10438c2ecf20Sopenharmony_ci	.id_table = kbl_board_ids,
10448c2ecf20Sopenharmony_ci};
10458c2ecf20Sopenharmony_ci
10468c2ecf20Sopenharmony_cimodule_platform_driver(kabylake_audio)
10478c2ecf20Sopenharmony_ci
10488c2ecf20Sopenharmony_ci/* Module information */
10498c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Audio Machine driver-RT5663 & MAX98927 in I2S mode");
10508c2ecf20Sopenharmony_ciMODULE_AUTHOR("Naveen M <naveen.m@intel.com>");
10518c2ecf20Sopenharmony_ciMODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
10528c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
10538c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:kbl_rt5663");
10548c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:kbl_rt5663_m98927");
1055