brcm2708: update linux 4.4 patches to latest version
[openwrt/staging/dedeckeh.git] / target / linux / brcm2708 / patches-4.4 / 0423-Add-support-for-Dion-Audio-LOCO-DAC-AMP-HAT.patch
1 From 6fa4c2110478a814a9dd44d64522e7a81a1a2793 Mon Sep 17 00:00:00 2001
2 From: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>
3 Date: Sat, 2 Jul 2016 16:26:19 +0100
4 Subject: [PATCH 423/423] Add support for Dion Audio LOCO DAC-AMP HAT
5
6 Using dedicated machine driver and pcm5102a codec driver.
7
8 Signed-off-by: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>
9 ---
10 arch/arm/boot/dts/overlays/Makefile | 1 +
11 arch/arm/boot/dts/overlays/README | 6 +
12 .../boot/dts/overlays/dionaudio-loco-overlay.dts | 39 +++++++
13 arch/arm/configs/bcm2709_defconfig | 1 +
14 arch/arm/configs/bcmrpi_defconfig | 1 +
15 sound/soc/bcm/Kconfig | 7 ++
16 sound/soc/bcm/Makefile | 3 +-
17 sound/soc/bcm/dionaudio_loco.c | 121 +++++++++++++++++++++
18 8 files changed, 178 insertions(+), 1 deletion(-)
19 create mode 100644 arch/arm/boot/dts/overlays/dionaudio-loco-overlay.dts
20 create mode 100644 sound/soc/bcm/dionaudio_loco.c
21
22 --- a/arch/arm/boot/dts/overlays/Makefile
23 +++ b/arch/arm/boot/dts/overlays/Makefile
24 @@ -20,6 +20,7 @@ dtbo-$(RPI_DT_OVERLAYS) += at86rf233.dtb
25 dtbo-$(RPI_DT_OVERLAYS) += audioinjector-wm8731-audio.dtbo
26 dtbo-$(RPI_DT_OVERLAYS) += bmp085_i2c-sensor.dtbo
27 dtbo-$(RPI_DT_OVERLAYS) += dht11.dtbo
28 +dtbo-$(RPI_DT_OVERLAYS) += dionaudio-loco.dtbo
29 dtbo-$(RPI_DT_OVERLAYS) += dpi24.dtbo
30 dtbo-$(RPI_DT_OVERLAYS) += dwc-otg.dtbo
31 dtbo-$(RPI_DT_OVERLAYS) += dwc2.dtbo
32 --- a/arch/arm/boot/dts/overlays/README
33 +++ b/arch/arm/boot/dts/overlays/README
34 @@ -268,6 +268,12 @@ Params: gpiopin GPIO con
35 (default 4)
36
37
38 +Name: dionaudio-loco
39 +Info: Configures the Dion Audio LOCO DAC-AMP
40 +Load: dtoverlay=dionaudio-loco
41 +Params: <None>
42 +
43 +
44 Name: dpi24
45 Info: Overlay for a generic 24-bit DPI display
46 This uses GPIOs 0-27 (so no I2C, uart etc.), and activates the output
47 --- /dev/null
48 +++ b/arch/arm/boot/dts/overlays/dionaudio-loco-overlay.dts
49 @@ -0,0 +1,39 @@
50 +// Definitions for Dion Audio LOCO DAC-AMP
51 +
52 +/*
53 + * PCM5242 DAC (in hardware mode) and TPA3118 AMP.
54 + */
55 +
56 +/dts-v1/;
57 +/plugin/;
58 +
59 +/ {
60 + compatible = "brcm,bcm2708";
61 +
62 + fragment@0 {
63 + target = <&i2s>;
64 + __overlay__ {
65 + status = "okay";
66 + };
67 + };
68 +
69 + fragment@1 {
70 + target-path = "/";
71 + __overlay__ {
72 + pcm5102a-codec {
73 + #sound-dai-cells = <0>;
74 + compatible = "ti,pcm5102a";
75 + status = "okay";
76 + };
77 + };
78 + };
79 +
80 + fragment@2 {
81 + target = <&sound>;
82 + __overlay__ {
83 + compatible = "dionaudio,loco-pcm5242-tpa3118";
84 + i2s-controller = <&i2s>;
85 + status = "okay";
86 + };
87 + };
88 +};
89 --- a/arch/arm/configs/bcm2709_defconfig
90 +++ b/arch/arm/configs/bcm2709_defconfig
91 @@ -870,6 +870,7 @@ CONFIG_SND_BCM2708_SOC_RASPIDAC3=m
92 CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD=m
93 CONFIG_SND_DIGIDAC1_SOUNDCARD=m
94 CONFIG_SND_BCM2708_SOC_ADAU1977_ADC=m
95 +CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO=m
96 CONFIG_SND_SOC_ADAU1701=m
97 CONFIG_SND_SOC_WM8804_I2C=m
98 CONFIG_SND_SIMPLE_CARD=m
99 --- a/arch/arm/configs/bcmrpi_defconfig
100 +++ b/arch/arm/configs/bcmrpi_defconfig
101 @@ -862,6 +862,7 @@ CONFIG_SND_BCM2708_SOC_RASPIDAC3=m
102 CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD=m
103 CONFIG_SND_DIGIDAC1_SOUNDCARD=m
104 CONFIG_SND_BCM2708_SOC_ADAU1977_ADC=m
105 +CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO=m
106 CONFIG_SND_SOC_ADAU1701=m
107 CONFIG_SND_SOC_WM8804_I2C=m
108 CONFIG_SND_SIMPLE_CARD=m
109 --- a/sound/soc/bcm/Kconfig
110 +++ b/sound/soc/bcm/Kconfig
111 @@ -107,3 +107,10 @@ config SND_DIGIDAC1_SOUNDCARD
112 select SND_SOC_WM8741
113 help
114 Say Y or M if you want to add support for Red Rocks Audio DigiDAC1 board.
115 +
116 +config SND_BCM2708_SOC_DIONAUDIO_LOCO
117 + tristate "Support for Dion Audio LOCO DAC-AMP"
118 + depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
119 + select SND_SOC_PCM5102a
120 + help
121 + Say Y or M if you want to add support for Dion Audio LOCO.
122 --- a/sound/soc/bcm/Makefile
123 +++ b/sound/soc/bcm/Makefile
124 @@ -18,6 +18,7 @@ snd-soc-iqaudio-digi-objs := iqaudio_dig
125 snd-soc-raspidac3-objs := raspidac3.o
126 snd-soc-audioinjector-pi-soundcard-objs := audioinjector-pi-soundcard.o
127 snd-soc-digidac1-soundcard-objs := digidac1-soundcard.o
128 +snd-soc-dionaudio-loco-objs := dionaudio_loco.o
129
130 obj-$(CONFIG_SND_BCM2708_SOC_ADAU1977_ADC) += snd-soc-adau1977-adc.o
131 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
132 @@ -33,4 +34,4 @@ obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DIG
133 obj-$(CONFIG_SND_BCM2708_SOC_RASPIDAC3) += snd-soc-raspidac3.o
134 obj-$(CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD) += snd-soc-audioinjector-pi-soundcard.o
135 obj-$(CONFIG_SND_DIGIDAC1_SOUNDCARD) += snd-soc-digidac1-soundcard.o
136 -
137 +obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO) += snd-soc-dionaudio-loco.o
138 --- /dev/null
139 +++ b/sound/soc/bcm/dionaudio_loco.c
140 @@ -0,0 +1,121 @@
141 +/*
142 + * ASoC Driver for Dion Audio LOCO DAC-AMP
143 + *
144 + * Author: Miquel Blauw <info@dionaudio.nl>
145 + * Copyright 2016
146 + *
147 + * Based on the software of the RPi-DAC writen by Florian Meier
148 + *
149 + * This program is free software; you can redistribute it and/or
150 + * modify it under the terms of the GNU General Public License
151 + * version 2 as published by the Free Software Foundation.
152 + *
153 + * This program is distributed in the hope that it will be useful, but
154 + * WITHOUT ANY WARRANTY; without even the implied warranty of
155 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
156 + * General Public License for more details.
157 + */
158 +
159 +#include <linux/module.h>
160 +#include <linux/platform_device.h>
161 +
162 +#include <sound/core.h>
163 +#include <sound/pcm.h>
164 +#include <sound/pcm_params.h>
165 +#include <sound/soc.h>
166 +#include <sound/jack.h>
167 +
168 +static int snd_rpi_dionaudio_loco_hw_params(
169 + struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
170 +{
171 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
172 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
173 +
174 + unsigned int sample_bits =
175 + snd_pcm_format_physical_width(params_format(params));
176 +
177 + return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
178 +}
179 +
180 +/* machine stream operations */
181 +static struct snd_soc_ops snd_rpi_dionaudio_loco_ops = {
182 + .hw_params = snd_rpi_dionaudio_loco_hw_params,
183 +};
184 +
185 +static struct snd_soc_dai_link snd_rpi_dionaudio_loco_dai[] = {
186 +{
187 + .name = "DionAudio LOCO",
188 + .stream_name = "DionAudio LOCO DAC-AMP",
189 + .cpu_dai_name = "bcm2708-i2s.0",
190 + .codec_dai_name = "pcm5102a-hifi",
191 + .platform_name = "bcm2708-i2s.0",
192 + .codec_name = "pcm5102a-codec",
193 + .dai_fmt = SND_SOC_DAIFMT_I2S |
194 + SND_SOC_DAIFMT_NB_NF |
195 + SND_SOC_DAIFMT_CBS_CFS,
196 + .ops = &snd_rpi_dionaudio_loco_ops,
197 +},
198 +};
199 +
200 +/* audio machine driver */
201 +static struct snd_soc_card snd_rpi_dionaudio_loco = {
202 + .name = "snd_rpi_dionaudio_loco",
203 + .dai_link = snd_rpi_dionaudio_loco_dai,
204 + .num_links = ARRAY_SIZE(snd_rpi_dionaudio_loco_dai),
205 +};
206 +
207 +static int snd_rpi_dionaudio_loco_probe(struct platform_device *pdev)
208 +{
209 + struct device_node *np;
210 + int ret = 0;
211 +
212 + snd_rpi_dionaudio_loco.dev = &pdev->dev;
213 +
214 + np = pdev->dev.of_node;
215 + if (np) {
216 + struct snd_soc_dai_link *dai = &snd_rpi_dionaudio_loco_dai[0];
217 + struct device_node *i2s_np;
218 +
219 + i2s_np = of_parse_phandle(np, "i2s-controller", 0);
220 + if (i2s_np) {
221 + dai->cpu_dai_name = NULL;
222 + dai->cpu_of_node = i2s_np;
223 + dai->platform_name = NULL;
224 + dai->platform_of_node = i2s_np;
225 + }
226 + }
227 +
228 + ret = snd_soc_register_card(&snd_rpi_dionaudio_loco);
229 + if (ret)
230 + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
231 + ret);
232 +
233 + return ret;
234 +}
235 +
236 +static int snd_rpi_dionaudio_loco_remove(struct platform_device *pdev)
237 +{
238 + return snd_soc_unregister_card(&snd_rpi_dionaudio_loco);
239 +}
240 +
241 +static const struct of_device_id snd_rpi_dionaudio_loco_of_match[] = {
242 + { .compatible = "dionaudio,loco-pcm5242-tpa3118", },
243 + { /* sentinel */ },
244 +};
245 +MODULE_DEVICE_TABLE(of, snd_rpi_dionaudio_loco_of_match);
246 +
247 +static struct platform_driver snd_rpi_dionaudio_loco_driver = {
248 + .driver = {
249 + .name = "snd-dionaudio-loco",
250 + .owner = THIS_MODULE,
251 + .of_match_table = snd_rpi_dionaudio_loco_of_match,
252 + },
253 + .probe = snd_rpi_dionaudio_loco_probe,
254 + .remove = snd_rpi_dionaudio_loco_remove,
255 +};
256 +
257 +module_platform_driver(snd_rpi_dionaudio_loco_driver);
258 +
259 +MODULE_AUTHOR("Miquel Blauw <info@dionaudio.nl>");
260 +MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO");
261 +MODULE_LICENSE("GPL v2");