aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorGraeme Gregory <gg@slimlogic.co.uk>2009-11-04 12:49:22 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-11-04 16:27:53 -0500
commit2dcf9fb99d4ecadecb2685a9eb82e6b85511c960 (patch)
tree45a7438819475ebbe3c781c520382dbd567ae113 /sound/soc
parent529697c5463d941445db18e9526e7fc76a18e503 (diff)
ASoC: ADS117x ADC driver
This patch adds support for the TI ADS117x family of multichannel ADCs and was sponsored by Shotspotter Inc. Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/ads117x.c127
-rw-r--r--sound/soc/codecs/ads117x.h13
4 files changed, 146 insertions, 0 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 4a3e8dcf24d9..52b005f8fed4 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -15,6 +15,7 @@ config SND_SOC_ALL_CODECS
15 select SND_SOC_AD1836 if SPI_MASTER 15 select SND_SOC_AD1836 if SPI_MASTER
16 select SND_SOC_AD1938 if SPI_MASTER 16 select SND_SOC_AD1938 if SPI_MASTER
17 select SND_SOC_AD1980 if SND_SOC_AC97_BUS 17 select SND_SOC_AD1980 if SND_SOC_AC97_BUS
18 select SND_SOC_ADS117X
18 select SND_SOC_AD73311 if I2C 19 select SND_SOC_AD73311 if I2C
19 select SND_SOC_AK4104 if SPI_MASTER 20 select SND_SOC_AK4104 if SPI_MASTER
20 select SND_SOC_AK4535 if I2C 21 select SND_SOC_AK4535 if I2C
@@ -91,6 +92,9 @@ config SND_SOC_AD1980
91 92
92config SND_SOC_AD73311 93config SND_SOC_AD73311
93 tristate 94 tristate
95
96config SND_SOC_ADS117X
97 tristate
94 98
95config SND_SOC_AK4104 99config SND_SOC_AK4104
96 tristate 100 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index cacfc7692d7f..dbaecb133ac7 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -3,6 +3,7 @@ snd-soc-ad1836-objs := ad1836.o
3snd-soc-ad1938-objs := ad1938.o 3snd-soc-ad1938-objs := ad1938.o
4snd-soc-ad1980-objs := ad1980.o 4snd-soc-ad1980-objs := ad1980.o
5snd-soc-ad73311-objs := ad73311.o 5snd-soc-ad73311-objs := ad73311.o
6snd-soc-ads117x-objs := ads117x.o
6snd-soc-ak4104-objs := ak4104.o 7snd-soc-ak4104-objs := ak4104.o
7snd-soc-ak4535-objs := ak4535.o 8snd-soc-ak4535-objs := ak4535.o
8snd-soc-ak4642-objs := ak4642.o 9snd-soc-ak4642-objs := ak4642.o
@@ -58,6 +59,7 @@ obj-$(CONFIG_SND_SOC_AD1836) += snd-soc-ad1836.o
58obj-$(CONFIG_SND_SOC_AD1938) += snd-soc-ad1938.o 59obj-$(CONFIG_SND_SOC_AD1938) += snd-soc-ad1938.o
59obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o 60obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o
60obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o 61obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o
62obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o
61obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o 63obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o
62obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o 64obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o
63obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o 65obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o
diff --git a/sound/soc/codecs/ads117x.c b/sound/soc/codecs/ads117x.c
new file mode 100644
index 000000000000..f3230927dc66
--- /dev/null
+++ b/sound/soc/codecs/ads117x.c
@@ -0,0 +1,127 @@
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/init.h>
15#include <linux/device.h>
16#include <sound/core.h>
17#include <sound/pcm.h>
18#include <sound/initval.h>
19#include <sound/soc.h>
20
21#include "ads117x.h"
22
23#define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
24
25#define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
26
27struct snd_soc_dai ads117x_dai = {
28/* ADC */
29 .name = "ADS117X ADC",
30 .id = 1,
31 .capture = {
32 .stream_name = "Capture",
33 .channels_min = 1,
34 .channels_max = 32,
35 .rates = ADS117X_RATES,
36 .formats = ADS117X_FORMATS,},
37};
38EXPORT_SYMBOL_GPL(ads117x_dai);
39
40/*
41 * initialise the ads117x driver
42 */
43static int ads117x_init(struct snd_soc_device *socdev)
44{
45 struct snd_soc_codec *codec = socdev->card->codec;
46 int ret = 0;
47
48 codec->name = "ADS117X";
49 codec->owner = THIS_MODULE;
50 codec->dai = &ads117x_dai;
51 codec->num_dai = 1;
52
53 /* register pcms */
54 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
55 if (ret < 0) {
56 printk(KERN_ERR "ads117x: failed to create pcms\n");
57 return ret;
58 }
59
60 ret = snd_soc_init_card(socdev);
61 if (ret < 0) {
62 printk(KERN_ERR "ads117x: failed to register card\n");
63 goto card_err;
64 }
65 return ret;
66
67card_err:
68 snd_soc_free_pcms(socdev);
69 return ret;
70}
71
72static int ads117x_probe(struct platform_device *pdev)
73{
74 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
75 struct snd_soc_codec *codec;
76 int ret;
77
78 pr_info("ads117x ADC\n");
79
80 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
81 if (codec == NULL)
82 return -ENOMEM;
83
84 socdev->card->codec = codec;
85 mutex_init(&codec->mutex);
86 INIT_LIST_HEAD(&codec->dapm_widgets);
87 INIT_LIST_HEAD(&codec->dapm_paths);
88
89 ret = ads117x_init(socdev);
90 if (ret != 0)
91 kfree(codec);
92
93 return ret;
94}
95
96static int ads117x_remove(struct platform_device *pdev)
97{
98 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
99 struct snd_soc_codec *codec = socdev->card->codec;
100
101 snd_soc_free_pcms(socdev);
102 kfree(codec);
103
104 return 0;
105}
106
107struct snd_soc_codec_device soc_codec_dev_ads117x = {
108 .probe = ads117x_probe,
109 .remove = ads117x_remove,
110};
111EXPORT_SYMBOL_GPL(soc_codec_dev_ads117x);
112
113static int __init ads117x_modinit(void)
114{
115 return snd_soc_register_dai(&ads117x_dai);
116}
117module_init(ads117x_modinit);
118
119static void __exit ads117x_exit(void)
120{
121 snd_soc_unregister_dai(&ads117x_dai);
122}
123module_exit(ads117x_exit);
124
125MODULE_DESCRIPTION("ASoC ads117x driver");
126MODULE_AUTHOR("Graeme Gregory");
127MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/ads117x.h b/sound/soc/codecs/ads117x.h
new file mode 100644
index 000000000000..dbcf50ec9bd1
--- /dev/null
+++ b/sound/soc/codecs/ads117x.h
@@ -0,0 +1,13 @@
1/*
2 * ads117x.h -- 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 */
12extern struct snd_soc_dai ads117x_dai;
13extern struct snd_soc_codec_device soc_codec_dev_ads117x;