Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * ads117x.c  --  Driver for ads1174/8 ADC chips
0004  *
0005  * Copyright 2009 ShotSpotter Inc.
0006  * Author: Graeme Gregory <gg@slimlogic.co.uk>
0007  */
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/slab.h>
0011 #include <linux/init.h>
0012 #include <linux/device.h>
0013 #include <linux/module.h>
0014 #include <sound/core.h>
0015 #include <sound/pcm.h>
0016 #include <sound/initval.h>
0017 #include <sound/soc.h>
0018 
0019 #include <linux/of.h>
0020 
0021 #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
0022 #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
0023 
0024 static const struct snd_soc_dapm_widget ads117x_dapm_widgets[] = {
0025 SND_SOC_DAPM_INPUT("Input1"),
0026 SND_SOC_DAPM_INPUT("Input2"),
0027 SND_SOC_DAPM_INPUT("Input3"),
0028 SND_SOC_DAPM_INPUT("Input4"),
0029 SND_SOC_DAPM_INPUT("Input5"),
0030 SND_SOC_DAPM_INPUT("Input6"),
0031 SND_SOC_DAPM_INPUT("Input7"),
0032 SND_SOC_DAPM_INPUT("Input8"),
0033 };
0034 
0035 static const struct snd_soc_dapm_route ads117x_dapm_routes[] = {
0036     { "Capture", NULL, "Input1" },
0037     { "Capture", NULL, "Input2" },
0038     { "Capture", NULL, "Input3" },
0039     { "Capture", NULL, "Input4" },
0040     { "Capture", NULL, "Input5" },
0041     { "Capture", NULL, "Input6" },
0042     { "Capture", NULL, "Input7" },
0043     { "Capture", NULL, "Input8" },
0044 };
0045 
0046 static struct snd_soc_dai_driver ads117x_dai = {
0047 /* ADC */
0048     .name = "ads117x-hifi",
0049     .capture = {
0050         .stream_name = "Capture",
0051         .channels_min = 1,
0052         .channels_max = 32,
0053         .rates = ADS117X_RATES,
0054         .formats = ADS117X_FORMATS,},
0055 };
0056 
0057 static const struct snd_soc_component_driver soc_component_dev_ads117x = {
0058     .dapm_widgets       = ads117x_dapm_widgets,
0059     .num_dapm_widgets   = ARRAY_SIZE(ads117x_dapm_widgets),
0060     .dapm_routes        = ads117x_dapm_routes,
0061     .num_dapm_routes    = ARRAY_SIZE(ads117x_dapm_routes),
0062     .idle_bias_on       = 1,
0063     .use_pmdown_time    = 1,
0064     .endianness     = 1,
0065 };
0066 
0067 static int ads117x_probe(struct platform_device *pdev)
0068 {
0069     return devm_snd_soc_register_component(&pdev->dev,
0070             &soc_component_dev_ads117x, &ads117x_dai, 1);
0071 }
0072 
0073 #if defined(CONFIG_OF)
0074 static const struct of_device_id ads117x_dt_ids[] = {
0075     { .compatible = "ti,ads1174" },
0076     { .compatible = "ti,ads1178" },
0077     { },
0078 };
0079 MODULE_DEVICE_TABLE(of, ads117x_dt_ids);
0080 #endif
0081 
0082 static struct platform_driver ads117x_codec_driver = {
0083     .driver = {
0084             .name = "ads117x-codec",
0085             .of_match_table = of_match_ptr(ads117x_dt_ids),
0086     },
0087 
0088     .probe = ads117x_probe,
0089 };
0090 
0091 module_platform_driver(ads117x_codec_driver);
0092 
0093 MODULE_DESCRIPTION("ASoC ads117x driver");
0094 MODULE_AUTHOR("Graeme Gregory");
0095 MODULE_LICENSE("GPL");