hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/sound/soc/codecs/adau7002.c
....@@ -1,13 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ADAU7002 Stereo PDM-to-I2S/TDM converter driver
34 *
45 * Copyright 2014-2016 Analog Devices
56 * Author: Lars-Peter Clausen <lars@metafoo.de>
6
- *
7
- * Licensed under the GPL-2.
87 */
98
109 #include <linux/acpi.h>
10
+#include <linux/delay.h>
1111 #include <linux/init.h>
1212 #include <linux/module.h>
1313 #include <linux/of.h>
....@@ -15,12 +15,55 @@
1515
1616 #include <sound/soc.h>
1717
18
+struct adau7002_priv {
19
+ int wakeup_delay;
20
+};
21
+
22
+static int adau7002_aif_event(struct snd_soc_dapm_widget *w,
23
+ struct snd_kcontrol *kcontrol, int event)
24
+{
25
+ struct snd_soc_component *component =
26
+ snd_soc_dapm_to_component(w->dapm);
27
+ struct adau7002_priv *adau7002 =
28
+ snd_soc_component_get_drvdata(component);
29
+
30
+ switch (event) {
31
+ case SND_SOC_DAPM_POST_PMU:
32
+ if (adau7002->wakeup_delay)
33
+ msleep(adau7002->wakeup_delay);
34
+ break;
35
+ }
36
+
37
+ return 0;
38
+}
39
+
40
+static int adau7002_component_probe(struct snd_soc_component *component)
41
+{
42
+ struct adau7002_priv *adau7002;
43
+
44
+ adau7002 = devm_kzalloc(component->dev, sizeof(*adau7002),
45
+ GFP_KERNEL);
46
+ if (!adau7002)
47
+ return -ENOMEM;
48
+
49
+ device_property_read_u32(component->dev, "wakeup-delay-ms",
50
+ &adau7002->wakeup_delay);
51
+
52
+ snd_soc_component_set_drvdata(component, adau7002);
53
+
54
+ return 0;
55
+}
56
+
1857 static const struct snd_soc_dapm_widget adau7002_widgets[] = {
58
+ SND_SOC_DAPM_AIF_OUT_E("ADAU AIF", "Capture", 0,
59
+ SND_SOC_NOPM, 0, 0, adau7002_aif_event,
60
+ SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
1961 SND_SOC_DAPM_INPUT("PDM_DAT"),
2062 SND_SOC_DAPM_REGULATOR_SUPPLY("IOVDD", 0, 0),
2163 };
2264
2365 static const struct snd_soc_dapm_route adau7002_routes[] = {
66
+ { "ADAU AIF", NULL, "PDM_DAT"},
2467 { "Capture", NULL, "PDM_DAT" },
2568 { "Capture", NULL, "IOVDD" },
2669 };
....@@ -40,6 +83,7 @@
4083 };
4184
4285 static const struct snd_soc_component_driver adau7002_component_driver = {
86
+ .probe = adau7002_component_probe,
4387 .dapm_widgets = adau7002_widgets,
4488 .num_dapm_widgets = ARRAY_SIZE(adau7002_widgets),
4589 .dapm_routes = adau7002_routes,