diff options
-rw-r--r-- | sound/soc/codecs/Kconfig | 11 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/codecs/pcm179x-spi.c | 72 | ||||
-rw-r--r-- | sound/soc/codecs/pcm179x.c | 52 | ||||
-rw-r--r-- | sound/soc/codecs/pcm179x.h | 5 |
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 | ||
529 | config SND_SOC_PCM179X | 529 | config SND_SOC_PCM179X |
530 | tristate "Texas Instruments PCM179X CODEC" | 530 | tristate |
531 | |||
532 | config 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 | ||
533 | config SND_SOC_PCM3008 | 540 | config 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 | |||
81 | snd-soc-nau8825-objs := nau8825.o | 81 | snd-soc-nau8825-objs := nau8825.o |
82 | snd-soc-pcm1681-objs := pcm1681.o | 82 | snd-soc-pcm1681-objs := pcm1681.o |
83 | snd-soc-pcm179x-codec-objs := pcm179x.o | 83 | snd-soc-pcm179x-codec-objs := pcm179x.o |
84 | snd-soc-pcm179x-spi-objs := pcm179x-spi.o | ||
84 | snd-soc-pcm3008-objs := pcm3008.o | 85 | snd-soc-pcm3008-objs := pcm3008.o |
85 | snd-soc-pcm3168a-objs := pcm3168a.o | 86 | snd-soc-pcm3168a-objs := pcm3168a.o |
86 | snd-soc-pcm3168a-i2c-objs := pcm3168a-i2c.o | 87 | snd-soc-pcm3168a-i2c-objs := pcm3168a-i2c.o |
@@ -285,6 +286,7 @@ obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o | |||
285 | obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o | 286 | obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o |
286 | obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o | 287 | obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o |
287 | obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o | 288 | obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o |
289 | obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o | ||
288 | obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o | 290 | obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o |
289 | obj-$(CONFIG_SND_SOC_PCM3168A) += snd-soc-pcm3168a.o | 291 | obj-$(CONFIG_SND_SOC_PCM3168A) += snd-soc-pcm3168a.o |
290 | obj-$(CONFIG_SND_SOC_PCM3168A_I2C) += snd-soc-pcm3168a-i2c.o | 292 | obj-$(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 | |||
26 | static 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 | |||
41 | static int pcm179x_spi_remove(struct spi_device *spi) | ||
42 | { | ||
43 | return pcm179x_common_exit(&spi->dev); | ||
44 | } | ||
45 | |||
46 | static const struct of_device_id pcm179x_of_match[] = { | ||
47 | { .compatible = "ti,pcm1792a", }, | ||
48 | { } | ||
49 | }; | ||
50 | MODULE_DEVICE_TABLE(of, pcm179x_of_match); | ||
51 | |||
52 | static const struct spi_device_id pcm179x_spi_ids[] = { | ||
53 | { "pcm179x", 0 }, | ||
54 | { }, | ||
55 | }; | ||
56 | MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids); | ||
57 | |||
58 | static 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 | |||
68 | module_spi_driver(pcm179x_spi_driver); | ||
69 | |||
70 | MODULE_DESCRIPTION("ASoC PCM179X SPI driver"); | ||
71 | MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>"); | ||
72 | MODULE_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 | ||
197 | static const struct of_device_id pcm179x_of_match[] = { | 195 | const struct regmap_config pcm179x_regmap_config = { |
198 | { .compatible = "ti,pcm1792a", }, | ||
199 | { } | ||
200 | }; | ||
201 | MODULE_DEVICE_TABLE(of, pcm179x_of_match); | ||
202 | |||
203 | static 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 | }; |
204 | EXPORT_SYMBOL_GPL(pcm179x_regmap_config); | ||
212 | 205 | ||
213 | static struct snd_soc_codec_driver soc_codec_dev_pcm179x = { | 206 | static 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 | ||
222 | static int pcm179x_spi_probe(struct spi_device *spi) | 215 | int 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 | } |
230 | EXPORT_SYMBOL_GPL(pcm179x_common_init); | ||
244 | 231 | ||
245 | static int pcm179x_spi_remove(struct spi_device *spi) | 232 | int 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 | 237 | EXPORT_SYMBOL_GPL(pcm179x_common_exit); | |
251 | static const struct spi_device_id pcm179x_spi_ids[] = { | ||
252 | { "pcm179x", 0 }, | ||
253 | { }, | ||
254 | }; | ||
255 | MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids); | ||
256 | |||
257 | static 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 | |||
267 | module_spi_driver(pcm179x_codec_driver); | ||
268 | 238 | ||
269 | MODULE_DESCRIPTION("ASoC PCM179X driver"); | 239 | MODULE_DESCRIPTION("ASoC PCM179X driver"); |
270 | MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>"); | 240 | MODULE_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 | ||
27 | extern const struct regmap_config pcm179x_regmap_config; | ||
28 | |||
29 | int pcm179x_common_init(struct device *dev, struct regmap *regmap); | ||
30 | int pcm179x_common_exit(struct device *dev); | ||
31 | |||
27 | #endif | 32 | #endif |