aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/Kconfig11
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/pcm179x-spi.c72
-rw-r--r--sound/soc/codecs/pcm179x.c52
-rw-r--r--sound/soc/codecs/pcm179x.h5
5 files changed, 99 insertions, 43 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 50693c867e71..ae720f1b15e8 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -87,7 +87,7 @@ config SND_SOC_ALL_CODECS
87 select SND_SOC_ML26124 if I2C 87 select SND_SOC_ML26124 if I2C
88 select SND_SOC_NAU8825 if I2C 88 select SND_SOC_NAU8825 if I2C
89 select SND_SOC_PCM1681 if I2C 89 select SND_SOC_PCM1681 if I2C
90 select SND_SOC_PCM179X if SPI_MASTER 90 select SND_SOC_PCM179X_SPI if SPI_MASTER
91 select SND_SOC_PCM3008 91 select SND_SOC_PCM3008
92 select SND_SOC_PCM3168A_I2C if I2C 92 select SND_SOC_PCM3168A_I2C if I2C
93 select SND_SOC_PCM3168A_SPI if SPI_MASTER 93 select SND_SOC_PCM3168A_SPI if SPI_MASTER
@@ -527,8 +527,15 @@ config SND_SOC_PCM1681
527 depends on I2C 527 depends on I2C
528 528
529config SND_SOC_PCM179X 529config SND_SOC_PCM179X
530 tristate "Texas Instruments PCM179X CODEC" 530 tristate
531
532config SND_SOC_PCM179X_SPI
533 tristate "Texas Instruments PCM179X CODEC (SPI)"
531 depends on SPI_MASTER 534 depends on SPI_MASTER
535 select SND_SOC_PCM179X
536 help
537 Enable support for Texas Instruments PCM179x CODEC.
538 Select this if your PCM179x is connected via an SPI bus.
532 539
533config SND_SOC_PCM3008 540config SND_SOC_PCM3008
534 tristate 541 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index d44f7d347183..56e94d88693f 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -81,6 +81,7 @@ snd-soc-ml26124-objs := ml26124.o
81snd-soc-nau8825-objs := nau8825.o 81snd-soc-nau8825-objs := nau8825.o
82snd-soc-pcm1681-objs := pcm1681.o 82snd-soc-pcm1681-objs := pcm1681.o
83snd-soc-pcm179x-codec-objs := pcm179x.o 83snd-soc-pcm179x-codec-objs := pcm179x.o
84snd-soc-pcm179x-spi-objs := pcm179x-spi.o
84snd-soc-pcm3008-objs := pcm3008.o 85snd-soc-pcm3008-objs := pcm3008.o
85snd-soc-pcm3168a-objs := pcm3168a.o 86snd-soc-pcm3168a-objs := pcm3168a.o
86snd-soc-pcm3168a-i2c-objs := pcm3168a-i2c.o 87snd-soc-pcm3168a-i2c-objs := pcm3168a-i2c.o
@@ -285,6 +286,7 @@ obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o
285obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o 286obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o
286obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o 287obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o
287obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o 288obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o
289obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o
288obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o 290obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o
289obj-$(CONFIG_SND_SOC_PCM3168A) += snd-soc-pcm3168a.o 291obj-$(CONFIG_SND_SOC_PCM3168A) += snd-soc-pcm3168a.o
290obj-$(CONFIG_SND_SOC_PCM3168A_I2C) += snd-soc-pcm3168a-i2c.o 292obj-$(CONFIG_SND_SOC_PCM3168A_I2C) += snd-soc-pcm3168a-i2c.o
diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c
new file mode 100644
index 000000000000..da924d444083
--- /dev/null
+++ b/sound/soc/codecs/pcm179x-spi.c
@@ -0,0 +1,72 @@
1/*
2 * PCM179X ASoC SPI driver
3 *
4 * Copyright (c) Amarula Solutions B.V. 2013
5 *
6 * Michael Trimarchi <michael@amarulasolutions.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/module.h>
20#include <linux/of.h>
21#include <linux/spi/spi.h>
22#include <linux/regmap.h>
23
24#include "pcm179x.h"
25
26static int pcm179x_spi_probe(struct spi_device *spi)
27{
28 struct regmap *regmap;
29 int ret;
30
31 regmap = devm_regmap_init_spi(spi, &pcm179x_regmap_config);
32 if (IS_ERR(regmap)) {
33 ret = PTR_ERR(regmap);
34 dev_err(&spi->dev, "Failed to allocate regmap: %d\n", ret);
35 return ret;
36 }
37
38 return pcm179x_common_init(&spi->dev, regmap);
39}
40
41static int pcm179x_spi_remove(struct spi_device *spi)
42{
43 return pcm179x_common_exit(&spi->dev);
44}
45
46static const struct of_device_id pcm179x_of_match[] = {
47 { .compatible = "ti,pcm1792a", },
48 { }
49};
50MODULE_DEVICE_TABLE(of, pcm179x_of_match);
51
52static const struct spi_device_id pcm179x_spi_ids[] = {
53 { "pcm179x", 0 },
54 { },
55};
56MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids);
57
58static struct spi_driver pcm179x_spi_driver = {
59 .driver = {
60 .name = "pcm179x",
61 .of_match_table = of_match_ptr(pcm179x_of_match),
62 },
63 .id_table = pcm179x_spi_ids,
64 .probe = pcm179x_spi_probe,
65 .remove = pcm179x_spi_remove,
66};
67
68module_spi_driver(pcm179x_spi_driver);
69
70MODULE_DESCRIPTION("ASoC PCM179X SPI driver");
71MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>");
72MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c
index a56c7b767d90..8f20f70af23e 100644
--- a/sound/soc/codecs/pcm179x.c
+++ b/sound/soc/codecs/pcm179x.c
@@ -20,7 +20,6 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/spi/spi.h>
24 23
25#include <sound/core.h> 24#include <sound/core.h>
26#include <sound/pcm.h> 25#include <sound/pcm.h>
@@ -29,7 +28,6 @@
29#include <sound/soc.h> 28#include <sound/soc.h>
30#include <sound/tlv.h> 29#include <sound/tlv.h>
31#include <linux/of.h> 30#include <linux/of.h>
32#include <linux/of_device.h>
33 31
34#include "pcm179x.h" 32#include "pcm179x.h"
35 33
@@ -194,13 +192,7 @@ static struct snd_soc_dai_driver pcm179x_dai = {
194 .ops = &pcm179x_dai_ops, 192 .ops = &pcm179x_dai_ops,
195}; 193};
196 194
197static const struct of_device_id pcm179x_of_match[] = { 195const struct regmap_config pcm179x_regmap_config = {
198 { .compatible = "ti,pcm1792a", },
199 { }
200};
201MODULE_DEVICE_TABLE(of, pcm179x_of_match);
202
203static const struct regmap_config pcm179x_regmap = {
204 .reg_bits = 8, 196 .reg_bits = 8,
205 .val_bits = 8, 197 .val_bits = 8,
206 .max_register = 23, 198 .max_register = 23,
@@ -209,6 +201,7 @@ static const struct regmap_config pcm179x_regmap = {
209 .writeable_reg = pcm179x_writeable_reg, 201 .writeable_reg = pcm179x_writeable_reg,
210 .readable_reg = pcm179x_accessible_reg, 202 .readable_reg = pcm179x_accessible_reg,
211}; 203};
204EXPORT_SYMBOL_GPL(pcm179x_regmap_config);
212 205
213static struct snd_soc_codec_driver soc_codec_dev_pcm179x = { 206static struct snd_soc_codec_driver soc_codec_dev_pcm179x = {
214 .controls = pcm179x_controls, 207 .controls = pcm179x_controls,
@@ -219,52 +212,29 @@ static struct snd_soc_codec_driver soc_codec_dev_pcm179x = {
219 .num_dapm_routes = ARRAY_SIZE(pcm179x_dapm_routes), 212 .num_dapm_routes = ARRAY_SIZE(pcm179x_dapm_routes),
220}; 213};
221 214
222static int pcm179x_spi_probe(struct spi_device *spi) 215int pcm179x_common_init(struct device *dev, struct regmap *regmap)
223{ 216{
224 struct pcm179x_private *pcm179x; 217 struct pcm179x_private *pcm179x;
225 int ret;
226 218
227 pcm179x = devm_kzalloc(&spi->dev, sizeof(struct pcm179x_private), 219 pcm179x = devm_kzalloc(dev, sizeof(struct pcm179x_private),
228 GFP_KERNEL); 220 GFP_KERNEL);
229 if (!pcm179x) 221 if (!pcm179x)
230 return -ENOMEM; 222 return -ENOMEM;
231 223
232 spi_set_drvdata(spi, pcm179x); 224 pcm179x->regmap = regmap;
233 225 dev_set_drvdata(dev, pcm179x);
234 pcm179x->regmap = devm_regmap_init_spi(spi, &pcm179x_regmap);
235 if (IS_ERR(pcm179x->regmap)) {
236 ret = PTR_ERR(pcm179x->regmap);
237 dev_err(&spi->dev, "Failed to register regmap: %d\n", ret);
238 return ret;
239 }
240 226
241 return snd_soc_register_codec(&spi->dev, 227 return snd_soc_register_codec(dev,
242 &soc_codec_dev_pcm179x, &pcm179x_dai, 1); 228 &soc_codec_dev_pcm179x, &pcm179x_dai, 1);
243} 229}
230EXPORT_SYMBOL_GPL(pcm179x_common_init);
244 231
245static int pcm179x_spi_remove(struct spi_device *spi) 232int pcm179x_common_exit(struct device *dev)
246{ 233{
247 snd_soc_unregister_codec(&spi->dev); 234 snd_soc_unregister_codec(dev);
248 return 0; 235 return 0;
249} 236}
250 237EXPORT_SYMBOL_GPL(pcm179x_common_exit);
251static const struct spi_device_id pcm179x_spi_ids[] = {
252 { "pcm179x", 0 },
253 { },
254};
255MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids);
256
257static struct spi_driver pcm179x_codec_driver = {
258 .driver = {
259 .name = "pcm179x",
260 .of_match_table = of_match_ptr(pcm179x_of_match),
261 },
262 .id_table = pcm179x_spi_ids,
263 .probe = pcm179x_spi_probe,
264 .remove = pcm179x_spi_remove,
265};
266
267module_spi_driver(pcm179x_codec_driver);
268 238
269MODULE_DESCRIPTION("ASoC PCM179X driver"); 239MODULE_DESCRIPTION("ASoC PCM179X driver");
270MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>"); 240MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>");
diff --git a/sound/soc/codecs/pcm179x.h b/sound/soc/codecs/pcm179x.h
index c6fdc062a497..c4eea4df915b 100644
--- a/sound/soc/codecs/pcm179x.h
+++ b/sound/soc/codecs/pcm179x.h
@@ -24,4 +24,9 @@
24#define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ 24#define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \
25 SNDRV_PCM_FMTBIT_S16_LE) 25 SNDRV_PCM_FMTBIT_S16_LE)
26 26
27extern const struct regmap_config pcm179x_regmap_config;
28
29int pcm179x_common_init(struct device *dev, struct regmap *regmap);
30int pcm179x_common_exit(struct device *dev);
31
27#endif 32#endif