18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci// Copyright(c) 2018 Intel Corporation. 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci/* 58c2ecf20Sopenharmony_ci * Intel Geminilake I2S Machine Driver with MAX98357A & RT5682 Codecs 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Modified from: 88c2ecf20Sopenharmony_ci * Intel Apollolake I2S Machine driver 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/input.h> 128c2ecf20Sopenharmony_ci#include <linux/module.h> 138c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 148c2ecf20Sopenharmony_ci#include <sound/core.h> 158c2ecf20Sopenharmony_ci#include <sound/jack.h> 168c2ecf20Sopenharmony_ci#include <sound/pcm.h> 178c2ecf20Sopenharmony_ci#include <sound/pcm_params.h> 188c2ecf20Sopenharmony_ci#include <sound/soc.h> 198c2ecf20Sopenharmony_ci#include <sound/soc-acpi.h> 208c2ecf20Sopenharmony_ci#include "../../codecs/rt5682.h" 218c2ecf20Sopenharmony_ci#include "../../codecs/hdac_hdmi.h" 228c2ecf20Sopenharmony_ci#include "hda_dsp_common.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* The platform clock outputs 19.2Mhz clock to codec as I2S MCLK */ 258c2ecf20Sopenharmony_ci#define GLK_PLAT_CLK_FREQ 19200000 268c2ecf20Sopenharmony_ci#define RT5682_PLL_FREQ (48000 * 512) 278c2ecf20Sopenharmony_ci#define GLK_REALTEK_CODEC_DAI "rt5682-aif1" 288c2ecf20Sopenharmony_ci#define GLK_MAXIM_CODEC_DAI "HiFi" 298c2ecf20Sopenharmony_ci#define MAXIM_DEV0_NAME "MX98357A:00" 308c2ecf20Sopenharmony_ci#define DUAL_CHANNEL 2 318c2ecf20Sopenharmony_ci#define QUAD_CHANNEL 4 328c2ecf20Sopenharmony_ci#define NAME_SIZE 32 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic struct snd_soc_jack geminilake_hdmi[3]; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistruct glk_hdmi_pcm { 378c2ecf20Sopenharmony_ci struct list_head head; 388c2ecf20Sopenharmony_ci struct snd_soc_dai *codec_dai; 398c2ecf20Sopenharmony_ci int device; 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct glk_card_private { 438c2ecf20Sopenharmony_ci struct snd_soc_jack geminilake_headset; 448c2ecf20Sopenharmony_ci struct list_head hdmi_pcm_list; 458c2ecf20Sopenharmony_ci bool common_hdmi_codec_drv; 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cienum { 498c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_PB = 0, 508c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_CP, 518c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_HS_PB, 528c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_ECHO_REF_CP, 538c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_REF_CP, 548c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_DMIC_CP, 558c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_HDMI1_PB, 568c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_HDMI2_PB, 578c2ecf20Sopenharmony_ci GLK_DPCM_AUDIO_HDMI3_PB, 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new geminilake_controls[] = { 618c2ecf20Sopenharmony_ci SOC_DAPM_PIN_SWITCH("Headphone Jack"), 628c2ecf20Sopenharmony_ci SOC_DAPM_PIN_SWITCH("Headset Mic"), 638c2ecf20Sopenharmony_ci SOC_DAPM_PIN_SWITCH("Spk"), 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget geminilake_widgets[] = { 678c2ecf20Sopenharmony_ci SND_SOC_DAPM_HP("Headphone Jack", NULL), 688c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIC("Headset Mic", NULL), 698c2ecf20Sopenharmony_ci SND_SOC_DAPM_SPK("Spk", NULL), 708c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIC("SoC DMIC", NULL), 718c2ecf20Sopenharmony_ci SND_SOC_DAPM_SPK("HDMI1", NULL), 728c2ecf20Sopenharmony_ci SND_SOC_DAPM_SPK("HDMI2", NULL), 738c2ecf20Sopenharmony_ci SND_SOC_DAPM_SPK("HDMI3", NULL), 748c2ecf20Sopenharmony_ci}; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route geminilake_map[] = { 778c2ecf20Sopenharmony_ci /* HP jack connectors - unknown if we have jack detection */ 788c2ecf20Sopenharmony_ci { "Headphone Jack", NULL, "HPOL" }, 798c2ecf20Sopenharmony_ci { "Headphone Jack", NULL, "HPOR" }, 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci /* speaker */ 828c2ecf20Sopenharmony_ci { "Spk", NULL, "Speaker" }, 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci /* other jacks */ 858c2ecf20Sopenharmony_ci { "IN1P", NULL, "Headset Mic" }, 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci /* digital mics */ 888c2ecf20Sopenharmony_ci { "DMic", NULL, "SoC DMIC" }, 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci /* CODEC BE connections */ 918c2ecf20Sopenharmony_ci { "HiFi Playback", NULL, "ssp1 Tx" }, 928c2ecf20Sopenharmony_ci { "ssp1 Tx", NULL, "codec0_out" }, 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci { "AIF1 Playback", NULL, "ssp2 Tx" }, 958c2ecf20Sopenharmony_ci { "ssp2 Tx", NULL, "codec1_out" }, 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci { "codec0_in", NULL, "ssp2 Rx" }, 988c2ecf20Sopenharmony_ci { "ssp2 Rx", NULL, "AIF1 Capture" }, 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci { "HDMI1", NULL, "hif5-0 Output" }, 1018c2ecf20Sopenharmony_ci { "HDMI2", NULL, "hif6-0 Output" }, 1028c2ecf20Sopenharmony_ci { "HDMI2", NULL, "hif7-0 Output" }, 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci { "hifi3", NULL, "iDisp3 Tx" }, 1058c2ecf20Sopenharmony_ci { "iDisp3 Tx", NULL, "iDisp3_out" }, 1068c2ecf20Sopenharmony_ci { "hifi2", NULL, "iDisp2 Tx" }, 1078c2ecf20Sopenharmony_ci { "iDisp2 Tx", NULL, "iDisp2_out" }, 1088c2ecf20Sopenharmony_ci { "hifi1", NULL, "iDisp1 Tx" }, 1098c2ecf20Sopenharmony_ci { "iDisp1 Tx", NULL, "iDisp1_out" }, 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci /* DMIC */ 1128c2ecf20Sopenharmony_ci { "dmic01_hifi", NULL, "DMIC01 Rx" }, 1138c2ecf20Sopenharmony_ci { "DMIC01 Rx", NULL, "DMIC AIF" }, 1148c2ecf20Sopenharmony_ci}; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_cistatic int geminilake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, 1178c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *params) 1188c2ecf20Sopenharmony_ci{ 1198c2ecf20Sopenharmony_ci struct snd_interval *rate = hw_param_interval(params, 1208c2ecf20Sopenharmony_ci SNDRV_PCM_HW_PARAM_RATE); 1218c2ecf20Sopenharmony_ci struct snd_interval *chan = hw_param_interval(params, 1228c2ecf20Sopenharmony_ci SNDRV_PCM_HW_PARAM_CHANNELS); 1238c2ecf20Sopenharmony_ci struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci /* The ADSP will convert the FE rate to 48k, stereo */ 1268c2ecf20Sopenharmony_ci rate->min = rate->max = 48000; 1278c2ecf20Sopenharmony_ci chan->min = chan->max = DUAL_CHANNEL; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci /* set SSP to 24 bit */ 1308c2ecf20Sopenharmony_ci snd_mask_none(fmt); 1318c2ecf20Sopenharmony_ci snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci return 0; 1348c2ecf20Sopenharmony_ci} 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cistatic int geminilake_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) 1378c2ecf20Sopenharmony_ci{ 1388c2ecf20Sopenharmony_ci struct glk_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 1398c2ecf20Sopenharmony_ci struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 1408c2ecf20Sopenharmony_ci struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 1418c2ecf20Sopenharmony_ci struct snd_soc_jack *jack; 1428c2ecf20Sopenharmony_ci int ret; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK, 1458c2ecf20Sopenharmony_ci GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ); 1468c2ecf20Sopenharmony_ci if (ret < 0) { 1478c2ecf20Sopenharmony_ci dev_err(rtd->dev, "can't set codec pll: %d\n", ret); 1488c2ecf20Sopenharmony_ci return ret; 1498c2ecf20Sopenharmony_ci } 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci /* Configure sysclk for codec */ 1528c2ecf20Sopenharmony_ci ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL1, 1538c2ecf20Sopenharmony_ci RT5682_PLL_FREQ, SND_SOC_CLOCK_IN); 1548c2ecf20Sopenharmony_ci if (ret < 0) 1558c2ecf20Sopenharmony_ci dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci /* 1588c2ecf20Sopenharmony_ci * Headset buttons map to the google Reference headset. 1598c2ecf20Sopenharmony_ci * These can be configured by userspace. 1608c2ecf20Sopenharmony_ci */ 1618c2ecf20Sopenharmony_ci ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", 1628c2ecf20Sopenharmony_ci SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | 1638c2ecf20Sopenharmony_ci SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT, 1648c2ecf20Sopenharmony_ci &ctx->geminilake_headset, NULL, 0); 1658c2ecf20Sopenharmony_ci if (ret) { 1668c2ecf20Sopenharmony_ci dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); 1678c2ecf20Sopenharmony_ci return ret; 1688c2ecf20Sopenharmony_ci } 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci jack = &ctx->geminilake_headset; 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); 1738c2ecf20Sopenharmony_ci snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); 1748c2ecf20Sopenharmony_ci snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); 1758c2ecf20Sopenharmony_ci snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci ret = snd_soc_component_set_jack(component, jack, NULL); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci if (ret) { 1808c2ecf20Sopenharmony_ci dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret); 1818c2ecf20Sopenharmony_ci return ret; 1828c2ecf20Sopenharmony_ci } 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci return ret; 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistatic int geminilake_rt5682_hw_params(struct snd_pcm_substream *substream, 1888c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *params) 1898c2ecf20Sopenharmony_ci{ 1908c2ecf20Sopenharmony_ci struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 1918c2ecf20Sopenharmony_ci struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 1928c2ecf20Sopenharmony_ci int ret; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci /* Set valid bitmask & configuration for I2S in 24 bit */ 1958c2ecf20Sopenharmony_ci ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x0, 0x0, 2, 24); 1968c2ecf20Sopenharmony_ci if (ret < 0) { 1978c2ecf20Sopenharmony_ci dev_err(rtd->dev, "set TDM slot err:%d\n", ret); 1988c2ecf20Sopenharmony_ci return ret; 1998c2ecf20Sopenharmony_ci } 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci return ret; 2028c2ecf20Sopenharmony_ci} 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_cistatic struct snd_soc_ops geminilake_rt5682_ops = { 2058c2ecf20Sopenharmony_ci .hw_params = geminilake_rt5682_hw_params, 2068c2ecf20Sopenharmony_ci}; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_cistatic int geminilake_hdmi_init(struct snd_soc_pcm_runtime *rtd) 2098c2ecf20Sopenharmony_ci{ 2108c2ecf20Sopenharmony_ci struct glk_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); 2118c2ecf20Sopenharmony_ci struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); 2128c2ecf20Sopenharmony_ci struct glk_hdmi_pcm *pcm; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); 2158c2ecf20Sopenharmony_ci if (!pcm) 2168c2ecf20Sopenharmony_ci return -ENOMEM; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci pcm->device = GLK_DPCM_AUDIO_HDMI1_PB + dai->id; 2198c2ecf20Sopenharmony_ci pcm->codec_dai = dai; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci return 0; 2248c2ecf20Sopenharmony_ci} 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_cistatic int geminilake_rt5682_fe_init(struct snd_soc_pcm_runtime *rtd) 2278c2ecf20Sopenharmony_ci{ 2288c2ecf20Sopenharmony_ci struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component; 2298c2ecf20Sopenharmony_ci struct snd_soc_dapm_context *dapm; 2308c2ecf20Sopenharmony_ci int ret; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci dapm = snd_soc_component_get_dapm(component); 2338c2ecf20Sopenharmony_ci ret = snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); 2348c2ecf20Sopenharmony_ci if (ret) { 2358c2ecf20Sopenharmony_ci dev_err(rtd->dev, "Ref Cap ignore suspend failed %d\n", ret); 2368c2ecf20Sopenharmony_ci return ret; 2378c2ecf20Sopenharmony_ci } 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci return ret; 2408c2ecf20Sopenharmony_ci} 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_cistatic const unsigned int rates[] = { 2438c2ecf20Sopenharmony_ci 48000, 2448c2ecf20Sopenharmony_ci}; 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list constraints_rates = { 2478c2ecf20Sopenharmony_ci .count = ARRAY_SIZE(rates), 2488c2ecf20Sopenharmony_ci .list = rates, 2498c2ecf20Sopenharmony_ci .mask = 0, 2508c2ecf20Sopenharmony_ci}; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_cistatic unsigned int channels_quad[] = { 2538c2ecf20Sopenharmony_ci QUAD_CHANNEL, 2548c2ecf20Sopenharmony_ci}; 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_cistatic struct snd_pcm_hw_constraint_list constraints_channels_quad = { 2578c2ecf20Sopenharmony_ci .count = ARRAY_SIZE(channels_quad), 2588c2ecf20Sopenharmony_ci .list = channels_quad, 2598c2ecf20Sopenharmony_ci .mask = 0, 2608c2ecf20Sopenharmony_ci}; 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_cistatic int geminilake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, 2638c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *params) 2648c2ecf20Sopenharmony_ci{ 2658c2ecf20Sopenharmony_ci struct snd_interval *chan = hw_param_interval(params, 2668c2ecf20Sopenharmony_ci SNDRV_PCM_HW_PARAM_CHANNELS); 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci /* 2698c2ecf20Sopenharmony_ci * set BE channel constraint as user FE channels 2708c2ecf20Sopenharmony_ci */ 2718c2ecf20Sopenharmony_ci chan->min = chan->max = 4; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci return 0; 2748c2ecf20Sopenharmony_ci} 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_cistatic int geminilake_dmic_startup(struct snd_pcm_substream *substream) 2778c2ecf20Sopenharmony_ci{ 2788c2ecf20Sopenharmony_ci struct snd_pcm_runtime *runtime = substream->runtime; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL; 2818c2ecf20Sopenharmony_ci snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 2828c2ecf20Sopenharmony_ci &constraints_channels_quad); 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci return snd_pcm_hw_constraint_list(substream->runtime, 0, 2858c2ecf20Sopenharmony_ci SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); 2868c2ecf20Sopenharmony_ci} 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_cistatic const struct snd_soc_ops geminilake_dmic_ops = { 2898c2ecf20Sopenharmony_ci .startup = geminilake_dmic_startup, 2908c2ecf20Sopenharmony_ci}; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_cistatic const unsigned int rates_16000[] = { 2938c2ecf20Sopenharmony_ci 16000, 2948c2ecf20Sopenharmony_ci}; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list constraints_16000 = { 2978c2ecf20Sopenharmony_ci .count = ARRAY_SIZE(rates_16000), 2988c2ecf20Sopenharmony_ci .list = rates_16000, 2998c2ecf20Sopenharmony_ci}; 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_cistatic int geminilake_refcap_startup(struct snd_pcm_substream *substream) 3028c2ecf20Sopenharmony_ci{ 3038c2ecf20Sopenharmony_ci return snd_pcm_hw_constraint_list(substream->runtime, 0, 3048c2ecf20Sopenharmony_ci SNDRV_PCM_HW_PARAM_RATE, 3058c2ecf20Sopenharmony_ci &constraints_16000); 3068c2ecf20Sopenharmony_ci}; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_cistatic const struct snd_soc_ops geminilake_refcap_ops = { 3098c2ecf20Sopenharmony_ci .startup = geminilake_refcap_startup, 3108c2ecf20Sopenharmony_ci}; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dummy, 3138c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_DUMMY())); 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(system, 3168c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("System Pin"))); 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(system2, 3198c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("System Pin2"))); 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(echoref, 3228c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin"))); 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(reference, 3258c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin"))); 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dmic, 3288c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin"))); 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(hdmi1, 3318c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin"))); 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(hdmi2, 3348c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin"))); 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(hdmi3, 3378c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin"))); 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp1_pin, 3408c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin"))); 3418c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp1_codec, 3428c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CODEC(MAXIM_DEV0_NAME, 3438c2ecf20Sopenharmony_ci GLK_MAXIM_CODEC_DAI))); 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp2_pin, 3468c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("SSP2 Pin"))); 3478c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp2_codec, 3488c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5682:00", 3498c2ecf20Sopenharmony_ci GLK_REALTEK_CODEC_DAI))); 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dmic_pin, 3528c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); 3538c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dmic_codec, 3548c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp1_pin, 3578c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin"))); 3588c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp1_codec, 3598c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1"))); 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp2_pin, 3628c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin"))); 3638c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp2_codec, 3648c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2"))); 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp3_pin, 3678c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin"))); 3688c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(idisp3_codec, 3698c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(platform, 3728c2ecf20Sopenharmony_ci DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:0e.0"))); 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci/* geminilake digital audio interface glue - connects codec <--> CPU */ 3758c2ecf20Sopenharmony_cistatic struct snd_soc_dai_link geminilake_dais[] = { 3768c2ecf20Sopenharmony_ci /* Front End DAI links */ 3778c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_PB] = { 3788c2ecf20Sopenharmony_ci .name = "Glk Audio Port", 3798c2ecf20Sopenharmony_ci .stream_name = "Audio", 3808c2ecf20Sopenharmony_ci .dynamic = 1, 3818c2ecf20Sopenharmony_ci .nonatomic = 1, 3828c2ecf20Sopenharmony_ci .init = geminilake_rt5682_fe_init, 3838c2ecf20Sopenharmony_ci .trigger = { 3848c2ecf20Sopenharmony_ci SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 3858c2ecf20Sopenharmony_ci .dpcm_playback = 1, 3868c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(system, dummy, platform), 3878c2ecf20Sopenharmony_ci }, 3888c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_CP] = { 3898c2ecf20Sopenharmony_ci .name = "Glk Audio Capture Port", 3908c2ecf20Sopenharmony_ci .stream_name = "Audio Record", 3918c2ecf20Sopenharmony_ci .dynamic = 1, 3928c2ecf20Sopenharmony_ci .nonatomic = 1, 3938c2ecf20Sopenharmony_ci .trigger = { 3948c2ecf20Sopenharmony_ci SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 3958c2ecf20Sopenharmony_ci .dpcm_capture = 1, 3968c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(system, dummy, platform), 3978c2ecf20Sopenharmony_ci }, 3988c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_HS_PB] = { 3998c2ecf20Sopenharmony_ci .name = "Glk Audio Headset Playback", 4008c2ecf20Sopenharmony_ci .stream_name = "Headset Audio", 4018c2ecf20Sopenharmony_ci .dpcm_playback = 1, 4028c2ecf20Sopenharmony_ci .nonatomic = 1, 4038c2ecf20Sopenharmony_ci .dynamic = 1, 4048c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(system2, dummy, platform), 4058c2ecf20Sopenharmony_ci }, 4068c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_ECHO_REF_CP] = { 4078c2ecf20Sopenharmony_ci .name = "Glk Audio Echo Reference cap", 4088c2ecf20Sopenharmony_ci .stream_name = "Echoreference Capture", 4098c2ecf20Sopenharmony_ci .init = NULL, 4108c2ecf20Sopenharmony_ci .dpcm_capture = 1, 4118c2ecf20Sopenharmony_ci .nonatomic = 1, 4128c2ecf20Sopenharmony_ci .dynamic = 1, 4138c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(echoref, dummy, platform), 4148c2ecf20Sopenharmony_ci }, 4158c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_REF_CP] = { 4168c2ecf20Sopenharmony_ci .name = "Glk Audio Reference cap", 4178c2ecf20Sopenharmony_ci .stream_name = "Refcap", 4188c2ecf20Sopenharmony_ci .init = NULL, 4198c2ecf20Sopenharmony_ci .dpcm_capture = 1, 4208c2ecf20Sopenharmony_ci .nonatomic = 1, 4218c2ecf20Sopenharmony_ci .dynamic = 1, 4228c2ecf20Sopenharmony_ci .ops = &geminilake_refcap_ops, 4238c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(reference, dummy, platform), 4248c2ecf20Sopenharmony_ci }, 4258c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_DMIC_CP] = { 4268c2ecf20Sopenharmony_ci .name = "Glk Audio DMIC cap", 4278c2ecf20Sopenharmony_ci .stream_name = "dmiccap", 4288c2ecf20Sopenharmony_ci .init = NULL, 4298c2ecf20Sopenharmony_ci .dpcm_capture = 1, 4308c2ecf20Sopenharmony_ci .nonatomic = 1, 4318c2ecf20Sopenharmony_ci .dynamic = 1, 4328c2ecf20Sopenharmony_ci .ops = &geminilake_dmic_ops, 4338c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(dmic, dummy, platform), 4348c2ecf20Sopenharmony_ci }, 4358c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_HDMI1_PB] = { 4368c2ecf20Sopenharmony_ci .name = "Glk HDMI Port1", 4378c2ecf20Sopenharmony_ci .stream_name = "Hdmi1", 4388c2ecf20Sopenharmony_ci .dpcm_playback = 1, 4398c2ecf20Sopenharmony_ci .init = NULL, 4408c2ecf20Sopenharmony_ci .trigger = { 4418c2ecf20Sopenharmony_ci SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 4428c2ecf20Sopenharmony_ci .nonatomic = 1, 4438c2ecf20Sopenharmony_ci .dynamic = 1, 4448c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(hdmi1, dummy, platform), 4458c2ecf20Sopenharmony_ci }, 4468c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_HDMI2_PB] = { 4478c2ecf20Sopenharmony_ci .name = "Glk HDMI Port2", 4488c2ecf20Sopenharmony_ci .stream_name = "Hdmi2", 4498c2ecf20Sopenharmony_ci .dpcm_playback = 1, 4508c2ecf20Sopenharmony_ci .init = NULL, 4518c2ecf20Sopenharmony_ci .trigger = { 4528c2ecf20Sopenharmony_ci SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 4538c2ecf20Sopenharmony_ci .nonatomic = 1, 4548c2ecf20Sopenharmony_ci .dynamic = 1, 4558c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(hdmi2, dummy, platform), 4568c2ecf20Sopenharmony_ci }, 4578c2ecf20Sopenharmony_ci [GLK_DPCM_AUDIO_HDMI3_PB] = { 4588c2ecf20Sopenharmony_ci .name = "Glk HDMI Port3", 4598c2ecf20Sopenharmony_ci .stream_name = "Hdmi3", 4608c2ecf20Sopenharmony_ci .trigger = { 4618c2ecf20Sopenharmony_ci SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 4628c2ecf20Sopenharmony_ci .dpcm_playback = 1, 4638c2ecf20Sopenharmony_ci .init = NULL, 4648c2ecf20Sopenharmony_ci .nonatomic = 1, 4658c2ecf20Sopenharmony_ci .dynamic = 1, 4668c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(hdmi3, dummy, platform), 4678c2ecf20Sopenharmony_ci }, 4688c2ecf20Sopenharmony_ci /* Back End DAI links */ 4698c2ecf20Sopenharmony_ci { 4708c2ecf20Sopenharmony_ci /* SSP1 - Codec */ 4718c2ecf20Sopenharmony_ci .name = "SSP1-Codec", 4728c2ecf20Sopenharmony_ci .id = 0, 4738c2ecf20Sopenharmony_ci .no_pcm = 1, 4748c2ecf20Sopenharmony_ci .dai_fmt = SND_SOC_DAIFMT_I2S | 4758c2ecf20Sopenharmony_ci SND_SOC_DAIFMT_NB_NF | 4768c2ecf20Sopenharmony_ci SND_SOC_DAIFMT_CBS_CFS, 4778c2ecf20Sopenharmony_ci .ignore_pmdown_time = 1, 4788c2ecf20Sopenharmony_ci .be_hw_params_fixup = geminilake_ssp_fixup, 4798c2ecf20Sopenharmony_ci .dpcm_playback = 1, 4808c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform), 4818c2ecf20Sopenharmony_ci }, 4828c2ecf20Sopenharmony_ci { 4838c2ecf20Sopenharmony_ci /* SSP2 - Codec */ 4848c2ecf20Sopenharmony_ci .name = "SSP2-Codec", 4858c2ecf20Sopenharmony_ci .id = 1, 4868c2ecf20Sopenharmony_ci .no_pcm = 1, 4878c2ecf20Sopenharmony_ci .init = geminilake_rt5682_codec_init, 4888c2ecf20Sopenharmony_ci .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 4898c2ecf20Sopenharmony_ci SND_SOC_DAIFMT_CBS_CFS, 4908c2ecf20Sopenharmony_ci .ignore_pmdown_time = 1, 4918c2ecf20Sopenharmony_ci .be_hw_params_fixup = geminilake_ssp_fixup, 4928c2ecf20Sopenharmony_ci .ops = &geminilake_rt5682_ops, 4938c2ecf20Sopenharmony_ci .dpcm_playback = 1, 4948c2ecf20Sopenharmony_ci .dpcm_capture = 1, 4958c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(ssp2_pin, ssp2_codec, platform), 4968c2ecf20Sopenharmony_ci }, 4978c2ecf20Sopenharmony_ci { 4988c2ecf20Sopenharmony_ci .name = "dmic01", 4998c2ecf20Sopenharmony_ci .id = 2, 5008c2ecf20Sopenharmony_ci .ignore_suspend = 1, 5018c2ecf20Sopenharmony_ci .be_hw_params_fixup = geminilake_dmic_fixup, 5028c2ecf20Sopenharmony_ci .dpcm_capture = 1, 5038c2ecf20Sopenharmony_ci .no_pcm = 1, 5048c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform), 5058c2ecf20Sopenharmony_ci }, 5068c2ecf20Sopenharmony_ci { 5078c2ecf20Sopenharmony_ci .name = "iDisp1", 5088c2ecf20Sopenharmony_ci .id = 3, 5098c2ecf20Sopenharmony_ci .init = geminilake_hdmi_init, 5108c2ecf20Sopenharmony_ci .dpcm_playback = 1, 5118c2ecf20Sopenharmony_ci .no_pcm = 1, 5128c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform), 5138c2ecf20Sopenharmony_ci }, 5148c2ecf20Sopenharmony_ci { 5158c2ecf20Sopenharmony_ci .name = "iDisp2", 5168c2ecf20Sopenharmony_ci .id = 4, 5178c2ecf20Sopenharmony_ci .init = geminilake_hdmi_init, 5188c2ecf20Sopenharmony_ci .dpcm_playback = 1, 5198c2ecf20Sopenharmony_ci .no_pcm = 1, 5208c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform), 5218c2ecf20Sopenharmony_ci }, 5228c2ecf20Sopenharmony_ci { 5238c2ecf20Sopenharmony_ci .name = "iDisp3", 5248c2ecf20Sopenharmony_ci .id = 5, 5258c2ecf20Sopenharmony_ci .init = geminilake_hdmi_init, 5268c2ecf20Sopenharmony_ci .dpcm_playback = 1, 5278c2ecf20Sopenharmony_ci .no_pcm = 1, 5288c2ecf20Sopenharmony_ci SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform), 5298c2ecf20Sopenharmony_ci }, 5308c2ecf20Sopenharmony_ci}; 5318c2ecf20Sopenharmony_ci 5328c2ecf20Sopenharmony_cistatic int glk_card_late_probe(struct snd_soc_card *card) 5338c2ecf20Sopenharmony_ci{ 5348c2ecf20Sopenharmony_ci struct glk_card_private *ctx = snd_soc_card_get_drvdata(card); 5358c2ecf20Sopenharmony_ci struct snd_soc_component *component = NULL; 5368c2ecf20Sopenharmony_ci char jack_name[NAME_SIZE]; 5378c2ecf20Sopenharmony_ci struct glk_hdmi_pcm *pcm; 5388c2ecf20Sopenharmony_ci int err; 5398c2ecf20Sopenharmony_ci int i = 0; 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_ci if (list_empty(&ctx->hdmi_pcm_list)) 5428c2ecf20Sopenharmony_ci return -EINVAL; 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci if (ctx->common_hdmi_codec_drv) { 5458c2ecf20Sopenharmony_ci pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm, 5468c2ecf20Sopenharmony_ci head); 5478c2ecf20Sopenharmony_ci component = pcm->codec_dai->component; 5488c2ecf20Sopenharmony_ci return hda_dsp_hdmi_build_controls(card, component); 5498c2ecf20Sopenharmony_ci } 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { 5528c2ecf20Sopenharmony_ci component = pcm->codec_dai->component; 5538c2ecf20Sopenharmony_ci snprintf(jack_name, sizeof(jack_name), 5548c2ecf20Sopenharmony_ci "HDMI/DP, pcm=%d Jack", pcm->device); 5558c2ecf20Sopenharmony_ci err = snd_soc_card_jack_new(card, jack_name, 5568c2ecf20Sopenharmony_ci SND_JACK_AVOUT, &geminilake_hdmi[i], 5578c2ecf20Sopenharmony_ci NULL, 0); 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci if (err) 5608c2ecf20Sopenharmony_ci return err; 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_ci err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, 5638c2ecf20Sopenharmony_ci &geminilake_hdmi[i]); 5648c2ecf20Sopenharmony_ci if (err < 0) 5658c2ecf20Sopenharmony_ci return err; 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci i++; 5688c2ecf20Sopenharmony_ci } 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_ci return hdac_hdmi_jack_port_init(component, &card->dapm); 5718c2ecf20Sopenharmony_ci} 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci/* geminilake audio machine driver for SPT + RT5682 */ 5748c2ecf20Sopenharmony_cistatic struct snd_soc_card glk_audio_card_rt5682_m98357a = { 5758c2ecf20Sopenharmony_ci .name = "glkrt5682max", 5768c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 5778c2ecf20Sopenharmony_ci .dai_link = geminilake_dais, 5788c2ecf20Sopenharmony_ci .num_links = ARRAY_SIZE(geminilake_dais), 5798c2ecf20Sopenharmony_ci .controls = geminilake_controls, 5808c2ecf20Sopenharmony_ci .num_controls = ARRAY_SIZE(geminilake_controls), 5818c2ecf20Sopenharmony_ci .dapm_widgets = geminilake_widgets, 5828c2ecf20Sopenharmony_ci .num_dapm_widgets = ARRAY_SIZE(geminilake_widgets), 5838c2ecf20Sopenharmony_ci .dapm_routes = geminilake_map, 5848c2ecf20Sopenharmony_ci .num_dapm_routes = ARRAY_SIZE(geminilake_map), 5858c2ecf20Sopenharmony_ci .fully_routed = true, 5868c2ecf20Sopenharmony_ci .late_probe = glk_card_late_probe, 5878c2ecf20Sopenharmony_ci}; 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_cistatic int geminilake_audio_probe(struct platform_device *pdev) 5908c2ecf20Sopenharmony_ci{ 5918c2ecf20Sopenharmony_ci struct glk_card_private *ctx; 5928c2ecf20Sopenharmony_ci struct snd_soc_acpi_mach *mach; 5938c2ecf20Sopenharmony_ci const char *platform_name; 5948c2ecf20Sopenharmony_ci struct snd_soc_card *card; 5958c2ecf20Sopenharmony_ci int ret; 5968c2ecf20Sopenharmony_ci 5978c2ecf20Sopenharmony_ci ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 5988c2ecf20Sopenharmony_ci if (!ctx) 5998c2ecf20Sopenharmony_ci return -ENOMEM; 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&ctx->hdmi_pcm_list); 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci card = &glk_audio_card_rt5682_m98357a; 6048c2ecf20Sopenharmony_ci card->dev = &pdev->dev; 6058c2ecf20Sopenharmony_ci snd_soc_card_set_drvdata(card, ctx); 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_ci /* override plaform name, if required */ 6088c2ecf20Sopenharmony_ci mach = pdev->dev.platform_data; 6098c2ecf20Sopenharmony_ci platform_name = mach->mach_params.platform; 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci ret = snd_soc_fixup_dai_links_platform_name(card, platform_name); 6128c2ecf20Sopenharmony_ci if (ret) 6138c2ecf20Sopenharmony_ci return ret; 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv; 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci return devm_snd_soc_register_card(&pdev->dev, card); 6188c2ecf20Sopenharmony_ci} 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_cistatic const struct platform_device_id glk_board_ids[] = { 6218c2ecf20Sopenharmony_ci { 6228c2ecf20Sopenharmony_ci .name = "glk_rt5682_max98357a", 6238c2ecf20Sopenharmony_ci .driver_data = 6248c2ecf20Sopenharmony_ci (kernel_ulong_t)&glk_audio_card_rt5682_m98357a, 6258c2ecf20Sopenharmony_ci }, 6268c2ecf20Sopenharmony_ci { } 6278c2ecf20Sopenharmony_ci}; 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_cistatic struct platform_driver geminilake_audio = { 6308c2ecf20Sopenharmony_ci .probe = geminilake_audio_probe, 6318c2ecf20Sopenharmony_ci .driver = { 6328c2ecf20Sopenharmony_ci .name = "glk_rt5682_max98357a", 6338c2ecf20Sopenharmony_ci .pm = &snd_soc_pm_ops, 6348c2ecf20Sopenharmony_ci }, 6358c2ecf20Sopenharmony_ci .id_table = glk_board_ids, 6368c2ecf20Sopenharmony_ci}; 6378c2ecf20Sopenharmony_cimodule_platform_driver(geminilake_audio) 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_ci/* Module information */ 6408c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Geminilake Audio Machine driver-RT5682 & MAX98357A in I2S mode"); 6418c2ecf20Sopenharmony_ciMODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>"); 6428c2ecf20Sopenharmony_ciMODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>"); 6438c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 6448c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:glk_rt5682_max98357a"); 645