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