From patchwork Thu Nov 29 07:21:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: niklas.morberg@axis.com, Carlsson@axis.com X-Patchwork-Id: 10709331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13CED14BD for ; Mon, 3 Dec 2018 11:46:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F15C22B432 for ; Mon, 3 Dec 2018 11:46:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE5BD2B450; Mon, 3 Dec 2018 11:46:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2656F2B44D for ; Mon, 3 Dec 2018 11:46:53 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 21DB426782E; Mon, 3 Dec 2018 12:46:52 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 09802267B21; Thu, 29 Nov 2018 08:22:12 +0100 (CET) Received: from bastet.se.axis.com (bastet.se.axis.com [195.60.68.11]) by alsa0.perex.cz (Postfix) with ESMTP id F3D8626751A for ; Thu, 29 Nov 2018 08:22:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 7C8E51858D; Thu, 29 Nov 2018 08:22:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id t_YEQCFZJLeI; Thu, 29 Nov 2018 08:22:06 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id 5880218403; Thu, 29 Nov 2018 08:22:06 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 470731E079; Thu, 29 Nov 2018 08:22:06 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3AEBF1E078; Thu, 29 Nov 2018 08:22:06 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Thu, 29 Nov 2018 08:22:06 +0100 (CET) Received: from XBOX04.axis.com (xbox04.axis.com [10.0.5.18]) by thoth.se.axis.com (Postfix) with ESMTP id 2EF0D730; Thu, 29 Nov 2018 08:22:06 +0100 (CET) Received: from lnxsofieka1.se.axis.com (10.0.5.60) by XBOX04.axis.com (10.0.5.18) with Microsoft SMTP Server (TLS) id 15.0.1365.1; Thu, 29 Nov 2018 08:22:05 +0100 From: niklas.morberg@axis.com, Carlsson@axis.com To: Date: Thu, 29 Nov 2018 08:21:44 +0100 Message-ID: <20181129072144.16208-1-niklasc@axis.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-ClientProxiedBy: XBOX02.axis.com (10.0.5.16) To XBOX04.axis.com (10.0.5.18) X-TM-AS-GCONF: 00 X-Mailman-Approved-At: Mon, 03 Dec 2018 12:46:49 +0100 Cc: niklasc@axis.com, alsa-devel@alsa-project.org, Lars-Peter Clausen , linux-kernel@vger.kernel.org, Takashi Iwai , Liam Girdwood , Mark Brown Subject: [alsa-devel] [PATCH] ASoC: adau1761: Ensure DSP_RUN and DSP_ENABLE are disabled X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Niklas Carlsson DSP_RUN and DSP_ENABLE needs to be disabled during FW load. This is not a problem after power-cycling but for soft reboots. Signed-off-by: Niklas Carlsson --- sound/soc/codecs/adau1761.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c index bef3e9e74c26..3075c13bcbbc 100644 --- a/sound/soc/codecs/adau1761.c +++ b/sound/soc/codecs/adau1761.c @@ -460,8 +460,35 @@ static int adau1761_set_bias_level(struct snd_soc_component *component, regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, ADAU17X1_CLOCK_CONTROL_SYSCLK_EN, ADAU17X1_CLOCK_CONTROL_SYSCLK_EN); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == + SND_SOC_BIAS_OFF) { + /* + * When going OFF -> STANDBY, the device can be in two + * states: + * 1) Power-cycled and reset + * 2) Soft reboot + * In the case of soft reboot, we need to sync the HW + * registers even if our regmap reports default values. + * Marking the cache as dirty ensures that both cases + * are handled. + */ + regcache_mark_dirty(adau->regmap); regcache_sync(adau->regmap); + /* + * In order for FW to load correctly, the device needs + * DSP_RUN and DSP_ENABLE to be 0. This might not be the + * case for soft reboots. Ensure that DSP_RUN and + * DSP_ENABLE is 0 by bypassing the cache and write + * directly to HW when going OFF -> STANDBY. + */ + if (adau17x1_has_dsp(adau)) { + regcache_cache_bypass(adau->regmap, true); + regmap_write(adau->regmap, ADAU17X1_DSP_RUN, 0); + regmap_write(adau->regmap, + ADAU17X1_DSP_ENABLE, 0); + regcache_cache_bypass(adau->regmap, false); + } + } break; case SND_SOC_BIAS_OFF: regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL,