ASoC: max98363: add soundwire amplifier driver
Subsystems (4)
PATCH v2 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.
sound/soc/codecs/Kconfig | 11 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/max98363.c | 468 ++++++++++++++++++++++++++++++++++++ sound/soc/codecs/max98363.h | 38 +++ 4 files changed, 519 insertions(+) create mode 100644 sound/soc/codecs/max98363.c create mode 100644 sound/soc/codecs/max98363.h
sound/soc/codecs/Kconfig +11 -0
@@ -130,6 +130,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
@@ -1089,6 +1090,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
@@ -143,6 +143,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
@@ -505,6 +506,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 +468 -0
468 lines not on this page · raw message
sound/soc/codecs/max98363.h new file +38 -0
@@ -0,0 +1,38 @@ +/* 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; +int slot; +unsigned int rx_mask; +bool hw_init; +bool first_hw_init; +}; +#endif
Signature · 1 line
2.34.1
PATCH v2 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
.../bindings/sound/adi,max98363.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/adi,max98363.yaml
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +42 -0
@@ -0,0 +1,42 @@ +# 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). + +properties: + compatible: + enum: + - adi,max98363 + reg: + maxItems: 1 + description: Peripheral-device unique ID decoded from pin. + +required: + - compatible + - reg +additionalProperties: false + +examples: + - | + soundwire { + #address-cells = <1>; + #size-cells = <0>; + amplifier@3 { + compatible = "adi,max98363"; + reg = <0x3>; + }; + };
Signature · 1 line
2.34.1
Re: [PATCH V2 2/2] ASoC: dt-bindings: max98363: add soundwire amplifier
Quoted 35 lines · “Ryan
From: Ryan Lee <[email protected]>
This patch adds dt-bindings information for Analog Devices MAX98363 SoundWire Amplifier.
Signed-off-by Ryan Lee <[email protected]>---
Changes from v1:
Fixed a syntax error for the 'dt_binding_check' build. Removed unnecessary properties.
Added description about SoundWire device ID of MAX98363.../bindings/sound/adi,max98363.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/adi,max98363.yamlDocumentation/devicetree/bindings/sound/adi,max98363.yaml new file +13
-0@@ -0,0 +1,42 @@ +# 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
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +10
-0+ 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). + +properties: + compatible: + enum: + - adi,max98363
Aren't soundwire devices supposed to use device ID as compatible?
Missing blank line
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 27
Quoted 4 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +4
-0+ reg: + maxItems: 1 + description: Peripheral-device unique ID decoded from pin. +
It's not a DAI?
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 30
Quoted 3 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +3
-0+required: + - compatible + - reg
Missing blank line
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 40
Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +10
-0+additionalProperties: false + +examples: + - | + soundwire { + #address-cells = <1>; + #size-cells = <0>; + amplifier@3 { + compatible = "adi,max98363"; + reg = <0x3>;
That looks a bit different than regular SoundWire bus. I would argue that it's not SoundWire at all...
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 42
Quoted 2 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +2
-0+ }; + };
Best regards,
Krzysztof
RE: [PATCH V2 2/2] ASoC: dt-bindings: max98363: add soundwire amplifier
Quoted 69 lines
-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Saturday, March 11, 2023 1:10 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 V2 2/2] ASoC: dt-bindings: max98363: add soundwire amplifier[External]
Quoted 25 lines · “Ryan
From: Ryan Lee <[email protected]>
This patch adds dt-bindings information for Analog Devices MAX98363 SoundWire Amplifier.
Signed-off-by Ryan Lee <[email protected]>---
Changes from v1:
Fixed a syntax error for the 'dt_binding_check' build. Removed unnecessary properties.
Added description about SoundWire device ID of MAX98363.../bindings/sound/adi,max98363.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644
Documentation/devicetree/bindings/sound/adi,max98363.yamlDocumentation/devicetree/bindings/sound/adi,max98363.yaml new file +0
-0Documentation/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,42 @@ +# 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!4ewyyKINBBx1aj2efOARVpQxC3TuNeK Cm-K4O
Documentation/devicetree/bindings/sound/adi,max98363.yaml
Quoted 3 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +3
-0+YvWFPfQFCpbhs6NefkJU5s0G-h625nyj5ItjNe-N4VH002-sZAucYo$ +$schema: +https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.y
Quoted 1 line
+aml*__;Iw!!A3Ni8CS0y2Y!4ewyyKINBBx1aj2efOARVpQxC3TuNeKCm-
K4OYvWFPfQFC
Quoted 13 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +13
-0+pbhs6NefkJU5s0G-h625nyj5ItjNe-N4VH002-Pnhea3U$ + +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.
Quoted 8 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 23
Quoted 6 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +6
-0+ It supports up to 10 peripheral devices(0x0 to 0x9). + +properties: + compatible: + enum: + - adi,max98363Aren't soundwire devices supposed to use device ID as compatible?
You are right. ACPI device ID is no longer valid. I shall add the proper SoundWire device ID for the amp.
Quoted 9 lines
Missing blank line
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 27
Quoted 4 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +4
-0+ reg: + maxItems: 1 + description: Peripheral-device unique ID decoded from pin. +It's not a DAI?
It is DAI. I suppose I need to add #sound-dai-cells' info. I shall add it.
Quoted 6 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 30
Quoted 4 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +3
-0+required: + - compatible + - regMissing blank line
Thanks. I shall fix this.
Quoted 14 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 40
Quoted 11 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +10
-0+additionalProperties: false + +examples: + - | + soundwire { + #address-cells = <1>; + #size-cells = <0>; + amplifier@3 { + compatible = "adi,max98363"; + reg = <0x3>;That looks a bit different than regular SoundWire bus. I would argue that it's not SoundWire at all...
Thanks for the review. My apologies. Your statement is fair. I shall modify the example.
Quoted 7 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml line 42
Quoted 4 lines
Documentation/devicetree/bindings/sound/adi,max98363.yaml new file +2
-0+ }; + };Best regards,
Krzysztof
sound/soc/codecs/max98363.c line 267
Quoted 13 lines
sound/soc/codecs/max98363.c new file +12
-0+ ret =sdw_stream_add_slave (max98363->slave, &stream_config, + &port_config,1 , stream); +if (ret) { +dev_err (dai->dev,"Unable to configure port\n" ); +return ret; + } + +if (params_channels (params) >16 ) { +dev_err (component->dev,"Unsupported channels %d\n" , +params_channels (params)); +return -EINVAL ; + }
Do you actually support more than 8 channels?
The data port DPnPrepareCtl and DPn_ChannelEn registers expose 8 channels max. It's always possible to 'cheat' by packing two channels in the same sample, but that would require custom signaling between manager and peripheral that isn't present.
Could it be a left-over from a TDM implementation?
The rest of the patch looks fine.
Quoted 32 lines
-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Monday, March 13, 2023 7:47 AM
To: “Ryan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [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 V2 1/2] ASoC: max98363: add soundwire amplifier driver[External]
sound/soc/codecs/max98363.c line 267
Quoted 12 lines
sound/soc/codecs/max98363.c new file +12
-0+ ret =sdw_stream_add_slave (max98363->slave, &stream_config, + &port_config,1 , stream); +if (ret) { +dev_err (dai->dev,"Unable to configure port\n" ); +return ret; + } + +if (params_channels (params) >16 ) { +dev_err (component->dev,"Unsupported channels %d\n" , +params_channels (params)); +return -EINVAL ; + }Do you actually support more than 8 channels?
Quoted 6 lines
The data port DPnPrepareCtl and
DPn_ChannelEnregisters expose 8 channels max. It's always possible to 'cheat' by packing two channels in the same sample, but that would require custom signaling between manager and peripheral that isn't present.Could it be a left-over from a TDM implementation?
Thanks for the comment.
I think it is a left-over from a TDM implementation.
I shall modify the code to accept only max number of channels supported by the amp.
Quoted 2 lines
The rest of the patch looks fine.