Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 1 | /* |
| 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 Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 15 | #include <linux/device.h> |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 16 | #include <linux/of_device.h> |
| 17 | #include <linux/of_platform.h> |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 18 | |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 19 | #include <sound/soc.h> |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 20 | |
| 21 | #include "mpc5200_dma.h" |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 22 | |
Takashi Iwai | afc5e65 | 2009-08-07 16:33:53 +0200 | [diff] [blame] | 23 | #define DRV_NAME "pcm030-audio-fabric" |
| 24 | |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 25 | static struct snd_soc_dai_link pcm030_fabric_dai[] = { |
| 26 | { |
| 27 | .name = "AC97", |
| 28 | .stream_name = "AC97 Analog", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 29 | .codec_dai_name = "wm9712-hifi", |
| 30 | .cpu_dai_name = "mpc5200-psc-ac97.0", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 31 | .codec_name = "wm9712-codec", |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 32 | }, |
| 33 | { |
| 34 | .name = "AC97", |
| 35 | .stream_name = "AC97 IEC958", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 36 | .codec_dai_name = "wm9712-aux", |
| 37 | .cpu_dai_name = "mpc5200-psc-ac97.1", |
Liam Girdwood | e94be5f | 2010-10-26 20:07:43 +0100 | [diff] [blame] | 38 | .codec_name = "wm9712-codec", |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 39 | }, |
| 40 | }; |
| 41 | |
Eric Millbrandt | 0840116 | 2012-09-20 10:36:44 -0400 | [diff] [blame^] | 42 | static struct snd_soc_card pcm030_card = { |
Axel Lin | 4c3c5df | 2011-12-22 21:04:54 +0800 | [diff] [blame] | 43 | .name = "pcm030", |
| 44 | .owner = THIS_MODULE, |
| 45 | .dai_link = pcm030_fabric_dai, |
| 46 | .num_links = ARRAY_SIZE(pcm030_fabric_dai), |
| 47 | }; |
| 48 | |
Eric Millbrandt | 0840116 | 2012-09-20 10:36:44 -0400 | [diff] [blame^] | 49 | static int __init pcm030_fabric_probe(struct platform_device *op) |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 50 | { |
Eric Millbrandt | 0840116 | 2012-09-20 10:36:44 -0400 | [diff] [blame^] | 51 | 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 Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 56 | |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 57 | if (!of_machine_is_compatible("phytec,pcm030")) |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 58 | return -ENODEV; |
| 59 | |
Eric Millbrandt | 0840116 | 2012-09-20 10:36:44 -0400 | [diff] [blame^] | 60 | 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 Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 66 | return -ENODEV; |
| 67 | } |
| 68 | |
Eric Millbrandt | 0840116 | 2012-09-20 10:36:44 -0400 | [diff] [blame^] | 69 | for (i = 0; i < card->num_links; i++) |
| 70 | card->dai_link[i].platform_of_node = platform_np; |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 71 | |
Eric Millbrandt | 0840116 | 2012-09-20 10:36:44 -0400 | [diff] [blame^] | 72 | 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 Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 77 | } |
| 78 | |
Eric Millbrandt | 0840116 | 2012-09-20 10:36:44 -0400 | [diff] [blame^] | 79 | static 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 | |
| 89 | static struct of_device_id pcm030_audio_match[] = { |
| 90 | { .compatible = "phytec,pcm030-audio-fabric", }, |
| 91 | {} |
| 92 | }; |
| 93 | MODULE_DEVICE_TABLE(of, pcm030_audio_match); |
| 94 | |
| 95 | static 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 | |
| 105 | module_platform_driver(pcm030_fabric_driver); |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 106 | |
| 107 | |
| 108 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); |
| 109 | MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 fabric driver"); |
| 110 | MODULE_LICENSE("GPL"); |
| 111 | |