xref: /linux/sound/soc/codecs/adau7002.c (revision e5c86679d5e864947a52fb31e45a425dea3e7fa9)
1 /*
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 
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 	.component_driver = {
43 		.dapm_widgets		= adau7002_widgets,
44 		.num_dapm_widgets	= ARRAY_SIZE(adau7002_widgets),
45 		.dapm_routes		= adau7002_routes,
46 		.num_dapm_routes	= ARRAY_SIZE(adau7002_routes),
47 	},
48 };
49 
50 static int adau7002_probe(struct platform_device *pdev)
51 {
52 	return snd_soc_register_codec(&pdev->dev, &adau7002_codec_driver,
53 			&adau7002_dai, 1);
54 }
55 
56 static int adau7002_remove(struct platform_device *pdev)
57 {
58 	snd_soc_unregister_codec(&pdev->dev);
59 	return 0;
60 }
61 
62 #ifdef CONFIG_OF
63 static const struct of_device_id adau7002_dt_ids[] = {
64 	{ .compatible = "adi,adau7002", },
65 	{ }
66 };
67 MODULE_DEVICE_TABLE(of, adau7002_dt_ids);
68 #endif
69 
70 static struct platform_driver adau7002_driver = {
71 	.driver = {
72 		.name = "adau7002",
73 		.of_match_table	= of_match_ptr(adau7002_dt_ids),
74 	},
75 	.probe = adau7002_probe,
76 	.remove = adau7002_remove,
77 };
78 module_platform_driver(adau7002_driver);
79 
80 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
81 MODULE_DESCRIPTION("ADAU7002 Stereo PDM-to-I2S/TDM Converter driver");
82 MODULE_LICENSE("GPL v2");
83