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