xref: /linux/sound/soc/fsl/imx-audmix.c (revision bf101022487091032fd8102c835b1157b8283c43)
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 <linux/pm_runtime.h>
19b86ef536SViorel Suman #include "fsl_sai.h"
20b86ef536SViorel Suman #include "fsl_audmix.h"
21b86ef536SViorel Suman 
22b86ef536SViorel Suman struct imx_audmix {
23b86ef536SViorel Suman 	struct platform_device *pdev;
24b86ef536SViorel Suman 	struct snd_soc_card card;
25b86ef536SViorel Suman 	struct platform_device *audmix_pdev;
26b86ef536SViorel Suman 	struct platform_device *out_pdev;
27b86ef536SViorel Suman 	struct clk *cpu_mclk;
28b86ef536SViorel Suman 	int num_dai;
29b86ef536SViorel Suman 	struct snd_soc_dai_link *dai;
30b86ef536SViorel Suman 	int num_dai_conf;
31b86ef536SViorel Suman 	struct snd_soc_codec_conf *dai_conf;
32b86ef536SViorel Suman 	int num_dapm_routes;
33b86ef536SViorel Suman 	struct snd_soc_dapm_route *dapm_routes;
34b86ef536SViorel Suman };
35b86ef536SViorel Suman 
36b86ef536SViorel Suman static const u32 imx_audmix_rates[] = {
37b86ef536SViorel Suman 	8000, 12000, 16000, 24000, 32000, 48000, 64000, 96000,
38b86ef536SViorel Suman };
39b86ef536SViorel Suman 
40b86ef536SViorel Suman static const struct snd_pcm_hw_constraint_list imx_audmix_rate_constraints = {
41b86ef536SViorel Suman 	.count = ARRAY_SIZE(imx_audmix_rates),
42b86ef536SViorel Suman 	.list = imx_audmix_rates,
43b86ef536SViorel Suman };
44b86ef536SViorel Suman 
45b86ef536SViorel Suman static int imx_audmix_fe_startup(struct snd_pcm_substream *substream)
46b86ef536SViorel Suman {
479f5f078aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
48b86ef536SViorel Suman 	struct imx_audmix *priv = snd_soc_card_get_drvdata(rtd->card);
49b86ef536SViorel Suman 	struct snd_pcm_runtime *runtime = substream->runtime;
50b86ef536SViorel Suman 	struct device *dev = rtd->card->dev;
51b86ef536SViorel Suman 	unsigned long clk_rate = clk_get_rate(priv->cpu_mclk);
52b86ef536SViorel Suman 	int ret;
53b86ef536SViorel Suman 
54b86ef536SViorel Suman 	if (clk_rate % 24576000 == 0) {
55b86ef536SViorel Suman 		ret = snd_pcm_hw_constraint_list(runtime, 0,
56b86ef536SViorel Suman 						 SNDRV_PCM_HW_PARAM_RATE,
57b86ef536SViorel Suman 						 &imx_audmix_rate_constraints);
58b86ef536SViorel Suman 		if (ret < 0)
59b86ef536SViorel Suman 			return ret;
60b86ef536SViorel Suman 	} else {
61b86ef536SViorel Suman 		dev_warn(dev, "mclk may be not supported %lu\n", clk_rate);
62b86ef536SViorel Suman 	}
63b86ef536SViorel Suman 
64b86ef536SViorel Suman 	ret = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS,
65b86ef536SViorel Suman 					   1, 8);
66b86ef536SViorel Suman 	if (ret < 0)
67b86ef536SViorel Suman 		return ret;
68b86ef536SViorel Suman 
69b86ef536SViorel Suman 	return snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT,
70b86ef536SViorel Suman 					    FSL_AUDMIX_FORMATS);
71b86ef536SViorel Suman }
72b86ef536SViorel Suman 
73b86ef536SViorel Suman static int imx_audmix_fe_hw_params(struct snd_pcm_substream *substream,
74b86ef536SViorel Suman 				   struct snd_pcm_hw_params *params)
75b86ef536SViorel Suman {
769f5f078aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
77b86ef536SViorel Suman 	struct device *dev = rtd->card->dev;
78b86ef536SViorel Suman 	bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
79b86ef536SViorel Suman 	unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
80b86ef536SViorel Suman 	u32 channels = params_channels(params);
81b86ef536SViorel Suman 	int ret, dir;
82b86ef536SViorel Suman 
83*bf101022SMark Brown 	/* For playback the AUDMIX is consumer, and for record is provider */
84*bf101022SMark Brown 	fmt |= tx ? SND_SOC_DAIFMT_CBC_CFC : SND_SOC_DAIFMT_CBP_CFP;
85b86ef536SViorel Suman 	dir  = tx ? SND_SOC_CLOCK_OUT : SND_SOC_CLOCK_IN;
86b86ef536SViorel Suman 
87b86ef536SViorel Suman 	/* set DAI configuration */
8817198ae7SKuninori Morimoto 	ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0), fmt);
89b86ef536SViorel Suman 	if (ret) {
90b86ef536SViorel Suman 		dev_err(dev, "failed to set cpu dai fmt: %d\n", ret);
91b86ef536SViorel Suman 		return ret;
92b86ef536SViorel Suman 	}
93b86ef536SViorel Suman 
9417198ae7SKuninori Morimoto 	ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0), FSL_SAI_CLK_MAST1, 0, dir);
95b86ef536SViorel Suman 	if (ret) {
96b86ef536SViorel Suman 		dev_err(dev, "failed to set cpu sysclk: %d\n", ret);
97b86ef536SViorel Suman 		return ret;
98b86ef536SViorel Suman 	}
99b86ef536SViorel Suman 
100b86ef536SViorel Suman 	/*
101b86ef536SViorel Suman 	 * Per datasheet, AUDMIX expects 8 slots and 32 bits
102b86ef536SViorel Suman 	 * for every slot in TDM mode.
103b86ef536SViorel Suman 	 */
10417198ae7SKuninori Morimoto 	ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), BIT(channels) - 1,
105b86ef536SViorel Suman 				       BIT(channels) - 1, 8, 32);
106b86ef536SViorel Suman 	if (ret)
107b86ef536SViorel Suman 		dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
108b86ef536SViorel Suman 
109b86ef536SViorel Suman 	return ret;
110b86ef536SViorel Suman }
111b86ef536SViorel Suman 
112b86ef536SViorel Suman static int imx_audmix_be_hw_params(struct snd_pcm_substream *substream,
113b86ef536SViorel Suman 				   struct snd_pcm_hw_params *params)
114b86ef536SViorel Suman {
1159f5f078aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
116b86ef536SViorel Suman 	struct device *dev = rtd->card->dev;
117b86ef536SViorel Suman 	bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
118b86ef536SViorel Suman 	unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
119b86ef536SViorel Suman 	int ret;
120b86ef536SViorel Suman 
121b86ef536SViorel Suman 	if (!tx)
122b86ef536SViorel Suman 		return 0;
123b86ef536SViorel Suman 
124*bf101022SMark Brown 	/* For playback the AUDMIX is consumer */
125*bf101022SMark Brown 	fmt |= SND_SOC_DAIFMT_CBP_CFP;
126b86ef536SViorel Suman 
127b86ef536SViorel Suman 	/* set AUDMIX DAI configuration */
12817198ae7SKuninori Morimoto 	ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0), fmt);
129b86ef536SViorel Suman 	if (ret)
130b86ef536SViorel Suman 		dev_err(dev, "failed to set AUDMIX DAI fmt: %d\n", ret);
131b86ef536SViorel Suman 
132b86ef536SViorel Suman 	return ret;
133b86ef536SViorel Suman }
134b86ef536SViorel Suman 
135815b55e1SRikard Falkeborn static const struct snd_soc_ops imx_audmix_fe_ops = {
136b86ef536SViorel Suman 	.startup = imx_audmix_fe_startup,
137b86ef536SViorel Suman 	.hw_params = imx_audmix_fe_hw_params,
138b86ef536SViorel Suman };
139b86ef536SViorel Suman 
140815b55e1SRikard Falkeborn static const struct snd_soc_ops imx_audmix_be_ops = {
141b86ef536SViorel Suman 	.hw_params = imx_audmix_be_hw_params,
142b86ef536SViorel Suman };
143b86ef536SViorel Suman 
144b86ef536SViorel Suman static int imx_audmix_probe(struct platform_device *pdev)
145b86ef536SViorel Suman {
146b86ef536SViorel Suman 	struct device_node *np = pdev->dev.of_node;
147b86ef536SViorel Suman 	struct device_node *audmix_np = NULL, *out_cpu_np = NULL;
148b86ef536SViorel Suman 	struct platform_device *audmix_pdev = NULL;
149b86ef536SViorel Suman 	struct platform_device *cpu_pdev;
150b86ef536SViorel Suman 	struct of_phandle_args args;
151b86ef536SViorel Suman 	struct imx_audmix *priv;
152b86ef536SViorel Suman 	int i, num_dai, ret;
153b86ef536SViorel Suman 	const char *fe_name_pref = "HiFi-AUDMIX-FE-";
154b86ef536SViorel Suman 	char *be_name, *be_pb, *be_cp, *dai_name, *capture_dai_name;
155b86ef536SViorel Suman 
156b86ef536SViorel Suman 	if (pdev->dev.parent) {
157b86ef536SViorel Suman 		audmix_np = pdev->dev.parent->of_node;
158b86ef536SViorel Suman 	} else {
159b86ef536SViorel Suman 		dev_err(&pdev->dev, "Missing parent device.\n");
160b86ef536SViorel Suman 		return -EINVAL;
161b86ef536SViorel Suman 	}
162b86ef536SViorel Suman 
163b86ef536SViorel Suman 	if (!audmix_np) {
164de70b2a5SColin Ian King 		dev_err(&pdev->dev, "Missing DT node for parent device.\n");
165b86ef536SViorel Suman 		return -EINVAL;
166b86ef536SViorel Suman 	}
167b86ef536SViorel Suman 
168b86ef536SViorel Suman 	audmix_pdev = of_find_device_by_node(audmix_np);
169b86ef536SViorel Suman 	if (!audmix_pdev) {
170b86ef536SViorel Suman 		dev_err(&pdev->dev, "Missing AUDMIX platform device for %s\n",
171b86ef536SViorel Suman 			np->full_name);
172b86ef536SViorel Suman 		return -EINVAL;
173b86ef536SViorel Suman 	}
1748bb678d7SViorel Suman 	put_device(&audmix_pdev->dev);
175b86ef536SViorel Suman 
176b86ef536SViorel Suman 	num_dai = of_count_phandle_with_args(audmix_np, "dais", NULL);
177b86ef536SViorel Suman 	if (num_dai != FSL_AUDMIX_MAX_DAIS) {
178b86ef536SViorel Suman 		dev_err(&pdev->dev, "Need 2 dais to be provided for %s\n",
179b86ef536SViorel Suman 			audmix_np->full_name);
180b86ef536SViorel Suman 		return -EINVAL;
181b86ef536SViorel Suman 	}
182b86ef536SViorel Suman 
183b86ef536SViorel Suman 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
184b86ef536SViorel Suman 	if (!priv)
185b86ef536SViorel Suman 		return -ENOMEM;
186b86ef536SViorel Suman 
187b86ef536SViorel Suman 	priv->num_dai = 2 * num_dai;
188f95cc5c1SXu Wang 	priv->dai = devm_kcalloc(&pdev->dev, priv->num_dai,
189b86ef536SViorel Suman 				 sizeof(struct snd_soc_dai_link), GFP_KERNEL);
190b86ef536SViorel Suman 	if (!priv->dai)
191b86ef536SViorel Suman 		return -ENOMEM;
192b86ef536SViorel Suman 
193b86ef536SViorel Suman 	priv->num_dai_conf = num_dai;
194f95cc5c1SXu Wang 	priv->dai_conf = devm_kcalloc(&pdev->dev, priv->num_dai_conf,
195b86ef536SViorel Suman 				      sizeof(struct snd_soc_codec_conf),
196b86ef536SViorel Suman 				      GFP_KERNEL);
197b86ef536SViorel Suman 	if (!priv->dai_conf)
198b86ef536SViorel Suman 		return -ENOMEM;
199b86ef536SViorel Suman 
200b86ef536SViorel Suman 	priv->num_dapm_routes = 3 * num_dai;
201f95cc5c1SXu Wang 	priv->dapm_routes = devm_kcalloc(&pdev->dev, priv->num_dapm_routes,
202b86ef536SViorel Suman 					 sizeof(struct snd_soc_dapm_route),
203b86ef536SViorel Suman 					 GFP_KERNEL);
204b86ef536SViorel Suman 	if (!priv->dapm_routes)
205b86ef536SViorel Suman 		return -ENOMEM;
206b86ef536SViorel Suman 
207b86ef536SViorel Suman 	for (i = 0; i < num_dai; i++) {
20879782e28SKuninori Morimoto 		struct snd_soc_dai_link_component *dlc;
20979782e28SKuninori Morimoto 
2109213866aSKuninori Morimoto 		/* for CPU/Codec/Platform x 2 */
211f95cc5c1SXu Wang 		dlc = devm_kcalloc(&pdev->dev, 6, sizeof(*dlc), GFP_KERNEL);
212723ca2f8SZhen Lei 		if (!dlc)
21379782e28SKuninori Morimoto 			return -ENOMEM;
21479782e28SKuninori Morimoto 
215b86ef536SViorel Suman 		ret = of_parse_phandle_with_args(audmix_np, "dais", NULL, i,
216b86ef536SViorel Suman 						 &args);
217b86ef536SViorel Suman 		if (ret < 0) {
218b86ef536SViorel Suman 			dev_err(&pdev->dev, "of_parse_phandle_with_args failed\n");
219b86ef536SViorel Suman 			return ret;
220b86ef536SViorel Suman 		}
221b86ef536SViorel Suman 
222b86ef536SViorel Suman 		cpu_pdev = of_find_device_by_node(args.np);
223b86ef536SViorel Suman 		if (!cpu_pdev) {
224b86ef536SViorel Suman 			dev_err(&pdev->dev, "failed to find SAI platform device\n");
225b86ef536SViorel Suman 			return -EINVAL;
226b86ef536SViorel Suman 		}
2278bb678d7SViorel Suman 		put_device(&cpu_pdev->dev);
228b86ef536SViorel Suman 
229b86ef536SViorel Suman 		dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s",
230b86ef536SViorel Suman 					  fe_name_pref, args.np->full_name + 1);
231b86ef536SViorel Suman 
232b86ef536SViorel Suman 		dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name);
233b86ef536SViorel Suman 
234b86ef536SViorel Suman 		if (i == 0) {
235b86ef536SViorel Suman 			out_cpu_np = args.np;
236b86ef536SViorel Suman 			capture_dai_name =
237b86ef536SViorel Suman 				devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
238b86ef536SViorel Suman 					       dai_name, "CPU-Capture");
239b86ef536SViorel Suman 		}
240b86ef536SViorel Suman 
24179782e28SKuninori Morimoto 		priv->dai[i].cpus = &dlc[0];
24279782e28SKuninori Morimoto 		priv->dai[i].codecs = &dlc[1];
2439213866aSKuninori Morimoto 		priv->dai[i].platforms = &dlc[2];
24479782e28SKuninori Morimoto 
24579782e28SKuninori Morimoto 		priv->dai[i].num_cpus = 1;
24679782e28SKuninori Morimoto 		priv->dai[i].num_codecs = 1;
2479213866aSKuninori Morimoto 		priv->dai[i].num_platforms = 1;
24879782e28SKuninori Morimoto 
249b86ef536SViorel Suman 		priv->dai[i].name = dai_name;
250b86ef536SViorel Suman 		priv->dai[i].stream_name = "HiFi-AUDMIX-FE";
25179782e28SKuninori Morimoto 		priv->dai[i].codecs->dai_name = "snd-soc-dummy-dai";
25279782e28SKuninori Morimoto 		priv->dai[i].codecs->name = "snd-soc-dummy";
25379782e28SKuninori Morimoto 		priv->dai[i].cpus->of_node = args.np;
25479782e28SKuninori Morimoto 		priv->dai[i].cpus->dai_name = dev_name(&cpu_pdev->dev);
2559213866aSKuninori Morimoto 		priv->dai[i].platforms->of_node = args.np;
256b86ef536SViorel Suman 		priv->dai[i].dynamic = 1;
257b86ef536SViorel Suman 		priv->dai[i].dpcm_playback = 1;
258b86ef536SViorel Suman 		priv->dai[i].dpcm_capture = (i == 0 ? 1 : 0);
259b86ef536SViorel Suman 		priv->dai[i].ignore_pmdown_time = 1;
260b86ef536SViorel Suman 		priv->dai[i].ops = &imx_audmix_fe_ops;
261b86ef536SViorel Suman 
262b86ef536SViorel Suman 		/* Add AUDMIX Backend */
263b86ef536SViorel Suman 		be_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
264b86ef536SViorel Suman 					 "audmix-%d", i);
265b86ef536SViorel Suman 		be_pb = devm_kasprintf(&pdev->dev, GFP_KERNEL,
266b86ef536SViorel Suman 				       "AUDMIX-Playback-%d", i);
267b86ef536SViorel Suman 		be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL,
268b86ef536SViorel Suman 				       "AUDMIX-Capture-%d", i);
269b86ef536SViorel Suman 
2709213866aSKuninori Morimoto 		priv->dai[num_dai + i].cpus = &dlc[3];
2719213866aSKuninori Morimoto 		priv->dai[num_dai + i].codecs = &dlc[4];
2729213866aSKuninori Morimoto 		priv->dai[num_dai + i].platforms = &dlc[5];
27379782e28SKuninori Morimoto 
27479782e28SKuninori Morimoto 		priv->dai[num_dai + i].num_cpus = 1;
27579782e28SKuninori Morimoto 		priv->dai[num_dai + i].num_codecs = 1;
2769213866aSKuninori Morimoto 		priv->dai[num_dai + i].num_platforms = 1;
27779782e28SKuninori Morimoto 
278b86ef536SViorel Suman 		priv->dai[num_dai + i].name = be_name;
27979782e28SKuninori Morimoto 		priv->dai[num_dai + i].codecs->dai_name = "snd-soc-dummy-dai";
28079782e28SKuninori Morimoto 		priv->dai[num_dai + i].codecs->name = "snd-soc-dummy";
28179782e28SKuninori Morimoto 		priv->dai[num_dai + i].cpus->of_node = audmix_np;
28279782e28SKuninori Morimoto 		priv->dai[num_dai + i].cpus->dai_name = be_name;
2839213866aSKuninori Morimoto 		priv->dai[num_dai + i].platforms->name = "snd-soc-dummy";
284b86ef536SViorel Suman 		priv->dai[num_dai + i].no_pcm = 1;
285b86ef536SViorel Suman 		priv->dai[num_dai + i].dpcm_playback = 1;
286b86ef536SViorel Suman 		priv->dai[num_dai + i].dpcm_capture  = 1;
287b86ef536SViorel Suman 		priv->dai[num_dai + i].ignore_pmdown_time = 1;
288b86ef536SViorel Suman 		priv->dai[num_dai + i].ops = &imx_audmix_be_ops;
289b86ef536SViorel Suman 
290eea23952SKuninori Morimoto 		priv->dai_conf[i].dlc.of_node = args.np;
291b86ef536SViorel Suman 		priv->dai_conf[i].name_prefix = dai_name;
292b86ef536SViorel Suman 
293b86ef536SViorel Suman 		priv->dapm_routes[i].source =
294b86ef536SViorel Suman 			devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
295b86ef536SViorel Suman 				       dai_name, "CPU-Playback");
296b86ef536SViorel Suman 		priv->dapm_routes[i].sink = be_pb;
297b86ef536SViorel Suman 		priv->dapm_routes[num_dai + i].source   = be_pb;
298b86ef536SViorel Suman 		priv->dapm_routes[num_dai + i].sink     = be_cp;
299b86ef536SViorel Suman 		priv->dapm_routes[2 * num_dai + i].source = be_cp;
300b86ef536SViorel Suman 		priv->dapm_routes[2 * num_dai + i].sink   = capture_dai_name;
301b86ef536SViorel Suman 	}
302b86ef536SViorel Suman 
303b86ef536SViorel Suman 	cpu_pdev = of_find_device_by_node(out_cpu_np);
304b86ef536SViorel Suman 	if (!cpu_pdev) {
305b86ef536SViorel Suman 		dev_err(&pdev->dev, "failed to find SAI platform device\n");
306b86ef536SViorel Suman 		return -EINVAL;
307b86ef536SViorel Suman 	}
3088bb678d7SViorel Suman 	put_device(&cpu_pdev->dev);
3098bb678d7SViorel Suman 
310b86ef536SViorel Suman 	priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1");
311b86ef536SViorel Suman 	if (IS_ERR(priv->cpu_mclk)) {
312b86ef536SViorel Suman 		ret = PTR_ERR(priv->cpu_mclk);
313b86ef536SViorel Suman 		dev_err(&cpu_pdev->dev, "failed to get DAI mclk1: %d\n", ret);
314b86ef536SViorel Suman 		return -EINVAL;
315b86ef536SViorel Suman 	}
316b86ef536SViorel Suman 
317b86ef536SViorel Suman 	priv->audmix_pdev = audmix_pdev;
318b86ef536SViorel Suman 	priv->out_pdev  = cpu_pdev;
319b86ef536SViorel Suman 
320b86ef536SViorel Suman 	priv->card.dai_link = priv->dai;
321b86ef536SViorel Suman 	priv->card.num_links = priv->num_dai;
322b86ef536SViorel Suman 	priv->card.codec_conf = priv->dai_conf;
323b86ef536SViorel Suman 	priv->card.num_configs = priv->num_dai_conf;
324b86ef536SViorel Suman 	priv->card.dapm_routes = priv->dapm_routes;
325b86ef536SViorel Suman 	priv->card.num_dapm_routes = priv->num_dapm_routes;
3269573820eSShengjiu Wang 	priv->card.dev = &pdev->dev;
327b86ef536SViorel Suman 	priv->card.owner = THIS_MODULE;
328b86ef536SViorel Suman 	priv->card.name = "imx-audmix";
329b86ef536SViorel Suman 
330b86ef536SViorel Suman 	platform_set_drvdata(pdev, &priv->card);
331b86ef536SViorel Suman 	snd_soc_card_set_drvdata(&priv->card, priv);
332b86ef536SViorel Suman 
3339573820eSShengjiu Wang 	ret = devm_snd_soc_register_card(&pdev->dev, &priv->card);
334b86ef536SViorel Suman 	if (ret) {
335b86ef536SViorel Suman 		dev_err(&pdev->dev, "snd_soc_register_card failed\n");
336b86ef536SViorel Suman 		return ret;
337b86ef536SViorel Suman 	}
338b86ef536SViorel Suman 
339b86ef536SViorel Suman 	return ret;
340b86ef536SViorel Suman }
341b86ef536SViorel Suman 
342b86ef536SViorel Suman static struct platform_driver imx_audmix_driver = {
343b86ef536SViorel Suman 	.probe = imx_audmix_probe,
344b86ef536SViorel Suman 	.driver = {
345b86ef536SViorel Suman 		.name = "imx-audmix",
346b86ef536SViorel Suman 		.pm = &snd_soc_pm_ops,
347b86ef536SViorel Suman 	},
348b86ef536SViorel Suman };
349b86ef536SViorel Suman module_platform_driver(imx_audmix_driver);
350b86ef536SViorel Suman 
351b86ef536SViorel Suman MODULE_DESCRIPTION("NXP AUDMIX ASoC machine driver");
352b86ef536SViorel Suman MODULE_AUTHOR("Viorel Suman <viorel.suman@nxp.com>");
353b86ef536SViorel Suman MODULE_ALIAS("platform:imx-audmix");
354b86ef536SViorel Suman MODULE_LICENSE("GPL v2");
355