Loading...
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * DB1200/DB1300/DB1550 ASoC audio fabric support code.
4 *
5 * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com>
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>
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
22#include "../codecs/wm8731.h"
23#include "psc.h"
24
25static const struct platform_device_id db1200_pids[] = {
26 {
27 .name = "db1200-ac97",
28 .driver_data = 0,
29 }, {
30 .name = "db1200-i2s",
31 .driver_data = 1,
32 }, {
33 .name = "db1300-ac97",
34 .driver_data = 2,
35 }, {
36 .name = "db1300-i2s",
37 .driver_data = 3,
38 }, {
39 .name = "db1550-ac97",
40 .driver_data = 4,
41 }, {
42 .name = "db1550-i2s",
43 .driver_data = 5,
44 },
45 {},
46};
47
48/*------------------------- AC97 PART ---------------------------*/
49
50SND_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
55static struct snd_soc_dai_link db1200_ac97_dai = {
56 .name = "AC97",
57 .stream_name = "AC97 HiFi",
58 SND_SOC_DAILINK_REG(db1200_ac97),
59};
60
61static struct snd_soc_card db1200_ac97_machine = {
62 .name = "DB1200_AC97",
63 .owner = THIS_MODULE,
64 .dai_link = &db1200_ac97_dai,
65 .num_links = 1,
66};
67
68SND_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
73static struct snd_soc_dai_link db1300_ac97_dai = {
74 .name = "AC97",
75 .stream_name = "AC97 HiFi",
76 SND_SOC_DAILINK_REG(db1300_ac97),
77};
78
79static struct snd_soc_card db1300_ac97_machine = {
80 .name = "DB1300_AC97",
81 .owner = THIS_MODULE,
82 .dai_link = &db1300_ac97_dai,
83 .num_links = 1,
84};
85
86static struct snd_soc_card db1550_ac97_machine = {
87 .name = "DB1550_AC97",
88 .owner = THIS_MODULE,
89 .dai_link = &db1200_ac97_dai,
90 .num_links = 1,
91};
92
93/*------------------------- I2S PART ---------------------------*/
94
95static int db1200_i2s_startup(struct snd_pcm_substream *substream)
96{
97 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
98 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
99
100 /* WM8731 has its own 12MHz crystal */
101 snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
102 12000000, SND_SOC_CLOCK_IN);
103
104 return 0;
105}
106
107static const struct snd_soc_ops db1200_i2s_wm8731_ops = {
108 .startup = db1200_i2s_startup,
109};
110
111SND_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
116static struct snd_soc_dai_link db1200_i2s_dai = {
117 .name = "WM8731",
118 .stream_name = "WM8731 PCM",
119 .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
120 SND_SOC_DAIFMT_CBP_CFP,
121 .ops = &db1200_i2s_wm8731_ops,
122 SND_SOC_DAILINK_REG(db1200_i2s),
123};
124
125static struct snd_soc_card db1200_i2s_machine = {
126 .name = "DB1200_I2S",
127 .owner = THIS_MODULE,
128 .dai_link = &db1200_i2s_dai,
129 .num_links = 1,
130};
131
132SND_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
137static struct snd_soc_dai_link db1300_i2s_dai = {
138 .name = "WM8731",
139 .stream_name = "WM8731 PCM",
140 .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
141 SND_SOC_DAIFMT_CBP_CFP,
142 .ops = &db1200_i2s_wm8731_ops,
143 SND_SOC_DAILINK_REG(db1300_i2s),
144};
145
146static struct snd_soc_card db1300_i2s_machine = {
147 .name = "DB1300_I2S",
148 .owner = THIS_MODULE,
149 .dai_link = &db1300_i2s_dai,
150 .num_links = 1,
151};
152
153SND_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
158static struct snd_soc_dai_link db1550_i2s_dai = {
159 .name = "WM8731",
160 .stream_name = "WM8731 PCM",
161 .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
162 SND_SOC_DAIFMT_CBP_CFP,
163 .ops = &db1200_i2s_wm8731_ops,
164 SND_SOC_DAILINK_REG(db1550_i2s),
165};
166
167static struct snd_soc_card db1550_i2s_machine = {
168 .name = "DB1550_I2S",
169 .owner = THIS_MODULE,
170 .dai_link = &db1550_i2s_dai,
171 .num_links = 1,
172};
173
174/*------------------------- COMMON PART ---------------------------*/
175
176static struct snd_soc_card *db1200_cards[] = {
177 &db1200_ac97_machine,
178 &db1200_i2s_machine,
179 &db1300_ac97_machine,
180 &db1300_i2s_machine,
181 &db1550_ac97_machine,
182 &db1550_i2s_machine,
183};
184
185static int db1200_audio_probe(struct platform_device *pdev)
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;
192 return devm_snd_soc_register_card(&pdev->dev, card);
193}
194
195static struct platform_driver db1200_audio_driver = {
196 .driver = {
197 .name = "db1200-ac97",
198 .pm = &snd_soc_pm_ops,
199 },
200 .id_table = db1200_pids,
201 .probe = db1200_audio_probe,
202};
203
204module_platform_driver(db1200_audio_driver);
205
206MODULE_LICENSE("GPL");
207MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
208MODULE_AUTHOR("Manuel Lauss");
1/*
2 * DB1200/DB1300/DB1550 ASoC audio fabric support code.
3 *
4 * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com>
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>
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
21#include "../codecs/wm8731.h"
22#include "psc.h"
23
24static 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 .name = "db1300-ac97",
33 .driver_data = 2,
34 }, {
35 .name = "db1300-i2s",
36 .driver_data = 3,
37 }, {
38 .name = "db1550-ac97",
39 .driver_data = 4,
40 }, {
41 .name = "db1550-i2s",
42 .driver_data = 5,
43 },
44 {},
45};
46
47/*------------------------- AC97 PART ---------------------------*/
48
49static struct snd_soc_dai_link db1200_ac97_dai = {
50 .name = "AC97",
51 .stream_name = "AC97 HiFi",
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",
56};
57
58static struct snd_soc_card db1200_ac97_machine = {
59 .name = "DB1200_AC97",
60 .owner = THIS_MODULE,
61 .dai_link = &db1200_ac97_dai,
62 .num_links = 1,
63};
64
65static 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
74static struct snd_soc_card db1300_ac97_machine = {
75 .name = "DB1300_AC97",
76 .owner = THIS_MODULE,
77 .dai_link = &db1300_ac97_dai,
78 .num_links = 1,
79};
80
81static struct snd_soc_card db1550_ac97_machine = {
82 .name = "DB1550_AC97",
83 .owner = THIS_MODULE,
84 .dai_link = &db1200_ac97_dai,
85 .num_links = 1,
86};
87
88/*------------------------- I2S PART ---------------------------*/
89
90static int db1200_i2s_startup(struct snd_pcm_substream *substream)
91{
92 struct snd_soc_pcm_runtime *rtd = substream->private_data;
93 struct snd_soc_dai *codec_dai = rtd->codec_dai;
94 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
95 int ret;
96
97 /* WM8731 has its own 12MHz crystal */
98 snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
99 12000000, SND_SOC_CLOCK_IN);
100
101 /* codec is bitclock and lrclk master */
102 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
103 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
104 if (ret < 0)
105 goto out;
106
107 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
108 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
109 if (ret < 0)
110 goto out;
111
112 ret = 0;
113out:
114 return ret;
115}
116
117static struct snd_soc_ops db1200_i2s_wm8731_ops = {
118 .startup = db1200_i2s_startup,
119};
120
121static struct snd_soc_dai_link db1200_i2s_dai = {
122 .name = "WM8731",
123 .stream_name = "WM8731 PCM",
124 .codec_dai_name = "wm8731-hifi",
125 .cpu_dai_name = "au1xpsc_i2s.1",
126 .platform_name = "au1xpsc-pcm.1",
127 .codec_name = "wm8731.0-001b",
128 .ops = &db1200_i2s_wm8731_ops,
129};
130
131static struct snd_soc_card db1200_i2s_machine = {
132 .name = "DB1200_I2S",
133 .owner = THIS_MODULE,
134 .dai_link = &db1200_i2s_dai,
135 .num_links = 1,
136};
137
138static struct snd_soc_dai_link db1300_i2s_dai = {
139 .name = "WM8731",
140 .stream_name = "WM8731 PCM",
141 .codec_dai_name = "wm8731-hifi",
142 .cpu_dai_name = "au1xpsc_i2s.2",
143 .platform_name = "au1xpsc-pcm.2",
144 .codec_name = "wm8731.0-001b",
145 .ops = &db1200_i2s_wm8731_ops,
146};
147
148static struct snd_soc_card db1300_i2s_machine = {
149 .name = "DB1300_I2S",
150 .owner = THIS_MODULE,
151 .dai_link = &db1300_i2s_dai,
152 .num_links = 1,
153};
154
155static struct snd_soc_dai_link db1550_i2s_dai = {
156 .name = "WM8731",
157 .stream_name = "WM8731 PCM",
158 .codec_dai_name = "wm8731-hifi",
159 .cpu_dai_name = "au1xpsc_i2s.3",
160 .platform_name = "au1xpsc-pcm.3",
161 .codec_name = "wm8731.0-001b",
162 .ops = &db1200_i2s_wm8731_ops,
163};
164
165static struct snd_soc_card db1550_i2s_machine = {
166 .name = "DB1550_I2S",
167 .owner = THIS_MODULE,
168 .dai_link = &db1550_i2s_dai,
169 .num_links = 1,
170};
171
172/*------------------------- COMMON PART ---------------------------*/
173
174static struct snd_soc_card *db1200_cards[] = {
175 &db1200_ac97_machine,
176 &db1200_i2s_machine,
177 &db1300_ac97_machine,
178 &db1300_i2s_machine,
179 &db1550_ac97_machine,
180 &db1550_i2s_machine,
181};
182
183static int db1200_audio_probe(struct platform_device *pdev)
184{
185 const struct platform_device_id *pid = platform_get_device_id(pdev);
186 struct snd_soc_card *card;
187
188 card = db1200_cards[pid->driver_data];
189 card->dev = &pdev->dev;
190 return snd_soc_register_card(card);
191}
192
193static int db1200_audio_remove(struct platform_device *pdev)
194{
195 struct snd_soc_card *card = platform_get_drvdata(pdev);
196 snd_soc_unregister_card(card);
197 return 0;
198}
199
200static struct platform_driver db1200_audio_driver = {
201 .driver = {
202 .name = "db1200-ac97",
203 .owner = THIS_MODULE,
204 .pm = &snd_soc_pm_ops,
205 },
206 .id_table = db1200_pids,
207 .probe = db1200_audio_probe,
208 .remove = db1200_audio_remove,
209};
210
211module_platform_driver(db1200_audio_driver);
212
213MODULE_LICENSE("GPL");
214MODULE_DESCRIPTION("DB1200/DB1300/DB1550 ASoC audio support");
215MODULE_AUTHOR("Manuel Lauss");