diff mbox series

ASoC: codecs: es8326: Fix power-up sequence

Message ID 20230630072515.49382-1-zhuning0077@gmail.com (mailing list archive)
State New, archived
Headers show
Series ASoC: codecs: es8326: Fix power-up sequence | expand

Commit Message

Zhu Ning June 30, 2023, 7:25 a.m. UTC
Old power-up sequence causes large pop noise during start-up.
Using a new sequence instead.

Signed-off-by: Zhu Ning <zhuning@everest-semi.com>
---
 sound/soc/codecs/es8326.c | 112 +++++++++++++++++++++++++-------------
 sound/soc/codecs/es8326.h |  14 +++--
 2 files changed, 83 insertions(+), 43 deletions(-)

Comments

kernel test robot June 30, 2023, 10:12 a.m. UTC | #1
Hi Zhu,

kernel test robot noticed the following build errors:

[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on tiwai-sound/for-next tiwai-sound/for-linus linus/master v6.4 next-20230630]
[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/Zhu-Ning/ASoC-codecs-es8326-Fix-power-up-sequence/20230630-152707
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20230630072515.49382-1-zhuning0077%40gmail.com
patch subject: [PATCH] ASoC: codecs: es8326: Fix power-up sequence
config: powerpc-randconfig-r011-20230630 (https://download.01.org/0day-ci/archive/20230630/202306301757.wbLjgJDY-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230630/202306301757.wbLjgJDY-lkp@intel.com/reproduce)

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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306301757.wbLjgJDY-lkp@intel.com/

All errors (new ones prefixed by >>):

>> sound/soc/codecs/es8326.c:713:54: error: use of undeclared identifier 'ES8326_MUTE_MASK'
     713 |         regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK,
         |                                                             ^
>> sound/soc/codecs/es8326.c:714:7: error: use of undeclared identifier 'ES8326_MUTE'
     714 |                            ES8326_MUTE);
         |                            ^
>> sound/soc/codecs/es8326.c:719:10: error: no member named 'version' in 'struct es8326_priv'
     719 |         es8326->version = reg;
         |         ~~~~~~  ^
   3 errors generated.


vim +/ES8326_MUTE_MASK +713 sound/soc/codecs/es8326.c

   644	
   645	static int es8326_resume(struct snd_soc_component *component)
   646	{
   647		struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
   648		unsigned int reg;
   649	
   650		regcache_cache_only(es8326->regmap, false);
   651		regcache_sync(es8326->regmap);
   652	
   653		/* reset register value to default */
   654		regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x01);
   655		usleep_range(1000, 3000);
   656		regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x00);
   657		/* reset internal state */
   658		regmap_write(es8326->regmap, ES8326_RESET, 0x1f);
   659		regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E);
   660		regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0x88);
   661		/* set headphone default type and detect pin */
   662		regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x81 |
   663			     ES8326_HP_DET_SRC_PIN9);
   664		regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05);
   665	
   666		/* set internal oscillator as clock source of headpone cp */
   667		regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x84);
   668		regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON);
   669		/* clock manager reset release */
   670		regmap_write(es8326->regmap, ES8326_RESET, 0x17);
   671		/* set headphone detection as half scan mode */
   672		regmap_write(es8326->regmap, ES8326_HP_MISC, 0x08);
   673		regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x02);
   674	
   675		/* enable headphone driver */
   676		regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa7);
   677		regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xa3);
   678		regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xb3);
   679		regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1);
   680	
   681		regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00);
   682		regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xc4);
   683		regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x81);
   684		regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x00);
   685	
   686		/* turn off headphone out */
   687		regmap_write(es8326->regmap, ES8326_HP_CAL, 0x00);
   688		/* set ADC and DAC in low power mode */
   689		regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0);
   690	
   691		/* force micbias on */
   692		regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0x4f);
   693		regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x08);
   694		regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7F);
   695		/* select vdda as micbias source */
   696		regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x23);
   697		/* set dac dsmclip = 1 */
   698		regmap_write(es8326->regmap, ES8326_DAC_DSM, 0x08);
   699		regmap_write(es8326->regmap, ES8326_DAC_VPPSCALE, 0x15);
   700	
   701		regmap_write(es8326->regmap, ES8326_INT_SOURCE, 0x0c);
   702		regmap_write(es8326->regmap, ES8326_INTOUT_IO,
   703			     es8326->interrupt_clk);
   704		regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
   705			    (ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT));
   706		regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT);
   707	
   708		regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b);
   709		regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON);
   710		regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, ES8326_MIC_SEL_MASK,
   711				   ES8326_MIC1_SEL);
   712	
 > 713		regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK,
 > 714				   ES8326_MUTE);
   715	
   716		regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x80 |
   717			     ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol);
   718		regmap_read(es8326->regmap, ES8326_CHIP_VERSION, &reg);
 > 719		es8326->version = reg;
   720		es8326_irq(es8326->irq, es8326);
   721		return 0;
   722	}
   723
kernel test robot June 30, 2023, 4:58 p.m. UTC | #2
Hi Zhu,

kernel test robot noticed the following build errors:

[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on tiwai-sound/for-next tiwai-sound/for-linus linus/master v6.4 next-20230630]
[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/Zhu-Ning/ASoC-codecs-es8326-Fix-power-up-sequence/20230630-152707
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20230630072515.49382-1-zhuning0077%40gmail.com
patch subject: [PATCH] ASoC: codecs: es8326: Fix power-up sequence
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230701/202307010058.iE2OHDes-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230701/202307010058.iE2OHDes-lkp@intel.com/reproduce)

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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307010058.iE2OHDes-lkp@intel.com/

All errors (new ones prefixed by >>):

   sound/soc/codecs/es8326.c: In function 'es8326_resume':
>> sound/soc/codecs/es8326.c:713:61: error: 'ES8326_MUTE_MASK' undeclared (first use in this function); did you mean 'ES8326_MIC_SEL_MASK'?
     713 |         regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK,
         |                                                             ^~~~~~~~~~~~~~~~
         |                                                             ES8326_MIC_SEL_MASK
   sound/soc/codecs/es8326.c:713:61: note: each undeclared identifier is reported only once for each function it appears in
>> sound/soc/codecs/es8326.c:714:28: error: 'ES8326_MUTE' undeclared (first use in this function); did you mean 'ES8326_FMT'?
     714 |                            ES8326_MUTE);
         |                            ^~~~~~~~~~~
         |                            ES8326_FMT
>> sound/soc/codecs/es8326.c:719:15: error: 'struct es8326_priv' has no member named 'version'
     719 |         es8326->version = reg;
         |               ^~


vim +713 sound/soc/codecs/es8326.c

   644	
   645	static int es8326_resume(struct snd_soc_component *component)
   646	{
   647		struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
   648		unsigned int reg;
   649	
   650		regcache_cache_only(es8326->regmap, false);
   651		regcache_sync(es8326->regmap);
   652	
   653		/* reset register value to default */
   654		regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x01);
   655		usleep_range(1000, 3000);
   656		regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x00);
   657		/* reset internal state */
   658		regmap_write(es8326->regmap, ES8326_RESET, 0x1f);
   659		regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E);
   660		regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0x88);
   661		/* set headphone default type and detect pin */
   662		regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x81 |
   663			     ES8326_HP_DET_SRC_PIN9);
   664		regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05);
   665	
   666		/* set internal oscillator as clock source of headpone cp */
   667		regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x84);
   668		regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON);
   669		/* clock manager reset release */
   670		regmap_write(es8326->regmap, ES8326_RESET, 0x17);
   671		/* set headphone detection as half scan mode */
   672		regmap_write(es8326->regmap, ES8326_HP_MISC, 0x08);
   673		regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x02);
   674	
   675		/* enable headphone driver */
   676		regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa7);
   677		regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xa3);
   678		regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xb3);
   679		regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1);
   680	
   681		regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00);
   682		regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xc4);
   683		regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x81);
   684		regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x00);
   685	
   686		/* turn off headphone out */
   687		regmap_write(es8326->regmap, ES8326_HP_CAL, 0x00);
   688		/* set ADC and DAC in low power mode */
   689		regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0);
   690	
   691		/* force micbias on */
   692		regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0x4f);
   693		regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x08);
   694		regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7F);
   695		/* select vdda as micbias source */
   696		regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x23);
   697		/* set dac dsmclip = 1 */
   698		regmap_write(es8326->regmap, ES8326_DAC_DSM, 0x08);
   699		regmap_write(es8326->regmap, ES8326_DAC_VPPSCALE, 0x15);
   700	
   701		regmap_write(es8326->regmap, ES8326_INT_SOURCE, 0x0c);
   702		regmap_write(es8326->regmap, ES8326_INTOUT_IO,
   703			     es8326->interrupt_clk);
   704		regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
   705			    (ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT));
   706		regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT);
   707	
   708		regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b);
   709		regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON);
   710		regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, ES8326_MIC_SEL_MASK,
   711				   ES8326_MIC1_SEL);
   712	
 > 713		regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK,
 > 714				   ES8326_MUTE);
   715	
   716		regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x80 |
   717			     ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol);
   718		regmap_read(es8326->regmap, ES8326_CHIP_VERSION, &reg);
 > 719		es8326->version = reg;
   720		es8326_irq(es8326->irq, es8326);
   721		return 0;
   722	}
   723
diff mbox series

Patch

diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c
index 9190a8779334..0b702bdf033a 100644
--- a/sound/soc/codecs/es8326.c
+++ b/sound/soc/codecs/es8326.c
@@ -159,7 +159,7 @@  static const struct snd_soc_dapm_route es8326_dapm_routes[] = {
 };
 
 static const struct regmap_range es8326_volatile_ranges[] = {
-	regmap_reg_range(ES8326_HP_DETECT, ES8326_HP_DETECT),
+	regmap_reg_range(ES8326_CTIA_OMTP_STA, ES8326_CSM_MUTE_STA),
 };
 
 static const struct regmap_access_table es8326_volatile_table = {
@@ -415,15 +415,17 @@  static int es8326_set_bias_level(struct snd_soc_component *codec,
 		ret = clk_prepare_enable(es8326->mclk);
 		if (ret)
 			return ret;
-		regmap_write(es8326->regmap, ES8326_RESET, ES8326_PWRUP_SEQ_EN);
-		regmap_write(es8326->regmap, ES8326_INTOUT_IO, 0x45);
+
+		regmap_write(es8326->regmap, ES8326_RESET, 0x9f);
+		msleep(20);
+		regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00);
+		regmap_write(es8326->regmap, ES8326_INTOUT_IO, es8326->interrupt_clk);
 		regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
 			    (ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT));
-		regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT);
-		regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05);
-		regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x02);
+		regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E);
 		regmap_write(es8326->regmap, ES8326_PGA_PDN, 0x40);
-		regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0xAA);
+		regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x00);
+		regmap_update_bits(es8326->regmap,  ES8326_CLK_CTL, 0x20, 0x20);
 		regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON);
 		break;
 	case SND_SOC_BIAS_PREPARE:
@@ -432,18 +434,15 @@  static int es8326_set_bias_level(struct snd_soc_component *codec,
 		break;
 	case SND_SOC_BIAS_OFF:
 		clk_disable_unprepare(es8326->mclk);
-		regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x11);
 		regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_OFF);
-		regmap_write(es8326->regmap, ES8326_PGA_PDN, 0xF8);
+		regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b);
 		regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x00);
-		regmap_write(es8326->regmap, ES8326_INT_SOURCE, 0x08);
+		regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x00);
 		regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, ES8326_IO_INPUT);
-		regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT);
 		regmap_write(es8326->regmap, ES8326_RESET,
 			     ES8326_CODEC_RESET | ES8326_PWRUP_SEQ_EN);
 		break;
 	}
-
 	return 0;
 }
 
@@ -519,7 +518,7 @@  static void es8326_jack_button_handler(struct work_struct *work)
 		return;
 
 	mutex_lock(&es8326->lock);
-	iface = snd_soc_component_read(comp, ES8326_HP_DETECT);
+	iface = snd_soc_component_read(comp, ES8326_HPDET_STA);
 	switch (iface) {
 	case 0x93:
 		/* pause button detected */
@@ -578,7 +577,7 @@  static void es8326_jack_detect_handler(struct work_struct *work)
 	unsigned int iface;
 
 	mutex_lock(&es8326->lock);
-	iface = snd_soc_component_read(comp, ES8326_HP_DETECT);
+	iface = snd_soc_component_read(comp, ES8326_HPDET_STA);
 	dev_dbg(comp->dev, "gpio flag %#04x", iface);
 	if ((iface & ES8326_HPINSERT_FLAG) == 0) {
 		/* Jack unplugged or spurious IRQ */
@@ -638,36 +637,73 @@  static int es8326_resume(struct snd_soc_component *component)
 	regcache_cache_only(es8326->regmap, false);
 	regcache_sync(es8326->regmap);
 
+	/* reset register value to default */
+	regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x01);
+	usleep_range(1000, 3000);
+	regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x00);
+	/* reset internal state */
+	regmap_write(es8326->regmap, ES8326_RESET, 0x1f);
+	regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E);
+	regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0x88);
+	/* set headphone default type and detect pin */
+	regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x81 |
+		     ES8326_HP_DET_SRC_PIN9);
+	regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05);
+
+	/* set internal oscillator as clock source of headpone cp */
+	regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x84);
 	regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON);
-	/* Two channel ADC */
+	/* clock manager reset release */
+	regmap_write(es8326->regmap, ES8326_RESET, 0x17);
+	/* set headphone detection as half scan mode */
+	regmap_write(es8326->regmap, ES8326_HP_MISC, 0x08);
 	regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x02);
+
+	/* enable headphone driver */
+	regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa7);
+	regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xa3);
+	regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xb3);
+	regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1);
+
 	regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00);
-	regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x1F);
-	regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xC8);
-	regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x88);
-	regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x20);
+	regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xc4);
+	regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x81);
+	regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x00);
+
+	/* turn off headphone out */
+	regmap_write(es8326->regmap, ES8326_HP_CAL, 0x00);
+	/* set ADC and DAC in low power mode */
+	regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0);
+
+	/* force micbias on */
+	regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0x4f);
 	regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x08);
-	regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x22);
-	regmap_write(es8326->regmap, ES8326_ADC1_SRC, es8326->mic1_src);
-	regmap_write(es8326->regmap, ES8326_ADC2_SRC, es8326->mic2_src);
-	regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0x88);
-	regmap_write(es8326->regmap, ES8326_HP_DET,
-		     ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol);
-	regmap_write(es8326->regmap, ES8326_INT_SOURCE, es8326->interrupt_src);
-	regmap_write(es8326->regmap, ES8326_INTOUT_IO, es8326->interrupt_clk);
+	regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7F);
+	/* select vdda as micbias source */
+	regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x23);
+	/* set dac dsmclip = 1 */
+	regmap_write(es8326->regmap, ES8326_DAC_DSM, 0x08);
+	regmap_write(es8326->regmap, ES8326_DAC_VPPSCALE, 0x15);
+
+	regmap_write(es8326->regmap, ES8326_INT_SOURCE, 0x0c);
+	regmap_write(es8326->regmap, ES8326_INTOUT_IO,
+		     es8326->interrupt_clk);
+	regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
+		    (ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT));
+	regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT);
+
+	regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b);
 	regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON);
-	snd_soc_component_update_bits(component, ES8326_PGAGAIN,
-				      ES8326_MIC_SEL_MASK, ES8326_MIC1_SEL);
+	regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, ES8326_MIC_SEL_MASK,
+			   ES8326_MIC1_SEL);
 
-	regmap_read(es8326->regmap, ES8326_CHIP_VERSION, &reg);
-	if ((reg & ES8326_VERSION_B) == 1) {
-		regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0xDD);
-		regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7F);
-		regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x0F);
-		/* enable button detect */
-		regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xA0);
-	}
+	regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK,
+			   ES8326_MUTE);
 
+	regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x80 |
+		     ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol);
+	regmap_read(es8326->regmap, ES8326_CHIP_VERSION, &reg);
+	es8326->version = reg;
 	es8326_irq(es8326->irq, es8326);
 	return 0;
 }
@@ -743,7 +779,7 @@  static void es8326_enable_jack_detect(struct snd_soc_component *component,
 
 	mutex_lock(&es8326->lock);
 	if (es8326->jd_inverted)
-		snd_soc_component_update_bits(component, ES8326_HP_DET,
+		snd_soc_component_update_bits(component, ES8326_HPDET_TYPE,
 					      ES8326_HP_DET_JACK_POL, ~es8326->jack_pol);
 	es8326->jack = jack;
 
diff --git a/sound/soc/codecs/es8326.h b/sound/soc/codecs/es8326.h
index 1eb9d0095378..9093222ae04d 100644
--- a/sound/soc/codecs/es8326.h
+++ b/sound/soc/codecs/es8326.h
@@ -9,8 +9,6 @@ 
 #ifndef _ES8326_H
 #define _ES8326_H
 
-#define CONFIG_HHTECH_MINIPMP	1
-
 /* ES8326 register space */
 #define ES8326_RESET		0x00
 #define ES8326_CLK_CTL		0x01
@@ -75,15 +73,19 @@ 
 #define ES8326_DRC_RECOVERY	0x53
 #define ES8326_DRC_WINSIZE	0x54
 #define ES8326_HPJACK_TIMER	0x56
-#define ES8326_HP_DET		0x57
+#define ES8326_HPDET_TYPE	0x57
 #define ES8326_INT_SOURCE	0x58
 #define ES8326_INTOUT_IO	0x59
 #define ES8326_SDINOUT1_IO	0x5A
 #define ES8326_SDINOUT23_IO	0x5B
 #define ES8326_JACK_PULSE	0x5C
 
+#define ES8326_HP_MISC		0xF7
+#define ES8326_CTIA_OMTP_STA	0xF8
 #define ES8326_PULLUP_CTL	0xF9
-#define ES8326_HP_DETECT	0xFB
+#define ES8326_CSM_I2C_STA	0xFA
+#define ES8326_HPDET_STA	0xFB
+#define ES8326_CSM_MUTE_STA	0xFC
 #define ES8326_CHIP_ID1		0xFD
 #define ES8326_CHIP_ID2		0xFE
 #define ES8326_CHIP_VERSION	0xFF
@@ -179,6 +181,8 @@ 
 #define ES8326_HPBUTTON_FLAG (1 << 0)
 
 /* ES8326_CHIP_VERSION 0xFF */
-#define ES8326_VERSION_B (1 << 0)
+#define ES8326_VERSION (1 << 0)
+#define ES8326_VERSION_B (3 << 0)
 
 #endif
+