]>
Commit | Line | Data |
---|---|---|
2874c5fd | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2dcf9fb9 GG |
2 | /* |
3 | * ads117x.c -- Driver for ads1174/8 ADC chips | |
4 | * | |
5 | * Copyright 2009 ShotSpotter Inc. | |
6 | * Author: Graeme Gregory <gg@slimlogic.co.uk> | |
2dcf9fb9 GG |
7 | */ |
8 | ||
9 | #include <linux/kernel.h> | |
5a0e3ad6 | 10 | #include <linux/slab.h> |
2dcf9fb9 GG |
11 | #include <linux/init.h> |
12 | #include <linux/device.h> | |
da155d5b | 13 | #include <linux/module.h> |
2dcf9fb9 GG |
14 | #include <sound/core.h> |
15 | #include <sound/pcm.h> | |
16 | #include <sound/initval.h> | |
17 | #include <sound/soc.h> | |
18 | ||
4f2bf0ac FV |
19 | #include <linux/of.h> |
20 | ||
2dcf9fb9 | 21 | #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000) |
2dcf9fb9 GG |
22 | #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) |
23 | ||
45a14a8b MB |
24 | static const struct snd_soc_dapm_widget ads117x_dapm_widgets[] = { |
25 | SND_SOC_DAPM_INPUT("Input1"), | |
26 | SND_SOC_DAPM_INPUT("Input2"), | |
27 | SND_SOC_DAPM_INPUT("Input3"), | |
28 | SND_SOC_DAPM_INPUT("Input4"), | |
29 | SND_SOC_DAPM_INPUT("Input5"), | |
30 | SND_SOC_DAPM_INPUT("Input6"), | |
31 | SND_SOC_DAPM_INPUT("Input7"), | |
32 | SND_SOC_DAPM_INPUT("Input8"), | |
33 | }; | |
34 | ||
35 | static const struct snd_soc_dapm_route ads117x_dapm_routes[] = { | |
36 | { "Capture", NULL, "Input1" }, | |
37 | { "Capture", NULL, "Input2" }, | |
38 | { "Capture", NULL, "Input3" }, | |
39 | { "Capture", NULL, "Input4" }, | |
40 | { "Capture", NULL, "Input5" }, | |
41 | { "Capture", NULL, "Input6" }, | |
42 | { "Capture", NULL, "Input7" }, | |
43 | { "Capture", NULL, "Input8" }, | |
44 | }; | |
45 | ||
f0fba2ad | 46 | static struct snd_soc_dai_driver ads117x_dai = { |
2dcf9fb9 | 47 | /* ADC */ |
f0fba2ad | 48 | .name = "ads117x-hifi", |
2dcf9fb9 GG |
49 | .capture = { |
50 | .stream_name = "Capture", | |
51 | .channels_min = 1, | |
52 | .channels_max = 32, | |
53 | .rates = ADS117X_RATES, | |
54 | .formats = ADS117X_FORMATS,}, | |
55 | }; | |
2dcf9fb9 | 56 | |
93101617 KM |
57 | static const struct snd_soc_component_driver soc_component_dev_ads117x = { |
58 | .dapm_widgets = ads117x_dapm_widgets, | |
59 | .num_dapm_widgets = ARRAY_SIZE(ads117x_dapm_widgets), | |
60 | .dapm_routes = ads117x_dapm_routes, | |
61 | .num_dapm_routes = ARRAY_SIZE(ads117x_dapm_routes), | |
62 | .idle_bias_on = 1, | |
63 | .use_pmdown_time = 1, | |
64 | .endianness = 1, | |
65 | .non_legacy_dai_naming = 1, | |
45a14a8b | 66 | }; |
2dcf9fb9 | 67 | |
7a79e94e | 68 | static int ads117x_probe(struct platform_device *pdev) |
2dcf9fb9 | 69 | { |
93101617 KM |
70 | return devm_snd_soc_register_component(&pdev->dev, |
71 | &soc_component_dev_ads117x, &ads117x_dai, 1); | |
f3d0e82f MB |
72 | } |
73 | ||
4f2bf0ac FV |
74 | #if defined(CONFIG_OF) |
75 | static const struct of_device_id ads117x_dt_ids[] = { | |
76 | { .compatible = "ti,ads1174" }, | |
77 | { .compatible = "ti,ads1178" }, | |
78 | { }, | |
79 | }; | |
80 | MODULE_DEVICE_TABLE(of, ads117x_dt_ids); | |
81 | #endif | |
82 | ||
f3d0e82f MB |
83 | static struct platform_driver ads117x_codec_driver = { |
84 | .driver = { | |
f0fba2ad | 85 | .name = "ads117x-codec", |
4f2bf0ac | 86 | .of_match_table = of_match_ptr(ads117x_dt_ids), |
f3d0e82f MB |
87 | }, |
88 | ||
f0fba2ad | 89 | .probe = ads117x_probe, |
f3d0e82f MB |
90 | }; |
91 | ||
5bbcc3c0 | 92 | module_platform_driver(ads117x_codec_driver); |
2dcf9fb9 GG |
93 | |
94 | MODULE_DESCRIPTION("ASoC ads117x driver"); | |
95 | MODULE_AUTHOR("Graeme Gregory"); | |
96 | MODULE_LICENSE("GPL"); |