| .. | .. |
|---|
| 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. |
|---|
| 12 | 8 | |
|---|
| 13 | 9 | #include <linux/module.h> |
|---|
| 14 | 10 | #include <linux/interrupt.h> |
|---|
| .. | .. |
|---|
| 102 | 98 | */ |
|---|
| 103 | 99 | static int mpc8610_hpcd_startup(struct snd_pcm_substream *substream) |
|---|
| 104 | 100 | { |
|---|
| 105 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 101 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 106 | 102 | struct mpc8610_hpcd_data *machine_data = |
|---|
| 107 | 103 | container_of(rtd->card, struct mpc8610_hpcd_data, card); |
|---|
| 108 | 104 | struct device *dev = rtd->card->dev; |
|---|
| 109 | 105 | int ret = 0; |
|---|
| 110 | 106 | |
|---|
| 111 | 107 | /* 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); |
|---|
| 113 | 109 | if (ret < 0) { |
|---|
| 114 | 110 | dev_err(dev, "could not set codec driver audio format\n"); |
|---|
| 115 | 111 | return ret; |
|---|
| .. | .. |
|---|
| 119 | 115 | * Tell the codec driver what the MCLK frequency is, and whether it's |
|---|
| 120 | 116 | * a slave or master. |
|---|
| 121 | 117 | */ |
|---|
| 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, |
|---|
| 123 | 119 | machine_data->clk_frequency, |
|---|
| 124 | 120 | machine_data->codec_clk_direction); |
|---|
| 125 | 121 | if (ret < 0) { |
|---|
| .. | .. |
|---|
| 193 | 189 | struct device_node *np = ssi_pdev->dev.of_node; |
|---|
| 194 | 190 | struct device_node *codec_np = NULL; |
|---|
| 195 | 191 | struct mpc8610_hpcd_data *machine_data; |
|---|
| 192 | + struct snd_soc_dai_link_component *comp; |
|---|
| 196 | 193 | int ret = -ENODEV; |
|---|
| 197 | 194 | const char *sprop; |
|---|
| 198 | 195 | const u32 *iprop; |
|---|
| .. | .. |
|---|
| 210 | 207 | goto error_alloc; |
|---|
| 211 | 208 | } |
|---|
| 212 | 209 | |
|---|
| 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); |
|---|
| 214 | 233 | machine_data->dai[0].ops = &mpc8610_hpcd_ops; |
|---|
| 215 | 234 | |
|---|
| 216 | 235 | /* 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; |
|---|
| 218 | 237 | |
|---|
| 219 | 238 | /* 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"; |
|---|
| 221 | 240 | |
|---|
| 222 | 241 | /* We register two DAIs per SSI, one for playback and the other for |
|---|
| 223 | 242 | * capture. Currently, we only support codecs that have one DAI for |
|---|
| .. | .. |
|---|
| 310 | 329 | } |
|---|
| 311 | 330 | |
|---|
| 312 | 331 | /* 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]; |
|---|
| 314 | 333 | ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", |
|---|
| 315 | 334 | &machine_data->dai[0], |
|---|
| 316 | 335 | &machine_data->dma_channel_id[0], |
|---|
| .. | .. |
|---|
| 321 | 340 | } |
|---|
| 322 | 341 | |
|---|
| 323 | 342 | /* 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]; |
|---|
| 325 | 344 | ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", |
|---|
| 326 | 345 | &machine_data->dai[1], |
|---|
| 327 | 346 | &machine_data->dma_channel_id[1], |
|---|
| .. | .. |
|---|
| 407 | 426 | guts_np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts"); |
|---|
| 408 | 427 | if (of_address_to_resource(guts_np, 0, &res)) { |
|---|
| 409 | 428 | pr_err("mpc8610-hpcd: missing/invalid global utilities node\n"); |
|---|
| 429 | + of_node_put(guts_np); |
|---|
| 410 | 430 | return -EINVAL; |
|---|
| 411 | 431 | } |
|---|
| 412 | 432 | guts_phys = res.start; |
|---|
| 433 | + of_node_put(guts_np); |
|---|
| 413 | 434 | |
|---|
| 414 | 435 | return platform_driver_register(&mpc8610_hpcd_driver); |
|---|
| 415 | 436 | } |
|---|