From patchwork Thu Nov 29 10:05:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Carlsson X-Patchwork-Id: 10709333 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 9182B15A6 for ; Mon, 3 Dec 2018 11:47:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 820F62B439 for ; Mon, 3 Dec 2018 11:47:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 767532B440; Mon, 3 Dec 2018 11:47:02 +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 D77172B44D for ; Mon, 3 Dec 2018 11:47:01 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id C3F712679A7; Mon, 3 Dec 2018 12:46:54 +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 DF297267B21; Thu, 29 Nov 2018 11:05:57 +0100 (CET) Received: from bastet.se.axis.com (bastet.se.axis.com [195.60.68.11]) by alsa0.perex.cz (Postfix) with ESMTP id 8D717267AF1 for ; Thu, 29 Nov 2018 11:05:55 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 0F75E185A7; Thu, 29 Nov 2018 11:05:55 +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 90sJfrhjrjyD; Thu, 29 Nov 2018 11:05:54 +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 18951185AB; Thu, 29 Nov 2018 11:05:53 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C16D21E076; Thu, 29 Nov 2018 11:05:53 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B4C821E074; Thu, 29 Nov 2018 11:05:53 +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 11:05:53 +0100 (CET) Received: from XBOX04.axis.com (xbox04.axis.com [10.0.5.18]) by thoth.se.axis.com (Postfix) with ESMTP id A74DD237C; Thu, 29 Nov 2018 11:05:53 +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 11:05:53 +0100 From: Niklas Carlsson To: Date: Thu, 29 Nov 2018 11:05:30 +0100 Message-ID: <20181129100530.9043-1-niklasc@axis.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-ClientProxiedBy: XBOX04.axis.com (10.0.5.18) 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 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,