Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp408790rbb; Sat, 24 Feb 2024 05:57:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWSN8jo4bnxuGYwsvpWUJ8NKwn4EW5PbstdwIR8uNfB1XcZxSM6lMAX3RiROsup49kztkKO5cevYBZ7ymE7DWXEgH+vOu+hZGoYkmI4+A== X-Google-Smtp-Source: AGHT+IFUzIsWERzs8XtwCkMlebCP3PtgJujLjj0/2zkuYMxqEpSHApAZZxVv/GQYDQAWjvOXF+yG X-Received: by 2002:a05:6358:9148:b0:17b:521d:9fcc with SMTP id r8-20020a056358914800b0017b521d9fccmr3540416rwr.9.1708783049931; Sat, 24 Feb 2024 05:57:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708783049; cv=pass; d=google.com; s=arc-20160816; b=EFoskk725W2ydBPwMpdhuqbFF4LgC8hUVqWLJ+isdJEQ6xssIKjoxtToN0x1WSjUhI zP7/hq1Bc+eGBJ6oSbw5fgndZxAB2qPbLaXHykeOw3gWCtGYSUnNm8UjabsiaAEbC6xE OXNIrDPlzjmDo1Cgln33yEKXGtYoHs+j61rpef6MB2D7pBsfk9Iy0BGVtyXmHYUv8oKS XPgC7Z8p8BqQgYzo6azolmKak1OEfFXUy64KqvTyjya4Km764hPQPDh52+3F5GDS0iQX Alb7OY9pEcn7G/T6bC8YgJrqJTswkAGdzMzkqWXYjSM07eDAc/sIaI+l+AGAZYVpQ9eX jh4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JGVtLGJoNrifEQCr1YZ3zkxMW3g5EFoYp9uHA+YPkVo=; fh=c0ByhCenn9n2/Gg3f79DXng527omIiP5Cr8W9F+Rrb8=; b=EdvJ4oarevPVQsS5TI1Tq9zoCIq5DQCo/EOj8j1ZdaPlIOI5+abBe3uxst8KoaJ3Wm niynMWOUcouLCmLTfbX0LSeM+in+DGGXG3/Pt+Q+AUOxLUzCJrkJotXfbvom44smePTG RCfJljpjbc7iu59B/fym0g1iQHmIylRVoZAdODGzeFF2cFZXV4V4jH2Rt9L/FqeyWnhJ 5nUClldtmuP88MqGacN7AoXnxzIvPcpha/ULHBh0TXrurRliY90jbVzfbRcTCaCZ1oHR cDAIUxAdF3Rqu9t9tTee1CO98QzdDa3ZmyOVj88Pp9MhyrBJqnpEsNpGsiUvcLS1pkQg d10Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=wd9DTMKD; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-79694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id bz16-20020a056a02061000b005dc67975e49si975134pgb.897.2024.02.24.05.57.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 05:57:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=wd9DTMKD; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-79694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 883D5B209D1 for ; Sat, 24 Feb 2024 13:57:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15E324B5A6; Sat, 24 Feb 2024 13:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="wd9DTMKD" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62012405F4; Sat, 24 Feb 2024 13:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708782913; cv=none; b=N2hYg0hImVK2Dv3sXI+tY3nx7J9M4dBCRHj/7qMM34dMRbpwBqhUqHp5go1E/P8yY8zXQNZv0JqShnVwubNVsNUf0h7alZevmV2Hrap/cuIGC3buVwoMm+FglIhBM4oAMebOVQQRRvpMCaR0s2heTxbG7W3L/l7urq3uXYdjWfM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708782913; c=relaxed/simple; bh=0xAlq3FKxyKOFVzLVHdJfOKR9ZGZX8El43JyE9dp5i8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fw1JAOlwjd7mrE7A7g1j5KRrnybkSEIyPpEoZtU3eucTZLM33C+BmRYvt/dG0K5t/RpCN+iPh3M0CjepkpGF0bYnFCKO31pVWcwUdfX9LKPF95ycw8gfkeUczdiD52GLzDCs2TAs9j3jJOdXOmyMrBCtMY4H3fdTdWaCPTuETEU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=wd9DTMKD; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708782909; bh=0xAlq3FKxyKOFVzLVHdJfOKR9ZGZX8El43JyE9dp5i8=; h=From:To:Cc:Subject:Date:References:From; b=wd9DTMKDUrorPP8TJV46+jKHCZLJxBaZKFYdOT9ySCSrdDNgeVRe44ufvZ/epRk8O 7Wx0XcEuPsXh5o060cK8SisRCJKlxtBEpBJG2SSB5O9aaRf9gWaGV+J1YnPS42qJur gKMLqqOIX/3IhKx93KD01QgunTwePGaSkocxW5RM= From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= To: linux-kernel@vger.kernel.org, Liam Girdwood , Rob Herring , Conor Dooley , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: Samuel Holland , Chen-Yu Tsai , Jernej Skrabec , Ondrej Jirman , Arnaud Ferraris , linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [RESEND PATCH v2 2/5] ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level Date: Sat, 24 Feb 2024 14:54:55 +0100 Message-ID: <20240224135501.3822390-3-megi@xff.cz> In-Reply-To: <20240224135501.3822390-1-megi@xff.cz> References: <20240224135501.3822390-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Samuel Holland With idle_bias_on and suspend_bias_off, there are bias level transitions that match the suspend/resume callbacks. However, there are also transitions during probe (OFF => STANDBY) and removal (STANDBY => OFF). By using the set_bias_level hook, the driver can have one copy of code that would otherwise be duplicated between the probe/resume and suspend/remove hooks. Signed-off-by: Samuel Holland Signed-off-by: Ondřej Jirman --- sound/soc/sunxi/sun50i-codec-analog.c | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/sound/soc/sunxi/sun50i-codec-analog.c b/sound/soc/sunxi/sun50i-codec-analog.c index 8a32d05e23e1..cedd4de42d1a 100644 --- a/sound/soc/sunxi/sun50i-codec-analog.c +++ b/sound/soc/sunxi/sun50i-codec-analog.c @@ -471,17 +471,23 @@ static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = { { "EARPIECE", NULL, "Earpiece Amp" }, }; -static int sun50i_a64_codec_suspend(struct snd_soc_component *component) +static int sun50i_a64_codec_set_bias_level(struct snd_soc_component *component, + enum snd_soc_bias_level level) { - return regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL, - BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE), - BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE)); -} + switch (level) { + case SND_SOC_BIAS_OFF: + regmap_set_bits(component->regmap, SUN50I_ADDA_HP_CTRL, + BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE)); + break; + case SND_SOC_BIAS_STANDBY: + regmap_clear_bits(component->regmap, SUN50I_ADDA_HP_CTRL, + BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE)); + break; + default: + break; + } -static int sun50i_a64_codec_resume(struct snd_soc_component *component) -{ - return regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL, - BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE), 0); + return 0; } static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = { @@ -491,8 +497,9 @@ static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = { .num_dapm_widgets = ARRAY_SIZE(sun50i_a64_codec_widgets), .dapm_routes = sun50i_a64_codec_routes, .num_dapm_routes = ARRAY_SIZE(sun50i_a64_codec_routes), - .suspend = sun50i_a64_codec_suspend, - .resume = sun50i_a64_codec_resume, + .set_bias_level = sun50i_a64_codec_set_bias_level, + .idle_bias_on = true, + .suspend_bias_off = true, }; static const struct of_device_id sun50i_codec_analog_of_match[] = { -- 2.43.0