diff options
author | Bo Shen <voice.shen@atmel.com> | 2012-11-14 05:09:11 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-11-15 20:27:27 -0500 |
commit | 531f67e41dcde1e358cf821d056241a66355cf03 (patch) | |
tree | 9ea52e17fbd5971d1e3857ab90f22c9bd447dbab /sound/soc | |
parent | 3310b57d62202b29b3bed37c714ee9c2054ded75 (diff) |
ASoC: at91sam9g20ek-wm8731: convert to dt support
convert at91sam9g20ek with wm8731 to device tree support
Signed-off-by: Bo Shen <voice.shen@atmel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/atmel/Kconfig | 3 | ||||
-rw-r--r-- | sound/soc/atmel/sam9g20_wm8731.c | 63 |
2 files changed, 62 insertions, 4 deletions
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 72b09cfd3dc3..397ec7526a5a 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig | |||
@@ -16,8 +16,7 @@ config SND_ATMEL_SOC_SSC | |||
16 | 16 | ||
17 | config SND_AT91_SOC_SAM9G20_WM8731 | 17 | config SND_AT91_SOC_SAM9G20_WM8731 |
18 | tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board" | 18 | tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board" |
19 | depends on ATMEL_SSC && ARCH_AT91SAM9G20 && SND_ATMEL_SOC && \ | 19 | depends on ATMEL_SSC && SND_ATMEL_SOC && AT91_PROGRAMMABLE_CLOCKS |
20 | AT91_PROGRAMMABLE_CLOCKS | ||
21 | select SND_ATMEL_SOC_SSC | 20 | select SND_ATMEL_SOC_SSC |
22 | select SND_SOC_WM8731 | 21 | select SND_SOC_WM8731 |
23 | help | 22 | help |
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index 4deba189bf10..0744610e53dd 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c | |||
@@ -38,6 +38,8 @@ | |||
38 | #include <linux/platform_device.h> | 38 | #include <linux/platform_device.h> |
39 | #include <linux/i2c.h> | 39 | #include <linux/i2c.h> |
40 | 40 | ||
41 | #include <linux/pinctrl/consumer.h> | ||
42 | |||
41 | #include <linux/atmel-ssc.h> | 43 | #include <linux/atmel-ssc.h> |
42 | 44 | ||
43 | #include <sound/core.h> | 45 | #include <sound/core.h> |
@@ -197,12 +199,24 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = { | |||
197 | 199 | ||
198 | static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev) | 200 | static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev) |
199 | { | 201 | { |
202 | struct device_node *np = pdev->dev.of_node; | ||
203 | struct device_node *codec_np, *cpu_np; | ||
200 | struct clk *pllb; | 204 | struct clk *pllb; |
201 | struct snd_soc_card *card = &snd_soc_at91sam9g20ek; | 205 | struct snd_soc_card *card = &snd_soc_at91sam9g20ek; |
206 | struct pinctrl *pinctrl; | ||
202 | int ret; | 207 | int ret; |
203 | 208 | ||
204 | if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) | 209 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); |
205 | return -ENODEV; | 210 | if (IS_ERR(pinctrl)) { |
211 | dev_err(&pdev->dev, "Failed to request pinctrl for mck\n"); | ||
212 | return PTR_ERR(pinctrl); | ||
213 | } | ||
214 | |||
215 | if (!np) { | ||
216 | if (!(machine_is_at91sam9g20ek() || | ||
217 | machine_is_at91sam9g20ek_2mmc())) | ||
218 | return -ENODEV; | ||
219 | } | ||
206 | 220 | ||
207 | ret = atmel_ssc_set_audio(0); | 221 | ret = atmel_ssc_set_audio(0); |
208 | if (ret) { | 222 | if (ret) { |
@@ -236,6 +250,42 @@ static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev) | |||
236 | clk_set_rate(mclk, MCLK_RATE); | 250 | clk_set_rate(mclk, MCLK_RATE); |
237 | 251 | ||
238 | card->dev = &pdev->dev; | 252 | card->dev = &pdev->dev; |
253 | |||
254 | /* Parse device node info */ | ||
255 | if (np) { | ||
256 | ret = snd_soc_of_parse_card_name(card, "atmel,model"); | ||
257 | if (ret) | ||
258 | goto err; | ||
259 | |||
260 | ret = snd_soc_of_parse_audio_routing(card, | ||
261 | "atmel,audio-routing"); | ||
262 | if (ret) | ||
263 | goto err; | ||
264 | |||
265 | /* Parse codec info */ | ||
266 | at91sam9g20ek_dai.codec_name = NULL; | ||
267 | codec_np = of_parse_phandle(np, "atmel,audio-codec", 0); | ||
268 | if (!codec_np) { | ||
269 | dev_err(&pdev->dev, "codec info missing\n"); | ||
270 | return -EINVAL; | ||
271 | } | ||
272 | at91sam9g20ek_dai.codec_of_node = codec_np; | ||
273 | |||
274 | /* Parse dai and platform info */ | ||
275 | at91sam9g20ek_dai.cpu_dai_name = NULL; | ||
276 | at91sam9g20ek_dai.platform_name = NULL; | ||
277 | cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0); | ||
278 | if (!cpu_np) { | ||
279 | dev_err(&pdev->dev, "dai and pcm info missing\n"); | ||
280 | return -EINVAL; | ||
281 | } | ||
282 | at91sam9g20ek_dai.cpu_of_node = cpu_np; | ||
283 | at91sam9g20ek_dai.platform_of_node = cpu_np; | ||
284 | |||
285 | of_node_put(codec_np); | ||
286 | of_node_put(cpu_np); | ||
287 | } | ||
288 | |||
239 | ret = snd_soc_register_card(card); | 289 | ret = snd_soc_register_card(card); |
240 | if (ret) { | 290 | if (ret) { |
241 | printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n"); | 291 | printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n"); |
@@ -263,10 +313,19 @@ static int __devexit at91sam9g20ek_audio_remove(struct platform_device *pdev) | |||
263 | return 0; | 313 | return 0; |
264 | } | 314 | } |
265 | 315 | ||
316 | #ifdef CONFIG_OF | ||
317 | static const struct of_device_id at91sam9g20ek_wm8731_dt_ids[] = { | ||
318 | { .compatible = "atmel,at91sam9g20ek-wm8731-audio", }, | ||
319 | { } | ||
320 | }; | ||
321 | MODULE_DEVICE_TABLE(of, at91sam9g20ek_wm8731_dt_ids); | ||
322 | #endif | ||
323 | |||
266 | static struct platform_driver at91sam9g20ek_audio_driver = { | 324 | static struct platform_driver at91sam9g20ek_audio_driver = { |
267 | .driver = { | 325 | .driver = { |
268 | .name = "at91sam9g20ek-audio", | 326 | .name = "at91sam9g20ek-audio", |
269 | .owner = THIS_MODULE, | 327 | .owner = THIS_MODULE, |
328 | .of_match_table = of_match_ptr(at91sam9g20ek_wm8731_dt_ids), | ||
270 | }, | 329 | }, |
271 | .probe = at91sam9g20ek_audio_probe, | 330 | .probe = at91sam9g20ek_audio_probe, |
272 | .remove = __devexit_p(at91sam9g20ek_audio_remove), | 331 | .remove = __devexit_p(at91sam9g20ek_audio_remove), |