blob: 893e24034816036c146f409dbb81305167bbfe5d [file] [log] [blame]
Jon Smirla9262c42009-05-26 08:34:12 -04001/*
2 * Phytec pcm030 driver for the PSC of the Freescale MPC52xx
3 * configured as AC97 interface
4 *
5 * Copyright 2008 Jon Smirl, Digispeaker
6 * Author: Jon Smirl <jonsmirl@gmail.com>
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
Jon Smirla9262c42009-05-26 08:34:12 -040015#include <linux/device.h>
Jon Smirla9262c42009-05-26 08:34:12 -040016#include <linux/of_device.h>
17#include <linux/of_platform.h>
Jon Smirla9262c42009-05-26 08:34:12 -040018
Jon Smirla9262c42009-05-26 08:34:12 -040019#include <sound/soc.h>
Jon Smirla9262c42009-05-26 08:34:12 -040020
21#include "mpc5200_dma.h"
Jon Smirla9262c42009-05-26 08:34:12 -040022
Takashi Iwaiafc5e652009-08-07 16:33:53 +020023#define DRV_NAME "pcm030-audio-fabric"
24
Jon Smirla9262c42009-05-26 08:34:12 -040025static struct snd_soc_dai_link pcm030_fabric_dai[] = {
26{
27 .name = "AC97",
28 .stream_name = "AC97 Analog",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000029 .codec_dai_name = "wm9712-hifi",
30 .cpu_dai_name = "mpc5200-psc-ac97.0",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000031 .codec_name = "wm9712-codec",
Jon Smirla9262c42009-05-26 08:34:12 -040032},
33{
34 .name = "AC97",
35 .stream_name = "AC97 IEC958",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000036 .codec_dai_name = "wm9712-aux",
37 .cpu_dai_name = "mpc5200-psc-ac97.1",
Liam Girdwoode94be5f2010-10-26 20:07:43 +010038 .codec_name = "wm9712-codec",
Jon Smirla9262c42009-05-26 08:34:12 -040039},
40};
41
Eric Millbrandt08401162012-09-20 10:36:44 -040042static struct snd_soc_card pcm030_card = {
Axel Lin4c3c5df2011-12-22 21:04:54 +080043 .name = "pcm030",
44 .owner = THIS_MODULE,
45 .dai_link = pcm030_fabric_dai,
46 .num_links = ARRAY_SIZE(pcm030_fabric_dai),
47};
48
Eric Millbrandt08401162012-09-20 10:36:44 -040049static int __init pcm030_fabric_probe(struct platform_device *op)
Jon Smirla9262c42009-05-26 08:34:12 -040050{
Eric Millbrandt08401162012-09-20 10:36:44 -040051 struct device_node *np = op->dev.of_node;
52 struct device_node *platform_np;
53 struct snd_soc_card *card = &pcm030_card;
54 int ret;
55 int i;
Jon Smirla9262c42009-05-26 08:34:12 -040056
Grant Likely71a157e2010-02-01 21:34:14 -070057 if (!of_machine_is_compatible("phytec,pcm030"))
Jon Smirla9262c42009-05-26 08:34:12 -040058 return -ENODEV;
59
Eric Millbrandt08401162012-09-20 10:36:44 -040060 card->dev = &op->dev;
61 platform_set_drvdata(op, card);
62
63 platform_np = of_parse_phandle(np, "asoc-platform", 0);
64 if (!platform_np) {
65 dev_err(&op->dev, "ac97 not registered\n");
Jon Smirla9262c42009-05-26 08:34:12 -040066 return -ENODEV;
67 }
68
Eric Millbrandt08401162012-09-20 10:36:44 -040069 for (i = 0; i < card->num_links; i++)
70 card->dai_link[i].platform_of_node = platform_np;
Jon Smirla9262c42009-05-26 08:34:12 -040071
Eric Millbrandt08401162012-09-20 10:36:44 -040072 ret = snd_soc_register_card(card);
73 if (ret)
74 dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);
75
76 return ret;
Jon Smirla9262c42009-05-26 08:34:12 -040077}
78
Eric Millbrandt08401162012-09-20 10:36:44 -040079static int __devexit pcm030_fabric_remove(struct platform_device *op)
80{
81 struct snd_soc_card *card = platform_get_drvdata(op);
82 int ret;
83
84 ret = snd_soc_unregister_card(card);
85
86 return ret;
87}
88
89static struct of_device_id pcm030_audio_match[] = {
90 { .compatible = "phytec,pcm030-audio-fabric", },
91 {}
92};
93MODULE_DEVICE_TABLE(of, pcm030_audio_match);
94
95static struct platform_driver pcm030_fabric_driver = {
96 .probe = pcm030_fabric_probe,
97 .remove = __devexit_p(pcm030_fabric_remove),
98 .driver = {
99 .name = DRV_NAME,
100 .owner = THIS_MODULE,
101 .of_match_table = pcm030_audio_match,
102 },
103};
104
105module_platform_driver(pcm030_fabric_driver);
Jon Smirla9262c42009-05-26 08:34:12 -0400106
107
108MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>");
109MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 fabric driver");
110MODULE_LICENSE("GPL");
111