Commit e968194b authored by Shawn Guo's avatar Shawn Guo Committed by Mark Brown

ASoC: mxs: add device tree support for mxs-sgtl5000

Add device tree probe for mxs-sgtl5000 machine driver.
Signed-off-by: default avatarShawn Guo <shawn.guo@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 08641c7c
* Freescale MXS audio complex with SGTL5000 codec
Required properties:
- compatible: "fsl,mxs-audio-sgtl5000"
- model: The user-visible name of this sound complex
- saif-controllers: The phandle list of the MXS SAIF controller
- audio-codec: The phandle of the SGTL5000 audio codec
Example:
sound {
compatible = "fsl,imx28-evk-sgtl5000",
"fsl,mxs-audio-sgtl5000";
model = "imx28-evk-sgtl5000";
saif-controllers = <&saif0 &saif1>;
audio-codec = <&sgtl5000>;
};
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/soc.h> #include <sound/soc.h>
...@@ -110,11 +112,48 @@ static struct snd_soc_card mxs_sgtl5000 = { ...@@ -110,11 +112,48 @@ static struct snd_soc_card mxs_sgtl5000 = {
.num_links = ARRAY_SIZE(mxs_sgtl5000_dai), .num_links = ARRAY_SIZE(mxs_sgtl5000_dai),
}; };
static int __devinit mxs_sgtl5000_probe_dt(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct device_node *saif_np[2], *codec_np;
int i, ret = 0;
if (!np)
return 1; /* no device tree */
saif_np[0] = of_parse_phandle(np, "saif-controllers", 0);
saif_np[1] = of_parse_phandle(np, "saif-controllers", 1);
codec_np = of_parse_phandle(np, "audio-codec", 0);
if (!saif_np[0] || !saif_np[1] || !codec_np) {
dev_err(&pdev->dev, "phandle missing or invalid\n");
return -EINVAL;
}
for (i = 0; i < 2; i++) {
mxs_sgtl5000_dai[i].codec_name = NULL;
mxs_sgtl5000_dai[i].codec_of_node = codec_np;
mxs_sgtl5000_dai[i].cpu_dai_name = NULL;
mxs_sgtl5000_dai[i].cpu_dai_of_node = saif_np[i];
mxs_sgtl5000_dai[i].platform_name = NULL;
mxs_sgtl5000_dai[i].platform_of_node = saif_np[i];
}
of_node_put(codec_np);
of_node_put(saif_np[0]);
of_node_put(saif_np[1]);
return ret;
}
static int __devinit mxs_sgtl5000_probe(struct platform_device *pdev) static int __devinit mxs_sgtl5000_probe(struct platform_device *pdev)
{ {
struct snd_soc_card *card = &mxs_sgtl5000; struct snd_soc_card *card = &mxs_sgtl5000;
int ret; int ret;
ret = mxs_sgtl5000_probe_dt(pdev);
if (ret < 0)
return ret;
/* /*
* Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w). * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w).
* The Sgtl5000 sysclk is derived from saif0 mclk and it's range * The Sgtl5000 sysclk is derived from saif0 mclk and it's range
...@@ -148,10 +187,17 @@ static int __devexit mxs_sgtl5000_remove(struct platform_device *pdev) ...@@ -148,10 +187,17 @@ static int __devexit mxs_sgtl5000_remove(struct platform_device *pdev)
return 0; return 0;
} }
static const struct of_device_id mxs_sgtl5000_dt_ids[] = {
{ .compatible = "fsl,mxs-audio-sgtl5000", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mxs_sgtl5000_dt_ids);
static struct platform_driver mxs_sgtl5000_audio_driver = { static struct platform_driver mxs_sgtl5000_audio_driver = {
.driver = { .driver = {
.name = "mxs-sgtl5000", .name = "mxs-sgtl5000",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = mxs_sgtl5000_dt_ids,
}, },
.probe = mxs_sgtl5000_probe, .probe = mxs_sgtl5000_probe,
.remove = __devexit_p(mxs_sgtl5000_remove), .remove = __devexit_p(mxs_sgtl5000_remove),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment