1a9262c4fSJon Smirl /* 2a9262c4fSJon Smirl * Phytec pcm030 driver for the PSC of the Freescale MPC52xx 3a9262c4fSJon Smirl * configured as AC97 interface 4a9262c4fSJon Smirl * 5a9262c4fSJon Smirl * Copyright 2008 Jon Smirl, Digispeaker 6a9262c4fSJon Smirl * Author: Jon Smirl <jonsmirl@gmail.com> 7a9262c4fSJon Smirl * 8a9262c4fSJon Smirl * This file is licensed under the terms of the GNU General Public License 9a9262c4fSJon Smirl * version 2. This program is licensed "as is" without any warranty of any 10a9262c4fSJon Smirl * kind, whether express or implied. 11a9262c4fSJon Smirl */ 12a9262c4fSJon Smirl 13a9262c4fSJon Smirl #include <linux/init.h> 14a9262c4fSJon Smirl #include <linux/module.h> 15a9262c4fSJon Smirl #include <linux/device.h> 16a9262c4fSJon Smirl #include <linux/of_device.h> 17a9262c4fSJon Smirl #include <linux/of_platform.h> 18a9262c4fSJon Smirl 19a9262c4fSJon Smirl #include <sound/soc.h> 20a9262c4fSJon Smirl 21a9262c4fSJon Smirl #include "mpc5200_dma.h" 22a9262c4fSJon Smirl 23afc5e652STakashi Iwai #define DRV_NAME "pcm030-audio-fabric" 24afc5e652STakashi Iwai 25a9262c4fSJon Smirl static struct snd_soc_dai_link pcm030_fabric_dai[] = { 26a9262c4fSJon Smirl { 27a9262c4fSJon Smirl .name = "AC97", 28a9262c4fSJon Smirl .stream_name = "AC97 Analog", 29f0fba2adSLiam Girdwood .codec_dai_name = "wm9712-hifi", 30f0fba2adSLiam Girdwood .cpu_dai_name = "mpc5200-psc-ac97.0", 31f0fba2adSLiam Girdwood .codec_name = "wm9712-codec", 32a9262c4fSJon Smirl }, 33a9262c4fSJon Smirl { 34a9262c4fSJon Smirl .name = "AC97", 35a9262c4fSJon Smirl .stream_name = "AC97 IEC958", 36f0fba2adSLiam Girdwood .codec_dai_name = "wm9712-aux", 37f0fba2adSLiam Girdwood .cpu_dai_name = "mpc5200-psc-ac97.1", 38e94be5f3SLiam Girdwood .codec_name = "wm9712-codec", 39a9262c4fSJon Smirl }, 40a9262c4fSJon Smirl }; 41a9262c4fSJon Smirl 4208401161SEric Millbrandt static struct snd_soc_card pcm030_card = { 434c3c5df0SAxel Lin .name = "pcm030", 444c3c5df0SAxel Lin .owner = THIS_MODULE, 454c3c5df0SAxel Lin .dai_link = pcm030_fabric_dai, 464c3c5df0SAxel Lin .num_links = ARRAY_SIZE(pcm030_fabric_dai), 474c3c5df0SAxel Lin }; 484c3c5df0SAxel Lin 4908401161SEric Millbrandt static int __init pcm030_fabric_probe(struct platform_device *op) 50a9262c4fSJon Smirl { 5108401161SEric Millbrandt struct device_node *np = op->dev.of_node; 5208401161SEric Millbrandt struct device_node *platform_np; 5308401161SEric Millbrandt struct snd_soc_card *card = &pcm030_card; 5408401161SEric Millbrandt int ret; 5508401161SEric Millbrandt int i; 56a9262c4fSJon Smirl 5771a157e8SGrant Likely if (!of_machine_is_compatible("phytec,pcm030")) 58a9262c4fSJon Smirl return -ENODEV; 59a9262c4fSJon Smirl 6008401161SEric Millbrandt card->dev = &op->dev; 6108401161SEric Millbrandt platform_set_drvdata(op, card); 6208401161SEric Millbrandt 6308401161SEric Millbrandt platform_np = of_parse_phandle(np, "asoc-platform", 0); 6408401161SEric Millbrandt if (!platform_np) { 6508401161SEric Millbrandt dev_err(&op->dev, "ac97 not registered\n"); 66a9262c4fSJon Smirl return -ENODEV; 67a9262c4fSJon Smirl } 68a9262c4fSJon Smirl 6908401161SEric Millbrandt for (i = 0; i < card->num_links; i++) 7008401161SEric Millbrandt card->dai_link[i].platform_of_node = platform_np; 71a9262c4fSJon Smirl 7208401161SEric Millbrandt ret = snd_soc_register_card(card); 7308401161SEric Millbrandt if (ret) 7408401161SEric Millbrandt dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret); 7508401161SEric Millbrandt 7608401161SEric Millbrandt return ret; 77a9262c4fSJon Smirl } 78a9262c4fSJon Smirl 7908401161SEric Millbrandt static int __devexit pcm030_fabric_remove(struct platform_device *op) 8008401161SEric Millbrandt { 8108401161SEric Millbrandt struct snd_soc_card *card = platform_get_drvdata(op); 8208401161SEric Millbrandt int ret; 8308401161SEric Millbrandt 8408401161SEric Millbrandt ret = snd_soc_unregister_card(card); 8508401161SEric Millbrandt 8608401161SEric Millbrandt return ret; 8708401161SEric Millbrandt } 8808401161SEric Millbrandt 8908401161SEric Millbrandt static struct of_device_id pcm030_audio_match[] = { 9008401161SEric Millbrandt { .compatible = "phytec,pcm030-audio-fabric", }, 9108401161SEric Millbrandt {} 9208401161SEric Millbrandt }; 9308401161SEric Millbrandt MODULE_DEVICE_TABLE(of, pcm030_audio_match); 9408401161SEric Millbrandt 9508401161SEric Millbrandt static struct platform_driver pcm030_fabric_driver = { 9608401161SEric Millbrandt .probe = pcm030_fabric_probe, 9708401161SEric Millbrandt .remove = __devexit_p(pcm030_fabric_remove), 9808401161SEric Millbrandt .driver = { 9908401161SEric Millbrandt .name = DRV_NAME, 10008401161SEric Millbrandt .owner = THIS_MODULE, 10108401161SEric Millbrandt .of_match_table = pcm030_audio_match, 10208401161SEric Millbrandt }, 10308401161SEric Millbrandt }; 10408401161SEric Millbrandt 10508401161SEric Millbrandt module_platform_driver(pcm030_fabric_driver); 106a9262c4fSJon Smirl 107a9262c4fSJon Smirl 108a9262c4fSJon Smirl MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); 109a9262c4fSJon Smirl MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 fabric driver"); 110a9262c4fSJon Smirl MODULE_LICENSE("GPL"); 111a9262c4fSJon Smirl 112