Linux Audio

Check our new training course

Embedded Linux training

Mar 10-20, 2025, special US time zones
Register
Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 * ads117x.c  --  Driver for ads1174/8 ADC chips
 4 *
 5 * Copyright 2009 ShotSpotter Inc.
 6 * Author: Graeme Gregory <gg@slimlogic.co.uk>
 
 
 
 
 
 7 */
 8
 9#include <linux/kernel.h>
10#include <linux/slab.h>
11#include <linux/init.h>
12#include <linux/device.h>
13#include <linux/module.h>
14#include <sound/core.h>
15#include <sound/pcm.h>
16#include <sound/initval.h>
17#include <sound/soc.h>
18
19#include <linux/of.h>
20
21#define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
22#define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
23
24static const struct snd_soc_dapm_widget ads117x_dapm_widgets[] = {
25SND_SOC_DAPM_INPUT("Input1"),
26SND_SOC_DAPM_INPUT("Input2"),
27SND_SOC_DAPM_INPUT("Input3"),
28SND_SOC_DAPM_INPUT("Input4"),
29SND_SOC_DAPM_INPUT("Input5"),
30SND_SOC_DAPM_INPUT("Input6"),
31SND_SOC_DAPM_INPUT("Input7"),
32SND_SOC_DAPM_INPUT("Input8"),
33};
34
35static 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
46static struct snd_soc_dai_driver ads117x_dai = {
47/* ADC */
48	.name = "ads117x-hifi",
49	.capture = {
50		.stream_name = "Capture",
51		.channels_min = 1,
52		.channels_max = 32,
53		.rates = ADS117X_RATES,
54		.formats = ADS117X_FORMATS,},
55};
56
57static 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};
66
67static int ads117x_probe(struct platform_device *pdev)
68{
69	return devm_snd_soc_register_component(&pdev->dev,
70			&soc_component_dev_ads117x, &ads117x_dai, 1);
 
 
 
 
 
 
71}
72
73#if defined(CONFIG_OF)
74static const struct of_device_id ads117x_dt_ids[] = {
75	{ .compatible = "ti,ads1174" },
76	{ .compatible = "ti,ads1178" },
77	{ },
78};
79MODULE_DEVICE_TABLE(of, ads117x_dt_ids);
80#endif
81
82static struct platform_driver ads117x_codec_driver = {
83	.driver = {
84			.name = "ads117x-codec",
85			.of_match_table = of_match_ptr(ads117x_dt_ids),
86	},
87
88	.probe = ads117x_probe,
 
89};
90
91module_platform_driver(ads117x_codec_driver);
92
93MODULE_DESCRIPTION("ASoC ads117x driver");
94MODULE_AUTHOR("Graeme Gregory");
95MODULE_LICENSE("GPL");
v4.10.11
 
  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>
 14#include <linux/slab.h>
 15#include <linux/init.h>
 16#include <linux/device.h>
 17#include <linux/module.h>
 18#include <sound/core.h>
 19#include <sound/pcm.h>
 20#include <sound/initval.h>
 21#include <sound/soc.h>
 22
 23#include <linux/of.h>
 24
 25#define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
 26#define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
 27
 28static const struct snd_soc_dapm_widget ads117x_dapm_widgets[] = {
 29SND_SOC_DAPM_INPUT("Input1"),
 30SND_SOC_DAPM_INPUT("Input2"),
 31SND_SOC_DAPM_INPUT("Input3"),
 32SND_SOC_DAPM_INPUT("Input4"),
 33SND_SOC_DAPM_INPUT("Input5"),
 34SND_SOC_DAPM_INPUT("Input6"),
 35SND_SOC_DAPM_INPUT("Input7"),
 36SND_SOC_DAPM_INPUT("Input8"),
 37};
 38
 39static 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
 50static struct snd_soc_dai_driver ads117x_dai = {
 51/* ADC */
 52	.name = "ads117x-hifi",
 53	.capture = {
 54		.stream_name = "Capture",
 55		.channels_min = 1,
 56		.channels_max = 32,
 57		.rates = ADS117X_RATES,
 58		.formats = ADS117X_FORMATS,},
 59};
 60
 61static struct snd_soc_codec_driver soc_codec_dev_ads117x = {
 62	.component_driver = {
 63		.dapm_widgets		= ads117x_dapm_widgets,
 64		.num_dapm_widgets	= ARRAY_SIZE(ads117x_dapm_widgets),
 65		.dapm_routes		= ads117x_dapm_routes,
 66		.num_dapm_routes	= ARRAY_SIZE(ads117x_dapm_routes),
 67	},
 
 68};
 69
 70static int ads117x_probe(struct platform_device *pdev)
 71{
 72	return snd_soc_register_codec(&pdev->dev,
 73			&soc_codec_dev_ads117x, &ads117x_dai, 1);
 74}
 75
 76static int ads117x_remove(struct platform_device *pdev)
 77{
 78	snd_soc_unregister_codec(&pdev->dev);
 79	return 0;
 80}
 81
 82#if defined(CONFIG_OF)
 83static const struct of_device_id ads117x_dt_ids[] = {
 84	{ .compatible = "ti,ads1174" },
 85	{ .compatible = "ti,ads1178" },
 86	{ },
 87};
 88MODULE_DEVICE_TABLE(of, ads117x_dt_ids);
 89#endif
 90
 91static struct platform_driver ads117x_codec_driver = {
 92	.driver = {
 93			.name = "ads117x-codec",
 94			.of_match_table = of_match_ptr(ads117x_dt_ids),
 95	},
 96
 97	.probe = ads117x_probe,
 98	.remove = ads117x_remove,
 99};
100
101module_platform_driver(ads117x_codec_driver);
102
103MODULE_DESCRIPTION("ASoC ads117x driver");
104MODULE_AUTHOR("Graeme Gregory");
105MODULE_LICENSE("GPL");