1 // SPDX-License-Identifier: GPL-2.0-only 1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 2 /* 3 * DB1200/DB1300/DB1550 ASoC audio fabric supp 3 * DB1200/DB1300/DB1550 ASoC audio fabric support code. 4 * 4 * 5 * (c) 2008-2011 Manuel Lauss <manuel.lauss@go 5 * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com> 6 * 6 * 7 */ 7 */ 8 8 9 #include <linux/module.h> 9 #include <linux/module.h> 10 #include <linux/moduleparam.h> 10 #include <linux/moduleparam.h> 11 #include <linux/timer.h> 11 #include <linux/timer.h> 12 #include <linux/interrupt.h> 12 #include <linux/interrupt.h> 13 #include <linux/platform_device.h> 13 #include <linux/platform_device.h> 14 #include <sound/core.h> 14 #include <sound/core.h> 15 #include <sound/pcm.h> 15 #include <sound/pcm.h> 16 #include <sound/soc.h> 16 #include <sound/soc.h> 17 #include <asm/mach-au1x00/au1000.h> 17 #include <asm/mach-au1x00/au1000.h> 18 #include <asm/mach-au1x00/au1xxx_psc.h> 18 #include <asm/mach-au1x00/au1xxx_psc.h> 19 #include <asm/mach-au1x00/au1xxx_dbdma.h> 19 #include <asm/mach-au1x00/au1xxx_dbdma.h> 20 #include <asm/mach-db1x00/bcsr.h> 20 #include <asm/mach-db1x00/bcsr.h> 21 21 22 #include "../codecs/wm8731.h" 22 #include "../codecs/wm8731.h" 23 #include "psc.h" 23 #include "psc.h" 24 24 25 static const struct platform_device_id db1200_ 25 static const struct platform_device_id db1200_pids[] = { 26 { 26 { 27 .name = "db1200-ac97 27 .name = "db1200-ac97", 28 .driver_data = 0, 28 .driver_data = 0, 29 }, { 29 }, { 30 .name = "db1200-i2s" 30 .name = "db1200-i2s", 31 .driver_data = 1, 31 .driver_data = 1, 32 }, { 32 }, { 33 .name = "db1300-ac97 33 .name = "db1300-ac97", 34 .driver_data = 2, 34 .driver_data = 2, 35 }, { 35 }, { 36 .name = "db1300-i2s" 36 .name = "db1300-i2s", 37 .driver_data = 3, 37 .driver_data = 3, 38 }, { 38 }, { 39 .name = "db1550-ac97 39 .name = "db1550-ac97", 40 .driver_data = 4, 40 .driver_data = 4, 41 }, { 41 }, { 42 .name = "db1550-i2s" 42 .name = "db1550-i2s", 43 .driver_data = 5, 43 .driver_data = 5, 44 }, 44 }, 45 {}, 45 {}, 46 }; 46 }; 47 MODULE_DEVICE_TABLE(platform, db1200_pids); << 48 47 49 /*------------------------- AC97 PART ------ 48 /*------------------------- AC97 PART ---------------------------*/ 50 49 51 SND_SOC_DAILINK_DEFS(db1200_ac97, 50 SND_SOC_DAILINK_DEFS(db1200_ac97, 52 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_a 51 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_ac97.1")), 53 DAILINK_COMP_ARRAY(COMP_CODEC("ac97-co 52 DAILINK_COMP_ARRAY(COMP_CODEC("ac97-codec.1", "ac97-hifi")), 54 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1x 53 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.1"))); 55 54 56 static struct snd_soc_dai_link db1200_ac97_dai 55 static struct snd_soc_dai_link db1200_ac97_dai = { 57 .name = "AC97", 56 .name = "AC97", 58 .stream_name = "AC97 HiFi", 57 .stream_name = "AC97 HiFi", 59 SND_SOC_DAILINK_REG(db1200_ac97), 58 SND_SOC_DAILINK_REG(db1200_ac97), 60 }; 59 }; 61 60 62 static struct snd_soc_card db1200_ac97_machine 61 static struct snd_soc_card db1200_ac97_machine = { 63 .name = "DB1200_AC97", 62 .name = "DB1200_AC97", 64 .owner = THIS_MODULE, 63 .owner = THIS_MODULE, 65 .dai_link = &db1200_ac97_dai, 64 .dai_link = &db1200_ac97_dai, 66 .num_links = 1, 65 .num_links = 1, 67 }; 66 }; 68 67 69 SND_SOC_DAILINK_DEFS(db1300_ac97, 68 SND_SOC_DAILINK_DEFS(db1300_ac97, 70 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_a 69 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_ac97.1")), 71 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712- 70 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec.1", "wm9712-hifi")), 72 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1x 71 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.1"))); 73 72 74 static struct snd_soc_dai_link db1300_ac97_dai 73 static struct snd_soc_dai_link db1300_ac97_dai = { 75 .name = "AC97", 74 .name = "AC97", 76 .stream_name = "AC97 HiFi", 75 .stream_name = "AC97 HiFi", 77 SND_SOC_DAILINK_REG(db1300_ac97), 76 SND_SOC_DAILINK_REG(db1300_ac97), 78 }; 77 }; 79 78 80 static struct snd_soc_card db1300_ac97_machine 79 static struct snd_soc_card db1300_ac97_machine = { 81 .name = "DB1300_AC97", 80 .name = "DB1300_AC97", 82 .owner = THIS_MODULE, 81 .owner = THIS_MODULE, 83 .dai_link = &db1300_ac97_dai, 82 .dai_link = &db1300_ac97_dai, 84 .num_links = 1, 83 .num_links = 1, 85 }; 84 }; 86 85 87 static struct snd_soc_card db1550_ac97_machine 86 static struct snd_soc_card db1550_ac97_machine = { 88 .name = "DB1550_AC97", 87 .name = "DB1550_AC97", 89 .owner = THIS_MODULE, 88 .owner = THIS_MODULE, 90 .dai_link = &db1200_ac97_dai, 89 .dai_link = &db1200_ac97_dai, 91 .num_links = 1, 90 .num_links = 1, 92 }; 91 }; 93 92 94 /*------------------------- I2S PART ------- 93 /*------------------------- I2S PART ---------------------------*/ 95 94 96 static int db1200_i2s_startup(struct snd_pcm_s 95 static int db1200_i2s_startup(struct snd_pcm_substream *substream) 97 { 96 { 98 struct snd_soc_pcm_runtime *rtd = snd_ !! 97 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 99 struct snd_soc_dai *codec_dai = snd_so !! 98 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 100 99 101 /* WM8731 has its own 12MHz crystal */ 100 /* WM8731 has its own 12MHz crystal */ 102 snd_soc_dai_set_sysclk(codec_dai, WM87 101 snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, 103 12000000, SND_ 102 12000000, SND_SOC_CLOCK_IN); 104 103 105 return 0; 104 return 0; 106 } 105 } 107 106 108 static const struct snd_soc_ops db1200_i2s_wm8 107 static const struct snd_soc_ops db1200_i2s_wm8731_ops = { 109 .startup = db1200_i2s_startup, 108 .startup = db1200_i2s_startup, 110 }; 109 }; 111 110 112 SND_SOC_DAILINK_DEFS(db1200_i2s, 111 SND_SOC_DAILINK_DEFS(db1200_i2s, 113 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i 112 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i2s.1")), 114 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731. 113 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.0-001b", "wm8731-hifi")), 115 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1x 114 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.1"))); 116 115 117 static struct snd_soc_dai_link db1200_i2s_dai 116 static struct snd_soc_dai_link db1200_i2s_dai = { 118 .name = "WM8731", 117 .name = "WM8731", 119 .stream_name = "WM8731 PCM", 118 .stream_name = "WM8731 PCM", 120 .dai_fmt = SND_SOC_DAIFMT_LEFT_ 119 .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF | 121 SND_SOC_DAIFMT_CBP_C !! 120 SND_SOC_DAIFMT_CBM_CFM, 122 .ops = &db1200_i2s_wm8731_o 121 .ops = &db1200_i2s_wm8731_ops, 123 SND_SOC_DAILINK_REG(db1200_i2s), 122 SND_SOC_DAILINK_REG(db1200_i2s), 124 }; 123 }; 125 124 126 static struct snd_soc_card db1200_i2s_machine 125 static struct snd_soc_card db1200_i2s_machine = { 127 .name = "DB1200_I2S", 126 .name = "DB1200_I2S", 128 .owner = THIS_MODULE, 127 .owner = THIS_MODULE, 129 .dai_link = &db1200_i2s_dai, 128 .dai_link = &db1200_i2s_dai, 130 .num_links = 1, 129 .num_links = 1, 131 }; 130 }; 132 131 133 SND_SOC_DAILINK_DEFS(db1300_i2s, 132 SND_SOC_DAILINK_DEFS(db1300_i2s, 134 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i 133 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i2s.2")), 135 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731. 134 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.0-001b", "wm8731-hifi")), 136 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1x 135 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.2"))); 137 136 138 static struct snd_soc_dai_link db1300_i2s_dai 137 static struct snd_soc_dai_link db1300_i2s_dai = { 139 .name = "WM8731", 138 .name = "WM8731", 140 .stream_name = "WM8731 PCM", 139 .stream_name = "WM8731 PCM", 141 .dai_fmt = SND_SOC_DAIFMT_LEFT_ 140 .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF | 142 SND_SOC_DAIFMT_CBP_C !! 141 SND_SOC_DAIFMT_CBM_CFM, 143 .ops = &db1200_i2s_wm8731_o 142 .ops = &db1200_i2s_wm8731_ops, 144 SND_SOC_DAILINK_REG(db1300_i2s), 143 SND_SOC_DAILINK_REG(db1300_i2s), 145 }; 144 }; 146 145 147 static struct snd_soc_card db1300_i2s_machine 146 static struct snd_soc_card db1300_i2s_machine = { 148 .name = "DB1300_I2S", 147 .name = "DB1300_I2S", 149 .owner = THIS_MODULE, 148 .owner = THIS_MODULE, 150 .dai_link = &db1300_i2s_dai, 149 .dai_link = &db1300_i2s_dai, 151 .num_links = 1, 150 .num_links = 1, 152 }; 151 }; 153 152 154 SND_SOC_DAILINK_DEFS(db1550_i2s, 153 SND_SOC_DAILINK_DEFS(db1550_i2s, 155 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i 154 DAILINK_COMP_ARRAY(COMP_CPU("au1xpsc_i2s.3")), 156 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731. 155 DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.0-001b", "wm8731-hifi")), 157 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1x 156 DAILINK_COMP_ARRAY(COMP_PLATFORM("au1xpsc-pcm.3"))); 158 157 159 static struct snd_soc_dai_link db1550_i2s_dai 158 static struct snd_soc_dai_link db1550_i2s_dai = { 160 .name = "WM8731", 159 .name = "WM8731", 161 .stream_name = "WM8731 PCM", 160 .stream_name = "WM8731 PCM", 162 .dai_fmt = SND_SOC_DAIFMT_LEFT_ 161 .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF | 163 SND_SOC_DAIFMT_CBP_C !! 162 SND_SOC_DAIFMT_CBM_CFM, 164 .ops = &db1200_i2s_wm8731_o 163 .ops = &db1200_i2s_wm8731_ops, 165 SND_SOC_DAILINK_REG(db1550_i2s), 164 SND_SOC_DAILINK_REG(db1550_i2s), 166 }; 165 }; 167 166 168 static struct snd_soc_card db1550_i2s_machine 167 static struct snd_soc_card db1550_i2s_machine = { 169 .name = "DB1550_I2S", 168 .name = "DB1550_I2S", 170 .owner = THIS_MODULE, 169 .owner = THIS_MODULE, 171 .dai_link = &db1550_i2s_dai, 170 .dai_link = &db1550_i2s_dai, 172 .num_links = 1, 171 .num_links = 1, 173 }; 172 }; 174 173 175 /*------------------------- COMMON PART ---- 174 /*------------------------- COMMON PART ---------------------------*/ 176 175 177 static struct snd_soc_card *db1200_cards[] = { 176 static struct snd_soc_card *db1200_cards[] = { 178 &db1200_ac97_machine, 177 &db1200_ac97_machine, 179 &db1200_i2s_machine, 178 &db1200_i2s_machine, 180 &db1300_ac97_machine, 179 &db1300_ac97_machine, 181 &db1300_i2s_machine, 180 &db1300_i2s_machine, 182 &db1550_ac97_machine, 181 &db1550_ac97_machine, 183 &db1550_i2s_machine, 182 &db1550_i2s_machine, 184 }; 183 }; 185 184 186 static int db1200_audio_probe(struct platform_ 185 static int db1200_audio_probe(struct platform_device *pdev) 187 { 186 { 188 const struct platform_device_id *pid = 187 const struct platform_device_id *pid = platform_get_device_id(pdev); 189 struct snd_soc_card *card; 188 struct snd_soc_card *card; 190 189 191 card = db1200_cards[pid->driver_data]; 190 card = db1200_cards[pid->driver_data]; 192 card->dev = &pdev->dev; 191 card->dev = &pdev->dev; 193 return devm_snd_soc_register_card(&pde 192 return devm_snd_soc_register_card(&pdev->dev, card); 194 } 193 } 195 194 196 static struct platform_driver db1200_audio_dri 195 static struct platform_driver db1200_audio_driver = { 197 .driver = { 196 .driver = { 198 .name = "db1200-ac97", 197 .name = "db1200-ac97", 199 .pm = &snd_soc_pm_ops, 198 .pm = &snd_soc_pm_ops, 200 }, 199 }, 201 .id_table = db1200_pids, 200 .id_table = db1200_pids, 202 .probe = db1200_audio_probe, 201 .probe = db1200_audio_probe, 203 }; 202 }; 204 203 205 module_platform_driver(db1200_audio_driver); 204 module_platform_driver(db1200_audio_driver); 206 205 207 MODULE_LICENSE("GPL"); 206 MODULE_LICENSE("GPL"); 208 MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC 207 MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support"); 209 MODULE_AUTHOR("Manuel Lauss"); 208 MODULE_AUTHOR("Manuel Lauss"); 210 209
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.