Skip to contentSkip to conversation

ASoC: dt-bindings: max98388: add amplifier driver

PATCH Superseded “Ryan 4 participants 5 messages Jun 8, 2023 – Jun 9, 2023

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

“Ryan

author
#0 lore raw

PATCH 1/2 ASoC: dt-bindings: max98388: add amplifier driver

From: Ryan Lee <[email protected]>

Add dt-bindings information for Analog Devices MAX98388 I2S Amplifier

---
 .../bindings/sound/adi,max98388.yaml          | 79 +++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/adi,max98388.yaml
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +79 -0
new file mode 100644
index 000000000000..fc0ac8d8c3ae
@@ -0,0 +1,79 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/adi,max98388.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices MAX98388 Speaker Amplifier
+
+maintainers:
+  - Ryan Lee <[email protected]>
+
+description:
+  The MAX98388 is a mono Class-D speaker amplifier with I/V feedback.
+  The device provides a PCM interface for audio data and a standard
+  I2C interface for control data communication.
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - adi,max98388
+  reg:
+    maxItems: 1
+    description: I2C address of the device.
+
+  '#sound-dai-cells':
+    const: 0
+
+  adi,vmon-slot-no:
+    description: slot number of the voltage feedback monitor
+    $ref: "/schemas/types.yaml#/definitions/uint32"
+    minimum: 0
+    maximum: 15
+    default: 0
+
+  adi,imon-slot-no:
+    description: slot number of the current feedback monitor
+    $ref: "/schemas/types.yaml#/definitions/uint32"
+    minimum: 0
+    maximum: 15
+    default: 1
+
+  adi,interleave-mode:
+    description:
+      For cases where a single combined channel for the I/V feedback data
+      is not sufficient, the device can also be configured to share
+      a single data output channel on alternating frames.
+      In this configuration, the current and voltage data will be frame
+      interleaved on a single output channel.
+    type: boolean
+
+  reset-gpios:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - "#sound-dai-cells"
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        max98388: amplifier@39 {
+            compatible = "adi,max98388";
+            reg = <0x39>;
+            #sound-dai-cells = <0>;
+            adi,vmon-slot-no = <0>;
+            adi,imon-slot-no = <1>;
+            adi,interleave-mode;
+            reset-gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
+        };
+    };
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/2 ASoC: max98388: add amplifier driver

From: Ryan Lee <[email protected]>

Added Analog Devices MAX98388 amplifier driver.
MAX98388 provides a PCM interface for audio data and a standard I2C interface for control data communication.

---
 sound/soc/codecs/Kconfig    |   10 +
 sound/soc/codecs/Makefile   |    2 +
 sound/soc/codecs/max98388.c | 1042 +++++++++++++++++++++++++++++++++++
 sound/soc/codecs/max98388.h |  234 ++++++++
 4 files changed, 1288 insertions(+)
 create mode 100644 sound/soc/codecs/max98388.c
 create mode 100644 sound/soc/codecs/max98388.h
sound/soc/codecs/Kconfig +10 -0
index 1f68d18515a6..e579ef11beb4 100644
@@ -137,6 +137,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_MAX98363
 	imply SND_SOC_MAX98373_I2C
 	imply SND_SOC_MAX98373_SDW
+	imply SND_SOC_MAX98388
 	imply SND_SOC_MAX98390
 	imply SND_SOC_MAX98396
 	imply SND_SOC_MAX9850
@@ -1175,6 +1176,15 @@ config SND_SOC_MAX98373_SDW
 	  interface for control data. Select this if MAX98373 is
 	  connected via soundwire.
 
+config SND_SOC_MAX98388
+	tristate "Analog Devices MAX98388 Speaker Amplifier"
+	depends on I2C
+	help
+	  Enable support for Analog Devices MAX98388 audio
+	  amplifier. The device provides a PCM interface for
+	  audio data and a standard I2C interface for control
+	  data communication.
+
 config SND_SOC_MAX98390
 	tristate "Maxim Integrated MAX98390 Speaker Amplifier"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index 67f336a12d74..0fd003d432e5 100644
@@ -153,6 +153,7 @@ 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
+snd-soc-max98388-objs := max98388.o
 snd-soc-max98390-objs := max98390.o
 snd-soc-max98396-objs := max98396.o
 snd-soc-max9850-objs := max9850.o
@@ -525,6 +526,7 @@ 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
+obj-$(CONFIG_SND_SOC_MAX98388)	+= snd-soc-max98388.o
 obj-$(CONFIG_SND_SOC_MAX98390)	+= snd-soc-max98390.o
 obj-$(CONFIG_SND_SOC_MAX98396)	+= snd-soc-max98396.o
 obj-$(CONFIG_SND_SOC_MAX9850)	+= snd-soc-max9850.o
sound/soc/codecs/max98388.c new file +1042 -0

1,042 lines not on this page · raw message

sound/soc/codecs/max98388.h new file +234 -0

234 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/2] ASoC: max98388: add amplifier driver

kernel test robot noticed the following build warnings:

Hi “Ryan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v6.4-rc5 next-20230608] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ryan/ASoC-max98388-add-amplifier-driver/20230608-134526
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20230608054230.344014-2-ryan.lee.analog%40gmail.com
patch subject: [PATCH 2/2] ASoC: max98388: add amplifier driver
config: mips-allmodconfig (https://download.01.org/0day-ci/archive/20230608/[email protected]/config)
compiler: mips-linux-gcc (GCC) 12.3.0

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git remote add broonie-sound https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
git fetch broonie-sound for-next
git checkout broonie-sound/for-next
b4 shazam https://lore.kernel.org/r/[email protected]
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=mips olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash sound/soc/codecs/

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> sound/soc/codecs/max98388.c:390:6: warning: no previous prototype for 'max98388_reset' [-Wmissing-prototypes]
     390 | void max98388_reset(struct max98388_priv *max98388, struct device *dev)
         |      ^~~~~~~~~~~~~~
>> sound/soc/codecs/max98388.c:904:6: warning: no previous prototype for 'max98388_read_deveice_property' [-Wmissing-prototypes]

904 | void max98388_read_deveice_property(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/max98388_reset +390 sound/soc/codecs/max98388.c

389

 > 390	void max98388_reset(struct max98388_priv *max98388, struct device *dev)

391 {
392 int ret, reg, count;
393
394 /* Software Reset */
395 ret = regmap_update_bits(max98388->regmap,
396 MAX98388_R2000_SW_RESET,
397 MAX98388_SOFT_RESET,
398 MAX98388_SOFT_RESET);
399 if (ret)
400 dev_err(dev, "Reset command failed. (ret:%d)\n", ret);
401
402 count = 0;
403 while (count < 3) {
404 usleep_range(10000, 11000);
405 /* Software Reset Verification */
406 ret = regmap_read(max98388->regmap,
407 MAX98388_R22FF_REV_ID, &reg);
408 if (!ret) {
409 dev_info(dev, "Reset completed (retry:%d)\n", count);
410 return;
411 }
412 count++;
413 }
414 dev_err(dev, "Reset failed. (ret:%d)\n", ret);
415 }
416

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw
In reply to “Ryan
Quoted 5 lines · “Ryan

From: Ryan Lee <[email protected]>

Add dt-bindings information for Analog Devices MAX98388 I2S Amplifier

Thank you for your patch. There is something to discuss/improve.

Documentation/devicetree/bindings/sound/adi,max98388.yaml line 23

Quoted 8 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +8 -0
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - adi,max98388

Blank line

Documentation/devicetree/bindings/sound/adi,max98388.yaml line 26

Quoted 3 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +3 -0
+  reg:
+    maxItems: 1
+    description: I2C address of the device.

Drop description, it's obvious.

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

Quoted 7 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +7 -0
+
+  '#sound-dai-cells':
+    const: 0
+
+  adi,vmon-slot-no:
+    description: slot number of the voltage feedback monitor
+    $ref: "/schemas/types.yaml#/definitions/uint32"

Drop quotes.

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

Quoted 7 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +7 -0
+    minimum: 0
+    maximum: 15
+    default: 0
+
+  adi,imon-slot-no:
+    description: slot number of the current feedback monitor
+    $ref: "/schemas/types.yaml#/definitions/uint32"

Drop quotes.

Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +10 -0
+    minimum: 0
+    maximum: 15
+    default: 1
+
+  adi,interleave-mode:
+    description:
+      For cases where a single combined channel for the I/V feedback data
+      is not sufficient, the device can also be configured to share
+      a single data output channel on alternating frames.
+      In this configuration, the current and voltage data will be frame

Documentation/devicetree/bindings/sound/adi,max98388.yaml line 60

Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +10 -0
+      interleaved on a single output channel.
+    type: boolean
+
+  reset-gpios:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - "#sound-dai-cells"

Keep consistent quotes - either ' or "

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+unevaluatedProperties: false

Best regards,
Krzysztof

#4 lore raw
Quoted 17 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Thursday, June 8, 2023 12:18 AM
To: “Ryan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lee, RyanS <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: Re: [PATCH 1/2] ASoC: dt-bindings: max98388: add amplifier driver

[External]

Quoted 8 lines
Quoted 5 lines · “Ryan

From: Ryan Lee <[email protected]>

Add dt-bindings information for Analog Devices MAX98388 I2S Amplifier

Thank you for your patch. There is something to discuss/improve.

Thanks for the comments. I shall fix the issues and submit the patch again.

Quoted 67 lines

Documentation/devicetree/bindings/sound/adi,max98388.yaml line 23

Quoted 9 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +8 -0
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - adi,max98388

Blank line

Documentation/devicetree/bindings/sound/adi,max98388.yaml line 26

Quoted 3 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +3 -0
+  reg:
+    maxItems: 1
+    description: I2C address of the device.

Drop description, it's obvious.

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

Quoted 7 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +7 -0
+
+  '#sound-dai-cells':
+    const: 0
+
+  adi,vmon-slot-no:
+    description: slot number of the voltage feedback monitor
+    $ref: "/schemas/types.yaml#/definitions/uint32"

Drop quotes.

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

Quoted 7 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +7 -0
+    minimum: 0
+    maximum: 15
+    default: 0
+
+  adi,imon-slot-no:
+    description: slot number of the current feedback monitor
+    $ref: "/schemas/types.yaml#/definitions/uint32"

Drop quotes.

Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +10 -0
+    minimum: 0
+    maximum: 15
+    default: 1
+
+  adi,interleave-mode:
+    description:
+      For cases where a single combined channel for the I/V feedback data
+      is not sufficient, the device can also be configured to share
+      a single data output channel on alternating frames.
+      In this configuration, the current and voltage data will be frame

Documentation/devicetree/bindings/sound/adi,max98388.yaml line 60

Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,max98388.yaml new file +10 -0
+      interleaved on a single output channel.
+    type: boolean
+
+  reset-gpios:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - "#sound-dai-cells"

Keep consistent quotes - either ' or "

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+unevaluatedProperties: false

Best regards,
Krzysztof