brcm2708: update to v3.18
[openwrt/svn-archive/archive.git] / target / linux / brcm2708 / patches-3.18 / 0042-Add-IQaudIO-Sound-Card-support-for-Raspberry-Pi.patch
1 From 19b5aa63015268ce3c736b720e1e7f8211f7cf98 Mon Sep 17 00:00:00 2001
2 From: Gordon Garrity <gordon@iqaudio.com>
3 Date: Sat, 8 Mar 2014 16:56:57 +0000
4 Subject: [PATCH 042/114] Add IQaudIO Sound Card support for Raspberry Pi
5
6 ---
7 arch/arm/configs/bcmrpi_defconfig | 1 +
8 arch/arm/mach-bcm2708/bcm2708.c | 22 ++++++++
9 sound/soc/bcm/Kconfig | 7 +++
10 sound/soc/bcm/Makefile | 2 +
11 sound/soc/bcm/iqaudio-dac.c | 111 ++++++++++++++++++++++++++++++++++++++
12 5 files changed, 143 insertions(+)
13 create mode 100644 sound/soc/bcm/iqaudio-dac.c
14
15 diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig
16 index c9d3fac..f15a4b9 100644
17 --- a/arch/arm/configs/bcmrpi_defconfig
18 +++ b/arch/arm/configs/bcmrpi_defconfig
19 @@ -758,6 +758,7 @@ CONFIG_SND_BCM2708_SOC_I2S=m
20 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
21 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
22 CONFIG_SND_BCM2708_SOC_RPI_DAC=m
23 +CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC=m
24 CONFIG_SND_SIMPLE_CARD=m
25 CONFIG_SOUND_PRIME=m
26 CONFIG_HIDRAW=y
27 diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c
28 index a57cb85..633be19 100644
29 --- a/arch/arm/mach-bcm2708/bcm2708.c
30 +++ b/arch/arm/mach-bcm2708/bcm2708.c
31 @@ -652,6 +652,22 @@ static struct platform_device snd_pcm1794a_codec_device = {
32 };
33 #endif
34
35 +
36 +#if defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) || defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC_MODULE)
37 +static struct platform_device snd_rpi_iqaudio_dac_device = {
38 + .name = "snd-rpi-iqaudio-dac",
39 + .id = 0,
40 + .num_resources = 0,
41 +};
42 +
43 +// Use the actual device name rather than generic driver name
44 +static struct i2c_board_info __initdata snd_pcm512x_i2c_devices[] = {
45 + {
46 + I2C_BOARD_INFO("pcm5122", 0x4c)
47 + },
48 +};
49 +#endif
50 +
51 int __init bcm_register_device(struct platform_device *pdev)
52 {
53 int ret;
54 @@ -791,6 +807,12 @@ void __init bcm2708_init(void)
55 bcm_register_device(&snd_pcm1794a_codec_device);
56 #endif
57
58 +#if defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) || defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC_MODULE)
59 + bcm_register_device(&snd_rpi_iqaudio_dac_device);
60 + i2c_register_board_info(1, snd_pcm512x_i2c_devices, ARRAY_SIZE(snd_pcm512x_i2c_devices));
61 +#endif
62 +
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 diff --git a/sound/soc/bcm/Kconfig b/sound/soc/bcm/Kconfig
68 index e563dbc..c621a5e 100644
69 --- a/sound/soc/bcm/Kconfig
70 +++ b/sound/soc/bcm/Kconfig
71 @@ -39,3 +39,10 @@ config SND_BCM2708_SOC_RPI_DAC
72 select SND_SOC_PCM1794A
73 help
74 Say Y or M if you want to add support for RPi-DAC.
75 +
76 +config SND_BCM2708_SOC_IQAUDIO_DAC
77 + tristate "Support for IQaudIO-DAC"
78 + depends on SND_BCM2708_SOC_I2S
79 + select SND_SOC_PCM512x_I2C
80 + help
81 + Say Y or M if you want to add support for IQaudIO-DAC.
82 diff --git a/sound/soc/bcm/Makefile b/sound/soc/bcm/Makefile
83 index 826df7d..d597fb0 100644
84 --- a/sound/soc/bcm/Makefile
85 +++ b/sound/soc/bcm/Makefile
86 @@ -12,7 +12,9 @@ obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd-soc-bcm2708-i2s.o
87 snd-soc-hifiberry-dac-objs := hifiberry_dac.o
88 snd-soc-hifiberry-digi-objs := hifiberry_digi.o
89 snd-soc-rpi-dac-objs := rpi-dac.o
90 +snd-soc-iqaudio-dac-objs := iqaudio-dac.o
91
92 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
93 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) += snd-soc-hifiberry-digi.o
94 obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
95 +obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
96 diff --git a/sound/soc/bcm/iqaudio-dac.c b/sound/soc/bcm/iqaudio-dac.c
97 new file mode 100644
98 index 0000000..8d0e2ae
99 --- /dev/null
100 +++ b/sound/soc/bcm/iqaudio-dac.c
101 @@ -0,0 +1,111 @@
102 +/*
103 + * ASoC Driver for IQaudIO DAC
104 + *
105 + * Author: Florian Meier <florian.meier@koalo.de>
106 + * Copyright 2013
107 + *
108 + * This program is free software; you can redistribute it and/or
109 + * modify it under the terms of the GNU General Public License
110 + * version 2 as published by the Free Software Foundation.
111 + *
112 + * This program is distributed in the hope that it will be useful, but
113 + * WITHOUT ANY WARRANTY; without even the implied warranty of
114 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
115 + * General Public License for more details.
116 + */
117 +
118 +#include <linux/module.h>
119 +#include <linux/platform_device.h>
120 +
121 +#include <sound/core.h>
122 +#include <sound/pcm.h>
123 +#include <sound/pcm_params.h>
124 +#include <sound/soc.h>
125 +#include <sound/jack.h>
126 +
127 +static int snd_rpi_iqaudio_dac_init(struct snd_soc_pcm_runtime *rtd)
128 +{
129 +// NOT USED struct snd_soc_codec *codec = rtd->codec;
130 +
131 + return 0;
132 +}
133 +
134 +static int snd_rpi_iqaudio_dac_hw_params(struct snd_pcm_substream *substream,
135 + struct snd_pcm_hw_params *params)
136 +{
137 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
138 +// NOT USED struct snd_soc_dai *codec_dai = rtd->codec_dai;
139 +// NOT USED struct snd_soc_codec *codec = rtd->codec;
140 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
141 +
142 + unsigned int sample_bits =
143 + snd_pcm_format_physical_width(params_format(params));
144 +
145 + return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
146 +}
147 +
148 +/* machine stream operations */
149 +static struct snd_soc_ops snd_rpi_iqaudio_dac_ops = {
150 + .hw_params = snd_rpi_iqaudio_dac_hw_params,
151 +};
152 +
153 +static struct snd_soc_dai_link snd_rpi_iqaudio_dac_dai[] = {
154 +{
155 + .name = "IQaudIO DAC",
156 + .stream_name = "IQaudIO DAC HiFi",
157 + .cpu_dai_name = "bcm2708-i2s.0",
158 + .codec_dai_name = "pcm512x-hifi",
159 + .platform_name = "bcm2708-i2s.0",
160 + .codec_name = "pcm512x.1-004c",
161 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
162 + SND_SOC_DAIFMT_CBS_CFS,
163 + .ops = &snd_rpi_iqaudio_dac_ops,
164 + .init = snd_rpi_iqaudio_dac_init,
165 +},
166 +};
167 +
168 +/* audio machine driver */
169 +static struct snd_soc_card snd_rpi_iqaudio_dac = {
170 + .name = "IQaudIODAC",
171 + .dai_link = snd_rpi_iqaudio_dac_dai,
172 + .num_links = ARRAY_SIZE(snd_rpi_iqaudio_dac_dai),
173 +};
174 +
175 +static int snd_rpi_iqaudio_dac_probe(struct platform_device *pdev)
176 +{
177 + int ret = 0;
178 +
179 + snd_rpi_iqaudio_dac.dev = &pdev->dev;
180 + ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);
181 + if (ret)
182 + dev_err(&pdev->dev,
183 + "snd_soc_register_card() failed: %d\n", ret);
184 +
185 + return ret;
186 +}
187 +
188 +static int snd_rpi_iqaudio_dac_remove(struct platform_device *pdev)
189 +{
190 + return snd_soc_unregister_card(&snd_rpi_iqaudio_dac);
191 +}
192 +
193 +static const struct of_device_id iqaudio_of_match[] = {
194 + { .compatible = "iqaudio,iqaudio-dac", },
195 + {},
196 +};
197 +
198 +static struct platform_driver snd_rpi_iqaudio_dac_driver = {
199 + .driver = {
200 + .name = "snd-rpi-iqaudio-dac",
201 + .owner = THIS_MODULE,
202 + .of_match_table = iqaudio_of_match,
203 + },
204 + .probe = snd_rpi_iqaudio_dac_probe,
205 + .remove = snd_rpi_iqaudio_dac_remove,
206 +};
207 +
208 +module_platform_driver(snd_rpi_iqaudio_dac_driver);
209 +
210 +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
211 +MODULE_DESCRIPTION("ASoC Driver for IQAudio DAC");
212 +MODULE_LICENSE("GPL v2");
213 --
214 1.8.3.2
215