xref: /openbmc/linux/sound/soc/fsl/fsl_rpmsg.c (revision 59f5a149f5072f4da79656cde9972ba2b616634f)
1b73d9e62SShengjiu Wang // SPDX-License-Identifier: GPL-2.0+
2b73d9e62SShengjiu Wang // Copyright 2018-2021 NXP
3b73d9e62SShengjiu Wang 
4b73d9e62SShengjiu Wang #include <linux/clk.h>
5b73d9e62SShengjiu Wang #include <linux/clk-provider.h>
6b73d9e62SShengjiu Wang #include <linux/delay.h>
7b73d9e62SShengjiu Wang #include <linux/dmaengine.h>
8b73d9e62SShengjiu Wang #include <linux/module.h>
9b73d9e62SShengjiu Wang #include <linux/of_device.h>
10b73d9e62SShengjiu Wang #include <linux/of_address.h>
11b73d9e62SShengjiu Wang #include <linux/pm_runtime.h>
12b73d9e62SShengjiu Wang #include <linux/rpmsg.h>
13b73d9e62SShengjiu Wang #include <linux/slab.h>
14b73d9e62SShengjiu Wang #include <sound/core.h>
15b73d9e62SShengjiu Wang #include <sound/dmaengine_pcm.h>
16b73d9e62SShengjiu Wang #include <sound/pcm_params.h>
17b73d9e62SShengjiu Wang 
18b73d9e62SShengjiu Wang #include "fsl_rpmsg.h"
19b73d9e62SShengjiu Wang #include "imx-pcm.h"
20b73d9e62SShengjiu Wang 
21b73d9e62SShengjiu Wang #define FSL_RPMSG_RATES        (SNDRV_PCM_RATE_8000 | \
22b73d9e62SShengjiu Wang 				SNDRV_PCM_RATE_16000 | \
23b73d9e62SShengjiu Wang 				SNDRV_PCM_RATE_48000)
24b73d9e62SShengjiu Wang #define FSL_RPMSG_FORMATS	SNDRV_PCM_FMTBIT_S16_LE
25b73d9e62SShengjiu Wang 
26b73d9e62SShengjiu Wang /* 192kHz/32bit/2ch/60s size is 0x574e00 */
27b73d9e62SShengjiu Wang #define LPA_LARGE_BUFFER_SIZE  (0x6000000)
28b73d9e62SShengjiu Wang 
29b73d9e62SShengjiu Wang static const unsigned int fsl_rpmsg_rates[] = {
30b73d9e62SShengjiu Wang 	8000, 11025, 16000, 22050, 44100,
31b73d9e62SShengjiu Wang 	32000, 48000, 96000, 88200, 176400, 192000,
32b73d9e62SShengjiu Wang 	352800, 384000, 705600, 768000, 1411200, 2822400,
33b73d9e62SShengjiu Wang };
34b73d9e62SShengjiu Wang 
35b73d9e62SShengjiu Wang static const struct snd_pcm_hw_constraint_list fsl_rpmsg_rate_constraints = {
36b73d9e62SShengjiu Wang 	.count = ARRAY_SIZE(fsl_rpmsg_rates),
37b73d9e62SShengjiu Wang 	.list = fsl_rpmsg_rates,
38b73d9e62SShengjiu Wang };
39b73d9e62SShengjiu Wang 
fsl_rpmsg_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_soc_dai * dai)40b73d9e62SShengjiu Wang static int fsl_rpmsg_hw_params(struct snd_pcm_substream *substream,
41b73d9e62SShengjiu Wang 			       struct snd_pcm_hw_params *params,
42b73d9e62SShengjiu Wang 			       struct snd_soc_dai *dai)
43b73d9e62SShengjiu Wang {
44b73d9e62SShengjiu Wang 	struct fsl_rpmsg *rpmsg = snd_soc_dai_get_drvdata(dai);
45502e5321SShengjiu Wang 	struct clk *p = rpmsg->mclk, *pll = NULL, *npll = NULL;
46b73d9e62SShengjiu Wang 	u64 rate = params_rate(params);
47b73d9e62SShengjiu Wang 	int ret = 0;
48b73d9e62SShengjiu Wang 
49b73d9e62SShengjiu Wang 	/* Get current pll parent */
50b73d9e62SShengjiu Wang 	while (p && rpmsg->pll8k && rpmsg->pll11k) {
51b73d9e62SShengjiu Wang 		struct clk *pp = clk_get_parent(p);
52b73d9e62SShengjiu Wang 
53b73d9e62SShengjiu Wang 		if (clk_is_match(pp, rpmsg->pll8k) ||
54b73d9e62SShengjiu Wang 		    clk_is_match(pp, rpmsg->pll11k)) {
55b73d9e62SShengjiu Wang 			pll = pp;
56b73d9e62SShengjiu Wang 			break;
57b73d9e62SShengjiu Wang 		}
58b73d9e62SShengjiu Wang 		p = pp;
59b73d9e62SShengjiu Wang 	}
60b73d9e62SShengjiu Wang 
61b73d9e62SShengjiu Wang 	/* Switch to another pll parent if needed. */
62b73d9e62SShengjiu Wang 	if (pll) {
63b73d9e62SShengjiu Wang 		npll = (do_div(rate, 8000) ? rpmsg->pll11k : rpmsg->pll8k);
64b73d9e62SShengjiu Wang 		if (!clk_is_match(pll, npll)) {
65b73d9e62SShengjiu Wang 			ret = clk_set_parent(p, npll);
66b73d9e62SShengjiu Wang 			if (ret < 0)
67b73d9e62SShengjiu Wang 				dev_warn(dai->dev, "failed to set parent %s: %d\n",
68b73d9e62SShengjiu Wang 					 __clk_get_name(npll), ret);
69b73d9e62SShengjiu Wang 		}
70b73d9e62SShengjiu Wang 	}
71b73d9e62SShengjiu Wang 
72b73d9e62SShengjiu Wang 	if (!(rpmsg->mclk_streams & BIT(substream->stream))) {
73b73d9e62SShengjiu Wang 		ret = clk_prepare_enable(rpmsg->mclk);
74b73d9e62SShengjiu Wang 		if (ret) {
75b73d9e62SShengjiu Wang 			dev_err(dai->dev, "failed to enable mclk: %d\n", ret);
76b73d9e62SShengjiu Wang 			return ret;
77b73d9e62SShengjiu Wang 		}
78b73d9e62SShengjiu Wang 
79b73d9e62SShengjiu Wang 		rpmsg->mclk_streams |= BIT(substream->stream);
80b73d9e62SShengjiu Wang 	}
81b73d9e62SShengjiu Wang 
82b73d9e62SShengjiu Wang 	return ret;
83b73d9e62SShengjiu Wang }
84b73d9e62SShengjiu Wang 
fsl_rpmsg_hw_free(struct snd_pcm_substream * substream,struct snd_soc_dai * dai)85b73d9e62SShengjiu Wang static int fsl_rpmsg_hw_free(struct snd_pcm_substream *substream,
86b73d9e62SShengjiu Wang 			     struct snd_soc_dai *dai)
87b73d9e62SShengjiu Wang {
88b73d9e62SShengjiu Wang 	struct fsl_rpmsg *rpmsg = snd_soc_dai_get_drvdata(dai);
89b73d9e62SShengjiu Wang 
90b73d9e62SShengjiu Wang 	if (rpmsg->mclk_streams & BIT(substream->stream)) {
91b73d9e62SShengjiu Wang 		clk_disable_unprepare(rpmsg->mclk);
92b73d9e62SShengjiu Wang 		rpmsg->mclk_streams &= ~BIT(substream->stream);
93b73d9e62SShengjiu Wang 	}
94b73d9e62SShengjiu Wang 
95b73d9e62SShengjiu Wang 	return 0;
96b73d9e62SShengjiu Wang }
97b73d9e62SShengjiu Wang 
fsl_rpmsg_startup(struct snd_pcm_substream * substream,struct snd_soc_dai * cpu_dai)98b73d9e62SShengjiu Wang static int fsl_rpmsg_startup(struct snd_pcm_substream *substream,
99b73d9e62SShengjiu Wang 			     struct snd_soc_dai *cpu_dai)
100b73d9e62SShengjiu Wang {
101b73d9e62SShengjiu Wang 	int ret;
102b73d9e62SShengjiu Wang 
103b73d9e62SShengjiu Wang 	ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
104b73d9e62SShengjiu Wang 					 SNDRV_PCM_HW_PARAM_RATE,
105b73d9e62SShengjiu Wang 					 &fsl_rpmsg_rate_constraints);
106b73d9e62SShengjiu Wang 
107b73d9e62SShengjiu Wang 	return ret;
108b73d9e62SShengjiu Wang }
109b73d9e62SShengjiu Wang 
110b73d9e62SShengjiu Wang static const struct snd_soc_dai_ops fsl_rpmsg_dai_ops = {
111b73d9e62SShengjiu Wang 	.startup	= fsl_rpmsg_startup,
112b73d9e62SShengjiu Wang 	.hw_params      = fsl_rpmsg_hw_params,
113b73d9e62SShengjiu Wang 	.hw_free        = fsl_rpmsg_hw_free,
114b73d9e62SShengjiu Wang };
115b73d9e62SShengjiu Wang 
116b73d9e62SShengjiu Wang static struct snd_soc_dai_driver fsl_rpmsg_dai = {
117b73d9e62SShengjiu Wang 	.playback = {
118b73d9e62SShengjiu Wang 		.stream_name = "CPU-Playback",
119b73d9e62SShengjiu Wang 		.channels_min = 2,
120f26c1bb8SChancel Liu 		.channels_max = 32,
121b73d9e62SShengjiu Wang 		.rates = SNDRV_PCM_RATE_KNOT,
122b73d9e62SShengjiu Wang 		.formats = FSL_RPMSG_FORMATS,
123b73d9e62SShengjiu Wang 	},
124b73d9e62SShengjiu Wang 	.capture = {
125b73d9e62SShengjiu Wang 		.stream_name = "CPU-Capture",
126b73d9e62SShengjiu Wang 		.channels_min = 2,
127f26c1bb8SChancel Liu 		.channels_max = 32,
128b73d9e62SShengjiu Wang 		.rates = SNDRV_PCM_RATE_KNOT,
129b73d9e62SShengjiu Wang 		.formats = FSL_RPMSG_FORMATS,
130b73d9e62SShengjiu Wang 	},
131b73d9e62SShengjiu Wang 	.symmetric_rate        = 1,
132b73d9e62SShengjiu Wang 	.symmetric_channels    = 1,
133b73d9e62SShengjiu Wang 	.symmetric_sample_bits = 1,
134b73d9e62SShengjiu Wang 	.ops = &fsl_rpmsg_dai_ops,
135b73d9e62SShengjiu Wang };
136b73d9e62SShengjiu Wang 
137b73d9e62SShengjiu Wang static const struct snd_soc_component_driver fsl_component = {
138b73d9e62SShengjiu Wang 	.name			= "fsl-rpmsg",
1391e63fcc7SCharles Keepax 	.legacy_dai_naming	= 1,
140b73d9e62SShengjiu Wang };
141b73d9e62SShengjiu Wang 
142b7bbbf01SShengjiu Wang static const struct fsl_rpmsg_soc_data imx7ulp_data = {
143b7bbbf01SShengjiu Wang 	.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
144b7bbbf01SShengjiu Wang 		 SNDRV_PCM_RATE_48000,
145b7bbbf01SShengjiu Wang 	.formats = SNDRV_PCM_FMTBIT_S16_LE,
146b7bbbf01SShengjiu Wang };
147b7bbbf01SShengjiu Wang 
148b7bbbf01SShengjiu Wang static const struct fsl_rpmsg_soc_data imx8mm_data = {
149b7bbbf01SShengjiu Wang 	.rates = SNDRV_PCM_RATE_KNOT,
150b7bbbf01SShengjiu Wang 	.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
151b7bbbf01SShengjiu Wang 		   SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_DSD_U8 |
152b7bbbf01SShengjiu Wang 		   SNDRV_PCM_FMTBIT_DSD_U16_LE | SNDRV_PCM_FMTBIT_DSD_U32_LE,
153b7bbbf01SShengjiu Wang };
154b7bbbf01SShengjiu Wang 
155b7bbbf01SShengjiu Wang static const struct fsl_rpmsg_soc_data imx8mn_data = {
156b7bbbf01SShengjiu Wang 	.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
157b7bbbf01SShengjiu Wang 		 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
158b7bbbf01SShengjiu Wang 		 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
159b7bbbf01SShengjiu Wang 		 SNDRV_PCM_RATE_192000,
160b7bbbf01SShengjiu Wang 	.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
161b7bbbf01SShengjiu Wang 		   SNDRV_PCM_FMTBIT_S32_LE,
162b7bbbf01SShengjiu Wang };
163b7bbbf01SShengjiu Wang 
164b7bbbf01SShengjiu Wang static const struct fsl_rpmsg_soc_data imx8mp_data = {
165b7bbbf01SShengjiu Wang 	.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
166b7bbbf01SShengjiu Wang 		 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
167b7bbbf01SShengjiu Wang 		 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
168b7bbbf01SShengjiu Wang 		 SNDRV_PCM_RATE_192000,
169b7bbbf01SShengjiu Wang 	.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
170b7bbbf01SShengjiu Wang 		   SNDRV_PCM_FMTBIT_S32_LE,
171b7bbbf01SShengjiu Wang };
172b7bbbf01SShengjiu Wang 
17360f38a59SChancel Liu static const struct fsl_rpmsg_soc_data imx93_data = {
17460f38a59SChancel Liu 	.rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_32000 |
17560f38a59SChancel Liu 		 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000,
17660f38a59SChancel Liu 	.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
17760f38a59SChancel Liu 		   SNDRV_PCM_FMTBIT_S32_LE,
17860f38a59SChancel Liu };
17960f38a59SChancel Liu 
180b73d9e62SShengjiu Wang static const struct of_device_id fsl_rpmsg_ids[] = {
181b7bbbf01SShengjiu Wang 	{ .compatible = "fsl,imx7ulp-rpmsg-audio", .data = &imx7ulp_data},
182b7bbbf01SShengjiu Wang 	{ .compatible = "fsl,imx8mm-rpmsg-audio", .data = &imx8mm_data},
183b7bbbf01SShengjiu Wang 	{ .compatible = "fsl,imx8mn-rpmsg-audio", .data = &imx8mn_data},
184b7bbbf01SShengjiu Wang 	{ .compatible = "fsl,imx8mp-rpmsg-audio", .data = &imx8mp_data},
1852cbf90a6SShengjiu Wang 	{ .compatible = "fsl,imx8ulp-rpmsg-audio", .data = &imx7ulp_data},
18660f38a59SChancel Liu 	{ .compatible = "fsl,imx93-rpmsg-audio", .data = &imx93_data},
187b73d9e62SShengjiu Wang 	{ /* sentinel */ }
188b73d9e62SShengjiu Wang };
189b73d9e62SShengjiu Wang MODULE_DEVICE_TABLE(of, fsl_rpmsg_ids);
190b73d9e62SShengjiu Wang 
fsl_rpmsg_probe(struct platform_device * pdev)191b73d9e62SShengjiu Wang static int fsl_rpmsg_probe(struct platform_device *pdev)
192b73d9e62SShengjiu Wang {
193b73d9e62SShengjiu Wang 	struct device_node *np = pdev->dev.of_node;
194b73d9e62SShengjiu Wang 	struct fsl_rpmsg *rpmsg;
195b73d9e62SShengjiu Wang 	int ret;
196b73d9e62SShengjiu Wang 
197b73d9e62SShengjiu Wang 	rpmsg = devm_kzalloc(&pdev->dev, sizeof(struct fsl_rpmsg), GFP_KERNEL);
198b73d9e62SShengjiu Wang 	if (!rpmsg)
199b73d9e62SShengjiu Wang 		return -ENOMEM;
200b73d9e62SShengjiu Wang 
201b7bbbf01SShengjiu Wang 	rpmsg->soc_data = of_device_get_match_data(&pdev->dev);
202b7bbbf01SShengjiu Wang 
203b7bbbf01SShengjiu Wang 	fsl_rpmsg_dai.playback.rates = rpmsg->soc_data->rates;
204b7bbbf01SShengjiu Wang 	fsl_rpmsg_dai.capture.rates = rpmsg->soc_data->rates;
205b7bbbf01SShengjiu Wang 	fsl_rpmsg_dai.playback.formats = rpmsg->soc_data->formats;
206b7bbbf01SShengjiu Wang 	fsl_rpmsg_dai.capture.formats = rpmsg->soc_data->formats;
207b7bbbf01SShengjiu Wang 
208b73d9e62SShengjiu Wang 	if (of_property_read_bool(np, "fsl,enable-lpa")) {
209b73d9e62SShengjiu Wang 		rpmsg->enable_lpa = 1;
210b73d9e62SShengjiu Wang 		rpmsg->buffer_size = LPA_LARGE_BUFFER_SIZE;
211b73d9e62SShengjiu Wang 	} else {
212b73d9e62SShengjiu Wang 		rpmsg->buffer_size = IMX_DEFAULT_DMABUF_SIZE;
213b73d9e62SShengjiu Wang 	}
214b73d9e62SShengjiu Wang 
215b73d9e62SShengjiu Wang 	/* Get the optional clocks */
2162fbbcffeSShengjiu Wang 	rpmsg->ipg = devm_clk_get_optional(&pdev->dev, "ipg");
217b73d9e62SShengjiu Wang 	if (IS_ERR(rpmsg->ipg))
2182fbbcffeSShengjiu Wang 		return PTR_ERR(rpmsg->ipg);
219b73d9e62SShengjiu Wang 
2202fbbcffeSShengjiu Wang 	rpmsg->mclk = devm_clk_get_optional(&pdev->dev, "mclk");
221b73d9e62SShengjiu Wang 	if (IS_ERR(rpmsg->mclk))
2222fbbcffeSShengjiu Wang 		return PTR_ERR(rpmsg->mclk);
223b73d9e62SShengjiu Wang 
2242fbbcffeSShengjiu Wang 	rpmsg->dma = devm_clk_get_optional(&pdev->dev, "dma");
225b73d9e62SShengjiu Wang 	if (IS_ERR(rpmsg->dma))
2262fbbcffeSShengjiu Wang 		return PTR_ERR(rpmsg->dma);
227b73d9e62SShengjiu Wang 
2282fbbcffeSShengjiu Wang 	rpmsg->pll8k = devm_clk_get_optional(&pdev->dev, "pll8k");
229b73d9e62SShengjiu Wang 	if (IS_ERR(rpmsg->pll8k))
2302fbbcffeSShengjiu Wang 		return PTR_ERR(rpmsg->pll8k);
231b73d9e62SShengjiu Wang 
2322fbbcffeSShengjiu Wang 	rpmsg->pll11k = devm_clk_get_optional(&pdev->dev, "pll11k");
233b73d9e62SShengjiu Wang 	if (IS_ERR(rpmsg->pll11k))
2342fbbcffeSShengjiu Wang 		return PTR_ERR(rpmsg->pll11k);
235b73d9e62SShengjiu Wang 
236b73d9e62SShengjiu Wang 	platform_set_drvdata(pdev, rpmsg);
237b73d9e62SShengjiu Wang 	pm_runtime_enable(&pdev->dev);
238b73d9e62SShengjiu Wang 
239b73d9e62SShengjiu Wang 	ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component,
240b73d9e62SShengjiu Wang 					      &fsl_rpmsg_dai, 1);
241b73d9e62SShengjiu Wang 	if (ret)
242*4deed2c6SChancel Liu 		goto err_pm_disable;
243b73d9e62SShengjiu Wang 
244b73d9e62SShengjiu Wang 	rpmsg->card_pdev = platform_device_register_data(&pdev->dev,
245b73d9e62SShengjiu Wang 							 "imx-audio-rpmsg",
24676a874caSChancel Liu 							 PLATFORM_DEVID_AUTO,
247b73d9e62SShengjiu Wang 							 NULL,
248b73d9e62SShengjiu Wang 							 0);
249b73d9e62SShengjiu Wang 	if (IS_ERR(rpmsg->card_pdev)) {
250b73d9e62SShengjiu Wang 		dev_err(&pdev->dev, "failed to register rpmsg card\n");
251b73d9e62SShengjiu Wang 		ret = PTR_ERR(rpmsg->card_pdev);
252*4deed2c6SChancel Liu 		goto err_pm_disable;
253b73d9e62SShengjiu Wang 	}
254b73d9e62SShengjiu Wang 
255b73d9e62SShengjiu Wang 	return 0;
256*4deed2c6SChancel Liu 
257*4deed2c6SChancel Liu err_pm_disable:
258*4deed2c6SChancel Liu 	pm_runtime_disable(&pdev->dev);
259*4deed2c6SChancel Liu 	return ret;
260b73d9e62SShengjiu Wang }
261b73d9e62SShengjiu Wang 
fsl_rpmsg_remove(struct platform_device * pdev)262126ce432SUwe Kleine-König static void fsl_rpmsg_remove(struct platform_device *pdev)
263b73d9e62SShengjiu Wang {
264b73d9e62SShengjiu Wang 	struct fsl_rpmsg *rpmsg = platform_get_drvdata(pdev);
265b73d9e62SShengjiu Wang 
266*4deed2c6SChancel Liu 	pm_runtime_disable(&pdev->dev);
267*4deed2c6SChancel Liu 
268b73d9e62SShengjiu Wang 	if (rpmsg->card_pdev)
269b73d9e62SShengjiu Wang 		platform_device_unregister(rpmsg->card_pdev);
270b73d9e62SShengjiu Wang }
271b73d9e62SShengjiu Wang 
272b73d9e62SShengjiu Wang #ifdef CONFIG_PM
fsl_rpmsg_runtime_resume(struct device * dev)273b73d9e62SShengjiu Wang static int fsl_rpmsg_runtime_resume(struct device *dev)
274b73d9e62SShengjiu Wang {
275b73d9e62SShengjiu Wang 	struct fsl_rpmsg *rpmsg = dev_get_drvdata(dev);
276b73d9e62SShengjiu Wang 	int ret;
277b73d9e62SShengjiu Wang 
278b73d9e62SShengjiu Wang 	ret = clk_prepare_enable(rpmsg->ipg);
279b73d9e62SShengjiu Wang 	if (ret) {
280b73d9e62SShengjiu Wang 		dev_err(dev, "failed to enable ipg clock: %d\n", ret);
281b73d9e62SShengjiu Wang 		goto ipg_err;
282b73d9e62SShengjiu Wang 	}
283b73d9e62SShengjiu Wang 
284b73d9e62SShengjiu Wang 	ret = clk_prepare_enable(rpmsg->dma);
285b73d9e62SShengjiu Wang 	if (ret) {
286b73d9e62SShengjiu Wang 		dev_err(dev, "Failed to enable dma clock %d\n", ret);
287b73d9e62SShengjiu Wang 		goto dma_err;
288b73d9e62SShengjiu Wang 	}
289b73d9e62SShengjiu Wang 
290b73d9e62SShengjiu Wang 	return 0;
291b73d9e62SShengjiu Wang 
292b73d9e62SShengjiu Wang dma_err:
293b73d9e62SShengjiu Wang 	clk_disable_unprepare(rpmsg->ipg);
294b73d9e62SShengjiu Wang ipg_err:
295b73d9e62SShengjiu Wang 	return ret;
296b73d9e62SShengjiu Wang }
297b73d9e62SShengjiu Wang 
fsl_rpmsg_runtime_suspend(struct device * dev)298b73d9e62SShengjiu Wang static int fsl_rpmsg_runtime_suspend(struct device *dev)
299b73d9e62SShengjiu Wang {
300b73d9e62SShengjiu Wang 	struct fsl_rpmsg *rpmsg = dev_get_drvdata(dev);
301b73d9e62SShengjiu Wang 
302b73d9e62SShengjiu Wang 	clk_disable_unprepare(rpmsg->dma);
303b73d9e62SShengjiu Wang 	clk_disable_unprepare(rpmsg->ipg);
304b73d9e62SShengjiu Wang 
305b73d9e62SShengjiu Wang 	return 0;
306b73d9e62SShengjiu Wang }
307b73d9e62SShengjiu Wang #endif
308b73d9e62SShengjiu Wang 
309b73d9e62SShengjiu Wang static const struct dev_pm_ops fsl_rpmsg_pm_ops = {
310b73d9e62SShengjiu Wang 	SET_RUNTIME_PM_OPS(fsl_rpmsg_runtime_suspend,
311b73d9e62SShengjiu Wang 			   fsl_rpmsg_runtime_resume,
312b73d9e62SShengjiu Wang 			   NULL)
313b73d9e62SShengjiu Wang };
314b73d9e62SShengjiu Wang 
315b73d9e62SShengjiu Wang static struct platform_driver fsl_rpmsg_driver = {
316b73d9e62SShengjiu Wang 	.probe  = fsl_rpmsg_probe,
317126ce432SUwe Kleine-König 	.remove_new = fsl_rpmsg_remove,
318b73d9e62SShengjiu Wang 	.driver = {
319b73d9e62SShengjiu Wang 		.name = "fsl_rpmsg",
320b73d9e62SShengjiu Wang 		.pm = &fsl_rpmsg_pm_ops,
321b73d9e62SShengjiu Wang 		.of_match_table = fsl_rpmsg_ids,
322b73d9e62SShengjiu Wang 	},
323b73d9e62SShengjiu Wang };
324b73d9e62SShengjiu Wang module_platform_driver(fsl_rpmsg_driver);
325b73d9e62SShengjiu Wang 
326b73d9e62SShengjiu Wang MODULE_DESCRIPTION("Freescale SoC Audio PRMSG CPU Interface");
327b73d9e62SShengjiu Wang MODULE_AUTHOR("Shengjiu Wang <shengjiu.wang@nxp.com>");
328b73d9e62SShengjiu Wang MODULE_ALIAS("platform:fsl_rpmsg");
329b73d9e62SShengjiu Wang MODULE_LICENSE("GPL");
330