xref: /linux/sound/soc/fsl/imx-audmix.c (revision 79782e283ed3df04bfb77129091f1d6726987f1e)
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  *
9b86ef536SViorel Suman  * http://www.opensource.org/licenses/gpl-license.html
10b86ef536SViorel Suman  * http://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 {
47b86ef536SViorel Suman 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
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 {
76b86ef536SViorel Suman 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
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 
83b86ef536SViorel Suman 	/* For playback the AUDMIX is slave, and for record is master */
84b86ef536SViorel Suman 	fmt |= tx ? SND_SOC_DAIFMT_CBS_CFS : SND_SOC_DAIFMT_CBM_CFM;
85b86ef536SViorel Suman 	dir  = tx ? SND_SOC_CLOCK_OUT : SND_SOC_CLOCK_IN;
86b86ef536SViorel Suman 
87b86ef536SViorel Suman 	/* set DAI configuration */
88b86ef536SViorel Suman 	ret = snd_soc_dai_set_fmt(rtd->cpu_dai, 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 
94b86ef536SViorel Suman 	ret = snd_soc_dai_set_sysclk(rtd->cpu_dai, 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 	 */
104b86ef536SViorel Suman 	ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 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 {
115b86ef536SViorel Suman 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
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 
124b86ef536SViorel Suman 	/* For playback the AUDMIX is slave */
125b86ef536SViorel Suman 	fmt |= SND_SOC_DAIFMT_CBM_CFM;
126b86ef536SViorel Suman 
127b86ef536SViorel Suman 	/* set AUDMIX DAI configuration */
128b86ef536SViorel Suman 	ret = snd_soc_dai_set_fmt(rtd->cpu_dai, 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 
135b86ef536SViorel Suman static 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 
140b86ef536SViorel Suman static 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;
188b86ef536SViorel Suman 	priv->dai = devm_kzalloc(&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;
194b86ef536SViorel Suman 	priv->dai_conf = devm_kzalloc(&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;
201b86ef536SViorel Suman 	priv->dapm_routes = devm_kzalloc(&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++) {
208*79782e28SKuninori Morimoto 		struct snd_soc_dai_link_component *dlc;
209*79782e28SKuninori Morimoto 
210*79782e28SKuninori Morimoto 		/* for CPU/Codec/Platform x 2 */
211*79782e28SKuninori Morimoto 		dlc = devm_kzalloc(&pdev->dev, 6 * sizeof(*dlc), GFP_KERNEL);
212*79782e28SKuninori Morimoto 		if (!dlc) {
213*79782e28SKuninori Morimoto 			dev_err(&pdev->dev, "failed to allocate dai_link\n");
214*79782e28SKuninori Morimoto 			return -ENOMEM;
215*79782e28SKuninori Morimoto 		}
216*79782e28SKuninori Morimoto 
217b86ef536SViorel Suman 		ret = of_parse_phandle_with_args(audmix_np, "dais", NULL, i,
218b86ef536SViorel Suman 						 &args);
219b86ef536SViorel Suman 		if (ret < 0) {
220b86ef536SViorel Suman 			dev_err(&pdev->dev, "of_parse_phandle_with_args failed\n");
221b86ef536SViorel Suman 			return ret;
222b86ef536SViorel Suman 		}
223b86ef536SViorel Suman 
224b86ef536SViorel Suman 		cpu_pdev = of_find_device_by_node(args.np);
225b86ef536SViorel Suman 		if (!cpu_pdev) {
226b86ef536SViorel Suman 			dev_err(&pdev->dev, "failed to find SAI platform device\n");
227b86ef536SViorel Suman 			return -EINVAL;
228b86ef536SViorel Suman 		}
2298bb678d7SViorel Suman 		put_device(&cpu_pdev->dev);
230b86ef536SViorel Suman 
231b86ef536SViorel Suman 		dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s",
232b86ef536SViorel Suman 					  fe_name_pref, args.np->full_name + 1);
233b86ef536SViorel Suman 
234b86ef536SViorel Suman 		dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name);
235b86ef536SViorel Suman 
236b86ef536SViorel Suman 		if (i == 0) {
237b86ef536SViorel Suman 			out_cpu_np = args.np;
238b86ef536SViorel Suman 			capture_dai_name =
239b86ef536SViorel Suman 				devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
240b86ef536SViorel Suman 					       dai_name, "CPU-Capture");
241b86ef536SViorel Suman 		}
242b86ef536SViorel Suman 
243*79782e28SKuninori Morimoto 		priv->dai[i].cpus = &dlc[0];
244*79782e28SKuninori Morimoto 		priv->dai[i].codecs = &dlc[1];
245*79782e28SKuninori Morimoto 		priv->dai[i].platforms = &dlc[2];
246*79782e28SKuninori Morimoto 
247*79782e28SKuninori Morimoto 		priv->dai[i].num_cpus = 1;
248*79782e28SKuninori Morimoto 		priv->dai[i].num_codecs = 1;
249*79782e28SKuninori Morimoto 		priv->dai[i].num_platforms = 1;
250*79782e28SKuninori Morimoto 
251b86ef536SViorel Suman 		priv->dai[i].name = dai_name;
252b86ef536SViorel Suman 		priv->dai[i].stream_name = "HiFi-AUDMIX-FE";
253*79782e28SKuninori Morimoto 		priv->dai[i].codecs->dai_name = "snd-soc-dummy-dai";
254*79782e28SKuninori Morimoto 		priv->dai[i].codecs->name = "snd-soc-dummy";
255*79782e28SKuninori Morimoto 		priv->dai[i].cpus->of_node = args.np;
256*79782e28SKuninori Morimoto 		priv->dai[i].cpus->dai_name = dev_name(&cpu_pdev->dev);
257*79782e28SKuninori Morimoto 		priv->dai[i].platforms->of_node = args.np;
258b86ef536SViorel Suman 		priv->dai[i].dynamic = 1;
259b86ef536SViorel Suman 		priv->dai[i].dpcm_playback = 1;
260b86ef536SViorel Suman 		priv->dai[i].dpcm_capture = (i == 0 ? 1 : 0);
261b86ef536SViorel Suman 		priv->dai[i].ignore_pmdown_time = 1;
262b86ef536SViorel Suman 		priv->dai[i].ops = &imx_audmix_fe_ops;
263b86ef536SViorel Suman 
264b86ef536SViorel Suman 		/* Add AUDMIX Backend */
265b86ef536SViorel Suman 		be_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
266b86ef536SViorel Suman 					 "audmix-%d", i);
267b86ef536SViorel Suman 		be_pb = devm_kasprintf(&pdev->dev, GFP_KERNEL,
268b86ef536SViorel Suman 				       "AUDMIX-Playback-%d", i);
269b86ef536SViorel Suman 		be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL,
270b86ef536SViorel Suman 				       "AUDMIX-Capture-%d", i);
271b86ef536SViorel Suman 
272*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].cpus = &dlc[3];
273*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].codecs = &dlc[4];
274*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].platforms = &dlc[5];
275*79782e28SKuninori Morimoto 
276*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].num_cpus = 1;
277*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].num_codecs = 1;
278*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].num_platforms = 1;
279*79782e28SKuninori Morimoto 
280b86ef536SViorel Suman 		priv->dai[num_dai + i].name = be_name;
281*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].codecs->dai_name = "snd-soc-dummy-dai";
282*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].codecs->name = "snd-soc-dummy";
283*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].cpus->of_node = audmix_np;
284*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].cpus->dai_name = be_name;
285*79782e28SKuninori Morimoto 		priv->dai[num_dai + i].platforms->name = "snd-soc-dummy";
286b86ef536SViorel Suman 		priv->dai[num_dai + i].no_pcm = 1;
287b86ef536SViorel Suman 		priv->dai[num_dai + i].dpcm_playback = 1;
288b86ef536SViorel Suman 		priv->dai[num_dai + i].dpcm_capture  = 1;
289b86ef536SViorel Suman 		priv->dai[num_dai + i].ignore_pmdown_time = 1;
290b86ef536SViorel Suman 		priv->dai[num_dai + i].ops = &imx_audmix_be_ops;
291b86ef536SViorel Suman 
292b86ef536SViorel Suman 		priv->dai_conf[i].of_node = args.np;
293b86ef536SViorel Suman 		priv->dai_conf[i].name_prefix = dai_name;
294b86ef536SViorel Suman 
295b86ef536SViorel Suman 		priv->dapm_routes[i].source =
296b86ef536SViorel Suman 			devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
297b86ef536SViorel Suman 				       dai_name, "CPU-Playback");
298b86ef536SViorel Suman 		priv->dapm_routes[i].sink = be_pb;
299b86ef536SViorel Suman 		priv->dapm_routes[num_dai + i].source   = be_pb;
300b86ef536SViorel Suman 		priv->dapm_routes[num_dai + i].sink     = be_cp;
301b86ef536SViorel Suman 		priv->dapm_routes[2 * num_dai + i].source = be_cp;
302b86ef536SViorel Suman 		priv->dapm_routes[2 * num_dai + i].sink   = capture_dai_name;
303b86ef536SViorel Suman 	}
304b86ef536SViorel Suman 
305b86ef536SViorel Suman 	cpu_pdev = of_find_device_by_node(out_cpu_np);
306b86ef536SViorel Suman 	if (!cpu_pdev) {
307b86ef536SViorel Suman 		dev_err(&pdev->dev, "failed to find SAI platform device\n");
308b86ef536SViorel Suman 		return -EINVAL;
309b86ef536SViorel Suman 	}
3108bb678d7SViorel Suman 	put_device(&cpu_pdev->dev);
3118bb678d7SViorel Suman 
312b86ef536SViorel Suman 	priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1");
313b86ef536SViorel Suman 	if (IS_ERR(priv->cpu_mclk)) {
314b86ef536SViorel Suman 		ret = PTR_ERR(priv->cpu_mclk);
315b86ef536SViorel Suman 		dev_err(&cpu_pdev->dev, "failed to get DAI mclk1: %d\n", ret);
316b86ef536SViorel Suman 		return -EINVAL;
317b86ef536SViorel Suman 	}
318b86ef536SViorel Suman 
319b86ef536SViorel Suman 	priv->audmix_pdev = audmix_pdev;
320b86ef536SViorel Suman 	priv->out_pdev  = cpu_pdev;
321b86ef536SViorel Suman 
322b86ef536SViorel Suman 	priv->card.dai_link = priv->dai;
323b86ef536SViorel Suman 	priv->card.num_links = priv->num_dai;
324b86ef536SViorel Suman 	priv->card.codec_conf = priv->dai_conf;
325b86ef536SViorel Suman 	priv->card.num_configs = priv->num_dai_conf;
326b86ef536SViorel Suman 	priv->card.dapm_routes = priv->dapm_routes;
327b86ef536SViorel Suman 	priv->card.num_dapm_routes = priv->num_dapm_routes;
328b86ef536SViorel Suman 	priv->card.dev = pdev->dev.parent;
329b86ef536SViorel Suman 	priv->card.owner = THIS_MODULE;
330b86ef536SViorel Suman 	priv->card.name = "imx-audmix";
331b86ef536SViorel Suman 
332b86ef536SViorel Suman 	platform_set_drvdata(pdev, &priv->card);
333b86ef536SViorel Suman 	snd_soc_card_set_drvdata(&priv->card, priv);
334b86ef536SViorel Suman 
335b86ef536SViorel Suman 	ret = devm_snd_soc_register_card(pdev->dev.parent, &priv->card);
336b86ef536SViorel Suman 	if (ret) {
337b86ef536SViorel Suman 		dev_err(&pdev->dev, "snd_soc_register_card failed\n");
338b86ef536SViorel Suman 		return ret;
339b86ef536SViorel Suman 	}
340b86ef536SViorel Suman 
341b86ef536SViorel Suman 	return ret;
342b86ef536SViorel Suman }
343b86ef536SViorel Suman 
344b86ef536SViorel Suman static struct platform_driver imx_audmix_driver = {
345b86ef536SViorel Suman 	.probe = imx_audmix_probe,
346b86ef536SViorel Suman 	.driver = {
347b86ef536SViorel Suman 		.name = "imx-audmix",
348b86ef536SViorel Suman 		.pm = &snd_soc_pm_ops,
349b86ef536SViorel Suman 	},
350b86ef536SViorel Suman };
351b86ef536SViorel Suman module_platform_driver(imx_audmix_driver);
352b86ef536SViorel Suman 
353b86ef536SViorel Suman MODULE_DESCRIPTION("NXP AUDMIX ASoC machine driver");
354b86ef536SViorel Suman MODULE_AUTHOR("Viorel Suman <viorel.suman@nxp.com>");
355b86ef536SViorel Suman MODULE_ALIAS("platform:imx-audmix");
356b86ef536SViorel Suman MODULE_LICENSE("GPL v2");
357