| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * eukrea-tlv320.c -- SoC audio for eukrea_cpuimxXX in I2S mode |
|---|
| 3 | | - * |
|---|
| 4 | | - * Copyright 2010 Eric Bénard, Eukréa Electromatique <eric@eukrea.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * based on sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c |
|---|
| 7 | | - * which is Copyright 2009 Simtec Electronics |
|---|
| 8 | | - * and on sound/soc/imx/phycore-ac97.c which is |
|---|
| 9 | | - * Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 12 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 13 | | - * Free Software Foundation; either version 2 of the License, or (at your |
|---|
| 14 | | - * option) any later version. |
|---|
| 15 | | - * |
|---|
| 16 | | - */ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 2 | +// |
|---|
| 3 | +// eukrea-tlv320.c -- SoC audio for eukrea_cpuimxXX in I2S mode |
|---|
| 4 | +// |
|---|
| 5 | +// Copyright 2010 Eric Bénard, Eukréa Electromatique <eric@eukrea.com> |
|---|
| 6 | +// |
|---|
| 7 | +// based on sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c |
|---|
| 8 | +// which is Copyright 2009 Simtec Electronics |
|---|
| 9 | +// and on sound/soc/imx/phycore-ac97.c which is |
|---|
| 10 | +// Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> |
|---|
| 17 | 11 | |
|---|
| 18 | 12 | #include <linux/errno.h> |
|---|
| 19 | 13 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 36 | 30 | static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream, |
|---|
| 37 | 31 | struct snd_pcm_hw_params *params) |
|---|
| 38 | 32 | { |
|---|
| 39 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 40 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
|---|
| 41 | | - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
|---|
| 33 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 34 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 35 | + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); |
|---|
| 42 | 36 | int ret; |
|---|
| 43 | 37 | |
|---|
| 44 | 38 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, |
|---|
| .. | .. |
|---|
| 67 | 61 | .hw_params = eukrea_tlv320_hw_params, |
|---|
| 68 | 62 | }; |
|---|
| 69 | 63 | |
|---|
| 64 | +SND_SOC_DAILINK_DEFS(hifi, |
|---|
| 65 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 66 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "tlv320aic23-hifi")), |
|---|
| 67 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 68 | + |
|---|
| 70 | 69 | static struct snd_soc_dai_link eukrea_tlv320_dai = { |
|---|
| 71 | 70 | .name = "tlv320aic23", |
|---|
| 72 | 71 | .stream_name = "TLV320AIC23", |
|---|
| 73 | | - .codec_dai_name = "tlv320aic23-hifi", |
|---|
| 74 | 72 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
|---|
| 75 | 73 | SND_SOC_DAIFMT_CBM_CFM, |
|---|
| 76 | 74 | .ops = &eukrea_tlv320_snd_ops, |
|---|
| 75 | + SND_SOC_DAILINK_REG(hifi), |
|---|
| 77 | 76 | }; |
|---|
| 78 | 77 | |
|---|
| 79 | 78 | static struct snd_soc_card eukrea_tlv320 = { |
|---|
| .. | .. |
|---|
| 87 | 86 | int ret; |
|---|
| 88 | 87 | int int_port = 0, ext_port; |
|---|
| 89 | 88 | struct device_node *np = pdev->dev.of_node; |
|---|
| 90 | | - struct device_node *ssi_np = NULL, *codec_np = NULL; |
|---|
| 89 | + struct device_node *ssi_np = NULL, *codec_np = NULL, *tmp_np = NULL; |
|---|
| 91 | 90 | |
|---|
| 92 | 91 | eukrea_tlv320.dev = &pdev->dev; |
|---|
| 93 | 92 | if (np) { |
|---|
| .. | .. |
|---|
| 110 | 109 | |
|---|
| 111 | 110 | codec_np = of_parse_phandle(ssi_np, "codec-handle", 0); |
|---|
| 112 | 111 | if (codec_np) |
|---|
| 113 | | - eukrea_tlv320_dai.codec_of_node = codec_np; |
|---|
| 112 | + eukrea_tlv320_dai.codecs->of_node = codec_np; |
|---|
| 114 | 113 | else |
|---|
| 115 | 114 | dev_err(&pdev->dev, "codec-handle node missing or invalid.\n"); |
|---|
| 116 | 115 | |
|---|
| .. | .. |
|---|
| 134 | 133 | int_port--; |
|---|
| 135 | 134 | ext_port--; |
|---|
| 136 | 135 | |
|---|
| 137 | | - eukrea_tlv320_dai.cpu_of_node = ssi_np; |
|---|
| 138 | | - eukrea_tlv320_dai.platform_of_node = ssi_np; |
|---|
| 136 | + eukrea_tlv320_dai.cpus->of_node = ssi_np; |
|---|
| 137 | + eukrea_tlv320_dai.platforms->of_node = ssi_np; |
|---|
| 139 | 138 | } else { |
|---|
| 140 | | - eukrea_tlv320_dai.cpu_dai_name = "imx-ssi.0"; |
|---|
| 141 | | - eukrea_tlv320_dai.platform_name = "imx-ssi.0"; |
|---|
| 142 | | - eukrea_tlv320_dai.codec_name = "tlv320aic23-codec.0-001a"; |
|---|
| 139 | + eukrea_tlv320_dai.cpus->dai_name = "imx-ssi.0"; |
|---|
| 140 | + eukrea_tlv320_dai.platforms->name = "imx-ssi.0"; |
|---|
| 141 | + eukrea_tlv320_dai.codecs->name = "tlv320aic23-codec.0-001a"; |
|---|
| 143 | 142 | eukrea_tlv320.name = "cpuimx-audio"; |
|---|
| 144 | 143 | } |
|---|
| 145 | 144 | |
|---|
| 146 | 145 | if (machine_is_eukrea_cpuimx27() || |
|---|
| 147 | | - of_find_compatible_node(NULL, NULL, "fsl,imx21-audmux")) { |
|---|
| 146 | + (tmp_np = of_find_compatible_node(NULL, NULL, "fsl,imx21-audmux"))) { |
|---|
| 148 | 147 | imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, |
|---|
| 149 | 148 | IMX_AUDMUX_V1_PCR_SYN | |
|---|
| 150 | 149 | IMX_AUDMUX_V1_PCR_TFSDIR | |
|---|
| .. | .. |
|---|
| 159 | 158 | IMX_AUDMUX_V1_PCR_SYN | |
|---|
| 160 | 159 | IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) |
|---|
| 161 | 160 | ); |
|---|
| 161 | + of_node_put(tmp_np); |
|---|
| 162 | 162 | } else if (machine_is_eukrea_cpuimx25sd() || |
|---|
| 163 | 163 | machine_is_eukrea_cpuimx35sd() || |
|---|
| 164 | 164 | machine_is_eukrea_cpuimx51sd() || |
|---|
| 165 | | - of_find_compatible_node(NULL, NULL, "fsl,imx31-audmux")) { |
|---|
| 165 | + (tmp_np = of_find_compatible_node(NULL, NULL, "fsl,imx31-audmux"))) { |
|---|
| 166 | 166 | if (!np) |
|---|
| 167 | 167 | ext_port = machine_is_eukrea_cpuimx25sd() ? |
|---|
| 168 | 168 | 4 : 3; |
|---|
| .. | .. |
|---|
| 179 | 179 | IMX_AUDMUX_V2_PTCR_SYN, |
|---|
| 180 | 180 | IMX_AUDMUX_V2_PDCR_RXDSEL(int_port) |
|---|
| 181 | 181 | ); |
|---|
| 182 | + of_node_put(tmp_np); |
|---|
| 182 | 183 | } else { |
|---|
| 183 | 184 | if (np) { |
|---|
| 184 | 185 | /* The eukrea,asoc-tlv320 driver was explicitly |
|---|