ALT Linux kernel packages development
 help / color / mirror / Atom feed
From: kovalev@altlinux.org
To: devel-kernel@lists.altlinux.org
Subject: [d-kernel] [PATCH 3/7] ASoC: codecs: downgrade es8326 codec to stable state
Date: Wed,  6 Dec 2023 19:44:09 +0300
Message-ID: <20231206164413.126554-4-kovalev@altlinux.org> (raw)
In-Reply-To: <20231206164413.126554-1-kovalev@altlinux.org>

From: Vasiliy Kovalev <kovalev@altlinux.org>

The current driver version does not correctly handle
speaker/headphone switching signal widgets and requires
more thorough testing.

Let's apply a more stable version of the driver from the
5.15.109-alt1 kernel.

Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
 sound/soc/codecs/es8326.c | 1233 ++++++++++++++++++-------------------
 sound/soc/codecs/es8326.h |  254 ++++----
 2 files changed, 756 insertions(+), 731 deletions(-)

diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c
index 555125efd9ad3f..0a85288bcc289b 100644
--- a/sound/soc/codecs/es8326.c
+++ b/sound/soc/codecs/es8326.c
@@ -1,221 +1,194 @@
-// SPDX-License-Identifier: GPL-2.0-only
-//
-// es8326.c -- es8326 ALSA SoC audio driver
-// Copyright Everest Semiconductor Co., Ltd
-//
-// Authors: David Yang <yangxiaohua@everest-semi.com>
-//
+/*
+ * es8326.c -- es8326 ALSA SoC audio driver
+ *
+ * Copyright (c) 2016 Rockchip Electronics Co. Ltd.
+ *
+ * Author: Mark Brown <will@everset-semi.com>
+ * Author: Jianqun Xu <jay.xu@rock-chips.com>
+ * Author: Nickey Yang <nickey.yang@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
 
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
 #include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
 #include <linux/i2c.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/module.h>
-#include <sound/jack.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/of_gpio.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
 #include <sound/pcm_params.h>
+#include <sound/tlv.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
-#include <sound/tlv.h>
+#include <sound/initval.h>
+#include <linux/proc_fs.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <sound/jack.h>
 #include "es8326.h"
 
+/* codec private data */
 struct es8326_priv {
+	struct mutex lock;
 	struct clk *mclk;
-	struct i2c_client *i2c;
 	struct regmap *regmap;
 	struct snd_soc_component *component;
-	struct delayed_work jack_detect_work;
-	struct delayed_work button_press_work;
 	struct snd_soc_jack *jack;
 	int irq;
-	/* The lock protects the situation that an irq is generated
-	 * while enabling or disabling or during an irq.
-	 */
-	struct mutex lock;
-	u8 mic1_src;
-	u8 mic2_src;
-	u8 jack_pol;
-	u8 interrupt_src;
-	u8 interrupt_clk;
-	bool jd_inverted;
 	unsigned int sysclk;
+	struct snd_pcm_hw_constraint_list sysclk_constraints;
+	bool spk_gpio_level;
+	bool jd_inverted;
 };
 
-static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(dac_vol_tlv, -9550, 50, 0);
-static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_vol_tlv, -9550, 50, 0);
-static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_analog_pga_tlv, 0, 300, 0);
-static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_pga_tlv, 0, 600, 0);
-static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(softramp_rate, 0, 100, 0);
-static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(drc_target_tlv, -3200, 200, 0);
-static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(drc_recovery_tlv, -125, 250, 0);
-
-static const char *const winsize[] = {
-	"0.25db/2  LRCK",
-	"0.25db/4  LRCK",
-	"0.25db/8  LRCK",
-	"0.25db/16  LRCK",
-	"0.25db/32  LRCK",
-	"0.25db/64  LRCK",
-	"0.25db/128  LRCK",
-	"0.25db/256  LRCK",
-	"0.25db/512  LRCK",
-	"0.25db/1024  LRCK",
-	"0.25db/2048  LRCK",
-	"0.25db/4096  LRCK",
-	"0.25db/8192  LRCK",
-	"0.25db/16384  LRCK",
-	"0.25db/32768  LRCK",
-	"0.25db/65536  LRCK",
+/*
+ * ES8326 controls
+ */
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(es8326_dac_vol_tlv, -9550, 50, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(es8326_adc_vol_tlv, -9550, 50, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(es8326_adc_pga_tlv, 0, 600, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(es8326_softramp_rate, 0, 100, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(es8326_drc_target_tlv, -3200,
+					     200, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(es8326_drc_recovery_tlv, -125,
+					     250, 0);
+
+static const char * const es8326_winsize[] = {
+	"0.25db/2 LRCK",
+	"0.25db/4 LRCK",
+	"0.25db/8 LRCK",
+	"0.25db/16 LRCK",
+	"0.25db/32 LRCK",
+	"0.25db/64 LRCK",
+	"0.25db/128 LRCK",
+	"0.25db/256 LRCK",
+	"0.25db/512 LRCK",
+	"0.25db/1024 LRCK",
+	"0.25db/2048 LRCK",
+	"0.25db/4096 LRCK",
+	"0.25db/8192 LRCK",
+	"0.25db/16384 LRCK",
+	"0.25db/32768 LRCK",
+	"0.25db/65536 LRCK",
 };
 
-static const char *const dacpol_txt[] =	{
-	"Normal", "R Invert", "L Invert", "L + R Invert" };
-
-static const struct soc_enum dacpol =
-	SOC_ENUM_SINGLE(ES8326_DAC_DSM, 4, 4, dacpol_txt);
-static const struct soc_enum alc_winsize =
-	SOC_ENUM_SINGLE(ES8326_ADC_RAMPRATE, 4, 16, winsize);
-static const struct soc_enum drc_winsize =
-	SOC_ENUM_SINGLE(ES8326_DRC_WINSIZE, 4, 16, winsize);
+static const char * const es8326_dacpol_txt[] = {
+	"Normal", "R Invert", "L Invert", "L + R Invert"
+};
+static const struct soc_enum es8326_dacpol =
+	SOC_ENUM_SINGLE(ES8326_DAC_DSM, 4, ARRAY_SIZE(es8326_dacpol_txt),
+			es8326_dacpol_txt);
+static const struct soc_enum es8326_alc_winsize =
+	SOC_ENUM_SINGLE(ES8326_ADC_RAMPRATE, 4, ARRAY_SIZE(es8326_winsize),
+			es8326_winsize);
+static const struct soc_enum es8326_drc_winsize =
+	SOC_ENUM_SINGLE(ES8326_DRC_WINSIZE, 4, ARRAY_SIZE(es8326_winsize),
+			es8326_winsize);
 
 static const struct snd_kcontrol_new es8326_snd_controls[] = {
-	SOC_SINGLE_TLV("DAC Playback Volume", ES8326_DAC_VOL, 0, 0xbf, 0, dac_vol_tlv),
-	SOC_ENUM("Playback Polarity", dacpol),
-	SOC_SINGLE_TLV("DAC Ramp Rate", ES8326_DAC_RAMPRATE, 0, 0x0f, 0, softramp_rate),
-	SOC_SINGLE_TLV("DRC Recovery Level", ES8326_DRC_RECOVERY, 0, 4, 0, drc_recovery_tlv),
-	SOC_ENUM("DRC Winsize", drc_winsize),
-	SOC_SINGLE_TLV("DRC Target Level", ES8326_DRC_WINSIZE, 0, 0x0f, 0, drc_target_tlv),
-
-	SOC_DOUBLE_R_TLV("ADC Capture Volume", ES8326_ADC1_VOL, ES8326_ADC2_VOL, 0, 0xff, 0,
-			 adc_vol_tlv),
-	SOC_DOUBLE_TLV("ADC PGA Volume", ES8326_ADC_SCALE, 4, 0, 5, 0, adc_pga_tlv),
-	SOC_SINGLE_TLV("ADC PGA Gain Volume", ES8326_PGAGAIN, 0, 10, 0, adc_analog_pga_tlv),
-	SOC_SINGLE_TLV("ADC Ramp Rate", ES8326_ADC_RAMPRATE, 0, 0x0f, 0, softramp_rate),
-	SOC_SINGLE("ALC Capture Switch", ES8326_ALC_RECOVERY, 3, 1, 0),
-	SOC_SINGLE_TLV("ALC Capture Recovery Level", ES8326_ALC_LEVEL,
-			0, 4, 0, drc_recovery_tlv),
-	SOC_ENUM("ALC Capture Winsize", alc_winsize),
-	SOC_SINGLE_TLV("ALC Capture Target Level", ES8326_ALC_LEVEL,
-			0, 0x0f, 0, drc_target_tlv),
+	SOC_SINGLE_TLV("DAC Playback Volume", ES8326_DAC_VOL, 0, 0xff, 0,
+		       es8326_dac_vol_tlv),
+	SOC_ENUM("Playback Polarity", es8326_dacpol),
+	SOC_SINGLE_TLV("DAC Ramp Rate", ES8326_DAC_RAMPRATE, 0, 0x0f, 0,
+		       es8326_softramp_rate),
+	SOC_SINGLE("DRC Switch", ES8326_DRC_RECOVERY, 3, 1, 0),
+	SOC_SINGLE_TLV("DRC Recovery Level", ES8326_DRC_RECOVERY, 0, 4, 0,
+		       es8326_drc_recovery_tlv),
+	SOC_ENUM("DRC Winsize", es8326_drc_winsize),
+	SOC_SINGLE_TLV("DRC Target Level", ES8326_DRC_WINSIZE, 0, 0x0f, 0,
+		       es8326_drc_target_tlv),
+
+	SOC_DOUBLE_R_TLV("ADC Capture Volume", ES8326_ADC1_VOL,
+			 ES8326_ADC2_VOL, 0, 0xff, 0, es8326_adc_vol_tlv),
+	SOC_DOUBLE_TLV("ADC PGA Gain Volume", ES8326_ADC_SCALE, 4, 0, 5, 0,
+		       es8326_adc_pga_tlv),
+	SOC_SINGLE_TLV("ADC Ramp Rate", ES8326_ADC_RAMPRATE, 0, 0x0f, 0,
+		       es8326_softramp_rate),
+	SOC_SINGLE("ALC Switch", ES8326_ALC_RECOVERY, 3, 1, 0),
+	SOC_SINGLE_TLV("ALC Recovery Level", ES8326_ALC_LEVEL, 0, 4, 0,
+		       es8326_drc_recovery_tlv),
+	SOC_ENUM("ALC Winsize", es8326_alc_winsize),
+	SOC_SINGLE_TLV("ALC Target Level", ES8326_ALC_LEVEL, 0, 0x0f, 0,
+		       es8326_drc_target_tlv),
+};
 
+static const char * const es8326_adc_src_txt[] = {
+	"Analog MIC", "DMIC SDINOUT2"
 };
+static const unsigned int es8326_adc_src_values[] = { 0, 0x44 };
+static const struct soc_enum es8326_adc1_src_enum =
+	SOC_VALUE_ENUM_SINGLE(ES8326_ADC1_SRC, 0, 0xff,
+			      ARRAY_SIZE(es8326_adc_src_txt),
+			      es8326_adc_src_txt,
+			      es8326_adc_src_values);
+static const struct snd_kcontrol_new es8326_mic_mux_controls =
+	SOC_DAPM_ENUM("Route", es8326_adc1_src_enum);
 
 static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = {
+	SND_SOC_DAPM_REG(snd_soc_dapm_supply, "Mic Bias", ES8326_ANA_MICBIAS,
+			 2, 0x3, 3, 0),
+
 	SND_SOC_DAPM_INPUT("MIC1"),
 	SND_SOC_DAPM_INPUT("MIC2"),
-	SND_SOC_DAPM_INPUT("MIC3"),
-	SND_SOC_DAPM_INPUT("MIC4"),
 
-	SND_SOC_DAPM_ADC("ADC L", NULL, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_ADC("ADC R", NULL, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_MUX("Mic Mux", SND_SOC_NOPM, 0, 0,
+			 &es8326_mic_mux_controls),
 
 	/* Digital Interface */
 	SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture", 0, SND_SOC_NOPM, 0, 0),
 	SND_SOC_DAPM_AIF_IN("I2S IN", "I2S1 Playback", 0, SND_SOC_NOPM, 0, 0),
 
-	/* ADC Digital Mute */
-	SND_SOC_DAPM_PGA("ADC L1", ES8326_ADC_MUTE, 0, 1, NULL, 0),
-	SND_SOC_DAPM_PGA("ADC R1", ES8326_ADC_MUTE, 1, 1, NULL, 0),
-	SND_SOC_DAPM_PGA("ADC L2", ES8326_ADC_MUTE, 2, 1, NULL, 0),
-	SND_SOC_DAPM_PGA("ADC R2", ES8326_ADC_MUTE, 3, 1, NULL, 0),
-
-	/* Analog Power Supply*/
-	SND_SOC_DAPM_DAC("Right DAC", NULL, ES8326_ANA_PDN, 0, 1),
-	SND_SOC_DAPM_DAC("Left DAC", NULL, ES8326_ANA_PDN, 1, 1),
-	SND_SOC_DAPM_SUPPLY("Analog Power", ES8326_ANA_PDN, 7, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("IBias Power", ES8326_ANA_PDN, 6, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("ADC Vref", ES8326_ANA_PDN, 5, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("DAC Vref", ES8326_ANA_PDN, 4, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("Vref Power", ES8326_ANA_PDN, 3, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("MICBIAS1", ES8326_ANA_MICBIAS, 2, 0, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("MICBIAS2", ES8326_ANA_MICBIAS, 3, 0, NULL, 0),
-
+	SND_SOC_DAPM_DAC("Right DAC", NULL, ES8326_ANA_PWR, 0, 1),
+	SND_SOC_DAPM_DAC("Left DAC", NULL, ES8326_ANA_PWR, 1, 1),
 	SND_SOC_DAPM_PGA("LHPMIX", ES8326_DAC2HPMIX, 7, 0, NULL, 0),
 	SND_SOC_DAPM_PGA("RHPMIX", ES8326_DAC2HPMIX, 3, 0, NULL, 0),
-
-	/* Headphone Charge Pump and Output */
-	SND_SOC_DAPM_SUPPLY("HPOR Cal", ES8326_HP_CAL, 7, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("HPOL Cal", ES8326_HP_CAL, 3, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("Headphone Charge Pump", ES8326_HP_DRIVER,
-			    3, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("Headphone Driver Bias", ES8326_HP_DRIVER,
-			    2, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("Headphone LDO", ES8326_HP_DRIVER,
-			    1, 1, NULL, 0),
-	SND_SOC_DAPM_SUPPLY("Headphone Reference", ES8326_HP_DRIVER,
-			    0, 1, NULL, 0),
-	SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPOR Supply", ES8326_HP_CAL,
-			 ES8326_HPOR_SHIFT, 7, 7, 0),
-	SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPOL Supply", ES8326_HP_CAL,
-			 0, 7, 7, 0),
-
+	SND_SOC_DAPM_SUPPLY("HPOR Cal", ES8326_HP_CTL, 7, 1, NULL, 0),
+	SND_SOC_DAPM_SUPPLY("HPOL Cal", ES8326_HP_CTL, 3, 1, NULL, 0),
+	SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPOR Supply", ES8326_HP_CTL,
+			 4, 0x7, 7, 0),
+	SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPOL Supply", ES8326_HP_CTL,
+			 0, 0x7, 7, 0),
 	SND_SOC_DAPM_OUTPUT("HPOL"),
 	SND_SOC_DAPM_OUTPUT("HPOR"),
 };
 
 static const struct snd_soc_dapm_route es8326_dapm_routes[] = {
-	{"ADC L1", NULL, "MIC1"},
-	{"ADC R1", NULL, "MIC2"},
-	{"ADC L2", NULL, "MIC3"},
-	{"ADC R2", NULL, "MIC4"},
-
-	{"ADC L", NULL, "ADC L1"},
-	{"ADC R", NULL, "ADC R1"},
-	{"ADC L", NULL, "ADC L2"},
-	{"ADC R", NULL, "ADC R2"},
-
-	{"I2S OUT", NULL, "ADC L"},
-	{"I2S OUT", NULL, "ADC R"},
-
-	{"I2S OUT", NULL, "Analog Power"},
-	{"I2S OUT", NULL, "ADC Vref"},
-	{"I2S OUT", NULL, "Vref Power"},
-	{"I2S OUT", NULL, "IBias Power"},
-	{"I2S IN", NULL, "Analog Power"},
-	{"I2S IN", NULL, "DAC Vref"},
-	{"I2S IN", NULL, "Vref Power"},
-	{"I2S IN", NULL, "IBias Power"},
+	/* Recording */
+	{"MIC1", NULL, "Mic Bias"},
+	{"MIC2", NULL, "Mic Bias"},
 
+	{"Mic Mux", "DMIC SDINOUT2", "MIC1"},
+	{"Mic Mux", "Analog MIC", "MIC2"},
+
+	{"I2S OUT", NULL, "Mic Mux"},
+
+	/* Playback */
 	{"Right DAC", NULL, "I2S IN"},
 	{"Left DAC", NULL, "I2S IN"},
 
 	{"LHPMIX", NULL, "Left DAC"},
 	{"RHPMIX", NULL, "Right DAC"},
 
-	{"HPOR", NULL, "HPOR Cal"},
-	{"HPOL", NULL, "HPOL Cal"},
-	{"HPOR", NULL, "HPOR Supply"},
-	{"HPOL", NULL, "HPOL Supply"},
-	{"HPOL", NULL, "Headphone Charge Pump"},
-	{"HPOR", NULL, "Headphone Charge Pump"},
-	{"HPOL", NULL, "Headphone Driver Bias"},
-	{"HPOR", NULL, "Headphone Driver Bias"},
-	{"HPOL", NULL, "Headphone LDO"},
-	{"HPOR", NULL, "Headphone LDO"},
-	{"HPOL", NULL, "Headphone Reference"},
-	{"HPOR", NULL, "Headphone Reference"},
+	{"HPOR", NULL , "HPOR Cal"},
+	{"HPOL", NULL , "HPOL Cal"},
+
+	{"HPOR", NULL , "HPOR Supply"},
+	{"HPOL", NULL , "HPOL Supply"},
 
 	{"HPOL", NULL, "LHPMIX"},
 	{"HPOR", NULL, "RHPMIX"},
 };
 
-static const struct regmap_range es8326_volatile_ranges[] = {
-	regmap_reg_range(ES8326_HP_DETECT, ES8326_HP_DETECT),
-};
-
-static const struct regmap_access_table es8326_volatile_table = {
-	.yes_ranges = es8326_volatile_ranges,
-	.n_yes_ranges = ARRAY_SIZE(es8326_volatile_ranges),
-};
-
-static const struct regmap_config es8326_regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-	.max_register = 0xff,
-	.volatile_table = &es8326_volatile_table,
-	.cache_type = REGCACHE_RBTREE,
-};
-
-struct _coeff_div {
+struct es8326_clk_coeff {
 	u16 fs;
 	u32 rate;
 	u32 mclk;
@@ -230,133 +203,208 @@ struct _coeff_div {
 };
 
 /* codec hifi mclk clock divider coefficients */
-/* {ratio, LRCK, MCLK, REG04, REG05, REG06, REG07, REG08, REG09, REG10, REG11} */
-static const struct _coeff_div coeff_div[] = {
-	{32, 8000, 256000, 0x60, 0x00, 0x0F, 0x75, 0x0A, 0x1B, 0x1F, 0x7F},
-	{32, 16000, 512000, 0x20, 0x00, 0x0D, 0x75, 0x0A, 0x1B, 0x1F, 0x3F},
-	{32, 44100, 1411200, 0x00, 0x00, 0x13, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{32, 48000, 1536000, 0x00, 0x00, 0x13, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{36, 8000, 288000, 0x20, 0x00, 0x0D, 0x75, 0x0A, 0x1B, 0x23, 0x47},
-	{36, 16000, 576000, 0x20, 0x00, 0x0D, 0x75, 0x0A, 0x1B, 0x23, 0x47},
-	{48, 8000, 384000, 0x60, 0x02, 0x1F, 0x75, 0x0A, 0x1B, 0x1F, 0x7F},
-	{48, 16000, 768000, 0x20, 0x02, 0x0F, 0x75, 0x0A, 0x1B, 0x1F, 0x3F},
-	{48, 48000, 2304000, 0x00, 0x02, 0x0D, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{64, 8000, 512000, 0x60, 0x00, 0x0D, 0x75, 0x0A, 0x1B, 0x1F, 0x7F},
-	{64, 16000, 1024000, 0x20, 0x00, 0x05, 0x75, 0x0A, 0x1B, 0x1F, 0x3F},
-
-	{64, 44100, 2822400, 0x00, 0x00, 0x11, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{64, 48000, 3072000, 0x00, 0x00, 0x11, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{72, 8000, 576000, 0x20, 0x00, 0x13, 0x35, 0x0A, 0x1B, 0x23, 0x47},
-	{72, 16000, 1152000, 0x20, 0x00, 0x05, 0x75, 0x0A, 0x1B, 0x23, 0x47},
-	{96, 8000, 768000, 0x60, 0x02, 0x1D, 0x75, 0x0A, 0x1B, 0x1F, 0x7F},
-	{96, 16000, 1536000, 0x20, 0x02, 0x0D, 0x75, 0x0A, 0x1B, 0x1F, 0x3F},
-	{100, 48000, 4800000, 0x04, 0x04, 0x3F, 0x6D, 0x38, 0x08, 0x4f, 0x1f},
-	{125, 48000, 6000000, 0x04, 0x04, 0x1F, 0x2D, 0x0A, 0x0A, 0x27, 0x27},
-	{128, 8000, 1024000, 0x60, 0x00, 0x13, 0x35, 0x0A, 0x1B, 0x1F, 0x7F},
-	{128, 16000, 2048000, 0x20, 0x00, 0x11, 0x35, 0x0A, 0x1B, 0x1F, 0x3F},
-
-	{128, 44100, 5644800, 0x00, 0x00, 0x01, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{128, 48000, 6144000, 0x00, 0x00, 0x01, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{144, 8000, 1152000, 0x20, 0x00, 0x03, 0x35, 0x0A, 0x1B, 0x23, 0x47},
-	{144, 16000, 2304000, 0x20, 0x00, 0x11, 0x35, 0x0A, 0x1B, 0x23, 0x47},
-	{192, 8000, 1536000, 0x60, 0x02, 0x0D, 0x75, 0x0A, 0x1B, 0x1F, 0x7F},
-	{192, 16000, 3072000, 0x20, 0x02, 0x05, 0x75, 0x0A, 0x1B, 0x1F, 0x3F},
-	{200, 48000, 9600000, 0x04, 0x04, 0x0F, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{250, 48000, 12000000, 0x04, 0x04, 0x0F, 0x2D, 0x0A, 0x0A, 0x27, 0x27},
-	{256, 8000, 2048000, 0x60, 0x00, 0x11, 0x35, 0x0A, 0x1B, 0x1F, 0x7F},
-	{256, 16000, 4096000, 0x20, 0x00, 0x01, 0x35, 0x0A, 0x1B, 0x1F, 0x3F},
-
-	{256, 44100, 11289600, 0x00, 0x00, 0x10, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{256, 48000, 12288000, 0x00, 0x00, 0x30, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{288, 8000, 2304000, 0x20, 0x00, 0x01, 0x35, 0x0A, 0x1B, 0x23, 0x47},
-	{384, 8000, 3072000, 0x60, 0x02, 0x05, 0x75, 0x0A, 0x1B, 0x1F, 0x7F},
-	{384, 16000, 6144000, 0x20, 0x02, 0x03, 0x35, 0x0A, 0x1B, 0x1F, 0x3F},
-	{384, 48000, 18432000, 0x00, 0x02, 0x01, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{400, 48000, 19200000, 0x09, 0x04, 0x0f, 0x6d, 0x3a, 0x0A, 0x4F, 0x1F},
-	{500, 48000, 24000000, 0x18, 0x04, 0x1F, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{512, 8000, 4096000, 0x60, 0x00, 0x01, 0x35, 0x0A, 0x1B, 0x1F, 0x7F},
-	{512, 16000, 8192000, 0x20, 0x00, 0x10, 0x35, 0x0A, 0x1B, 0x1F, 0x3F},
-
-	{512, 44100, 22579200, 0x00, 0x00, 0x00, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{512, 48000, 24576000, 0x00, 0x00, 0x00, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{768, 8000, 6144000, 0x60, 0x02, 0x11, 0x35, 0x0A, 0x1B, 0x1F, 0x7F},
-	{768, 16000, 12288000, 0x20, 0x02, 0x01, 0x35, 0x0A, 0x1B, 0x1F, 0x3F},
-	{800, 48000, 38400000, 0x00, 0x18, 0x13, 0x2D, 0x0A, 0x0A, 0x1F, 0x1F},
-	{1024, 8000, 8192000, 0x60, 0x00, 0x10, 0x35, 0x0A, 0x1B, 0x1F, 0x7F},
-	{1024, 16000, 16384000, 0x20, 0x00, 0x00, 0x35, 0x0A, 0x1B, 0x1F, 0x3F},
-	{1152, 16000, 18432000, 0x20, 0x08, 0x11, 0x35, 0x0A, 0x1B, 0x1F, 0x3F},
-	{1536, 8000, 12288000, 0x60, 0x02, 0x01, 0x35, 0x0A, 0x1B, 0x1F, 0x7F},
-
-	{1536, 16000, 24576000, 0x20, 0x02, 0x10, 0x35, 0x0A, 0x1B, 0x1F, 0x3F},
-	{1625, 8000, 13000000, 0x0C, 0x18, 0x1F, 0x2D, 0x0A, 0x0A, 0x27, 0x27},
-	{1625, 16000, 26000000, 0x0C, 0x18, 0x1F, 0x2D, 0x0A, 0x0A, 0x27, 0x27},
-	{2048, 8000, 16384000, 0x60, 0x00, 0x00, 0x35, 0x0A, 0x1B, 0x1F, 0x7F},
-	{2304, 8000, 18432000, 0x40, 0x02, 0x10, 0x35, 0x0A, 0x1B, 0x1F, 0x5F},
-	{3072, 8000, 24576000, 0x60, 0x02, 0x10, 0x35, 0x0A, 0x1B, 0x1F, 0x7F},
-	{3250, 8000, 26000000, 0x0C, 0x18, 0x0F, 0x2D, 0x0A, 0x0A, 0x27, 0x27},
-
+static const struct es8326_clk_coeff es8326_coeff_div[] = {
+	{  32,  8000,   256000, 0x60, 0x00, 0x0f, 0x75, 0x0a, 0x1b, 0x1f, 0x7f},
+	{  32, 16000,   512000, 0x20, 0x00, 0x0d, 0x75, 0x0a, 0x1b, 0x1f, 0x3f},
+	{  32, 44100,  1411200, 0x00, 0x00, 0x13, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{  32, 48000,  1536000, 0x00, 0x00, 0x13, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{  36,  8000,   288000, 0x20, 0x00, 0x0d, 0x75, 0x0a, 0x1b, 0x23, 0x47},
+	{  36, 16000,   576000, 0x20, 0x00, 0x0d, 0x75, 0x0a, 0x1b, 0x23, 0x47},
+	{  48,  8000,   384000, 0x60, 0x02, 0x1f, 0x75, 0x0a, 0x1b, 0x1f, 0x7f},
+	{  48, 16000,   768000, 0x20, 0x02, 0x0f, 0x75, 0x0a, 0x1b, 0x1f, 0x3f},
+	{  48, 48000,  2304000, 0x00, 0x02, 0x0d, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{  64,  8000,   512000, 0x60, 0x00, 0x0d, 0x75, 0x0a, 0x1b, 0x1f, 0x7f},
+	{  64, 16000,  1024000, 0x20, 0x00, 0x05, 0x75, 0x0a, 0x1b, 0x1f, 0x3f},
+
+	{  64, 44100,  2822400, 0x00, 0x00, 0x11, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{  64, 48000,  3072000, 0x00, 0x00, 0x11, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{  72,  8000,   576000, 0x20, 0x00, 0x13, 0x35, 0x0a, 0x1b, 0x23, 0x47},
+	{  72, 16000,  1152000, 0x20, 0x00, 0x05, 0x75, 0x0a, 0x1b, 0x23, 0x47},
+	{  96,  8000,   768000, 0x60, 0x02, 0x1d, 0x75, 0x0a, 0x1b, 0x1f, 0x7f},
+	{  96, 16000,  1536000, 0x20, 0x02, 0x0d, 0x75, 0x0a, 0x1b, 0x1f, 0x3f},
+	{ 100, 48000,  4800000, 0x04, 0x04, 0x1f, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 125, 48000,  6000000, 0x04, 0x04, 0x1f, 0x2d, 0x0a, 0x0a, 0x27, 0x27},
+	{ 128,  8000,  1024000, 0x60, 0x00, 0x13, 0x35, 0x0a, 0x1b, 0x1f, 0x7f},
+	{ 128, 16000,  2048000, 0x20, 0x00, 0x11, 0x35, 0x0a, 0x1b, 0x1f, 0x3f},
+
+	{ 128, 44100,  5644800, 0x00, 0x00, 0x01, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 128, 48000,  6144000, 0x00, 0x00, 0x01, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 144,  8000,  1152000, 0x20, 0x00, 0x03, 0x35, 0x0a, 0x1b, 0x23, 0x47},
+	{ 144, 16000,  2304000, 0x20, 0x00, 0x11, 0x35, 0x0a, 0x1b, 0x23, 0x47},
+	{ 192,  8000,  1536000, 0x60, 0x02, 0x0d, 0x75, 0x0a, 0x1b, 0x1f, 0x7f},
+	{ 192, 16000,  3072000, 0x20, 0x02, 0x05, 0x75, 0x0a, 0x1b, 0x1f, 0x3f},
+	{ 200, 48000,  9600000, 0x04, 0x04, 0x0f, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 250, 48000, 12000000, 0x04, 0x04, 0x0f, 0x2d, 0x0a, 0x0a, 0x27, 0x27},
+	{ 256,  8000,  2048000, 0x60, 0x00, 0x11, 0x35, 0x0a, 0x1b, 0x1f, 0x7f},
+	{ 256, 16000,  4096000, 0x20, 0x00, 0x01, 0x35, 0x0a, 0x1b, 0x1f, 0x3f},
+
+	{ 256, 44100, 11289600, 0x00, 0x00, 0x10, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 256, 48000, 12288000, 0x00, 0x00, 0x10, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 288,  8000,  2304000, 0x20, 0x00, 0x01, 0x35, 0x0a, 0x1b, 0x23, 0x47},
+	{ 384,  8000,  3072000, 0x60, 0x02, 0x05, 0x75, 0x0a, 0x1b, 0x1f, 0x7f},
+	{ 384, 16000,  6144000, 0x20, 0x02, 0x03, 0x35, 0x0a, 0x1b, 0x1f, 0x3f},
+	{ 384, 48000, 18432000, 0x00, 0x02, 0x01, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 400, 48000, 19200000, 0x09, 0x04, 0x0f, 0x6d, 0x3a, 0x0a, 0x4f, 0x1f},
+	{ 500, 48000, 24000000, 0x18, 0x04, 0x1f, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 512,  8000,  4096000, 0x60, 0x00, 0x01, 0x35, 0x0a, 0x1b, 0x1f, 0x7f},
+	{ 512, 16000,  8192000, 0x20, 0x00, 0x10, 0x35, 0x0a, 0x1b, 0x1f, 0x3f},
+
+	{ 512, 44100, 22579200, 0x00, 0x00, 0x00, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 512, 48000, 24576000, 0x00, 0x00, 0x00, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 768,  8000,  6144000, 0x60, 0x02, 0x11, 0x35, 0x0a, 0x1b, 0x1f, 0x7f},
+	{ 768, 16000, 12288000, 0x20, 0x02, 0x01, 0x35, 0x0a, 0x1b, 0x1f, 0x3f},
+	{ 800, 48000, 38400000, 0x00, 0x18, 0x13, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 812, 16000, 13000000, 0x0c, 0x04, 0x0f, 0x2d, 0x0a, 0x0a, 0x31, 0x31},
+	{1024,  8000,  8192000, 0x60, 0x00, 0x10, 0x35, 0x0a, 0x1b, 0x1f, 0x7f},
+	{1024, 16000, 16384000, 0x20, 0x00, 0x00, 0x35, 0x0a, 0x1b, 0x1f, 0x3f},
+	{1152, 16000, 18432000, 0x20, 0x08, 0x11, 0x35, 0x0a, 0x1b, 0x1f, 0x3f},
+	{1536,  8000, 12288000, 0x60, 0x02, 0x01, 0x35, 0x0a, 0x1b, 0x1f, 0x7f},
+
+	{1536, 16000, 24576000, 0x20, 0x02, 0x10, 0x35, 0x0a, 0x1b, 0x1f, 0x3f},
+	{1625,  8000, 13000000, 0x0c, 0x18, 0x1f, 0x2d, 0x0a, 0x0a, 0x27, 0x27},
+	{1625, 16000, 26000000, 0x0c, 0x18, 0x1f, 0x2d, 0x0a, 0x0a, 0x27, 0x27},
+	{2048,  8000, 16384000, 0x60, 0x00, 0x00, 0x35, 0x0a, 0x1b, 0x1f, 0x7f},
+	{2304,  8000, 18432000, 0x40, 0x02, 0x10, 0x35, 0x0a, 0x1b, 0x1f, 0x5f},
+	{3072,  8000, 24576000, 0x60, 0x02, 0x10, 0x35, 0x0a, 0x1b, 0x1f, 0x7f},
+	{3250,  8000, 26000000, 0x0c, 0x18, 0x0f, 0x2d, 0x0a, 0x0a, 0x27, 0x27},
+	{  21, 48000,  1024320, 0x00, 0x00, 0x09, 0x2d, 0x0a, 0x0a, 0x1f, 0x1f},
+	{ 541, 48000, 26000000, 0x00, 0x00, 0x00, 0x35, 0x0a, 0x1b, 0x20, 0x20},
 };
 
-static inline int get_coeff(int mclk, int rate)
+static const struct es8326_clk_coeff *es8326_get_coeff(int mclk, int rate)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
-		if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
-			return i;
+	for (i = 0; i < ARRAY_SIZE(es8326_coeff_div); i++) {
+		if (es8326_coeff_div[i].rate == rate &&
+		    es8326_coeff_div[i].mclk == mclk)
+			return &es8326_coeff_div[i];
 	}
 
-	return -EINVAL;
+	return NULL;
 }
 
+/* The set of rates we can generate from the above for each SYSCLK */
+
+static unsigned int es8326_rates_12288[] = {
+	8000, 12000, 16000, 24000, 24000, 32000, 48000, 96000,
+};
+
+static struct snd_pcm_hw_constraint_list es8326_constraints_12288 = {
+	.count = ARRAY_SIZE(es8326_rates_12288),
+	.list = es8326_rates_12288,
+};
+
+static unsigned int es8326_rates_112896[] = {
+	8000, 11025, 22050, 44100,
+};
+
+static struct snd_pcm_hw_constraint_list es8326_constraints_112896 = {
+	.count = ARRAY_SIZE(es8326_rates_112896),
+	.list = es8326_rates_112896,
+};
+
+static unsigned int es8326_rates_12[] = {
+	8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
+	48000, 88235, 96000,
+};
+
+static struct snd_pcm_hw_constraint_list es8326_constraints_12 = {
+	.count = ARRAY_SIZE(es8326_rates_12),
+	.list = es8326_rates_12,
+};
+
+/*
+ * Note that this should be called from init rather than from hw_params.
+ */
 static int es8326_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 				 int clk_id, unsigned int freq, int dir)
 {
-	struct snd_soc_component *codec = codec_dai->component;
-	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(codec);
+	struct snd_soc_component *component = codec_dai->component;
+	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
+	int ret;
 
 	es8326->sysclk = freq;
 
-	return 0;
-}
+	if (freq == 0) {
+		es8326->sysclk_constraints.list = NULL;
+		es8326->sysclk_constraints.count = 0;
 
-static int es8326_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
-{
-	struct snd_soc_component *component = codec_dai->component;
-	u8 iface = 0;
+		return 0;
+	}
+
+	ret = clk_set_rate(es8326->mclk, freq);
+	if (ret)
+		return ret;
+
+	switch (freq) {
+	case 11289600:
+	case 18432000:
+	case 22579200:
+	case 36864000:
+		es8326->sysclk_constraints = es8326_constraints_112896;
+		return 0;
+
+	case 12288000:
+	case 16934400:
+	case 24576000:
+	case 33868800:
+		es8326->sysclk_constraints = es8326_constraints_12288;
+		return 0;
+
+	case 12000000:
+	case 19200000:
+	case 24000000:
+		es8326->sysclk_constraints = es8326_constraints_12;
+		return 0;
 
-	switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
-	case SND_SOC_DAIFMT_CBC_CFP:
-		snd_soc_component_update_bits(component, ES8326_RESET,
-					      ES8326_MASTER_MODE_EN, ES8326_MASTER_MODE_EN);
-		break;
-	case SND_SOC_DAIFMT_CBC_CFC:
-		break;
 	default:
 		return -EINVAL;
 	}
+}
+
+static int es8326_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
+{
+	struct snd_soc_component *component = codec_dai->component;
+	u8 iface;
 
 	/* interface format */
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
+		iface = ES8326_FMT_SDP_FMT_I2S;
 		break;
-	case SND_SOC_DAIFMT_RIGHT_J:
-		dev_err(component->dev, "Codec driver does not support right justified\n");
-		return -EINVAL;
 	case SND_SOC_DAIFMT_LEFT_J:
-		iface |= ES8326_DAIFMT_LEFT_J;
+		iface = ES8326_FMT_SDP_FMT_LJ;
 		break;
 	case SND_SOC_DAIFMT_DSP_A:
-		iface |= ES8326_DAIFMT_DSP_A;
-		break;
 	case SND_SOC_DAIFMT_DSP_B:
-		iface |= ES8326_DAIFMT_DSP_B;
+		iface = ES8326_FMT_SDP_FMT_DSP;
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	snd_soc_component_update_bits(component, ES8326_FMT, ES8326_DAIFMT_MASK, iface);
+	snd_soc_component_write(component, ES8326_FMT, iface);
+	snd_soc_component_update_bits(component, ES8326_FMT,
+				      ES8326_FMT_SDP_FMT_MASK, iface);
+
+	return 0;
+}
+
+static int es8326_pcm_startup(struct snd_pcm_substream *substream,
+			      struct snd_soc_dai *dai)
+{
+	struct snd_soc_component *component = dai->component;
+	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
+
+	/* The set of sample rates that can be supported depends on the
+	 * MCLK supplied to the CODEC - enforce this.
+	 */
+
+	if (es8326->sysclk_constraints.list)
+		snd_pcm_hw_constraint_list(substream->runtime, 0,
+					   SNDRV_PCM_HW_PARAM_RATE,
+					   &es8326->sysclk_constraints);
 
 	return 0;
 }
@@ -367,334 +415,281 @@ static int es8326_pcm_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_component *component = dai->component;
 	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
-	u8 srate = 0;
-	int coeff;
+	const struct es8326_clk_coeff *coeff;
+	u8 wordlen;
+
+	coeff = es8326_get_coeff(es8326->sysclk, params_rate(params));
+	if (!coeff)
+		return -EINVAL;
 
-	coeff = get_coeff(es8326->sysclk, params_rate(params));
 	/* bit size */
 	switch (params_format(params)) {
 	case SNDRV_PCM_FORMAT_S16_LE:
-		srate |= ES8326_S16_LE;
+		wordlen = ES8326_FMT_SDP_WL_16;
 		break;
 	case SNDRV_PCM_FORMAT_S20_3LE:
-		srate |= ES8326_S20_3_LE;
+		wordlen = ES8326_FMT_SDP_WL_20;
 		break;
 	case SNDRV_PCM_FORMAT_S18_3LE:
-		srate |= ES8326_S18_LE;
+		wordlen = ES8326_FMT_SDP_WL_18;
 		break;
 	case SNDRV_PCM_FORMAT_S24_LE:
-		srate |= ES8326_S24_LE;
+		wordlen = ES8326_FMT_SDP_WL_24;
 		break;
 	case SNDRV_PCM_FORMAT_S32_LE:
-		srate |= ES8326_S32_LE;
+		wordlen = ES8326_FMT_SDP_WL_32;
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	/* set iface & srate */
-	snd_soc_component_update_bits(component, ES8326_FMT, ES8326_DATA_LEN_MASK, srate);
-
-	if (coeff >= 0) {
-		regmap_write(es8326->regmap,  ES8326_CLK_DIV1,
-			     coeff_div[coeff].reg4);
-		regmap_write(es8326->regmap,  ES8326_CLK_DIV2,
-			     coeff_div[coeff].reg5);
-		regmap_write(es8326->regmap,  ES8326_CLK_DLL,
-			     coeff_div[coeff].reg6);
-		regmap_write(es8326->regmap,  ES8326_CLK_MUX,
-			     coeff_div[coeff].reg7);
-		regmap_write(es8326->regmap,  ES8326_CLK_ADC_SEL,
-			     coeff_div[coeff].reg8);
-		regmap_write(es8326->regmap,  ES8326_CLK_DAC_SEL,
-			     coeff_div[coeff].reg9);
-		regmap_write(es8326->regmap,  ES8326_CLK_ADC_OSR,
-			     coeff_div[coeff].rega);
-		regmap_write(es8326->regmap,  ES8326_CLK_DAC_OSR,
-			     coeff_div[coeff].regb);
-	} else {
-		dev_warn(component->dev, "Clock coefficients do not match");
-	}
-
+	snd_soc_component_update_bits(component, ES8326_FMT,
+				      ES8326_FMT_SDP_WL_MASK, wordlen);
+
+	snd_soc_component_write(component, ES8326_CLK_DIV1, coeff->reg4);
+	snd_soc_component_write(component, ES8326_CLK_DIV2, coeff->reg5);
+	snd_soc_component_write(component, ES8326_CLK_DLL, coeff->reg6);
+	snd_soc_component_write(component, ES8326_CLK_MUX, coeff->reg7);
+	snd_soc_component_write(component, ES8326_CLK_ADC_SEL, coeff->reg8);
+	snd_soc_component_write(component, ES8326_CLK_DAC_SEL, coeff->reg9);
+	snd_soc_component_write(component, ES8326_CLK_ADC_OSR, coeff->rega);
+	snd_soc_component_write(component, ES8326_CLK_DAC_OSR, coeff->regb);
 	return 0;
 }
 
-static int es8326_set_bias_level(struct snd_soc_component *codec,
-				 enum snd_soc_bias_level level)
+static int es8326_mute(struct snd_soc_dai *dai, int mute, int stream)
 {
-	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(codec);
-	int ret;
-
-	switch (level) {
-	case SND_SOC_BIAS_ON:
-		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_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_PGA_PDN, 0x40);
-		regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0xAA);
-		regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON);
-		break;
-	case SND_SOC_BIAS_PREPARE:
+	switch (stream) {
+	case SNDRV_PCM_STREAM_PLAYBACK:
+		snd_soc_component_update_bits(dai->component, ES8326_DAC_MUTE,
+				ES8326_DAC_MUTE_S2P_MUTE_MASK,
+				mute ?  ES8326_DAC_MUTE_S2P_MUTE_MASK : 0);
 		break;
-	case SND_SOC_BIAS_STANDBY:
-		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_VMIDSEL, 0x00);
-		regmap_write(es8326->regmap, ES8326_INT_SOURCE, 0x08);
-		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);
+	case SNDRV_PCM_STREAM_CAPTURE:
+		snd_soc_component_update_bits(dai->component, ES8326_ADC_MUTE,
+				ES8326_ADC_MUTE_P2S_MUTE_MASK,
+				mute ? ES8326_ADC_MUTE_P2S_MUTE_MASK : 0);
 		break;
 	}
 
 	return 0;
 }
 
-#define es8326_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
-	SNDRV_PCM_FMTBIT_S24_LE)
+#define ES8326_FORMATS	(SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
+			 SNDRV_PCM_FMTBIT_S24_LE)
 
-static const struct snd_soc_dai_ops es8326_ops = {
+static struct snd_soc_dai_ops es8326_ops = {
+	.startup = es8326_pcm_startup,
 	.hw_params = es8326_pcm_hw_params,
 	.set_fmt = es8326_set_dai_fmt,
 	.set_sysclk = es8326_set_dai_sysclk,
+	.mute_stream = es8326_mute,
 };
 
 static struct snd_soc_dai_driver es8326_dai = {
-	.name = "ES8326 HiFi",
+	.name = "ES8316 HiFi",
 	.playback = {
 		.stream_name = "Playback",
 		.channels_min = 1,
 		.channels_max = 2,
-		.rates = SNDRV_PCM_RATE_8000_48000,
-		.formats = es8326_FORMATS,
-		},
+		.rates = SNDRV_PCM_RATE_8000_96000,
+		.formats = ES8326_FORMATS,
+	},
 	.capture = {
 		.stream_name = "Capture",
 		.channels_min = 1,
 		.channels_max = 2,
-		.rates = SNDRV_PCM_RATE_8000_48000,
-		.formats = es8326_FORMATS,
-		},
+		.rates = SNDRV_PCM_RATE_8000_96000,
+		.formats = ES8326_FORMATS,
+	},
 	.ops = &es8326_ops,
 	.symmetric_rate = 1,
 };
 
-static void es8326_enable_micbias(struct snd_soc_component *component)
+static void es8326_enable_micbias_for_mic_gnd_short_detect(
+					struct snd_soc_component *component)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
 
-	snd_soc_dapm_mutex_lock(dapm);
-	snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS1");
-	snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS2");
-	snd_soc_dapm_sync_unlocked(dapm);
-	snd_soc_dapm_mutex_unlock(dapm);
+	snd_soc_dapm_force_enable_pin(dapm, "Mic Bias");
+
+	msleep(500);
 }
 
-static void es8326_disable_micbias(struct snd_soc_component *component)
+static void es8326_disable_micbias_for_mic_gnd_short_detect(
+					struct snd_soc_component *component)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
 
-	snd_soc_dapm_mutex_lock(dapm);
-	snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS1");
-	snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS2");
-	snd_soc_dapm_sync_unlocked(dapm);
-	snd_soc_dapm_mutex_unlock(dapm);
+	snd_soc_dapm_disable_pin(dapm, "Mic Bias");
 }
 
-/*
- *	For button detection, set the following in soundcard
- *	snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
- *	snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
- *	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
- */
-static void es8326_jack_button_handler(struct work_struct *work)
+static irqreturn_t es8326_irq(int irq, void *data)
 {
-	struct es8326_priv *es8326 =
-		container_of(work, struct es8326_priv, button_press_work.work);
+	struct es8326_priv *es8326 = data;
 	struct snd_soc_component *comp = es8326->component;
-	unsigned int iface;
-	static int button_to_report, press_count;
-	static int prev_button, cur_button;
-
-	if (!(es8326->jack->status & SND_JACK_HEADSET)) /* Jack unplugged */
-		return;
+	unsigned int flags;
 
 	mutex_lock(&es8326->lock);
-	iface = snd_soc_component_read(comp, ES8326_HP_DETECT);
-	switch (iface) {
-	case 0x93:
-		/* pause button detected */
-		cur_button = SND_JACK_BTN_0;
-		break;
-	case 0x6f:
-		/* button volume up */
-		cur_button = SND_JACK_BTN_1;
-		break;
-	case 0x27:
-		/* button volume down */
-		cur_button = SND_JACK_BTN_2;
-		break;
-	case 0x1e:
-		/* button released or not pressed */
-		cur_button = 0;
-		break;
-	default:
-		break;
-	}
 
-	if ((prev_button == cur_button) && (cur_button != 0)) {
-		press_count++;
-		if (press_count > 10) {
-			/* report a press every 500ms */
-			snd_soc_jack_report(es8326->jack, cur_button,
-					SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2);
-			press_count = 0;
-		}
-		button_to_report = cur_button;
-		queue_delayed_work(system_wq, &es8326->button_press_work,
-				   msecs_to_jiffies(50));
-	} else if (prev_button != cur_button) {
-		/* mismatch, detect again */
-		prev_button = cur_button;
-		queue_delayed_work(system_wq, &es8326->button_press_work,
-				   msecs_to_jiffies(50));
+	/* Catch spurious IRQ before set_jack is called */
+	if (!es8326->jack)
+		goto out;
+
+	es8326_enable_micbias_for_mic_gnd_short_detect(comp);
+
+	regmap_read(es8326->regmap, ES8326_HP_DETECT, &flags);
+	if (es8326->jd_inverted)
+		flags ^= ES8326_HP_DETECT_NOT_INSERTED;
+
+	dev_dbg(comp->dev, "flags: %#04x\n", flags);
+	if (flags & ES8326_HP_DETECT_NOT_INSERTED) {
+		snd_soc_jack_report(es8326->jack, 0,
+				    SND_JACK_HEADSET | SND_JACK_BTN_0);
+		dev_dbg(comp->dev, "jack unplugged\n");
 	} else {
-		/* released or no pressed */
-		if (button_to_report != 0) {
-			snd_soc_jack_report(es8326->jack, button_to_report,
-				    SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2);
-			snd_soc_jack_report(es8326->jack, 0,
-				    SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2);
-			button_to_report = 0;
+		if (flags & ES8326_HP_DETECT_GM_NOT_SHORTED) {
+			dev_dbg(comp->dev, "headphones detected\n");
+			snd_soc_jack_report(es8326->jack, SND_JACK_HEADPHONE,
+					    SND_JACK_HEADSET);
+		} else {
+			dev_dbg(comp->dev, "headset detected\n");
+			snd_soc_jack_report(es8326->jack, SND_JACK_HEADSET,
+					    SND_JACK_HEADSET);
 		}
 	}
+
+	if (!(es8326->jack->status & SND_JACK_MICROPHONE))
+		es8326_disable_micbias_for_mic_gnd_short_detect(comp);
+out:
 	mutex_unlock(&es8326->lock);
+	return IRQ_HANDLED;
 }
 
-static void es8326_jack_detect_handler(struct work_struct *work)
+static void es8326_enable_jack_detect(struct snd_soc_component *component,
+				      struct snd_soc_jack *jack)
 {
-	struct es8326_priv *es8326 =
-		container_of(work, struct es8326_priv, jack_detect_work.work);
-	struct snd_soc_component *comp = es8326->component;
-	unsigned int iface;
+	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
+
+	/*
+	 * Init es8326->jd_inverted here and not in the probe, as we cannot
+	 * guarantee that the sof-essx8336 driver, which might set this
+	 * property, will probe before us.
+	 */
+	es8326->jd_inverted =
+		device_property_read_bool(component->dev,
+					  "everest,jack-detect-inverted");
 
 	mutex_lock(&es8326->lock);
-	iface = snd_soc_component_read(comp, ES8326_HP_DETECT);
-	dev_dbg(comp->dev, "gpio flag %#04x", iface);
-	if ((iface & ES8326_HPINSERT_FLAG) == 0) {
-		/* Jack unplugged or spurious IRQ */
-		dev_dbg(comp->dev, "No headset detected");
-		if (es8326->jack->status & SND_JACK_HEADPHONE) {
-			snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET);
-			snd_soc_component_write(comp, ES8326_ADC1_SRC, es8326->mic2_src);
-			es8326_disable_micbias(comp);
-		}
-	} else if ((iface & ES8326_HPINSERT_FLAG) == ES8326_HPINSERT_FLAG) {
-		if (es8326->jack->status & SND_JACK_HEADSET) {
-			/* detect button */
-			queue_delayed_work(system_wq, &es8326->button_press_work, 10);
-		} else {
-			if ((iface & ES8326_HPBUTTON_FLAG) == 0x00) {
-				dev_dbg(comp->dev, "Headset detected");
-				snd_soc_jack_report(es8326->jack,
-						    SND_JACK_HEADSET, SND_JACK_HEADSET);
-				snd_soc_component_write(comp,
-							ES8326_ADC1_SRC, es8326->mic1_src);
-			} else {
-				dev_dbg(comp->dev, "Headphone detected");
-				snd_soc_jack_report(es8326->jack,
-						    SND_JACK_HEADPHONE, SND_JACK_HEADSET);
-			}
-		}
-	}
+
+	es8326->jack = jack;
+
+	snd_soc_component_write(component, ES8326_HPJACK_POL,
+				ES8326_HPJACK_POL_HP_TYPE_CTIA |
+				ES8326_HPJACK_POL_BUTTON_POL_ACTIVE_LOW |
+				ES8326_HPJACK_POL_HPJACK_POL_ACTIVE_LOW |
+				ES8326_HPJACK_POL_HPINSERT_SEL_PIN9);
+	snd_soc_component_write(component, ES8326_INT_SOURCE,
+				ES8326_INT_SOURCE_BUTTON |
+				ES8326_INT_SOURCE_PIN9);
+
 	mutex_unlock(&es8326->lock);
+
+	/* Enable irq and sync initial jack state */
+	enable_irq(es8326->irq);
+	es8326_irq(es8326->irq, es8326);
 }
 
-static irqreturn_t es8326_irq(int irq, void *dev_id)
+static void es8326_disable_jack_detect(struct snd_soc_component *component)
 {
-	struct es8326_priv *es8326 = dev_id;
-	struct snd_soc_component *comp = es8326->component;
+	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
 
-	if (!es8326->jack)
-		goto out;
+	disable_irq(es8326->irq);
 
-	es8326_enable_micbias(comp);
+	mutex_lock(&es8326->lock);
 
-	if (es8326->jack->status & SND_JACK_HEADSET)
-		queue_delayed_work(system_wq, &es8326->jack_detect_work,
-				   msecs_to_jiffies(10));
-	else
-		queue_delayed_work(system_wq, &es8326->jack_detect_work,
-				   msecs_to_jiffies(300));
+	snd_soc_component_write(component, ES8326_INT_SOURCE, 0);
 
-out:
-	return IRQ_HANDLED;
-}
+	if (es8326->jack->status & SND_JACK_MICROPHONE)
+		snd_soc_jack_report(es8326->jack, 0, SND_JACK_BTN_0);
 
-static int es8326_resume(struct snd_soc_component *component)
-{
-	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
-	unsigned int reg;
+	es8326->jack = NULL;
 
-	regcache_cache_only(es8326->regmap, false);
-	regcache_sync(es8326->regmap);
+	mutex_unlock(&es8326->lock);
+}
 
-	regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON);
-	/* Two channel ADC */
-	regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x02);
-	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_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_RESET, ES8326_CSM_ON);
-	snd_soc_component_update_bits(component, 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);
-	}
+static int es8326_set_jack(struct snd_soc_component *component,
+			   struct snd_soc_jack *jack, void *data)
+{
+	if (jack)
+		es8326_enable_jack_detect(component, jack);
+	else
+		es8326_disable_jack_detect(component);
 
-	es8326_irq(es8326->irq, es8326);
 	return 0;
 }
 
-static int es8326_suspend(struct snd_soc_component *component)
+static int es8326_set_bias_level(struct snd_soc_component *component,
+				 enum snd_soc_bias_level level)
 {
-	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
+	switch (level) {
+	case SND_SOC_BIAS_ON:
+		dev_dbg(component->dev, "%s on\n", __func__);
+		snd_soc_component_write(component, ES8326_HP_DRIVER, 0);
+		snd_soc_component_write(component, ES8326_ANA_PWR, 0);
+		snd_soc_component_update_bits(component, ES8326_PGA_PWR,
+					      ES8326_PGA_PWR_PDN_PGA |
+					      ES8326_PGA_PWR_PDN_MOD |
+					      ES8326_PGA_PWR_MODTOP_RST,
+					      0);
+		snd_soc_component_write(component, ES8326_VMIDSEL,
+					ES8326_VMIDSEL_NORMAL);
+		break;
 
-	cancel_delayed_work_sync(&es8326->jack_detect_work);
-	es8326_disable_micbias(component);
+	case SND_SOC_BIAS_PREPARE:
+		dev_dbg(component->dev, "%s prepare\n", __func__);
+		break;
 
-	regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_OFF);
-	regcache_cache_only(es8326->regmap, true);
-	regcache_mark_dirty(es8326->regmap);
+	case SND_SOC_BIAS_STANDBY:
+		dev_dbg(component->dev, "%s standby\n", __func__);
+		snd_soc_component_update_bits(component, ES8326_HP_DRIVER,
+					      ES8326_HP_DRIVER_LP_MASK,
+					      ES8326_HP_DRIVER_LP_MASK);
+		snd_soc_component_update_bits(component, ES8326_ANA_PWR,
+					      ES8326_ANA_PWR_LP_DAC,
+					      ES8326_ANA_PWR_LP_DAC);
+		break;
+
+	case SND_SOC_BIAS_OFF:
+		dev_dbg(component->dev, "%s off\n", __func__);
+		snd_soc_component_write(component, ES8326_VMIDSEL,
+					ES8326_VMIDSEL_POWER_DOWN);
+		snd_soc_component_update_bits(component, ES8326_PGA_PWR,
+					      ES8326_PGA_PWR_PDN_PGA |
+					      ES8326_PGA_PWR_PDN_MOD |
+					      ES8326_PGA_PWR_MODTOP_RST,
+					      ES8326_PGA_PWR_PDN_PGA |
+					      ES8326_PGA_PWR_PDN_MOD |
+					      ES8326_PGA_PWR_MODTOP_RST);
+		snd_soc_component_write(component, ES8326_ANA_PWR,
+					ES8326_ANA_PWR_PDN_DACR |
+					ES8326_ANA_PWR_PDN_DACL |
+					ES8326_ANA_PWR_LP_DAC |
+					ES8326_ANA_PWR_PDN_VRP |
+					ES8326_ANA_PWR_PDN_DACVREFGEN |
+					ES8326_ANA_PWR_PDN_ADCVREFGEN |
+					ES8326_ANA_PWR_PDN_IBIASGEN |
+					ES8326_ANA_PWR_PDN_ANA);
+		snd_soc_component_update_bits(component, ES8326_HP_DRIVER,
+					      ES8326_HP_DRIVER_PDN_MASK |
+					      ES8326_HP_DRIVER_ENREFR_HP,
+					      ES8326_HP_DRIVER_PDN_MASK |
+					      ES8326_HP_DRIVER_ENREFR_HP);
+		break;
+
+	default:
+		break;
+	}
 
 	return 0;
 }
@@ -705,172 +700,161 @@ static int es8326_probe(struct snd_soc_component *component)
 	int ret;
 
 	es8326->component = component;
-	es8326->jd_inverted = device_property_read_bool(component->dev,
-							"everest,jack-detect-inverted");
-
-	ret = device_property_read_u8(component->dev, "everest,mic1-src", &es8326->mic1_src);
-	if (ret != 0) {
-		dev_dbg(component->dev, "mic1-src return %d", ret);
-		es8326->mic1_src = ES8326_ADC_AMIC;
-	}
-	dev_dbg(component->dev, "mic1-src %x", es8326->mic1_src);
-
-	ret = device_property_read_u8(component->dev, "everest,mic2-src", &es8326->mic2_src);
-	if (ret != 0) {
-		dev_dbg(component->dev, "mic2-src return %d", ret);
-		es8326->mic2_src = ES8326_ADC_DMIC;
-	}
-	dev_dbg(component->dev, "mic2-src %x", es8326->mic2_src);
-
-	ret = device_property_read_u8(component->dev, "everest,jack-pol", &es8326->jack_pol);
-	if (ret != 0) {
-		dev_dbg(component->dev, "jack-pol return %d", ret);
-		es8326->jack_pol = ES8326_HP_DET_BUTTON_POL | ES8326_HP_TYPE_OMTP;
-	}
-	dev_dbg(component->dev, "jack-pol %x", es8326->jack_pol);
 
-	ret = device_property_read_u8(component->dev, "everest,interrupt-src",
-				      &es8326->interrupt_src);
-	if (ret != 0) {
-		dev_dbg(component->dev, "interrupt-src return %d", ret);
-		es8326->interrupt_src = ES8326_HP_DET_SRC_PIN9;
+	es8326->mclk = devm_clk_get_optional(component->dev, "mclk");
+	if (IS_ERR(es8326->mclk)) {
+		dev_err(component->dev,"unable to get mclk\n");
+		return PTR_ERR(es8326->mclk);
 	}
-	dev_dbg(component->dev, "interrupt-src %x", es8326->interrupt_src);
+	if (!es8326->mclk)
+		dev_warn(component->dev,"assuming static mclk\n");
 
-	ret = device_property_read_u8(component->dev, "everest,interrupt-clk",
-				      &es8326->interrupt_clk);
-	if (ret != 0) {
-		dev_dbg(component->dev, "interrupt-clk return %d", ret);
-		es8326->interrupt_clk = 0x45;
+	ret = clk_prepare_enable(es8326->mclk);
+	if (ret) {
+		dev_err(component->dev,"unable to enable mclk\n");
+		return ret;
 	}
-	dev_dbg(component->dev, "interrupt-clk %x", es8326->interrupt_clk);
 
-	es8326_resume(component);
+	snd_soc_component_init_regmap(component, es8326->regmap);
+
+	/* Reset codec and enable current state machine */
+	snd_soc_component_write(component, ES8326_RESET, ES8326_RESET_RST_MASK);
+	usleep_range(5000, 5500);
+	snd_soc_component_write(component, ES8326_RESET, ES8326_RESET_CSM_ON);
+	msleep(30);
+
+	snd_soc_component_write(component, ES8326_PULLUP_CTL,
+				ES8326_PULLUP_CTL_ADC34_OFF);
+	snd_soc_component_write(component, ES8326_CLK_CTL,
+				ES8326_CLK_CTL_CLK9_ON |
+				ES8326_CLK_CTL_CLK8_ON |
+				ES8326_CLK_CTL_CLK3_ON |
+				ES8326_CLK_CTL_CLK1_ON |
+				ES8326_CLK_CTL_BCLK_ON |
+				ES8326_CLK_CTL_MCLK_ON |
+				ES8326_CLK_CTL_CPCLK_ON);
+	snd_soc_component_write(component, ES8326_CLK_RESAMPLE,
+				ES8326_CLK_RESAMPLE_OSC_EN_ALWAYS_ON |
+				ES8326_CLK_RESAMPLE_INTCLK_SEL_OSC);
+	snd_soc_component_write(component, ES8326_ADC_MUTE, 0);
+	snd_soc_component_update_bits(component, ES8326_PGAGAIN,
+				      ES8326_PGAGAIN_MIC1SEL,
+				      ES8326_PGAGAIN_MIC1SEL);
 	return 0;
 }
 
-static void es8326_enable_jack_detect(struct snd_soc_component *component,
-				struct snd_soc_jack *jack)
+static void es8326_remove(struct snd_soc_component *component)
 {
 	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
 
-	mutex_lock(&es8326->lock);
-	if (es8326->jd_inverted)
-		snd_soc_component_update_bits(component, ES8326_HP_DET,
-					      ES8326_HP_DET_JACK_POL, ~es8326->jack_pol);
-	es8326->jack = jack;
+	snd_soc_component_exit_regmap(component);
 
-	mutex_unlock(&es8326->lock);
-	es8326_irq(es8326->irq, es8326);
+	clk_disable_unprepare(es8326->mclk);
 }
 
-static void es8326_disable_jack_detect(struct snd_soc_component *component)
+#ifdef CONFIG_PM_SLEEP
+static int es8326_suspend(struct device *dev)
 {
-	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
+	struct es8326_priv *es8326 = dev_get_drvdata(dev);
 
-	dev_dbg(component->dev, "Enter into %s\n", __func__);
-	if (!es8326->jack)
-		return; /* Already disabled (or never enabled) */
-	cancel_delayed_work_sync(&es8326->jack_detect_work);
+	dev_dbg(dev, "%s: Enter\n", __func__);
 
-	mutex_lock(&es8326->lock);
-	if (es8326->jack->status & SND_JACK_MICROPHONE) {
-		es8326_disable_micbias(component);
-		snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET);
-	}
-	es8326->jack = NULL;
-	mutex_unlock(&es8326->lock);
+	regcache_cache_only(es8326->regmap, true);
+	regcache_mark_dirty(es8326->regmap);
+
+	return 0;
 }
 
-static int es8326_set_jack(struct snd_soc_component *component,
-			struct snd_soc_jack *jack, void *data)
+static int es8326_resume(struct device *dev)
 {
-	if (jack)
-		es8326_enable_jack_detect(component, jack);
-	else
-		es8326_disable_jack_detect(component);
+	struct es8326_priv *es8326 = dev_get_drvdata(dev);
+
+	dev_dbg(dev, "%s: Enter\n", __func__);
+
+	regcache_cache_only(es8326->regmap, false);
+	regcache_sync(es8326->regmap);
+
+	es8326_irq(es8326->irq, es8326);
 
 	return 0;
 }
+#endif
 
-static void es8326_remove(struct snd_soc_component *component)
-{
-	es8326_disable_jack_detect(component);
-	es8326_set_bias_level(component, SND_SOC_BIAS_OFF);
-}
+static const struct dev_pm_ops es8326_pm = {
+	SET_SYSTEM_SLEEP_PM_OPS(es8326_suspend, es8326_resume)
+};
 
-static const struct snd_soc_component_driver soc_component_dev_es8326 = {
-	.probe		= es8326_probe,
-	.remove		= es8326_remove,
-	.resume		= es8326_resume,
-	.suspend	= es8326_suspend,
-	.set_bias_level = es8326_set_bias_level,
-	.set_jack	= es8326_set_jack,
-	.dapm_widgets	= es8326_dapm_widgets,
+static struct snd_soc_component_driver soc_component_dev_es8326 = {
+	.probe			= es8326_probe,
+	.remove			= es8326_remove,
+	.set_bias_level		= es8326_set_bias_level,
+	.set_jack		= es8326_set_jack,
+	.controls		= es8326_snd_controls,
+	.num_controls		= ARRAY_SIZE(es8326_snd_controls),
+	.dapm_widgets		= es8326_dapm_widgets,
 	.num_dapm_widgets	= ARRAY_SIZE(es8326_dapm_widgets),
 	.dapm_routes		= es8326_dapm_routes,
 	.num_dapm_routes	= ARRAY_SIZE(es8326_dapm_routes),
-	.controls		= es8326_snd_controls,
-	.num_controls		= ARRAY_SIZE(es8326_snd_controls),
 	.use_pmdown_time	= 1,
 	.endianness		= 1,
 };
 
-static int es8326_i2c_probe(struct i2c_client *i2c,
+static const struct regmap_range es8326_volatile_ranges[] = {
+	regmap_reg_range(ES8326_HP_DETECT, ES8326_HP_DETECT),
+};
+
+static const struct regmap_access_table es8326_volatile_table = {
+	.yes_ranges	= es8326_volatile_ranges,
+	.n_yes_ranges	= ARRAY_SIZE(es8326_volatile_ranges),
+};
+
+static const struct regmap_config es8326_regmap = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = 0xff,
+	.volatile_table	= &es8326_volatile_table,
+	.cache_type = REGCACHE_RBTREE,
+	.use_single_read = true,
+	.use_single_write = true,
+};
+
+static int es8326_i2c_probe(struct i2c_client *i2c_client,
 			    const struct i2c_device_id *id)
 {
+	struct device *dev = &i2c_client->dev;
 	struct es8326_priv *es8326;
 	int ret;
 
-	es8326 = devm_kzalloc(&i2c->dev, sizeof(struct es8326_priv), GFP_KERNEL);
-	if (!es8326)
+	es8326 = devm_kzalloc(dev, sizeof(*es8326), GFP_KERNEL);
+	if (es8326 == NULL)
 		return -ENOMEM;
 
-	i2c_set_clientdata(i2c, es8326);
-	es8326->i2c = i2c;
+	i2c_set_clientdata(i2c_client, es8326);
+
+	es8326->regmap = devm_regmap_init_i2c(i2c_client, &es8326_regmap);
+	if (IS_ERR(es8326->regmap))
+		return PTR_ERR(es8326->regmap);
+
+	es8326->irq = i2c_client->irq;
 	mutex_init(&es8326->lock);
-	es8326->regmap = devm_regmap_init_i2c(i2c, &es8326_regmap_config);
-	if (IS_ERR(es8326->regmap)) {
-		ret = PTR_ERR(es8326->regmap);
-		dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret);
-		return ret;
-	}
 
-	es8326->irq = i2c->irq;
-	INIT_DELAYED_WORK(&es8326->jack_detect_work,
-			  es8326_jack_detect_handler);
-	INIT_DELAYED_WORK(&es8326->button_press_work,
-			  es8326_jack_button_handler);
-	/* ES8316 is level-based while ES8326 is edge-based */
-	ret = devm_request_threaded_irq(&i2c->dev, es8326->irq, NULL, es8326_irq,
-					IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+	ret = devm_request_threaded_irq(dev, es8326->irq, NULL, es8326_irq,
+					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
 					"es8326", es8326);
-	if (ret) {
-		dev_warn(&i2c->dev, "Failed to request IRQ: %d: %d\n",
-		es8326->irq, ret);
+	if (ret == 0) {
+		/* Gets re-enabled by es8326_set_jack() */
+		disable_irq(es8326->irq);
+	} else {
+		dev_warn(dev, "Failed to get IRQ %d: %d\n", es8326->irq, ret);
 		es8326->irq = -ENXIO;
 	}
 
-	es8326->mclk = devm_clk_get_optional(&i2c->dev, "mclk");
-	if (IS_ERR(es8326->mclk)) {
-		dev_err(&i2c->dev, "unable to get mclk\n");
-		return PTR_ERR(es8326->mclk);
-	}
-	if (!es8326->mclk)
-		dev_warn(&i2c->dev, "assuming static mclk\n");
-
-	ret = clk_prepare_enable(es8326->mclk);
-	if (ret) {
-		dev_err(&i2c->dev, "unable to enable mclk\n");
-		return ret;
-	}
-	return devm_snd_soc_register_component(&i2c->dev,
-					&soc_component_dev_es8326,
-					&es8326_dai, 1);
+	return devm_snd_soc_register_component(dev, &soc_component_dev_es8326,
+					       &es8326_dai, 1);
 }
 
 static const struct i2c_device_id es8326_i2c_id[] = {
-	{"es8326", 0 },
+	{"es8326", 0},
 	{}
 };
 MODULE_DEVICE_TABLE(i2c, es8326_i2c_id);
@@ -893,15 +877,16 @@ MODULE_DEVICE_TABLE(acpi, es8326_acpi_match);
 
 static struct i2c_driver es8326_i2c_driver = {
 	.driver = {
-		.name = "es8326",
-		.acpi_match_table = ACPI_PTR(es8326_acpi_match),
-		.of_match_table = of_match_ptr(es8326_of_match),
+		.name			= "es8326",
+		.acpi_match_table	= ACPI_PTR(es8326_acpi_match),
+		.of_match_table		= of_match_ptr(es8326_of_match),
+		.pm			= &es8326_pm,
 	},
-	.probe = es8326_i2c_probe,
-	.id_table = es8326_i2c_id,
+	.probe		= es8326_i2c_probe,
+	.id_table	= es8326_i2c_id,
 };
 module_i2c_driver(es8326_i2c_driver);
 
-MODULE_DESCRIPTION("ASoC es8326 driver");
-MODULE_AUTHOR("David Yang <yangxiaohua@everest-semi.com>");
-MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Everest Semi ES8326 ALSA SoC Codec Driver");
+MODULE_AUTHOR("David <zhuning@everset-semi.com>");
+MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/es8326.h b/sound/soc/codecs/es8326.h
index 8e5ffe5ee10da3..5a9396658aa23f 100644
--- a/sound/soc/codecs/es8326.h
+++ b/sound/soc/codecs/es8326.h
@@ -1,18 +1,27 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * es8326.h -- es8326 ALSA SoC audio driver
- * Copyright Everest Semiconductor Co.,Ltd
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Author: Richard Purdie <richard@openedhand.com>
+ *
+ * Based on ES8326.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
  *
- * Authors: David Yang <yangxiaohua@everest-semi.com>
  */
 
 #ifndef _ES8326_H
 #define _ES8326_H
 
-#define CONFIG_HHTECH_MINIPMP	1
+/*
+ * ES8326 register space
+ */
 
-/* ES8326 register space */
+/* Reset */
 #define ES8326_RESET		0x00
+
+/* Clock Manager */
 #define ES8326_CLK_CTL		0x01
 #define ES8326_CLK_INV		0x02
 #define ES8326_CLK_RESAMPLE	0x03
@@ -31,14 +40,17 @@
 #define ES8326_CLK_VMIDS1	0x10
 #define ES8326_CLK_VMIDS2	0x11
 #define ES8326_CLK_CAL_TIME	0x12
-#define ES8326_FMT		0x13
 
+/* SDP */
+#define ES8326_FMT		0x13
 #define ES8326_DAC_MUTE		0x14
 #define ES8326_ADC_MUTE		0x15
-#define ES8326_ANA_PDN		0x16
-#define ES8326_PGA_PDN		0x17
+
+/* Analog */
+#define ES8326_ANA_PWR		0x16
+#define ES8326_PGA_PWR		0x17
 #define ES8326_VMIDSEL		0x18
-#define ES8326_ANA_LP		0x19
+#define ES8326_ANA_LOWPOWER	0x19
 #define ES8326_ANA_DMS		0x1a
 #define ES8326_ANA_MICBIAS	0x1b
 #define ES8326_ANA_VSEL		0x1c
@@ -52,8 +64,10 @@
 #define ES8326_HP_DRIVER	0x24
 #define ES8326_DAC2HPMIX	0x25
 #define ES8326_HP_VOL		0x26
-#define ES8326_HP_CAL		0x27
+#define ES8326_HP_CTL		0x27
 #define ES8326_HP_DRIVER_REF	0x28
+
+/* ADC Control */
 #define ES8326_ADC_SCALE	0x29
 #define ES8326_ADC1_SRC		0x2a
 #define ES8326_ADC2_SRC		0x2b
@@ -65,118 +79,144 @@
 #define ES8326_ADC_HPFS1	0x34
 #define ES8326_ADC_HPFS2	0x35
 #define ES8326_ADC_EQ		0x36
-#define ES8326_HP_OFFSET_CAL	0x4A
-#define ES8326_HPL_OFFSET_INI	0x4B
-#define ES8326_HPR_OFFSET_INI	0x4C
-#define ES8326_DAC_DSM		0x4D
-#define ES8326_DAC_RAMPRATE	0x4E
-#define ES8326_DAC_VPPSCALE	0x4F
+
+/* DAC Control */
+#define ES8326_HP_CAL		0x4a
+#define ES8326_HPL_OFFSET_INI	0x4b
+#define ES8326_HPR_OFFSET_INI	0x4c
+#define ES8326_DAC_DSM		0x4d
+#define ES8326_DAC_RAMPRATE	0x4e
+#define ES8326_DAC_VPPSCALE	0x4f
 #define ES8326_DAC_VOL		0x50
 #define ES8326_DRC_RECOVERY	0x53
 #define ES8326_DRC_WINSIZE	0x54
+
+/* GPIO */
 #define ES8326_HPJACK_TIMER	0x56
-#define ES8326_HP_DET		0x57
+#define ES8326_HPJACK_POL	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_SDINOUT1_IO	0x5a
+#define ES8326_SDINOUT23_IO	0x5b
+#define ES8326_JACK_PULSE	0x5c
+
+/* Test Mode */
+#define ES8326_PULLUP_CTL	0xf9
 
-#define ES8326_PULLUP_CTL	0xF9
-#define ES8326_HP_DETECT	0xFB
-#define ES8326_CHIP_ID1		0xFD
-#define ES8326_CHIP_ID2		0xFE
-#define ES8326_CHIP_VERSION	0xFF
+#define ES8326_HP_DETECT	0xfb
+
+/* Chip ID */
+#define ES8326_CHIP_ID1		0xfd
+#define ES8326_CHIP_ID2		0xfe
+#define ES8326_CHIP_VERSION	0xff
+
+/*
+ * Field definitions
+ */
 
 /* ES8326_RESET */
-#define ES8326_CSM_ON (1 << 7)
-#define ES8326_MASTER_MODE_EN	(1 << 6)
-#define	ES8326_PWRUP_SEQ_EN	(1 << 5)
-#define ES8326_CODEC_RESET (0x0f << 0)
-#define ES8326_CSM_OFF (0 << 7)
+#define ES8326_RESET_RST_MASK			0x1f
+#define ES8326_RESET_RST_DACDIG			0x01
+#define ES8326_RESET_RST_ADCDIG			0x02
+#define ES8326_RESET_RST_MST			0x04
+#define ES8326_RESET_RST_CMG			0x08
+#define ES8326_RESET_RST_DIG			0x10
+#define ES8326_RESET_SEQ_DIS			0x20
+#define ES8326_RESET_MSC			0x40
+#define ES8326_RESET_CSM_ON			0x80
 
 /* ES8326_CLK_CTL */
-#define ES8326_CLK_ON (0x7f << 0)
-#define ES8326_CLK_OFF (0 << 0)
-
-/* ES8326_CLK_INV */
-#define ES8326_BCLK_AS_MCLK (1 << 3)
+#define ES8326_CLK_CTL_CLK9_ON			0x01
+#define ES8326_CLK_CTL_CLK8_ON			0x02
+#define ES8326_CLK_CTL_CLK3_ON			0x04
+#define ES8326_CLK_CTL_CLK1_ON			0x08
+#define ES8326_CLK_CTL_BCLK_ON			0x10
+#define ES8326_CLK_CTL_MCLK_ON			0x20
+#define ES8326_CLK_CTL_CPCLK_ON			0x40
+
+/* ES8326_CLK_RESAMPLE */
+#define ES8326_CLK_RESAMPLE_OSC_EN_ALWAYS_ON	0x01
+#define ES8326_CLK_RESAMPLE_INTCLK_SEL_OSC	0x04
 
 /* ES8326_FMT */
-#define ES8326_S24_LE	(0 << 2)
-#define ES8326_S20_3_LE	(1 << 2)
-#define ES8326_S18_LE	(2 << 2)
-#define ES8326_S16_LE	(3 << 2)
-#define ES8326_S32_LE	(4 << 2)
-#define ES8326_DATA_LEN_MASK	(7 << 2)
-
-#define ES8326_DAIFMT_MASK	((1 << 5) | (3 << 0))
-#define ES8326_DAIFMT_I2S	0
-#define ES8326_DAIFMT_LEFT_J	(1 << 0)
-#define ES8326_DAIFMT_DSP_A	(3 << 0)
-#define ES8326_DAIFMT_DSP_B	((1 << 5) | (3 << 0))
+#define ES8326_FMT_SDP_WL_MASK			0x1c
+#define ES8326_FMT_SDP_WL_24			0x00
+#define ES8326_FMT_SDP_WL_20			0x04
+#define ES8326_FMT_SDP_WL_18			0x08
+#define ES8326_FMT_SDP_WL_16			0x0c
+#define ES8326_FMT_SDP_WL_32			0x10
+#define ES8326_FMT_SDP_FMT_MASK			0x03
+#define ES8326_FMT_SDP_FMT_I2S			0x00
+#define ES8326_FMT_SDP_FMT_LJ			0x01
+#define ES8326_FMT_SDP_FMT_DSP			0x03
+
+/* ES8326_DAC_MUTE */
+#define ES8326_DAC_MUTE_S2P_MUTE_MASK		0x03
+#define ES8326_DAC_MUTE_S2P_MUTE_L		0x01
+#define ES8326_DAC_MUTE_S2P_MUTE_R		0x02
+
+/* ES8326_ADC_MUTE */
+#define ES8326_ADC_MUTE_P2S_MUTE_MASK		0x0f
+#define ES8326_ADC_MUTE_P2S_MUTE_1		0x01
+#define ES8326_ADC_MUTE_P2S_MUTE_2		0x02
+#define ES8326_ADC_MUTE_P2S_MUTE_3		0x04
+#define ES8326_ADC_MUTE_P2S_MUTE_4		0x08
+#define ES8326_ADC_MUTE_P2S_TDM_MODE		0x10
+
+/* ES8326_ANA_PWR */
+#define ES8326_ANA_PWR_PDN_DACR			0x01
+#define ES8326_ANA_PWR_PDN_DACL			0x02
+#define ES8326_ANA_PWR_LP_DAC			0x04
+#define ES8326_ANA_PWR_PDN_VRP			0x08
+#define ES8326_ANA_PWR_PDN_DACVREFGEN		0x10
+#define ES8326_ANA_PWR_PDN_ADCVREFGEN		0x20
+#define ES8326_ANA_PWR_PDN_IBIASGEN		0x40
+#define ES8326_ANA_PWR_PDN_ANA			0x80
+
+/* ES8326_PGA_PWR */
+#define ES8326_PGA_PWR_PDN_PGA			0x08
+#define ES8326_PGA_PWR_PDN_MOD			0x10
+#define ES8326_PGA_PWR_MODTOP_RST		0x20
+
+/* ES8326_VMIDSEL */
+#define ES8326_VMIDSEL_POWER_DOWN		0x00
+#define ES8326_VMIDSEL_NORMAL			0x02
 
 /* ES8326_PGAGAIN */
-#define ES8326_MIC_SEL_MASK (3 << 4)
-#define ES8326_MIC1_SEL	(1 << 4)
-#define ES8326_MIC2_SEL (1 << 5)
-
-/* ES8326_HP_CAL */
-#define ES8326_HPOR_SHIFT 4
-
-/* ES8326_ADC1_SRC */
-#define ES8326_ADC1_SHIFT 0
-#define ES8326_ADC2_SHIFT 4
-#define ES8326_ADC_SRC_ANA 0
-#define ES8326_ADC_SRC_ANA_INV_SW0 1
-#define ES8326_ADC_SRC_ANA_INV_SW1 2
-#define ES8326_ADC_SRC_DMIC_MCLK 3
-#define ES8326_ADC_SRC_DMIC_SDIN2 4
-#define ES8326_ADC_SRC_DMIC_SDIN2_INV 5
-#define ES8326_ADC_SRC_DMIC_SDIN3 6
-#define ES8326_ADC_SRC_DMIC_SDIN3_INV 7
-
-#define ES8326_ADC_AMIC	((ES8326_ADC_SRC_ANA_INV_SW1 << ES8326_ADC2_SHIFT) \
-		| (ES8326_ADC_SRC_ANA_INV_SW1 << ES8326_ADC1_SHIFT))
-#define ES8326_ADC_DMIC	((ES8326_ADC_SRC_DMIC_SDIN2 << ES8326_ADC2_SHIFT) \
-		| (ES8326_ADC_SRC_DMIC_SDIN2 << ES8326_ADC1_SHIFT))
-/* ES8326_ADC2_SRC */
-#define ES8326_ADC3_SHIFT 0
-#define ES8326_ADC4_SHIFT 3
-
-/* ES8326_HP_DET */
-#define ES8326_HP_DET_SRC_PIN27 (1 << 5)
-#define ES8326_HP_DET_SRC_PIN9 (1 << 4)
-#define ES8326_HP_DET_JACK_POL (1 << 3)
-#define ES8326_HP_DET_BUTTON_POL (1 << 2)
-#define ES8326_HP_TYPE_OMTP	(3 << 0)
-#define ES8326_HP_TYPE_CTIA	(2 << 0)
-#define ES8326_HP_TYPE_AUTO	(1 << 0)
-#define ES8326_HP_TYPE_AUTO_INV	(0 << 0)
-
-/* ES8326_SDINOUT1_IO */
-#define ES8326_IO_INPUT	(0 << 0)
-#define ES8326_IO_SDIN_SLOT0 (1 << 0)
-#define ES8326_IO_SDIN_SLOT1 (2 << 0)
-#define ES8326_IO_SDIN_SLOT2 (3 << 0)
-#define ES8326_IO_SDIN_SLOT7 (8 << 0)
-#define ES8326_IO_DMIC_CLK (9 << 0)
-#define ES8326_IO_DMIC_CLK_INV (0x0a << 0)
-#define ES8326_IO_SDOUT2 (0x0b << 0)
-#define ES8326_IO_LOW (0x0e << 0)
-#define ES8326_IO_HIGH (0x0f << 0)
-#define ES8326_ADC2DAC (1 << 3)
-#define ES8326_SDINOUT1_SHIFT 4
-
-/* ES8326_SDINOUT23_IO */
-#define ES8326_SDINOUT2_SHIFT 4
-#define ES8326_SDINOUT3_SHIFT 0
+#define ES8326_PGAGAIN_MIC1SEL			0x10
+
+/* ES8326_HP_DRIVER */
+#define ES8326_HP_DRIVER_ENREFR_HP		0x01
+#define ES8326_HP_DRIVER_PDN_MASK		0x0e
+#define ES8326_HP_DRIVER_PDN_CPNLDO		0x02
+#define ES8326_HP_DRIVER_PDN_CPHP		0x04
+#define ES8326_HP_DRIVER_PDN_CP			0x08
+#define ES8326_HP_DRIVER_LP_MASK		0x70
+#define ES8326_HP_DRIVER_LP_CPNLDO		0x10
+#define ES8326_HP_DRIVER_LP_HPMIX		0x20
+#define ES8326_HP_DRIVER_LP_HP			0x40
+
+/* ES8326_HPJACK_POL */
+#define ES8326_HPJACK_POL_HP_TYPE_CTIA		0x03
+#define ES8326_HPJACK_POL_BUTTON_POL_ACTIVE_LOW	0x04
+#define ES8326_HPJACK_POL_HPJACK_POL_ACTIVE_LOW	0x08
+#define ES8326_HPJACK_POL_HPINSERT_SEL_PIN9	0x10
+
+/* ES8326_INT_SOURCE */
+#define ES8326_INT_SOURCE_BUTTON		0x04
+#define ES8326_INT_SOURCE_PIN9			0x08
+
+/* ES8326_PULLUP_CTL */
+#define ES8326_PULLUP_CTL_ADC34_OFF		0x02
+#define ES8326_PULLUP_CTL_ISO_VDDA		0x08
+#define ES8326_PULLUP_CTL_PULLUP_MASK		0xf0
+#define ES8326_PULLUP_CTL_PULLUP_SDINOUT	0x10
+#define ES8326_PULLUP_CTL_PULLUP_MCLK		0x20
+#define ES8326_PULLUP_CTL_PULLUP_LRCK		0x40
+#define ES8326_PULLUP_CTL_PULLUP_BCLK		0x80
 
 /* ES8326_HP_DETECT */
-#define ES8326_HPINSERT_FLAG (1 << 1)
-#define ES8326_HPBUTTON_FLAG (1 << 0)
-
-/* ES8326_CHIP_VERSION 0xFF */
-#define ES8326_VERSION_B (1 << 0)
+#define ES8326_HP_DETECT_GM_NOT_SHORTED		0x01
+#define ES8326_HP_DETECT_NOT_INSERTED		0x02
 
 #endif
-- 
2.33.8



  parent reply	other threads:[~2023-12-06 16:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 16:44 [d-kernel] [PATCH 0/7] ASoC: Intel/codecs: fix support es83x6 codecs drivers kovalev
2023-12-06 16:44 ` [d-kernel] [PATCH 1/7] ASoC: Intel: update strategy UCM components for es8336 driver kovalev
2023-12-06 16:44 ` [d-kernel] [PATCH 2/7] ASoC: Intel: add more DMI info into sof-essx8336 driver kovalev
2023-12-06 16:44 ` kovalev [this message]
2023-12-06 22:05   ` [d-kernel] [PATCH 3/7] ASoC: codecs: downgrade es8326 codec to stable state Vitaly Chikunov
2023-12-06 16:44 ` [d-kernel] [PATCH 4/7] ASoC: Intel: add UCM component for es8336 headset mic + Dmic inverse topology kovalev
2023-12-06 16:44 ` [d-kernel] [PATCH 5/7] ASoC: Intel: sof-essx8336 - add DMI info of the HUAWEI BOD-WXX9-PCB-B4 laptop kovalev
2023-12-06 16:44 ` [d-kernel] [PATCH 6/7] ASoC: Intel: sof-essx8336 - add DMI info of the Kraftway ACCORD S15T laptop kovalev
2023-12-06 16:44 ` [d-kernel] [PATCH 7/7] ASoC: codecs: fix warning for the es8316 codec build kovalev
2023-12-06 22:06 ` [d-kernel] [PATCH 0/7] ASoC: Intel/codecs: fix support es83x6 codecs drivers Vitaly Chikunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231206164413.126554-4-kovalev@altlinux.org \
    --to=kovalev@altlinux.org \
    --cc=devel-kernel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux kernel packages development

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel-kernel/0 devel-kernel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel-kernel devel-kernel/ http://lore.altlinux.org/devel-kernel \
		devel-kernel@altlinux.org devel-kernel@altlinux.ru devel-kernel@altlinux.com
	public-inbox-index devel-kernel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git