2 * ASoC HDMI Transmitter driver for IMX development boards
4 * Copyright (C) 2011-2013 Freescale Semiconductor, Inc.
6 * based on stmp3780_devb_hdmi.c
8 * Vladimir Barinov <vbarinov@embeddedalley.com>
10 * Copyright 2008 SigmaTel, Inc
11 * Copyright 2008 Embedded Alley Solutions, Inc
13 * This file is licensed under the terms of the GNU General Public License
14 * version 2. This program is licensed "as is" without any warranty of any
15 * kind, whether express or implied.
18 #include <linux/module.h>
19 #include <linux/of_platform.h>
20 #include <linux/mfd/mxc-hdmi-core.h>
21 #include <sound/soc.h>
25 /* imx digital audio interface glue - connects codec <--> CPU */
26 static struct snd_soc_dai_link imx_hdmi_dai_link = {
27 .name = "i.MX HDMI Audio Tx",
28 .stream_name = "i.MX HDMI Audio Tx",
29 .codec_dai_name = "hdmi-hifi",
30 .codec_name = "hdmi-audio-codec",
31 .platform_name = "imx-hdmi-audio",
34 static struct snd_soc_card snd_soc_card_imx_hdmi = {
35 .name = "imx-hdmi-soc",
36 .dai_link = &imx_hdmi_dai_link,
40 static struct platform_device *codec_dev;
42 static int imx_hdmi_audio_probe(struct platform_device *pdev)
44 struct device_node *hdmi_np, *np = pdev->dev.of_node;
45 struct snd_soc_card *card = &snd_soc_card_imx_hdmi;
46 struct platform_device *hdmi_pdev;
49 if (!hdmi_get_registered()) {
50 dev_err(&pdev->dev, "initialize HDMI-audio failed. load HDMI-video first!\n");
54 hdmi_np = of_parse_phandle(np, "hdmi-controller", 0);
56 dev_err(&pdev->dev, "failed to find hdmi-audio cpudai\n");
61 hdmi_pdev = of_find_device_by_node(hdmi_np);
63 dev_err(&pdev->dev, "failed to find SSI platform device\n");
68 codec_dev = platform_device_register_simple("hdmi-audio-codec", -1, NULL, 0);
69 if (IS_ERR(codec_dev)) {
70 dev_err(&pdev->dev, "failed to register HDMI audio codec\n");
71 ret = PTR_ERR(codec_dev);
75 card->dev = &pdev->dev;
76 card->dai_link->cpu_dai_name = dev_name(&hdmi_pdev->dev);
78 ret = snd_soc_register_card(card);
80 dev_err(&pdev->dev, "failed to register card: %d\n", ret);
87 platform_device_unregister(codec_dev);
95 static int imx_hdmi_audio_remove(struct platform_device *pdev)
97 struct snd_soc_card *card = &snd_soc_card_imx_hdmi;
99 platform_device_unregister(codec_dev);
100 snd_soc_unregister_card(card);
105 static const struct of_device_id imx_hdmi_dt_ids[] = {
106 { .compatible = "fsl,imx-audio-hdmi", },
109 MODULE_DEVICE_TABLE(of, imx_hdmi_dt_ids);
111 static struct platform_driver imx_hdmi_audio_driver = {
112 .probe = imx_hdmi_audio_probe,
113 .remove = imx_hdmi_audio_remove,
115 .of_match_table = imx_hdmi_dt_ids,
116 .name = "imx-audio-hdmi",
117 .owner = THIS_MODULE,
121 module_platform_driver(imx_hdmi_audio_driver);
123 MODULE_AUTHOR("Freescale Semiconductor, Inc.");
124 MODULE_DESCRIPTION("IMX HDMI TX ASoC driver");
125 MODULE_LICENSE("GPL");
126 MODULE_ALIAS("platform:imx-audio-hdmi");