return 0;
 }
 
+static int fsl_asoc_card_spdif_init(struct device_node *codec_np[],
+                                   struct device_node *cpu_np,
+                                   const char *codec_dai_name[],
+                                   struct fsl_asoc_card_priv *priv)
+{
+       struct device *dev = &priv->pdev->dev;
+       struct device_node *np = dev->of_node;
+
+       if (!of_node_name_eq(cpu_np, "spdif")) {
+               dev_err(dev, "CPU phandle invalid, should be an SPDIF device\n");
+               return -EINVAL;
+       }
+
+       priv->dai_link[0].playback_only = true;
+       priv->dai_link[0].capture_only = true;
+
+       for (int i = 0; i < 2; i++) {
+               if (!codec_np[i])
+                       break;
+
+               if (of_device_is_compatible(codec_np[i], "linux,spdif-dit")) {
+                       priv->dai_link[0].capture_only = false;
+                       codec_dai_name[i] = "dit-hifi";
+               } else if (of_device_is_compatible(codec_np[i], "linux,spdif-dir")) {
+                       priv->dai_link[0].playback_only = false;
+                       codec_dai_name[i] = "dir-hifi";
+               }
+       }
+
+       // Old SPDIF DT binding
+       if (!codec_np[0]) {
+               codec_dai_name[0] = snd_soc_dummy_dlc.dai_name;
+               if (of_property_read_bool(np, "spdif-out"))
+                       priv->dai_link[0].capture_only = false;
+               if (of_property_read_bool(np, "spdif-in"))
+                       priv->dai_link[0].playback_only = false;
+       }
+
+       if (priv->dai_link[0].playback_only && priv->dai_link[0].capture_only) {
+               dev_err(dev, "no enabled S/PDIF DAI link\n");
+               return -EINVAL;
+       }
+
+       if (priv->dai_link[0].playback_only) {
+               priv->dai_link[1].dpcm_capture = false;
+               priv->dai_link[2].dpcm_capture = false;
+               priv->card.dapm_routes = audio_map_tx;
+               priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx);
+       } else if (priv->dai_link[0].capture_only) {
+               priv->dai_link[1].dpcm_playback = false;
+               priv->dai_link[2].dpcm_playback = false;
+               priv->card.dapm_routes = audio_map_rx;
+               priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_rx);
+       }
+
+       // No DAPM routes with old bindings and dummy codec
+       if (!codec_np[0]) {
+               priv->card.dapm_routes = NULL;
+               priv->card.num_dapm_routes = 0;
+       }
+
+       if (codec_np[0] && codec_np[1]) {
+               priv->dai_link[0].num_codecs = 2;
+               priv->dai_link[2].num_codecs = 2;
+       }
+
+       return 0;
+}
+
 static int hp_jack_event(struct notifier_block *nb, unsigned long event,
                         void *data)
 {
        priv->pdev = pdev;
 
        cpu_np = of_parse_phandle(np, "audio-cpu", 0);
-       /* Give a chance to old DT binding */
+       /* Give a chance to old DT bindings */
        if (!cpu_np)
                cpu_np = of_parse_phandle(np, "ssi-controller", 0);
+       if (!cpu_np)
+               cpu_np = of_parse_phandle(np, "spdif-controller", 0);
        if (!cpu_np) {
                dev_err(&pdev->dev, "CPU phandle missing or invalid\n");
                ret = -EINVAL;
                priv->codec_priv[0].fll_id = WM8904_CLK_FLL;
                priv->codec_priv[0].pll_id = WM8904_FLL_MCLK;
                priv->dai_fmt |= SND_SOC_DAIFMT_CBP_CFP;
+       } else if (of_device_is_compatible(np, "fsl,imx-audio-spdif")) {
+               ret = fsl_asoc_card_spdif_init(codec_np, cpu_np, codec_dai_name, priv);
+               if (ret)
+                       goto asrc_fail;
        } else {
                dev_err(&pdev->dev, "unknown Device Tree compatible\n");
                ret = -EINVAL;
        of_node_put(bitclkprovider);
        of_node_put(frameprovider);
 
-       if (!fsl_asoc_card_is_ac97(priv) && !codec_dev[0]) {
+       if (!fsl_asoc_card_is_ac97(priv) && !codec_dev[0]
+           && codec_dai_name[0] != snd_soc_dummy_dlc.dai_name) {
                dev_dbg(&pdev->dev, "failed to find codec device\n");
                ret = -EPROBE_DEFER;
                goto asrc_fail;
                codec_comp->dai_name = codec_dai_name[codec_idx];
        }
 
+       // Old SPDIF DT binding support
+       if (codec_dai_name[0] == snd_soc_dummy_dlc.dai_name)
+               priv->dai_link[0].codecs[0].name = snd_soc_dummy_dlc.name;
+
        if (!fsl_asoc_card_is_ac97(priv)) {
                for_each_link_codecs((&(priv->dai_link[0])), codec_idx, codec_comp) {
                        codec_comp->of_node = codec_np[codec_idx];
        { .compatible = "fsl,imx-audio-wm8958", },
        { .compatible = "fsl,imx-audio-nau8822", },
        { .compatible = "fsl,imx-audio-wm8904", },
+       { .compatible = "fsl,imx-audio-spdif", },
        {}
 };
 MODULE_DEVICE_TABLE(of, fsl_asoc_card_dt_ids);
 
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-//
-// Copyright (C) 2013 Freescale Semiconductor, Inc.
-
-#include <linux/module.h>
-#include <linux/of_platform.h>
-#include <sound/soc.h>
-
-struct imx_spdif_data {
-       struct snd_soc_dai_link dai;
-       struct snd_soc_card card;
-};
-
-static int imx_spdif_audio_probe(struct platform_device *pdev)
-{
-       struct device_node *spdif_np, *np = pdev->dev.of_node;
-       struct imx_spdif_data *data;
-       struct snd_soc_dai_link_component *comp;
-       int ret = 0;
-
-       spdif_np = of_parse_phandle(np, "spdif-controller", 0);
-       if (!spdif_np) {
-               dev_err(&pdev->dev, "failed to find spdif-controller\n");
-               ret = -EINVAL;
-               goto end;
-       }
-
-       data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
-       comp = devm_kzalloc(&pdev->dev, sizeof(*comp), GFP_KERNEL);
-       if (!data || !comp) {
-               ret = -ENOMEM;
-               goto end;
-       }
-
-       /*
-        * CPU == Platform
-        * platform is using soc-generic-dmaengine-pcm
-        */
-       data->dai.cpus          =
-       data->dai.platforms     = comp;
-       data->dai.codecs        = &snd_soc_dummy_dlc;
-
-       data->dai.num_cpus      = 1;
-       data->dai.num_codecs    = 1;
-       data->dai.num_platforms = 1;
-
-       data->dai.name = "S/PDIF PCM";
-       data->dai.stream_name = "S/PDIF PCM";
-       data->dai.cpus->of_node = spdif_np;
-       data->dai.playback_only = true;
-       data->dai.capture_only = true;
-
-       if (of_property_read_bool(np, "spdif-out"))
-               data->dai.capture_only = false;
-
-       if (of_property_read_bool(np, "spdif-in"))
-               data->dai.playback_only = false;
-
-       if (data->dai.playback_only && data->dai.capture_only) {
-               dev_err(&pdev->dev, "no enabled S/PDIF DAI link\n");
-               goto end;
-       }
-
-       data->card.dev = &pdev->dev;
-       data->card.dai_link = &data->dai;
-       data->card.num_links = 1;
-       data->card.owner = THIS_MODULE;
-
-       ret = snd_soc_of_parse_card_name(&data->card, "model");
-       if (ret)
-               goto end;
-
-       ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
-       if (ret)
-               dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n");
-
-end:
-       of_node_put(spdif_np);
-
-       return ret;
-}
-
-static const struct of_device_id imx_spdif_dt_ids[] = {
-       { .compatible = "fsl,imx-audio-spdif", },
-       { /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, imx_spdif_dt_ids);
-
-static struct platform_driver imx_spdif_driver = {
-       .driver = {
-               .name = "imx-spdif",
-               .pm = &snd_soc_pm_ops,
-               .of_match_table = imx_spdif_dt_ids,
-       },
-       .probe = imx_spdif_audio_probe,
-};
-
-module_platform_driver(imx_spdif_driver);
-
-MODULE_AUTHOR("Freescale Semiconductor, Inc.");
-MODULE_DESCRIPTION("Freescale i.MX S/PDIF machine driver");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:imx-spdif");