Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 1 | /* |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 2 | * DB1200/DB1300/DB1550 ASoC audio fabric support code. |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 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 | |
Krzysztof Kozlowski | 6c21919 | 2015-05-02 01:00:11 +0900 | [diff] [blame] | 24 | static const struct platform_device_id db1200_pids[] = { |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 25 | { |
| 26 | .name = "db1200-ac97", |
| 27 | .driver_data = 0, |
| 28 | }, { |
| 29 | .name = "db1200-i2s", |
| 30 | .driver_data = 1, |
Manuel Lauss | 64cd04d | 2011-11-10 12:03:26 +0000 | [diff] [blame] | 31 | }, { |
| 32 | .name = "db1300-ac97", |
| 33 | .driver_data = 2, |
| 34 | }, { |
| 35 | .name = "db1300-i2s", |
| 36 | .driver_data = 3, |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 37 | }, { |
| 38 | .name = "db1550-ac97", |
| 39 | .driver_data = 4, |
| 40 | }, { |
| 41 | .name = "db1550-i2s", |
| 42 | .driver_data = 5, |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 43 | }, |
| 44 | {}, |
| 45 | }; |
| 46 | |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 47 | /*------------------------- AC97 PART ---------------------------*/ |
| 48 | |
| 49 | static struct snd_soc_dai_link db1200_ac97_dai = { |
| 50 | .name = "AC97", |
| 51 | .stream_name = "AC97 HiFi", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 52 | .codec_dai_name = "ac97-hifi", |
Manuel Lauss | ffc4fdb | 2010-08-26 14:53:51 +0200 | [diff] [blame] | 53 | .cpu_dai_name = "au1xpsc_ac97.1", |
| 54 | .platform_name = "au1xpsc-pcm.1", |
| 55 | .codec_name = "ac97-codec.1", |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | static struct snd_soc_card db1200_ac97_machine = { |
| 59 | .name = "DB1200_AC97", |
Axel Lin | 662d4e5c | 2011-12-23 09:53:55 +0800 | [diff] [blame] | 60 | .owner = THIS_MODULE, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 61 | .dai_link = &db1200_ac97_dai, |
| 62 | .num_links = 1, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 63 | }; |
| 64 | |
Manuel Lauss | 64cd04d | 2011-11-10 12:03:26 +0000 | [diff] [blame] | 65 | static struct snd_soc_dai_link db1300_ac97_dai = { |
| 66 | .name = "AC97", |
| 67 | .stream_name = "AC97 HiFi", |
| 68 | .codec_dai_name = "wm9712-hifi", |
| 69 | .cpu_dai_name = "au1xpsc_ac97.1", |
| 70 | .platform_name = "au1xpsc-pcm.1", |
| 71 | .codec_name = "wm9712-codec.1", |
| 72 | }; |
| 73 | |
| 74 | static struct snd_soc_card db1300_ac97_machine = { |
| 75 | .name = "DB1300_AC97", |
Wei Yongjun | 35261ed | 2013-07-02 17:19:25 +0800 | [diff] [blame] | 76 | .owner = THIS_MODULE, |
Manuel Lauss | 64cd04d | 2011-11-10 12:03:26 +0000 | [diff] [blame] | 77 | .dai_link = &db1300_ac97_dai, |
| 78 | .num_links = 1, |
| 79 | }; |
| 80 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 81 | static struct snd_soc_card db1550_ac97_machine = { |
| 82 | .name = "DB1550_AC97", |
Wei Yongjun | 35261ed | 2013-07-02 17:19:25 +0800 | [diff] [blame] | 83 | .owner = THIS_MODULE, |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 84 | .dai_link = &db1200_ac97_dai, |
| 85 | .num_links = 1, |
| 86 | }; |
| 87 | |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 88 | /*------------------------- I2S PART ---------------------------*/ |
| 89 | |
| 90 | static int db1200_i2s_startup(struct snd_pcm_substream *substream) |
| 91 | { |
| 92 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 93 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 94 | |
| 95 | /* WM8731 has its own 12MHz crystal */ |
Mark Brown | 9745e82 | 2010-08-17 23:40:24 +0100 | [diff] [blame] | 96 | snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 97 | 12000000, SND_SOC_CLOCK_IN); |
| 98 | |
Lars-Peter Clausen | b4508d0 | 2015-01-01 17:16:11 +0100 | [diff] [blame] | 99 | return 0; |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | static struct snd_soc_ops db1200_i2s_wm8731_ops = { |
| 103 | .startup = db1200_i2s_startup, |
| 104 | }; |
| 105 | |
| 106 | static struct snd_soc_dai_link db1200_i2s_dai = { |
| 107 | .name = "WM8731", |
| 108 | .stream_name = "WM8731 PCM", |
Manuel Lauss | ffc4fdb | 2010-08-26 14:53:51 +0200 | [diff] [blame] | 109 | .codec_dai_name = "wm8731-hifi", |
| 110 | .cpu_dai_name = "au1xpsc_i2s.1", |
| 111 | .platform_name = "au1xpsc-pcm.1", |
Mark Brown | 99b59f3 | 2011-03-27 14:35:15 +0100 | [diff] [blame] | 112 | .codec_name = "wm8731.0-001b", |
Lars-Peter Clausen | b4508d0 | 2015-01-01 17:16:11 +0100 | [diff] [blame] | 113 | .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF | |
| 114 | SND_SOC_DAIFMT_CBM_CFM, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 115 | .ops = &db1200_i2s_wm8731_ops, |
| 116 | }; |
| 117 | |
| 118 | static struct snd_soc_card db1200_i2s_machine = { |
| 119 | .name = "DB1200_I2S", |
Axel Lin | 662d4e5c | 2011-12-23 09:53:55 +0800 | [diff] [blame] | 120 | .owner = THIS_MODULE, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 121 | .dai_link = &db1200_i2s_dai, |
| 122 | .num_links = 1, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 123 | }; |
| 124 | |
Manuel Lauss | 64cd04d | 2011-11-10 12:03:26 +0000 | [diff] [blame] | 125 | static struct snd_soc_dai_link db1300_i2s_dai = { |
| 126 | .name = "WM8731", |
| 127 | .stream_name = "WM8731 PCM", |
| 128 | .codec_dai_name = "wm8731-hifi", |
| 129 | .cpu_dai_name = "au1xpsc_i2s.2", |
| 130 | .platform_name = "au1xpsc-pcm.2", |
| 131 | .codec_name = "wm8731.0-001b", |
Lars-Peter Clausen | e74679b | 2015-09-25 11:07:04 +0200 | [diff] [blame] | 132 | .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF | |
| 133 | SND_SOC_DAIFMT_CBM_CFM, |
Manuel Lauss | 64cd04d | 2011-11-10 12:03:26 +0000 | [diff] [blame] | 134 | .ops = &db1200_i2s_wm8731_ops, |
| 135 | }; |
| 136 | |
| 137 | static struct snd_soc_card db1300_i2s_machine = { |
| 138 | .name = "DB1300_I2S", |
Wei Yongjun | 35261ed | 2013-07-02 17:19:25 +0800 | [diff] [blame] | 139 | .owner = THIS_MODULE, |
Manuel Lauss | 64cd04d | 2011-11-10 12:03:26 +0000 | [diff] [blame] | 140 | .dai_link = &db1300_i2s_dai, |
| 141 | .num_links = 1, |
| 142 | }; |
| 143 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 144 | static struct snd_soc_dai_link db1550_i2s_dai = { |
| 145 | .name = "WM8731", |
| 146 | .stream_name = "WM8731 PCM", |
| 147 | .codec_dai_name = "wm8731-hifi", |
| 148 | .cpu_dai_name = "au1xpsc_i2s.3", |
| 149 | .platform_name = "au1xpsc-pcm.3", |
| 150 | .codec_name = "wm8731.0-001b", |
Lars-Peter Clausen | e74679b | 2015-09-25 11:07:04 +0200 | [diff] [blame] | 151 | .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF | |
| 152 | SND_SOC_DAIFMT_CBM_CFM, |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 153 | .ops = &db1200_i2s_wm8731_ops, |
| 154 | }; |
| 155 | |
| 156 | static struct snd_soc_card db1550_i2s_machine = { |
| 157 | .name = "DB1550_I2S", |
Wei Yongjun | 35261ed | 2013-07-02 17:19:25 +0800 | [diff] [blame] | 158 | .owner = THIS_MODULE, |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 159 | .dai_link = &db1550_i2s_dai, |
| 160 | .num_links = 1, |
| 161 | }; |
| 162 | |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 163 | /*------------------------- COMMON PART ---------------------------*/ |
| 164 | |
Bill Pemberton | 5c658be | 2012-12-07 09:26:22 -0500 | [diff] [blame] | 165 | static struct snd_soc_card *db1200_cards[] = { |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 166 | &db1200_ac97_machine, |
| 167 | &db1200_i2s_machine, |
Manuel Lauss | 64cd04d | 2011-11-10 12:03:26 +0000 | [diff] [blame] | 168 | &db1300_ac97_machine, |
| 169 | &db1300_i2s_machine, |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 170 | &db1550_ac97_machine, |
| 171 | &db1550_i2s_machine, |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 172 | }; |
| 173 | |
Bill Pemberton | 5c658be | 2012-12-07 09:26:22 -0500 | [diff] [blame] | 174 | static int db1200_audio_probe(struct platform_device *pdev) |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 175 | { |
| 176 | const struct platform_device_id *pid = platform_get_device_id(pdev); |
| 177 | struct snd_soc_card *card; |
| 178 | |
| 179 | card = db1200_cards[pid->driver_data]; |
| 180 | card->dev = &pdev->dev; |
Axel Lin | 2342caf | 2015-08-30 17:16:01 +0800 | [diff] [blame] | 181 | return devm_snd_soc_register_card(&pdev->dev, card); |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | static struct platform_driver db1200_audio_driver = { |
| 185 | .driver = { |
| 186 | .name = "db1200-ac97", |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 187 | .pm = &snd_soc_pm_ops, |
| 188 | }, |
| 189 | .id_table = db1200_pids, |
| 190 | .probe = db1200_audio_probe, |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 191 | }; |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 192 | |
Axel Lin | 8a124f9 | 2011-11-25 10:06:59 +0800 | [diff] [blame] | 193 | module_platform_driver(db1200_audio_driver); |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 194 | |
| 195 | MODULE_LICENSE("GPL"); |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 196 | MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support"); |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 197 | MODULE_AUTHOR("Manuel Lauss"); |