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