diff options
author | Jacob Siverskog <jacob@teenage.engineering> | 2016-01-22 07:39:54 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-01-28 18:36:21 -0500 |
commit | 70e3e56e6c3d499be47322037ed4a42314a8e509 (patch) | |
tree | 08a466c428c81e4e45f5c7263cf7ec742264e784 | |
parent | 1b347b6891335a30131899dd16ec6ca843c578f0 (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.txt | 11 | ||||
-rw-r--r-- | sound/soc/codecs/Kconfig | 9 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/codecs/pcm179x-i2c.c | 73 |
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 @@ | |||
1 | Texas Instruments pcm179x DT bindings | 1 | Texas Instruments pcm179x DT bindings |
2 | 2 | ||
3 | This driver supports the SPI bus. | 3 | This driver supports both the I2C and SPI bus. |
4 | 4 | ||
5 | Required properties: | 5 | Required properties: |
6 | 6 | ||
@@ -9,6 +9,11 @@ Required properties: | |||
9 | For required properties on SPI, please consult | 9 | For required properties on SPI, please consult |
10 | Documentation/devicetree/bindings/spi/spi-bus.txt | 10 | Documentation/devicetree/bindings/spi/spi-bus.txt |
11 | 11 | ||
12 | Required properties on I2C: | ||
13 | |||
14 | - reg: the I2C address | ||
15 | |||
16 | |||
12 | Examples: | 17 | Examples: |
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 | |||
529 | config SND_SOC_PCM179X | 530 | config SND_SOC_PCM179X |
530 | tristate | 531 | tristate |
531 | 532 | ||
533 | config 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 | |||
532 | config SND_SOC_PCM179X_SPI | 541 | config 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 | |||
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-i2c-objs := pcm179x-i2c.o | ||
84 | snd-soc-pcm179x-spi-objs := pcm179x-spi.o | 85 | snd-soc-pcm179x-spi-objs := pcm179x-spi.o |
85 | snd-soc-pcm3008-objs := pcm3008.o | 86 | snd-soc-pcm3008-objs := pcm3008.o |
86 | snd-soc-pcm3168a-objs := pcm3168a.o | 87 | snd-soc-pcm3168a-objs := pcm3168a.o |
@@ -286,6 +287,7 @@ obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o | |||
286 | obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o | 287 | obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o |
287 | obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o | 288 | obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o |
288 | obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o | 289 | obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o |
290 | obj-$(CONFIG_SND_SOC_PCM179X_I2C) += snd-soc-pcm179x-i2c.o | ||
289 | obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o | 291 | obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o |
290 | obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o | 292 | obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o |
291 | obj-$(CONFIG_SND_SOC_PCM3168A) += snd-soc-pcm3168a.o | 293 | obj-$(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 | |||
26 | static 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 | |||
42 | static int pcm179x_i2c_remove(struct i2c_client *client) | ||
43 | { | ||
44 | return pcm179x_common_exit(&client->dev); | ||
45 | } | ||
46 | |||
47 | static const struct of_device_id pcm179x_of_match[] = { | ||
48 | { .compatible = "ti,pcm1792a", }, | ||
49 | { } | ||
50 | }; | ||
51 | MODULE_DEVICE_TABLE(of, pcm179x_of_match); | ||
52 | |||
53 | static const struct i2c_device_id pcm179x_i2c_ids[] = { | ||
54 | { "pcm179x", 0 }, | ||
55 | { } | ||
56 | }; | ||
57 | MODULE_DEVICE_TABLE(i2c, pcm179x_i2c_ids); | ||
58 | |||
59 | static 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 | |||
69 | module_i2c_driver(pcm179x_i2c_driver); | ||
70 | |||
71 | MODULE_DESCRIPTION("ASoC PCM179X I2C driver"); | ||
72 | MODULE_AUTHOR("Jacob Siverskog <jacob@teenage.engineering>"); | ||
73 | MODULE_LICENSE("GPL"); | ||