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> |
Shengjiu Wang | 3b17119 | 2020-07-15 22:09:39 +0800 | [diff] [blame] | 18 | #include <sound/jack.h> |
| 19 | #include <sound/simple_card_utils.h> |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 20 | |
| 21 | #include "fsl_esai.h" |
| 22 | #include "fsl_sai.h" |
| 23 | #include "imx-audmux.h" |
| 24 | |
| 25 | #include "../codecs/sgtl5000.h" |
| 26 | #include "../codecs/wm8962.h" |
Zidan Wang | 50e0ee0 | 2015-08-14 19:11:09 +0800 | [diff] [blame] | 27 | #include "../codecs/wm8960.h" |
Shengjiu Wang | efd0b16 | 2021-03-17 21:05:02 +0800 | [diff] [blame] | 28 | #include "../codecs/wm8994.h" |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 29 | |
Felipe F. Tonello | 57e756d | 2016-01-29 11:01:00 +0000 | [diff] [blame] | 30 | #define CS427x_SYSCLK_MCLK 0 |
| 31 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 32 | #define RX 0 |
| 33 | #define TX 1 |
| 34 | |
| 35 | /* Default DAI format without Master and Slave flag */ |
| 36 | #define DAI_FMT_BASE (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF) |
| 37 | |
| 38 | /** |
Pierre-Louis Bossart | 31deacf | 2020-07-02 14:21:38 -0500 | [diff] [blame] | 39 | * struct codec_priv - CODEC private data |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 40 | * @mclk_freq: Clock rate of MCLK |
Shengjiu Wang | efd0b16 | 2021-03-17 21:05:02 +0800 | [diff] [blame] | 41 | * @free_freq: Clock rate of MCLK for hw_free() |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 42 | * @mclk_id: MCLK (or main clock) id for set_sysclk() |
| 43 | * @fll_id: FLL (or secordary clock) id for set_sysclk() |
| 44 | * @pll_id: PLL id for set_pll() |
| 45 | */ |
| 46 | struct codec_priv { |
| 47 | unsigned long mclk_freq; |
Shengjiu Wang | efd0b16 | 2021-03-17 21:05:02 +0800 | [diff] [blame] | 48 | unsigned long free_freq; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 49 | u32 mclk_id; |
| 50 | u32 fll_id; |
| 51 | u32 pll_id; |
| 52 | }; |
| 53 | |
| 54 | /** |
Pierre-Louis Bossart | 31deacf | 2020-07-02 14:21:38 -0500 | [diff] [blame] | 55 | * struct cpu_priv - CPU private data |
| 56 | * @sysclk_freq: SYSCLK rates for set_sysclk() |
| 57 | * @sysclk_dir: SYSCLK directions for set_sysclk() |
| 58 | * @sysclk_id: SYSCLK ids for set_sysclk() |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 59 | * @slot_width: Slot width of each frame |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 60 | * |
| 61 | * Note: [1] for tx and [0] for rx |
| 62 | */ |
| 63 | struct cpu_priv { |
| 64 | unsigned long sysclk_freq[2]; |
| 65 | u32 sysclk_dir[2]; |
| 66 | u32 sysclk_id[2]; |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 67 | u32 slot_width; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | /** |
Pierre-Louis Bossart | 31deacf | 2020-07-02 14:21:38 -0500 | [diff] [blame] | 71 | * struct fsl_asoc_card_priv - Freescale Generic ASOC card private data |
| 72 | * @dai_link: DAI link structure including normal one and DPCM link |
Shengjiu Wang | 3b17119 | 2020-07-15 22:09:39 +0800 | [diff] [blame] | 73 | * @hp_jack: Headphone Jack structure |
| 74 | * @mic_jack: Microphone Jack structure |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 75 | * @pdev: platform device pointer |
| 76 | * @codec_priv: CODEC private data |
| 77 | * @cpu_priv: CPU private data |
| 78 | * @card: ASoC card structure |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 79 | * @streams: Mask of current active streams |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 80 | * @sample_rate: Current sample rate |
| 81 | * @sample_format: Current sample format |
| 82 | * @asrc_rate: ASRC sample rate used by Back-Ends |
| 83 | * @asrc_format: ASRC sample format used by Back-Ends |
| 84 | * @dai_fmt: DAI format between CPU and CODEC |
| 85 | * @name: Card name |
| 86 | */ |
| 87 | |
| 88 | struct fsl_asoc_card_priv { |
| 89 | struct snd_soc_dai_link dai_link[3]; |
Shengjiu Wang | 3b17119 | 2020-07-15 22:09:39 +0800 | [diff] [blame] | 90 | struct asoc_simple_jack hp_jack; |
| 91 | struct asoc_simple_jack mic_jack; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 92 | struct platform_device *pdev; |
| 93 | struct codec_priv codec_priv; |
| 94 | struct cpu_priv cpu_priv; |
| 95 | struct snd_soc_card card; |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 96 | u8 streams; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 97 | u32 sample_rate; |
Fabio Estevam | fc734c24 | 2018-02-11 19:53:18 -0200 | [diff] [blame] | 98 | snd_pcm_format_t sample_format; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 99 | u32 asrc_rate; |
Fabio Estevam | fc734c24 | 2018-02-11 19:53:18 -0200 | [diff] [blame] | 100 | snd_pcm_format_t asrc_format; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 101 | u32 dai_fmt; |
| 102 | char name[32]; |
| 103 | }; |
| 104 | |
Pierre-Louis Bossart | 31deacf | 2020-07-02 14:21:38 -0500 | [diff] [blame] | 105 | /* |
Lee Jones | 1b58214 | 2020-07-15 16:00:09 +0100 | [diff] [blame] | 106 | * This dapm route map exists for DPCM link only. |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 107 | * The other routes shall go through Device Tree. |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 108 | * |
| 109 | * Note: keep all ASRC routes in the second half |
| 110 | * to drop them easily for non-ASRC cases. |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 111 | */ |
| 112 | static const struct snd_soc_dapm_route audio_map[] = { |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 113 | /* 1st half -- Normal DAPM routes */ |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 114 | {"Playback", NULL, "CPU-Playback"}, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 115 | {"CPU-Capture", NULL, "Capture"}, |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 116 | /* 2nd half -- ASRC DAPM routes */ |
| 117 | {"CPU-Playback", NULL, "ASRC-Playback"}, |
| 118 | {"ASRC-Capture", NULL, "CPU-Capture"}, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 119 | }; |
| 120 | |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 121 | static const struct snd_soc_dapm_route audio_map_ac97[] = { |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 122 | /* 1st half -- Normal DAPM routes */ |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 123 | {"Playback", NULL, "AC97 Playback"}, |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 124 | {"AC97 Capture", NULL, "Capture"}, |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 125 | /* 2nd half -- ASRC DAPM routes */ |
| 126 | {"AC97 Playback", NULL, "ASRC-Playback"}, |
| 127 | {"ASRC-Capture", NULL, "AC97 Capture"}, |
Maciej S. Szmigiero | 25e5ef9 | 2015-12-20 21:34:29 +0100 | [diff] [blame] | 128 | }; |
| 129 | |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 130 | static const struct snd_soc_dapm_route audio_map_tx[] = { |
| 131 | /* 1st half -- Normal DAPM routes */ |
| 132 | {"Playback", NULL, "CPU-Playback"}, |
| 133 | /* 2nd half -- ASRC DAPM routes */ |
| 134 | {"CPU-Playback", NULL, "ASRC-Playback"}, |
| 135 | }; |
| 136 | |
Shengjiu Wang | 77f1ff75 | 2020-11-30 11:57:47 +0800 | [diff] [blame] | 137 | static const struct snd_soc_dapm_route audio_map_rx[] = { |
| 138 | /* 1st half -- Normal DAPM routes */ |
| 139 | {"CPU-Capture", NULL, "Capture"}, |
| 140 | /* 2nd half -- ASRC DAPM routes */ |
| 141 | {"ASRC-Capture", NULL, "CPU-Capture"}, |
| 142 | }; |
| 143 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 144 | /* Add all possible widgets into here without being redundant */ |
| 145 | static const struct snd_soc_dapm_widget fsl_asoc_card_dapm_widgets[] = { |
| 146 | SND_SOC_DAPM_LINE("Line Out Jack", NULL), |
| 147 | SND_SOC_DAPM_LINE("Line In Jack", NULL), |
| 148 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 149 | SND_SOC_DAPM_SPK("Ext Spk", NULL), |
| 150 | SND_SOC_DAPM_MIC("Mic Jack", NULL), |
| 151 | SND_SOC_DAPM_MIC("AMIC", NULL), |
| 152 | SND_SOC_DAPM_MIC("DMIC", NULL), |
| 153 | }; |
| 154 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 155 | static bool fsl_asoc_card_is_ac97(struct fsl_asoc_card_priv *priv) |
| 156 | { |
| 157 | return priv->dai_fmt == SND_SOC_DAIFMT_AC97; |
| 158 | } |
| 159 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 160 | static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream, |
| 161 | struct snd_pcm_hw_params *params) |
| 162 | { |
Kuninori Morimoto | 9f5f078 | 2020-07-20 10:18:38 +0900 | [diff] [blame] | 163 | struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 164 | struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); |
| 165 | bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 166 | struct codec_priv *codec_priv = &priv->codec_priv; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 167 | struct cpu_priv *cpu_priv = &priv->cpu_priv; |
| 168 | struct device *dev = rtd->card->dev; |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 169 | unsigned int pll_out; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 170 | int ret; |
| 171 | |
| 172 | priv->sample_rate = params_rate(params); |
| 173 | priv->sample_format = params_format(params); |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 174 | priv->streams |= BIT(substream->stream); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 175 | |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 176 | if (fsl_asoc_card_is_ac97(priv)) |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 177 | return 0; |
| 178 | |
| 179 | /* Specific configurations of DAIs starts from here */ |
Kuninori Morimoto | 17198ae | 2020-03-23 14:18:30 +0900 | [diff] [blame] | 180 | ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0), cpu_priv->sysclk_id[tx], |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 181 | cpu_priv->sysclk_freq[tx], |
| 182 | cpu_priv->sysclk_dir[tx]); |
Nicolin Chen | 758a3b0 | 2017-09-07 22:27:33 -0700 | [diff] [blame] | 183 | if (ret && ret != -ENOTSUPP) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 184 | dev_err(dev, "failed to set sysclk for cpu dai\n"); |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 185 | goto fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 186 | } |
| 187 | |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 188 | if (cpu_priv->slot_width) { |
Kuninori Morimoto | 17198ae | 2020-03-23 14:18:30 +0900 | [diff] [blame] | 189 | ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), 0x3, 0x3, 2, |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 190 | cpu_priv->slot_width); |
Nicolin Chen | 758a3b0 | 2017-09-07 22:27:33 -0700 | [diff] [blame] | 191 | if (ret && ret != -ENOTSUPP) { |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 192 | dev_err(dev, "failed to set TDM slot for cpu dai\n"); |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 193 | goto fail; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /* Specific configuration for PLL */ |
| 198 | if (codec_priv->pll_id && codec_priv->fll_id) { |
| 199 | if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE) |
| 200 | pll_out = priv->sample_rate * 384; |
| 201 | else |
| 202 | pll_out = priv->sample_rate * 256; |
| 203 | |
| 204 | ret = snd_soc_dai_set_pll(asoc_rtd_to_codec(rtd, 0), |
| 205 | codec_priv->pll_id, |
| 206 | codec_priv->mclk_id, |
| 207 | codec_priv->mclk_freq, pll_out); |
| 208 | if (ret) { |
| 209 | dev_err(dev, "failed to start FLL: %d\n", ret); |
| 210 | goto fail; |
| 211 | } |
| 212 | |
| 213 | ret = snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), |
| 214 | codec_priv->fll_id, |
| 215 | pll_out, SND_SOC_CLOCK_IN); |
| 216 | |
| 217 | if (ret && ret != -ENOTSUPP) { |
| 218 | dev_err(dev, "failed to set SYSCLK: %d\n", ret); |
| 219 | goto fail; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | return 0; |
| 224 | |
| 225 | fail: |
| 226 | priv->streams &= ~BIT(substream->stream); |
| 227 | return ret; |
| 228 | } |
| 229 | |
| 230 | static int fsl_asoc_card_hw_free(struct snd_pcm_substream *substream) |
| 231 | { |
| 232 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 233 | struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); |
| 234 | struct codec_priv *codec_priv = &priv->codec_priv; |
| 235 | struct device *dev = rtd->card->dev; |
| 236 | int ret; |
| 237 | |
| 238 | priv->streams &= ~BIT(substream->stream); |
| 239 | |
| 240 | if (!priv->streams && codec_priv->pll_id && codec_priv->fll_id) { |
Shengjiu Wang | efd0b16 | 2021-03-17 21:05:02 +0800 | [diff] [blame] | 241 | /* Force freq to be free_freq to avoid error message in codec */ |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 242 | ret = snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), |
| 243 | codec_priv->mclk_id, |
Shengjiu Wang | efd0b16 | 2021-03-17 21:05:02 +0800 | [diff] [blame] | 244 | codec_priv->free_freq, |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 245 | SND_SOC_CLOCK_IN); |
| 246 | if (ret) { |
| 247 | dev_err(dev, "failed to switch away from FLL: %d\n", ret); |
| 248 | return ret; |
| 249 | } |
| 250 | |
| 251 | ret = snd_soc_dai_set_pll(asoc_rtd_to_codec(rtd, 0), |
| 252 | codec_priv->pll_id, 0, 0, 0); |
| 253 | if (ret && ret != -ENOTSUPP) { |
| 254 | dev_err(dev, "failed to stop FLL: %d\n", ret); |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 255 | return ret; |
| 256 | } |
| 257 | } |
| 258 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 259 | return 0; |
| 260 | } |
| 261 | |
Julia Lawall | ddba7fa | 2016-10-15 16:55:50 +0200 | [diff] [blame] | 262 | static const struct snd_soc_ops fsl_asoc_card_ops = { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 263 | .hw_params = fsl_asoc_card_hw_params, |
Shengjiu Wang | f36e8ed | 2020-08-03 10:13:31 +0800 | [diff] [blame] | 264 | .hw_free = fsl_asoc_card_hw_free, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 265 | }; |
| 266 | |
| 267 | static int be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 268 | struct snd_pcm_hw_params *params) |
| 269 | { |
| 270 | struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); |
| 271 | struct snd_interval *rate; |
| 272 | struct snd_mask *mask; |
| 273 | |
| 274 | rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); |
| 275 | rate->max = rate->min = priv->asrc_rate; |
| 276 | |
| 277 | mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
| 278 | snd_mask_none(mask); |
Takashi Iwai | ebc22af | 2018-07-25 23:17:20 +0200 | [diff] [blame] | 279 | snd_mask_set_format(mask, priv->asrc_format); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 280 | |
| 281 | return 0; |
| 282 | } |
| 283 | |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 284 | SND_SOC_DAILINK_DEFS(hifi, |
| 285 | DAILINK_COMP_ARRAY(COMP_EMPTY()), |
Kuninori Morimoto | 9998d3e | 2019-06-28 10:47:18 +0900 | [diff] [blame] | 286 | DAILINK_COMP_ARRAY(COMP_EMPTY()), |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 287 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 288 | |
| 289 | SND_SOC_DAILINK_DEFS(hifi_fe, |
| 290 | DAILINK_COMP_ARRAY(COMP_EMPTY()), |
Kuninori Morimoto | 9998d3e | 2019-06-28 10:47:18 +0900 | [diff] [blame] | 291 | DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 292 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 293 | |
| 294 | SND_SOC_DAILINK_DEFS(hifi_be, |
| 295 | DAILINK_COMP_ARRAY(COMP_EMPTY()), |
| 296 | DAILINK_COMP_ARRAY(COMP_EMPTY()), |
| 297 | DAILINK_COMP_ARRAY(COMP_DUMMY())); |
| 298 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 299 | static struct snd_soc_dai_link fsl_asoc_card_dai[] = { |
| 300 | /* Default ASoC DAI Link*/ |
| 301 | { |
| 302 | .name = "HiFi", |
| 303 | .stream_name = "HiFi", |
| 304 | .ops = &fsl_asoc_card_ops, |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 305 | SND_SOC_DAILINK_REG(hifi), |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 306 | }, |
| 307 | /* DPCM Link between Front-End and Back-End (Optional) */ |
| 308 | { |
| 309 | .name = "HiFi-ASRC-FE", |
| 310 | .stream_name = "HiFi-ASRC-FE", |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 311 | .dpcm_playback = 1, |
| 312 | .dpcm_capture = 1, |
| 313 | .dynamic = 1, |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 314 | SND_SOC_DAILINK_REG(hifi_fe), |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 315 | }, |
| 316 | { |
| 317 | .name = "HiFi-ASRC-BE", |
| 318 | .stream_name = "HiFi-ASRC-BE", |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 319 | .be_hw_params_fixup = be_hw_params_fixup, |
| 320 | .ops = &fsl_asoc_card_ops, |
| 321 | .dpcm_playback = 1, |
| 322 | .dpcm_capture = 1, |
| 323 | .no_pcm = 1, |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 324 | SND_SOC_DAILINK_REG(hifi_be), |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 325 | }, |
| 326 | }; |
| 327 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 328 | static int fsl_asoc_card_audmux_init(struct device_node *np, |
| 329 | struct fsl_asoc_card_priv *priv) |
| 330 | { |
| 331 | struct device *dev = &priv->pdev->dev; |
| 332 | u32 int_ptcr = 0, ext_ptcr = 0; |
| 333 | int int_port, ext_port; |
| 334 | int ret; |
| 335 | |
| 336 | ret = of_property_read_u32(np, "mux-int-port", &int_port); |
| 337 | if (ret) { |
| 338 | dev_err(dev, "mux-int-port missing or invalid\n"); |
| 339 | return ret; |
| 340 | } |
| 341 | ret = of_property_read_u32(np, "mux-ext-port", &ext_port); |
| 342 | if (ret) { |
| 343 | dev_err(dev, "mux-ext-port missing or invalid\n"); |
| 344 | return ret; |
| 345 | } |
| 346 | |
| 347 | /* |
| 348 | * The port numbering in the hardware manual starts at 1, while |
| 349 | * the AUDMUX API expects it starts at 0. |
| 350 | */ |
| 351 | int_port--; |
| 352 | ext_port--; |
| 353 | |
| 354 | /* |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 355 | * Use asynchronous mode (6 wires) for all cases except AC97. |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 356 | * If only 4 wires are needed, just set SSI into |
| 357 | * synchronous mode and enable 4 PADs in IOMUX. |
| 358 | */ |
| 359 | switch (priv->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 360 | case SND_SOC_DAIFMT_CBM_CFM: |
| 361 | int_ptcr = IMX_AUDMUX_V2_PTCR_RFSEL(8 | ext_port) | |
| 362 | IMX_AUDMUX_V2_PTCR_RCSEL(8 | ext_port) | |
| 363 | IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) | |
| 364 | IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | |
| 365 | IMX_AUDMUX_V2_PTCR_RFSDIR | |
| 366 | IMX_AUDMUX_V2_PTCR_RCLKDIR | |
| 367 | IMX_AUDMUX_V2_PTCR_TFSDIR | |
| 368 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 369 | break; |
| 370 | case SND_SOC_DAIFMT_CBM_CFS: |
| 371 | int_ptcr = IMX_AUDMUX_V2_PTCR_RCSEL(8 | ext_port) | |
| 372 | IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | |
| 373 | IMX_AUDMUX_V2_PTCR_RCLKDIR | |
| 374 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 375 | ext_ptcr = IMX_AUDMUX_V2_PTCR_RFSEL(8 | int_port) | |
| 376 | IMX_AUDMUX_V2_PTCR_TFSEL(int_port) | |
| 377 | IMX_AUDMUX_V2_PTCR_RFSDIR | |
| 378 | IMX_AUDMUX_V2_PTCR_TFSDIR; |
| 379 | break; |
| 380 | case SND_SOC_DAIFMT_CBS_CFM: |
| 381 | int_ptcr = IMX_AUDMUX_V2_PTCR_RFSEL(8 | ext_port) | |
| 382 | IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) | |
| 383 | IMX_AUDMUX_V2_PTCR_RFSDIR | |
| 384 | IMX_AUDMUX_V2_PTCR_TFSDIR; |
| 385 | ext_ptcr = IMX_AUDMUX_V2_PTCR_RCSEL(8 | int_port) | |
| 386 | IMX_AUDMUX_V2_PTCR_TCSEL(int_port) | |
| 387 | IMX_AUDMUX_V2_PTCR_RCLKDIR | |
| 388 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 389 | break; |
| 390 | case SND_SOC_DAIFMT_CBS_CFS: |
| 391 | ext_ptcr = IMX_AUDMUX_V2_PTCR_RFSEL(8 | int_port) | |
| 392 | IMX_AUDMUX_V2_PTCR_RCSEL(8 | int_port) | |
| 393 | IMX_AUDMUX_V2_PTCR_TFSEL(int_port) | |
| 394 | IMX_AUDMUX_V2_PTCR_TCSEL(int_port) | |
| 395 | IMX_AUDMUX_V2_PTCR_RFSDIR | |
| 396 | IMX_AUDMUX_V2_PTCR_RCLKDIR | |
| 397 | IMX_AUDMUX_V2_PTCR_TFSDIR | |
| 398 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 399 | break; |
| 400 | default: |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 401 | if (!fsl_asoc_card_is_ac97(priv)) |
| 402 | return -EINVAL; |
| 403 | } |
| 404 | |
| 405 | if (fsl_asoc_card_is_ac97(priv)) { |
| 406 | int_ptcr = IMX_AUDMUX_V2_PTCR_SYN | |
| 407 | IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | |
| 408 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
| 409 | ext_ptcr = IMX_AUDMUX_V2_PTCR_SYN | |
| 410 | IMX_AUDMUX_V2_PTCR_TFSEL(int_port) | |
| 411 | IMX_AUDMUX_V2_PTCR_TFSDIR; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | /* Asynchronous mode can not be set along with RCLKDIR */ |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 415 | if (!fsl_asoc_card_is_ac97(priv)) { |
| 416 | unsigned int pdcr = |
| 417 | IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port); |
| 418 | |
| 419 | ret = imx_audmux_v2_configure_port(int_port, 0, |
| 420 | pdcr); |
| 421 | if (ret) { |
| 422 | dev_err(dev, "audmux internal port setup failed\n"); |
| 423 | return ret; |
| 424 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | ret = imx_audmux_v2_configure_port(int_port, int_ptcr, |
| 428 | IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port)); |
| 429 | if (ret) { |
| 430 | dev_err(dev, "audmux internal port setup failed\n"); |
| 431 | return ret; |
| 432 | } |
| 433 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 434 | if (!fsl_asoc_card_is_ac97(priv)) { |
| 435 | unsigned int pdcr = |
| 436 | IMX_AUDMUX_V2_PDCR_RXDSEL(int_port); |
| 437 | |
| 438 | ret = imx_audmux_v2_configure_port(ext_port, 0, |
| 439 | pdcr); |
| 440 | if (ret) { |
| 441 | dev_err(dev, "audmux external port setup failed\n"); |
| 442 | return ret; |
| 443 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | ret = imx_audmux_v2_configure_port(ext_port, ext_ptcr, |
| 447 | IMX_AUDMUX_V2_PDCR_RXDSEL(int_port)); |
| 448 | if (ret) { |
| 449 | dev_err(dev, "audmux external port setup failed\n"); |
| 450 | return ret; |
| 451 | } |
| 452 | |
| 453 | return 0; |
| 454 | } |
| 455 | |
Shengjiu Wang | 3b17119 | 2020-07-15 22:09:39 +0800 | [diff] [blame] | 456 | static int hp_jack_event(struct notifier_block *nb, unsigned long event, |
| 457 | void *data) |
| 458 | { |
| 459 | struct snd_soc_jack *jack = (struct snd_soc_jack *)data; |
| 460 | struct snd_soc_dapm_context *dapm = &jack->card->dapm; |
| 461 | |
| 462 | if (event & SND_JACK_HEADPHONE) |
| 463 | /* Disable speaker if headphone is plugged in */ |
| 464 | snd_soc_dapm_disable_pin(dapm, "Ext Spk"); |
| 465 | else |
| 466 | snd_soc_dapm_enable_pin(dapm, "Ext Spk"); |
| 467 | |
| 468 | return 0; |
| 469 | } |
| 470 | |
| 471 | static struct notifier_block hp_jack_nb = { |
| 472 | .notifier_call = hp_jack_event, |
| 473 | }; |
| 474 | |
| 475 | static int mic_jack_event(struct notifier_block *nb, unsigned long event, |
| 476 | void *data) |
| 477 | { |
| 478 | struct snd_soc_jack *jack = (struct snd_soc_jack *)data; |
| 479 | struct snd_soc_dapm_context *dapm = &jack->card->dapm; |
| 480 | |
| 481 | if (event & SND_JACK_MICROPHONE) |
| 482 | /* Disable dmic if microphone is plugged in */ |
| 483 | snd_soc_dapm_disable_pin(dapm, "DMIC"); |
| 484 | else |
| 485 | snd_soc_dapm_enable_pin(dapm, "DMIC"); |
| 486 | |
| 487 | return 0; |
| 488 | } |
| 489 | |
| 490 | static struct notifier_block mic_jack_nb = { |
| 491 | .notifier_call = mic_jack_event, |
| 492 | }; |
| 493 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 494 | static int fsl_asoc_card_late_probe(struct snd_soc_card *card) |
| 495 | { |
| 496 | struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(card); |
Vinod Koul | abd657b | 2015-11-20 22:45:20 +0530 | [diff] [blame] | 497 | struct snd_soc_pcm_runtime *rtd = list_first_entry( |
| 498 | &card->rtd_list, struct snd_soc_pcm_runtime, list); |
Kuninori Morimoto | 17198ae | 2020-03-23 14:18:30 +0900 | [diff] [blame] | 499 | struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 500 | struct codec_priv *codec_priv = &priv->codec_priv; |
| 501 | struct device *dev = card->dev; |
| 502 | int ret; |
| 503 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 504 | if (fsl_asoc_card_is_ac97(priv)) { |
| 505 | #if IS_ENABLED(CONFIG_SND_AC97_CODEC) |
Kuninori Morimoto | 17198ae | 2020-03-23 14:18:30 +0900 | [diff] [blame] | 506 | struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; |
Kuninori Morimoto | 845f80c | 2017-12-05 04:23:21 +0000 | [diff] [blame] | 507 | struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 508 | |
| 509 | /* |
| 510 | * Use slots 3/4 for S/PDIF so SSI won't try to enable |
| 511 | * other slots and send some samples there |
| 512 | * due to SLOTREQ bits for S/PDIF received from codec |
| 513 | */ |
| 514 | snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, |
| 515 | AC97_EA_SPSA_SLOT_MASK, AC97_EA_SPSA_3_4); |
| 516 | #endif |
| 517 | |
| 518 | return 0; |
| 519 | } |
| 520 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 521 | ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id, |
| 522 | codec_priv->mclk_freq, SND_SOC_CLOCK_IN); |
Nicolin Chen | 758a3b0 | 2017-09-07 22:27:33 -0700 | [diff] [blame] | 523 | if (ret && ret != -ENOTSUPP) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 524 | dev_err(dev, "failed to set sysclk in %s\n", __func__); |
| 525 | return ret; |
| 526 | } |
| 527 | |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | static int fsl_asoc_card_probe(struct platform_device *pdev) |
| 532 | { |
| 533 | struct device_node *cpu_np, *codec_np, *asrc_np; |
| 534 | struct device_node *np = pdev->dev.of_node; |
| 535 | struct platform_device *asrc_pdev = NULL; |
Shengjiu Wang | 08b54b5e | 2020-07-21 11:41:49 +0800 | [diff] [blame] | 536 | struct device_node *bitclkmaster = NULL; |
| 537 | struct device_node *framemaster = NULL; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 538 | struct platform_device *cpu_pdev; |
| 539 | struct fsl_asoc_card_priv *priv; |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 540 | struct device *codec_dev = NULL; |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 541 | const char *codec_dai_name; |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 542 | const char *codec_dev_name; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 543 | u32 width; |
| 544 | int ret; |
| 545 | |
| 546 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
| 547 | if (!priv) |
| 548 | return -ENOMEM; |
| 549 | |
| 550 | cpu_np = of_parse_phandle(np, "audio-cpu", 0); |
| 551 | /* Give a chance to old DT binding */ |
| 552 | if (!cpu_np) |
| 553 | cpu_np = of_parse_phandle(np, "ssi-controller", 0); |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 554 | if (!cpu_np) { |
| 555 | dev_err(&pdev->dev, "CPU phandle missing or invalid\n"); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 556 | ret = -EINVAL; |
| 557 | goto fail; |
| 558 | } |
| 559 | |
| 560 | cpu_pdev = of_find_device_by_node(cpu_np); |
| 561 | if (!cpu_pdev) { |
| 562 | dev_err(&pdev->dev, "failed to find CPU DAI device\n"); |
| 563 | ret = -EINVAL; |
| 564 | goto fail; |
| 565 | } |
| 566 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 567 | codec_np = of_parse_phandle(np, "audio-codec", 0); |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 568 | if (codec_np) { |
| 569 | struct platform_device *codec_pdev; |
| 570 | struct i2c_client *codec_i2c; |
| 571 | |
| 572 | codec_i2c = of_find_i2c_device_by_node(codec_np); |
| 573 | if (codec_i2c) { |
| 574 | codec_dev = &codec_i2c->dev; |
| 575 | codec_dev_name = codec_i2c->name; |
| 576 | } |
| 577 | if (!codec_dev) { |
| 578 | codec_pdev = of_find_device_by_node(codec_np); |
| 579 | if (codec_pdev) { |
| 580 | codec_dev = &codec_pdev->dev; |
| 581 | codec_dev_name = codec_pdev->name; |
| 582 | } |
| 583 | } |
| 584 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 585 | |
| 586 | asrc_np = of_parse_phandle(np, "audio-asrc", 0); |
| 587 | if (asrc_np) |
| 588 | asrc_pdev = of_find_device_by_node(asrc_np); |
| 589 | |
| 590 | /* 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] | 591 | if (codec_dev) { |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 592 | struct clk *codec_clk = clk_get(codec_dev, NULL); |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 593 | |
| 594 | if (!IS_ERR(codec_clk)) { |
| 595 | priv->codec_priv.mclk_freq = clk_get_rate(codec_clk); |
| 596 | clk_put(codec_clk); |
| 597 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | /* Default sample rate and format, will be updated in hw_params() */ |
| 601 | priv->sample_rate = 44100; |
| 602 | priv->sample_format = SNDRV_PCM_FORMAT_S16_LE; |
| 603 | |
| 604 | /* Assign a default DAI format, and allow each card to overwrite it */ |
| 605 | priv->dai_fmt = DAI_FMT_BASE; |
| 606 | |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 607 | memcpy(priv->dai_link, fsl_asoc_card_dai, |
| 608 | sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link)); |
| 609 | |
| 610 | priv->card.dapm_routes = audio_map; |
| 611 | priv->card.num_dapm_routes = ARRAY_SIZE(audio_map); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 612 | /* Diversify the card configurations */ |
| 613 | if (of_device_is_compatible(np, "fsl,imx-audio-cs42888")) { |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 614 | codec_dai_name = "cs42888"; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 615 | priv->cpu_priv.sysclk_freq[TX] = priv->codec_priv.mclk_freq; |
| 616 | priv->cpu_priv.sysclk_freq[RX] = priv->codec_priv.mclk_freq; |
| 617 | priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT; |
| 618 | priv->cpu_priv.sysclk_dir[RX] = SND_SOC_CLOCK_OUT; |
Nicolin Chen | cb3fc1f | 2014-10-24 16:48:13 -0700 | [diff] [blame] | 619 | priv->cpu_priv.slot_width = 32; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 620 | priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; |
Felipe F. Tonello | 57e756d | 2016-01-29 11:01:00 +0000 | [diff] [blame] | 621 | } else if (of_device_is_compatible(np, "fsl,imx-audio-cs427x")) { |
| 622 | codec_dai_name = "cs4271-hifi"; |
| 623 | priv->codec_priv.mclk_id = CS427x_SYSCLK_MCLK; |
| 624 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 625 | } else if (of_device_is_compatible(np, "fsl,imx-audio-sgtl5000")) { |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 626 | codec_dai_name = "sgtl5000"; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 627 | priv->codec_priv.mclk_id = SGTL5000_SYSCLK; |
| 628 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
Matthias Schiffer | b507475 | 2020-08-21 09:11:53 +0200 | [diff] [blame] | 629 | } else if (of_device_is_compatible(np, "fsl,imx-audio-tlv320aic32x4")) { |
| 630 | codec_dai_name = "tlv320aic32x4-hifi"; |
| 631 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 632 | } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8962")) { |
Nicolin Chen | 114bb13 | 2015-08-12 13:06:12 -0700 | [diff] [blame] | 633 | codec_dai_name = "wm8962"; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 634 | priv->codec_priv.mclk_id = WM8962_SYSCLK_MCLK; |
| 635 | priv->codec_priv.fll_id = WM8962_SYSCLK_FLL; |
| 636 | priv->codec_priv.pll_id = WM8962_FLL; |
| 637 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
Zidan Wang | 50e0ee0 | 2015-08-14 19:11:09 +0800 | [diff] [blame] | 638 | } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8960")) { |
| 639 | codec_dai_name = "wm8960-hifi"; |
Zidan Wang | 50e0ee0 | 2015-08-14 19:11:09 +0800 | [diff] [blame] | 640 | priv->codec_priv.fll_id = WM8960_SYSCLK_AUTO; |
| 641 | priv->codec_priv.pll_id = WM8960_SYSCLK_AUTO; |
| 642 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 643 | } else if (of_device_is_compatible(np, "fsl,imx-audio-ac97")) { |
| 644 | codec_dai_name = "ac97-hifi"; |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 645 | priv->dai_fmt = SND_SOC_DAIFMT_AC97; |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 646 | priv->card.dapm_routes = audio_map_ac97; |
| 647 | priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_ac97); |
| 648 | } else if (of_device_is_compatible(np, "fsl,imx-audio-mqs")) { |
| 649 | codec_dai_name = "fsl-mqs-dai"; |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 650 | priv->dai_fmt = SND_SOC_DAIFMT_LEFT_J | |
| 651 | SND_SOC_DAIFMT_CBS_CFS | |
| 652 | SND_SOC_DAIFMT_NB_NF; |
| 653 | priv->dai_link[1].dpcm_capture = 0; |
| 654 | priv->dai_link[2].dpcm_capture = 0; |
| 655 | priv->card.dapm_routes = audio_map_tx; |
| 656 | priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx); |
Shengjiu Wang | 3cd9902 | 2020-06-23 14:52:46 +0800 | [diff] [blame] | 657 | } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8524")) { |
| 658 | codec_dai_name = "wm8524-hifi"; |
Shengjiu Wang | 3cd9902 | 2020-06-23 14:52:46 +0800 | [diff] [blame] | 659 | priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; |
| 660 | priv->dai_link[1].dpcm_capture = 0; |
| 661 | priv->dai_link[2].dpcm_capture = 0; |
| 662 | priv->cpu_priv.slot_width = 32; |
| 663 | priv->card.dapm_routes = audio_map_tx; |
| 664 | priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx); |
Shengjiu Wang | 77f1ff75 | 2020-11-30 11:57:47 +0800 | [diff] [blame] | 665 | } else if (of_device_is_compatible(np, "fsl,imx-audio-si476x")) { |
| 666 | codec_dai_name = "si476x-codec"; |
| 667 | priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; |
| 668 | priv->card.dapm_routes = audio_map_rx; |
| 669 | priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_rx); |
Shengjiu Wang | efd0b16 | 2021-03-17 21:05:02 +0800 | [diff] [blame] | 670 | } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8958")) { |
| 671 | codec_dai_name = "wm8994-aif1"; |
| 672 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
| 673 | priv->codec_priv.mclk_id = WM8994_FLL_SRC_MCLK1; |
| 674 | priv->codec_priv.fll_id = WM8994_SYSCLK_FLL1; |
| 675 | priv->codec_priv.pll_id = WM8994_FLL1; |
| 676 | priv->codec_priv.free_freq = priv->codec_priv.mclk_freq; |
| 677 | priv->card.dapm_routes = NULL; |
| 678 | priv->card.num_dapm_routes = 0; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 679 | } else { |
| 680 | dev_err(&pdev->dev, "unknown Device Tree compatible\n"); |
Maciej S. Szmigiero | 6bd3c6f | 2015-08-31 17:07:12 +0200 | [diff] [blame] | 681 | ret = -EINVAL; |
| 682 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 683 | } |
| 684 | |
Shengjiu Wang | 08b54b5e | 2020-07-21 11:41:49 +0800 | [diff] [blame] | 685 | /* Format info from DT is optional. */ |
Kuninori Morimoto | 3bba941 | 2021-06-14 09:57:51 +0900 | [diff] [blame^] | 686 | snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL, &bitclkmaster, &framemaster); |
Shengjiu Wang | 08b54b5e | 2020-07-21 11:41:49 +0800 | [diff] [blame] | 687 | if (bitclkmaster || framemaster) { |
Kuninori Morimoto | 3bba941 | 2021-06-14 09:57:51 +0900 | [diff] [blame^] | 688 | unsigned int daifmt = snd_soc_daifmt_parse_format(np, NULL); |
| 689 | |
Shengjiu Wang | 08b54b5e | 2020-07-21 11:41:49 +0800 | [diff] [blame] | 690 | if (codec_np == bitclkmaster) |
| 691 | daifmt |= (codec_np == framemaster) ? |
| 692 | SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS; |
| 693 | else |
| 694 | daifmt |= (codec_np == framemaster) ? |
| 695 | SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS; |
| 696 | |
| 697 | /* Override dai_fmt with value from DT */ |
| 698 | priv->dai_fmt = daifmt; |
| 699 | } |
| 700 | |
| 701 | /* Change direction according to format */ |
| 702 | if (priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM) { |
| 703 | priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_IN; |
| 704 | priv->cpu_priv.sysclk_dir[RX] = SND_SOC_CLOCK_IN; |
| 705 | } |
| 706 | |
| 707 | of_node_put(bitclkmaster); |
| 708 | of_node_put(framemaster); |
| 709 | |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 710 | if (!fsl_asoc_card_is_ac97(priv) && !codec_dev) { |
| 711 | dev_err(&pdev->dev, "failed to find codec device\n"); |
Shengjiu Wang | e396dec | 2020-06-04 14:25:30 +0800 | [diff] [blame] | 712 | ret = -EPROBE_DEFER; |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 713 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | /* Common settings for corresponding Freescale CPU DAI driver */ |
Rob Herring | 1d52a74 | 2018-12-05 13:50:49 -0600 | [diff] [blame] | 717 | if (of_node_name_eq(cpu_np, "ssi")) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 718 | /* Only SSI needs to configure AUDMUX */ |
| 719 | ret = fsl_asoc_card_audmux_init(np, priv); |
| 720 | if (ret) { |
| 721 | dev_err(&pdev->dev, "failed to init audmux\n"); |
Shengjiu Wang | 5f37671 | 2014-08-18 16:38:39 +0800 | [diff] [blame] | 722 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 723 | } |
Rob Herring | 1d52a74 | 2018-12-05 13:50:49 -0600 | [diff] [blame] | 724 | } else if (of_node_name_eq(cpu_np, "esai")) { |
Shengjiu Wang | a8fd5ca | 2020-08-10 16:11:43 +0800 | [diff] [blame] | 725 | struct clk *esai_clk = clk_get(&cpu_pdev->dev, "extal"); |
| 726 | |
| 727 | if (!IS_ERR(esai_clk)) { |
| 728 | priv->cpu_priv.sysclk_freq[TX] = clk_get_rate(esai_clk); |
| 729 | priv->cpu_priv.sysclk_freq[RX] = clk_get_rate(esai_clk); |
| 730 | clk_put(esai_clk); |
| 731 | } else if (PTR_ERR(esai_clk) == -EPROBE_DEFER) { |
| 732 | ret = -EPROBE_DEFER; |
| 733 | goto asrc_fail; |
| 734 | } |
| 735 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 736 | priv->cpu_priv.sysclk_id[1] = ESAI_HCKT_EXTAL; |
| 737 | priv->cpu_priv.sysclk_id[0] = ESAI_HCKR_EXTAL; |
Rob Herring | 1d52a74 | 2018-12-05 13:50:49 -0600 | [diff] [blame] | 738 | } else if (of_node_name_eq(cpu_np, "sai")) { |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 739 | priv->cpu_priv.sysclk_id[1] = FSL_SAI_CLK_MAST1; |
| 740 | priv->cpu_priv.sysclk_id[0] = FSL_SAI_CLK_MAST1; |
| 741 | } |
| 742 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 743 | /* Initialize sound card */ |
| 744 | priv->pdev = pdev; |
| 745 | priv->card.dev = &pdev->dev; |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 746 | ret = snd_soc_of_parse_card_name(&priv->card, "model"); |
| 747 | if (ret) { |
| 748 | snprintf(priv->name, sizeof(priv->name), "%s-audio", |
| 749 | fsl_asoc_card_is_ac97(priv) ? "ac97" : codec_dev_name); |
| 750 | priv->card.name = priv->name; |
| 751 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 752 | priv->card.dai_link = priv->dai_link; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 753 | priv->card.late_probe = fsl_asoc_card_late_probe; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 754 | priv->card.dapm_widgets = fsl_asoc_card_dapm_widgets; |
| 755 | priv->card.num_dapm_widgets = ARRAY_SIZE(fsl_asoc_card_dapm_widgets); |
| 756 | |
Nicolin Chen | 089dfaf | 2016-01-30 23:07:00 -0800 | [diff] [blame] | 757 | /* Drop the second half of DAPM routes -- ASRC */ |
| 758 | if (!asrc_pdev) |
| 759 | priv->card.num_dapm_routes /= 2; |
| 760 | |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 761 | if (of_property_read_bool(np, "audio-routing")) { |
| 762 | ret = snd_soc_of_parse_audio_routing(&priv->card, "audio-routing"); |
| 763 | if (ret) { |
| 764 | dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret); |
| 765 | goto asrc_fail; |
| 766 | } |
Nicolin Chen | 3185878 | 2015-02-14 17:22:50 -0800 | [diff] [blame] | 767 | } |
| 768 | |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 769 | /* Normal DAI Link */ |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 770 | priv->dai_link[0].cpus->of_node = cpu_np; |
| 771 | priv->dai_link[0].codecs->dai_name = codec_dai_name; |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 772 | |
| 773 | if (!fsl_asoc_card_is_ac97(priv)) |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 774 | priv->dai_link[0].codecs->of_node = codec_np; |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 775 | else { |
| 776 | u32 idx; |
| 777 | |
| 778 | ret = of_property_read_u32(cpu_np, "cell-index", &idx); |
| 779 | if (ret) { |
| 780 | dev_err(&pdev->dev, |
| 781 | "cannot get CPU index property\n"); |
| 782 | goto asrc_fail; |
| 783 | } |
| 784 | |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 785 | priv->dai_link[0].codecs->name = |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 786 | devm_kasprintf(&pdev->dev, GFP_KERNEL, |
| 787 | "ac97-codec.%u", |
| 788 | (unsigned int)idx); |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 789 | if (!priv->dai_link[0].codecs->name) { |
Arvind Yadav | 7add71b | 2017-09-21 10:50:03 +0530 | [diff] [blame] | 790 | ret = -ENOMEM; |
| 791 | goto asrc_fail; |
| 792 | } |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 793 | } |
| 794 | |
Kuninori Morimoto | 9998d3e | 2019-06-28 10:47:18 +0900 | [diff] [blame] | 795 | priv->dai_link[0].platforms->of_node = cpu_np; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 796 | priv->dai_link[0].dai_fmt = priv->dai_fmt; |
| 797 | priv->card.num_links = 1; |
| 798 | |
| 799 | if (asrc_pdev) { |
| 800 | /* DPCM DAI Links only if ASRC exsits */ |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 801 | priv->dai_link[1].cpus->of_node = asrc_np; |
Kuninori Morimoto | 9998d3e | 2019-06-28 10:47:18 +0900 | [diff] [blame] | 802 | priv->dai_link[1].platforms->of_node = asrc_np; |
Kuninori Morimoto | 893f195 | 2019-06-06 13:15:11 +0900 | [diff] [blame] | 803 | priv->dai_link[2].codecs->dai_name = codec_dai_name; |
| 804 | priv->dai_link[2].codecs->of_node = codec_np; |
| 805 | priv->dai_link[2].codecs->name = |
| 806 | priv->dai_link[0].codecs->name; |
| 807 | priv->dai_link[2].cpus->of_node = cpu_np; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 808 | priv->dai_link[2].dai_fmt = priv->dai_fmt; |
| 809 | priv->card.num_links = 3; |
| 810 | |
| 811 | ret = of_property_read_u32(asrc_np, "fsl,asrc-rate", |
| 812 | &priv->asrc_rate); |
| 813 | if (ret) { |
| 814 | dev_err(&pdev->dev, "failed to get output rate\n"); |
| 815 | ret = -EINVAL; |
Shengjiu Wang | 5f37671 | 2014-08-18 16:38:39 +0800 | [diff] [blame] | 816 | goto asrc_fail; |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 817 | } |
| 818 | |
Shengjiu Wang | 859e364 | 2020-04-16 20:25:33 +0800 | [diff] [blame] | 819 | ret = of_property_read_u32(asrc_np, "fsl,asrc-format", |
| 820 | &priv->asrc_format); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 821 | if (ret) { |
Shengjiu Wang | 859e364 | 2020-04-16 20:25:33 +0800 | [diff] [blame] | 822 | /* Fallback to old binding; translate to asrc_format */ |
| 823 | ret = of_property_read_u32(asrc_np, "fsl,asrc-width", |
| 824 | &width); |
| 825 | if (ret) { |
| 826 | dev_err(&pdev->dev, |
| 827 | "failed to decide output format\n"); |
| 828 | goto asrc_fail; |
| 829 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 830 | |
Shengjiu Wang | 859e364 | 2020-04-16 20:25:33 +0800 | [diff] [blame] | 831 | if (width == 24) |
| 832 | priv->asrc_format = SNDRV_PCM_FORMAT_S24_LE; |
| 833 | else |
| 834 | priv->asrc_format = SNDRV_PCM_FORMAT_S16_LE; |
| 835 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | /* Finish card registering */ |
| 839 | platform_set_drvdata(pdev, priv); |
| 840 | snd_soc_card_set_drvdata(&priv->card, priv); |
| 841 | |
| 842 | ret = devm_snd_soc_register_card(&pdev->dev, &priv->card); |
Shengjiu Wang | 3b17119 | 2020-07-15 22:09:39 +0800 | [diff] [blame] | 843 | if (ret) { |
| 844 | if (ret != -EPROBE_DEFER) |
| 845 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); |
| 846 | goto asrc_fail; |
| 847 | } |
| 848 | |
| 849 | /* |
| 850 | * Properties "hp-det-gpio" and "mic-det-gpio" are optional, and |
| 851 | * asoc_simple_init_jack uses these properties for creating |
| 852 | * Headphone Jack and Microphone Jack. |
| 853 | * |
| 854 | * The notifier is initialized in snd_soc_card_jack_new(), then |
| 855 | * snd_soc_jack_notifier_register can be called. |
| 856 | */ |
| 857 | if (of_property_read_bool(np, "hp-det-gpio")) { |
| 858 | ret = asoc_simple_init_jack(&priv->card, &priv->hp_jack, |
| 859 | 1, NULL, "Headphone Jack"); |
| 860 | if (ret) |
| 861 | goto asrc_fail; |
| 862 | |
| 863 | snd_soc_jack_notifier_register(&priv->hp_jack.jack, &hp_jack_nb); |
| 864 | } |
| 865 | |
| 866 | if (of_property_read_bool(np, "mic-det-gpio")) { |
| 867 | ret = asoc_simple_init_jack(&priv->card, &priv->mic_jack, |
| 868 | 0, NULL, "Mic Jack"); |
| 869 | if (ret) |
| 870 | goto asrc_fail; |
| 871 | |
| 872 | snd_soc_jack_notifier_register(&priv->mic_jack.jack, &mic_jack_nb); |
| 873 | } |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 874 | |
Shengjiu Wang | 5f37671 | 2014-08-18 16:38:39 +0800 | [diff] [blame] | 875 | asrc_fail: |
| 876 | of_node_put(asrc_np); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 877 | of_node_put(codec_np); |
wen yang | 11907e9d | 2019-02-02 14:53:16 +0000 | [diff] [blame] | 878 | put_device(&cpu_pdev->dev); |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 879 | fail: |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 880 | of_node_put(cpu_np); |
| 881 | |
| 882 | return ret; |
| 883 | } |
| 884 | |
| 885 | static const struct of_device_id fsl_asoc_card_dt_ids[] = { |
Maciej S. Szmigiero | 50760ca | 2015-09-19 02:00:25 +0200 | [diff] [blame] | 886 | { .compatible = "fsl,imx-audio-ac97", }, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 887 | { .compatible = "fsl,imx-audio-cs42888", }, |
Felipe F. Tonello | 57e756d | 2016-01-29 11:01:00 +0000 | [diff] [blame] | 888 | { .compatible = "fsl,imx-audio-cs427x", }, |
Matthias Schiffer | b507475 | 2020-08-21 09:11:53 +0200 | [diff] [blame] | 889 | { .compatible = "fsl,imx-audio-tlv320aic32x4", }, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 890 | { .compatible = "fsl,imx-audio-sgtl5000", }, |
| 891 | { .compatible = "fsl,imx-audio-wm8962", }, |
Zidan Wang | 50e0ee0 | 2015-08-14 19:11:09 +0800 | [diff] [blame] | 892 | { .compatible = "fsl,imx-audio-wm8960", }, |
Shengjiu Wang | 039652a | 2020-06-17 12:48:25 +0800 | [diff] [blame] | 893 | { .compatible = "fsl,imx-audio-mqs", }, |
Shengjiu Wang | 3cd9902 | 2020-06-23 14:52:46 +0800 | [diff] [blame] | 894 | { .compatible = "fsl,imx-audio-wm8524", }, |
Shengjiu Wang | 77f1ff75 | 2020-11-30 11:57:47 +0800 | [diff] [blame] | 895 | { .compatible = "fsl,imx-audio-si476x", }, |
Shengjiu Wang | efd0b16 | 2021-03-17 21:05:02 +0800 | [diff] [blame] | 896 | { .compatible = "fsl,imx-audio-wm8958", }, |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 897 | {} |
| 898 | }; |
Luis de Bethencourt | 5226f23 | 2015-09-03 12:57:47 +0200 | [diff] [blame] | 899 | MODULE_DEVICE_TABLE(of, fsl_asoc_card_dt_ids); |
Nicolin Chen | 708b435 | 2014-07-30 19:27:38 +0800 | [diff] [blame] | 900 | |
| 901 | static struct platform_driver fsl_asoc_card_driver = { |
| 902 | .probe = fsl_asoc_card_probe, |
| 903 | .driver = { |
| 904 | .name = "fsl-asoc-card", |
| 905 | .pm = &snd_soc_pm_ops, |
| 906 | .of_match_table = fsl_asoc_card_dt_ids, |
| 907 | }, |
| 908 | }; |
| 909 | module_platform_driver(fsl_asoc_card_driver); |
| 910 | |
| 911 | MODULE_DESCRIPTION("Freescale Generic ASoC Sound Card driver with ASRC"); |
| 912 | MODULE_AUTHOR("Nicolin Chen <nicoleotsuka@gmail.com>"); |
| 913 | MODULE_ALIAS("platform:fsl-asoc-card"); |
| 914 | MODULE_LICENSE("GPL"); |