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 */ 888f5870dSLucas 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> 1388f5870dSLucas 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 VG_JUPITER 1 26c10955e4SLucas Tanure #define ACP5X_NAU8821_BCLK 3072000 279a617f0eSVijendar Mukunda #define ACP5X_NAU8821_FREQ_OUT 12288000 28c10955e4SLucas Tanure #define ACP5X_NAU8821_COMP_NAME "i2c-NVTN2020:00" 29c10955e4SLucas Tanure #define ACP5X_NAU8821_DAI_NAME "nau8821-hifi" 30c10955e4SLucas Tanure #define ACP5X_CS35L41_COMP_LNAME "spi-VLV1776:00" 31c10955e4SLucas Tanure #define ACP5X_CS35L41_COMP_RNAME "spi-VLV1776:01" 32c10955e4SLucas Tanure #define ACP5X_CS35L41_DAI_NAME "cs35l41-pcm" 3334a0094bSVijendar Mukunda 3434a0094bSVijendar Mukunda static unsigned long acp5x_machine_id; 3534a0094bSVijendar Mukunda static struct snd_soc_jack vg_headset; 3634a0094bSVijendar Mukunda 37ab89aa0dSLucas Tanure SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("acp5x_i2s_dma.0"))); 38ab89aa0dSLucas Tanure SND_SOC_DAILINK_DEF(acp5x_i2s, DAILINK_COMP_ARRAY(COMP_CPU("acp5x_i2s_playcap.0"))); 39ab89aa0dSLucas Tanure SND_SOC_DAILINK_DEF(acp5x_bt, DAILINK_COMP_ARRAY(COMP_CPU("acp5x_i2s_playcap.1"))); 40c10955e4SLucas Tanure SND_SOC_DAILINK_DEF(nau8821, DAILINK_COMP_ARRAY(COMP_CODEC(ACP5X_NAU8821_COMP_NAME, 41c10955e4SLucas Tanure ACP5X_NAU8821_DAI_NAME))); 42ab89aa0dSLucas Tanure 4334a0094bSVijendar Mukunda static struct snd_soc_jack_pin acp5x_nau8821_jack_pins[] = { 4434a0094bSVijendar Mukunda { 4534a0094bSVijendar Mukunda .pin = "Headphone", 4634a0094bSVijendar Mukunda .mask = SND_JACK_HEADPHONE, 4734a0094bSVijendar Mukunda }, 4834a0094bSVijendar Mukunda { 4934a0094bSVijendar Mukunda .pin = "Headset Mic", 5034a0094bSVijendar Mukunda .mask = SND_JACK_MICROPHONE, 5134a0094bSVijendar Mukunda }, 5234a0094bSVijendar Mukunda }; 5334a0094bSVijendar Mukunda 54ab89aa0dSLucas Tanure static const struct snd_kcontrol_new acp5x_8821_controls[] = { 55ab89aa0dSLucas Tanure SOC_DAPM_PIN_SWITCH("Headphone"), 56ab89aa0dSLucas Tanure SOC_DAPM_PIN_SWITCH("Headset Mic"), 57ab89aa0dSLucas Tanure SOC_DAPM_PIN_SWITCH("Int Mic"), 58ab89aa0dSLucas Tanure }; 59ab89aa0dSLucas Tanure 60ab89aa0dSLucas Tanure static int platform_clock_control(struct snd_soc_dapm_widget *w, 61ab89aa0dSLucas Tanure struct snd_kcontrol *k, int event) 62ab89aa0dSLucas Tanure { 63ab89aa0dSLucas Tanure struct snd_soc_dapm_context *dapm = w->dapm; 64ab89aa0dSLucas Tanure struct snd_soc_card *card = dapm->card; 65ab89aa0dSLucas Tanure struct snd_soc_dai *dai; 66ab89aa0dSLucas Tanure int ret = 0; 67ab89aa0dSLucas Tanure 68c10955e4SLucas Tanure dai = snd_soc_card_get_codec_dai(card, ACP5X_NAU8821_DAI_NAME); 69ab89aa0dSLucas Tanure if (!dai) { 70ab89aa0dSLucas Tanure dev_err(card->dev, "Codec dai not found\n"); 71ab89aa0dSLucas Tanure return -EIO; 72ab89aa0dSLucas Tanure } 73ab89aa0dSLucas Tanure 74ab89aa0dSLucas Tanure if (SND_SOC_DAPM_EVENT_OFF(event)) { 75ab89aa0dSLucas Tanure ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN); 76ab89aa0dSLucas Tanure if (ret < 0) { 77ab89aa0dSLucas Tanure dev_err(card->dev, "set sysclk err = %d\n", ret); 78ab89aa0dSLucas Tanure return -EIO; 79ab89aa0dSLucas Tanure } 80ab89aa0dSLucas Tanure } else { 81ab89aa0dSLucas Tanure ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_FLL_BLK, 0, SND_SOC_CLOCK_IN); 82ab89aa0dSLucas Tanure if (ret < 0) 83ab89aa0dSLucas Tanure dev_err(dai->dev, "can't set BLK clock %d\n", ret); 84c10955e4SLucas Tanure ret = snd_soc_dai_set_pll(dai, 0, 0, ACP5X_NAU8821_BCLK, ACP5X_NAU8821_FREQ_OUT); 85ab89aa0dSLucas Tanure if (ret < 0) 86ab89aa0dSLucas Tanure dev_err(dai->dev, "can't set FLL: %d\n", ret); 87ab89aa0dSLucas Tanure } 88ab89aa0dSLucas Tanure 89ab89aa0dSLucas Tanure return ret; 90ab89aa0dSLucas Tanure } 91ab89aa0dSLucas Tanure 9234a0094bSVijendar Mukunda static int acp5x_8821_init(struct snd_soc_pcm_runtime *rtd) 9334a0094bSVijendar Mukunda { 94ddd42a12SLucas Tanure struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 9534a0094bSVijendar Mukunda int ret; 9634a0094bSVijendar Mukunda 9734a0094bSVijendar Mukunda /* 9834a0094bSVijendar Mukunda * Headset buttons map to the google Reference headset. 9934a0094bSVijendar Mukunda * These can be configured by userspace. 10034a0094bSVijendar Mukunda */ 101ddd42a12SLucas Tanure ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", 10234a0094bSVijendar Mukunda SND_JACK_HEADSET | SND_JACK_BTN_0, 10334a0094bSVijendar Mukunda &vg_headset, acp5x_nau8821_jack_pins, 10434a0094bSVijendar Mukunda ARRAY_SIZE(acp5x_nau8821_jack_pins)); 10534a0094bSVijendar Mukunda if (ret) { 10634a0094bSVijendar Mukunda dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret); 10734a0094bSVijendar Mukunda return ret; 10834a0094bSVijendar Mukunda } 10934a0094bSVijendar Mukunda 11034a0094bSVijendar Mukunda snd_jack_set_key(vg_headset.jack, SND_JACK_BTN_0, KEY_MEDIA); 11134a0094bSVijendar Mukunda nau8821_enable_jack_detect(component, &vg_headset); 112ddd42a12SLucas Tanure 11334a0094bSVijendar Mukunda return ret; 11434a0094bSVijendar Mukunda } 11534a0094bSVijendar Mukunda 11634a0094bSVijendar Mukunda static const unsigned int rates[] = { 11734a0094bSVijendar Mukunda 48000, 11834a0094bSVijendar Mukunda }; 11934a0094bSVijendar Mukunda 12034a0094bSVijendar Mukunda static const struct snd_pcm_hw_constraint_list constraints_rates = { 12134a0094bSVijendar Mukunda .count = ARRAY_SIZE(rates), 12234a0094bSVijendar Mukunda .list = rates, 12334a0094bSVijendar Mukunda .mask = 0, 12434a0094bSVijendar Mukunda }; 12534a0094bSVijendar Mukunda 12634a0094bSVijendar Mukunda static const unsigned int channels[] = { 12734a0094bSVijendar Mukunda 2, 12834a0094bSVijendar Mukunda }; 12934a0094bSVijendar Mukunda 13034a0094bSVijendar Mukunda static const struct snd_pcm_hw_constraint_list constraints_channels = { 13134a0094bSVijendar Mukunda .count = ARRAY_SIZE(channels), 13234a0094bSVijendar Mukunda .list = channels, 13334a0094bSVijendar Mukunda .mask = 0, 13434a0094bSVijendar Mukunda }; 13534a0094bSVijendar Mukunda 1360c38cc1dSVijendar Mukunda static const unsigned int acp5x_nau8821_format[] = {32}; 1370c38cc1dSVijendar Mukunda 1380c38cc1dSVijendar Mukunda static struct snd_pcm_hw_constraint_list constraints_sample_bits = { 1390c38cc1dSVijendar Mukunda .list = acp5x_nau8821_format, 1400c38cc1dSVijendar Mukunda .count = ARRAY_SIZE(acp5x_nau8821_format), 1410c38cc1dSVijendar Mukunda }; 1420c38cc1dSVijendar Mukunda 14334a0094bSVijendar Mukunda static int acp5x_8821_startup(struct snd_pcm_substream *substream) 14434a0094bSVijendar Mukunda { 14534a0094bSVijendar Mukunda struct snd_pcm_runtime *runtime = substream->runtime; 146a2253ec7SZhen Ni struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 147ddd42a12SLucas Tanure struct acp5x_platform_info *machine = snd_soc_card_get_drvdata(rtd->card); 14834a0094bSVijendar Mukunda 14934a0094bSVijendar Mukunda machine->play_i2s_instance = I2S_SP_INSTANCE; 15034a0094bSVijendar Mukunda machine->cap_i2s_instance = I2S_SP_INSTANCE; 15134a0094bSVijendar Mukunda 15234a0094bSVijendar Mukunda runtime->hw.channels_max = DUAL_CHANNEL; 15334a0094bSVijendar Mukunda snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 15434a0094bSVijendar Mukunda &constraints_channels); 15534a0094bSVijendar Mukunda snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 15634a0094bSVijendar Mukunda &constraints_rates); 1570c38cc1dSVijendar Mukunda snd_pcm_hw_constraint_list(substream->runtime, 0, 1580c38cc1dSVijendar Mukunda SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 1590c38cc1dSVijendar Mukunda &constraints_sample_bits); 160ddd42a12SLucas Tanure 16134a0094bSVijendar Mukunda return 0; 16234a0094bSVijendar Mukunda } 16334a0094bSVijendar Mukunda 16434a0094bSVijendar Mukunda static int acp5x_nau8821_hw_params(struct snd_pcm_substream *substream, 16534a0094bSVijendar Mukunda struct snd_pcm_hw_params *params) 16634a0094bSVijendar Mukunda { 167a2253ec7SZhen Ni struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 16834a0094bSVijendar Mukunda struct snd_soc_card *card = rtd->card; 169c10955e4SLucas Tanure struct snd_soc_dai *dai = snd_soc_card_get_codec_dai(card, ACP5X_NAU8821_DAI_NAME); 1709490fbb8SLucas Tanure int ret, bclk; 17134a0094bSVijendar Mukunda 172ddd42a12SLucas Tanure ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_FLL_BLK, 0, SND_SOC_CLOCK_IN); 17334a0094bSVijendar Mukunda if (ret < 0) 17434a0094bSVijendar Mukunda dev_err(card->dev, "can't set FS clock %d\n", ret); 1759490fbb8SLucas Tanure 1769490fbb8SLucas Tanure bclk = snd_soc_params_to_bclk(params); 1779490fbb8SLucas Tanure if (bclk < 0) { 1789490fbb8SLucas Tanure dev_err(dai->dev, "Fail to get BCLK rate: %d\n", bclk); 1799490fbb8SLucas Tanure return bclk; 1809490fbb8SLucas Tanure } 1819490fbb8SLucas Tanure 1829490fbb8SLucas Tanure ret = snd_soc_dai_set_pll(dai, 0, 0, bclk, params_rate(params) * 256); 18334a0094bSVijendar Mukunda if (ret < 0) 18434a0094bSVijendar Mukunda dev_err(card->dev, "can't set FLL: %d\n", ret); 18534a0094bSVijendar Mukunda 18634a0094bSVijendar Mukunda return ret; 18734a0094bSVijendar Mukunda } 18834a0094bSVijendar Mukunda 189ab89aa0dSLucas Tanure static const struct snd_soc_ops acp5x_8821_ops = { 190ab89aa0dSLucas Tanure .startup = acp5x_8821_startup, 191ab89aa0dSLucas Tanure .hw_params = acp5x_nau8821_hw_params, 192ab89aa0dSLucas Tanure }; 193ab89aa0dSLucas Tanure 19434a0094bSVijendar Mukunda static int acp5x_cs35l41_startup(struct snd_pcm_substream *substream) 19534a0094bSVijendar Mukunda { 196a2253ec7SZhen Ni struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 197ddd42a12SLucas Tanure struct acp5x_platform_info *machine = snd_soc_card_get_drvdata(rtd->card); 198ddd42a12SLucas Tanure struct snd_pcm_runtime *runtime = substream->runtime; 19934a0094bSVijendar Mukunda 20034a0094bSVijendar Mukunda machine->play_i2s_instance = I2S_HS_INSTANCE; 20134a0094bSVijendar Mukunda 20234a0094bSVijendar Mukunda runtime->hw.channels_max = DUAL_CHANNEL; 20334a0094bSVijendar Mukunda snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 20434a0094bSVijendar Mukunda &constraints_channels); 20534a0094bSVijendar Mukunda snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 20634a0094bSVijendar Mukunda &constraints_rates); 207ddd42a12SLucas Tanure 20834a0094bSVijendar Mukunda return 0; 20934a0094bSVijendar Mukunda } 21034a0094bSVijendar Mukunda 21134a0094bSVijendar Mukunda static int acp5x_cs35l41_hw_params(struct snd_pcm_substream *substream, 21234a0094bSVijendar Mukunda struct snd_pcm_hw_params *params) 21334a0094bSVijendar Mukunda { 214a2253ec7SZhen Ni struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 215a719afe6SLucas Tanure unsigned int bclk, rate = params_rate(params); 216a719afe6SLucas Tanure struct snd_soc_component *comp; 217ddd42a12SLucas Tanure int ret, i; 21834a0094bSVijendar Mukunda 219a719afe6SLucas Tanure switch (rate) { 22034a0094bSVijendar Mukunda case 48000: 221a719afe6SLucas Tanure bclk = 1536000; 22234a0094bSVijendar Mukunda break; 22334a0094bSVijendar Mukunda default: 224a719afe6SLucas Tanure bclk = 0; 225a719afe6SLucas Tanure break; 226a719afe6SLucas Tanure } 227a719afe6SLucas Tanure 228a719afe6SLucas Tanure for_each_rtd_components(rtd, i, comp) { 229c10955e4SLucas Tanure if (!(strcmp(comp->name, ACP5X_CS35L41_COMP_LNAME)) || 230c10955e4SLucas Tanure !(strcmp(comp->name, ACP5X_CS35L41_COMP_RNAME))) { 231a719afe6SLucas Tanure if (!bclk) { 232a719afe6SLucas Tanure dev_err(comp->dev, "Invalid sample rate: 0x%x\n", rate); 23334a0094bSVijendar Mukunda return -EINVAL; 23434a0094bSVijendar Mukunda } 235a719afe6SLucas Tanure 236a719afe6SLucas Tanure ret = snd_soc_component_set_sysclk(comp, 0, 0, bclk, SND_SOC_CLOCK_IN); 237a719afe6SLucas Tanure if (ret) { 238a719afe6SLucas Tanure dev_err(comp->dev, "failed to set SYSCLK: %d\n", ret); 23934a0094bSVijendar Mukunda return ret; 24034a0094bSVijendar Mukunda } 24134a0094bSVijendar Mukunda } 24234a0094bSVijendar Mukunda } 24334a0094bSVijendar Mukunda 244a719afe6SLucas Tanure return 0; 245a719afe6SLucas Tanure 24634a0094bSVijendar Mukunda } 24734a0094bSVijendar Mukunda 24834a0094bSVijendar Mukunda static const struct snd_soc_ops acp5x_cs35l41_play_ops = { 24934a0094bSVijendar Mukunda .startup = acp5x_cs35l41_startup, 25034a0094bSVijendar Mukunda .hw_params = acp5x_cs35l41_hw_params, 25134a0094bSVijendar Mukunda }; 25234a0094bSVijendar Mukunda 253e9023248SLucas Tanure static struct snd_soc_codec_conf acp5x_cs35l41_conf[] = { 25434a0094bSVijendar Mukunda { 255c10955e4SLucas Tanure .dlc = COMP_CODEC_CONF(ACP5X_CS35L41_COMP_LNAME), 25634a0094bSVijendar Mukunda .name_prefix = "Left", 25734a0094bSVijendar Mukunda }, 25834a0094bSVijendar Mukunda { 259c10955e4SLucas Tanure .dlc = COMP_CODEC_CONF(ACP5X_CS35L41_COMP_RNAME), 26034a0094bSVijendar Mukunda .name_prefix = "Right", 26134a0094bSVijendar Mukunda }, 26234a0094bSVijendar Mukunda }; 26334a0094bSVijendar Mukunda 264c10955e4SLucas Tanure SND_SOC_DAILINK_DEF(cs35l41, DAILINK_COMP_ARRAY(COMP_CODEC(ACP5X_CS35L41_COMP_LNAME, 265c10955e4SLucas Tanure ACP5X_CS35L41_DAI_NAME), 266c10955e4SLucas Tanure COMP_CODEC(ACP5X_CS35L41_COMP_RNAME, 267c10955e4SLucas Tanure ACP5X_CS35L41_DAI_NAME))); 26834a0094bSVijendar Mukunda 269e9023248SLucas Tanure static struct snd_soc_dai_link acp5x_8821_35l41_dai[] = { 27034a0094bSVijendar Mukunda { 2715363d730SVijendar Mukunda .name = "acp5x-8821-play", 27234a0094bSVijendar Mukunda .stream_name = "Playback/Capture", 273ddd42a12SLucas Tanure .dai_fmt = SND_SOC_DAIFMT_I2S | 274ddd42a12SLucas Tanure SND_SOC_DAIFMT_NB_NF | 27534a0094bSVijendar Mukunda SND_SOC_DAIFMT_CBC_CFC, 27634a0094bSVijendar Mukunda .dpcm_playback = 1, 27734a0094bSVijendar Mukunda .dpcm_capture = 1, 27834a0094bSVijendar Mukunda .ops = &acp5x_8821_ops, 27934a0094bSVijendar Mukunda .init = acp5x_8821_init, 28034a0094bSVijendar Mukunda SND_SOC_DAILINK_REG(acp5x_i2s, nau8821, platform), 28134a0094bSVijendar Mukunda }, 28234a0094bSVijendar Mukunda { 28334a0094bSVijendar Mukunda .name = "acp5x-CS35L41-Stereo", 28434a0094bSVijendar Mukunda .stream_name = "CS35L41 Stereo Playback", 285ddd42a12SLucas Tanure .dai_fmt = SND_SOC_DAIFMT_I2S | 286ddd42a12SLucas Tanure SND_SOC_DAIFMT_NB_NF | 28734a0094bSVijendar Mukunda SND_SOC_DAIFMT_CBC_CFC, 28834a0094bSVijendar Mukunda .dpcm_playback = 1, 28934a0094bSVijendar Mukunda .playback_only = 1, 29034a0094bSVijendar Mukunda .ops = &acp5x_cs35l41_play_ops, 29134a0094bSVijendar Mukunda SND_SOC_DAILINK_REG(acp5x_bt, cs35l41, platform), 29234a0094bSVijendar Mukunda }, 29334a0094bSVijendar Mukunda }; 29434a0094bSVijendar Mukunda 29534a0094bSVijendar Mukunda 29634a0094bSVijendar Mukunda 297e9023248SLucas Tanure static const struct snd_soc_dapm_widget acp5x_8821_35l41_widgets[] = { 29834a0094bSVijendar Mukunda SND_SOC_DAPM_HP("Headphone", NULL), 29934a0094bSVijendar Mukunda SND_SOC_DAPM_MIC("Headset Mic", NULL), 30034a0094bSVijendar Mukunda SND_SOC_DAPM_MIC("Int Mic", NULL), 30134a0094bSVijendar Mukunda SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, 302ddd42a12SLucas Tanure platform_clock_control, 303ddd42a12SLucas Tanure SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 30434a0094bSVijendar Mukunda }; 30534a0094bSVijendar Mukunda 306e9023248SLucas Tanure static const struct snd_soc_dapm_route acp5x_8821_35l41_audio_route[] = { 30734a0094bSVijendar Mukunda /* HP jack connectors - unknown if we have jack detection */ 30834a0094bSVijendar Mukunda { "Headphone", NULL, "HPOL" }, 30934a0094bSVijendar Mukunda { "Headphone", NULL, "HPOR" }, 31034a0094bSVijendar Mukunda { "MICL", NULL, "Headset Mic" }, 31134a0094bSVijendar Mukunda { "MICR", NULL, "Headset Mic" }, 31234a0094bSVijendar Mukunda { "DMIC", NULL, "Int Mic" }, 31334a0094bSVijendar Mukunda 31434a0094bSVijendar Mukunda { "Headphone", NULL, "Platform Clock" }, 31534a0094bSVijendar Mukunda { "Headset Mic", NULL, "Platform Clock" }, 31634a0094bSVijendar Mukunda { "Int Mic", NULL, "Platform Clock" }, 31734a0094bSVijendar Mukunda }; 31834a0094bSVijendar Mukunda 319e9023248SLucas Tanure static struct snd_soc_card acp5x_8821_35l41_card = { 32034a0094bSVijendar Mukunda .name = "acp5x", 32134a0094bSVijendar Mukunda .owner = THIS_MODULE, 322e9023248SLucas Tanure .dai_link = acp5x_8821_35l41_dai, 323e9023248SLucas Tanure .num_links = ARRAY_SIZE(acp5x_8821_35l41_dai), 324e9023248SLucas Tanure .dapm_widgets = acp5x_8821_35l41_widgets, 325e9023248SLucas Tanure .num_dapm_widgets = ARRAY_SIZE(acp5x_8821_35l41_widgets), 326e9023248SLucas Tanure .dapm_routes = acp5x_8821_35l41_audio_route, 327e9023248SLucas Tanure .num_dapm_routes = ARRAY_SIZE(acp5x_8821_35l41_audio_route), 328e9023248SLucas Tanure .codec_conf = acp5x_cs35l41_conf, 329e9023248SLucas Tanure .num_configs = ARRAY_SIZE(acp5x_cs35l41_conf), 33034a0094bSVijendar Mukunda .controls = acp5x_8821_controls, 33134a0094bSVijendar Mukunda .num_controls = ARRAY_SIZE(acp5x_8821_controls), 33234a0094bSVijendar Mukunda }; 33334a0094bSVijendar Mukunda 33434a0094bSVijendar Mukunda static int acp5x_vg_quirk_cb(const struct dmi_system_id *id) 33534a0094bSVijendar Mukunda { 33634a0094bSVijendar Mukunda acp5x_machine_id = VG_JUPITER; 337ddd42a12SLucas Tanure 33834a0094bSVijendar Mukunda return 1; 33934a0094bSVijendar Mukunda } 34034a0094bSVijendar Mukunda 34134a0094bSVijendar Mukunda static const struct dmi_system_id acp5x_vg_quirk_table[] = { 34234a0094bSVijendar Mukunda { 34334a0094bSVijendar Mukunda .callback = acp5x_vg_quirk_cb, 34434a0094bSVijendar Mukunda .matches = { 34534a0094bSVijendar Mukunda DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Valve"), 34634a0094bSVijendar Mukunda DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Jupiter"), 34734a0094bSVijendar Mukunda } 34834a0094bSVijendar Mukunda }, 34934a0094bSVijendar Mukunda {} 35034a0094bSVijendar Mukunda }; 35134a0094bSVijendar Mukunda 35234a0094bSVijendar Mukunda static int acp5x_probe(struct platform_device *pdev) 35334a0094bSVijendar Mukunda { 35434a0094bSVijendar Mukunda struct acp5x_platform_info *machine; 355ddd42a12SLucas Tanure struct device *dev = &pdev->dev; 35634a0094bSVijendar Mukunda struct snd_soc_card *card; 357ddd42a12SLucas Tanure int ret; 35834a0094bSVijendar Mukunda 35950e81116SLucas Tanure machine = devm_kzalloc(dev, sizeof(*machine), GFP_KERNEL); 36034a0094bSVijendar Mukunda if (!machine) 36134a0094bSVijendar Mukunda return -ENOMEM; 36234a0094bSVijendar Mukunda 36334a0094bSVijendar Mukunda dmi_check_system(acp5x_vg_quirk_table); 36434a0094bSVijendar Mukunda switch (acp5x_machine_id) { 36534a0094bSVijendar Mukunda case VG_JUPITER: 366e9023248SLucas Tanure card = &acp5x_8821_35l41_card; 36734a0094bSVijendar Mukunda break; 36834a0094bSVijendar Mukunda default: 36934a0094bSVijendar Mukunda return -ENODEV; 37034a0094bSVijendar Mukunda } 371ddd42a12SLucas Tanure card->dev = dev; 37234a0094bSVijendar Mukunda platform_set_drvdata(pdev, card); 37334a0094bSVijendar Mukunda snd_soc_card_set_drvdata(card, machine); 37434a0094bSVijendar Mukunda 375ddd42a12SLucas Tanure ret = devm_snd_soc_register_card(dev, card); 376ddd42a12SLucas Tanure if (ret) 377ddd42a12SLucas Tanure return dev_err_probe(dev, ret, "Register card (%s) failed\n", card->name); 378ddd42a12SLucas Tanure 37934a0094bSVijendar Mukunda return 0; 38034a0094bSVijendar Mukunda } 38134a0094bSVijendar Mukunda 38234a0094bSVijendar Mukunda static struct platform_driver acp5x_mach_driver = { 38334a0094bSVijendar Mukunda .driver = { 384*a0cb05cbSCristian Ciocaltea .name = DRV_NAME, 38534a0094bSVijendar Mukunda .pm = &snd_soc_pm_ops, 38634a0094bSVijendar Mukunda }, 38734a0094bSVijendar Mukunda .probe = acp5x_probe, 38834a0094bSVijendar Mukunda }; 38934a0094bSVijendar Mukunda 39034a0094bSVijendar Mukunda module_platform_driver(acp5x_mach_driver); 39134a0094bSVijendar Mukunda 39234a0094bSVijendar Mukunda MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); 39334a0094bSVijendar Mukunda MODULE_DESCRIPTION("NAU8821 & CS35L41 audio support"); 39434a0094bSVijendar Mukunda MODULE_LICENSE("GPL v2"); 39534a0094bSVijendar Mukunda MODULE_ALIAS("platform:" DRV_NAME); 396