2 * sound/soc/codecs/wm8782.c
3 * simple, strap-pin configured 24bit 2ch ADC
5 * Copyright: 2011 Raumfeld GmbH
6 * Author: Johannes Stezenbach <js@sig21.net>
9 * Copyright: Analog Device Inc.
10 * Author: Cliff Cai <cliff.cai@analog.com>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
18 #include <linux/init.h>
19 #include <linux/slab.h>
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/device.h>
23 #include <linux/regulator/consumer.h>
24 #include <sound/core.h>
25 #include <sound/pcm.h>
26 #include <sound/ac97_codec.h>
27 #include <sound/initval.h>
28 #include <sound/soc.h>
30 static const struct snd_soc_dapm_widget wm8782_dapm_widgets[] = {
31 SND_SOC_DAPM_INPUT("AINL"),
32 SND_SOC_DAPM_INPUT("AINR"),
35 static const struct snd_soc_dapm_route wm8782_dapm_routes[] = {
36 { "Capture", NULL, "AINL" },
37 { "Capture", NULL, "AINR" },
40 static struct snd_soc_dai_driver wm8782_dai = {
43 .stream_name = "Capture",
46 /* For configurations with FSAMPEN=0 */
47 .rates = SNDRV_PCM_RATE_8000_48000,
48 .formats = SNDRV_PCM_FMTBIT_S16_LE |
49 SNDRV_PCM_FMTBIT_S20_3LE |
50 SNDRV_PCM_FMTBIT_S24_LE,
54 /* regulator power supply names */
55 static const char *supply_names[] = {
56 "Vdda", /* analog supply, 2.7V - 3.6V */
57 "Vdd", /* digital supply, 2.7V - 5.5V */
61 struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
64 static int wm8782_soc_probe(struct snd_soc_component *component)
66 struct wm8782_priv *priv = snd_soc_component_get_drvdata(component);
67 return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
70 static void wm8782_soc_remove(struct snd_soc_component *component)
72 struct wm8782_priv *priv = snd_soc_component_get_drvdata(component);
73 regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
77 static int wm8782_soc_suspend(struct snd_soc_component *component)
79 struct wm8782_priv *priv = snd_soc_component_get_drvdata(component);
80 regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
84 static int wm8782_soc_resume(struct snd_soc_component *component)
86 struct wm8782_priv *priv = snd_soc_component_get_drvdata(component);
87 return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
90 #define wm8782_soc_suspend NULL
91 #define wm8782_soc_resume NULL
92 #endif /* CONFIG_PM */
94 static const struct snd_soc_component_driver soc_component_dev_wm8782 = {
95 .probe = wm8782_soc_probe,
96 .remove = wm8782_soc_remove,
97 .suspend = wm8782_soc_suspend,
98 .resume = wm8782_soc_resume,
99 .dapm_widgets = wm8782_dapm_widgets,
100 .num_dapm_widgets = ARRAY_SIZE(wm8782_dapm_widgets),
101 .dapm_routes = wm8782_dapm_routes,
102 .num_dapm_routes = ARRAY_SIZE(wm8782_dapm_routes),
104 .use_pmdown_time = 1,
106 .non_legacy_dai_naming = 1,
109 static int wm8782_probe(struct platform_device *pdev)
111 struct device *dev = &pdev->dev;
112 struct wm8782_priv *priv;
115 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
119 dev_set_drvdata(dev, priv);
121 for (i = 0; i < ARRAY_SIZE(supply_names); i++)
122 priv->supplies[i].supply = supply_names[i];
124 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(priv->supplies),
129 return devm_snd_soc_register_component(&pdev->dev,
130 &soc_component_dev_wm8782, &wm8782_dai, 1);
134 static const struct of_device_id wm8782_of_match[] = {
135 { .compatible = "wlf,wm8782", },
138 MODULE_DEVICE_TABLE(of, wm8782_of_match);
141 static struct platform_driver wm8782_codec_driver = {
144 .of_match_table = of_match_ptr(wm8782_of_match),
146 .probe = wm8782_probe,
149 module_platform_driver(wm8782_codec_driver);
151 MODULE_DESCRIPTION("ASoC WM8782 driver");
152 MODULE_AUTHOR("Johannes Stezenbach <js@sig21.net>");
153 MODULE_LICENSE("GPL");