xref: /openbmc/linux/sound/soc/intel/boards/bdw-rt5677.c (revision 9b6fdef62b37714af9495d09eab1d0c8ba0509bd)
12d995e5dSJohn Keeping /*
22d995e5dSJohn Keeping  * ASoC machine driver for Intel Broadwell platforms with RT5677 codec
32d995e5dSJohn Keeping  *
42d995e5dSJohn Keeping  * Copyright (c) 2014, The Chromium OS Authors.  All rights reserved.
52d995e5dSJohn Keeping  *
62d995e5dSJohn Keeping  * This program is free software; you can redistribute it and/or modify it
72d995e5dSJohn Keeping  * under the terms and conditions of the GNU General Public License,
82d995e5dSJohn Keeping  * version 2, as published by the Free Software Foundation.
92d995e5dSJohn Keeping  *
102d995e5dSJohn Keeping  * This program is distributed in the hope it will be useful, but WITHOUT
112d995e5dSJohn Keeping  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
122d995e5dSJohn Keeping  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
132d995e5dSJohn Keeping  * more details.
142d995e5dSJohn Keeping  *
152d995e5dSJohn Keeping  * You should have received a copy of the GNU General Public License
162d995e5dSJohn Keeping  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
172d995e5dSJohn Keeping  */
182d995e5dSJohn Keeping 
192d995e5dSJohn Keeping #include <linux/module.h>
202d995e5dSJohn Keeping #include <linux/platform_device.h>
212d995e5dSJohn Keeping #include <linux/gpio/consumer.h>
222d995e5dSJohn Keeping #include <linux/delay.h>
232d995e5dSJohn Keeping #include <sound/core.h>
242d995e5dSJohn Keeping #include <sound/pcm.h>
252d995e5dSJohn Keeping #include <sound/soc.h>
262d995e5dSJohn Keeping #include <sound/pcm_params.h>
272d995e5dSJohn Keeping #include <sound/jack.h>
282d995e5dSJohn Keeping 
292d995e5dSJohn Keeping #include "../common/sst-dsp.h"
302d995e5dSJohn Keeping #include "../haswell/sst-haswell-ipc.h"
312d995e5dSJohn Keeping 
322d995e5dSJohn Keeping #include "../../codecs/rt5677.h"
332d995e5dSJohn Keeping 
342d995e5dSJohn Keeping struct bdw_rt5677_priv {
352d995e5dSJohn Keeping 	struct gpio_desc *gpio_hp_en;
362d995e5dSJohn Keeping 	struct snd_soc_codec *codec;
372d995e5dSJohn Keeping };
382d995e5dSJohn Keeping 
392d995e5dSJohn Keeping static int bdw_rt5677_event_hp(struct snd_soc_dapm_widget *w,
402d995e5dSJohn Keeping 			struct snd_kcontrol *k, int event)
412d995e5dSJohn Keeping {
422d995e5dSJohn Keeping 	struct snd_soc_dapm_context *dapm = w->dapm;
432d995e5dSJohn Keeping 	struct snd_soc_card *card = dapm->card;
442d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
452d995e5dSJohn Keeping 
462d995e5dSJohn Keeping 	if (SND_SOC_DAPM_EVENT_ON(event))
472d995e5dSJohn Keeping 		msleep(70);
482d995e5dSJohn Keeping 
492d995e5dSJohn Keeping 	gpiod_set_value_cansleep(bdw_rt5677->gpio_hp_en,
502d995e5dSJohn Keeping 		SND_SOC_DAPM_EVENT_ON(event));
512d995e5dSJohn Keeping 
522d995e5dSJohn Keeping 	return 0;
532d995e5dSJohn Keeping }
542d995e5dSJohn Keeping 
552d995e5dSJohn Keeping static const struct snd_soc_dapm_widget bdw_rt5677_widgets[] = {
562d995e5dSJohn Keeping 	SND_SOC_DAPM_HP("Headphone", bdw_rt5677_event_hp),
572d995e5dSJohn Keeping 	SND_SOC_DAPM_SPK("Speaker", NULL),
582d995e5dSJohn Keeping 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
592d995e5dSJohn Keeping 	SND_SOC_DAPM_MIC("Local DMICs", NULL),
602d995e5dSJohn Keeping 	SND_SOC_DAPM_MIC("Remote DMICs", NULL),
612d995e5dSJohn Keeping };
622d995e5dSJohn Keeping 
632d995e5dSJohn Keeping static const struct snd_soc_dapm_route bdw_rt5677_map[] = {
642d995e5dSJohn Keeping 	/* Speakers */
652d995e5dSJohn Keeping 	{"Speaker", NULL, "PDM1L"},
662d995e5dSJohn Keeping 	{"Speaker", NULL, "PDM1R"},
672d995e5dSJohn Keeping 
682d995e5dSJohn Keeping 	/* Headset jack connectors */
692d995e5dSJohn Keeping 	{"Headphone", NULL, "LOUT1"},
702d995e5dSJohn Keeping 	{"Headphone", NULL, "LOUT2"},
712d995e5dSJohn Keeping 	{"IN1P", NULL, "Headset Mic"},
722d995e5dSJohn Keeping 	{"IN1N", NULL, "Headset Mic"},
732d995e5dSJohn Keeping 
742d995e5dSJohn Keeping 	/* Digital MICs
752d995e5dSJohn Keeping 	 * Local DMICs: the two DMICs on the mainboard
762d995e5dSJohn Keeping 	 * Remote DMICs: the two DMICs on the camera module
772d995e5dSJohn Keeping 	 */
782d995e5dSJohn Keeping 	{"DMIC L1", NULL, "Remote DMICs"},
792d995e5dSJohn Keeping 	{"DMIC R1", NULL, "Remote DMICs"},
802d995e5dSJohn Keeping 	{"DMIC L2", NULL, "Local DMICs"},
812d995e5dSJohn Keeping 	{"DMIC R2", NULL, "Local DMICs"},
822d995e5dSJohn Keeping 
832d995e5dSJohn Keeping 	/* CODEC BE connections */
842d995e5dSJohn Keeping 	{"SSP0 CODEC IN", NULL, "AIF1 Capture"},
852d995e5dSJohn Keeping 	{"AIF1 Playback", NULL, "SSP0 CODEC OUT"},
862d995e5dSJohn Keeping };
872d995e5dSJohn Keeping 
882d995e5dSJohn Keeping static const struct snd_kcontrol_new bdw_rt5677_controls[] = {
892d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Speaker"),
902d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Headphone"),
912d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
922d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Local DMICs"),
932d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Remote DMICs"),
942d995e5dSJohn Keeping };
952d995e5dSJohn Keeping 
962d995e5dSJohn Keeping 
972d995e5dSJohn Keeping static struct snd_soc_jack headphone_jack;
982d995e5dSJohn Keeping static struct snd_soc_jack mic_jack;
992d995e5dSJohn Keeping 
1002d995e5dSJohn Keeping static struct snd_soc_jack_pin headphone_jack_pin = {
1012d995e5dSJohn Keeping 	.pin	= "Headphone",
1022d995e5dSJohn Keeping 	.mask	= SND_JACK_HEADPHONE,
1032d995e5dSJohn Keeping };
1042d995e5dSJohn Keeping 
1052d995e5dSJohn Keeping static struct snd_soc_jack_pin mic_jack_pin = {
1062d995e5dSJohn Keeping 	.pin	= "Headset Mic",
1072d995e5dSJohn Keeping 	.mask	= SND_JACK_MICROPHONE,
1082d995e5dSJohn Keeping };
1092d995e5dSJohn Keeping 
1102d995e5dSJohn Keeping static struct snd_soc_jack_gpio headphone_jack_gpio = {
1112d995e5dSJohn Keeping 	.name			= "plug-det",
1122d995e5dSJohn Keeping 	.report			= SND_JACK_HEADPHONE,
1132d995e5dSJohn Keeping 	.debounce_time		= 200,
1142d995e5dSJohn Keeping };
1152d995e5dSJohn Keeping 
1162d995e5dSJohn Keeping static struct snd_soc_jack_gpio mic_jack_gpio = {
1172d995e5dSJohn Keeping 	.name			= "mic-present",
1182d995e5dSJohn Keeping 	.report			= SND_JACK_MICROPHONE,
1192d995e5dSJohn Keeping 	.debounce_time		= 200,
1202d995e5dSJohn Keeping 	.invert			= 1,
1212d995e5dSJohn Keeping };
1222d995e5dSJohn Keeping 
1232d995e5dSJohn Keeping static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
1242d995e5dSJohn Keeping 			struct snd_pcm_hw_params *params)
1252d995e5dSJohn Keeping {
1262d995e5dSJohn Keeping 	struct snd_interval *rate = hw_param_interval(params,
1272d995e5dSJohn Keeping 			SNDRV_PCM_HW_PARAM_RATE);
1282d995e5dSJohn Keeping 	struct snd_interval *channels = hw_param_interval(params,
1292d995e5dSJohn Keeping 						SNDRV_PCM_HW_PARAM_CHANNELS);
1302d995e5dSJohn Keeping 
1312d995e5dSJohn Keeping 	/* The ADSP will covert the FE rate to 48k, stereo */
1322d995e5dSJohn Keeping 	rate->min = rate->max = 48000;
1332d995e5dSJohn Keeping 	channels->min = channels->max = 2;
1342d995e5dSJohn Keeping 
1352d995e5dSJohn Keeping 	/* set SSP0 to 16 bit */
1362d995e5dSJohn Keeping 	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
1372d995e5dSJohn Keeping 				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
1382d995e5dSJohn Keeping 				    SNDRV_PCM_FORMAT_S16_LE);
1392d995e5dSJohn Keeping 	return 0;
1402d995e5dSJohn Keeping }
1412d995e5dSJohn Keeping 
1422d995e5dSJohn Keeping static int bdw_rt5677_hw_params(struct snd_pcm_substream *substream,
1432d995e5dSJohn Keeping 	struct snd_pcm_hw_params *params)
1442d995e5dSJohn Keeping {
1452d995e5dSJohn Keeping 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
1462d995e5dSJohn Keeping 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
1472d995e5dSJohn Keeping 	int ret;
1482d995e5dSJohn Keeping 
1492d995e5dSJohn Keeping 	ret = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_MCLK, 24576000,
1502d995e5dSJohn Keeping 		SND_SOC_CLOCK_IN);
1512d995e5dSJohn Keeping 	if (ret < 0) {
1522d995e5dSJohn Keeping 		dev_err(rtd->dev, "can't set codec sysclk configuration\n");
1532d995e5dSJohn Keeping 		return ret;
1542d995e5dSJohn Keeping 	}
1552d995e5dSJohn Keeping 
1562d995e5dSJohn Keeping 	return ret;
1572d995e5dSJohn Keeping }
1582d995e5dSJohn Keeping 
159*9b6fdef6SJulia Lawall static const struct snd_soc_ops bdw_rt5677_ops = {
1602d995e5dSJohn Keeping 	.hw_params = bdw_rt5677_hw_params,
1612d995e5dSJohn Keeping };
1622d995e5dSJohn Keeping 
1632d995e5dSJohn Keeping static int bdw_rt5677_rtd_init(struct snd_soc_pcm_runtime *rtd)
1642d995e5dSJohn Keeping {
1652d995e5dSJohn Keeping 	struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev);
1662d995e5dSJohn Keeping 	struct sst_hsw *broadwell = pdata->dsp;
1672d995e5dSJohn Keeping 	int ret;
1682d995e5dSJohn Keeping 
1692d995e5dSJohn Keeping 	/* Set ADSP SSP port settings */
1702d995e5dSJohn Keeping 	ret = sst_hsw_device_set_config(broadwell, SST_HSW_DEVICE_SSP_0,
1712d995e5dSJohn Keeping 		SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
1722d995e5dSJohn Keeping 		SST_HSW_DEVICE_CLOCK_MASTER, 9);
1732d995e5dSJohn Keeping 	if (ret < 0) {
1742d995e5dSJohn Keeping 		dev_err(rtd->dev, "error: failed to set device config\n");
1752d995e5dSJohn Keeping 		return ret;
1762d995e5dSJohn Keeping 	}
1772d995e5dSJohn Keeping 
1782d995e5dSJohn Keeping 	return 0;
1792d995e5dSJohn Keeping }
1802d995e5dSJohn Keeping 
1812d995e5dSJohn Keeping static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd)
1822d995e5dSJohn Keeping {
1832d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677 =
1842d995e5dSJohn Keeping 			snd_soc_card_get_drvdata(rtd->card);
1852d995e5dSJohn Keeping 	struct snd_soc_codec *codec = rtd->codec;
1862d995e5dSJohn Keeping 	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
1872d995e5dSJohn Keeping 
1882d995e5dSJohn Keeping 	/* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1.
1892d995e5dSJohn Keeping 	 * The ASRC clock source is clk_i2s1_asrc.
1902d995e5dSJohn Keeping 	 */
1912d995e5dSJohn Keeping 	rt5677_sel_asrc_clk_src(codec, RT5677_DA_STEREO_FILTER |
1922d995e5dSJohn Keeping 			RT5677_AD_STEREO1_FILTER | RT5677_I2S1_SOURCE,
1932d995e5dSJohn Keeping 			RT5677_CLK_SEL_I2S1_ASRC);
1942d995e5dSJohn Keeping 
1952d995e5dSJohn Keeping 	/* Request rt5677 GPIO for headphone amp control */
1962d995e5dSJohn Keeping 	bdw_rt5677->gpio_hp_en = devm_gpiod_get_index(codec->dev,
1972d995e5dSJohn Keeping 			"headphone-enable", 0, 0);
1982d995e5dSJohn Keeping 	if (IS_ERR(bdw_rt5677->gpio_hp_en)) {
1992d995e5dSJohn Keeping 		dev_err(codec->dev, "Can't find HP_AMP_SHDN_L gpio\n");
2002d995e5dSJohn Keeping 		return PTR_ERR(bdw_rt5677->gpio_hp_en);
2012d995e5dSJohn Keeping 	}
2022d995e5dSJohn Keeping 	gpiod_direction_output(bdw_rt5677->gpio_hp_en, 0);
2032d995e5dSJohn Keeping 
2042d995e5dSJohn Keeping 	/* Create and initialize headphone jack */
2052d995e5dSJohn Keeping 	if (!snd_soc_card_jack_new(rtd->card, "Headphone Jack",
2062d995e5dSJohn Keeping 			SND_JACK_HEADPHONE, &headphone_jack,
2072d995e5dSJohn Keeping 			&headphone_jack_pin, 1)) {
2082d995e5dSJohn Keeping 		headphone_jack_gpio.gpiod_dev = codec->dev;
2092d995e5dSJohn Keeping 		if (snd_soc_jack_add_gpios(&headphone_jack, 1,
2102d995e5dSJohn Keeping 				&headphone_jack_gpio))
2112d995e5dSJohn Keeping 			dev_err(codec->dev, "Can't add headphone jack gpio\n");
2122d995e5dSJohn Keeping 	} else {
2132d995e5dSJohn Keeping 		dev_err(codec->dev, "Can't create headphone jack\n");
2142d995e5dSJohn Keeping 	}
2152d995e5dSJohn Keeping 
2162d995e5dSJohn Keeping 	/* Create and initialize mic jack */
2172d995e5dSJohn Keeping 	if (!snd_soc_card_jack_new(rtd->card, "Mic Jack",
2182d995e5dSJohn Keeping 			SND_JACK_MICROPHONE, &mic_jack,
2192d995e5dSJohn Keeping 			&mic_jack_pin, 1)) {
2202d995e5dSJohn Keeping 		mic_jack_gpio.gpiod_dev = codec->dev;
2212d995e5dSJohn Keeping 		if (snd_soc_jack_add_gpios(&mic_jack, 1, &mic_jack_gpio))
2222d995e5dSJohn Keeping 			dev_err(codec->dev, "Can't add mic jack gpio\n");
2232d995e5dSJohn Keeping 	} else {
2242d995e5dSJohn Keeping 		dev_err(codec->dev, "Can't create mic jack\n");
2252d995e5dSJohn Keeping 	}
2262d995e5dSJohn Keeping 	bdw_rt5677->codec = codec;
2272d995e5dSJohn Keeping 
2282d995e5dSJohn Keeping 	snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
2292d995e5dSJohn Keeping 	return 0;
2302d995e5dSJohn Keeping }
2312d995e5dSJohn Keeping 
2322d995e5dSJohn Keeping /* broadwell digital audio interface glue - connects codec <--> CPU */
2332d995e5dSJohn Keeping static struct snd_soc_dai_link bdw_rt5677_dais[] = {
2342d995e5dSJohn Keeping 	/* Front End DAI links */
2352d995e5dSJohn Keeping 	{
2362d995e5dSJohn Keeping 		.name = "System PCM",
2372d995e5dSJohn Keeping 		.stream_name = "System Playback/Capture",
2382d995e5dSJohn Keeping 		.cpu_dai_name = "System Pin",
2392d995e5dSJohn Keeping 		.platform_name = "haswell-pcm-audio",
2402d995e5dSJohn Keeping 		.dynamic = 1,
2412d995e5dSJohn Keeping 		.codec_name = "snd-soc-dummy",
2422d995e5dSJohn Keeping 		.codec_dai_name = "snd-soc-dummy-dai",
2432d995e5dSJohn Keeping 		.init = bdw_rt5677_rtd_init,
2442d995e5dSJohn Keeping 		.trigger = {
2452d995e5dSJohn Keeping 			SND_SOC_DPCM_TRIGGER_POST,
2462d995e5dSJohn Keeping 			SND_SOC_DPCM_TRIGGER_POST
2472d995e5dSJohn Keeping 		},
2482d995e5dSJohn Keeping 		.dpcm_capture = 1,
2492d995e5dSJohn Keeping 		.dpcm_playback = 1,
2502d995e5dSJohn Keeping 	},
2512d995e5dSJohn Keeping 
2522d995e5dSJohn Keeping 	/* Back End DAI links */
2532d995e5dSJohn Keeping 	{
2542d995e5dSJohn Keeping 		/* SSP0 - Codec */
2552d995e5dSJohn Keeping 		.name = "Codec",
2562d995e5dSJohn Keeping 		.id = 0,
2572d995e5dSJohn Keeping 		.cpu_dai_name = "snd-soc-dummy-dai",
2582d995e5dSJohn Keeping 		.platform_name = "snd-soc-dummy",
2592d995e5dSJohn Keeping 		.no_pcm = 1,
2602d995e5dSJohn Keeping 		.codec_name = "i2c-RT5677CE:00",
2612d995e5dSJohn Keeping 		.codec_dai_name = "rt5677-aif1",
2622d995e5dSJohn Keeping 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
2632d995e5dSJohn Keeping 			SND_SOC_DAIFMT_CBS_CFS,
2642d995e5dSJohn Keeping 		.ignore_suspend = 1,
2652d995e5dSJohn Keeping 		.ignore_pmdown_time = 1,
2662d995e5dSJohn Keeping 		.be_hw_params_fixup = broadwell_ssp0_fixup,
2672d995e5dSJohn Keeping 		.ops = &bdw_rt5677_ops,
2682d995e5dSJohn Keeping 		.dpcm_playback = 1,
2692d995e5dSJohn Keeping 		.dpcm_capture = 1,
2702d995e5dSJohn Keeping 		.init = bdw_rt5677_init,
2712d995e5dSJohn Keeping 	},
2722d995e5dSJohn Keeping };
2732d995e5dSJohn Keeping 
2742d995e5dSJohn Keeping static int bdw_rt5677_suspend_pre(struct snd_soc_card *card)
2752d995e5dSJohn Keeping {
2762d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
2772d995e5dSJohn Keeping 	struct snd_soc_dapm_context *dapm;
2782d995e5dSJohn Keeping 
2792d995e5dSJohn Keeping 	if (bdw_rt5677->codec) {
2802d995e5dSJohn Keeping 		dapm = snd_soc_codec_get_dapm(bdw_rt5677->codec);
2812d995e5dSJohn Keeping 		snd_soc_dapm_disable_pin(dapm, "MICBIAS1");
2822d995e5dSJohn Keeping 	}
2832d995e5dSJohn Keeping 	return 0;
2842d995e5dSJohn Keeping }
2852d995e5dSJohn Keeping 
2862d995e5dSJohn Keeping static int bdw_rt5677_resume_post(struct snd_soc_card *card)
2872d995e5dSJohn Keeping {
2882d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
2892d995e5dSJohn Keeping 	struct snd_soc_dapm_context *dapm;
2902d995e5dSJohn Keeping 
2912d995e5dSJohn Keeping 	if (bdw_rt5677->codec) {
2922d995e5dSJohn Keeping 		dapm = snd_soc_codec_get_dapm(bdw_rt5677->codec);
2932d995e5dSJohn Keeping 		snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
2942d995e5dSJohn Keeping 	}
2952d995e5dSJohn Keeping 	return 0;
2962d995e5dSJohn Keeping }
2972d995e5dSJohn Keeping 
2982d995e5dSJohn Keeping /* ASoC machine driver for Broadwell DSP + RT5677 */
2992d995e5dSJohn Keeping static struct snd_soc_card bdw_rt5677_card = {
3002d995e5dSJohn Keeping 	.name = "bdw-rt5677",
3012d995e5dSJohn Keeping 	.owner = THIS_MODULE,
3022d995e5dSJohn Keeping 	.dai_link = bdw_rt5677_dais,
3032d995e5dSJohn Keeping 	.num_links = ARRAY_SIZE(bdw_rt5677_dais),
3042d995e5dSJohn Keeping 	.dapm_widgets = bdw_rt5677_widgets,
3052d995e5dSJohn Keeping 	.num_dapm_widgets = ARRAY_SIZE(bdw_rt5677_widgets),
3062d995e5dSJohn Keeping 	.dapm_routes = bdw_rt5677_map,
3072d995e5dSJohn Keeping 	.num_dapm_routes = ARRAY_SIZE(bdw_rt5677_map),
3082d995e5dSJohn Keeping 	.controls = bdw_rt5677_controls,
3092d995e5dSJohn Keeping 	.num_controls = ARRAY_SIZE(bdw_rt5677_controls),
3102d995e5dSJohn Keeping 	.fully_routed = true,
3112d995e5dSJohn Keeping 	.suspend_pre = bdw_rt5677_suspend_pre,
3122d995e5dSJohn Keeping 	.resume_post = bdw_rt5677_resume_post,
3132d995e5dSJohn Keeping };
3142d995e5dSJohn Keeping 
3152d995e5dSJohn Keeping static int bdw_rt5677_probe(struct platform_device *pdev)
3162d995e5dSJohn Keeping {
3172d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677;
3182d995e5dSJohn Keeping 
3192d995e5dSJohn Keeping 	bdw_rt5677_card.dev = &pdev->dev;
3202d995e5dSJohn Keeping 
3212d995e5dSJohn Keeping 	/* Allocate driver private struct */
3222d995e5dSJohn Keeping 	bdw_rt5677 = devm_kzalloc(&pdev->dev, sizeof(struct bdw_rt5677_priv),
3232d995e5dSJohn Keeping 		GFP_KERNEL);
3242d995e5dSJohn Keeping 	if (!bdw_rt5677) {
3252d995e5dSJohn Keeping 		dev_err(&pdev->dev, "Can't allocate bdw_rt5677\n");
3262d995e5dSJohn Keeping 		return -ENOMEM;
3272d995e5dSJohn Keeping 	}
3282d995e5dSJohn Keeping 
3292d995e5dSJohn Keeping 	snd_soc_card_set_drvdata(&bdw_rt5677_card, bdw_rt5677);
3302d995e5dSJohn Keeping 
3312d995e5dSJohn Keeping 	return devm_snd_soc_register_card(&pdev->dev, &bdw_rt5677_card);
3322d995e5dSJohn Keeping }
3332d995e5dSJohn Keeping 
3342d995e5dSJohn Keeping static struct platform_driver bdw_rt5677_audio = {
3352d995e5dSJohn Keeping 	.probe = bdw_rt5677_probe,
3362d995e5dSJohn Keeping 	.driver = {
3372d995e5dSJohn Keeping 		.name = "bdw-rt5677",
3382d995e5dSJohn Keeping 	},
3392d995e5dSJohn Keeping };
3402d995e5dSJohn Keeping 
3412d995e5dSJohn Keeping module_platform_driver(bdw_rt5677_audio)
3422d995e5dSJohn Keeping 
3432d995e5dSJohn Keeping /* Module information */
3442d995e5dSJohn Keeping MODULE_AUTHOR("Ben Zhang");
3452d995e5dSJohn Keeping MODULE_DESCRIPTION("Intel Broadwell RT5677 machine driver");
3462d995e5dSJohn Keeping MODULE_LICENSE("GPL v2");
3472d995e5dSJohn Keeping MODULE_ALIAS("platform:bdw-rt5677");
348