1 // SPDX-License-Identifier: GPL-2.0+
2 // Copyright 2017-2021 NXP
4 #include <linux/module.h>
5 #include <linux/init.h>
6 #include <linux/slab.h>
7 #include <linux/gpio/consumer.h>
8 #include <linux/of_device.h>
10 #include <linux/of_gpio.h>
11 #include <linux/clk.h>
12 #include <sound/soc.h>
13 #include <sound/pcm_params.h>
14 #include <sound/pcm.h>
15 #include <sound/soc-dapm.h>
16 #include <sound/simple_card_utils.h>
20 #define IMX_CARD_MCLK_22P5792MHZ 22579200
21 #define IMX_CARD_MCLK_24P576MHZ 24576000
32 * Mapping LRCK fs and frame width, table 3 & 4 in datasheet
35 * @wmin: min frame ratio
36 * @wmax: max frame ratio
38 struct imx_akcodec_fs_mul {
46 * Mapping TDM mode and frame width
48 struct imx_akcodec_tdm_fs_mul {
55 * struct imx_card_plat_data - specific info for codecs
57 * @fs_mul: ratio of mclk/fs for normal mode
58 * @tdm_fs_mul: ratio of mclk/fs for tdm mode
59 * @support_rates: supported sample rate
60 * @support_tdm_rates: supported sample rate for tdm mode
61 * @support_channels: supported channels
62 * @support_tdm_channels: supported channels for tdm mode
63 * @num_fs_mul: ARRAY_SIZE of fs_mul
64 * @num_tdm_fs_mul: ARRAY_SIZE of tdm_fs_mul
65 * @num_rates: ARRAY_SIZE of support_rates
66 * @num_tdm_rates: ARRAY_SIZE of support_tdm_rates
67 * @num_channels: ARRAY_SIZE of support_channels
68 * @num_tdm_channels: ARRAY_SIZE of support_tdm_channels
71 struct imx_card_plat_data {
72 struct imx_akcodec_fs_mul *fs_mul;
73 struct imx_akcodec_tdm_fs_mul *tdm_fs_mul;
74 const u32 *support_rates;
75 const u32 *support_tdm_rates;
76 const u32 *support_channels;
77 const u32 *support_tdm_channels;
78 unsigned int num_fs_mul;
79 unsigned int num_tdm_fs_mul;
80 unsigned int num_rates;
81 unsigned int num_tdm_rates;
82 unsigned int num_channels;
83 unsigned int num_tdm_channels;
84 unsigned int num_codecs;
89 * struct dai_link_data - specific info for dai link
92 * @slot_width: slot width value
93 * @cpu_sysclk_id: sysclk id for cpu dai
94 * @one2one_ratio: true if mclk equal to bclk
96 struct dai_link_data {
98 unsigned int slot_width;
99 unsigned int cpu_sysclk_id;
104 * struct imx_card_data - platform device data
106 * @plat_data: pointer of imx_card_plat_data
107 * @dapm_routes: pointer of dapm_routes
108 * @link_data: private data for dai link
109 * @card: card instance
110 * @num_dapm_routes: number of dapm_routes
111 * @asrc_rate: asrc rates
112 * @asrc_format: asrc format
114 struct imx_card_data {
115 struct imx_card_plat_data *plat_data;
116 struct snd_soc_dapm_route *dapm_routes;
117 struct dai_link_data *link_data;
118 struct snd_soc_card card;
121 snd_pcm_format_t asrc_format;
124 static struct imx_akcodec_fs_mul ak4458_fs_mul[] = {
125 /* Normal, < 32kHz */
126 { .rmin = 8000, .rmax = 24000, .wmin = 256, .wmax = 1024, },
128 { .rmin = 32000, .rmax = 32000, .wmin = 256, .wmax = 1024, },
130 { .rmin = 44100, .rmax = 48000, .wmin = 256, .wmax = 768, },
132 { .rmin = 88200, .rmax = 96000, .wmin = 256, .wmax = 512, },
134 { .rmin = 176400, .rmax = 192000, .wmin = 128, .wmax = 256, },
136 { .rmin = 352800, .rmax = 384000, .wmin = 32, .wmax = 128, },
138 { .rmin = 705600, .rmax = 768000, .wmin = 16, .wmax = 64, },
141 static struct imx_akcodec_tdm_fs_mul ak4458_tdm_fs_mul[] = {
143 * Table 13 - Audio Interface Format
144 * For TDM mode, MCLK should is set to
145 * obtained from 2 * slots * slot_width
147 { .min = 128, .max = 128, .mul = 256 }, /* TDM128 */
148 { .min = 256, .max = 256, .mul = 512 }, /* TDM256 */
149 { .min = 512, .max = 512, .mul = 1024 }, /* TDM512 */
152 static struct imx_akcodec_fs_mul ak4497_fs_mul[] = {
154 * Table 7 - mapping multiplier and speed mode
155 * Tables 8 & 9 - mapping speed mode and LRCK fs
157 { .rmin = 8000, .rmax = 32000, .wmin = 256, .wmax = 1024, }, /* Normal, <= 32kHz */
158 { .rmin = 44100, .rmax = 48000, .wmin = 256, .wmax = 512, }, /* Normal */
159 { .rmin = 88200, .rmax = 96000, .wmin = 256, .wmax = 256, }, /* Double */
160 { .rmin = 176400, .rmax = 192000, .wmin = 128, .wmax = 128, }, /* Quad */
161 { .rmin = 352800, .rmax = 384000, .wmin = 128, .wmax = 128, }, /* Oct */
162 { .rmin = 705600, .rmax = 768000, .wmin = 64, .wmax = 64, }, /* Hex */
166 * Auto MCLK selection based on LRCK for Normal Mode
167 * (Table 4 from datasheet)
169 static struct imx_akcodec_fs_mul ak5558_fs_mul[] = {
170 { .rmin = 8000, .rmax = 32000, .wmin = 512, .wmax = 1024, },
171 { .rmin = 44100, .rmax = 48000, .wmin = 512, .wmax = 512, },
172 { .rmin = 88200, .rmax = 96000, .wmin = 256, .wmax = 256, },
173 { .rmin = 176400, .rmax = 192000, .wmin = 128, .wmax = 128, },
174 { .rmin = 352800, .rmax = 384000, .wmin = 64, .wmax = 64, },
175 { .rmin = 705600, .rmax = 768000, .wmin = 32, .wmax = 32, },
179 * MCLK and BCLK selection based on TDM mode
180 * because of SAI we also add the restriction: MCLK >= 2 * BCLK
181 * (Table 9 from datasheet)
183 static struct imx_akcodec_tdm_fs_mul ak5558_tdm_fs_mul[] = {
184 { .min = 128, .max = 128, .mul = 256 },
185 { .min = 256, .max = 256, .mul = 512 },
186 { .min = 512, .max = 512, .mul = 1024 },
189 static const u32 akcodec_rates[] = {
190 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
191 96000, 176400, 192000, 352800, 384000, 705600, 768000,
194 static const u32 akcodec_tdm_rates[] = {
195 8000, 16000, 32000, 48000, 96000,
198 static const u32 ak4458_channels[] = {
199 1, 2, 4, 6, 8, 10, 12, 14, 16,
202 static const u32 ak4458_tdm_channels[] = {
203 1, 2, 3, 4, 5, 6, 7, 8, 16,
206 static const u32 ak5558_channels[] = {
210 static const u32 ak5558_tdm_channels[] = {
211 1, 2, 3, 4, 5, 6, 7, 8,
214 static bool format_is_dsd(struct snd_pcm_hw_params *params)
216 snd_pcm_format_t format = params_format(params);
219 case SNDRV_PCM_FORMAT_DSD_U8:
220 case SNDRV_PCM_FORMAT_DSD_U16_LE:
221 case SNDRV_PCM_FORMAT_DSD_U16_BE:
222 case SNDRV_PCM_FORMAT_DSD_U32_LE:
223 case SNDRV_PCM_FORMAT_DSD_U32_BE:
230 static bool format_is_tdm(struct dai_link_data *link_data)
232 if (link_data->slots > 2)
238 static bool codec_is_akcodec(unsigned int type)
252 static unsigned long akcodec_get_mclk_rate(struct snd_pcm_substream *substream,
253 struct snd_pcm_hw_params *params,
254 int slots, int slot_width)
256 struct snd_soc_pcm_runtime *rtd = substream->private_data;
257 struct imx_card_data *data = snd_soc_card_get_drvdata(rtd->card);
258 const struct imx_card_plat_data *plat_data = data->plat_data;
259 struct dai_link_data *link_data = &data->link_data[rtd->num];
260 unsigned int width = slots * slot_width;
261 unsigned int rate = params_rate(params);
264 if (format_is_tdm(link_data)) {
265 for (i = 0; i < plat_data->num_tdm_fs_mul; i++) {
266 /* min = max = slots * slots_width */
267 if (width != plat_data->tdm_fs_mul[i].min)
269 return rate * plat_data->tdm_fs_mul[i].mul;
272 for (i = 0; i < plat_data->num_fs_mul; i++) {
273 if (rate >= plat_data->fs_mul[i].rmin &&
274 rate <= plat_data->fs_mul[i].rmax) {
275 width = max(width, plat_data->fs_mul[i].wmin);
276 width = min(width, plat_data->fs_mul[i].wmax);
278 /* Adjust SAI bclk:mclk ratio */
279 width *= link_data->one2one_ratio ? 1 : 2;
286 /* Let DAI manage clk frequency by default */
290 static int imx_aif_hw_params(struct snd_pcm_substream *substream,
291 struct snd_pcm_hw_params *params)
293 struct snd_soc_pcm_runtime *rtd = substream->private_data;
294 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
295 struct snd_soc_card *card = rtd->card;
296 struct imx_card_data *data = snd_soc_card_get_drvdata(card);
297 struct dai_link_data *link_data = &data->link_data[rtd->num];
298 struct imx_card_plat_data *plat_data = data->plat_data;
299 struct device *dev = card->dev;
300 struct snd_soc_dai *codec_dai;
301 unsigned long mclk_freq;
302 unsigned int fmt = rtd->dai_link->dai_fmt;
303 unsigned int slots, slot_width;
306 slots = link_data->slots;
307 slot_width = link_data->slot_width;
309 if (!format_is_tdm(link_data)) {
310 if (format_is_dsd(params)) {
312 slot_width = params_width(params);
313 fmt = (rtd->dai_link->dai_fmt & ~SND_SOC_DAIFMT_FORMAT_MASK) |
317 slot_width = params_physical_width(params);
318 fmt = (rtd->dai_link->dai_fmt & ~SND_SOC_DAIFMT_FORMAT_MASK) |
323 ret = snd_soc_dai_set_fmt(cpu_dai, snd_soc_daifmt_clock_provider_flipped(fmt));
324 if (ret && ret != -ENOTSUPP) {
325 dev_err(dev, "failed to set cpu dai fmt: %d\n", ret);
328 ret = snd_soc_dai_set_tdm_slot(cpu_dai,
332 if (ret && ret != -ENOTSUPP) {
333 dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
337 for_each_rtd_codec_dais(rtd, i, codec_dai) {
338 ret = snd_soc_dai_set_fmt(codec_dai, fmt);
339 if (ret && ret != -ENOTSUPP) {
340 dev_err(dev, "failed to set codec dai[%d] fmt: %d\n", i, ret);
344 ret = snd_soc_dai_set_tdm_slot(codec_dai,
348 if (ret && ret != -ENOTSUPP) {
349 dev_err(dev, "failed to set codec dai[%d] tdm slot: %d\n", i, ret);
355 if (codec_is_akcodec(plat_data->type))
356 mclk_freq = akcodec_get_mclk_rate(substream, params, slots, slot_width);
358 mclk_freq = params_rate(params) * slots * slot_width;
360 if (format_is_dsd(params)) {
361 /* Use the maximum freq from DSD512 (512*44100 = 22579200) */
362 if (!(params_rate(params) % 11025))
363 mclk_freq = IMX_CARD_MCLK_22P5792MHZ;
365 mclk_freq = IMX_CARD_MCLK_24P576MHZ;
368 ret = snd_soc_dai_set_sysclk(cpu_dai, link_data->cpu_sysclk_id, mclk_freq,
370 if (ret && ret != -ENOTSUPP) {
371 dev_err(dev, "failed to set cpui dai mclk1 rate (%lu): %d\n", mclk_freq, ret);
378 static int ak5558_hw_rule_rate(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *r)
380 struct dai_link_data *link_data = r->private;
381 struct snd_interval t = { .min = 8000, .max = 8000, };
382 unsigned long mclk_freq;
386 fs = hw_param_interval(p, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min;
387 fs *= link_data->slots;
389 /* Identify maximum supported rate */
390 for (i = 0; i < ARRAY_SIZE(akcodec_rates); i++) {
391 mclk_freq = fs * akcodec_rates[i];
392 /* Adjust SAI bclk:mclk ratio */
393 mclk_freq *= link_data->one2one_ratio ? 1 : 2;
395 /* Skip rates for which MCLK is beyond supported value */
396 if (mclk_freq > 36864000)
399 if (t.max < akcodec_rates[i])
400 t.max = akcodec_rates[i];
403 return snd_interval_refine(hw_param_interval(p, r->var), &t);
406 static int imx_aif_startup(struct snd_pcm_substream *substream)
408 struct snd_pcm_runtime *runtime = substream->runtime;
409 struct snd_soc_pcm_runtime *rtd = substream->private_data;
410 struct snd_soc_card *card = rtd->card;
411 struct imx_card_data *data = snd_soc_card_get_drvdata(card);
412 struct dai_link_data *link_data = &data->link_data[rtd->num];
413 static struct snd_pcm_hw_constraint_list constraint_rates;
414 static struct snd_pcm_hw_constraint_list constraint_channels;
417 if (format_is_tdm(link_data)) {
418 constraint_channels.list = data->plat_data->support_tdm_channels;
419 constraint_channels.count = data->plat_data->num_tdm_channels;
420 constraint_rates.list = data->plat_data->support_tdm_rates;
421 constraint_rates.count = data->plat_data->num_tdm_rates;
423 constraint_channels.list = data->plat_data->support_channels;
424 constraint_channels.count = data->plat_data->num_channels;
425 constraint_rates.list = data->plat_data->support_rates;
426 constraint_rates.count = data->plat_data->num_rates;
429 if (constraint_channels.count) {
430 ret = snd_pcm_hw_constraint_list(runtime, 0,
431 SNDRV_PCM_HW_PARAM_CHANNELS,
432 &constraint_channels);
437 if (constraint_rates.count) {
438 ret = snd_pcm_hw_constraint_list(runtime, 0,
439 SNDRV_PCM_HW_PARAM_RATE,
445 if (data->plat_data->type == CODEC_AK5558)
446 ret = snd_pcm_hw_rule_add(substream->runtime, 0,
447 SNDRV_PCM_HW_PARAM_RATE,
448 ak5558_hw_rule_rate, link_data,
449 SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1);
454 static const struct snd_soc_ops imx_aif_ops = {
455 .hw_params = imx_aif_hw_params,
456 .startup = imx_aif_startup,
459 static const struct snd_soc_ops imx_aif_ops_be = {
460 .hw_params = imx_aif_hw_params,
463 static int be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
464 struct snd_pcm_hw_params *params)
466 struct snd_soc_card *card = rtd->card;
467 struct imx_card_data *data = snd_soc_card_get_drvdata(card);
468 struct snd_interval *rate;
469 struct snd_mask *mask;
471 rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
472 rate->max = data->asrc_rate;
473 rate->min = data->asrc_rate;
475 mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
477 snd_mask_set(mask, (__force unsigned int)data->asrc_format);
482 static int imx_card_parse_of(struct imx_card_data *data)
484 struct imx_card_plat_data *plat_data = data->plat_data;
485 struct snd_soc_card *card = &data->card;
486 struct snd_soc_dai_link_component *dlc;
487 struct device_node *platform = NULL;
488 struct device_node *codec = NULL;
489 struct device_node *cpu = NULL;
490 struct device_node *np;
491 struct device *dev = card->dev;
492 struct snd_soc_dai_link *link;
493 struct dai_link_data *link_data;
494 struct of_phandle_args args;
499 ret = snd_soc_of_parse_card_name(card, "model");
501 dev_err(dev, "Error parsing card name: %d\n", ret);
506 if (of_property_read_bool(dev->of_node, "audio-routing")) {
507 ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
513 num_links = of_get_child_count(dev->of_node);
515 /* Allocate the DAI link array */
516 card->dai_link = devm_kcalloc(dev, num_links, sizeof(*link), GFP_KERNEL);
520 data->link_data = devm_kcalloc(dev, num_links, sizeof(*link), GFP_KERNEL);
521 if (!data->link_data)
524 card->num_links = num_links;
525 link = card->dai_link;
526 link_data = data->link_data;
528 for_each_child_of_node(dev->of_node, np) {
529 dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL);
535 link->cpus = &dlc[0];
536 link->platforms = &dlc[1];
539 link->num_platforms = 1;
541 ret = of_property_read_string(np, "link-name", &link->name);
543 dev_err(card->dev, "error getting codec dai_link name\n");
547 cpu = of_get_child_by_name(np, "cpu");
549 dev_err(dev, "%s: Can't find cpu DT node\n", link->name);
554 ret = of_parse_phandle_with_args(cpu, "sound-dai",
555 "#sound-dai-cells", 0, &args);
557 dev_err(card->dev, "%s: error getting cpu phandle\n", link->name);
561 if (of_node_name_eq(args.np, "sai")) {
563 link_data->cpu_sysclk_id = FSL_SAI_CLK_MAST1;
565 /* sai may support mclk/bclk = 1 */
566 if (of_property_read_bool(np, "fsl,mclk-equal-bclk")) {
567 link_data->one2one_ratio = true;
572 * i.MX8MQ don't support one2one ratio, then
573 * with ak4497 only 16bit case is supported.
575 for (i = 0; i < ARRAY_SIZE(ak4497_fs_mul); i++) {
576 if (ak4497_fs_mul[i].rmin == 705600 &&
577 ak4497_fs_mul[i].rmax == 768000) {
578 ak4497_fs_mul[i].wmin = 32;
579 ak4497_fs_mul[i].wmax = 32;
585 link->cpus->of_node = args.np;
586 link->platforms->of_node = link->cpus->of_node;
587 link->id = args.args[0];
589 ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name);
591 dev_err_probe(card->dev, ret,
592 "%s: error getting cpu dai name\n", link->name);
596 codec = of_get_child_by_name(np, "codec");
598 ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
600 dev_err_probe(dev, ret, "%s: codec dai not found\n",
605 plat_data->num_codecs = link->num_codecs;
607 /* Check the akcodec type */
608 if (!strcmp(link->codecs->dai_name, "ak4458-aif"))
609 plat_data->type = CODEC_AK4458;
610 else if (!strcmp(link->codecs->dai_name, "ak4497-aif"))
611 plat_data->type = CODEC_AK4497;
612 else if (!strcmp(link->codecs->dai_name, "ak5558-aif"))
613 plat_data->type = CODEC_AK5558;
614 else if (!strcmp(link->codecs->dai_name, "ak5552-aif"))
615 plat_data->type = CODEC_AK5552;
618 dlc = devm_kzalloc(dev, sizeof(*dlc), GFP_KERNEL);
625 link->num_codecs = 1;
627 link->codecs->dai_name = "snd-soc-dummy-dai";
628 link->codecs->name = "snd-soc-dummy";
631 if (!strncmp(link->name, "HiFi-ASRC-FE", 12)) {
634 link->dpcm_merged_chan = 1;
636 ret = of_property_read_u32(args.np, "fsl,asrc-rate", &data->asrc_rate);
638 dev_err(dev, "failed to get output rate\n");
643 ret = of_property_read_u32(args.np, "fsl,asrc-format", &asrc_fmt);
644 data->asrc_format = (__force snd_pcm_format_t)asrc_fmt;
646 /* Fallback to old binding; translate to asrc_format */
647 ret = of_property_read_u32(args.np, "fsl,asrc-width", &width);
650 "failed to decide output format\n");
655 data->asrc_format = SNDRV_PCM_FORMAT_S24_LE;
657 data->asrc_format = SNDRV_PCM_FORMAT_S16_LE;
659 } else if (!strncmp(link->name, "HiFi-ASRC-BE", 12)) {
662 link->platforms->of_node = NULL;
663 link->platforms->name = "snd-soc-dummy";
665 link->be_hw_params_fixup = be_hw_params_fixup;
666 link->ops = &imx_aif_ops_be;
668 link->ops = &imx_aif_ops;
671 if (link->no_pcm || link->dynamic)
672 snd_soc_dai_link_set_capabilities(link);
675 ret = asoc_simple_parse_daifmt(dev, np, codec,
676 NULL, &link->dai_fmt);
678 link->dai_fmt = SND_SOC_DAIFMT_NB_NF |
679 SND_SOC_DAIFMT_CBC_CFC |
683 snd_soc_of_parse_tdm_slot(np, NULL, NULL,
685 &link_data->slot_width);
687 if (!link_data->slots)
688 link_data->slots = 2;
690 if (!link_data->slot_width)
691 link_data->slot_width = 32;
693 link->ignore_pmdown_time = 1;
694 link->stream_name = link->name;
700 of_node_put(platform);
711 of_node_put(platform);
717 static int imx_card_probe(struct platform_device *pdev)
719 struct snd_soc_dai_link *link_be = NULL, *link;
720 struct imx_card_plat_data *plat_data;
721 struct imx_card_data *data;
724 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
728 plat_data = devm_kzalloc(&pdev->dev, sizeof(*plat_data), GFP_KERNEL);
732 data->plat_data = plat_data;
733 data->card.dev = &pdev->dev;
735 dev_set_drvdata(&pdev->dev, &data->card);
736 snd_soc_card_set_drvdata(&data->card, data);
737 ret = imx_card_parse_of(data);
741 data->num_dapm_routes = plat_data->num_codecs + 1;
742 data->dapm_routes = devm_kcalloc(&pdev->dev, data->num_dapm_routes,
743 sizeof(struct snd_soc_dapm_route),
745 if (!data->dapm_routes)
748 /* configure the dapm routes */
749 switch (plat_data->type) {
752 if (plat_data->num_codecs == 1) {
753 data->dapm_routes[0].sink = "Playback";
754 data->dapm_routes[0].source = "CPU-Playback";
757 for (i = 0; i < plat_data->num_codecs; i++) {
758 data->dapm_routes[i].sink =
759 devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d %s",
761 data->dapm_routes[i].source = "CPU-Playback";
764 data->dapm_routes[i].sink = "CPU-Playback";
765 data->dapm_routes[i].source = "ASRC-Playback";
769 if (plat_data->num_codecs == 1) {
770 data->dapm_routes[0].sink = "CPU-Capture";
771 data->dapm_routes[0].source = "Capture";
774 for (i = 0; i < plat_data->num_codecs; i++) {
775 data->dapm_routes[i].source =
776 devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d %s",
778 data->dapm_routes[i].sink = "CPU-Capture";
781 data->dapm_routes[i].sink = "ASRC-Capture";
782 data->dapm_routes[i].source = "CPU-Capture";
788 /* default platform data for akcodecs */
789 if (codec_is_akcodec(plat_data->type)) {
790 plat_data->support_rates = akcodec_rates;
791 plat_data->num_rates = ARRAY_SIZE(akcodec_rates);
792 plat_data->support_tdm_rates = akcodec_tdm_rates;
793 plat_data->num_tdm_rates = ARRAY_SIZE(akcodec_tdm_rates);
795 switch (plat_data->type) {
797 plat_data->fs_mul = ak4458_fs_mul;
798 plat_data->num_fs_mul = ARRAY_SIZE(ak4458_fs_mul);
799 plat_data->tdm_fs_mul = ak4458_tdm_fs_mul;
800 plat_data->num_tdm_fs_mul = ARRAY_SIZE(ak4458_tdm_fs_mul);
801 plat_data->support_channels = ak4458_channels;
802 plat_data->num_channels = ARRAY_SIZE(ak4458_channels);
803 plat_data->support_tdm_channels = ak4458_tdm_channels;
804 plat_data->num_tdm_channels = ARRAY_SIZE(ak4458_tdm_channels);
807 plat_data->fs_mul = ak4497_fs_mul;
808 plat_data->num_fs_mul = ARRAY_SIZE(ak4497_fs_mul);
809 plat_data->support_channels = ak4458_channels;
810 plat_data->num_channels = ARRAY_SIZE(ak4458_channels);
814 plat_data->fs_mul = ak5558_fs_mul;
815 plat_data->num_fs_mul = ARRAY_SIZE(ak5558_fs_mul);
816 plat_data->tdm_fs_mul = ak5558_tdm_fs_mul;
817 plat_data->num_tdm_fs_mul = ARRAY_SIZE(ak5558_tdm_fs_mul);
818 plat_data->support_channels = ak5558_channels;
819 plat_data->num_channels = ARRAY_SIZE(ak5558_channels);
820 plat_data->support_tdm_channels = ak5558_tdm_channels;
821 plat_data->num_tdm_channels = ARRAY_SIZE(ak5558_tdm_channels);
828 /* with asrc as front end */
829 if (data->card.num_links == 3) {
830 data->card.dapm_routes = data->dapm_routes;
831 data->card.num_dapm_routes = data->num_dapm_routes;
832 for_each_card_prelinks(&data->card, i, link) {
833 if (link->no_pcm == 1)
836 for_each_card_prelinks(&data->card, i, link) {
837 if (link->dynamic == 1 && link_be) {
838 link->dpcm_playback = link_be->dpcm_playback;
839 link->dpcm_capture = link_be->dpcm_capture;
844 ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
846 return dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n");
851 static const struct of_device_id imx_card_dt_ids[] = {
852 { .compatible = "fsl,imx-audio-card", },
855 MODULE_DEVICE_TABLE(of, imx_card_dt_ids);
857 static struct platform_driver imx_card_driver = {
860 .pm = &snd_soc_pm_ops,
861 .of_match_table = imx_card_dt_ids,
863 .probe = imx_card_probe,
865 module_platform_driver(imx_card_driver);
867 MODULE_DESCRIPTION("Freescale i.MX ASoC Machine Driver");
868 MODULE_LICENSE("GPL v2");
869 MODULE_ALIAS("platform:imx-card");