Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp29153ybj; Fri, 8 May 2020 05:53:41 -0700 (PDT) X-Google-Smtp-Source: APiQypJteICQuOzcMDIcKu9cUdAJs2bkS8F7OqejVUsgnKWAJlzHceODShgxUJgXbV8/7ItYlvkA X-Received: by 2002:a17:906:4317:: with SMTP id j23mr1658259ejm.377.1588942421627; Fri, 08 May 2020 05:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588942421; cv=none; d=google.com; s=arc-20160816; b=hTqW+xj0JCFy4fUXzCDj+I9DSsO36PmRei+qGMPDAGTHLOM1wvjEmygK/gfBamjTHo QVmbEieBWwqmVctL8UAvB93O/jdXcC0Qm0JdCPelEEW0WOuUhXA1Ybx/dyGTbpA3w0+G NfpHlzB9ROn645v3M1aREv6VTFgLHfKChpKMmA2biz+Tmn1VEsMnX4C7PlL2E7rz2WsZ PDqWJfm0ovl289BVzYX+MMNwKO7xqP8iJWrriIuvtpcerTe5zyiXjWTW5WtJHkWfkIwh JhuXn046tVvw+O1oF3VbX3kyLIs4Y6Ae7HlkHshBrEoGDQ2r3WRp5DcnvrcXH9I/4cKZ 8p+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E8zuGX91n9N1ncCY2HnuLZeUEdkspRax/R0Z1EYssFg=; b=tAo6gNOsPfJlQFY+sQZZgvyAVWqz4n5aV8ja8FEDVABVpL2Z6idBOQhCLUcz1cI6Ns 8tq/cbEJWxQfa3RDXn5HjZ8V33By4PP1mt6IHZsKF7RCbyVhXurR2P0urDb7Qh36TPpW NMCmOKuywwFhjfKZG4S5PtTcVyeJmyNHFizRawyBxRS98kdYBCoTBUBrExGVp653NTQv H4MlfLApIavnZX1633Gz64wnzqdRRGPdOwZa7N5B0Zogyf3Oy8PrNVtIe/k7dOanBoU9 LV2wv7yKZ241+lBujd8XFFZwcmMyOSzpiXWtKeQWt3+GWogPJn2rUTWH4aZJxBc6qqHg i+LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uo6XAIaZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ba9si891447edb.114.2020.05.08.05.53.15; Fri, 08 May 2020 05:53:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uo6XAIaZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728555AbgEHMt4 (ORCPT + 99 others); Fri, 8 May 2020 08:49:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:56402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729783AbgEHMty (ORCPT ); Fri, 8 May 2020 08:49:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D3D932495C; Fri, 8 May 2020 12:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588942193; bh=1zmpipjnMooc1w5cUbGhIiwypqc7ZZkCX0Tk+H7CoTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uo6XAIaZ8FPH/umhmsiPw/AR7Q4XWXcY4UPLmyPMwFexW6kcKRexHRt9YezQzSYs/ DNNT4/Hr0LH3a0m4JUaZizqvErmAXyNgkItPyWYqR5sroCMnjYm6v6+8Bg++2G2R2v rhOBICJ2xXmg2JkdnPoaC8pnUhlmFrbAh5ffJSM8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Reichel , Fabio Estevam , Mark Brown , Sasha Levin Subject: [PATCH 4.9 05/18] ASoC: sgtl5000: Fix VAG power-on handling Date: Fri, 8 May 2020 14:35:08 +0200 Message-Id: <20200508123032.260507863@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200508123030.497793118@linuxfoundation.org> References: <20200508123030.497793118@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Reichel [ Upstream commit aa7812737f2877e192d57626cbe8825cc7cf6de9 ] As mentioned slightly out of patch context in the code, there is no reset routine for the chip. On boards where the chip is supplied by a fixed regulator, it might not even be resetted during (e.g. watchdog) reboot and can be in any state. If the device is probed with VAG enabled, the driver's probe routine will generate a loud pop sound when ANA_POWER is being programmed. Avoid this by properly disabling just the VAG bit and waiting the required power down time. Signed-off-by: Sebastian Reichel Reviewed-by: Fabio Estevam Link: https://lore.kernel.org/r/20200414181140.145825-1-sebastian.reichel@collabora.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/sgtl5000.c | 34 ++++++++++++++++++++++++++++++++++ sound/soc/codecs/sgtl5000.h | 1 + 2 files changed, 35 insertions(+) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 39810b713d5f2..0c2a1413a8f57 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1464,6 +1464,40 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, dev_err(&client->dev, "Error %d initializing CHIP_CLK_CTRL\n", ret); + /* Mute everything to avoid pop from the following power-up */ + ret = regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_CTRL, + SGTL5000_CHIP_ANA_CTRL_DEFAULT); + if (ret) { + dev_err(&client->dev, + "Error %d muting outputs via CHIP_ANA_CTRL\n", ret); + goto disable_clk; + } + + /* + * If VAG is powered-on (e.g. from previous boot), it would be disabled + * by the write to ANA_POWER in later steps of the probe code. This + * may create a loud pop even with all outputs muted. The proper way + * to circumvent this is disabling the bit first and waiting the proper + * cool-down time. + */ + ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, &value); + if (ret) { + dev_err(&client->dev, "Failed to read ANA_POWER: %d\n", ret); + goto disable_clk; + } + if (value & SGTL5000_VAG_POWERUP) { + ret = regmap_update_bits(sgtl5000->regmap, + SGTL5000_CHIP_ANA_POWER, + SGTL5000_VAG_POWERUP, + 0); + if (ret) { + dev_err(&client->dev, "Error %d disabling VAG\n", ret); + goto disable_clk; + } + + msleep(SGTL5000_VAG_POWERDOWN_DELAY); + } + /* Follow section 2.2.1.1 of AN3663 */ ana_pwr = SGTL5000_ANA_POWER_DEFAULT; if (sgtl5000->num_supplies <= VDDD) { diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h index 22f3442af9826..9ea41749d0375 100644 --- a/sound/soc/codecs/sgtl5000.h +++ b/sound/soc/codecs/sgtl5000.h @@ -236,6 +236,7 @@ /* * SGTL5000_CHIP_ANA_CTRL */ +#define SGTL5000_CHIP_ANA_CTRL_DEFAULT 0x0133 #define SGTL5000_LINE_OUT_MUTE 0x0100 #define SGTL5000_HP_SEL_MASK 0x0040 #define SGTL5000_HP_SEL_SHIFT 6 -- 2.20.1