Skip to content

Commit a0d3546

Browse files
larsclausenbroonie
authored andcommitted
ASoC: Add ADAU7002 Stereo PDM-to-I2S/TDM Converter driver
This patch adds support for the ADAU7002 PDM-to-I2S/TDM converter. The ADAU7002 takes a stereo PDM signal (e.g. from two digital microphones) and converts it into a I2S/TDM PCM stream. The chip does not have a programmable control interface and the driver simply describes the static capabilities of the chip. Signed-off-by: Lars-Peter Clausen <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 254a138 commit a0d3546

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

sound/soc/codecs/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ config SND_SOC_ALL_CODECS
3232
select SND_SOC_ADAU1977_SPI if SPI_MASTER
3333
select SND_SOC_ADAU1977_I2C if I2C
3434
select SND_SOC_ADAU1701 if I2C
35+
select SND_SOC_ADAU7002
3536
select SND_SOC_ADS117X
3637
select SND_SOC_AK4104 if SPI_MASTER
3738
select SND_SOC_AK4535 if I2C
@@ -322,6 +323,9 @@ config SND_SOC_ADAU1977_I2C
322323
select SND_SOC_ADAU1977
323324
select REGMAP_I2C
324325

326+
config SND_SOC_ADAU7002
327+
tristate "Analog Devices ADAU7002 Stereo PDM-to-I2S/TDM Converter"
328+
325329
config SND_SOC_ADAV80X
326330
tristate
327331

sound/soc/codecs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ snd-soc-adau1781-spi-objs := adau1781-spi.o
1919
snd-soc-adau1977-objs := adau1977.o
2020
snd-soc-adau1977-spi-objs := adau1977-spi.o
2121
snd-soc-adau1977-i2c-objs := adau1977-i2c.o
22+
snd-soc-adau7002-objs := adau7002.o
2223
snd-soc-adav80x-objs := adav80x.o
2324
snd-soc-adav801-objs := adav801.o
2425
snd-soc-adav803-objs := adav803.o
@@ -232,6 +233,7 @@ obj-$(CONFIG_SND_SOC_ADAU1781_SPI) += snd-soc-adau1781-spi.o
232233
obj-$(CONFIG_SND_SOC_ADAU1977) += snd-soc-adau1977.o
233234
obj-$(CONFIG_SND_SOC_ADAU1977_SPI) += snd-soc-adau1977-spi.o
234235
obj-$(CONFIG_SND_SOC_ADAU1977_I2C) += snd-soc-adau1977-i2c.o
236+
obj-$(CONFIG_SND_SOC_ADAU7002) += snd-soc-adau7002.o
235237
obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o
236238
obj-$(CONFIG_SND_SOC_ADAV801) += snd-soc-adav801.o
237239
obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o

sound/soc/codecs/adau7002.c

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* ADAU7002 Stereo PDM-to-I2S/TDM converter driver
3+
*
4+
* Copyright 2014-2016 Analog Devices
5+
* Author: Lars-Peter Clausen <[email protected]>
6+
*
7+
* Licensed under the GPL-2.
8+
*/
9+
10+
#include <linux/init.h>
11+
#include <linux/module.h>
12+
#include <linux/of.h>
13+
#include <linux/platform_device.h>
14+
15+
#include <sound/soc.h>
16+
17+
static const struct snd_soc_dapm_widget adau7002_widgets[] = {
18+
SND_SOC_DAPM_INPUT("PDM_DAT"),
19+
SND_SOC_DAPM_REGULATOR_SUPPLY("IOVDD", 0, 0),
20+
};
21+
22+
static const struct snd_soc_dapm_route adau7002_routes[] = {
23+
{ "Capture", NULL, "PDM_DAT" },
24+
{ "Capture", NULL, "IOVDD" },
25+
};
26+
27+
static struct snd_soc_dai_driver adau7002_dai = {
28+
.name = "adau7002-hifi",
29+
.capture = {
30+
.stream_name = "Capture",
31+
.channels_min = 2,
32+
.channels_max = 2,
33+
.rates = SNDRV_PCM_RATE_8000_96000,
34+
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE |
35+
SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE |
36+
SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
37+
.sig_bits = 20,
38+
},
39+
};
40+
41+
static const struct snd_soc_codec_driver adau7002_codec_driver = {
42+
.dapm_widgets = adau7002_widgets,
43+
.num_dapm_widgets = ARRAY_SIZE(adau7002_widgets),
44+
.dapm_routes = adau7002_routes,
45+
.num_dapm_routes = ARRAY_SIZE(adau7002_routes),
46+
};
47+
48+
static int adau7002_probe(struct platform_device *pdev)
49+
{
50+
return snd_soc_register_codec(&pdev->dev, &adau7002_codec_driver,
51+
&adau7002_dai, 1);
52+
}
53+
54+
static int adau7002_remove(struct platform_device *pdev)
55+
{
56+
snd_soc_unregister_codec(&pdev->dev);
57+
return 0;
58+
}
59+
60+
#ifdef CONFIG_OF
61+
static const struct of_device_id adau7002_dt_ids[] = {
62+
{ .compatible = "adi,adau7002", },
63+
{ }
64+
};
65+
MODULE_DEVICE_TABLE(of, adau7002_dt_ids);
66+
#endif
67+
68+
static struct platform_driver adau7002_driver = {
69+
.driver = {
70+
.name = "adau7002",
71+
.of_match_table = of_match_ptr(adau7002_dt_ids),
72+
},
73+
.probe = adau7002_probe,
74+
.remove = adau7002_remove,
75+
};
76+
module_platform_driver(adau7002_driver);
77+
78+
MODULE_AUTHOR("Lars-Peter Clausen <[email protected]>");
79+
MODULE_DESCRIPTION("ADAU7002 Stereo PDM-to-I2S/TDM Converter driver");
80+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)