aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/mxs
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2012-05-11 10:24:18 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-05-12 06:04:59 -0400
commite968194b45c4e8077dada75c5bae5660b37628fe (patch)
tree9da66cff5aa5373a694ea049a8a5633f956acdec /sound/soc/mxs
parent08641c7c74dddfcd726512edfaa3b4cbe42e523e (diff)
ASoC: mxs: add device tree support for mxs-sgtl5000
Add device tree probe for mxs-sgtl5000 machine driver. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/mxs')
-rw-r--r--sound/soc/mxs/mxs-sgtl5000.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c
index e9e6112ff196..3e6e8764b2e6 100644
--- a/sound/soc/mxs/mxs-sgtl5000.c
+++ b/sound/soc/mxs/mxs-sgtl5000.c
@@ -18,6 +18,8 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/of.h>
22#include <linux/of_device.h>
21#include <sound/core.h> 23#include <sound/core.h>
22#include <sound/pcm.h> 24#include <sound/pcm.h>
23#include <sound/soc.h> 25#include <sound/soc.h>
@@ -110,11 +112,48 @@ static struct snd_soc_card mxs_sgtl5000 = {
110 .num_links = ARRAY_SIZE(mxs_sgtl5000_dai), 112 .num_links = ARRAY_SIZE(mxs_sgtl5000_dai),
111}; 113};
112 114
115static int __devinit mxs_sgtl5000_probe_dt(struct platform_device *pdev)
116{
117 struct device_node *np = pdev->dev.of_node;
118 struct device_node *saif_np[2], *codec_np;
119 int i, ret = 0;
120
121 if (!np)
122 return 1; /* no device tree */
123
124 saif_np[0] = of_parse_phandle(np, "saif-controllers", 0);
125 saif_np[1] = of_parse_phandle(np, "saif-controllers", 1);
126 codec_np = of_parse_phandle(np, "audio-codec", 0);
127 if (!saif_np[0] || !saif_np[1] || !codec_np) {
128 dev_err(&pdev->dev, "phandle missing or invalid\n");
129 return -EINVAL;
130 }
131
132 for (i = 0; i < 2; i++) {
133 mxs_sgtl5000_dai[i].codec_name = NULL;
134 mxs_sgtl5000_dai[i].codec_of_node = codec_np;
135 mxs_sgtl5000_dai[i].cpu_dai_name = NULL;
136 mxs_sgtl5000_dai[i].cpu_dai_of_node = saif_np[i];
137 mxs_sgtl5000_dai[i].platform_name = NULL;
138 mxs_sgtl5000_dai[i].platform_of_node = saif_np[i];
139 }
140
141 of_node_put(codec_np);
142 of_node_put(saif_np[0]);
143 of_node_put(saif_np[1]);
144
145 return ret;
146}
147
113static int __devinit mxs_sgtl5000_probe(struct platform_device *pdev) 148static int __devinit mxs_sgtl5000_probe(struct platform_device *pdev)
114{ 149{
115 struct snd_soc_card *card = &mxs_sgtl5000; 150 struct snd_soc_card *card = &mxs_sgtl5000;
116 int ret; 151 int ret;
117 152
153 ret = mxs_sgtl5000_probe_dt(pdev);
154 if (ret < 0)
155 return ret;
156
118 /* 157 /*
119 * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w). 158 * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w).
120 * The Sgtl5000 sysclk is derived from saif0 mclk and it's range 159 * 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 return 0; 187 return 0;
149} 188}
150 189
190static const struct of_device_id mxs_sgtl5000_dt_ids[] = {
191 { .compatible = "fsl,mxs-audio-sgtl5000", },
192 { /* sentinel */ }
193};
194MODULE_DEVICE_TABLE(of, mxs_sgtl5000_dt_ids);
195
151static struct platform_driver mxs_sgtl5000_audio_driver = { 196static struct platform_driver mxs_sgtl5000_audio_driver = {
152 .driver = { 197 .driver = {
153 .name = "mxs-sgtl5000", 198 .name = "mxs-sgtl5000",
154 .owner = THIS_MODULE, 199 .owner = THIS_MODULE,
200 .of_match_table = mxs_sgtl5000_dt_ids,
155 }, 201 },
156 .probe = mxs_sgtl5000_probe, 202 .probe = mxs_sgtl5000_probe,
157 .remove = __devexit_p(mxs_sgtl5000_remove), 203 .remove = __devexit_p(mxs_sgtl5000_remove),