Skip to contentSkip to conversation

ASoC: codecs: add support for ES8326

PATCH In review Zhu Ning 3 participants 4 messages Apr 5, 2022 – Apr 18, 2022

Subsystems (2)
lore
Share & tools
lore

Zhu Ning

author
#0 lore raw

PATCH 1/1 ASoC: codecs: add support for ES8326

From: yangxiaohua <[email protected]>

The ES8326 codec is not compatible with ES8316 and requires a dedicated driver.

---
 sound/soc/codecs/Kconfig  |   5 +
 sound/soc/codecs/Makefile |   2 +
 sound/soc/codecs/es8326.c | 753 ++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/es8326.h | 184 ++++++++++
 4 files changed, 944 insertions(+)
 create mode 100755 sound/soc/codecs/es8326.c
 create mode 100755 sound/soc/codecs/es8326.h
sound/soc/codecs/Kconfig +5 -0
index c2627f7489a4..66bc2358e31e 100644
@@ -95,6 +95,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_DA9055
 	imply SND_SOC_DMIC
 	imply SND_SOC_ES8316
+	imply SND_SOC_ES8326
 	imply SND_SOC_ES8328_SPI
 	imply SND_SOC_ES8328_I2C
 	imply SND_SOC_ES7134
@@ -867,6 +868,10 @@ config SND_SOC_ES8316
 	tristate "Everest Semi ES8316 CODEC"
 	depends on I2C
 
+config SND_SOC_ES8326
+	tristate "Everest Semi ES8326 CODEC"
+	depends on I2C
+
 config SND_SOC_ES8328
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index b4e11c3e4a08..73043d5bc1ea 100644
@@ -95,6 +95,7 @@ snd-soc-dmic-objs := dmic.o
 snd-soc-es7134-objs := es7134.o
 snd-soc-es7241-objs := es7241.o
 snd-soc-es8316-objs := es8316.o
+snd-soc-es8326-objs := es8326.o
 snd-soc-es8328-objs := es8328.o
 snd-soc-es8328-i2c-objs := es8328-i2c.o
 snd-soc-es8328-spi-objs := es8328-spi.o
@@ -437,6 +438,7 @@ obj-$(CONFIG_SND_SOC_DMIC)	+= snd-soc-dmic.o
 obj-$(CONFIG_SND_SOC_ES7134)	+= snd-soc-es7134.o
 obj-$(CONFIG_SND_SOC_ES7241)	+= snd-soc-es7241.o
 obj-$(CONFIG_SND_SOC_ES8316)    += snd-soc-es8316.o
+obj-$(CONFIG_SND_SOC_ES8326)    += snd-soc-es8326.o
 obj-$(CONFIG_SND_SOC_ES8328)	+= snd-soc-es8328.o
 obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
 obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
sound/soc/codecs/es8326.c new file +753 -0

753 lines not on this page · raw message

sound/soc/codecs/es8326.h new file +184 -0

184 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 1 line · Zhu Ning

The ES8326 codec is not compatible with ES8316 and requires a dedicated driver.

This looks mostly good - a few things below but nothing huge that should require big restructurings or anything.

sound/soc/codecs/es8326.c line 4

Quoted 6 lines

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

sound/soc/codecs/es8326.c new file +4 -0
@@ -0,0 +1,753 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * es8326.c -- es8326 ALSA SoC audio driver
+ * Copyright Everest Semiconductor Co., Ltd

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

sound/soc/codecs/es8326.c line 10

Quoted 2 lines
sound/soc/codecs/es8326.c new file +2 -0
+#include <linux/clk.h>
+#include <linux/gpio.h>

The driver doesn't actually seem to use the GPIO APIs?

sound/soc/codecs/es8326.c line 40

Quoted 4 lines
sound/soc/codecs/es8326.c new file +4 -0
+	/* The lock protects the situation that an irq is generated
+	 * while the previous irq is still being processed.
+	 */
+	struct mutex lock;

It doesn't seem to, it seems to protect registrations and deregistrations from racing against each other? The actual interrupt handling doesn't use it.

sound/soc/codecs/es8326.c line 140

Quoted 1 line
sound/soc/codecs/es8326.c new file +1 -0
+	SOC_SINGLE_TLV("ADC Analog PGA Gain", ES8326_PAGGAIN_23, 0, 10, 0, adc_analog_pga_tlv),

Control name should end in Volume - see control-names.rst.

Quoted 18 lines
sound/soc/codecs/es8326.c new file +18 -0
+	regmap_write(es8326->regmap, ES8326_CLK_CTL_01, ES8326_CLK_ON);
+	/* Two channel ADC */
+	regmap_write(es8326->regmap, ES8326_PULLUP_CTL_F9, 0x02);
+	regmap_write(es8326->regmap, ES8326_CLK_INV_02, 0x00);
+	regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC_0C, 0x1F);
+	regmap_write(es8326->regmap, ES8326_CLK_TRI_0E, 0x00);
+	regmap_write(es8326->regmap, ES8326_CLK_VMIDS1_10, 0xC8);
+	regmap_write(es8326->regmap, ES8326_CLK_VMIDS2_11, 0x88);
+	regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME_12, 0x20);
+	regmap_write(es8326->regmap, ES8326_DAC_MUTE_14, 0x00);
+	regmap_write(es8326->regmap, ES8326_ANA_LOWPOWER_19, 0xF0);
+	regmap_write(es8326->regmap, ES8326_SYS_BIAS_1D, 0x08);
+	regmap_write(es8326->regmap, ES8326_DAC2HPMIX_25, 0x22);
+	regmap_write(es8326->regmap, ES8326_ADC_SCALE_29, 0x00);
+	regmap_write(es8326->regmap, ES8326_ADC1_SRC_2A, es8326->mic1_src);
+	regmap_write(es8326->regmap, ES8326_ADC2_SRC_2B, es8326->mic2_src);
+	regmap_write(es8326->regmap, ES8326_HP_CAL_4A, 0x00);
+	regmap_write(es8326->regmap, ES8326_DAC_DSM_4D, 0x08);

sound/soc/codecs/es8326.c line 592

Quoted 10 lines
sound/soc/codecs/es8326.c new file +10 -0
+	regmap_write(es8326->regmap, ES8326_DAC_RAMPRATE_4E, 0x20);
+	regmap_write(es8326->regmap, ES8326_DAC_VPPSCALE_4F, 0x15);
+	regmap_write(es8326->regmap, ES8326_HPJACK_TIMER_56, 0x88);
+	regmap_write(es8326->regmap, ES8326_HP_DET_57,
+		     ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol);
+	regmap_write(es8326->regmap, ES8326_INT_SOURCE_58, 0x08);
+	regmap_write(es8326->regmap, ES8326_INTOUT_IO_59, 0x45);
+	regmap_write(es8326->regmap, ES8326_RESET_00, ES8326_CSM_ON);
+	snd_soc_component_update_bits(component, ES8326_PAGGAIN_23,
+				      ES8326_MIC_SEL_MASK, ES8326_MIC1_SEL);

This looks like some or all of it is doing routing which would normally be configured from userspace using controls - the ADC1/2 sources and DAC controls jump out for example. Some of it like the pullups might make sense fixed, or as DT properties like the jack detect polarity is here, but not all of it.

sound/soc/codecs/es8326.c line 724

Quoted 7 lines
sound/soc/codecs/es8326.c new file +7 -0
+#ifdef CONFIG_OF
+static const struct i2c_device_id es8326_i2c_id[] = {
+	{"es8326", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, es8326_i2c_id);
+#endif

This should be unconditional, the ifdefs should be around es8326_of_match instead.

#2 lore raw
In reply to Zhu Ning
Thank you for the patch! Perhaps something to improve:

Hi Zhu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on tiwai-sound/for-next v5.18-rc2 next-20220408] [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]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhu-Ning/ASoC-codecs-add-support-for-ES8326/20220408-155312
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: mips-randconfig-r006-20220410 (https://download.01.org/0day-ci/archive/20220411/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c6e83f560f06cdfe8aa47b248d8bdc58f947274b)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/a03666fc9b47aca9c81a796145c3d31fa718a49e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Zhu-Ning/ASoC-codecs-add-support-for-ES8326/20220408-155312
git checkout a03666fc9b47aca9c81a796145c3d31fa718a49e
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> sound/soc/codecs/es8326.c:719:35: warning: unused variable 'es8326_i2c_id' [-Wunused-const-variable]
   static const struct i2c_device_id es8326_i2c_id[] = {
                                     ^

1 warning generated.

vim +/es8326_i2c_id +719 sound/soc/codecs/es8326.c

717
718 #ifdef CONFIG_OF

 > 719	static const struct i2c_device_id es8326_i2c_id[] = {

720 {"es8326", 0 },
721 {}
722 };
723 MODULE_DEVICE_TABLE(i2c, es8326_i2c_id);
724 #endif
725

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#3 lore raw
In reply to Zhu Ning
Thank you for the patch! Perhaps something to improve:

Hi Zhu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on tiwai-sound/for-next v5.18-rc3 next-20220414] [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]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhu-Ning/ASoC-codecs-add-support-for-ES8326/20220408-155312
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: hexagon-randconfig-r012-20220418 (https://download.01.org/0day-ci/archive/20220418/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 429cbac0390654f90bba18a41799464adf31a5ec)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/a03666fc9b47aca9c81a796145c3d31fa718a49e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Zhu-Ning/ASoC-codecs-add-support-for-ES8326/20220408-155312
git checkout a03666fc9b47aca9c81a796145c3d31fa718a49e
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> sound/soc/codecs/es8326.c:734:34: warning: unused variable 'es8326_of_match' [-Wunused-const-variable]
   static const struct of_device_id es8326_of_match[] = {
                                    ^

1 warning generated.

vim +/es8326_of_match +734 sound/soc/codecs/es8326.c

733

 > 734	static const struct of_device_id es8326_of_match[] = {

735 { .compatible = "everest, es8326", },
736 {}
737 };
738 MODULE_DEVICE_TABLE(of, es8326_of_match);
739

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp