xref: /openbmc/linux/sound/soc/intel/boards/bdw-rt5677.c (revision 2d995e5dc283adbfbf9c1eb81bf35ca7af2d22a6)
1*2d995e5dSJohn Keeping /*
2*2d995e5dSJohn Keeping  * ASoC machine driver for Intel Broadwell platforms with RT5677 codec
3*2d995e5dSJohn Keeping  *
4*2d995e5dSJohn Keeping  * Copyright (c) 2014, The Chromium OS Authors.  All rights reserved.
5*2d995e5dSJohn Keeping  *
6*2d995e5dSJohn Keeping  * This program is free software; you can redistribute it and/or modify it
7*2d995e5dSJohn Keeping  * under the terms and conditions of the GNU General Public License,
8*2d995e5dSJohn Keeping  * version 2, as published by the Free Software Foundation.
9*2d995e5dSJohn Keeping  *
10*2d995e5dSJohn Keeping  * This program is distributed in the hope it will be useful, but WITHOUT
11*2d995e5dSJohn Keeping  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12*2d995e5dSJohn Keeping  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13*2d995e5dSJohn Keeping  * more details.
14*2d995e5dSJohn Keeping  *
15*2d995e5dSJohn Keeping  * You should have received a copy of the GNU General Public License
16*2d995e5dSJohn Keeping  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17*2d995e5dSJohn Keeping  */
18*2d995e5dSJohn Keeping 
19*2d995e5dSJohn Keeping #include <linux/module.h>
20*2d995e5dSJohn Keeping #include <linux/platform_device.h>
21*2d995e5dSJohn Keeping #include <linux/gpio/consumer.h>
22*2d995e5dSJohn Keeping #include <linux/delay.h>
23*2d995e5dSJohn Keeping #include <sound/core.h>
24*2d995e5dSJohn Keeping #include <sound/pcm.h>
25*2d995e5dSJohn Keeping #include <sound/soc.h>
26*2d995e5dSJohn Keeping #include <sound/pcm_params.h>
27*2d995e5dSJohn Keeping #include <sound/jack.h>
28*2d995e5dSJohn Keeping 
29*2d995e5dSJohn Keeping #include "../common/sst-dsp.h"
30*2d995e5dSJohn Keeping #include "../haswell/sst-haswell-ipc.h"
31*2d995e5dSJohn Keeping 
32*2d995e5dSJohn Keeping #include "../../codecs/rt5677.h"
33*2d995e5dSJohn Keeping 
34*2d995e5dSJohn Keeping struct bdw_rt5677_priv {
35*2d995e5dSJohn Keeping 	struct gpio_desc *gpio_hp_en;
36*2d995e5dSJohn Keeping 	struct snd_soc_codec *codec;
37*2d995e5dSJohn Keeping };
38*2d995e5dSJohn Keeping 
39*2d995e5dSJohn Keeping static int bdw_rt5677_event_hp(struct snd_soc_dapm_widget *w,
40*2d995e5dSJohn Keeping 			struct snd_kcontrol *k, int event)
41*2d995e5dSJohn Keeping {
42*2d995e5dSJohn Keeping 	struct snd_soc_dapm_context *dapm = w->dapm;
43*2d995e5dSJohn Keeping 	struct snd_soc_card *card = dapm->card;
44*2d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
45*2d995e5dSJohn Keeping 
46*2d995e5dSJohn Keeping 	if (SND_SOC_DAPM_EVENT_ON(event))
47*2d995e5dSJohn Keeping 		msleep(70);
48*2d995e5dSJohn Keeping 
49*2d995e5dSJohn Keeping 	gpiod_set_value_cansleep(bdw_rt5677->gpio_hp_en,
50*2d995e5dSJohn Keeping 		SND_SOC_DAPM_EVENT_ON(event));
51*2d995e5dSJohn Keeping 
52*2d995e5dSJohn Keeping 	return 0;
53*2d995e5dSJohn Keeping }
54*2d995e5dSJohn Keeping 
55*2d995e5dSJohn Keeping static const struct snd_soc_dapm_widget bdw_rt5677_widgets[] = {
56*2d995e5dSJohn Keeping 	SND_SOC_DAPM_HP("Headphone", bdw_rt5677_event_hp),
57*2d995e5dSJohn Keeping 	SND_SOC_DAPM_SPK("Speaker", NULL),
58*2d995e5dSJohn Keeping 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
59*2d995e5dSJohn Keeping 	SND_SOC_DAPM_MIC("Local DMICs", NULL),
60*2d995e5dSJohn Keeping 	SND_SOC_DAPM_MIC("Remote DMICs", NULL),
61*2d995e5dSJohn Keeping };
62*2d995e5dSJohn Keeping 
63*2d995e5dSJohn Keeping static const struct snd_soc_dapm_route bdw_rt5677_map[] = {
64*2d995e5dSJohn Keeping 	/* Speakers */
65*2d995e5dSJohn Keeping 	{"Speaker", NULL, "PDM1L"},
66*2d995e5dSJohn Keeping 	{"Speaker", NULL, "PDM1R"},
67*2d995e5dSJohn Keeping 
68*2d995e5dSJohn Keeping 	/* Headset jack connectors */
69*2d995e5dSJohn Keeping 	{"Headphone", NULL, "LOUT1"},
70*2d995e5dSJohn Keeping 	{"Headphone", NULL, "LOUT2"},
71*2d995e5dSJohn Keeping 	{"IN1P", NULL, "Headset Mic"},
72*2d995e5dSJohn Keeping 	{"IN1N", NULL, "Headset Mic"},
73*2d995e5dSJohn Keeping 
74*2d995e5dSJohn Keeping 	/* Digital MICs
75*2d995e5dSJohn Keeping 	 * Local DMICs: the two DMICs on the mainboard
76*2d995e5dSJohn Keeping 	 * Remote DMICs: the two DMICs on the camera module
77*2d995e5dSJohn Keeping 	 */
78*2d995e5dSJohn Keeping 	{"DMIC L1", NULL, "Remote DMICs"},
79*2d995e5dSJohn Keeping 	{"DMIC R1", NULL, "Remote DMICs"},
80*2d995e5dSJohn Keeping 	{"DMIC L2", NULL, "Local DMICs"},
81*2d995e5dSJohn Keeping 	{"DMIC R2", NULL, "Local DMICs"},
82*2d995e5dSJohn Keeping 
83*2d995e5dSJohn Keeping 	/* CODEC BE connections */
84*2d995e5dSJohn Keeping 	{"SSP0 CODEC IN", NULL, "AIF1 Capture"},
85*2d995e5dSJohn Keeping 	{"AIF1 Playback", NULL, "SSP0 CODEC OUT"},
86*2d995e5dSJohn Keeping };
87*2d995e5dSJohn Keeping 
88*2d995e5dSJohn Keeping static const struct snd_kcontrol_new bdw_rt5677_controls[] = {
89*2d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Speaker"),
90*2d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Headphone"),
91*2d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
92*2d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Local DMICs"),
93*2d995e5dSJohn Keeping 	SOC_DAPM_PIN_SWITCH("Remote DMICs"),
94*2d995e5dSJohn Keeping };
95*2d995e5dSJohn Keeping 
96*2d995e5dSJohn Keeping 
97*2d995e5dSJohn Keeping static struct snd_soc_jack headphone_jack;
98*2d995e5dSJohn Keeping static struct snd_soc_jack mic_jack;
99*2d995e5dSJohn Keeping 
100*2d995e5dSJohn Keeping static struct snd_soc_jack_pin headphone_jack_pin = {
101*2d995e5dSJohn Keeping 	.pin	= "Headphone",
102*2d995e5dSJohn Keeping 	.mask	= SND_JACK_HEADPHONE,
103*2d995e5dSJohn Keeping };
104*2d995e5dSJohn Keeping 
105*2d995e5dSJohn Keeping static struct snd_soc_jack_pin mic_jack_pin = {
106*2d995e5dSJohn Keeping 	.pin	= "Headset Mic",
107*2d995e5dSJohn Keeping 	.mask	= SND_JACK_MICROPHONE,
108*2d995e5dSJohn Keeping };
109*2d995e5dSJohn Keeping 
110*2d995e5dSJohn Keeping static struct snd_soc_jack_gpio headphone_jack_gpio = {
111*2d995e5dSJohn Keeping 	.name			= "plug-det",
112*2d995e5dSJohn Keeping 	.report			= SND_JACK_HEADPHONE,
113*2d995e5dSJohn Keeping 	.debounce_time		= 200,
114*2d995e5dSJohn Keeping };
115*2d995e5dSJohn Keeping 
116*2d995e5dSJohn Keeping static struct snd_soc_jack_gpio mic_jack_gpio = {
117*2d995e5dSJohn Keeping 	.name			= "mic-present",
118*2d995e5dSJohn Keeping 	.report			= SND_JACK_MICROPHONE,
119*2d995e5dSJohn Keeping 	.debounce_time		= 200,
120*2d995e5dSJohn Keeping 	.invert			= 1,
121*2d995e5dSJohn Keeping };
122*2d995e5dSJohn Keeping 
123*2d995e5dSJohn Keeping static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
124*2d995e5dSJohn Keeping 			struct snd_pcm_hw_params *params)
125*2d995e5dSJohn Keeping {
126*2d995e5dSJohn Keeping 	struct snd_interval *rate = hw_param_interval(params,
127*2d995e5dSJohn Keeping 			SNDRV_PCM_HW_PARAM_RATE);
128*2d995e5dSJohn Keeping 	struct snd_interval *channels = hw_param_interval(params,
129*2d995e5dSJohn Keeping 						SNDRV_PCM_HW_PARAM_CHANNELS);
130*2d995e5dSJohn Keeping 
131*2d995e5dSJohn Keeping 	/* The ADSP will covert the FE rate to 48k, stereo */
132*2d995e5dSJohn Keeping 	rate->min = rate->max = 48000;
133*2d995e5dSJohn Keeping 	channels->min = channels->max = 2;
134*2d995e5dSJohn Keeping 
135*2d995e5dSJohn Keeping 	/* set SSP0 to 16 bit */
136*2d995e5dSJohn Keeping 	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
137*2d995e5dSJohn Keeping 				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
138*2d995e5dSJohn Keeping 				    SNDRV_PCM_FORMAT_S16_LE);
139*2d995e5dSJohn Keeping 	return 0;
140*2d995e5dSJohn Keeping }
141*2d995e5dSJohn Keeping 
142*2d995e5dSJohn Keeping static int bdw_rt5677_hw_params(struct snd_pcm_substream *substream,
143*2d995e5dSJohn Keeping 	struct snd_pcm_hw_params *params)
144*2d995e5dSJohn Keeping {
145*2d995e5dSJohn Keeping 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
146*2d995e5dSJohn Keeping 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
147*2d995e5dSJohn Keeping 	int ret;
148*2d995e5dSJohn Keeping 
149*2d995e5dSJohn Keeping 	ret = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_MCLK, 24576000,
150*2d995e5dSJohn Keeping 		SND_SOC_CLOCK_IN);
151*2d995e5dSJohn Keeping 	if (ret < 0) {
152*2d995e5dSJohn Keeping 		dev_err(rtd->dev, "can't set codec sysclk configuration\n");
153*2d995e5dSJohn Keeping 		return ret;
154*2d995e5dSJohn Keeping 	}
155*2d995e5dSJohn Keeping 
156*2d995e5dSJohn Keeping 	return ret;
157*2d995e5dSJohn Keeping }
158*2d995e5dSJohn Keeping 
159*2d995e5dSJohn Keeping static struct snd_soc_ops bdw_rt5677_ops = {
160*2d995e5dSJohn Keeping 	.hw_params = bdw_rt5677_hw_params,
161*2d995e5dSJohn Keeping };
162*2d995e5dSJohn Keeping 
163*2d995e5dSJohn Keeping static int bdw_rt5677_rtd_init(struct snd_soc_pcm_runtime *rtd)
164*2d995e5dSJohn Keeping {
165*2d995e5dSJohn Keeping 	struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev);
166*2d995e5dSJohn Keeping 	struct sst_hsw *broadwell = pdata->dsp;
167*2d995e5dSJohn Keeping 	int ret;
168*2d995e5dSJohn Keeping 
169*2d995e5dSJohn Keeping 	/* Set ADSP SSP port settings */
170*2d995e5dSJohn Keeping 	ret = sst_hsw_device_set_config(broadwell, SST_HSW_DEVICE_SSP_0,
171*2d995e5dSJohn Keeping 		SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
172*2d995e5dSJohn Keeping 		SST_HSW_DEVICE_CLOCK_MASTER, 9);
173*2d995e5dSJohn Keeping 	if (ret < 0) {
174*2d995e5dSJohn Keeping 		dev_err(rtd->dev, "error: failed to set device config\n");
175*2d995e5dSJohn Keeping 		return ret;
176*2d995e5dSJohn Keeping 	}
177*2d995e5dSJohn Keeping 
178*2d995e5dSJohn Keeping 	return 0;
179*2d995e5dSJohn Keeping }
180*2d995e5dSJohn Keeping 
181*2d995e5dSJohn Keeping static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd)
182*2d995e5dSJohn Keeping {
183*2d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677 =
184*2d995e5dSJohn Keeping 			snd_soc_card_get_drvdata(rtd->card);
185*2d995e5dSJohn Keeping 	struct snd_soc_codec *codec = rtd->codec;
186*2d995e5dSJohn Keeping 	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
187*2d995e5dSJohn Keeping 
188*2d995e5dSJohn Keeping 	/* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1.
189*2d995e5dSJohn Keeping 	 * The ASRC clock source is clk_i2s1_asrc.
190*2d995e5dSJohn Keeping 	 */
191*2d995e5dSJohn Keeping 	rt5677_sel_asrc_clk_src(codec, RT5677_DA_STEREO_FILTER |
192*2d995e5dSJohn Keeping 			RT5677_AD_STEREO1_FILTER | RT5677_I2S1_SOURCE,
193*2d995e5dSJohn Keeping 			RT5677_CLK_SEL_I2S1_ASRC);
194*2d995e5dSJohn Keeping 
195*2d995e5dSJohn Keeping 	/* Request rt5677 GPIO for headphone amp control */
196*2d995e5dSJohn Keeping 	bdw_rt5677->gpio_hp_en = devm_gpiod_get_index(codec->dev,
197*2d995e5dSJohn Keeping 			"headphone-enable", 0, 0);
198*2d995e5dSJohn Keeping 	if (IS_ERR(bdw_rt5677->gpio_hp_en)) {
199*2d995e5dSJohn Keeping 		dev_err(codec->dev, "Can't find HP_AMP_SHDN_L gpio\n");
200*2d995e5dSJohn Keeping 		return PTR_ERR(bdw_rt5677->gpio_hp_en);
201*2d995e5dSJohn Keeping 	}
202*2d995e5dSJohn Keeping 	gpiod_direction_output(bdw_rt5677->gpio_hp_en, 0);
203*2d995e5dSJohn Keeping 
204*2d995e5dSJohn Keeping 	/* Create and initialize headphone jack */
205*2d995e5dSJohn Keeping 	if (!snd_soc_card_jack_new(rtd->card, "Headphone Jack",
206*2d995e5dSJohn Keeping 			SND_JACK_HEADPHONE, &headphone_jack,
207*2d995e5dSJohn Keeping 			&headphone_jack_pin, 1)) {
208*2d995e5dSJohn Keeping 		headphone_jack_gpio.gpiod_dev = codec->dev;
209*2d995e5dSJohn Keeping 		if (snd_soc_jack_add_gpios(&headphone_jack, 1,
210*2d995e5dSJohn Keeping 				&headphone_jack_gpio))
211*2d995e5dSJohn Keeping 			dev_err(codec->dev, "Can't add headphone jack gpio\n");
212*2d995e5dSJohn Keeping 	} else {
213*2d995e5dSJohn Keeping 		dev_err(codec->dev, "Can't create headphone jack\n");
214*2d995e5dSJohn Keeping 	}
215*2d995e5dSJohn Keeping 
216*2d995e5dSJohn Keeping 	/* Create and initialize mic jack */
217*2d995e5dSJohn Keeping 	if (!snd_soc_card_jack_new(rtd->card, "Mic Jack",
218*2d995e5dSJohn Keeping 			SND_JACK_MICROPHONE, &mic_jack,
219*2d995e5dSJohn Keeping 			&mic_jack_pin, 1)) {
220*2d995e5dSJohn Keeping 		mic_jack_gpio.gpiod_dev = codec->dev;
221*2d995e5dSJohn Keeping 		if (snd_soc_jack_add_gpios(&mic_jack, 1, &mic_jack_gpio))
222*2d995e5dSJohn Keeping 			dev_err(codec->dev, "Can't add mic jack gpio\n");
223*2d995e5dSJohn Keeping 	} else {
224*2d995e5dSJohn Keeping 		dev_err(codec->dev, "Can't create mic jack\n");
225*2d995e5dSJohn Keeping 	}
226*2d995e5dSJohn Keeping 	bdw_rt5677->codec = codec;
227*2d995e5dSJohn Keeping 
228*2d995e5dSJohn Keeping 	snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
229*2d995e5dSJohn Keeping 	return 0;
230*2d995e5dSJohn Keeping }
231*2d995e5dSJohn Keeping 
232*2d995e5dSJohn Keeping /* broadwell digital audio interface glue - connects codec <--> CPU */
233*2d995e5dSJohn Keeping static struct snd_soc_dai_link bdw_rt5677_dais[] = {
234*2d995e5dSJohn Keeping 	/* Front End DAI links */
235*2d995e5dSJohn Keeping 	{
236*2d995e5dSJohn Keeping 		.name = "System PCM",
237*2d995e5dSJohn Keeping 		.stream_name = "System Playback/Capture",
238*2d995e5dSJohn Keeping 		.cpu_dai_name = "System Pin",
239*2d995e5dSJohn Keeping 		.platform_name = "haswell-pcm-audio",
240*2d995e5dSJohn Keeping 		.dynamic = 1,
241*2d995e5dSJohn Keeping 		.codec_name = "snd-soc-dummy",
242*2d995e5dSJohn Keeping 		.codec_dai_name = "snd-soc-dummy-dai",
243*2d995e5dSJohn Keeping 		.init = bdw_rt5677_rtd_init,
244*2d995e5dSJohn Keeping 		.trigger = {
245*2d995e5dSJohn Keeping 			SND_SOC_DPCM_TRIGGER_POST,
246*2d995e5dSJohn Keeping 			SND_SOC_DPCM_TRIGGER_POST
247*2d995e5dSJohn Keeping 		},
248*2d995e5dSJohn Keeping 		.dpcm_capture = 1,
249*2d995e5dSJohn Keeping 		.dpcm_playback = 1,
250*2d995e5dSJohn Keeping 	},
251*2d995e5dSJohn Keeping 
252*2d995e5dSJohn Keeping 	/* Back End DAI links */
253*2d995e5dSJohn Keeping 	{
254*2d995e5dSJohn Keeping 		/* SSP0 - Codec */
255*2d995e5dSJohn Keeping 		.name = "Codec",
256*2d995e5dSJohn Keeping 		.id = 0,
257*2d995e5dSJohn Keeping 		.cpu_dai_name = "snd-soc-dummy-dai",
258*2d995e5dSJohn Keeping 		.platform_name = "snd-soc-dummy",
259*2d995e5dSJohn Keeping 		.no_pcm = 1,
260*2d995e5dSJohn Keeping 		.codec_name = "i2c-RT5677CE:00",
261*2d995e5dSJohn Keeping 		.codec_dai_name = "rt5677-aif1",
262*2d995e5dSJohn Keeping 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
263*2d995e5dSJohn Keeping 			SND_SOC_DAIFMT_CBS_CFS,
264*2d995e5dSJohn Keeping 		.ignore_suspend = 1,
265*2d995e5dSJohn Keeping 		.ignore_pmdown_time = 1,
266*2d995e5dSJohn Keeping 		.be_hw_params_fixup = broadwell_ssp0_fixup,
267*2d995e5dSJohn Keeping 		.ops = &bdw_rt5677_ops,
268*2d995e5dSJohn Keeping 		.dpcm_playback = 1,
269*2d995e5dSJohn Keeping 		.dpcm_capture = 1,
270*2d995e5dSJohn Keeping 		.init = bdw_rt5677_init,
271*2d995e5dSJohn Keeping 	},
272*2d995e5dSJohn Keeping };
273*2d995e5dSJohn Keeping 
274*2d995e5dSJohn Keeping static int bdw_rt5677_suspend_pre(struct snd_soc_card *card)
275*2d995e5dSJohn Keeping {
276*2d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
277*2d995e5dSJohn Keeping 	struct snd_soc_dapm_context *dapm;
278*2d995e5dSJohn Keeping 
279*2d995e5dSJohn Keeping 	if (bdw_rt5677->codec) {
280*2d995e5dSJohn Keeping 		dapm = snd_soc_codec_get_dapm(bdw_rt5677->codec);
281*2d995e5dSJohn Keeping 		snd_soc_dapm_disable_pin(dapm, "MICBIAS1");
282*2d995e5dSJohn Keeping 	}
283*2d995e5dSJohn Keeping 	return 0;
284*2d995e5dSJohn Keeping }
285*2d995e5dSJohn Keeping 
286*2d995e5dSJohn Keeping static int bdw_rt5677_resume_post(struct snd_soc_card *card)
287*2d995e5dSJohn Keeping {
288*2d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
289*2d995e5dSJohn Keeping 	struct snd_soc_dapm_context *dapm;
290*2d995e5dSJohn Keeping 
291*2d995e5dSJohn Keeping 	if (bdw_rt5677->codec) {
292*2d995e5dSJohn Keeping 		dapm = snd_soc_codec_get_dapm(bdw_rt5677->codec);
293*2d995e5dSJohn Keeping 		snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
294*2d995e5dSJohn Keeping 	}
295*2d995e5dSJohn Keeping 	return 0;
296*2d995e5dSJohn Keeping }
297*2d995e5dSJohn Keeping 
298*2d995e5dSJohn Keeping /* ASoC machine driver for Broadwell DSP + RT5677 */
299*2d995e5dSJohn Keeping static struct snd_soc_card bdw_rt5677_card = {
300*2d995e5dSJohn Keeping 	.name = "bdw-rt5677",
301*2d995e5dSJohn Keeping 	.owner = THIS_MODULE,
302*2d995e5dSJohn Keeping 	.dai_link = bdw_rt5677_dais,
303*2d995e5dSJohn Keeping 	.num_links = ARRAY_SIZE(bdw_rt5677_dais),
304*2d995e5dSJohn Keeping 	.dapm_widgets = bdw_rt5677_widgets,
305*2d995e5dSJohn Keeping 	.num_dapm_widgets = ARRAY_SIZE(bdw_rt5677_widgets),
306*2d995e5dSJohn Keeping 	.dapm_routes = bdw_rt5677_map,
307*2d995e5dSJohn Keeping 	.num_dapm_routes = ARRAY_SIZE(bdw_rt5677_map),
308*2d995e5dSJohn Keeping 	.controls = bdw_rt5677_controls,
309*2d995e5dSJohn Keeping 	.num_controls = ARRAY_SIZE(bdw_rt5677_controls),
310*2d995e5dSJohn Keeping 	.fully_routed = true,
311*2d995e5dSJohn Keeping 	.suspend_pre = bdw_rt5677_suspend_pre,
312*2d995e5dSJohn Keeping 	.resume_post = bdw_rt5677_resume_post,
313*2d995e5dSJohn Keeping };
314*2d995e5dSJohn Keeping 
315*2d995e5dSJohn Keeping static int bdw_rt5677_probe(struct platform_device *pdev)
316*2d995e5dSJohn Keeping {
317*2d995e5dSJohn Keeping 	struct bdw_rt5677_priv *bdw_rt5677;
318*2d995e5dSJohn Keeping 
319*2d995e5dSJohn Keeping 	bdw_rt5677_card.dev = &pdev->dev;
320*2d995e5dSJohn Keeping 
321*2d995e5dSJohn Keeping 	/* Allocate driver private struct */
322*2d995e5dSJohn Keeping 	bdw_rt5677 = devm_kzalloc(&pdev->dev, sizeof(struct bdw_rt5677_priv),
323*2d995e5dSJohn Keeping 		GFP_KERNEL);
324*2d995e5dSJohn Keeping 	if (!bdw_rt5677) {
325*2d995e5dSJohn Keeping 		dev_err(&pdev->dev, "Can't allocate bdw_rt5677\n");
326*2d995e5dSJohn Keeping 		return -ENOMEM;
327*2d995e5dSJohn Keeping 	}
328*2d995e5dSJohn Keeping 
329*2d995e5dSJohn Keeping 	snd_soc_card_set_drvdata(&bdw_rt5677_card, bdw_rt5677);
330*2d995e5dSJohn Keeping 
331*2d995e5dSJohn Keeping 	return devm_snd_soc_register_card(&pdev->dev, &bdw_rt5677_card);
332*2d995e5dSJohn Keeping }
333*2d995e5dSJohn Keeping 
334*2d995e5dSJohn Keeping static struct platform_driver bdw_rt5677_audio = {
335*2d995e5dSJohn Keeping 	.probe = bdw_rt5677_probe,
336*2d995e5dSJohn Keeping 	.driver = {
337*2d995e5dSJohn Keeping 		.name = "bdw-rt5677",
338*2d995e5dSJohn Keeping 	},
339*2d995e5dSJohn Keeping };
340*2d995e5dSJohn Keeping 
341*2d995e5dSJohn Keeping module_platform_driver(bdw_rt5677_audio)
342*2d995e5dSJohn Keeping 
343*2d995e5dSJohn Keeping /* Module information */
344*2d995e5dSJohn Keeping MODULE_AUTHOR("Ben Zhang");
345*2d995e5dSJohn Keeping MODULE_DESCRIPTION("Intel Broadwell RT5677 machine driver");
346*2d995e5dSJohn Keeping MODULE_LICENSE("GPL v2");
347*2d995e5dSJohn Keeping MODULE_ALIAS("platform:bdw-rt5677");
348