9cd839e045fff1928a32997c7b15bf2c5add783c
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.19 / 950-0264-Added-driver-for-the-HiFiBerry-DAC-ADC-2694.patch
1 From dde0ec6b9fd5755de3a8962489cde9c0ce5e5005 Mon Sep 17 00:00:00 2001
2 From: HiFiBerry <info@hifiberry.com>
3 Date: Mon, 8 Oct 2018 18:10:12 +0200
4 Subject: [PATCH] Added driver for the HiFiBerry DAC+ ADC (#2694)
5
6 Signed-off-by: Daniel Matuschek <daniel@hifiberry.com>
7 ---
8 arch/arm/boot/dts/overlays/Makefile | 1 +
9 arch/arm/boot/dts/overlays/README | 21 +
10 .../overlays/hifiberry-dacplusadc-overlay.dts | 71 +++
11 sound/soc/bcm/Kconfig | 8 +
12 sound/soc/bcm/Makefile | 2 +
13 sound/soc/bcm/hifiberry_dacplusadc.c | 407 ++++++++++++++++++
14 8 files changed, 512 insertions(+)
15 create mode 100644 arch/arm/boot/dts/overlays/hifiberry-dacplusadc-overlay.dts
16 create mode 100644 sound/soc/bcm/hifiberry_dacplusadc.c
17
18 --- a/arch/arm/boot/dts/overlays/Makefile
19 +++ b/arch/arm/boot/dts/overlays/Makefile
20 @@ -49,6 +49,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
21 hifiberry-amp.dtbo \
22 hifiberry-dac.dtbo \
23 hifiberry-dacplus.dtbo \
24 + hifiberry-dacplusadc.dtbo \
25 hifiberry-digi.dtbo \
26 hifiberry-digi-pro.dtbo \
27 hy28a.dtbo \
28 --- a/arch/arm/boot/dts/overlays/README
29 +++ b/arch/arm/boot/dts/overlays/README
30 @@ -779,6 +779,27 @@ Params: 24db_digital_gain Allow ga
31 master for bit clock and frame clock.
32
33
34 +Name: hifiberry-dacplusadc
35 +Info: Configures the HifiBerry DAC+ADC audio card
36 +Load: dtoverlay=hifiberry-dacplusadc,<param>=<val>
37 +Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
38 + Digital volume control. Enable with
39 + "dtoverlay=hifiberry-dacplus,24db_digital_gain"
40 + (The default behaviour is that the Digital
41 + volume control is limited to a maximum of
42 + 0dB. ie. it can attenuate but not provide
43 + gain. For most users, this will be desired
44 + as it will prevent clipping. By appending
45 + the 24dB_digital_gain parameter, the Digital
46 + volume control will allow up to 24dB of
47 + gain. If this parameter is enabled, it is the
48 + responsibility of the user to ensure that
49 + the Digital volume control is set to a value
50 + that does not result in clipping/distortion!)
51 + slave Force DAC+ Pro into slave mode, using Pi as
52 + master for bit clock and frame clock.
53 +
54 +
55 Name: hifiberry-digi
56 Info: Configures the HifiBerry Digi and Digi+ audio card
57 Load: dtoverlay=hifiberry-digi
58 --- /dev/null
59 +++ b/arch/arm/boot/dts/overlays/hifiberry-dacplusadc-overlay.dts
60 @@ -0,0 +1,71 @@
61 +// Definitions for HiFiBerry DAC+ADC
62 +/dts-v1/;
63 +/plugin/;
64 +
65 +/ {
66 + compatible = "brcm,bcm2708";
67 +
68 + fragment@0 {
69 + target-path = "/clocks";
70 + __overlay__ {
71 + dacpro_osc: dacpro_osc {
72 + compatible = "hifiberry,dacpro-clk";
73 + #clock-cells = <0>;
74 + };
75 + };
76 + };
77 +
78 + fragment@1 {
79 + target = <&i2s>;
80 + __overlay__ {
81 + status = "okay";
82 + };
83 + };
84 +
85 + fragment@2 {
86 + target = <&i2c1>;
87 + __overlay__ {
88 + #address-cells = <1>;
89 + #size-cells = <0>;
90 + status = "okay";
91 +
92 + pcm_codec: pcm5122@4d {
93 + #sound-dai-cells = <0>;
94 + compatible = "ti,pcm5122";
95 + reg = <0x4d>;
96 + clocks = <&dacpro_osc>;
97 + AVDD-supply = <&vdd_3v3_reg>;
98 + DVDD-supply = <&vdd_3v3_reg>;
99 + CPVDD-supply = <&vdd_3v3_reg>;
100 + status = "okay";
101 + };
102 + };
103 + };
104 +
105 + fragment@3 {
106 + target-path = "/";
107 + __overlay__ {
108 + dmic {
109 + #sound-dai-cells = <0>;
110 + compatible = "dmic-codec";
111 + num-channels = <2>;
112 + status = "okay";
113 + };
114 + };
115 + };
116 +
117 + fragment@4 {
118 + target = <&sound>;
119 + hifiberry_dacplusadc: __overlay__ {
120 + compatible = "hifiberry,hifiberry-dacplusadc";
121 + i2s-controller = <&i2s>;
122 + status = "okay";
123 + };
124 + };
125 +
126 + __overrides__ {
127 + 24db_digital_gain =
128 + <&hifiberry_dacplusadc>,"hifiberry,24db_digital_gain?";
129 + slave = <&hifiberry_dacplusadc>,"hifiberry-dacplusadc,slave?";
130 + };
131 +};
132 --- a/sound/soc/bcm/Kconfig
133 +++ b/sound/soc/bcm/Kconfig
134 @@ -46,6 +46,14 @@ config SND_BCM2708_SOC_HIFIBERRY_DACPLUS
135 help
136 Say Y or M if you want to add support for HifiBerry DAC+.
137
138 +config SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC
139 + tristate "Support for HifiBerry DAC+ADC"
140 + depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
141 + select SND_SOC_PCM512x_I2C
142 + select SND_SOC_DMIC
143 + help
144 + Say Y or M if you want to add support for HifiBerry DAC+ADC.
145 +
146 config SND_BCM2708_SOC_HIFIBERRY_DIGI
147 tristate "Support for HifiBerry Digi"
148 depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
149 --- a/sound/soc/bcm/Makefile
150 +++ b/sound/soc/bcm/Makefile
151 @@ -14,6 +14,7 @@ snd-soc-googlevoicehat-codec-objs := goo
152 # BCM2708 Machine Support
153 snd-soc-3dlab-nano-player-objs := 3dlab-nano-player.o
154 snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
155 +snd-soc-hifiberry-dacplusadc-objs := hifiberry_dacplusadc.o
156 snd-soc-justboom-dac-objs := justboom-dac.o
157 snd-soc-rpi-cirrus-objs := rpi-cirrus.o
158 snd-soc-rpi-proto-objs := rpi-proto.o
159 @@ -36,6 +37,7 @@ snd-soc-rpi-wm8804-soundcard-objs := rpi
160 obj-$(CONFIG_SND_BCM2708_SOC_3DLAB_NANO_PLAYER) += snd-soc-3dlab-nano-player.o
161 obj-$(CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD) += snd-soc-googlevoicehat-codec.o
162 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
163 +obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC) += snd-soc-hifiberry-dacplusadc.o
164 obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC) += snd-soc-justboom-dac.o
165 obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS) += snd-soc-rpi-cirrus.o
166 obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
167 --- /dev/null
168 +++ b/sound/soc/bcm/hifiberry_dacplusadc.c
169 @@ -0,0 +1,407 @@
170 +/*
171 + * ASoC Driver for HiFiBerry DAC+ / DAC Pro with ADC
172 + *
173 + * Author: Daniel Matuschek, Stuart MacLean <stuart@hifiberry.com>
174 + * Copyright 2014-2015
175 + * based on code by Florian Meier <florian.meier@koalo.de>
176 + * ADC added by Joerg Schambacher <joscha@schambacher.com>
177 + * Copyright 2018
178 + *
179 + * This program is free software; you can redistribute it and/or
180 + * modify it under the terms of the GNU General Public License
181 + * version 2 as published by the Free Software Foundation.
182 + *
183 + * This program is distributed in the hope that it will be useful, but
184 + * WITHOUT ANY WARRANTY; without even the implied warranty of
185 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
186 + * General Public License for more details.
187 + */
188 +
189 +#include <linux/module.h>
190 +#include <linux/platform_device.h>
191 +#include <linux/kernel.h>
192 +#include <linux/clk.h>
193 +#include <linux/kernel.h>
194 +#include <linux/module.h>
195 +#include <linux/of.h>
196 +#include <linux/slab.h>
197 +#include <linux/delay.h>
198 +
199 +#include <sound/core.h>
200 +#include <sound/pcm.h>
201 +#include <sound/pcm_params.h>
202 +#include <sound/soc.h>
203 +#include <sound/jack.h>
204 +
205 +#include "../codecs/pcm512x.h"
206 +
207 +#define HIFIBERRY_DACPRO_NOCLOCK 0
208 +#define HIFIBERRY_DACPRO_CLK44EN 1
209 +#define HIFIBERRY_DACPRO_CLK48EN 2
210 +
211 +struct platform_device *dmic_codec_dev;
212 +
213 +struct pcm512x_priv {
214 + struct regmap *regmap;
215 + struct clk *sclk;
216 +};
217 +
218 +/* Clock rate of CLK44EN attached to GPIO6 pin */
219 +#define CLK_44EN_RATE 22579200UL
220 +/* Clock rate of CLK48EN attached to GPIO3 pin */
221 +#define CLK_48EN_RATE 24576000UL
222 +
223 +static bool slave;
224 +static bool snd_rpi_hifiberry_is_dacpro;
225 +static bool digital_gain_0db_limit = true;
226 +
227 +static void snd_rpi_hifiberry_dacplusadc_select_clk(struct snd_soc_component *component,
228 + int clk_id)
229 +{
230 + switch (clk_id) {
231 + case HIFIBERRY_DACPRO_NOCLOCK:
232 + snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x24, 0x00);
233 + break;
234 + case HIFIBERRY_DACPRO_CLK44EN:
235 + snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x24, 0x20);
236 + break;
237 + case HIFIBERRY_DACPRO_CLK48EN:
238 + snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x24, 0x04);
239 + break;
240 + }
241 +}
242 +
243 +static void snd_rpi_hifiberry_dacplusadc_clk_gpio(struct snd_soc_component *component)
244 +{
245 + snd_soc_component_update_bits(component, PCM512x_GPIO_EN, 0x24, 0x24);
246 + snd_soc_component_update_bits(component, PCM512x_GPIO_OUTPUT_3, 0x0f, 0x02);
247 + snd_soc_component_update_bits(component, PCM512x_GPIO_OUTPUT_6, 0x0f, 0x02);
248 +}
249 +
250 +static bool snd_rpi_hifiberry_dacplusadc_is_sclk(struct snd_soc_component *component)
251 +{
252 + unsigned int sck;
253 +
254 + snd_soc_component_read(component, PCM512x_RATE_DET_4, &sck);
255 + return (!(sck & 0x40));
256 +}
257 +
258 +static bool snd_rpi_hifiberry_dacplusadc_is_sclk_sleep(
259 + struct snd_soc_component *component)
260 +{
261 + msleep(2);
262 + return snd_rpi_hifiberry_dacplusadc_is_sclk(component);
263 +}
264 +
265 +static bool snd_rpi_hifiberry_dacplusadc_is_pro_card(struct snd_soc_component *component)
266 +{
267 + bool isClk44EN, isClk48En, isNoClk;
268 +
269 + snd_rpi_hifiberry_dacplusadc_clk_gpio(component);
270 +
271 + snd_rpi_hifiberry_dacplusadc_select_clk(component, HIFIBERRY_DACPRO_CLK44EN);
272 + isClk44EN = snd_rpi_hifiberry_dacplusadc_is_sclk_sleep(component);
273 +
274 + snd_rpi_hifiberry_dacplusadc_select_clk(component, HIFIBERRY_DACPRO_NOCLOCK);
275 + isNoClk = snd_rpi_hifiberry_dacplusadc_is_sclk_sleep(component);
276 +
277 + snd_rpi_hifiberry_dacplusadc_select_clk(component, HIFIBERRY_DACPRO_CLK48EN);
278 + isClk48En = snd_rpi_hifiberry_dacplusadc_is_sclk_sleep(component);
279 +
280 + return (isClk44EN && isClk48En && !isNoClk);
281 +}
282 +
283 +static int snd_rpi_hifiberry_dacplusadc_clk_for_rate(int sample_rate)
284 +{
285 + int type;
286 +
287 + switch (sample_rate) {
288 + case 11025:
289 + case 22050:
290 + case 44100:
291 + case 88200:
292 + case 176400:
293 + case 352800:
294 + type = HIFIBERRY_DACPRO_CLK44EN;
295 + break;
296 + default:
297 + type = HIFIBERRY_DACPRO_CLK48EN;
298 + break;
299 + }
300 + return type;
301 +}
302 +
303 +static void snd_rpi_hifiberry_dacplusadc_set_sclk(struct snd_soc_component *component,
304 + int sample_rate)
305 +{
306 + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
307 +
308 + if (!IS_ERR(pcm512x->sclk)) {
309 + int ctype;
310 +
311 + ctype = snd_rpi_hifiberry_dacplusadc_clk_for_rate(sample_rate);
312 + clk_set_rate(pcm512x->sclk, (ctype == HIFIBERRY_DACPRO_CLK44EN)
313 + ? CLK_44EN_RATE : CLK_48EN_RATE);
314 + snd_rpi_hifiberry_dacplusadc_select_clk(component, ctype);
315 + }
316 +}
317 +
318 +static int snd_rpi_hifiberry_dacplusadc_init(struct snd_soc_pcm_runtime *rtd)
319 +{
320 + struct snd_soc_component *component = rtd->codec_dai->component;
321 + struct pcm512x_priv *priv;
322 +
323 + if (slave)
324 + snd_rpi_hifiberry_is_dacpro = false;
325 + else
326 + snd_rpi_hifiberry_is_dacpro =
327 + snd_rpi_hifiberry_dacplusadc_is_pro_card(component);
328 +
329 + if (snd_rpi_hifiberry_is_dacpro) {
330 + struct snd_soc_dai_link *dai = rtd->dai_link;
331 +
332 + dai->name = "HiFiBerry ADCDAC+ Pro";
333 + dai->stream_name = "HiFiBerry ADCDAC+ Pro HiFi";
334 + dai->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
335 + | SND_SOC_DAIFMT_CBM_CFM;
336 +
337 + snd_soc_component_update_bits(component, PCM512x_BCLK_LRCLK_CFG, 0x31, 0x11);
338 + snd_soc_component_update_bits(component, PCM512x_MASTER_MODE, 0x03, 0x03);
339 + snd_soc_component_update_bits(component, PCM512x_MASTER_CLKDIV_2, 0x7f, 63);
340 + } else {
341 + priv = snd_soc_component_get_drvdata(component);
342 + priv->sclk = ERR_PTR(-ENOENT);
343 + }
344 +
345 + snd_soc_component_update_bits(component, PCM512x_GPIO_EN, 0x08, 0x08);
346 + snd_soc_component_update_bits(component, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
347 + snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1, 0x08, 0x08);
348 +
349 + if (digital_gain_0db_limit) {
350 + int ret;
351 + struct snd_soc_card *card = rtd->card;
352 +
353 + ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
354 + if (ret < 0)
355 + dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
356 + }
357 +
358 + return 0;
359 +}
360 +
361 +static int snd_rpi_hifiberry_dacplusadc_update_rate_den(
362 + struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
363 +{
364 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
365 + struct snd_soc_component *component = rtd->codec_dai->component;
366 + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
367 + struct snd_ratnum *rats_no_pll;
368 + unsigned int num = 0, den = 0;
369 + int err;
370 +
371 + rats_no_pll = devm_kzalloc(rtd->dev, sizeof(*rats_no_pll), GFP_KERNEL);
372 + if (!rats_no_pll)
373 + return -ENOMEM;
374 +
375 + rats_no_pll->num = clk_get_rate(pcm512x->sclk) / 64;
376 + rats_no_pll->den_min = 1;
377 + rats_no_pll->den_max = 128;
378 + rats_no_pll->den_step = 1;
379 +
380 + err = snd_interval_ratnum(hw_param_interval(params,
381 + SNDRV_PCM_HW_PARAM_RATE), 1, rats_no_pll, &num, &den);
382 + if (err >= 0 && den) {
383 + params->rate_num = num;
384 + params->rate_den = den;
385 + }
386 +
387 + devm_kfree(rtd->dev, rats_no_pll);
388 + return 0;
389 +}
390 +
391 +static int snd_rpi_hifiberry_dacplusadc_hw_params(
392 + struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
393 +{
394 + int ret = 0;
395 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
396 + int channels = params_channels(params);
397 + int width = 32;
398 +
399 + if (snd_rpi_hifiberry_is_dacpro) {
400 + struct snd_soc_component *component = rtd->codec_dai->component;
401 +
402 + width = snd_pcm_format_physical_width(params_format(params));
403 +
404 + snd_rpi_hifiberry_dacplusadc_set_sclk(component,
405 + params_rate(params));
406 +
407 + ret = snd_rpi_hifiberry_dacplusadc_update_rate_den(
408 + substream, params);
409 + }
410 +
411 + ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x03, 0x03,
412 + channels, width);
413 + if (ret)
414 + return ret;
415 + ret = snd_soc_dai_set_tdm_slot(rtd->codec_dai, 0x03, 0x03,
416 + channels, width);
417 + return ret;
418 +}
419 +
420 +static int hifiberry_dacplusadc_LED_cnt;
421 +
422 +static int snd_rpi_hifiberry_dacplusadc_startup(
423 + struct snd_pcm_substream *substream)
424 +{
425 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
426 + struct snd_soc_component *component = rtd->codec_dai->component;
427 +
428 + snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1,
429 + 0x08, 0x08);
430 + hifiberry_dacplusadc_LED_cnt++;
431 + return 0;
432 +}
433 +
434 +static void snd_rpi_hifiberry_dacplusadc_shutdown(
435 + struct snd_pcm_substream *substream)
436 +{
437 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
438 + struct snd_soc_component *component = rtd->codec_dai->component;
439 +
440 + hifiberry_dacplusadc_LED_cnt--;
441 + if (!hifiberry_dacplusadc_LED_cnt)
442 + snd_soc_component_update_bits(component, PCM512x_GPIO_CONTROL_1,
443 + 0x08, 0x00);
444 +}
445 +
446 +/* machine stream operations */
447 +static struct snd_soc_ops snd_rpi_hifiberry_dacplusadc_ops = {
448 + .hw_params = snd_rpi_hifiberry_dacplusadc_hw_params,
449 + .startup = snd_rpi_hifiberry_dacplusadc_startup,
450 + .shutdown = snd_rpi_hifiberry_dacplusadc_shutdown,
451 +};
452 +
453 +static struct snd_soc_dai_link_component snd_rpi_hifiberry_dacplusadc_codecs[] = {
454 + {
455 + .name = "pcm512x.1-004d",
456 + .dai_name = "pcm512x-hifi",
457 + },
458 + {
459 + .name = "dmic-codec",
460 + .dai_name = "dmic-hifi",
461 + },
462 +};
463 +
464 +static struct snd_soc_dai_link snd_rpi_hifiberry_dacplusadc_dai[] = {
465 +{
466 + .name = "HiFiBerry DAC+ADC",
467 + .stream_name = "HiFiBerry DAC+ADC HiFi",
468 + .cpu_dai_name = "bcm2708-i2s.0",
469 + .platform_name = "bcm2708-i2s.0",
470 + .codecs = snd_rpi_hifiberry_dacplusadc_codecs,
471 + .num_codecs = 2,
472 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
473 + SND_SOC_DAIFMT_CBS_CFS,
474 + .ops = &snd_rpi_hifiberry_dacplusadc_ops,
475 + .init = snd_rpi_hifiberry_dacplusadc_init,
476 +},
477 +};
478 +
479 +/* audio machine driver */
480 +static struct snd_soc_card snd_rpi_hifiberry_dacplusadc = {
481 + .name = "snd_rpi_hifiberry_dacplusadc",
482 + .driver_name = "HifiberryDacpAdc",
483 + .owner = THIS_MODULE,
484 + .dai_link = snd_rpi_hifiberry_dacplusadc_dai,
485 + .num_links = ARRAY_SIZE(snd_rpi_hifiberry_dacplusadc_dai),
486 +};
487 +
488 +
489 +static int snd_rpi_hifiberry_dacplusadc_probe(struct platform_device *pdev)
490 +{
491 + int ret = 0;
492 +
493 + snd_rpi_hifiberry_dacplusadc.dev = &pdev->dev;
494 + if (pdev->dev.of_node) {
495 + struct device_node *i2s_node;
496 + struct snd_soc_dai_link *dai;
497 +
498 + dai = &snd_rpi_hifiberry_dacplusadc_dai[0];
499 + i2s_node = of_parse_phandle(pdev->dev.of_node,
500 + "i2s-controller", 0);
501 + if (i2s_node) {
502 + dai->cpu_of_node = i2s_node;
503 + dai->platform_of_node = i2s_node;
504 + dai->cpu_dai_name = NULL;
505 + dai->platform_name = NULL;
506 + }
507 + dai = &snd_rpi_hifiberry_dacplusadc_dai[1];
508 + i2s_node = of_parse_phandle(pdev->dev.of_node, "dmic", 0);
509 + if (i2s_node) {
510 + dai->cpu_of_node = i2s_node;
511 + dai->platform_of_node = i2s_node;
512 + }
513 +
514 + }
515 + digital_gain_0db_limit = !of_property_read_bool(
516 + pdev->dev.of_node, "hifiberry,24db_digital_gain");
517 + slave = of_property_read_bool(pdev->dev.of_node,
518 + "hifiberry-dacplusadc,slave");
519 +
520 + ret = devm_snd_soc_register_card(&pdev->dev,
521 + &snd_rpi_hifiberry_dacplusadc);
522 + if (ret && ret != -EPROBE_DEFER)
523 + dev_err(&pdev->dev,
524 + "snd_soc_register_card() failed: %d\n", ret);
525 +
526 + return ret;
527 +}
528 +
529 +static const struct of_device_id snd_rpi_hifiberry_dacplusadc_of_match[] = {
530 + { .compatible = "hifiberry,hifiberry-dacplusadc", },
531 + {},
532 +};
533 +
534 +MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_dacplusadc_of_match);
535 +
536 +static struct platform_driver snd_rpi_hifiberry_dacplusadc_driver = {
537 + .driver = {
538 + .name = "snd-rpi-hifiberry-dacplusadc",
539 + .owner = THIS_MODULE,
540 + .of_match_table = snd_rpi_hifiberry_dacplusadc_of_match,
541 + },
542 + .probe = snd_rpi_hifiberry_dacplusadc_probe,
543 +};
544 +
545 +static int __init hifiberry_dacplusadc_init(void)
546 +{
547 + int ret;
548 +
549 + dmic_codec_dev = platform_device_register_simple("dmic-codec", -1, NULL,
550 + 0);
551 + if (IS_ERR(dmic_codec_dev)) {
552 + pr_err("%s: dmic-codec device registration failed\n", __func__);
553 + return PTR_ERR(dmic_codec_dev);
554 + }
555 +
556 + ret = platform_driver_register(&snd_rpi_hifiberry_dacplusadc_driver);
557 + if (ret) {
558 + pr_err("%s: platform driver registration failed\n", __func__);
559 + platform_device_unregister(dmic_codec_dev);
560 + }
561 +
562 + return ret;
563 +}
564 +module_init(hifiberry_dacplusadc_init);
565 +
566 +static void __exit hifiberry_dacplusadc_exit(void)
567 +{
568 + platform_driver_unregister(&snd_rpi_hifiberry_dacplusadc_driver);
569 + platform_device_unregister(dmic_codec_dev);
570 +}
571 +module_exit(hifiberry_dacplusadc_exit);
572 +
573 +MODULE_AUTHOR("Joerg Schambacher <joscha@schambacher.com>");
574 +MODULE_AUTHOR("Daniel Matuschek <daniel@hifiberry.com>");
575 +MODULE_DESCRIPTION("ASoC Driver for HiFiBerry DAC+ADC");
576 +MODULE_LICENSE("GPL v2");