aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Siverskog <jacob@teenage.engineering>2016-01-22 07:39:54 -0500
committerMark Brown <broonie@kernel.org>2016-01-28 18:36:21 -0500
commit70e3e56e6c3d499be47322037ed4a42314a8e509 (patch)
tree08a466c428c81e4e45f5c7263cf7ec742264e784
parent1b347b6891335a30131899dd16ec6ca843c578f0 (diff)
ASoC: pcm179x: Add I2C interface driver
The PCM179x family supports both SPI and I2C. This patch adds support for the I2C interface. Signed-off-by: Jacob Siverskog <jacob@teenage.engineering> Reviewed-by: Johan Hovold <johan@kernel.org> Acked-by: Michael Trimarchi <michael@amarulasolutions.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/sound/pcm179x.txt11
-rw-r--r--sound/soc/codecs/Kconfig9
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/pcm179x-i2c.c73
4 files changed, 94 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/sound/pcm179x.txt b/Documentation/devicetree/bindings/sound/pcm179x.txt
index 4ae70d3462d6..436c2b247693 100644
--- a/Documentation/devicetree/bindings/sound/pcm179x.txt
+++ b/Documentation/devicetree/bindings/sound/pcm179x.txt
@@ -1,6 +1,6 @@
1Texas Instruments pcm179x DT bindings 1Texas Instruments pcm179x DT bindings
2 2
3This driver supports the SPI bus. 3This driver supports both the I2C and SPI bus.
4 4
5Required properties: 5Required properties:
6 6
@@ -9,6 +9,11 @@ Required properties:
9For required properties on SPI, please consult 9For required properties on SPI, please consult
10Documentation/devicetree/bindings/spi/spi-bus.txt 10Documentation/devicetree/bindings/spi/spi-bus.txt
11 11
12Required properties on I2C:
13
14 - reg: the I2C address
15
16
12Examples: 17Examples:
13 18
14 codec_spi: 1792a@0 { 19 codec_spi: 1792a@0 {
@@ -16,3 +21,7 @@ Examples:
16 spi-max-frequency = <600000>; 21 spi-max-frequency = <600000>;
17 }; 22 };
18 23
24 codec_i2c: 1792a@4c {
25 compatible = "ti,pcm1792a";
26 reg = <0x4c>;
27 };
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index ae720f1b15e8..3a8fcf13200f 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -87,6 +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_I2C if I2C
90 select SND_SOC_PCM179X_SPI if SPI_MASTER 91 select SND_SOC_PCM179X_SPI if SPI_MASTER
91 select SND_SOC_PCM3008 92 select SND_SOC_PCM3008
92 select SND_SOC_PCM3168A_I2C if I2C 93 select SND_SOC_PCM3168A_I2C if I2C
@@ -529,6 +530,14 @@ config SND_SOC_PCM1681
529config SND_SOC_PCM179X 530config SND_SOC_PCM179X
530 tristate 531 tristate
531 532
533config SND_SOC_PCM179X_I2C
534 tristate "Texas Instruments PCM179X CODEC (I2C)"
535 depends on I2C
536 select SND_SOC_PCM179X
537 help
538 Enable support for Texas Instruments PCM179x CODEC.
539 Select this if your PCM179x is connected via an I2C bus.
540
532config SND_SOC_PCM179X_SPI 541config SND_SOC_PCM179X_SPI
533 tristate "Texas Instruments PCM179X CODEC (SPI)" 542 tristate "Texas Instruments PCM179X CODEC (SPI)"
534 depends on SPI_MASTER 543 depends on SPI_MASTER
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 56e94d88693f..9acd777a7a98 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-i2c-objs := pcm179x-i2c.o
84snd-soc-pcm179x-spi-objs := pcm179x-spi.o 85snd-soc-pcm179x-spi-objs := pcm179x-spi.o
85snd-soc-pcm3008-objs := pcm3008.o 86snd-soc-pcm3008-objs := pcm3008.o
86snd-soc-pcm3168a-objs := pcm3168a.o 87snd-soc-pcm3168a-objs := pcm3168a.o
@@ -286,6 +287,7 @@ obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o
286obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o 287obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o
287obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o 288obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o
288obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o 289obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o
290obj-$(CONFIG_SND_SOC_PCM179X_I2C) += snd-soc-pcm179x-i2c.o
289obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o 291obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o
290obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o 292obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o
291obj-$(CONFIG_SND_SOC_PCM3168A) += snd-soc-pcm3168a.o 293obj-$(CONFIG_SND_SOC_PCM3168A) += snd-soc-pcm3168a.o
diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c
new file mode 100644
index 000000000000..4118106abb8d
--- /dev/null
+++ b/sound/soc/codecs/pcm179x-i2c.c
@@ -0,0 +1,73 @@
1/*
2 * PCM179X ASoC I2C driver
3 *
4 * Copyright (c) Teenage Engineering AB 2016
5 *
6 * Jacob Siverskog <jacob@teenage.engineering>
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/i2c.h>
22#include <linux/regmap.h>
23
24#include "pcm179x.h"
25
26static int pcm179x_i2c_probe(struct i2c_client *client,
27 const struct i2c_device_id *id)
28{
29 struct regmap *regmap;
30 int ret;
31
32 regmap = devm_regmap_init_i2c(client, &pcm179x_regmap_config);
33 if (IS_ERR(regmap)) {
34 ret = PTR_ERR(regmap);
35 dev_err(&client->dev, "Failed to allocate regmap: %d\n", ret);
36 return ret;
37 }
38
39 return pcm179x_common_init(&client->dev, regmap);
40}
41
42static int pcm179x_i2c_remove(struct i2c_client *client)
43{
44 return pcm179x_common_exit(&client->dev);
45}
46
47static const struct of_device_id pcm179x_of_match[] = {
48 { .compatible = "ti,pcm1792a", },
49 { }
50};
51MODULE_DEVICE_TABLE(of, pcm179x_of_match);
52
53static const struct i2c_device_id pcm179x_i2c_ids[] = {
54 { "pcm179x", 0 },
55 { }
56};
57MODULE_DEVICE_TABLE(i2c, pcm179x_i2c_ids);
58
59static struct i2c_driver pcm179x_i2c_driver = {
60 .driver = {
61 .name = "pcm179x",
62 .of_match_table = of_match_ptr(pcm179x_of_match),
63 },
64 .id_table = pcm179x_i2c_ids,
65 .probe = pcm179x_i2c_probe,
66 .remove = pcm179x_i2c_remove,
67};
68
69module_i2c_driver(pcm179x_i2c_driver);
70
71MODULE_DESCRIPTION("ASoC PCM179X I2C driver");
72MODULE_AUTHOR("Jacob Siverskog <jacob@teenage.engineering>");
73MODULE_LICENSE("GPL");