xref: /linux/sound/soc/amd/vangogh/acp5x-mach.c (revision 88f5870dd360e6604dceff808bf960bf6ddf0377)
134a0094bSVijendar Mukunda // SPDX-License-Identifier: GPL-2.0+
234a0094bSVijendar Mukunda /*
334a0094bSVijendar Mukunda  * Machine driver for AMD Vangogh platform using NAU8821 & CS35L41
434a0094bSVijendar Mukunda  * codecs.
534a0094bSVijendar Mukunda  *
634a0094bSVijendar Mukunda  * Copyright 2021 Advanced Micro Devices, Inc.
734a0094bSVijendar Mukunda  */
8*88f5870dSLucas Tanure 
9ddd42a12SLucas Tanure #include <linux/acpi.h>
10ddd42a12SLucas Tanure #include <linux/dmi.h>
1134a0094bSVijendar Mukunda #include <linux/gpio/consumer.h>
1234a0094bSVijendar Mukunda #include <linux/i2c.h>
13*88f5870dSLucas Tanure #include <linux/input-event-codes.h>
14ddd42a12SLucas Tanure #include <linux/module.h>
15ddd42a12SLucas Tanure #include <sound/jack.h>
16ddd42a12SLucas Tanure #include <sound/pcm_params.h>
17ddd42a12SLucas Tanure #include <sound/soc.h>
18ddd42a12SLucas Tanure #include <sound/soc-dapm.h>
1934a0094bSVijendar Mukunda 
2034a0094bSVijendar Mukunda #include "../../codecs/nau8821.h"
2134a0094bSVijendar Mukunda #include "acp5x.h"
2234a0094bSVijendar Mukunda 
2334a0094bSVijendar Mukunda #define DRV_NAME			"acp5x_mach"
2434a0094bSVijendar Mukunda #define DUAL_CHANNEL			2
2534a0094bSVijendar Mukunda #define ACP5X_NUVOTON_CODEC_DAI		"nau8821-hifi"
2634a0094bSVijendar Mukunda #define VG_JUPITER			1
279a617f0eSVijendar Mukunda #define ACP5X_NUVOTON_BCLK		3072000
289a617f0eSVijendar Mukunda #define ACP5X_NAU8821_FREQ_OUT		12288000
2934a0094bSVijendar Mukunda 
3034a0094bSVijendar Mukunda static unsigned long acp5x_machine_id;
3134a0094bSVijendar Mukunda static struct snd_soc_jack vg_headset;
3234a0094bSVijendar Mukunda 
3334a0094bSVijendar Mukunda static struct snd_soc_jack_pin acp5x_nau8821_jack_pins[] = {
3434a0094bSVijendar Mukunda 	{
3534a0094bSVijendar Mukunda 		.pin	= "Headphone",
3634a0094bSVijendar Mukunda 		.mask	= SND_JACK_HEADPHONE,
3734a0094bSVijendar Mukunda 	},
3834a0094bSVijendar Mukunda 	{
3934a0094bSVijendar Mukunda 		.pin	= "Headset Mic",
4034a0094bSVijendar Mukunda 		.mask	= SND_JACK_MICROPHONE,
4134a0094bSVijendar Mukunda 	},
4234a0094bSVijendar Mukunda };
4334a0094bSVijendar Mukunda 
4434a0094bSVijendar Mukunda static int acp5x_8821_init(struct snd_soc_pcm_runtime *rtd)
4534a0094bSVijendar Mukunda {
46ddd42a12SLucas Tanure 	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
4734a0094bSVijendar Mukunda 	int ret;
4834a0094bSVijendar Mukunda 
4934a0094bSVijendar Mukunda 	/*
5034a0094bSVijendar Mukunda 	 * Headset buttons map to the google Reference headset.
5134a0094bSVijendar Mukunda 	 * These can be configured by userspace.
5234a0094bSVijendar Mukunda 	 */
53ddd42a12SLucas Tanure 	ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
5434a0094bSVijendar Mukunda 					 SND_JACK_HEADSET | SND_JACK_BTN_0,
5534a0094bSVijendar Mukunda 					 &vg_headset, acp5x_nau8821_jack_pins,
5634a0094bSVijendar Mukunda 					 ARRAY_SIZE(acp5x_nau8821_jack_pins));
5734a0094bSVijendar Mukunda 	if (ret) {
5834a0094bSVijendar Mukunda 		dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
5934a0094bSVijendar Mukunda 		return ret;
6034a0094bSVijendar Mukunda 	}
6134a0094bSVijendar Mukunda 
6234a0094bSVijendar Mukunda 	snd_jack_set_key(vg_headset.jack, SND_JACK_BTN_0, KEY_MEDIA);
6334a0094bSVijendar Mukunda 	nau8821_enable_jack_detect(component, &vg_headset);
64ddd42a12SLucas Tanure 
6534a0094bSVijendar Mukunda 	return ret;
6634a0094bSVijendar Mukunda }
6734a0094bSVijendar Mukunda 
6834a0094bSVijendar Mukunda static const unsigned int rates[] = {
6934a0094bSVijendar Mukunda 	48000,
7034a0094bSVijendar Mukunda };
7134a0094bSVijendar Mukunda 
7234a0094bSVijendar Mukunda static const struct snd_pcm_hw_constraint_list constraints_rates = {
7334a0094bSVijendar Mukunda 	.count = ARRAY_SIZE(rates),
7434a0094bSVijendar Mukunda 	.list  = rates,
7534a0094bSVijendar Mukunda 	.mask = 0,
7634a0094bSVijendar Mukunda };
7734a0094bSVijendar Mukunda 
7834a0094bSVijendar Mukunda static const unsigned int channels[] = {
7934a0094bSVijendar Mukunda 	2,
8034a0094bSVijendar Mukunda };
8134a0094bSVijendar Mukunda 
8234a0094bSVijendar Mukunda static const struct snd_pcm_hw_constraint_list constraints_channels = {
8334a0094bSVijendar Mukunda 	.count = ARRAY_SIZE(channels),
8434a0094bSVijendar Mukunda 	.list = channels,
8534a0094bSVijendar Mukunda 	.mask = 0,
8634a0094bSVijendar Mukunda };
8734a0094bSVijendar Mukunda 
880c38cc1dSVijendar Mukunda static const unsigned int acp5x_nau8821_format[] = {32};
890c38cc1dSVijendar Mukunda 
900c38cc1dSVijendar Mukunda static struct snd_pcm_hw_constraint_list constraints_sample_bits = {
910c38cc1dSVijendar Mukunda 	.list = acp5x_nau8821_format,
920c38cc1dSVijendar Mukunda 	.count = ARRAY_SIZE(acp5x_nau8821_format),
930c38cc1dSVijendar Mukunda };
940c38cc1dSVijendar Mukunda 
9534a0094bSVijendar Mukunda static int acp5x_8821_startup(struct snd_pcm_substream *substream)
9634a0094bSVijendar Mukunda {
9734a0094bSVijendar Mukunda 	struct snd_pcm_runtime *runtime = substream->runtime;
98a2253ec7SZhen Ni 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
99ddd42a12SLucas Tanure 	struct acp5x_platform_info *machine = snd_soc_card_get_drvdata(rtd->card);
10034a0094bSVijendar Mukunda 
10134a0094bSVijendar Mukunda 	machine->play_i2s_instance = I2S_SP_INSTANCE;
10234a0094bSVijendar Mukunda 	machine->cap_i2s_instance = I2S_SP_INSTANCE;
10334a0094bSVijendar Mukunda 
10434a0094bSVijendar Mukunda 	runtime->hw.channels_max = DUAL_CHANNEL;
10534a0094bSVijendar Mukunda 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
10634a0094bSVijendar Mukunda 				   &constraints_channels);
10734a0094bSVijendar Mukunda 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
10834a0094bSVijendar Mukunda 				   &constraints_rates);
1090c38cc1dSVijendar Mukunda 	snd_pcm_hw_constraint_list(substream->runtime, 0,
1100c38cc1dSVijendar Mukunda 				   SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
1110c38cc1dSVijendar Mukunda 				   &constraints_sample_bits);
112ddd42a12SLucas Tanure 
11334a0094bSVijendar Mukunda 	return 0;
11434a0094bSVijendar Mukunda }
11534a0094bSVijendar Mukunda 
11634a0094bSVijendar Mukunda static int acp5x_nau8821_hw_params(struct snd_pcm_substream *substream,
11734a0094bSVijendar Mukunda 				   struct snd_pcm_hw_params *params)
11834a0094bSVijendar Mukunda {
119a2253ec7SZhen Ni 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
12034a0094bSVijendar Mukunda 	struct snd_soc_card *card = rtd->card;
121ddd42a12SLucas Tanure 	struct snd_soc_dai *dai = snd_soc_card_get_codec_dai(card, ACP5X_NUVOTON_CODEC_DAI);
12234a0094bSVijendar Mukunda 	int ret;
12334a0094bSVijendar Mukunda 
124ddd42a12SLucas Tanure 	ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_FLL_BLK, 0, SND_SOC_CLOCK_IN);
12534a0094bSVijendar Mukunda 	if (ret < 0)
12634a0094bSVijendar Mukunda 		dev_err(card->dev, "can't set FS clock %d\n", ret);
127ddd42a12SLucas Tanure 	ret = snd_soc_dai_set_pll(dai, 0, 0, snd_soc_params_to_bclk(params),
12834a0094bSVijendar Mukunda 				  params_rate(params) * 256);
12934a0094bSVijendar Mukunda 	if (ret < 0)
13034a0094bSVijendar Mukunda 		dev_err(card->dev, "can't set FLL: %d\n", ret);
13134a0094bSVijendar Mukunda 
13234a0094bSVijendar Mukunda 	return ret;
13334a0094bSVijendar Mukunda }
13434a0094bSVijendar Mukunda 
13534a0094bSVijendar Mukunda static int acp5x_cs35l41_startup(struct snd_pcm_substream *substream)
13634a0094bSVijendar Mukunda {
137a2253ec7SZhen Ni 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
138ddd42a12SLucas Tanure 	struct acp5x_platform_info *machine = snd_soc_card_get_drvdata(rtd->card);
139ddd42a12SLucas Tanure 	struct snd_pcm_runtime *runtime = substream->runtime;
14034a0094bSVijendar Mukunda 
14134a0094bSVijendar Mukunda 	machine->play_i2s_instance = I2S_HS_INSTANCE;
14234a0094bSVijendar Mukunda 
14334a0094bSVijendar Mukunda 	runtime->hw.channels_max = DUAL_CHANNEL;
14434a0094bSVijendar Mukunda 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
14534a0094bSVijendar Mukunda 				   &constraints_channels);
14634a0094bSVijendar Mukunda 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
14734a0094bSVijendar Mukunda 				   &constraints_rates);
148ddd42a12SLucas Tanure 
14934a0094bSVijendar Mukunda 	return 0;
15034a0094bSVijendar Mukunda }
15134a0094bSVijendar Mukunda 
15234a0094bSVijendar Mukunda static int acp5x_cs35l41_hw_params(struct snd_pcm_substream *substream,
15334a0094bSVijendar Mukunda 				   struct snd_pcm_hw_params *params)
15434a0094bSVijendar Mukunda {
155a2253ec7SZhen Ni 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1563989ade2SKuninori Morimoto 	unsigned int num_codecs = rtd->dai_link->num_codecs;
157ddd42a12SLucas Tanure 	struct snd_soc_card *card = rtd->card;
158ddd42a12SLucas Tanure 	struct snd_soc_dai *dai;
15934a0094bSVijendar Mukunda 	unsigned int bclk_val;
160ddd42a12SLucas Tanure 	int ret, i;
16134a0094bSVijendar Mukunda 
1626f989800SVijendar Mukunda 	ret = 0;
16334a0094bSVijendar Mukunda 	for (i = 0; i < num_codecs; i++) {
164ddd42a12SLucas Tanure 		dai = asoc_rtd_to_codec(rtd, i);
165ddd42a12SLucas Tanure 		if (strcmp(dai->name, "cs35l41-pcm") == 0) {
16634a0094bSVijendar Mukunda 			switch (params_rate(params)) {
16734a0094bSVijendar Mukunda 			case 48000:
16834a0094bSVijendar Mukunda 				bclk_val = 1536000;
16934a0094bSVijendar Mukunda 				break;
17034a0094bSVijendar Mukunda 			default:
17134a0094bSVijendar Mukunda 				dev_err(card->dev, "Invalid Samplerate:0x%x\n",
17234a0094bSVijendar Mukunda 					params_rate(params));
17334a0094bSVijendar Mukunda 				return -EINVAL;
17434a0094bSVijendar Mukunda 			}
175ddd42a12SLucas Tanure 			ret = snd_soc_component_set_sysclk(dai->component, 0, 0,
176ddd42a12SLucas Tanure 							   bclk_val, SND_SOC_CLOCK_IN);
17734a0094bSVijendar Mukunda 			if (ret < 0) {
17834a0094bSVijendar Mukunda 				dev_err(card->dev, "failed to set sysclk for CS35l41 dai\n");
17934a0094bSVijendar Mukunda 				return ret;
18034a0094bSVijendar Mukunda 			}
18134a0094bSVijendar Mukunda 		}
18234a0094bSVijendar Mukunda 	}
18334a0094bSVijendar Mukunda 
18434a0094bSVijendar Mukunda 	return ret;
18534a0094bSVijendar Mukunda }
18634a0094bSVijendar Mukunda 
18734a0094bSVijendar Mukunda static const struct snd_soc_ops acp5x_8821_ops = {
18834a0094bSVijendar Mukunda 	.startup = acp5x_8821_startup,
18934a0094bSVijendar Mukunda 	.hw_params = acp5x_nau8821_hw_params,
19034a0094bSVijendar Mukunda };
19134a0094bSVijendar Mukunda 
19234a0094bSVijendar Mukunda static const struct snd_soc_ops acp5x_cs35l41_play_ops = {
19334a0094bSVijendar Mukunda 	.startup = acp5x_cs35l41_startup,
19434a0094bSVijendar Mukunda 	.hw_params = acp5x_cs35l41_hw_params,
19534a0094bSVijendar Mukunda };
19634a0094bSVijendar Mukunda 
19734a0094bSVijendar Mukunda static struct snd_soc_codec_conf cs35l41_conf[] = {
19834a0094bSVijendar Mukunda 	{
19934a0094bSVijendar Mukunda 		.dlc = COMP_CODEC_CONF("spi-VLV1776:00"),
20034a0094bSVijendar Mukunda 		.name_prefix = "Left",
20134a0094bSVijendar Mukunda 	},
20234a0094bSVijendar Mukunda 	{
20334a0094bSVijendar Mukunda 		.dlc = COMP_CODEC_CONF("spi-VLV1776:01"),
20434a0094bSVijendar Mukunda 		.name_prefix = "Right",
20534a0094bSVijendar Mukunda 	},
20634a0094bSVijendar Mukunda };
20734a0094bSVijendar Mukunda 
208ddd42a12SLucas Tanure SND_SOC_DAILINK_DEF(platform,  DAILINK_COMP_ARRAY(COMP_PLATFORM("acp5x_i2s_dma.0")));
209ddd42a12SLucas Tanure SND_SOC_DAILINK_DEF(acp5x_i2s, DAILINK_COMP_ARRAY(COMP_CPU("acp5x_i2s_playcap.0")));
210ddd42a12SLucas Tanure SND_SOC_DAILINK_DEF(acp5x_bt,  DAILINK_COMP_ARRAY(COMP_CPU("acp5x_i2s_playcap.1")));
211ddd42a12SLucas Tanure SND_SOC_DAILINK_DEF(nau8821,   DAILINK_COMP_ARRAY(COMP_CODEC("i2c-NVTN2020:00", "nau8821-hifi")));
212ddd42a12SLucas Tanure SND_SOC_DAILINK_DEF(cs35l41,   DAILINK_COMP_ARRAY(COMP_CODEC("spi-VLV1776:00", "cs35l41-pcm"),
21334a0094bSVijendar Mukunda 						  COMP_CODEC("spi-VLV1776:01", "cs35l41-pcm")));
21434a0094bSVijendar Mukunda 
21534a0094bSVijendar Mukunda static struct snd_soc_dai_link acp5x_dai[] = {
21634a0094bSVijendar Mukunda 	{
2175363d730SVijendar Mukunda 		.name = "acp5x-8821-play",
21834a0094bSVijendar Mukunda 		.stream_name = "Playback/Capture",
219ddd42a12SLucas Tanure 		.dai_fmt = SND_SOC_DAIFMT_I2S |
220ddd42a12SLucas Tanure 			   SND_SOC_DAIFMT_NB_NF |
22134a0094bSVijendar Mukunda 			   SND_SOC_DAIFMT_CBC_CFC,
22234a0094bSVijendar Mukunda 		.dpcm_playback = 1,
22334a0094bSVijendar Mukunda 		.dpcm_capture = 1,
22434a0094bSVijendar Mukunda 		.ops = &acp5x_8821_ops,
22534a0094bSVijendar Mukunda 		.init = acp5x_8821_init,
22634a0094bSVijendar Mukunda 		SND_SOC_DAILINK_REG(acp5x_i2s, nau8821, platform),
22734a0094bSVijendar Mukunda 	},
22834a0094bSVijendar Mukunda 	{
22934a0094bSVijendar Mukunda 		.name = "acp5x-CS35L41-Stereo",
23034a0094bSVijendar Mukunda 		.stream_name = "CS35L41 Stereo Playback",
231ddd42a12SLucas Tanure 		.dai_fmt = SND_SOC_DAIFMT_I2S |
232ddd42a12SLucas Tanure 			   SND_SOC_DAIFMT_NB_NF |
23334a0094bSVijendar Mukunda 			   SND_SOC_DAIFMT_CBC_CFC,
23434a0094bSVijendar Mukunda 		.dpcm_playback = 1,
23534a0094bSVijendar Mukunda 		.playback_only = 1,
23634a0094bSVijendar Mukunda 		.ops = &acp5x_cs35l41_play_ops,
23734a0094bSVijendar Mukunda 		SND_SOC_DAILINK_REG(acp5x_bt, cs35l41, platform),
23834a0094bSVijendar Mukunda 	},
23934a0094bSVijendar Mukunda };
24034a0094bSVijendar Mukunda 
24134a0094bSVijendar Mukunda static int platform_clock_control(struct snd_soc_dapm_widget *w,
24234a0094bSVijendar Mukunda 				  struct snd_kcontrol *k, int event)
24334a0094bSVijendar Mukunda {
24434a0094bSVijendar Mukunda 	struct snd_soc_dapm_context *dapm = w->dapm;
24534a0094bSVijendar Mukunda 	struct snd_soc_card *card = dapm->card;
246ddd42a12SLucas Tanure 	struct snd_soc_dai *dai;
24734a0094bSVijendar Mukunda 	int ret = 0;
24834a0094bSVijendar Mukunda 
249ddd42a12SLucas Tanure 	dai = snd_soc_card_get_codec_dai(card, ACP5X_NUVOTON_CODEC_DAI);
250ddd42a12SLucas Tanure 	if (!dai) {
25134a0094bSVijendar Mukunda 		dev_err(card->dev, "Codec dai not found\n");
25234a0094bSVijendar Mukunda 		return -EIO;
25334a0094bSVijendar Mukunda 	}
25434a0094bSVijendar Mukunda 
25534a0094bSVijendar Mukunda 	if (SND_SOC_DAPM_EVENT_OFF(event)) {
256ddd42a12SLucas Tanure 		ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN);
25734a0094bSVijendar Mukunda 		if (ret < 0) {
25834a0094bSVijendar Mukunda 			dev_err(card->dev, "set sysclk err = %d\n", ret);
25934a0094bSVijendar Mukunda 			return -EIO;
26034a0094bSVijendar Mukunda 		}
2619a617f0eSVijendar Mukunda 	} else {
262ddd42a12SLucas Tanure 		ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_FLL_BLK, 0, SND_SOC_CLOCK_IN);
2639a617f0eSVijendar Mukunda 		if (ret < 0)
264ddd42a12SLucas Tanure 			dev_err(dai->dev, "can't set BLK clock %d\n", ret);
265ddd42a12SLucas Tanure 		ret = snd_soc_dai_set_pll(dai, 0, 0, ACP5X_NUVOTON_BCLK, ACP5X_NAU8821_FREQ_OUT);
2669a617f0eSVijendar Mukunda 		if (ret < 0)
267ddd42a12SLucas Tanure 			dev_err(dai->dev, "can't set FLL: %d\n", ret);
26834a0094bSVijendar Mukunda 	}
269ddd42a12SLucas Tanure 
27034a0094bSVijendar Mukunda 	return ret;
27134a0094bSVijendar Mukunda }
27234a0094bSVijendar Mukunda 
27334a0094bSVijendar Mukunda static const struct snd_kcontrol_new acp5x_8821_controls[] = {
27434a0094bSVijendar Mukunda 	SOC_DAPM_PIN_SWITCH("Headphone"),
27534a0094bSVijendar Mukunda 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
27634a0094bSVijendar Mukunda 	SOC_DAPM_PIN_SWITCH("Int Mic"),
27734a0094bSVijendar Mukunda };
27834a0094bSVijendar Mukunda 
27934a0094bSVijendar Mukunda static const struct snd_soc_dapm_widget acp5x_8821_widgets[] = {
28034a0094bSVijendar Mukunda 	SND_SOC_DAPM_HP("Headphone", NULL),
28134a0094bSVijendar Mukunda 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
28234a0094bSVijendar Mukunda 	SND_SOC_DAPM_MIC("Int Mic", NULL),
28334a0094bSVijendar Mukunda 	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
284ddd42a12SLucas Tanure 			    platform_clock_control,
285ddd42a12SLucas Tanure 			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
28634a0094bSVijendar Mukunda };
28734a0094bSVijendar Mukunda 
28834a0094bSVijendar Mukunda static const struct snd_soc_dapm_route acp5x_8821_audio_route[] = {
28934a0094bSVijendar Mukunda 	/* HP jack connectors - unknown if we have jack detection */
29034a0094bSVijendar Mukunda 	{ "Headphone", NULL, "HPOL" },
29134a0094bSVijendar Mukunda 	{ "Headphone", NULL, "HPOR" },
29234a0094bSVijendar Mukunda 	{ "MICL", NULL, "Headset Mic" },
29334a0094bSVijendar Mukunda 	{ "MICR", NULL, "Headset Mic" },
29434a0094bSVijendar Mukunda 	{ "DMIC", NULL, "Int Mic" },
29534a0094bSVijendar Mukunda 
29634a0094bSVijendar Mukunda 	{ "Headphone", NULL, "Platform Clock" },
29734a0094bSVijendar Mukunda 	{ "Headset Mic", NULL, "Platform Clock" },
29834a0094bSVijendar Mukunda 	{ "Int Mic", NULL, "Platform Clock" },
29934a0094bSVijendar Mukunda };
30034a0094bSVijendar Mukunda 
30134a0094bSVijendar Mukunda static struct snd_soc_card acp5x_card = {
30234a0094bSVijendar Mukunda 	.name = "acp5x",
30334a0094bSVijendar Mukunda 	.owner = THIS_MODULE,
30434a0094bSVijendar Mukunda 	.dai_link = acp5x_dai,
30534a0094bSVijendar Mukunda 	.num_links = ARRAY_SIZE(acp5x_dai),
30634a0094bSVijendar Mukunda 	.dapm_widgets = acp5x_8821_widgets,
30734a0094bSVijendar Mukunda 	.num_dapm_widgets = ARRAY_SIZE(acp5x_8821_widgets),
30834a0094bSVijendar Mukunda 	.dapm_routes = acp5x_8821_audio_route,
30934a0094bSVijendar Mukunda 	.num_dapm_routes = ARRAY_SIZE(acp5x_8821_audio_route),
31034a0094bSVijendar Mukunda 	.codec_conf = cs35l41_conf,
31134a0094bSVijendar Mukunda 	.num_configs = ARRAY_SIZE(cs35l41_conf),
31234a0094bSVijendar Mukunda 	.controls = acp5x_8821_controls,
31334a0094bSVijendar Mukunda 	.num_controls = ARRAY_SIZE(acp5x_8821_controls),
31434a0094bSVijendar Mukunda };
31534a0094bSVijendar Mukunda 
31634a0094bSVijendar Mukunda static int acp5x_vg_quirk_cb(const struct dmi_system_id *id)
31734a0094bSVijendar Mukunda {
31834a0094bSVijendar Mukunda 	acp5x_machine_id = VG_JUPITER;
319ddd42a12SLucas Tanure 
32034a0094bSVijendar Mukunda 	return 1;
32134a0094bSVijendar Mukunda }
32234a0094bSVijendar Mukunda 
32334a0094bSVijendar Mukunda static const struct dmi_system_id acp5x_vg_quirk_table[] = {
32434a0094bSVijendar Mukunda 	{
32534a0094bSVijendar Mukunda 		.callback = acp5x_vg_quirk_cb,
32634a0094bSVijendar Mukunda 		.matches = {
32734a0094bSVijendar Mukunda 			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Valve"),
32834a0094bSVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Jupiter"),
32934a0094bSVijendar Mukunda 		}
33034a0094bSVijendar Mukunda 	},
33134a0094bSVijendar Mukunda 	{}
33234a0094bSVijendar Mukunda };
33334a0094bSVijendar Mukunda 
33434a0094bSVijendar Mukunda static int acp5x_probe(struct platform_device *pdev)
33534a0094bSVijendar Mukunda {
33634a0094bSVijendar Mukunda 	struct acp5x_platform_info *machine;
337ddd42a12SLucas Tanure 	struct device *dev = &pdev->dev;
33834a0094bSVijendar Mukunda 	struct snd_soc_card *card;
339ddd42a12SLucas Tanure 	int ret;
34034a0094bSVijendar Mukunda 
34150e81116SLucas Tanure 	machine = devm_kzalloc(dev, sizeof(*machine), GFP_KERNEL);
34234a0094bSVijendar Mukunda 	if (!machine)
34334a0094bSVijendar Mukunda 		return -ENOMEM;
34434a0094bSVijendar Mukunda 
34534a0094bSVijendar Mukunda 	dmi_check_system(acp5x_vg_quirk_table);
34634a0094bSVijendar Mukunda 	switch (acp5x_machine_id) {
34734a0094bSVijendar Mukunda 	case VG_JUPITER:
34834a0094bSVijendar Mukunda 		card = &acp5x_card;
34934a0094bSVijendar Mukunda 		break;
35034a0094bSVijendar Mukunda 	default:
35134a0094bSVijendar Mukunda 		return -ENODEV;
35234a0094bSVijendar Mukunda 	}
353ddd42a12SLucas Tanure 	card->dev = dev;
35434a0094bSVijendar Mukunda 	platform_set_drvdata(pdev, card);
35534a0094bSVijendar Mukunda 	snd_soc_card_set_drvdata(card, machine);
35634a0094bSVijendar Mukunda 
357ddd42a12SLucas Tanure 	ret = devm_snd_soc_register_card(dev, card);
358ddd42a12SLucas Tanure 	if (ret)
359ddd42a12SLucas Tanure 		return dev_err_probe(dev, ret, "Register card (%s) failed\n", card->name);
360ddd42a12SLucas Tanure 
36134a0094bSVijendar Mukunda 	return 0;
36234a0094bSVijendar Mukunda }
36334a0094bSVijendar Mukunda 
36434a0094bSVijendar Mukunda static struct platform_driver acp5x_mach_driver = {
36534a0094bSVijendar Mukunda 	.driver = {
36634a0094bSVijendar Mukunda 		.name = "acp5x_mach",
36734a0094bSVijendar Mukunda 		.pm = &snd_soc_pm_ops,
36834a0094bSVijendar Mukunda 	},
36934a0094bSVijendar Mukunda 	.probe = acp5x_probe,
37034a0094bSVijendar Mukunda };
37134a0094bSVijendar Mukunda 
37234a0094bSVijendar Mukunda module_platform_driver(acp5x_mach_driver);
37334a0094bSVijendar Mukunda 
37434a0094bSVijendar Mukunda MODULE_AUTHOR("Vijendar.Mukunda@amd.com");
37534a0094bSVijendar Mukunda MODULE_DESCRIPTION("NAU8821 & CS35L41 audio support");
37634a0094bSVijendar Mukunda MODULE_LICENSE("GPL v2");
37734a0094bSVijendar Mukunda MODULE_ALIAS("platform:" DRV_NAME);
378