Skip to contentSkip to conversation

Add the Infineon PEB2466 codec support

PATCH In review Herve Codina 4 participants 8 messages Feb 6, 2023 – Feb 9, 2023

Subsystems (5)
Device tree bindings Sound ASoC GPIO +1 more subsystems
lore
Share & tools
lore

Herve Codina

author maintainer
#0 lore raw

cover Add the Infineon PEB2466 codec support

Hi,

The Infineon PEB2466 codec is a programmable DSP-based four channels codec with filters capabilities.
It also provides signals as GPIOs.

Best regards,
Herve Codina

Herve Codina (3):
dt-bindings: sound: Add the Infineon PEB2466 codec
ASoC: codecs: Add support for the Infineon PEB2466 codec
MAINTAINERS: add the Infineon PEB2466 codec entry

 .../bindings/sound/infineon,peb2466.yaml      |   91 +
 MAINTAINERS                                   |    7 +
 sound/soc/codecs/Kconfig                      |   12 +
 sound/soc/codecs/Makefile                     |    2 +
 sound/soc/codecs/peb2466.c                    | 2071 +++++++++++++++++
 5 files changed, 2183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/infineon,peb2466.yaml
 create mode 100644 sound/soc/codecs/peb2466.c
Signature · 1 line
2.39.1
author maintainer
#1 lore raw

PATCH 1/3 dt-bindings: sound: Add the Infineon PEB2466 codec

The Infineon PEB2466 codec is a programmable DSP-based four channels codec with filters capabilities.

---
 .../bindings/sound/infineon,peb2466.yaml      | 91 +++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/infineon,peb2466.yaml
Documentation/devicetree/bindings/sound/infineon,peb2466.yaml new file +91 -0
new file mode 100644
index 000000000000..66993d378aaf
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/infineon,peb2466.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Infineon PEB2466 codec
+
+maintainers:
+  - Herve Codina <[email protected]>
+
+description: |
+  The Infineon PEB2466 codec is a programmable DSP-based four channels codec
+  with filters capabilities.
+
+  The time-slots used by the codec must be set and so, the properties
+  'dai-tdm-slot-num', 'dai-tdm-slot-width', 'dai-tdm-slot-tx-mask' and
+  'dai-tdm-slot-rx-mask' must be present in the sound card node for sub-nodes
+  that involve the codec. The codec uses one 8bit time-slot per channel.
+  'dai-tdm-tdm-slot-with' must be set to 8.
+
+  The PEB2466 codec also supports 28 gpios (signaling pins).
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: infineon,peb2466
+
+  reg:
+    description:
+      SPI device address.
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Master clock
+
+  clock-names:
+    items:
+      - const: mclk
+
+  spi-max-frequency:
+    maximum: 8192000
+
+  reset-gpios:
+    description:
+      GPIO used to reset the device.
+    maxItems: 1
+
+  firmware-name:
+    $ref: /schemas/types.yaml#/definitions/string
+    description:
+      Filters coefficients file to load. If this property is omitted, internal
+      filters are disabled.
+
+  '#sound-dai-cells':
+    const: 0
+
+  '#gpio-cells':
+    const: 2
+
+  gpio-controller: true
+
+required:
+  - compatible
+  - reg
+  - '#sound-dai-cells'
+  - gpio-controller
+  - '#gpio-cells'
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        audio-codec@0 {
+            compatible = "infineon,peb2466";
+            reg = <0>;
+            spi-max-frequency = <8192000>;
+            reset-gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
+            #sound-dai-cells = <0>;
+            gpio-controller;
+            #gpio-cells = <2>;
+        };
+    };
Signature · 1 line
2.39.1
maintainer Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] dt-bindings: sound: Add the Infineon PEB2466 codec

Quoted 9 lines · Herve Codina

The Infineon PEB2466 codec is a programmable DSP-based four channels codec with filters capabilities.

---
 .../bindings/sound/infineon,peb2466.yaml      | 91 +++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/infineon,peb2466.yaml
author maintainer
#3 lore raw

PATCH 2/3 ASoC: codecs: Add support for the Infineon PEB2466 codec

In reply to Herve Codina

The Infineon PEB2466 codec is a programmable DSP-based four channels codec with filters capabilities.
It also provides signals as GPIOs.

---
 sound/soc/codecs/Kconfig   |   12 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/peb2466.c | 2071 ++++++++++++++++++++++++++++++++++++
 3 files changed, 2085 insertions(+)
 create mode 100644 sound/soc/codecs/peb2466.c
sound/soc/codecs/Kconfig +12 -0
index 19afa0067305..80dd454695b6 100644
@@ -165,6 +165,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_PCM5102A
 	imply SND_SOC_PCM512x_I2C
 	imply SND_SOC_PCM512x_SPI
+	imply SND_SOC_PEB2466
 	imply SND_SOC_RK3328
 	imply SND_SOC_RK817
 	imply SND_SOC_RT274
@@ -1217,6 +1218,17 @@ config SND_SOC_PCM512x_SPI
 	select SND_SOC_PCM512x
 	select REGMAP_SPI
 
+config SND_SOC_PEB2466
+	tristate "Infineon PEB2466 quad PCM codec"
+	depends on SPI
+	select REGMAP_SPI
+	help
+	  Enable support for the Infineon PEB2466 quad PCM codec,
+	  also named SICOFI 4-uC.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-soc-peb2466.
+
 config SND_SOC_RK3328
 	tristate "Rockchip RK3328 audio CODEC"
 	select REGMAP_MMIO
sound/soc/codecs/Makefile +2 -0
index a1d6de6a18f6..a48fec03703d 100644
@@ -184,6 +184,7 @@ snd-soc-pcm5102a-objs := pcm5102a.o
 snd-soc-pcm512x-objs := pcm512x.o
 snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o
 snd-soc-pcm512x-spi-objs := pcm512x-spi.o
+snd-soc-peb2466-objs := peb2466.o
 snd-soc-rk3328-objs := rk3328_codec.o
 snd-soc-rk817-objs := rk817_codec.o
 snd-soc-rl6231-objs := rl6231.o
@@ -542,6 +543,7 @@ obj-$(CONFIG_SND_SOC_PCM5102A)	+= snd-soc-pcm5102a.o
 obj-$(CONFIG_SND_SOC_PCM512x)	+= snd-soc-pcm512x.o
 obj-$(CONFIG_SND_SOC_PCM512x_I2C)	+= snd-soc-pcm512x-i2c.o
 obj-$(CONFIG_SND_SOC_PCM512x_SPI)	+= snd-soc-pcm512x-spi.o
+obj-$(CONFIG_SND_SOC_PEB2466)	+= snd-soc-peb2466.o
 obj-$(CONFIG_SND_SOC_RK3328)	+= snd-soc-rk3328.o
 obj-$(CONFIG_SND_SOC_RK817)	+= snd-soc-rk817.o
 obj-$(CONFIG_SND_SOC_RL6231)	+= snd-soc-rl6231.o
sound/soc/codecs/peb2466.c new file +2071 -0

2,071 lines not on this page · raw message

Signature · 1 line
2.39.1
#4 lore raw

Re: [PATCH 2/3] ASoC: codecs: Add support for the Infineon PEB2466 codec

Le 06/02/2023 à 15:49, Herve Codina a écrit :

Quoted 12 lines

The Infineon PEB2466 codec is a programmable DSP-based four channels codec with filters capabilities.
It also provides signals as GPIOs.

---
  sound/soc/codecs/Kconfig   |   12 +
  sound/soc/codecs/Makefile  |    2 +
  sound/soc/codecs/peb2466.c | 2071 ++++++++++++++++++++++++++++++++++++
  3 files changed, 2085 insertions(+)

create mode 100644 sound/soc/codecs/peb2466.c

[...]

Quoted 19 lines
sound/soc/codecs/peb2466.c new file +19 -0
+static int peb2466_spi_probe(struct spi_device *spi)
+{
+	struct peb2466 *peb2466;
+	unsigned long mclk_rate;
+	int ret;
+	u8 xr5;
+
+	spi->bits_per_word = 8;
+	ret = spi_setup(spi);
+	if (ret < 0)
+		return ret;
+
+	peb2466 = devm_kzalloc(&spi->dev, sizeof(*peb2466), GFP_KERNEL);
+	if (!peb2466)
+		return -ENOMEM;
+
+	peb2466->spi = spi;
+
+	peb2466->regmap = devm_regmap_init(&peb2466->spi->dev, NULL, peb2466,

sound/soc/codecs/peb2466.c line 1978

Quoted 10 lines
sound/soc/codecs/peb2466.c new file +10 -0
+					   &peb2466_regmap_config);
+	if (IS_ERR(peb2466->regmap))
+		return PTR_ERR(peb2466->regmap);
+
+	peb2466->reset_gpio = devm_gpiod_get_optional(&peb2466->spi->dev,
+						      "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(peb2466->reset_gpio))
+		return PTR_ERR(peb2466->reset_gpio);
+
+	peb2466->mclk = devm_clk_get(&peb2466->spi->dev, "mclk");

Hi,

Up to you to decide if it is a good idea or not, but using devm_clk_get_enabled() would save the 'mclk' field in peb2466 ...

sound/soc/codecs/peb2466.c line 1983

Quoted 5 lines
sound/soc/codecs/peb2466.c new file +5 -0
+	if (IS_ERR(peb2466->mclk))
+		return PTR_ERR(peb2466->mclk);
+	ret = clk_prepare_enable(peb2466->mclk);
+	if (ret)
+		return ret;

... these 3 lines ...

sound/soc/codecs/peb2466.c line 1992

Quoted 9 lines
sound/soc/codecs/peb2466.c new file +9 -0
+
+	if (peb2466->reset_gpio) {
+		gpiod_set_value_cansleep(peb2466->reset_gpio, 1);
+		udelay(4);
+		gpiod_set_value_cansleep(peb2466->reset_gpio, 0);
+		udelay(4);
+	}
+
+	spi_set_drvdata(spi, peb2466);

... this spi_set_drvdata() call ...

Quoted 33 lines
sound/soc/codecs/peb2466.c new file +33 -0
+
+	mclk_rate = clk_get_rate(peb2466->mclk);
+	switch (mclk_rate) {
+	case 1536000:
+		xr5 = PEB2466_XR5_MCLK_1536;
+		break;
+	case 2048000:
+		xr5 = PEB2466_XR5_MCLK_2048;
+		break;
+	case 4096000:
+		xr5 = PEB2466_XR5_MCLK_4096;
+		break;
+	case 8192000:
+		xr5 = PEB2466_XR5_MCLK_8192;
+		break;
+	default:
+		dev_err(&peb2466->spi->dev, "Unsupported clock rate %lu\n",
+			mclk_rate);
+		ret = -EINVAL;
+		goto failed;
+	}
+	ret = regmap_write(peb2466->regmap, PEB2466_XR5, xr5);
+	if (ret) {
+		dev_err(&peb2466->spi->dev, "Setting MCLK failed (%d)\n", ret);
+		goto failed;
+	}
+
+	ret = devm_snd_soc_register_component(&spi->dev, &peb2466_component_driver,
+					      &peb2466_dai_driver, 1);
+	if (ret)
+		goto failed;
+
+	if (IS_ENABLED(CONFIG_GPIOLIB)) {

sound/soc/codecs/peb2466.c line 2035

Quoted 10 lines
sound/soc/codecs/peb2466.c new file +10 -0
+		ret = peb2466_gpio_init(peb2466);
+		if (ret)
+			goto failed;
+	}
+
+	return 0;
+
+failed:
+	clk_disable_unprepare(peb2466->mclk);
+	return ret;

... this error handling path ...

sound/soc/codecs/peb2466.c line 2043

Quoted 8 lines
sound/soc/codecs/peb2466.c new file +8 -0
+}
+
+static void peb2466_spi_remove(struct spi_device *spi)
+{
+	struct peb2466 *peb2466 = spi_get_drvdata(spi);
+
+	clk_disable_unprepare(peb2466->mclk);
+}

... and the remove function.

CJ

Quoted 28 lines
sound/soc/codecs/peb2466.c new file +28 -0
+
+static const struct of_device_id peb2466_of_match[] = {
+	{ .compatible = "infineon,peb2466", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, peb2466_of_match);
+
+static const struct spi_device_id peb2466_id_table[] = {
+	{ "peb2466", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, peb2466_id_table);
+
+static struct spi_driver peb2466_spi_driver = {
+	.driver  = {
+		.name   = "peb2466",
+		.of_match_table = peb2466_of_match,
+	},
+	.id_table = peb2466_id_table,
+	.probe  = peb2466_spi_probe,
+	.remove = peb2466_spi_remove,
+};
+
+module_spi_driver(peb2466_spi_driver);
+
+MODULE_AUTHOR("Herve Codina <[email protected]>");
+MODULE_DESCRIPTION("PEB2466 ALSA SoC driver");
+MODULE_LICENSE("GPL");
author maintainer
#5 lore raw

Re: [PATCH 2/3] ASoC: codecs: Add support for the Infineon PEB2466 codec

On Tue, 7 Feb 2023 22:17:39 +0100
Hi Christophe,

Quoted 128 lines · Christophe JAILLET

Le 06/02/2023 à 15:49, Herve Codina a écrit :

Quoted 12 lines

The Infineon PEB2466 codec is a programmable DSP-based four channels codec with filters capabilities.
It also provides signals as GPIOs.

---
  sound/soc/codecs/Kconfig   |   12 +
  sound/soc/codecs/Makefile  |    2 +
  sound/soc/codecs/peb2466.c | 2071 ++++++++++++++++++++++++++++++++++++
  3 files changed, 2085 insertions(+)

create mode 100644 sound/soc/codecs/peb2466.c

[...]

Quoted 19 lines
sound/soc/codecs/peb2466.c new file +19 -0
+static int peb2466_spi_probe(struct spi_device *spi)
+{
+	struct peb2466 *peb2466;
+	unsigned long mclk_rate;
+	int ret;
+	u8 xr5;
+
+	spi->bits_per_word = 8;
+	ret = spi_setup(spi);
+	if (ret < 0)
+		return ret;
+
+	peb2466 = devm_kzalloc(&spi->dev, sizeof(*peb2466), GFP_KERNEL);
+	if (!peb2466)
+		return -ENOMEM;
+
+	peb2466->spi = spi;
+
+	peb2466->regmap = devm_regmap_init(&peb2466->spi->dev, NULL, peb2466,

sound/soc/codecs/peb2466.c line 1978

Quoted 10 lines
sound/soc/codecs/peb2466.c new file +10 -0
+					   &peb2466_regmap_config);
+	if (IS_ERR(peb2466->regmap))
+		return PTR_ERR(peb2466->regmap);
+
+	peb2466->reset_gpio = devm_gpiod_get_optional(&peb2466->spi->dev,
+						      "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(peb2466->reset_gpio))
+		return PTR_ERR(peb2466->reset_gpio);
+
+	peb2466->mclk = devm_clk_get(&peb2466->spi->dev, "mclk");  

Hi,

Up to you to decide if it is a good idea or not, but using devm_clk_get_enabled() would save the 'mclk' field in peb2466 ...

sound/soc/codecs/peb2466.c line 1983

Quoted 5 lines
sound/soc/codecs/peb2466.c new file +5 -0
+	if (IS_ERR(peb2466->mclk))
+		return PTR_ERR(peb2466->mclk);
+	ret = clk_prepare_enable(peb2466->mclk);
+	if (ret)
+		return ret;  

... these 3 lines ...

sound/soc/codecs/peb2466.c line 1992

Quoted 9 lines
sound/soc/codecs/peb2466.c new file +9 -0
+
+	if (peb2466->reset_gpio) {
+		gpiod_set_value_cansleep(peb2466->reset_gpio, 1);
+		udelay(4);
+		gpiod_set_value_cansleep(peb2466->reset_gpio, 0);
+		udelay(4);
+	}
+
+	spi_set_drvdata(spi, peb2466);  

... this spi_set_drvdata() call ...

Quoted 33 lines
sound/soc/codecs/peb2466.c new file +33 -0
+
+	mclk_rate = clk_get_rate(peb2466->mclk);
+	switch (mclk_rate) {
+	case 1536000:
+		xr5 = PEB2466_XR5_MCLK_1536;
+		break;
+	case 2048000:
+		xr5 = PEB2466_XR5_MCLK_2048;
+		break;
+	case 4096000:
+		xr5 = PEB2466_XR5_MCLK_4096;
+		break;
+	case 8192000:
+		xr5 = PEB2466_XR5_MCLK_8192;
+		break;
+	default:
+		dev_err(&peb2466->spi->dev, "Unsupported clock rate %lu\n",
+			mclk_rate);
+		ret = -EINVAL;
+		goto failed;
+	}
+	ret = regmap_write(peb2466->regmap, PEB2466_XR5, xr5);
+	if (ret) {
+		dev_err(&peb2466->spi->dev, "Setting MCLK failed (%d)\n", ret);
+		goto failed;
+	}
+
+	ret = devm_snd_soc_register_component(&spi->dev, &peb2466_component_driver,
+					      &peb2466_dai_driver, 1);
+	if (ret)
+		goto failed;
+
+	if (IS_ENABLED(CONFIG_GPIOLIB)) {

sound/soc/codecs/peb2466.c line 2035

Quoted 10 lines
sound/soc/codecs/peb2466.c new file +10 -0
+		ret = peb2466_gpio_init(peb2466);
+		if (ret)
+			goto failed;
+	}
+
+	return 0;
+
+failed:
+	clk_disable_unprepare(peb2466->mclk);
+	return ret;  

... this error handling path ...

sound/soc/codecs/peb2466.c line 2043

Quoted 8 lines
sound/soc/codecs/peb2466.c new file +8 -0
+}
+
+static void peb2466_spi_remove(struct spi_device *spi)
+{
+	struct peb2466 *peb2466 = spi_get_drvdata(spi);
+
+	clk_disable_unprepare(peb2466->mclk);
+}  

... and the remove function.

Quoted 2 lines

CJ

Thanks for pointing this.
I will use devm_clk_get_enabled() in the next series iteration as suggested.

Best regards,
Hervé

Signature · 3 lines
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author maintainer
#6 lore raw

PATCH 3/3 MAINTAINERS: add the Infineon PEB2466 codec entry

In reply to Herve Codina

After contributing the driver, add myself as the maintainer for the Infineon PEB2466 codec.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index cd22e8e06561..0cd8a4d1f7b0 100644
@@ -10184,6 +10184,13 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/iio/pressure/dps310.c
 
+INFINEON PEB2466 ASoC CODEC
+M:	Herve Codina <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/sound/infineon,peb2466.yaml
+F:	sound/soc/codecs/peb2466.c
+
 INFINIBAND SUBSYSTEM
 M:	Jason Gunthorpe <[email protected]>
 M:	Leon Romanovsky <[email protected]>
Signature · 1 line
2.39.1
maintainer
#7 lore raw
In reply to Herve Codina
Quoted 8 lines · Herve Codina

The Infineon PEB2466 codec is a programmable DSP-based four channels codec with filters capabilities.
It also provides signals as GPIOs.

Best regards,
Herve Codina

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] dt-bindings: sound: Add the Infineon PEB2466 codec

      commit: 4c03e952ad8688a28aed9b72fc48291240707c7d
[2/3] ASoC: codecs: Add support for the Infineon PEB2466 codec
      commit: 227f609c7c0e44f2103a8406ff9379ee1de3bc28
[3/3] MAINTAINERS: add the Infineon PEB2466 codec entry
      commit: 564972dbf85c0900521e6273b772fd7f0b720dd7

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