Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4450636imw; Tue, 19 Jul 2022 06:54:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sBguQnCQIbkVH4HA5beijSeDGvvBsIX5RozZZgtDSdhmmisCi27tsTNGnbLsnXAI8zp8+U X-Received: by 2002:a17:907:2d23:b0:72b:7c6a:24c with SMTP id gs35-20020a1709072d2300b0072b7c6a024cmr30240559ejc.44.1658238849333; Tue, 19 Jul 2022 06:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238849; cv=none; d=google.com; s=arc-20160816; b=NOrP0Cx1EqYeEgIY3YL03IRe4PjUwGtUgtNNxhaoWXrShBFqMwavQ7Gr7SLtTMZl59 o6ii/CAvgnHLkMAbPS6W+k2f/breOBDz+Z6c5fJhZ16w0c8R6ORrV22nl9UXykAny2P7 kZnrk/VV+kFSy/Ke8tf20KYu7AQ8J+KbHhqiGmgdN3rZLLaLSuD8pwN/L7lgS9LnQDI2 foY5agGYqmUy8NITwGCwiI5WFPNvz6po/fky39liA+6Tz62xsY5m8Eipaugq7ZINt8P7 d0oe2W8XAi/C5GqLQ6ybEn2ejcDzFnXpvYwCSlYCwXtJA3BfxcaFq1HnDkbxP1pkYfPt 9//g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kR31nhtHfNB9O1yCZCrjPSg0i/A5vI3J1FkiKq6zHdA=; b=PYGKKANzEbB2lOGfxM/OePocpm8ADBscndRDMuhRznff/jRqmrqoAHzDOxToXDdwv7 GBq92SryKSSGW4tFi8HpTgjwCFyWhIu4xkvlLrDzfEPDF/IV2OIXiV1xgzMOsUeCfVrz k2McnIAXxVBCqHvBEprpfJ6XtoJV1kLPIL0fFLh7WYFXaQxx9iqUn+2bZIZHb+NSPOv3 yL2kgi3YzyNeNtrU4YDYVj0MsBiomi7efeYH8foO+SzEtL1JYC2JKQQSrFA4mnY619Ni YYKeCJu6eD4gNEwn1bqS98ZQuFJVQayK51M/x7T0IKS6p8Fq90nZ7S1GCE/pil/zSMDo mRMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g6jDmmKY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f32-20020a05640232a000b0043a45dcaf33si19429090eda.521.2022.07.19.06.53.44; Tue, 19 Jul 2022 06:54:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g6jDmmKY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238218AbiGSMF5 (ORCPT + 99 others); Tue, 19 Jul 2022 08:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238318AbiGSME2 (ORCPT ); Tue, 19 Jul 2022 08:04:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CC2237C5; Tue, 19 Jul 2022 05:00:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D8F2BB81A8F; Tue, 19 Jul 2022 12:00:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45CAFC341C6; Tue, 19 Jul 2022 12:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232015; bh=jGPwMUwbfOZ7GpoOyhWdg7Ls+gHDhmAm/kZrbrmQ56A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g6jDmmKYZ3CgAZKIpP1rJrmhFCY9phToWt4lmEQX4PK+EqthlPHZZC9DDnfPecn4Z phrLe1apm6DkRM78UAZLDKDfV2p/waL5kSmKk1QRQgjN3tQbpWToNEIatHHwNjAMXL Xo/J4jFFyG8EfrtmNP1AfSrHoETF/PCbgp16oQ7s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Francesco Dolcini , Fabio Estevam , Mark Brown , Sasha Levin Subject: [PATCH 4.19 13/48] ASoC: sgtl5000: Fix noise on shutdown/remove Date: Tue, 19 Jul 2022 13:53:50 +0200 Message-Id: <20220719114521.041462345@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114518.915546280@linuxfoundation.org> References: <20220719114518.915546280@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Francesco Dolcini [ Upstream commit 040e3360af3736348112d29425bf5d0be5b93115 ] Put the SGTL5000 in a silent/safe state on shutdown/remove, this is required since the SGTL5000 produces a constant noise on its output after it is configured and its clock is removed. Without this change this is happening every time the module is unbound/removed or from reboot till the clock is enabled again. The issue was experienced on both a Toradex Colibri/Apalis iMX6, but can be easily reproduced everywhere just playing something on the codec and after that removing/unbinding the driver. Fixes: 9b34e6cc3bc2 ("ASoC: Add Freescale SGTL5000 codec support") Signed-off-by: Francesco Dolcini Reviewed-by: Fabio Estevam Link: https://lore.kernel.org/r/20220624101301.441314-1-francesco.dolcini@toradex.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/sgtl5000.c | 9 +++++++++ sound/soc/codecs/sgtl5000.h | 1 + 2 files changed, 10 insertions(+) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 17255e9683f5..13e752f8b3f7 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1769,6 +1769,9 @@ static int sgtl5000_i2c_remove(struct i2c_client *client) { struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client); + regmap_write(sgtl5000->regmap, SGTL5000_CHIP_DIG_POWER, SGTL5000_DIG_POWER_DEFAULT); + regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, SGTL5000_ANA_POWER_DEFAULT); + clk_disable_unprepare(sgtl5000->mclk); regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies); regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies); @@ -1776,6 +1779,11 @@ static int sgtl5000_i2c_remove(struct i2c_client *client) return 0; } +static void sgtl5000_i2c_shutdown(struct i2c_client *client) +{ + sgtl5000_i2c_remove(client); +} + static const struct i2c_device_id sgtl5000_id[] = { {"sgtl5000", 0}, {}, @@ -1796,6 +1804,7 @@ static struct i2c_driver sgtl5000_i2c_driver = { }, .probe = sgtl5000_i2c_probe, .remove = sgtl5000_i2c_remove, + .shutdown = sgtl5000_i2c_shutdown, .id_table = sgtl5000_id, }; diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h index 066517e352a7..0ed4bad92cd1 100644 --- a/sound/soc/codecs/sgtl5000.h +++ b/sound/soc/codecs/sgtl5000.h @@ -80,6 +80,7 @@ /* * SGTL5000_CHIP_DIG_POWER */ +#define SGTL5000_DIG_POWER_DEFAULT 0x0000 #define SGTL5000_ADC_EN 0x0040 #define SGTL5000_DAC_EN 0x0020 #define SGTL5000_DAP_POWERUP 0x0010 -- 2.35.1