| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * ASoC machine driver for Snow boards |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or |
|---|
| 5 | | - * modify it under the terms of the GNU General Public License |
|---|
| 6 | | - * version 2 as published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 9 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 11 | | - * General Public License for more details. |
|---|
| 12 | | - */ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | +// |
|---|
| 3 | +// ASoC machine driver for Snow boards |
|---|
| 13 | 4 | |
|---|
| 14 | 5 | #include <linux/clk.h> |
|---|
| 15 | 6 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 23 | 14 | |
|---|
| 24 | 15 | #define FIN_PLL_RATE 24000000 |
|---|
| 25 | 16 | |
|---|
| 17 | +SND_SOC_DAILINK_DEFS(links, |
|---|
| 18 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 19 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 20 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 21 | + |
|---|
| 26 | 22 | struct snow_priv { |
|---|
| 27 | 23 | struct snd_soc_dai_link dai_link; |
|---|
| 28 | 24 | struct clk *clk_i2s_bus; |
|---|
| .. | .. |
|---|
| 34 | 30 | static const unsigned int pll_rate[] = { |
|---|
| 35 | 31 | 73728000U, 67737602U, 49152000U, 45158401U, 32768001U |
|---|
| 36 | 32 | }; |
|---|
| 37 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 33 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 38 | 34 | struct snow_priv *priv = snd_soc_card_get_drvdata(rtd->card); |
|---|
| 39 | 35 | int bfs, psr, rfs, bitwidth; |
|---|
| 40 | 36 | unsigned long int rclk; |
|---|
| .. | .. |
|---|
| 110 | 106 | struct snd_soc_pcm_runtime *rtd; |
|---|
| 111 | 107 | struct snd_soc_dai *codec_dai; |
|---|
| 112 | 108 | |
|---|
| 113 | | - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); |
|---|
| 109 | + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); |
|---|
| 114 | 110 | |
|---|
| 115 | 111 | /* In the multi-codec case codec_dais 0 is MAX98095 and 1 is HDMI. */ |
|---|
| 116 | 112 | if (rtd->num_codecs > 1) |
|---|
| 117 | | - codec_dai = rtd->codec_dais[0]; |
|---|
| 113 | + codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 118 | 114 | else |
|---|
| 119 | | - codec_dai = rtd->codec_dai; |
|---|
| 115 | + codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 120 | 116 | |
|---|
| 121 | 117 | /* Set the MCLK rate for the codec */ |
|---|
| 122 | 118 | return snd_soc_dai_set_sysclk(codec_dai, 0, |
|---|
| .. | .. |
|---|
| 150 | 146 | link->name = "Primary"; |
|---|
| 151 | 147 | link->stream_name = link->name; |
|---|
| 152 | 148 | |
|---|
| 149 | + link->cpus = links_cpus; |
|---|
| 150 | + link->num_cpus = ARRAY_SIZE(links_cpus); |
|---|
| 151 | + link->codecs = links_codecs; |
|---|
| 152 | + link->num_codecs = ARRAY_SIZE(links_codecs); |
|---|
| 153 | + link->platforms = links_platforms; |
|---|
| 154 | + link->num_platforms = ARRAY_SIZE(links_platforms); |
|---|
| 155 | + |
|---|
| 153 | 156 | card->dai_link = link; |
|---|
| 154 | 157 | card->num_links = 1; |
|---|
| 155 | 158 | card->dev = dev; |
|---|
| .. | .. |
|---|
| 160 | 163 | if (cpu) { |
|---|
| 161 | 164 | link->ops = &snow_card_ops; |
|---|
| 162 | 165 | |
|---|
| 163 | | - link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); |
|---|
| 166 | + link->cpus->of_node = of_parse_phandle(cpu, "sound-dai", 0); |
|---|
| 164 | 167 | of_node_put(cpu); |
|---|
| 165 | 168 | |
|---|
| 166 | | - if (!link->cpu_of_node) { |
|---|
| 169 | + if (!link->cpus->of_node) { |
|---|
| 167 | 170 | dev_err(dev, "Failed parsing cpu/sound-dai property\n"); |
|---|
| 168 | 171 | return -EINVAL; |
|---|
| 169 | 172 | } |
|---|
| .. | .. |
|---|
| 173 | 176 | of_node_put(codec); |
|---|
| 174 | 177 | |
|---|
| 175 | 178 | if (ret < 0) { |
|---|
| 176 | | - of_node_put(link->cpu_of_node); |
|---|
| 179 | + of_node_put(link->cpus->of_node); |
|---|
| 177 | 180 | dev_err(dev, "Failed parsing codec node\n"); |
|---|
| 178 | 181 | return ret; |
|---|
| 179 | 182 | } |
|---|
| 180 | 183 | |
|---|
| 181 | | - priv->clk_i2s_bus = of_clk_get_by_name(link->cpu_of_node, |
|---|
| 184 | + priv->clk_i2s_bus = of_clk_get_by_name(link->cpus->of_node, |
|---|
| 182 | 185 | "i2s_opclk0"); |
|---|
| 183 | 186 | if (IS_ERR(priv->clk_i2s_bus)) { |
|---|
| 184 | 187 | snd_soc_of_put_dai_link_codecs(link); |
|---|
| 185 | | - of_node_put(link->cpu_of_node); |
|---|
| 188 | + of_node_put(link->cpus->of_node); |
|---|
| 186 | 189 | return PTR_ERR(priv->clk_i2s_bus); |
|---|
| 187 | 190 | } |
|---|
| 188 | 191 | } else { |
|---|
| 189 | | - link->codec_dai_name = "HiFi", |
|---|
| 192 | + link->codecs->dai_name = "HiFi", |
|---|
| 190 | 193 | |
|---|
| 191 | | - link->cpu_of_node = of_parse_phandle(dev->of_node, |
|---|
| 194 | + link->cpus->of_node = of_parse_phandle(dev->of_node, |
|---|
| 192 | 195 | "samsung,i2s-controller", 0); |
|---|
| 193 | | - if (!link->cpu_of_node) { |
|---|
| 196 | + if (!link->cpus->of_node) { |
|---|
| 194 | 197 | dev_err(dev, "i2s-controller property parse error\n"); |
|---|
| 195 | 198 | return -EINVAL; |
|---|
| 196 | 199 | } |
|---|
| 197 | 200 | |
|---|
| 198 | | - link->codec_of_node = of_parse_phandle(dev->of_node, |
|---|
| 201 | + link->codecs->of_node = of_parse_phandle(dev->of_node, |
|---|
| 199 | 202 | "samsung,audio-codec", 0); |
|---|
| 200 | | - if (!link->codec_of_node) { |
|---|
| 201 | | - of_node_put(link->cpu_of_node); |
|---|
| 203 | + if (!link->codecs->of_node) { |
|---|
| 204 | + of_node_put(link->cpus->of_node); |
|---|
| 202 | 205 | dev_err(dev, "audio-codec property parse error\n"); |
|---|
| 203 | 206 | return -EINVAL; |
|---|
| 204 | 207 | } |
|---|
| 205 | 208 | } |
|---|
| 206 | 209 | |
|---|
| 207 | | - link->platform_of_node = link->cpu_of_node; |
|---|
| 210 | + link->platforms->of_node = link->cpus->of_node; |
|---|
| 208 | 211 | |
|---|
| 209 | 212 | /* Update card-name if provided through DT, else use default name */ |
|---|
| 210 | 213 | snd_soc_of_parse_card_name(card, "samsung,model"); |
|---|
| .. | .. |
|---|
| 212 | 215 | snd_soc_card_set_drvdata(card, priv); |
|---|
| 213 | 216 | |
|---|
| 214 | 217 | ret = devm_snd_soc_register_card(dev, card); |
|---|
| 215 | | - if (ret) { |
|---|
| 216 | | - dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); |
|---|
| 217 | | - return ret; |
|---|
| 218 | | - } |
|---|
| 218 | + if (ret) |
|---|
| 219 | + return dev_err_probe(&pdev->dev, ret, |
|---|
| 220 | + "snd_soc_register_card failed\n"); |
|---|
| 219 | 221 | |
|---|
| 220 | 222 | return ret; |
|---|
| 221 | 223 | } |
|---|
| .. | .. |
|---|
| 225 | 227 | struct snow_priv *priv = platform_get_drvdata(pdev); |
|---|
| 226 | 228 | struct snd_soc_dai_link *link = &priv->dai_link; |
|---|
| 227 | 229 | |
|---|
| 228 | | - of_node_put(link->cpu_of_node); |
|---|
| 229 | | - of_node_put(link->codec_of_node); |
|---|
| 230 | + of_node_put(link->cpus->of_node); |
|---|
| 231 | + of_node_put(link->codecs->of_node); |
|---|
| 230 | 232 | snd_soc_of_put_dai_link_codecs(link); |
|---|
| 231 | 233 | |
|---|
| 232 | 234 | clk_put(priv->clk_i2s_bus); |
|---|