Skip to contentSkip to conversation

ASoC: max98363: add soundwire amplifier driver

PATCH Superseded “Ryan 3 participants 4 messages Mar 23, 2023 – Mar 30, 2023

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

“Ryan

author
#0 lore raw

PATCH v3 1/2 ASoC: max98363: add soundwire amplifier driver

From: Ryan Lee <[email protected]>

Added Analog Devices MAX98363 SoundWire Amplifier Driver. The MAX98363 is a SoundWire peripheral device that supports MIPI SoundWire v1.2-compatible digital interface for audio and control data.

---
Changes from v1:
Removed the standard SoundWire registers from the amp register table. Removed .of_match_table and .acpi_match_table.
Removed vdd/dvddio control.
Removed unnecessary source port control in .read_prop. Removed legacy from I2S driver not used for SoundWire driver. Removed .shutdown, .bus_config, and unused functions. Sorted include files in alphabetical order.
Changes from v2:
Changed .channels_max from 2 to 1.
stream_config.ch_count is limited to .channels_max. Removed unused variables. rx_mask and slot from max98363_priv.

 sound/soc/codecs/Kconfig    |  11 +
 sound/soc/codecs/Makefile   |   2 +
 sound/soc/codecs/max98363.c | 464 ++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/max98363.h |  36 +++
 4 files changed, 513 insertions(+)
 create mode 100644 sound/soc/codecs/max98363.c
 create mode 100644 sound/soc/codecs/max98363.h
sound/soc/codecs/Kconfig +11 -0
index 03630d13d35f..4062fe3fbb1c 100644
@@ -133,6 +133,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_MAX98925
 	imply SND_SOC_MAX98926
 	imply SND_SOC_MAX98927
+	imply SND_SOC_MAX98363
 	imply SND_SOC_MAX98373_I2C
 	imply SND_SOC_MAX98373_SDW
 	imply SND_SOC_MAX98390
@@ -1133,6 +1134,16 @@ config SND_SOC_MAX98520
 
 	  To compile this driver as a module, choose M here.
 
+config SND_SOC_MAX98363
+	tristate "Analog Devices MAX98363 Soundwire Speaker Amplifier"
+	depends on SOUNDWIRE
+	select REGMAP_SOUNDWIRE
+	help
+	  Enable support for Analog Devices MAX98363 Soundwire
+	  amplifier. MAX98363 supports the MIPI SoundWire v1.2
+	  compatible interface for audio and control data.
+	  This amplifier does not support I2C and I2S.
+
 config SND_SOC_MAX98373
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 25ebce58a0ba..44ea747579fd 100644
@@ -148,6 +148,7 @@ snd-soc-max98925-objs := max98925.o
 snd-soc-max98926-objs := max98926.o
 snd-soc-max98927-objs := max98927.o
 snd-soc-max98520-objs := max98520.o
+snd-soc-max98363-objs := max98363.o
 snd-soc-max98373-objs := max98373.o
 snd-soc-max98373-i2c-objs := max98373-i2c.o
 snd-soc-max98373-sdw-objs := max98373-sdw.o
@@ -515,6 +516,7 @@ obj-$(CONFIG_SND_SOC_MAX98925)	+= snd-soc-max98925.o
 obj-$(CONFIG_SND_SOC_MAX98926)	+= snd-soc-max98926.o
 obj-$(CONFIG_SND_SOC_MAX98927)	+= snd-soc-max98927.o
 obj-$(CONFIG_SND_SOC_MAX98520)	+= snd-soc-max98520.o
+obj-$(CONFIG_SND_SOC_MAX98363)	+= snd-soc-max98363.o
 obj-$(CONFIG_SND_SOC_MAX98373)	+= snd-soc-max98373.o
 obj-$(CONFIG_SND_SOC_MAX98373_I2C)   += snd-soc-max98373-i2c.o
 obj-$(CONFIG_SND_SOC_MAX98373_SDW)   += snd-soc-max98373-sdw.o
sound/soc/codecs/max98363.c new file +464 -0

464 lines not on this page · raw message

sound/soc/codecs/max98363.h new file +36 -0
new file mode 100644
index 000000000000..2b6743d3a2cf
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2022 Analog Devices Inc. */
+
+#ifndef _MAX98363_H
+#define _MAX98363_H
+
+#define MAX98363_R2000_SW_RESET			0x2000
+#define MAX98363_R2001_INTR_RAW			0x2001
+#define MAX98363_R2003_INTR_STATE		0x2003
+#define MAX98363_R2005_INTR_FALG		0x2005
+#define MAX98363_R2007_INTR_EN			0x2007
+#define MAX98363_R2009_INTR_CLR			0x2009
+#define MAX98363_R2021_ERR_MON_CTRL		0x2021
+#define MAX98363_R2022_SPK_MON_THRESH		0x2022
+#define MAX98363_R2023_SPK_MON_DURATION		0x2023
+#define MAX98363_R2030_TONE_GEN_CFG		0x2030
+#define MAX98363_R203F_TONE_GEN_EN		0x203F
+#define MAX98363_R2040_AMP_VOL			0x2040
+#define MAX98363_R2041_AMP_GAIN			0x2041
+#define MAX98363_R2042_DSP_CFG			0x2042
+#define MAX98363_R21FF_REV_ID			0x21FF
+
+/* MAX98363_R2021_ERR_MON_CTRL */
+#define MAX98363_SPKMON_SHIFT			(3)
+#define MAX98363_CLOCK_MON_SHIFT		(0)
+
+/* MAX98363_R2042_DSP_CFG */
+#define MAX98363_AMP_DSP_CFG_RMP_SHIFT		(3)
+
+struct max98363_priv {
+	struct regmap *regmap;
+	struct sdw_slave *slave;
+	bool hw_init;
+	bool first_hw_init;
+};
+#endif
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 2/2 ASoC: dt-bindings: max98363: add soundwire amplifier

From: Ryan Lee <[email protected]>

This patch adds dt-bindings information for Analog Devices MAX98363 SoundWire Amplifier.

---
Changes from v1:
Fixed a syntax error for the 'dt_binding_check' build.
Removed unnecessary properties.
Added description about SoundWire device ID of MAX98363
Changes from v2:
Removed the legacy from i2c/i2s driver and added SoundWire device ID info. Added missing information about DAI.

 .../bindings/sound/adi,max98363.yaml          | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/adi,max98363.yaml
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +62 -0
new file mode 100644
index 000000000000..92352a23e1cb
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/adi,max98363.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices MAX98363 SoundWire Amplifier
+
+maintainers:
+  - Ryan Lee <[email protected]>
+
+description:
+  The MAX98363 is a SoundWire input Class D mono amplifier that
+  supports MIPI SoundWire v1.2-compatible digital interface for
+  audio and control data.
+  SoundWire peripheral device ID of MAX98363 is 0x3X019F836300
+  where X is the peripheral device unique ID decoded from pin.
+  It supports up to 10 peripheral devices(0x0 to 0x9).
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: sdw3019F836300
+
+  reg:
+    maxItems: 1
+
+  '#sound-dai-cells':
+    const: 0
+
+  sound-name-prefix: true
+
+required:
+  - compatible
+  - reg
+  - "#sound-dai-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    soundwire-controller@3250000 {
+        #address-cells = <2>;
+        #size-cells = <0>;
+        reg = <0x3250000 0x2000>;
+
+        speaker@0,0 {
+            compatible = "sdw3019F836300";
+            reg = <0 0>;
+            #sound-dai-cells = <0>;
+            sound-name-prefix = "Speaker Left";
+        };
+
+        speaker@0,1 {
+            compatible = "sdw3019F836300";
+            reg = <0 1>;
+            #sound-dai-cells = <0>;
+            sound-name-prefix = "Speaker Right";
+        };
+    };
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH V3 2/2] ASoC: dt-bindings: max98363: add soundwire amplifier

Quoted 4 lines · “Ryan

From: Ryan Lee <[email protected]>

This patch adds dt-bindings information for Analog Devices MAX98363 SoundWire Amplifier.

No improvements here. So reminding:

Do not use "This commit/patch", but imperative mood. See:
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95

Quoted 27 lines

---
Changes from v1:
Fixed a syntax error for the 'dt_binding_check' build.
Removed unnecessary properties.
Added description about SoundWire device ID of MAX98363
Changes from v2:
Removed the legacy from i2c/i2s driver and added SoundWire device ID info. Added missing information about DAI.

 .../bindings/sound/adi,max98363.yaml          | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/adi,max98363.yaml
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +6 -0
new file mode 100644
index 000000000000..92352a23e1cb
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/adi,max98363.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 16

Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +10 -0
+title: Analog Devices MAX98363 SoundWire Amplifier
+
+maintainers:
+  - Ryan Lee <[email protected]>
+
+description:
+  The MAX98363 is a SoundWire input Class D mono amplifier that
+  supports MIPI SoundWire v1.2-compatible digital interface for
+  audio and control data.
+  SoundWire peripheral device ID of MAX98363 is 0x3X019F836300

lowercase hex

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 25

Quoted 9 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +9 -0
+  where X is the peripheral device unique ID decoded from pin.
+  It supports up to 10 peripheral devices(0x0 to 0x9).
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: sdw3019F836300

lowercase hex (also in example)

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 33

Quoted 8 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +8 -0
+
+  reg:
+    maxItems: 1
+
+  '#sound-dai-cells':
+    const: 0
+
+  sound-name-prefix: true

Drop this.

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 40

Quoted 7 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +7 -0
+
+required:
+  - compatible
+  - reg
+  - "#sound-dai-cells"
+
+additionalProperties: false

Instead:
unevaluatedProperties: false

Best regards,
Krzysztof

#3 lore raw

RE: [PATCH V3 2/2] ASoC: dt-bindings: max98363: add soundwire amplifier

Quoted 23 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Friday, March 24, 2023 4:37 AM
To: “Ryan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lee, RyanS <[email protected]>
Subject: Re: [PATCH V3 2/2] ASoC: dt-bindings: max98363: add soundwire amplifier

[External]

Quoted 4 lines · “Ryan

From: Ryan Lee <[email protected]>

This patch adds dt-bindings information for Analog Devices MAX98363 SoundWire Amplifier.

Quoted 8 lines

No improvements here. So reminding:

Do not use "This commit/patch", but imperative mood. See:
https://urldefense.com/v3/__https://elixir.bootlin.com/linux/v5.17.1/sourc
e/Documentation/process/submitting- patches.rst*L95__;Iw!!A3Ni8CS0y2Y!45rMxtn89otlen5mjEOGMXoPQwnsl3p9 qtuTJR99QgKZDNdFOo-ufIWE2OeebHfJynGjhmC4y2fFPWtYaTwRKjXhfkE$

Thanks for the comment. I shall fix this and the rest.

Quoted 90 lines
Quoted 9 lines

---
Changes from v1:
Fixed a syntax error for the 'dt_binding_check' build. Removed unnecessary properties.
Added description about SoundWire device ID of MAX98363 Changes from
v2:
Removed the legacy from i2c/i2s driver and added SoundWire device ID

info.

Quoted 15 lines

Added missing information about DAI.

 .../bindings/sound/adi,max98363.yaml          | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/sound/adi,max98363.yaml

Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +0 -0
new file mode 100644
index 000000000000..92352a23e1cb

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 3

Quoted 3 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +3 -0
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
+---
+$id:

+https://urldefense.com/v3/__http://devicetree.org/schemas/sound/adi,m

Quoted 1 line

+ax98363.yaml*__;Iw!!A3Ni8CS0y2Y!45rMxtn89otlen5mjEOGMXoPQwnsl3p 9qtuTJ

Documentation/devicetree/bindings/sound/adi,max98363.yaml

Quoted 3 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +3 -0
+R99QgKZDNdFOo-ufIWE2OeebHfJynGjhmC4y2fFPWtYaTwRYaJNMro$
+$schema:
+https://urldefense.com/v3/__http://devicetree.org/meta-

schemas/core.y

Quoted 1 line

+aml*__;Iw!!A3Ni8CS0y2Y!45rMxtn89otlen5mjEOGMXoPQwnsl3p9qtuTJR99 QgKZDN

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 16

Quoted 12 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +12 -0
+dFOo-ufIWE2OeebHfJynGjhmC4y2fFPWtYaTwRTMn3208$
+
+title: Analog Devices MAX98363 SoundWire Amplifier
+
+maintainers:
+  - Ryan Lee <[email protected]>
+
+description:
+  The MAX98363 is a SoundWire input Class D mono amplifier that
+  supports MIPI SoundWire v1.2-compatible digital interface for
+  audio and control data.
+  SoundWire peripheral device ID of MAX98363 is 0x3X019F836300

lowercase hex

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 25

Quoted 9 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +9 -0
+  where X is the peripheral device unique ID decoded from pin.
+  It supports up to 10 peripheral devices(0x0 to 0x9).
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: sdw3019F836300

lowercase hex (also in example)

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 33

Quoted 8 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +8 -0
+
+  reg:
+    maxItems: 1
+
+  '#sound-dai-cells':
+    const: 0
+
+  sound-name-prefix: true

Drop this.

Documentation/devicetree/bindings/sound/adi,max98363.yaml line 40

Quoted 7 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +7 -0
+
+required:
+  - compatible
+  - reg
+  - "#sound-dai-cells"
+
+additionalProperties: false

Instead:
unevaluatedProperties: false

Best regards,
Krzysztof