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