18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * ASoC machine driver for Intel Broadwell platforms with RT5650 codec
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2019, The Chromium OS Authors.  All rights reserved.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/delay.h>
98c2ecf20Sopenharmony_ci#include <linux/gpio/consumer.h>
108c2ecf20Sopenharmony_ci#include <linux/module.h>
118c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
128c2ecf20Sopenharmony_ci#include <sound/core.h>
138c2ecf20Sopenharmony_ci#include <sound/jack.h>
148c2ecf20Sopenharmony_ci#include <sound/pcm.h>
158c2ecf20Sopenharmony_ci#include <sound/pcm_params.h>
168c2ecf20Sopenharmony_ci#include <sound/soc.h>
178c2ecf20Sopenharmony_ci#include <sound/soc-acpi.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include "../../codecs/rt5645.h"
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistruct bdw_rt5650_priv {
228c2ecf20Sopenharmony_ci	struct gpio_desc *gpio_hp_en;
238c2ecf20Sopenharmony_ci	struct snd_soc_component *component;
248c2ecf20Sopenharmony_ci};
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget bdw_rt5650_widgets[] = {
278c2ecf20Sopenharmony_ci	SND_SOC_DAPM_HP("Headphone", NULL),
288c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SPK("Speaker", NULL),
298c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIC("Headset Mic", NULL),
308c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIC("DMIC Pair1", NULL),
318c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIC("DMIC Pair2", NULL),
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route bdw_rt5650_map[] = {
358c2ecf20Sopenharmony_ci	/* Speakers */
368c2ecf20Sopenharmony_ci	{"Speaker", NULL, "SPOL"},
378c2ecf20Sopenharmony_ci	{"Speaker", NULL, "SPOR"},
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	/* Headset jack connectors */
408c2ecf20Sopenharmony_ci	{"Headphone", NULL, "HPOL"},
418c2ecf20Sopenharmony_ci	{"Headphone", NULL, "HPOR"},
428c2ecf20Sopenharmony_ci	{"IN1P", NULL, "Headset Mic"},
438c2ecf20Sopenharmony_ci	{"IN1N", NULL, "Headset Mic"},
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	/* Digital MICs
468c2ecf20Sopenharmony_ci	 * DMIC Pair1 are the two DMICs connected on the DMICN1 connector.
478c2ecf20Sopenharmony_ci	 * DMIC Pair2 are the two DMICs connected on the DMICN2 connector.
488c2ecf20Sopenharmony_ci	 * Facing the camera, DMIC Pair1 are on the left side, DMIC Pair2
498c2ecf20Sopenharmony_ci	 * are on the right side.
508c2ecf20Sopenharmony_ci	 */
518c2ecf20Sopenharmony_ci	{"DMIC L1", NULL, "DMIC Pair1"},
528c2ecf20Sopenharmony_ci	{"DMIC R1", NULL, "DMIC Pair1"},
538c2ecf20Sopenharmony_ci	{"DMIC L2", NULL, "DMIC Pair2"},
548c2ecf20Sopenharmony_ci	{"DMIC R2", NULL, "DMIC Pair2"},
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci	/* CODEC BE connections */
578c2ecf20Sopenharmony_ci	{"SSP0 CODEC IN", NULL, "AIF1 Capture"},
588c2ecf20Sopenharmony_ci	{"AIF1 Playback", NULL, "SSP0 CODEC OUT"},
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new bdw_rt5650_controls[] = {
628c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Speaker"),
638c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Headphone"),
648c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("Headset Mic"),
658c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("DMIC Pair1"),
668c2ecf20Sopenharmony_ci	SOC_DAPM_PIN_SWITCH("DMIC Pair2"),
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_cistatic struct snd_soc_jack headphone_jack;
718c2ecf20Sopenharmony_cistatic struct snd_soc_jack mic_jack;
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic struct snd_soc_jack_pin headphone_jack_pin = {
748c2ecf20Sopenharmony_ci	.pin	= "Headphone",
758c2ecf20Sopenharmony_ci	.mask	= SND_JACK_HEADPHONE,
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistatic struct snd_soc_jack_pin mic_jack_pin = {
798c2ecf20Sopenharmony_ci	.pin	= "Headset Mic",
808c2ecf20Sopenharmony_ci	.mask	= SND_JACK_MICROPHONE,
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
848c2ecf20Sopenharmony_ci			struct snd_pcm_hw_params *params)
858c2ecf20Sopenharmony_ci{
868c2ecf20Sopenharmony_ci	struct snd_interval *rate = hw_param_interval(params,
878c2ecf20Sopenharmony_ci						      SNDRV_PCM_HW_PARAM_RATE);
888c2ecf20Sopenharmony_ci	struct snd_interval *chan = hw_param_interval(params,
898c2ecf20Sopenharmony_ci						      SNDRV_PCM_HW_PARAM_CHANNELS);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	/* The ADSP will covert the FE rate to 48k, max 4-channels */
928c2ecf20Sopenharmony_ci	rate->min = rate->max = 48000;
938c2ecf20Sopenharmony_ci	chan->min = 2;
948c2ecf20Sopenharmony_ci	chan->max = 4;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	/* set SSP0 to 24 bit */
978c2ecf20Sopenharmony_ci	snd_mask_set_format(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT),
988c2ecf20Sopenharmony_ci			    SNDRV_PCM_FORMAT_S24_LE);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	return 0;
1018c2ecf20Sopenharmony_ci}
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_cistatic int bdw_rt5650_hw_params(struct snd_pcm_substream *substream,
1048c2ecf20Sopenharmony_ci	struct snd_pcm_hw_params *params)
1058c2ecf20Sopenharmony_ci{
1068c2ecf20Sopenharmony_ci	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1078c2ecf20Sopenharmony_ci	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
1088c2ecf20Sopenharmony_ci	int ret;
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	/* Workaround: set codec PLL to 19.2MHz that PLL source is
1118c2ecf20Sopenharmony_ci	 * from MCLK(24MHz) to conform 2.4MHz DMIC clock.
1128c2ecf20Sopenharmony_ci	 */
1138c2ecf20Sopenharmony_ci	ret = snd_soc_dai_set_pll(codec_dai, 0, RT5645_PLL1_S_MCLK,
1148c2ecf20Sopenharmony_ci		24000000, 19200000);
1158c2ecf20Sopenharmony_ci	if (ret < 0) {
1168c2ecf20Sopenharmony_ci		dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
1178c2ecf20Sopenharmony_ci		return ret;
1188c2ecf20Sopenharmony_ci	}
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	/* The actual MCLK freq is 24MHz. The codec is told that MCLK is
1218c2ecf20Sopenharmony_ci	 * 24.576MHz to satisfy the requirement of rl6231_get_clk_info.
1228c2ecf20Sopenharmony_ci	 * ASRC is enabled on AD and DA filters to ensure good audio quality.
1238c2ecf20Sopenharmony_ci	 */
1248c2ecf20Sopenharmony_ci	ret = snd_soc_dai_set_sysclk(codec_dai, RT5645_SCLK_S_PLL1, 24576000,
1258c2ecf20Sopenharmony_ci		SND_SOC_CLOCK_IN);
1268c2ecf20Sopenharmony_ci	if (ret < 0) {
1278c2ecf20Sopenharmony_ci		dev_err(rtd->dev, "can't set codec sysclk configuration\n");
1288c2ecf20Sopenharmony_ci		return ret;
1298c2ecf20Sopenharmony_ci	}
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	return ret;
1328c2ecf20Sopenharmony_ci}
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_cistatic struct snd_soc_ops bdw_rt5650_ops = {
1358c2ecf20Sopenharmony_ci	.hw_params = bdw_rt5650_hw_params,
1368c2ecf20Sopenharmony_ci};
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistatic const unsigned int channels[] = {
1398c2ecf20Sopenharmony_ci	2, 4,
1408c2ecf20Sopenharmony_ci};
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cistatic const struct snd_pcm_hw_constraint_list constraints_channels = {
1438c2ecf20Sopenharmony_ci	.count = ARRAY_SIZE(channels),
1448c2ecf20Sopenharmony_ci	.list = channels,
1458c2ecf20Sopenharmony_ci	.mask = 0,
1468c2ecf20Sopenharmony_ci};
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic int bdw_rt5650_fe_startup(struct snd_pcm_substream *substream)
1498c2ecf20Sopenharmony_ci{
1508c2ecf20Sopenharmony_ci	struct snd_pcm_runtime *runtime = substream->runtime;
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	/* Board supports stereo and quad configurations for capture */
1538c2ecf20Sopenharmony_ci	if (substream->stream != SNDRV_PCM_STREAM_CAPTURE)
1548c2ecf20Sopenharmony_ci		return 0;
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	runtime->hw.channels_max = 4;
1578c2ecf20Sopenharmony_ci	return snd_pcm_hw_constraint_list(runtime, 0,
1588c2ecf20Sopenharmony_ci					  SNDRV_PCM_HW_PARAM_CHANNELS,
1598c2ecf20Sopenharmony_ci					  &constraints_channels);
1608c2ecf20Sopenharmony_ci}
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistatic const struct snd_soc_ops bdw_rt5650_fe_ops = {
1638c2ecf20Sopenharmony_ci	.startup = bdw_rt5650_fe_startup,
1648c2ecf20Sopenharmony_ci};
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_cistatic int bdw_rt5650_init(struct snd_soc_pcm_runtime *rtd)
1678c2ecf20Sopenharmony_ci{
1688c2ecf20Sopenharmony_ci	struct bdw_rt5650_priv *bdw_rt5650 =
1698c2ecf20Sopenharmony_ci		snd_soc_card_get_drvdata(rtd->card);
1708c2ecf20Sopenharmony_ci	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
1718c2ecf20Sopenharmony_ci	struct snd_soc_component *component = codec_dai->component;
1728c2ecf20Sopenharmony_ci	int ret;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	/* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1.
1758c2ecf20Sopenharmony_ci	 * The ASRC clock source is clk_i2s1_asrc.
1768c2ecf20Sopenharmony_ci	 */
1778c2ecf20Sopenharmony_ci	rt5645_sel_asrc_clk_src(component,
1788c2ecf20Sopenharmony_ci				RT5645_DA_STEREO_FILTER |
1798c2ecf20Sopenharmony_ci				RT5645_DA_MONO_L_FILTER |
1808c2ecf20Sopenharmony_ci				RT5645_DA_MONO_R_FILTER |
1818c2ecf20Sopenharmony_ci				RT5645_AD_STEREO_FILTER |
1828c2ecf20Sopenharmony_ci				RT5645_AD_MONO_L_FILTER |
1838c2ecf20Sopenharmony_ci				RT5645_AD_MONO_R_FILTER,
1848c2ecf20Sopenharmony_ci				RT5645_CLK_SEL_I2S1_ASRC);
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci	/* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
1878c2ecf20Sopenharmony_ci	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0xF, 4, 24);
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci	if (ret < 0) {
1908c2ecf20Sopenharmony_ci		dev_err(rtd->dev, "can't set codec TDM slot %d\n", ret);
1918c2ecf20Sopenharmony_ci		return ret;
1928c2ecf20Sopenharmony_ci	}
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	/* Create and initialize headphone jack */
1958c2ecf20Sopenharmony_ci	if (snd_soc_card_jack_new(rtd->card, "Headphone Jack",
1968c2ecf20Sopenharmony_ci			SND_JACK_HEADPHONE, &headphone_jack,
1978c2ecf20Sopenharmony_ci			&headphone_jack_pin, 1)) {
1988c2ecf20Sopenharmony_ci		dev_err(component->dev, "Can't create headphone jack\n");
1998c2ecf20Sopenharmony_ci	}
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	/* Create and initialize mic jack */
2028c2ecf20Sopenharmony_ci	if (snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
2038c2ecf20Sopenharmony_ci			&mic_jack, &mic_jack_pin, 1)) {
2048c2ecf20Sopenharmony_ci		dev_err(component->dev, "Can't create mic jack\n");
2058c2ecf20Sopenharmony_ci	}
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci	rt5645_set_jack_detect(component, &headphone_jack, &mic_jack, NULL);
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	bdw_rt5650->component = component;
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci	return 0;
2128c2ecf20Sopenharmony_ci}
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci/* broadwell digital audio interface glue - connects codec <--> CPU */
2158c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(dummy,
2168c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_DUMMY()));
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(fe,
2198c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(platform,
2228c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_PLATFORM("haswell-pcm-audio")));
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(be,
2258c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5650:00", "rt5645-aif1")));
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEF(ssp0_port,
2288c2ecf20Sopenharmony_ci	    DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistatic struct snd_soc_dai_link bdw_rt5650_dais[] = {
2318c2ecf20Sopenharmony_ci	/* Front End DAI links */
2328c2ecf20Sopenharmony_ci	{
2338c2ecf20Sopenharmony_ci		.name = "System PCM",
2348c2ecf20Sopenharmony_ci		.stream_name = "System Playback",
2358c2ecf20Sopenharmony_ci		.nonatomic = 1,
2368c2ecf20Sopenharmony_ci		.dynamic = 1,
2378c2ecf20Sopenharmony_ci		.ops = &bdw_rt5650_fe_ops,
2388c2ecf20Sopenharmony_ci		.trigger = {
2398c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST,
2408c2ecf20Sopenharmony_ci			SND_SOC_DPCM_TRIGGER_POST
2418c2ecf20Sopenharmony_ci		},
2428c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
2438c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
2448c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(fe, dummy, platform),
2458c2ecf20Sopenharmony_ci	},
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	/* Back End DAI links */
2488c2ecf20Sopenharmony_ci	{
2498c2ecf20Sopenharmony_ci		/* SSP0 - Codec */
2508c2ecf20Sopenharmony_ci		.name = "Codec",
2518c2ecf20Sopenharmony_ci		.id = 0,
2528c2ecf20Sopenharmony_ci		.no_pcm = 1,
2538c2ecf20Sopenharmony_ci		.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF |
2548c2ecf20Sopenharmony_ci			SND_SOC_DAIFMT_CBS_CFS,
2558c2ecf20Sopenharmony_ci		.ignore_pmdown_time = 1,
2568c2ecf20Sopenharmony_ci		.be_hw_params_fixup = broadwell_ssp0_fixup,
2578c2ecf20Sopenharmony_ci		.ops = &bdw_rt5650_ops,
2588c2ecf20Sopenharmony_ci		.dpcm_playback = 1,
2598c2ecf20Sopenharmony_ci		.dpcm_capture = 1,
2608c2ecf20Sopenharmony_ci		.init = bdw_rt5650_init,
2618c2ecf20Sopenharmony_ci		SND_SOC_DAILINK_REG(ssp0_port, be, platform),
2628c2ecf20Sopenharmony_ci	},
2638c2ecf20Sopenharmony_ci};
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
2668c2ecf20Sopenharmony_ci/* use space before codec name to simplify card ID, and simplify driver name */
2678c2ecf20Sopenharmony_ci#define CARD_NAME "bdw rt5650" /* card name will be 'sof-bdw rt5650' */
2688c2ecf20Sopenharmony_ci#define DRIVER_NAME "SOF"
2698c2ecf20Sopenharmony_ci#else
2708c2ecf20Sopenharmony_ci#define CARD_NAME "bdw-rt5650"
2718c2ecf20Sopenharmony_ci#define DRIVER_NAME NULL /* card name will be used for driver name */
2728c2ecf20Sopenharmony_ci#endif
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci/* ASoC machine driver for Broadwell DSP + RT5650 */
2758c2ecf20Sopenharmony_cistatic struct snd_soc_card bdw_rt5650_card = {
2768c2ecf20Sopenharmony_ci	.name = CARD_NAME,
2778c2ecf20Sopenharmony_ci	.driver_name = DRIVER_NAME,
2788c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
2798c2ecf20Sopenharmony_ci	.dai_link = bdw_rt5650_dais,
2808c2ecf20Sopenharmony_ci	.num_links = ARRAY_SIZE(bdw_rt5650_dais),
2818c2ecf20Sopenharmony_ci	.dapm_widgets = bdw_rt5650_widgets,
2828c2ecf20Sopenharmony_ci	.num_dapm_widgets = ARRAY_SIZE(bdw_rt5650_widgets),
2838c2ecf20Sopenharmony_ci	.dapm_routes = bdw_rt5650_map,
2848c2ecf20Sopenharmony_ci	.num_dapm_routes = ARRAY_SIZE(bdw_rt5650_map),
2858c2ecf20Sopenharmony_ci	.controls = bdw_rt5650_controls,
2868c2ecf20Sopenharmony_ci	.num_controls = ARRAY_SIZE(bdw_rt5650_controls),
2878c2ecf20Sopenharmony_ci	.fully_routed = true,
2888c2ecf20Sopenharmony_ci};
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_cistatic int bdw_rt5650_probe(struct platform_device *pdev)
2918c2ecf20Sopenharmony_ci{
2928c2ecf20Sopenharmony_ci	struct bdw_rt5650_priv *bdw_rt5650;
2938c2ecf20Sopenharmony_ci	struct snd_soc_acpi_mach *mach;
2948c2ecf20Sopenharmony_ci	int ret;
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci	bdw_rt5650_card.dev = &pdev->dev;
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci	/* Allocate driver private struct */
2998c2ecf20Sopenharmony_ci	bdw_rt5650 = devm_kzalloc(&pdev->dev, sizeof(struct bdw_rt5650_priv),
3008c2ecf20Sopenharmony_ci		GFP_KERNEL);
3018c2ecf20Sopenharmony_ci	if (!bdw_rt5650)
3028c2ecf20Sopenharmony_ci		return -ENOMEM;
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci	/* override plaform name, if required */
3058c2ecf20Sopenharmony_ci	mach = pdev->dev.platform_data;
3068c2ecf20Sopenharmony_ci	ret = snd_soc_fixup_dai_links_platform_name(&bdw_rt5650_card,
3078c2ecf20Sopenharmony_ci						    mach->mach_params.platform);
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	if (ret)
3108c2ecf20Sopenharmony_ci		return ret;
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	snd_soc_card_set_drvdata(&bdw_rt5650_card, bdw_rt5650);
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_ci	return devm_snd_soc_register_card(&pdev->dev, &bdw_rt5650_card);
3158c2ecf20Sopenharmony_ci}
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_cistatic struct platform_driver bdw_rt5650_audio = {
3188c2ecf20Sopenharmony_ci	.probe = bdw_rt5650_probe,
3198c2ecf20Sopenharmony_ci	.driver = {
3208c2ecf20Sopenharmony_ci		.name = "bdw-rt5650",
3218c2ecf20Sopenharmony_ci		.pm = &snd_soc_pm_ops,
3228c2ecf20Sopenharmony_ci	},
3238c2ecf20Sopenharmony_ci};
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_cimodule_platform_driver(bdw_rt5650_audio)
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci/* Module information */
3288c2ecf20Sopenharmony_ciMODULE_AUTHOR("Ben Zhang <benzh@chromium.org>");
3298c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Intel Broadwell RT5650 machine driver");
3308c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
3318c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:bdw-rt5650");
332