From patchwork Mon Jun 24 03:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13718002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09C7BC30653 for ; Mon, 1 Jul 2024 12:29:06 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AC58A2BAE; Mon, 1 Jul 2024 14:28:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AC58A2BAE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719836944; bh=5J5ZNAAJbWkqzsag62Y82/cg4YZqgDN0MGp8CKzv1Bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=dnCiIggo5+KKpR7A44GZEYt2FkSfI1RK8m6VNRY+9hKH8v0BjRfvion8uUkme4e8Q RQOjBVeI7M/7z1HZRYvqNcLC1kma8d0UFhtHpvco0pwGca+VAGAJK7v7oDYxalyzDr qJMCkDVBgJvA2/ML5Oo75xoOy2kQ0zkfbsgTWo+Y= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0378AF89832; Mon, 1 Jul 2024 14:21:47 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6092CF8981E; Mon, 1 Jul 2024 14:21:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C5196F80495; Mon, 24 Jun 2024 05:06:53 +0200 (CEST) Received: from mail78-63.sinamail.sina.com.cn (mail78-63.sinamail.sina.com.cn [219.142.78.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A49AAF80423 for ; Mon, 24 Jun 2024 05:06:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A49AAF80423 Received: from unknown (HELO zy-virtual-machine.localdomain)([116.227.101.59]) by sina.net (10.75.30.239) with ESMTP id 6678E2A10002B8DA; Mon, 24 Jun 2024 11:06:13 +0800 (CST) X-Sender: zhangyi@everest-semi.com X-Auth-ID: zhangyi@everest-semi.com Authentication-Results: sina.net; spf=none smtp.mailfrom=zhangyi@everest-semi.com; dkim=none header.i=none; dmarc=none action=none header.from=zhangyi@everest-semi.com X-SMAIL-MID: 395BF61A51784BC0B22DCD28835C84F8 X-SMAIL-UIID: 395BF61A51784BC0B22DCD28835C84F8-20240624-110613 From: Zhang Yi To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com Subject: [PATCH 1/4] ASoC: codecs: ES8326: Slove headphone detection issue Date: Mon, 24 Jun 2024 11:06:04 +0800 Message-Id: <20240624030607.4307-2-zhangyi@everest-semi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240624030607.4307-1-zhangyi@everest-semi.com> References: <20240624030607.4307-1-zhangyi@everest-semi.com> X-MailFrom: zhangyi@everest-semi.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: OLA6NA6G3FV2NIQS7IHTAPLCWWKTSV7O X-Message-ID-Hash: OLA6NA6G3FV2NIQS7IHTAPLCWWKTSV7O X-Mailman-Approved-At: Mon, 01 Jul 2024 12:21:21 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We modified the headphone detection setting to avoid an error button state after codec resume from suspend state Signed-off-by: Zhang Yi --- sound/soc/codecs/es8326.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 4d87bebca5c1..8c9d79686185 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -877,6 +877,8 @@ static void es8326_jack_detect_handler(struct work_struct *work) if (es8326->jack->status & SND_JACK_HEADSET) { /* detect button */ dev_dbg(comp->dev, "button pressed\n"); + regmap_write(es8326->regmap, ES8326_INT_SOURCE, + (ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON)); queue_delayed_work(system_wq, &es8326->button_press_work, 10); goto exit; } @@ -1052,11 +1054,6 @@ static int es8326_resume(struct snd_soc_component *component) regmap_write(es8326->regmap, ES8326_ADC_MUTE, 0x0f); - es8326->jack_remove_retry = 0; - es8326->hp = 0; - es8326->hpl_vol = 0x03; - es8326->hpr_vol = 0x03; - es8326_irq(es8326->irq, es8326); return 0; } @@ -1211,6 +1208,10 @@ static int es8326_i2c_probe(struct i2c_client *i2c) } es8326->irq = i2c->irq; + es8326->jack_remove_retry = 0; + es8326->hp = 0; + es8326->hpl_vol = 0x03; + es8326->hpr_vol = 0x03; INIT_DELAYED_WORK(&es8326->jack_detect_work, es8326_jack_detect_handler); INIT_DELAYED_WORK(&es8326->button_press_work, From patchwork Mon Jun 24 03:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13718003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1191DC2BD09 for ; Mon, 1 Jul 2024 12:29:23 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3D9D92BAF; Mon, 1 Jul 2024 14:29:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3D9D92BAF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719836961; bh=HeYnn2+dl8cfrms6otkFFZfFhtM5NtP3TFk1r1EJl34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=OFuW677Ms9n52MOHbOgWGTQajLR8+yS4vQR28QvuguZUXx6YPr7ah3Ysit79Kf+E3 50m/Or0Zfn3DK0Ea3yuLHxNH3aZ5BZNd31OdbuzRVjeLzZLX8UlN61sK+Y1X3kB/v9 BKVmRS3fSss56/exmEdn4APi1/NcLOrNzP38A5CY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4F280F89840; Mon, 1 Jul 2024 14:21:51 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6F71AF89845; Mon, 1 Jul 2024 14:21:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3F22F80423; Mon, 24 Jun 2024 05:06:57 +0200 (CEST) Received: from mail78-63.sinamail.sina.com.cn (mail78-63.sinamail.sina.com.cn [219.142.78.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4F583F8049C for ; Mon, 24 Jun 2024 05:06:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4F583F8049C Received: from unknown (HELO zy-virtual-machine.localdomain)([116.227.101.59]) by sina.net (10.75.30.239) with ESMTP id 6678E2A10002B8DA; Mon, 24 Jun 2024 11:06:14 +0800 (CST) X-Sender: zhangyi@everest-semi.com X-Auth-ID: zhangyi@everest-semi.com Authentication-Results: sina.net; spf=none smtp.mailfrom=zhangyi@everest-semi.com; dkim=none header.i=none; dmarc=none action=none header.from=zhangyi@everest-semi.com X-SMAIL-MID: 4133754A44F7435C98A7B3A18DE2F114 X-SMAIL-UIID: 4133754A44F7435C98A7B3A18DE2F114-20240624-110614 From: Zhang Yi To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com Subject: [PATCH 2/4] ASoC: codecs: ES8326: codec can't enter suspend issue Date: Mon, 24 Jun 2024 11:06:05 +0800 Message-Id: <20240624030607.4307-3-zhangyi@everest-semi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240624030607.4307-1-zhangyi@everest-semi.com> References: <20240624030607.4307-1-zhangyi@everest-semi.com> X-MailFrom: zhangyi@everest-semi.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: JYOFZ7JLX7KJCIHNFEC2WYG5YLZ2YUJB X-Message-ID-Hash: JYOFZ7JLX7KJCIHNFEC2WYG5YLZ2YUJB X-Mailman-Approved-At: Mon, 01 Jul 2024 12:21:21 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When widgets "MICBIAS1" and "MICBIAS2" are active, the codec cannot enter suspend mode. So we removed these two widgets.We replaced enable_micbias and disable_micbias with regmap_update_bits to make sure the codec can enter suspend mode. Signed-off-by: Zhang Yi --- sound/soc/codecs/es8326.c | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 8c9d79686185..95bf751d8bab 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -286,8 +286,6 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = { /* 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("MICBIAS1", ES8326_ANA_MICBIAS, 2, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("MICBIAS2", ES8326_ANA_MICBIAS, 3, 0, NULL, 0), SND_SOC_DAPM_PGA("LHPMIX", ES8326_DAC2HPMIX, 7, 0, NULL, 0), SND_SOC_DAPM_PGA("RHPMIX", ES8326_DAC2HPMIX, 3, 0, NULL, 0), @@ -697,28 +695,6 @@ static struct snd_soc_dai_driver es8326_dai = { .symmetric_rate = 1, }; -static void es8326_enable_micbias(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); -} - -static void es8326_disable_micbias(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); -} - /* * For button detection, set the following in soundcard * snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); @@ -822,7 +798,7 @@ static void es8326_jack_detect_handler(struct work_struct *work) if ((iface & ES8326_HPINSERT_FLAG) == 0) { /* Jack unplugged or spurious IRQ */ dev_dbg(comp->dev, "No headset detected\n"); - es8326_disable_micbias(es8326->component); + regmap_update_bits(es8326->regmap, ES8326_ANA_MICBIAS, 0x0C, 0x00); if (es8326->jack->status & SND_JACK_HEADPHONE) { dev_dbg(comp->dev, "Report hp remove event\n"); snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET); @@ -860,7 +836,7 @@ static void es8326_jack_detect_handler(struct work_struct *work) regmap_write(es8326->regmap, ES8326_INT_SOURCE, 0x00); regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x10, 0x00); - es8326_enable_micbias(es8326->component); + regmap_update_bits(es8326->regmap, ES8326_ANA_MICBIAS, 0x0C, 0x0C); usleep_range(50000, 70000); regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x10, 0x10); @@ -1034,7 +1010,7 @@ static int es8326_resume(struct snd_soc_component *component) (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol) : (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol | 0x04))); usleep_range(5000, 10000); - es8326_enable_micbias(es8326->component); + regmap_update_bits(es8326->regmap, ES8326_ANA_MICBIAS, 0x0C, 0x0C); usleep_range(50000, 70000); regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9); @@ -1063,7 +1039,7 @@ static int es8326_suspend(struct snd_soc_component *component) struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); cancel_delayed_work_sync(&es8326->jack_detect_work); - es8326_disable_micbias(component); + regmap_update_bits(es8326->regmap, ES8326_ANA_MICBIAS, 0x0C, 0x00); es8326->calibrated = false; regmap_write(es8326->regmap, ES8326_CLK_MUX, 0x2d); regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x00); @@ -1142,7 +1118,7 @@ static void es8326_disable_jack_detect(struct snd_soc_component *component) mutex_lock(&es8326->lock); if (es8326->jack->status & SND_JACK_MICROPHONE) { - es8326_disable_micbias(component); + regmap_update_bits(es8326->regmap, ES8326_ANA_MICBIAS, 0x0C, 0x00); snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET); } es8326->jack = NULL; From patchwork Mon Jun 24 03:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13718000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD9EEC2BD09 for ; Mon, 1 Jul 2024 12:28:35 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4DF5323E1; Mon, 1 Jul 2024 14:28:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4DF5323E1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719836913; bh=v4pEOq2KyOczU7HAYfd6jAGUPqtbLowFOyH3Gcsf68k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UyU+lV+HdX0NNIIxXuPI3u+oL/bVotqUiMtCHwmoCv0CUrNwiuZNScAAvhMsQcGuw 4+r6LW9tPtp0tYpU6Meg861HZvqVeeTcUEntrbBcbT7EYmzstqqbD7m6ptyeDhBo+t NrrzDIvWiRxDE3l8XJDmxKbmHhQBllt+YY5gI+A8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8E3BFF897FB; Mon, 1 Jul 2024 14:21:41 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 93B46F897FB; Mon, 1 Jul 2024 14:21:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5713EF804F2; Mon, 24 Jun 2024 05:06:32 +0200 (CEST) Received: from mail78-63.sinamail.sina.com.cn (mail78-63.sinamail.sina.com.cn [219.142.78.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4C20AF80495 for ; Mon, 24 Jun 2024 05:06:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4C20AF80495 Received: from unknown (HELO zy-virtual-machine.localdomain)([116.227.101.59]) by sina.net (10.75.30.239) with ESMTP id 6678E2A10002B8DA; Mon, 24 Jun 2024 11:06:15 +0800 (CST) X-Sender: zhangyi@everest-semi.com X-Auth-ID: zhangyi@everest-semi.com Authentication-Results: sina.net; spf=none smtp.mailfrom=zhangyi@everest-semi.com; dkim=none header.i=none; dmarc=none action=none header.from=zhangyi@everest-semi.com X-SMAIL-MID: 3E50B45B19E54113901157FF9F7EC4AC X-SMAIL-UIID: 3E50B45B19E54113901157FF9F7EC4AC-20240624-110615 From: Zhang Yi To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com Subject: [PATCH 3/4] ASoC: codecs: ES8326: Minimize the pop noise Date: Mon, 24 Jun 2024 11:06:06 +0800 Message-Id: <20240624030607.4307-4-zhangyi@everest-semi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240624030607.4307-1-zhangyi@everest-semi.com> References: <20240624030607.4307-1-zhangyi@everest-semi.com> X-MailFrom: zhangyi@everest-semi.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: ANTSRAFWE4IVZL4SGNA5GVYVVDF2TNYM X-Message-ID-Hash: ANTSRAFWE4IVZL4SGNA5GVYVVDF2TNYM X-Mailman-Approved-At: Mon, 01 Jul 2024 12:21:21 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Executing regcache_sync at initialization, we can hear a gentle pop noise. So we created es8326_init for initialization instead of executing es8326_resume Signed-off-by: Zhang Yi --- sound/soc/codecs/es8326.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 95bf751d8bab..4f10ab5394ec 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -950,14 +950,10 @@ static int es8326_calibrate(struct snd_soc_component *component) return 0; } -static int es8326_resume(struct snd_soc_component *component) +static void es8326_init(struct snd_soc_component *component) { struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); - regcache_cache_only(es8326->regmap, false); - regcache_sync(es8326->regmap); - - /* reset internal clock state */ regmap_write(es8326->regmap, ES8326_RESET, 0x1f); regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E); regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0); @@ -1013,7 +1009,6 @@ static int es8326_resume(struct snd_soc_component *component) regmap_update_bits(es8326->regmap, ES8326_ANA_MICBIAS, 0x0C, 0x0C); usleep_range(50000, 70000); regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); - regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9); regmap_write(es8326->regmap, ES8326_INTOUT_IO, es8326->interrupt_clk); regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, @@ -1029,6 +1024,28 @@ static int es8326_resume(struct snd_soc_component *component) ES8326_MUTE); regmap_write(es8326->regmap, ES8326_ADC_MUTE, 0x0f); + regmap_write(es8326->regmap, ES8326_CLK_DIV_LRCK, 0xff); + + msleep(200); + regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9); +} + +static int es8326_resume(struct snd_soc_component *component) +{ + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int reg; + + regcache_cache_only(es8326->regmap, false); + regcache_cache_bypass(es8326->regmap, true); + regmap_read(es8326->regmap, ES8326_CLK_RESAMPLE, ®); + regcache_cache_bypass(es8326->regmap, false); + /* reset internal clock state */ + if (reg == 0x05) + regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON); + else + es8326_init(component); + + regcache_sync(es8326->regmap); es8326_irq(es8326->irq, es8326); return 0; @@ -1088,7 +1105,7 @@ static int es8326_probe(struct snd_soc_component *component) } dev_dbg(component->dev, "interrupt-clk %x", es8326->interrupt_clk); - es8326_resume(component); + es8326_init(component); return 0; } From patchwork Mon Jun 24 03:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13718001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0FEAC2BD09 for ; Mon, 1 Jul 2024 12:28:50 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0F5352BA5; Mon, 1 Jul 2024 14:28:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0F5352BA5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719836929; bh=aKjfunUPatqAejqdZtGwl92h5nzm1QwzOHxT5bISx3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YlNeCXpl9OOlfgqNO3Oj0bDQ0izRoqpzIDrAW8yxPHKFD0ET9TYurOJNIMOVBsdi5 1OaJomr768rKNOGy0PDlrcX2OZlkkDtr/4lHcoiPakR9dAZJquTmFtlQ5uAcmPB1ve Zok/xwlrSrwrp5h1whrS2r+dlu5H8rP3dfsP2er4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73BEEF8068D; Mon, 1 Jul 2024 14:21:44 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 33ED3F8980E; Mon, 1 Jul 2024 14:21:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 74A82F80495; Mon, 24 Jun 2024 05:06:52 +0200 (CEST) Received: from mail78-63.sinamail.sina.com.cn (mail78-63.sinamail.sina.com.cn [219.142.78.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0FC10F804D6 for ; Mon, 24 Jun 2024 05:06:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0FC10F804D6 Received: from unknown (HELO zy-virtual-machine.localdomain)([116.227.101.59]) by sina.net (10.75.30.239) with ESMTP id 6678E2A10002B8DA; Mon, 24 Jun 2024 11:06:16 +0800 (CST) X-Sender: zhangyi@everest-semi.com X-Auth-ID: zhangyi@everest-semi.com Authentication-Results: sina.net; spf=none smtp.mailfrom=zhangyi@everest-semi.com; dkim=none header.i=none; dmarc=none action=none header.from=zhangyi@everest-semi.com X-SMAIL-MID: C96BF33DB7C74C91AC49603CE80D6180 X-SMAIL-UIID: C96BF33DB7C74C91AC49603CE80D6180-20240624-110616 From: Zhang Yi To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com Subject: [PATCH 4/4] ASoC: codecs: ES8326: regcache_sync error issue Date: Mon, 24 Jun 2024 11:06:07 +0800 Message-Id: <20240624030607.4307-5-zhangyi@everest-semi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240624030607.4307-1-zhangyi@everest-semi.com> References: <20240624030607.4307-1-zhangyi@everest-semi.com> X-MailFrom: zhangyi@everest-semi.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: T7SY6WASGIZ4KT56ZG2BSQYOFT4SCU76 X-Message-ID-Hash: T7SY6WASGIZ4KT56ZG2BSQYOFT4SCU76 X-Mailman-Approved-At: Mon, 01 Jul 2024 12:21:21 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We modified the regmap_config members to fix cach sync error. There are several registers that should be read-only registers. If these registers are written while synchronizing the register values, the codec will enter an error state.So we create es8326_writeable_register, and set these registers to false Signed-off-by: Zhang Yi --- sound/soc/codecs/es8326.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 4f10ab5394ec..d209865be9e1 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -327,11 +327,29 @@ static bool es8326_volatile_register(struct device *dev, unsigned int reg) } } +static bool es8326_writeable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case ES8326_BIAS_SW1: + case ES8326_BIAS_SW2: + case ES8326_BIAS_SW3: + case ES8326_BIAS_SW4: + case ES8326_ADC_HPFS1: + case ES8326_ADC_HPFS2: + return false; + default: + return true; + } +} + static const struct regmap_config es8326_regmap_config = { .reg_bits = 8, .val_bits = 8, .max_register = 0xff, + .use_single_read = true, + .use_single_write = true, .volatile_reg = es8326_volatile_register, + .writeable_reg = es8326_writeable_register, .cache_type = REGCACHE_RBTREE, };