Fabio Estevam | aa624a0 | 2018-07-24 09:48:30 -0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // |
| 3 | // Freescale Generic ASoC Sound Card driver with ASRC |
| 4 | // |
| 5 | // Copyright (C) 2014 Freescale Semiconductor, Inc. |
| 6 | // |
| 7 | // Author: Nicolin Chen <nicoleotsuka@gmail.com> |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 8 | |
| 9 | #include <linux/clk.h> |
| 10 | #include <linux/i2c.h> |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/of_platform.h> |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 13 | #if IS_ENABLED(CONFIG_SND_AC97_CODEC) |
| 14 | #include <sound/ac97_codec.h> |
| 15 | #endif |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 16 | #include <sound/pcm_params.h> |
| 17 | #include <sound/soc.h> |
| 18 | |
| 19 | #include "fsl_esai.h" |
| 20 | #include "fsl_sai.h" |
| 21 | #include "imx-audmux.h" |
| 22 | |
| 23 | #include "../codecs/sgtl5000.h" |
| 24 | #include "../codecs/wm8962.h" |
Zidan Wang | 50e0ee0 | 2015-08-14 19:11:09 +0800 | [diff] [blame] | 25 | #include "../codecs/wm8960.h" |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 26 | |
Felipe F. Tonello | 57e756d | 2016-01-29 11:01:00 +0000 | [diff] [blame] | 27 | #define CS427x_SYSCLK_MCLK 0 |
| 28 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 29 | #define RX 0 |
| 30 | #define TX 1 |
| 31 | |
| 32 | /* Default DAI format without Master and Slave flag */ |
| 33 | #define DAI_FMT_BASE (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF) |
| 34 | |
| 35 | /** |
| 36 | * CODEC private data |
| 37 | * |
| 38 | * @mclk_freq: Clock rate of MCLK |
| 39 | * @mclk_id: MCLK (or main clock) id for set_sysclk() |
| 40 | * @fll_id: FLL (or secordary clock) id for set_sysclk() |
| 41 | * @pll_id: PLL id for set_pll() |
| 42 | */ |
| 43 | struct codec_priv { |
| 44 | unsigned long mclk_freq; |
| 45 | u32 mclk_id; |
| 46 | u32 fll_id; |
| 47 | u32 pll_id; |
| 48 | }; |
| 49 | |
| 50 | /** |
| 51 | * CPU private data |
| 52 | * |
| 53 | * @sysclk_freq[2]: SYSCLK rates for set_sysclk() |
| 54 | * @sysclk_dir[2]: SYSCLK directions for set_sysclk() |
| 55 | * @sysclk_id[2]: SYSCLK ids for set_sysclk() |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 56 | * @slot_width: Slot width of each frame |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 57 | * |
| 58 | * Note: [1] for tx and [0] for rx |
| 59 | */ |
| 60 | struct cpu_priv { |
| 61 | unsigned long sysclk_freq[2]; |
| 62 | u32 sysclk_dir[2]; |
| 63 | u32 sysclk_id[2]; |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 64 | u32 slot_width; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | /** |
| 68 | * Freescale Generic ASOC card private data |
| 69 | * |
| 70 | * @dai_link[3]: DAI link structure including normal one and DPCM link |
| 71 | * @pdev: platform device pointer |
| 72 | * @codec_priv: CODEC private data |
| 73 | * @cpu_priv: CPU private data |
| 74 | * @card: ASoC card structure |
| 75 | * @sample_rate: Current sample rate |
| 76 | * @sample_format: Current sample format |
| 77 | * @asrc_rate: ASRC sample rate used by Back-Ends |
| 78 | * @asrc_format: ASRC sample format used by Back-Ends |
| 79 | * @dai_fmt: DAI format between CPU and CODEC |
| 80 | * @name: Card name |
| 81 | */ |
| 82 | |
| 83 | struct fsl_asoc_card_priv { |
| 84 | struct snd_soc_dai_link dai_link[3]; |
| 85 | struct platform_device *pdev; |
| 86 | struct codec_priv codec_priv; |
| 87 | struct cpu_priv cpu_priv; |
| 88 | struct snd_soc_card card; |
| 89 | u32 sample_rate; |
Fabio Estevam | fc734c24 | 2018-02-11 19:53:18 -0200 | [diff] [blame] | 90 | snd_pcm_format_t sample_format; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 91 | u32 asrc_rate; |
Fabio Estevam | fc734c24 | 2018-02-11 19:53:18 -0200 | [diff] [blame] | 92 | snd_pcm_format_t asrc_format; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 93 | u32 dai_fmt; |
| 94 | char name[32]; |
| 95 | }; |
| 96 | |
| 97 | /** |
| 98 | * This dapm route map exsits for DPCM link only. |
| 99 | * The other routes shall go through Device Tree. |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 100 | * |
| 101 | * Note: keep all ASRC routes in the second half |
| 102 | * to drop them easily for non-ASRC cases. |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 103 | */ |
| 104 | static const struct snd_soc_dapm_route audio_map[] = { |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 105 | /* 1st half -- Normal DAPM routes */ |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 106 | {"Playback", NULL, "CPU-Playback"}, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 107 | {"CPU-Capture", NULL, "Capture"}, |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 108 | /* 2nd half -- ASRC DAPM routes */ |
| 109 | {"CPU-Playback", NULL, "ASRC-Playback"}, |
| 110 | {"ASRC-Capture", NULL, "CPU-Capture"}, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 111 | }; |
| 112 | |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 113 | static const struct snd_soc_dapm_route audio_map_ac97[] = { |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 114 | /* 1st half -- Normal DAPM routes */ |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 115 | {"Playback", NULL, "AC97 Playback"}, |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 116 | {"AC97 Capture", NULL, "Capture"}, |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 117 | /* 2nd half -- ASRC DAPM routes */ |
| 118 | {"AC97 Playback", NULL, "ASRC-Playback"}, |
| 119 | {"ASRC-Capture", NULL, "AC97 Capture"}, |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 120 | }; |
| 121 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 122 | /* Add all possible widgets into here without being redundant */ |
| 123 | static const struct snd_soc_dapm_widget fsl_asoc_card_dapm_widgets[] = { |
| 124 | SND_SOC_DAPM_LINE("Line Out Jack", NULL), |
| 125 | SND_SOC_DAPM_LINE("Line In Jack", NULL), |
| 126 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 127 | SND_SOC_DAPM_SPK("Ext Spk", NULL), |
| 128 | SND_SOC_DAPM_MIC("Mic Jack", NULL), |
| 129 | SND_SOC_DAPM_MIC("AMIC", NULL), |
| 130 | SND_SOC_DAPM_MIC("DMIC", NULL), |
| 131 | }; |
| 132 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 133 | static bool fsl_asoc_card_is_ac97(struct fsl_asoc_card_priv *priv) |
| 134 | { |
| 135 | return priv->dai_fmt == SND_SOC_DAIFMT_AC97; |
| 136 | } |
| 137 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 138 | static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream, |
| 139 | struct snd_pcm_hw_params *params) |
| 140 | { |
| 141 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 142 | struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); |
| 143 | bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
| 144 | struct cpu_priv *cpu_priv = &priv->cpu_priv; |
| 145 | struct device *dev = rtd->card->dev; |
| 146 | int ret; |
| 147 | |
| 148 | priv->sample_rate = params_rate(params); |
| 149 | priv->sample_format = params_format(params); |
| 150 | |
Nicolin Chen | 4128292 | 2014-10-24 16:48:11 -0700 | [diff] [blame] | 151 | /* |
| 152 | * If codec-dai is DAI Master and all configurations are already in the |
| 153 | * set_bias_level(), bypass the remaining settings in hw_params(). |
| 154 | * Note: (dai_fmt & CBM_CFM) includes CBM_CFM and CBM_CFS. |
| 155 | */ |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 156 | if ((priv->card.set_bias_level && |
| 157 | priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM) || |
| 158 | fsl_asoc_card_is_ac97(priv)) |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 159 | return 0; |
| 160 | |
| 161 | /* Specific configurations of DAIs starts from here */ |
| 162 | ret = snd_soc_dai_set_sysclk(rtd->cpu_dai, cpu_priv->sysclk_id[tx], |
| 163 | cpu_priv->sysclk_freq[tx], |
| 164 | cpu_priv->sysclk_dir[tx]); |
Nicolin Chen | 758a3b0 | 2017-09-07 22:27:33 -0700 | [diff] [blame] | 165 | if (ret && ret != -ENOTSUPP) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 166 | dev_err(dev, "failed to set sysclk for cpu dai\n"); |
| 167 | return ret; |
| 168 | } |
| 169 | |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 170 | if (cpu_priv->slot_width) { |
| 171 | ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, |
| 172 | cpu_priv->slot_width); |
Nicolin Chen | 758a3b0 | 2017-09-07 22:27:33 -0700 | [diff] [blame] | 173 | if (ret && ret != -ENOTSUPP) { |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 174 | dev_err(dev, "failed to set TDM slot for cpu dai\n"); |
| 175 | return ret; |
| 176 | } |
| 177 | } |
| 178 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 179 | return 0; |
| 180 | } |
| 181 | |
Julia Lawall | ddba7fa | 2016-10-15 16:55:50 +0200 | [diff] [blame] | 182 | static const struct snd_soc_ops fsl_asoc_card_ops = { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 183 | .hw_params = fsl_asoc_card_hw_params, |
| 184 | }; |
| 185 | |
| 186 | static int be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 187 | struct snd_pcm_hw_params *params) |
| 188 | { |
| 189 | struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); |
| 190 | struct snd_interval *rate; |
| 191 | struct snd_mask *mask; |
| 192 | |
| 193 | rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); |
| 194 | rate->max = rate->min = priv->asrc_rate; |
| 195 | |
| 196 | mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
| 197 | snd_mask_none(mask); |
Takashi Iwai | ebc22af | 2018-07-25 23:17:20 +0200 | [diff] [blame] | 198 | snd_mask_set_format(mask, priv->asrc_format); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 199 | |
| 200 | return 0; |
| 201 | } |
| 202 | |
| 203 | static struct snd_soc_dai_link fsl_asoc_card_dai[] = { |
| 204 | /* Default ASoC DAI Link*/ |
| 205 | { |
| 206 | .name = "HiFi", |
| 207 | .stream_name = "HiFi", |
| 208 | .ops = &fsl_asoc_card_ops, |
| 209 | }, |
| 210 | /* DPCM Link between Front-End and Back-End (Optional) */ |
| 211 | { |
| 212 | .name = "HiFi-ASRC-FE", |
| 213 | .stream_name = "HiFi-ASRC-FE", |
| 214 | .codec_name = "snd-soc-dummy", |
| 215 | .codec_dai_name = "snd-soc-dummy-dai", |
| 216 | .dpcm_playback = 1, |
| 217 | .dpcm_capture = 1, |
| 218 | .dynamic = 1, |
| 219 | }, |
| 220 | { |
| 221 | .name = "HiFi-ASRC-BE", |
| 222 | .stream_name = "HiFi-ASRC-BE", |
| 223 | .platform_name = "snd-soc-dummy", |
| 224 | .be_hw_params_fixup = be_hw_params_fixup, |
| 225 | .ops = &fsl_asoc_card_ops, |
| 226 | .dpcm_playback = 1, |
| 227 | .dpcm_capture = 1, |
| 228 | .no_pcm = 1, |
| 229 | }, |
| 230 | }; |
| 231 | |
| 232 | static int fsl_asoc_card_set_bias_level(struct snd_soc_card *card, |
| 233 | struct snd_soc_dapm_context *dapm, |
| 234 | enum snd_soc_bias_level level) |
| 235 | { |
| 236 | struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(card); |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 237 | struct snd_soc_pcm_runtime *rtd; |
| 238 | struct snd_soc_dai *codec_dai; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 239 | struct codec_priv *codec_priv = &priv->codec_priv; |
| 240 | struct device *dev = card->dev; |
| 241 | unsigned int pll_out; |
| 242 | int ret; |
| 243 | |
Mengdong Lin | 5015920 | 2015-11-18 02:34:01 -0500 | [diff] [blame] | 244 | rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); |
| 245 | codec_dai = rtd->codec_dai; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 246 | if (dapm->dev != codec_dai->dev) |
| 247 | return 0; |
| 248 | |
| 249 | switch (level) { |
| 250 | case SND_SOC_BIAS_PREPARE: |
| 251 | if (dapm->bias_level != SND_SOC_BIAS_STANDBY) |
| 252 | break; |
| 253 | |
| 254 | if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE) |
| 255 | pll_out = priv->sample_rate * 384; |
| 256 | else |
| 257 | pll_out = priv->sample_rate * 256; |
| 258 | |
| 259 | ret = snd_soc_dai_set_pll(codec_dai, codec_priv->pll_id, |
| 260 | codec_priv->mclk_id, |
| 261 | codec_priv->mclk_freq, pll_out); |
| 262 | if (ret) { |
| 263 | dev_err(dev, "failed to start FLL: %d\n", ret); |
| 264 | return ret; |
| 265 | } |
| 266 | |
| 267 | ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->fll_id, |
| 268 | pll_out, SND_SOC_CLOCK_IN); |
Nicolin Chen | 758a3b0 | 2017-09-07 22:27:33 -0700 | [diff] [blame] | 269 | if (ret && ret != -ENOTSUPP) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 270 | dev_err(dev, "failed to set SYSCLK: %d\n", ret); |
| 271 | return ret; |
| 272 | } |
| 273 | break; |
| 274 | |
| 275 | case SND_SOC_BIAS_STANDBY: |
| 276 | if (dapm->bias_level != SND_SOC_BIAS_PREPARE) |
| 277 | break; |
| 278 | |
| 279 | ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id, |
| 280 | codec_priv->mclk_freq, |
| 281 | SND_SOC_CLOCK_IN); |
Nicolin Chen | 758a3b0 | 2017-09-07 22:27:33 -0700 | [diff] [blame] | 282 | if (ret && ret != -ENOTSUPP) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 283 | dev_err(dev, "failed to switch away from FLL: %d\n", ret); |
| 284 | return ret; |
| 285 | } |
| 286 | |
| 287 | ret = snd_soc_dai_set_pll(codec_dai, codec_priv->pll_id, 0, 0, 0); |
| 288 | if (ret) { |
| 289 | dev_err(dev, "failed to stop FLL: %d\n", ret); |
| 290 | return ret; |
| 291 | } |
| 292 | break; |
| 293 | |
| 294 | default: |
| 295 | break; |
| 296 | } |
| 297 | |
| 298 | return 0; |
| 299 | } |
| 300 | |
| 301 | static int fsl_asoc_card_audmux_init(struct device_node *np, |
| 302 | struct fsl_asoc_card_priv *priv) |
| 303 | { |
| 304 | struct device *dev = &priv->pdev->dev; |
| 305 | u32 int_ptcr = 0, ext_ptcr = 0; |
| 306 | int int_port, ext_port; |
| 307 | int ret; |
| 308 | |
| 309 | ret = of_property_read_u32(np, "mux-int-port", &int_port); |
| 310 | if (ret) { |
| 311 | dev_err(dev, "mux-int-port missing or invalid\n"); |
| 312 | return ret; |
| 313 | } |
| 314 | ret = of_property_read_u32(np, "mux-ext-port", &ext_port); |
| 315 | if (ret) { |
| 316 | dev_err(dev, "mux-ext-port missing or invalid\n"); |
| 317 | return ret; |
| 318 | } |
| 319 | |
| 320 | /* |
| 321 | * The port numbering in the hardware manual starts at 1, while |
| 322 | * the AUDMUX API expects it starts at 0. |
| 323 | */ |
| 324 | int_port--; |
| 325 | ext_port--; |
| 326 | |
| 327 | /* |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 328 | * Use asynchronous mode (6 wires) for all cases except AC97. |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 329 | * If only 4 wires are needed, just set SSI into |
| 330 | * synchronous mode and enable 4 PADs in IOMUX. |
| 331 | */ |
| 332 | switch (priv->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 333 | case SND_SOC_DAIFMT_CBM_CFM: |
| 334 | int_ptcr = IMX_AUDMUX_V2_PTCR_RFSEL(8 | ext_port) | |
| 335 | IMX_AUDMUX_V2_PTCR_RCSEL(8 | ext_port) | |
| 336 | IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) | |
| 337 | IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | |
| 338 | IMX_AUDMUX_V2_PTCR_RFSDIR | |
| 339 | IMX_AUDMUX_V2_PTCR_RCLKDIR | |
| 340 | IMX_AUDMUX_V2_PTCR_TFSDIR | |
| 341 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 342 | break; |
| 343 | case SND_SOC_DAIFMT_CBM_CFS: |
| 344 | int_ptcr = IMX_AUDMUX_V2_PTCR_RCSEL(8 | ext_port) | |
| 345 | IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | |
| 346 | IMX_AUDMUX_V2_PTCR_RCLKDIR | |
| 347 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 348 | ext_ptcr = IMX_AUDMUX_V2_PTCR_RFSEL(8 | int_port) | |
| 349 | IMX_AUDMUX_V2_PTCR_TFSEL(int_port) | |
| 350 | IMX_AUDMUX_V2_PTCR_RFSDIR | |
| 351 | IMX_AUDMUX_V2_PTCR_TFSDIR; |
| 352 | break; |
| 353 | case SND_SOC_DAIFMT_CBS_CFM: |
| 354 | int_ptcr = IMX_AUDMUX_V2_PTCR_RFSEL(8 | ext_port) | |
| 355 | IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) | |
| 356 | IMX_AUDMUX_V2_PTCR_RFSDIR | |
| 357 | IMX_AUDMUX_V2_PTCR_TFSDIR; |
| 358 | ext_ptcr = IMX_AUDMUX_V2_PTCR_RCSEL(8 | int_port) | |
| 359 | IMX_AUDMUX_V2_PTCR_TCSEL(int_port) | |
| 360 | IMX_AUDMUX_V2_PTCR_RCLKDIR | |
| 361 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 362 | break; |
| 363 | case SND_SOC_DAIFMT_CBS_CFS: |
| 364 | ext_ptcr = IMX_AUDMUX_V2_PTCR_RFSEL(8 | int_port) | |
| 365 | IMX_AUDMUX_V2_PTCR_RCSEL(8 | int_port) | |
| 366 | IMX_AUDMUX_V2_PTCR_TFSEL(int_port) | |
| 367 | IMX_AUDMUX_V2_PTCR_TCSEL(int_port) | |
| 368 | IMX_AUDMUX_V2_PTCR_RFSDIR | |
| 369 | IMX_AUDMUX_V2_PTCR_RCLKDIR | |
| 370 | IMX_AUDMUX_V2_PTCR_TFSDIR | |
| 371 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 372 | break; |
| 373 | default: |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 374 | if (!fsl_asoc_card_is_ac97(priv)) |
| 375 | return -EINVAL; |
| 376 | } |
| 377 | |
| 378 | if (fsl_asoc_card_is_ac97(priv)) { |
| 379 | int_ptcr = IMX_AUDMUX_V2_PTCR_SYN | |
| 380 | IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | |
| 381 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 382 | ext_ptcr = IMX_AUDMUX_V2_PTCR_SYN | |
| 383 | IMX_AUDMUX_V2_PTCR_TFSEL(int_port) | |
| 384 | IMX_AUDMUX_V2_PTCR_TFSDIR; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /* Asynchronous mode can not be set along with RCLKDIR */ |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 388 | if (!fsl_asoc_card_is_ac97(priv)) { |
| 389 | unsigned int pdcr = |
| 390 | IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port); |
| 391 | |
| 392 | ret = imx_audmux_v2_configure_port(int_port, 0, |
| 393 | pdcr); |
| 394 | if (ret) { |
| 395 | dev_err(dev, "audmux internal port setup failed\n"); |
| 396 | return ret; |
| 397 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | ret = imx_audmux_v2_configure_port(int_port, int_ptcr, |
| 401 | IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port)); |
| 402 | if (ret) { |
| 403 | dev_err(dev, "audmux internal port setup failed\n"); |
| 404 | return ret; |
| 405 | } |
| 406 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 407 | if (!fsl_asoc_card_is_ac97(priv)) { |
| 408 | unsigned int pdcr = |
| 409 | IMX_AUDMUX_V2_PDCR_RXDSEL(int_port); |
| 410 | |
| 411 | ret = imx_audmux_v2_configure_port(ext_port, 0, |
| 412 | pdcr); |
| 413 | if (ret) { |
| 414 | dev_err(dev, "audmux external port setup failed\n"); |
| 415 | return ret; |
| 416 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | ret = imx_audmux_v2_configure_port(ext_port, ext_ptcr, |
| 420 | IMX_AUDMUX_V2_PDCR_RXDSEL(int_port)); |
| 421 | if (ret) { |
| 422 | dev_err(dev, "audmux external port setup failed\n"); |
| 423 | return ret; |
| 424 | } |
| 425 | |
| 426 | return 0; |
| 427 | } |
| 428 | |
| 429 | static int fsl_asoc_card_late_probe(struct snd_soc_card *card) |
| 430 | { |
| 431 | struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(card); |
Vinod Koul | abd657b | 2015-11-20 22:45:20 +0530 | [diff] [blame] | 432 | struct snd_soc_pcm_runtime *rtd = list_first_entry( |
| 433 | &card->rtd_list, struct snd_soc_pcm_runtime, list); |
| 434 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 435 | struct codec_priv *codec_priv = &priv->codec_priv; |
| 436 | struct device *dev = card->dev; |
| 437 | int ret; |
| 438 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 439 | if (fsl_asoc_card_is_ac97(priv)) { |
| 440 | #if IS_ENABLED(CONFIG_SND_AC97_CODEC) |
Kuninori Morimoto | 845f80c | 2017-12-05 04:23:21 +0000 | [diff] [blame] | 441 | struct snd_soc_component *component = rtd->codec_dai->component; |
| 442 | struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 443 | |
| 444 | /* |
| 445 | * Use slots 3/4 for S/PDIF so SSI won't try to enable |
| 446 | * other slots and send some samples there |
| 447 | * due to SLOTREQ bits for S/PDIF received from codec |
| 448 | */ |
| 449 | snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, |
| 450 | AC97_EA_SPSA_SLOT_MASK, AC97_EA_SPSA_3_4); |
| 451 | #endif |
| 452 | |
| 453 | return 0; |
| 454 | } |
| 455 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 456 | ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id, |
| 457 | codec_priv->mclk_freq, SND_SOC_CLOCK_IN); |
Nicolin Chen | 758a3b0 | 2017-09-07 22:27:33 -0700 | [diff] [blame] | 458 | if (ret && ret != -ENOTSUPP) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 459 | dev_err(dev, "failed to set sysclk in %s\n", __func__); |
| 460 | return ret; |
| 461 | } |
| 462 | |
| 463 | return 0; |
| 464 | } |
| 465 | |
| 466 | static int fsl_asoc_card_probe(struct platform_device *pdev) |
| 467 | { |
| 468 | struct device_node *cpu_np, *codec_np, *asrc_np; |
| 469 | struct device_node *np = pdev->dev.of_node; |
| 470 | struct platform_device *asrc_pdev = NULL; |
| 471 | struct platform_device *cpu_pdev; |
| 472 | struct fsl_asoc_card_priv *priv; |
| 473 | struct i2c_client *codec_dev; |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 474 | const char *codec_dai_name; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 475 | u32 width; |
| 476 | int ret; |
| 477 | |
| 478 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
| 479 | if (!priv) |
| 480 | return -ENOMEM; |
| 481 | |
| 482 | cpu_np = of_parse_phandle(np, "audio-cpu", 0); |
| 483 | /* Give a chance to old DT binding */ |
| 484 | if (!cpu_np) |
| 485 | cpu_np = of_parse_phandle(np, "ssi-controller", 0); |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 486 | if (!cpu_np) { |
| 487 | dev_err(&pdev->dev, "CPU phandle missing or invalid\n"); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 488 | ret = -EINVAL; |
| 489 | goto fail; |
| 490 | } |
| 491 | |
| 492 | cpu_pdev = of_find_device_by_node(cpu_np); |
| 493 | if (!cpu_pdev) { |
| 494 | dev_err(&pdev->dev, "failed to find CPU DAI device\n"); |
| 495 | ret = -EINVAL; |
| 496 | goto fail; |
| 497 | } |
| 498 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 499 | codec_np = of_parse_phandle(np, "audio-codec", 0); |
| 500 | if (codec_np) |
| 501 | codec_dev = of_find_i2c_device_by_node(codec_np); |
| 502 | else |
| 503 | codec_dev = NULL; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 504 | |
| 505 | asrc_np = of_parse_phandle(np, "audio-asrc", 0); |
| 506 | if (asrc_np) |
| 507 | asrc_pdev = of_find_device_by_node(asrc_np); |
| 508 | |
| 509 | /* Get the MCLK rate only, and leave it controlled by CODEC drivers */ |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 510 | if (codec_dev) { |
| 511 | struct clk *codec_clk = clk_get(&codec_dev->dev, NULL); |
| 512 | |
| 513 | if (!IS_ERR(codec_clk)) { |
| 514 | priv->codec_priv.mclk_freq = clk_get_rate(codec_clk); |
| 515 | clk_put(codec_clk); |
| 516 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | /* Default sample rate and format, will be updated in hw_params() */ |
| 520 | priv->sample_rate = 44100; |
| 521 | priv->sample_format = SNDRV_PCM_FORMAT_S16_LE; |
| 522 | |
| 523 | /* Assign a default DAI format, and allow each card to overwrite it */ |
| 524 | priv->dai_fmt = DAI_FMT_BASE; |
| 525 | |
| 526 | /* Diversify the card configurations */ |
| 527 | if (of_device_is_compatible(np, "fsl,imx-audio-cs42888")) { |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 528 | codec_dai_name = "cs42888"; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 529 | priv->card.set_bias_level = NULL; |
| 530 | priv->cpu_priv.sysclk_freq[TX] = priv->codec_priv.mclk_freq; |
| 531 | priv->cpu_priv.sysclk_freq[RX] = priv->codec_priv.mclk_freq; |
| 532 | priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT; |
| 533 | priv->cpu_priv.sysclk_dir[RX] = SND_SOC_CLOCK_OUT; |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 534 | priv->cpu_priv.slot_width = 32; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 535 | priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; |
Felipe F. Tonello | 57e756d | 2016-01-29 11:01:00 +0000 | [diff] [blame] | 536 | } else if (of_device_is_compatible(np, "fsl,imx-audio-cs427x")) { |
| 537 | codec_dai_name = "cs4271-hifi"; |
| 538 | priv->codec_priv.mclk_id = CS427x_SYSCLK_MCLK; |
| 539 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 540 | } else if (of_device_is_compatible(np, "fsl,imx-audio-sgtl5000")) { |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 541 | codec_dai_name = "sgtl5000"; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 542 | priv->codec_priv.mclk_id = SGTL5000_SYSCLK; |
| 543 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
| 544 | } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8962")) { |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 545 | codec_dai_name = "wm8962"; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 546 | priv->card.set_bias_level = fsl_asoc_card_set_bias_level; |
| 547 | priv->codec_priv.mclk_id = WM8962_SYSCLK_MCLK; |
| 548 | priv->codec_priv.fll_id = WM8962_SYSCLK_FLL; |
| 549 | priv->codec_priv.pll_id = WM8962_FLL; |
| 550 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
Zidan Wang | 50e0ee0 | 2015-08-14 19:11:09 +0800 | [diff] [blame] | 551 | } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8960")) { |
| 552 | codec_dai_name = "wm8960-hifi"; |
| 553 | priv->card.set_bias_level = fsl_asoc_card_set_bias_level; |
| 554 | priv->codec_priv.fll_id = WM8960_SYSCLK_AUTO; |
| 555 | priv->codec_priv.pll_id = WM8960_SYSCLK_AUTO; |
| 556 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 557 | } else if (of_device_is_compatible(np, "fsl,imx-audio-ac97")) { |
| 558 | codec_dai_name = "ac97-hifi"; |
| 559 | priv->card.set_bias_level = NULL; |
| 560 | priv->dai_fmt = SND_SOC_DAIFMT_AC97; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 561 | } else { |
| 562 | dev_err(&pdev->dev, "unknown Device Tree compatible\n"); |
Maciej S. Szmigiero | 6bd3c6f | 2015-08-31 17:07:12 +0200 | [diff] [blame] | 563 | ret = -EINVAL; |
| 564 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 565 | } |
| 566 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 567 | if (!fsl_asoc_card_is_ac97(priv) && !codec_dev) { |
| 568 | dev_err(&pdev->dev, "failed to find codec device\n"); |
| 569 | ret = -EINVAL; |
| 570 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | /* Common settings for corresponding Freescale CPU DAI driver */ |
Rob Herring | 1d52a74 | 2018-12-05 13:50:49 -0600 | [diff] [blame] | 574 | if (of_node_name_eq(cpu_np, "ssi")) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 575 | /* Only SSI needs to configure AUDMUX */ |
| 576 | ret = fsl_asoc_card_audmux_init(np, priv); |
| 577 | if (ret) { |
| 578 | dev_err(&pdev->dev, "failed to init audmux\n"); |
Shengjiu Wang | 5f37671 | 2014-08-18 16:38:39 +0800 | [diff] [blame] | 579 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 580 | } |
Rob Herring | 1d52a74 | 2018-12-05 13:50:49 -0600 | [diff] [blame] | 581 | } else if (of_node_name_eq(cpu_np, "esai")) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 582 | priv->cpu_priv.sysclk_id[1] = ESAI_HCKT_EXTAL; |
| 583 | priv->cpu_priv.sysclk_id[0] = ESAI_HCKR_EXTAL; |
Rob Herring | 1d52a74 | 2018-12-05 13:50:49 -0600 | [diff] [blame] | 584 | } else if (of_node_name_eq(cpu_np, "sai")) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 585 | priv->cpu_priv.sysclk_id[1] = FSL_SAI_CLK_MAST1; |
| 586 | priv->cpu_priv.sysclk_id[0] = FSL_SAI_CLK_MAST1; |
| 587 | } |
| 588 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 589 | snprintf(priv->name, sizeof(priv->name), "%s-audio", |
| 590 | fsl_asoc_card_is_ac97(priv) ? "ac97" : |
| 591 | codec_dev->name); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 592 | |
| 593 | /* Initialize sound card */ |
| 594 | priv->pdev = pdev; |
| 595 | priv->card.dev = &pdev->dev; |
| 596 | priv->card.name = priv->name; |
| 597 | priv->card.dai_link = priv->dai_link; |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 598 | priv->card.dapm_routes = fsl_asoc_card_is_ac97(priv) ? |
| 599 | audio_map_ac97 : audio_map; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 600 | priv->card.late_probe = fsl_asoc_card_late_probe; |
| 601 | priv->card.num_dapm_routes = ARRAY_SIZE(audio_map); |
| 602 | priv->card.dapm_widgets = fsl_asoc_card_dapm_widgets; |
| 603 | priv->card.num_dapm_widgets = ARRAY_SIZE(fsl_asoc_card_dapm_widgets); |
| 604 | |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 605 | /* Drop the second half of DAPM routes -- ASRC */ |
| 606 | if (!asrc_pdev) |
| 607 | priv->card.num_dapm_routes /= 2; |
| 608 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 609 | memcpy(priv->dai_link, fsl_asoc_card_dai, |
| 610 | sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link)); |
| 611 | |
Nicolin Chen | 3185878 | 2015-02-14 17:22:50 -0800 | [diff] [blame] | 612 | ret = snd_soc_of_parse_audio_routing(&priv->card, "audio-routing"); |
| 613 | if (ret) { |
| 614 | dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret); |
| 615 | goto asrc_fail; |
| 616 | } |
| 617 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 618 | /* Normal DAI Link */ |
| 619 | priv->dai_link[0].cpu_of_node = cpu_np; |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 620 | priv->dai_link[0].codec_dai_name = codec_dai_name; |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 621 | |
| 622 | if (!fsl_asoc_card_is_ac97(priv)) |
| 623 | priv->dai_link[0].codec_of_node = codec_np; |
| 624 | else { |
| 625 | u32 idx; |
| 626 | |
| 627 | ret = of_property_read_u32(cpu_np, "cell-index", &idx); |
| 628 | if (ret) { |
| 629 | dev_err(&pdev->dev, |
| 630 | "cannot get CPU index property\n"); |
| 631 | goto asrc_fail; |
| 632 | } |
| 633 | |
| 634 | priv->dai_link[0].codec_name = |
| 635 | devm_kasprintf(&pdev->dev, GFP_KERNEL, |
| 636 | "ac97-codec.%u", |
| 637 | (unsigned int)idx); |
Arvind Yadav | 7add71b | 2017-09-21 10:50:03 +0530 | [diff] [blame] | 638 | if (!priv->dai_link[0].codec_name) { |
| 639 | ret = -ENOMEM; |
| 640 | goto asrc_fail; |
| 641 | } |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 642 | } |
| 643 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 644 | priv->dai_link[0].platform_of_node = cpu_np; |
| 645 | priv->dai_link[0].dai_fmt = priv->dai_fmt; |
| 646 | priv->card.num_links = 1; |
| 647 | |
| 648 | if (asrc_pdev) { |
| 649 | /* DPCM DAI Links only if ASRC exsits */ |
| 650 | priv->dai_link[1].cpu_of_node = asrc_np; |
| 651 | priv->dai_link[1].platform_of_node = asrc_np; |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 652 | priv->dai_link[2].codec_dai_name = codec_dai_name; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 653 | priv->dai_link[2].codec_of_node = codec_np; |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 654 | priv->dai_link[2].codec_name = |
| 655 | priv->dai_link[0].codec_name; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 656 | priv->dai_link[2].cpu_of_node = cpu_np; |
| 657 | priv->dai_link[2].dai_fmt = priv->dai_fmt; |
| 658 | priv->card.num_links = 3; |
| 659 | |
| 660 | ret = of_property_read_u32(asrc_np, "fsl,asrc-rate", |
| 661 | &priv->asrc_rate); |
| 662 | if (ret) { |
| 663 | dev_err(&pdev->dev, "failed to get output rate\n"); |
| 664 | ret = -EINVAL; |
Shengjiu Wang | 5f37671 | 2014-08-18 16:38:39 +0800 | [diff] [blame] | 665 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | ret = of_property_read_u32(asrc_np, "fsl,asrc-width", &width); |
| 669 | if (ret) { |
| 670 | dev_err(&pdev->dev, "failed to get output rate\n"); |
| 671 | ret = -EINVAL; |
Shengjiu Wang | 5f37671 | 2014-08-18 16:38:39 +0800 | [diff] [blame] | 672 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | if (width == 24) |
| 676 | priv->asrc_format = SNDRV_PCM_FORMAT_S24_LE; |
| 677 | else |
| 678 | priv->asrc_format = SNDRV_PCM_FORMAT_S16_LE; |
| 679 | } |
| 680 | |
| 681 | /* Finish card registering */ |
| 682 | platform_set_drvdata(pdev, priv); |
| 683 | snd_soc_card_set_drvdata(&priv->card, priv); |
| 684 | |
| 685 | ret = devm_snd_soc_register_card(&pdev->dev, &priv->card); |
Lucas Stach | e5d619e | 2017-08-18 18:33:35 +0200 | [diff] [blame] | 686 | if (ret && ret != -EPROBE_DEFER) |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 687 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); |
| 688 | |
Shengjiu Wang | 5f37671 | 2014-08-18 16:38:39 +0800 | [diff] [blame] | 689 | asrc_fail: |
| 690 | of_node_put(asrc_np); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 691 | of_node_put(codec_np); |
wen yang | 11907e9d | 2019-02-02 14:53:16 +0000 | [diff] [blame^] | 692 | put_device(&cpu_pdev->dev); |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 693 | fail: |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 694 | of_node_put(cpu_np); |
| 695 | |
| 696 | return ret; |
| 697 | } |
| 698 | |
| 699 | static const struct of_device_id fsl_asoc_card_dt_ids[] = { |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 700 | { .compatible = "fsl,imx-audio-ac97", }, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 701 | { .compatible = "fsl,imx-audio-cs42888", }, |
Felipe F. Tonello | 57e756d | 2016-01-29 11:01:00 +0000 | [diff] [blame] | 702 | { .compatible = "fsl,imx-audio-cs427x", }, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 703 | { .compatible = "fsl,imx-audio-sgtl5000", }, |
| 704 | { .compatible = "fsl,imx-audio-wm8962", }, |
Zidan Wang | 50e0ee0 | 2015-08-14 19:11:09 +0800 | [diff] [blame] | 705 | { .compatible = "fsl,imx-audio-wm8960", }, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 706 | {} |
| 707 | }; |
Luis de Bethencourt | 5226f23 | 2015-09-03 12:57:47 +0200 | [diff] [blame] | 708 | MODULE_DEVICE_TABLE(of, fsl_asoc_card_dt_ids); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 709 | |
| 710 | static struct platform_driver fsl_asoc_card_driver = { |
| 711 | .probe = fsl_asoc_card_probe, |
| 712 | .driver = { |
| 713 | .name = "fsl-asoc-card", |
| 714 | .pm = &snd_soc_pm_ops, |
| 715 | .of_match_table = fsl_asoc_card_dt_ids, |
| 716 | }, |
| 717 | }; |
| 718 | module_platform_driver(fsl_asoc_card_driver); |
| 719 | |
| 720 | MODULE_DESCRIPTION("Freescale Generic ASoC Sound Card driver with ASRC"); |
| 721 | MODULE_AUTHOR("Nicolin Chen <nicoleotsuka@gmail.com>"); |
| 722 | MODULE_ALIAS("platform:fsl-asoc-card"); |
| 723 | MODULE_LICENSE("GPL"); |