blob: 49475e36a4e4a53cab898290af39edebea8fd54f [file] [log] [blame]
Lars-Peter Clausena0d35462016-06-02 14:19:42 +02001/*
2 * ADAU7002 Stereo PDM-to-I2S/TDM converter driver
3 *
4 * Copyright 2014-2016 Analog Devices
5 * Author: Lars-Peter Clausen <lars@metafoo.de>
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
17static 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
22static const struct snd_soc_dapm_route adau7002_routes[] = {
23 { "Capture", NULL, "PDM_DAT" },
24 { "Capture", NULL, "IOVDD" },
25};
26
27static 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
Kuninori Morimotod5bc5482018-01-29 04:11:10 +000041static const struct snd_soc_component_driver adau7002_component_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 .idle_bias_on = 1,
47 .use_pmdown_time = 1,
48 .endianness = 1,
49 .non_legacy_dai_naming = 1,
Lars-Peter Clausena0d35462016-06-02 14:19:42 +020050};
51
52static int adau7002_probe(struct platform_device *pdev)
53{
Kuninori Morimotod5bc5482018-01-29 04:11:10 +000054 return devm_snd_soc_register_component(&pdev->dev,
55 &adau7002_component_driver,
Lars-Peter Clausena0d35462016-06-02 14:19:42 +020056 &adau7002_dai, 1);
57}
58
59static int adau7002_remove(struct platform_device *pdev)
60{
Lars-Peter Clausena0d35462016-06-02 14:19:42 +020061 return 0;
62}
63
64#ifdef CONFIG_OF
65static const struct of_device_id adau7002_dt_ids[] = {
66 { .compatible = "adi,adau7002", },
67 { }
68};
69MODULE_DEVICE_TABLE(of, adau7002_dt_ids);
70#endif
71
72static struct platform_driver adau7002_driver = {
73 .driver = {
74 .name = "adau7002",
75 .of_match_table = of_match_ptr(adau7002_dt_ids),
76 },
77 .probe = adau7002_probe,
78 .remove = adau7002_remove,
79};
80module_platform_driver(adau7002_driver);
81
82MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
83MODULE_DESCRIPTION("ADAU7002 Stereo PDM-to-I2S/TDM Converter driver");
84MODULE_LICENSE("GPL v2");