hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/sound/soc/fsl/mpc8610_hpcd.c
....@@ -1,14 +1,10 @@
1
-/**
2
- * Freescale MPC8610HPCD ALSA SoC Machine driver
3
- *
4
- * Author: Timur Tabi <timur@freescale.com>
5
- *
6
- * Copyright 2007-2010 Freescale Semiconductor, Inc.
7
- *
8
- * This file is licensed under the terms of the GNU General Public License
9
- * version 2. This program is licensed "as is" without any warranty of any
10
- * kind, whether express or implied.
11
- */
1
+// SPDX-License-Identifier: GPL-2.0
2
+//
3
+// Freescale MPC8610HPCD ALSA SoC Machine driver
4
+//
5
+// Author: Timur Tabi <timur@freescale.com>
6
+//
7
+// Copyright 2007-2010 Freescale Semiconductor, Inc.
128
139 #include <linux/module.h>
1410 #include <linux/interrupt.h>
....@@ -102,14 +98,14 @@
10298 */
10399 static int mpc8610_hpcd_startup(struct snd_pcm_substream *substream)
104100 {
105
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
101
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
106102 struct mpc8610_hpcd_data *machine_data =
107103 container_of(rtd->card, struct mpc8610_hpcd_data, card);
108104 struct device *dev = rtd->card->dev;
109105 int ret = 0;
110106
111107 /* Tell the codec driver what the serial protocol is. */
112
- ret = snd_soc_dai_set_fmt(rtd->codec_dai, machine_data->dai_format);
108
+ ret = snd_soc_dai_set_fmt(asoc_rtd_to_codec(rtd, 0), machine_data->dai_format);
113109 if (ret < 0) {
114110 dev_err(dev, "could not set codec driver audio format\n");
115111 return ret;
....@@ -119,7 +115,7 @@
119115 * Tell the codec driver what the MCLK frequency is, and whether it's
120116 * a slave or master.
121117 */
122
- ret = snd_soc_dai_set_sysclk(rtd->codec_dai, 0,
118
+ ret = snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0,
123119 machine_data->clk_frequency,
124120 machine_data->codec_clk_direction);
125121 if (ret < 0) {
....@@ -193,6 +189,7 @@
193189 struct device_node *np = ssi_pdev->dev.of_node;
194190 struct device_node *codec_np = NULL;
195191 struct mpc8610_hpcd_data *machine_data;
192
+ struct snd_soc_dai_link_component *comp;
196193 int ret = -ENODEV;
197194 const char *sprop;
198195 const u32 *iprop;
....@@ -210,14 +207,36 @@
210207 goto error_alloc;
211208 }
212209
213
- machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
210
+ comp = devm_kzalloc(&pdev->dev, 6 * sizeof(*comp), GFP_KERNEL);
211
+ if (!comp) {
212
+ ret = -ENOMEM;
213
+ goto error_alloc;
214
+ }
215
+
216
+ machine_data->dai[0].cpus = &comp[0];
217
+ machine_data->dai[0].codecs = &comp[1];
218
+ machine_data->dai[0].platforms = &comp[2];
219
+
220
+ machine_data->dai[0].num_cpus = 1;
221
+ machine_data->dai[0].num_codecs = 1;
222
+ machine_data->dai[0].num_platforms = 1;
223
+
224
+ machine_data->dai[1].cpus = &comp[3];
225
+ machine_data->dai[1].codecs = &comp[4];
226
+ machine_data->dai[1].platforms = &comp[5];
227
+
228
+ machine_data->dai[1].num_cpus = 1;
229
+ machine_data->dai[1].num_codecs = 1;
230
+ machine_data->dai[1].num_platforms = 1;
231
+
232
+ machine_data->dai[0].cpus->dai_name = dev_name(&ssi_pdev->dev);
214233 machine_data->dai[0].ops = &mpc8610_hpcd_ops;
215234
216235 /* ASoC core can match codec with device node */
217
- machine_data->dai[0].codec_of_node = codec_np;
236
+ machine_data->dai[0].codecs->of_node = codec_np;
218237
219238 /* The DAI name from the codec (snd_soc_dai_driver.name) */
220
- machine_data->dai[0].codec_dai_name = "cs4270-hifi";
239
+ machine_data->dai[0].codecs->dai_name = "cs4270-hifi";
221240
222241 /* We register two DAIs per SSI, one for playback and the other for
223242 * capture. Currently, we only support codecs that have one DAI for
....@@ -310,7 +329,7 @@
310329 }
311330
312331 /* Find the playback DMA channel to use. */
313
- machine_data->dai[0].platform_name = machine_data->platform_name[0];
332
+ machine_data->dai[0].platforms->name = machine_data->platform_name[0];
314333 ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma",
315334 &machine_data->dai[0],
316335 &machine_data->dma_channel_id[0],
....@@ -321,7 +340,7 @@
321340 }
322341
323342 /* Find the capture DMA channel to use. */
324
- machine_data->dai[1].platform_name = machine_data->platform_name[1];
343
+ machine_data->dai[1].platforms->name = machine_data->platform_name[1];
325344 ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma",
326345 &machine_data->dai[1],
327346 &machine_data->dma_channel_id[1],
....@@ -407,9 +426,11 @@
407426 guts_np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts");
408427 if (of_address_to_resource(guts_np, 0, &res)) {
409428 pr_err("mpc8610-hpcd: missing/invalid global utilities node\n");
429
+ of_node_put(guts_np);
410430 return -EINVAL;
411431 }
412432 guts_phys = res.start;
433
+ of_node_put(guts_np);
413434
414435 return platform_driver_register(&mpc8610_hpcd_driver);
415436 }