xref: /linux/sound/soc/fsl/imx-audmix.c (revision b19a5733de255cabba5feecabf6e900638b582d1)
1b86ef536SViorel Suman // SPDX-License-Identifier: GPL-2.0
2b86ef536SViorel Suman /*
3b86ef536SViorel Suman  * Copyright 2017 NXP
4b86ef536SViorel Suman  *
5b86ef536SViorel Suman  * The code contained herein is licensed under the GNU General Public
6b86ef536SViorel Suman  * License. You may obtain a copy of the GNU General Public License
7b86ef536SViorel Suman  * Version 2 or later at the following locations:
8b86ef536SViorel Suman  *
91ce8f643SAlexander A. Klimov  * https://www.opensource.org/licenses/gpl-license.html
101ce8f643SAlexander A. Klimov  * https://www.gnu.org/copyleft/gpl.html
11b86ef536SViorel Suman  */
12b86ef536SViorel Suman 
13b86ef536SViorel Suman #include <linux/module.h>
14b86ef536SViorel Suman #include <linux/of_platform.h>
15b86ef536SViorel Suman #include <linux/clk.h>
16b86ef536SViorel Suman #include <sound/soc.h>
17b86ef536SViorel Suman #include <sound/soc-dapm.h>
18b86ef536SViorel Suman #include "fsl_sai.h"
19b86ef536SViorel Suman #include "fsl_audmix.h"
20b86ef536SViorel Suman 
21b86ef536SViorel Suman struct imx_audmix {
22b86ef536SViorel Suman 	struct platform_device *pdev;
23b86ef536SViorel Suman 	struct snd_soc_card card;
24b86ef536SViorel Suman 	struct platform_device *audmix_pdev;
25b86ef536SViorel Suman 	struct platform_device *out_pdev;
26b86ef536SViorel Suman 	struct clk *cpu_mclk;
27b86ef536SViorel Suman 	int num_dai;
28b86ef536SViorel Suman 	struct snd_soc_dai_link *dai;
29b86ef536SViorel Suman 	int num_dai_conf;
30b86ef536SViorel Suman 	struct snd_soc_codec_conf *dai_conf;
31b86ef536SViorel Suman 	int num_dapm_routes;
32b86ef536SViorel Suman 	struct snd_soc_dapm_route *dapm_routes;
33b86ef536SViorel Suman };
34b86ef536SViorel Suman 
35b86ef536SViorel Suman static const u32 imx_audmix_rates[] = {
36b86ef536SViorel Suman 	8000, 12000, 16000, 24000, 32000, 48000, 64000, 96000,
37b86ef536SViorel Suman };
38b86ef536SViorel Suman 
39b86ef536SViorel Suman static const struct snd_pcm_hw_constraint_list imx_audmix_rate_constraints = {
40b86ef536SViorel Suman 	.count = ARRAY_SIZE(imx_audmix_rates),
41b86ef536SViorel Suman 	.list = imx_audmix_rates,
42b86ef536SViorel Suman };
43b86ef536SViorel Suman 
44b86ef536SViorel Suman static int imx_audmix_fe_startup(struct snd_pcm_substream *substream)
45b86ef536SViorel Suman {
469f5f078aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
47b86ef536SViorel Suman 	struct imx_audmix *priv = snd_soc_card_get_drvdata(rtd->card);
48b86ef536SViorel Suman 	struct snd_pcm_runtime *runtime = substream->runtime;
49b86ef536SViorel Suman 	struct device *dev = rtd->card->dev;
50b86ef536SViorel Suman 	unsigned long clk_rate = clk_get_rate(priv->cpu_mclk);
51b86ef536SViorel Suman 	int ret;
52b86ef536SViorel Suman 
53b86ef536SViorel Suman 	if (clk_rate % 24576000 == 0) {
54b86ef536SViorel Suman 		ret = snd_pcm_hw_constraint_list(runtime, 0,
55b86ef536SViorel Suman 						 SNDRV_PCM_HW_PARAM_RATE,
56b86ef536SViorel Suman 						 &imx_audmix_rate_constraints);
57b86ef536SViorel Suman 		if (ret < 0)
58b86ef536SViorel Suman 			return ret;
59b86ef536SViorel Suman 	} else {
60b86ef536SViorel Suman 		dev_warn(dev, "mclk may be not supported %lu\n", clk_rate);
61b86ef536SViorel Suman 	}
62b86ef536SViorel Suman 
63b86ef536SViorel Suman 	ret = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS,
64b86ef536SViorel Suman 					   1, 8);
65b86ef536SViorel Suman 	if (ret < 0)
66b86ef536SViorel Suman 		return ret;
67b86ef536SViorel Suman 
68b86ef536SViorel Suman 	return snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT,
69b86ef536SViorel Suman 					    FSL_AUDMIX_FORMATS);
70b86ef536SViorel Suman }
71b86ef536SViorel Suman 
72b86ef536SViorel Suman static int imx_audmix_fe_hw_params(struct snd_pcm_substream *substream,
73b86ef536SViorel Suman 				   struct snd_pcm_hw_params *params)
74b86ef536SViorel Suman {
759f5f078aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
76b86ef536SViorel Suman 	struct device *dev = rtd->card->dev;
77b86ef536SViorel Suman 	bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
78b86ef536SViorel Suman 	unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
79b86ef536SViorel Suman 	u32 channels = params_channels(params);
80b86ef536SViorel Suman 	int ret, dir;
81b86ef536SViorel Suman 
82bf101022SMark Brown 	/* For playback the AUDMIX is consumer, and for record is provider */
833b14c15aSCharles Keepax 	fmt |= tx ? SND_SOC_DAIFMT_BP_FP : SND_SOC_DAIFMT_BC_FC;
84b86ef536SViorel Suman 	dir  = tx ? SND_SOC_CLOCK_OUT : SND_SOC_CLOCK_IN;
85b86ef536SViorel Suman 
86b86ef536SViorel Suman 	/* set DAI configuration */
8717198ae7SKuninori Morimoto 	ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0), fmt);
88b86ef536SViorel Suman 	if (ret) {
89b86ef536SViorel Suman 		dev_err(dev, "failed to set cpu dai fmt: %d\n", ret);
90b86ef536SViorel Suman 		return ret;
91b86ef536SViorel Suman 	}
92b86ef536SViorel Suman 
9317198ae7SKuninori Morimoto 	ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0), FSL_SAI_CLK_MAST1, 0, dir);
94b86ef536SViorel Suman 	if (ret) {
95b86ef536SViorel Suman 		dev_err(dev, "failed to set cpu sysclk: %d\n", ret);
96b86ef536SViorel Suman 		return ret;
97b86ef536SViorel Suman 	}
98b86ef536SViorel Suman 
99b86ef536SViorel Suman 	/*
100b86ef536SViorel Suman 	 * Per datasheet, AUDMIX expects 8 slots and 32 bits
101b86ef536SViorel Suman 	 * for every slot in TDM mode.
102b86ef536SViorel Suman 	 */
10317198ae7SKuninori Morimoto 	ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), BIT(channels) - 1,
104b86ef536SViorel Suman 				       BIT(channels) - 1, 8, 32);
105b86ef536SViorel Suman 	if (ret)
106b86ef536SViorel Suman 		dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
107b86ef536SViorel Suman 
108b86ef536SViorel Suman 	return ret;
109b86ef536SViorel Suman }
110b86ef536SViorel Suman 
111b86ef536SViorel Suman static int imx_audmix_be_hw_params(struct snd_pcm_substream *substream,
112b86ef536SViorel Suman 				   struct snd_pcm_hw_params *params)
113b86ef536SViorel Suman {
1149f5f078aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
115b86ef536SViorel Suman 	struct device *dev = rtd->card->dev;
116b86ef536SViorel Suman 	bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
117b86ef536SViorel Suman 	unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
118b86ef536SViorel Suman 	int ret;
119b86ef536SViorel Suman 
120b86ef536SViorel Suman 	if (!tx)
121b86ef536SViorel Suman 		return 0;
122b86ef536SViorel Suman 
123bf101022SMark Brown 	/* For playback the AUDMIX is consumer */
1243b14c15aSCharles Keepax 	fmt |= SND_SOC_DAIFMT_BC_FC;
125b86ef536SViorel Suman 
126b86ef536SViorel Suman 	/* set AUDMIX DAI configuration */
12717198ae7SKuninori Morimoto 	ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0), fmt);
128b86ef536SViorel Suman 	if (ret)
129b86ef536SViorel Suman 		dev_err(dev, "failed to set AUDMIX DAI fmt: %d\n", ret);
130b86ef536SViorel Suman 
131b86ef536SViorel Suman 	return ret;
132b86ef536SViorel Suman }
133b86ef536SViorel Suman 
134815b55e1SRikard Falkeborn static const struct snd_soc_ops imx_audmix_fe_ops = {
135b86ef536SViorel Suman 	.startup = imx_audmix_fe_startup,
136b86ef536SViorel Suman 	.hw_params = imx_audmix_fe_hw_params,
137b86ef536SViorel Suman };
138b86ef536SViorel Suman 
139815b55e1SRikard Falkeborn static const struct snd_soc_ops imx_audmix_be_ops = {
140b86ef536SViorel Suman 	.hw_params = imx_audmix_be_hw_params,
141b86ef536SViorel Suman };
142b86ef536SViorel Suman 
143b86ef536SViorel Suman static int imx_audmix_probe(struct platform_device *pdev)
144b86ef536SViorel Suman {
145b86ef536SViorel Suman 	struct device_node *np = pdev->dev.of_node;
146b86ef536SViorel Suman 	struct device_node *audmix_np = NULL, *out_cpu_np = NULL;
147b86ef536SViorel Suman 	struct platform_device *audmix_pdev = NULL;
148b86ef536SViorel Suman 	struct platform_device *cpu_pdev;
149b86ef536SViorel Suman 	struct of_phandle_args args;
150b86ef536SViorel Suman 	struct imx_audmix *priv;
151b86ef536SViorel Suman 	int i, num_dai, ret;
152b86ef536SViorel Suman 	const char *fe_name_pref = "HiFi-AUDMIX-FE-";
153b86ef536SViorel Suman 	char *be_name, *be_pb, *be_cp, *dai_name, *capture_dai_name;
154b86ef536SViorel Suman 
155b86ef536SViorel Suman 	if (pdev->dev.parent) {
156b86ef536SViorel Suman 		audmix_np = pdev->dev.parent->of_node;
157b86ef536SViorel Suman 	} else {
158b86ef536SViorel Suman 		dev_err(&pdev->dev, "Missing parent device.\n");
159b86ef536SViorel Suman 		return -EINVAL;
160b86ef536SViorel Suman 	}
161b86ef536SViorel Suman 
162b86ef536SViorel Suman 	if (!audmix_np) {
163de70b2a5SColin Ian King 		dev_err(&pdev->dev, "Missing DT node for parent device.\n");
164b86ef536SViorel Suman 		return -EINVAL;
165b86ef536SViorel Suman 	}
166b86ef536SViorel Suman 
167b86ef536SViorel Suman 	audmix_pdev = of_find_device_by_node(audmix_np);
168b86ef536SViorel Suman 	if (!audmix_pdev) {
169b86ef536SViorel Suman 		dev_err(&pdev->dev, "Missing AUDMIX platform device for %s\n",
170b86ef536SViorel Suman 			np->full_name);
171b86ef536SViorel Suman 		return -EINVAL;
172b86ef536SViorel Suman 	}
1738bb678d7SViorel Suman 	put_device(&audmix_pdev->dev);
174b86ef536SViorel Suman 
175b86ef536SViorel Suman 	num_dai = of_count_phandle_with_args(audmix_np, "dais", NULL);
176b86ef536SViorel Suman 	if (num_dai != FSL_AUDMIX_MAX_DAIS) {
177b86ef536SViorel Suman 		dev_err(&pdev->dev, "Need 2 dais to be provided for %s\n",
178b86ef536SViorel Suman 			audmix_np->full_name);
179b86ef536SViorel Suman 		return -EINVAL;
180b86ef536SViorel Suman 	}
181b86ef536SViorel Suman 
182b86ef536SViorel Suman 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
183b86ef536SViorel Suman 	if (!priv)
184b86ef536SViorel Suman 		return -ENOMEM;
185b86ef536SViorel Suman 
186b86ef536SViorel Suman 	priv->num_dai = 2 * num_dai;
187f95cc5c1SXu Wang 	priv->dai = devm_kcalloc(&pdev->dev, priv->num_dai,
188b86ef536SViorel Suman 				 sizeof(struct snd_soc_dai_link), GFP_KERNEL);
189b86ef536SViorel Suman 	if (!priv->dai)
190b86ef536SViorel Suman 		return -ENOMEM;
191b86ef536SViorel Suman 
192b86ef536SViorel Suman 	priv->num_dai_conf = num_dai;
193f95cc5c1SXu Wang 	priv->dai_conf = devm_kcalloc(&pdev->dev, priv->num_dai_conf,
194b86ef536SViorel Suman 				      sizeof(struct snd_soc_codec_conf),
195b86ef536SViorel Suman 				      GFP_KERNEL);
196b86ef536SViorel Suman 	if (!priv->dai_conf)
197b86ef536SViorel Suman 		return -ENOMEM;
198b86ef536SViorel Suman 
199b86ef536SViorel Suman 	priv->num_dapm_routes = 3 * num_dai;
200f95cc5c1SXu Wang 	priv->dapm_routes = devm_kcalloc(&pdev->dev, priv->num_dapm_routes,
201b86ef536SViorel Suman 					 sizeof(struct snd_soc_dapm_route),
202b86ef536SViorel Suman 					 GFP_KERNEL);
203b86ef536SViorel Suman 	if (!priv->dapm_routes)
204b86ef536SViorel Suman 		return -ENOMEM;
205b86ef536SViorel Suman 
206b86ef536SViorel Suman 	for (i = 0; i < num_dai; i++) {
20779782e28SKuninori Morimoto 		struct snd_soc_dai_link_component *dlc;
20879782e28SKuninori Morimoto 
20987e39e9bSKuninori Morimoto 		/* for CPU x 2 */
21087e39e9bSKuninori Morimoto 		dlc = devm_kcalloc(&pdev->dev, 2, sizeof(*dlc), GFP_KERNEL);
211723ca2f8SZhen Lei 		if (!dlc)
21279782e28SKuninori Morimoto 			return -ENOMEM;
21379782e28SKuninori Morimoto 
214b86ef536SViorel Suman 		ret = of_parse_phandle_with_args(audmix_np, "dais", NULL, i,
215b86ef536SViorel Suman 						 &args);
216b86ef536SViorel Suman 		if (ret < 0) {
217b86ef536SViorel Suman 			dev_err(&pdev->dev, "of_parse_phandle_with_args failed\n");
218b86ef536SViorel Suman 			return ret;
219b86ef536SViorel Suman 		}
220b86ef536SViorel Suman 
221b86ef536SViorel Suman 		cpu_pdev = of_find_device_by_node(args.np);
222b86ef536SViorel Suman 		if (!cpu_pdev) {
223b86ef536SViorel Suman 			dev_err(&pdev->dev, "failed to find SAI platform device\n");
224b86ef536SViorel Suman 			return -EINVAL;
225b86ef536SViorel Suman 		}
2268bb678d7SViorel Suman 		put_device(&cpu_pdev->dev);
227b86ef536SViorel Suman 
228b86ef536SViorel Suman 		dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s",
229b86ef536SViorel Suman 					  fe_name_pref, args.np->full_name + 1);
2302f76e1d6SClaudiu Beznea 		if (!dai_name)
2312f76e1d6SClaudiu Beznea 			return -ENOMEM;
232b86ef536SViorel Suman 
233b86ef536SViorel Suman 		dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name);
234b86ef536SViorel Suman 
235b86ef536SViorel Suman 		if (i == 0) {
236b86ef536SViorel Suman 			out_cpu_np = args.np;
237b86ef536SViorel Suman 			capture_dai_name =
238b86ef536SViorel Suman 				devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
239b86ef536SViorel Suman 					       dai_name, "CPU-Capture");
2402f76e1d6SClaudiu Beznea 			if (!capture_dai_name)
2412f76e1d6SClaudiu Beznea 				return -ENOMEM;
242b86ef536SViorel Suman 		}
243b86ef536SViorel Suman 
2443ce08f85SKuninori Morimoto 		/*
2453ce08f85SKuninori Morimoto 		 * CPU == Platform
2463ce08f85SKuninori Morimoto 		 * platform is using soc-generic-dmaengine-pcm
2473ce08f85SKuninori Morimoto 		 */
2483ce08f85SKuninori Morimoto 		priv->dai[i].cpus	=
2493ce08f85SKuninori Morimoto 		priv->dai[i].platforms	= &dlc[0];
25087e39e9bSKuninori Morimoto 		priv->dai[i].codecs	= &asoc_dummy_dlc;
25179782e28SKuninori Morimoto 
25279782e28SKuninori Morimoto 		priv->dai[i].num_cpus = 1;
25379782e28SKuninori Morimoto 		priv->dai[i].num_codecs = 1;
25409cda705SShengjiu Wang 		priv->dai[i].num_platforms = 1;
25579782e28SKuninori Morimoto 
256b86ef536SViorel Suman 		priv->dai[i].name = dai_name;
257b86ef536SViorel Suman 		priv->dai[i].stream_name = "HiFi-AUDMIX-FE";
25879782e28SKuninori Morimoto 		priv->dai[i].cpus->of_node = args.np;
25979782e28SKuninori Morimoto 		priv->dai[i].cpus->dai_name = dev_name(&cpu_pdev->dev);
260b86ef536SViorel Suman 		priv->dai[i].dynamic = 1;
261b86ef536SViorel Suman 		priv->dai[i].dpcm_playback = 1;
262b86ef536SViorel Suman 		priv->dai[i].dpcm_capture = (i == 0 ? 1 : 0);
263b86ef536SViorel Suman 		priv->dai[i].ignore_pmdown_time = 1;
264b86ef536SViorel Suman 		priv->dai[i].ops = &imx_audmix_fe_ops;
265b86ef536SViorel Suman 
266b86ef536SViorel Suman 		/* Add AUDMIX Backend */
267b86ef536SViorel Suman 		be_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
268b86ef536SViorel Suman 					 "audmix-%d", i);
269b86ef536SViorel Suman 		be_pb = devm_kasprintf(&pdev->dev, GFP_KERNEL,
270b86ef536SViorel Suman 				       "AUDMIX-Playback-%d", i);
271b86ef536SViorel Suman 		be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL,
272b86ef536SViorel Suman 				       "AUDMIX-Capture-%d", i);
2732f76e1d6SClaudiu Beznea 		if (!be_name || !be_pb || !be_cp)
2742f76e1d6SClaudiu Beznea 			return -ENOMEM;
275b86ef536SViorel Suman 
27687e39e9bSKuninori Morimoto 		priv->dai[num_dai + i].cpus	= &dlc[1];
27787e39e9bSKuninori Morimoto 		priv->dai[num_dai + i].codecs	= &asoc_dummy_dlc;
27879782e28SKuninori Morimoto 
27979782e28SKuninori Morimoto 		priv->dai[num_dai + i].num_cpus = 1;
28079782e28SKuninori Morimoto 		priv->dai[num_dai + i].num_codecs = 1;
28179782e28SKuninori Morimoto 
282b86ef536SViorel Suman 		priv->dai[num_dai + i].name = be_name;
28379782e28SKuninori Morimoto 		priv->dai[num_dai + i].cpus->of_node = audmix_np;
28479782e28SKuninori Morimoto 		priv->dai[num_dai + i].cpus->dai_name = be_name;
285b86ef536SViorel Suman 		priv->dai[num_dai + i].no_pcm = 1;
286b86ef536SViorel Suman 		priv->dai[num_dai + i].dpcm_playback = 1;
287b86ef536SViorel Suman 		priv->dai[num_dai + i].dpcm_capture  = 1;
288b86ef536SViorel Suman 		priv->dai[num_dai + i].ignore_pmdown_time = 1;
289b86ef536SViorel Suman 		priv->dai[num_dai + i].ops = &imx_audmix_be_ops;
290b86ef536SViorel Suman 
291eea23952SKuninori Morimoto 		priv->dai_conf[i].dlc.of_node = args.np;
292b86ef536SViorel Suman 		priv->dai_conf[i].name_prefix = dai_name;
293b86ef536SViorel Suman 
294b86ef536SViorel Suman 		priv->dapm_routes[i].source =
295b86ef536SViorel Suman 			devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
296b86ef536SViorel Suman 				       dai_name, "CPU-Playback");
2972f76e1d6SClaudiu Beznea 		if (!priv->dapm_routes[i].source)
2982f76e1d6SClaudiu Beznea 			return -ENOMEM;
2992f76e1d6SClaudiu Beznea 
300b86ef536SViorel Suman 		priv->dapm_routes[i].sink = be_pb;
301b86ef536SViorel Suman 		priv->dapm_routes[num_dai + i].source   = be_pb;
302b86ef536SViorel Suman 		priv->dapm_routes[num_dai + i].sink     = be_cp;
303b86ef536SViorel Suman 		priv->dapm_routes[2 * num_dai + i].source = be_cp;
304b86ef536SViorel Suman 		priv->dapm_routes[2 * num_dai + i].sink   = capture_dai_name;
305b86ef536SViorel Suman 	}
306b86ef536SViorel Suman 
307b86ef536SViorel Suman 	cpu_pdev = of_find_device_by_node(out_cpu_np);
308b86ef536SViorel Suman 	if (!cpu_pdev) {
309b86ef536SViorel Suman 		dev_err(&pdev->dev, "failed to find SAI platform device\n");
310b86ef536SViorel Suman 		return -EINVAL;
311b86ef536SViorel Suman 	}
3128bb678d7SViorel Suman 	put_device(&cpu_pdev->dev);
3138bb678d7SViorel Suman 
314b86ef536SViorel Suman 	priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1");
315b86ef536SViorel Suman 	if (IS_ERR(priv->cpu_mclk)) {
316b86ef536SViorel Suman 		ret = PTR_ERR(priv->cpu_mclk);
317b86ef536SViorel Suman 		dev_err(&cpu_pdev->dev, "failed to get DAI mclk1: %d\n", ret);
318*b19a5733SShengjiu Wang 		return ret;
319b86ef536SViorel Suman 	}
320b86ef536SViorel Suman 
321b86ef536SViorel Suman 	priv->audmix_pdev = audmix_pdev;
322b86ef536SViorel Suman 	priv->out_pdev  = cpu_pdev;
323b86ef536SViorel Suman 
324b86ef536SViorel Suman 	priv->card.dai_link = priv->dai;
325b86ef536SViorel Suman 	priv->card.num_links = priv->num_dai;
326b86ef536SViorel Suman 	priv->card.codec_conf = priv->dai_conf;
327b86ef536SViorel Suman 	priv->card.num_configs = priv->num_dai_conf;
328b86ef536SViorel Suman 	priv->card.dapm_routes = priv->dapm_routes;
329b86ef536SViorel Suman 	priv->card.num_dapm_routes = priv->num_dapm_routes;
3309573820eSShengjiu Wang 	priv->card.dev = &pdev->dev;
331b86ef536SViorel Suman 	priv->card.owner = THIS_MODULE;
332b86ef536SViorel Suman 	priv->card.name = "imx-audmix";
333b86ef536SViorel Suman 
334b86ef536SViorel Suman 	platform_set_drvdata(pdev, &priv->card);
335b86ef536SViorel Suman 	snd_soc_card_set_drvdata(&priv->card, priv);
336b86ef536SViorel Suman 
3379573820eSShengjiu Wang 	ret = devm_snd_soc_register_card(&pdev->dev, &priv->card);
338b86ef536SViorel Suman 	if (ret) {
339b86ef536SViorel Suman 		dev_err(&pdev->dev, "snd_soc_register_card failed\n");
340b86ef536SViorel Suman 		return ret;
341b86ef536SViorel Suman 	}
342b86ef536SViorel Suman 
343b86ef536SViorel Suman 	return ret;
344b86ef536SViorel Suman }
345b86ef536SViorel Suman 
346b86ef536SViorel Suman static struct platform_driver imx_audmix_driver = {
347b86ef536SViorel Suman 	.probe = imx_audmix_probe,
348b86ef536SViorel Suman 	.driver = {
349b86ef536SViorel Suman 		.name = "imx-audmix",
350b86ef536SViorel Suman 		.pm = &snd_soc_pm_ops,
351b86ef536SViorel Suman 	},
352b86ef536SViorel Suman };
353b86ef536SViorel Suman module_platform_driver(imx_audmix_driver);
354b86ef536SViorel Suman 
355b86ef536SViorel Suman MODULE_DESCRIPTION("NXP AUDMIX ASoC machine driver");
356b86ef536SViorel Suman MODULE_AUTHOR("Viorel Suman <viorel.suman@nxp.com>");
357b86ef536SViorel Suman MODULE_ALIAS("platform:imx-audmix");
358b86ef536SViorel Suman MODULE_LICENSE("GPL v2");
359