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> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/of_device.h> |
| 19 | #include <linux/of_platform.h> |
| 20 | #include <linux/dma-mapping.h> |
| 21 | |
| 22 | #include <sound/core.h> |
| 23 | #include <sound/pcm.h> |
| 24 | #include <sound/pcm_params.h> |
| 25 | #include <sound/initval.h> |
| 26 | #include <sound/soc.h> |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 27 | |
| 28 | #include "mpc5200_dma.h" |
| 29 | #include "mpc5200_psc_ac97.h" |
| 30 | #include "../codecs/wm9712.h" |
| 31 | |
Takashi Iwai | afc5e65 | 2009-08-07 16:33:53 +0200 | [diff] [blame] | 32 | #define DRV_NAME "pcm030-audio-fabric" |
| 33 | |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 34 | static struct snd_soc_card card; |
| 35 | |
| 36 | static struct snd_soc_dai_link pcm030_fabric_dai[] = { |
| 37 | { |
| 38 | .name = "AC97", |
| 39 | .stream_name = "AC97 Analog", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 40 | .codec_dai_name = "wm9712-hifi", |
| 41 | .cpu_dai_name = "mpc5200-psc-ac97.0", |
| 42 | .platform_name = "mpc5200-pcm-audio", |
| 43 | .codec_name = "wm9712-codec", |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 44 | }, |
| 45 | { |
| 46 | .name = "AC97", |
| 47 | .stream_name = "AC97 IEC958", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 48 | .codec_dai_name = "wm9712-aux", |
| 49 | .cpu_dai_name = "mpc5200-psc-ac97.1", |
| 50 | .platform_name = "mpc5200-pcm-audio", |
Liam Girdwood | e94be5f | 2010-10-26 20:07:43 +0100 | [diff] [blame] | 51 | .codec_name = "wm9712-codec", |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 52 | }, |
| 53 | }; |
| 54 | |
| 55 | static __init int pcm030_fabric_init(void) |
| 56 | { |
| 57 | struct platform_device *pdev; |
| 58 | int rc; |
| 59 | |
Grant Likely | 71a157e | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 60 | if (!of_machine_is_compatible("phytec,pcm030")) |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 61 | return -ENODEV; |
| 62 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 63 | |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 64 | card.name = "pcm030"; |
| 65 | card.dai_link = pcm030_fabric_dai; |
| 66 | card.num_links = ARRAY_SIZE(pcm030_fabric_dai); |
| 67 | |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 68 | pdev = platform_device_alloc("soc-audio", 1); |
| 69 | if (!pdev) { |
| 70 | pr_err("pcm030_fabric_init: platform_device_alloc() failed\n"); |
| 71 | return -ENODEV; |
| 72 | } |
| 73 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 74 | platform_set_drvdata(pdev, &card); |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 75 | |
| 76 | rc = platform_device_add(pdev); |
| 77 | if (rc) { |
| 78 | pr_err("pcm030_fabric_init: platform_device_add() failed\n"); |
Axel Lin | 917dac0 | 2010-11-25 15:08:31 +0800 | [diff] [blame^] | 79 | platform_device_put(pdev); |
Jon Smirl | a9262c4 | 2009-05-26 08:34:12 -0400 | [diff] [blame] | 80 | return -ENODEV; |
| 81 | } |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | module_init(pcm030_fabric_init); |
| 86 | |
| 87 | |
| 88 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); |
| 89 | MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 fabric driver"); |
| 90 | MODULE_LICENSE("GPL"); |
| 91 | |