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

sof_cs42l42.c (16924B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2// Copyright(c) 2021 Intel Corporation.
      3
      4/*
      5 * Intel SOF Machine Driver with Cirrus Logic CS42L42 Codec
      6 * and speaker codec MAX98357A
      7 */
      8#include <linux/i2c.h>
      9#include <linux/input.h>
     10#include <linux/module.h>
     11#include <linux/platform_device.h>
     12#include <linux/regulator/consumer.h>
     13#include <linux/dmi.h>
     14#include <sound/core.h>
     15#include <sound/jack.h>
     16#include <sound/pcm.h>
     17#include <sound/pcm_params.h>
     18#include <sound/soc.h>
     19#include <sound/sof.h>
     20#include <sound/soc-acpi.h>
     21#include <dt-bindings/sound/cs42l42.h>
     22#include "../../codecs/hdac_hdmi.h"
     23#include "../common/soc-intel-quirks.h"
     24#include "hda_dsp_common.h"
     25#include "sof_maxim_common.h"
     26
     27#define NAME_SIZE 32
     28
     29#define SOF_CS42L42_SSP_CODEC(quirk)		((quirk) & GENMASK(2, 0))
     30#define SOF_CS42L42_SSP_CODEC_MASK		(GENMASK(2, 0))
     31#define SOF_SPEAKER_AMP_PRESENT			BIT(3)
     32#define SOF_CS42L42_SSP_AMP_SHIFT		4
     33#define SOF_CS42L42_SSP_AMP_MASK		(GENMASK(6, 4))
     34#define SOF_CS42L42_SSP_AMP(quirk)	\
     35	(((quirk) << SOF_CS42L42_SSP_AMP_SHIFT) & SOF_CS42L42_SSP_AMP_MASK)
     36#define SOF_CS42L42_NUM_HDMIDEV_SHIFT		7
     37#define SOF_CS42L42_NUM_HDMIDEV_MASK		(GENMASK(9, 7))
     38#define SOF_CS42L42_NUM_HDMIDEV(quirk)	\
     39	(((quirk) << SOF_CS42L42_NUM_HDMIDEV_SHIFT) & SOF_CS42L42_NUM_HDMIDEV_MASK)
     40#define SOF_CS42L42_DAILINK_SHIFT		10
     41#define SOF_CS42L42_DAILINK_MASK		(GENMASK(24, 10))
     42#define SOF_CS42L42_DAILINK(link1, link2, link3, link4, link5) \
     43	((((link1) | ((link2) << 3) | ((link3) << 6) | ((link4) << 9) | ((link5) << 12)) << SOF_CS42L42_DAILINK_SHIFT) & SOF_CS42L42_DAILINK_MASK)
     44#define SOF_MAX98357A_SPEAKER_AMP_PRESENT	BIT(25)
     45#define SOF_MAX98360A_SPEAKER_AMP_PRESENT	BIT(26)
     46
     47enum {
     48	LINK_NONE = 0,
     49	LINK_HP = 1,
     50	LINK_SPK = 2,
     51	LINK_DMIC = 3,
     52	LINK_HDMI = 4,
     53};
     54
     55/* Default: SSP2 */
     56static unsigned long sof_cs42l42_quirk = SOF_CS42L42_SSP_CODEC(2);
     57
     58struct sof_hdmi_pcm {
     59	struct list_head head;
     60	struct snd_soc_dai *codec_dai;
     61	struct snd_soc_jack hdmi_jack;
     62	int device;
     63};
     64
     65struct sof_card_private {
     66	struct snd_soc_jack headset_jack;
     67	struct list_head hdmi_pcm_list;
     68	bool common_hdmi_codec_drv;
     69};
     70
     71static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd)
     72{
     73	struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
     74	struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
     75	struct sof_hdmi_pcm *pcm;
     76
     77	pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
     78	if (!pcm)
     79		return -ENOMEM;
     80
     81	/* dai_link id is 1:1 mapped to the PCM device */
     82	pcm->device = rtd->dai_link->id;
     83	pcm->codec_dai = dai;
     84
     85	list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
     86
     87	return 0;
     88}
     89
     90static int sof_cs42l42_init(struct snd_soc_pcm_runtime *rtd)
     91{
     92	struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
     93	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
     94	struct snd_soc_jack *jack = &ctx->headset_jack;
     95	int ret;
     96
     97	/*
     98	 * Headset buttons map to the google Reference headset.
     99	 * These can be configured by userspace.
    100	 */
    101	ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
    102				    SND_JACK_HEADSET | SND_JACK_BTN_0 |
    103				    SND_JACK_BTN_1 | SND_JACK_BTN_2 |
    104				    SND_JACK_BTN_3,
    105				    jack);
    106	if (ret) {
    107		dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
    108		return ret;
    109	}
    110
    111	snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
    112	snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
    113	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
    114	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
    115
    116	ret = snd_soc_component_set_jack(component, jack, NULL);
    117	if (ret) {
    118		dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
    119		return ret;
    120	}
    121
    122	return ret;
    123};
    124
    125static void sof_cs42l42_exit(struct snd_soc_pcm_runtime *rtd)
    126{
    127	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
    128
    129	snd_soc_component_set_jack(component, NULL, NULL);
    130}
    131
    132static int sof_cs42l42_hw_params(struct snd_pcm_substream *substream,
    133				 struct snd_pcm_hw_params *params)
    134{
    135	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
    136	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
    137	int clk_freq, ret;
    138
    139	clk_freq = sof_dai_get_bclk(rtd); /* BCLK freq */
    140
    141	if (clk_freq <= 0) {
    142		dev_err(rtd->dev, "get bclk freq failed: %d\n", clk_freq);
    143		return -EINVAL;
    144	}
    145
    146	/* Configure sysclk for codec */
    147	ret = snd_soc_dai_set_sysclk(codec_dai, 0,
    148				     clk_freq, SND_SOC_CLOCK_IN);
    149	if (ret < 0)
    150		dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
    151
    152	return ret;
    153}
    154
    155static const struct snd_soc_ops sof_cs42l42_ops = {
    156	.hw_params = sof_cs42l42_hw_params,
    157};
    158
    159static struct snd_soc_dai_link_component platform_component[] = {
    160	{
    161		/* name might be overridden during probe */
    162		.name = "0000:00:1f.3"
    163	}
    164};
    165
    166static int sof_card_late_probe(struct snd_soc_card *card)
    167{
    168	struct sof_card_private *ctx = snd_soc_card_get_drvdata(card);
    169	struct snd_soc_component *component = NULL;
    170	char jack_name[NAME_SIZE];
    171	struct sof_hdmi_pcm *pcm;
    172	int err;
    173
    174	if (list_empty(&ctx->hdmi_pcm_list))
    175		return -EINVAL;
    176
    177	if (ctx->common_hdmi_codec_drv) {
    178		pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
    179				       head);
    180		component = pcm->codec_dai->component;
    181		return hda_dsp_hdmi_build_controls(card, component);
    182	}
    183
    184	list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
    185		component = pcm->codec_dai->component;
    186		snprintf(jack_name, sizeof(jack_name),
    187			 "HDMI/DP, pcm=%d Jack", pcm->device);
    188		err = snd_soc_card_jack_new(card, jack_name,
    189					    SND_JACK_AVOUT, &pcm->hdmi_jack);
    190
    191		if (err)
    192			return err;
    193
    194		err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
    195					  &pcm->hdmi_jack);
    196		if (err < 0)
    197			return err;
    198	}
    199
    200	return hdac_hdmi_jack_port_init(component, &card->dapm);
    201}
    202
    203static const struct snd_kcontrol_new sof_controls[] = {
    204	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
    205	SOC_DAPM_PIN_SWITCH("Headset Mic"),
    206};
    207
    208static const struct snd_soc_dapm_widget sof_widgets[] = {
    209	SND_SOC_DAPM_HP("Headphone Jack", NULL),
    210	SND_SOC_DAPM_MIC("Headset Mic", NULL),
    211};
    212
    213static const struct snd_soc_dapm_widget dmic_widgets[] = {
    214	SND_SOC_DAPM_MIC("SoC DMIC", NULL),
    215};
    216
    217static const struct snd_soc_dapm_route sof_map[] = {
    218	/* HP jack connectors - unknown if we have jack detection */
    219	{"Headphone Jack", NULL, "HP"},
    220
    221	/* other jacks */
    222	{"HS", NULL, "Headset Mic"},
    223};
    224
    225static const struct snd_soc_dapm_route dmic_map[] = {
    226	/* digital mics */
    227	{"DMic", NULL, "SoC DMIC"},
    228};
    229
    230static int dmic_init(struct snd_soc_pcm_runtime *rtd)
    231{
    232	struct snd_soc_card *card = rtd->card;
    233	int ret;
    234
    235	ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
    236					ARRAY_SIZE(dmic_widgets));
    237	if (ret) {
    238		dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
    239		/* Don't need to add routes if widget addition failed */
    240		return ret;
    241	}
    242
    243	ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
    244				      ARRAY_SIZE(dmic_map));
    245
    246	if (ret)
    247		dev_err(card->dev, "DMic map addition failed: %d\n", ret);
    248
    249	return ret;
    250}
    251
    252/* sof audio machine driver for cs42l42 codec */
    253static struct snd_soc_card sof_audio_card_cs42l42 = {
    254	.name = "cs42l42", /* the sof- prefix is added by the core */
    255	.owner = THIS_MODULE,
    256	.controls = sof_controls,
    257	.num_controls = ARRAY_SIZE(sof_controls),
    258	.dapm_widgets = sof_widgets,
    259	.num_dapm_widgets = ARRAY_SIZE(sof_widgets),
    260	.dapm_routes = sof_map,
    261	.num_dapm_routes = ARRAY_SIZE(sof_map),
    262	.fully_routed = true,
    263	.late_probe = sof_card_late_probe,
    264};
    265
    266static struct snd_soc_dai_link_component cs42l42_component[] = {
    267	{
    268		.name = "i2c-10134242:00",
    269		.dai_name = "cs42l42",
    270	}
    271};
    272
    273static struct snd_soc_dai_link_component dmic_component[] = {
    274	{
    275		.name = "dmic-codec",
    276		.dai_name = "dmic-hifi",
    277	}
    278};
    279
    280static int create_spk_amp_dai_links(struct device *dev,
    281				    struct snd_soc_dai_link *links,
    282				    struct snd_soc_dai_link_component *cpus,
    283				    int *id, int ssp_amp)
    284{
    285	int ret = 0;
    286
    287	/* speaker amp */
    288	if (!(sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT))
    289		return 0;
    290
    291	links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
    292					 ssp_amp);
    293	if (!links[*id].name) {
    294		ret = -ENOMEM;
    295		goto devm_err;
    296	}
    297
    298	links[*id].id = *id;
    299
    300	if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) {
    301		max_98357a_dai_link(&links[*id]);
    302	} else if (sof_cs42l42_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) {
    303		max_98360a_dai_link(&links[*id]);
    304	} else {
    305		dev_err(dev, "no amp defined\n");
    306		ret = -EINVAL;
    307		goto devm_err;
    308	}
    309
    310	links[*id].platforms = platform_component;
    311	links[*id].num_platforms = ARRAY_SIZE(platform_component);
    312	links[*id].dpcm_playback = 1;
    313	links[*id].no_pcm = 1;
    314	links[*id].cpus = &cpus[*id];
    315	links[*id].num_cpus = 1;
    316
    317	links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
    318						   "SSP%d Pin", ssp_amp);
    319	if (!links[*id].cpus->dai_name) {
    320		ret = -ENOMEM;
    321		goto devm_err;
    322	}
    323
    324	(*id)++;
    325
    326devm_err:
    327	return ret;
    328}
    329
    330static int create_hp_codec_dai_links(struct device *dev,
    331				     struct snd_soc_dai_link *links,
    332				     struct snd_soc_dai_link_component *cpus,
    333				     int *id, int ssp_codec)
    334{
    335	/* codec SSP */
    336	links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
    337					 ssp_codec);
    338	if (!links[*id].name)
    339		goto devm_err;
    340
    341	links[*id].id = *id;
    342	links[*id].codecs = cs42l42_component;
    343	links[*id].num_codecs = ARRAY_SIZE(cs42l42_component);
    344	links[*id].platforms = platform_component;
    345	links[*id].num_platforms = ARRAY_SIZE(platform_component);
    346	links[*id].init = sof_cs42l42_init;
    347	links[*id].exit = sof_cs42l42_exit;
    348	links[*id].ops = &sof_cs42l42_ops;
    349	links[*id].dpcm_playback = 1;
    350	links[*id].dpcm_capture = 1;
    351	links[*id].no_pcm = 1;
    352	links[*id].cpus = &cpus[*id];
    353	links[*id].num_cpus = 1;
    354
    355	links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
    356						   "SSP%d Pin",
    357						   ssp_codec);
    358	if (!links[*id].cpus->dai_name)
    359		goto devm_err;
    360
    361	(*id)++;
    362
    363	return 0;
    364
    365devm_err:
    366	return -ENOMEM;
    367}
    368
    369static int create_dmic_dai_links(struct device *dev,
    370				 struct snd_soc_dai_link *links,
    371				 struct snd_soc_dai_link_component *cpus,
    372				 int *id, int dmic_be_num)
    373{
    374	int i;
    375
    376	/* dmic */
    377	if (dmic_be_num <= 0)
    378		return 0;
    379
    380	/* at least we have dmic01 */
    381	links[*id].name = "dmic01";
    382	links[*id].cpus = &cpus[*id];
    383	links[*id].cpus->dai_name = "DMIC01 Pin";
    384	links[*id].init = dmic_init;
    385	if (dmic_be_num > 1) {
    386		/* set up 2 BE links at most */
    387		links[*id + 1].name = "dmic16k";
    388		links[*id + 1].cpus = &cpus[*id + 1];
    389		links[*id + 1].cpus->dai_name = "DMIC16k Pin";
    390		dmic_be_num = 2;
    391	}
    392
    393	for (i = 0; i < dmic_be_num; i++) {
    394		links[*id].id = *id;
    395		links[*id].num_cpus = 1;
    396		links[*id].codecs = dmic_component;
    397		links[*id].num_codecs = ARRAY_SIZE(dmic_component);
    398		links[*id].platforms = platform_component;
    399		links[*id].num_platforms = ARRAY_SIZE(platform_component);
    400		links[*id].ignore_suspend = 1;
    401		links[*id].dpcm_capture = 1;
    402		links[*id].no_pcm = 1;
    403
    404		(*id)++;
    405	}
    406
    407	return 0;
    408}
    409
    410static int create_hdmi_dai_links(struct device *dev,
    411				 struct snd_soc_dai_link *links,
    412				 struct snd_soc_dai_link_component *cpus,
    413				 int *id, int hdmi_num)
    414{
    415	struct snd_soc_dai_link_component *idisp_components;
    416	int i;
    417
    418	/* HDMI */
    419	if (hdmi_num <= 0)
    420		return 0;
    421
    422	idisp_components = devm_kzalloc(dev,
    423					sizeof(struct snd_soc_dai_link_component) *
    424					hdmi_num, GFP_KERNEL);
    425	if (!idisp_components)
    426		goto devm_err;
    427
    428	for (i = 1; i <= hdmi_num; i++) {
    429		links[*id].name = devm_kasprintf(dev, GFP_KERNEL,
    430						 "iDisp%d", i);
    431		if (!links[*id].name)
    432			goto devm_err;
    433
    434		links[*id].id = *id;
    435		links[*id].cpus = &cpus[*id];
    436		links[*id].num_cpus = 1;
    437		links[*id].cpus->dai_name = devm_kasprintf(dev,
    438							   GFP_KERNEL,
    439							   "iDisp%d Pin",
    440							   i);
    441		if (!links[*id].cpus->dai_name)
    442			goto devm_err;
    443
    444		idisp_components[i - 1].name = "ehdaudio0D2";
    445		idisp_components[i - 1].dai_name = devm_kasprintf(dev,
    446								  GFP_KERNEL,
    447								  "intel-hdmi-hifi%d",
    448								  i);
    449		if (!idisp_components[i - 1].dai_name)
    450			goto devm_err;
    451
    452		links[*id].codecs = &idisp_components[i - 1];
    453		links[*id].num_codecs = 1;
    454		links[*id].platforms = platform_component;
    455		links[*id].num_platforms = ARRAY_SIZE(platform_component);
    456		links[*id].init = sof_hdmi_init;
    457		links[*id].dpcm_playback = 1;
    458		links[*id].no_pcm = 1;
    459
    460		(*id)++;
    461	}
    462
    463	return 0;
    464
    465devm_err:
    466	return -ENOMEM;
    467}
    468
    469static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
    470							  int ssp_codec,
    471							  int ssp_amp,
    472							  int dmic_be_num,
    473							  int hdmi_num)
    474{
    475	struct snd_soc_dai_link_component *cpus;
    476	struct snd_soc_dai_link *links;
    477	int ret, id = 0, link_seq;
    478
    479	links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) *
    480			     sof_audio_card_cs42l42.num_links, GFP_KERNEL);
    481	cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component) *
    482			     sof_audio_card_cs42l42.num_links, GFP_KERNEL);
    483	if (!links || !cpus)
    484		goto devm_err;
    485
    486	link_seq = (sof_cs42l42_quirk & SOF_CS42L42_DAILINK_MASK) >> SOF_CS42L42_DAILINK_SHIFT;
    487
    488	while (link_seq) {
    489		int link_type = link_seq & 0x07;
    490
    491		switch (link_type) {
    492		case LINK_HP:
    493			ret = create_hp_codec_dai_links(dev, links, cpus, &id, ssp_codec);
    494			if (ret < 0) {
    495				dev_err(dev, "fail to create hp codec dai links, ret %d\n",
    496					ret);
    497				goto devm_err;
    498			}
    499			break;
    500		case LINK_SPK:
    501			ret = create_spk_amp_dai_links(dev, links, cpus, &id, ssp_amp);
    502			if (ret < 0) {
    503				dev_err(dev, "fail to create spk amp dai links, ret %d\n",
    504					ret);
    505				goto devm_err;
    506			}
    507			break;
    508		case LINK_DMIC:
    509			ret = create_dmic_dai_links(dev, links, cpus, &id, dmic_be_num);
    510			if (ret < 0) {
    511				dev_err(dev, "fail to create dmic dai links, ret %d\n",
    512					ret);
    513				goto devm_err;
    514			}
    515			break;
    516		case LINK_HDMI:
    517			ret = create_hdmi_dai_links(dev, links, cpus, &id, hdmi_num);
    518			if (ret < 0) {
    519				dev_err(dev, "fail to create hdmi dai links, ret %d\n",
    520					ret);
    521				goto devm_err;
    522			}
    523			break;
    524		case LINK_NONE:
    525			/* caught here if it's not used as terminator in macro */
    526		default:
    527			dev_err(dev, "invalid link type %d\n", link_type);
    528			goto devm_err;
    529		}
    530
    531		link_seq >>= 3;
    532	}
    533
    534	return links;
    535devm_err:
    536	return NULL;
    537}
    538
    539static int sof_audio_probe(struct platform_device *pdev)
    540{
    541	struct snd_soc_dai_link *dai_links;
    542	struct snd_soc_acpi_mach *mach;
    543	struct sof_card_private *ctx;
    544	int dmic_be_num, hdmi_num;
    545	int ret, ssp_amp, ssp_codec;
    546
    547	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
    548	if (!ctx)
    549		return -ENOMEM;
    550
    551	if (pdev->id_entry && pdev->id_entry->driver_data)
    552		sof_cs42l42_quirk = (unsigned long)pdev->id_entry->driver_data;
    553
    554	mach = pdev->dev.platform_data;
    555
    556	if (soc_intel_is_glk()) {
    557		dmic_be_num = 1;
    558		hdmi_num = 3;
    559	} else {
    560		dmic_be_num = 2;
    561		hdmi_num = (sof_cs42l42_quirk & SOF_CS42L42_NUM_HDMIDEV_MASK) >>
    562			 SOF_CS42L42_NUM_HDMIDEV_SHIFT;
    563		/* default number of HDMI DAI's */
    564		if (!hdmi_num)
    565			hdmi_num = 3;
    566	}
    567
    568	dev_dbg(&pdev->dev, "sof_cs42l42_quirk = %lx\n", sof_cs42l42_quirk);
    569
    570	ssp_amp = (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >>
    571			SOF_CS42L42_SSP_AMP_SHIFT;
    572
    573	ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK;
    574
    575	/* compute number of dai links */
    576	sof_audio_card_cs42l42.num_links = 1 + dmic_be_num + hdmi_num;
    577
    578	if (sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT)
    579		sof_audio_card_cs42l42.num_links++;
    580
    581	dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp,
    582					      dmic_be_num, hdmi_num);
    583	if (!dai_links)
    584		return -ENOMEM;
    585
    586	sof_audio_card_cs42l42.dai_link = dai_links;
    587
    588	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
    589
    590	sof_audio_card_cs42l42.dev = &pdev->dev;
    591
    592	/* set platform name for each dailink */
    593	ret = snd_soc_fixup_dai_links_platform_name(&sof_audio_card_cs42l42,
    594						    mach->mach_params.platform);
    595	if (ret)
    596		return ret;
    597
    598	ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
    599
    600	snd_soc_card_set_drvdata(&sof_audio_card_cs42l42, ctx);
    601
    602	return devm_snd_soc_register_card(&pdev->dev,
    603					  &sof_audio_card_cs42l42);
    604}
    605
    606static const struct platform_device_id board_ids[] = {
    607	{
    608		.name = "glk_cs4242_mx98357a",
    609		.driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(2) |
    610					SOF_SPEAKER_AMP_PRESENT |
    611					SOF_MAX98357A_SPEAKER_AMP_PRESENT |
    612					SOF_CS42L42_SSP_AMP(1)) |
    613					SOF_CS42L42_DAILINK(LINK_SPK, LINK_HP, LINK_DMIC, LINK_HDMI, LINK_NONE),
    614	},
    615	{
    616		.name = "jsl_cs4242_mx98360a",
    617		.driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) |
    618					SOF_SPEAKER_AMP_PRESENT |
    619					SOF_MAX98360A_SPEAKER_AMP_PRESENT |
    620					SOF_CS42L42_SSP_AMP(1)) |
    621					SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_NONE),
    622	},
    623	{ }
    624};
    625MODULE_DEVICE_TABLE(platform, board_ids);
    626
    627static struct platform_driver sof_audio = {
    628	.probe = sof_audio_probe,
    629	.driver = {
    630		.name = "sof_cs42l42",
    631		.pm = &snd_soc_pm_ops,
    632	},
    633	.id_table = board_ids,
    634};
    635module_platform_driver(sof_audio)
    636
    637/* Module information */
    638MODULE_DESCRIPTION("SOF Audio Machine driver for CS42L42");
    639MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
    640MODULE_LICENSE("GPL");
    641MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
    642MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);