1 From a6bc94bfd95cb3351ebac3ccff75cd915a8d9e86 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Mon, 13 Apr 2015 18:45:39 +0100
4 Subject: [PATCH 050/203] Adding Device Tree support for some RPi audio cards
7 arch/arm/mach-bcm2709/bcm2709.c | 143 ++++++++++++++++++++++++++++++++++++++
8 sound/soc/bcm/hifiberry_dac.c | 22 ++++++
9 sound/soc/bcm/hifiberry_dacplus.c | 22 ++++++
10 sound/soc/bcm/hifiberry_digi.c | 22 ++++++
11 sound/soc/bcm/iqaudio-dac.c | 16 +++++
12 sound/soc/codecs/pcm5102a.c | 7 ++
13 6 files changed, 232 insertions(+)
15 --- a/arch/arm/mach-bcm2709/bcm2709.c
16 +++ b/arch/arm/mach-bcm2709/bcm2709.c
17 @@ -636,6 +636,115 @@ static struct platform_device bcm2835_th
18 .name = "bcm2835_thermal",
21 +#if defined(CONFIG_SND_BCM2708_SOC_I2S) || defined(CONFIG_SND_BCM2708_SOC_I2S_MODULE)
22 +static struct resource bcm2708_i2s_resources[] = {
25 + .end = I2S_BASE + 0x20,
26 + .flags = IORESOURCE_MEM,
29 + .start = PCM_CLOCK_BASE,
30 + .end = PCM_CLOCK_BASE + 0x02,
31 + .flags = IORESOURCE_MEM,
35 +static struct platform_device bcm2708_i2s_device = {
36 + .name = "bcm2708-i2s",
38 + .num_resources = ARRAY_SIZE(bcm2708_i2s_resources),
39 + .resource = bcm2708_i2s_resources,
43 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC_MODULE)
44 +static struct platform_device snd_hifiberry_dac_device = {
45 + .name = "snd-hifiberry-dac",
50 +static struct platform_device snd_pcm5102a_codec_device = {
51 + .name = "pcm5102a-codec",
57 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS_MODULE)
58 +static struct platform_device snd_rpi_hifiberry_dacplus_device = {
59 + .name = "snd-rpi-hifiberry-dacplus",
64 +static struct i2c_board_info __initdata snd_pcm512x_hbdacplus_i2c_devices[] = {
66 + I2C_BOARD_INFO("pcm5122", 0x4d)
71 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI_MODULE)
72 +static struct platform_device snd_hifiberry_digi_device = {
73 + .name = "snd-hifiberry-digi",
78 +static struct i2c_board_info __initdata snd_wm8804_i2c_devices[] = {
80 + I2C_BOARD_INFO("wm8804", 0x3b)
86 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP_MODULE)
87 +static struct platform_device snd_hifiberry_amp_device = {
88 + .name = "snd-hifiberry-amp",
93 +static struct i2c_board_info __initdata snd_tas5713_i2c_devices[] = {
95 + I2C_BOARD_INFO("tas5713", 0x1b)
100 +#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE)
101 +static struct platform_device snd_rpi_dac_device = {
102 + .name = "snd-rpi-dac",
104 + .num_resources = 0,
107 +static struct platform_device snd_pcm1794a_codec_device = {
108 + .name = "pcm1794a-codec",
110 + .num_resources = 0,
115 +#if defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) || defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC_MODULE)
116 +static struct platform_device snd_rpi_iqaudio_dac_device = {
117 + .name = "snd-rpi-iqaudio-dac",
119 + .num_resources = 0,
122 +// Use the actual device name rather than generic driver name
123 +static struct i2c_board_info __initdata snd_pcm512x_i2c_devices[] = {
125 + I2C_BOARD_INFO("pcm5122", 0x4c)
130 int __init bcm_register_device(struct platform_device *pdev)
133 @@ -800,6 +909,40 @@ void __init bcm2709_init(void)
135 bcm_register_device_dt(&bcm2835_thermal_device);
137 +#if defined(CONFIG_SND_BCM2708_SOC_I2S) || defined(CONFIG_SND_BCM2708_SOC_I2S_MODULE)
138 + bcm_register_device_dt(&bcm2708_i2s_device);
141 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC_MODULE)
142 + bcm_register_device_dt(&snd_hifiberry_dac_device);
143 + bcm_register_device_dt(&snd_pcm5102a_codec_device);
146 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS_MODULE)
147 + bcm_register_device_dt(&snd_rpi_hifiberry_dacplus_device);
148 + i2c_register_board_info_dt(1, snd_pcm512x_hbdacplus_i2c_devices, ARRAY_SIZE(snd_pcm512x_hbdacplus_i2c_devices));
151 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI_MODULE)
152 + bcm_register_device_dt(&snd_hifiberry_digi_device);
153 + i2c_register_board_info_dt(1, snd_wm8804_i2c_devices, ARRAY_SIZE(snd_wm8804_i2c_devices));
156 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP_MODULE)
157 + bcm_register_device_dt(&snd_hifiberry_amp_device);
158 + i2c_register_board_info_dt(1, snd_tas5713_i2c_devices, ARRAY_SIZE(snd_tas5713_i2c_devices));
161 +#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE)
162 + bcm_register_device_dt(&snd_rpi_dac_device);
163 + bcm_register_device_dt(&snd_pcm1794a_codec_device);
166 +#if defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) || defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC_MODULE)
167 + bcm_register_device_dt(&snd_rpi_iqaudio_dac_device);
168 + i2c_register_board_info_dt(1, snd_pcm512x_i2c_devices, ARRAY_SIZE(snd_pcm512x_i2c_devices));
172 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
173 struct amba_device *d = amba_devs[i];
174 --- a/sound/soc/bcm/hifiberry_dac.c
175 +++ b/sound/soc/bcm/hifiberry_dac.c
176 @@ -72,6 +72,21 @@ static int snd_rpi_hifiberry_dac_probe(s
179 snd_rpi_hifiberry_dac.dev = &pdev->dev;
181 + if (pdev->dev.of_node) {
182 + struct device_node *i2s_node;
183 + struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_dac_dai[0];
184 + i2s_node = of_parse_phandle(pdev->dev.of_node,
185 + "i2s-controller", 0);
188 + dai->cpu_dai_name = NULL;
189 + dai->cpu_of_node = i2s_node;
190 + dai->platform_name = NULL;
191 + dai->platform_of_node = i2s_node;
195 ret = snd_soc_register_card(&snd_rpi_hifiberry_dac);
197 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
198 @@ -84,10 +99,17 @@ static int snd_rpi_hifiberry_dac_remove(
199 return snd_soc_unregister_card(&snd_rpi_hifiberry_dac);
202 +static const struct of_device_id snd_rpi_hifiberry_dac_of_match[] = {
203 + { .compatible = "hifiberry,hifiberry-dac", },
206 +MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_dac_of_match);
208 static struct platform_driver snd_rpi_hifiberry_dac_driver = {
210 .name = "snd-hifiberry-dac",
211 .owner = THIS_MODULE,
212 + .of_match_table = snd_rpi_hifiberry_dac_of_match,
214 .probe = snd_rpi_hifiberry_dac_probe,
215 .remove = snd_rpi_hifiberry_dac_remove,
216 --- a/sound/soc/bcm/hifiberry_dacplus.c
217 +++ b/sound/soc/bcm/hifiberry_dacplus.c
218 @@ -90,6 +90,21 @@ static int snd_rpi_hifiberry_dacplus_pro
221 snd_rpi_hifiberry_dacplus.dev = &pdev->dev;
223 + if (pdev->dev.of_node) {
224 + struct device_node *i2s_node;
225 + struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_dacplus_dai[0];
226 + i2s_node = of_parse_phandle(pdev->dev.of_node,
227 + "i2s-controller", 0);
230 + dai->cpu_dai_name = NULL;
231 + dai->cpu_of_node = i2s_node;
232 + dai->platform_name = NULL;
233 + dai->platform_of_node = i2s_node;
237 ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplus);
240 @@ -103,10 +118,17 @@ static int snd_rpi_hifiberry_dacplus_rem
241 return snd_soc_unregister_card(&snd_rpi_hifiberry_dacplus);
244 +static const struct of_device_id snd_rpi_hifiberry_dacplus_of_match[] = {
245 + { .compatible = "hifiberry,hifiberry-dacplus", },
248 +MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_dacplus_of_match);
250 static struct platform_driver snd_rpi_hifiberry_dacplus_driver = {
252 .name = "snd-rpi-hifiberry-dacplus",
253 .owner = THIS_MODULE,
254 + .of_match_table = snd_rpi_hifiberry_dacplus_of_match,
256 .probe = snd_rpi_hifiberry_dacplus_probe,
257 .remove = snd_rpi_hifiberry_dacplus_remove,
258 --- a/sound/soc/bcm/hifiberry_digi.c
259 +++ b/sound/soc/bcm/hifiberry_digi.c
260 @@ -173,6 +173,21 @@ static int snd_rpi_hifiberry_digi_probe(
263 snd_rpi_hifiberry_digi.dev = &pdev->dev;
265 + if (pdev->dev.of_node) {
266 + struct device_node *i2s_node;
267 + struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_digi_dai[0];
268 + i2s_node = of_parse_phandle(pdev->dev.of_node,
269 + "i2s-controller", 0);
272 + dai->cpu_dai_name = NULL;
273 + dai->cpu_of_node = i2s_node;
274 + dai->platform_name = NULL;
275 + dai->platform_of_node = i2s_node;
279 ret = snd_soc_register_card(&snd_rpi_hifiberry_digi);
281 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
282 @@ -185,10 +200,17 @@ static int snd_rpi_hifiberry_digi_remove
283 return snd_soc_unregister_card(&snd_rpi_hifiberry_digi);
286 +static const struct of_device_id snd_rpi_hifiberry_digi_of_match[] = {
287 + { .compatible = "hifiberry,hifiberry-digi", },
290 +MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_digi_of_match);
292 static struct platform_driver snd_rpi_hifiberry_digi_driver = {
294 .name = "snd-hifiberry-digi",
295 .owner = THIS_MODULE,
296 + .of_match_table = snd_rpi_hifiberry_digi_of_match,
298 .probe = snd_rpi_hifiberry_digi_probe,
299 .remove = snd_rpi_hifiberry_digi_remove,
300 --- a/sound/soc/bcm/iqaudio-dac.c
301 +++ b/sound/soc/bcm/iqaudio-dac.c
302 @@ -82,6 +82,21 @@ static int snd_rpi_iqaudio_dac_probe(str
305 snd_rpi_iqaudio_dac.dev = &pdev->dev;
307 + if (pdev->dev.of_node) {
308 + struct device_node *i2s_node;
309 + struct snd_soc_dai_link *dai = &snd_rpi_iqaudio_dac_dai[0];
310 + i2s_node = of_parse_phandle(pdev->dev.of_node,
311 + "i2s-controller", 0);
314 + dai->cpu_dai_name = NULL;
315 + dai->cpu_of_node = i2s_node;
316 + dai->platform_name = NULL;
317 + dai->platform_of_node = i2s_node;
321 ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);
324 @@ -99,6 +114,7 @@ static const struct of_device_id iqaudio
325 { .compatible = "iqaudio,iqaudio-dac", },
328 +MODULE_DEVICE_TABLE(of, iqaudio_of_match);
330 static struct platform_driver snd_rpi_iqaudio_dac_driver = {
332 --- a/sound/soc/codecs/pcm5102a.c
333 +++ b/sound/soc/codecs/pcm5102a.c
334 @@ -47,12 +47,19 @@ static int pcm5102a_remove(struct platfo
338 +static const struct of_device_id pcm5102a_of_match[] = {
339 + { .compatible = "ti,pcm5102a", },
342 +MODULE_DEVICE_TABLE(of, pcm5102a_of_match);
344 static struct platform_driver pcm5102a_codec_driver = {
345 .probe = pcm5102a_probe,
346 .remove = pcm5102a_remove,
348 .name = "pcm5102a-codec",
349 .owner = THIS_MODULE,
350 + .of_match_table = pcm5102a_of_match,