Skip to contentSkip to conversation

Add the Renesas IDT821034 codec support

PATCH Superseded Herve Codina 3 participants 12 messages Jan 11, 2023 – Jan 13, 2023

Subsystems (5)
Device tree bindings Sound ASoC GPIO +1 more subsystems

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Herve Codina

author maintainer
#0 lore raw

cover Add the Renesas IDT821034 codec support

Hi,

The Renesas IDT821034 codec is four channel PCM codec with on-chip filters and programmable gain setting.
It also provides SLIC (Subscriber Line Interface Circuit) signals as GPIOs.

Best regards,
Herve Codina

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

 .../bindings/sound/renesas,idt821034.yaml     |   97 ++
 MAINTAINERS                                   |    7 +
 sound/soc/codecs/Kconfig                      |   12 +
 sound/soc/codecs/Makefile                     |    2 +
 sound/soc/codecs/idt821034.c                  | 1234 +++++++++++++++++
 5 files changed, 1352 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/renesas,idt821034.yaml
 create mode 100644 sound/soc/codecs/idt821034.c
Signature · 1 line
2.38.1
author maintainer
#1 lore raw

PATCH 1/3 dt-bindings: sound: Add Renesas IDT821034 codec

The Renesas IDT821034 codec is a quad PCM codec with programmable gain.

---
 .../bindings/sound/renesas,idt821034.yaml     | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/renesas,idt821034.yaml
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +97 -0
new file mode 100644
index 000000000000..2c29b770e3f7
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/renesas,idt821034.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas IDT821034 codec device
+
+maintainers:
+  - Herve Codina <[email protected]>
+
+description: |
+  The IDT821034 codec is a four channel PCM codec with onchip filters and
+  programmable gain setting.
+
+  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 ALSA 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 IDT821034 codec also supports 5 gpios (SLIC signals) per channel.
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+  - $ref: /schemas/gpio/gpio.yaml#
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: renesas,idt821034
+
+  reg:
+    description:
+      SPI device address.
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 8192000
+
+  spi-cpha: true
+
+  '#sound-dai-cells':
+    const: 0
+
+  '#gpio-cells':
+    const: 2
+
+  gpio-controller: true
+
+required:
+  - compatible
+  - reg
+  - spi-cpha
+  - '#sound-dai-cells'
+  - gpio-controller
+  - '#gpio-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    spi0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        codec: idt821034@0 {
+            compatible = "renesas,idt821034";
+            reg = <0>;
+            spi-max-frequency = <8192000>;
+            spi-cpha;
+            #sound-dai-cells = <0>;
+            gpio-controller;
+            #gpio-cells = <2>;
+        };
+    };
+    sound {
+        compatible = "simple-audio-card";
+        #address-cells = <1>;
+        #size-cells = <0>;
+        simple-audio-card,dai-link@0 {
+            reg = <0>;
+            format = "dsp_b";
+            cpu {
+                sound-dai = <&cpu_dai>;
+            };
+            codec {
+                sound-dai = <&codec>;
+                dai-tdm-slot-num = <4>;
+                dai-tdm-slot-width = <8>;
+                /* TS 2, 3, 5, 7 */
+                dai-tdm-slot-tx-mask = <0 0 1 1 0 1 0 1>;
+                dai-tdm-slot-rx-mask = <0 0 1 1 0 1 0 1>;
+            };
+        };
+    };
Signature · 1 line
2.38.1
author maintainer
#4 lore raw

PATCH 2/3 ASoC: codecs: Add support for the Renesas IDT821034 codec

In reply to Herve Codina

The Renesas IDT821034 codec is four channel PCM codec with on-chip filters and programmable gain setting.
It also provides SLIC (Subscriber Line Interface Circuit) signals as GPIOs.

---
 sound/soc/codecs/Kconfig     |   12 +
 sound/soc/codecs/Makefile    |    2 +
 sound/soc/codecs/idt821034.c | 1234 ++++++++++++++++++++++++++++++++++
 3 files changed, 1248 insertions(+)
 create mode 100644 sound/soc/codecs/idt821034.c
sound/soc/codecs/Kconfig +12 -0
index 0f9d71490075..67489b2ebd9f 100644
@@ -107,6 +107,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_HDAC_HDMI
 	imply SND_SOC_HDAC_HDA
 	imply SND_SOC_ICS43432
+	imply SND_SOC_IDT821034
 	imply SND_SOC_INNO_RK3036
 	imply SND_SOC_ISABELLE
 	imply SND_SOC_JZ4740_CODEC
@@ -972,6 +973,17 @@ config SND_SOC_HDA
 config SND_SOC_ICS43432
 	tristate "ICS43423 and compatible i2s microphones"
 
+config SND_SOC_IDT821034
+	tristate "Renesas IDT821034 quad PCM codec"
+	depends on SPI
+	select REGMAP_SPI
+	help
+	  Enable support for the Renesas IDT821034 quad PCM with
+	  programmable gain codec.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-soc-idt821034.
+
 config SND_SOC_INNO_RK3036
 	tristate "Inno codec driver for RK3036 SoC"
 	select REGMAP_MMIO
sound/soc/codecs/Makefile +2 -0
index 71d3ce5867e4..bcf95de654fd 100644
@@ -111,6 +111,7 @@ snd-soc-hdac-hdmi-objs := hdac_hdmi.o
 snd-soc-hdac-hda-objs := hdac_hda.o
 snd-soc-hda-codec-objs := hda.o hda-dai.o
 snd-soc-ics43432-objs := ics43432.o
+snd-soc-idt821034-objs := idt821034.o
 snd-soc-inno-rk3036-objs := inno_rk3036.o
 snd-soc-isabelle-objs := isabelle.o
 snd-soc-jz4740-codec-objs := jz4740.o
@@ -472,6 +473,7 @@ obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-soc-hdac-hdmi.o
 obj-$(CONFIG_SND_SOC_HDAC_HDA) += snd-soc-hdac-hda.o
 obj-$(CONFIG_SND_SOC_HDA) += snd-soc-hda-codec.o
 obj-$(CONFIG_SND_SOC_ICS43432)	+= snd-soc-ics43432.o
+obj-$(CONFIG_SND_SOC_IDT821034)	+= snd-soc-idt821034.o
 obj-$(CONFIG_SND_SOC_INNO_RK3036)	+= snd-soc-inno-rk3036.o
 obj-$(CONFIG_SND_SOC_ISABELLE)	+= snd-soc-isabelle.o
 obj-$(CONFIG_SND_SOC_JZ4740_CODEC)	+= snd-soc-jz4740-codec.o
sound/soc/codecs/idt821034.c new file +1234 -0

1,234 lines not on this page · raw message

Signature · 1 line
2.38.1
author maintainer
#11 lore raw

PATCH 3/3 MAINTAINERS: add the Renesas IDT821034 codec entry

In reply to Herve Codina

After contributing the driver, add myself as the maintainer for the Renesas IDT821034 codec.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 9dcfadec5aa3..31115a7e01c1 100644
@@ -17809,6 +17809,13 @@ F:	Documentation/devicetree/bindings/net/renesas,*.yaml
 F:	drivers/net/ethernet/renesas/
 F:	include/linux/sh_eth.h
 
+RENESAS IDT821034 ASoC CODEC
+M:	Herve Codina <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/sound/renesas,idt821034.yaml
+F:	sound/soc/codecs/idt821034.c
+
 RENESAS R-CAR GYROADC DRIVER
 M:	Marek Vasut <[email protected]>
 L:	[email protected]
Signature · 1 line
2.38.1
maintainer
#5 lore raw

Re: [PATCH 2/3] ASoC: codecs: Add support for the Renesas IDT821034 codec

In reply to Herve Codina

sound/soc/codecs/idt821034.c line 3

Quoted 5 lines · Herve Codina

+++ b/sound/soc/codecs/idt821034.c

sound/soc/codecs/idt821034.c new file +3 -0
@@ -0,0 +1,1234 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * IDT821034 ALSA SoC driver

Please make the entire comment a C++ one so things look more intentional.

Quoted 9 lines
sound/soc/codecs/idt821034.c new file +9 -0
+static int idt821034_8bit_write(struct idt821034 *idt821034, u8 val)
+{
+	struct spi_transfer xfer[] = {
+		{
+			.tx_buf = &idt821034->spi_tx_buf,
+			.len = 1,
+		}, {
+			.cs_off = 1,
+			.tx_buf = &idt821034->spi_tx_buf,

sound/soc/codecs/idt821034.c line 59

Quoted 10 lines
sound/soc/codecs/idt821034.c new file +10 -0
+			.len = 1,
+		}
+	};
+	int ret;
+
+	idt821034->spi_tx_buf = val;
+
+	dev_vdbg(&idt821034->spi->dev, "spi xfer wr 0x%x\n", val);
+
+	ret = spi_sync_transfer(idt821034->spi, xfer, 2);

Why is this open coding register I/O rather than using regmap?

Review line 23

Quoted 1 line
(quoted diff) +1 -0
+	conf = 0x80 | idt821034->cache.codec_conf | IDT821034_CONF_CHANNEL(ch);

regmap provides cache support too.

Quoted 4 lines
sound/soc/codecs/idt821034.c new file +4 -0
+static int idt821034_reg_write_gain(struct idt821034 *idt821034,
+				    unsigned int reg, unsigned int val)
+{
+	u16 gain_val;

sound/soc/codecs/idt821034.c line 521

Quoted 10 lines
sound/soc/codecs/idt821034.c new file +10 -0
+	u8 gain_type;
+	u8 ch;
+
+	ch = IDT821034_REGMAP_ADDR_GET_CH(reg);
+	gain_type = IDT821034_REGMAP_ADDR_IS_DIR_OUT(reg) ?
+			IDT821034_GAIN_RX : IDT821034_GAIN_TX;
+	gain_val = (val & 0x01) ? 0 : val >> 1;
+
+	return idt821034_set_gain_channel(idt821034, ch, gain_type, gain_val);
+}

So if the low bit of the gain is zero we just discard the value? This really needs some comments...

sound/soc/codecs/idt821034.c line 597

Quoted 10 lines
sound/soc/codecs/idt821034.c new file +10 -0
+static int idt821034_reg_write(void *context, unsigned int reg, unsigned int val)
+{
+	struct idt821034 *idt821034 = context;
+
+	dev_dbg(&idt821034->spi->dev, "reg_write(0x%x, 0x%x)\n", reg, val);
+
+	switch (IDT821034_REGMAP_ADDR_GET_TYPE(reg)) {
+	case IDT821034_REGMAP_ADDR_TYPE_GBLCONF:
+		return idt821034_reg_write_gblconf(idt821034, reg, val);
+

Oh, so there is some regmap stuff but it's not actually a regmap and is instead some virtual thing which rewrites all the values with no comments or anything explaining what's going on.... this all feels very confused. I would expect the regmap usage to be such that the regmap represents the physical device, any rewriting of the values or anything like that should be done on top of the regmap rather than underneath it.

Without knowing why things are written in this way or what it's trying to accomplish it's hard to comment in detail on what specifically should be done.

#2 lore raw

Re: [PATCH 1/3] dt-bindings: sound: Add Renesas IDT821034 codec

In reply to Herve Codina
Quoted 32 lines · Herve Codina

The Renesas IDT821034 codec is a quad PCM codec with programmable gain.

---
 .../bindings/sound/renesas,idt821034.yaml     | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/renesas,idt821034.yaml
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +17 -0
new file mode 100644
index 000000000000..2c29b770e3f7
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/renesas,idt821034.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas IDT821034 codec device
+
+maintainers:
+  - Herve Codina <[email protected]>
+
+description: |
+  The IDT821034 codec is a four channel PCM codec with onchip filters and
+  programmable gain setting.
+
+  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

Documentation/devicetree/bindings/sound/renesas,idt821034.yaml line 27

Quoted 10 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +10 -0
+  'dai-tdm-slot-rx-mask' must be present in the ALSA 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 IDT821034 codec also supports 5 gpios (SLIC signals) per channel.
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+  - $ref: /schemas/gpio/gpio.yaml#

This one is never needed. Drop.

Quoted 23 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +23 -0
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: renesas,idt821034
+
+  reg:
+    description:
+      SPI device address.
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 8192000
+
+  spi-cpha: true
+
+  '#sound-dai-cells':
+    const: 0
+
+  '#gpio-cells':
+    const: 2
+
+  gpio-controller: true

Documentation/devicetree/bindings/sound/renesas,idt821034.yaml line 60

Quoted 10 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +10 -0
+
+required:
+  - compatible
+  - reg
+  - spi-cpha
+  - '#sound-dai-cells'
+  - gpio-controller
+  - '#gpio-cells'
+
+additionalProperties: false

This should be rather unevaluatedProperties: false, so other properties from spi-props and dai-common will work.

Documentation/devicetree/bindings/sound/renesas,idt821034.yaml line 68

Quoted 8 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +8 -0
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    spi0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        codec: idt821034@0 {

Node names should be generic, so "audio-codec"
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Documentation/devicetree/bindings/sound/renesas,idt821034.yaml line 79

Quoted 11 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +11 -0
+            compatible = "renesas,idt821034";
+            reg = <0>;
+            spi-max-frequency = <8192000>;
+            spi-cpha;
+            #sound-dai-cells = <0>;
+            gpio-controller;
+            #gpio-cells = <2>;
+        };
+    };
+    sound {
+        compatible = "simple-audio-card";

Drop sound{} node. Not relevant to the case here and it's the same in every case of audio codec... unless something here is specific. But even the dai-tdm properties are sound card specific.

Best regards,
Krzysztof

author maintainer
#6 lore raw

Re: [PATCH 2/3] ASoC: codecs: Add support for the Renesas IDT821034 codec

In reply to Mark Brown

Hi Mark,

Quoted 10 lines · On Wed, 11 Jan 2023 14:09:45 +0000 Mark Brown <[email protected]> wrote:

sound/soc/codecs/idt821034.c line 3

Quoted 5 lines · Herve Codina

+++ b/sound/soc/codecs/idt821034.c

sound/soc/codecs/idt821034.c new file +3 -0
@@ -0,0 +1,1234 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * IDT821034 ALSA SoC driver  

Please make the entire comment a C++ one so things look more intentional.

Ok, I will change in v2.

Quoted 63 lines
Quoted 10 lines
sound/soc/codecs/idt821034.c new file +9 -0
+static int idt821034_8bit_write(struct idt821034 *idt821034, u8 val)
+{
+	struct spi_transfer xfer[] = {
+		{
+			.tx_buf = &idt821034->spi_tx_buf,
+			.len = 1,
+		}, {
+			.cs_off = 1,
+			.tx_buf = &idt821034->spi_tx_buf,

sound/soc/codecs/idt821034.c line 59

Quoted 10 lines
sound/soc/codecs/idt821034.c new file +10 -0
+			.len = 1,
+		}
+	};
+	int ret;
+
+	idt821034->spi_tx_buf = val;
+
+	dev_vdbg(&idt821034->spi->dev, "spi xfer wr 0x%x\n", val);
+
+	ret = spi_sync_transfer(idt821034->spi, xfer, 2);  

Why is this open coding register I/O rather than using regmap?

Review line 23

Quoted 1 line
(quoted diff) +1 -0
+	conf = 0x80 | idt821034->cache.codec_conf | IDT821034_CONF_CHANNEL(ch);  

regmap provides cache support too.

Quoted 4 lines
sound/soc/codecs/idt821034.c new file +4 -0
+static int idt821034_reg_write_gain(struct idt821034 *idt821034,
+				    unsigned int reg, unsigned int val)
+{
+	u16 gain_val;

sound/soc/codecs/idt821034.c line 521

Quoted 10 lines
sound/soc/codecs/idt821034.c new file +10 -0
+	u8 gain_type;
+	u8 ch;
+
+	ch = IDT821034_REGMAP_ADDR_GET_CH(reg);
+	gain_type = IDT821034_REGMAP_ADDR_IS_DIR_OUT(reg) ?
+			IDT821034_GAIN_RX : IDT821034_GAIN_TX;
+	gain_val = (val & 0x01) ? 0 : val >> 1;
+
+	return idt821034_set_gain_channel(idt821034, ch, gain_type, gain_val);
+}  

So if the low bit of the gain is zero we just discard the value? This really needs some comments...

sound/soc/codecs/idt821034.c line 597

Quoted 10 lines
sound/soc/codecs/idt821034.c new file +10 -0
+static int idt821034_reg_write(void *context, unsigned int reg, unsigned int val)
+{
+	struct idt821034 *idt821034 = context;
+
+	dev_dbg(&idt821034->spi->dev, "reg_write(0x%x, 0x%x)\n", reg, val);
+
+	switch (IDT821034_REGMAP_ADDR_GET_TYPE(reg)) {
+	case IDT821034_REGMAP_ADDR_TYPE_GBLCONF:
+		return idt821034_reg_write_gblconf(idt821034, reg, val);
+  

Oh, so there is some regmap stuff but it's not actually a regmap and is instead some virtual thing which rewrites all the values with no comments or anything explaining what's going on.... this all feels very confused. I would expect the regmap usage to be such that the regmap represents the physical device, any rewriting of the values or anything like that should be done on top of the regmap rather than underneath it.

Quoted 3 lines

Without knowing why things are written in this way or what it's trying to accomplish it's hard to comment in detail on what specifically should be done.

Yes, I use regmap to ease the integration of controls and use the already defined controls macros but the device registers do not fit well with regmap.

The device registers are not defined as simple as address/value pairs. Accesses contains one or more bytes and the signification of the data (and bytes) depends on the first bits.
- 0b10xxxxxx means 'Control register' with some data as xxxxxx and one extra byte
- 0b1101yyyy means 'Configuration register, slic mode' with some other data as yyyy and one extra byte
- 0b1100zzzz means 'Configuration register, gain mode' with some other data as zzzz and two extra bytes

The datasheet is available at
https://www.renesas.com/us/en/document/dst/821034-data-sheet

This does not fit well for a regmap usage.

So I wrote some low-level access functions to handle this protocol and use some kind of "virtual registers" to map this protocol to regmap and use them in controls.

The "virtual registers" were defined to match what I need.

For instance, idt821034_reg_write_gain() is the regmap write access for one of the gain "virtual register". The mapping of this virtual register is:

   |15          1|0|
   | Gain value  |M|

With M for Mute flag.

The gain value is not discarded as it is available in the regmap cache.
For the low-level access, I write the 'Gain Value' or 0 if the mute flag was set.

In some low level accesses, I need save some data (cache) in order to be able to use them later for an other access. For instance when a channel is powered-on, a timeslot need to be present in the bytes sent.

Of course, I can describe all of these in details. Where do you want to have this information ? All at the top of the file ? Each part (low-level, virtual regs, ...) at the beginning of each part in the code ?

Best regards,
Hervé

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

Re: [PATCH 1/3] dt-bindings: sound: Add Renesas IDT821034 codec

In reply to Krzysztof Kozlowski
Quoted 37 lines · On Wed, 11 Jan 2023 17:28:11 +0100 Krzysztof Kozlowski…
Quoted 36 lines · Herve Codina

The Renesas IDT821034 codec is a quad PCM codec with programmable gain.

---
 .../bindings/sound/renesas,idt821034.yaml     | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/renesas,idt821034.yaml
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +21 -0
new file mode 100644
index 000000000000..2c29b770e3f7
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/renesas,idt821034.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas IDT821034 codec device
+
+maintainers:
+  - Herve Codina <[email protected]>
+
+description: |
+  The IDT821034 codec is a four channel PCM codec with onchip filters and
+  programmable gain setting.
+
+  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 ALSA 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.
Quoted 8 lines

Documentation/devicetree/bindings/sound/renesas,idt821034.yaml line 27

Quoted 6 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +6 -0
+
+  The IDT821034 codec also supports 5 gpios (SLIC signals) per channel.
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+  - $ref: /schemas/gpio/gpio.yaml#  

This one is never needed. Drop.

Ok, I will drop it in v2.

Quoted 29 lines
Quoted 29 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +28 -0
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: renesas,idt821034
+
+  reg:
+    description:
+      SPI device address.
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 8192000
+
+  spi-cpha: true
+
+  '#sound-dai-cells':
+    const: 0
+
+  '#gpio-cells':
+    const: 2
+
+  gpio-controller: true
+
+required:
+  - compatible
+  - reg
+  - spi-cpha
Quoted 8 lines

Documentation/devicetree/bindings/sound/renesas,idt821034.yaml line 60

Quoted 5 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +5 -0
+  - '#sound-dai-cells'
+  - gpio-controller
+  - '#gpio-cells'
+
+additionalProperties: false  

This should be rather unevaluatedProperties: false, so other properties from spi-props and dai-common will work.

Ok, I will change in v2.

Quoted 25 lines

Documentation/devicetree/bindings/sound/renesas,idt821034.yaml line 68

Quoted 9 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +8 -0
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    spi0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        codec: idt821034@0 {  

Node names should be generic, so "audio-codec"
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Documentation/devicetree/bindings/sound/renesas,idt821034.yaml line 79

Quoted 11 lines
Documentation/devicetree/bindings/sound/renesas,idt821034.yaml new file +11 -0
+            compatible = "renesas,idt821034";
+            reg = <0>;
+            spi-max-frequency = <8192000>;
+            spi-cpha;
+            #sound-dai-cells = <0>;
+            gpio-controller;
+            #gpio-cells = <2>;
+        };
+    };
+    sound {
+        compatible = "simple-audio-card";  
Quoted 3 lines

Drop sound{} node. Not relevant to the case here and it's the same in every case of audio codec... unless something here is specific. But even the dai-tdm properties are sound card specific.

Indeed, I wanted to show the dai-tdm properties.
But ok, I will drop the node.

Quoted 5 lines

Best regards,
Krzysztof

Thanks for the review.

Best regards,
Hervé

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

Re: [PATCH 2/3] ASoC: codecs: Add support for the Renesas IDT821034 codec

In reply to Herve Codina
Quoted 10 lines · Herve Codina
Quoted 5 lines · Mark Brown

On Wed, Jan 11, 2023 at 02:49:04PM +0100, Herve Codina wrote:

Without knowing why things are written in this way or what it's trying to accomplish it's hard to comment in detail on what specifically should be done.

Yes, I use regmap to ease the integration of controls and use the already defined controls macros but the device registers do not fit well with regmap.

If this doesn't fit into regmap then don't try to shoehorn it into regmap, that just makes it incredibly hard to follow what's going on.

Quoted 9 lines

The device registers are not defined as simple as address/value pairs. Accesses contains one or more bytes and the signification of the data (and bytes) depends on the first bits.
- 0b10xxxxxx means 'Control register' with some data as xxxxxx and one extra byte
- 0b1101yyyy means 'Configuration register, slic mode' with some other data as yyyy and one extra byte
- 0b1100zzzz means 'Configuration register, gain mode' with some other data as zzzz and two extra bytes

So really the device only has three registers, each of different sizes and windowed fields within those registers? I love innovation, innovation is great and it's good that our hardware design colleagues work so hard to keep us in jobs. It seems hardly worth it to treat them as registers TBH. This is so far off a register/value type thing that I just wouldn't even try.

Quoted 4 lines

Of course, I can describe all of these in details. Where do you want to have this information ? All at the top of the file ? Each part (low-level, virtual regs, ...) at the beginning of each part in the code ?

I'm not sure what problem it solves to use regmap or have virtual registers in the first place. I think you would be better off with custom _EXT controls, you almost have that anway just hidden in the middle of the fake register stuff instead of directly there. My sense is that the result would be much less code. If you are trying to map things onto registers you probably want comments at every level since you don't know where people are going to end up jumping into the code.

Perhaps it's possible to write some new SND_SOC_ helpers that work with just a value in the device's driver data rather than a regmap and have a callback to trigger a write to the device? I suspect that'd be generally useful actually...

author maintainer
#8 lore raw

Re: [PATCH 2/3] ASoC: codecs: Add support for the Renesas IDT821034 codec

Hi Mark,

Quoted 45 lines · On Wed, 11 Jan 2023 17:57:01 +0000 Mark Brown <[email protected]> wrote:
Quoted 10 lines · Herve Codina
Quoted 5 lines · Mark Brown

On Wed, Jan 11, 2023 at 02:49:04PM +0100, Herve Codina wrote:

Without knowing why things are written in this way or what it's trying to accomplish it's hard to comment in detail on what specifically should be done.

Yes, I use regmap to ease the integration of controls and use the already defined controls macros but the device registers do not fit well with regmap.

If this doesn't fit into regmap then don't try to shoehorn it into regmap, that just makes it incredibly hard to follow what's going on.

Quoted 9 lines

The device registers are not defined as simple as address/value pairs. Accesses contains one or more bytes and the signification of the data (and bytes) depends on the first bits.
- 0b10xxxxxx means 'Control register' with some data as xxxxxx and one extra byte
- 0b1101yyyy means 'Configuration register, slic mode' with some other data as yyyy and one extra byte
- 0b1100zzzz means 'Configuration register, gain mode' with some other data as zzzz and two extra bytes

So really the device only has three registers, each of different sizes and windowed fields within those registers? I love innovation, innovation is great and it's good that our hardware design colleagues work so hard to keep us in jobs. It seems hardly worth it to treat them as registers TBH. This is so far off a register/value type thing that I just wouldn't even try.

Quoted 4 lines

Of course, I can describe all of these in details. Where do you want to have this information ? All at the top of the file ? Each part (low-level, virtual regs, ...) at the beginning of each part in the code ?

I'm not sure what problem it solves to use regmap or have virtual registers in the first place. I think you would be better off with custom _EXT controls, you almost have that anway just hidden in the middle of the fake register stuff instead of directly there. My sense is that the result would be much less code. If you are trying to map things onto registers you probably want comments at every level since you don't know where people are going to end up jumping into the code.

Quoted 4 lines

Perhaps it's possible to write some new SND_SOC_ helpers that work with just a value in the device's driver data rather than a regmap and have a callback to trigger a write to the device? I suspect that'd be generally useful actually...

Well, I wil try to use my own .put() and .get() for snd_controls.

For DAPM (struct snd_soc_dapm_widget), no kind of .put() and .get() are available. I will use some Ids for the 'reg' value and use the .write() and .read() hooks available in struct snd_soc_component_driver in order to handle these Ids and so perform the accesses.

Do you think this can be the right way (at least for a first try) ?

Best regards,
Hervé

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

Re: [PATCH 2/3] ASoC: codecs: Add support for the Renesas IDT821034 codec

Quoted 4 lines · Herve Codina

For DAPM (struct snd_soc_dapm_widget), no kind of .put() and .get() are available. I will use some Ids for the 'reg' value and use the .write() and .read() hooks available in struct snd_soc_component_driver in order to handle these Ids and so perform the accesses.

That's what the event hooks are for - there's plenty of widgets using SND_SOC_NOPM as the register, look at those for examples.

author maintainer
#10 lore raw

Re: [PATCH 2/3] ASoC: codecs: Add support for the Renesas IDT821034 codec

Hi Mark,

Quoted 9 lines · On Fri, 13 Jan 2023 12:59:59 +0000 Mark Brown <[email protected]> wrote:
Quoted 4 lines · Herve Codina

For DAPM (struct snd_soc_dapm_widget), no kind of .put() and .get() are available. I will use some Ids for the 'reg' value and use the .write() and .read() hooks available in struct snd_soc_component_driver in order to handle these Ids and so perform the accesses.

That's what the event hooks are for - there's plenty of widgets using SND_SOC_NOPM as the register, look at those for examples.

Indeed, got it.
Thanks for pointing it.

Best regards,
Hervé

Signature · 3 lines
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com