return np;
 }
 
+static void tegra_machine_unregister_codec(void *pdev)
+{
+       platform_device_unregister(pdev);
+}
+
+static int tegra_machine_register_codec(struct device *dev, const char *name)
+{
+       struct platform_device *pdev;
+       int err;
+
+       if (!name)
+               return 0;
+
+       pdev = platform_device_register_simple(name, -1, NULL, 0);
+       if (IS_ERR(pdev))
+               return PTR_ERR(pdev);
+
+       err = devm_add_action_or_reset(dev, tegra_machine_unregister_codec,
+                                      pdev);
+       if (err)
+               return err;
+
+       return 0;
+}
+
 int tegra_asoc_machine_probe(struct platform_device *pdev)
 {
-       struct device_node *np_codec, *np_i2s;
+       struct device_node *np_codec, *np_i2s, *np_ac97;
        const struct tegra_asoc_data *asoc;
        struct device *dev = &pdev->dev;
        struct tegra_machine *machine;
                        return err;
        }
 
-       np_codec = tegra_machine_parse_phandle(dev, "nvidia,audio-codec");
-       if (IS_ERR(np_codec))
-               return PTR_ERR(np_codec);
+       if (asoc->set_ac97) {
+               err = tegra_machine_register_codec(dev, asoc->codec_dev_name);
+               if (err)
+                       return err;
+
+               np_ac97 = tegra_machine_parse_phandle(dev, "nvidia,ac97-controller");
+               if (IS_ERR(np_ac97))
+                       return PTR_ERR(np_ac97);
 
-       np_i2s = tegra_machine_parse_phandle(dev, "nvidia,i2s-controller");
-       if (IS_ERR(np_i2s))
-               return PTR_ERR(np_i2s);
+               card->dai_link->cpus->of_node = np_ac97;
+               card->dai_link->platforms->of_node = np_ac97;
+       } else {
+               np_codec = tegra_machine_parse_phandle(dev, "nvidia,audio-codec");
+               if (IS_ERR(np_codec))
+                       return PTR_ERR(np_codec);
 
-       card->dai_link->cpus->of_node = np_i2s;
-       card->dai_link->codecs->of_node = np_codec;
-       card->dai_link->platforms->of_node = np_i2s;
+               np_i2s = tegra_machine_parse_phandle(dev, "nvidia,i2s-controller");
+               if (IS_ERR(np_i2s))
+                       return PTR_ERR(np_i2s);
+
+               card->dai_link->cpus->of_node = np_i2s;
+               card->dai_link->codecs->of_node = np_codec;
+               card->dai_link->platforms->of_node = np_i2s;
+       }
 
        if (asoc->add_common_controls) {
                card->controls = tegra_machine_controls;
 static const struct tegra_asoc_data tegra_wm9712_data = {
        .card = &snd_soc_tegra_wm9712,
        .add_common_dapm_widgets = true,
+       .codec_dev_name = "wm9712-codec",
        .set_ac97 = true,
 };