Skip to contentSkip to conversation

dt-bindings: sound: add Microsemi ZL38060 binding

PATCH Superseded Sven Van Asbroeck 2 participants 5 messages Apr 16, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: sound: add Microsemi ZL38060 binding

Add devicetree binding for the Microsemi ZL38060 Connected Home Audio Processor.

---

Tree: v5.7-rc1

 .../devicetree/bindings/sound/zl38060.yaml    | 90 +++++++++++++++++++
 1 file changed, 90 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/zl38060.yaml
Documentation/devicetree/bindings/sound/zl38060.yaml new file +90 -0
new file mode 100644
index 000000000000..8e1976bee76b
@@ -0,0 +1,90 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/zl38060.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ZL38060 Connected Home Audio Processor from Microsemi.
+
+description: |
+  The ZL38060 is a "Connected Home Audio Processor" from Microsemi,
+  which consists of a Digital Signal Processor (DSP), several Digital
+  Audio Interfaces (DAIs), analog outputs, and a block of 14 GPIOs.
+
+maintainers:
+  - Jaroslav Kysela <[email protected]>
+  - Takashi Iwai <[email protected]>
+
+properties:
+  compatible:
+    const: mscc,zl38060
+
+  reg:
+    description:
+      SPI device address.
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 24000000
+
+  reset-gpios:
+    description:
+      A GPIO line handling reset of the chip. As the line is active low,
+      it should be marked GPIO_ACTIVE_LOW (see ../gpio/gpio.txt)
+    maxItems: 1
+
+  mscc,load-firmware:
+    description:
+      If present, the driver will attempt to load firmware into the chip via
+      the SPI interface.
+    type: boolean
+
+  '#gpio-cells':
+    const: 2
+
+  gpio-controller: true
+
+  '#sound-dai-cells':
+    const: 0
+
+  amp-en-gpios:
+    description:
+      An optional GPIO line which is active when the codec is playing back
+      audio. Can be used to control an external amplifier.
+    maxItems: 1
+
+  mscc,amp-startup-delay-ms:
+    description:
+      An optional delay between amp-en-gpio becoming active, and the start
+      of audio playback. In milliseconds.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+required:
+  - compatible
+  - reg
+  - '#gpio-cells'
+  - gpio-controller
+  - '#sound-dai-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    spi0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        codec: zl38060@0 {
+            gpio-controller;
+            #gpio-cells = <2>;
+            #sound-dai-cells = <0>;
+            compatible = "mscc,zl38060";
+            reg = <0>;
+            spi-max-frequency = <12000000>;
+            reset-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
+            amp-en-gpios = <&codec 3 GPIO_ACTIVE_HIGH>;
+            mscc,amp-startup-delay-ms = <12>;
+            mscc,load-firmware;
+        };
+    };
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 ASoC: Add initial ZL38060 driver

The ZL38060 is a "Connected Home Audio Processor" from Microsemi, which consists of a Digital Signal Processor (DSP), several Digital Audio Interfaces (DAIs), analog outputs, and a block of 14 GPIOs.

This driver supports only a tiny subset of the chip's functionality and possible configurations:
- bypass mode (whole dsp block is bypassed)
- chip's DAI routed directly to/from DACs and microphone
- chip's internal clock is driven by a 12 MHz external crystal
- chip's DAI connected to CPU is I2S, and bit + frame clock master

---

Tree: v5.7-rc1

 sound/soc/codecs/Kconfig   |  11 +
 sound/soc/codecs/Makefile  |   2 +
 sound/soc/codecs/zl38060.c | 643 +++++++++++++++++++++++++++++++++++++
 3 files changed, 656 insertions(+)
 create mode 100644 sound/soc/codecs/zl38060.c
sound/soc/codecs/Kconfig +11 -0
index e6a0c5d05fa5..7cb032757d32 100644
@@ -272,6 +272,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_WM9712
 	imply SND_SOC_WM9713
 	imply SND_SOC_WSA881X
+	imply SND_SOC_ZL38060
 	help
 	  Normally ASoC codec drivers are only built if a machine driver which
 	  uses them is also built since they are only usable with a machine
@@ -1642,6 +1643,16 @@ config SND_SOC_WSA881X
 	  This enables support for Qualcomm WSA8810/WSA8815 Class-D
 	  Smart Speaker Amplifier.
 
+config SND_SOC_ZL38060
+	tristate "Microsemi ZL38060 Connected Home Audio Processor"
+	depends on SPI_MASTER
+	select GPIOLIB
+	select REGMAP
+	help
+	  Support for ZL38060 Connected Home Audio Processor from Microsemi,
+	  which consists of a Digital Signal Processor (DSP), several Digital
+	  Audio Interfaces (DAIs), analog outputs, and a block of 14 GPIOs.
+
 config SND_SOC_ZX_AUD96P22
 	tristate "ZTE ZX AUD96P22 CODEC"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index 03533157cda6..a603532c7af5 100644
@@ -288,6 +288,7 @@ snd-soc-wm9712-objs := wm9712.o
 snd-soc-wm9713-objs := wm9713.o
 snd-soc-wm-hubs-objs := wm_hubs.o
 snd-soc-wsa881x-objs := wsa881x.o
+snd-soc-zl38060-objs := zl38060.o
 snd-soc-zx-aud96p22-objs := zx_aud96p22.o
 # Amp
 snd-soc-max9877-objs := max9877.o
@@ -588,6 +589,7 @@ obj-$(CONFIG_SND_SOC_WM9713)	+= snd-soc-wm9713.o
 obj-$(CONFIG_SND_SOC_WM_ADSP)	+= snd-soc-wm-adsp.o
 obj-$(CONFIG_SND_SOC_WM_HUBS)	+= snd-soc-wm-hubs.o
 obj-$(CONFIG_SND_SOC_WSA881X)	+= snd-soc-wsa881x.o
+obj-$(CONFIG_SND_SOC_ZL38060)	+= snd-soc-zl38060.o
 obj-$(CONFIG_SND_SOC_ZX_AUD96P22) += snd-soc-zx-aud96p22.o
 
 # Amp
sound/soc/codecs/zl38060.c new file +643 -0

643 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v1 2/2] ASoC: Add initial ZL38060 driver

sound/soc/codecs/zl38060.c line 4

Quoted 6 lines · Sven Van Asbroeck

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

sound/soc/codecs/zl38060.c new file +4 -0
@@ -0,0 +1,643 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Codec driver for Microsemi ZL38060 Connected Home Audio Processor.
+ *

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

sound/soc/codecs/zl38060.c line 199

Quoted 7 lines
sound/soc/codecs/zl38060.c new file +7 -0
+			err = zl38_fw_send_data(regmap, addr, rec->data, len);
+		} else if (len == 4) {
+			/* execution address ihex record */
+			err = zl38_fw_send_xaddr(regmap, rec->data);
+		} else
+			err = -EINVAL;
+		if (err)

If any part of an if/else has { } then all of them should.

sound/soc/codecs/zl38060.c line 318

Quoted 7 lines
sound/soc/codecs/zl38060.c new file +7 -0
+skip_setup:
+	if (priv->amp_en_gpio && tx) {
+		/* enable the external amplifier before playback starts */
+		gpiod_set_value_cansleep(priv->amp_en_gpio, 1);
+		if (priv->amp_startup_delay_ms)
+			msleep(priv->amp_startup_delay_ms);
+	}

This external amplifier support shouldn't be here, if there's other devices in the system then they will have their own drivers and the machine driver will take care of linking things together.

sound/soc/codecs/zl38060.c line 560

Quoted 10 lines
sound/soc/codecs/zl38060.c new file +10 -0
+	/* take chip out of reset, if a reset gpio is provided */
+	reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(reset_gpio))
+		return PTR_ERR(reset_gpio);
+	if (reset_gpio) {
+		/* according to the datasheet, chip needs 3ms for its digital
+		 * section to become stable.
+		 */
+		usleep_range(3000, 10000);
+	}

It would be better to explicitly put the chip into reset and then bring it out of reset if there's a GPIO, that way the chip is in a known state.

sound/soc/codecs/zl38060.c line 571

Quoted 4 lines
sound/soc/codecs/zl38060.c new file +4 -0
+	priv->regmap = devm_regmap_init(dev, &zl38_regmap_bus, spi,
+					&zl38_regmap_conf);
+	if (IS_ERR(priv->regmap))
+		return PTR_ERR(priv->regmap);

devm_regmap_init_spi()

sound/soc/codecs/zl38060.c line 577

Quoted 5 lines
sound/soc/codecs/zl38060.c new file +5 -0
+	if (device_property_present(dev, "mscc,load-firmware")) {
+		err = zl38_load_firmware(dev, priv->regmap);
+		if (err)
+			return err;
+	}

I'm assuming this is for the case where the device has a flash attached to the master SPI port I can see described on the web site and can boot off it - if that's the case I think it'd be clearer for the DT to explicitly say that rather than this indirected property.

#3 lore raw

Re: [PATCH v1 2/2] ASoC: Add initial ZL38060 driver

Thank you Mark for the constructive feedback !
A few follow-up questions below.

Quoted 10 lines · Mark Brown

sound/soc/codecs/zl38060.c line 4

Quoted 7 lines

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

sound/soc/codecs/zl38060.c new file +4 -0
@@ -0,0 +1,643 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Codec driver for Microsemi ZL38060 Connected Home Audio Processor.
+ *

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

The 'weird' combination of // SPDX and /* Description/copyright */ seems to be a kernel-wide standard (for C files, at least) ?

E.g.:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/wm9090.c?h=v5.7-rc1#n2
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/wm8904.c?h=v5.7-rc1#n2

Ok to keep?

Quoted 9 lines

sound/soc/codecs/zl38060.c line 318

Quoted 8 lines
sound/soc/codecs/zl38060.c new file +7 -0
+skip_setup:
+     if (priv->amp_en_gpio && tx) {
+             /* enable the external amplifier before playback starts */
+             gpiod_set_value_cansleep(priv->amp_en_gpio, 1);
+             if (priv->amp_startup_delay_ms)
+                     msleep(priv->amp_startup_delay_ms);
+     }
Quoted 3 lines

This external amplifier support shouldn't be here, if there's other devices in the system then they will have their own drivers and the machine driver will take care of linking things together.

In our application, the amp is a "dumb" class-D amp with a single enable line:
https://www.onsemi.com/pub/Collateral/FAB3103-D.pdf

I am not sure how I could make this more general. Could you point me to an example somewhere in the tree?

Quoted 7 lines

sound/soc/codecs/zl38060.c line 571

Quoted 5 lines
sound/soc/codecs/zl38060.c new file +4 -0
+     priv->regmap = devm_regmap_init(dev, &zl38_regmap_bus, spi,
+                                     &zl38_regmap_conf);
+     if (IS_ERR(priv->regmap))
+             return PTR_ERR(priv->regmap);

devm_regmap_init_spi()

I wish !! This chip has complex SPI addressing, using an "address" which:
- is variable length, depending on the page of the register being accessed;
- contains a field with the length of the data to follow.

Unfortunately, during firmware programming, multi-writes are mandatory (usually address header + 32 data bytes).

Implementing my own regmap_bus looked like the only way out.

maintainer
#4 lore raw

Re: [PATCH v1 2/2] ASoC: Add initial ZL38060 driver

Quoted 11 lines · Sven Van Asbroeck
Quoted 8 lines · Mark Brown

sound/soc/codecs/zl38060.c line 4

Quoted 5 lines
sound/soc/codecs/zl38060.c new file +4 -0
@@ -0,0 +1,643 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Codec driver for Microsemi ZL38060 Connected Home Audio Processor.
+ *

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

Quoted 8 lines

The 'weird' combination of // SPDX and /* Description/copyright */ seems to be a kernel-wide standard (for C files, at least) ?

E.g.:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/wm9090.c?h=v5.7-rc1#n2
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/wm8904.c?h=v5.7-rc1#n2

Ok to keep?

Those were all automatically converted, one of these days I might get round to updating them :/

Quoted 9 lines
Quoted 3 lines

This external amplifier support shouldn't be here, if there's other devices in the system then they will have their own drivers and the machine driver will take care of linking things together.

In our application, the amp is a "dumb" class-D amp with a single enable line:
https://www.onsemi.com/pub/Collateral/FAB3103-D.pdf

I am not sure how I could make this more general. Could you point me to an example somewhere in the tree?

Look for GPIOs in machine drivers, there's quite a lot of examples (eg, rx51 has a speaker amp although it's not the most modern).

Quoted 10 lines
Quoted 6 lines

sound/soc/codecs/zl38060.c line 571

Quoted 4 lines
sound/soc/codecs/zl38060.c new file +4 -0
+     priv->regmap = devm_regmap_init(dev, &zl38_regmap_bus, spi,
+                                     &zl38_regmap_conf);
+     if (IS_ERR(priv->regmap))
+             return PTR_ERR(priv->regmap);

devm_regmap_init_spi()

I wish !! This chip has complex SPI addressing, using an "address" which:
- is variable length, depending on the page of the register being accessed;
- contains a field with the length of the data to follow.

OK.