Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp702330rdb; Thu, 22 Feb 2024 17:52:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWogD5XUb6dC6oFNVE2XkDvWpQPx/r42lviLsP6aPk+6f/n0JJKgpkianTGZQ6FuI6Kt5C4Y7urtUEsi4tLs4X/k9k/aW+OsBLuV+hX4g== X-Google-Smtp-Source: AGHT+IFoxpau/UXpDeDjgcOXLti9fL0S9tXqqhafYpZixUtEPclTjWNhORErQiNsBhJGkwGWS5YI X-Received: by 2002:a81:ac0d:0:b0:607:85dd:a694 with SMTP id k13-20020a81ac0d000000b0060785dda694mr748578ywh.45.1708653174378; Thu, 22 Feb 2024 17:52:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708653174; cv=pass; d=google.com; s=arc-20160816; b=uCya+M0u7RT/f62CoyocmJiN9jgVYxSo78GqEwZ9XG/EUeyL+KG39tFMxw2mTtrqbC EQkQD5i0sU+OQKXuWBXuhb73lPz0bbI1zPZ5AY3Fn89LpKogBVOIxJJenGmf2fa8CEyb cqkuiw6NUaB/lvffeJzq77gQ7Rx0dImIyj9ekSs+ei84o4dHxaMid40ECYEjoDmcGi00 cY2W2jNiE7XqIrHKMckq1wjWglTglFa1T9x2NaMm4SnbfHXPs14UsxEZBB9ivg8zxySm eJBT2fS6PS4NFCr+AbCuAAoZ7PqRmmtn+Fe/Gzbr9lQPmmffKlCa0Sx5aLfZ6li9swh3 vpKg== 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=QGdVBqYg4q7jIiN9KcNXeuSkybNfaLt8K5LfUlN67/I=; b=PYvcQ3/VxvbjmUjb/LZtaKaWBgXBVrtGhR0jXnr8tC7Gw7COjBOI5ux+Nf3mOpvHgv cuvI45gnXqFpnFP8TN+CBfFz0z3QAJ0FcsNUIPD/54bmk+bQVctjoTD60eGfc6RHRJNQ x+JYtcZjum89bI7PYL+L/KF2+hghaNxVXF//0qncr1NcNhg3NXdVBHATwl0TDjgs3eYu mRMf87jPtTLcfJBnj4tEXXd7Q1E6BMey2P2Un661PoUNk/o6o4MTIZ+OgXAulYqYFP/p vi/BzH2BmDW54P7CElctZsyhVHXgs1Uatu4bWYJBTApP8tHYM6Nc9IMvfW+zYhIOOiB/ 5DSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="rgj35SW/"; 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-77654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77654-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e1-20020a0562140d8100b0068fcad11be5si1651570qve.68.2024.02.22.17.52.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 17:52:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="rgj35SW/"; 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-77654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77654-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 241731C22D1E for ; Fri, 23 Feb 2024 01:52:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8727C8DD; Fri, 23 Feb 2024 01:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="rgj35SW/" 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 5427EB671; Fri, 23 Feb 2024 01:52:30 +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=1708653152; cv=none; b=kohSNH9e5Wndc0vgrgptYlflQ5aoO2UZ/kpGYo3t7MxVR1bNhxhCF6hCfe9f9dRDCPI16tIvYUmvz9msKeViTWsSjCaxbO26qxhj0EgiJ0R/VtGC/GbdYfiCVWETSHGc4WGdObeeTnKsNLW66I8N6P1Krfvk+7VtY6GxFEP6xqw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708653152; c=relaxed/simple; bh=0xAlq3FKxyKOFVzLVHdJfOKR9ZGZX8El43JyE9dp5i8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JQdRUYqnUAMsfCEtIx2gJjHceNH8VoIu4wuVueJ10cLDcYxCHG4r2lU+9NSyC9I1w7Mf5pwnOqrxeeG8XdQKJndGFGrumSe+w5JMM5isvZNbNDZXREWmzM0gS7nUppNUhCd2xF0oeBeJm2r42jIZMSHMPaT+wYQO0nS085rdlw0= 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=rgj35SW/; 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=1708653141; bh=0xAlq3FKxyKOFVzLVHdJfOKR9ZGZX8El43JyE9dp5i8=; h=From:To:Cc:Subject:Date:References:From; b=rgj35SW/h7h9d8qcHLZE3bORQC8cnupdAgLbC/J6svJ9qk5A/fljXHg4ok9bIw1iO V42hGHce2rMR0ZWZcD7WAq72CXnrb9PbJqDQJM78lTa4JKZR/ma4DhILdPE8Rf2WPI XeN7svlDEMQELBfpAdlTKGGn1Pxskh6q7PmyK3yU= From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= To: linux-kernel@vger.kernel.org, Liam Girdwood , 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, linux-sunxi@lists.linux.dev Subject: [PATCH v2 2/5] ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level Date: Fri, 23 Feb 2024 02:52:12 +0100 Message-ID: <20240223015219.3618111-3-megi@xff.cz> In-Reply-To: <20240223015219.3618111-1-megi@xff.cz> References: <20240223015219.3618111-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