ASoC: codecs: Added MAX98373 Soundwire Driver
PATCH 1/1 ASoC: codecs: Added MAX98373 Soundwire Driver
From: Ryan Lee <[email protected]>
Add SoundWire support for this amplifier, tested on Tigerlake platform.
--- sound/soc/codecs/Kconfig | 14 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/max98373-sdw.c | 950 ++++++++++++++++++++++++++++++++ sound/soc/codecs/max98373-sdw.h | 73 +++ sound/soc/codecs/max98373.c | 15 + sound/soc/codecs/max98373.h | 8 + 6 files changed, 1062 insertions(+) create mode 100644 sound/soc/codecs/max98373-sdw.c create mode 100644 sound/soc/codecs/max98373-sdw.h
sound/soc/codecs/Kconfig +14 -0
@@ -116,6 +116,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_MAX98926 imply SND_SOC_MAX98927 imply SND_SOC_MAX98373 + imply SND_SOC_MAX98373_SDW imply SND_SOC_MAX98390 imply SND_SOC_MAX9850 imply SND_SOC_MAX9860
@@ -871,6 +872,19 @@ config SND_SOC_MAX98373 tristate "Maxim Integrated MAX98373 Speaker Amplifier" depends on I2C +config SND_SOC_MAX98373_SDW + tristate "Maxim Integrated MAX98373 Speaker Amplifier - SDW" + depends on SOUNDWIRE + select SND_SOC_MAX98373 + select REGMAP_SOUNDWIRE + help + Enable support for Maxim Integrated MAX98373 Soundwire + amplifier. MAX98373 supports either the MIPI SoundWire + compatible interface for audio and control data, or + the PCM interface for audio data and a standard I2C + interface for control data. Select this if MAX98373 is + connected via soundwire. + config SND_SOC_MAX98390 tristate "Maxim Integrated MAX98390 Speaker Amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -115,6 +115,7 @@ snd-soc-max98925-objs := max98925.o snd-soc-max98926-objs := max98926.o snd-soc-max98927-objs := max98927.o snd-soc-max98373-objs := max98373.o +snd-soc-max98373-sdw-objs := max98373-sdw.o snd-soc-max98390-objs := max98390.o snd-soc-max9850-objs := max9850.o snd-soc-max9860-objs := max9860.o
@@ -418,6 +419,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_MAX98373) += snd-soc-max98373.o +obj-$(CONFIG_SND_SOC_MAX98373_SDW) += snd-soc-max98373-sdw.o obj-$(CONFIG_SND_SOC_MAX98390) += snd-soc-max98390.o obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o obj-$(CONFIG_SND_SOC_MAX9860) += snd-soc-max9860.o
sound/soc/codecs/max98373-sdw.c new file +950 -0
950 lines not on this page · raw message
sound/soc/codecs/max98373-sdw.h new file +73 -0
73 lines not on this page · raw message
sound/soc/codecs/max98373.c +15 -0
@@ -875,6 +875,21 @@ static const struct snd_soc_component_driver soc_codec_dev_max98373 = { .non_legacy_dai_naming = 1, }; +const struct snd_soc_component_driver soc_codec_dev_max98373_sdw = { + .probe =NULL , + .controls = max98373_snd_controls, + .num_controls =ARRAY_SIZE (max98373_snd_controls), + .dapm_widgets = max98373_dapm_widgets, + .num_dapm_widgets =ARRAY_SIZE (max98373_dapm_widgets), + .dapm_routes = max98373_audio_map, + .num_dapm_routes =ARRAY_SIZE (max98373_audio_map), + .idle_bias_on =1 , + .use_pmdown_time =1 , + .endianness =1 , + .non_legacy_dai_naming =1 , +}; +EXPORT_SYMBOL_GPL (soc_codec_dev_max98373_sdw); +static const struct regmap_config max98373_regmap = { .reg_bits =16 , .val_bits =8 ,
sound/soc/codecs/max98373.h +8 -0
@@ -212,5 +212,13 @@ struct max98373_priv {bool interleave_mode;unsigned int ch_size;bool tdm_mode; +/* variables to support soundwire */ +struct sdw_slave *slave; +bool hw_init; +bool pm_init_once; +int slot; + unsigned int rx_mask; }; + +extern const struct snd_soc_component_driver soc_codec_dev_max98373_sdw;#endif
base-commit: f61b9273c347980f570d1f9cecb867a7835c613d
Signature · 1 line
2.20.1
Mark Brown
maintainersound/soc/codecs/max98373-sdw.c line 251
Quoted 10 lines · Pierre-Louis Bossart
sound/soc/codecs/max98373-sdw.c new file +10
-0+static void max98373_read_config (struct sdw_slave *slave) +{ +int value; +struct device *dev = &slave->dev; +struct max98373_priv *max98373 =dev_get_drvdata (dev); + +if (!device_property_read_u32 (dev,"maxim,vmon-slot-no" , &value)) + max98373->v_slot = value &0xF ; +else + max98373->v_slot =0 ;
The DT bindings need updating to add SoundWire support.
Quoted 4 lines
sound/soc/codecs/max98373-sdw.c new file +4
-0+/* L/R mix configuration */ +regmap_write (max98373->regmap, +MAX98373_R2029_PCM_TO_SPK_MONO_MIX_1 , +0x80 );
sound/soc/codecs/max98373-sdw.c line 469
Quoted 10 lines
sound/soc/codecs/max98373-sdw.c new file +10
-0+regmap_write (max98373->regmap, +MAX98373_R202A_PCM_TO_SPK_MONO_MIX_2 , +0x1 ); +/* Set initial volume (0dB) */ +regmap_write (max98373->regmap, +MAX98373_R203D_AMP_DIG_VOL_CTRL , +0x00 ); +regmap_write (max98373->regmap, +MAX98373_R203E_AMP_PATH_GAIN , +0x00 );
I'd expect these to be chip defaults, especially the volumes.
sound/soc/codecs/max98373-sdw.c line 516
Quoted 4 lines
sound/soc/codecs/max98373-sdw.c new file +4
-0+/* Speaker enable */ +regmap_update_bits (max98373->regmap, +MAX98373_R2043_AMP_EN , +MAX98373_SPK_EN_MASK ,1 );
I'd expect this to be managed via DAPM.
Quoted 1 line
+/* SPDX-License-Identifier: GPL-2.0-only
AIUI this needs the trailing */ on the same line for the license compliance people.
Thanks for the review Mark,
Quoted 4 lines
Quoted 4 lines
sound/soc/codecs/max98373-sdw.c new file +4
-0+static void max98373_read_config (struct sdw_slave *slave) +{ +int value; +struct device *dev = &slave->dev;
Quoted 8 lines
sound/soc/codecs/max98373-sdw.c line 251
Quoted 6 lines
sound/soc/codecs/max98373-sdw.c new file +6
-0+struct max98373_priv *max98373 =dev_get_drvdata (dev); + +if (!device_property_read_u32 (dev,"maxim,vmon-slot-no" , &value)) + max98373->v_slot = value &0xF ; +else + max98373->v_slot =0 ;The DT bindings need updating to add SoundWire support.
Interesting. The properties are the same in I2C and SoundWire mode, so would we need a completely different file that just specifies the SoundWire DeviceID, e.g.
properties:
compatible:
const: sdw10217201000
What's the process for such dual-mode devices?
Quoted 17 lines
Quoted 5 lines
sound/soc/codecs/max98373-sdw.c new file +4
-0+/* L/R mix configuration */ +regmap_write (max98373->regmap, +MAX98373_R2029_PCM_TO_SPK_MONO_MIX_1 , +0x80 );sound/soc/codecs/max98373-sdw.c line 469
Quoted 10 lines
sound/soc/codecs/max98373-sdw.c new file +10
-0+regmap_write (max98373->regmap, +MAX98373_R202A_PCM_TO_SPK_MONO_MIX_2 , +0x1 ); +/* Set initial volume (0dB) */ +regmap_write (max98373->regmap, +MAX98373_R203D_AMP_DIG_VOL_CTRL , +0x00 ); +regmap_write (max98373->regmap, +MAX98373_R203E_AMP_PATH_GAIN , +0x00 );I'd expect these to be chip defaults, especially the volumes.
The same sequence is already used in the I2C probe. if this needs to change, it's got to be applied for both cases.
Quoted 7 lines
sound/soc/codecs/max98373-sdw.c line 516
Quoted 5 lines
sound/soc/codecs/max98373-sdw.c new file +4
-0+/* Speaker enable */ +regmap_update_bits (max98373->regmap, +MAX98373_R2043_AMP_EN , +MAX98373_SPK_EN_MASK ,1 );I'd expect this to be managed via DAPM.
It's also copied as is from the existing I2C parts.
We should probably cut the common parts out, as done for rt5682. Ryan, can you look into this.
Quoted 5 lines
Quoted 2 lines
+/* SPDX-License-Identifier: GPL-2.0-only
AIUI this needs the trailing */ on the same line for the license compliance people.
Indeed, that's a miss.
Mark Brown
maintainerQuoted 11 lines · Pierre-Louis Bossart
Quoted 1 line
The DT bindings need updating to add SoundWire support.
Interesting. The properties are the same in I2C and SoundWire mode, so would we need a completely different file that just specifies the SoundWire DeviceID, e.g.
properties:
compatible:const: sdw10217201000What's the process for such dual-mode devices?
I'd hope it could be added to the existing bindings document like for other dual bus devices.
Quoted 11 lines
Quoted 8 lines
sound/soc/codecs/max98373-sdw.c line 469
Quoted 6 lines
sound/soc/codecs/max98373-sdw.c new file +6
-0+regmap_write (max98373->regmap, +MAX98373_R203D_AMP_DIG_VOL_CTRL , +0x00 ); +regmap_write (max98373->regmap, +MAX98373_R203E_AMP_PATH_GAIN , +0x00 );I'd expect these to be chip defaults, especially the volumes.
The same sequence is already used in the I2C probe. if this needs to change, it's got to be applied for both cases.
Yes, it should.
Quoted 2 lines
We should probably cut the common parts out, as done for rt5682. Ryan, can you look into this.
Indeed.
Quoted 37 lines
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Thursday, June 18, 2020 8:11 AM
To: Pierre-Louis Bossart <[email protected]>
Cc: Guennadi Liakhovetski <[email protected]>; alsa- [email protected]; Ryan Lee <[email protected]>; [email protected]; [email protected]; [email protected]; Naveen Manohar <[email protected]>; Bard liao <yung- [email protected]>; Rander Wang <[email protected]>
Subject: Re: [PATCH] ASoC: codecs: Added MAX98373 Soundwire DriverQuoted 11 lines · Pierre-Louis Bossart
Quoted 1 line
The DT bindings need updating to add SoundWire support.
Interesting. The properties are the same in I2C and SoundWire mode, so would we need a completely different file that just specifies the SoundWire DeviceID, e.g.
properties:
compatible:const: sdw10217201000What's the process for such dual-mode devices?
I'd hope it could be added to the existing bindings document like for other dual bus devices.
Quoted 8 lines
Quoted 8 lines
sound/soc/codecs/max98373-sdw.c line 469
Quoted 6 lines
sound/soc/codecs/max98373-sdw.c new file +6
-0+regmap_write (max98373->regmap, +MAX98373_R203D_AMP_DIG_VOL_CTRL , +0x00 ); +regmap_write (max98373->regmap, +MAX98373_R203E_AMP_PATH_GAIN , +0x00 );I'd expect these to be chip defaults, especially the volumes.
Quoted 4 lines
Quoted 2 lines
The same sequence is already used in the I2C probe. if this needs to change, it's got to be applied for both cases.
Yes, it should.
Agreed. Shall remove volume configuration.
Quoted 5 lines
Quoted 3 lines
We should probably cut the common parts out, as done for rt5682. Ryan, can you look into this.
Indeed.
OK. Shall re-use common parts and remove duplication.