lantiq: Use the BAR0 base address in the ath PCI fixup code
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.18 / 0036-ASoC-BCM2708-Add-support-for-RPi-DAC.patch
1 From 52fceff596533a847231d1f9b8ea13d4e6ee829b Mon Sep 17 00:00:00 2001
2 From: Florian Meier <florian.meier@koalo.de>
3 Date: Fri, 6 Dec 2013 20:50:28 +0100
4 Subject: [PATCH 036/114] ASoC: BCM2708: Add support for RPi-DAC
5
6 This adds a machine driver for the RPi-DAC.
7
8 Signed-off-by: Florian Meier <florian.meier@koalo.de>
9 ---
10 arch/arm/configs/bcmrpi_defconfig | 1 +
11 arch/arm/mach-bcm2708/bcm2708.c | 19 ++++++++
12 sound/soc/bcm/Kconfig | 7 +++
13 sound/soc/bcm/Makefile | 2 +
14 sound/soc/bcm/rpi-dac.c | 97 +++++++++++++++++++++++++++++++++++++++
15 sound/soc/codecs/Kconfig | 4 ++
16 sound/soc/codecs/Makefile | 2 +
17 sound/soc/codecs/pcm1794a.c | 62 +++++++++++++++++++++++++
18 8 files changed, 194 insertions(+)
19 create mode 100644 sound/soc/bcm/rpi-dac.c
20 create mode 100644 sound/soc/codecs/pcm1794a.c
21
22 --- a/arch/arm/configs/bcmrpi_defconfig
23 +++ b/arch/arm/configs/bcmrpi_defconfig
24 @@ -756,6 +756,7 @@ CONFIG_SND_USB_6FIRE=m
25 CONFIG_SND_SOC=m
26 CONFIG_SND_BCM2708_SOC_I2S=m
27 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
28 +CONFIG_SND_BCM2708_SOC_RPI_DAC=m
29 CONFIG_SND_SIMPLE_CARD=m
30 CONFIG_SOUND_PRIME=m
31 CONFIG_HIDRAW=y
32 --- a/arch/arm/mach-bcm2708/bcm2708.c
33 +++ b/arch/arm/mach-bcm2708/bcm2708.c
34 @@ -623,6 +623,20 @@ static struct platform_device snd_pcm510
35 };
36 #endif
37
38 +#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE)
39 +static struct platform_device snd_rpi_dac_device = {
40 + .name = "snd-rpi-dac",
41 + .id = 0,
42 + .num_resources = 0,
43 +};
44 +
45 +static struct platform_device snd_pcm1794a_codec_device = {
46 + .name = "pcm1794a-codec",
47 + .id = -1,
48 + .num_resources = 0,
49 +};
50 +#endif
51 +
52 int __init bcm_register_device(struct platform_device *pdev)
53 {
54 int ret;
55 @@ -752,6 +766,11 @@ void __init bcm2708_init(void)
56 bcm_register_device(&snd_pcm5102a_codec_device);
57 #endif
58
59 +#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE)
60 + bcm_register_device(&snd_rpi_dac_device);
61 + bcm_register_device(&snd_pcm1794a_codec_device);
62 +#endif
63 +
64 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
65 struct amba_device *d = amba_devs[i];
66 amba_device_register(d, &iomem_resource);
67 --- a/sound/soc/bcm/Kconfig
68 +++ b/sound/soc/bcm/Kconfig
69 @@ -25,3 +25,10 @@ config SND_BCM2708_SOC_HIFIBERRY_DAC
70 select SND_SOC_PCM5102A
71 help
72 Say Y or M if you want to add support for HifiBerry DAC.
73 +
74 +config SND_BCM2708_SOC_RPI_DAC
75 + tristate "Support for RPi-DAC"
76 + depends on SND_BCM2708_SOC_I2S
77 + select SND_SOC_PCM1794A
78 + help
79 + Say Y or M if you want to add support for RPi-DAC.
80 --- a/sound/soc/bcm/Makefile
81 +++ b/sound/soc/bcm/Makefile
82 @@ -10,5 +10,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd
83
84 # BCM2708 Machine Support
85 snd-soc-hifiberry-dac-objs := hifiberry_dac.o
86 +snd-soc-rpi-dac-objs := rpi-dac.o
87
88 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
89 +obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
90 --- /dev/null
91 +++ b/sound/soc/bcm/rpi-dac.c
92 @@ -0,0 +1,97 @@
93 +/*
94 + * ASoC Driver for RPi-DAC.
95 + *
96 + * Author: Florian Meier <florian.meier@koalo.de>
97 + * Copyright 2013
98 + *
99 + * This program is free software; you can redistribute it and/or
100 + * modify it under the terms of the GNU General Public License
101 + * version 2 as published by the Free Software Foundation.
102 + *
103 + * This program is distributed in the hope that it will be useful, but
104 + * WITHOUT ANY WARRANTY; without even the implied warranty of
105 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
106 + * General Public License for more details.
107 + */
108 +
109 +#include <linux/module.h>
110 +#include <linux/platform_device.h>
111 +
112 +#include <sound/core.h>
113 +#include <sound/pcm.h>
114 +#include <sound/pcm_params.h>
115 +#include <sound/soc.h>
116 +#include <sound/jack.h>
117 +
118 +static int snd_rpi_rpi_dac_init(struct snd_soc_pcm_runtime *rtd)
119 +{
120 + return 0;
121 +}
122 +
123 +static int snd_rpi_rpi_dac_hw_params(struct snd_pcm_substream *substream,
124 + struct snd_pcm_hw_params *params)
125 +{
126 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
127 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
128 +
129 + return snd_soc_dai_set_bclk_ratio(cpu_dai, 32*2);
130 +}
131 +
132 +/* machine stream operations */
133 +static struct snd_soc_ops snd_rpi_rpi_dac_ops = {
134 + .hw_params = snd_rpi_rpi_dac_hw_params,
135 +};
136 +
137 +static struct snd_soc_dai_link snd_rpi_rpi_dac_dai[] = {
138 +{
139 + .name = "RPi-DAC",
140 + .stream_name = "RPi-DAC HiFi",
141 + .cpu_dai_name = "bcm2708-i2s.0",
142 + .codec_dai_name = "pcm1794a-hifi",
143 + .platform_name = "bcm2708-i2s.0",
144 + .codec_name = "pcm1794a-codec",
145 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
146 + SND_SOC_DAIFMT_CBS_CFS,
147 + .ops = &snd_rpi_rpi_dac_ops,
148 + .init = snd_rpi_rpi_dac_init,
149 +},
150 +};
151 +
152 +/* audio machine driver */
153 +static struct snd_soc_card snd_rpi_rpi_dac = {
154 + .name = "snd_rpi_rpi_dac",
155 + .dai_link = snd_rpi_rpi_dac_dai,
156 + .num_links = ARRAY_SIZE(snd_rpi_rpi_dac_dai),
157 +};
158 +
159 +static int snd_rpi_rpi_dac_probe(struct platform_device *pdev)
160 +{
161 + int ret = 0;
162 +
163 + snd_rpi_rpi_dac.dev = &pdev->dev;
164 + ret = snd_soc_register_card(&snd_rpi_rpi_dac);
165 + if (ret)
166 + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
167 +
168 + return ret;
169 +}
170 +
171 +static int snd_rpi_rpi_dac_remove(struct platform_device *pdev)
172 +{
173 + return snd_soc_unregister_card(&snd_rpi_rpi_dac);
174 +}
175 +
176 +static struct platform_driver snd_rpi_rpi_dac_driver = {
177 + .driver = {
178 + .name = "snd-rpi-dac",
179 + .owner = THIS_MODULE,
180 + },
181 + .probe = snd_rpi_rpi_dac_probe,
182 + .remove = snd_rpi_rpi_dac_remove,
183 +};
184 +
185 +module_platform_driver(snd_rpi_rpi_dac_driver);
186 +
187 +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
188 +MODULE_DESCRIPTION("ASoC Driver for RPi-DAC");
189 +MODULE_LICENSE("GPL v2");
190 --- a/sound/soc/codecs/Kconfig
191 +++ b/sound/soc/codecs/Kconfig
192 @@ -81,6 +81,7 @@ config SND_SOC_ALL_CODECS
193 select SND_SOC_PCM512x_SPI if SPI_MASTER
194 select SND_SOC_RT286 if I2C
195 select SND_SOC_PCM5102A if I2C
196 + select SND_SOC_PCM1794A if I2C
197 select SND_SOC_RT5631 if I2C
198 select SND_SOC_RT5640 if I2C
199 select SND_SOC_RT5645 if I2C
200 @@ -487,6 +488,9 @@ config SND_SOC_RT286
201 tristate
202 depends on I2C
203
204 +config SND_SOC_PCM1794A
205 + tristate
206 +
207 config SND_SOC_PCM5102A
208 tristate
209
210 --- a/sound/soc/codecs/Makefile
211 +++ b/sound/soc/codecs/Makefile
212 @@ -74,6 +74,7 @@ snd-soc-pcm512x-i2c-objs := pcm512x-i2c.
213 snd-soc-pcm512x-spi-objs := pcm512x-spi.o
214 snd-soc-rl6231-objs := rl6231.o
215 snd-soc-rt286-objs := rt286.o
216 +snd-soc-pcm1794a-objs := pcm1794a.o
217 snd-soc-pcm5102a-objs := pcm5102a.o
218 snd-soc-rt5631-objs := rt5631.o
219 snd-soc-rt5640-objs := rt5640.o
220 @@ -251,6 +252,7 @@ obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd
221 obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o
222 obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o
223 obj-$(CONFIG_SND_SOC_RT286) += snd-soc-rt286.o
224 +obj-$(CONFIG_SND_SOC_PCM1794A) += snd-soc-pcm1794a.o
225 obj-$(CONFIG_SND_SOC_PCM5102A) += snd-soc-pcm5102a.o
226 obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
227 obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o
228 --- /dev/null
229 +++ b/sound/soc/codecs/pcm1794a.c
230 @@ -0,0 +1,62 @@
231 +/*
232 + * Driver for the PCM1794A codec
233 + *
234 + * Author: Florian Meier <florian.meier@koalo.de>
235 + * Copyright 2013
236 + *
237 + * This program is free software; you can redistribute it and/or
238 + * modify it under the terms of the GNU General Public License
239 + * version 2 as published by the Free Software Foundation.
240 + *
241 + * This program is distributed in the hope that it will be useful, but
242 + * WITHOUT ANY WARRANTY; without even the implied warranty of
243 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
244 + * General Public License for more details.
245 + */
246 +
247 +
248 +#include <linux/init.h>
249 +#include <linux/module.h>
250 +#include <linux/platform_device.h>
251 +
252 +#include <sound/soc.h>
253 +
254 +static struct snd_soc_dai_driver pcm1794a_dai = {
255 + .name = "pcm1794a-hifi",
256 + .playback = {
257 + .channels_min = 2,
258 + .channels_max = 2,
259 + .rates = SNDRV_PCM_RATE_8000_192000,
260 + .formats = SNDRV_PCM_FMTBIT_S16_LE |
261 + SNDRV_PCM_FMTBIT_S24_LE
262 + },
263 +};
264 +
265 +static struct snd_soc_codec_driver soc_codec_dev_pcm1794a;
266 +
267 +static int pcm1794a_probe(struct platform_device *pdev)
268 +{
269 + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pcm1794a,
270 + &pcm1794a_dai, 1);
271 +}
272 +
273 +static int pcm1794a_remove(struct platform_device *pdev)
274 +{
275 + snd_soc_unregister_codec(&pdev->dev);
276 + return 0;
277 +}
278 +
279 +static struct platform_driver pcm1794a_codec_driver = {
280 + .probe = pcm1794a_probe,
281 + .remove = pcm1794a_remove,
282 + .driver = {
283 + .name = "pcm1794a-codec",
284 + .owner = THIS_MODULE,
285 + },
286 +};
287 +
288 +module_platform_driver(pcm1794a_codec_driver);
289 +
290 +MODULE_DESCRIPTION("ASoC PCM1794A codec driver");
291 +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
292 +MODULE_LICENSE("GPL v2");