2 * Freescale Generic ASoC Sound Card driver with ASRC
4 * Copyright (C) 2014 Freescale Semiconductor, Inc.
6 * Author: Nicolin Chen <nicoleotsuka@gmail.com>
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
13 #include <linux/clk.h>
14 #include <linux/i2c.h>
15 #include <linux/module.h>
16 #include <linux/of_platform.h>
17 #if IS_ENABLED(CONFIG_SND_AC97_CODEC)
18 #include <sound/ac97_codec.h>
20 #include <sound/pcm_params.h>
21 #include <sound/soc.h>
25 #include "imx-audmux.h"
27 #include "../codecs/sgtl5000.h"
28 #include "../codecs/wm8962.h"
29 #include "../codecs/wm8960.h"
34 /* Default DAI format without Master and Slave flag */
35 #define DAI_FMT_BASE (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF)
40 * @mclk_freq: Clock rate of MCLK
41 * @mclk_id: MCLK (or main clock) id for set_sysclk()
42 * @fll_id: FLL (or secordary clock) id for set_sysclk()
43 * @pll_id: PLL id for set_pll()
46 unsigned long mclk_freq
;
55 * @sysclk_freq[2]: SYSCLK rates for set_sysclk()
56 * @sysclk_dir[2]: SYSCLK directions for set_sysclk()
57 * @sysclk_id[2]: SYSCLK ids for set_sysclk()
58 * @slot_width: Slot width of each frame
60 * Note: [1] for tx and [0] for rx
63 unsigned long sysclk_freq
[2];
70 * Freescale Generic ASOC card private data
72 * @dai_link[3]: DAI link structure including normal one and DPCM link
73 * @pdev: platform device pointer
74 * @codec_priv: CODEC private data
75 * @cpu_priv: CPU private data
76 * @card: ASoC card structure
77 * @sample_rate: Current sample rate
78 * @sample_format: Current sample format
79 * @asrc_rate: ASRC sample rate used by Back-Ends
80 * @asrc_format: ASRC sample format used by Back-Ends
81 * @dai_fmt: DAI format between CPU and CODEC
85 struct fsl_asoc_card_priv
{
86 struct snd_soc_dai_link dai_link
[3];
87 struct platform_device
*pdev
;
88 struct codec_priv codec_priv
;
89 struct cpu_priv cpu_priv
;
90 struct snd_soc_card card
;
100 * This dapm route map exsits for DPCM link only.
101 * The other routes shall go through Device Tree.
103 static const struct snd_soc_dapm_route audio_map
[] = {
104 {"CPU-Playback", NULL
, "ASRC-Playback"},
105 {"Playback", NULL
, "CPU-Playback"},
106 {"ASRC-Capture", NULL
, "CPU-Capture"},
107 {"CPU-Capture", NULL
, "Capture"},
110 static const struct snd_soc_dapm_route audio_map_ac97
[] = {
111 {"AC97 Playback", NULL
, "ASRC-Playback"},
112 {"Playback", NULL
, "AC97 Playback"},
113 {"ASRC-Capture", NULL
, "AC97 Capture"},
114 {"AC97 Capture", NULL
, "Capture"},
117 /* Add all possible widgets into here without being redundant */
118 static const struct snd_soc_dapm_widget fsl_asoc_card_dapm_widgets
[] = {
119 SND_SOC_DAPM_LINE("Line Out Jack", NULL
),
120 SND_SOC_DAPM_LINE("Line In Jack", NULL
),
121 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
122 SND_SOC_DAPM_SPK("Ext Spk", NULL
),
123 SND_SOC_DAPM_MIC("Mic Jack", NULL
),
124 SND_SOC_DAPM_MIC("AMIC", NULL
),
125 SND_SOC_DAPM_MIC("DMIC", NULL
),
128 static bool fsl_asoc_card_is_ac97(struct fsl_asoc_card_priv
*priv
)
130 return priv
->dai_fmt
== SND_SOC_DAIFMT_AC97
;
133 static int fsl_asoc_card_hw_params(struct snd_pcm_substream
*substream
,
134 struct snd_pcm_hw_params
*params
)
136 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
137 struct fsl_asoc_card_priv
*priv
= snd_soc_card_get_drvdata(rtd
->card
);
138 bool tx
= substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
;
139 struct cpu_priv
*cpu_priv
= &priv
->cpu_priv
;
140 struct device
*dev
= rtd
->card
->dev
;
143 priv
->sample_rate
= params_rate(params
);
144 priv
->sample_format
= params_format(params
);
147 * If codec-dai is DAI Master and all configurations are already in the
148 * set_bias_level(), bypass the remaining settings in hw_params().
149 * Note: (dai_fmt & CBM_CFM) includes CBM_CFM and CBM_CFS.
151 if ((priv
->card
.set_bias_level
&&
152 priv
->dai_fmt
& SND_SOC_DAIFMT_CBM_CFM
) ||
153 fsl_asoc_card_is_ac97(priv
))
156 /* Specific configurations of DAIs starts from here */
157 ret
= snd_soc_dai_set_sysclk(rtd
->cpu_dai
, cpu_priv
->sysclk_id
[tx
],
158 cpu_priv
->sysclk_freq
[tx
],
159 cpu_priv
->sysclk_dir
[tx
]);
161 dev_err(dev
, "failed to set sysclk for cpu dai\n");
165 if (cpu_priv
->slot_width
) {
166 ret
= snd_soc_dai_set_tdm_slot(rtd
->cpu_dai
, 0x3, 0x3, 2,
167 cpu_priv
->slot_width
);
169 dev_err(dev
, "failed to set TDM slot for cpu dai\n");
177 static struct snd_soc_ops fsl_asoc_card_ops
= {
178 .hw_params
= fsl_asoc_card_hw_params
,
181 static int be_hw_params_fixup(struct snd_soc_pcm_runtime
*rtd
,
182 struct snd_pcm_hw_params
*params
)
184 struct fsl_asoc_card_priv
*priv
= snd_soc_card_get_drvdata(rtd
->card
);
185 struct snd_interval
*rate
;
186 struct snd_mask
*mask
;
188 rate
= hw_param_interval(params
, SNDRV_PCM_HW_PARAM_RATE
);
189 rate
->max
= rate
->min
= priv
->asrc_rate
;
191 mask
= hw_param_mask(params
, SNDRV_PCM_HW_PARAM_FORMAT
);
193 snd_mask_set(mask
, priv
->asrc_format
);
198 static struct snd_soc_dai_link fsl_asoc_card_dai
[] = {
199 /* Default ASoC DAI Link*/
202 .stream_name
= "HiFi",
203 .ops
= &fsl_asoc_card_ops
,
205 /* DPCM Link between Front-End and Back-End (Optional) */
207 .name
= "HiFi-ASRC-FE",
208 .stream_name
= "HiFi-ASRC-FE",
209 .codec_name
= "snd-soc-dummy",
210 .codec_dai_name
= "snd-soc-dummy-dai",
216 .name
= "HiFi-ASRC-BE",
217 .stream_name
= "HiFi-ASRC-BE",
218 .platform_name
= "snd-soc-dummy",
219 .be_hw_params_fixup
= be_hw_params_fixup
,
220 .ops
= &fsl_asoc_card_ops
,
227 static int fsl_asoc_card_set_bias_level(struct snd_soc_card
*card
,
228 struct snd_soc_dapm_context
*dapm
,
229 enum snd_soc_bias_level level
)
231 struct fsl_asoc_card_priv
*priv
= snd_soc_card_get_drvdata(card
);
232 struct snd_soc_pcm_runtime
*rtd
;
233 struct snd_soc_dai
*codec_dai
;
234 struct codec_priv
*codec_priv
= &priv
->codec_priv
;
235 struct device
*dev
= card
->dev
;
236 unsigned int pll_out
;
239 rtd
= snd_soc_get_pcm_runtime(card
, card
->dai_link
[0].name
);
240 codec_dai
= rtd
->codec_dai
;
241 if (dapm
->dev
!= codec_dai
->dev
)
245 case SND_SOC_BIAS_PREPARE
:
246 if (dapm
->bias_level
!= SND_SOC_BIAS_STANDBY
)
249 if (priv
->sample_format
== SNDRV_PCM_FORMAT_S24_LE
)
250 pll_out
= priv
->sample_rate
* 384;
252 pll_out
= priv
->sample_rate
* 256;
254 ret
= snd_soc_dai_set_pll(codec_dai
, codec_priv
->pll_id
,
256 codec_priv
->mclk_freq
, pll_out
);
258 dev_err(dev
, "failed to start FLL: %d\n", ret
);
262 ret
= snd_soc_dai_set_sysclk(codec_dai
, codec_priv
->fll_id
,
263 pll_out
, SND_SOC_CLOCK_IN
);
265 dev_err(dev
, "failed to set SYSCLK: %d\n", ret
);
270 case SND_SOC_BIAS_STANDBY
:
271 if (dapm
->bias_level
!= SND_SOC_BIAS_PREPARE
)
274 ret
= snd_soc_dai_set_sysclk(codec_dai
, codec_priv
->mclk_id
,
275 codec_priv
->mclk_freq
,
278 dev_err(dev
, "failed to switch away from FLL: %d\n", ret
);
282 ret
= snd_soc_dai_set_pll(codec_dai
, codec_priv
->pll_id
, 0, 0, 0);
284 dev_err(dev
, "failed to stop FLL: %d\n", ret
);
296 static int fsl_asoc_card_audmux_init(struct device_node
*np
,
297 struct fsl_asoc_card_priv
*priv
)
299 struct device
*dev
= &priv
->pdev
->dev
;
300 u32 int_ptcr
= 0, ext_ptcr
= 0;
301 int int_port
, ext_port
;
304 ret
= of_property_read_u32(np
, "mux-int-port", &int_port
);
306 dev_err(dev
, "mux-int-port missing or invalid\n");
309 ret
= of_property_read_u32(np
, "mux-ext-port", &ext_port
);
311 dev_err(dev
, "mux-ext-port missing or invalid\n");
316 * The port numbering in the hardware manual starts at 1, while
317 * the AUDMUX API expects it starts at 0.
323 * Use asynchronous mode (6 wires) for all cases except AC97.
324 * If only 4 wires are needed, just set SSI into
325 * synchronous mode and enable 4 PADs in IOMUX.
327 switch (priv
->dai_fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
328 case SND_SOC_DAIFMT_CBM_CFM
:
329 int_ptcr
= IMX_AUDMUX_V2_PTCR_RFSEL(8 | ext_port
) |
330 IMX_AUDMUX_V2_PTCR_RCSEL(8 | ext_port
) |
331 IMX_AUDMUX_V2_PTCR_TFSEL(ext_port
) |
332 IMX_AUDMUX_V2_PTCR_TCSEL(ext_port
) |
333 IMX_AUDMUX_V2_PTCR_RFSDIR
|
334 IMX_AUDMUX_V2_PTCR_RCLKDIR
|
335 IMX_AUDMUX_V2_PTCR_TFSDIR
|
336 IMX_AUDMUX_V2_PTCR_TCLKDIR
;
338 case SND_SOC_DAIFMT_CBM_CFS
:
339 int_ptcr
= IMX_AUDMUX_V2_PTCR_RCSEL(8 | ext_port
) |
340 IMX_AUDMUX_V2_PTCR_TCSEL(ext_port
) |
341 IMX_AUDMUX_V2_PTCR_RCLKDIR
|
342 IMX_AUDMUX_V2_PTCR_TCLKDIR
;
343 ext_ptcr
= IMX_AUDMUX_V2_PTCR_RFSEL(8 | int_port
) |
344 IMX_AUDMUX_V2_PTCR_TFSEL(int_port
) |
345 IMX_AUDMUX_V2_PTCR_RFSDIR
|
346 IMX_AUDMUX_V2_PTCR_TFSDIR
;
348 case SND_SOC_DAIFMT_CBS_CFM
:
349 int_ptcr
= IMX_AUDMUX_V2_PTCR_RFSEL(8 | ext_port
) |
350 IMX_AUDMUX_V2_PTCR_TFSEL(ext_port
) |
351 IMX_AUDMUX_V2_PTCR_RFSDIR
|
352 IMX_AUDMUX_V2_PTCR_TFSDIR
;
353 ext_ptcr
= IMX_AUDMUX_V2_PTCR_RCSEL(8 | int_port
) |
354 IMX_AUDMUX_V2_PTCR_TCSEL(int_port
) |
355 IMX_AUDMUX_V2_PTCR_RCLKDIR
|
356 IMX_AUDMUX_V2_PTCR_TCLKDIR
;
358 case SND_SOC_DAIFMT_CBS_CFS
:
359 ext_ptcr
= IMX_AUDMUX_V2_PTCR_RFSEL(8 | int_port
) |
360 IMX_AUDMUX_V2_PTCR_RCSEL(8 | int_port
) |
361 IMX_AUDMUX_V2_PTCR_TFSEL(int_port
) |
362 IMX_AUDMUX_V2_PTCR_TCSEL(int_port
) |
363 IMX_AUDMUX_V2_PTCR_RFSDIR
|
364 IMX_AUDMUX_V2_PTCR_RCLKDIR
|
365 IMX_AUDMUX_V2_PTCR_TFSDIR
|
366 IMX_AUDMUX_V2_PTCR_TCLKDIR
;
369 if (!fsl_asoc_card_is_ac97(priv
))
373 if (fsl_asoc_card_is_ac97(priv
)) {
374 int_ptcr
= IMX_AUDMUX_V2_PTCR_SYN
|
375 IMX_AUDMUX_V2_PTCR_TCSEL(ext_port
) |
376 IMX_AUDMUX_V2_PTCR_TCLKDIR
;
377 ext_ptcr
= IMX_AUDMUX_V2_PTCR_SYN
|
378 IMX_AUDMUX_V2_PTCR_TFSEL(int_port
) |
379 IMX_AUDMUX_V2_PTCR_TFSDIR
;
382 /* Asynchronous mode can not be set along with RCLKDIR */
383 if (!fsl_asoc_card_is_ac97(priv
)) {
385 IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port
);
387 ret
= imx_audmux_v2_configure_port(int_port
, 0,
390 dev_err(dev
, "audmux internal port setup failed\n");
395 ret
= imx_audmux_v2_configure_port(int_port
, int_ptcr
,
396 IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port
));
398 dev_err(dev
, "audmux internal port setup failed\n");
402 if (!fsl_asoc_card_is_ac97(priv
)) {
404 IMX_AUDMUX_V2_PDCR_RXDSEL(int_port
);
406 ret
= imx_audmux_v2_configure_port(ext_port
, 0,
409 dev_err(dev
, "audmux external port setup failed\n");
414 ret
= imx_audmux_v2_configure_port(ext_port
, ext_ptcr
,
415 IMX_AUDMUX_V2_PDCR_RXDSEL(int_port
));
417 dev_err(dev
, "audmux external port setup failed\n");
424 static int fsl_asoc_card_late_probe(struct snd_soc_card
*card
)
426 struct fsl_asoc_card_priv
*priv
= snd_soc_card_get_drvdata(card
);
427 struct snd_soc_pcm_runtime
*rtd
= list_first_entry(
428 &card
->rtd_list
, struct snd_soc_pcm_runtime
, list
);
429 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
430 struct codec_priv
*codec_priv
= &priv
->codec_priv
;
431 struct device
*dev
= card
->dev
;
434 if (fsl_asoc_card_is_ac97(priv
)) {
435 #if IS_ENABLED(CONFIG_SND_AC97_CODEC)
436 struct snd_soc_codec
*codec
= rtd
->codec
;
437 struct snd_ac97
*ac97
= snd_soc_codec_get_drvdata(codec
);
440 * Use slots 3/4 for S/PDIF so SSI won't try to enable
441 * other slots and send some samples there
442 * due to SLOTREQ bits for S/PDIF received from codec
444 snd_ac97_update_bits(ac97
, AC97_EXTENDED_STATUS
,
445 AC97_EA_SPSA_SLOT_MASK
, AC97_EA_SPSA_3_4
);
451 ret
= snd_soc_dai_set_sysclk(codec_dai
, codec_priv
->mclk_id
,
452 codec_priv
->mclk_freq
, SND_SOC_CLOCK_IN
);
454 dev_err(dev
, "failed to set sysclk in %s\n", __func__
);
461 static int fsl_asoc_card_probe(struct platform_device
*pdev
)
463 struct device_node
*cpu_np
, *codec_np
, *asrc_np
;
464 struct device_node
*np
= pdev
->dev
.of_node
;
465 struct platform_device
*asrc_pdev
= NULL
;
466 struct platform_device
*cpu_pdev
;
467 struct fsl_asoc_card_priv
*priv
;
468 struct i2c_client
*codec_dev
;
469 const char *codec_dai_name
;
473 priv
= devm_kzalloc(&pdev
->dev
, sizeof(*priv
), GFP_KERNEL
);
477 cpu_np
= of_parse_phandle(np
, "audio-cpu", 0);
478 /* Give a chance to old DT binding */
480 cpu_np
= of_parse_phandle(np
, "ssi-controller", 0);
482 dev_err(&pdev
->dev
, "CPU phandle missing or invalid\n");
487 cpu_pdev
= of_find_device_by_node(cpu_np
);
489 dev_err(&pdev
->dev
, "failed to find CPU DAI device\n");
494 codec_np
= of_parse_phandle(np
, "audio-codec", 0);
496 codec_dev
= of_find_i2c_device_by_node(codec_np
);
500 asrc_np
= of_parse_phandle(np
, "audio-asrc", 0);
502 asrc_pdev
= of_find_device_by_node(asrc_np
);
504 /* Get the MCLK rate only, and leave it controlled by CODEC drivers */
506 struct clk
*codec_clk
= clk_get(&codec_dev
->dev
, NULL
);
508 if (!IS_ERR(codec_clk
)) {
509 priv
->codec_priv
.mclk_freq
= clk_get_rate(codec_clk
);
514 /* Default sample rate and format, will be updated in hw_params() */
515 priv
->sample_rate
= 44100;
516 priv
->sample_format
= SNDRV_PCM_FORMAT_S16_LE
;
518 /* Assign a default DAI format, and allow each card to overwrite it */
519 priv
->dai_fmt
= DAI_FMT_BASE
;
521 /* Diversify the card configurations */
522 if (of_device_is_compatible(np
, "fsl,imx-audio-cs42888")) {
523 codec_dai_name
= "cs42888";
524 priv
->card
.set_bias_level
= NULL
;
525 priv
->cpu_priv
.sysclk_freq
[TX
] = priv
->codec_priv
.mclk_freq
;
526 priv
->cpu_priv
.sysclk_freq
[RX
] = priv
->codec_priv
.mclk_freq
;
527 priv
->cpu_priv
.sysclk_dir
[TX
] = SND_SOC_CLOCK_OUT
;
528 priv
->cpu_priv
.sysclk_dir
[RX
] = SND_SOC_CLOCK_OUT
;
529 priv
->cpu_priv
.slot_width
= 32;
530 priv
->dai_fmt
|= SND_SOC_DAIFMT_CBS_CFS
;
531 } else if (of_device_is_compatible(np
, "fsl,imx-audio-sgtl5000")) {
532 codec_dai_name
= "sgtl5000";
533 priv
->codec_priv
.mclk_id
= SGTL5000_SYSCLK
;
534 priv
->dai_fmt
|= SND_SOC_DAIFMT_CBM_CFM
;
535 } else if (of_device_is_compatible(np
, "fsl,imx-audio-wm8962")) {
536 codec_dai_name
= "wm8962";
537 priv
->card
.set_bias_level
= fsl_asoc_card_set_bias_level
;
538 priv
->codec_priv
.mclk_id
= WM8962_SYSCLK_MCLK
;
539 priv
->codec_priv
.fll_id
= WM8962_SYSCLK_FLL
;
540 priv
->codec_priv
.pll_id
= WM8962_FLL
;
541 priv
->dai_fmt
|= SND_SOC_DAIFMT_CBM_CFM
;
542 } else if (of_device_is_compatible(np
, "fsl,imx-audio-wm8960")) {
543 codec_dai_name
= "wm8960-hifi";
544 priv
->card
.set_bias_level
= fsl_asoc_card_set_bias_level
;
545 priv
->codec_priv
.fll_id
= WM8960_SYSCLK_AUTO
;
546 priv
->codec_priv
.pll_id
= WM8960_SYSCLK_AUTO
;
547 priv
->dai_fmt
|= SND_SOC_DAIFMT_CBM_CFM
;
548 } else if (of_device_is_compatible(np
, "fsl,imx-audio-ac97")) {
549 codec_dai_name
= "ac97-hifi";
550 priv
->card
.set_bias_level
= NULL
;
551 priv
->dai_fmt
= SND_SOC_DAIFMT_AC97
;
553 dev_err(&pdev
->dev
, "unknown Device Tree compatible\n");
558 if (!fsl_asoc_card_is_ac97(priv
) && !codec_dev
) {
559 dev_err(&pdev
->dev
, "failed to find codec device\n");
564 /* Common settings for corresponding Freescale CPU DAI driver */
565 if (strstr(cpu_np
->name
, "ssi")) {
566 /* Only SSI needs to configure AUDMUX */
567 ret
= fsl_asoc_card_audmux_init(np
, priv
);
569 dev_err(&pdev
->dev
, "failed to init audmux\n");
572 } else if (strstr(cpu_np
->name
, "esai")) {
573 priv
->cpu_priv
.sysclk_id
[1] = ESAI_HCKT_EXTAL
;
574 priv
->cpu_priv
.sysclk_id
[0] = ESAI_HCKR_EXTAL
;
575 } else if (strstr(cpu_np
->name
, "sai")) {
576 priv
->cpu_priv
.sysclk_id
[1] = FSL_SAI_CLK_MAST1
;
577 priv
->cpu_priv
.sysclk_id
[0] = FSL_SAI_CLK_MAST1
;
580 snprintf(priv
->name
, sizeof(priv
->name
), "%s-audio",
581 fsl_asoc_card_is_ac97(priv
) ? "ac97" :
584 /* Initialize sound card */
586 priv
->card
.dev
= &pdev
->dev
;
587 priv
->card
.name
= priv
->name
;
588 priv
->card
.dai_link
= priv
->dai_link
;
589 priv
->card
.dapm_routes
= fsl_asoc_card_is_ac97(priv
) ?
590 audio_map_ac97
: audio_map
;
591 priv
->card
.late_probe
= fsl_asoc_card_late_probe
;
592 priv
->card
.num_dapm_routes
= ARRAY_SIZE(audio_map
);
593 priv
->card
.dapm_widgets
= fsl_asoc_card_dapm_widgets
;
594 priv
->card
.num_dapm_widgets
= ARRAY_SIZE(fsl_asoc_card_dapm_widgets
);
596 memcpy(priv
->dai_link
, fsl_asoc_card_dai
,
597 sizeof(struct snd_soc_dai_link
) * ARRAY_SIZE(priv
->dai_link
));
599 ret
= snd_soc_of_parse_audio_routing(&priv
->card
, "audio-routing");
601 dev_err(&pdev
->dev
, "failed to parse audio-routing: %d\n", ret
);
605 /* Normal DAI Link */
606 priv
->dai_link
[0].cpu_of_node
= cpu_np
;
607 priv
->dai_link
[0].codec_dai_name
= codec_dai_name
;
609 if (!fsl_asoc_card_is_ac97(priv
))
610 priv
->dai_link
[0].codec_of_node
= codec_np
;
614 ret
= of_property_read_u32(cpu_np
, "cell-index", &idx
);
617 "cannot get CPU index property\n");
621 priv
->dai_link
[0].codec_name
=
622 devm_kasprintf(&pdev
->dev
, GFP_KERNEL
,
627 priv
->dai_link
[0].platform_of_node
= cpu_np
;
628 priv
->dai_link
[0].dai_fmt
= priv
->dai_fmt
;
629 priv
->card
.num_links
= 1;
632 /* DPCM DAI Links only if ASRC exsits */
633 priv
->dai_link
[1].cpu_of_node
= asrc_np
;
634 priv
->dai_link
[1].platform_of_node
= asrc_np
;
635 priv
->dai_link
[2].codec_dai_name
= codec_dai_name
;
636 priv
->dai_link
[2].codec_of_node
= codec_np
;
637 priv
->dai_link
[2].codec_name
=
638 priv
->dai_link
[0].codec_name
;
639 priv
->dai_link
[2].cpu_of_node
= cpu_np
;
640 priv
->dai_link
[2].dai_fmt
= priv
->dai_fmt
;
641 priv
->card
.num_links
= 3;
643 ret
= of_property_read_u32(asrc_np
, "fsl,asrc-rate",
646 dev_err(&pdev
->dev
, "failed to get output rate\n");
651 ret
= of_property_read_u32(asrc_np
, "fsl,asrc-width", &width
);
653 dev_err(&pdev
->dev
, "failed to get output rate\n");
659 priv
->asrc_format
= SNDRV_PCM_FORMAT_S24_LE
;
661 priv
->asrc_format
= SNDRV_PCM_FORMAT_S16_LE
;
664 /* Finish card registering */
665 platform_set_drvdata(pdev
, priv
);
666 snd_soc_card_set_drvdata(&priv
->card
, priv
);
668 ret
= devm_snd_soc_register_card(&pdev
->dev
, &priv
->card
);
670 dev_err(&pdev
->dev
, "snd_soc_register_card failed (%d)\n", ret
);
673 of_node_put(asrc_np
);
674 of_node_put(codec_np
);
681 static const struct of_device_id fsl_asoc_card_dt_ids
[] = {
682 { .compatible
= "fsl,imx-audio-ac97", },
683 { .compatible
= "fsl,imx-audio-cs42888", },
684 { .compatible
= "fsl,imx-audio-sgtl5000", },
685 { .compatible
= "fsl,imx-audio-wm8962", },
686 { .compatible
= "fsl,imx-audio-wm8960", },
689 MODULE_DEVICE_TABLE(of
, fsl_asoc_card_dt_ids
);
691 static struct platform_driver fsl_asoc_card_driver
= {
692 .probe
= fsl_asoc_card_probe
,
694 .name
= "fsl-asoc-card",
695 .pm
= &snd_soc_pm_ops
,
696 .of_match_table
= fsl_asoc_card_dt_ids
,
699 module_platform_driver(fsl_asoc_card_driver
);
701 MODULE_DESCRIPTION("Freescale Generic ASoC Sound Card driver with ASRC");
702 MODULE_AUTHOR("Nicolin Chen <nicoleotsuka@gmail.com>");
703 MODULE_ALIAS("platform:fsl-asoc-card");
704 MODULE_LICENSE("GPL");