[alsa-devel] [PATCH v3 0/3] ASoC: pcm179x: Add I2C support, declare support for continuous rates
This series add support for I2C and declares support for continuous sample rates.
Please note that this has only been tested using I2C and PCM1791A. I'd be grateful if someone can test it with other devices in the PCM179X family and/or SPI.
These patches are against linux-next.
[V3]: Allocation of private data moved to common code.
[V2]: Fix build issues found by kbuild test robot by adding static keyword and proper symbol exports.
Jacob Siverskog (3): ASoC: pcm179x: Split into core and SPI parts ASoC: pcm179x: Add I2C interface driver ASoC: pcm179x: Support continuous rates
.../devicetree/bindings/sound/pcm179x.txt | 11 +++- sound/soc/codecs/Kconfig | 20 ++++++- sound/soc/codecs/Makefile | 4 ++ sound/soc/codecs/pcm179x-i2c.c | 64 ++++++++++++++++++++++ sound/soc/codecs/pcm179x-spi.c | 63 +++++++++++++++++++++ sound/soc/codecs/pcm179x.c | 61 +++++++-------------- sound/soc/codecs/pcm179x.h | 9 +-- 7 files changed, 184 insertions(+), 48 deletions(-) create mode 100644 sound/soc/codecs/pcm179x-i2c.c create mode 100644 sound/soc/codecs/pcm179x-spi.c
The pcm179x family supports both SPI and I2C for configuration. This patch splits the driver into core and SPI parts, in preparation for I2C support.
Reviewed-by: Johan Hovold johan@kernel.org Signed-off-by: Jacob Siverskog jacob@teenage.engineering --- sound/soc/codecs/Kconfig | 11 ++++++-- sound/soc/codecs/Makefile | 2 ++ sound/soc/codecs/pcm179x-spi.c | 63 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/pcm179x.c | 57 ++++++++++++-------------------------- sound/soc/codecs/pcm179x.h | 5 ++++ 5 files changed, 96 insertions(+), 42 deletions(-) create mode 100644 sound/soc/codecs/pcm179x-spi.c
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 0f279c2..3866717 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -83,7 +83,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ML26124 if I2C select SND_SOC_NAU8825 if I2C select SND_SOC_PCM1681 if I2C - select SND_SOC_PCM179X if SPI_MASTER + select SND_SOC_PCM179X_SPI if SPI_MASTER select SND_SOC_PCM3008 select SND_SOC_PCM512x_I2C if I2C select SND_SOC_PCM512x_SPI if SPI_MASTER @@ -500,8 +500,15 @@ config SND_SOC_PCM1681 depends on I2C
config SND_SOC_PCM179X - tristate "Texas Instruments PCM179X CODEC" + tristate + +config SND_SOC_PCM179X_SPI + tristate "Texas Instruments PCM179X CODEC (SPI)" depends on SPI_MASTER + select SND_SOC_PCM179X + help + Enable support for Texas Instruments PCM179x CODEC. + Select this if your PCM179x is connected via an SPI bus.
config SND_SOC_PCM3008 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index c2d2ced..0fa454c 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -77,6 +77,7 @@ snd-soc-ml26124-objs := ml26124.o snd-soc-nau8825-objs := nau8825.o snd-soc-pcm1681-objs := pcm1681.o snd-soc-pcm179x-codec-objs := pcm179x.o +snd-soc-pcm179x-spi-objs := pcm179x-spi.o snd-soc-pcm3008-objs := pcm3008.o snd-soc-pcm512x-objs := pcm512x.o snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o @@ -275,6 +276,7 @@ obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o +obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c new file mode 100644 index 0000000..5842add9 --- /dev/null +++ b/sound/soc/codecs/pcm179x-spi.c @@ -0,0 +1,63 @@ +/* + * PCM179X ASoC SPI driver + * + * Copyright (c) Amarula Solutions B.V. 2013 + * + * Michael Trimarchi michael@amarulasolutions.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <linux/module.h> +#include <linux/of.h> +#include <linux/spi/spi.h> +#include <linux/regmap.h> + +#include "pcm179x.h" + +static int pcm179x_spi_probe(struct spi_device *spi) +{ + return pcm179x_common_init(&spi->dev, + devm_regmap_init_spi(spi, &pcm179x_regmap_config)); +} + +static int pcm179x_spi_remove(struct spi_device *spi) +{ + return pcm179x_common_exit(&spi->dev); +} + +static const struct of_device_id pcm179x_of_match[] = { + { .compatible = "ti,pcm1792a", }, + { } +}; +MODULE_DEVICE_TABLE(of, pcm179x_of_match); + +static const struct spi_device_id pcm179x_spi_ids[] = { + { "pcm179x", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids); + +static struct spi_driver pcm179x_spi_driver = { + .driver = { + .name = "pcm179x", + .of_match_table = of_match_ptr(pcm179x_of_match), + }, + .id_table = pcm179x_spi_ids, + .probe = pcm179x_spi_probe, + .remove = pcm179x_spi_remove, +}; + +module_spi_driver(pcm179x_spi_driver); + +MODULE_DESCRIPTION("ASoC PCM179X SPI driver"); +MODULE_AUTHOR("Michael Trimarchi michael@amarulasolutions.com"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index a56c7b7..eba451f 100644 --- a/sound/soc/codecs/pcm179x.c +++ b/sound/soc/codecs/pcm179x.c @@ -20,7 +20,6 @@ #include <linux/slab.h> #include <linux/kernel.h> #include <linux/device.h> -#include <linux/spi/spi.h>
#include <sound/core.h> #include <sound/pcm.h> @@ -29,7 +28,6 @@ #include <sound/soc.h> #include <sound/tlv.h> #include <linux/of.h> -#include <linux/of_device.h>
#include "pcm179x.h"
@@ -194,13 +192,7 @@ static struct snd_soc_dai_driver pcm179x_dai = { .ops = &pcm179x_dai_ops, };
-static const struct of_device_id pcm179x_of_match[] = { - { .compatible = "ti,pcm1792a", }, - { } -}; -MODULE_DEVICE_TABLE(of, pcm179x_of_match); - -static const struct regmap_config pcm179x_regmap = { +const struct regmap_config pcm179x_regmap_config = { .reg_bits = 8, .val_bits = 8, .max_register = 23, @@ -209,6 +201,7 @@ static const struct regmap_config pcm179x_regmap = { .writeable_reg = pcm179x_writeable_reg, .readable_reg = pcm179x_accessible_reg, }; +EXPORT_SYMBOL_GPL(pcm179x_regmap_config);
static struct snd_soc_codec_driver soc_codec_dev_pcm179x = { .controls = pcm179x_controls, @@ -219,52 +212,36 @@ static struct snd_soc_codec_driver soc_codec_dev_pcm179x = { .num_dapm_routes = ARRAY_SIZE(pcm179x_dapm_routes), };
-static int pcm179x_spi_probe(struct spi_device *spi) +int pcm179x_common_init(struct device *dev, struct regmap *regmap) { struct pcm179x_private *pcm179x; int ret;
- pcm179x = devm_kzalloc(&spi->dev, sizeof(struct pcm179x_private), + if (IS_ERR(regmap)) { + ret = PTR_ERR(regmap); + dev_err(dev, "Failed to register regmap: %d\n", ret); + return ret; + } + + pcm179x = devm_kzalloc(dev, sizeof(struct pcm179x_private), GFP_KERNEL); if (!pcm179x) return -ENOMEM;
- spi_set_drvdata(spi, pcm179x); - - pcm179x->regmap = devm_regmap_init_spi(spi, &pcm179x_regmap); - if (IS_ERR(pcm179x->regmap)) { - ret = PTR_ERR(pcm179x->regmap); - dev_err(&spi->dev, "Failed to register regmap: %d\n", ret); - return ret; - } + pcm179x->regmap = regmap; + dev_set_drvdata(dev, pcm179x);
- return snd_soc_register_codec(&spi->dev, + return snd_soc_register_codec(dev, &soc_codec_dev_pcm179x, &pcm179x_dai, 1); } +EXPORT_SYMBOL_GPL(pcm179x_common_init);
-static int pcm179x_spi_remove(struct spi_device *spi) +int pcm179x_common_exit(struct device *dev) { - snd_soc_unregister_codec(&spi->dev); + snd_soc_unregister_codec(dev); return 0; } - -static const struct spi_device_id pcm179x_spi_ids[] = { - { "pcm179x", 0 }, - { }, -}; -MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids); - -static struct spi_driver pcm179x_codec_driver = { - .driver = { - .name = "pcm179x", - .of_match_table = of_match_ptr(pcm179x_of_match), - }, - .id_table = pcm179x_spi_ids, - .probe = pcm179x_spi_probe, - .remove = pcm179x_spi_remove, -}; - -module_spi_driver(pcm179x_codec_driver); +EXPORT_SYMBOL_GPL(pcm179x_common_exit);
MODULE_DESCRIPTION("ASoC PCM179X driver"); MODULE_AUTHOR("Michael Trimarchi michael@amarulasolutions.com"); diff --git a/sound/soc/codecs/pcm179x.h b/sound/soc/codecs/pcm179x.h index c6fdc06..c4eea4d 100644 --- a/sound/soc/codecs/pcm179x.h +++ b/sound/soc/codecs/pcm179x.h @@ -24,4 +24,9 @@ #define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S16_LE)
+extern const struct regmap_config pcm179x_regmap_config; + +int pcm179x_common_init(struct device *dev, struct regmap *regmap); +int pcm179x_common_exit(struct device *dev); + #endif
On Thu, Jan 21, 2016 at 04:26:56PM +0100, Jacob Siverskog wrote:
The pcm179x family supports both SPI and I2C for configuration. This patch splits the driver into core and SPI parts, in preparation for I2C support.
Reviewed-by: Johan Hovold johan@kernel.org Signed-off-by: Jacob Siverskog jacob@teenage.engineering
diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c new file mode 100644 index 0000000..5842add9 --- /dev/null +++ b/sound/soc/codecs/pcm179x-spi.c @@ -0,0 +1,63 @@ +/*
- PCM179X ASoC SPI driver
- Copyright (c) Amarula Solutions B.V. 2013
Michael Trimarchi <michael@amarulasolutions.com>
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- */
+#include <linux/module.h> +#include <linux/of.h> +#include <linux/spi/spi.h> +#include <linux/regmap.h>
+#include "pcm179x.h"
+static int pcm179x_spi_probe(struct spi_device *spi) +{
- return pcm179x_common_init(&spi->dev,
devm_regmap_init_spi(spi, &pcm179x_regmap_config));
+}
-static int pcm179x_spi_probe(struct spi_device *spi) +int pcm179x_common_init(struct device *dev, struct regmap *regmap) { struct pcm179x_private *pcm179x; int ret;
- pcm179x = devm_kzalloc(&spi->dev, sizeof(struct pcm179x_private),
- if (IS_ERR(regmap)) {
ret = PTR_ERR(regmap);
dev_err(dev, "Failed to register regmap: %d\n", ret);
return ret;
- }
This looks weird. I think you should check for error where you do the allocation even if this means a four more lines of code in total.
- pcm179x = devm_kzalloc(dev, sizeof(struct pcm179x_private), GFP_KERNEL); if (!pcm179x) return -ENOMEM;
- spi_set_drvdata(spi, pcm179x);
- pcm179x->regmap = devm_regmap_init_spi(spi, &pcm179x_regmap);
- if (IS_ERR(pcm179x->regmap)) {
ret = PTR_ERR(pcm179x->regmap);
dev_err(&spi->dev, "Failed to register regmap: %d\n", ret);
return ret;
- }
- pcm179x->regmap = regmap;
- dev_set_drvdata(dev, pcm179x);
- return snd_soc_register_codec(&spi->dev,
- return snd_soc_register_codec(dev, &soc_codec_dev_pcm179x, &pcm179x_dai, 1);
}
Thanks, Johan
Hi
On Thu, Jan 21, 2016 at 4:36 PM, Johan Hovold johan@kernel.org wrote:
On Thu, Jan 21, 2016 at 04:26:56PM +0100, Jacob Siverskog wrote:
The pcm179x family supports both SPI and I2C for configuration. This patch splits the driver into core and SPI parts, in preparation for I2C support.
Reviewed-by: Johan Hovold johan@kernel.org Signed-off-by: Jacob Siverskog jacob@teenage.engineering
diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c new file mode 100644 index 0000000..5842add9 --- /dev/null +++ b/sound/soc/codecs/pcm179x-spi.c @@ -0,0 +1,63 @@ +/*
- PCM179X ASoC SPI driver
- Copyright (c) Amarula Solutions B.V. 2013
Michael Trimarchi <michael@amarulasolutions.com>
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- */
+#include <linux/module.h> +#include <linux/of.h> +#include <linux/spi/spi.h> +#include <linux/regmap.h>
+#include "pcm179x.h"
+static int pcm179x_spi_probe(struct spi_device *spi) +{
return pcm179x_common_init(&spi->dev,
devm_regmap_init_spi(spi, &pcm179x_regmap_config));
+}
-static int pcm179x_spi_probe(struct spi_device *spi) +int pcm179x_common_init(struct device *dev, struct regmap *regmap) { struct pcm179x_private *pcm179x; int ret;
pcm179x = devm_kzalloc(&spi->dev, sizeof(struct pcm179x_private),
if (IS_ERR(regmap)) {
ret = PTR_ERR(regmap);
dev_err(dev, "Failed to register regmap: %d\n", ret);
return ret;
}
This looks weird. I think you should check for error where you do the allocation even if this means a four more lines of code in total.
agree on that
pcm179x = devm_kzalloc(dev, sizeof(struct pcm179x_private), GFP_KERNEL); if (!pcm179x) return -ENOMEM;
spi_set_drvdata(spi, pcm179x);
pcm179x->regmap = devm_regmap_init_spi(spi, &pcm179x_regmap);
if (IS_ERR(pcm179x->regmap)) {
ret = PTR_ERR(pcm179x->regmap);
dev_err(&spi->dev, "Failed to register regmap: %d\n", ret);
return ret;
}
pcm179x->regmap = regmap;
dev_set_drvdata(dev, pcm179x);
snd_soc_codec_set_drvdata
Is this more "codec" like?
Michael
return snd_soc_register_codec(&spi->dev,
return snd_soc_register_codec(dev, &soc_codec_dev_pcm179x, &pcm179x_dai, 1);
}
Thanks, Johan
On Thu, Jan 21, 2016 at 05:27:58PM +0100, Michael Trimarchi wrote:
Hi
On Thu, Jan 21, 2016 at 4:36 PM, Johan Hovold johan@kernel.org wrote:
On Thu, Jan 21, 2016 at 04:26:56PM +0100, Jacob Siverskog wrote:
The pcm179x family supports both SPI and I2C for configuration. This patch splits the driver into core and SPI parts, in preparation for I2C support.
Reviewed-by: Johan Hovold johan@kernel.org Signed-off-by: Jacob Siverskog jacob@teenage.engineering
diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c new file mode 100644 index 0000000..5842add9 --- /dev/null +++ b/sound/soc/codecs/pcm179x-spi.c
-static int pcm179x_spi_probe(struct spi_device *spi) +int pcm179x_common_init(struct device *dev, struct regmap *regmap) { struct pcm179x_private *pcm179x; int ret;
pcm179x = devm_kzalloc(&spi->dev, sizeof(struct pcm179x_private),
if (IS_ERR(regmap)) {
ret = PTR_ERR(regmap);
dev_err(dev, "Failed to register regmap: %d\n", ret);
return ret;
}
This looks weird. I think you should check for error where you do the allocation even if this means a four more lines of code in total.
agree on that
pcm179x = devm_kzalloc(dev, sizeof(struct pcm179x_private), GFP_KERNEL); if (!pcm179x) return -ENOMEM;
spi_set_drvdata(spi, pcm179x);
pcm179x->regmap = devm_regmap_init_spi(spi, &pcm179x_regmap);
if (IS_ERR(pcm179x->regmap)) {
ret = PTR_ERR(pcm179x->regmap);
dev_err(&spi->dev, "Failed to register regmap: %d\n", ret);
return ret;
}
pcm179x->regmap = regmap;
dev_set_drvdata(dev, pcm179x);
snd_soc_codec_set_drvdata
Is this more "codec" like?
I'd say, only if you also add a codec probe callback and use it from there. The other codec drivers appear to be consistent on that.
Thanks, Johan
On Thu, Jan 21, 2016 at 6:56 PM, Johan Hovold johan@kernel.org wrote:
On Thu, Jan 21, 2016 at 05:27:58PM +0100, Michael Trimarchi wrote:
Hi
On Thu, Jan 21, 2016 at 4:36 PM, Johan Hovold johan@kernel.org wrote:
On Thu, Jan 21, 2016 at 04:26:56PM +0100, Jacob Siverskog wrote:
The pcm179x family supports both SPI and I2C for configuration. This patch splits the driver into core and SPI parts, in preparation for I2C support.
Reviewed-by: Johan Hovold johan@kernel.org Signed-off-by: Jacob Siverskog jacob@teenage.engineering
diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c new file mode 100644 index 0000000..5842add9 --- /dev/null +++ b/sound/soc/codecs/pcm179x-spi.c
-static int pcm179x_spi_probe(struct spi_device *spi) +int pcm179x_common_init(struct device *dev, struct regmap *regmap) { struct pcm179x_private *pcm179x; int ret;
pcm179x = devm_kzalloc(&spi->dev, sizeof(struct pcm179x_private),
if (IS_ERR(regmap)) {
ret = PTR_ERR(regmap);
dev_err(dev, "Failed to register regmap: %d\n", ret);
return ret;
}
This looks weird. I think you should check for error where you do the allocation even if this means a four more lines of code in total.
agree on that
Ok.
pcm179x = devm_kzalloc(dev, sizeof(struct pcm179x_private), GFP_KERNEL); if (!pcm179x) return -ENOMEM;
spi_set_drvdata(spi, pcm179x);
pcm179x->regmap = devm_regmap_init_spi(spi, &pcm179x_regmap);
if (IS_ERR(pcm179x->regmap)) {
ret = PTR_ERR(pcm179x->regmap);
dev_err(&spi->dev, "Failed to register regmap: %d\n", ret);
return ret;
}
pcm179x->regmap = regmap;
dev_set_drvdata(dev, pcm179x);
snd_soc_codec_set_drvdata
Is this more "codec" like?
I'd say, only if you also add a codec probe callback and use it from there. The other codec drivers appear to be consistent on that.
I agree. Using snd_soc_codec_set_drvdata would mean larger logical changes that I don't really see the purpose of doing. All other codec drivers that are separated in a similar fashion as this patch use dev_set_drvdata.
The PCM179x family supports both SPI and I2C. This patch adds support for the I2C interface.
Reviewed-by: Johan Hovold johan@kernel.org Signed-off-by: Jacob Siverskog jacob@teenage.engineering --- .../devicetree/bindings/sound/pcm179x.txt | 11 +++- sound/soc/codecs/Kconfig | 9 +++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/pcm179x-i2c.c | 64 ++++++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 sound/soc/codecs/pcm179x-i2c.c
diff --git a/Documentation/devicetree/bindings/sound/pcm179x.txt b/Documentation/devicetree/bindings/sound/pcm179x.txt index 4ae70d3..436c2b2 100644 --- a/Documentation/devicetree/bindings/sound/pcm179x.txt +++ b/Documentation/devicetree/bindings/sound/pcm179x.txt @@ -1,6 +1,6 @@ Texas Instruments pcm179x DT bindings
-This driver supports the SPI bus. +This driver supports both the I2C and SPI bus.
Required properties:
@@ -9,6 +9,11 @@ Required properties: For required properties on SPI, please consult Documentation/devicetree/bindings/spi/spi-bus.txt
+Required properties on I2C: + + - reg: the I2C address + + Examples:
codec_spi: 1792a@0 { @@ -16,3 +21,7 @@ Examples: spi-max-frequency = <600000>; };
+ codec_i2c: 1792a@4c { + compatible = "ti,pcm1792a"; + reg = <0x4c>; + }; diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 3866717..a27da1b 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -83,6 +83,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ML26124 if I2C select SND_SOC_NAU8825 if I2C select SND_SOC_PCM1681 if I2C + select SND_SOC_PCM179X_I2C if I2C select SND_SOC_PCM179X_SPI if SPI_MASTER select SND_SOC_PCM3008 select SND_SOC_PCM512x_I2C if I2C @@ -502,6 +503,14 @@ config SND_SOC_PCM1681 config SND_SOC_PCM179X tristate
+config SND_SOC_PCM179X_I2C + tristate "Texas Instruments PCM179X CODEC (I2C)" + depends on I2C + select SND_SOC_PCM179X + help + Enable support for Texas Instruments PCM179x CODEC. + Select this if your PCM179x is connected via an I2C bus. + config SND_SOC_PCM179X_SPI tristate "Texas Instruments PCM179X CODEC (SPI)" depends on SPI_MASTER diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 0fa454c..972395e 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -77,6 +77,7 @@ snd-soc-ml26124-objs := ml26124.o snd-soc-nau8825-objs := nau8825.o snd-soc-pcm1681-objs := pcm1681.o snd-soc-pcm179x-codec-objs := pcm179x.o +snd-soc-pcm179x-i2c-objs := pcm179x-i2c.o snd-soc-pcm179x-spi-objs := pcm179x-spi.o snd-soc-pcm3008-objs := pcm3008.o snd-soc-pcm512x-objs := pcm512x.o @@ -276,6 +277,7 @@ obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o +obj-$(CONFIG_SND_SOC_PCM179X_I2C) += snd-soc-pcm179x-i2c.o obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c new file mode 100644 index 0000000..ee73576 --- /dev/null +++ b/sound/soc/codecs/pcm179x-i2c.c @@ -0,0 +1,64 @@ +/* + * PCM179X ASoC I2C driver + * + * Copyright (c) Teenage Engineering AB 2016 + * + * Jacob Siverskog jacob@teenage.engineering + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <linux/module.h> +#include <linux/of.h> +#include <linux/i2c.h> +#include <linux/regmap.h> + +#include "pcm179x.h" + +static int pcm179x_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + return pcm179x_common_init(&client->dev, + devm_regmap_init_i2c(client, &pcm179x_regmap_config)); +} + +static int pcm179x_i2c_remove(struct i2c_client *client) +{ + return pcm179x_common_exit(&client->dev); +} + +static const struct of_device_id pcm179x_of_match[] = { + { .compatible = "ti,pcm1792a", }, + { } +}; +MODULE_DEVICE_TABLE(of, pcm179x_of_match); + +static const struct i2c_device_id pcm179x_i2c_ids[] = { + { "pcm179x", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, pcm179x_i2c_ids); + +static struct i2c_driver pcm179x_i2c_driver = { + .driver = { + .name = "pcm179x", + .of_match_table = of_match_ptr(pcm179x_of_match), + }, + .id_table = pcm179x_i2c_ids, + .probe = pcm179x_i2c_probe, + .remove = pcm179x_i2c_remove, +}; + +module_i2c_driver(pcm179x_i2c_driver); + +MODULE_DESCRIPTION("ASoC PCM179X I2C driver"); +MODULE_AUTHOR("Jacob Siverskog jacob@teenage.engineering"); +MODULE_LICENSE("GPL");
According to the PCM179x data sheets sampling frequencies between 10 kHz and 200 kHz are supported. Specify support in the driver.
Tested with PCM1791A.
References: http://www.ti.com/lit/ds/symlink/pcm1791a.pdf http://www.ti.com/lit/ds/symlink/pcm1792a.pdf http://www.ti.com/lit/ds/symlink/pcm1795.pdf http://www.ti.com/lit/ds/symlink/pcm1796.pdf
Reviewed-by: Johan Hovold johan@kernel.org Signed-off-by: Jacob Siverskog jacob@teenage.engineering --- sound/soc/codecs/pcm179x.c | 4 +++- sound/soc/codecs/pcm179x.h | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index eba451f..d492b5a 100644 --- a/sound/soc/codecs/pcm179x.c +++ b/sound/soc/codecs/pcm179x.c @@ -187,7 +187,9 @@ static struct snd_soc_dai_driver pcm179x_dai = { .stream_name = "Playback", .channels_min = 2, .channels_max = 2, - .rates = PCM1792A_RATES, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 10000, + .rate_max = 200000, .formats = PCM1792A_FORMATS, }, .ops = &pcm179x_dai_ops, }; diff --git a/sound/soc/codecs/pcm179x.h b/sound/soc/codecs/pcm179x.h index c4eea4d..11e3312 100644 --- a/sound/soc/codecs/pcm179x.h +++ b/sound/soc/codecs/pcm179x.h @@ -17,10 +17,6 @@ #ifndef __PCM179X_H__ #define __PCM179X_H__
-#define PCM1792A_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_8000_48000 | \ - SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | \ - SNDRV_PCM_RATE_192000) - #define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S16_LE)
The patch
ASoC: pcm179x: Support continuous rates
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From e0236f541e68aa2187a9a402bf74bec6f007eb84 Mon Sep 17 00:00:00 2001
From: Jacob Siverskog jacob@teenage.engineering Date: Fri, 22 Jan 2016 13:39:55 +0100 Subject: [PATCH] ASoC: pcm179x: Support continuous rates
According to the PCM179x data sheets sampling frequencies between 10 kHz and 200 kHz are supported. Specify support in the driver.
Tested with PCM1791A.
References: http://www.ti.com/lit/ds/symlink/pcm1791a.pdf http://www.ti.com/lit/ds/symlink/pcm1792a.pdf http://www.ti.com/lit/ds/symlink/pcm1795.pdf http://www.ti.com/lit/ds/symlink/pcm1796.pdf
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 --- sound/soc/codecs/pcm179x.c | 4 +++- sound/soc/codecs/pcm179x.h | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index 8f20f70..06a6657 100644 --- a/sound/soc/codecs/pcm179x.c +++ b/sound/soc/codecs/pcm179x.c @@ -187,7 +187,9 @@ static struct snd_soc_dai_driver pcm179x_dai = { .stream_name = "Playback", .channels_min = 2, .channels_max = 2, - .rates = PCM1792A_RATES, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 10000, + .rate_max = 200000, .formats = PCM1792A_FORMATS, }, .ops = &pcm179x_dai_ops, }; diff --git a/sound/soc/codecs/pcm179x.h b/sound/soc/codecs/pcm179x.h index c4eea4d..11e3312 100644 --- a/sound/soc/codecs/pcm179x.h +++ b/sound/soc/codecs/pcm179x.h @@ -17,10 +17,6 @@ #ifndef __PCM179X_H__ #define __PCM179X_H__
-#define PCM1792A_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_8000_48000 | \ - SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | \ - SNDRV_PCM_RATE_192000) - #define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S16_LE)
participants (4)
-
Jacob Siverskog
-
Johan Hovold
-
Mark Brown
-
Michael Trimarchi