Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 1 | /* |
| 2 | * DB1200 ASoC audio fabric support code. |
| 3 | * |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 4 | * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com> |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/moduleparam.h> |
| 10 | #include <linux/timer.h> |
| 11 | #include <linux/interrupt.h> |
| 12 | #include <linux/platform_device.h> |
| 13 | #include <sound/core.h> |
| 14 | #include <sound/pcm.h> |
| 15 | #include <sound/soc.h> |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 16 | #include <asm/mach-au1x00/au1000.h> |
| 17 | #include <asm/mach-au1x00/au1xxx_psc.h> |
| 18 | #include <asm/mach-au1x00/au1xxx_dbdma.h> |
| 19 | #include <asm/mach-db1x00/bcsr.h> |
| 20 | |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 21 | #include "../codecs/wm8731.h" |
| 22 | #include "psc.h" |
| 23 | |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 24 | static struct platform_device_id db1200_pids[] = { |
| 25 | { |
| 26 | .name = "db1200-ac97", |
| 27 | .driver_data = 0, |
| 28 | }, { |
| 29 | .name = "db1200-i2s", |
| 30 | .driver_data = 1, |
| 31 | }, |
| 32 | {}, |
| 33 | }; |
| 34 | |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 35 | /*------------------------- AC97 PART ---------------------------*/ |
| 36 | |
| 37 | static struct snd_soc_dai_link db1200_ac97_dai = { |
| 38 | .name = "AC97", |
| 39 | .stream_name = "AC97 HiFi", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 40 | .codec_dai_name = "ac97-hifi", |
Manuel Lauss | ffc4fdb | 2010-08-26 14:53:51 +0200 | [diff] [blame] | 41 | .cpu_dai_name = "au1xpsc_ac97.1", |
| 42 | .platform_name = "au1xpsc-pcm.1", |
| 43 | .codec_name = "ac97-codec.1", |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | static struct snd_soc_card db1200_ac97_machine = { |
| 47 | .name = "DB1200_AC97", |
| 48 | .dai_link = &db1200_ac97_dai, |
| 49 | .num_links = 1, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | /*------------------------- I2S PART ---------------------------*/ |
| 53 | |
| 54 | static int db1200_i2s_startup(struct snd_pcm_substream *substream) |
| 55 | { |
| 56 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 57 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 58 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 59 | int ret; |
| 60 | |
| 61 | /* WM8731 has its own 12MHz crystal */ |
Mark Brown | 9745e82 | 2010-08-17 23:40:24 +0100 | [diff] [blame] | 62 | snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 63 | 12000000, SND_SOC_CLOCK_IN); |
| 64 | |
| 65 | /* codec is bitclock and lrclk master */ |
| 66 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J | |
| 67 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); |
| 68 | if (ret < 0) |
| 69 | goto out; |
| 70 | |
| 71 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J | |
| 72 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); |
| 73 | if (ret < 0) |
| 74 | goto out; |
| 75 | |
| 76 | ret = 0; |
| 77 | out: |
| 78 | return ret; |
| 79 | } |
| 80 | |
| 81 | static struct snd_soc_ops db1200_i2s_wm8731_ops = { |
| 82 | .startup = db1200_i2s_startup, |
| 83 | }; |
| 84 | |
| 85 | static struct snd_soc_dai_link db1200_i2s_dai = { |
| 86 | .name = "WM8731", |
| 87 | .stream_name = "WM8731 PCM", |
Manuel Lauss | ffc4fdb | 2010-08-26 14:53:51 +0200 | [diff] [blame] | 88 | .codec_dai_name = "wm8731-hifi", |
| 89 | .cpu_dai_name = "au1xpsc_i2s.1", |
| 90 | .platform_name = "au1xpsc-pcm.1", |
Mark Brown | 99b59f3 | 2011-03-27 14:35:15 +0100 | [diff] [blame] | 91 | .codec_name = "wm8731.0-001b", |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 92 | .ops = &db1200_i2s_wm8731_ops, |
| 93 | }; |
| 94 | |
| 95 | static struct snd_soc_card db1200_i2s_machine = { |
| 96 | .name = "DB1200_I2S", |
| 97 | .dai_link = &db1200_i2s_dai, |
| 98 | .num_links = 1, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | /*------------------------- COMMON PART ---------------------------*/ |
| 102 | |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 103 | static struct snd_soc_card *db1200_cards[] __devinitdata = { |
| 104 | &db1200_ac97_machine, |
| 105 | &db1200_i2s_machine, |
| 106 | }; |
| 107 | |
| 108 | static int __devinit db1200_audio_probe(struct platform_device *pdev) |
| 109 | { |
| 110 | const struct platform_device_id *pid = platform_get_device_id(pdev); |
| 111 | struct snd_soc_card *card; |
| 112 | |
| 113 | card = db1200_cards[pid->driver_data]; |
| 114 | card->dev = &pdev->dev; |
| 115 | return snd_soc_register_card(card); |
| 116 | } |
| 117 | |
| 118 | static int __devexit db1200_audio_remove(struct platform_device *pdev) |
| 119 | { |
| 120 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
| 121 | snd_soc_unregister_card(card); |
| 122 | return 0; |
| 123 | } |
| 124 | |
| 125 | static struct platform_driver db1200_audio_driver = { |
| 126 | .driver = { |
| 127 | .name = "db1200-ac97", |
| 128 | .owner = THIS_MODULE, |
| 129 | .pm = &snd_soc_pm_ops, |
| 130 | }, |
| 131 | .id_table = db1200_pids, |
| 132 | .probe = db1200_audio_probe, |
| 133 | .remove = __devexit_p(db1200_audio_remove), |
| 134 | }; |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 135 | |
Axel Lin | 8a124f9 | 2011-11-25 10:06:59 +0800 | [diff] [blame^] | 136 | module_platform_driver(db1200_audio_driver); |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 137 | |
| 138 | MODULE_LICENSE("GPL"); |
| 139 | MODULE_DESCRIPTION("DB1200 ASoC audio support"); |
| 140 | MODULE_AUTHOR("Manuel Lauss"); |