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