cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

cml_rt1011_rt5682.c (16367B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2// Copyright(c) 2019 Intel Corporation.
      3
      4/*
      5 * Intel Cometlake I2S Machine driver for RT1011 + RT5682 codec
      6 */
      7
      8#include <linux/input.h>
      9#include <linux/module.h>
     10#include <linux/platform_device.h>
     11#include <linux/clk.h>
     12#include <linux/dmi.h>
     13#include <linux/slab.h>
     14#include <linux/acpi.h>
     15#include <sound/core.h>
     16#include <sound/jack.h>
     17#include <sound/pcm.h>
     18#include <sound/pcm_params.h>
     19#include <sound/soc.h>
     20#include <sound/rt5682.h>
     21#include <sound/soc-acpi.h>
     22#include "../../codecs/rt1011.h"
     23#include "../../codecs/rt5682.h"
     24#include "../../codecs/hdac_hdmi.h"
     25#include "hda_dsp_common.h"
     26
     27/* The platform clock outputs 24Mhz clock to codec as I2S MCLK */
     28#define CML_PLAT_CLK	24000000
     29#define CML_RT1011_CODEC_DAI "rt1011-aif"
     30#define CML_RT5682_CODEC_DAI "rt5682-aif1"
     31#define NAME_SIZE 32
     32
     33#define SOF_RT1011_SPEAKER_WL		BIT(0)
     34#define SOF_RT1011_SPEAKER_WR		BIT(1)
     35#define SOF_RT1011_SPEAKER_TL		BIT(2)
     36#define SOF_RT1011_SPEAKER_TR		BIT(3)
     37
     38/* Default: Woofer speakers  */
     39static unsigned long sof_rt1011_quirk = SOF_RT1011_SPEAKER_WL |
     40					SOF_RT1011_SPEAKER_WR;
     41
     42static int sof_rt1011_quirk_cb(const struct dmi_system_id *id)
     43{
     44	sof_rt1011_quirk = (unsigned long)id->driver_data;
     45	return 1;
     46}
     47
     48static const struct dmi_system_id sof_rt1011_quirk_table[] = {
     49	{
     50		.callback = sof_rt1011_quirk_cb,
     51		.matches = {
     52			DMI_MATCH(DMI_SYS_VENDOR, "Google"),
     53			DMI_MATCH(DMI_PRODUCT_NAME, "Helios"),
     54	},
     55		.driver_data = (void *)(SOF_RT1011_SPEAKER_WL | SOF_RT1011_SPEAKER_WR |
     56					SOF_RT1011_SPEAKER_TL | SOF_RT1011_SPEAKER_TR),
     57	},
     58	{
     59	}
     60};
     61
     62static struct snd_soc_jack hdmi_jack[3];
     63
     64struct hdmi_pcm {
     65	struct list_head head;
     66	struct snd_soc_dai *codec_dai;
     67	int device;
     68};
     69
     70struct card_private {
     71	char codec_name[SND_ACPI_I2C_ID_LEN];
     72	struct snd_soc_jack headset;
     73	struct list_head hdmi_pcm_list;
     74	bool common_hdmi_codec_drv;
     75};
     76
     77static const struct snd_kcontrol_new cml_controls[] = {
     78	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
     79	SOC_DAPM_PIN_SWITCH("Headset Mic"),
     80	SOC_DAPM_PIN_SWITCH("WL Ext Spk"),
     81	SOC_DAPM_PIN_SWITCH("WR Ext Spk"),
     82};
     83
     84static const struct snd_kcontrol_new cml_rt1011_tt_controls[] = {
     85	SOC_DAPM_PIN_SWITCH("TL Ext Spk"),
     86	SOC_DAPM_PIN_SWITCH("TR Ext Spk"),
     87};
     88
     89static const struct snd_soc_dapm_widget cml_rt1011_rt5682_widgets[] = {
     90	SND_SOC_DAPM_SPK("WL Ext Spk", NULL),
     91	SND_SOC_DAPM_SPK("WR Ext Spk", NULL),
     92	SND_SOC_DAPM_HP("Headphone Jack", NULL),
     93	SND_SOC_DAPM_MIC("Headset Mic", NULL),
     94	SND_SOC_DAPM_MIC("SoC DMIC", NULL),
     95};
     96
     97static const struct snd_soc_dapm_widget cml_rt1011_tt_widgets[] = {
     98	SND_SOC_DAPM_SPK("TL Ext Spk", NULL),
     99	SND_SOC_DAPM_SPK("TR Ext Spk", NULL),
    100};
    101
    102static const struct snd_soc_dapm_route cml_rt1011_rt5682_map[] = {
    103	/*WL/WR speaker*/
    104	{"WL Ext Spk", NULL, "WL SPO"},
    105	{"WR Ext Spk", NULL, "WR SPO"},
    106
    107	/* HP jack connectors - unknown if we have jack detection */
    108	{ "Headphone Jack", NULL, "HPOL" },
    109	{ "Headphone Jack", NULL, "HPOR" },
    110
    111	/* other jacks */
    112	{ "IN1P", NULL, "Headset Mic" },
    113
    114	/* DMIC */
    115	{"DMic", NULL, "SoC DMIC"},
    116};
    117
    118static const struct snd_soc_dapm_route cml_rt1011_tt_map[] = {
    119	/*TL/TR speaker*/
    120	{"TL Ext Spk", NULL, "TL SPO" },
    121	{"TR Ext Spk", NULL, "TR SPO" },
    122};
    123
    124static int cml_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
    125{
    126	struct card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
    127	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
    128	struct snd_soc_jack *jack;
    129	int ret;
    130
    131	/* need to enable ASRC function for 24MHz mclk rate */
    132	rt5682_sel_asrc_clk_src(component, RT5682_DA_STEREO1_FILTER |
    133					RT5682_AD_STEREO1_FILTER,
    134					RT5682_CLK_SEL_I2S1_ASRC);
    135
    136	/*
    137	 * Headset buttons map to the google Reference headset.
    138	 * These can be configured by userspace.
    139	 */
    140	ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
    141				    SND_JACK_HEADSET | SND_JACK_BTN_0 |
    142				    SND_JACK_BTN_1 | SND_JACK_BTN_2 |
    143				    SND_JACK_BTN_3,
    144				    &ctx->headset);
    145	if (ret) {
    146		dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
    147		return ret;
    148	}
    149
    150	jack = &ctx->headset;
    151
    152	snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
    153	snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
    154	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
    155	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
    156	ret = snd_soc_component_set_jack(component, jack, NULL);
    157	if (ret)
    158		dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
    159
    160	return ret;
    161};
    162
    163static void cml_rt5682_codec_exit(struct snd_soc_pcm_runtime *rtd)
    164{
    165	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
    166
    167	snd_soc_component_set_jack(component, NULL, NULL);
    168}
    169
    170static int cml_rt1011_spk_init(struct snd_soc_pcm_runtime *rtd)
    171{
    172	int ret = 0;
    173	struct snd_soc_card *card = rtd->card;
    174
    175	if (sof_rt1011_quirk & (SOF_RT1011_SPEAKER_TL |
    176				SOF_RT1011_SPEAKER_TR)) {
    177
    178		ret = snd_soc_add_card_controls(card, cml_rt1011_tt_controls,
    179					ARRAY_SIZE(cml_rt1011_tt_controls));
    180		if (ret)
    181			return ret;
    182
    183		ret = snd_soc_dapm_new_controls(&card->dapm,
    184					cml_rt1011_tt_widgets,
    185					ARRAY_SIZE(cml_rt1011_tt_widgets));
    186		if (ret)
    187			return ret;
    188
    189		ret = snd_soc_dapm_add_routes(&card->dapm, cml_rt1011_tt_map,
    190					ARRAY_SIZE(cml_rt1011_tt_map));
    191
    192		if (ret)
    193			return ret;
    194	}
    195
    196	return ret;
    197}
    198
    199static int cml_rt5682_hw_params(struct snd_pcm_substream *substream,
    200				struct snd_pcm_hw_params *params)
    201{
    202	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
    203	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
    204	int clk_id, clk_freq, pll_out, ret;
    205
    206	clk_id = RT5682_PLL1_S_MCLK;
    207	clk_freq = CML_PLAT_CLK;
    208
    209	pll_out = params_rate(params) * 512;
    210
    211	ret = snd_soc_dai_set_pll(codec_dai, 0, clk_id, clk_freq, pll_out);
    212	if (ret < 0)
    213		dev_warn(rtd->dev, "snd_soc_dai_set_pll err = %d\n", ret);
    214
    215	/* Configure sysclk for codec */
    216	ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL1,
    217				     pll_out, SND_SOC_CLOCK_IN);
    218	if (ret < 0)
    219		dev_warn(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
    220
    221	/*
    222	 * slot_width should be equal or large than data length, set them
    223	 * be the same
    224	 */
    225	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x0, 0x0, 2,
    226				       params_width(params));
    227	if (ret < 0)
    228		dev_warn(rtd->dev, "set TDM slot err:%d\n", ret);
    229	return ret;
    230}
    231
    232static int cml_rt1011_hw_params(struct snd_pcm_substream *substream,
    233				struct snd_pcm_hw_params *params)
    234{
    235	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
    236	struct snd_soc_dai *codec_dai;
    237	struct snd_soc_card *card = rtd->card;
    238	int srate, i, ret = 0;
    239
    240	srate = params_rate(params);
    241
    242	for_each_rtd_codec_dais(rtd, i, codec_dai) {
    243
    244		/* 100 Fs to drive 24 bit data */
    245		ret = snd_soc_dai_set_pll(codec_dai, 0, RT1011_PLL1_S_BCLK,
    246					  100 * srate, 256 * srate);
    247		if (ret < 0) {
    248			dev_err(card->dev, "codec_dai clock not set\n");
    249			return ret;
    250		}
    251
    252		ret = snd_soc_dai_set_sysclk(codec_dai,
    253					     RT1011_FS_SYS_PRE_S_PLL1,
    254					     256 * srate, SND_SOC_CLOCK_IN);
    255		if (ret < 0) {
    256			dev_err(card->dev, "codec_dai clock not set\n");
    257			return ret;
    258		}
    259
    260		/*
    261		 * Codec TDM is configured as 24 bit capture/ playback.
    262		 * 2 CH PB is done over 4 codecs - 2 Woofers and 2 Tweeters.
    263		 * The Left woofer and tweeter plays the Left playback data
    264		 * and  similar by the Right.
    265		 * Hence 2 codecs (1 T and 1 W pair) share same Rx slot.
    266		 * The feedback is captured for each codec individually.
    267		 * Hence all 4 codecs use 1 Tx slot each for feedback.
    268		 */
    269		if (sof_rt1011_quirk & (SOF_RT1011_SPEAKER_WL |
    270					SOF_RT1011_SPEAKER_WR)) {
    271			if (!strcmp(codec_dai->component->name, "i2c-10EC1011:00")) {
    272				ret = snd_soc_dai_set_tdm_slot(codec_dai,
    273							       0x4, 0x1, 4, 24);
    274				if (ret < 0)
    275					break;
    276			}
    277
    278			if (!strcmp(codec_dai->component->name, "i2c-10EC1011:01")) {
    279				ret = snd_soc_dai_set_tdm_slot(codec_dai,
    280							       0x8, 0x2, 4, 24);
    281				if (ret < 0)
    282					break;
    283			}
    284		}
    285
    286		if (sof_rt1011_quirk & (SOF_RT1011_SPEAKER_TL |
    287					SOF_RT1011_SPEAKER_TR)) {
    288			if (!strcmp(codec_dai->component->name, "i2c-10EC1011:02")) {
    289				ret = snd_soc_dai_set_tdm_slot(codec_dai,
    290							       0x1, 0x1, 4, 24);
    291				if (ret < 0)
    292					break;
    293			}
    294
    295			if (!strcmp(codec_dai->component->name, "i2c-10EC1011:03")) {
    296				ret = snd_soc_dai_set_tdm_slot(codec_dai,
    297							       0x2, 0x2, 4, 24);
    298				if (ret < 0)
    299					break;
    300			}
    301		}
    302	}
    303	if (ret < 0)
    304		dev_err(rtd->dev,
    305			"set codec TDM slot for %s failed with error %d\n",
    306			codec_dai->component->name, ret);
    307	return ret;
    308}
    309
    310static struct snd_soc_ops cml_rt5682_ops = {
    311	.hw_params = cml_rt5682_hw_params,
    312};
    313
    314static const struct snd_soc_ops cml_rt1011_ops = {
    315	.hw_params = cml_rt1011_hw_params,
    316};
    317
    318static int sof_card_late_probe(struct snd_soc_card *card)
    319{
    320	struct card_private *ctx = snd_soc_card_get_drvdata(card);
    321	struct snd_soc_component *component = NULL;
    322	char jack_name[NAME_SIZE];
    323	struct hdmi_pcm *pcm;
    324	int ret, i = 0;
    325
    326	if (list_empty(&ctx->hdmi_pcm_list))
    327		return -EINVAL;
    328
    329	if (ctx->common_hdmi_codec_drv) {
    330		pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
    331				       head);
    332		component = pcm->codec_dai->component;
    333		return hda_dsp_hdmi_build_controls(card, component);
    334	}
    335
    336	list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
    337		component = pcm->codec_dai->component;
    338		snprintf(jack_name, sizeof(jack_name),
    339			 "HDMI/DP, pcm=%d Jack", pcm->device);
    340		ret = snd_soc_card_jack_new(card, jack_name,
    341					    SND_JACK_AVOUT, &hdmi_jack[i]);
    342		if (ret)
    343			return ret;
    344
    345		ret = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
    346					  &hdmi_jack[i]);
    347		if (ret < 0)
    348			return ret;
    349
    350		i++;
    351	}
    352
    353	return hdac_hdmi_jack_port_init(component, &card->dapm);
    354}
    355
    356static int hdmi_init(struct snd_soc_pcm_runtime *rtd)
    357{
    358	struct card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
    359	struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
    360	struct hdmi_pcm *pcm;
    361
    362	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
    363	if (!pcm)
    364		return -ENOMEM;
    365
    366	pcm->device = dai->id;
    367	pcm->codec_dai = dai;
    368
    369	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
    370
    371	return 0;
    372}
    373
    374/* Cometlake digital audio interface glue - connects codec <--> CPU */
    375
    376SND_SOC_DAILINK_DEF(ssp0_pin,
    377	DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
    378SND_SOC_DAILINK_DEF(ssp0_codec,
    379	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5682:00",
    380				CML_RT5682_CODEC_DAI)));
    381
    382SND_SOC_DAILINK_DEF(ssp1_pin,
    383	DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
    384SND_SOC_DAILINK_DEF(ssp1_codec_2spk,
    385	DAILINK_COMP_ARRAY(
    386	/* WL */ COMP_CODEC("i2c-10EC1011:00", CML_RT1011_CODEC_DAI),
    387	/* WR */ COMP_CODEC("i2c-10EC1011:01", CML_RT1011_CODEC_DAI)));
    388SND_SOC_DAILINK_DEF(ssp1_codec_4spk,
    389	DAILINK_COMP_ARRAY(
    390	/* WL */ COMP_CODEC("i2c-10EC1011:00", CML_RT1011_CODEC_DAI),
    391	/* WR */ COMP_CODEC("i2c-10EC1011:01", CML_RT1011_CODEC_DAI),
    392	/* TL */ COMP_CODEC("i2c-10EC1011:02", CML_RT1011_CODEC_DAI),
    393	/* TR */ COMP_CODEC("i2c-10EC1011:03", CML_RT1011_CODEC_DAI)));
    394
    395
    396SND_SOC_DAILINK_DEF(dmic_pin,
    397	DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
    398
    399SND_SOC_DAILINK_DEF(dmic16k_pin,
    400	DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));
    401
    402SND_SOC_DAILINK_DEF(dmic_codec,
    403	DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
    404
    405SND_SOC_DAILINK_DEF(idisp1_pin,
    406	DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
    407SND_SOC_DAILINK_DEF(idisp1_codec,
    408	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
    409
    410SND_SOC_DAILINK_DEF(idisp2_pin,
    411	DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
    412SND_SOC_DAILINK_DEF(idisp2_codec,
    413	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
    414
    415SND_SOC_DAILINK_DEF(idisp3_pin,
    416	DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
    417SND_SOC_DAILINK_DEF(idisp3_codec,
    418	DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
    419
    420SND_SOC_DAILINK_DEF(platform,
    421	DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
    422
    423static struct snd_soc_dai_link cml_rt1011_rt5682_dailink[] = {
    424	/* Back End DAI links */
    425	{
    426		/* SSP0 - Codec */
    427		.name = "SSP0-Codec",
    428		.id = 0,
    429		.init = cml_rt5682_codec_init,
    430		.exit = cml_rt5682_codec_exit,
    431		.ignore_pmdown_time = 1,
    432		.ops = &cml_rt5682_ops,
    433		.dpcm_playback = 1,
    434		.dpcm_capture = 1,
    435		.no_pcm = 1,
    436		SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
    437	},
    438	{
    439		.name = "dmic01",
    440		.id = 1,
    441		.ignore_suspend = 1,
    442		.dpcm_capture = 1,
    443		.no_pcm = 1,
    444		SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
    445	},
    446	{
    447		.name = "dmic16k",
    448		.id = 2,
    449		.ignore_suspend = 1,
    450		.dpcm_capture = 1,
    451		.no_pcm = 1,
    452		SND_SOC_DAILINK_REG(dmic16k_pin, dmic_codec, platform),
    453	},
    454	{
    455		.name = "iDisp1",
    456		.id = 3,
    457		.init = hdmi_init,
    458		.dpcm_playback = 1,
    459		.no_pcm = 1,
    460		SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
    461	},
    462	{
    463		.name = "iDisp2",
    464		.id = 4,
    465		.init = hdmi_init,
    466		.dpcm_playback = 1,
    467		.no_pcm = 1,
    468		SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
    469	},
    470	{
    471		.name = "iDisp3",
    472		.id = 5,
    473		.init = hdmi_init,
    474		.dpcm_playback = 1,
    475		.no_pcm = 1,
    476		SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
    477	},
    478	{
    479		/*
    480		 * SSP1 - Codec : added to end of list ensuring
    481		 * reuse of common topologies for other end points
    482		 * and changing only SSP1's codec
    483		 */
    484		.name = "SSP1-Codec",
    485		.id = 6,
    486		.dpcm_playback = 1,
    487		.dpcm_capture = 1, /* Capture stream provides Feedback */
    488		.no_pcm = 1,
    489		.init = cml_rt1011_spk_init,
    490		.ops = &cml_rt1011_ops,
    491		SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec_2spk, platform),
    492	},
    493};
    494
    495static struct snd_soc_codec_conf rt1011_conf[] = {
    496	{
    497		.dlc = COMP_CODEC_CONF("i2c-10EC1011:00"),
    498		.name_prefix = "WL",
    499	},
    500	{
    501		.dlc = COMP_CODEC_CONF("i2c-10EC1011:01"),
    502		.name_prefix = "WR",
    503	},
    504	/* single configuration structure for 2 and 4 channels */
    505	{
    506		.dlc = COMP_CODEC_CONF("i2c-10EC1011:02"),
    507		.name_prefix = "TL",
    508	},
    509	{
    510		.dlc = COMP_CODEC_CONF("i2c-10EC1011:03"),
    511		.name_prefix = "TR",
    512	},
    513};
    514
    515/* Cometlake audio machine driver for RT1011 and RT5682 */
    516static struct snd_soc_card snd_soc_card_cml = {
    517	.name = "cml_rt1011_rt5682",
    518	.owner = THIS_MODULE,
    519	.dai_link = cml_rt1011_rt5682_dailink,
    520	.num_links = ARRAY_SIZE(cml_rt1011_rt5682_dailink),
    521	.codec_conf = rt1011_conf,
    522	.num_configs = ARRAY_SIZE(rt1011_conf),
    523	.dapm_widgets = cml_rt1011_rt5682_widgets,
    524	.num_dapm_widgets = ARRAY_SIZE(cml_rt1011_rt5682_widgets),
    525	.dapm_routes = cml_rt1011_rt5682_map,
    526	.num_dapm_routes = ARRAY_SIZE(cml_rt1011_rt5682_map),
    527	.controls = cml_controls,
    528	.num_controls = ARRAY_SIZE(cml_controls),
    529	.fully_routed = true,
    530	.late_probe = sof_card_late_probe,
    531};
    532
    533static int snd_cml_rt1011_probe(struct platform_device *pdev)
    534{
    535	struct snd_soc_dai_link *dai_link;
    536	struct card_private *ctx;
    537	struct snd_soc_acpi_mach *mach;
    538	const char *platform_name;
    539	int ret, i;
    540
    541	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
    542	if (!ctx)
    543		return -ENOMEM;
    544
    545	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
    546	mach = pdev->dev.platform_data;
    547	snd_soc_card_cml.dev = &pdev->dev;
    548	platform_name = mach->mach_params.platform;
    549
    550	dmi_check_system(sof_rt1011_quirk_table);
    551
    552	dev_dbg(&pdev->dev, "sof_rt1011_quirk = %lx\n", sof_rt1011_quirk);
    553
    554	/* when 4 speaker is available, update codec config */
    555	if (sof_rt1011_quirk & (SOF_RT1011_SPEAKER_TL |
    556				SOF_RT1011_SPEAKER_TR)) {
    557		for_each_card_prelinks(&snd_soc_card_cml, i, dai_link) {
    558			if (!strcmp(dai_link->codecs[0].dai_name,
    559				    CML_RT1011_CODEC_DAI)) {
    560				dai_link->codecs = ssp1_codec_4spk;
    561				dai_link->num_codecs = ARRAY_SIZE(ssp1_codec_4spk);
    562			}
    563		}
    564	}
    565
    566	/* set platform name for each dailink */
    567	ret = snd_soc_fixup_dai_links_platform_name(&snd_soc_card_cml,
    568						    platform_name);
    569	if (ret)
    570		return ret;
    571
    572	ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
    573
    574	snd_soc_card_set_drvdata(&snd_soc_card_cml, ctx);
    575
    576	return devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cml);
    577}
    578
    579static struct platform_driver snd_cml_rt1011_rt5682_driver = {
    580	.probe = snd_cml_rt1011_probe,
    581	.driver = {
    582		.name = "cml_rt1011_rt5682",
    583		.pm = &snd_soc_pm_ops,
    584	},
    585};
    586module_platform_driver(snd_cml_rt1011_rt5682_driver);
    587
    588/* Module information */
    589MODULE_DESCRIPTION("Cometlake Audio Machine driver - RT1011 and RT5682 in I2S mode");
    590MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
    591MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>");
    592MODULE_AUTHOR("Shuming Fan <shumingf@realtek.com>");
    593MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
    594MODULE_LICENSE("GPL v2");
    595MODULE_ALIAS("platform:cml_rt1011_rt5682");
    596MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);